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

    <!-- 操作按钮区域 -->

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{ y: 200, x: 1282 }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="false"
        :loading="loading"
        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: 'DeliveryPlanDetailList',
    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:'PO',
            align:"center",
            dataIndex: 'po'
          },
          {
            title:'料号',
            align:"center",
            dataIndex: 'pn'
          },
          {
            title:'数量',
            align:"center",
            dataIndex: 'planQty'
          },
          {
            title:'单位',
            align:"center",
            dataIndex: 'unit'
          },
          {
            title:'供应商',
            align:"center",
            dataIndex: 'supplier'
          },
        ],
        url: {
          list: "/deliveryplandetail/deliveryPlanDetail/list",
          delete: "/deliveryplandetail/deliveryPlanDetail/delete",
          deleteBatch: "/deliveryplandetail/deliveryPlanDetail/deleteBatch",
          exportXlsUrl: "/deliveryplandetail/deliveryPlanDetail/exportXls",
          importExcelUrl: "deliveryplandetail/deliveryPlanDetail/importExcel",
          getByDeliveryPlanId: "/deliveryplandetail/deliveryPlanDetail/getByDeliveryPlanId"
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      getByDeliveryPlanId(id){
        getAction(this.url.getByDeliveryPlanId,{id: id}).then(res => {
          if(res.success){
            this.dataSource = res.result;
          }
        })
      },
      loadData(){},
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'po',text:'PO'})
        fieldList.push({type:'string',value:'pn',text:'料号'})
        fieldList.push({type:'number',value:'planqty',text:'数量'})
        fieldList.push({type:'string',value:'unit',text:'单位'})
        fieldList.push({type:'string',value:'supplier',text:'供应商'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>