<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="handleAdd" type="primary" icon="plus">新增</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>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <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,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>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(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>

    <wz-outbound-order-b-modal ref="modalForm" @ok="modalFormOk"></wz-outbound-order-b-modal>
  </a-card>
</template>

<script>

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

  export default {
    name: 'WzOutboundOrderBList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      WzOutboundOrderBModal
    },
    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: 'rwh'
          },
          {
            title:'出库单号',
            align:"center",
            dataIndex: 'ckdh'
          },
          {
            title:'采购单价',
            align:"center",
            dataIndex: 'cgdj'
          },
          {
            title:'内部单价',
            align:"center",
            dataIndex: 'nbdj'
          },
          {
            title:'实发主数量',
            align:"center",
            dataIndex: 'sfzsl'
          },
          {
            title:'物料编码',
            align:"center",
            dataIndex: 'wlbm'
          },
          {
            title:'物料名称',
            align:"center",
            dataIndex: 'wlmc'
          },
          {
            title:'规格型号',
            align:"center",
            dataIndex: 'ggxh'
          },
          {
            title:'牌号',
            align:"center",
            dataIndex: 'ph'
          },
          {
            title:'详细技术规范',
            align:"center",
            dataIndex: 'xxjsgf'
          },
          {
            title:'技术标准',
            align:"center",
            dataIndex: 'jsbz'
          },
          {
            title:'质量等级',
            align:"center",
            dataIndex: 'zldj'
          },
          {
            title:'封装形式',
            align:"center",
            dataIndex: 'fzxs'
          },
          {
            title:'生产厂家',
            align:"center",
            dataIndex: 'sccj'
          },
          {
            title:'国产进口',
            align:"center",
            dataIndex: 'gcjk'
          },
          {
            title:'备料计划单据号',
            align:"center",
            dataIndex: 'bljhdjh'
          },
          {
            title:'行号',
            align:"center",
            dataIndex: 'hh'
          },
          {
            title:'出库日期',
            align:"center",
            dataIndex: 'ckrq'
          },
          {
            title:'应发主数量',
            align:"center",
            dataIndex: 'yfzsl'
          },
          {
            title:'入库批次号',
            align:"center",
            dataIndex: 'rkpch'
          },
          {
            title:'型号规格技术指标',
            align:"center",
            dataIndex: 'xhgljszb'
          },
          {
            title:'工序单号',
            align:"center",
            dataIndex: 'gxdh'
          },
          {
            title:'DPA号',
            align:"center",
            dataIndex: 'dpah'
          },
          {
            title:'合格证上传情况',
            align:"center",
            dataIndex: 'hgzscqk'
          },
          {
            title:'质保有效期',
            align:"center",
            dataIndex: 'zbyxq'
          },
          {
            title:'外观标识',
            align:"center",
            dataIndex: 'wgbs'
          },
          {
            title:'供应商批次号',
            align:"center",
            dataIndex: 'gyspch'
          },
          {
            title:'库位号',
            align:"center",
            dataIndex: 'kwh'
          },
          {
            title:'质保单位',
            align:"center",
            dataIndex: 'zbdw'
          },
          {
            title:'质保依据',
            align:"center",
            dataIndex: 'zbyj'
          },
          {
            title:'元器件分类',
            align:"center",
            dataIndex: 'yqjfl'
          },
          {
            title:'出库备注',
            align:"center",
            dataIndex: 'ckbz'
          },
          {
            title:'出库单表头主键',
            align:"center",
            dataIndex: 'ckdbtzj'
          },
          {
            title:'出库单表体主键',
            align:"center",
            dataIndex: 'ckdbtizj'
          },
          {
            title:'来源单据号',
            align:"center",
            dataIndex: 'lydjh'
          },
          {
            title:'来源单类型编码',
            align:"center",
            dataIndex: 'lydlxbm'
          },
          {
            title:'来源交易类型主键',
            align:"center",
            dataIndex: 'lyjylxzj'
          },
          {
            title:'件数',
            align:"center",
            dataIndex: 'js'
          },
          {
            title:'条码',
            align:"center",
            dataIndex: 'tm'
          },
          {
            title:'复验单位',
            align:"center",
            dataIndex: 'fydw'
          },
          {
            title:'最新时间戳',
            align:"center",
            dataIndex: 'zxsjc'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/wzOutboundOrder/wzOutboundOrderB/list",
          delete: "/wzOutboundOrder/wzOutboundOrderB/delete",
          deleteBatch: "/wzOutboundOrder/wzOutboundOrderB/deleteBatch",
          exportXlsUrl: "/wzOutboundOrder/wzOutboundOrderB/exportXls",
          importExcelUrl: "wzOutboundOrder/wzOutboundOrderB/importExcel",

        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'wlbm',text:'物料编码'})
        fieldList.push({type:'string',value:'wlmc',text:'物料名称'})
        fieldList.push({type:'string',value:'ggxh',text:'规格型号'})
        fieldList.push({type:'string',value:'ph',text:'牌号'})
        fieldList.push({type:'string',value:'xxjsgf',text:'详细技术规范'})
        fieldList.push({type:'string',value:'jsbz',text:'技术标准'})
        fieldList.push({type:'string',value:'zldj',text:'质量等级'})
        fieldList.push({type:'string',value:'fzxs',text:'封装形式'})
        fieldList.push({type:'string',value:'sccj',text:'生产厂家'})
        fieldList.push({type:'string',value:'gcjk',text:'国产进口'})
        fieldList.push({type:'number',value:'cgdj',text:'采购单价'})
        fieldList.push({type:'number',value:'nbdj',text:'内部单价'})
        fieldList.push({type:'string',value:'bljhdjh',text:'备料计划单据号'})
        fieldList.push({type:'string',value:'hh',text:'行号'})
        fieldList.push({type:'string',value:'ckrq',text:'出库日期'})
        fieldList.push({type:'number',value:'sfzsl',text:'实发主数量'})
        fieldList.push({type:'number',value:'yfzsl',text:'应发主数量'})
        fieldList.push({type:'string',value:'rkpch',text:'入库批次号'})
        fieldList.push({type:'string',value:'xhgljszb',text:'型号规格技术指标'})
        fieldList.push({type:'string',value:'gxdh',text:'工序单号'})
        fieldList.push({type:'string',value:'dpah',text:'DPA号'})
        fieldList.push({type:'string',value:'hgzscqk',text:'合格证上传情况'})
        fieldList.push({type:'string',value:'zbyxq',text:'质保有效期'})
        fieldList.push({type:'string',value:'wgbs',text:'外观标识'})
        fieldList.push({type:'string',value:'gyspch',text:'供应商批次号'})
        fieldList.push({type:'string',value:'kwh',text:'库位号'})
        fieldList.push({type:'string',value:'zbdw',text:'质保单位'})
        fieldList.push({type:'string',value:'zbyj',text:'质保依据'})
        fieldList.push({type:'string',value:'rwh',text:'任务号'})
        fieldList.push({type:'string',value:'yqjfl',text:'元器件分类'})
        fieldList.push({type:'string',value:'ckbz',text:'出库备注'})
        fieldList.push({type:'string',value:'ckdbtzj',text:'出库单表头主键'})
        fieldList.push({type:'string',value:'ckdbtizj',text:'出库单表体主键'})
        fieldList.push({type:'string',value:'lydjh',text:'来源单据号'})
        fieldList.push({type:'string',value:'lydlxbm',text:'来源单类型编码'})
        fieldList.push({type:'string',value:'lyjylxzj',text:'来源交易类型主键'})
        fieldList.push({type:'string',value:'js',text:'件数'})
        fieldList.push({type:'string',value:'tm',text:'条码'})
        fieldList.push({type:'string',value:'ckdh',text:'出库单号'})
        fieldList.push({type:'string',value:'fydw',text:'复验单位'})
        fieldList.push({type:'string',value:'zxsjc',text:'最新时间戳'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>