<template>
  <div class="mod-config">
    <!-- 查询条件 -->
    <el-form :inline="true" label-position="top" :model="searchData" @keyup.enter.native="getDataList()">
      <el-form-item :label="'物料编码'">
        <el-input v-model="searchData.partNo" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'物料名称'">
        <el-input v-model="searchData.partDesc" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="' '">
        <el-button :loading="queryLoading" @click="getDataList()">查询</el-button>
        <el-button type="primary" @click="addModal()">新增</el-button>
        <el-button type="primary" @click="delModal()">删除</el-button>
        <download-excel
          :fields="fields()"
          :data="exportData"
          type="xls"
          :name="exportName"
          :header="exportHeader"
          :footer="exportFooter"
          :fetch="createExportData"
          :before-generate="startDownload"
          :before-finish="finishDownload"
          worksheet="导出信息"
          class="el-button el-button--primary el-button--medium">
          {{ "导出" }}
        </download-excel>
      </el-form-item>
    </el-form>

    <!-- routing列表 -->
    <el-table
      :height="height"
      :data="dataList"
      border
      @selection-change="selectionRouting"
      style="width: 100%;">
      <el-table-column
        type="selection"
        header-align="center"
        align="center"
        :selectable="selectFlag"
        width="50">
      </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-column
        fixed="right"
        header-align="center"
        align="center"
        width="120"
        label="操作">
        <template slot-scope="scope">
          <a type="text" size="small" @click="updateModal(scope.row)">编辑</a>
          <a type="text" size="small" @click="checkOutToBom(scope.row.partNo)">切换Bom</a>
        </template>
      </el-table-column>
    </el-table>

    <!-- 复选统计 -->
    <selectDiv ref="selectDiv"></selectDiv>

    <!-- 分页插件 -->
    <el-pagination style="margin-top: 0px"
                   @size-change="sizeChangeHandle"
                   @current-change="currentChangeHandle"
                   :current-page="pageIndex"
                   :page-sizes="[20, 50, 100, 200, 500]"
                   :page-size="pageSize"
                   :total="totalPage"
                   layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>

    <!-- routing新增/编辑模态框 -->
    <el-dialog :close-on-click-modal="false" v-drag :before-close="closeModalX" :visible.sync="modalFlag" width="1110px">
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 5px">
        <el-form-item prop="partNo" :rules="rules.partNo">
          <span v-if="!modalDisableFlag" slot="label" @click="queryPartList"><a herf="#">物料编码</a></span>
          <span v-else="modalDisableFlag" slot="label">物料编码</span>
          <el-input v-model="modalData.partNo" :disabled="modalDisableFlag" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item :label="'物料名称'" prop="partDesc" :rules="rules.partDesc">
          <el-input v-model="modalData.partDesc" disabled style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item :label="'物料单位'">
          <el-input v-model="modalData.printUnitName" disabled style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item :label="'工艺类型'" prop="routingType" :rules="rules.routingType">
          <el-select v-model="modalData.routingType" @change="routingTypeChange" :disabled="modalDisableFlag" style="width: 120px">
            <el-option label="Manufacturing" value="Manufacturing"></el-option>
            <el-option label="Repair" value="Repair"></el-option>
            <el-option label="Prototype" value="Prototype"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="生效日期" prop="phaseInDate" :rules="rules.phaseInDate">
          <el-date-picker
            style="width: 221px"
            v-model="modalData.phaseInDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择日期"
            :editable=false>
          </el-date-picker>
        </el-form-item>
        <el-form-item label="失效日期">
          <el-date-picker
            style="width: 221px"
            v-model="modalData.phaseOutDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择日期"
            :editable=false>
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="'Routing版本号'" prop="routingRevision" :rules="rules.routingRevision">
          <el-input v-model="modalData.routingRevision" type="number" disabled style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button v-if="modalData.flag === '1'" :loading="saveHeaderLoading" type="primary" @click="saveRoutingHeader" style="margin-top: 23px;width: 142px">保存</el-button>
          <el-button v-else type="primary" @click="copyRoutingRevision" style="margin-top: 23px;width: 120px">Copy</el-button>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="备注">
          <el-input type="textarea" v-model="modalData.noteText" :rows="3" resize='none' show-word-limit style="width: 1082px;height: 20px"></el-input>
        </el-form-item>
      </el-form>
      <el-tabs v-model="detailTable" style="margin-top: 50px; width: 100%" type="border-card" @tab-click="tabDetailClick" class="detail-tab">
        <!-- Routing明细信息页签 -->
        <el-tab-pane label="Routings" name="routing_detail">
          <el-form label-position="top" style="margin-top: -10px">
            <el-form-item>
              <el-button type="primary" @click="saveRoutingDetail" style="margin-left: 7px">新增</el-button>
              <el-button type="primary" @click="deleteRoutingDetail">删除</el-button>
              <el-button type="primary" @click="updateRoutingDetail">编辑</el-button>
              <el-button v-if="modalData.flag === '2'" type="primary" @click="copyRoutingAlternative">Copy</el-button>
              <el-button v-if="detailData.status === 'Tentative' || detailData.status === 'Obsolete'" type="primary" @click="updateStatusToBuildable">Build</el-button>
              <el-button v-if="detailData.status === 'Buildable' && (modalData.effPhaseOutDate == null || modalData.effPhaseOutDate === '')" type="primary" @click="updateStatusToObsolete">Retire</el-button>
              <el-button v-if="modalData.flag === '2' && detailData.officialFlag !== 'Y'" type="primary" @click="toBecomeOfficialRouting">转正式Routing</el-button>
            </el-form-item>
          </el-form>
          <el-form :inline="true" label-position="top" :model="detailData" :rules="rules" style="margin-left: 7px">
            <el-form-item :label="'替代编码'">
              <el-select v-model="detailData.alternativeNo" @change="alternativeChange" style="width: 221px">
                <el-option
                  v-for = "(i, index) in detailDataList"
                  :key = "index"
                  :label = "i.alternativeNo"
                  :value = "i.alternativeNo">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item :label="'替代名称'">
              <el-input v-model="detailData.alternativeDescription" readonly style="width: 221px"></el-input>
            </el-form-item>
            <el-form-item :label="'状态'">
              <el-input v-model="detailData.status" readonly style="width: 221px"></el-input>
            </el-form-item>
          </el-form>
          <el-form :inline="true" label-position="top" :model="detailData" style="margin-left: 7px">
            <el-form-item label="备注">
              <el-input type="textarea" v-model="detailData.detailNoteText" :rows="3" resize='none' show-word-limit readonly style="width: 1073px;height: 20px"></el-input>
            </el-form-item>
          </el-form>
        </el-tab-pane>
        <!-- Routing工具页签 -->
        <el-tab-pane label="Routing Tools" name="routing_tool">
          <el-form label-position="top" style="margin-top: -10px">
            <el-form-item>
              <el-button type="primary" @click="saveRoutingTool" style="margin-left: 7px">新增</el-button>
              <el-button type="primary" @click="deleteRoutingTool">删除</el-button>
            </el-form-item>
          </el-form>
          <el-table
            :data="routingToolList"
            height="500px"
            border
            ref="toolTable"
            @row-click="toolClickRow"
            @selection-change="toolSelectionChange"
            style="width:100%">
            <el-table-column type="selection" align="center" width="50"></el-table-column>
            <el-table-column
              v-for="(item,index) in columnRoutingToolList" :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-column
              fixed="right"
              header-align="center"
              align="center"
              width="100"
              label="操作">
              <template slot-scope="scope">
                <a type="text" size="small" @click="updateToolModal(scope.row)">编辑</a>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
      <el-tabs v-show="detailTable === 'routing_detail'" v-model="subDetailTable" style="width: 100%; min-height: 330px" type="border-card" @tab-click="tabSubDetailClick" class="sub_detail-tab">
        <!-- Routing子明细信息页签 -->
        <el-tab-pane label="Operations" name="routing_sub_detail">
          <el-form label-position="top" style="margin-top: 5px">
            <el-form-item>
              <el-button type="primary" @click="saveComponentModal" style="margin-left: 7px">新增</el-button>
              <el-button type="primary" @click="deleteComponentPart">删除</el-button>
            </el-form-item>
          </el-form>
          <el-table
            :data="subDetailList"
            height="256px"
            border
            ref="componentTable"
            @row-click="componentClickRow"
            :row-class-name="rowClassName"
            @selection-change="componentSelectionChange"
            style="width:100%">
            <el-table-column type="selection" align="center" width="50"></el-table-column>
            <el-table-column
              v-for="(item,index) in columnSubDetailList" :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-column
              fixed="right"
              header-align="center"
              align="center"
              width="100"
              label="操作">
              <template slot-scope="scope">
                <a type="text" size="small" @click="workGuidelineModal(scope.row)">工艺指导</a>
                <a type="text" size="small" @click="updateComponentModal(scope.row)">编辑</a>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
      <el-footer style="height:30px;margin-top:20px;text-align:center">
        <el-button :loading="saveAllLoading" type="primary" @click="saveData()">保存</el-button>
        <el-button type="primary" @click="closeModal">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 明细新增模态框 -->
    <el-dialog title="替代" :close-on-click-modal="false" v-drag :visible.sync="saveDetailModalFlag" width="730px">
      <el-form :inline="true" label-position="top" :model="saveDetailData" :rules="detailRules" style="margin-left: 5px">
        <el-form-item :label="'替代编码'" prop="alternativeNo" :disabled="saveDetailModalDisable" :rules="detailRules.alternativeNo">
          <el-input v-model="saveDetailData.alternativeNo" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item :label="'替代名称'" prop="alternativeDescription" :rules="detailRules.alternativeDescription">
          <el-input v-model="saveDetailData.alternativeDescription" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item :label="'状态'" prop="status" :rules="detailRules.status">
          <el-input v-model="saveDetailData.status" disabled style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="saveDetailData" style="margin-left: 5px">
        <el-form-item label="备注">
          <el-input type="textarea" v-model="saveDetailData.detailNoteText" :rows="3" resize='none' show-word-limit style="width: 690px;height: 20px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:35px;margin-top:65px;text-align:center">
        <el-button :loading="saveDetailLoading" type="primary" @click="detailDataSave()">保存</el-button>
        <el-button type="primary" @click="saveDetailModalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 物料模态框 -->
    <el-dialog title="物料清单" :close-on-click-modal="false" v-drag :visible.sync="partModelFlag" width="520px">
      <div class="rq">
        <el-form :inline="true" label-position="top" :model="partData">
          <el-form-item :label="'物料编码'">
            <el-input v-model="partData.partNo" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'物料名称'">
            <el-input v-model="partData.partDesc" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="' '">
            <el-button type="primary" @click="queryPartList()">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table
          :height="300"
          :data="partList"
          @row-dblclick="getRowData"
          border
          style="width: 100%;">
          <el-table-column
            v-for="(item,index) in partColumnList" :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>
      </div>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="partModelFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 子明细工序模态框 -->
    <el-dialog title="工序清单" :close-on-click-modal="false" v-drag :visible.sync="componentPartModelFlag" width="520px">
      <el-form :inline="true" label-position="top" :model="operationData">
        <el-form-item :label="'工序编码'">
          <el-input v-model="operationData.operationNo" clearable style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'工序名称'">
          <el-input v-model="operationData.operationName" clearable style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="' '">
          <el-button type="primary" @click="queryOperationList()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="300"
        :data="operationList"
        @row-dblclick="getComponentRowData"
        border
        style="width: 100%;">
        <el-table-column
          v-for="(item,index) in componentOperationColumnList" :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-dialog>

    <!-- 子明细新增模态框 -->
    <el-dialog title="工序" :close-on-click-modal="false" v-drag :visible.sync="componentSaveModal" width="500px">
      <el-form :inline="true" label-position="top" :model="componentData" :rules="componentRules" style="margin-left: 5px">
