<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>

    <!-- table区域-begin -->
    <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,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" 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>
      </a-table>
    </div>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { getAction } from '@/api/manage'

  export default {
    name: 'DeliveryDemandDetailList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
    },
    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: 'invoice'
          },
          {
            title:'取货仓库',
            align:"center",
            dataIndex: 'pickUpHub'
          },
          {
            title:'取货仓库编码',
            align:"center",
            dataIndex: 'pickUpHubCode'
          },
          {
            title:'料号',
            align:"center",
            dataIndex: 'pn'
          },
          {
            title:'品名',
            align:"center",
            dataIndex: 'productName'
          },
          {
            title:'规格',
            align:"center",
            dataIndex: 'specName'
          },
          {
            title:'发货数量',
            align:"center",
            dataIndex: 'shipNumber'
          },
          {
            title:'单位',
            align:"center",
            dataIndex: 'unit'
          },
        ],
        url: {
          list: "/deliverydemanddetail/deliveryDemandDetail/list",
          delete: "/deliverydemanddetail/deliveryDemandDetail/delete",
          deleteBatch: "/deliverydemanddetail/deliveryDemandDetail/deleteBatch",
          exportXlsUrl: "/deliverydemanddetail/deliveryDemandDetail/exportXls",
          importExcelUrl: "deliverydemanddetail/deliveryDemandDetail/importExcel",
          queryByDeliveryDemandId: "/deliverydemanddetail/deliveryDemandDetail/queryByDeliveryDemandId"
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      queryByDeliveryDemandId(id){
        getAction(this.url.queryByDeliveryDemandId,{deliveryDemandId: id}).then(res => {
          if(res.success){
            this.dataSource = res.result;
          }
        })
      },
      loadData(){},
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'invoice',text:'发货单'})
        fieldList.push({type:'string',value:'pickUpHub',text:'取货仓库'})
        fieldList.push({type:'string',value:'pickUpHubCode',text:'取货仓库编码'})
        fieldList.push({type:'string',value:'pn',text:'料号'})
        fieldList.push({type:'string',value:'productName',text:'品名'})
        fieldList.push({type:'string',value:'specName',text:'规格'})
        fieldList.push({type:'string',value:'shipNumber',text:'发货数量'})
        fieldList.push({type:'string',value:'unit',text:'单位'})
        fieldList.push({type:'string',value:'deliveryDemandId',text:'发货需求id'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>