<template>
  <div class="mod-config">
    <el-form label-position="top" style="margin-top: 1px; margin-left: 0px;" v-if="searchData.buNo=='RDC'">
      <el-row :gutter="20" >
        <el-col :span="24"><div class="grid-content bg-purple">
          <el-form-item :label="'过程及过程控制/Process and Production Control'">
            <el-input
              type="textarea"
              v-model="dataForm.processDetail "
              :rows="3"
              resize='none'
              maxlength="255"
              show-word-limit
              :disabled="ifDisableFlag"
              style="height: 60px" >
            </el-input>
          </el-form-item>
        </div></el-col>
      </el-row>
      <el-row :gutter="20" style="margin-top: 60px">
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'是否提供胶条/Supply Adhesive Tape'">
            <el-select clearable v-model="dataForm.supplyAdhesiveTape" :disabled="ifDisableFlag">
              <el-option label="Yes" value="Y"></el-option>
              <el-option label="No" value="N"></el-option>
            </el-select>
          </el-form-item>
        </div></el-col>
        <el-col :span="18"><div class="grid-content bg-purple">
          <el-form-item :label="'图稿/Drawing'">
            <el-input v-model="dataForm.routingDrawing" :disabled="ifDisableFlag"  ></el-input>
          </el-form-item>
        </div></el-col>
      </el-row>
      <el-row :gutter="20" >
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'图稿版本/Drawing Revison'">
            <el-input v-model="dataForm.drawingRevison" :disabled="ifDisableFlag"  ></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'图稿日期/Drawing Date'">
            <el-date-picker
              v-model="searchData.drawingDate"
              type="date"
              value-format="yyyy-MM-dd"
              :disabled="ifDisableFlag"
              placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </div></el-col>
      </el-row>
      <el-row :gutter="20" >
        <el-col :span="24"><div class="grid-content bg-purple">
          <el-form-item :label="'作业说明/WI'">
            <el-input
              type="textarea"
              v-model="dataForm.workInfo"
              :rows="3"
              resize='none'
              maxlength="255"
              show-word-limit
              :disabled="ifDisableFlag"
              style="height: 60px" >
            </el-input>
          </el-form-item>
        </div></el-col>
      </el-row>
      <el-row :gutter="20" style="margin-top: 60px">
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'作业说明版本/WI Revison'">
            <el-input v-model="dataForm.wiRevison" :disabled="ifDisableFlag"  ></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'作业说明日期/WI Date'">
            <el-date-picker
              v-model="searchData.wiDate"
              type="date"
              value-format="yyyy-MM-dd"
              :disabled="ifDisableFlag"
              placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </div></el-col>
      </el-row>
      <el-row :gutter="20"   >
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item>
            <span slot="label" style="" @click="reviewEngineerChooseModal()"><a herf="#">选择审查工程师/Select ME Review Engineer</a></span>
            <el-input v-model="dataForm.reviewEngineer" readonly style=""  @focus="reviewEngineerChooseModal()" ></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item >
            <span slot="label" style="" @click="peEngineerChooseModal()"><a herf="#">选择PE工程师/Select PE Engineer</a></span>
            <el-input v-model="dataForm.peEngineer" readonly style=""  @focus="peEngineerChooseModal()" ></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item >
            <span slot="label" style="" @click="cqeModal()"><a herf="#">选择CQE/Select CQE</a></span>
            <el-input v-model="dataForm.cqe" readonly style=""  @focus="cqeModal()" ></el-input>
          </el-form-item>
        </div></el-col>
      </el-row>
      <el-row :gutter="20" >
        <el-col :span="24"><div class="grid-content bg-purple">
          <el-form-item :label="'备注/Remark'">
            <el-input
              type="textarea"
              v-model="dataForm.routingRemark"
              :rows="3"
              resize='none'
              maxlength="255"
              show-word-limit
              :disabled="ifDisableFlag"
              style="height: 60px" >
            </el-input>
          </el-form-item>
        </div></el-col>
      </el-row>
      <el-row :gutter="20" style="margin-top: 60px">
        <el-col :span="24"><div class="grid-content bg-purple">
          <el-form-item :label="'Action'">
            <el-input
              type="textarea"
              v-model="dataForm.routingAction"
              :rows="3"
              resize='none'
              maxlength="255"
              show-word-limit
              :disabled="ifDisableFlag"
              style="height: 60px" >
            </el-input>
          </el-form-item>
        </div></el-col>
      </el-row>
      <el-form-item style="margin-top: 60px;text-align:center">
        <el-button type="primary" @click="saveData()" v-if="!ifDisableFlag">保存</el-button>
      </el-form-item>
    </el-form>

    <el-form label-position="top" style="margin-top: 1px; margin-left: 0px;" v-if="searchData.buNo!='RDC'">
      <el-form :inline="true" label-position="top" style="margin-top: 1px; margin-left: 0px;" >
        <el-form-item  label="物料">
          <el-input v-model="routeData.partNo" readonly style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item  label="工艺路线类型">
          <el-input v-model="routeData.routingType" readonly style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item  label="工艺路线版本">
          <el-input v-model="routeData.routingRevision" readonly style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item  label="替代编码">
          <el-input v-model="routeData.alternativeNo" readonly style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item  label=" ">
          <el-button type="primary" @click="searchTable()" >刷新</el-button>
          <el-button type="primary" @click="changeBomRev()" >变更</el-button>
          <!--        <el-button type="primary" @click="newData()" v-if="!ifDisableFlag">新增</el-button>-->
        </el-form-item>
      </el-form>
      <el-table
        :height="'250'"
        :data="tableData"
        highlight-current-row
        border
        @row-click="chooseRoute"
        style="width: 100%">
        <el-table-column
          fixed="left"
          header-align="center"
          align="center"
          width="60"
          label="操作">
          <template slot-scope="scope">
            <a type="text" size="small" @click="bmModel(scope.row)">填写</a>
          </template>
        </el-table-column>
        <el-table-column
          v-for="(item,index) in columnList1" :key="index"
          :sortable="item.columnSortable"
          :prop="item.columnProp"
          :header-align="item.headerAlign"
          :show-overflow-tooltip="item.showOverflowTooltip"
          :align="item.align"
          :fixed="item.fixed == ''?false:item.fixed"
          :min-width="item.columnWidth"
          :label="item.columnLabel">
          <template slot-scope="scope">
            <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
            <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
          </template>
        </el-table-column>
      </el-table>
      <component style="margin-top: 5px" :is="selectedComponent" ref="routeRef"></component>
    </el-form>

