<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('zy_process')">导出</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">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" 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 @click="fuzhi(record)">复制</a>

          <a-divider type="vertical" />
            <a @click="dongzuo(record.id)">动作</a>
            <a-divider type="vertical" />
           <a @click="shebei(record.id)">设备</a>
            <a-divider type="vertical" />
           <a @click="fuliao(record.id)">辅料</a>
            <a-divider type="vertical" />
          <a @click="gongju(record.id)">工具</a>
            <a-divider type="vertical" />
          <a @click="mianliao(record.id)">面料</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="openDetail(record.id)">详情</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>
<!--        新建一个管理列-->
<!--        <span slot="action1" slot-scope="text, record">-->
<!--       -->
<!--        </span>-->
      </a-table>
    </div>
    <ZyProcessDetail ref="zyProcessDetail"></ZyProcessDetail>
    <zy-process-modal ref="modalForm" @ok="modalFormOk"></zy-process-modal>
    <zy-process-modal1 ref="modalForm1" @ok="modalFormOk"></zy-process-modal1>
    <zy-process-modal2 ref="modalForm2" @ok="modalFormOk"></zy-process-modal2>
    <zy-process-modal3 ref="modalForm3" @ok="modalFormOk"></zy-process-modal3>
    <zy-process-modal4 ref="modalForm4" @ok="modalFormOk"></zy-process-modal4>
    <zy-process-modal5 ref="modalForm5" @ok="modalFormOk"></zy-process-modal5>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ZyProcessModal from './modules/ZyProcessModal'
  import ZyProcessModal1 from './modules/ZyProcessModal1'
  import ZyProcessModal2 from './modules/ZyProcessModal2'
  import ZyProcessModal3 from './modules/ZyProcessModal3'
  import ZyProcessModal4 from './modules/ZyProcessModal4'
  import ZyProcessModal5 from './modules/ZyProcessModal5'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  import ZyProcessDetail from './modules/ZyProcessDetail'
  export default {
    name: 'ZyProcessList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      ZyProcessModal,
      ZyProcessDetail,
       ZyProcessModal1,
      ZyProcessModal2,
      ZyProcessModal3,
       ZyProcessModal4,
      ZyProcessModal5
    },
    data () {
      return {
        description: 'zy_process管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'工序代码',
            align:"center",
            dataIndex: 'processCode'
          },
          {
            title:'工序名称',
            align:"center",
            dataIndex: 'processName'
          },
          // {
          //   title:'工艺描述',
          //   align:"center",
          //   dataIndex: 'processDescribe'
          // },
          {
            title:'品质要求',
            align:"center",
            dataIndex: 'qualityRequire'
          },
          {
            title:'工序时间',
            align:"center",
            dataIndex: 'processTime'
          },
          {
            title:'工序单价',
            align:"center",
            dataIndex: 'price'
          },
          {
            title:'工序等级',
            align:"center",
            dataIndex: 'grade'
          },
          // {
          //   title:'面料代码',
          //   align:"center",
          //   dataIndex: 'fabricNum'
          // },
          // {
          //   title:'设备名',
          //   align:"center",
          //   dataIndex: 'machineId_dictText'
          // },
          // {
          //   title:'部件',
          //   align:"center",
          //   dataIndex: 'componentId_dictText'
          // },
          // {
          //   title:'工具名称',
          //   align:"center",
          //   dataIndex: 'toolId_dictText'
          // },
          {
            title:'款式名称',
            align:"center",
            dataIndex: 'styleId'
          },
          {
            title:'工段代码',
            align:"center",
            dataIndex: 'worksectionCode'
          },
          // {
          //   title:'合同号',
          //   align:"center",
          //   dataIndex: 'contractNum'
          // },
          {
            title:'合计（手工TMU）',
            align:"center",
            dataIndex: 'totalManualTmu'
          },
          {
            title:'合计（机器TMU）',
            align:"center",
            dataIndex: 'totalMachineTmu'
          },
          {
            title:'合计（手工秒）',
            align:"center",
            dataIndex: 'totalMaunal'
          },
          {
            title:'合计（设备秒）',
            align:"center",
            dataIndex: 'totalMachine'
          },
          {
            title:'创建时间',
            align:"center",
            dataIndex: 'createTime'
          },
          // {
          //   title: '管理',
          //   dataIndex: 'action1',
          //   align:"center",
          //   fixed:"right",
          //   width:147,
          //   scopedSlots: { customRender: 'action1' }
          // },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/base/zyProcess/list",
          delete: "/base/zyProcess/delete",
          deleteBatch: "/base/zyProcess/deleteBatch",
          exportXlsUrl: "/base/zyProcess/exportXls",
          importExcelUrl: "base/zyProcess/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:'processCode',text:'工序代码',dictCode:''})
        fieldList.push({type:'string',value:'processName',text:'工序名称',dictCode:''})
        fieldList.push({type:'string',value:'processDescribe',text:'工艺描述',dictCode:''})
        fieldList.push({type:'string',value:'mkExplain',text:'做工说明',dictCode:''})
        fieldList.push({type:'string',value:'qualityRequire',text:'品质要求',dictCode:''})
        fieldList.push({type:'string',value:'processTime',text:'工序时间',dictCode:''})
        fieldList.push({type:'double',value:'price',text:'工序单价',dictCode:''})
        fieldList.push({type:'string',value:'grade',text:'工序等级',dictCode:''})
        fieldList.push({type:'string',value:'fabricNum',text:'面料代码',dictCode:''})
        fieldList.push({type:'string',value:'fabricGrade',text:'面料等级',dictCode:''})
        fieldList.push({type:'int',value:'needlePitch',text:'针距（针/厘米）',dictCode:''})
        fieldList.push({type:'string',value:'machineId',text:'机器名',dictCode:'zy_machine,name,id'})
        fieldList.push({type:'string',value:'manualWide',text:'手工宽放',dictCode:''})
        fieldList.push({type:'double',value:'manualTime',text:'手工时间',dictCode:''})
        fieldList.push({type:'int',value:'machineSpeed',text:'机器转速',dictCode:''})
        fieldList.push({type:'string',value:'machineWide',text:'机器宽放',dictCode:''})
        fieldList.push({type:'double',value:'machineTime',text:'机器时间',dictCode:''})
        fieldList.push({type:'string',value:'machineFloat',text:'机器浮于',dictCode:''})
        fieldList.push({type:'string',value:'bundleWide',text:'绑包宽放',dictCode:''})
        fieldList.push({type:'string',value:'bundleTime',text:'绑包时间',dictCode:''})
        fieldList.push({type:'string',value:'componentId',text:'部件表',dictCode:'zy_cloths_component,parts_name,id'})
        fieldList.push({type:'int',value:'isBottleneck',text:'是否为瓶颈工序',dictCode:''})
        fieldList.push({type:'string',value:'enterpriseId',text:'企业名称',dictCode:''})
        fieldList.push({type:'string',value:'toolId',text:'工具名称',dictCode:'zy_tool,name,id'})
        fieldList.push({type:'string',value:'styleId',text:'款式名称',dictCode:''})
        fieldList.push({type:'string',value:'worksectionCode',text:'工段代码',dictCode:''})
        fieldList.push({type:'string',value:'contractNum',text:'合同号',dictCode:''})
        fieldList.push({type:'int',value:'totalManualTmu',text:'合计（手工TMU）',dictCode:''})
        fieldList.push({type:'int',value:'totalMachineTmu',text:'合计（机器TMU）',dictCode:''})
        fieldList.push({type:'int',value:'totalMaunal',text:'合计（手工秒）',dictCode:''})
        fieldList.push({type:'int',value:'totalMachine',text:'合计（机器秒）',dictCode:''})
        fieldList.push({type:'string',value:'image',text:'图片',dictCode:''})
        fieldList.push({type:'string',value:'vedio',text:'视频',dictCode:''})
        this.superFieldList = fieldList
      },
      openDetail(id){
        this.$refs.zyProcessDetail.showModal(id)
        // this.$children[0].showModal(id)
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>