<!--        <el-form-item prop="operationId" :rules="componentRules.operationId">-->
<!--          <span v-if="!componentDisableFlag" slot="label" @click="queryOperationList()"><a herf="#">工序号</a></span>-->
<!--          <span v-if="componentDisableFlag" slot="label">工序号</span>-->
<!--          <el-input v-model="componentData.operationId" :disabled="componentDisableFlag" style="width: 221px"></el-input>-->
<!--        </el-form-item>-->
        <el-form-item :label="'工序编码'" prop="operationNo" :rules="componentRules.operationNo">
          <el-input v-model="componentData.operationNo" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item :label="'工序名称'" prop="operationName" :rules="componentRules.operationName">
          <el-input v-model="componentData.operationName" style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="componentData" :rules="componentRules" style="margin-left: 5px">
        <el-form-item>
          <span slot="label" @click="getBaseList(119)"><a herf="#">加工中心编码</a></span>
          <el-input v-model="componentData.workCenterNo" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item :label="'加工中心名称'">
          <el-input v-model="componentData.workCenterDesc" disabled style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="componentData" style="margin-left: 5px">
        <el-form-item :label="'机器运行速度'">
          <el-input class="inlineNumber numInput" v-model="componentData.machRunFactor" @input="handleInput(componentData.machRunFactor,1)" type="number" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item :label="'人工生产速度'">
          <el-input class="inlineNumber numInput" v-model="componentData.laborSetupTime" @input="handleInput(componentData.laborSetupTime,5)" type="number" style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="componentData" style="margin-left: 5px">
        <el-form-item :label="'调机时长'">
          <el-input class="inlineNumber numInput" v-model="componentData.machSetupTime" @input="handleInput(componentData.machSetupTime,2)" type="number" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item :label="'时长单位'">
          <el-select v-model="componentData.runTimeCode" clearable style="width: 221px">
            <el-option label="单位/小时" value="A"></el-option>
            <el-option label="小时/单位" value="B"></el-option>
            <el-option label="小时" value="C"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="componentData" style="margin-left: 5px">
        <el-form-item :label="'调机过程中人数'">
          <el-input class="inlineNumber numInput" v-model="componentData.setupCrewSize" @input="handleInput(componentData.setupCrewSize,3)" type="number" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item :label="'生产过程中人数'">
            <el-input class="inlineNumber numInput" v-model="componentData.crewSize" @input="handleInput(componentData.crewSize,4)" type="number" style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="componentData" style="margin-left: 5px">
        <el-form-item :label="'机器效率%'">
          <el-input class="inlineNumber numInput" v-model="componentData.efficiencyFactor" @input="handleInputB(componentData.efficiencyFactor,1)" type="number" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item :label="'人工效率%'">
          <el-input class="inlineNumber numInput" v-model="componentData.laborRunFactor" @input="handleInputB(componentData.laborRunFactor,2)" type="number" style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="componentData" style="margin-left: 5px">
        <el-form-item>
          <span slot="label" @click="getBaseList(118, 1)"><a herf="#">人员等级</a></span>
          <el-input v-model="componentData.laborClassDesc" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item>
          <span slot="label" @click="getBaseList(118, 2)"><a herf="#">调机时的人员等级</a></span>
          <el-input v-model="componentData.setupLaborClassDesc" style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="componentData" style="margin-left: 5px">
        <el-form-item :label="'外协采购料号'">
          <el-input v-model="componentData.outsideOpItem" style="width: 456px"></el-input>
        </el-form-item>