<!--    <el-dialog append-to-body title="工艺路线" :close-on-click-modal="false" v-drag :visible.sync="routeFlag" width="470px">-->
<!--      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">-->
<!--            <el-form-item :label="'工序编码'">-->
<!--              <el-input v-model="routingData.itemNo" type="number" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" ></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item :label="'工序名称'">-->
<!--              <el-input v-model="routingData.operationDesc" style="width: 440px" ></el-input>-->
<!--            </el-form-item>-->
<!--      </el-form>-->
<!--      <el-footer style="height:40px;margin-top: 10px;text-align:center">-->
<!--        <el-button type="primary" @click="routeSave()">保存</el-button>-->
<!--        <el-button type="primary" @click="routeFlag = false">取消</el-button>-->
<!--      </el-footer>-->
<!--    </el-dialog>-->



    <el-dialog
      width="530px"
      title="审查工程师"
      :close-on-click-modal="false"
      :visible.sync="reviewEngineerFlag">
      <el-transfer v-model="reviewEngineerList" class="rq" filterable  :props="{
      key: 'operatorId',
      label: 'operatorName'
    }" :data="operatorList" :titles="['未选择', '已选择']"></el-transfer>
      <span slot="footer" class="dialog-footer">
        <div style="margin-top: 5px">
                <el-button type="primary" @click="savereviewEngineerList()">确定</el-button>
                <el-button @click="reviewEngineerFlag = false" type="primary">取消</el-button>
        </div>
    </span>
    </el-dialog>
    <el-dialog
      width="530px"
      title="PE工程师"
      :close-on-click-modal="false"
      :visible.sync="peEngineerFlag">
      <el-transfer v-model="peEngineerList" class="rq" filterable :props="{
      key: 'operatorId',
      label: 'operatorName'
    }" :data="operatorList" :titles="['未选择', '已选择']"></el-transfer>
      <span slot="footer" class="dialog-footer">
        <div style="margin-top: 5px">
                <el-button type="primary" @click="savepeEngineerList()">确定</el-button>
                <el-button @click="peEngineerFlag = false" type="primary">取消</el-button>
        </div>
    </span>
    </el-dialog>
    <el-dialog
      width="530px"
      title="选择CQE"
      :close-on-click-modal="false"
      :visible.sync="cqeFlag">
      <el-transfer v-model="cqeList" class="rq" filterable :props="{
      key: 'operatorId',
      label: 'operatorName'
    }" :data="operatorList" :titles="['未选择', '已选择']"></el-transfer>
      <span slot="footer" class="dialog-footer">
        <div style="margin-top: 5px">
                <el-button type="primary" @click="savecqeList()">确定</el-button>
                <el-button @click="cqeFlag = false" type="primary">取消</el-button>
        </div>
    </span>
    </el-dialog>

    <el-dialog
      append-to-body
      width="900px"
      title="工序记录"
      top="10vh"
      :close-on-click-modal="false"
      :visible.sync="routeModelFlag">
      <el-form label-position="top" style="margin-top: -5px; margin-left: 0px;" >
        <el-row :gutter="20">
          <el-col :span="6"><div class="grid-content bg-purple">
            <el-form-item :label="'工序编码'">
              <el-input v-model="currentRow.operationNo" disabled ></el-input>
            </el-form-item>
          </div></el-col>
          <el-col :span="6"><div class="grid-content bg-purple">
            <el-form-item :label="'工序名称'">
              <el-input v-model="currentRow.operationName" disabled ></el-input>
            </el-form-item>
          </div></el-col>
        </el-row>
      </el-form>
      <div v-if="currentRow.itemType === 'prepress'">
          <prepress  ref="prepress"  @closeModel="closeModel"></prepress>
      </div>
      <div v-else-if="currentRow.itemType === 'printing'">
        <printing ref="printing"  @closeModel="closeModel"></printing>
      </div>
      <div v-else-if="currentRow.itemType === 'printOther'">
        <printOther ref="printOther" @closeModel="closeModel"></printOther>
      </div>
      <div v-else-if="currentRow.itemType === 'overprinting'">
        <overprinting ref="overprinting" @closeModel="closeModel"></overprinting>
      </div>
      <div v-else-if="currentRow.itemType === 'slitting'">
        <slitting ref="slitting"></slitting>
      </div>
      <div v-else-if="currentRow.itemType === 'lamTemperature'">
        <lamTemperature ref="lamTemperature"></lamTemperature>
      </div>
      <div v-else-if="currentRow.itemType === 'cutting'">
        <cutting ref="cutting"></cutting>
      </div>
      <div v-else-if="currentRow.itemType === 'InkMixing'">
        <InkMixing ref="InkMixing"></InkMixing>
      </div>
      <div v-else-if="currentRow.itemType === 'InkFormulation'">
        <InkFormulation ref="InkFormulation"></InkFormulation>
      </div>
      <div v-else-if="currentRow.itemType === 'lamination'">
        <lamination ref="lamination"></lamination>
      </div>
      <div v-else-if="currentRow.itemType === 'CNC'">
        <CNC ref="CNC"></CNC>
      </div>
      <div v-else-if="currentRow.itemType === 'Cut'">
        <Cut ref="Cut"></Cut>
      </div>
      <div v-else-if="currentRow.itemType === 'packagePage'">
        <packagePage ref="packagePage"></packagePage>
      </div>
      <div v-else-if="currentRow.itemType === 'fqc'">
        <fqc ref="fqc"></fqc>
      </div>
      <div v-else-if="currentRow.itemType === 'cqc'">
        <cqc ref="cqc"></cqc>
      </div>
    </el-dialog>

    <Chooselist ref="baseList"  @getBaseData="getBaseData"></Chooselist>
  </div>
