<template>
  <div class="mod-config">
    <!-- 查询条件 -->
    <el-form :inline="true" label-position="top" :model="searchData" @keyup.enter.native="getDataList()">
      <el-form-item :label="'PLM物料编码'">
        <el-input v-model="searchData.plmPartNo" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'IFS物料编码'">
        <el-input v-model="searchData.ifsPartNo" 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-select v-model="searchData.bomType" clearable style="width: 120px">
          <el-option label="Manufacturing" value="Manufacturing"></el-option>
          <el-option label="Repair" value="Repair"></el-option>
          <el-option label="Purchase" value="Purchase"></el-option>
          <el-option label="Prototype" value="Prototype"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'Recipe版本号'">
        <el-input v-model="searchData.engChgLevel" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="' '">
        <el-button :loading="queryLoading" @click="getDataList()">查询</el-button>
        <el-button v-if="isAuth('104002003:save')" type="primary" @click="addModal()">新增</el-button>
        <el-button v-if="isAuth('104002003:delete')" 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>

    <!-- recipe列表 -->
    <el-table
      :height="height"
      :data="dataList"
      border
      @selection-change="selectionRecipe"
      style="width: 100%;">
      <el-table-column
        type="selection"
        header-align="center"
        align="center"
        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">
          <el-link v-if="isAuth('104002003:update')" style="cursor: pointer" @click="updateModal(scope.row)">编辑</el-link>
          <el-link v-if="isAuth('104002003:details')" style="cursor: pointer" @click="detailsModal(scope.row)">详情</el-link>
          <el-link style="cursor: pointer" @click="checkOutToRouting(scope.row.partNo)">切换Routing</el-link>
        </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>

    <!-- recipe新增/编辑模态框 -->
    <el-dialog :close-on-click-modal="false" top="8vh" :before-close="closeModalX" v-drag :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 slot="label">物料编码</span>
          <el-input v-model="modalData.partNo" :disabled="modalDisableFlag" @blur="partNoBlur" style="width: 150px"></el-input>
        </el-form-item>
        <el-form-item :label="'物料名称'" prop="partDesc" :rules="rules.partDesc">
          <el-input v-model="modalData.partDesc" disabled style="width: 350px"></el-input>
        </el-form-item>
        <el-form-item :label="'物料单位'">
          <el-input v-model="modalData.printUnit" disabled style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'制造类型'" prop="bomType" :rules="rules.bomType">
          <el-select v-model="modalData.bomType" :disabled="modalDisableFlag" style="width: 140px">
            <el-option label="Manufacturing" value="Manufacturing"></el-option>
            <el-option label="Repair" value="Repair"></el-option>
            <el-option label="Purchase" value="Purchase"></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="effPhaseInDate" :rules="rules.effPhaseInDate">
          <el-date-picker
            :readonly="detailData.partNo != ''"
            style="width: 150px"
            v-model="modalData.effPhaseInDate"
            type="date"
            format="yyyy-MM-dd"
            placeholder="请选择日期"
            :editable=false>
          </el-date-picker>
        </el-form-item>
        <el-form-item label="失效日期">
          <el-date-picker
            readonly
            style="width: 150px"
            v-model="modalData.effPhaseOutDate"
            type="date"
            format="yyyy-MM-dd"
            placeholder="请选择日期"
            :editable=false>
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="'Recipe版本号'" prop="engChgLevel" :rules="rules.engChgLevel">
          <el-input v-model="modalData.engChgLevel" :disabled="modalDisableFlag" type="number" style="width: 80px"></el-input>
        </el-form-item>
        <el-form-item :label="'工程版本号'">
          <el-input v-model="modalData.engRevision" readonly style="width: 90px"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button v-if="modalData.flag === '1' && headerSaveFlag" :loading="saveHeaderLoading" type="primary" @click="saveRecipeHeader" style="margin-top: 23px;width: 120px">保存</el-button>
          <el-button v-else-if="modalData.flag === '2'" type="primary" @click="copyRecipeRevision" 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%; min-height: 120px" type="border-card" @tab-click="tabDetailClick" class="detail-tab">
        <!-- Recipe明细信息页签 -->
        <el-tab-pane label="Product Structure" name="recipe_detail">
          <el-form label-position="top" style="margin-top: -10px">
            <el-form-item v-if="modalData.flag === '3'"></el-form-item>
            <el-form-item v-else>
              <el-button type="primary" @click="saveRecipeDetail" style="margin-left: 7px">新增</el-button>
              <el-button type="primary" @click="deleteRecipeDetail">删除</el-button>
              <el-button type="primary" @click="updateRecipeDetail">编辑</el-button>
              <el-button v-if="modalData.flag === '2'" type="primary" @click="copyRecipeAlternative">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'" type="primary" @click="updateStatusToObsolete">Retire</el-button>
              <el-button v-if="modalData.flag === '2' && detailData.officialFlag !== 'Y' && (modalData.ifsPartNo == null || modalData.ifsPartNo === '')" type="primary" @click="toBecomeOfficialRecipe" :loading="toBecomeOfficialLoading">转正式Recipe</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: 150px">
                <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: 350px"></el-input>
            </el-form-item>
            <el-form-item :label="'状态'">
              <el-input v-model="detailData.status" readonly style="width: 120px"></el-input>
            </el-form-item>
            <el-form-item :label="'状态'">
              <el-input v-model="detailData.regUnit" readonly style="width: 120px"></el-input>
            </el-form-item>
            <el-form-item :label="'重量单位'">
              <el-input v-model="detailData.displayWeightUom" readonly style="width: 120px"></el-input>
            </el-form-item>
            <el-form-item :label="'体积单位'">
              <el-input v-model="detailData.displayVolumeUom" readonly style="width: 120px"></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>
      </el-tabs>

      <el-tabs v-model="subDetailTable" style="width: 100%; min-height: 330px" type="border-card" @tab-click="tabSubDetailClick" class="sub_detail-tab">
        <!-- Recipe子明细信息页签 -->
        <el-tab-pane label="Components" name="recipe_sub_detail">
          <el-form label-position="top" style="margin-top: 5px">
            <el-form-item v-if="modalData.flag === '3'"></el-form-item>
            <el-form-item v-else>
              <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
              v-if="modalData.flag !== '3'"
              fixed="right"
              header-align="center"
              align="center"
              width="100"
              label="操作">
              <template slot-scope="scope">
                <el-link style="cursor: pointer" @click="updateComponentModal(scope.row)">编辑</el-link>
              </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="530px">
      <el-form :inline="true" label-position="top" :model="saveDetailData" :rules="detailRules" style="margin-left: 5px">
        <el-form-item :label="'替代编码'" prop="alternativeNo" :rules="detailRules.alternativeNo">
          <el-input v-model="saveDetailData.alternativeNo" :disabled="saveDetailModalDisable" style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'替代名称'" prop="alternativeDescription" :rules="detailRules.alternativeDescription">
          <el-input v-model="saveDetailData.alternativeDescription" style="width: 225px"></el-input>
        </el-form-item>
        <el-form-item :label="'状态'" prop="status" :rules="detailRules.status">
          <el-input v-model="saveDetailData.status" disabled style="width: 120px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="saveDetailData" :rules="detailRules" style="margin-left: 5px">
        <el-form-item :label="'输入方式'" prop="regUnit" :rules="detailRules.regUnit">
          <el-input v-model="saveDetailData.regUnit" disabled style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item prop="displayWeightUom" :rules="detailRules.displayWeightUom">
          <span style="cursor: pointer" slot="label" @click="getBaseList(1008)"><a herf="#">重量单位</a></span>
          <el-input v-model="saveDetailData.displayWeightUom" style="width: 105px"></el-input>
        </el-form-item>
        <el-form-item prop="displayVolumeUom" :rules="detailRules.displayVolumeUom">
          <span style="cursor: pointer" slot="label" @click="getBaseList(1009)"><a herf="#">体积单位</a></span>
          <el-input v-model="saveDetailData.displayVolumeUom" style="width: 105px"></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: 500px;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="940px">
      <div class="rq">
        <el-form :inline="true" label-position="top" :model="partData">
          <el-form-item :label="'PLM物料编码'">
            <el-input v-model="partData.plmPartNo" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'IFS物料编码'">
            <el-input v-model="partData.ifsPartNo" 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>
        <!-- 分页插件 -->
        <el-pagination
          style="margin-top: 5px"
          @size-change="sizeChangeHandle2"
          @current-change="currentChangeHandle2"
          :current-page="pageIndex2"
          :page-sizes="[20, 50, 100, 200, 500]"
          :page-size="pageSize2"
          :total="totalPage2"
          layout="total, sizes, prev, pager, next, jumper">
        </el-pagination>
      </div>
      <el-footer style="height:35px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="partModelFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 子明细物料模态框 -->
    <el-dialog title="物料清单" top="17vh" :close-on-click-modal="false" v-drag :visible.sync="componentPartModelFlag" width="940px">
      <el-form :inline="true" label-position="top" :model="componentPartData">
        <el-form-item :label="'PLM物料编码'">
          <el-input v-model="componentPartData.plmPartNo" clearable style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'IFS物料编码'">
          <el-input v-model="componentPartData.ifsPartNo" clearable style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'物料名称'">
          <el-input v-model="componentPartData.partDesc" clearable style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'正式物料'">
          <el-select v-model="componentPartData.status" clearable style="width: 120px">
            <el-option label="临时物料" value="N"></el-option>
            <el-option label="正式物料" value="Y"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="' '">
          <el-button type="primary" @click="queryComponentPartList">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="250"
        :data="componentPartList"
        @row-dblclick="getComponentRowData"
        border
        style="width: 100%;">
        <el-table-column
          v-for="(item,index) in componentPartColumnList" :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-pagination
        style="margin-top: 5px"
        @size-change="sizeChangeHandle3"
        @current-change="currentChangeHandle3"
        :current-page="pageIndex3"
        :page-sizes="[20, 50, 100, 200, 500]"
        :page-size="pageSize3"
        :total="totalPage3"
        layout="total, sizes, prev, pager, next, jumper">
      </el-pagination>
      <el-footer style="height:35px;margin-top:10px;text-align:center">
        <el-button type="primary" @click="componentPartModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 子明细新增模态框 -->
    <el-dialog title="子物料" :close-on-click-modal="false" top="25vh" v-drag :visible.sync="componentSaveModal" width="800px">
      <el-form :inline="true" label-position="top" :model="componentData" :rules="componentRules" style="margin-left: 5px">
        <el-form-item :label="'序号'" prop="lineSequence" :rules="componentRules.lineSequence">
          <el-input-number :controls="false" :step="0" v-model="componentData.lineSequence" style="width: 49px"></el-input-number>
        </el-form-item>
        <el-form-item prop="componentPart" :rules="componentRules.componentPart">
          <span v-if="!componentDisableFlag" slot="label" @click="queryComponentPartModal"><a herf="#">子物料编码</a></span>
          <span v-if="componentDisableFlag" slot="label">子物料编码</span>
          <el-input v-model="componentData.componentPart" :disabled="componentDisableFlag" @blur="componentPartBlur" style="width: 130px"></el-input>
        </el-form-item>
        <el-form-item :label="'子物料名称'">
          <el-input v-model="componentData.componentPartDesc" disabled style="width: 249px"></el-input>
        </el-form-item>
        <el-form-item :label="'单位'">
          <el-input v-model="componentData.printUnit" disabled style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item v-show="componentData.productFlag === 'component'" :label="'消耗项目'" prop="consumptionItem" :rules="componentRules.consumptionItem">
          <el-select v-model="componentData.consumptionItem" style="width: 165px">
            <el-option label="Consumed" value="Consumed"></el-option>
            <el-option label="Not Consumed" value="Not Consumed"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="componentData" :rules="componentRules" style="margin-left: 5px">
        <el-form-item :label="'重量分配'" prop="weightShare" :rules="componentRules.weightShare">
          <el-input-number :precision="10" :controls="false" :step="0" v-model="componentData.weightShare" @change="changeWeightShare" style="width: 115px"></el-input-number>
        </el-form-item>
        <el-form-item :label="'零件-按重量'">
          <el-input-number :precision="10" :controls="false" :step="0" v-model="componentData.partsByWeight" disabled style="width: 115px"></el-input-number>
        </el-form-item>
        <el-form-item :label="'数量计量单位'">
          <el-input-number :precision="10" :controls="false" :step="0" v-model="componentData.qtyUom" disabled style="width: 115px"></el-input-number>
        </el-form-item>
        <el-form-item :label="'单位用量'">
          <el-input-number :precision="16" :controls="false" :step="0" v-model="componentData.qtyPerAssembly" disabled style="width: 115px"></el-input-number>
        </el-form-item>
        <el-form-item :label="'调机量'">
          <el-input-number :precision="10" :controls="false" :step="0" v-model="componentData.componentScrap" style="width: 115px"></el-input-number>
        </el-form-item>
        <el-form-item :label="'损耗率%'">
          <el-input-number :controls="false" :step="0" min="0" max="100" v-model="componentData.shrinkageFactor" style="width: 114px"></el-input-number>
        </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="queryOperationList"><a>工序</a></span>
          <el-input v-model="componentData.operationNo" readonly style="width: 115px"></el-input>
        </el-form-item>
        <el-form-item>
          <span style="cursor: pointer" slot="label" @click="getBaseList(117)"><a herf="#">发料库位</a></span>
          <el-input v-model="componentData.issueToLocName" readonly style="width: 115px"></el-input>
        </el-form-item>
        <el-form-item :label="'生产属性'" prop="issueType" :rules="componentRules.issueType">
          <el-select v-model="componentData.issueType" style="width: 165px">
            <el-option label="Reserve And Backflush" value="Reserve And Backflush"></el-option>
            <el-option label="Reserve" value="Reserve"></el-option>
            <el-option label="Backflush" value="Backflush"></el-option>
            <el-option label="Manual" value="Manual"></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 type="textarea" v-model="componentData.noteText" :rows="3" resize='none' show-word-limit style="width: 759px;height: 20px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:35px;margin-top:65px;text-align:center">
        <el-button v-if="componentData.flag === '1'" type="primary" @click="componentDataSave(true)">应用</el-button>
        <el-button type="primary" @click="componentDataSave(false)">保存</el-button>
        <el-button type="primary" @click="componentSaveModal = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 副产品成本分配辑模态框 -->
    <el-dialog title="编辑副产品成本分配" :close-on-click-modal="false" v-drag :visible.sync="manufStructCostDistribModal" width="500px">
      <el-form :inline="true" label-position="top" :model="manufStructCostDistribData" style="margin-left: 5px">
        <el-form-item :label="'副产品行项目号'">
          <el-input class="inlineNumber numInput" v-model="manufStructCostDistribData.byProdLineItemNo" disabled style="width: 85px"></el-input>
        </el-form-item>
        <el-form-item :label="'副产品物料编码'">
          <el-input v-model="manufStructCostDistribData.byProdPartNo" disabled style="width: 150px"></el-input>
        </el-form-item>
        <el-form-item :label="'副产品物料名称'">
          <el-input v-model="manufStructCostDistribData.byProdPartDesc" disabled style="width: 200px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="manufStructCostDistribData" style="margin-left: 5px">
        <el-form-item :label="'子物料项目号'">
          <el-input class="inlineNumber numInput" v-model="manufStructCostDistribData.componentLineItemNo" disabled style="width: 85px"></el-input>
        </el-form-item>
        <el-form-item :label="'子物料编码'">
          <el-input v-model="manufStructCostDistribData.componentPartNo" disabled style="width: 150px"></el-input>
        </el-form-item>
        <el-form-item :label="'子物料名称'">
          <el-input v-model="manufStructCostDistribData.componentPartDesc" disabled style="width: 200px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="manufStructCostDistribData" style="margin-left: 5px">
        <el-form-item label="项目成本分配因素">
          <el-input-number :controls="false" :step="0" v-model="manufStructCostDistribData.itemCostDistribution" style="width: 85px"></el-input-number>
        </el-form-item>
      </el-form>
      <el-footer style="height:35px;margin-top:10px;text-align:center">
        <el-button type="primary" @click="manufStructCostDistribUpdate">保存</el-button>
        <el-button type="primary" @click="manufStructCostDistribModal = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 工序 -->
    <el-dialog title="工序清单" :close-on-click-modal="false" v-drag :visible.sync="operationModelFlag" width="700px">
      <div class="rq">
        <el-form :inline="true" label-position="top" :model="operationData">
          <el-form-item label="Routing版本号">
            <el-input v-model="operationData.routingRevision" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item label="工艺类型">
            <el-select v-model="operationData.routingType" clearable 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-item label="替代编码">
            <el-input v-model="operationData.alternativeNo" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item label="工序编码">
            <el-input v-model="operationData.operationNo" 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="getRowOperationData"
          border
          style="width: 100%;">
          <el-table-column
            v-for="(item,index) in operationDetailList" :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="operationModelFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- copyRecipe -->
    <el-dialog title="Copy Structure Revision" :close-on-click-modal="false" v-drag :visible.sync="copyRecipeModelFlag" 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: 120px"></el-input>
          </el-form-item>
          <el-form-item label="物料名称">
            <el-input v-model="modalData.partDesc" readonly style="width: 249px"></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="Site">
            <el-input v-model="modalData.site" readonly style="width: 85px"></el-input>
          </el-form-item>
          <el-form-item label="Recipe版本号">
            <el-input v-model="modalData.engChgLevel" readonly style="width: 85px"></el-input>
          </el-form-item>
          <el-form-item label="制造类型">
            <el-input v-model="modalData.bomType" 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.effPhaseInDate" 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.effPhaseOutDate" 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 columnRecipeDetailList" :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="copyRecipeData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item>
            <span slot="label" @click="queryCopyPartModal"><a herf="#">物料编码</a></span>
            <el-input v-model="copyRecipeData.partNo" @change="copyBomTypeChange" @blur="copyPartBlur" style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'物料名称'">
            <el-input v-model="copyRecipeData.partDesc" disabled style="width: 249px"></el-input>
          </el-form-item>
        </el-form>
        <el-form :inline="true" label-position="top" :model="copyRecipeData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item label="Site">
            <el-input v-model="copyRecipeData.site" disabled style="width: 85px"></el-input>
          </el-form-item>
          <el-form-item label="Recipe版本号">
            <el-input v-model="copyRecipeData.engChgLevel" disabled style="width: 85px"></el-input>
          </el-form-item>
          <el-form-item label="制造类型">
            <el-select v-model="copyRecipeData.bomType" @change="copyBomTypeChange" style="width: 185px">
              <el-option label="Manufacturing" value="Manufacturing"></el-option>
              <el-option label="Repair" value="Repair"></el-option>
              <el-option label="Purchase" value="Purchase"></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="copyRecipeData" style="margin-left: 7px;margin-top: -5px;">
          <el-form-item label="生效日期">
            <el-date-picker style="width: 185px" v-model="copyRecipeData.effPhaseInDate" 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="copyRecipeData.effPhaseOutDate" 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" :loading="copyLoading" @click="copyRecipe">保存</el-button>
        <el-button type="primary" @click="copyRecipeModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- copy物料模态框 -->
    <el-dialog title="物料清单" top="17vh" :close-on-click-modal="false" v-drag :visible.sync="copyPartModelFlag" width="940px">
      <el-form :inline="true" label-position="top" :model="copyPartData">
        <el-form-item :label="'PLM物料编码'">
          <el-input v-model="copyPartData.plmPartNo" clearable style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'IFS物料编码'">
          <el-input v-model="copyPartData.ifsPartNo" clearable style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'物料名称'">
          <el-input v-model="copyPartData.partDesc" clearable style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="' '">
          <el-button type="primary" @click="queryCopyPartList">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="250"
        :data="copyPartList"
        @row-dblclick="getCopyRowData"
        border
        style="width: 100%;">
        <el-table-column
          v-for="(item,index) in componentPartColumnList" :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-pagination
        style="margin-top: 5px"
        @size-change="sizeChangeHandle4"
        @current-change="currentChangeHandle4"
        :current-page="pageIndex4"
        :page-sizes="[20, 50, 100, 200, 500]"
        :page-size="pageSize4"
        :total="totalPage4"
        layout="total, sizes, prev, pager, next, jumper">
      </el-pagination>
      <el-footer style="height:35px;margin-top:10px;text-align:center">
        <el-button type="primary" @click="copyPartModelFlag = 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: 120px"></el-input>
          </el-form-item>
          <el-form-item label="物料名称">
            <el-input v-model="modalData.partDesc" readonly style="width: 249px"></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="Site">
            <el-input v-model="detailData.site" readonly style="width: 85px"></el-input>
          </el-form-item>
          <el-form-item label="Recipe版本号">
            <el-input v-model="detailData.engChgLevel" readonly style="width: 85px"></el-input>
          </el-form-item>
          <el-form-item label="制造类型">
            <el-input v-model="detailData.bomType" 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>
            <span slot="label" @click="queryCopyPartModal"><a herf="#">物料编码</a></span>
            <el-input v-model="copyAlternativeData.partNo" @blur="copyPartBlur" style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'物料名称'">
            <el-input v-model="copyAlternativeData.partDesc" disabled style="width: 249px"></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="Site">
            <el-input v-model="copyAlternativeData.site" disabled style="width: 85px"></el-input>
          </el-form-item>
          <el-form-item label="Recipe版本号">
            <el-input v-model="copyAlternativeData.engChgLevel" style="width: 85px"></el-input>
          </el-form-item>
          <el-form-item label="制造类型">
            <el-select v-model="copyAlternativeData.bomType" style="width: 185px">
              <el-option label="Manufacturing" value="Manufacturing"></el-option>
              <el-option label="Repair" value="Repair"></el-option>
              <el-option label="Purchase" value="Purchase"></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" :loading="copyLoading" @click="copyAlternative">保存</el-button>
        <el-button type="primary" @click="copyAlternativeModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

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