<!--        <el-form-item :label="'机台'">-->
<!--          <el-input v-model="componentData.machineNo" style="width: 221px"></el-input>-->
<!--        </el-form-item>-->
      </el-form>
      <el-form :inline="true" label-position="top" :model="componentData" style="margin-left: 5px">
        <el-form-item label="备注">
          <el-input type="textarea" v-model="componentData.noteText" :rows="3" resize='none' show-word-limit style="width: 456px;height: 20px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:35px;margin-top:65px;text-align:center">
        <el-button :loading="saveComponentLoading" type="primary" @click="componentDataSave()">保存</el-button>
        <el-button type="primary" @click="componentSaveModal = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- routingTool 新增模态框 -->
    <el-dialog title="工艺工具" :close-on-click-modal="false" v-drag :visible.sync="saveRoutingToolModal" width="500px">
      <el-form :inline="true" label-position="top" :model="routingToolData" style="margin-left: 5px">
        <el-form-item :label="'替代'">
          <el-select v-model="routingToolData.alternativeNo" placeholder="请选择" :disabled="saveRoutingToolDisableModal" style="width: 330px">
            <el-option
              v-for = "i in alternativeList"
              :key = "i.alternativeNo"
              :label = "i.alternativeDescription"
              :value = "i.alternativeNo">
              <span style="float: left;width: 100px">{{ i.alternativeNo }}</span>
              <span style="float: right; color: #8492a6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; font-size: 11px;width: 60px">{{ i.alternativeDescription }}</span>
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="'工具数量'">
          <el-input class="inlineNumber numInput" v-model="routingToolData.toolQty" type="number" style="width: 120px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="routingToolData" style="margin-left: 5px">
        <el-form-item>
          <span v-if="saveRoutingToolDisableModal === false" slot="label" @click="queryOperationList()"><a>工序</a></span>
          <span v-if="saveRoutingToolDisableModal === true" slot="label">工序</span>
          <el-input v-model="routingToolData.operationNo" :disabled="saveRoutingToolDisableModal" style="width: 120px"></el-input>
          <el-input v-model="routingToolData.operationName" disabled style="width: 340px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="routingToolData" style="margin-left: 5px">
        <el-form-item>
          <span v-if="saveRoutingToolDisableModal === false" slot="label" @click="getBaseList(122)"><a>工具</a></span>
          <span v-if="saveRoutingToolDisableModal === true" slot="label">工具</span>
          <el-input v-model="routingToolData.toolId" :disabled="saveRoutingToolDisableModal" style="width: 120px"></el-input>
          <el-input v-model="routingToolData.toolDescription" disabled style="width: 340px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="routingToolData" style="margin-left: 5px">
        <el-form-item :label="'备注'">
          <el-input v-model="routingToolData.remark" style="width: 462px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:35px;margin-top:25px;text-align:center">
        <el-button type="primary" @click="routingToolSave()">保存</el-button>
        <el-button type="primary" @click="saveRoutingToolModal = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- copyRouting -->
    <el-dialog title="Copy Structure Revision" :close-on-click-modal="false" v-drag :visible.sync="copyRoutingModelFlag" width="450px">
      <fieldset style="width: 426px">
        <legend>Source Revision</legend>
        <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item label="物料编码">
            <el-input v-model="modalData.partNo" readonly style="width: 185px"></el-input>
          </el-form-item>
          <el-form-item label="site">
            <el-input v-model="modalData.site" disabled style="width: 185px"></el-input>
          </el-form-item>
        </el-form>
        <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item label="Routing版本号">
            <el-input v-model="modalData.routingRevision" readonly style="width: 185px"></el-input>
          </el-form-item>
          <el-form-item label="工艺类型">
            <el-input v-model="modalData.routingType" readonly style="width: 185px"></el-input>
          </el-form-item>
        </el-form>
        <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item label="生效日期">
            <el-date-picker style="width: 185px" v-model="modalData.phaseInDate" readonly type="date" value-format="yyyy-MM-dd"></el-date-picker>
          </el-form-item>
          <el-form-item label="失效日期">
            <el-date-picker style="width: 185px" v-model="modalData.phaseOutDate" readonly type="date" value-format="yyyy-MM-dd"></el-date-picker>
          </el-form-item>
        </el-form>
        <el-table
          :data="detailDataList"
          height="100px"
          border
          style="width:100%">
          <el-table-column
            v-for="(item,index) in columnRoutingDetailList" :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>
      </fieldset>
      <fieldset style="width: 426px">
        <legend>Destination Revision</legend>
        <el-form :inline="true" label-position="top" :model="copyRoutingData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item label="物料编码">
            <el-input v-model="copyRoutingData.partNo" style="width: 185px"></el-input>
          </el-form-item>
          <el-form-item label="site">
            <el-input v-model="copyRoutingData.site" disabled style="width: 185px"></el-input>
          </el-form-item>
        </el-form>
        <el-form :inline="true" label-position="top" :model="copyRoutingData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item label="Routing版本号">
            <el-input v-model="copyRoutingData.routingRevision" style="width: 185px"></el-input>
          </el-form-item>
          <el-form-item label="工艺类型">
            <el-select v-model="copyRoutingData.routingType" style="width: 185px">
              <el-option label="Manufacturing" value="Manufacturing"></el-option>
              <el-option label="Repair" value="Repair"></el-option>
              <el-option label="Prototype" value="Prototype"></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <el-form :inline="true" label-position="top" :model="copyRoutingData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item label="生效日期">
            <el-date-picker style="width: 185px" v-model="copyRoutingData.phaseInDate" type="date" value-format="yyyy-MM-dd" placeholder="选择日期"></el-date-picker>
          </el-form-item>
          <el-form-item label="失效日期">
            <el-date-picker style="width: 185px" v-model="copyRoutingData.phaseOutDate" type="date" value-format="yyyy-MM-dd" placeholder="选择日期"></el-date-picker>
          </el-form-item>
        </el-form>
      </fieldset>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="copyRouting">保存</el-button>
        <el-button type="primary" @click="copyRoutingModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- copyAlternative -->
    <el-dialog title="Copy Structure Alternative" :close-on-click-modal="false" v-drag :visible.sync="copyAlternativeModelFlag" width="450px">
      <fieldset style="width: 426px">
        <legend>Source Revision</legend>
        <el-form :inline="true" label-position="top" :model="detailData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item label="物料编码">
            <el-input v-model="detailData.partNo" readonly style="width: 185px"></el-input>
          </el-form-item>
          <el-form-item label="site">
            <el-input v-model="detailData.site" disabled style="width: 185px"></el-input>
          </el-form-item>
        </el-form>
        <el-form :inline="true" label-position="top" :model="detailData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item label="Routing版本号">
            <el-input v-model="detailData.routingRevision" readonly style="width: 185px"></el-input>
          </el-form-item>
          <el-form-item label="工艺类型">
            <el-input v-model="detailData.routingType" readonly style="width: 185px"></el-input>
          </el-form-item>
        </el-form>
        <el-form :inline="true" label-position="top" :model="detailData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item label="替代编码">
            <el-input v-model="detailData.alternativeNo" readonly style="width: 185px"></el-input>
          </el-form-item>
          <el-form-item label="替代名称">
            <el-input v-model="detailData.alternativeDescription" readonly style="width: 185px"></el-input>
          </el-form-item>
        </el-form>
      </fieldset>
      <fieldset style="width: 426px">
        <legend>Destination Revision</legend>
        <el-form :inline="true" label-position="top" :model="copyAlternativeData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item label="物料编码">
            <el-input v-model="copyAlternativeData.partNo" style="width: 185px"></el-input>
          </el-form-item>
          <el-form-item label="site">
            <el-input v-model="copyAlternativeData.site" disabled style="width: 185px"></el-input>
          </el-form-item>
        </el-form>
        <el-form :inline="true" label-position="top" :model="copyAlternativeData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item label="Routing版本号">
            <el-input v-model="copyAlternativeData.routingRevision" style="width: 185px"></el-input>
          </el-form-item>
          <el-form-item label="工艺类型">
            <el-select v-model="copyAlternativeData.routingType" style="width: 185px">
              <el-option label="Manufacturing" value="Manufacturing"></el-option>
              <el-option label="Repair" value="Repair"></el-option>
              <el-option label="Prototype" value="Prototype"></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <el-form :inline="true" label-position="top" :model="copyAlternativeData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item label="替代编码">
            <el-input v-model="copyAlternativeData.alternativeNo" style="width: 185px"></el-input>
          </el-form-item>
          <el-form-item label="替代名称">
            <el-input v-model="copyAlternativeData.alternativeDescription" style="width: 185px"></el-input>
          </el-form-item>
        </el-form>
      </fieldset>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="copyAlternative">保存</el-button>
        <el-button type="primary" @click="copyAlternativeModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- workGuideline -->
    <el-dialog title="工艺指导" :close-on-click-modal="false" v-drag :visible.sync="queryWorkGuidelineModal" width="1000px">
      <el-form :inline="true" label-position="top" :model="workGuidelineData" style="margin-left: 5px">
        <el-form-item :label="'物料编码'">
          <el-input v-model="workGuidelineData.partNo" readonly style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'物料名称'">
          <el-input v-model="workGuidelineData.partDesc" readonly style="width: 240px"></el-input>
        </el-form-item>
        <el-form-item :label="'Routing版本号'">
          <el-input v-model="workGuidelineData.routingRevision" readonly style="width: 80px"></el-input>
        </el-form-item>
        <el-form-item :label="'工艺类型'">
          <el-input v-model="workGuidelineData.routingType" readonly style="width: 120px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="workGuidelineData" style="margin-left: 5px">
        <el-form-item :label="'替代编码'">
          <el-input v-model="workGuidelineData.alternativeNo" readonly style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'替代名称'">
          <el-input v-model="workGuidelineData.alternativeDescription" readonly style="width: 240px"></el-input>
        </el-form-item>
        <el-form-item :label="'工序编码'">
          <el-input v-model="workGuidelineData.operationNo" readonly style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'工序名称'">
          <el-input v-model="workGuidelineData.operationName" readonly style="width: 240px"></el-input>
        </el-form-item>
      </el-form>
      <!-- 页签 -->
      <el-tabs style="width: 100%" type="border-card" class="customer-tab">
        <!-- Graphical Structure页签 -->
        <el-tab-pane label="Work Guidelines">
          <el-form label-position="top" style="margin-top: 0px">
            <el-button type="primary" @click="saveWorkGuideline()" style="margin-left: 2px">新增</el-button>
            <el-button type="primary" @click="deleteModal()">删除</el-button>
          </el-form>
          <el-table
            height="400px"
            :data="workGuidelineList"
            border
            @selection-change="selectionWorkGuideline"
            style="width: 100%">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              :selectable="selectFlag"
              width="50">
            </el-table-column>
            <el-table-column
              v-for="(item,index) in workGuidelineColumnList" :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-column
              fixed="right"
              header-align="center"
              align="center"
              width="100"
              label="操作">
              <template slot-scope="scope">
                <a type="text" size="small" @click="updateWorkGuidelineModal(scope.row)">编辑</a>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="queryWorkGuidelineModal = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- workGuideline 新增模态框 -->
    <el-dialog title="替代" :close-on-click-modal="false" v-drag :visible.sync="saveWorkGuidelineModal" width="664px">
      <el-form :inline="true" label-position="top" :model="saveWorkGuidelineData" :rules="guidelineRules" style="margin-left: 5px">
        <el-form-item :label="'序号'" prop="guidelineSeq" :rules="guidelineRules.guidelineSeq">
          <el-input class="inlineNumber numInput" v-model="saveWorkGuidelineData.guidelineSeq" type="number" style="width: 60px"></el-input>
        </el-form-item>
        <el-form-item :label="'工艺指导名称'" prop="guidelineDesc" :rules="guidelineRules.guidelineDesc">
          <el-input v-model="saveWorkGuidelineData.guidelineDesc" style="width: 126px"></el-input>
        </el-form-item>
        <el-form-item :label="'工艺指导描述'">
          <el-input v-model="saveWorkGuidelineData.guidelineText" style="width: 413px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="saveWorkGuidelineData" :rules="guidelineRules" style="margin-left: 5px">
        <el-form-item :label="'工艺指导类型'" prop="guidelineType" :rules="guidelineRules.guidelineType">
          <el-select v-model="saveWorkGuidelineData.guidelineType" style="width: 200px">
            <el-option label="Subtask" value="Subtask"></el-option>
            <el-option label="Instruction" value="Instruction"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="'签字'" prop="signOffRequired" :rules="guidelineRules.signOffRequired">
          <el-select v-model="saveWorkGuidelineData.signOffRequired" style="width: 200px">
            <el-option label="Required to Close Operation" value="Required to Close Operation"></el-option>
            <el-option label="Not Required" value="Not Required"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="'检验签字'" prop="inspectionSignOffRequired" :rules="guidelineRules.inspectionSignOffRequired">
          <el-select v-model="saveWorkGuidelineData.inspectionSignOffRequired" style="width: 200px">
            <el-option label="Required to Shop Order" value="Required to Shop Order"></el-option>
            <el-option label="Required to Close Operation" value="Required to Close Operation"></el-option>
            <el-option label="Not Required" value="Not Required"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-footer style="height:35px;margin-top:25px;text-align:center">
        <el-button type="primary" @click="workGuidelineCommit()">保存</el-button>
        <el-button type="primary" @click="saveWorkGuidelineModal = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- chooseList模态框 -->
    <ChooseList ref="baseList" @getBaseData="getBaseData"></ChooseList>
  </div>
</template>

<script>
import {
  routingManagementSearch, // routing 列表查询
  routingManagementSave, // routing 新增
  routingManagementEdit, // routing 编辑
  routingManagementDelete, // routing 删除
  queryRoutingHeader, // 查询 routing 主信息
  saveRoutingHeader, // 新增 routing 主信息
  queryRoutingDetail, // 查 routing 明细
  routingDetailSave, // routing 明细新增
  routingDetailUpdate, // routing 明细编辑
  updateAlternativeStatus, // 修改明细状态
  routingDetailDelete, // routing 明细删除
  queryPartList, // 查询物料清单
  queryRoutingComponent, // 查询 routing 子明细
  saveRoutingComponent, // 新增 routing 子明细
  updateRoutingComponent, // 修改 routing 子明细
  deleteRoutingComponent, // 删除 routing 子明细
  queryOperationList, // 查询工序列表
  getRottingRevision, // 获取物料的 routing 版本号
  searchRoutingTools, // 获取 routingTools
  routingToolSave, // 新增 routingTool
  queryOperationListByAlternative, // 根据替代查询工序列表
  queryAlternativeListByPartNo, // 根据物料查询替代
  routingToolEdit, // 编辑 routingTool
  deleteRoutingTool, // 删除 routingTool
  copyRouting, // 复制routing
  copyAlternative, // 复制alternative
  toBecomeOfficialRouting, // 转正式Routing
} from '@/api/part/routingManagement.js'
import {
  routingSearchAlternative, // routing 替代列表查询
  getRoutingWorkGuideline, // 获取 workGuideline
  getGuidelineSeq, // 获取 guidelineSeq
  workGuidelineSave, // 新增 workGuideline
  workGuidelineEdit, // 编辑 workGuideline
  deleteWorkGuideline, // 删除 workGuideline
} from '@/api/part/routingOperationWorkGuidelines.js'
import ChooseList from '@/views/modules/common/Chooselist'