</template>

<script>
  import {
    searchBMRoutingDetail,
    searchTechnicalSpecificationTeamStr,
    updateBMRoutingDetail,
    searchBMRoute,
  } from "@/api/sampleManagement/technicalSpecificationList.js"
  import Chooselist from '@/views/modules/common/Chooselist'
  import {
    searchOperatorWithSite,
  } from "@/api/project/project.js"
  import prepress from "./com_bm_prepress";/*组件*/
  import printing from "./com_bm_printing";/*组件*/
  import printOther from "./com_bm_printOther";/*组件*/
  import overprinting from "./com_bm_demoSlot";/*组件*/
  import slitting from "./com_bm_demoSlot";/*组件*/
  import lamTemperature from "./com_bm_demoSlot";/*组件*/
  import cutting from "./com_bm_demoSlot";/*组件*/
  import InkMixing from "./com_bm_inkMixing";/*组件*/
  import InkFormulation from "./com_bm_inkFormulation";/*组件*/
  import lamination from "./com_bm_lamination";/*组件*/
  import CNC from "./com_bm_cnc";
  import Cut from "./com_bm_cut";
  import packagePage from "./com_bm_demoSlot";/*组件*/
  import fqc from "./com_bm_demoSlot";/*组件*/
  import cqc from "./com_bm_demoSlot";/*组件*/


