<template>
  <div class="mod-config">
    <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
      <el-form-item>
        <span slot="label" style="" @click="getSearchModal()"><a herf="#">{{ labels.partNo }}</a></span>
        <el-input v-model="mainData.partNo" readonly style="width: 130px"></el-input>
      </el-form-item>
      <el-form-item :label="labels.spec">
        <el-input v-model="mainData.spec" readonly style="width: 274px"></el-input>
      </el-form-item>
      <el-form-item :label="labels.status">
        <el-input v-model="mainData.status" readonly style="width: 130px"></el-input>
      </el-form-item>
      <el-form-item :label="labels.site">
        <el-input v-model="mainData.site" readonly style="width: 130px"></el-input>
        <el-button @click="getPartDetail()" type="primary" style="margin-left: 2px;margin-top: 0px">
          {{ buttons.getPartDetail }}
        </el-button>
        <el-button @click="changeStatus()" type="primary" style="margin-left: 2px;margin-top: 0px">
          {{ buttons.changeStatus }}
        </el-button>
      </el-form-item>
    </el-form>
    <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
      <el-form-item :label="labels.routingType">
        <el-input v-model="mainData.routingType" readonly style="width: 130px"></el-input>
      </el-form-item>
      <el-form-item :label="labels.revNo">
        <el-input v-model="mainData.revNo" readonly style="width: 130px"></el-input>
      </el-form-item>
      <el-form-item :label="labels.phaseInDate">
        <el-input v-model="mainData.phaseInDate" readonly style="width: 130px"></el-input>
      </el-form-item>
      <el-form-item :label="labels.phaseOutDate">
        <el-input v-model="mainData.phaseOutDate" readonly style="width: 130px"></el-input>
      </el-form-item>
      <el-form-item :label="labels.umid">
        <el-input v-model="mainData.umid" readonly style="width: 130px"></el-input>
        <el-button @click="tongBuOrder()" type="primary" style="margin-left: 2px;margin-top: 0px">
          {{ buttons.tongBuOrder }}
        </el-button>
      </el-form-item>
    </el-form>
    <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
      <el-form-item :label="labels.remark">
        <el-input v-model="mainData.remark" readonly style="width: 417px"></el-input>
        <!--        <el-checkbox style="margin-left: 20px" disabled v-model="mainData.defaultflag">默认</el-checkbox>-->
        <!--        <el-checkbox style="margin-left: 80px" disabled v-model="mainData.repairFlag">修复版本</el-checkbox>-->
      </el-form-item>
      <el-form-item :label="labels.defaultflag">
        <el-checkbox style="margin-left: 0px" disabled v-model="mainData.defaultflag"></el-checkbox>
      </el-form-item>
      <el-form-item :label="labels.repairFlag" style="margin-left: 20px">
        <el-checkbox style="margin-left: 0px" disabled v-model="mainData.repairFlag"></el-checkbox>
        <el-button @click="setDefault()" type="primary" style="margin-left: 58px;margin-top: 0px">
          {{ buttons.setDefault }}
        </el-button>
        <el-button @click="copyRouting()" type="primary" style="margin-left: 2px;margin-top: 0px">
          {{ buttons.copyRouting }}
        </el-button>
        <el-button @click="addRoutingHeaderModel()" :disabled="authAdd" type="primary"
                   style="margin-left: 2px;margin-top: 0px">{{ buttons.addPart }}
        </el-button>
      </el-form-item>
    </el-form>
    <el-tabs v-model="activeName">
      <el-tab-pane :label="labels.detail" name="first">
        <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
          <el-button @click="addRoutingDetail()" type="primary" :disabled="authAdd"
                     style="margin-left: 2px;margin-top: 0px">{{ buttons.add }}
          </el-button>
          <el-button @click="editRoutingDetail()" type="primary" :disabled="authEdit"
                     style="margin-left: 2px;margin-top: 0px">{{ buttons.update }}
          </el-button>
          <el-button @click="copyItemRouting()" type="primary" :disabled="authEdit"
                     style="margin-left: 2px;margin-top: 0px">{{ '复制' }}
          </el-button>
          <el-button @click="deleteRoutingDetail()" type="primary" :disabled="authDelete"
                     style="margin-left: 2px;margin-top: 0px">{{ buttons.delete }}
          </el-button>
          <el-button @click="jumpWorkCenter()" type="primary" :disabled="!jumpFlag"
                     style="margin-left: 2px;margin-top: 0px">{{ buttons.workCenter }}
          </el-button>
          <el-button @click="getResourceModel()" type="primary" style="margin-left: 2px;margin-top: 0px">
            {{ buttons.availableResource }}
          </el-button>
        </el-form>
        <el-table
          :height="height"
          :data="dataList2"
          border
          @row-click="clickData"
          highlight-current-row
          v-loading="dataListLoading"
          style="width: 100%;">
          <el-table-column
            v-for="(item,index) in columnList2" :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"
            :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>
      </el-tab-pane>
      <el-tab-pane :label="labels.toolDetail" name="second">
        <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
          <el-button @click="addRoutingTool()" type="primary" :disabled="authAdd"
                     style="margin-left: 2px;margin-top: 0px">{{ buttons.add }}
          </el-button>
          <el-button @click="editRoutingTool()" type="primary" :disabled="authEdit"
                     style="margin-left: 2px;margin-top: 0px">{{ buttons.update }}
          </el-button>
          <el-button @click="deleteRoutingTool()" type="primary" :disabled="authDelete"
                     style="margin-left: 2px;margin-top: 0px">{{ buttons.delete }}
          </el-button>
          <el-button @click="jumpToolInfo()" type="primary" :disabled="!jumpFlag2"
                     style="margin-left: 2px;margin-top: 0px">{{ buttons.toolDetail }}
          </el-button>
        </el-form>
        <el-table
          :height="height"
          :data="dataList3"
          border
          @row-click="clickData2"
          highlight-current-row
          v-loading="dataListLoading"
          style="width: 100%;">
          <el-table-column
            v-for="(item,index) in columnList3" :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"
            :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>
      </el-tab-pane>
    </el-tabs>
    <el-dialog :title="labels.dataList" :close-on-click-modal="false" v-drag :visible.sync="modelFlag" width="680px">
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
        <el-form-item :label="labels.partNo">
          <el-input v-model="searchPartNo" style="width: 130px"></el-input>
          <el-button @click="searchRoutingWithPartNo()" type="primary">{{ buttons.search }}</el-button>
          <!--          <el-button @click="addRoutingHeaderModel()" :disabled="authAdd" type="primary">{{ buttons.add }}</el-button>-->
        </el-form-item>
      </el-form>
      <el-table
        height="300"
        :data="dataList"
        border
        @row-dblclick="tableHanddle"
        v-loading="dataListLoading"
        style="width: 100%;">
        <el-table-column
          header-align="center"
          align="center"
          width="150"
          :label="labels.do">
          <template slot-scope="scope">
            <a type="text" size="small" v-if="!authEdit"
               @click="editRoutingHeaderModel(scope.row)">{{ buttons.update }}</a>
            <a type="text" size="small" v-if="!authDelete"
               @click="deleteRoutingHeaderData(scope.row)">{{ buttons.delete }}</a>
          </template>
        </el-table-column>
        <el-table-column
          v-for="(item,index) in columnList" :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>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="modelFlag = false">{{ buttons.close }}</el-button>
      </el-footer>
    </el-dialog>
    <el-dialog title="维护工艺路线明细" :close-on-click-modal="false" v-drag :visible.sync="detailmodelFlag"
               width="620px">
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item :label="labels.itemNo">
          <el-input v-model="detailData.itemNo" :disabled="detailmodelInputFlag" style="width: 130px;text-align: right"
                    type="number"></el-input>
        </el-form-item>
        <el-form-item :label="labels.operationDesc">
          <el-input v-model="detailData.operationDesc" style="width: 130px"></el-input>
        </el-form-item>
        <el-form-item>
          <span slot="label" style="" @click="getBaseList(24,0)"><a herf="#">{{ labels.workCenterNo }}</a></span>
          <el-input v-model="detailData.workCenterNo" style="width: 130px"></el-input>
        </el-form-item>
        <el-form-item :label="labels.machSetupTime">
          <el-input v-model="detailData.machSetupTime" style="width: 130px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item :label="labels.machRunFactor">
          <el-input v-model="detailData.machRunFactor" type="number" style="width: 130px"></el-input>
        </el-form-item>
        <el-form-item :label="labels.factorUnit">
          <el-select filterable v-model="detailData.factorUnit" style="width: 130px">
            <el-option :label="labels.oneandtime" value="单位/小时"></el-option>
            <el-option :label="labels.time" value="小时"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="labels.jjgzUnitPrice">
          <el-input v-model="detailData.jjgzUnitPrice" type="number" style="width: 130px"></el-input>
        </el-form-item>
        <el-form-item :label="labels.jjgzUnitFactor">
          <el-select filterable v-model="detailData.jjgzUnitFactor" style="width: 130px">
            <el-option :label="labels.time" value="小时"></el-option>
            <el-option :label="labels.one" value="件"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item :label="labels.efficiency">
          <el-input v-model="detailData.efficiency" type="number" style="width: 130px"></el-input>
        </el-form-item>
        <el-form-item :label="labels.crewsize">
          <el-input v-model="detailData.crewsize" type="number" style="width: 130px"></el-input>
        </el-form-item>
        <el-form-item :label="labels.remark">
          <el-input v-model="detailData.remark" style="width: 130px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="saveRoutingDetailData()">{{ buttons.save }}</el-button>
        <el-button type="primary" @click="detailmodelFlag = false">{{ buttons.close }}</el-button>
      </el-footer>
    </el-dialog>
    <el-dialog :title="labels.updateRoutingTool" :close-on-click-modal="false" v-drag :visible.sync="ToolmodelFlag"
               width="480px">
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item :label="labels.itemNo">
          <el-select v-model="toolData.itemNo" @change="getOperationDesc()" :disabled="toolmodelInputFlag"
                     style="width: 130px" placeholder="请选择">
            <el-option
              v-for="(item,index) in selectList"
              :key="index"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="labels.operationDesc">
          <el-input v-model="toolData.operationDesc" disabled style="width: 130px;text-align: right"></el-input>
        </el-form-item>
        <el-form-item>
          <span slot="label" style="" @click="getBaseList(70,0)"><a herf="#">{{ labels.toolID }}</a></span>
          <el-input v-model="toolData.newToolId" @change="getToolDesc()"
                    style="width: 130px;text-align: right"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item :label="labels.toolDescription">
          <el-input v-model="toolData.toolDescription" disabled style="width: 130px;text-align: right"></el-input>
        </el-form-item>
        <el-form-item :label="labels.spec2">
          <el-input v-model="toolData.spec" disabled style="width: 275px;text-align: right"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item :label="labels.toolQty">
          <el-input v-model="toolData.toolQty" style="width: 130px;text-align: right" type="number"></el-input>
        </el-form-item>
        <el-form-item :label="labels.remark">
          <el-input v-model="toolData.remark" style="width: 275px;text-align: right"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="saveRoutingTool()">{{ buttons.save }}</el-button>
        <el-button type="primary" @click="ToolmodelFlag = false">{{ buttons.close }}</el-button>
      </el-footer>
    </el-dialog>
    <el-dialog :title="labels.availableResource" :close-on-click-modal="false" v-drag :visible.sync="routingModelFlag"
               width="800px">
      <el-container>
        <el-main style="width: 300px">
          <span style="">{{ labels.chooseableResource }}</span>
          <el-table
            height="300px"
            :data="resourceList1"
            border
            @row-click="clickData3"
            highlight-current-row
            v-loading="dataListLoading"
            style="width: 100%">
            <el-table-column
              v-for="(item,index) in columnList4" :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>
        </el-main>
        <el-main style="width: 100px">
          <div style="margin-top: 100px">
            <el-button type="primary" @click="addResource()">{{ buttons.addResource }}>></el-button>
          </div>
          <div style="margin-top: 20px">
            <el-button type="primary" @click="deleteResource()">{{ buttons.deleteResource }}<<</el-button>
          </div>
        </el-main>
        <el-main style="width: 300px">
          <span style="">{{ labels.choosedResource }}</span>
          <el-table
            height="300px"
            :data="resourceList2"
            border
            @row-click="clickData4"
            highlight-current-row
            v-loading="dataListLoading"
            style="width: 100%">
            <el-table-column
              v-for="(item,index) in columnList5" :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>
        </el-main>
      </el-container>
      <!--      <el-footer  style="height:40px;margin-top: 20px;text-align:center">-->
      <!--        <el-button type="primary" @click="routingModelFlag = false">关闭</el-button>-->
      <!--      </el-footer>-->
    </el-dialog>
    <el-dialog :title="labels.partDesc" :close-on-click-modal="false" v-drag :visible.sync="partFlag" width="630px">
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item :label="labels.partNo">
          <el-input v-model="partData.partNo" readonly style="width: 130px"></el-input>
        </el-form-item>
        <el-form-item :label="labels.partDescription">
          <el-input v-model="partData.partDescription" readonly style="width: 260px"></el-input>
        </el-form-item>
        <el-form-item :label="labels.site">
          <el-input v-model="partData.site" readonly style="width: 130px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item :label="labels.createDate">
          <el-input v-model="partData.createDate" readonly style="width: 130px"></el-input>
        </el-form-item>
        <el-form-item :label="labels.umid">
          <el-input v-model="partData.umid" readonly style="width: 130px"></el-input>
        </el-form-item>
        <el-form-item :label="labels.active" style="margin-left: 130px">
          <el-input v-model="partData.active" readonly style="width: 130px;"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item :label="labels.configurationTemplateID">
          <el-input v-model="partData.configurationTemplateID" readonly style="width: 130px"></el-input>
        </el-form-item>
        <el-form-item :label="labels.partNo2">
          <el-input v-model="partData.remark" readonly style="width: 260px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="partFlag = false">{{ buttons.close }}</el-button>
      </el-footer>
    </el-dialog>
    <el-dialog :title="labels.更改状态" :close-on-click-modal="false" v-drag :visible.sync="statusFlag" width="240px">
      <el-form :inline="true" label-position="top" style="margin-left: 0px;margin-top: -5px;">
        <el-form-item :label="labels.status" style="margin-left: 48px">
          <el-select v-model="status" style="width: 120px">
            <el-option :label="labels.test" value="试验"></el-option>
            <el-option :label="labels.product" value="投产"></el-option>
            <el-option :label="labels.stopUse" value="停用"></el-option>
          </el-select>
        </el-form-item>
        <el-footer style="height:40px;margin-top: 20px;text-align:center">
          <el-button type="primary" @click="saveStatus()">{{ buttons.save }}</el-button>
          <el-button type="primary" @click="statusFlag = false">{{ buttons.close }}</el-button>
        </el-footer>
      </el-form>
    </el-dialog>
    <el-dialog :title="labels.copyRouting" :close-on-click-modal="false" v-drag :visible.sync="copyRoutingModelFlag"
               width="600px">
      <el-container>
        <el-main style="width: 450px;margin-top: -20px">
          <fieldset style="margin-left: 0px; margin-top: 0px; width: 420px;">
            <legend>{{ labels.oldRouting }}</legend>
            <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -8px;">
              <el-form-item :label="labels.partNo3">
                <el-input v-model="copyRoutingData.partNo" disabled style="width: 120px;text-align: right"></el-input>
              </el-form-item>
              <el-form-item :label="labels.partDescription2">
                <el-input v-model="copyRoutingData.partDescription" disabled
                          style="width: 250px;text-align: right"></el-input>
              </el-form-item>
            </el-form>
            <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -0px;">
              <el-form-item :label="labels.revNo">
                <el-input v-model="copyRoutingData.revNo" disabled style="width: 120px;text-align: right"></el-input>
              </el-form-item>
              <el-form-item :label="labels.phaseInDate">
                <el-input v-model="copyRoutingData.phaseInDate" disabled
                          style="width: 120px;text-align: right"></el-input>
              </el-form-item>
              <el-form-item :label="labels.repairFlag">
                <el-checkbox style="margin-left: 0px" disabled v-model="copyRoutingData.repairFlag"></el-checkbox>
              </el-form-item>
            </el-form>
          </fieldset>
          <fieldset style="margin-left: 0px; margin-top: 0px; width: 420px;">
            <legend>{{ labels.newRouting }}</legend>
            <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -8px;">
              <el-form-item>
                <span slot="label" style="" @click="getBaseList(5,1)"><a herf="#">工艺路线编码：</a></span>
                <el-input v-model="copyRoutingData.partNo1" @change="getPartDescription()"
                          style="width: 120px;text-align: right"></el-input>
              </el-form-item>
              <el-form-item :label="labels.partNo3">
                <el-input v-model="copyRoutingData.partDescription1" disabled
                          style="width: 250px;text-align: right"></el-input>
              </el-form-item>
            </el-form>
            <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -0px;">
              <el-form-item :label="labels.revNo">
                <el-input v-model="copyRoutingData.revNo1" style="width: 120px;text-align: right"></el-input>
              </el-form-item>
              <el-form-item :label="labels.phaseInDate">
                <el-date-picker
                  style="width: 130px"
                  v-model="copyRoutingData.phaseInDate1"
                  value-format="yyyy-MM-dd"
                  :placeholder="labels.chooseDate">
                </el-date-picker>
              </el-form-item>
              <el-form-item :label="labels.repairFlag">
                <el-checkbox style="margin-left: 0px" v-model="copyRoutingData.repairFlag1"></el-checkbox>
              </el-form-item>
            </el-form>
          </fieldset>
        </el-main>
        <el-main style="width: 140px">
          <div style="width: 115px;">
            <el-checkbox style="margin-left: 0px" v-model="copyRoutingData.oldFlag"></el-checkbox>
            <span style="font-size: 11px">{{ labels.oldFlag }} </span>
          </div>
          <div>
            <span style="font-size: 11px;width: 115px">
              (仅用于相同产品版本升级的时候)
            </span>
          </div>
          <div style="width: 115px;margin-top: 15px">
            <el-checkbox style="margin-left: 0px" v-model="copyRoutingData.toolFlag"></el-checkbox>
            <span style="font-size: 11px">{{ labels.toolFlag }} </span>
          </div>
          <div style="width: 115px;margin-top: 15px">
            <el-checkbox style="margin-left: 0px" v-model="copyRoutingData.resourceFlag"></el-checkbox>
            <span style="font-size: 11px">{{ labels.resourceFlag }} </span>
          </div>
        </el-main>
      </el-container>
      <el-footer style="height:40px;margin-top: 0px;text-align:center">
        <el-button type="primary" @click="saveCopyRouting()">{{ buttons.save }}</el-button>
        <el-button type="primary" @click="copyRoutingModelFlag = false">{{ buttons.close }}</el-button>
      </el-footer>
    </el-dialog>
    <el-dialog :title="labels.updateRouting" :close-on-click-modal="false" v-drag :visible.sync="routingHeaderModelFlag"
               width="480px">
      <el-form :inline="true" label-position="top" style="margin-left: 0px;margin-top: -5px;">
        <el-form-item>
          <span slot="label" style="" @click="getBaseList(5,2)"><a herf="#">{{ labels.partNo3 }}</a></span>
          <el-input v-model="routingHeaderData.partNo" :disabled="routingHeaderInputFlag"
                    style="width: 130px;text-align: right"></el-input>
        </el-form-item>
        <el-form-item :label="labels.site">
          <el-input v-model="routingHeaderData.site" disabled style="width: 130px;text-align: right"></el-input>
        </el-form-item>
        <el-form-item :label="labels.status">
          <el-input v-model="routingHeaderData.status" disabled style="width: 130px;text-align: right"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 0px;margin-top: -5px;">
        <el-form-item :label="labels.revNo">
          <el-input v-model="routingHeaderData.revNo" :disabled="routingHeaderInputFlag"
                    style="width: 130px;text-align: right"></el-input>
        </el-form-item>
        <el-form-item :label="labels.phaseInDate">
          <el-date-picker
            style="width: 130px"
            v-model="routingHeaderData.phaseInDate"
            value-format="yyyy-MM-dd"
            :placeholder="labels.chooseDate">
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="labels.phaseOutDate">
          <el-date-picker
            style="width: 130px"
            v-model="routingHeaderData.phaseOutDate"
            value-format="yyyy-MM-dd"
            :placeholder="labels.chooseDate">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 0px;margin-top: -5px;">
        <el-form-item :label="labels.routingType">
          <el-input v-model="routingHeaderData.routingType" disabled style="width: 130px;text-align: right"></el-input>
        </el-form-item>
        <el-form-item :label="labels.remark">
          <el-input v-model="routingHeaderData.remark" style="width: 275px;text-align: right"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 0px;margin-top: -5px;">
        <el-form-item :label="labels.defaultflag">
          <el-select v-model="routingHeaderData.defaultflag" :disabled="routingHeaderInputFlag" style="width: 130px">
            <el-option :label="labels.yes" value="Y"></el-option>
            <el-option :label="labels.no" value="N"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="labels.repairFlag">
          <el-select v-model="routingHeaderData.repairFlag" style="width: 130px">
            <el-option :label="labels.yes" value="Y"></el-option>
            <el-option :label="labels.no" value="N"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="saveRoutingHeaderData()">{{ buttons.save }}</el-button>
        <el-button type="primary" @click="routingHeaderModelFlag = false">{{ buttons.close }}</el-button>
      </el-footer>
    </el-dialog>
    <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  </div>