export default {
  // 组件
  components: {
    ChooseList
  },
  // 监听
  watch: {
    searchData: {
      deep: true,
      handler: function (newV, oldV) {
        this.searchData.partNo = this.searchData.partNo.toUpperCase()
      }
    },
    saveDetailData: {
      deep: true,
      handler: function (newV, oldV) {
        this.saveDetailData.alternativeNo = this.saveDetailData.alternativeNo.toUpperCase()
      }
    }
  },
  // 对象
  data () {
    return {
      // 导出
      exportData: [],
      exportName: 'routing物料列表' + this.dayjs().format('YYYYMMDDHHmmss'),
      exportHeader: ['routing物料列表'],
      exportFooter: [],
      resultList: [],
      // ======== 行高 ========
      height: 200,
      // ======== 分页 ========
      pageIndex: 1,
      pageSize: 50,
      totalPage: 0,
      selectedDataNum: 0,
      // 条件查询
      searchData: {
        site: this.$store.state.user.site,
        partNo: '',
        partDesc: '',
        page: 1,
        limit: 10
      },
      // loading
      queryLoading: false,
      saveHeaderLoading: false,
      saveDetailLoading: false,
      saveComponentLoading: false,
      saveAllLoading: false,
      // 初始页签
      detailTable: 'routing_detail',
      subDetailTable: 'routing_sub_detail',
      // ======== 数据对象 ========
      modalData: {
        flag: '',
        title: '',
        site: this.$store.state.user.site,
        partNo: '',
        partDesc: '',
        routingRevision: '',
        routingType: '',
        noteText: '',
        phaseInDate: '',
        phaseOutDate: '',
        createDate: '',
        createBy: '',
        updateDate: '',
        updateBy: '',
        printUnit: '',
        printUnitName: '',
        officialFlag: ''
      },
      detailData: {
        site: this.$store.state.user.site,
        partNo: '',
        routingRevision: '',
        routingType: '',
        alternativeNo: '',
        alternativeDescription: '',
        routTemplateId: '',
        planDate: '',
        fixedLeadTimeDay: '',
        fixedLeadTimeHour: '',
        variableLeadTimeDay: '',
        variableLeadTimeHour: '',
        forStdLotByDay: '',
        forLotByDay: '',
        minLotQty: '',
        detailNoteText: '',
        status: '',
        createDate: '',
        createBy: '',
        updateDate: '',
        updateBy: '',
        officialFlag: ''
      },
      componentData: {
        flag: '',
        site: this.$store.state.user.site,
        partNo: '',
        routingRevision: '',
        routingType: '',
        alternativeNo: '',
        operationId: '',
        operationNo: '',
        operationName: '',
        efficiencyFactor: '',
        machRunFactor: '',
        machSetupTime: '',
        runTimeCode: '',
        laborRunFactor: '',
        laborSetupTime: '',
        crewSize: '',
        setupCrewSize: '',
        outsideOpItem: '',
        machineNo: '',
        workCenterNo: '',
        workCenterDesc: '',
        laborClassNo: '',
        laborClassDesc: '',
        setupLaborClassNo: '',
        setupLaborClassDesc: '',
        overlap: '',
        noteText: '',
        createDate: '',
        createBy: '',
        updateDate: '',
        updateBy: ''
      },
      partData: {
        site: this.$store.state.user.site,
        partNo: '',
        partDesc: '',
      },
      operationData: {
        site: this.$store.state.user.site,
        partNo: '',
        routingRevision: '',
        routingType: '',
        alternativeNo: '',
        operationNo: '',
        operationName: '',
      },
      saveDetailData: {
        flag: '',
        site: this.$store.state.user.site,
        partNo: '',
        routingRevision: '',
        routingType: '',
        alternativeNo: '',
        alternativeDescription: '',
        routTemplateId: '',
        planDate: '',
        fixedLeadTimeDay: '',
        fixedLeadTimeHour: '',
        variableLeadTimeDay: '',
        variableLeadTimeHour: '',
        forStdLotByDay: '',
        forLotByDay: '',
        minLotQty: '',
        detailNoteText: '',
        status: '',
        createDate: '',
        createBy: '',
        updateDate: '',
        updateBy: ''
      },
      routingToolData: {
        flag: '',
        site: this.$store.state.user.site,
        partNo: '',
        partDesc: '',
        routingRevision: '',
        routingType: '',
        alternativeNo: '',
        alternativeDescription: '',
        operationId: '',
        operationNo: '',
        operationName: '',
        toolId: '',
        toolDescription: '',
        toolQty: '',
        remark: '',
        createBy: '',
        updateBy: ''
      },
      copyRoutingData: {
        site: '',
        partNo: '',
        routingRevision: '',
        routingType: '',
        phaseInDate: '',
        phaseOutDate: '',
        previousVersion: {},
        createBy: ''
      },
      copyAlternativeData: {
        site: '',
        partNo: '',
        routingRevision: '',
        routingType: '',
        alternativeNo: '',
        alternativeDescription: '',
        routTemplateId: '',
        planDate: '',
        fixedLeadTimeDay: '',
        fixedLeadTimeHour: '',
        variableLeadTimeDay: '',
        variableLeadTimeHour: '',
        forStdLotByDay: '',
        forLotByDay: '',
        minLotQty: '',
        detailNoteText: '',
        status: '',
        previousVersion: {},
        createBy: ''
      },
      workGuidelineData: {
        site: this.$store.state.user.site,
        partNo: '',
        partDesc: '',
        routingRevision: '',
        routingType: '',
        alternativeNo: '',
        alternativeDescription: '',
        operationId: '',
        operationNo: '',
        operationName: ''
      },
      saveWorkGuidelineData: {
        flag: '',
        id: '',
        site: this.$store.state.user.site,
        partNo: '',
        partDesc: '',
        routingRevision: '',
        routingType: '',
        alternativeNo: '',
        alternativeDescription: '',
        operationId: '',
        operationNo: '',
        operationName: '',
        guidelineSeq: '',
        guidelineDesc: '',
        guidelineText: '',
        guidelineType: '',
        signOffRequired: '',
        inspectionSignOffRequired: '',
        createBy: '',
        updateBy: ''
      },
      // ======== 数据列表 ========
      dataList: [],
      partList: [],
      operationList: [],
      componentPartSelections: [],
      subDetailList: [],
      detailDataList: [],
      checkedDetail: [],
      checkedTool: [],
      routingToolList: [],
      alternativeList: [],
      workGuidelineList: [],
      // ======== 列表表头 ========
      columnList: [
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table1PartNo',
          tableId: '104003Table1',
          tableName: 'Routing信息表',
          columnProp: 'partNo',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '物料编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table1PartDesc',
          tableId: '104003Table1',
          tableName: 'Routing信息表',
          columnProp: 'partDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '物料名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table1RoutingType',
          tableId: '104003Table1',
          tableName: 'Routing信息表',
          columnProp: 'routingType',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '工艺类型',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table1RoutingRevision',
          tableId: '104003Table1',
          tableName: 'Routing信息表',
          columnProp: 'routingRevision',
          headerAlign: 'center',
          align: 'center',
          columnLabel: 'Routing版本号',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table1CreateDate',
          tableId: '104003Table1',
          tableName: 'Routing信息表',
          columnProp: 'createDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '创建时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 160
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table1CreateBy',
          tableId: '104003Table1',
          tableName: 'Routing信息表',
          columnProp: 'createBy',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '创建人',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table1UpdateDate',
          tableId: '104003Table1',
          tableName: 'Routing信息表',
          columnProp: 'updateDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '更新时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 160
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table1UpdateBy',
          tableId: '104003Table1',
          tableName: 'Routing信息表',
          columnProp: 'updateBy',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '更新人',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        }
      ],
      partColumnList: [
        {
          columnProp: 'partNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '物料编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
        },
        {
          columnProp: 'partDesc',
          headerAlign: "center",
          align: "center",
          columnLabel: '物料名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
        },
        {
          columnProp: 'spec',
          headerAlign: "center",
          align: "center",
          columnLabel: '规格型号',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
        },
        {
          columnProp: 'printUnitName',
          headerAlign: "center",
          align: "center",
          columnLabel: '计量单位',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
        },
      ],
      componentOperationColumnList: [
        {
          columnProp: 'operationNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '工序编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
        },
        {
          columnProp: 'operationName',
          headerAlign: "center",
          align: "center",
          columnLabel: '工序名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
        }
      ],
      columnSubDetailList: [
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2OperationNo',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'operationNo',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '工序编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2OperationName',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'operationName',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '工序名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2EfficiencyFactor',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'efficiencyFactor',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '机器效率',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2MachRunFactor',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'machRunFactor',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '机器运行速度',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2MachSetupTime',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'machSetupTime',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '调机时长',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2RunTimeCode',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'runTimeCode',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '时长单位',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 60
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2LaborRunFactor',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'laborRunFactor',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '人工效率',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2LaborSetupTime',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'laborSetupTime',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '人工生产速度',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2CrewSize',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'crewSize',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '生产过程人数',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2SetupCrewSize',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'setupCrewSize',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '调机过程人数',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2OutsideOpItem',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'outsideOpItem',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '外协采购料号',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        // {
        //   userId: this.$store.state.user.name,
        //   functionId: 104003,
        //   serialNumber: '104003Table2MachineNo',
        //   tableId: '104003Table2',
        //   tableName: 'Routing工序表',
        //   columnProp: 'machineNo',
        //   headerAlign: 'center',
        //   align: 'center',
        //   columnLabel: '机台',
        //   columnHidden: false,
        //   columnImage: false,
        //   columnSortable: false,
        //   sortLv: 0,
        //   status: true,
        //   fixed: '',
        //   columnWidth: 80
        // },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2WorkCenterDesc',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'workCenterDesc',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '加工中心',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2LaborClassNo',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'laborClassDesc',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '人员等级',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2SetupLaborClassDesc',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'setupLaborClassDesc',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '调机时人员等级',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table2NoteText',
          tableId: '104003Table2',
          tableName: 'Routing工序表',
          columnProp: 'noteText',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '备注',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 150
        },
      ],
      columnRoutingToolList: [
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table3AlternativeNo',
          tableId: '104003Table3',
          tableName: 'Routing工具表',
          columnProp: 'alternativeNo',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '替代编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table3AlternativeDescription',
          tableId: '104003Table3',
          tableName: 'Routing工具表',
          columnProp: 'alternativeDescription',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '替代名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table3OperationNo',
          tableId: '104003Table3',
          tableName: 'Routing工具表',
          columnProp: 'operationNo',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '工序编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table3OperationName',
          tableId: '104003Table3',
          tableName: 'Routing工具表',
          columnProp: 'operationName',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '工序名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table3ToolId',
          tableId: '104003Table3',
          tableName: 'Routing工具表',
          columnProp: 'toolId',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '工具编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table3ToolDescription',
          tableId: '104003Table3',
          tableName: 'Routing工具表',
          columnProp: 'toolDescription',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '工具名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table3ToolQty',
          tableId: '104003Table3',
          tableName: 'Routing工具表',
          columnProp: 'toolQty',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '工具数量',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 60
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table3Remark',
          tableId: '104003Table3',
          tableName: 'Routing工具表',
          columnProp: 'remark',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '备注',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 150
        },
      ],
      columnRoutingDetailList: [
        {
          columnProp: 'alternativeNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '替代编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
        },
        {
          columnProp: 'alternativeDescription',
          headerAlign: "center",
          align: "center",
          columnLabel: '替代名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
        },
        {
          columnProp: 'status',
          headerAlign: "center",
          align: "center",
          columnLabel: '状态',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
        },
      ],
      workGuidelineColumnList: [
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table4GuidelineSeq',
          tableId: '104003Table4',
          tableName: 'workGuideline表',
          columnProp: 'guidelineSeq',
          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: 104003,
          serialNumber: '104003Table4GuidelineDesc',
          tableId: '104003Table4',
          tableName: 'workGuideline表',
          columnProp: 'guidelineDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '工艺指导名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table4GuidelineText',
          tableId: '104003Table4',
          tableName: 'workGuideline表',
          columnProp: 'guidelineText',
          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: 104003,
          serialNumber: '104003Table4GuidelineType',
          tableId: '104003Table4',
          tableName: 'workGuideline表',
          columnProp: 'guidelineType',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '工艺指导类型',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table4SignOffRequired',
          tableId: '104003Table4',
          tableName: 'workGuideline表',
          columnProp: 'signOffRequired',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '签字',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 150
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table4InspectionSignOffRequired',
          tableId: '104003Table4',
          tableName: 'workGuideline表',
          columnProp: 'inspectionSignOffRequired',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '检验签字',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 150
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table4CreateDate',
          tableId: '104003Table4',
          tableName: 'BOM信息表',
          columnProp: 'createDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '创建时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 130
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table4CreateBy',
          tableId: '104003Table4',
          tableName: 'BOM信息表',
          columnProp: 'createBy',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '创建人',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table4UpdateDate',
          tableId: '104003Table4',
          tableName: 'BOM信息表',
          columnProp: 'updateDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '更新时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 130
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104003,
          serialNumber: '104003Table4UpdateBy',
          tableId: '104003Table4',
          tableName: 'BOM信息表',
          columnProp: 'updateBy',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '更新人',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        }
      ],
      // ======== 必填规则 ========
      rules: {
        partNo: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        partDesc: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        routingType: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        phaseInDate: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        routingRevision: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ]
      },
      detailRules: {
        alternativeNo: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        alternativeDescription: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        status: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ]
      },
      componentRules: {
        operationId: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        operationName: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        operationNo: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ]
      },
      guidelineRules: {
        guidelineSeq: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        guidelineDesc: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        guidelineType: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        signOffRequired: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        inspectionSignOffRequired: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ]
      },
      // ======== 复选数据集 ========
      routingSelections: [],
      workGuidelineSelections: [],
      // ======== 模态框开关控制 ========
      modalFlag: false,
      modalDisableFlag: false,
      partModelFlag: false,
      componentPartModelFlag: false,
      saveDetailModalFlag: false,
      saveDetailModalDisable: false,
      componentSaveModal: false,
      componentDisableFlag: false,
      saveRoutingToolModal: false,
      saveRoutingToolDisableModal: false,
      copyRoutingModelFlag: false,
      copyAlternativeModelFlag: false,
      queryWorkGuidelineModal: false,
      saveWorkGuidelineModal: false,
      workGuidelineDisableModal: false
    }
  },

  mounted () {
    this.$nextTick(() => {
      this.height = window.innerHeight - 180
    })
  },

  created () {
    this.getDataList()
  },

  activated() {
    if (this.$route.params.partNo) {
      this.searchData.partNo = this.$route.params.partNo
    }
    this.getDataList()
  },

  // js
  methods: {
    // ======== 分页相关方法 ========
    /**
     * 每页数
     * @param val
     */
    sizeChangeHandle (val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    /**
     * 当前页
     * @param val
     */
    currentChangeHandle (val) {
      this.pageIndex = val
      this.getDataList()
    },

    // ======== 页签切换相关方法 ========
    /**
     * 明细页签选择替换
     * @param tab
     * @param event
     */
    tabDetailClick (tab, event) {
      // 刷新列表数据
      this.refreshDetailTable()
    },
    /**
     * 子明细页签选择替换
     * @param tab
     * @param event
     */
    tabSubDetailClick (tab, event) {
      // 刷新列表数据
      this.refreshSubDetailTable()
    },
    /**
     * 刷新明细页签的table数据
     */
    refreshDetailTable () {
      if (this.detailTable === 'routing_detail') {

      } else if (this.detailTable === 'routing_tool') {
        this.searchRoutingTools()
      }
    },
    /**
     * 刷新子明细页签的table数据
     */
    refreshSubDetailTable () {
      if (this.subDetailTable === 'routing_sub_detail') {

      }
    },

    // ======== 列表数据操作方法 ========
    /**
     * 未知
     * @returns {boolean}
     */
    selectFlag () {
      return true
    },
    /**
     * 获取数据列表
     */
    getDataList () {
      this.searchData.limit = this.pageSize
      this.searchData.page = this.pageIndex
      this.queryLoading = true
      routingManagementSearch(this.searchData).then(({data}) => {
        if (data.code === 0) {
          this.dataList = data.page.list
          this.pageIndex = data.page.currPage
          this.pageSize = data.page.pageSize
          this.totalPage = data.page.totalCount
          this.$refs.selectDiv.setLengthAll( this.dataList.length)
        }
        this.queryLoading = false
      })
    },
    /**
     * 复选列表信息
     * @param val
     */
    selectionRouting (val) {
      this.routingSelections = val
      this.$refs.selectDiv.setLengthselected(this.routingSelections.length)
    },
    /**
     * 查询 routingTools
     */
    searchRoutingTools () {
      searchRoutingTools(this.modalData).then(({data}) => {
        if (data && data.code === 0) {
          this.routingToolList = data.rows
        } else {
          this.routingToolList = []
        }
      })
    },

    // ======== 新增/编辑模态框 ========
    /**
     * routing新增模态框
     */
    addModal () {
      this.modalData = {
        flag: '1',
        title: 'Routing新增',
        site: this.$store.state.user.site,
        partNo: '',
        partDesc: '',
        routingRevision: '',
        routingType: 'Manufacturing',
        noteText: '',
        phaseInDate: new Date(+ new Date() + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, ''),
        phaseOutDate: '',
        createBy: this.$store.state.user.name,
        printUnit: '',
        printUnitName: '',
        officialFlag: 'N'
      }
      this.detailData = {
        site: this.$store.state.user.site,
        partNo: '',
        routingRevision: '',
        routingType: '',
        alternativeNo: '',
        alternativeDescription: '',
        routTemplateId: '',
        planDate: '',
        fixedLeadTimeDay: '',
        fixedLeadTimeHour: '',
        variableLeadTimeDay: '',
        variableLeadTimeHour: '',
        forStdLotByDay: '',
        forLotByDay: '',
        minLotQty: '',
        detailNoteText: '',
        status: '',
        createBy: this.$store.state.user.name,
        officialFlag: 'N'
      }
      this.detailDataList = []
      this.subDetailList = []
      this.modalDisableFlag = false
      this.modalFlag = true
    },
    /**
     * routing编辑模态框
     */
    async updateModal (row) {
      this.modalData = {
        flag: '2',
        site: row.site,
        partNo: row.partNo,
        partDesc: row.partDesc,
        routingRevision: row.routingRevision,
        routingType: row.routingType,
        noteText: row.noteText,
        phaseInDate: row.phaseInDate,
        phaseOutDate: row.phaseOutDate,
        engRevision: row.engRevision,
        typeFlag: row.typeFlag,
        netWeight: row.netWeight,
        updateBy: this.$store.state.user.name,
        printUnit: row.printUnit,
        printUnitName: row.printUnitName,
        officialFlag: row.officialFlag
      }
      // 查routing明细
      queryRoutingDetail(this.modalData).then(({data}) => {
        if (data && data.code === 0) {
          this.detailDataList = data.rows.detailList
          this.subDetailList = data.rows.componentList
          this.detailData = data.rows.detailData
          this.modalDisableFlag = true
          this.modalFlag = true
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },
    /**
     * 新增替代模态框
     */
    saveRoutingDetail () {
      if (this.modalData.partNo === '' || this.modalData.partNo == null) {
        this.$message.warning('请先选择Routing物料！')
        return
      }
      if (this.modalData.routingRevision === '' || this.modalData.routingRevision == null) {
        this.$message.warning('请先填写Routing版本号！')
        return
      }
      if (this.modalData.routingType === '' || this.modalData.routingType == null) {
        this.$message.warning('请先选择工艺类型！')
        return
      }
      this.saveDetailData = {
        flag: '1',
        site: this.$store.state.user.site,
        partNo: this.modalData.partNo,
        routingRevision: this.modalData.routingRevision,
        routingType: this.modalData.routingType,
        alternativeNo: '',
        alternativeDescription: '',
        routTemplateId: '',
        planDate: '',
        fixedLeadTimeDay: '',
        fixedLeadTimeHour: '',
        variableLeadTimeDay: '',
        variableLeadTimeHour: '',
        forStdLotByDay: '',
        forLotByDay: '',
        minLotQty: '',
        detailNoteText: '',
        status: 'Tentative',
        createDate: '',
        createBy: this.$store.state.user.name,
        officialFlag: 'N'
      }
      // 查询routing主信息
      queryRoutingHeader(this.modalData).then(({data}) => {
        if (data && data.code === 0) {
          if (data.rows.length > 0) {
            this.saveDetailModalFlag = true
            this.saveDetailModalDisable = false
          } else {
            this.$message.warning('请先保存Routing主记录！')
          }
        } else {
          this.$alert(data.msg, '提示', {
            confirmButtonText: '确定'
          })
        }
      })
    },
    /**
     * 替代编辑模态框
     */
    updateRoutingDetail () {
      if (this.modalData.partNo === '' || this.modalData.partNo == null) {
        this.$message.warning('请先选择Routing物料！')
        return
      }
      if (this.modalData.routingRevision === '' || this.modalData.routingRevision == null) {
        this.$message.warning('请先填写Routing版本号！')
        return
      }
      if (this.modalData.routingType === '' || this.modalData.routingType == null) {
        this.$message.warning('请先选择工艺类型！')
        return
      }
      this.saveDetailData = {
        flag: '2',
        site: this.detailData.site,
        partNo: this.detailData.partNo,
        routingRevision: this.detailData.routingRevision,
        routingType: this.detailData.routingType,
        alternativeNo: this.detailData.alternativeNo,
        alternativeDescription: this.detailData.alternativeDescription,
        routTemplateId: this.detailData.routTemplateId,
        planDate: this.detailData.planDate,
        fixedLeadTimeDay: this.detailData.fixedLeadTimeDay,
        fixedLeadTimeHour: this.detailData.fixedLeadTimeHour,
        variableLeadTimeDay: this.detailData.variableLeadTimeDay,
        variableLeadTimeHour: this.detailData.variableLeadTimeHour,
        forStdLotByDay: this.detailData.forStdLotByDay,
        forLotByDay: this.detailData.forLotByDay,
        minLotQty: this.detailData.minLotQty,
        detailNoteText: this.detailData.detailNoteText,
        status: this.detailData.status,
        updateBy: this.$store.state.user.name,
        officialFlag: this.detailData.officialFlag
      }
      // 查询routing主信息
      queryRoutingHeader(this.modalData).then(({data}) => {
        if (data && data.code === 0) {
          if (data.rows.length > 0) {
            this.saveDetailModalFlag = true
            this.saveDetailModalDisable = true
          } else {
            this.$message.warning('请先保存Routing主记录！')
          }
        } else {
          this.$alert(data.msg, '提示', {
            confirmButtonText: '确定'
          })
        }
      })
    },
    /**
     * 新增子明细模态框
     */
    saveComponentModal () {
      if (this.detailData.alternativeNo === '' || this.detailData.alternativeNo == null) {
        this.$message.warning('请先选择替代！')
        return
      }
      if (this.detailData.status != null && this.detailData.status !== '' && this.detailData.status !== 'Tentative') {
        this.$message.warning('不可编辑的替代状态!')
        return
      }
      this.componentData = {
        flag: '1',
        site: this.$store.state.user.site,
        partNo: this.modalData.partNo,
        routingRevision: this.modalData.routingRevision,
        routingType: this.modalData.routingType,
        alternativeNo: this.detailData.alternativeNo,
        operationId: '',
        operationNo: '',
        operationName: '',
        efficiencyFactor: 100,
        machRunFactor: '',
        machSetupTime: '',
        runTimeCode: '',
        laborRunFactor: 100,
        laborSetupTime: '',
        crewSize: 1,
        setupCrewSize: 1,
        outsideOpItem: '',
        machineNo: '',
        workCenterNo: '',
        workCenterDesc: '',
        laborClassNo: '',
        laborClassDesc: '',
        setupLaborClassNo: '',
        setupLaborClassDesc: '',
        overlap: '',
        noteText: '',
        createBy: this.$store.state.user.name,
      }
      this.componentDisableFlag = false
      this.componentSaveModal = true
    },
    /**
     * 编辑模态框
     */
    updateComponentModal (row) {
      if (this.detailData.status != null && this.detailData.status !== '' && this.detailData.status !== 'Tentative') {
        this.$message.warning('不可编辑的替代状态!')
        return
      }
      this.componentData = {
        flag: '2',
        site: row.site,
        partNo: row.partNo,
        routingRevision: row.routingRevision,
        routingType: row.routingType,
        alternativeNo: row.alternativeNo,
        operationId: row.operationId,
        operationNo: row.operationNo,
        operationName: row.operationName,
        efficiencyFactor: row.efficiencyFactor,
        machRunFactor: row.machRunFactor,
        machSetupTime: row.machSetupTime,
        runTimeCode: row.runTimeCode,
        laborRunFactor: row.laborRunFactor,
        laborSetupTime: row.laborSetupTime,
        crewSize: row.crewSize,
        setupCrewSize: row.setupCrewSize,
        outsideOpItem: row.outsideOpItem,
        machineNo: row.machineNo,
        workCenterNo: row.workCenterNo,
        workCenterDesc: row.workCenterDesc,
        laborClassNo: row.laborClassNo,
        laborClassDesc: row.laborClassDesc,
        setupLaborClassNo: row.setupLaborClassNo,
        setupLaborClassDesc: row.setupLaborClassDesc,
        overlap: row.overlap,
        noteText: row.noteText,
        updateBy: this.$store.state.user.name,
      }
      this.componentDisableFlag = true
      this.componentSaveModal = true
    },
    /**
     * routingTool 新增模态框
     */
    saveRoutingTool () {
      this.routingToolData = {
        flag: '1',
        site: this.$store.state.user.site,
        partNo: this.modalData.partNo,
        partDesc: this.modalData.partDesc,
        routingRevision: this.modalData.routingRevision,
        routingType: this.modalData.routingType,
        alternativeNo: '',
        alternativeDescription: '',
        operationId: '',
        operationNo: '',
        operationName: '',
        toolId: '',
        toolDescription: '',
        toolQty: '',
        remark: '',
        createBy: this.$store.state.user.name
      }
      this.queryAlternativeList()
      this.saveRoutingToolModal = true
      this.saveRoutingToolDisableModal = false
    },
    /**
     * routingTool 编辑模态框
     */
    updateToolModal (row) {
      this.routingToolData = {
        flag: '2',
        site: row.site,
        partNo: row.partNo,
        partDesc: row.partDesc,
        routingRevision: row.routingRevision,
        routingType: row.routingType,
        alternativeNo: row.alternativeNo,
        alternativeDescription: row.alternativeDescription,
        operationId: row.operationId,
        operationNo: row.operationNo,
        operationName: row.operationName,
        toolId: row.toolId,
        toolDescription: row.toolDescription,
        toolQty: row.toolQty,
        remark: row.remark,
        updateBy: this.$store.state.user.name
      }
      this.queryAlternativeList()
      this.saveRoutingToolModal = true
      this.saveRoutingToolDisableModal = true
    },

    // ======== 新增/编辑/删除方法 ========
    /**
     * routing新增/编辑
     */
    saveData () {
      if (this.modalData.partNo === '' || this.modalData.partNo == null) {
        this.$message.warning('请选择物料编码！')
        return
      }
      if (this.modalData.partDesc === '' || this.modalData.partDesc == null) {
        this.$message.warning('请选择物料名称！')
        return
      }
      if (this.modalData.routingType === '' || this.modalData.routingType == null) {
        this.$message.warning('请选择制造类型！')
        return
      }
      if (this.modalData.phaseInDate === '' || this.modalData.phaseInDate == null) {
        this.$message.warning('请选择生效时间！')
        return
      }
      if (this.modalData.routingRevision === '' || this.modalData.routingRevision == null) {
        this.$message.warning('请填写Routing版本号！')
        return
      }
      if (this.detailData.alternativeNo === '' || this.detailData.alternativeNo == null) {
        this.$message.warning('请选择替代！')
        return
      }
      if (this.detailData.status === '' || this.detailData.status == null) {
        this.$message.warning('请选择替代状态！')
        return
      }
      let tempData = {
        site: this.$store.state.user.site,
        partNo: this.modalData.partNo,
        partDesc: this.modalData.partDesc,
        routingRevision: this.modalData.routingRevision,
        routingType: this.modalData.routingType,
        noteText: this.modalData.noteText,
        phaseInDate: this.modalData.phaseInDate,
        phaseOutDate: this.modalData.phaseOutDate,
        alternativeNo: this.detailData.alternativeNo,
        alternativeDescription: this.detailData.alternativeDescription,
        detailNoteText: this.detailData.detailNoteText,
        status: this.detailData.status,
        createBy: this.$store.state.user.name,
        updateBy: this.$store.state.user.name,
        informationList: this.subDetailList
      }
      if (this.modalData.flag === '1') {
        this.saveAllLoading = true
        routingManagementSave(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.getDataList()
            this.modalFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
          this.saveAllLoading = false
        })
      } else {
        this.saveAllLoading = true
        routingManagementEdit(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.getDataList()
            this.modalFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
          this.saveAllLoading = false
        })
      }
    },
    /**
     * 新增编辑模态框关闭
     */
    closeModal () {
      this.getDataList()
      this.modalFlag = false
    },
    /**
     * 新增编辑模态框关闭
     */
    closeModalX (done) {
      this.getDataList()
      done()
    },
    /**
     * routing删除
     */
    delModal () {
      if(this.routingSelections.length === 0){
        this.$message.warning('请勾选要删除的Routing！')
        return
      }
      this.$confirm(`是否删除这 `+ this.routingSelections.length +` 条Routing?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let tempData = {
          informationList: this.routingSelections
        }
        routingManagementDelete(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.getDataList()
            this.routingSelections = []
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      }).catch(() => {
      })
    },
    /**
     * 查询物料
     */
    queryPartList () {
      queryPartList(this.partData).then(({data}) => {
        if (data && data.code === 0) {
          this.partList = data.rows
          this.partModelFlag = true
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },
    /**
     * 双击选中物料
     * @param row
     */
    getRowData (row) {
      this.modalData.partNo = row.partNo
      this.modalData.partDesc = row.partDesc
      this.modalData.printUnit = row.printUnit
      this.modalData.printUnitName = row.printUnitName
      // 获取物料的routing版本号
      getRottingRevision(this.modalData).then(({data}) => {
        if (data && data.code === 0) {
          this.modalData.routingRevision = data.routingRevision
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
        this.partModelFlag = false
      })
    },
    /**
     * 工艺类型改变
     */
    routingTypeChange () {
      // 获取物料的routing版本号
      getRottingRevision(this.modalData).then(({data}) => {
        if (data && data.code === 0) {
          this.modalData.routingRevision = data.routingRevision
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },
    /**
     * 选中工序
     * @param row
     */
    getComponentRowData (row) {
      this.routingToolData.operationId = row.operationId
      this.routingToolData.operationNo = row.operationNo
      this.routingToolData.operationName = row.operationName
      this.componentPartModelFlag = false
    },
    /**
     * 工序列表
     */
    queryOperationList () {
      if (this.routingToolData.alternativeNo === '' || this.routingToolData.alternativeNo == null) {
        this.$message.warning('请先选择替代！')
        return
      }
      this.operationData.site = this.routingToolData.site
      this.operationData.partNo = this.routingToolData.partNo
      this.operationData.routingRevision = this.routingToolData.routingRevision
      this.operationData.routingType = this.routingToolData.routingType
      this.operationData.alternativeNo = this.routingToolData.alternativeNo
      // 查询所有工序
      queryOperationListByAlternative(this.operationData).then(({data}) => {
        if (data && data.code === 0) {
          this.operationList = data.rows
          this.componentPartModelFlag = true
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },
    /**
     * 替代列表
     */
    queryAlternativeList () {
      // 查询所有替代
      queryAlternativeListByPartNo(this.modalData).then(({data}) => {
        if (data && data.code === 0) {
          this.alternativeList = data.rows
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },
    /**
     * 表格的新增
     * @param row
     * @param rowIndex
     */
    rowClassName({ row, rowIndex }) {
      row.xh = rowIndex + 1
    },
    /**
     * 单选框选中数据
     * @param selection
     */
    componentSelectionChange(selection) {
      this.checkedDetail = selection
    },
    toolSelectionChange (selection) {
      this.checkedTool = selection
    },
    /**
     * 删除子物料
     */
    deleteComponentPart () {
      if (this.detailData.status != null && this.detailData.status !== '' && this.detailData.status !== 'Tentative') {
        this.$message.warning('不可编辑的替代状态!')
        return
      }
      if (this.checkedDetail.length === 0) {
        this.$message.warning('请选择要删除子物料！')
        return
      } else {
        this.$confirm("请是否确认删除该子明细记录?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          let tempData = {
            informationList: this.checkedDetail
          }
          deleteRoutingComponent(tempData).then(({data}) => {
            if (data && data.code === 0) {
              this.subDetailList = data.rows
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }).catch(() => {
        })
      }
    },
    /**
     * 子物料
     * @param row
     */
    componentClickRow (row) {
      this.$refs.componentTable.toggleRowSelection(row)
    },
    toolClickRow (row) {
      this.$refs.toolTable.toggleRowSelection(row)
    },
    /**
     * 新增子明细方法
     */
    componentDataSave () {
      if (this.componentData.partNo === '' || this.componentData.partNo == null) {
        this.$message.warning('请选择主记录物料编码！')
        return
      }
      if (this.componentData.routingType === '' || this.componentData.routingType == null) {
        this.$message.warning('请选择主记录工艺类型！')
        return
      }
      if (this.componentData.routingRevision === '' || this.componentData.routingRevision == null) {
        this.$message.warning('请填写主记录Routing版本号！')
        return
      }
      if (this.componentData.operationNo === '' || this.componentData.operationNo == null) {
        this.$message.warning('请填写工序编码！')
        return
      }
      if (this.componentData.operationName === '' || this.componentData.operationName == null) {
        this.$message.warning('请选择工序名称！')
        return
      }
      if (this.componentData.flag === '1') {
        this.saveComponentLoading = true
        saveRoutingComponent(this.componentData).then(({data}) => {
          if (data && data.code === 0) {
            this.subDetailList = data.rows
            this.componentSaveModal = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
          this.saveComponentLoading = false
        })
      } else if (this.componentData.flag === '2') {
        this.saveComponentLoading = true
        updateRoutingComponent(this.componentData).then(({data}) => {
          if (data && data.code === 0) {
            this.subDetailList = data.rows
            this.componentSaveModal = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
          this.saveComponentLoading = false
        })
      }
    },
    /**
     * 回车事件
     */
    focusNextInput (index, type) {
      let aaa = ''
      if (this.subDetailList.length - 1 === index) {
        aaa = `${type}0`
      } else {
        aaa = `${type}${index + 1}`
      }
      this.$nextTick(() => {
        this.$refs[aaa].focus()
      })
    },
    /**
     * 保存主表信息
     */
    saveRoutingHeader () {
      if (this.modalData.partNo === '' || this.modalData.partNo == null) {
        this.$message.warning('请先选择Routing物料！')
        return
      }
      if (this.modalData.routingRevision === '' || this.modalData.routingRevision == null) {
        this.$message.warning('请先填写Routing版本号！')
        return
      }
      if (this.modalData.routingType === '' || this.modalData.routingType == null) {
        this.$message.warning('请先选择制造类型！')
        return
      }
      if (this.modalData.phaseOutDate != null && this.modalData.phaseOutDate !== '' && (this.modalData.phaseInDate > this.modalData.phaseOutDate)) {
        this.$message.warning('失效日期不能小于生效日期！')
        return
      }
      this.saveHeaderLoading = true
      // 新增主表信息
      saveRoutingHeader(this.modalData).then(({data}) => {
        if (data && data.code === 0) {
          this.modalData = {
            flag: '1',
            title: 'routing新增',
            site: data.rows.modalData.site,
            partNo: data.rows.modalData.partNo,
            partDesc: data.rows.modalData.partDesc,
            routingRevision: data.rows.modalData.routingRevision,
            routingType: data.rows.modalData.routingType,
            noteText: data.rows.modalData.noteText,
            phaseInDate: data.rows.modalData.phaseInDate,
            phaseOutDate: data.rows.modalData.phaseOutDate,
            engRevision: data.rows.modalData.engRevision,
            typeFlag: data.rows.modalData.typeFlag,
            netWeight: data.rows.modalData.netWeight,
            officialFlag: data.rows.modalData.officialFlag
          }
          this.detailDataList = data.rows.detailDataList
          this.detailData = data.rows.detailData
          this.subDetailList = []
          this.modalDisableFlag = true
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
        this.saveHeaderLoading = false
      })
    },

    /**
     * 复制Routing的模态框
     */
    copyRoutingRevision () {
      this.copyRoutingData = {
        site: this.modalData.site,
        partNo: this.modalData.partNo,
        routingRevision: this.modalData.routingRevision + 1,
        routingType: this.modalData.routingType,
        phaseInDate: this.dayjs(new Date()).format('YYYY-MM-DD'),
        phaseOutDate: '',
        previousVersion: {},
        createBy: this.$store.state.user.name,
        officialFlag: 'N'
      }
      this.copyRoutingModelFlag = true
    },
    /**
     * 复制Routing的方法
     */
    copyRouting () {
      if (this.copyRoutingData.partNo === '' || this.copyRoutingData.partNo == null) {
        this.$message.warning('请选择Routing物料！')
        return
      }
      if (this.copyRoutingData.routingRevision === '' || this.copyRoutingData.routingRevision == null) {
        this.$message.warning('请填写Routing版本号！')
        return
      }
      if (this.copyRoutingData.routingType === '' || this.copyRoutingData.routingType == null) {
        this.$message.warning('请选择工艺类型！')
        return
      }
      this.copyRoutingData.previousVersion = this.modalData
      // 新增主表信息
      copyRouting(this.copyRoutingData).then(({data}) => {
        if (data && data.code === 0) {
          this.copyRoutingModelFlag = false
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },
    /**
     * 复制alternative的模态框
     */
    copyRoutingAlternative () {
      this.copyAlternativeData = {
        site: this.detailData.site,
        partNo: this.detailData.partNo,
        routingRevision: this.detailData.routingRevision,
        routingType: this.detailData.routingType,
        alternativeNo: this.detailData.alternativeNo,
        alternativeDescription: this.detailData.alternativeDescription,
        routTemplateId: '',
        planDate: '',
        fixedLeadTimeDay: '',
        fixedLeadTimeHour: '',
        variableLeadTimeDay: '',
        variableLeadTimeHour: '',
        forStdLotByDay: '',
        forLotByDay: '',
        minLotQty: '',
        detailNoteText: this.detailData.detailNoteText,
        status: 'Tentative',
        officialFlag: 'N',
        previousVersion: {},
        createBy: this.$store.state.user.name
      }
      this.copyAlternativeModelFlag = true
    },

    /**
     * 工艺指导模态框
     */
    workGuidelineModal (row) {
      this.workGuidelineData = {
        site: this.modalData.site,
        partNo: this.modalData.partNo,
        partDesc: this.modalData.partDesc,
        routingRevision: this.modalData.routingRevision,
        routingType: this.modalData.routingType,
        alternativeNo: this.detailData.alternativeNo,
        alternativeDescription: this.detailData.alternativeDescription,
        operationId: row.operationId,
        operationNo: row.operationNo,
        operationName: row.operationName
      }
      this.getRoutingWorkGuideline()
      this.queryWorkGuidelineModal = true
    },
    /**
     * 获取 workGuideline
     */
    getRoutingWorkGuideline () {
      getRoutingWorkGuideline(this.workGuidelineData).then(({data}) => {
        if (data && data.code === 0) {
          this.workGuidelineList = data.rows
        } else {
          this.workGuidelineList = []
        }
      })
    },
    /**
     * 复选列表信息
     * @param val
     */
    selectionWorkGuideline (val) {
      this.workGuidelineSelections = val
    },
    /**
     * workGuideline 新增模态框
     */
    saveWorkGuideline () {
      this.saveWorkGuidelineData = {
        flag: '1',
        id: '',
        site: this.workGuidelineData.site,
        partNo: this.workGuidelineData.partNo,
        partDesc: this.workGuidelineData.partDesc,
        routingRevision: this.workGuidelineData.routingRevision,
        routingType: this.workGuidelineData.routingType,
        alternativeNo: this.workGuidelineData.alternativeNo,
        alternativeDescription: this.workGuidelineData.alternativeDescription,
        operationId: this.workGuidelineData.operationId,
        operationNo: this.workGuidelineData.operationNo,
        operationName: this.workGuidelineData.operationName,
        guidelineSeq: '',
        guidelineDesc: '',
        guidelineText: '',
        guidelineType: 'Instruction',
        signOffRequired: 'Not Required',
        inspectionSignOffRequired: 'Not Required',
        createBy: this.$store.state.user.name,
        updateBy: ''
      }
      // 查询seq
      getGuidelineSeq(this.workGuidelineData).then(({data}) => {
        if (data && data.code === 0) {
          this.saveWorkGuidelineData.guidelineSeq = data.guidelineSeq
        }
      })
      // 开启模态框
      this.saveWorkGuidelineModal = true
      this.workGuidelineDisableModal = false
    },
    /**
     * workGuideline 编辑模态框
     */
    updateWorkGuidelineModal (row) {
      this.saveWorkGuidelineData = {
        flag: '2',
        id: row.id,
        site: row.site,
        partNo: row.partNo,
        partDesc: row.partDesc,
        routingRevision: row.routingRevision,
        routingType: row.routingType,
        alternativeNo: row.alternativeNo,
        alternativeDescription: row.alternativeDescription,
        operationId: row.operationId,
        operationNo: row.operationNo,
        operationName: row.operationName,
        guidelineSeq: row.guidelineSeq,
        guidelineDesc: row.guidelineDesc,
        guidelineText: row.guidelineText,
        guidelineType: row.guidelineType,
        signOffRequired: row.signOffRequired,
        inspectionSignOffRequired: row.inspectionSignOffRequired,
        createBy: '',
        updateBy: this.$store.state.user.name
      }
      // 开启模态框
      this.saveWorkGuidelineModal = true
      this.workGuidelineDisableModal = true
    },
    /**
     * workGuideline 新增方法
     */
    workGuidelineCommit () {
      if (this.saveWorkGuidelineData.guidelineSeq === '' || this.saveWorkGuidelineData.guidelineSeq == null) {
        this.$message.warning('请输入序号！')
        return
      }
      if (this.saveWorkGuidelineData.guidelineDesc === '' || this.saveWorkGuidelineData.guidelineDesc == null) {
        this.$message.warning('请输入工艺指导名称！')
        return
      }
      if (this.saveWorkGuidelineData.guidelineType === '' || this.saveWorkGuidelineData.guidelineType == null) {
        this.$message.warning('请选择工艺指导类型！')
        return
      }
      if (this.saveWorkGuidelineData.signOffRequired === '' || this.saveWorkGuidelineData.signOffRequired == null) {
        this.$message.warning('请选择签字！')
        return
      }
      if (this.saveWorkGuidelineData.inspectionSignOffRequired === '' || this.saveWorkGuidelineData.inspectionSignOffRequired == null) {
        this.$message.warning('请选择检验签字！')
        return
      }
      if (this.saveWorkGuidelineData.flag === '1') {
        workGuidelineSave(this.saveWorkGuidelineData).then(({data}) => {
          if (data && data.code === 0) {
            this.getRoutingWorkGuideline()
            this.saveWorkGuidelineModal = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      } else {
        workGuidelineEdit(this.saveWorkGuidelineData).then(({data}) => {
          if (data && data.code === 0) {
            this.getRoutingWorkGuideline()
            this.saveWorkGuidelineModal = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      }
    },
    /**
     * 删除 workGuideline
     */
    deleteModal () {
      if(this.workGuidelineSelections.length === 0){
        this.$message.warning('请勾选要删除的工艺指导！')
        return
      }
      this.$confirm(`是否删除这 `+ this.workGuidelineSelections.length +` 条工艺指导?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let tempData = {
          informationList: this.workGuidelineSelections
        }
        deleteWorkGuideline(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.getRoutingWorkGuideline()
            this.workGuidelineSelections = []
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      }).catch(() => {
      })
    },


    /**
     * 复制alternative的方法
     */
    copyAlternative () {
      if (this.copyAlternativeData.partNo === '' || this.copyAlternativeData.partNo == null) {
        this.$message.warning('请选择Routing物料！')
        return
      }
      if (this.copyAlternativeData.routingRevision === '' || this.copyAlternativeData.routingRevision == null) {
        this.$message.warning('请填写Routing版本号！')
        return
      }
      if (this.copyAlternativeData.routingType === '' || this.copyAlternativeData.routingType == null) {
        this.$message.warning('请选择工艺类型！')
        return
      }
      if (this.copyAlternativeData.alternativeNo === '' || this.copyAlternativeData.alternativeNo == null) {
        this.$message.warning('请填写替代编码！')
        return
      }
      if (this.copyAlternativeData.alternativeDescription === '' || this.copyAlternativeData.alternativeDescription == null) {
        this.$message.warning('请填写替代名称！')
        return
      }
      this.copyAlternativeData.previousVersion = this.detailData
      copyAlternative(this.copyAlternativeData).then(({data}) => {
        if (data && data.code === 0) {
          this.detailDataList = data.rows.detailDataList
          this.copyAlternativeModelFlag = false
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    /**
     * 新增替代方法
     */
    detailDataSave () {
      if (this.saveDetailData.partNo === '' || this.saveDetailData.partNo == null) {
        this.$message.warning('请先选择Routing物料！')
        return
      }
      if (this.saveDetailData.routingRevision === '' || this.saveDetailData.routingRevision == null) {
        this.$message.warning('请先填写Routing版本号！')
        return
      }
      if (this.saveDetailData.routingType === '' || this.saveDetailData.routingType == null) {
        this.$message.warning('请先选择工艺类型！')
        return
      }
      if (this.saveDetailData.alternativeNo === '' || this.saveDetailData.alternativeNo == null) {
        this.$message.warning('请填写替代编码！')
        return
      }
      if (this.saveDetailData.alternativeDescription === '' || this.saveDetailData.alternativeDescription == null) {
        this.$message.warning('请填写替代名称！')
        return
      }
      if (this.saveDetailData.status === '' || this.saveDetailData.status == null) {
        this.$message.warning('请选择替代状态！')
        return
      }
      this.saveDetailLoading = true
      if (this.saveDetailData.flag === '1') {
        routingDetailSave(this.saveDetailData).then(({data}) => {
          if (data && data.code === 0) {
            this.detailDataList = data.rows
            this.detailData = this.saveDetailData
            this.subDetailList = []
            this.saveDetailModalFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
          this.saveDetailLoading = false
        })
      } else {
        routingDetailUpdate(this.saveDetailData).then(({data}) => {
          if (data && data.code === 0) {
            this.detailDataList = data.rows.detailDataList
            this.detailData = data.rows.detailData
            this.subDetailList = data.rows.subDetailList
            this.saveDetailModalFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
          this.saveDetailLoading = false
        })
      }

    },
    /**
     * 删除替代
     */
    deleteRoutingDetail () {
      if (this.detailData.alternativeNo === '' || this.detailData.alternativeNo == null) {
        this.$message.warning('请选择要删除的替代编码！')
        return
      }
      if (this.detailData.alternativeNo === '*') {
        this.$message.warning('当前为默认替代，不可以删除！')
        return
      }
      this.$confirm(`是否删除这项替代?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        routingDetailDelete(this.detailData).then(({data}) => {
          if (data && data.code === 0) {
            this.detailData = data.rows.detailData
            this.detailDataList = data.rows.detailDataList
            this.subDetailList = data.rows.subDetailList
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      }).catch(() => {
      })
    },
    /**
     * 修改替代状态为 Buildable
     */
    updateStatusToBuildable () {
      this.$confirm(`是否修改状态为Buildable?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        updateAlternativeStatus(this.detailData).then(({data}) => {
          if (data && data.code === 0) {
            this.detailDataList = data.rows.detailDataList
            this.detailData = data.rows.detailData
            this.subDetailList = data.rows.subDetailList
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {confirmButtonText: '确定'})
            // 刷新替代和子明细
            this.alternativeChange()
          }
        })
      }).catch(() => {
      })
    },
    /**
     * 修改替代状态为 Obsolete
     */
    updateStatusToObsolete () {
      this.$confirm(`是否修改状态为Obsolete?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        updateAlternativeStatus(this.detailData).then(({data}) => {
          if (data && data.code === 0) {
            this.detailDataList = data.rows.detailDataList
            this.detailData = data.rows.detailData
            this.subDetailList = data.rows.subDetailList
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {confirmButtonText: '确定'})
            // 刷新替代和子明细
            this.alternativeChange()
          }
        })
      }).catch(() => {
      })
    },
    /**
     * 替代改变事件
     */
    alternativeChange () {
      queryRoutingComponent(this.detailData).then(({data}) => {
        if (data && data.code === 0) {
          this.detailDataList = data.rows.detailDataList
          this.detailData = data.rows.detailData
          this.subDetailList = data.rows.subDetailList
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    // 临时Routing转为正式Routing
    toBecomeOfficialRouting () {
      toBecomeOfficialRouting(this.detailData).then(({data}) => {
        if (data && data.code === 0) {
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    /**
     * 新增 routingTool
     */
    routingToolSave () {
      if (this.routingToolData.alternativeNo === '' || this.routingToolData.alternativeNo == null) {
        this.$message.warning('请选择替代！')
        return
      }
      if (this.routingToolData.operationNo === '' || this.routingToolData.operationNo == null) {
        this.$message.warning('请选择工序！')
        return
      }
      if (this.routingToolData.toolId === '' || this.routingToolData.toolId == null) {
        this.$message.warning('请选择工具！')
        return
      }
      if (this.routingToolData.toolQty === '' || this.routingToolData.toolQty == null) {
        this.$message.warning('请输入工具数量！')
        return
      }
      if (this.routingToolData.flag === '1') {
        routingToolSave(this.routingToolData).then(({data}) => {
          if (data && data.code === 0) {
            this.searchRoutingTools()
            this.saveRoutingToolModal = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      } else {
        routingToolEdit(this.routingToolData).then(({data}) => {
          if (data && data.code === 0) {
            this.searchRoutingTools()
            this.saveRoutingToolModal = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      }
    },
    /**
     * 删除 routingTool
     */
    deleteRoutingTool () {
      if (this.checkedTool.length === 0) {
        this.$message.warning('请选择要删除的工具！')
        return
      } else {
        this.$confirm("请是否确认删除该工具?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          let tempData = {
            informationList: this.checkedTool
          }
          deleteRoutingTool(tempData).then(({data}) => {
            if (data && data.code === 0) {
              this.searchRoutingTools()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }).catch(() => {
        })
      }
    },

    // ======= 正则校验 =======
    handleInput (value, type) {
      // 大于等于0，且只能输入4位小数
      let val = value.replace(/^\D*([0-9]\d*\.?\d{0,4})?.*$/,'$1')
      if (val == null || val == undefined || val == '') {
        val = 0
      }
      if (type === 1) {
        this.modalData.machRunFactor = val
      } else if (type === 2) {
        this.detailData.machSetupTime = val
      } else if (type === 3) {
        this.saveDetailData.setupCrewSize = val
      } else if (type === 4) {
        this.componentData.crewSize = val
      } else if (type === 5) {
        this.componentData.laborSetupTime = val
      }
    },
    handleInputB (value, type) {
      const reg = /^(([1-9]?\d{0,1}(\.\d{1,2})?)|100|100\.(0){1,2})$/
      if (type === 1) {
        if (reg.test(value) === true) {
          this.componentData.efficiencyFactor = value
        } else if (value > 100) {
          this.componentData.efficiencyFactor = 100
        } else {
          this.componentData.efficiencyFactor = 0
        }
      } else if (type === 2) {
        if (reg.test(value) === true) {
          this.componentData.laborRunFactor = value
        } else if (value > 100) {
          this.componentData.laborRunFactor = 100
        } else {
          this.componentData.laborRunFactor = 0
        }
      }

    },

    // ======== chooseList相关方法 ========
    /**
     * 获取基础数据列表S
     * @param val
     * @param type
     */
    getBaseList (val, type) {
      this.tagNo = val
      this.tagNo1 = type
      this.$nextTick(() => {
        let strVal = ''
        if (val === 118) {
          if(type === 1) {
            strVal = this.componentData.laborClassNo
          } else if (type === 2) {
            strVal = this.componentData.setupLaborClassNo
          }
        }
        if (val === 119) {
          strVal = this.componentData.workCenterNo
        }
        if (val === 122) {
          strVal = this.routingToolData.toolId
        }
        this.$refs.baseList.init(val, strVal)
      })
    },
    /**
     * 列表方法的回调
     * @param val
     */
    getBaseData (val) {
      if (this.tagNo === 118) {
        if (this.tagNo1 === 1) {
          this.componentData.laborClassNo = val.level_id
          this.componentData.laborClassDesc = val.level_desc
        } else if (this.tagNo1 === 2) {
          this.componentData.setupLaborClassNo = val.level_id
          this.componentData.setupLaborClassDesc = val.level_desc
        }
      }
      if (this.tagNo === 119) {
        this.componentData.workCenterNo = val.work_center_no
        this.componentData.workCenterDesc = val.work_center_desc
      }
      if (this.tagNo === 122) {
        this.routingToolData.toolId = val.tool_id
        this.routingToolData.toolDescription = val.tool_description
      }
    },

    // ======== 导出相关方法 ========
    /**
     * 导出excel
     */
    async createExportData () {
      this.searchData.limit = -1
      this.searchData.page = 1
      await routingManagementSearch(this.searchData).then(({data}) => {
        this.resultList = data.page.list
      })
      return this.resultList
    },

    startDownload () {},

    finishDownload () {},

    fields () {
      let json = '{'
      this.columnList.forEach((item, index) => {
        if (index == this.columnList.length - 1) {
          json += '"' + item.columnLabel + '"' + ':' + '"' + item.columnProp + '"'
        } else {
          json += '"' + item.columnLabel + '"' + ':' + '"' + item.columnProp + '"' + ','
        }
      })
      json += '}'
      let s = eval('(' + json + ')')
      return s
    },

    // 切换到Bom
    checkOutToBom (partNo) {
      if (this.$router.resolve('part-bomManagement').resolved.name === '404') {
        this.$alert('权限不足,访问失败', '警告', {confirmButtonText: '确定',})
      } else {
        this.$router.push({name:"part-bomManagement",params:{partNo: partNo}})
      }
    }
  }
}
</script>

<style scoped lang="scss">
/deep/ .customer-tab .el-tabs__content {
  padding: 0px !important;
}
/deep/ .detail-tab .el-tabs__content {
  height: 165px;
  padding: 15px 0px 0px 0px;
}
/deep/ .sub_detail-tab .el-tabs__content {
  height: 280px;
  padding: 0px;
}
.numInput /deep/ .el-input__inner{
  text-align: right;
}
/deep/  .inlineNumber input::-webkit-outer-spin-button,
/deep/  .inlineNumber input::-webkit-inner-spin-button {
  -webkit-appearance: none;

}
/deep/  .inlineNumber input[type="number"]{
  -moz-appearance: textfield;
  padding-right: 5px !important;
}
</style>