//表格下方的引用
  import prepress2 from "./com_bm_prepress";/*组件*/
  import printing2 from "./com_bm_printing";/*组件*/
  import printOther2 from "./com_bm_printOther";/*组件*/
  import overprinting2 from "./com_bm_demoSlot";/*组件*/
  import slitting2 from "./com_bm_demoSlot";/*组件*/
  import lamTemperature2 from "./com_bm_demoSlot";/*组件*/
  import cutting2 from "./com_bm_demoSlot";/*组件*/
  import InkMixing2 from "./com_bm_inkMixing";/*组件*/
  import InkFormulation2 from "./com_bm_inkFormulation";/*组件*/
  import lamination2 from "./com_bm_lamination";/*组件*/
  import CNC2 from "./com_bm_cnc";
  import Cut2 from "./com_bm_cut";
  import packagePage2 from "./com_bm_demoSlot";/*组件*/
  import fqc2 from "./com_bm_demoSlot";/*组件*/
  import cqc2 from "./com_bm_demoSlot";/*组件*/
  export default {
    components: {
      Chooselist,
      prepress,
      printing,
      printOther,
      overprinting,
      slitting,
      lamTemperature,
      cutting,
      InkMixing,
      InkFormulation,
      lamination,
      CNC,
      Cut,
      packagePage,
      fqc,
      cqc,
      prepress2,
      printing2,
      printOther2,
      overprinting2,
      slitting2,
      lamTemperature2,
      cutting2,
      InkMixing2,
      InkFormulation2,
      lamination2,
      CNC2,
      Cut2,
      packagePage2,
      fqc2,
      cqc2,
    },

    data() {
      return {
        //动态组件
        selectedComponent: null,
        routeData:{
          site: '',
          partNo:'',
          alternativeNo:'',
          routingType:'',
          routingRevision:'',
        },
        routeFlag:false,
        routeModelFlag:false,
        height:200,
        searchData: {
          site: '',
          username: this.$store.state.user.name,
          codeNo: '',
          buNo:'',
        },
        tableData:'',
        partList:[],
        ifDisableFlag:false,
        dataForm:{
          site: '',
          codeNo:'',
          processDetail:'',
          supplyAdhesiveTape: '',
          routingDrawing:'',
          drawingRevison:'',
          drawingDate:'',
          workInfo:'',
          wiRevison:'',
          wiDate:'',
          reviewEngineer: '',
          routingRemark:'',
          routingAction:'',
          username:this.$store.state.user.name,
          peEngineer:'',
          cqe:'',
          reviewEngineerList:[],
          peEngineerList:[],
          cqeList:[],
        },
        reviewEngineerFlag:false,
        peEngineerFlag:false,
        cqeFlag:false,
        operatorList:[],
        reviewEngineerList:[],
        peEngineerList:[],
        cqeList:[],
        //工艺路线部分
        routingData:{
          id:0,
          site:'',
          codeNo:'',
          itemNo:'',
          operationDesc:'',
          remark:'',
          username:'',
        },
        columnList1: [
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2OperationNo',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'operationNo',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '工序编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2OperationName',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'operationName',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '工序名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2EfficiencyFactor',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'efficiencyFactor',
            headerAlign: 'center',
            align: 'right',
            columnLabel: '机器效率',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2MachRunFactor',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'machRunFactor',
            headerAlign: 'center',
            align: 'right',
            columnLabel: '机器运行速度',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2MachSetupTime',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'machSetupTime',
            headerAlign: 'center',
            align: 'right',
            columnLabel: '调机时长',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2RunTimeCode',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'runTimeCode',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '时长单位',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2LaborRunFactor',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'laborRunFactor',
            headerAlign: 'center',
            align: 'right',
            columnLabel: '人工效率',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2LaborSetupTime',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'laborSetupTime',
            headerAlign: 'center',
            align: 'right',
            columnLabel: '人工生产速度',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2CrewSize',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'crewSize',
            headerAlign: 'center',
            align: 'right',
            columnLabel: '生产过程人数',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2SetupCrewSize',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'setupCrewSize',
            headerAlign: 'center',
            align: 'right',
            columnLabel: '调机过程人数',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2OutsideOpItem',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'outsideOpItem',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '外协采购料号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2MachineNo',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'machineNo',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '机台',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2WorkCenterDesc',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'workCenterDesc',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '加工中心',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2LaborClassNo',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'laborClassDesc',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '人员等级',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2SetupLaborClassDesc',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'setupLaborClassDesc',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '调机时人员等级',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104003,
            serialNumber: '104003Table2NoteText',
            tableId: '104003Table2',
            tableName: 'Routing工序表',
            columnProp: 'noteText',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '备注',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150
          },
        ],
        currentRow:{},
      }
    },
    mounted () {
      this.$nextTick(() => {
        this.height = window.innerHeight - 100
      })
    },
    methods: {
      // 获取基础数据列表S
      getBaseList (val, type) {
        this.tagNo = val
        this.tagNo1 = type
        this.$nextTick(() => {
          let strVal = ''
          if (val === 1013) {
            if(type==1) {
              strVal = this.dataForm.partType
            }
          }
          this.$refs.baseList.init(val, strVal)
        })
      },
      /* 列表方法的回调 */
      getBaseData (val) {
        if (this.tagNo === 1013) {
          if(this.tagNo1==1) {
            this.dataForm.partType = val.Base_id
            this.dataForm.partTypeDesc = val.Base_desc
          }
        }
      },



      //初始化组件的参数
      init(inData) {
        if(this.dataForm.codeNo!=null&&this.dataForm.codeNo!=''){
          return false;
        }
        //初始化参数
        this.searchData = JSON.parse(JSON.stringify(inData));
        //刷新表格
        this.searchTable();

      },
      searchTable(){
        if(this.searchData.buNo==='RDC'){
          searchBMRoutingDetail(this.searchData).then(({data}) => {
            if(data.rows.length>0){
              this.dataForm=data.rows[0]
            }else {
              this.dataForm.site=this.searchData.site
              this.dataForm.codeNo=this.searchData.codeNo
            }

          });
          let inData = {
            site: this.searchData.site,
            codeNo: this.searchData.codeNo,
            type: 'reviewEngineer',
          }
          searchTechnicalSpecificationTeamStr(inData).then(({data}) => {
            this.dataForm.reviewEngineerList = data.rows
          })
          let inData2 = {
            site: this.searchData.site,
            codeNo: this.searchData.codeNo,
            type: 'cqe',
          }
          searchTechnicalSpecificationTeamStr(inData2).then(({data}) => {
            this.dataForm.cqeList = data.rows
          })
          let inData3 = {
            site: this.searchData.site,
            codeNo: this.searchData.codeNo,
            type: 'peEngineer',
          }
          searchTechnicalSpecificationTeamStr(inData3).then(({data}) => {
            this.dataForm.peEngineerList = data.rows
          })

        }else {
          searchBMRoute(this.searchData).then(({data}) => {
            this.tableData = data.rows;
            this.routeData = data.row;
          });
        }
      },
      closeModel(){
        console.log('666')
        this.routeModelFlag=false;
      },
      //根据itemType
      bmModel(row){
        this.currentRow=row;
        this.routeModelFlag=true
        setTimeout(() => {
          switch (this.currentRow.itemType) {
            case 'prepress':
              this.getPrepress();
            case 'printing':
              this.getPrinting();
            case 'printOther':
              this.getPrintOther();
            case 'overprinting':
              this.getOverprinting();
            case 'slitting':
              this.getSlitting();
            case 'lamTemperature':
              this.getLamTemperature();
            case 'cutting':
              this.getCutting();
            case 'InkMixing':
              this.getInkMixing();
            case 'InkFormulation':
              this.getInkFormulation();
            case 'lamination':
              this.getLamination();
            case 'CNC':
              this.getCNC();
            case 'Cut':
              this.getCut();
            case 'packagePage':
              this.getPackagePage();
            case 'fqc':
              this.getFqc();
            case 'cqc':
              this.getCqc();

          }
        }, 500);
      },
      getPrepress(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='prepress'
        this.$refs.prepress.init(inData)
      },
      getPrinting(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='printing'
        this.$refs.printing.init(inData)
      },
      getPrintOther(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='printOther'
        this.$refs.printOther.init(inData)
      },
      getOverprinting(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='overprinting'
        this.$refs.overprinting.init(inData)
      },
      getSlitting(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='slitting'
        this.$refs.slitting.init(inData)
      },
      getLamTemperature(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='lamTemperature'
        this.$refs.lamTemperature.init(inData)
      },
      getCutting(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='cutting'
        this.$refs.cutting.init(inData)
      },
      getInkMixing(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='InkMixing'
        this.$refs.InkMixing.init(inData)
      },
      getInkFormulation(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='InkFormulation'
        this.$refs.InkFormulation.init(inData)
      },
      getLamination(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='lamination'
        this.$refs.lamination.init(inData)
      },
      getCNC(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='CNC'
        this.$refs.CNC.init(inData)
      },
      getCut(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='Cut'
        this.$refs.Cut.init(inData)
      },
      getPackagePage(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='packagePage'
        this.$refs.packagePage.init(inData)
      },
      getFqc(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='fqc'
        this.$refs.fqc.init(inData)
      },
      getCqc(){
        let inData=JSON.parse(JSON.stringify(this.searchData))
        inData.type='cqc'
        this.$refs.cqc.init(inData)
      },
      reviewEngineerChooseModal(){
        if(this.ifDisableFlag){
          return false
        }
        let inData={
          site:this.searchData.site,
        }
        searchOperatorWithSite(inData).then(({data}) => {
          this.operatorList=data.rows
        })
        this.reviewEngineerList = JSON.parse(JSON.stringify(this.dataForm.reviewEngineerList));
        this.reviewEngineerFlag=true
      },

      savereviewEngineerList(){
        let reviewEngineerName='';
        for (let i = 0; i < this.reviewEngineerList.length; i++) {
          let select= this.operatorList.filter(item => item.operatorId === this.reviewEngineerList[i])
          if(select.length>0){
            reviewEngineerName+=select[0].operatorName+';'
          }
        }
        this.dataForm.reviewEngineer=reviewEngineerName
        this.dataForm.reviewEngineerList=JSON.parse(JSON.stringify(this.reviewEngineerList));
        this.reviewEngineerFlag=false
      },

      peEngineerChooseModal(){
        if(this.ifDisableFlag){
          return false
        }
        let inData={
          site:this.searchData.site,
        }
        searchOperatorWithSite(inData).then(({data}) => {
          this.operatorList=data.rows
        })
        this.peEngineerList = JSON.parse(JSON.stringify(this.dataForm.peEngineerList));
        this.peEngineerFlag=true
      },

      savepeEngineerList(){
        let peEngineerName='';
        for (let i = 0; i < this.peEngineerList.length; i++) {
          let select= this.operatorList.filter(item => item.operatorId === this.peEngineerList[i])
          if(select.length>0){
            peEngineerName+=select[0].operatorName+';'
          }
        }
        this.dataForm.peEngineer=peEngineerName
        this.dataForm.peEngineerList=JSON.parse(JSON.stringify(this.peEngineerList));
        this.peEngineerFlag=false
      },

      cqeModal(){
        if(this.ifDisableFlag){
          return false
        }
        let inData={
          site:this.searchData.site,
        }
        searchOperatorWithSite(inData).then(({data}) => {
          this.operatorList=data.rows
        })
        this.cqeList = JSON.parse(JSON.stringify(this.dataForm.cqeList));
        this.cqeFlag=true
      },
      savecqeList(){
        let cqeName='';
        for (let i = 0; i < this.cqeList.length; i++) {
          let select= this.operatorList.filter(item => item.operatorId === this.cqeList[i])
          if(select.length>0){
            cqeName+=select[0].operatorName+';'
          }
        }
        this.dataForm.cqe=cqeName
        this.dataForm.cqeList=JSON.parse(JSON.stringify(this.cqeList));
        this.cqeFlag=false
      },
      saveData(){
        this.$confirm("是否保存基本信息？", '保存提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(() => {
          updateBMRoutingDetail(this.dataForm).then(({data}) => {
            if (data && data.code === 0) {
              this.$message.success( '操作成功')
            } else {
              this.$message.error(data.msg)
            }
          })
        }).catch(() => {
          return
        })
      },
      chooseRoute(row){
          switch (row.itemType) {
              case 'Cut':
                this.selectedComponent='Cut2';
                let inData=JSON.parse(JSON.stringify(this.searchData))
                inData.type='Cut'
                inData.ifDisableFlag=true
                this.$nextTick (()=>{this.$refs.routeRef.init(inData)});
                break;
              case 'prepress':
                this.selectedComponent='prepress2';
                let prepressData=JSON.parse(JSON.stringify(this.searchData))
                prepressData.type='prepress'
                prepressData.ifDisableFlag=true
                this.$nextTick (()=>{this.$refs.routeRef.init(prepressData)});
                break;
              default :
                this.selectedComponent=null;
                break;
          }
      },

    },
  }
</script>

<style scoped>

</style>
