<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('mes装机信息卡')">导出</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>

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

<script>

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

  export default {
    name: 'MesInfoList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      MesInfoModal
    },
    data () {
      return {
        description: 'mes装机信息卡管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'keyId',
            align:"center",
            dataIndex: 'keyId'
          },
          {
            title:'任务号',
            align:"center",
            dataIndex: 'taskno'
          },
          {
            title:'工单号',
            align:"center",
            dataIndex: 'wo'
          },
          {
            title:'制令单号',
            align:"center",
            dataIndex: 'mo'
          },
          {
            title:'生产条码',
            align:"center",
            dataIndex: 'serialNumber'
          },
          {
            title:'出所编号',
            align:"center",
            dataIndex: 'outNo'
          },
          {
            title:'产品代号',
            align:"center",
            dataIndex: 'productNumber'
          },
          {
            title:'物料编码',
            align:"center",
            dataIndex: 'pnCode'
          },
          {
            title:'物料名称',
            align:"center",
            dataIndex: 'pnName'
          },
          {
            title:'批次',
            align:"center",
            dataIndex: 'batchNo'
          },
          {
            title:'元器件编号',
            align:"center",
            dataIndex: 'componentSn'
          },
          {
            title:'供应商',
            align:"center",
            dataIndex: 'supplier'
          },
          {
            title:'质量等级',
            align:"center",
            dataIndex: 'qualitygrate'
          },
          {
            title:'位号',
            align:"center",
            dataIndex: 'pcbItem'
          },
          {
            title:'数量',
            align:"center",
            dataIndex: 'qty'
          },
          {
            title:'有效期',
            align:"center",
            dataIndex: 'validDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'筛选情况',
            align:"center",
            dataIndex: 'filter'
          },
          {
            title:'备注',
            align:"center",
            dataIndex: 'remarks'
          },
          {
            title:'更新人',
            align:"center",
            dataIndex: 'updator'
          },
          {
            title:'更新时间',
            align:"center",
            dataIndex: 'updateDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'位号2',
            align:"center",
            dataIndex: 'pcbItem2'
          },
          {
            title:'型号规格',
            align:"center",
            dataIndex: 'pnSpec'
          },
          {
            title:'物料条码',
            align:"center",
            dataIndex: 'iqcSn'
          },
          {
            title:'操作者',
            align:"center",
            dataIndex: 'workMan'
          },
          {
            title:'操作工序',
            align:"center",
            dataIndex: 'workLocat'
          },
          {
            title:'检验者',
            align:"center",
            dataIndex: 'checkMan'
          },
          {
            title:'j检验时间',
            align:"center",
            dataIndex: 'checkDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'原始位号',
            align:"center",
            dataIndex: 'pcbItemS'
          },
          {
            title:'原始数量',
            align:"center",
            dataIndex: 'qtyS'
          },
          {
            title:'拆除位号',
            align:"center",
            dataIndex: 'pcbItemR'
          },
          {
            title:'拆除数量',
            align:"center",
            dataIndex: 'qtyR'
          },
          {
            title:'呈现位号',
            align:"center",
            dataIndex: 'pcbItemShow'
          },
          {
            title:'PID',
            align:"center",
            dataIndex: 'pid'
          },
          {
            title:'dpano',
            align:"center",
            dataIndex: 'dpano'
          },
          {
            title:'technicalstandard',
            align:"center",
            dataIndex: 'technicalstandard'
          },
          {
            title:'行号',
            align:"center",
            dataIndex: 'iqcIndex'
          },
          {
            title:'出库单号',
            align:"center",
            dataIndex: 'outStockNo'
          },
          {
            title:'印制板号',
            align:"center",
            dataIndex: 'boardNo'
          },
          {
            title:'入库批次号',
            align:"center",
            dataIndex: 'inbatchno'
          },
          {
            title:'采购单价',
            align:"center",
            dataIndex: 'purchaseprice'
          },
          {
            title:'内部单价',
            align:"center",
            dataIndex: 'internalprice'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/mesInfo/mesInfo/list",
          delete: "/mesInfo/mesInfo/delete",
          deleteBatch: "/mesInfo/mesInfo/deleteBatch",
          exportXlsUrl: "/mesInfo/mesInfo/exportXls",
          importExcelUrl: "mesInfo/mesInfo/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'int',value:'keyId',text:'keyId'})
        fieldList.push({type:'string',value:'taskno',text:'任务号'})
        fieldList.push({type:'string',value:'wo',text:'工单号'})
        fieldList.push({type:'string',value:'mo',text:'制令单号'})
        fieldList.push({type:'string',value:'serialNumber',text:'生产条码'})
        fieldList.push({type:'string',value:'outNo',text:'出所编号'})
        fieldList.push({type:'string',value:'productNumber',text:'产品代号'})
        fieldList.push({type:'string',value:'pnCode',text:'物料编码'})
        fieldList.push({type:'string',value:'pnName',text:'物料名称'})
        fieldList.push({type:'string',value:'batchNo',text:'批次'})
        fieldList.push({type:'string',value:'componentSn',text:'元器件编号'})
        fieldList.push({type:'string',value:'supplier',text:'供应商'})
        fieldList.push({type:'string',value:'qualitygrate',text:'质量等级'})
        fieldList.push({type:'string',value:'pcbItem',text:'位号'})
        fieldList.push({type:'number',value:'qty',text:'数量'})
        fieldList.push({type:'date',value:'validDate',text:'有效期'})
        fieldList.push({type:'string',value:'filter',text:'筛选情况'})
        fieldList.push({type:'string',value:'remarks',text:'备注'})
        fieldList.push({type:'string',value:'updator',text:'更新人'})
        fieldList.push({type:'date',value:'updateDate',text:'更新时间'})
        fieldList.push({type:'string',value:'pcbItem2',text:'位号2'})
        fieldList.push({type:'string',value:'pnSpec',text:'型号规格'})
        fieldList.push({type:'string',value:'iqcSn',text:'物料条码'})
        fieldList.push({type:'string',value:'workMan',text:'操作者'})
        fieldList.push({type:'string',value:'workLocat',text:'操作工序'})
        fieldList.push({type:'string',value:'checkMan',text:'检验者'})
        fieldList.push({type:'date',value:'checkDate',text:'j检验时间'})
        fieldList.push({type:'string',value:'pcbItemS',text:'原始位号'})
        fieldList.push({type:'number',value:'qtyS',text:'原始数量'})
        fieldList.push({type:'string',value:'pcbItemR',text:'拆除位号'})
        fieldList.push({type:'number',value:'qtyR',text:'拆除数量'})
        fieldList.push({type:'string',value:'pcbItemShow',text:'呈现位号'})
        fieldList.push({type:'string',value:'pid',text:'PID'})
        fieldList.push({type:'string',value:'dpano',text:'dpano'})
        fieldList.push({type:'string',value:'technicalstandard',text:'technicalstandard'})
        fieldList.push({type:'string',value:'iqcIndex',text:'行号'})
        fieldList.push({type:'string',value:'outStockNo',text:'出库单号'})
        fieldList.push({type:'string',value:'boardNo',text:'印制板号'})
        fieldList.push({type:'string',value:'inbatchno',text:'入库批次号'})
        fieldList.push({type:'number',value:'purchaseprice',text:'采购单价'})
        fieldList.push({type:'number',value:'internalprice',text:'内部单价'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>