<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handletb(url.syn)" type="primary">同步</a-button>
      <!-- <a-button type="primary" icon="download" @click="handleExportXls('供货单信息')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown> -->
    </div>

    <!-- table区域-begin -->
    <div>
      <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div> -->

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">查看明细</a>
          <!-- <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown> -->
        </span>

      </a-table>
    </div>

    <supplylist-modal ref="modalForm" @ok="modalFormOk"></supplylist-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixinA'
  import SupplylistModal from './modules/SupplylistModal'

  export default {
    name: 'SupplylistList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      SupplylistModal
    },
    data () {
      return {
        description: '供货单信息管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'采购方总部编码',
            align:"center",
            dataIndex: 'purchaserhqcode'
          },
          {
            title:'供应商编码',
            align:"center",
            dataIndex: 'suppliercode'
          },
          {
            title:'合同类型',
            align:"center",
            dataIndex: 'contype'
          },
          {
            title:'采购供货单编号',
            align:"center",
            dataIndex: 'supplyno'
          },
          {
            title:'合同编号',
            align:"center",
            dataIndex: 'concode'
          },
          {
            title:'合同签订日期',
            align:"center",
            dataIndex: 'sellersigntime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'工程项目名称',
            align:"center",
            dataIndex: 'prjname'
          },
          {
            title:'合同名称',
            align:"center",
            dataIndex: 'conname'
          },
          {
            title:'合同编号（国网经法)',
            align:"center",
            dataIndex: 'sellerconcode'
          },
          {
            title:'物资大类编号',
            align:"center",
            dataIndex: 'matmaxcode'
          },
          {
            title:'物资中类编号',
            align:"center",
            dataIndex: 'matmedcode'
          },
          {
            title:'物资小类编号',
            align:"center",
            dataIndex: 'matmincode'
          },
          {
            title:'物资大类名称',
            align:"center",
            dataIndex: 'matmaxname'
          },
          {
            title:'物资中类名称',
            align:"center",
            dataIndex: 'matmedname'
          },
          {
            title:'物资小类名称',
            align:"center",
            dataIndex: 'matminname'
          },
          {
            title:'货物名称',
            align:"center",
            dataIndex: 'cargoname'
          },
          {
            title:'品类编码',
            align:"center",
            dataIndex: 'categorycode'
          },
          {
            title:'种类编码',
            align:"center",
            dataIndex: 'subclasscode'
          },
          {
            title:'采购方公司名称',
            align:"center",
            dataIndex: 'purchasename'
          },
          {
            title:'采购方公司编码',
            align:"center",
            dataIndex: 'purchasecode'
          },
          {
            title:'供货单项目号',
            align:"center",
            dataIndex: 'poitemno'
          },
          {
            title:'供货单行项目收货方公司名称',
            align:"center",
            dataIndex: 'receivedname'
          },
          {
            title:'供货单行项目供应商侧物料编码',
            align:"center",
            dataIndex: 'materialcode'
          },
          {
            title:'供货单行项目物料描述',
            align:"center",
            dataIndex: 'materialdesc'
          },
          {
            title:'供货单行项目国网侧物料编码',
            align:"center",
            dataIndex: 'eipmaterialcode'
          },
          {
            title:'供货单行项目国网侧物料描述',
            align:"center",
            dataIndex: 'eipmaterialdesc'
          },
          {
            title:'供货单行项目采购数量',
            align:"center",
            dataIndex: 'amount'
          },
          {
            title:'供货单行项目计量单位',
            align:"center",
            dataIndex: 'measunit'
          },
          {
            title:'数据来源',
            align:"center",
            dataIndex: 'datasource'
          },
          {
            title:'来源数据创建时间',
            align:"center",
            dataIndex: 'datasourcecreatetime'
          },
          {
            title:'备注',
            align:"center",
            dataIndex: 'remark'
          },
          {
            title:'数据拥有方：取值：供应商编码',
            align:"center",
            dataIndex: 'ownerid'
          },
          {
            title:'数据可见方：取值：采购方编码',
            align:"center",
            dataIndex: 'openid'
          },
          {
            title:'供货单编码',
            align:'center',
            dataIndex:''
          },
          // {
          //   title:'实体主键',
          //   align:"center",
          //   dataIndex: 'fid'
          // },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/API/supplyListPojo/list",
          delete: "/ras/supplylist/delete",
          deleteBatch: "/ras/supplylist/deleteBatch",
          exportXlsUrl: "/ras/supplylist/exportXls",
          importExcelUrl: "ras/supplylist/importExcel",
          syn: '/API/supplyListPojo/synchronization',
        },
        dictOptions:{},
      }
    },
    created() {
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>