<script>
import {
  recipeManagementSearch, // recipe列表查询
  recipeManagementSave, // recipe新增
  recipeManagementEdit, // recipe编辑
  recipeManagementDelete, // recipe删除
  queryRecipeHeader, // 查询recipe主信息
  saveRecipeHeader, // 新增recipe主信息
  queryRecipeDetail, // 查recipe明细
  recipeDetailSave, // recipe明细新增
  recipeDetailUpdate, // recipe明细编辑
  recipeDetailDelete, // recipe明细删除
  updateAlternativeStatus, // 修改明细状态
  queryPartList, // 查询物料清单
  queryRecipeComponent, // 查询recipe子明细
  saveRecipeComponent, // 新增recipe子明细
  updateRecipeComponent, // 修改recipe子明细
  deleteRecipeComponent, // 删除recipe子明细
  queryOperationList, // 根据物料编码查询工序
  getRecipeEngChgLevel, // 获取物料的recipe版本号
  getComponentLineSequence, // 获取子料的序号
  copyRecipe, // 复制recipe
  copyAlternative, // 复制alternative,
  toBecomeOfficialRecipe, // 转正式Recipe
  updateManufStructCostDistrib, // 新编辑副产品成本分配
  queryRecipeComponentTable, // 刷新子物料
  queryRecipeByProductTable, // 刷新副产品
  queryManufStructCostDistribtionTable, // 刷新项目成本分配
  queryMultiLevelStructureTable, // 刷新多级别结构
  queryPartListRecipe, // 查出可创建Recipe的物料
  queryPartListAll, // 查询包含Purchase(Raw)的物料
} from '@/api/part/recipeManagement.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()
      }
    },
    modalData: {
      deep: true,
      handler: function (newV, oldV) {
        this.modalData.partNo = this.modalData.partNo.toUpperCase()
      }
    },
    saveDetailData: {
      deep: true,
      handler: function (newV, oldV) {
        this.saveDetailData.alternativeNo = this.saveDetailData.alternativeNo.toUpperCase()
      }
    },
    componentData: {
      deep: true,
      handler: function (newV, oldV) {
        this.componentData.componentPart = this.componentData.componentPart.toUpperCase()
      }
    },
    copyRecipeData: {
      deep: true,
      handler: function (newV, oldV) {
        this.copyRecipeData.partNo = this.copyRecipeData.partNo.toUpperCase()
      }
    },
    copyAlternativeData: {
      deep: true,
      handler: function (newV, oldV) {
        this.copyAlternativeData.partNo = this.copyAlternativeData.partNo.toUpperCase()
      }
    },
    partData: {
      deep: true,
      handler: function (newV, oldV) {
        this.partData.partNo = this.partData.partNo.toUpperCase()
      }
    },

  },
  // 对象
  data () {
    return {
      initPage:false,
      // 导出
      exportData: [],
      exportName: 'Recipe列表' + this.dayjs().format('YYYYMMDDHHmmss'),
      exportHeader: ['Recipe列表'],
      exportFooter: [],
      resultList: [],
      // ======== 行高 ========
      height: 200,
      // ======== 分页 ========
      pageIndex: 1,
      pageSize: 50,
      totalPage: 0,
      pageIndex2: 1,
      pageSize2: 20,
      totalPage2: 0,
      pageIndex3: 1,
      pageSize3: 20,
      totalPage3: 0,
      pageIndex4: 1,
      pageSize4: 20,
      totalPage4: 0,
      selectedDataNum: 0,
      // 条件查询
      searchData: {
        site: this.$store.state.user.site,
        partNo: '',
        plmPartNo: '',
        ifsPartNo: '',
        partDesc: '',
        bomType:'',
        engChgLevel:'',
        page: 1,
        limit: 10
      },
      // loading
      queryLoading: false,
      saveHeaderLoading: false,
      saveDetailLoading: false,
      saveAllLoading: false,
      toBecomeOfficialLoading: false,
      copyLoading: false,
      // 初始页签
      detailTable: 'recipe_detail',
      subDetailTable: 'recipe_sub_detail',
      // ======== 数据对象 ========
      modalData: {
        flag: '',
        title: '',
        site: this.$store.state.user.site,
        partNo: '',
        partDesc: '',
        engChgLevel: '',
        bomType: '',
        noteText: '',
        effPhaseInDate: '',
        effPhaseOutDate: '',
        engRevision: '',
        typeFlag: '',
        netWeight: '',
        createDate: '',
        createBy: '',
        updateDate: '',
        updateBy: '',
        printUnit: '',
        printUnitName: '',
        officialFlag: ''
      },
      detailData: {
        site: this.$store.state.user.site,
        partNo: '',
        engChgLevel: '',
        bomType: '',
        alternativeNo: '',
        alternativeDescription: '',
        minLotQty: '',
        defaultFlag: '',
        detailNoteText: '',
        status: '',
        createDate: '',
        createBy: '',
        updateDate: '',
        updateBy: '',
        officialFlag: 'N',
        regUnit: '',
        displayWeightUom: '',
        displayVolumeUom: ''
      },
      componentData: {
        flag: '',
        site: this.$store.state.user.site,
        partNo: '',
        engChgLevel: '',
        bomType: '',
        alternativeNo: '',
        componentPart: '',
        componentPartDesc: '',
        printUnit: '',
        printUnitName: '',
        qtyPerAssembly: '',
        componentScrap: '',
        issueType: '',
        shrinkageFactor: '',
        lineItemNo: '',
        operationId: '',
        operationNo: '',
        issueToLoc: '',
        issueToLocName: '',
        noteText: '',
        createDate: '',
        createBy: '',
        updateDate: '',
        updateBy: '',
        lineSequence: '',
        consumptionItem: '',
        productFlag: '',
        weightShare: '',
        partsByWeight: '',
        qtyUom: '',
        issuePlannedScrapDb: '',
        issueOverreportedQtyDb: '',
        fixedQtyFlag: '',
        promisePlanned: '',
        phantomConsume: '',
        operCostDistribution: '',
        genOhCostDistribution: '',
        qtyKg: '',
        byProdAsSupplyInMrpDb: '',
        leadtimeOffset: '',
        stdPlannedItem: '',
        chargedItem: '',
        excludeFromCalculationsDb: '',
        excludeFromAsBuiltDb: '',
        lotBatchOriginDb: ''
      },
      partData: {
        site: this.$store.state.user.site,
        partNo: '',
        plmPartNo: '',
        ifsPartNo: '',
        partDesc: '',
        page: 1,
        limit: 10
      },
      componentPartData: {
        site: this.$store.state.user.site,
        partNo: '',
        plmPartNo: '',
        ifsPartNo: '',
        partDesc: '',
        status: '',
        page: 1,
        limit: 10
      },
      copyPartData: {
        type: '',
        site: this.$store.state.user.site,
        partNo: '',
        plmPartNo: '',
        ifsPartNo: '',
        partDesc: '',
        page: 1,
        limit: 10
      },
      saveDetailData: {
        flag: '',
        site: this.$store.state.user.site,
        partNo: '',
        engChgLevel: '',
        bomType: '',
        alternativeNo: '',
        alternativeDescription: '',
        minLotQty: '',
        defaultFlag: '',
        detailNoteText: '',
        status: '',
        createDate: '',
        createBy: '',
        updateDate: '',
        updateBy: '',
        officialFlag: '',
        displayWeightUom: '',
        displayVolumeUom: '',
        regUnit: ''
      },
      operationData: {
        site: this.$store.state.user.site,
        partNo: '',
        routingRevision: '',
        routingType: '',
        alternativeNo: '',
        operationNo: '',
        operationName: '',
      },
      copyRecipeData: {
        site: '',
        partNo: '',
        partDesc: '',
        engChgLevel: '',
        bomType: '',
        effPhaseInDate: '',
        effPhaseOutDate: '',
        previousVersion: {},
        createBy: '',
        officialFlag: ''
      },
      copyAlternativeData: {
        site: '',
        partNo: '',
        partDesc: '',
        engChgLevel: '',
        bomType: '',
        alternativeNo: '',
        alternativeDescription: '',
        minLotQty: '',
        defaultFlag: '',
        detailNoteText: '',
        status: '',
        previousVersion: {},
        createBy: '',
        officialFlag: ''
      },
      manufStructCostDistribData: {
        site: '',
        partNo: '',
        engChgLevel: '',
        bomType: '',
        alternativeNo: '',
        byProdLineItemNo: '',
        componentLineItemNo: '',
        componentPartNo: '',
        componentPartDesc: '',
        byProdPartNo: '',
        byProdPartDesc: '',
        itemCostDistribution: '',
        updateBy: '',
      },
      // ======== 数据列表 ========
      dataList: [],
      partList: [],
      componentPartList: [],
      copyPartList: [],
      componentPartSelections: [],
      subDetailList: [],
      byProductList: [],
      manufStructCostDistribList: [],
      detailDataList: [],
      checkedDetail: [],
      checkedByProduct: [],
      operationList: [],
      multiLevelStructureList: [],
      // ======== 列表表头 ========
      columnList: [
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table1PlmPartNo',
          tableId: '104002003Table1',
          tableName: 'Recipe信息表',
          columnProp: 'plmPartNo',
          headerAlign: 'center',
          align: 'center',
          columnLabel: 'PLM物料编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table1IfsPartNo',
          tableId: '104002003Table1',
          tableName: 'Recipe信息表',
          columnProp: 'ifsPartNo',
          headerAlign: 'center',
          align: 'center',
          columnLabel: 'IFS物料编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table1PartDesc',
          tableId: '104002003Table1',
          tableName: 'Recipe信息表',
          columnProp: 'partDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '物料名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 300
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table1BomType',
          tableId: '104002003Table1',
          tableName: 'Recipe信息表',
          columnProp: 'bomType',
          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: 104002003,
          serialNumber: '104002003Table1EngChgLevel',
          tableId: '104002003Table1',
          tableName: 'Recipe信息表',
          columnProp: 'engChgLevel',
          headerAlign: 'center',
          align: 'right',
          columnLabel: 'Recipe版本号',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table1engRevision',
          tableId: '104002003Table1',
          tableName: 'Recipe信息表',
          columnProp: 'engRevision',
          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: 104002003,
        //   serialNumber: '104002003Table1NetWeight',
        //   tableId: '104002003Table1',
        //   tableName: 'Recipe信息表',
        //   columnProp: 'netWeight',
        //   headerAlign: 'center',
        //   align: 'right',
        //   columnLabel: '净重',
        //   columnHidden: false,
        //   columnImage: false,
        //   columnSortable: false,
        //   sortLv: 0,
        //   status: true,
        //   fixed: '',
        //   columnWidth: 100
        // },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table1EffPhaseInDate',
          tableId: '104002003Table1',
          tableName: 'Recipe信息表',
          columnProp: 'effPhaseInDate',
          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: 104002003,
          serialNumber: '104002003Table1EffPhaseOutDate',
          tableId: '104002003Table1',
          tableName: 'Recipe信息表',
          columnProp: 'effPhaseOutDate',
          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: 104002003,
          serialNumber: '104002003Table1CreateDate',
          tableId: '104002003Table1',
          tableName: 'Recipe信息表',
          columnProp: 'createDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '创建时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 170
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table1CreateBy',
          tableId: '104002003Table1',
          tableName: 'Recipe信息表',
          columnProp: 'createBy',
          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: 104002003,
          serialNumber: '104002003Table1UpdateDate',
          tableId: '104002003Table1',
          tableName: 'Recipe信息表',
          columnProp: 'updateDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '更新时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 170
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table1UpdateBy',
          tableId: '104002003Table1',
          tableName: 'Recipe信息表',
          columnProp: 'updateBy',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '更新人',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        }
      ],
      partColumnList: [
        {
          columnProp: 'plmPartNo',
          headerAlign: "center",
          align: "center",
          columnLabel: 'PLM物料编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          columnProp: 'IFSPartNo',
          headerAlign: "center",
          align: "center",
          columnLabel: 'IFS物料编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          columnProp: 'partDesc',
          headerAlign: "center",
          align: "left",
          columnLabel: '物料名称',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 200
        },
        {
          columnProp: 'familyName',
          headerAlign: "center",
          align: "center",
          columnLabel: '物料分类',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'printUnit',
          headerAlign: "center",
          align: "left",
          columnLabel: '计量单位',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'spec',
          headerAlign: "center",
          align: "left",
          columnLabel: '规格型号',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'partType',
          headerAlign: "center",
          align: "left",
          columnLabel: '零件类型',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 140
        },
        {
          columnProp: 'partStatusDesc',
          headerAlign: "center",
          align: "left",
          columnLabel: '零件状态',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 120
        }
      ],
      componentPartColumnList: [
        {
          columnProp: 'plmPartNo',
          headerAlign: "center",
          align: "center",
          columnLabel: 'PLM物料编码',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          columnProp: 'ifsPartNo',
          headerAlign: "center",
          align: "center",
          columnLabel: 'IFS物料编码',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          columnProp: 'partDesc',
          headerAlign: "center",
          align: "left",
          columnLabel: '物料名称',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 200
        },
        {
          columnProp: 'familyName',
          headerAlign: "center",
          align: "center",
          columnLabel: '产品大类',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'printUnit',
          headerAlign: "center",
          align: "left",
          columnLabel: '计量单位',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'productGroupName4',
          headerAlign: "center",
          align: "left",
          columnLabel: '计划人',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'partType',
          headerAlign: "center",
          align: "center",
          columnLabel: '零件类型',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 130
        },
        {
          columnProp: 'partStatus',
          headerAlign: "center",
          align: "left",
          columnLabel: '零件状态',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 120
        }
      ],
      columnSubDetailList: [
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table2LineSequence',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'lineSequence',
          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: 104002003,
          serialNumber: '104002003Table2ComponentPart',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'componentPart',
          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: 104002003,
          serialNumber: '104002003Table2ComponentPartDesc',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'componentPartDesc',
          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: 104002003,
          serialNumber: '104002003Table2PartStatus',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'partStatus',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '零件状态编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table2PartStatusDesc',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'partStatusDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '零件状态名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table2WeightShare',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'weightShare',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '重量分配',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 110
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table2PartsByWeight',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'partsByWeight',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '零件-按重量',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 110
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table2QtyUom',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'qtyUom',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '数量计量单位',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 110
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table2QtyPerAssembly',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'qtyPerAssembly',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '单位用量',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 110
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table2ComponentScrap',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'componentScrap',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '调机量',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 110
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table2ShrinkageFactor',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'shrinkageFactor',
          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: 104002003,
          serialNumber: '104002003Table2ConsumptionItem',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'consumptionItem',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '消耗项目',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table2PrintUnit',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'printUnit',
          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: 104002003,
          serialNumber: '104002003Table2IssueType',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'issueType',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '生产属性',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 140
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table2OperationNo',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          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: 104002003,
          serialNumber: '104002003Table2IssueToLoc',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'issueToLocName',
          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: 104002003,
          serialNumber: '104002003Table2NoteText',
          tableId: '104002003Table2',
          tableName: 'Recipe子物料表',
          columnProp: 'noteText',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '备注',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 150
        },
      ],
      columnSubDetailList2: [
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table3LineSequence',
          tableId: '104002003Table3',
          tableName: 'Recipe副产品表',
          columnProp: 'lineSequence',
          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: 104002003,
          serialNumber: '104002003Table3ComponentPart',
          tableId: '104002003Table3',
          tableName: 'Recipe副产品表',
          columnProp: 'componentPart',
          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: 104002003,
          serialNumber: '104002003Table3ComponentPartDesc',
          tableId: '104002003Table3',
          tableName: 'Recipe副产品表',
          columnProp: 'componentPartDesc',
          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: 104002003,
          serialNumber: '104002003Table3PartStatus',
          tableId: '104002003Table3',
          tableName: 'Recipe副产品表',
          columnProp: 'partStatus',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '零件状态编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table3PartStatusDesc',
          tableId: '104002003Table3',
          tableName: 'Recipe副产品表',
          columnProp: 'partStatusDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '零件状态名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table3QtyPerAssembly',
          tableId: '104002003Table3',
          tableName: 'Recipe副产品表',
          columnProp: 'qtyPerAssembly',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '单位用量',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 110
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table3ComponentScrap',
          tableId: '104002003Table3',
          tableName: 'Recipe副产品表',
          columnProp: 'componentScrap',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '调机量',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 110
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table3ShrinkageFactor',
          tableId: '104002003Table3',
          tableName: 'Recipe副产品表',
          columnProp: 'shrinkageFactor',
          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: 104002003,
          serialNumber: '104002003Table3PrintUnit',
          tableId: '104002003Table3',
          tableName: 'Recipe副产品表',
          columnProp: 'printUnit',
          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: 104002003,
          serialNumber: '104002003Table3IssueType',
          tableId: '104002003Table3',
          tableName: 'Recipe副产品表',
          columnProp: 'issueType',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '生产属性',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 140
        },
        {
          userId: this.$store.state.user.name,
          functionId: 104002003,
          serialNumber: '104002003Table3OperationNo',
          tableId: '104002003Table3',
          tableName: 'Recipe副产品表',
          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: 104002003,
          serialNumber: '104002003Table3IssueToLoc',
          tableId: '104002003Table3',
          tableName: 'Recipe副产品表',
          columnProp: 'issueToLocName',
          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: 104002003,
          serialNumber: '104002003Table3NoteText',
          tableId: '104002003Table3',
          tableName: 'Recipe副产品表',
          columnProp: 'noteText',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '备注',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 150
        },
      ],
      operationDetailList: [
        {
          columnProp: 'routingRevision',
          headerAlign: "center",
          align: "center",
          columnLabel: 'Routing版本号',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'routingType',
          headerAlign: "center",
          align: "center",
          columnLabel: '工艺类型',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'alternativeNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '替代编码',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          columnProp: 'alternativeDescription',
          headerAlign: "center",
          align: "left",
          columnLabel: '替代名称',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'status',
          headerAlign: "center",
          align: "center",
          columnLabel: '替代状态',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          columnProp: 'operationNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '工序编码',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          columnProp: 'operationName',
          headerAlign: "center",
          align: "left",
          columnLabel: '工序名称',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        }
      ],
      columnRecipeDetailList: [
        {
          columnProp: 'alternativeNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '替代编码',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'alternativeDescription',
          headerAlign: "center",
          align: "left",
          columnLabel: '替代名称',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 200
        },
        {
          columnProp: 'status',
          headerAlign: "center",
          align: "center",
          columnLabel: '状态',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
      ],
      columnManufStructCostDistribList: [
        {
          columnProp: 'byProdLineItemNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '副产品行项目号',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 60
        },
        {
          columnProp: 'byProdPartNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '副产品物料编码',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          columnProp: 'byProdPartDesc',
          headerAlign: "center",
          align: "left",
          columnLabel: '副产品物料名称',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 150
        },
        {
          columnProp: 'componentLineItemNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '子物料项目号',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 60
        },
        {
          columnProp: 'componentPartNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '子物料编码',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          columnProp: 'componentPartDesc',
          headerAlign: "center",
          align: "left",
          columnLabel: '子物料名称',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 150
        },
        {
          columnProp: 'itemCostDistribution',
          headerAlign: "center",
          align: "center",
          columnLabel: '项目成本分配因素',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 60
        },
      ],
      columnMultiLevelStructureList: [
        {
          columnProp: 'partNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '物料编码',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'partDesc',
          headerAlign: "center",
          align: "left",
          columnLabel: '物料名称',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 150
        },
        {
          columnProp: 'engChgLevel',
          headerAlign: "center",
          align: "center",
          columnLabel: 'Recipe版本号',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          columnProp: 'bomType',
          headerAlign: "center",
          align: "center",
          columnLabel: '制造类型',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'alternativeNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '替代编码',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'alternativeDescription',
          headerAlign: "center",
          align: "left",
          columnLabel: '替代名称',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 150
        },
        {
          columnProp: 'componentPart',
          headerAlign: "center",
          align: "center",
          columnLabel: '子物料编码',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'componentPartDesc',
          headerAlign: "center",
          align: "left",
          columnLabel: '子物料名称',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 150
        },
        {
          columnProp: 'qtyPerAssembly',
          headerAlign: "center",
          align: "right",
          columnLabel: '单位用量',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 110
        },
        {
          columnProp: 'printUnit',
          headerAlign: "center",
          align: "left",
          columnLabel: '计量单位',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          columnProp: 'productGroupName4',
          headerAlign: "center",
          align: "left",
          columnLabel: '计划人',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'minOrderQty',
          headerAlign: "center",
          align: "right",
          columnLabel: '最小批量',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 60
        },
        {
          columnProp: 'mulOrderQty',
          headerAlign: "center",
          align: "right",
          columnLabel: '多种批量大小',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 60
        },
        {
          columnProp: 'planningMethod',
          headerAlign: "center",
          align: "left",
          columnLabel: '计划方法',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'cumLeadTime',
          headerAlign: "center",
          align: "right",
          columnLabel: '父级累计提前期',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'unprotectedLeadTime',
          headerAlign: "center",
          align: "right",
          columnLabel: '父级未受保护提前期',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'componentCumLeadTime',
          headerAlign: "center",
          align: "right",
          columnLabel: '子物料累计提前期',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'componentUnprotectedLeadTime',
          headerAlign: "center",
          align: "right",
          columnLabel: '子物料未受保护提前期',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
      ],
      // ======== 必填规则 ========
      rules: {
        partNo: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        partDesc: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        bomType: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        effPhaseInDate: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        engChgLevel: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ]
      },
      detailRules: {
        alternativeNo: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        alternativeDescription: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        minLotQty: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        status: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        regUnit: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        displayWeightUom: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        displayVolumeUom: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ]
      },
      componentRules: {
        componentPart: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        lineSequence: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        issueType: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        consumptionItem: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        weightShare: [
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
      },
      // ======== 复选数据集 ========
      recipeSelections: [],
      // ======== 模态框开关控制 ========
      modalFlag: false,
      modalDisableFlag: false,
      partModelFlag: false,
      componentPartModelFlag: false,
      copyPartModelFlag: false,
      saveDetailModalFlag :false,
      saveDetailModalDisable: false,
      componentSaveModal: false,
      componentDisableFlag: false,
      operationModelFlag: false,
      copyRecipeModelFlag: false,
      copyAlternativeModelFlag: false,
      headerSaveFlag: false,
      manufStructCostDistribModal: false
    }
  },

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

  activated() {
    if (this.$route.params && this.$route.params.type && this.$route.params.type === 'quote') {
      this.handleQueryRecipeByQuote()
    } else if (this.$route.params.partNo) {
      this.searchData.partNo = this.$route.params.partNo
      this.getDataList()
    } else if (this.initPage === false) {
      this.getDataList()
    }
    this.initPage = true
  },
  // js
  methods: {
    // === 报价查询 ===
    handleQueryRecipeByQuote () {
      let params = {
        site: this.$route.params.site,
        partNo: this.$route.params.partNo,
        bomType: this.$route.params.bomType,
        engChgLevel: this.$route.params.engChgLevel,
        page: this.pageIndex,
        limit: this.pageSize
      }
      this.queryLoading = true
      recipeManagementSearch(params).then(({data})=>{
        if (data && 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
      })
    },
    // ======== 分页相关方法 ========
    // 每页数
    sizeChangeHandle (val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },

    // 当前页
    currentChangeHandle (val) {
      this.pageIndex = val
      this.getDataList()
    },

    // 每页数
    sizeChangeHandle2 (val) {
      this.pageSize2 = val
      this.pageIndex2 = 1
      this.queryPartList()
    },

    // 当前页
    currentChangeHandle2 (val) {
      this.pageIndex2 = val
      this.queryPartList()
    },

    // 每页数
    sizeChangeHandle3 (val) {
      this.pageSize3 = val
      this.pageIndex3 = 1
      this.queryComponentPartList()
    },

    // 当前页
    currentChangeHandle3 (val) {
      this.pageIndex3 = val
      this.queryComponentPartList()
    },

    // 每页数
    sizeChangeHandle4 (val) {
      this.pageSize4 = val
      this.pageIndex4 = 1
      this.queryCopyPartModal()
    },

    // 当前页
    currentChangeHandle4 (val) {
      this.pageIndex4 = val
      this.queryCopyPartModal()
    },

    // ======== 页签切换相关方法 ========
    // 明细页签选择替换
    tabDetailClick (tab, event) {
      // 刷新列表数据
      this.refreshDetailTable()
    },

    // 子明细页签选择替换
    tabSubDetailClick (tab, event) {
      // 刷新列表数据
      this.refreshSubDetailTable()
    },

    // 刷新明细页签的table数据
    refreshDetailTable () {
      if (this.detailTable === 'recipe_detail') {

      }
    },

    // 刷新子明细页签的table数据
    refreshSubDetailTable () {
      if (this.subDetailTable === 'recipe_sub_detail') {
        this.queryRecipeComponentTable()
      } else if (this.subDetailTable === 'by_products') {
        this.queryRecipeByProductTable()
      } else if (this.subDetailTable === 'manuf_struct_cost_distribtion') {
        this.queryManufStructCostDistribtionTable()
      } else if (this.subDetailTable === 'multi_level_structure') {
        this.queryMultiLevelStructureTable()
      }
    },

    // 刷新方法
    queryRecipeComponentTable () {
      queryRecipeComponentTable(this.detailData).then(({data}) => {
        if (data.code === 0) {
          this.subDetailList = data.rows
        }
      })
    },

    // 刷新方法
    queryRecipeByProductTable () {
      queryRecipeByProductTable(this.detailData).then(({data}) => {
        if (data.code === 0) {
          this.byProductList = data.rows
        }
      })
    },

    // 刷新方法
    queryManufStructCostDistribtionTable () {
      queryManufStructCostDistribtionTable(this.detailData).then(({data}) => {
        if (data.code === 0) {
          this.manufStructCostDistribList = data.rows
        }
      })
    },

    // 刷新方法
    queryMultiLevelStructureTable () {
      queryMultiLevelStructureTable(this.detailData).then(({data}) => {
        if (data.code === 0) {
          this.multiLevelStructureList = data.rows
        }
      })
    },

    // ======== 列表数据操作方法 ========

    // 获取数据列表
    getDataList () {
      //如果是跳转过来的 要判断
      if (localStorage.getItem('recipeData') != undefined) {
        let data = JSON.parse(localStorage.getItem('recipeData'))
        this.searchData.partNo = data.partNo
        this.searchData.bomType = data.bomType
        this.searchData.engChgLevel = data.engChgLevel
      }
      this.searchData.limit = this.pageSize
      this.searchData.page = this.pageIndex
      this.queryLoading = true
      recipeManagementSearch(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)
          if (localStorage.getItem('recipeData') != undefined) {
            let data = JSON.parse(localStorage.getItem('recipeData'))
            if(data.engChgLevel&&data.engChgLevel!==''&&data.engChgLevel!==null){
              this.updateModal(this.dataList[0])
            }
          }
        }
        this.queryLoading = false
        if (localStorage.getItem('recipeData') != undefined) {
          this.$nextTick(function () {
            localStorage.removeItem('recipeData')
          })
        }
      })
    },

    // 复选列表信息
    selectionRecipe (val) {
      this.recipeSelections = val
      this.$refs.selectDiv.setLengthselected(this.recipeSelections.length)
    },

    // ======== 新增/编辑模态框 ========
    // recipe新增模态框
    addModal () {
      this.modalData = {
        flag: '1',
        title: 'recipe新增',
        site: this.$store.state.user.site,
        partNo: '',
        partDesc: '',
        engChgLevel: '',
        bomType: 'Manufacturing',
        noteText: '',
        effPhaseInDate: new Date(+ new Date() + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, ''),
        effPhaseOutDate: '',
        engRevision: '',
        typeFlag: 'B',
        netWeight: 0,
        createBy: this.$store.state.user.name,
        printUnit: '',
        printUnitName: '',
        officialFlag: 'N'
      }
      this.detailData = {
        site: this.$store.state.user.site,
        partNo: '',
        engChgLevel: '',
        bomType: '',
        alternativeNo: '',
        alternativeDescription: '',
        minLotQty: '',
        defaultFlag: '',
        detailNoteText: '',
        status: '',
        createDate: '',
        createBy: this.$store.state.user.name,
        updateDate: '',
        updateBy: this.$store.state.user.name,
        officialFlag: 'N',
        displayWeightUom: 'kg',
        displayVolumeUom: 'ml',
        regUnit: 'Weight Share'
      }
      this.detailDataList = []
      this.subDetailList = []
      this.byProductList = []
      this.manufStructCostDistribList = []
      this.headerSaveFlag = true
      this.modalDisableFlag = false
      this.modalFlag = true
    },

    // recipe编辑模态框
    async updateModal (row) {
      this.modalData = {
        flag: '2',
        site: row.site,
        partNo: row.partNo,
        partDesc: row.partDesc,
        engChgLevel: row.engChgLevel,
        bomType: row.bomType,
        noteText: row.noteText,
        effPhaseInDate: row.effPhaseInDate,
        effPhaseOutDate: row.effPhaseOutDate,
        engRevision: row.engRevision,
        typeFlag: row.typeFlag,
        netWeight: row.netWeight,
        updateBy: this.$store.state.user.name,
        printUnit: row.printUnit,
        printUnitName: row.printUnitName,
        officialFlag: row.officialFlag,
        alternativeNo: row.alternativeNo,
        ifsPartNo: row.ifsPartNo
      }
      this.subDetailTable = 'recipe_sub_detail'
      // 查recipe明细
      queryRecipeDetail(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: '确定'
          })
        }
      })
    },

    // 详情
    async detailsModal (row) {
      this.modalData = {
        ...row,
        flag: '3',
        updateBy: this.$store.state.user.name,
      }
      this.subDetailTable = 'recipe_sub_detail'
      // 查bom明细
      queryRecipeDetail(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: '确定'
          })
        }
      })
    },

    // 替代新增模态框
    saveRecipeDetail () {
      if (this.modalData.partNo === '' || this.modalData.partNo == null) {
        this.$message.warning('请先选择Recipe物料！')
        return
      }
      if (this.modalData.engChgLevel === '' || this.modalData.engChgLevel == null) {
        this.$message.warning('请先填写Recipe版本号！')
        return
      }
      if (this.modalData.bomType === '' || this.modalData.bomType == null) {
        this.$message.warning('请先选择制造类型！')
        return
      }
      this.saveDetailData = {
        flag: '1',
        site: this.$store.state.user.site,
        partNo: this.modalData.partNo,
        engChgLevel: this.modalData.engChgLevel,
        bomType: this.modalData.bomType,
        alternativeNo: '',
        alternativeDescription: '',
        minLotQty: 0,
        defaultFlag: '',
        detailNoteText: '',
        status: 'Tentative',
        createDate: '',
        createBy: this.$store.state.user.name,
        officialFlag: 'N',
        displayWeightUom: 'kg',
        displayVolumeUom: 'ml',
        regUnit: 'Weight Share'
      }
      // 查询recipe主信息
      queryRecipeHeader(this.modalData).then(({data}) => {
        if (data && data.code === 0) {
          if (data.rows.length > 0) {
            this.saveDetailModalFlag = true
            this.saveDetailModalDisable = false
          } else {
            this.$message.warning('请先保存Recipe主记录！')
          }
        } else {
          this.$alert(data.msg, '提示', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    // 替代编辑模态框
    updateRecipeDetail () {
      if (this.modalData.partNo === '' || this.modalData.partNo == null) {
        this.$message.warning('请先选择Recipe物料！')
        return
      }
      if (this.modalData.engChgLevel === '' || this.modalData.engChgLevel == null) {
        this.$message.warning('请先填写Recipe版本号！')
        return
      }
      if (this.modalData.bomType === '' || this.modalData.bomType == null) {
        this.$message.warning('请先选择制造类型！')
        return
      }
      this.saveDetailData = {
        flag: '2',
        site: this.detailData.site,
        partNo: this.detailData.partNo,
        engChgLevel: this.detailData.engChgLevel,
        bomType: this.detailData.bomType,
        alternativeNo: this.detailData.alternativeNo,
        alternativeDescription: this.detailData.alternativeDescription,
        minLotQty: this.detailData.minLotQty,
        defaultFlag: '',
        detailNoteText: this.detailData.detailNoteText,
        status: this.detailData.status,
        updateBy: this.$store.state.user.name,
        officialFlag: this.detailData.officialFlag,
        displayWeightUom: this.detailData.displayWeightUom,
        displayVolumeUom: this.detailData.displayVolumeUom,
        regUnit: 'Weight Share'
      }
      // 查询recipe主信息
      queryRecipeHeader(this.modalData).then(({data}) => {
        if (data && data.code === 0) {
          if (data.rows.length > 0) {
            this.saveDetailModalFlag = true
            this.saveDetailModalDisable = true
          } else {
            this.$message.warning('请先保存Recipe主记录！')
          }
        } else {
          this.$alert(data.msg, '提示', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    // 子明细新增模态框
    saveComponentModal () {
      if (this.detailData.alternativeNo === '' || this.detailData.alternativeNo == null) {
        this.$message.warning('请先选择替代！')
        return
      }
      this.componentData = {
        flag: '1',
        site: this.$store.state.user.site,
        partNo: this.modalData.partNo,
        engChgLevel: this.modalData.engChgLevel,
        bomType: this.modalData.bomType,
        alternativeNo: this.detailData.alternativeNo,
        componentPart: '',
        componentPartDesc: '',
        printUnit: '',
        printUnitName: '',
        qtyPerAssembly: undefined,
        componentScrap: 0,
        issueType: 'Reserve And Backflush',
        shrinkageFactor: 0,
        lineItemNo: '',
        operationId: '',
        operationNo: '',
        issueToLoc: '',
        issueToLocName: '',
        noteText: '',
        createBy: this.$store.state.user.name,
        lineSequence: '',
        consumptionItem: 'Consumed',
        productFlag: 'component',
        weightShare: undefined,
        partsByWeight: undefined,
        qtyUom: undefined,
        issuePlannedScrapDb: 'TRUE',
        issueOverreportedQtyDb: 'FALSE',
        fixedQtyFlag: 'Not fixed',
        promisePlanned: 'Promised',
        phantomConsume: 'Not Phantom Consume',
        operCostDistribution: '0',
        genOhCostDistribution: '0',
        qtyKg: undefined,
        byProdAsSupplyInMrpDb: 'FALSE',
        leadtimeOffset: '0',
        stdPlannedItem: '1',
        chargedItem: 'Item not charged',
        excludeFromCalculationsDb: 'FALSE',
        excludeFromAsBuiltDb: 'FALSE',
        lotBatchOriginDb: 'FALSE'
      }

      // 获取子料的序号
      getComponentLineSequence(this.componentData).then(({data}) => {
        if (data && data.code === 0) {
          this.componentData.lineSequence = data.lineSequence
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
      this.componentDisableFlag = false
      this.componentSaveModal = true
    },

    // 副产品新增模态框
    saveByProductModal () {
      if (this.detailData.alternativeNo === '' || this.detailData.alternativeNo == null) {
        this.$message.warning('请先选择替代！')
        return
      }
      this.componentData = {
        flag: '1',
        site: this.$store.state.user.site,
        partNo: this.modalData.partNo,
        engChgLevel: this.modalData.engChgLevel,
        bomType: this.modalData.bomType,
        alternativeNo: this.detailData.alternativeNo,
        componentPart: '',
        componentPartDesc: '',
        printUnit: '',
        printUnitName: '',
        qtyPerAssembly: 0,
        componentScrap: 0,
        issueType: 'Reserve And Backflush',
        shrinkageFactor: 0,
        lineItemNo: '',
        operationId: '',
        operationNo: '',
        issueToLoc: '',
        issueToLocName: '',
        noteText: '',
        createBy: this.$store.state.user.name,
        lineSequence: '',
        consumptionItem: '',
        productFlag: 'byProduct'
      }
      // 获取子料的序号
      getComponentLineSequence(this.componentData).then(({data}) => {
        if (data && data.code === 0) {
          this.componentData.lineSequence = data.lineSequence
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
      this.componentDisableFlag = false
      this.componentSaveModal = true
    },

    // 子明细编辑模态框
    updateComponentModal (row) {
      this.componentData = {
        flag: '2',
        site: row.site,
        partNo: row.partNo,
        engChgLevel: row.engChgLevel,
        bomType: row.bomType,
        alternativeNo: row.alternativeNo,
        componentPart: row.componentPart,
        componentPartDesc: row.componentPartDesc,
        printUnit: row.printUnit,
        printUnitName: row.printUnitName,
        qtyPerAssembly: row.qtyPerAssembly,
        componentScrap: row.componentScrap,
        issueType: row.issueType,
        shrinkageFactor: row.shrinkageFactor,
        lineItemNo: row.lineItemNo,
        operationId: row.operationId,
        operationNo: row.operationNo,
        issueToLoc: row.issueToLoc,
        issueToLocName: row.issueToLocName,
        noteText: row.noteText,
        updateBy: this.$store.state.user.name,
        lineSequence: row.lineSequence,
        consumptionItem: row.consumptionItem,
        productFlag: 'component',
        weightShare: row.weightShare,
        partsByWeight: row.partsByWeight,
        qtyUom: row.qtyUom,
        issuePlannedScrapDb: row.issuePlannedScrapDb,
        issueOverreportedQtyDb: row.issueOverreportedQtyDb,
        fixedQtyFlag: row.fixedQtyFlag,
        promisePlanned: row.promisePlanned,
        phantomConsume: row.phantomConsume,
        operCostDistribution: row.operCostDistribution,
        genOhCostDistribution: row.genOhCostDistribution,
        qtyKg: row.qtyKg,
        byProdAsSupplyInMrpDb: row.byProdAsSupplyInMrpDb,
        leadtimeOffset: row.leadtimeOffset,
        stdPlannedItem: row.stdPlannedItem,
        chargedItem: row.chargedItem,
        excludeFromCalculationsDb: row.excludeFromCalculationsDb,
        excludeFromAsBuiltDb: row.excludeFromAsBuiltDb,
        lotBatchOriginDb: row.lotBatchOriginDb
      }
      this.componentDisableFlag = true
      this.componentSaveModal = true
    },

    // 副产品编辑模态框
    updateByProductModal (row) {
      this.componentData = {
        flag: '2',
        site: row.site,
        partNo: row.partNo,
        engChgLevel: row.engChgLevel,
        bomType: row.bomType,
        alternativeNo: row.alternativeNo,
        componentPart: row.componentPart,
        componentPartDesc: row.componentPartDesc,
        printUnit: row.printUnit,
        printUnitName: row.printUnitName,
        qtyPerAssembly: row.qtyPerAssembly,
        componentScrap: row.componentScrap,
        issueType: row.issueType,
        shrinkageFactor: row.shrinkageFactor,
        lineItemNo: row.lineItemNo,
        operationId: row.operationId,
        operationNo: row.operationNo,
        issueToLoc: row.issueToLoc,
        issueToLocName: row.issueToLocName,
        noteText: row.noteText,
        updateBy: this.$store.state.user.name,
        lineSequence: row.lineSequence,
        consumptionItem: row.consumptionItem,
        productFlag: 'byProduct'
      }
      this.componentDisableFlag = true
      this.componentSaveModal = true
    },

    // 副产品成本分配编辑模态框
    updateManufStructCostDistribModal (row) {
      this.manufStructCostDistribData = {
        site: row.site,
        partNo: row.partNo,
        engChgLevel: row.engChgLevel,
        bomType: row.bomType,
        alternativeNo: row.alternativeNo,
        byProdLineItemNo: row.byProdLineItemNo,
        componentLineItemNo: row.componentLineItemNo,
        componentPartNo: row.componentPartNo,
        componentPartDesc: row.componentPartDesc,
        byProdPartNo: row.byProdPartNo,
        byProdPartDesc: row.byProdPartDesc,
        itemCostDistribution: row.itemCostDistribution,
        updateBy: this.$store.state.user.name,
      }
      this.manufStructCostDistribModal = true
    },

    // ======== 新增/编辑/删除方法 ========
    // recipe新增/编辑
    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.bomType === '' || this.modalData.bomType == null) {
        this.$message.warning('请选择制造类型！')
        return
      }
      if (this.modalData.effPhaseInDate === '' || this.modalData.effPhaseInDate == null) {
        this.$message.warning('请选择生效日期！')
        return
      }
      if (this.modalData.engChgLevel === '' || this.modalData.engChgLevel == null) {
        this.$message.warning('请填写Recipe版本号！')
        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,
        engChgLevel: this.modalData.engChgLevel,
        bomType: this.modalData.bomType,
        noteText: this.modalData.noteText,
        effPhaseInDate: this.modalData.effPhaseInDate,
        effPhaseOutDate: this.modalData.effPhaseOutDate,
        engRevision: this.modalData.engRevision,
        typeFlag: this.modalData.typeFlag,
        netWeight: this.modalData.netWeight,
        officialFlag: this.modalData.officialFlag,
        alternativeNo: this.detailData.alternativeNo,
        alternativeDescription: this.detailData.alternativeDescription,
        minLotQty: this.detailData.minLotQty,
        defaultFlag: this.detailData.defaultFlag,
        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
        recipeManagementSave(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
        recipeManagementEdit(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.modalFlag = false
    },

    // 新增编辑模态框关闭
    closeModalX (done) {
      done()
    },

    // recipe删除
    delModal () {
      if (this.recipeSelections.length === 0) {
        this.$message.warning('请勾选要删除的Recipe！')
        return
      }
      this.$confirm(`是否删除这 `+ this.recipeSelections.length +` 条Recipe?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let tempData = {
          informationList: this.recipeSelections
        }
        recipeManagementDelete(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.getDataList()
            this.recipeSelections = []
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      }).catch(() => {
      })
    },

    // 查询物料
    queryPartList () {
      this.partData.limit = this.pageSize2
      this.partData.page = this.pageIndex2
      queryPartListRecipe(this.partData).then(({data}) => {
        if (data && data.code === 0) {
          this.partList = data.page.list
          this.pageIndex2 = data.page.currPage
          this.pageSize2 = data.page.pageSize
          this.totalPage2 = data.page.totalCount
          this.partModelFlag = true
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    // 物料编码失焦事件
    partNoBlur () {
      this.partData.limit = this.pageSize2
      this.partData.page = this.pageIndex2
      this.partData.partNo = this.modalData.partNo
      queryPartList(this.partData).then(({data}) => {
        if (data && data.code === 0) {
          if (data.page.list.length === 1) {
            this.modalData.partDesc = data.page.list[0].partDesc
            this.modalData.printUnit = data.page.list[0].printUnit
            this.modalData.printUnitName = data.page[0].printUnitName
          }
        }
      })
    },

    // 双击选中物料
    getRowData (row) {
      this.modalData.partNo = row.partNo
      this.modalData.partDesc = row.partDesc
      this.modalData.printUnit = row.printUnit
      this.modalData.printUnitName = row.printUnitName
      this.partModelFlag = false
    },

    // 双击选中工序
    getRowOperationData (row) {
      this.componentData.operationId = row.operationId
      this.componentData.operationNo = row.operationNo
      this.operationModelFlag = false
    },

    // 双击选中子物料
    getComponentRowData (row) {
      this.componentData.componentPart = row.partNo
      this.componentData.componentPartDesc = row.partDesc
      this.componentData.printUnit = row.printUnit
      this.componentData.printUnitName = row.printUnitName
      this.componentPartModelFlag = false
    },

    // 双击选择copy物料
    getCopyRowData (row) {
      if (this.copyPartData.type === '1') {
        this.copyRecipeData.partNo = row.partNo
        this.copyRecipeData.partDesc = row.partDesc
        this.copyBomTypeChange()
      } else {
        this.copyAlternativeData.partNo = row.partNo
        this.copyAlternativeData.partDesc = row.partDesc
      }
      this.copyPartModelFlag = false
    },

    // 子物料列表
    queryComponentPartModal () {
      this.componentPartData.limit = this.pageSize3
      this.componentPartData.page = this.pageIndex3
      this.componentPartData.status = 'Y'
      // 查询所有物料
      queryPartListAll(this.componentPartData).then(({data}) => {
        if (data && data.code === 0) {
          this.componentPartList = data.page.list
          this.pageIndex3 = data.page.currPage
          this.pageSize3 = data.page.pageSize
          this.totalPage3 = data.page.totalCount
          this.componentPartModelFlag = true
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    // copy物料列表
    queryCopyPartModal () {
      this.copyPartData.limit = this.pageSize4
      this.copyPartData.page = this.pageIndex4
      // 查询所有物料
      queryPartList(this.copyPartData).then(({data}) => {
        if (data && data.code === 0) {
          this.copyPartList = data.page.list
          this.pageIndex4 = data.page.currPage
          this.pageSize4 = data.page.pageSize
          this.totalPage4 = data.page.totalCount
          this.copyPartModelFlag = true
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    // 物料列表
    queryComponentPartList () {
      this.componentPartData.limit = this.pageSize3
      this.componentPartData.page = this.pageIndex3
      // 查询所有物料
      queryPartListAll(this.componentPartData).then(({data}) => {
        if (data && data.code === 0) {
          this.componentPartList = data.page.list
          this.pageIndex3 = data.page.currPage
          this.pageSize3 = data.page.pageSize
          this.totalPage3 = data.page.totalCount
        } else {
          this.componentPartList = []
        }
      })
    },

    // copy物料查询列表
    queryCopyPartList () {
      this.copyPartData.limit = this.pageSize4
      this.copyPartData.page = this.pageIndex4
      // 查询所有物料
      queryPartList(this.copyPartData).then(({data}) => {
        if (data && data.code === 0) {
          this.copyPartList = data.page.list
          this.pageIndex4 = data.page.currPage
          this.pageSize4 = data.page.pageSize
          this.totalPage4 = data.page.totalCount
        } else {
          this.copyPartList = []
        }
      })
    },

    // 子物料编码失焦事件
    componentPartBlur () {
      if (this.componentData.componentPart != null && this.componentData.componentPart !== '') {
        this.componentPartData.limit = this.pageSize3
        this.componentPartData.page = this.pageIndex3
        this.componentPartData.partNo = this.componentData.componentPart
        queryPartListAll(this.componentPartData).then(({data}) => {
          if (data && data.code === 0) {
            if (data.page.list.length === 1) {
              this.componentData.componentPartDesc = data.page.list[0].partDesc
              this.componentData.printUnit = data.page.list[0].printUnit
              this.componentData.printUnitName = data.page.list[0].printUnitName
              return
            }
          }
        })
      }
      this.componentData.componentPartDesc = ''
      this.componentData.printUnit = ''
      this.componentData.printUnitName = ''
    },

    // copy物料编码失焦事件
    copyPartBlur () {
      if (this.copyPartData.type === '1') {
        if (this.copyRecipeData.partNo != null && this.copyRecipeData.partNo !== '') {
          this.copyPartData.limit = this.pageSize4
          this.copyPartData.page = this.pageIndex4
          this.copyPartData.partNo = this.copyRecipeData.partNo
          queryPartList(this.copyPartData).then(({data}) => {
            if (data && data.code === 0) {
              if (data.page.list.length === 1) {
                this.copyRecipeData.partDesc = data.page.list[0].partDesc
                return
              }
            }
          })
        }
        this.copyRecipeData.partDesc = ''
      } else {
        if (this.copyAlternativeData.partNo != null && this.copyAlternativeData.partNo !== '') {
          this.copyPartData.limit = this.pageSize4
          this.copyPartData.page = this.pageIndex4
          this.copyPartData.partNo = this.copyAlternativeData.partNo
          queryPartList(this.copyPartData).then(({data}) => {
            if (data && data.code === 0) {
              if (data.page.list.length === 1) {
                this.copyAlternativeData.partDesc = data.page.list[0].partDesc
                return
              }
            }
          })
        }
        this.copyAlternativeData.partDesc = ''
      }
    },

    // copy Recipe类型改变
    copyBomTypeChange () {
      // 获取物料的recipe版本号
      getRecipeEngChgLevel(this.copyRecipeData).then(({data}) => {
        if (data && data.code === 0) {
          this.copyRecipeData.engChgLevel = data.engChgLevel
        } else {
          this.copyRecipeData.engChgLevel = ''
        }
      })
    },

    // 表格的新增
    rowClassName({ row, rowIndex }) {
      row.xh = rowIndex + 1
    },

    // 选中数据
    componentSelectionChange(selection) {
      this.checkedDetail = selection
    },

    byProductSelection (selection) {
      this.checkedByProduct = selection
    },

    // 删除子物料
    deleteComponentPart () {
      if (this.checkedDetail.length === 0) {
        this.$message.warning('请选择要删除子物料！')
        return
      } else {
        this.$confirm("请是否确认删除该子明细记录?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          let tempData = {
            informationList: this.checkedDetail,
            productFlag: 'component',
            updateBy: this.$store.state.user.name,
          }
          deleteRecipeComponent(tempData).then(({data}) => {
            if (data && data.code === 0) {
              this.subDetailList = data.rows.subDetailList
              this.byProductList = data.rows.byProductList
              this.manufStructCostDistribList = data.rows.manufStructCostDistribList
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        })
      }
    },

    // 删除子物料
    deleteByProduct () {
      if (this.checkedByProduct.length === 0) {
        this.$message.warning('请选择要删除副产品！')
        return
      } else {
        this.$confirm("请是否确认删除该副产品记录?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          let tempData = {
            informationList: this.checkedByProduct,
            productFlag: 'byProduct',
            updateBy: this.$store.state.user.name,
          }
          deleteRecipeComponent(tempData).then(({data}) => {
            if (data && data.code === 0) {
              this.subDetailList = data.rows.subDetailList
              this.byProductList = data.rows.byProductList
              this.manufStructCostDistribList = data.rows.manufStructCostDistribList
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        })
      }
    },

    // 子物料
    componentClickRow (row) {
      this.$refs.componentTable.toggleRowSelection(row)
    },

    byProductClickRow (row) {
      this.$refs.byProductTable.toggleRowSelection(row)
    },

    // 重量分配改变
    changeWeightShare () {
      this.componentData.partsByWeight = this.componentData.weightShare
      this.componentData.qtyUom = this.componentData.weightShare / 100
      this.componentData.qtyPerAssembly = this.componentData.weightShare / 100
      this.componentData.qtyKg = this.componentData.weightShare / 100
    },

    // 新增子明细方法
    componentDataSave (isClose) {
      if (this.componentData.lineSequence === '' || this.componentData.lineSequence == null) {
        this.$message.warning('序号不能为空！')
        return
      }
      if (this.componentData.partNo === '' || this.componentData.partNo == null) {
        this.$message.warning('请选择主记录物料编码！')
        return
      }
      if (this.componentData.bomType === '' || this.componentData.bomType == null) {
        this.$message.warning('请选择主记录制造类型！')
        return
      }
      if (this.componentData.engChgLevel === '' || this.componentData.engChgLevel == null) {
        this.$message.warning('请填写主记录Recipe版本号！')
        return
      }
      if (this.componentData.componentPart === '' || this.componentData.componentPart == null) {
        this.$message.warning('请选择子物料编码！')
        return
      }
      if (this.componentData.productFlag === 'component' && (this.componentData.consumptionItem === '' || this.componentData.consumptionItem == null)) {
        this.$message.warning('请选择消耗项目！')
        return
      }
      if (this.componentData.weightShare === '' || this.componentData.weightShare == null) {
        this.$message.warning('请填写重量分配！')
        return
      }
      if (this.componentData.issueType === '' || this.componentData.issueType == null) {
        this.$message.warning('请选择生产属性！')
        return
      }
      if (this.componentData.flag === '1') {
        saveRecipeComponent(this.componentData).then(({data}) => {
          if (data && data.code === 0) {
            this.subDetailList = data.rows.subDetailList
            this.byProductList = data.rows.byProductList
            this.manufStructCostDistribList = data.rows.manufStructCostDistribList
            if (isClose) {
              if (this.subDetailTable === 'by_products') {
                this.saveByProductModal()
              } else {
                this.saveComponentModal()
              }
            } else {
              this.componentSaveModal = false
            }
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      } else if (this.componentData.flag === '2') {
        updateRecipeComponent(this.componentData).then(({data}) => {
          if (data && data.code === 0) {
            this.subDetailList = data.rows.subDetailList
            this.byProductList = data.rows.byProductList
            this.componentSaveModal = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      }
    },

    // 编辑副产品成本分配方法
    manufStructCostDistribUpdate () {
      if (this.manufStructCostDistribData.itemCostDistribution < 0 || this.manufStructCostDistribData.itemCostDistribution > 1) {
        this.$message.warning('项目成本分配系数必须介于0和1之间！')
        return
      }
      updateManufStructCostDistrib(this.manufStructCostDistribData).then(({data}) => {
        if (data && data.code === 0) {
          this.manufStructCostDistribList = data.rows.manufStructCostDistribList
          this.manufStructCostDistribModal = false
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    // 回车事件
    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()
      })
    },

    // 保存主表信息
    saveRecipeHeader () {
      if (this.modalData.partNo === '' || this.modalData.partNo == null) {
        this.$message.warning('请先选择Recipe物料！')
        return
      }
      if (this.modalData.engChgLevel === '' || this.modalData.engChgLevel == null) {
        this.$message.warning('请先填写Recipe版本号！')
        return
      }
      if (this.modalData.bomType === '' || this.modalData.bomType == null) {
        this.$message.warning('请先选择制造类型！')
        return
      }
      if (this.modalData.typeFlag === '' || this.modalData.typeFlag == null) {
        this.$message.warning('请先选择类型！')
        return
      }
      this.saveHeaderLoading = true
      // 新增主表信息
      saveRecipeHeader(this.modalData).then(({data}) => {
        if (data && data.code === 0) {
          this.modalData = {
            flag: '1',
            title: 'recipe新增',
            site: data.rows.modalData.site,
            partNo: data.rows.modalData.partNo,
            partDesc: data.rows.modalData.partDesc,
            engChgLevel: data.rows.modalData.engChgLevel,
            bomType: data.rows.modalData.bomType,
            noteText: data.rows.modalData.noteText,
            effPhaseInDate: data.rows.modalData.effPhaseInDate,
            effPhaseOutDate: data.rows.modalData.effPhaseOutDate,
            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.headerSaveFlag = false
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
        this.saveHeaderLoading = false
      })
    },

    // 复制recipe的模态框
    copyRecipeRevision () {
      this.copyRecipeData = {
        site: this.modalData.site,
        partNo: this.modalData.partNo,
        partDesc: this.modalData.partDesc,
        engChgLevel: '',
        bomType: this.modalData.bomType,
        effPhaseInDate: this.dayjs(new Date()).format('YYYY-MM-DD'),
        effPhaseOutDate: '',
        previousVersion: {},
        createBy: this.$store.state.user.name,
        officialFlag: 'N'
      }
      // 获取物料的recipe版本号
      getRecipeEngChgLevel(this.copyRecipeData).then(({data}) => {
        if (data && data.code === 0) {
          this.copyRecipeData.engChgLevel = data.engChgLevel
        }
      })
      this.copyPartData = {
        type: '1',
        site: this.$store.state.user.site,
        partNo: '',
        plmPartNo: '',
        ifsPartNo: '',
        partDesc: '',
        page: 1,
        limit: 10
      }
      this.copyRecipeModelFlag = true
    },

    // 复制recipe的方法
    copyRecipe () {
      if (this.copyRecipeData.partNo === '' || this.copyRecipeData.partNo == null) {
        this.$message.warning('请选择Recipe物料！')
        return
      }
      if (this.copyRecipeData.engChgLevel === '' || this.copyRecipeData.engChgLevel == null) {
        this.$message.warning('请填写Recipe版本号！')
        return
      }
      if (this.copyRecipeData.bomType === '' || this.copyRecipeData.bomType == null) {
        this.$message.warning('请选择制造类型！')
        return
      }
      if (this.copyRecipeData.effPhaseOutDate != null && this.copyRecipeData.effPhaseOutDate !== '' && this.copyRecipeData.effPhaseOutDate < this.copyRecipeData.effPhaseInDate) {
        this.$message.warning('失效日期必须大于生效日期！')
        return
      }
      this.copyRecipeData.previousVersion = this.modalData
      this.copyLoading = true
      // 新增主表信息
      copyRecipe(this.copyRecipeData).then(({data}) => {
        if (data && data.code === 0) {
          this.copyRecipeModelFlag = false
          this.updateModal(data.rows)
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
        this.copyLoading = false
      }).catch(()=>{
        this.copyLoading = false
      })
    },

    // 复制alternative的模态框
    copyRecipeAlternative () {
      this.copyAlternativeData = {
        site: this.detailData.site,
        partNo: this.detailData.partNo,
        partDesc: this.modalData.partDesc,
        engChgLevel: this.detailData.engChgLevel,
        bomType: this.detailData.bomType,
        alternativeNo: this.detailData.alternativeNo,
        alternativeDescription: this.detailData.alternativeDescription,
        minLotQty: this.detailData.minLotQty,
        defaultFlag: this.detailData.defaultFlag,
        detailNoteText: this.detailData.detailNoteText,
        status: 'Tentative',
        officialFlag: 'N',
        previousVersion: {},
        createBy: this.$store.state.user.name
      }
      this.copyPartData = {
        type: '2',
        site: this.$store.state.user.site,
        partNo: '',
        plmPartNo: '',
        ifsPartNo: '',
        partDesc: '',
        page: 1,
        limit: 10
      }
      this.copyAlternativeModelFlag = true
    },

    // 复制alternative的方法
    copyAlternative () {
      if (this.copyAlternativeData.partNo === '' || this.copyAlternativeData.partNo == null) {
        this.$message.warning('请选择Recipe物料！')
        return
      }
      if (this.copyAlternativeData.engChgLevel === '' || this.copyAlternativeData.engChgLevel == null) {
        this.$message.warning('请填写Recipe版本号！')
        return
      }
      if (this.copyAlternativeData.bomType === '' || this.copyAlternativeData.bomType == 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
      this.copyLoading = true
      copyAlternative(this.copyAlternativeData).then(({data}) => {
        if (data && data.code === 0) {
          this.copyAlternativeModelFlag = false
          this.updateModal(data.rows)
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
        this.copyLoading = false
      }).catch(()=>{
        this.copyLoading = false
      })
    },

    // 新增替代方法
    detailDataSave () {
      if (this.saveDetailData.partNo === '' || this.saveDetailData.partNo == null) {
        this.$message.warning('请先选择Recipe物料！')
        return
      }
      if (this.saveDetailData.engChgLevel === '' || this.saveDetailData.engChgLevel == null) {
        this.$message.warning('请先填写Recipe版本号！')
        return
      }
      if (this.saveDetailData.bomType === '' || this.saveDetailData.bomType == 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
      }
      if (this.saveDetailData.displayWeightUom === '' || this.saveDetailData.displayWeightUom == null) {
        this.$message.warning('请选择重量单位！')
        return
      }
      if (this.saveDetailData.displayVolumeUom === '' || this.saveDetailData.displayVolumeUom == null) {
        this.$message.warning('请选择体积单位！')
        return
      }
      this.saveDetailLoading = true
      if (this.saveDetailData.flag === '1') {
        recipeDetailSave(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 {
        recipeDetailUpdate(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
        })
      }
    },

    // 删除替代
    deleteRecipeDetail () {
      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(() => {
        this.detailData.updateBy = this.$store.state.user.name
        recipeDetailDelete(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: '确定'
            })
          }
        })
      })
    },

    // 修改替代状态为 Buildable
    updateStatusToBuildable () {
      this.detailData.updateBy = this.$store.state.user.name
      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()
          }
        })
      })
    },

    // 修改替代状态为 Obsolete
    updateStatusToObsolete () {
      this.detailData.updateBy = this.$store.state.user.name
      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()
          }
        })
      })
    },

    // 替代改变事件
    alternativeChange () {
      queryRecipeComponent(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.refreshSubDetailTable()
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    // 临时Recipe转为正式Recipe
    toBecomeOfficialRecipe () {
      this.detailData.updateBy = this.$store.state.user.name
      this.toBecomeOfficialLoading = true
      toBecomeOfficialRecipe(this.detailData).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.toBecomeOfficialLoading = false
      }).catch(()=>{
        this.toBecomeOfficialLoading = false
      })
    },

    // 根据物料编码查询工序
    queryOperationList () {
      this.operationData.partNo = this.modalData.partNo
      // 查询所有
      queryOperationList(this.operationData).then(({data}) => {
        if (data && data.code === 0) {
          this.operationList = data.rows
          this.operationData = {
            site: this.$store.state.user.site,
            partNo: this.modalData.partNo,
            routingRevision: '',
            routingType: '',
            alternativeNo: '',
            operationNo: '',
            operationName: '',
          }
          this.operationModelFlag = true
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    // ======== chooseList相关方法 ========
    // 获取基础数据列表S
    getBaseList (val, type) {
      this.tagNo = val
      this.$nextTick(() => {
        let strVal = ''
        if (val === 117) {
          strVal = this.componentData.issueToLoc
        } else if (val === 1008) {
          strVal = this.saveDetailData.displayWeightUom
        } else if (val === 1009) {
          strVal = this.saveDetailData.displayVolumeUom
        }
        this.$refs.baseList.init(val, strVal)
      })
    },

    // 列表方法的回调
    getBaseData (val) {
      if (this.tagNo === 117) {
        this.componentData.issueToLoc = val.location_id
        this.componentData.issueToLocName = val.location_name
      } else if (this.tagNo === 1008) {
        this.saveDetailData.displayWeightUom = val.um_id
      } else if (this.tagNo === 1009) {
        this.saveDetailData.displayVolumeUom = val.um_id
      }
    },

    // ======== 导出相关方法 ========
    // 导出excel
    async createExportData () {
      this.searchData.limit = -1
      this.searchData.page = 1
      await recipeManagementSearch(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
    },

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

<style scoped lang="scss">
/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>