</template>

<script>
import {
  searchRoutingWithPartNo,
  searchRoutingDetailData,
  saveRoutingDetailData,
  deleteRoutingDetail,
  searchRoutingToolData,
  searchUsedResource,
  searchAllResource,
  addRoutingResource,
  deleteRoutingResource,
  getItemSelect,
  getToolDesc,
  saveRoutingTool,
  deleteRoutingTool,
  searchPartNoData,
  changeRoutingStatus,
  checkRoutingAndOrder,
  changeOrderRouting,
  saveCopyRouting,
  setDefault,
  saveRoutingHeaderData,
  deleteRoutingHeaderData,
  getPartNoRouteInMaxItemNo
} from "@/api/base/site.js"
import Chooselist from '@/views/modules/common/Chooselist'
import {

  searchFunctionButtonList,

} from "@/api/sysLanguage.js"

var functionId = '103006';
export default {
  name: "maintainProductRouting",
  components: {
    Chooselist
  },
  data() {
    return {
      labels: {
        site: '工厂编号:',
        partNo: '物料编码:',
        spec: '物料名称/规格型号:',
        status: '状态:',
        routingType: '工艺路线类型:',
        revNo: '版本号:',
        phaseInDate: '启用日期:',
        phaseOutDate: '停用日期:',
        umid: '计量单位:',
        remark: '备注:',
        defaultflag: '默认:',
        repairFlag: '修复版本:',
        detail: '明细',
        toolDetail: '工具清单',
        dataList: '数据表',
        do: '操作',
        itemNo: '工序号:',
        operationDesc: '工序名称:',
        workCenterNo: '加工中心编码:',
        machSetupTime: '准备时间:',
        machRunFactor: '单位产出量:',
        factorUnit: '产出单位:',
        jjgzUnitPrice: '计价单价:',
        jjgzUnitFactor: '单位:',
        efficiency: '效率:',
        crewsize: '操作工人数:',
        updateRoutingTool: '维护工艺路线工具',
        toolID: '工具编号:',
        toolDescription: '工具名称:',
        spec2: '规格型号:',
        toolQty: '工具数量:',
        availableResource: '可用机台',
        chooseableResource: '可选机台',
        choosedResource: '已选机台:',
        partDescription: '物料名称:',
        createDate: '新增日期:',
        active: '在用:',
        configurationTemplateID: '客户名称:',
        partNo2: '客户产品料号:',
        partDesc: '物料信息:',
        oneandtime: '单位/小时',
        time: '小时',
        one: '件',
        changeStatus: '更改状态',
        test: '试验',
        product: '投产',
        stopUse: '停用',
        copyRouting: '复制产品工艺路线',
        oldRouting: '源产品工艺路线',
        partNo3: '工艺路线编码:',
        partDescription2: '工艺路线名称:',
        newRouting: '新产品工艺路线',
        chooseDate: '选择日期',
        oldFlag: '自动停用早期所有版本:',
        toolFlag: '复制工具信息:',
        resourceFlag: '复制可用机台:',
        updateRouting: '维护工艺路线',
        yes: '是',
        no: '否',
        error: '错误',
        true: '确定',
        inRoutingNo: '请输入工艺路线号！',
        inRevNo: '请输入版本号！',
        inPhaseInDate: '请选择启用日期！',
        doYes: '操作成功!',
        cancel: '取消',
        deleteRoutingAsk: '是否删除此工艺路线的所有数据?',
        point: '提示',
        inPartNo: '请选择物料编码！',
        inItemNo: '请输入工序号！',
        inOperationDesc: '请输入工序名称！',
        inMachSetupTime: '请输入准备时间！',
        inWorkCenterNo: '请输入加工中心编码！',
        inJjgzUnitPrice: '请输入计价单价！',
        inCrewsize: '请输入操作员人数！',
        inEfficiency: '请输入效率！',
        efficiencyAsk: '效率必须大于0！',
        inRoutingItem: '请选择工艺路线工序！',
        deleteItemAsk: '是否删除此工艺路线工序?',
        inAvailableResource: '请选择可选机台:',
        inTool: '请选择工具！',
        chooseItem: '请选择工序号！',
        inToolId: '请输入工具编号！',
        inToolQty: '请输入工具数量！',
        deleteToolAsk: '是否删除此工具信息?',
        deleteResourceAsk: '是否删除机台',
        chooseResourceCan: '请选择可选机台',
        partNoNot: '该物料编码不存在',
        partNoNO1: '该物料状态为',
        partNoNO2: '，不需要修改！',
        cannottongbu: '特殊订单无法同步！',
        orderAsk: '确定要把该工艺路线同步到该产品的未开工生产订单上吗？',
        orderContinue: '个生产订单将会被同步是否继续？',
        inNewPartNo: '请输入新物料号！',
        inNewRevNo: '请输入新版本号！',
        inNewPhaseInDate: '请选择新启用日期！',
        defaultflagAsk: '是否将此工艺路线版本设为默认?',


      },
      buttons: {
        search: '查询',
        getPartDetail: '物料信息',
        changeStatus: '更改状态',
        download: '导出',
        tongBuOrder: '同步工艺路线到订单',
        setDefault: '设为默认',
        copyRouting: '复制产品工艺路线',
        add: '新增',
        addPart: '新增物料',
        close: '关闭',
        update: '修改',
        delete: '删除',
        workCenter: '加工中心',
        availableResource: '可用机台',
        toolDetail: '工具信息',
        save: '保存',
        addResource: '添加机台',
        deleteResource: '删除机台',
      },
      queryButton: {
        functionId: functionId,
        table_id: '*',
        languageCode: this.$i18n.locale,
        objectType: 'button'
      },
      queryLabel: {
        functionId: functionId,
        table_id: '*',
        languageCode: this.$i18n.locale,
        objectType: 'label'
      },
      routingHeaderInputFlag: false,
      routingHeaderModelFlag: false,
      routingHeaderData: {
        partNo: '',
        site: '',
        status: '',
        revNo: '',
        phaseInDate: '',
        phaseOutDate: '',
        routingType: '',
        remark: '',
        defaultflag: '',
        repairFlag: '',
        add: '',
      },
      selectList: [],
      resourceList1: [],
      resourceList2: [],
      currentRow4: null,
      currentRow3: null,
      currentRow2: null,
      currentRow: null,
      tagNo: '',
      status: '',
      dataListLoading: false,
      searchPartNo: '',
      height: 200,
      mainData: {
        partNo: '',
        spec: '',
        status: '',
        site: '',
        routingType: '',
        revNo: '',
        phaseInDate: '',
        phaseOutDate: '',
        umid: '',
        remark: '',
        defaultflag: '',
        repairFlag: '',
      },
      partData: {
        partNo: '',
        partDescription: '',
        site: '',
        createDate: '',
        umid: '',
        active: '',
        configurationTemplateID: '',
        modelFlag: '',
      },
      copyRoutingData: {
        partNo: '',
        partDescription: '',
        revNo: '',
        phaseInDate: '',
        repairFlag: '',
        partNo1: '',
        partDescription1: '',
        revNo1: '',
        phaseInDate1: '',
        repairFlag1: false,
        oldFlag: false,
        toolFlag: false,
        resourceFlag: false,
      },
      activeName: 'first',
      modelFlag: false,
      ToolmodelFlag: false,
      detailmodelFlag: false,
      detailmodelInputFlag: false,
      toolmodelInputFlag: false,
      copyRoutingModelFlag: false,
      partFlag: false,
      statusFlag: false,
      dataList: [],
      dataList2: [],
      dataList3: [],
      toolData: {
        site: '',
        partNo: '',
        revNo: '',
        itemNo: '',
        operationDesc: '',
        toolID: '',
        toolDescription: '',
        spec: '',
        toolQty: '',
        remark: '',
        user: '',
        add: '',
        newToolId: ''
      },
      columnList: [
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040TablePartNo',
          tableId: "6040Table",
          tableName: "维护工艺路线数据表",
          columnProp: "partNo",
          headerAlign: "center",
          align: "left",
          columnLabel: "物料编码",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040TableSpec',
          tableId: "6040Table",
          tableName: "维护工艺路线数据表",
          columnProp: "spec",
          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: 6040,
          serialNumber: '6040TableRoutingType',
          tableId: "6040Table",
          tableName: "维护工艺路线数据表",
          columnProp: "routingType",
          headerAlign: "center",
          align: "left",
          columnLabel: "工艺路线类型",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040TableRevNo',
          tableId: "6040Table",
          tableName: "维护工艺路线数据表",
          columnProp: "revNo",
          headerAlign: "center",
          align: "left",
          columnLabel: "版本号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 60
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040TablePhaseInDate',
          tableId: "6040Table",
          tableName: "维护工艺路线数据表",
          columnProp: "phaseInDate",
          headerAlign: "center",
          align: "left",
          columnLabel: "启用日期",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040TablePhaseOutDate',
          tableId: "6040Table",
          tableName: "维护工艺路线数据表",
          columnProp: "phaseOutDate",
          headerAlign: "center",
          align: "left",
          columnLabel: "停用日期",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040TableStatus',
          tableId: "6040Table",
          tableName: "维护工艺路线数据表",
          columnProp: "status",
          headerAlign: "center",
          align: "left",
          columnLabel: "状态",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 40
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040TableSite',
          tableId: "6040Table",
          tableName: "维护工艺路线数据表",
          columnProp: "site",
          headerAlign: "center",
          align: "left",
          columnLabel: "工厂编码",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 60
        },
      ],
      columnList2: [
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table2ItemNo',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "itemNo",
          headerAlign: "center",
          align: "right",
          columnLabel: "工序号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 60
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table2OperationDesc',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "operationDesc",
          headerAlign: "center",
          align: "left",
          columnLabel: "工序名称",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 300
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table2WorkCenterNo',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "workCenterNo",
          headerAlign: "center",
          align: "left",
          columnLabel: "加工中心编码",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table2WorkCenterDesc',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "workCenterDesc",
          headerAlign: "center",
          align: "left",
          columnLabel: "加工中心名称",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table2MachSetupTime',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "machSetupTime",
          headerAlign: "center",
          align: "right",
          columnLabel: "准备时间(小时)",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table2MachRunFactor',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "machRunFactor",
          headerAlign: "center",
          align: "right",
          columnLabel: "单位产出量",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table2FactorUnit',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "factorUnit",
          headerAlign: "center",
          align: "left",
          columnLabel: "产出单位",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table2Efficiency',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "efficiency",
          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: 6040,
          serialNumber: '6040Table2Remark',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "remark",
          headerAlign: "center",
          align: "left",
          columnLabel: "备注",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 160
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table2JJGZUnitPrice',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "jjgzUnitPrice",
          headerAlign: "center",
          align: "right",
          columnLabel: "每件计价",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table2JJGZUnitFactor',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "jjgzUnitFactor",
          headerAlign: "center",
          align: "left",
          columnLabel: "计价单位",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table2Crewsize',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "crewsize",
          headerAlign: "center",
          align: "left",
          columnLabel: "操作工人数",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table2WorkCenterType',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "workCenterType",
          headerAlign: "center",
          align: "left",
          columnLabel: "加工中心类型",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table2WXPartNo',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "wxPartNo",
          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: 6040,
          serialNumber: '6040Table2WXSpec',
          tableId: "6040Table2",
          tableName: "维护工艺路线工序表",
          columnProp: "wxSpec",
          headerAlign: "center",
          align: "left",
          columnLabel: "费用结算物料名称/规格",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 250
        },


      ],
      columnList3: [
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table3RevNo',
          tableId: "6040Table3",
          tableName: "维护工艺路线工具表",
          columnProp: "revNo",
          headerAlign: "center",
          align: "left",
          columnLabel: "版本号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table3ItemNo',
          tableId: "6040Table3",
          tableName: "维护工艺路线工具表",
          columnProp: "itemNo",
          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: 6040,
          serialNumber: '6040Table3ToolID',
          tableId: "6040Table3",
          tableName: "维护工艺路线工具表",
          columnProp: "toolID",
          headerAlign: "center",
          align: "left",
          columnLabel: "工具编号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 150
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table3ToolDescription',
          tableId: "6040Table3",
          tableName: "维护工艺路线工具表",
          columnProp: "toolDescription",
          headerAlign: "center",
          align: "left",
          columnLabel: "工具名称",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 200
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table3Spec',
          tableId: "6040Table3",
          tableName: "维护工艺路线工具表",
          columnProp: "spec",
          headerAlign: "center",
          align: "left",
          columnLabel: "规格型号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 150
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table3ToolQty',
          tableId: "6040Table3",
          tableName: "维护工艺路线工具表",
          columnProp: "toolQty",
          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: 6040,
          serialNumber: '6040Table3Active',
          tableId: "6040Table3",
          tableName: "维护工艺路线工具表",
          columnProp: "active",
          headerAlign: "center",
          align: "left",
          columnLabel: "在用",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 60
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table3FamilyID',
          tableId: "6040Table3",
          tableName: "维护工艺路线工具表",
          columnProp: "familyID",
          headerAlign: "center",
          align: "left",
          columnLabel: "工具分类",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table3FamilyName',
          tableId: "6040Table3",
          tableName: "维护工艺路线工具表",
          columnProp: "familyName",
          headerAlign: "center",
          align: "left",
          columnLabel: "工具分类名称",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 150
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table3Remark',
          tableId: "6040Table3",
          tableName: "维护工艺路线工具表",
          columnProp: "remark",
          headerAlign: "center",
          align: "left",
          columnLabel: "备注",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 200
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table3CreateDate',
          tableId: "6040Table3",
          tableName: "维护工艺路线工具表",
          columnProp: "createDate",
          headerAlign: "center",
          align: "left",
          columnLabel: "录入日期",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 160
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table3CreatedBy',
          tableId: "6040Table3",
          tableName: "维护工艺路线工具表",
          columnProp: "createdBy",
          headerAlign: "center",
          align: "left",
          columnLabel: "录入人",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
      ],
      columnList4: [
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table4ResourceID',
          tableId: "6040Table4",
          tableName: "维护工艺路线可用机台表",
          columnProp: "resourceID",
          headerAlign: "center",
          align: "left",
          columnLabel: "机台编码",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 70
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table4ResourceDesc',
          tableId: "6040Table4",
          tableName: "维护工艺路线可用机台表",
          columnProp: "resourceDesc",
          headerAlign: "center",
          align: "left",
          columnLabel: "机台名称",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 160
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table4Active',
          tableId: "6040Table4",
          tableName: "维护工艺路线可用机台表",
          columnProp: "active",
          headerAlign: "center",
          align: "left",
          columnLabel: "在用",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 50
        },
      ],
      columnList5: [
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table5ResourceID',
          tableId: "6040Table5",
          tableName: "维护工艺路线已选机台表",
          columnProp: "resourceID",
          headerAlign: "center",
          align: "left",
          columnLabel: "机台编码",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 70
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table5ResourceDesc',
          tableId: "6040Table5",
          tableName: "维护工艺路线已选机台表",
          columnProp: "resourceDesc",
          headerAlign: "center",
          align: "left",
          columnLabel: "机台名称",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 160
        },
        {
          userId: this.$store.state.user.name,
          functionId: 6040,
          serialNumber: '6040Table5Active',
          tableId: "6040Table5",
          tableName: "维护工艺路线已选机台表",
          columnProp: "active",
          headerAlign: "center",
          align: "left",
          columnLabel: "在用",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 50
        },
      ],
      routingModelFlag: false,
      detailData: {
        itemNo: '',
        operationDesc: '',
        workCenterNo: '',
        machSetupTime: '',
        machRunFactor: '',
        factorUnit: '单位/小时',
        jjgzUnitPrice: '',
        jjgzUnitFactor: '小时',
        efficiency: '',
        crewsize: 1,
        remark: '',
        site: '',
        partNo: '',
        revNo: '',
        add: '',
        user: '',
      },
      tagNo2: '',
      authEdit: false,
      authAdd: false,
      authDelete: false,
      menuId: this.$route.meta.menuId,
      jumpFlag: true,
      jumpFlag2: true,
    }
  },
  watch: {
    toolData: {
      deep: true,
      handler: function (newV, oldV) {
        //this.toolData.toolID = this.toolData.toolID.toUpperCase()
        this.toolData.newToolId = this.toolData.newToolId.toUpperCase()
      }
    },
    detailData: {
      deep: true,
      handler: function (newV, oldV) {
        this.detailData.workCenterNo = this.detailData.workCenterNo.toUpperCase()
      }
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.height = window.innerHeight - 310;
    })
  },
  methods: {
    // 复制
    copyItemRouting() {
      if (!this.currentRow) {
        this.$message.warning('请选择需要复制的工序!')
        return
      }
      // 获取
      getPartNoRouteInMaxItemNo(this.currentRow).then(({data}) => {
        if (data.code == 0) {
          let maxItem = JSON.parse(JSON.stringify(this.currentRow))
          maxItem.itemNo = Number(data.data) + 10
          let dto = {
            itemNo: Number(data.data) + 10,
            add: 0,
            crewsize: maxItem.crewsize,
            efficiency: maxItem.efficiency,
            factorUnit: maxItem.factorUnit,
            jjgzUnitFactor: maxItem.jjgzUnitFactor,
            jjgzUnitPrice: maxItem.jjgzUnitPrice,
            machRunFactor: maxItem.machRunFactor,
            machSetupTime: maxItem.machSetupTime,
            operationDesc: maxItem.operationDesc,
            partNo: maxItem.partNo,
            remark: maxItem.remark,
            revNo: maxItem.revNo,
            site: maxItem.site,
            user:this.$store.state.user.name,
            workCenterNo: maxItem.workCenterNo,
          }
          // 保存信息
          saveRoutingDetailData(dto).then(({data}) => {
            if (data && data.code == 200) {
              this.detailmodelFlag = false
              let data1 = {
                site: this.mainData.site,
                partNo: this.mainData.partNo,
                revNo: this.mainData.revNo,
              }
              searchRoutingDetailData(data1).then(({data}) => {
                if (data.total == 0) {
                  this.dataList2 = []
                } else {
                  this.dataList2 = data.rows;
                }
              })

              this.$message.success(this.labels.doYes)
            } else {
              this.$alert(data.msg, this.labels.error, {
                confirmButtonText: this.labels.true
              })
            }
          })
        }
      })
    },
    editRoutingHeaderModel(row) {
      this.routingHeaderData = {
        partNo: row.partNo,
        site: row.site,
        status: row.status,
        revNo: row.revNo,
        phaseInDate: row.phaseInDate,
        phaseOutDate: row.phaseOutDate,
        routingType: row.routingType,
        remark: row.remark,
        defaultflag: row.defaultflag,
        repairFlag: row.repairFlag,
        add: 1,
      };
      this.routingHeaderInputFlag = true;
      this.routingHeaderModelFlag = true;
    },
    addRoutingHeaderModel() {
      this.routingHeaderData = {
        partNo: '',
        site: this.$store.state.user.site,
        status: '试验',
        revNo: '',
        phaseInDate: new Date(),
        phaseOutDate: null,
        routingType: '制造',
        remark: '',
        defaultflag: 'Y',
        repairFlag: 'N',
        add: 0,
      };
      this.routingHeaderInputFlag = false;
      this.routingHeaderModelFlag = true;
    },
    saveRoutingHeaderData() {
      if (this.routingHeaderData.partNo == '' || this.routingHeaderData.partNo == null) {
        this.$alert(this.labels.inRoutingNo, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      if (this.routingHeaderData.revNo == '' || this.routingHeaderData.revNo == null) {
        this.$alert(this.labels.inRevNo, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      if (this.routingHeaderData.phaseInDate == '' || this.routingHeaderData.phaseInDate == null) {
        this.$alert(this.labels.inPhaseInDate, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      saveRoutingHeaderData(this.routingHeaderData).then(({data}) => {
        if (data && data.code == 200) {
          this.routingHeaderModelFlag = false;
          //设置查询的物料编码
          this.searchPartNo = this.routingHeaderData.partNo;
          this.tableHanddle(this.routingHeaderData);
          //this.searchRoutingWithPartNo(); 调用有问题2022-12-26
          this.$message.success(this.labels.doYes)
        } else {
          this.$alert(data.msg, this.labels.error, {
            confirmButtonText: this.labels.true
          })
        }
      })
    },
    deleteRoutingHeaderData(row) {
      this.$confirm(this.labels.deleteRoutingAsk, this.labels.point, {
        confirmButtonText: this.labels.true,
        cancelButtonText: this.labels.cancel,
        type: 'warning'
      }).then(() => {
        let inData = {
          site: row.site,
          partNo: row.partNo,
          revNo: row.revNo,
        }
        deleteRoutingHeaderData(inData).then(({data}) => {
          if (data && data.code == 200) {
            this.searchRoutingWithPartNo();
          } else {
            this.$alert(data.msg, this.labels.error, {
              confirmButtonText: this.labels.true
            })
          }
        })
      })
    },
    getBaseData(val) {
      if (this.tagNo === 24) {
        this.detailData.workCenterNo = val.WorkCenterNo
      }
      if (this.tagNo === 70) {
        this.toolData.newToolId = val.ToolID
        this.getToolDesc();
      }
      if (this.tagNo === 5) {
        if (this.tagNo2 === 1) {
          this.copyRoutingData.partNo1 = val.PartNo
          this.getPartDescription();
        } else {
          this.routingHeaderData.partNo = val.PartNo
        }
      }
    },
    // 获取基础数据列表
    getBaseList(val, val2) {
      this.tagNo = val
      this.tagNo2 = val2
      this.$nextTick(() => {
        let strVal = "";
        if (val === 24) {
          strVal = this.detailData.workCenterNo
        }
        if (val === 70) {
          strVal = this.toolData.toolID

        }
        if (val === 5) {
          if (val2 === 1) {
            strVal = this.copyRoutingData.partNo1
          } else {
            strVal = this.routingHeaderData.partNo
          }
        }
        this.$refs.baseList.init(val, strVal)
      })
    },
    addRoutingDetail() {
      if (this.mainData.partNo == null || this.mainData.partNo == '') {
        this.$alert(this.labels.inPartNo, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      let itemNo;
      if (this.dataList2 === [] || this.dataList2.length == 0) {
        itemNo = 10;
      } else {
        itemNo = this.dataList2[0].itemNo;
        for (let i = 0; i < this.dataList2.length; i++) {
          if (itemNo < this.dataList2[i].itemNo) {
            itemNo = this.dataList2[i].itemNo
          }
        }
        itemNo += 10;
      }
      // if(this.dataList2){
      //   size=this.dataList2.length;
      //   itemNo=this.dataList2[Number(size-1)].itemNo+10;
      // }else {
      //   itemNo=10;
      // }
      this.detailData = {
        itemNo: itemNo,
        operationDesc: '',
        workCenterNo: '',
        machSetupTime: 0,
        machRunFactor: 0,
        factorUnit: '单位/小时',
        jjgzUnitFactor: '小时',
        jjgzUnitPrice: 0,
        efficiency: 100,
        crewsize: 1,
        remark: '',
        add: 0,
        partNo: this.mainData.partNo,
        revNo: this.mainData.revNo,
        site: this.mainData.site,
        user: this.$store.state.user.name,
      }
      this.detailmodelInputFlag = false;
      this.detailmodelFlag = true;

    },
    saveRoutingDetailData() {
      if (this.detailData.itemNo == '' || this.detailData.itemNo == null) {
        this.$alert(this.labels.inItemNo, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      if (this.detailData.operationDesc == '' || this.detailData.operationDesc == null) {
        this.$alert(this.labels.inOperationDesc, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      if (this.detailData.machSetupTime === '' || this.detailData.machSetupTime == null) {
        this.$alert(this.labels.inMachSetupTime, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      if (this.detailData.workCenterNo == '' || this.detailData.workCenterNo == null) {
        this.$alert(this.labels.inWorkCenterNo, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      // if (this.detailData.jjgzUnitPrice === '' || this.detailData.jjgzUnitPrice == null) {
      //   this.$alert(this.labels.inJjgzUnitPrice, this.labels.error, {
      //     confirmButtonText: this.labels.true
      //   })
      //   return false;
      // }
      if (this.detailData.crewsize === '' || this.detailData.crewsize == null) {
        this.$alert(this.labels.inCrewsize, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      if (this.detailData.efficiency === '' || this.detailData.efficiency == null) {
        this.$alert(this.labels.inEfficiency, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      if (this.detailData.efficiency <= 0) {
        this.$alert(this.labels.efficiencyAsk, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }

      if (this.detailData.machRunFactor <= 0) {
        this.$message.warning('单位产出量不能小于0!')
        return
      }
      if (this.detailData.crewsize < 1) {
        this.$message.warning('操作工人数不能少于1!')
        return
      }
      saveRoutingDetailData(this.detailData).then(({data}) => {
        this.currentRow = null;
        if (data && data.code == 200) {
          this.detailmodelFlag = false
          let data1 = {
            site: this.mainData.site,
            partNo: this.mainData.partNo,
            revNo: this.mainData.revNo,
          }
          searchRoutingDetailData(data1).then(({data}) => {

            if (data.total == 0) {
              this.dataList2 = []
            } else {
              this.dataList2 = data.rows;
            }
          })

          this.$message.success(this.labels.doYes)
        } else {
          this.$alert(data.msg, this.labels.error, {
            confirmButtonText: this.labels.true
          })
        }
      })
    },
    deleteRoutingDetail() {
      if (this.currentRow == null) {
        this.$alert(this.labels.inRoutingItem, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      this.$confirm(this.labels.deleteItemAsk, this.labels.point, {
        confirmButtonText: this.labels.true,
        cancelButtonText: this.labels.cancel,
        type: 'warning'

      }).then(() => {
        deleteRoutingDetail(this.currentRow).then(({data}) => {
          this.currentRow = null;
          if (data && data.code == 200) {
            let data1 = {
              site: this.mainData.site,
              partNo: this.mainData.partNo,
              revNo: this.mainData.revNo,
            }
            searchRoutingDetailData(data1).then(({data}) => {
              this.dataList2 = data.rows;
            })
            this.$message({
              message: this.labels.doYes,
              type: 'success',
              duration: 1500,
              onClose: () => {
              }
            })
            this.$message.success(this.labels.doYes)
          } else {
            this.$alert(data.msg, this.labels.error, {
              confirmButtonText: this.labels.true
            })
          }
        })
      })
    },
    tableHanddle(row) {
      let data = {
        partNo: row.partNo,
        site: row.site,
        revNo: row.revNo,
      }
      searchRoutingWithPartNo(data).then(({data}) => {
        if (data.rows.length > 0) {
          if (data.rows[0].repairFlag == 'Y') {
            data.rows[0].repairFlag = true;
          } else {
            data.rows[0].repairFlag = false;
          }
          if (data.rows[0].defaultflag == 'Y') {
            data.rows[0].defaultflag = true;
          } else {
            data.rows[0].defaultflag = false;
          }
          this.mainData = data.rows[0]
          let data1 = {
            site: data.rows[0].site,
            partNo: data.rows[0].partNo,
            revNo: data.rows[0].revNo,
          }
          searchRoutingDetailData(data1).then(({data}) => {
            this.dataList2 = data.rows;
          })
          searchRoutingToolData(data1).then(({data}) => {
            this.dataList3 = data.rows;
          })
        }

      })
      this.modelFlag = false;

    },
    getResourceModel() {
      if (this.currentRow == null) {
        this.$alert(this.labels.inRoutingItem, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      let data1 = {
        site: this.mainData.site,
        workCenterNo: this.currentRow.workCenterNo,
      }
      searchAllResource(data1).then(({data}) => {
        this.resourceList1 = data.rows
      })
      let data2 = {
        site: this.mainData.site,
        partNo: this.mainData.partNo,
        revNo: this.currentRow.revNo,
        itemNo: this.currentRow.itemNo
      }
      searchUsedResource(data2).then(({data}) => {
        this.resourceList2 = data.rows
      })
      this.routingModelFlag = true;
    },
    getSearchModal() {
      this.searchPartNo = '';
      // this.searchRoutingWithPartNo();
      this.modelFlag = true;
    },
    editRoutingDetail() {
      if (this.currentRow == null) {
        this.$alert(this.labels.inRoutingItem, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      this.detailData = {
        itemNo: this.currentRow.itemNo,
        operationDesc: this.currentRow.operationDesc,
        workCenterNo: this.currentRow.workCenterNo,
        machSetupTime: this.currentRow.machSetupTime,
        machRunFactor: this.currentRow.machRunFactor,
        factorUnit: this.currentRow.factorUnit,
        jjgzUnitPrice: this.currentRow.jjgzUnitPrice,
        jjgzUnitFactor: this.currentRow.jjgzUnitFactor,
        efficiency: this.currentRow.efficiency,
        crewsize: this.currentRow.crewsize,
        remark: this.currentRow.remark,
        add: 1,
        partNo: this.mainData.partNo,
        revNo: this.mainData.revNo,
        site: this.mainData.site,
        user: this.$store.state.user.name,
      }
      this.detailmodelInputFlag = true;
      this.detailmodelFlag = true;
    },
    searchRoutingWithPartNo() {
      let data = {
        partNo: this.searchPartNo
      }
      searchRoutingWithPartNo(data).then(({data}) => {
        this.dataList = data.rows
      })
    },
    clickData(row) {
      this.currentRow = JSON.parse(JSON.stringify(row));
    },
    clickData2(row) {
      this.currentRow2 = JSON.parse(JSON.stringify(row));
    },
    clickData3(row) {
      this.currentRow3 = JSON.parse(JSON.stringify(row));
    },
    clickData4(row) {
      this.currentRow4 = JSON.parse(JSON.stringify(row));
    },
    addResource() {
      if (this.currentRow3 == null) {
        this.$alert(this.labels.inAvailableResource, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      let inData = {
        site: this.mainData.site,
        partNo: this.mainData.partNo,
        revNo: this.mainData.revNo,
        itemNo: this.currentRow.itemNo,
        resourceID: this.currentRow3.resourceID
      }
      addRoutingResource(inData).then(({data}) => {

        if (data && data.code == 200) {
          let data2 = {
            site: this.mainData.site,
            partNo: this.mainData.partNo,
            revNo: this.currentRow.revNo,
            itemNo: this.currentRow.itemNo
          }
          searchUsedResource(data2).then(({data}) => {
            this.resourceList2 = data.rows
          })
        } else {
          this.$alert(data.msg, this.labels.error, {
            confirmButtonText: this.labels.true
          })
        }
      })
    },
    addRoutingTool() {
      if (this.mainData.partNo == null || this.mainData.partNo == '') {
        this.$alert(this.labels.inPartNo, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      this.toolData = {
        site: this.mainData.site,
        partNo: this.mainData.partNo,
        revNo: this.mainData.revNo,
        itemNo: '',
        operationDesc: '',
        toolID: '',
        newToolId: '',
        toolDescription: '',
        spec: '',
        toolQty: '',
        remark: '',
        user: this.$store.state.user.name,
        add: 0,
      };
      this.selectList = [];
      let data = {
        site: this.mainData.site,
        partNo: this.mainData.partNo,
        revNo: this.mainData.revNo,
      }
      getItemSelect(data).then(({data}) => {
        let list = data.rows;
        for (let i = 0; i < list.length; i++) {
          let resultData = {
            value: list[i].itemNo,
            label: list[i].itemNo
          }
          this.selectList.push(resultData);
        }
      })
      this.toolmodelInputFlag = false;
      this.ToolmodelFlag = true;
    },
    editRoutingTool() {
      if (this.currentRow2 == null) {
        this.$alert(this.labels.inTool, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      this.toolData = {
        site: this.mainData.site,
        partNo: this.mainData.partNo,
        revNo: this.mainData.revNo,
        itemNo: this.currentRow2.itemNo,
        operationDesc: this.currentRow2.operationDesc,
        toolID: this.currentRow2.toolID,
        newToolId: this.currentRow2.toolID,
        toolDescription: this.currentRow2.toolDescription,
        spec: this.currentRow2.spec,
        toolQty: this.currentRow2.toolQty,
        remark: this.currentRow2.remark,
        user: this.$store.state.user.name,
        add: 1,
      };
      this.getOperationDesc();
      this.toolmodelInputFlag = true;
      this.ToolmodelFlag = true;
    },
    saveRoutingTool() {
      if (this.toolData.itemNo == '' || this.toolData.itemNo == null) {
        this.$alert(this.labels.chooseItem, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      if (this.toolData.newToolId == '' || this.toolData.newToolId == null) {
        this.$alert(this.labels.inToolId, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      if (this.toolData.toolQty == '' || this.toolData.toolQty == null) {
        this.$alert(this.labels.inToolQty, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      saveRoutingTool(this.toolData).then(({data}) => {
        this.currentRow2 = null;
        if (data && data.code == 200) {
          this.ToolmodelFlag = false
          let data1 = {
            site: this.mainData.site,
            partNo: this.mainData.partNo,
            revNo: this.mainData.revNo,
          }
          searchRoutingToolData(data1).then(({data}) => {
            this.dataList3 = data.rows;
          })
          this.$message.success(this.labels.doYes)
        } else {
          this.$alert(data.msg, this.labels.error, {
            confirmButtonText: this.labels.true
          })
        }
      })
    },
    deleteRoutingTool() {
      if (this.currentRow2 == null) {
        this.$alert(this.labels.inTool, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      this.$confirm(this.labels.deleteToolAsk, this.labels.point, {
        confirmButtonText: this.labels.true,
        cancelButtonText: this.labels.cancel,
        type: 'warning'
      }).then(() => {
        let delDate = {
          site: this.mainData.site,
          partNo: this.mainData.partNo,
          revNo: this.mainData.revNo,
          itemNo: this.currentRow2.itemNo,
          toolID: this.currentRow2.toolID,
        }
        deleteRoutingTool(delDate).then(({data}) => {
          this.currentRow2 = null;
          if (data && data.code == 200) {
            this.ToolmodelFlag = false
            let data1 = {
              site: this.mainData.site,
              partNo: this.mainData.partNo,
              revNo: this.mainData.revNo,
            }
            searchRoutingToolData(data1).then(({data}) => {
              this.dataList3 = data.rows;
            })
            this.$message.success(this.labels.doYes)
          } else {
            this.$alert(data.msg, this.labels.error, {
              confirmButtonText: this.labels.true
            })
          }
        })
      })
    },
    getOperationDesc() {
      let data = {
        site: this.mainData.site,
        partNo: this.mainData.partNo,
        revNo: this.mainData.revNo,
        itemNo: this.toolData.itemNo
      }
      getItemSelect(data).then(({data}) => {
        if (data.rows.length > 0) {
          this.toolData.operationDesc = data.rows[0].operationDesc
        }
      })
    },
    getToolDesc() {
      let data = {
        site: this.mainData.site,
        toolID: this.toolData.toolID
      }
      getToolDesc(data).then(({data}) => {
        if (data.rows.length > 0) {
          this.toolData.toolDescription = data.rows[0].toolDescription
          this.toolData.spec = data.rows[0].spec
        }
      })
    },
    deleteResource() {
      if (this.currentRow4 == null) {
        this.$alert(this.labels.chooseResourceCan, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      this.$confirm(this.labels.deleteResourceAsk, this.labels.point, {
        confirmButtonText: this.labels.true,
        cancelButtonText: this.labels.cancel,
        type: 'warning'

      }).then(() => {
        let inData = {
          site: this.mainData.site,
          partNo: this.mainData.partNo,
          revNo: this.mainData.revNo,
          itemNo: this.currentRow.itemNo,
          resourceID: this.currentRow4.resourceID
        }
        deleteRoutingResource(inData).then(({data}) => {
          if (data && data.code == 200) {
            this.currentRow4 = null;
            let data2 = {
              site: this.mainData.site,
              partNo: this.mainData.partNo,
              revNo: this.currentRow.revNo,
              itemNo: this.currentRow.itemNo
            }
            searchUsedResource(data2).then(({data}) => {
              this.resourceList2 = data.rows
            })
          } else {
            this.$alert(data.msg, this.labels.error, {
              confirmButtonText: this.labels.true
            })
          }
        })
      })
    },
    jumpWorkCenter() {
      if (this.currentRow == null) {
        this.$alert(this.labels.inRoutingItem, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      let inData = {
        user: this.$store.state.user.name,
        site: this.currentRow.site,
        workCenterNo: this.currentRow.workCenterNo
      };
      localStorage.setItem('workCenterNo', JSON.stringify(inData))
      this.$router.replace('base-workCenter')
    },
    jumpToolInfo() {
      if (this.currentRow2 == null) {
        this.$alert(this.labels.inTool, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      let inData = {
        site: this.$store.state.user.site,
        toolId: this.currentRow2.toolID,
        toolDescription: this.currentRow2.toolDescription
      };
      localStorage.setItem('toolInfo', JSON.stringify(inData))
      this.$router.replace('knifemold-tool-info')
    },
    getPartDetail() {
      if (this.mainData.partNo == null || this.mainData.partNo == '') {
        this.$alert(this.labels.inPartNo, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      let inData = {
        user: this.$store.state.user.name,
        site: this.mainData.site,
        partNo: this.mainData.partNo
      }
      searchPartNoData(inData).then(({data}) => {
        if (data.rows.length == 0) {
          this.$alert(this.labels.partNoNot, this.labels.error, {
            confirmButtonText: this.labels.true
          })
          return false;
        }
        this.partData = data.rows[0];
        this.partFlag = true;
      })
    },
    changeStatus() {
      if (this.mainData.partNo == null || this.mainData.partNo == '') {
        this.$alert(this.labels.inPartNo, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      this.status = this.mainData.status;
      this.statusFlag = true;
    },
    saveStatus() {
      if (this.status == this.mainData.status) {
        this.$alert(this.labels.partNoNO1 + this.status + this.labels.partNoNO2, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      let inData = {
        partNo: this.mainData.partNo,
        site: this.mainData.site,
        revNo: this.mainData.revNo,
        status: this.status
      }
      changeRoutingStatus(inData).then(({data}) => {
        if (data && data.code == 200) {
          this.statusFlag = false
          searchRoutingWithPartNo(inData).then(({data}) => {
            if (data.rows.length > 0) {
              if (data.rows[0].repairFlag == 'Y') {
                data.rows[0].repairFlag = true;
              } else {
                data.rows[0].repairFlag = false;
              }
              if (data.rows[0].defaultflag == 'Y') {
                data.rows[0].defaultflag = true;
              } else {
                data.rows[0].defaultflag = false;
              }
              this.mainData = data.rows[0]
              let data1 = {
                site: data.rows[0].site,
                partNo: data.rows[0].partNo,
                revNo: data.rows[0].revNo,
              }
              searchRoutingDetailData(data1).then(({data}) => {
                this.dataList2 = data.rows;
              })
              searchRoutingToolData(data1).then(({data}) => {
                this.dataList3 = data.rows;
              })
            }

          })
          this.$message.success(this.labels.doYes)
        } else {
          this.$alert(data.msg, this.labels.error, {
            confirmButtonText: this.labels.true
          })
        }
      })
    },
    tongBuOrder() {
      if (this.mainData.partNo == null || this.mainData.partNo == '') {
        this.$alert(this.labels.inPartNo, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      if (this.mainData.partNo == '999998' || this.mainData.partNo == '999999') {
        this.$alert(this.labels.cannottongbu, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      this.$confirm(this.labels.orderAsk, this.labels.point, {
        confirmButtonText: this.labels.true,
        cancelButtonText: this.labels.cancel,
        type: 'warning'
      }).then(() => {
        let inData = {
          partNo: this.mainData.partNo,
          site: this.mainData.site,
          revNo: this.mainData.revNo,
          user: this.$store.state.user.name,
        }
        checkRoutingAndOrder(inData).then(({data}) => {
          if (data && data.code == 200) {
            this.$confirm(data.obj + this.labels.orderContinue, this.labels.point, {
              confirmButtonText: this.labels.true,
              cancelButtonText: this.labels.cancel,
              type: 'warning'
            }).then(() => {
              changeOrderRouting(inData).then(({data}) => {
                if (data && data.code == 200) {
                  this.$message.success(this.labels.doYes)
                } else {
                  this.$alert(data.msg, this.labels.error, {
                    confirmButtonText: this.labels.true
                  })
                }
              })
            })
          } else {
            this.$alert(data.msg, this.labels.error, {
              confirmButtonText: this.labels.true
            })
          }
        })
      })
    },
    copyRouting() {
      if (this.mainData.partNo == null || this.mainData.partNo == '') {
        this.$alert(this.labels.inPartNo, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      this.copyRoutingData = {
        partNo: this.mainData.partNo,
        partDescription: this.mainData.spec,
        revNo: this.mainData.revNo,
        phaseInDate: this.mainData.phaseInDate,
        repairFlag: this.mainData.repairFlag,
        partNo1: '',
        partDescription1: '',
        revNo1: '',
        phaseInDate1: new Date(),
        repairFlag1: false,
        oldFlag: false,
        toolFlag: false,
        resourceFlag: false,
      },
        this.copyRoutingModelFlag = true;
    },
    saveCopyRouting() {
      if (this.copyRoutingData.partNo1 == '' || this.copyRoutingData.partNo1 == null) {
        this.$alert(this.labels.inNewPartNo, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      if (this.copyRoutingData.revNo1 == '' || this.copyRoutingData.revNo1 == null) {
        this.$alert(this.labels.inNewRevNo, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      if (this.copyRoutingData.phaseInDate1 == '' || this.copyRoutingData.phaseInDate1 == null) {
        this.$alert(this.labels.inNewPhaseInDate, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      let repairFlag1 = 'N';
      if (this.copyRoutingData.repairFlag1 === true) {
        repairFlag1 = 'Y';
      }
      let inData = {
        site: this.mainData.site,
        partNo: this.copyRoutingData.partNo,
        revNo: this.copyRoutingData.revNo,
        partNo1: this.copyRoutingData.partNo1,
        revNo1: this.copyRoutingData.revNo1,
        phaseInDate1: this.copyRoutingData.phaseInDate1,
        repairFlag1: repairFlag1,
        oldFlag: this.copyRoutingData.oldFlag,
        toolFlag: this.copyRoutingData.toolFlag,
        resourceFlag: this.copyRoutingData.resourceFlag,
        user: this.$store.state.user.name
      }
      saveCopyRouting(inData).then(({data}) => {
        if (data && data.code == 200) {
          this.copyRoutingModelFlag = false
          let data = {
            partNo: this.mainData.partNo,
            site: this.mainData.site,
            revNo: this.mainData.revNo,
          }
          searchRoutingWithPartNo(data).then(({data}) => {
            if (data.rows.length > 0) {
              if (data.rows[0].repairFlag == 'Y') {
                data.rows[0].repairFlag = true;
              } else {
                data.rows[0].repairFlag = false;
              }
              if (data.rows[0].defaultflag == 'Y') {
                data.rows[0].defaultflag = true;
              } else {
                data.rows[0].defaultflag = false;
              }
              this.mainData = data.rows[0]
              let data1 = {
                site: data.rows[0].site,
                partNo: data.rows[0].partNo,
                revNo: data.rows[0].revNo,
              }
              searchRoutingDetailData(data1).then(({data}) => {
                this.dataList2 = data.rows;
              })
              searchRoutingToolData(data1).then(({data}) => {
                this.dataList3 = data.rows;
              })
            }

          })
          this.$message.success(this.labels.doYes)
          let row = {
            partNo: this.copyRoutingData.partNo1,
            site: this.mainData.site,
            revNo: this.copyRoutingData.revNo1,
          }
          this.tableHanddle(row)
        } else {
          this.$alert(data.msg, this.labels.error, {
            confirmButtonText: this.labels.true
          })
        }
      })
    },
    getPartDescription() {
      let inData = {
        user: this.$store.state.user.name,
        site: this.mainData.site,
        partNo: this.copyRoutingData.partNo1
      }
      searchPartNoData(inData).then(({data}) => {
        if (data.rows.length == 0) {
          return false;
        }
        this.copyRoutingData.partDescription1 = data.rows[0].partDescription;
      })

    },
    setDefault() {
      if (this.mainData.partNo == null || this.mainData.partNo == '') {
        this.$alert(this.labels.inPartNo, this.labels.error, {
          confirmButtonText: this.labels.true
        })
        return false;
      }
      this.$confirm(this.labels.defaultflagAsk, this.labels.point, {
        confirmButtonText: this.labels.true,
        cancelButtonText: this.labels.cancel,
        type: 'warning'

      }).then(() => {
        let data1 = {
          site: this.mainData.site,
          partNo: this.mainData.partNo,
          revNo: this.mainData.revNo,
        }
        setDefault(data1).then(({data}) => {
          if (data && data.code == 200) {
            this.mainData.defaultflag = true;
            this.$message.success(this.labels.doYes)

          } else {
            this.$alert(data.msg, this.labels.error, {
              confirmButtonText: this.labels.true
            })
          }
        })
      })
    },
    //获取按钮的权限数据
    getButtonAuthData() {
      let updateFlag = this.isAuth(this.menuId + ":revise");
      let fullControFlag = this.isAuth(this.menuId + ":fullContro");
      let deleteFlag = this.isAuth(this.menuId + ":remove");
      //处理页面的权限数据
      this.authEdit = !updateFlag || !fullControFlag;
      this.authAdd = !fullControFlag;
      this.authDelete = !deleteFlag;

//跳转页面
      let menList = JSON.parse(sessionStorage.getItem('dynamicMenuRoutes') || '[]').filter(item => item.path == 'base-workCenter')
      if (menList.length > 0) {
        this.jumpFlag = false
      }

//跳转页面
      let menList2 = JSON.parse(sessionStorage.getItem('dynamicMenuRoutes') || '[]').filter(item => item.path == 'knifemold-tool-info')
      if (menList2.length > 0) {
        this.jumpFlag2 = false
      }
    },
    //多语言
    getMultiLanguageList() {
      //首先查询当前按钮的多语言
      searchFunctionButtonList(this.queryButton).then(({data}) => {
        if (data && data.code == 0) {
          this.buttons = data.data
        } else {
          // saveButtonList(this.buttonList).then(({data}) => {
          // })
        }
      });
      //其次查询当前标签的多语言
      searchFunctionButtonList(this.queryLabel).then(({data}) => {
        if (data && data.code == 0) {
          this.labels = data.data
        } else {
          // saveButtonList(this.buttonList).then(({data}) => {
          // })
        }
      });
    },
  },
  created() {
    //获取按钮的权限
    this.getButtonAuthData();
    this.getMultiLanguageList()//刷新按钮
  }
}
</script>

<style scoped>

</style>
