<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: 300, x:1100 }"
        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 { postAction,getAction } from '@/api/manage'

  export default {
    name: 'VehicleDemandHisList',
    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: 'shipDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'到货日期',
            align:"center",
            dataIndex: 'deliveryDate'
          },
          {
            title:'运输类型',
            align:"center",
            dataIndex: 'shipType_dictText',
          },
          {
            title:'预计装车总托数',
            align:"center",
            dataIndex: 'preTotalPallets',
          },
          {
            title:'实际装车总托数',
            align:"center",
            dataIndex: 'totalPallets',
          },
          {
            title:'总发货数量',
            align:"center",
            dataIndex: 'totalShips',
          },
          {
            title:'取货地点',
            align:"center",
            dataIndex: 'pickUpHub',
          },
          {
            title:'送货地点',
            align:"center",
            dataIndex: 'deliveryAddress',
          },
          {
            title:'用车需求编号',
            align:"center",
            dataIndex: 'vdNo',
          },
          {
            title:'当前状态',
            align:"center",
            dataIndex: 'currentStatus_dictText',
          },
        ],
        url: {
          list: "/vehicledemanddetail/vehicleDemandDetail/list",
          delete: "/vehicledemanddetail/vehicleDemandDetail/delete",
          deleteBatch: "/vehicledemanddetail/vehicleDemandDetail/deleteBatch",
          exportXlsUrl: "/vehicledemanddetail/vehicleDemandDetail/exportXls",
          importExcelUrl: "vehicledemanddetail/vehicleDemandDetail/importExcel",
          getByVdNo: "vehicledemanddetail/vehicleDemandDetail/getByVdNo",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      getByVdNo(vdNo){
        this.loading = true;
        getAction(this.url.getByVdNo,{vdNo: vdNo}).then(res => {
          if (res.success) {
            this.dataSource = res.result.records;
          } else {
            this.$message.warning(res.message)
          }
        }).finally(()=>{
          this.loading = false;
        })
      },
      loadData(){},
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'currentStatus',text:'currentStatus'})
        fieldList.push({type:'string',value:'deliveryArea',text:'deliveryArea'})
        fieldList.push({type:'date',value:'shipDate',text:'shipDate'})
        fieldList.push({type:'int',value:'totalShips',text:'totalShips'})
        fieldList.push({type:'date',value:'deliveryDate',text:'deliveryDate'})
        fieldList.push({type:'string',value:'shipType',text:'shipType'})
        fieldList.push({type:'string',value:'vdNo',text:'vdNo'})
        fieldList.push({type:'string',value:'deliveryAddress',text:'deliveryAddress'})
        fieldList.push({type:'string',value:'pickUpHub',text:'pickUpHub'})
        fieldList.push({type:'string',value:'preTotalPallets',text:'preTotalPallets'})
        fieldList.push({type:'int',value:'totalPallets',text:'totalPallets'})
        fieldList.push({type:'string',value:'pn',text:'pn'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>