<template>
  <div class="white-body-view">
    <el-form :inline="true" label-position="top" :model="searchData">
      <el-form-item label="BU">
        <el-input v-model="searchData.buNo" readonly style="width: 80px"></el-input>
      </el-form-item>
      <el-form-item label="产品编码">
        <el-input v-model="searchData.partNo" readonly style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item label="产品描述">
        <el-input v-model="searchData.partDesc" readonly style="width: 300px"></el-input>
      </el-form-item>
      <el-form-item label=" ">
        <el-button type="primary" @click="queryPartListInfo">选择物料</el-button>
      </el-form-item>
      <el-form-item label=" ">
        <el-button type="primary" @click="updatePartModal">维护</el-button>
      </el-form-item>
      <el-form-item label=" ">
        <el-button type="primary" @click="handleBatchUpdatePart">物料属性批量维护</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :height="60"
      :data="dataList"
      border
      v-loading="this.dataListLoading"
      style="width: 100%;">
      <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">
          <div v-if="!item.columnHidden" @dblclick="startEditCell(scope.$index, item.columnProp, scope.row[item.columnProp])" style="min-height: 23px; cursor: pointer;" :title="editingCell.rowIndex === scope.$index && editingCell.columnProp === item.columnProp ? '' : '双击编辑,回车保存'">
            <el-input
              v-if="editingCell.rowIndex === scope.$index && editingCell.columnProp === item.columnProp"
              v-model="editingCell.value"
              size="small"
              ref="editInput"
              :disabled="editingCell.isSaving"
              @keyup.enter.native="saveEditCell(scope.$index, item.columnProp, item.columnLabel)"
              @keyup.esc.native="cancelEditCell"
              style="width: 100%;">
            </el-input>
            <span v-else>{{ scope.row[item.columnProp] || '-' }}</span>
          </div>
          <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
        </template>
      </el-table-column>
    </el-table>

    <el-row :gutter="5">
      <!-- 树形结构 -->
      <el-col :span="7" :style="{height: this.height + 'px'}" style="display: block;overflow-y: scroll">
        <el-card style="width: 99%">
          <div slot="header" style="height: 20px;margin-top: -10px;text-align: center">
            <el-button size="mini" type="primary" round style="margin-left: -5px" @click="addTree">新增节点</el-button>
            <el-button size="mini" type="info" round @click="getNodeTree">刷新</el-button>
            <el-button size="mini" type="primary" round :loading="buildAllLoading" @click="batchBuild" style="margin-left: 10px">批量Build</el-button>
<!--            <el-button size="mini" type="primary" round :loading="resetAllLoading" @click="resetNodePart">重置物料</el-button>-->
          </div>
          <div class="scroll-bar item">
            <el-tree
              id="my-tree"
              class="tree-view structure-tree scroll-bar"
              highlight-current
              check-strictly
              :data="treeData"
              :default-expand-all=true
              :props="defaultProps"
              :expand-on-click-node=false
              @node-click="handleNodeClick"
              :auto-expand-parent=false>
              <span slot-scope="{ node, data }" class="custom-tree-node">
                <span class="tooltip">
                  <span class="add-f-s-14">{{ data.nodeName }}</span>
                </span>
                <div class="operation-view" style="display: inline-block; padding: 0px 5px; margin-left: 5px; color: #777777;">
<!--                  <i style="color:#1c92e0" class="small-operation-btn el-icon-plus" @click="addTreeItem(data)"/>-->
<!--                  <i style="color:#1c92e0" class="small-operation-btn el-icon-edit" @click="editTreeItem(data)"/>-->
<!--                  <i style="color:#1c92e0" class="small-operation-btn el-icon-delete" @click="deleteTreeItem(data)"/>-->
                  <el-popover
                    placement="right"
                    width="80"
                    trigger="click">
                    <a style="cursor: pointer" @click="queryPartList2(data)">已有料号</a>
                    <el-divider></el-divider>
                    <a style="cursor: pointer" @click="addPartModal(data)">新增料号</a>
                    <el-divider></el-divider>
                    <a style="cursor: pointer" @click="editTreeItem(data)">修改节点</a>
                    <el-divider></el-divider>
                    <a style="cursor: pointer" @click="deleteTreeItem(data)">删除节点</a>
                    <i style="color:#1c92e0" slot="reference" class="small-operation-btn el-icon-more"/>
                  </el-popover>
                </div>
              </span>
            </el-tree>
          </div>
        </el-card>
      </el-col>
      <!-- 数据 -->
      <el-col :span="17" :style="{height: this.height + 'px'}" style="display: block;overflow-y: scroll">
        <!-- 页签 -->
        <el-tabs v-model="activeTable" :style="{height: this.height + 'px'}" style="width: 100%" type="border-card" @tab-click="refreshCurrentTabTable" class="customer-tab">
          <!-- BOM页签 -->
          <el-tab-pane label="产品BOM管理" name="bom_info">
            <bom-create v-loading="bomLoading" ref="BomCreate" :batchUpdateFlag="batchUpdateFlag" @handleBatchUpdatePart="handleBatchUpdatePart" @refreshNode="refreshNode" @refreshBomLoading="refreshBomLoading" v-drag></bom-create>
          </el-tab-pane>
          <!-- Routing页签 -->
          <el-tab-pane label="工艺路线管理" name="routing_info">
            <routing-create v-loading="routingLoading" ref="RoutingCreate" :batchUpdateFlag="batchUpdateFlag" @refreshRoutingLoading="refreshRoutingLoading" v-drag></routing-create>
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>

    <!-- 节点新增模态框 -->
    <el-dialog title="节点" :close-on-click-modal="false" v-drag :visible.sync="nodeModalFlag" width="360px">
      <el-form :inline="true" label-position="top" :model="nodeData" :rules="nodeRules" style="margin-left: 7px;margin-top: -5px;">
<!--        <el-form-item label="节点编码" prop="nodeId" :rules="nodeRules.nodeId">-->
<!--          <el-input v-model="nodeData.nodeId" :disabled="nodeModalDisableFlag" style="width: 140px"></el-input>-->
<!--        </el-form-item>-->
        <el-form-item label="节点名称" prop="nodeName" :rules="nodeRules.nodeName">
          <el-input v-model="nodeData.nodeName" style="width: 320px"></el-input>
        </el-form-item>
        <el-form-item v-if="this.nodeData.flag === '1'" label="父节点" prop="pId" :rules="nodeRules.parentNodeName">
          <el-popover
            ref="nodeListPopover"
            placement="bottom-start"
            v-model="treeVisible"
            onclick="treeVisible=true"
            trigger="click">
            <el-tree
              id="my-tree"
              node-key="nodeId"
              class="tree-view structure-tree scroll-bar"
              highlight-current
              check-strictly
              @current-change="nodeListTreeCurrentChangeHandle"
              :data="treeData1"
              :default-expand-all=true
              :props="defaultProps"
              :expand-on-click-node=false
              :auto-expand-parent=false>
            </el-tree>
          </el-popover>
          <el-input style="width: 140px;" v-model="nodeData.parentNodeName" v-popover:nodeListPopover :readonly="true"  class="node-list__input"></el-input>
        </el-form-item>
        <el-form-item label="子节点" v-if="this.nodeData.flag === '1'" :rules="nodeRules.id">
          <el-select v-model="nodeData.id" style="width: 100%;">
            <el-option :label="item.nodeName" :value="item.id" v-for="item in childrenNodeList" :key="item.id"></el-option>
            <el-option label="无" value="-1"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="saveNodeData()">保存</el-button>
        <el-button type="primary" @click="nodeModalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 物料模态框 -->
    <el-dialog title="物料清单" :close-on-click-modal="false" v-drag :visible.sync="partModelFlag" width="900px">
      <div class="rq">
        <el-form :inline="true" label-position="top" :model="partData">
          <el-form-item :label="'物料编码'">
            <el-input v-model="partData.partNo" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'物料名称'">
            <el-input v-model="partData.partDesc" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="' '">
            <el-button type="primary" @click="queryPartList">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table
          :height="300"
          :data="partList"
          @row-dblclick="getRowData"
          border
          style="width: 100%;">
          <el-table-column
            v-for="(item,index) in partColumnList" :key="index"
            :sortable="item.columnSortable"
            :prop="item.columnProp"
            :header-align="item.headerAlign"
            :show-overflow-tooltip="item.showOverflowTooltip"
            :align="item.align"
            :fixed="item.fixed==''?false:item.fixed"
            :min-width="item.columnWidth"
            :label="item.columnLabel">
            <template slot-scope="scope">
              <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
              <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
            </template>
          </el-table-column>
        </el-table>
        <!-- 分页插件 -->
        <el-pagination
          @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:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="partModelFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>

<!--  物料属性批量维护模态框-->
    <el-dialog title="物料属性批量维护" :close-on-click-modal="false" v-drag
               :visible.sync="batchUpdateFlag"
               width="90vw"
               :before-close="handleBatchUpdateDialogClose">
      <div class="rq" slot-scope="scope">
        <div style="display: flex; align-items: center; justify-content: space-between;">
          <div style="display: flex; gap: 10px;">
            <el-button style="height: 20px" type="primary" @click="handleCopy">copy</el-button>
            <el-button style="height: 20px" type="primary" @click="handleEditInfo">{{ attributeFlag ? '编辑' : '保存' }}</el-button>
          </div>
          <el-form label-position="top" inline style="margin-right: -10px;margin-top: -20px">
            <el-form-item label="属性模板">
              <el-select v-model="searchData.codeNo" placeholder="请选择" @change="handleCodeNoChange" style="width: 235px">
                <el-option
                  v-for="option in codeList"
                  :key="option.fieldname1"
                  :label="option.caption1"
                  :value="option.fieldname1">
                </el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
        <el-table
          v-show="attributeFlag"
          @row-click="partClickRow"
          :row-style="rowStyle"
          :height="300"
          :header-cell-style="{padding: '2px 2px'}"
          :data="partList1"
          border
          style="width: 100%;">
          <el-table-column
            header-align="center"
            align="center"
            width="150"
            fixed="left"
            label="操作">
            <template slot-scope="scope">
              <div class="operation-view" style="display: inline-block; padding: 0px 5px; margin-left: 5px; color: #777777;">
                <el-popover
                  placement="right"
                  width="80"
                  trigger="click">
                  <a style="cursor: pointer" @click="queryPartList2(scope.row)">已有料号</a>
<!--                  <el-divider></el-divider>
                  <a style="cursor: pointer" @click="addPartModal(scope.row)">新增料号</a>-->
                  <i style="color:#1c92e0" slot="reference" class="small-operation-btn el-icon-more"/>
                </el-popover>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            v-for="(item,index) in partColumnList1" :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">
                <span v-if="item.columnProp==='partType2'">
                  <span v-if="scope.row.partType2==='Manufactured'">
                    成品
                  </span>
                  <span v-if="scope.row.partType2==='Manufactured Recipe'">
                    半成品
                  </span>
                  <span v-if="scope.row.partType2==='Purchased (raw)'">
                    原材料
                  </span>
                </span>
                <span v-if="item.columnProp!=='partType2'">
                  {{scope.row[item.columnProp]}}
                </span>
              </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-table
          v-show="!attributeFlag"
          :height="300"
          @row-click="partClickRow"
          :row-style="rowStyle"
          :header-cell-style="{padding: '2px 2px'}"
          :data="partList1"
          border
          style="width: 100%;">
          <el-table-column
            header-align="center"
            align="center"
            width="150"
            fixed="left"
            label="操作">
            <template slot-scope="scope">
              <div class="operation-view" style="display: inline-block; padding: 0px 5px; margin-left: 5px; color: #777777;">
                <el-popover
                  placement="right"
                  width="80"
                  trigger="click">
                  <a style="cursor: pointer" @click="queryPartList2(scope.row)">已有料号</a>
                  <i style="color:#1c92e0" slot="reference" class="small-operation-btn el-icon-more"/>
                </el-popover>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            v-for="(item,index) in partColumnList2" :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-show="!item.columnHidden">
                <span v-if="item.columnProp==='partNo'||item.columnProp==='nodeName'">{{scope.row[item.columnProp]}}</span>
                <span v-if="item.columnProp==='buNo'">
                  <el-select v-model="scope.row.buNo" v-show="!scope.row.partNo||scope.row.partNo===''" clearable @change="changeBuOfNode(scope.row)" placeholder="请选择">
                    <el-option
                      v-for = "i in userBuList"
                      :key = "i.buNo.split('_')[1]"
                      :label = "i.buNo.split('_')[1]"
                      :value = "i.buNo.split('_')[1]">
                    </el-option>
                  </el-select>
                  <span v-if="scope.row.partNo&&scope.row.partNo!==''">{{scope.row[item.columnProp]}}</span>
                </span>
                <span v-if="item.columnProp==='partDesc'">
                  <el-input v-model="scope.row.partDesc" clearable></el-input>
                </span>
                <span v-if="item.columnProp==='tempNo'">
                  <el-select :loading="buNoQueryLoading" v-model="scope.row.tempNo" clearable @change="chooseTemplate(scope.row)">
                    <el-option
                      v-for="option in scope.row.tempList"
                      :key="option.templateNo"
                      :label="option.templateName"
                      :value="option.templateNo">
                    </el-option>
                  </el-select>
                </span>
                <span v-if="item.columnProp==='engChgLevel'">
                  <el-select :loading="buNoQueryLoading" v-model="scope.row.engChgLevel" clearable>
                    <el-option
                      v-for="option in scope.row.engChgLevelList"
                      :key="option"
                      :label="option"
                      :value="option">
                    </el-option>
                  </el-select>
                </span>
                <span v-if="item.columnProp==='routingRevision'">
                  <el-select :loading="buNoQueryLoading" v-model="scope.row.routingRevision" clearable>
                    <el-option
                      v-for="option in scope.row.routingRevisionList"
                      :key="option"
                      :label="option"
                      :value="option">
                    </el-option>
                  </el-select>
                </span>
                <span v-if="item.columnProp==='codeDesc'">
                  <el-select v-model="scope.row.codeNo" placeholder="请选择" clearable style="width: 200px">
                    <el-option :loading="buNoQueryLoading"
                      v-for="option in scope.row.codeList"
                      :key="option.fieldname1"
                      :label="option.caption1"
                      :value="option.fieldname1">
                    </el-option>
                  </el-select>
                </span>
                <span v-if="item.columnProp==='partType2'">
                  <el-select v-model="scope.row.partType2" clearable>
                    <el-option label="成品" value="Manufactured"></el-option>
                    <el-option label="半成品" value="Manufactured Recipe"></el-option>
                    <el-option label="原材料" value="Purchased (raw)"></el-option>
                  </el-select>
                </span>
                <span v-if="item.columnProp==='umName'">
                  <el-select
                    v-model="scope.row.umId2" clearable>
                    <el-option
                      v-for="option in scope.row.umList"
                      :key="option.fieldname1"
                      :label="option.caption1"
                      :value="option.fieldname1">
                    </el-option>
                  </el-select>
                </span>
                <span v-if="item.columnProp==='familyName'">
                  <el-select :loading="buNoQueryLoading"
                    v-model="scope.row.familyID" clearable>
                    <el-option
                      v-for="option in scope.row.partFamilyList"
                      :key="option.fieldname1"
                      :label="option.caption1"
                      :value="option.fieldname1">
                    </el-option>
                  </el-select>
                </span>
                <span v-if="item.columnProp==='productGroupName1'">
                  <el-select :loading="buNoQueryLoading"
                    v-model="scope.row.productGroupId1" clearable>
                    <el-option
                      v-for="option in scope.row.partProductGroupList1"
                      :key="option.fieldname1"
                      :label="option.caption1"
                      :value="option.fieldname1">
                    </el-option>
                  </el-select>
                </span>
                <span v-if="item.columnProp==='productGroupName2'">
                  <el-select :loading="buNoQueryLoading"
                    v-model="scope.row.productGroupId2" clearable>
                    <el-option
                      v-for="option in scope.row.partProductGroupList2"
                      :key="option.fieldname1"
                      :label="option.caption1"
                      :value="option.fieldname1">
                    </el-option>
                  </el-select>
                </span>
                <span v-if="item.columnProp==='productGroupName3'">
                  <el-select :loading="buNoQueryLoading"
                    v-model="scope.row.productGroupId3" clearable>
                    <el-option
                      v-for="option in scope.row.partProductGroupList3"
                      :key="option.fieldname1"
                      :label="option.caption1"
                      :value="option.fieldname1">
                    </el-option>
                  </el-select>
                </span>
                <span v-if="item.columnProp==='templateName'">
                  <el-select :loading="buNoQueryLoading"
                    v-model="scope.row.templateNo" clearable>
                    <el-option
                      v-for="option in scope.row.templateList"
                      :key="option.fieldname1"
                      :label="option.caption1"
                      :value="option.fieldname1">
                    </el-option>
                  </el-select>
                </span>
                <span v-if="item.columnProp==='remark'">
                  <el-input
                    type="textarea"
                    :autosize="{ minRows: 1}"
                    v-model="scope.row.remark">
                  </el-input>
                </span>

              </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-tabs v-model="inventoryPartTable" style="width: 100%;height: 400px;" :before-leave="tabLeave" @tab-click="tabClick" type="border-card">
          <el-tab-pane label="新增物料属性" style="margin-top: -10px" name="part_item">
            <el-form label-position="top" style="margin-left: 2px;">
              <el-button type="primary" @click="addOrDelItem1">新增</el-button>
              <el-button type="primary" :loading="loading" @click="clickSave1">{{ attributeFlag1?'编辑':'保存' }}</el-button>
              <el-button type="primary" @click="openPtmDialog">ProcessTimeMatrix</el-button>
            </el-form>
            <div class="rq " v-show="attributeFlag1">
              <el-table
                :data="partItemList1"
                height="340px"
                border
                :header-cell-style="{padding: '2px 2px'}"
                style="width: 100%;">
                <el-table-column
                  v-for="(item,index) in columnItemList" :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">
                    <div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
                      <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>
                    </div>
                    <div v-else>
                      <template v-if="item.columnProp==='textValue' && scope.row.valueTypeDb==='T'">
                        {{ scope.row['textValue'] }}
                      </template>
                      <template v-else-if="item.columnProp==='textValue' && scope.row.valueTypeDb==='N'">
                        {{ scope.row['numValue'] }}
                      </template>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <div class="rq " v-show="!attributeFlag1">
              <el-table
                :data="partItemList1"
                height="340px"
                border
                :header-cell-style="{padding: '2px 2px'}"
                style="width: 100%">
                <el-table-column
                  v-for="(item,index) in columnItemList" :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">
                    <div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
                      <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>
                    </div>
                    <div v-else>
                      <div v-if="scope.row.valueChooseFlag !== 'Y'">
                        <el-input-number v-model="scope.row.numValue" style="padding: 0;width: 100%" v-if="scope.row.valueTypeDb === 'N'" :controls="false"></el-input-number>
                        <el-input v-model="scope.row.textValue" v-else></el-input>
                      </div>
                      <div v-else>
                        <el-select style="width: 100%;" clearable v-if="scope.row.valueTypeDb === 'T'" v-model="scope.row.textValue">
                          <el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.availableValueList" :key="key"></el-option>
                        </el-select>
                        <el-select style="width: 100%;" clearable v-else v-model="scope.row.numValue">
                          <el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.availableValueList" :key="key"></el-option>
                        </el-select>
                      </div>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
          <el-tab-pane label="已有物料属性" style="margin-top: -10px" name="part_item1">
            <el-form label-position="top" style="margin-left: 2px;">
              <el-button type="primary" @click="addOrDelItem">新增</el-button>
              <el-button type="primary" :loading="loading" @click="clickSave">{{ attributeFlag1?'编辑':'保存' }}</el-button>
            </el-form>
            <div class="rq " v-show="attributeFlag1">
              <el-table
                :data="partItemList"
                height="340px"
                border
                :header-cell-style="{padding: '2px 2px'}"
                style="width: 100%;">
                <el-table-column
                  v-for="(item,index) in columnItemList" :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">
                    <div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
                      <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>
                    </div>
                    <div v-else>
                      <template v-if="item.columnProp==='textValue' && scope.row.valueTypeDb==='T'">
                        {{ scope.row['textValue'] }}
                      </template>
                      <template v-else-if="item.columnProp==='textValue' && scope.row.valueTypeDb==='N'">
                        {{ scope.row['numValue'] }}
                      </template>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <div class="rq " v-show="!attributeFlag1">
              <el-table
                :data="partItemList"
                height="340px"
                border
                :header-cell-style="{padding: '2px 2px'}"
                style="width: 100%">
                <el-table-column
                  v-for="(item,index) in columnItemList" :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">
                    <div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
                      <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>
                    </div>
                    <div v-else>
                      <div v-if="scope.row.valueChooseFlag !== 'Y'">
                        <el-input-number v-model="scope.row.numValue" style="padding: 0;width: 100%" v-if="scope.row.valueTypeDb === 'N'" :controls="false"></el-input-number>
                        <el-input v-model="scope.row.textValue" v-else></el-input>
                      </div>
                      <div v-else>
                        <el-select style="width: 100%;" v-if="scope.row.valueTypeDb === 'T'" v-model="scope.row.textValue">
                          <el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.availableValueList" :key="key"></el-option>
                        </el-select>
                        <el-select style="width: 100%;" v-else v-model="scope.row.numValue">
                          <el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.availableValueList" :key="key"></el-option>
                        </el-select>
                      </div>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
          <el-tab-pane label="版本信息" style="margin-top: -10px" name="revision_info">
            <el-row>
              <el-col :style="{width: 25 + 'vw',height: 340 + 'px'}" class="down-tree">
                <el-tabs v-model="activeTab1" style="width: 100%;height: 170px; margin-top: -5px" @tab-click="bomInfoTabClick">
                  <el-tab-pane label="产品结构版本" name="default">
                    <el-table
                      :height="120"
                      :data="bomComponentList"
                      border
                      :header-cell-style="{padding: '2px 2px'}"
                      :row-style="bomRowStyle"
                      @row-click="bomInfoRowClick"
                      @row-dblclick="bomInfoRowDblClick"
                      style="width: 100%">
                      <el-table-column
                        header-align="center"
                        align="center"
                        width="80"
                        fixed="left"
                        label="操作">
                        <template slot-scope="scope">
                          <div class="operation-view" style="display: inline-block; padding: 0px 5px; margin-left: 5px; color: #777777;">
                            <a href="javascript:void(0)" @click="updateRevision(scope.row, 'bom')">
                              选择版本
                            </a>
                          </div>
                        </template>
                      </el-table-column>
                      <el-table-column
                        v-for="(item,index) in bomComponentListColumns" :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>
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-tab-pane>
                </el-tabs>
                <el-tabs v-model="activeTab2" style="width: 100%;height: 165px;" @tab-click="routingInfoTabClick">
                  <el-tab-pane label="工艺路线版本" name="default">
                    <el-table
                      :height="120"
                      :data="routingComponentList"
                      border
                      :header-cell-style="{padding: '2px 2px'}"
                      :row-style="routingRowStyle"
                      @row-click="routingInfoRowClick"
                      @row-dblclick="routingInfoRowDblClick"
                      style="width: 100%">
                      <el-table-column
                        header-align="center"
                        align="center"
                        width="80"
                        fixed="left"
                        label="操作">
                        <template slot-scope="scope">
                          <div class="operation-view" style="display: inline-block; padding: 0px 5px; margin-left: 5px; color: #777777;">
                            <a href="javascript:void(0)" @click="updateRevision(scope.row, 'bom')">
                              选择版本
                            </a>
                          </div>
                        </template>
                      </el-table-column>
                      <el-table-column
                        v-for="(item,index) in routingComponentListColumns" :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>
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-tab-pane>
                </el-tabs>
              </el-col>
              <el-col :style="{width: 60 + 'vw',height: 340 + 'px'}">
                <el-table
                  v-if="bomFlag"
                  :height="340"
                  :data="bomComponentPartList"
                  border
                  :header-cell-style="{padding: '2px 2px'}"
                  style="width: 100%">
                  <el-table-column
                    v-for="(item,index) in bomComponentListColumnList" :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-table
                  v-if="!bomFlag"
                  :height="340"
                  :data="routingComponentPartList"
                  border
                  :header-cell-style="{padding: '2px 2px'}"
                  style="width: 100%">
                  <el-table-column
                    v-for="(item,index) in routingComponentListColumnList" :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-col>
            </el-row>
          </el-tab-pane>
        </el-tabs>
        <el-footer style="height:40px;margin-top: 20px;text-align:center">
          <el-button type="primary" @click="handleBatchUpdateDialogClose">关闭</el-button>
        </el-footer>
      </div>
    </el-dialog>


    <el-dialog title="新增" :close-on-click-modal="false" v-drag :visible.sync="fastAddFlag" width="1000px">
      <div style="font-size: 12px">
        <el-form :inline="true" label-position="top" :model="itemData">
          <el-form-item :label="'属性编码'">
            <el-input v-model="itemData.propertiesItemNo" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'属性名称'">
            <el-input v-model="itemData.itemDesc" clearable style="width: 150px"></el-input>
          </el-form-item>
          <el-form-item :label="' '">
            <el-button type="primary" @click="queryPartItem()">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <el-container style="margin-top: 0px;">
        <el-main style="width: 350px;padding: 1px">
          <span style="font-size: 12px" >可选属性</span>
          <el-table
            height="400px"
            :data="itemList1"
            border
            ref="itemTable1"
            @row-click="itemClickRow1"
            @selection-change="selectionItem1"
            highlight-current-row
            style="width: 100%">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              width="50">
            </el-table-column>
            <el-table-column
              prop="itNo"
              header-align="center"
              align="center"
              min-width="80"
              label="属性编码">
            </el-table-column>
            <el-table-column
              prop="itemDesc"
              header-align="center"
              align="center"
              min-width="200"
              label="属性名称">
            </el-table-column>
          </el-table>
        </el-main>
        <el-main style="width: 10px;padding: 1px">
          <div style="margin-top: 200px;margin-left: 18px">
            <el-button type="primary" :loading="addItemLoading" @click="addItem()">添加>></el-button>
          </div>
          <div style="margin-top: 15px;margin-left: 18px">
            <el-button type="primary" :loading="deleteItemLoading" @click="deleteItem()">删除<<</el-button>
          </div>
        </el-main>
        <el-main style="width: 350px;padding: 1px">
          <span style="font-size: 12px" >已有属性</span>
          <el-table
            height="400px"
            :data="itemList2"
            border
            ref="itemTable2"
            @row-click="itemClickRow2"
            @selection-change="selectionItem2"
            highlight-current-row
            style="width: 100%">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              width="50">
            </el-table-column>
            <el-table-column
              prop="itNo"
              header-align="center"
              align="center"
              min-width="80"
              label="属性编码">
            </el-table-column>
            <el-table-column
              prop="itemDesc"
              header-align="center"
              align="center"
              min-width="200"
              label="属性名称">
            </el-table-column>
          </el-table>
        </el-main>
      </el-container>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="fastAddFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <el-dialog title="新增" :close-on-click-modal="false" v-drag :visible.sync="fastAddFlag1" width="1000px">
      <div style="font-size: 12px">
        <el-form :inline="true" label-position="top" :model="itemData">
          <el-form-item :label="'属性编码'">
            <el-input v-model="itemData.propertiesItemNo" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'属性名称'">
            <el-input v-model="itemData.itemDesc" clearable style="width: 150px"></el-input>
          </el-form-item>
          <el-form-item :label="' '">
            <el-button type="primary" @click="queryPartItem()">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <el-container style="margin-top: 0px;">
        <el-main style="width: 350px;padding: 1px">
          <span style="font-size: 12px" >可选属性</span>
          <el-table
            height="400px"
            :data="itemList1"
            border
            ref="itemTable1"
            @row-click="itemClickRow1"
            @selection-change="selectionItem1"
            highlight-current-row
            style="width: 100%">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              width="50">
            </el-table-column>
            <el-table-column
              prop="itNo"
              header-align="center"
              align="center"
              min-width="80"
              label="属性编码">
            </el-table-column>
            <el-table-column
              prop="itemDesc"
              header-align="center"
              align="center"
              min-width="200"
              label="属性名称">
            </el-table-column>
          </el-table>
        </el-main>
        <el-main style="width: 10px;padding: 1px">
          <div style="margin-top: 200px;margin-left: 18px">
            <el-button type="primary" :loading="addItemLoading" @click="addItem1()">添加>></el-button>
          </div>
          <div style="margin-top: 15px;margin-left: 18px">
            <el-button type="primary" :loading="deleteItemLoading" @click="deleteItem1()">删除<<</el-button>
          </div>
        </el-main>
        <el-main style="width: 350px;padding: 1px">
          <span style="font-size: 12px" >已有属性</span>
          <el-table
            height="400px"
            :data="itemList2"
            border
            ref="itemTable2"
            @row-click="itemClickRow2"
            @selection-change="selectionItem2"
            highlight-current-row
            style="width: 100%">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              width="50">
            </el-table-column>
            <el-table-column
              prop="itNo"
              header-align="center"
              align="center"
              min-width="80"
              label="属性编码">
            </el-table-column>
            <el-table-column
              prop="itemDesc"
              header-align="center"
              align="center"
              min-width="200"
              label="属性名称">
            </el-table-column>
          </el-table>
        </el-main>
      </el-container>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="fastAddFlag1 = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <el-dialog :close-on-click-modal="false" v-drag :visible.sync="copyVisible" width="90vw">
      <div class="rq">
        <div style="display: flex; justify-content: space-between;">
          <fieldset style="width: 31vw">
            <legend v-if="partCurrentRow.partNo&&partCurrentRow.partNo!==''">目标物料</legend>
            <legend v-else>新物料</legend>
            <el-form :inline="true" label-position="top" :model="copyData" :rules="rules" ref="copyForm">
              <el-form-item :label="'BU'" prop="buNo">
                <el-select v-model="copyData.buNo" placeholder="请选择" @change="userBuList = userBuList.filter(item => item.buNo!=='')" style="width: 7.5vw">
                  <el-option
                    v-for = "i in userBuList"
                    :key = "i.buNo.split('_')[1]"
                    :label = "i.buNo.split('_')[1]"
                    :value = "i.buNo.split('_')[1]">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item :label="'物料编码'">
                <el-input v-model="copyData.partNo" disabled style="width: 8vw"></el-input>
              </el-form-item>
              <el-form-item :label="'物料描述'" prop="partDesc">
                <el-input v-model="copyData.partDesc" clearable style="width: 10vw"></el-input>
              </el-form-item>
              <el-form-item label="制造类型" v-if="copyData.bomFlag==='Y'" prop="bomType">
                <el-select v-model="copyData.bomType" style="width: 5vw">
                  <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="工艺类型" v-if="copyData.routingFlag==='Y'" prop="routingType">
                <el-select v-model="copyData.routingType" style="width: 5vw">
                  <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="生效日期" v-if="copyData.routingFlag==='Y'||copyData.bomFlag==='Y'" prop="effPhaseInDate">
                <el-date-picker style="width: 7vw" v-model="copyData.effPhaseInDate" clearable type="date" value-format="yyyy-MM-dd" placeholder="选择日期"></el-date-picker>
              </el-form-item>
              <el-form-item label="失效日期" v-if="copyData.routingFlag==='Y'||copyData.bomFlag==='Y'">
                <el-date-picker style="width: 7vw" v-model="copyData.effPhaseOutDate" clearable type="date" value-format="yyyy-MM-dd" placeholder="选择日期"></el-date-picker>
              </el-form-item>
            </el-form>
          </fieldset>
          <fieldset style="width: 57vw">
            <legend>被复制的物料</legend>
            <el-form :inline="true" label-position="top" :model="copyData">
              <el-form-item>
                <span slot="label" @click="queryCopyPartModal"><a herf="#">物料编码</a></span>
                <el-input v-model="copyData.previousVersion.partNo" disabled style="width: 10vw"></el-input>
              </el-form-item>
              <el-form-item label="物料描述">
                <el-input v-model="copyData.previousVersion.partDesc" disabled style="width: 14vw"></el-input>
              </el-form-item>
              <el-form-item label="零件类型">
                <el-input v-model="copyData.previousVersion.partType2Desc" disabled style="width: 5vw"></el-input>
              </el-form-item>
              <el-form-item label="计量单位">
                <el-input v-model="copyData.previousVersion.umName" disabled style="width: 5vw"></el-input>
              </el-form-item>
              <el-form-item label="商品组1">
                <el-input v-model="copyData.previousVersion.productGroupName1" disabled style="width: 12vw"></el-input>
              </el-form-item>
              <el-form-item label="商品组2">
                <el-input v-model="copyData.previousVersion.productGroupName2" disabled style="width: 12vw"></el-input>
              </el-form-item>
              <el-form-item label="BOM版本号">
                <el-input v-model="copyData.previousVersion.engChgLevel" disabled style="width: 5vw"></el-input>
              </el-form-item>
              <el-form-item label="Routing版本号">
                <el-input v-model="copyData.previousVersion.routingRevision" disabled style="width: 5vw"></el-input>
              </el-form-item>
              <el-form-item :label="' '">
                <el-checkbox v-model="copyData.bomFlag" true-label="Y" false-label="N" style="margin-left: 8vw">复制BOM</el-checkbox>
                <el-checkbox v-model="copyData.routingFlag" true-label="Y" false-label="N">复制Routing</el-checkbox>
              </el-form-item>
            </el-form>
          </fieldset>
        </div>
        <fieldset>
          <legend>版本信息</legend>
          <el-row>
            <el-col :style="{width: 25 + 'vw',height: 340 + 'px'}" class="down-tree">
              <el-tabs v-model="activeTab1" style="width: 100%;height: 170px; margin-top: -5px" @tab-click="bomInfoTabClick1">
                <el-tab-pane label="产品结构版本" name="default">
                  <el-table
                    :height="120"
                    :data="bomComponentList1"
                    border
                    :header-cell-style="{padding: '2px 2px'}"
                    :row-style="bomRowStyle1"
                    @row-click="bomInfoRowClick1"
                    @row-dblclick="bomInfoRowDblClick1"
                    style="width: 100%">
                    <el-table-column
                      header-align="center"
                      align="center"
                      width="80"
                      fixed="left"
                      label="操作">
                      <template slot-scope="scope">
                        <div class="operation-view" style="display: inline-block; padding: 0px 5px; margin-left: 5px; color: #777777;">
                          <a href="javascript:void(0)" @click="bomInfoRowDblClick1(scope.row)">
                            选择版本
                          </a>
                        </div>
                      </template>
                    </el-table-column>
                    <el-table-column
                      v-for="(item,index) in bomComponentListColumns" :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>
                      </template>
                    </el-table-column>
                  </el-table>
                </el-tab-pane>
              </el-tabs>
              <el-tabs v-model="activeTab2" style="width: 100%;height: 165px;" @tab-click="routingInfoTabClick1">
                <el-tab-pane label="工艺路线版本" name="default">
                  <el-table
                    :height="120"
                    :data="routingComponentList1"
                    border
                    :header-cell-style="{padding: '2px 2px'}"
                    :row-style="routingRowStyle1"
                    @row-click="routingInfoRowClick1"
                    @row-dblclick="routingInfoRowDblClick1"
                    style="width: 100%">
                    <el-table-column
                      header-align="center"
                      align="center"
                      width="80"
                      fixed="left"
                      label="操作">
                      <template slot-scope="scope">
                        <div class="operation-view" style="display: inline-block; padding: 0px 5px; margin-left: 5px; color: #777777;">
                          <a href="javascript:void(0)" @click="routingInfoRowDblClick1(scope.row)">
                            选择版本
                          </a>
                        </div>
                      </template>
                    </el-table-column>
                    <el-table-column
                      v-for="(item,index) in routingComponentListColumns" :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>
                      </template>
                    </el-table-column>
                  </el-table>
                </el-tab-pane>
              </el-tabs>
            </el-col>
            <el-col :style="{width: 56 + 'vw',height: 340 + 'px'}">
              <el-table
                v-if="bomFlag1"
                :height="340"
                :data="bomComponentPartList1"
                border
                :header-cell-style="{padding: '2px 2px'}"
                style="width: 100%">
                <el-table-column
                  v-for="(item,index) in bomComponentListColumnList" :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-table
                v-if="!bomFlag1"
                :height="340"
                :data="routingComponentPartList1"
                border
                :header-cell-style="{padding: '2px 2px'}"
                style="width: 100%">
                <el-table-column
                  v-for="(item,index) in routingComponentListColumnList" :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-col>
          </el-row>
        </fieldset>
      </div>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="copySave">保存</el-button>
        <el-button type="primary" @click="copyVisible=false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- copy物料模态框 -->
    <el-dialog title="物料清单" top="17vh" :close-on-click-modal="false" v-drag :visible.sync="copyPartModelFlag" width="700px">
      <el-form :inline="true" label-position="top" :model="copyData.previousVersion">
        <el-form-item :label="'物料编码'">
          <el-input v-model="copyModalData.partNo" clearable style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'物料名称'">
          <el-input v-model="copyModalData.partDesc" clearable style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="' '">
          <el-button type="primary" @click="queryCopyPartModal">查询</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
        @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>

    <el-dialog :title="'修改属性'" :close-on-click-modal="false" v-drag :visible.sync="itemUpdateFlag" width="1100px">
      <el-table
        :data="partItemList1"
        border
        :header-cell-style="{padding: '2px 2px'}"
        style="width: 100%">
        <el-table-column
          v-for="(item,index) in columnItemList" :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">
            <div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
              <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>
            </div>
            <div v-else>
              <div v-if="scope.row.valueChooseFlag !== 'Y'">
                <el-input-number v-model="scope.row.numValue" style="padding: 0;width: 100%" v-if="scope.row.valueTypeDb === 'N'" :controls="false"></el-input-number>
                <el-input v-model="scope.row.textValue" v-else></el-input>
              </div>
              <div v-else>
                <el-select style="width: 100%;" clearable v-if="scope.row.valueTypeDb === 'T'" v-model="scope.row.textValue">
                  <el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.availableValueList" :key="key"></el-option>
                </el-select>
                <el-select style="width: 100%;" clearable v-else v-model="scope.row.numValue">
                  <el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.availableValueList" :key="key"></el-option>
                </el-select>
              </div>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="itemUpdateSave">保存</el-button>
        <el-button type="primary" @click="itemUpdateFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- PTM参数选择对话框 -->
    <el-dialog
      title="选择ProcessTimeMatrix参数"
      :close-on-click-modal="false"
      v-drag
      :visible.sync="ptmDialogVisible"
      width="95%"
      top="3vh">
      <div class="rq">
        <el-form :inline="true" label-position="top" style="margin-bottom: 10px">
          <el-form-item label="商品组1">
            <el-select
              v-model="ptmSelectedProductGroupId"
              placeholder="请选择商品组1"
              clearable
              filterable
              style="width: 300px"
              @change="handleProductGroupChange">
              <el-option
                v-for="item in ptmProductGroupList"
                :key="item.productGroupId"
                :label="item.productGroupName"
                :value="item.productGroupId">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="Code筛选">
            <el-input v-model="ptmSearchCode" placeholder="请输入条件描述" clearable style="width: 260px" @keyup.enter.native="filterPtmList"></el-input>
          </el-form-item>
          <el-form-item label=" ">
            <el-button type="primary" @click="filterPtmList">筛选</el-button>
            <el-button @click="resetPtmFilter">重置</el-button>
          </el-form-item>
          <el-form-item label=" " style="float: right">
            <span style="color: #67C23A; font-size: 13px;">
              💡 提示：双击某一行直接添加该ProcessTimeMatrix的参数
            </span>
          </el-form-item>
        </el-form>
        <el-table
          ref="ptmTable"
          :data="filteredPtmDataList"
          :height="520"
          border
          @row-dblclick="handlePtmRowDoubleClick"
          highlight-current-row
          :header-cell-style="{padding: '2px 2px', fontSize: '12px'}"
          :cell-style="{padding: '2px 2px', fontSize: '11px', cursor: 'pointer'}"
          style="width: 100%;">
          <el-table-column
            type="index"
            label="序号"
            width="60"
            align="center"
            fixed="left">
          </el-table-column>
          <el-table-column
            prop="conditionDesc"
            label="Code"
            width="300"
            header-align="center"
            align="left"
            fixed="left">
          </el-table-column>
          <el-table-column
            v-for="(col, index) in ptmColumnList"
            :key="index"
            :prop="col.prop"
            :label="col.label"
            :min-width="col.width || 100"
            header-align="center"
            :align="col.align || 'center'"
            show-overflow-tooltip>
            <template slot-scope="scope">
              <span>{{ scope.row[col.prop] || '-' }}</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="ptmDialogVisible=false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 新增物料 -->
    <part-create :init-data="searchData" ref="PartCreate" @update-part-item="getPartItem" @refreshPageTables="getBomInfo" @refreshPageTables2="getInfoByBomTemplate" v-drag></part-create>

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

<script>
import {
  getNodeTree,
  nodeSave,
  nodeDelete,
  nodeEdit,
  batchBuildInfo,
  resetNodePartInfo
} from "@/api/part/quicklyCreateBom.js"
import {
  queryPartListBom, // 查出可创建BOM的物料
} from "@/api/part/bomManagement.js"
import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
import ChooseList from '@/views/modules/common/Chooselist_eam'
import {Decimal} from "decimal.js";
import BomCreate from "./bom_create.vue";
import RoutingCreate from "./routing_create.vue";
import PartCreate from "./part_create.vue";
import {updateInquiryDetailStatusAndPart} from "../../../api/inquiry/inquiryDetail";
import {EventBus} from "../../../main";
import {searchProductGroupPtmCondition, batchSearchProductGroupPtmConditionsWithItems, productGroupInformationSearch} from "../../../api/part/partProductGroupInformation";
import {
  addPartItem,
  batchUpdateItem,
  commitItemValue, deletePartItem,
  getPartItem,
  partInfoByMainPart,
  queryPartItem,
  getItemLists, batchSavePartInfo, addPartsItem, batchUpdateCodeNo, deletePartsItem, commitItemsValue, getCopyRowData, recalculateBomAndRouting
} from "../../../api/part/partInformation";
import {getChooselist1} from "../../../api/chooselist/chooselist";
import {
  chooseEngChgLevel,
  chooseTemplate, getBomAndRoutingRevision,
  getBomInformationListByPartNo,
  getRoutingInformationListByPartNo,
  getTemplateList,
  savePartInfo, setRevision,
  updatePartNoOfNode
} from "../../../api/part/quicklyCreateBom";
import {getSiteAndBuByUserName} from "../../../api/qc/qc";
import Data from "lodash";
import {copyBom, queryBomDetail, queryPartList} from "../../../api/part/bomManagement";
import {copyRouting, queryRoutingDetail} from "../../../api/part/routingManagement";
export default {
  components: {
    PartCreate,
    BomCreate,
    RoutingCreate,
    ChooseList
  },
  watch: {
    nodeData: {
      deep: true,
      handler: function (newV, oldV) {
        this.nodeData.nodeId = this.nodeData.nodeId.toUpperCase()
      }
    },
    itemUpdateFlag: {
      deep: true,
      handler: function (newV, oldV) {
        if (!newV) {
          this.partItemList1 = []
        }
      }
    },
    'partCurrentRow': {
      deep: true,
      handler: function (newV, oldV) {
        if (this.inventoryPartTable==='part_item1'&&this.attributeFlag1){
          this.getPartItem1()
        } else if (this.inventoryPartTable==='revision_info'){
          this.getRevisionInfo()
        }
      }
    },
    'bomCurrentRow': {
      deep: true,
      handler: function (newV, oldV) {
        if (newV) {
          this.routingCurrentRow = null
        }
      }
    },
    'routingCurrentRow': {
      deep: true,
      handler: function (newV, oldV) {
        if (newV) {
          this.bomCurrentRow = null
        }
      }
    },
    'bomCurrentRow1': {
      deep: true,
      handler: function (newV, oldV) {
        if (newV) {
          this.routingCurrentRow1 = null
        }
      }
    },
    'routingCurrentRow1': {
      deep: true,
      handler: function (newV, oldV) {
        if (newV) {
          this.bomCurrentRow1 = null
        }
      }
    },
    batchUpdateFlag: {
      handler: function (newV, oldV) {
        if (newV===false) {
          this.attributeFlag = true
          this.attributeFlag1 = true
          this.inventoryPartTable = 'part_item'
          this.getNodeTree()
          this.getPartItem()
        } else {
          this.previousCodeNo = this.searchData.codeNo
        }
      }
    },
    'nodeData.pId': {
      deep: true,
      handler: function (newV, oldV) {
        this.childrenNodeList = [];
        if (!newV || newV.trim().length === 0) {
          return;
        }
        const findNodeById = (nodes, targetId) => {
          for (let i = 0; i < nodes.length; i++) {
            const node = nodes[i];
            if (node.id === targetId) {
              return node;
            }
            if (node.nodeList && node.nodeList.length > 0) {
              const result = findNodeById(node.nodeList, targetId);
              if (result) return result;
            }
          }
          return null;
        };
        const foundNode = findNodeById(this.treeData1, newV);
        if (foundNode && foundNode.nodeList) {
          this.childrenNodeList = foundNode.nodeList.filter(node => node.nodeName!==null&&node.nodeName.trim()!=="");
        } else {
          this.childrenNodeList = [];
        }
      }
    },
    'routingComponentPartList': {
      deep: true,
      handler: function (newV, oldV) {
        newV.forEach(item => {
          item.formula = this.getFormula(item.operationName)
        })
      }
    },
    'routingComponentPartList1': {
      deep: true,
      handler: function (newV, oldV) {
        newV.forEach(item => {
          item.formula = this.getFormula(item.operationName)
        })
      }
    },
    'copyVisible': {
      deep: true,
      handler: function (newV, oldV) {
        if (!newV) {
          this.copyData= {
            flag: '',
            site: this.$store.state.user.site,
            partNo: '',
            partDesc: '',
            umId2: null,
            productGroupId1: null,
            productGroupId2: null,
            productGroupId3: null,
            codeNo: null,
            familyID: null,
            partType2: null,
            routingType: 'Manufacturing',
            bomType: 'Manufacturing',
            effPhaseInDate: null,
            effPhaseOutDate: null,
            phaseOutDate: null,
            phaseInDate: null,
            previousVersion: {},
            nodeFlag: false,
            mainPart: '',
            nodeId: '',
            engChgLevel: null,
            routingRevision: null,
            active: '',
            createBy: '',
            routingFlag: 'Y',
            bomFlag: 'Y',
            page: 1,
            limit: 10
          }
          this.bomComponentList1 = []
          this.routingComponentList1 = []
          this.bomComponentPartList1 = []
          this.routingComponentPartList1 = []
          this.handleBatchUpdatePart()
          this.getRevisionInfo()
        }
      }
    },
    '$route.query.data': {
      handler(newData, oldData) {
        if (newData) {
          this.searchData = newData;
          this.searchData.partDesc = newData.testPartDesc;
          this.searchData.codeNo = newData.partCodeNo;
          this.searchData.rfqDetailId = newData.id;
          this.dataList = [{}]
          this.getNodeTree();
          this.getPartItem();
        }
      },
      immediate: true
    }
  },
  data () {
    return {
      activeTable: 'bom_info',
      activeTab1: 'default',
      activeTab2: 'default',
      inventoryPartTable: 'part_item',
      partItemList: [],
      partItemList1: [],
      copyAttributeList: [],
      treeData: [],
      treeData1: [],
      childrenNodeList: [],
      userBuList: [],
      partFamilyList: [],
      partProductGroupList1: [],
      partProductGroupList2: [],
      partProductGroupList3: [],
      templateList: [],
      tempList: [],
      defaultProps: {
        children: "nodeList",
        label: "nodeName",
      },
      menuId: this.$route.meta.menuId,
      // 是否收藏
      favorite: false,
      exportData: [],
      exportName: "节点" + this.dayjs().format('YYYYMMDDHHmmss'),
      exportHeader: ["节点"],
      exportFooter: [],
      height: 200,
      rightWidth: '',
      pageIndex: 1,
      pageSize: 20,
      totalPage: 0,
      pageIndex2: 1,
      pageSize2: 20,
      totalPage2: 0,
      pageIndex3: 1,
      pageSize3: 20,
      totalPage3: 0,
      pageIndex4: 1,
      pageSize4: 20,
      totalPage4: 0,
      partList: [],
      partList1: [],
      codeList: [],
      itemSelections1: [],
      itemSelections2: [],
      itemList1: [],
      itemList2: [],
      bomComponentPartList: [],
      bomComponentPartList1: [],
      routingComponentPartList: [],
      routingComponentPartList1: [],
      bomComponentList: [],
      bomComponentList1: [],
      routingComponentList: [],
      routingComponentList1: [],
      copyPartList: [],
      previousCodeNo: '',
      rules: {
        buNo:[
          {
            required: true,
            message: ' ',
            trigger: ['blur', 'change']
          }
        ],
        partDesc: [
          {
            required: true,
            message: ' ',
            trigger: ['blur', 'change']
          }
        ],
        bomType: [
          {
            required: true,
            message: ' ',
            trigger: ['blur', 'change']
          }
        ],
        routingType: [
          {
            required: true,
            message: ' ',
            trigger: ['blur', 'change']
          }
        ],
        effPhaseInDate: [
          {
            required: true,
            message: ' ',
            trigger: ['blur', 'change']
          }
        ],
      },
      searchData: {
        site: this.$store.state.user.site,
        buNo: '',
        partNo: '',
        partDesc: '',
        codeNo: '',
        rfqDetailId: null
      },
      partNoGenerated: false, // 标记产品编码是否已通过"维护"生成
      savedPartData: null, // 保存已生成的产品数据，防止被路由参数覆盖
      itemData: {
        site: this.$store.state.user.site,
        partNo: '',
        propertiesItemNo: '',
        codeNo: '',
        itemDesc: '',
        textValue: '',
        numValue: '',
        recordType: ''
      },
      nodeData: {
        flag: '',
        site: this.$store.state.user.site,
        nodeId: '',
        nodeName: '',
        id: '',
        pId: '',
        parentNodeName: '',
        createBy: this.$store.state.user.name,
        updateBy: this.$store.state.user.name,
        mainPart: '',
        rfqDetailId: null
      },
      partData: {
        flag: '',
        site: '',
        partNo: '',
        partDesc: '',
        nodeFlag: false,
        mainPart: '',
        nodeId: '',
        engChgLevel: null,
        page: 1,
        limit: 10
      },
      copyData: {
        flag: '',
        site: this.$store.state.user.site,
        partNo: '',
        partDesc: '',
        umId2: null,
        productGroupId1: null,
        productGroupId2: null,
        productGroupId3: null,
        codeNo: null,
        familyID: null,
        partType2: null,
        routingType: 'Manufacturing',
        bomType: 'Manufacturing',
        effPhaseInDate: null,
        effPhaseOutDate: null,
        phaseOutDate: null,
        phaseInDate: null,
        previousVersion: {},
        nodeFlag: false,
        mainPart: '',
        nodeId: '',
        engChgLevel: null,
        routingRevision: null,
        active: '',
        createBy: '',
        routingFlag: 'Y',
        bomFlag: 'Y',
        page: 1,
        limit: 10
      },
      copyModalData: {
        site: '',
        partNo: '',
        partDesc: '',
        page: 1,
        limit: 10
      },
      nodeRules:{
        nodeId:[
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        nodeName:[
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        parentNodeName:[
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ],
        id:[
          {
            required: true,
            message: ' ',
            trigger: ['blur','change']
          }
        ]
      },
      dataList: [{}],
      editingCell: {
        rowIndex: -1,
        columnProp: null,
        value: '',
        isSaving: false
      },
      currentNode: {},
      partCurrentRow: {},
      bomCurrentRow: {},
      bomCurrentRow1: {},
      routingCurrentRow: {},
      routingCurrentRow1: {},
      partCurrentRowIndex: -1,
      columnList: [
        {
          userId: this.$store.state.user.name,
          columnProp: 'family1',
          headerAlign: 'left',
          align: 'left',
          columnLabel: 'Family1',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 50
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'family2',
          headerAlign: 'left',
          align: 'left',
          columnLabel: 'Family2',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 50
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'bondingPitch',
          headerAlign: 'left',
          align: 'left',
          columnLabel: 'Bonding Pitch',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'bondingLanes',
          headerAlign: 'left',
          align: 'left',
          columnLabel: '绑定列数',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 50
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'printingLanes',
          headerAlign: 'left',
          align: 'left',
          columnLabel: 'Printing lanes',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'uph-tal',
          headerAlign: 'left',
          align: 'left',
          columnLabel: 'UPH-TAL',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'uph-paris',
          headerAlign: 'left',
          align: 'left',
          columnLabel: 'UPH-Paris',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'cl60k-up',
          headerAlign: 'left',
          align: 'left',
          columnLabel: 'CL60k-UP',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'cl60k-pitch',
          headerAlign: 'left',
          align: 'left',
          columnLabel: 'CL60k-Pitch',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'cl60k-cd',
          headerAlign: 'left',
          align: 'left',
          columnLabel: 'CL60k-CD',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'compositeLanes',
          headerAlign: 'left',
          align: 'left',
          columnLabel: '复合列数',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 50
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'labelingLanes',
          headerAlign: 'left',
          align: 'left',
          columnLabel: '贴标列数',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 50
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'inspectionLanes',
          headerAlign: 'left',
          align: 'left',
          columnLabel: '检测列数',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 50
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'finalInspection-uph',
          headerAlign: 'left',
          align: 'left',
          columnLabel: '后道检品-UPH',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'coding-uph',
          headerAlign: 'left',
          align: 'left',
          columnLabel: '编码-UPH',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          columnProp: 'codingPrinting-uph',
          headerAlign: 'left',
          align: 'left',
          columnLabel: '编码打印-UPH',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
      ],
      partColumnList1: [
        {
          columnProp: 'buNo',
          headerAlign: "center",
          align: "center",
          columnLabel: 'BU',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'partNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '料号',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          columnProp: 'partDesc',
          headerAlign: "center",
          align: "left",
          columnLabel: '物料描述',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 320
        },
        {
          columnProp: 'codeDesc',
          headerAlign: "center",
          align: "center",
          columnLabel: '属性模板',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 220
        },
        {
          columnProp: 'nodeName',
          headerAlign: "center",
          align: "center",
          columnLabel: '节点',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'partType2',
          headerAlign: "center",
          align: "center",
          columnLabel: '零件类型',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 130
        },
        {
          columnProp: 'umName',
          headerAlign: "center",
          align: "center",
          columnLabel: '计量单位',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'familyName',
          headerAlign: "center",
          align: "center",
          columnLabel: '物料分类',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'productGroupName1',
          headerAlign: "center",
          align: "center",
          columnLabel: '商品组1',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 250
        },
        {
          columnProp: 'productGroupName2',
          headerAlign: "center",
          align: "center",
          columnLabel: '商品组2',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 250
        },
        {
          columnProp: 'productGroupName3',
          headerAlign: "center",
          align: "center",
          columnLabel: '商品组3',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 250
        },
        // {
        //   columnProp: 'nodeName',
        //   headerAlign: "center",
        //   align: "center",
        //   columnLabel: '属性模板',
        //   columnHidden: false,
        //   columnImage: false,
        //   status: true,
        //   fixed: '',
        //   columnWidth: 100
        // },
        {
          columnProp: 'templateName',
          headerAlign: "center",
          align: "center",
          columnLabel: 'BOM模板',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'engChgLevel',
          headerAlign: "center",
          align: "center",
          columnLabel: 'BOM版本号',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'routingRevision',
          headerAlign: "center",
          align: "center",
          columnLabel: 'Routing版本号',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'remark',
          headerAlign: "center",
          align: "center",
          columnLabel: '备注',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 200
        },
      ],
      partColumnList2: [
        {
          columnProp: 'buNo',
          headerAlign: "center",
          align: "center",
          columnLabel: 'BU',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'partNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '料号',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          columnProp: 'partDesc',
          headerAlign: "center",
          align: "left",
          columnLabel: '物料描述',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 320
        },
        {
          columnProp: 'codeDesc',
          headerAlign: "center",
          align: "center",
          columnLabel: '属性模板',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 220
        },
        {
          columnProp: 'nodeName',
          headerAlign: "center",
          align: "center",
          columnLabel: '节点',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'tempNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '模板',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'partType2',
          headerAlign: "center",
          align: "center",
          columnLabel: '零件类型',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },

        {
          columnProp: 'umName',
          headerAlign: "center",
          align: "center",
          columnLabel: '计量单位',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'familyName',
          headerAlign: "center",
          align: "center",
          columnLabel: '物料分类',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'productGroupName1',
          headerAlign: "center",
          align: "center",
          columnLabel: '商品组1',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 250
        },
        {
          columnProp: 'productGroupName2',
          headerAlign: "center",
          align: "center",
          columnLabel: '商品组2',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 250
        },
        {
          columnProp: 'productGroupName3',
          headerAlign: "center",
          align: "center",
          columnLabel: '商品组3',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 250
        },
        // {
        //   columnProp: 'nodeName',
        //   headerAlign: "center",
        //   align: "center",
        //   columnLabel: '属性模板',
        //   columnHidden: false,
        //   columnImage: false,
        //   status: true,
        //   fixed: '',
        //   columnWidth: 100
        // },
        {
          columnProp: 'templateName',
          headerAlign: "center",
          align: "center",
          columnLabel: 'BOM模板',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'engChgLevel',
          headerAlign: "center",
          align: "center",
          columnLabel: 'BOM版本号',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'routingRevision',
          headerAlign: "center",
          align: "center",
          columnLabel: 'Routing版本号',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'remark',
          headerAlign: "center",
          align: "center",
          columnLabel: '备注',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 200
        },
      ],
      partColumnList: [
        {
          columnProp: 'buNo',
          headerAlign: "center",
          align: "center",
          columnLabel: 'BU',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'partNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '物料编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          columnProp: 'partDesc',
          headerAlign: "center",
          align: "center",
          columnLabel: '物料名称',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 300
        },
        {
          columnProp: 'spec',
          headerAlign: "center",
          align: "center",
          columnLabel: '规格型号',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 300
        },
        {
          columnProp: 'printUnitName',
          headerAlign: "center",
          align: "center",
          columnLabel: '计量单位',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'partType2',
          headerAlign: "center",
          align: "center",
          columnLabel: '零件类型',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          columnProp: 'yieldRate',
          headerAlign: "center",
          align: "right",
          columnLabel: '良品率',
          columnHidden: false,
          columnImage: false,
          status: true,
          fixed: '',
          columnWidth: 100
        },
      ],
      columnItemList:[
      {
        userId: this.$store.state.user.name,
        functionId: 601001,
        serialNumber: '601001Table2PropertiesItemID',
        tableId: "601001Table2",
        tableName: "物料属性表",
        columnProp: 'propertiesItemNo',
        headerAlign: "center",
        align: "center",
        columnLabel: '属性编码',
        columnHidden: false,
        columnImage: false,
        status: true,
        fixed: '',
        columnWidth: 200,
      },
      {
        userId: this.$store.state.user.name,
        functionId: 601001,
        serialNumber: '601001Table2PropertiesItemDesc',
        tableId: "601001Table2",
        tableName: "物料属性表",
        columnProp: 'itemDesc',
        headerAlign: "center",
        align: "center",
        columnLabel: '属性名称',
        columnHidden: false,
        columnImage: false,
        status: true,
        fixed: '',
        columnWidth: 200,
      },
      {
        userId: this.$store.state.user.name,
        functionId: 601001,
        serialNumber: '601001Table2ValueType',
        tableId: "601001Table2",
        tableName: "物料属性表",
        columnProp: 'valueType',
        headerAlign: "center",
        align: "center",
        columnLabel: '属性类型',
        columnHidden: false,
        columnImage: false,
        status: true,
        fixed: '',
        columnWidth: 240,
      },
      {
        userId: this.$store.state.user.name,
        functionId: 601001,
        serialNumber: '601001Table2ValueChooseFlag',
        tableId: "601001Table2",
        tableName: "物料属性表",
        columnProp: 'textValue',
        headerAlign: "center",
        align: "center",
        columnLabel: '属性值',
        columnHidden: false,
        columnImage: false,
        status: true,
        fixed: '',
        columnWidth: 200,
      },
    ],
    bomComponentListColumnList: [
      {
        userId: this.$store.state.user.name,
        functionId: 601002,
        serialNumber: '601002Table2LineSequence',
        tableId: '601002Table2',
        tableName: 'BOM子物料表',
        columnProp: 'lineSequence',
        headerAlign: 'center',
        align: 'center',
        columnLabel: '序号',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 50
      },
      {
        userId: this.$store.state.user.name,
        functionId: 601002,
        serialNumber: '601002Table2ComponentPart',
        tableId: '601002Table2',
        tableName: 'BOM子物料表',
        columnProp: 'componentPart',
        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: 601002,
        serialNumber: '601002Table2ComponentPartDesc',
        tableId: '601002Table2',
        tableName: 'BOM子物料表',
        columnProp: 'componentPartDesc',
        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: 601002,
        serialNumber: '601002Table2ComponentPartDesc',
        tableId: '601002Table2',
        tableName: 'BOM子物料表',
        columnProp: 'formula',
        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: 601002,
        serialNumber: '601002Table2PrintUnit',
        tableId: '601002Table2',
        tableName: 'BOM子物料表',
        columnProp: 'printUnitName',
        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: 601002,
        serialNumber: '601002Table2PrintUnit',
        tableId: '601002Table2',
        tableName: 'BOM子物料表',
        columnProp: 'qtyPerAssembly',
        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: 601002,
        serialNumber: '601002Table2PrintUnit',
        tableId: '601002Table2',
        tableName: 'BOM子物料表',
        columnProp: 'shrinkageFactor',
        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: 601002,
        serialNumber: '601002Table2OperationNo',
        tableId: '601002Table2',
        tableName: 'BOM子物料表',
        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: 601002,
        serialNumber: '601002Table2OperationName',
        tableId: '601002Table2',
        tableName: 'BOM子物料表',
        columnProp: 'operationName',
        headerAlign: 'center',
        align: 'left',
        columnLabel: '工序名称',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 120
      },
      {
        userId: this.$store.state.user.name,
        functionId: 601002,
        serialNumber: '601002Table2NoteText',
        tableId: '601002Table2',
        tableName: 'BOM子物料表',
        columnProp: 'noteText',
        headerAlign: 'center',
        align: 'center',
        columnLabel: '备注',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 150
      },
    ],
    bomComponentListColumns: [
      {
        userId: this.$store.state.user.name,
        columnProp: 'engChgLevel',
        headerAlign: 'center',
        align: 'center',
        columnLabel: 'BOM版本号',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 80
      },
      {
        userId: this.$store.state.user.name,
        columnProp: 'noteText',
        headerAlign: 'center',
        align: 'left',
        columnLabel: '备注',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 200
      },
    ],
    routingComponentListColumns: [
      {
        userId: this.$store.state.user.name,
        columnProp: 'routingRevision',
        headerAlign: 'center',
        align: 'center',
        columnLabel: 'Routing版本号',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 100
      },
      {
        userId: this.$store.state.user.name,
        columnProp: 'noteText',
        headerAlign: 'center',
        align: 'left',
        columnLabel: '备注',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 200
      },
    ],
    routingComponentListColumnList: [
      {
        userId: this.$store.state.user.name,
        functionId: 601003,
        serialNumber: '104003Table2OperationNo',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'operationNo',
        headerAlign: 'center',
        align: 'center',
        columnLabel: '工序编码',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 80
      },
      {
        userId: this.$store.state.user.name,
        functionId: 601003,
        serialNumber: '104003Table2OperationName',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'operationName',
        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: 601003,
        serialNumber: '104003Table2MachCycleTime',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'machCycleTime',
        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: 601003,
        serialNumber: '104003Table2OperationName',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'formula',
        headerAlign: 'center',
        align: 'left',
        columnLabel: '计算公式',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 260
      },
      {
        userId: this.$store.state.user.name,
        functionId: 601003,
        serialNumber: '104003Table2OperationName',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'crewSize',
        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: 601003,
        serialNumber: '104003Table2OperationName',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'refSpeed',
        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: 601003,
        serialNumber: '104003Table2OperationName',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'refTime',
        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: 601003,
        serialNumber: '104003Table2OperationName',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'refEfficiency',
        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: 601003,
        serialNumber: '104003Table2SetupCrewSize',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'setupCrewSize',
        headerAlign: 'center',
        align: 'right',
        columnLabel: '调机过程人数',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 100
      },
      {
        userId: this.$store.state.user.name,
        functionId: 601003,
        serialNumber: '104003Table2MachRunFactor',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'machRunFactor',
        headerAlign: 'center',
        align: 'right',
        columnLabel: '机器单位产出',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 100
      },
      {
        userId: this.$store.state.user.name,
        functionId: 601003,
        serialNumber: '104003Table2CrewSize',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'crewSize',
        headerAlign: 'center',
        align: 'right',
        columnLabel: '生产过程人数',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 100
      },
      {
        userId: this.$store.state.user.name,
        functionId: 601003,
        serialNumber: '104003Table2LaborClassNo',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'laborClassDesc',
        headerAlign: 'center',
        align: 'center',
        columnLabel: '人员等级',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 120
      },
      {
        userId: this.$store.state.user.name,
        functionId: 601003,
        serialNumber: '104003Table2LaborCycleTime',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'laborCycleTime',
        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: 601003,
        serialNumber: '104003Table2LaborRunFactor',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'laborRunFactor',
        headerAlign: 'center',
        align: 'right',
        columnLabel: '人工单位产出',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 100
      },
      {
        userId: this.$store.state.user.name,
        functionId: 601003,
        serialNumber: '104003Table2EfficiencyFactor',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'efficiencyFactor',
        headerAlign: 'center',
        align: 'right',
        columnLabel: '效率%',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 80
      },
      {
        userId: this.$store.state.user.name,
        functionId: 601003,
        serialNumber: '104003Table2WorkCenterNo',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'workCenterNo',
        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: 601003,
        serialNumber: '104003Table2NoteText',
        tableId: '104003Table2',
        tableName: 'Routing工序表',
        columnProp: 'noteText',
        headerAlign: 'center',
        align: 'center',
        columnLabel: '备注',
        columnHidden: false,
        columnImage: false,
        columnSortable: false,
        sortLv: 0,
        status: true,
        fixed: '',
        columnWidth: 120
      },
    ],
    componentPartColumnList: [
      {
        columnProp: 'partNo',
        headerAlign: "center",
        align: "center",
        columnLabel: '物料编码',
        columnHidden: false,
        columnImage: false,
        status: true,
        fixed: '',
        columnWidth: 120
      },
      {
        columnProp: 'partDesc',
        headerAlign: "center",
        align: "center",
        columnLabel: '物料名称',
        columnHidden: false,
        columnImage: false,
        status: true,
        fixed: '',
        columnWidth: 300
      },
      {
        columnProp: 'spec',
        headerAlign: "center",
        align: "center",
        columnLabel: '规格型号',
        columnHidden: false,
        columnImage: false,
        status: true,
        fixed: '',
        columnWidth: 300
      },
      {
        columnProp: 'printUnitName',
        headerAlign: "center",
        align: "center",
        columnLabel: '计量单位',
        columnHidden: false,
        columnImage: false,
        status: true,
        fixed: '',
        columnWidth: 100
      },
      {
        columnProp: 'partType2',
        headerAlign: "center",
        align: "center",
        columnLabel: '零件类型',
        columnHidden: false,
        columnImage: false,
        status: true,
        fixed: '',
        columnWidth: 100
      }
    ],
      // 控制
      nodeModalFlag: false,
      nodeModalDisableFlag: false,
      partModelFlag: false,
      buildAllLoading: false,
      resetAllLoading: false,
      bomLoading: false,
      routingLoading: false,
      treeVisible: false,
      addNodeFlag: true,
      batchUpdateFlag: false,
      attributeFlag: true,
      attributeFlag1: true,
      attributeFlag2: true,
      fastAddFlag: false,
      fastAddFlag1: false,
      loading: false,
      dataListLoading: false,
      addItemLoading: false,
      deleteItemLoading: false,
      buNoQueryLoading: false,
      alternativeLoading: false,
      processTimeMatrixLoading: false,
      bomFlag: true,
      bomFlag1: true,
      copyVisible: false,
      copyPartModelFlag: false,
      itemUpdateFlag: false,

      ptmDialogVisible: false,  // PTM参数选择对话框显示控制
      ptmDataList: [],  // PTM完整数据列表（53行，每行包含Code和12个参数列）
      filteredPtmDataList: [],  // PTM筛选后的数据列表
      ptmColumnList: [],  // PTM参数动态列配置（12个参数列）
      ptmSearchCode: '',  // PTM Code筛选条件
      ptmItemList: [],  // PTM参数列表（去重后的item列表）
      selectedPtmItems: [],  // 用户勾选的PTM参数
      ptmProductGroupList: [],  // 当前BU下所有商品组1列表
      ptmSelectedProductGroupId: '',  // 当前选中的商品组1ID
      ptmCurrentBuNo: ''  // 当前BU编号
    }
  },
  created () {
    // 按钮控制
    this.getButtonAuthData()
    // 校验用户是否收藏
    this.favoriteIsOk()
    // 获取树形结构
    // this.searchData = {
    //   site: '2',
    //   buNo: '03-RFID',
    //   partNo: '*',
    //   partDesc: '***'
    // }
  },
  mounted () {
    this.$nextTick(() => {
      this.height = window.innerHeight - 151
    })
  },
  activated() {
    if (this.$route.query.data) {
      console.log('activated 触发 - partNoGenerated 标记:', this.partNoGenerated)
      console.log('activated 触发 - 当前 partNo:', this.searchData.partNo)
      console.log('activated 触发 - 路由参数 partNo:', this.$route.query.data.partNo)
      console.log('activated 触发 - savedPartData:', this.savedPartData)

      // 如果产品编码已通过"维护"生成，从保存的副本恢复数据
      if (this.partNoGenerated && this.savedPartData) {
        console.log('产品编码已生成，从 savedPartData 恢复数据:', this.savedPartData.partNo)

        // 从保存的副本恢复数据
        this.searchData.site = this.savedPartData.site
        this.searchData.buNo = this.savedPartData.buNo
        this.searchData.partNo = this.savedPartData.partNo
        this.searchData.partDesc = this.savedPartData.partDesc
        this.searchData.testPartId = this.savedPartData.testPartId
        this.searchData.codeNo = this.savedPartData.codeNo || this.$route.query.data.partCodeNo
        this.searchData.rfqDetailId = this.savedPartData.rfqDetailId || this.$route.query.data.id

        console.log('恢复后的 searchData.partNo:', this.searchData.partNo)

        // 刷新相关数据
        this.getNodeTree();
        this.getPartItem();
        return
      }

      // 产品编码未生成时，正常从路由参数加载数据
      console.log('从路由参数加载初始数据')
      this.searchData = this.$route.query.data
      this.searchData.partDesc = this.$route.query.data.testPartDesc
      this.searchData.codeNo = this.$route.query.data.partCodeNo
      this.searchData.rfqDetailId = this.$route.query.data.id
      this.getNodeTree();
      this.getPartItem();
    }
  },
  methods: {
    // 每页数
    sizeChangeHandle2 (val) {
      this.pageSize2 = val
      this.pageIndex2 = 1
      this.queryPartList()
    },

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

    // 查询下拉树结构
    getNodeTree () {
      let tempData = {
        site: this.searchData.site,
        mainPart: this.searchData.partNo,
        rfqDetailId: this.searchData.rfqDetailId,
        pId: '0'
      }
      getNodeTree(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.$set(this, 'treeData', data.rows)
        }
        if (this.batchUpdateFlag){
          this.handleBatchUpdatePart()
        }
      })
    },

    // 新增节点
    addTree () {
      this.nodeData = {
        flag: '1',
        site: this.$store.state.user.site,
        nodeId: 'NODE' + Data.now(),
        nodeName: '',
        pId: '0',
        createBy: this.$store.state.user.name,
        updateBy: this.$store.state.user.name,
        mainPart: this.searchData.partNo,
        rfqDetailId: this.searchData.rfqDetailId,
      }
      this.treeData1 = [
        {
          id: '0',
          nodeName: '首节点',
          nodeList: []
        }
      ]
      if (Array.isArray(this.treeData) && this.treeData.length > 0) {
        this.treeData1[0].nodeList = [...this.treeData]
      }
      this.nodeModalDisableFlag = false
      this.nodeModalFlag = true
    },


    // 修改节点
    editTreeItem (data) {
      this.nodeData = {
        flag: '2',
        site: data.site,
        nodeId: data.nodeId,
        nodeName: data.nodeName,
        mainPart: this.searchData.partNo,
        createBy: this.$store.state.user.name,
        updateBy: this.$store.state.user.name,
      }
      this.nodeModalDisableFlag = true
      this.nodeModalFlag = true
    },

    // 删除节点
    deleteTreeItem (data) {
      this.$confirm('将删除该节点及其子节点数据！', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        nodeDelete(data).then(({data}) => {
          if (data && data.code === 0) {
            this.getNodeTree()
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      })
    },

    // 分类新增/编辑方法
    saveNodeData () {
      if (this.nodeData.nodeId === '' || this.nodeData.nodeId == null) {
        this.$message.warning('请输入节点编码！')
        return
      }
      if (this.nodeData.nodeName === '' || this.nodeData.nodeName == null) {
        this.$message.warning('请输入节点名称！')
        return
      }
      if(this.nodeData.flag === '1') {
        nodeSave(this.nodeData).then(({data}) => {
          if (data && data.code === 0) {
            this.getNodeTree()
            this.nodeModalFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      } else {
        nodeEdit(this.nodeData).then(({data}) => {
          if (data && data.code === 0) {
            this.getNodeTree()
            this.nodeModalFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      }
    },

    // 批量build
    batchBuild () {
      let tempData = {
        site: this.searchData.site,
        mainPart: this.searchData.partNo
      }
      this.$confirm('将所有节点的BOM和Routing状态改为Build！', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.buildAllLoading = true
        batchBuildInfo(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.refreshCurrentTabTable()
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
          this.buildAllLoading = false
        })
      })
    },

    // 重置节点物料
    resetNodePart() {
      let tempData = {
        site: this.$store.state.user.site
      }
      this.$confirm('将重置所有节点的关联物料！', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.resetAllLoading = true
        resetNodePartInfo(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.currentNode = {}
            this.getNodeTree()
            this.refreshCurrentTabTable()
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
          this.resetAllLoading = false
        })
      })
    },

    /**
     * 刷新页签的table数据
     */
    refreshCurrentTabTable () {
      if (this.activeTable === 'bom_info') {
        if (this.currentNode.partNo != null && this.currentNode.partNo.length > 0) {
          this.getBomInfo2(this.currentNode)
        } else {
          this.$nextTick(() => {
            this.$refs.BomCreate.init2()
          })
        }
      } else if (this.activeTable === 'routing_info') {
        if (this.currentNode.partNo != null && this.currentNode.partNo.length > 0) {
          this.getRoutingInfo(this.currentNode)
        } else {
          this.$nextTick(() => {
            this.$refs.RoutingCreate.init2()
          })
        }
      }
    },

    queryPartList2(data) {
      this.partData = {
        flag: '2',
        site: '',
        partNo: '',
        partDesc: '',
        nodeFlag: true,
        page: 1,
        limit: 10,
        mainPart: this.searchData.partNo,
        nodeId: this.treeData[0].nodeId,
        engChgLevel: this.treeData[0].engChgLevel
      }
      this.currentNode = data
      this.queryPartList()
    },

    queryPartListInfo () {
      this.partData = {
        flag: '1',
        site: '',
        partNo: '',
        partDesc: '',
        page: 1,
        limit: 10
      }
      this.queryPartList3()
    },

    queryPartList3 () {
      this.partData.limit = this.pageSize2
      this.partData.page = this.pageIndex2
      queryPartListBom(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.partList = []
        }
      })
    },

    // 查询物料
    queryPartList () {
      this.partData.limit = this.pageSize2
      this.partData.page = this.pageIndex2
      this.partData.site = this.nodeData.site
      queryPartListBom(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.partList = []
        }
      })
    },

    // 双击选中物料
    getRowData (row) {
      if (this.partData.flag === '1') {
        this.getInfoByBomTemplate(row)
      } else {
        this.toPartModule(row)
      }
    },

    // 获取物料的Bom模板详情
    async getInfoByBomTemplate (row) {
      console.log('getInfoByBomTemplate 接收到的 row:', row)
      this.searchData.site = row.site
      this.searchData.buNo = row.buNo
      this.searchData.partNo = row.partNo
      this.searchData.partDesc = row.partDesc
      this.searchData.testPartId = row.id

      // 标记产品编码已生成（从 * 变成实际编码）并保存数据副本
      if (row.partNo && row.partNo !== '*') {
        this.partNoGenerated = true
        // 保存完整的产品数据副本，用于页签切换时恢复
        this.savedPartData = {
          site: row.site,
          buNo: row.buNo,
          partNo: row.partNo,
          partDesc: row.partDesc,
          testPartId: row.id,
          rfqDetailId: this.searchData.rfqDetailId
        }
        console.log('设置 partNoGenerated = true，保存的数据:', this.savedPartData)
      }

      console.log('更新后的 searchData.partNo:', this.searchData.partNo)

      await this.getNodeTree()
      let tempData = {
        site: this.$store.state.user.site,
        buNo: this.searchData.buNo,
        partNo: this.searchData.partNo,
        codeNo: this.searchData.codeNo
      }
      await partInfoByMainPart(tempData).then(({data}) => {
        if (data && data.code === 0){
          this.$set(this, 'partList1', data.rows)
          this.searchData.codeNo = this.partList1[0].codeNo
          // 同步更新保存的数据
          if (this.savedPartData) {
            this.savedPartData.codeNo = this.partList1[0].codeNo
          }
        }
      })
      this.getPartItem();
      this.partModelFlag = false
    },

    // 到物料编辑组件
    toPartModule (row) {
      let tempData = {
        site: row.site,
        buNo: row.buNo,
        mainPart: this.searchData.partNo,
        partNo: row.partNo,
        bomType: 'Manufacturing',
        partDesc: row.partDesc,
        printUnit: row.printUnit,
        printUnitName: row.printUnitName,
        shrinkageFactor: new Decimal(100).sub(new Decimal(row.yieldRate)).toNumber(),
        nodeId: this.currentNode.nodeId,
        offFlag: '1'
      }
      //打开组件 去做新增业务
      this.$nextTick(() => {
        this.$refs.BomCreate.init(tempData)
      })
      this.partModelFlag = false
    },

    // 新增物料
    addPartModal (data) {
      this.currentNode = data
      //打开组件 去做新增业务
      this.$nextTick(() => {
        this.$refs.PartCreate.init()
      })
    },

    // 维护
    updatePartModal () {
      if (this.searchData.partNo === '' || this.searchData.partNo == null) {
        this.$message.warning('请选择产品！')
        return
      }
      let templateData = {
        site: this.searchData.site,
        buNo: this.searchData.buNo,
        partNo: this.searchData.partNo,
        partDesc: this.searchData.partDesc
      }
      //打开组件 去做编辑业务
      this.$nextTick(() => {
        this.$refs.PartCreate.updateModal(templateData)
      })
    },

    // 根据物料获取BOM信息
    getBomInfo (row) {
      let tempData = {
        site: row.site,
        buNo: row.buNo,
        mainPart: this.searchData.partNo,
        partNo: row.partNo,
        partDesc: row.partDesc,
        printUnit: row.umId2,
        printUnitName: row.umName,
        bomType: 'Manufacturing',
        nodeId: this.currentNode.nodeId,
        offFlag: '1'
      }
      //打开组件 去做新增业务
      this.$nextTick(() => {
        this.$refs.BomCreate.init(tempData)
      })
    },

    // 根据物料获取Routing信息
    getRoutingInfo (row) {
      this.routingLoading = true
      let tempData = {
        site: row.site,
        buNo: row.buNo,
        partNo: row.partNo,
        partDesc: row.partDesc,
        printUnit: row.printUnit,
        printUnitName: row.printUnitName,
        routingType: 'Manufacturing',
      }
      //打开组件 去做新增业务
      this.$nextTick(() => {
        this.$refs.RoutingCreate.init(tempData)
      })
    },

    // 树节点单机事件
    handleNodeClick (e, node) {
      this.currentNode = e
      if (e.partNo != null && e.partNo.length > 0) {
        if (this.activeTable === 'routing_info') {
          this.getRoutingInfo(e)
        } else {
          this.getBomInfo2(e)
        }
      } else {
        if (this.activeTable === 'routing_info') {
          this.$nextTick(() => {
            this.$refs.RoutingCreate.init2()
          })
        } else {
          this.$nextTick(() => {
            this.$refs.BomCreate.init2()
          })
        }
      }
    },

    // 根据物料获取BOM信息
    getBomInfo2 (row) {
      this.bomLoading = true
      let tempData = {
        site: row.site,
        buNo: row.buNo,
        mainPart: this.searchData.partNo,
        partNo: row.partNo,
        partDesc: row.partDesc,
        printUnit: row.printUnit,
        printUnitName: row.printUnitName,
        processUnit: row.processUnit,
        bomType: 'Manufacturing',
        nodeId: this.currentNode.nodeId,
        offFlag: '2'
      }
      //打开组件 去做新增业务
      this.$nextTick(() => {
        this.$refs.BomCreate.init(tempData)
      })
    },

    // 刷新BOM的loading
    refreshBomLoading () {
      this.bomLoading = false
    },

    // 刷新Routing的loading
    refreshRoutingLoading () {
      this.routingLoading = false
    },

    // 刷新节点列表
    refreshNode (partNo) {
      this.getNodeTree()
      this.currentNode.partNo = partNo
    },

    // 获取基础数据列表S
    getBaseList (val, type) {
      this.tagNo = val
      this.$nextTick(() => {
        let strVal = ''
        if (val === 215) {
          strVal = this.componentData.issueToLoc
        }
        this.$refs.baseList.init(val, strVal)
      })
    },

    // 列表方法的回调
    getBaseData (val) {
      if (this.tagNo === 215) {
        this.componentData.issueToLoc = val.location_id
        this.componentData.issueToLocName = val.location_name
      }
    },

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

    // 校验用户是否收藏
    favoriteIsOk () {
      let userFavorite = {
        userId: this.$store.state.user.id,
        languageCode: this.$i18n.locale
      }
      userFavoriteList(userFavorite).then(({data}) => {
        for (let i = 0; i < data.list.length; i++) {
          if (this.$route.meta.menuId === data.list[i].menuId) {
            this.favorite = true
          }
        }
      })
    },

    updateInquiryDetailStatus () {
      let inData = {
        id: this.searchData.id,
        testPartId: this.searchData.testPartId,
        testPartDesc: this.searchData.partDesc,
        partBomStatus: this.searchData.partBomStatus,
        updateBy: this.$store.state.user.name,
      }
      this.$confirm('是否确认完成？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        updateInquiryDetailStatusAndPart(inData).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success'
            })
            EventBus.$emit('refreshInquiryOneDetail1')
            EventBus.$emit('refreshInquiryOneDetail2')
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      })
    },

    // 收藏 OR 取消收藏
    favoriteFunction() {
      let userFavorite = {
        userId: this.$store.state.user.id,
        functionId: this.$route.meta.menuId,
      }
      if (this.favorite) {
        removeUserFavorite(userFavorite).then(({data}) => {
          this.$message.success(data.msg)
          this.favorite = false
        })
      } else {
        // 收藏
        saveUserFavorite(userFavorite).then(({data}) => {
          this.$message.success(data.msg)
          this.favorite = true
        })
      }
    },

    //获取按钮的权限数据
    getButtonAuthData () {
      let searchFlag = this.isAuth(this.menuId+":search")
      let saveFlag = this.isAuth(this.menuId+":save")
      let updateFlag = this.isAuth(this.menuId+":update")
      let deleteFlag = this.isAuth(this.menuId+":delete")
      //处理页面的权限数据
      this.authSearch = !searchFlag
      this.authSave = !saveFlag
      this.authUpdate = !updateFlag
      this.authDelete = !deleteFlag
    },

    nodeListTreeCurrentChangeHandle (data, node) {
      this.nodeData.pId = data.id
      this.nodeData.parentNodeName = data.nodeName
      this.treeVisible = false
    },

    getPartItem() {
      let tempData = {
        site: this.$store.state.user.site,
        buNo: this.searchData.buNo,
        partNo: this.searchData.partNo,
        codeNo: this.searchData.codeNo,
        recordType: 'IP'
      }
      this.dataListLoading = true
      getPartItem(tempData).then(({data}) => {
        this.dataList = [{}]
        if (data && data.code === 0 && data.rows.length > 0) {
          for (let i = 0; i < data.rows.length; i++) {
            const itemDesc = data.rows[i].itemDesc;
            const value = data.rows[i].numValue ? data.rows[i].numValue : data.rows[i].textValue;
            switch (itemDesc) {
              case 'Family1':
                this.$set(this.dataList[0], 'family1', value);
                break;
              case 'Family2':
                this.$set(this.dataList[0], 'family2', value);
                break;
              case 'Bonding Pitch':
                this.$set(this.dataList[0], 'bondingPitch', value);
                break;
              case '绑定列数':
                this.$set(this.dataList[0], 'bondingLanes', value);
                break;
              case 'Printing lanes':
                this.$set(this.dataList[0], 'printingLanes', value);
                break;
              case 'UPH-TAL':
                this.$set(this.dataList[0], 'uph-tal', value);
                break;
              case 'UPH-Paris':
                this.$set(this.dataList[0], 'uph-paris', value);
                break;
              case 'CL60k-UP':
                this.$set(this.dataList[0], 'cl60k-up', value);
                break;
              case 'CL60k-Pitch':
                this.$set(this.dataList[0], 'cl60k-pitch', value);
                break;
              case 'CL60k-CD':
                this.$set(this.dataList[0], 'cl60k-cd', value);
                break;
              case '复合列数':
                this.$set(this.dataList[0], 'compositeLanes', value);
                break;
              case '贴标列数':
                this.$set(this.dataList[0], 'labelingLanes', value);
                break;
              case '检测列数':
                this.$set(this.dataList[0], 'inspectionLanes', value);
                break;
              case '后道检品-UPH':
                this.$set(this.dataList[0], 'finalInspection-uph', value);
                break;
              case '编码-UPH':
                this.$set(this.dataList[0], 'coding-uph', value);
                break;
              case '编码打印-UPH':
                this.$set(this.dataList[0], 'codingPrinting-uph', value);
                break;
            }
          }
          this.$forceUpdate()
        } else {
          this.dataList = [{}]
        }
        this.dataListLoading = false
      })
    },

    getPartItem1 () {
      let tempData = {
        site: this.partCurrentRow.site,
        buNo: this.partCurrentRow.buNo,
        partNo: this.partCurrentRow.partNo,
        codeNo: this.partCurrentRow.codeNo,
        recordType: 'IP'
      }
      getPartItem(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.partItemList = data.rows
        } else {
          this.partItemList = []
        }
      })
    },

    getPartItem2 () {
      let tempData = {
        site: this.partList1[0].site,
        buNo: this.partList1[0].buNo,
        partNo: this.partList1[0].partNo,
        codeNo: this.partList1[0].codeNo,
        recordType: 'IP'
      }
      getPartItem(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.partItemList1 = data.rows
        } else {
          this.partItemList1 = []
        }
      })
    },

    getRevisionInfo(){
      if (this.partCurrentRow.partNo!==null&&this.partCurrentRow.partNo.length>0){
        let tempData = {
          site: this.partCurrentRow.site,
          buNo: this.partCurrentRow.buNo,
          mainPart: this.searchData.partNo,
          partNo: this.partCurrentRow.partNo,
          partDesc: this.partCurrentRow.partDesc,
          printUnit: this.partCurrentRow.umId2,
          printUnitName: this.partCurrentRow.umName,
          bomType: 'Manufacturing',
          routingType: 'Manufacturing',
          nodeId: this.partCurrentRow.nodeId,
          offFlag: '2'
        }
        this.$nextTick(() => {
          getBomInformationListByPartNo(tempData).then(({data}) => {
            if (data && data.code === 0) {
              this.bomComponentList = []
              this.bomComponentPartList = []
              if (data.rows.length > 0) {
                data.rows = data.rows.filter(item => item.partNo!==null&&item.partNo.length>0)
                if (data.rows.length > 0) {
                  for (let i = 0; i < data.rows.length; i++) {
                    this.$set(data.rows[i], 'index', i)
                    this.$set(this.bomComponentList, i, data.rows[i])
                    this.queryBomDetail(data.rows[i])
                  }
                }
              }
            } else {
              this.$alert(data.msg, '提示', {
                confirmButtonText: '确定'
              })
            }
          })
          getRoutingInformationListByPartNo(tempData).then(({data}) => {
            if (data && data.code === 0) {
              this.routingComponentList = []
              this.routingComponentPartList = []
              if (data.rows.length > 0) {
                data.rows = data.rows.filter(item => item.partNo!==null&&item.partNo.length>0)
                if (data.rows.length > 0) {
                  for (let i = 0; i < data.rows.length; i++) {
                    this.$set(data.rows[i], 'index', i)
                    this.$set(this.routingComponentList, i, data.rows[i])
                    this.queryRoutingDetail(data.rows[i])
                  }
                }
              }
            } else {
              this.$alert(data.msg, '提示', {
                confirmButtonText: '确定'
              })
            }
          })
        })
      }
    },

    getRevisionInfo1(row){
      let tempData = {
        site: row.site,
        buNo: row.buNo,
        mainPart: this.searchData.partNo,
        partNo: row.partNo,
        partDesc: row.partDesc,
        printUnit: row.umId2,
        printUnitName: row.umName,
        bomType: 'Manufacturing',
        routingType: 'Manufacturing',
        offFlag: '2'
      }
      this.$nextTick(() => {
        getBomInformationListByPartNo(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.bomComponentList1 = []
            this.bomComponentPartList1 = []
            if (data.rows.length > 0) {
              data.rows = data.rows.filter(item => item.partNo!==null&&item.partNo.length>0)
              if (data.rows.length > 0) {
                for (let i = 0; i < data.rows.length; i++) {
                  this.$set(data.rows[i], 'index', i)
                  this.$set(this.bomComponentList1, i, data.rows[i])
                  this.queryBomDetail1(data.rows[i])
                }
              }
            }
          } else {
            this.$alert(data.msg, '提示', {
              confirmButtonText: '确定'
            })
          }
        })
        getRoutingInformationListByPartNo(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.routingComponentList1 = []
            this.routingComponentPartList1 = []
            if (data.rows.length > 0) {
              data.rows = data.rows.filter(item => item.partNo!==null&&item.partNo.length>0)
              if (data.rows.length > 0) {
                for (let i = 0; i < data.rows.length; i++) {
                  this.$set(data.rows[i], 'index', i)
                  this.$set(this.routingComponentList1, i, data.rows[i])
                  this.queryRoutingDetail1(data.rows[i])
                }
              }
            }
          } else {
            this.$alert(data.msg, '提示', {
              confirmButtonText: '确定'
            })
          }
        })
      })
    },

    handleBatchUpdatePart(){
      if(this.treeData.length===0){
        this.$message.warning('请先维护主物料的BOM模板!')
        return
      }
      let tempData = {
        site: this.$store.state.user.site,
        buNo: this.searchData.buNo,
        partNo: this.searchData.partNo,
        codeNo: this.searchData.codeNo
      }
      partInfoByMainPart(tempData).then(({data}) => {
        if (data && data.code === 0){
          this.$set(this, 'partList1', data.rows)
          this.searchData.codeNo = this.partList1[0].codeNo
          this.partCurrentRow = JSON.parse(JSON.stringify(this.partList1[0]))
          let tempList = []
          tempList.push(
            ["Select code_no as fieldname1, code_desc as caption1 from plm_properties_model_header where function_type = 'IP' and active = 'Y' and (code_no like '%%' OR code_desc like '%%' )  and site in (select site from eam_access_site where username = '"+this.$store.state.user.name+"')  and (site + '-' + bu_no) in (select (a.site + '-' + a.bu_no) from AccessBu as a left join eam_access_site as b on a.site = b.site and a.username = b.username where a.username = '"+this.$store.state.user.name+"') and site = '"+this.$store.state.user.site+"' and bu_no = '"+this.searchData.buNo+"'"]
          )
          getChooselist1(tempList).then(({data}) => {
            this.$set(this, 'codeList', data.list[0][0])
          })
          let tempData1 = {
            username: this.$store.state.user.name,
          }
          getSiteAndBuByUserName(tempData1).then(({data}) => {
            if (data&&data.code === 0) {
              this.userBuList = data.rows.sort((a, b) => {
                return a.buNo.split('_')[1].localeCompare(b.buNo.split('_')[1]);
              });
            }
          })
          this.getTemplateList()
          this.getPartItem2()
          this.getBomAndRoutingRevision()
          this.batchUpdateFlag = true
        }else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    addOrDelItem () {
      if (!this.attributeFlag1) {
        this.$message.warning('请保存更改！')
        return
      }
      this.itemSelections1 = null
      this.itemSelections2 = null
      this.itemData.propertiesItemNo = ''
      this.itemData.itemDesc = ''
      let tempData = {
        site: this.partCurrentRow.site,
        buNo: this.partCurrentRow.buNo,
        partNo: this.partCurrentRow.partNo,
        codeNo: this.partCurrentRow.codeNo||this.searchData.codeNo,
        recordType: 'IP'
      }
      getItemLists(tempData).then(({data}) => {
        this.itemList1 = data.row1
        this.itemList2 = data.row2
      })
      this.fastAddFlag = true
    },

    addOrDelItem1 () {
      if (!this.attributeFlag1) {
        this.$message.warning('请保存更改！')
        return
      }
      this.itemSelections1 = null
      this.itemSelections2 = null
      this.itemData.propertiesItemNo = ''
      this.itemData.itemDesc = ''
      let tempData = {
        site: this.partList1[0].site,
        buNo: this.partList1[0].buNo,
        partNo: this.partList1[0].partNo,
        codeNo: this.partList1[0].codeNo,
        recordType: 'IP'
      }
      getItemLists(tempData).then(({data}) => {
        this.itemList1 = data.row1
        this.itemList2 = data.row2
      })
      this.fastAddFlag1 = true
    },

    clickSave1 () {
      if (!this.attributeFlag1) { // 保存
        this.updateItemValue1()
        this.attributeFlag1 = true
      } else { // 编辑
        this.copyAttributeList = JSON.parse(JSON.stringify(this.partItemList1))
        this.attributeFlag1 = false
      }
    },
    clickSave () {
      if (!this.attributeFlag1) { // 保存
        this.updateItemValue()
        this.attributeFlag1 = true
      } else { // 编辑
        this.copyAttributeList = JSON.parse(JSON.stringify(this.partItemList))
        this.attributeFlag1 = false
      }
    },

    // 列表表格选择替换
    tabClick (tab, event) {
      this.refreshCurrentTabTable1()
    },
    tabLeave (activeName, oldActiveName) {
      if (!this.attributeFlag1) {
        this.$message.warning('请先保存当前编辑的内容！')
        return false
      }
      return true
    },

    // 刷新页签的table数据
    refreshCurrentTabTable1 () {
      if (this.inventoryPartTable === 'part_item') {
        this.getPartItem2()
      } else if (this.inventoryPartTable === 'part_item1') {
        this.getPartItem1()
      } else if (this.inventoryPartTable === 'revision_info') {
        this.getRevisionInfo()
      }
    },

    // 查询物料属性
    queryPartItem () {
      this.itemData.codeNo = this.modalData.codeNo
      this.itemData.partNo = this.modalData.partNo
      queryPartItem(this.itemData).then(({data}) => {
        if (data && data.code === 0) {
          this.itemList1 = data.rows
        } else {
          this.itemList1 = []
        }
      })
    },

    // 可选属性
    itemClickRow1 (row) {
      this.$refs.itemTable1.toggleRowSelection(row)
    },

    // 复选属性
    selectionItem1 (val) {
      this.itemSelections1 = val
    },

    // 已有属性
    itemClickRow2 (row) {
      this.$refs.itemTable2.toggleRowSelection(row)
    },

    // 复选属性
    selectionItem2 (val) {
      this.itemSelections2 = val
    },

    updateItemValue1 () {
      this.loading = true
      let list = []
      for (let i = 0; i <this.partList1.length; i++) {
        if (this.partList1[i].partNo&&this.partList1.partNo!==''&&this.partList1[i].buNo && this.partList1[i].buNo === this.searchData.buNo){
          let items = JSON.parse(JSON.stringify(this.partItemList1))
          for (let j = 0; j < this.partItemList1.length; j++) {
            items[j].site = this.partList1[i].site
            items[j].buNo = this.partList1[i].buNo
            items[j].partNo = this.partList1[i].partNo
            items[j].codeNo = this.partList1[i].codeNo
            items[j].recordType = 'IP'
          }
          list.push({
            site: this.partList1[i].site,
            buNo: this.partList1[i].buNo,
            partNo: this.partList1[i].partNo,
            codeNo: this.partList1[i].codeNo,
            recordType: 'IP',
            itemList: items
          })
        }
      }
      commitItemsValue(list).then(({data}) => {
        if (data && data.code === 0) {
          this.getPartItem2()
          this.loading = false
          this.attributeFlag1 = true
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
          this.attributeFlag1 = true
          this.loading = false
        }
      }).catch((error) => {
        this.attributeFlag1 = true
        this.$set(this, 'loading', false)
        this.$message.error(error)
      })
    },
    updateItemValue () {
      this.loading = true
      let tempData = {
        itemList: JSON.parse(JSON.stringify(this.partItemList))
      }
      commitItemValue(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.getPartItem1()
          this.loading = false
          this.attributeFlag1 = true
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      }).catch((error) => {
        this.$set(this, 'loading', false)
        this.$message.error(error)
      })
    },

    // 物料项目新增
    addItem () {
      if (this.itemSelections1 == null || this.itemSelections1.length === 0) {
        this.$message.warning('请选择可选属性！')
        return
      }
      let inData = {
        site: this.partCurrentRow.site,
        buNo: this.partCurrentRow.buNo,
        partNo: this.partCurrentRow.partNo,
        codeNo: this.partCurrentRow.codeNo,
        codeDesc: this.partCurrentRow.codeDesc,
        recordType: 'IP',
        itemList: this.itemSelections1
      }
      addPartItem(inData).then(({data}) => {
        if (data && data.code === 0) {
          getItemLists(inData).then(({data}) => {
            this.itemList1 = data.row1
            this.itemList2 = data.row2
          })
          this.getPartItem1()
          this.itemSelections1 = []
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    addItem1 () {
      if (this.itemSelections1 == null || this.itemSelections1.length === 0) {
        this.$message.warning('请选择可选属性！')
        return
      }
      let partList = this.partList1.filter(item => item.partNo&&item.partNo!==''&&item.buNo && item.buNo === this.searchData.buNo)
      this.addItemLoading = true
      let inDataList = []
      for (let i = 0; i < partList.length; i++){
        if (!partList[i].codeNo||partList[i].codeNo===''){
          continue
        }
        inDataList.push({
          site: partList[i].site,
          buNo: partList[i].buNo,
          partNo: partList[i].partNo,
          codeNo: partList[i].codeNo,
          codeDesc: partList[i].codeDesc,
          recordType: 'IP',
          itemList: this.itemSelections1
        })
      }
      addPartsItem(inDataList).then(({data}) => {
        if (data && data.code === 0) {
          getItemLists(inDataList[0]).then(({data}) => {
            this.itemList1 = data.row1
            this.itemList2 = data.row2
            this.addItemLoading = false
            this.getPartItem2()
          })
          this.itemSelections1 = []
        } else {
          this.addItemLoading = false
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      }).catch((error) => {
        this.addItemLoading = false
        this.$message.error(error)
      })
    },

    // 物料项目删除
    deleteItem () {
      if (this.itemSelections2 == null || this.itemSelections2.length === 0) {
        this.$alert("请选择已有属性！", '提示', {
          confirmButtonText: '确定'
        })
        return false
      }
      let inData = {
        site: this.partCurrentRow.site,
        buNo: this.partCurrentRow.buNo,
        partNo: this.partCurrentRow.partNo,
        codeNo: this.partCurrentRow.codeNo,
        codeDesc: this.partCurrentRow.codeDesc,
        recordType: 'IP',
        itemList: this.itemSelections2
      }
      deletePartItem(inData).then(({data}) => {
        if (data && data.code === 0) {
          getItemLists(inData).then(({data}) => {
            this.itemList1 = data.row1
            this.itemList2 = data.row2
          })
          this.getPartItem1()
          this.itemSelections2 = []
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    // 物料项目删除
    deleteItem1 () {
      if (this.itemSelections2 == null || this.itemSelections2.length === 0) {
        this.$alert("请选择已有属性！", '提示', {
          confirmButtonText: '确定'
        })
        return false
      }
      let partList = this.partList1.filter(item => item.partNo&&item.partNo!==''&&item.buNo && item.buNo === this.searchData.buNo)
      let inDataList = []
      for (let i = 0; i < partList.length; i++){
        let items = JSON.parse(JSON.stringify(this.itemSelections2))
        for (let j = 0; j < this.itemSelections2.length; j++) {
          items[j].site = partList[i].site
          items[j].buNo = partList[i].buNo
          items[j].partNo = partList[i].partNo
          items[j].codeNo = partList[i].codeNo
          items[j].recordType = 'IP'
        }
        inDataList.push({
          itemList: items
        })
      }
      deletePartsItem(inDataList).then(({data}) => {
        if (data && data.code === 0) {
          this.$set(this.partList1[0], 'recordType', 'IP')
          getItemLists(this.partList1[0]).then(({data}) => {
            this.itemList1 = data.row1
            this.itemList2 = data.row2
          })
          this.getPartItem2()
          this.itemSelections2 = []
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    rowStyle({row}){
      if(this.partCurrentRow&&row.nodeName===this.partCurrentRow.nodeName)
        return { 'background-color': '#E8F7F6', cursor: 'pointer' };
    },

    bomRowStyle({row}){
      if(this.bomCurrentRow&&row.engChgLevel===this.bomCurrentRow.engChgLevel)
        return { 'background-color': '#E8F7F6', cursor: 'pointer' };
    },

    bomRowStyle1({row}){
      if(this.bomCurrentRow1&&row.engChgLevel===this.bomCurrentRow1.engChgLevel)
        return { 'background-color': '#E8F7F6', cursor: 'pointer' };
    },

    routingRowStyle({row}){
      if(this.routingCurrentRow&&row.routingRevision===this.routingCurrentRow.routingRevision)
        return { 'background-color': '#E8F7F6', cursor: 'pointer' };
    },

    routingRowStyle1({row}){
      if(this.routingCurrentRow1&&row.routingRevision===this.routingCurrentRow1.routingRevision)
        return { 'background-color': '#E8F7F6', cursor: 'pointer' };
    },

    partClickRow(row) {
      this.partCurrentRow = JSON.parse(JSON.stringify(row))
      this.partCurrentRowIndex = this.partList1.indexOf(row)
    },

    async handleEditInfo(){
      if (this.attributeFlag===true){
        this.getPropertiesList()
        this.attributeFlag = false
      } else {
        for (let i = 0; i < this.partList1.length; i++) {
          if (!this.partList1[i].partNo||this.partList1[i].partNo===''){
            console.log('处理行数据',i+1)
            // 没有物料编号就新增料号
            // 没有填写物料描述就认为用户暂时不在这个节点新建料号
            if (this.partList1[i].partDesc === '' || this.partList1[i].partDesc == null) {
              console.log('没有物料描述的行数据',i+1)
              continue
            }
            if (this.partList1[i].buNo === '' || this.partList1[i].buNo == null) {
              console.log('没有BU的行数据',i+1)
              this.$message.warning('请选择'+ this.partList1[i].nodeName +'节点的BU！')
              return
            }
            if (this.partList1[i].partType2 === '' || this.partList1[i].partType2 == null) {
              console.log('没有零件类型的行数据',i+1)
              this.$message.warning('请选择'+ this.partList1[i].nodeName +'节点的零件类型！')
              return
            }
            if (this.partList1[i].umId2 === '' || this.partList1[i].umId2 == null) {
              console.log('没有计量单位的行数据',i+1)
              this.$message.warning('请选择'+ this.partList1[i].nodeName +'节点的计量单位！')
              return
            }
            if (this.partList1[i].partType2 === 'Purchased (raw)' && (this.partList1[i].familyID === '' || this.partList1[i].familyID == null)) {
              console.log('没有物料分类的行数据',i+1)
              this.$message.warning('请选择'+ this.partList1[i].nodeName +'节点的物料分类！')
              return
            }
            if (this.partList1[i].partType2 !== 'Purchased (raw)' && (this.partList1[i].productGroupId1 === '' || this.partList1[i].productGroupId1 == null)) {
              console.log('没有商品组1的行数据',i+1)
              this.$message.warning('请选择'+ this.partList1[i].nodeName +'节点的商品组1！')
              return
            }
            if (this.partList1[i].partType2 !== 'Purchased (raw)' && (this.partList1[i].productGroupId2 === '' || this.partList1[i].productGroupId2 == null)) {
              console.log('没有商品组2的行数据',i+1)
              this.$message.warning('请选择'+ this.partList1[i].nodeName +'节点的商品组2！')
              return
            }
            if (this.partList1[i].codeNo === '' || this.partList1[i].codeNo == null) {
              console.log('没有属性模板的行数据',i+1)
              this.$message.warning('请选择'+ this.partList1[i].nodeName +'节点的属性模板！')
              return
            }
            let flag = true
            this.partList1[i].partNo = '*'
            this.partList1[i].active = 'Y'
            this.partList1[i].createBy = this.$store.state.user.name
            this.partList1[i].mainPart = this.searchData.partNo
            console.log('其他数据赋值完成',i+1)
            // 创建物料
            await savePartInfo(this.partList1[i]).then((data) => {
              if (data.data && data.data.code === 0) {
                console.log('创建物料成功',i+1)
                this.partList1[i].partNo = data.data.rows.partNo
                updatePartNoOfNode(this.partList1[i]).then((data) => {
                  if (data.data && data.data.code === 0) {
                  }else {
                    this.$message.error(data.msg)
                  }
                })
              } else {
                this.$message.error(data.msg)
                flag = false
              }
            })
            if (!flag) {
              return
            }
          }
        }
        this.partList1.forEach(item => this.$set(item, 'mainPart', this.searchData.partNo))
        // 修改物料的属性
        batchSavePartInfo(this.partList1.filter(item => item.partNo&&item.partNo!=='')).then(({data}) => {
          if (data && data.code === 0){
            this.handleBatchUpdatePart()
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
            this.attributeFlag = true
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      }
    },

    handleBatchUpdateDialogClose(){
      if (!this.attributeFlag||!this.attributeFlag1){
        this.$confirm(`编辑尚未保存，是否关闭?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.batchUpdateFlag = false
        })
      } else {
        this.batchUpdateFlag = false
      }
    },

    getPropertiesList(){
      const propLists = []
      for (let i = 0; i <= this.partList1.length; i++) {
        if (i === this.partList1.length){
          propLists[i] = [
            "Select UMID fieldname1, UMName caption1 from UM where site in (select site from eam_access_site where username = '"+this.$store.state.user.name+"')  and site = '"+this.$store.state.user.site+"'",
            "Select template_no fieldname1, template_name caption1 from plm_bom_template where site in (select site from eam_access_site where username = '"+this.$store.state.user.name+"')  and site = '"+this.$store.state.user.site+"'",
          ]
        } else {
          propLists[i] = [
            "select family_id fieldname1, family_name caption1 from part_family where active = 'Y' and site in (select site from eam_access_site where username = '"+this.$store.state.user.name+"')  and (site + '-' + bu_no) in (select (a.site + '-' + a.bu_no) from AccessBu as a left join eam_access_site as b on a.site = b.site and a.username = b.username where a.username = '"+this.$store.state.user.name+"') and site = '"+this.$store.state.user.site+"' and bu_no = '"+this.partList1[i].buNo+"'",
            "select product_group_id fieldname1,product_group_name caption1 from part_product_group where active = 'Y' and type = '1' and site in (select site from eam_access_site where username = '"+this.$store.state.user.name+"')  and (site + '-' + bu_no) in (select (a.site + '-' + a.bu_no) from AccessBu as a left join eam_access_site as b on a.site = b.site and a.username = b.username where a.username = '"+this.$store.state.user.name+"') and site = '"+this.$store.state.user.site+"' and bu_no = '"+this.partList1[i].buNo+"'",
            "select product_group_id fieldname1,product_group_name caption1 from part_product_group where active = 'Y' and type = '2' and site in (select site from eam_access_site where username = '"+this.$store.state.user.name+"')  and (site + '-' + bu_no) in (select (a.site + '-' + a.bu_no) from AccessBu as a left join eam_access_site as b on a.site = b.site and a.username = b.username where a.username = '"+this.$store.state.user.name+"') and site = '"+this.$store.state.user.site+"' and bu_no = '"+this.partList1[i].buNo+"'",
            "select product_group_id fieldname1,product_group_name caption1 from part_product_group where active = 'Y' and type = '3' and site in (select site from eam_access_site where username = '"+this.$store.state.user.name+"')  and (site + '-' + bu_no) in (select (a.site + '-' + a.bu_no) from AccessBu as a left join eam_access_site as b on a.site = b.site and a.username = b.username where a.username = '"+this.$store.state.user.name+"') and site = '"+this.$store.state.user.site+"' and bu_no = '"+this.partList1[i].buNo+"'",
            "Select code_no as fieldname1, code_desc as caption1 from plm_properties_model_header where function_type = 'IP' and active = 'Y' and (code_no like '%%' OR code_desc like '%%' )  and site in (select site from eam_access_site where username = '"+this.$store.state.user.name+"')  and (site + '-' + bu_no) in (select (a.site + '-' + a.bu_no) from AccessBu as a left join eam_access_site as b on a.site = b.site and a.username = b.username where a.username = '"+this.$store.state.user.name+"') and site = '"+this.$store.state.user.site+"' and bu_no = '"+this.partList1[i].buNo+"'"
          ]
        }
      }
      getChooselist1(propLists).then((data) => {
        if (data.data && data.data.code === 0){
          // 对 umList 进行排序，将"米"和"千张"放在最前面
          let umList = data.data.list[this.partList1.length][0] || []
          if (Array.isArray(umList) && umList.length > 0) {
            try {
              const priorityList = []
              const otherList = []

              umList.forEach(item => {
                if (!item) return
                const umid = String(item.fieldname1 || item.UMID || '')
                const umName = String(item.caption1 || item.UMName || '')
                const isQianZhang = umid === '1002' || umName.includes('千张')
                const isMi = umName === '米' || (umName.includes('米') && umName.length <= 2 && !umName.includes('千'))

                if (isMi || isQianZhang) {
                  priorityList.push({ item, isMi, isQianZhang })
                } else {
                  otherList.push(item)
                }
              })

              // 米优先，然后千张
              priorityList.sort((a, b) => {
                if (a.isMi && !b.isMi) return -1
                if (!a.isMi && b.isMi) return 1
                return 0
              })

              if (priorityList.length > 0) {
                umList = [...priorityList.map(p => p.item), ...otherList]
              }
            } catch (error) {
              console.warn('计量单位排序失败，使用原始顺序:', error)
            }
          }

          for (let i = 0; i < this.partList1.length; i++) {
            this.$set(this.partList1[i], 'umList', umList);
            this.$set(this.partList1[i], 'partFamilyList', data.data.list[i][0]);
            this.$set(this.partList1[i], 'partProductGroupList1', data.data.list[i][1]);
            this.$set(this.partList1[i], 'partProductGroupList2', data.data.list[i][2]);
            this.$set(this.partList1[i], 'partProductGroupList3', data.data.list[i][3]);
            this.$set(this.partList1[i], 'codeList', data.data.list[i][4]);
            this.$set(this.partList1[i], 'templateList', data.data.list[this.partList1.length][1]);
          }
        }
      })
    },

    handleCodeNoChange(value) {
      const previousValue = this.previousCodeNo;
      let partList = []
      for (let i = 0; i < this.partList1.length; i++) {
        if (this.partList1[i].partNo&&this.partList1[i].partNo!==''&&this.partList1[i].buNo&&this.partList1[i].buNo === this.searchData.buNo){
          let temp = {
            site: this.$store.state.user.site,
            partNo: this.partList1[i].partNo,
            codeNo: value
          }
          partList.push(temp)
        }
      }
      batchUpdateCodeNo(partList).then(({data}) => {
        if (data&&data.code === 0){
          this.handleBatchUpdatePart()
          this.handleEditInfo()
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
        } else {
          this.$set(this.searchData, 'codeNo', previousValue)
          this.$message({
            message: data.msg,
            type: 'error',
            duration: 1500,
            onClose: () => {}
          })
        }
      })
    },

    async changeBuOfNode(row) {
      this.buNoQueryLoading = true
      row.familyId = ''
      row.productGroupId1 = ''
      row.productGroupId2 = ''
      row.productGroupId3 = ''
      row.codeNo = ''
      row.bu = this.$store.state.user.site + '_' + row.buNo
      const propLists = [
        [
          "select family_id fieldname1, family_name caption1 from part_family where active = 'Y' and site in (select site from eam_access_site where username = '"+this.$store.state.user.name+"')  and (site + '-' + bu_no) in (select (a.site + '-' + a.bu_no) from AccessBu as a left join eam_access_site as b on a.site = b.site and a.username = b.username where a.username = '"+this.$store.state.user.name+"') and site = '"+this.$store.state.user.site+"' and bu_no = '"+row.buNo+"'",
          "select product_group_id fieldname1,product_group_name caption1 from part_product_group where active = 'Y' and type = '1' and site in (select site from eam_access_site where username = '"+this.$store.state.user.name+"')  and (site + '-' + bu_no) in (select (a.site + '-' + a.bu_no) from AccessBu as a left join eam_access_site as b on a.site = b.site and a.username = b.username where a.username = '"+this.$store.state.user.name+"') and site = '"+this.$store.state.user.site+"' and bu_no = '"+row.buNo+"'",
          "select product_group_id fieldname1,product_group_name caption1 from part_product_group where active = 'Y' and type = '2' and site in (select site from eam_access_site where username = '"+this.$store.state.user.name+"')  and (site + '-' + bu_no) in (select (a.site + '-' + a.bu_no) from AccessBu as a left join eam_access_site as b on a.site = b.site and a.username = b.username where a.username = '"+this.$store.state.user.name+"') and site = '"+this.$store.state.user.site+"' and bu_no = '"+row.buNo+"'",
          "select product_group_id fieldname1,product_group_name caption1 from part_product_group where active = 'Y' and type = '3' and site in (select site from eam_access_site where username = '"+this.$store.state.user.name+"')  and (site + '-' + bu_no) in (select (a.site + '-' + a.bu_no) from AccessBu as a left join eam_access_site as b on a.site = b.site and a.username = b.username where a.username = '"+this.$store.state.user.name+"') and site = '"+this.$store.state.user.site+"' and bu_no = '"+row.buNo+"'",
          "Select code_no as fieldname1, code_desc as caption1 from plm_properties_model_header where function_type = 'IP' and active = 'Y' and (code_no like '%%' OR code_desc like '%%' )  and site in (select site from eam_access_site where username = '"+this.$store.state.user.name+"')  and (site + '-' + bu_no) in (select (a.site + '-' + a.bu_no) from AccessBu as a left join eam_access_site as b on a.site = b.site and a.username = b.username where a.username = '"+this.$store.state.user.name+"') and site = '"+this.$store.state.user.site+"' and bu_no = '"+row.buNo+"'"
        ]
      ]
      await getChooselist1(propLists).then((data) => {
        if (data.data && data.data.code === 0){
          this.$set(row, 'partFamilyList', data.data.list[0][0])
          this.$set(row, 'partProductGroupList1', data.data.list[0][1])
          this.$set(row, 'partProductGroupList2', data.data.list[0][2])
          this.$set(row, 'partProductGroupList3', data.data.list[0][3])
          this.$set(row, 'codeList', data.data.list[0][4])
        }
      })
      await getTemplateList(row).then(({data}) => {
        if (data && data.code === 0) {
          this.$set(row, 'tempList', data.rows)
        }
      })
      this.buNoQueryLoading = false
    },

    chooseTemplate(row){
      chooseTemplate(row).then(({data}) => {
        if (data&&data.code===0) {
          Object.keys(data.data).forEach(key => {
            if (key !== 'templateNo') {
              row[key] = data.data[key];
            }
          });
          row.umId2 = data.data.umId
          row.familyID = data.data.familyId
          if (row.partType2&&row.partType2==='Manufactured'){
            row.templateNo = data.data.bomTemplateNo
            row.templateName = data.data.bomTemplateName
          }
        }
      })
    },

    getTemplateList() {
      for (let i = 0; i < this.partList1.length; i++) {
        getTemplateList(this.partList1[i]).then(({data}) => {
          if (data && data.code === 0) {
            this.partList1[i].tempList = data.rows
          }
        })
      }
    },

    queryBomDetail(row) {
      let tempData = {
        flag: '2',
        site: row.site,
        buNo: row.buNo,
        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,
        alternativeNo: row.alternativeNo,
        yieldRate: row.yieldRate,
        shrinkageFactor: new Decimal(100).sub(new Decimal(row.yieldRate)).toNumber(),
        processUnit: row.processUnit,
        processUnitName: row.processUnitName
      }
      queryBomDetail(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.bomComponentPartList = data.rows.componentList
          this.bomComponentList[row.index] = { ...this.bomComponentList[row.index], ...data.rows.detailData}
          this.bomCurrentRow = JSON.parse(JSON.stringify(this.bomComponentList[0]))
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    queryBomDetail1(row) {
      let tempData = {
        flag: '2',
        site: row.site,
        buNo: row.buNo,
        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,
        alternativeNo: row.alternativeNo,
        yieldRate: row.yieldRate,
        shrinkageFactor: new Decimal(100).sub(new Decimal(row.yieldRate)).toNumber(),
        processUnit: row.processUnit,
        processUnitName: row.processUnitName
      }
      queryBomDetail(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.bomComponentPartList1 = data.rows.componentList
          this.bomComponentList1[row.index] = { ...this.bomComponentList1[row.index], ...data.rows.detailData}
          this.bomCurrentRow1 = JSON.parse(JSON.stringify(this.bomComponentList1[0]))
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    queryRoutingDetail (row) {
      let tempData = {
        flag: '2',
        site: row.site,
        buNo: row.buNo,
        partNo: row.partNo,
        partDesc: row.partDesc,
        routingRevision: row.routingRevision,
        routingType: row.routingType,
        noteText: row.noteText,
        phaseInDate: row.phaseInDate,
        phaseOutDate: row.phaseOutDate,
        engRevision: row.engRevision,
        typeFlag: row.typeFlag,
        netWeight: row.netWeight,
        updateBy: this.$store.state.user.name,
        printUnit: row.printUnit,
        printUnitName: row.printUnitName,
        alternativeNo: row.alternativeNo,
      }
      // 查routing明细
      queryRoutingDetail(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.routingComponentPartList = data.rows.componentList
          this.routingComponentList[row.index] = { ...this.routingComponentList[row.index], ...data.rows.detailData}
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    queryRoutingDetail1 (row) {
      let tempData = {
        flag: '2',
        site: row.site,
        buNo: row.buNo,
        partNo: row.partNo,
        partDesc: row.partDesc,
        routingRevision: row.routingRevision,
        routingType: row.routingType,
        noteText: row.noteText,
        phaseInDate: row.phaseInDate,
        phaseOutDate: row.phaseOutDate,
        engRevision: row.engRevision,
        typeFlag: row.typeFlag,
        netWeight: row.netWeight,
        updateBy: this.$store.state.user.name,
        printUnit: row.printUnit,
        printUnitName: row.printUnitName,
        alternativeNo: row.alternativeNo,
      }
      // 查routing明细
      queryRoutingDetail(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.routingComponentPartList1 = data.rows.componentList
          this.routingComponentList1[row.index] = { ...this.routingComponentList1[row.index], ...data.rows.detailData}
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    bomRowClick() {
      let tempData = {
        flag: '2',
        site: this.bomCurrentRow.site,
        buNo: this.bomCurrentRow.buNo,
        partNo: this.bomCurrentRow.partNo,
        partDesc: this.bomCurrentRow.partDesc,
        engChgLevel: this.bomCurrentRow.engChgLevel,
        bomType: this.bomCurrentRow.bomType,
        noteText: this.bomCurrentRow.noteText,
        effPhaseInDate: this.bomCurrentRow.effPhaseInDate,
        effPhaseOutDate: this.bomCurrentRow.effPhaseOutDate,
        engRevision: this.bomCurrentRow.engRevision,
        typeFlag: this.bomCurrentRow.typeFlag,
        netWeight: this.bomCurrentRow.netWeight,
        updateBy: this.$store.state.user.name,
        printUnit: this.bomCurrentRow.printUnit,
        printUnitName: this.bomCurrentRow.printUnitName,
        alternativeNo: this.bomCurrentRow.alternativeNo,
        yieldRate: this.bomCurrentRow.yieldRate,
        shrinkageFactor: new Decimal(100).sub(new Decimal(this.bomCurrentRow.yieldRate)).toNumber(),
        processUnit: this.bomCurrentRow.processUnit,
        processUnitName: this.bomCurrentRow.processUnitName
      }
      queryBomDetail(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.bomComponentPartList = data.rows.componentList
          this.bomFlag = true
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    bomRowClick1() {
      let tempData = {
        flag: '2',
        site: this.bomCurrentRow1.site,
        buNo: this.bomCurrentRow1.buNo,
        partNo: this.bomCurrentRow1.partNo,
        partDesc: this.bomCurrentRow1.partDesc,
        engChgLevel: this.bomCurrentRow1.engChgLevel,
        bomType: this.bomCurrentRow1.bomType,
        noteText: this.bomCurrentRow1.noteText,
        effPhaseInDate: this.bomCurrentRow1.effPhaseInDate,
        effPhaseOutDate: this.bomCurrentRow1.effPhaseOutDate,
        engRevision: this.bomCurrentRow1.engRevision,
        typeFlag: this.bomCurrentRow1.typeFlag,
        netWeight: this.bomCurrentRow1.netWeight,
        updateBy: this.$store.state.user.name,
        printUnit: this.bomCurrentRow1.printUnit,
        printUnitName: this.bomCurrentRow1.printUnitName,
        alternativeNo: this.bomCurrentRow1.alternativeNo,
        yieldRate: this.bomCurrentRow1.yieldRate,
        shrinkageFactor: new Decimal(100).sub(new Decimal(this.bomCurrentRow1.yieldRate)).toNumber(),
        processUnit: this.bomCurrentRow1.processUnit,
        processUnitName: this.bomCurrentRow1.processUnitName
      }
      queryBomDetail(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.bomComponentPartList1 = data.rows.componentList
          this.bomFlag1 = true
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    bomInfoRowClick(row) {
      this.bomCurrentRow = JSON.parse(JSON.stringify(row))
      this.bomRowClick()
    },

    bomInfoRowClick1(row) {
      this.bomCurrentRow1 = JSON.parse(JSON.stringify(row))
      this.bomRowClick1()
    },

    bomInfoTabClick() {
      if (this.bomComponentList.length>0){
        if (!this.bomCurrentRow) {
          this.bomCurrentRow = this.bomComponentList[0]
        }
        this.bomRowClick()
      }
    },

    bomInfoTabClick1() {
      if (this.bomComponentList1.length>0){
        if (!this.bomCurrentRow1) {
          this.bomCurrentRow1 = this.bomComponentList1[0]
        }
        this.bomRowClick1()
      }
    },

    bomInfoRowDblClick(row){
      let tempData = {
        site: this.$store.state.user.site,
        partNo: row.partNo,
        mainPart: this.searchData.partNo,
        engChgLevel: row.engChgLevel,
        routingRevision: this.partCurrentRow.routingRevision
      }
      setRevision(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.handleBatchUpdatePart()
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
        }
      })
    },

    bomInfoRowDblClick1(row){
      this.$set(this.copyData.previousVersion, 'engChgLevel', row.engChgLevel)
      this.$set(this.copyData.previousVersion, 'bomType', row.bomType)
    },

    routingInfoRowDblClick(row){
      let tempData = {
        site: this.$store.state.user.site,
        partNo: row.partNo,
        mainPart: this.searchData.partNo,
        engChgLevel: this.partCurrentRow.engChgLevel,
        routingRevision: row.routingRevision
      }
      setRevision(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.handleBatchUpdatePart()
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
        }
      })
    },

    routingInfoRowDblClick1(row){
      this.copyData.previousVersion.routingRevision = row.routingRevision
      this.copyData.previousVersion.routingType = row.routingType
    },

    routingInfoRowClick(row) {
      this.routingCurrentRow = JSON.parse(JSON.stringify(row))
      this.routingRowClick()
    },

    routingInfoRowClick1(row) {
      this.routingCurrentRow1 = JSON.parse(JSON.stringify(row))
      this.routingRowClick1()
    },

    routingInfoTabClick() {
      if (this.routingComponentList.length>0) {
        if (!this.routingCurrentRow) {
          this.routingCurrentRow = this.routingComponentList[0]
        }
        this.routingRowClick()
      }
    },

    routingInfoTabClick1() {
      if (this.routingComponentList1.length>0) {
        if (!this.routingCurrentRow1) {
          this.routingCurrentRow1 = this.routingComponentList1[0]
        }
        this.routingRowClick1()
      }
    },

    routingRowClick() {
      let tempData = {
        flag: '2',
        site: this.routingCurrentRow.site,
        buNo: this.routingCurrentRow.buNo,
        partNo: this.routingCurrentRow.partNo,
        partDesc: this.routingCurrentRow.partDesc,
        routingRevision: this.routingCurrentRow.routingRevision,
        routingType: this.routingCurrentRow.routingType,
        noteText: this.routingCurrentRow.noteText,
        phaseInDate: this.routingCurrentRow.phaseInDate,
        phaseOutDate: this.routingCurrentRow.phaseOutDate,
        engRevision: this.routingCurrentRow.engRevision,
        typeFlag: this.routingCurrentRow.typeFlag,
        netWeight: this.routingCurrentRow.netWeight,
        updateBy: this.$store.state.user.name,
        printUnit: this.routingCurrentRow.printUnit,
        printUnitName: this.routingCurrentRow.printUnitName,
        alternativeNo: this.routingCurrentRow.alternativeNo,
      }
      // 查routing明细
      queryRoutingDetail(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.routingComponentPartList = data.rows.componentList
          this.bomFlag = false
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    routingRowClick1() {
      let tempData = {
        flag: '2',
        site: this.routingCurrentRow1.site,
        buNo: this.routingCurrentRow1.buNo,
        partNo: this.routingCurrentRow1.partNo,
        partDesc: this.routingCurrentRow1.partDesc,
        routingRevision: this.routingCurrentRow1.routingRevision,
        routingType: this.routingCurrentRow1.routingType,
        noteText: this.routingCurrentRow1.noteText,
        phaseInDate: this.routingCurrentRow1.phaseInDate,
        phaseOutDate: this.routingCurrentRow1.phaseOutDate,
        engRevision: this.routingCurrentRow1.engRevision,
        typeFlag: this.routingCurrentRow1.typeFlag,
        netWeight: this.routingCurrentRow1.netWeight,
        updateBy: this.$store.state.user.name,
        printUnit: this.routingCurrentRow1.printUnit,
        printUnitName: this.routingCurrentRow1.printUnitName,
        alternativeNo: this.routingCurrentRow1.alternativeNo,
      }
      // 查routing明细
      queryRoutingDetail(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.routingComponentPartList1 = data.rows.componentList
          this.bomFlag1 = false
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    getFormula(value) {
      switch (value) {
        case '一复': case '熟化': case 'RFID前道检品':
          return '人数/（速度x时间x效率）'
        case '印刷': case 'RFID-蚀刻': case 'RFID-分切':
          return '人数/（速度x时间x效率）/Printing lanes'
        case '绑定': case 'RFID编码': case 'RFID编码打印':
          return '人数/(UPH(每小时产量)*效率)*1KCT'
        case 'RFID多条检测':
          return '人数/(速度x时间xCDx效率）*1KCT'
        case 'RFID复合模切检测':
          return '人数/(速度x时间x效率x(CDx复合列数))*1KCT'
        case 'RFID后道检品':
          return '人数/UPH（每小时产量）*100%*1KCT'
        case 'RFID自动贴标':
          return '人数/(速度x时间x效率x(CDx贴标列数))*1KCT'
        case 'Voyantic在线检测':
          return '人数/(速度x时间x效率x(CDx检测列数))*1KCT'
        case 'RFID包装':
          return '人数/(日产量/8小时/17人均摊)*1KCT'
        default:
          return ''
      }
    },

    getBomAndRoutingRevision(){
      let list = []
      for (let i = 0; i < this.partList1.length; i++) {
        list.push({
          site: this.partList1[i].site,
          buNo: this.partList1[i].buNo,
          partNo: this.partList1[i].partNo,
          partDesc: this.partList1[i].partDesc,
          printUnit: this.partList1[i].umId2,
          printUnitName: this.partList1[i].umName,
          bomType: 'Manufacturing',
          routingType: 'Manufacturing',
          nodeId: this.partList1[i].nodeId,
          offFlag: '2'
        })
      }
      getBomAndRoutingRevision(list).then(({data}) => {
        if (data && data.code === 0) {
          for (let i = 0; i <this.partList1.length; i++) {
            this.$set(this.partList1[i], 'engChgLevelList', data.rows.engChgLevelList[this.partList1[i].nodeId])
            this.$set(this.partList1[i], 'routingRevisionList', data.rows.routingRevisionList[this.partList1[i].nodeId])
          }
        }
      })
    },

    updateRevision(row, type) {
      if(type === 'bom') {
        let tempData = {
          site: this.$store.state.user.site,
          partNo: row.partNo,
          mainPart: this.searchData.partNo,
          engChgLevel: row.engChgLevel,
          routingRevision: this.partCurrentRow.routingRevision
        }
        setRevision(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.handleBatchUpdatePart()
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          }
        })
      } else if(type === 'routing') {
        let tempData = {
          site: this.$store.state.user.site,
          partNo: row.partNo,
          mainPart: this.searchData.partNo,
          engChgLevel: this.partCurrentRow.engChgLevel,
          routingRevision: row.routingRevision
        }
        setRevision(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.handleBatchUpdatePart()
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          }
        })
      }
    },

    handleCopy() {
      this.copyData.partNo = this.partCurrentRow.partNo
      this.copyData.partDesc = this.partCurrentRow.partDesc
      this.copyData.buNo = this.partCurrentRow.buNo
      this.copyData.bomType = 'Manufacturing'
      this.copyData.routingType = 'Manufacturing'
      this.copyData.effPhaseInDate = new Date()
      this.copyVisible = true
    },

    queryCopyPartModal () {
      this.copyModalData.limit = this.pageSize4
      this.copyModalData.page = this.pageIndex4
      this.copyModalData.site = this.searchData.site
      this.copyModalData.buNo = this.searchData.buNo
      // 查询所有物料
      queryPartList(this.copyModalData).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: '确定'
          })
        }
      })
    },

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

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

    getCopyRowData(row) {
      getCopyRowData(row).then(({data}) => {
        if (data && data.code === 0) {
          this.copyData.previousVersion = data.rows
          this.getRevisionInfo1(data.rows)
          this.copyPartModelFlag = false
        }
      })
    },

    async copySave() {
      if (!this.copyData.previousVersion.partNo) {
        this.$message.warning('请先选择要复制的料号！')
        return
      }
      if (this.copyData.bomFlag&&this.copyData.bomFlag==='Y'&&!this.copyData.previousVersion.engChgLevel) {
        this.$message.warning('请选择要复制的BOM版本!')
        return
      }
      if (this.copyData.routingFlag&&this.copyData.routingFlag==='Y'&&!this.copyData.previousVersion.routingRevision) {
        this.$message.warning('请选择要复制的routing版本!')
        return
      }
      let flag = true
      if (!this.copyData.partNo||this.copyData.partNo==='') {
        // 没有料号就先新建
        if (this.copyData.previousVersion.buNo !== this.copyData.buNo) {
          this.$message.warning('所选的被复制的物料的BU和新物料的不一致!')
          return
        }
        this.copyData.partNo = '*'
        this.copyData.active = 'Y'
        this.copyData.createBy = this.$store.state.user.name
        this.copyData.mainPart = this.searchData.partNo
        this.copyData.bu = this.$store.state.user.site + '_' + this.copyData.buNo

        this.copyData.partType2 = this.copyData.previousVersion.partType2
        this.copyData.umId2 = this.copyData.previousVersion.umId2
        this.copyData.productGroupId1 = this.copyData.previousVersion.productGroupId1
        this.copyData.productGroupId2 = this.copyData.previousVersion.productGroupId2
        this.copyData.productGroupId3 = this.copyData.previousVersion.productGroupId3
        this.copyData.familyID = this.copyData.previousVersion.familyID
        this.copyData.codeNo = this.copyData.previousVersion.codeNo

        await savePartInfo(this.copyData).then(async ({data}) => {
          if (data && data.code === 0) {
            this.$set(this.partList1[this.partCurrentRowIndex], 'partNo', data.rows.partNo)
            this.partList1[this.partCurrentRowIndex].mainPart = this.searchData.partNo
            // 等待 updatePartNoOfNode 完成
            const {data: updateNodeData} = await updatePartNoOfNode(this.partList1[this.partCurrentRowIndex]);
            if (updateNodeData && updateNodeData.code === 0) {
              this.copyData.partNo = this.partList1[this.partCurrentRowIndex].partNo;
            } else {
              this.$message.error(data.msg);
              flag = false;
            }
          } else {
            this.$message.error(data.msg)
            flag = false
          }
        })
      }
      if (this.copyData.bomFlag&&this.copyData.bomFlag==='Y') {
        await copyBom(this.copyData).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
            flag = false
          }
        }).catch(()=>{
          flag = false
        })
      }
      if (this.copyData.routingFlag&&this.copyData.routingFlag==='Y') {
        this.copyData.phaseInDate = this.copyData.effPhaseInDate
        this.copyData.phaseOutDate = this.copyData.effPhaseOutDate
        await copyRouting(this.copyData).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
            flag = false
          }
        }).catch(()=>{
          flag = false
        })
      }
      if (flag) {
        this.copyVisible = false
      }
    },

    // 双击单元格开始编辑
    startEditCell(rowIndex, columnProp, value) {
      this.editingCell.rowIndex = rowIndex
      this.editingCell.columnProp = columnProp
      this.editingCell.value = value || ''

      // 下一帧聚焦输入框
      this.$nextTick(() => {
        if (this.$refs.editInput && this.$refs.editInput[0]) {
          this.$refs.editInput[0].focus()
        }
      })
    },

    // 保存单元格编辑
    async saveEditCell(rowIndex, columnProp, columnLabel) {
      // 防止重复保存
      if (this.editingCell.isSaving) {
        return
      }

      const newValue = this.editingCell.value
      const oldValue = this.dataList[rowIndex][columnProp]

      // 值未改变，直接取消编辑
      if (newValue === oldValue) {
        this.cancelEditCell()
        return
      }

        this.editingCell.isSaving = true

        // 显示loading
        const loading = this.$loading({
          lock: true,
          text: '保存中...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.5)'
        })

        try {
          // 更新本地显示
          this.$set(this.dataList[rowIndex], columnProp, newValue)

        // 先获取当前属性的完整信息
        let itemTemplate = null
        await getPartItem({
          site: this.$store.state.user.site,
          buNo: this.searchData.buNo,
          partNo: this.searchData.partNo,
          codeNo: this.searchData.codeNo,
          recordType: 'IP'
        }).then(({data}) => {
          if (data && data.code === 0 && data.rows) {
            itemTemplate = data.rows.find(item => item.itemDesc === columnLabel)
          }
        })

        if (!itemTemplate) {
          loading.close()
          this.$message.error('未找到属性配置')
          this.$set(this.dataList[rowIndex], columnProp, oldValue)
          this.editingCell.isSaving = false
          this.cancelEditCell()
          return
        }

        // 根据属性类型更新对应的值
        if (itemTemplate.valueTypeDb === 'N') {
          // 数值类型
          const parsedValue = parseFloat(newValue)
          if (newValue !== '' && isNaN(parsedValue)) {
            loading.close()
            this.$message.error('请输入有效的数值')
            this.$set(this.dataList[rowIndex], columnProp, oldValue)
            this.editingCell.isSaving = false
            this.cancelEditCell()
            return
          }
          itemTemplate.numValue = newValue === '' ? null : parsedValue
          itemTemplate.textValue = ''
        } else {
          // 文本类型
          itemTemplate.textValue = newValue || ''
          itemTemplate.numValue = null
        }

        // 准备保存到后端
        let tempData = {
          site: this.$store.state.user.site,
          buNo: this.searchData.buNo,
          partNo: this.searchData.partNo,
          codeNo: this.searchData.codeNo
        }

        // 获取所有物料
        await partInfoByMainPart(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.$set(this, 'partList1', data.rows)
          }
        })

        // 构建保存数据
        let list = []
        let partList = this.partList1.filter(item => item.buNo === this.searchData.buNo)

        for (let i = 0; i < partList.length; i++) {
          if (partList[i].partNo && partList[i].partNo !== '' && partList[i].buNo) {
            // 克隆item对象并更新部分字段
            let itemCopy = JSON.parse(JSON.stringify(itemTemplate))
            itemCopy.site = partList[i].site
            itemCopy.buNo = partList[i].buNo
            itemCopy.partNo = partList[i].partNo
            itemCopy.codeNo = partList[i].codeNo
            itemCopy.recordType = 'IP'

            list.push({
              site: partList[i].site,
              buNo: partList[i].buNo,
              partNo: partList[i].partNo,
              codeNo: partList[i].codeNo,
              recordType: 'IP',
              itemList: [itemCopy]
            })
          }
        }

        // 调用保存接口
        commitItemsValue(list).then(({data}) => {
          if (data && data.code === 0) {
            this.$message.success('保存成功')
            this.editingCell.isSaving = false
            this.cancelEditCell()

            // 关闭"保存中"的loading，创建"重新计算中"的loading
            loading.close()
            const recalcLoading = this.$loading({
              lock: true,
              text: '重新计算中，请稍后...',
              spinner: 'el-icon-loading',
              background: 'rgba(0, 0, 0, 0.5)'
            })

            // 重新计算BOM单位用量和Routing机器处理时间
            const recalcData = {
              site: this.searchData.site,
              buNo: this.searchData.buNo,
              partNo: this.searchData.partNo,
              codeNo: this.searchData.codeNo
            }

            recalculateBomAndRouting(recalcData).then(({data}) => {
              recalcLoading.close()
              if (data && data.code === 0) {
                this.$message.success('重新计算完成')

                // 刷新当前节点的BOM和Routing数据
                if (this.currentNode && this.currentNode.partNo) {
                  if (this.activeTable === 'routing_info') {
                    // 如果当前显示Routing，刷新Routing数据
                    this.getRoutingInfo(this.currentNode)
                  } else {
                    // 如果当前显示BOM，刷新BOM数据
                    this.getBomInfo2(this.currentNode)
                  }
                }
              } else {
                this.$message.warning('重新计算失败，但属性已保存')
              }
            }).catch(error => {
              recalcLoading.close()
              this.$message.warning('重新计算失败，但属性已保存')
            })
          } else {
            loading.close()
            this.$message.error(data.msg || '保存失败')
            this.$set(this.dataList[rowIndex], columnProp, oldValue)
            this.editingCell.isSaving = false
            this.cancelEditCell()
          }
        }).catch(error => {
          loading.close()
          this.$message.error('保存异常')
          this.$set(this.dataList[rowIndex], columnProp, oldValue)
          this.editingCell.isSaving = false
          this.cancelEditCell()
        })

        } catch (error) {
          loading.close()
          this.$message.error('操作失败')
          this.$set(this.dataList[rowIndex], columnProp, oldValue)
          this.editingCell.isSaving = false
          this.cancelEditCell()
        }
    },

    // 取消单元格编辑
    cancelEditCell() {
      this.editingCell.rowIndex = -1
      this.editingCell.columnProp = null
      this.editingCell.value = ''
      this.editingCell.isSaving = false
    },


    async itemUpdateSave() {
      let tempData = {
        site: this.$store.state.user.site,
        buNo: this.searchData.buNo,
        partNo: this.searchData.partNo,
        codeNo: this.searchData.codeNo
      }
      await partInfoByMainPart(tempData).then(({data}) => {
        if (data && data.code === 0){
          this.$set(this, 'partList1', data.rows)
        }else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })

      let list = []
      let partList = this.partList1.filter(item => item.buNo === this.searchData.buNo)
      for (let i = 0; i <this.partList1.length; i++) {
        if (this.partList1[i].partNo&&this.partList1[i].partNo!==''&&this.partList1[i].buNo){
          let items = JSON.parse(JSON.stringify(this.partItemList1))
          items[0].site = this.searchData.site
          items[0].buNo = partList[i].buNo
          items[0].partNo = partList[i].partNo
          items[0].codeNo = partList[i].codeNo
          items[0].recordType = 'IP'
          list.push({
            site: this.partList1[i].site,
            buNo: this.partList1[i].buNo,
            partNo: this.partList1[i].partNo,
            codeNo: this.partList1[i].codeNo,
            recordType: 'IP',
            itemList: items
          })
        }
      }
      commitItemsValue(list).then(({data}) => {
        if (data && data.code === 0) {
          this.getPartItem()
          // this.autoCompute()
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
          this.itemUpdateFlag = false
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      }).catch((error) => {
        this.$message.error(error)
      })
    },

    /**
     * 打开ProcessTimeMatrix选择对话框
     * 默认查询且只查询商品组编码为 G1701、G1702、G1703、G1704 的数据
     */
    openPtmDialog() {
      if (!this.attributeFlag1) {
        this.$message.warning('请先保存当前编辑的内容！')
        return
      }

      // 检查是否有选中的物料
      if (!this.partList1 || this.partList1.length === 0) {
        this.$message.warning('请先选择物料！')
        return
      }

      // 获取第一个物料的信息
      const firstPart = this.partList1[0]

      // 保存当前BU编号
      this.ptmCurrentBuNo = firstPart.buNo

      // 显示加载提示
      const loadingInstance = this.$loading({
        lock: true,
        text: '正在加载商品组数据...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.3)'
      })

      // 查询该BU下所有商品组1
      const productGroupQuery = {
        userName: this.$store.state.user.name,
        type:'1',
        limit :100,
        page :1
      }

      productGroupInformationSearch(productGroupQuery).then(({data}) => {
        if (data && data.code === 0) {
          const allProductGroups = data.page.list || []

          // 筛选出商品组编码为 G1701、G1702、G1703、G1704 的商品组
          const targetProductGroupIds = ['G1701', 'G1702', 'G1703', 'G1704']
          this.ptmProductGroupList = allProductGroups.filter(item =>
            targetProductGroupIds.includes(item.productGroupId)
          )

          if (this.ptmProductGroupList.length === 0) {
            loadingInstance.close()
            this.$message.warning('未找到商品组编码为 G1701、G1702、G1703、G1704 的商品组！')
            return
          }

          // 默认选中第一个筛选出的商品组
          this.ptmSelectedProductGroupId = this.ptmProductGroupList[0].productGroupId

          // 加载默认选中商品组的PTM数据
          this.loadPtmDataByProductGroup(this.ptmSelectedProductGroupId, loadingInstance)
        } else {
          loadingInstance.close()
          this.$alert(data.msg || '查询商品组失败', '错误', {
            confirmButtonText: '确定'
          })
        }
      }).catch(error => {
        loadingInstance.close()
        this.$message.error('查询商品组异常')
        console.error(error)
      })
    },

    /**
     * 根据商品组ID加载PTM数据
     * @param productGroupId 商品组ID
     * @param loadingInstance loading实例（可选）
     */
    loadPtmDataByProductGroup(productGroupId, loadingInstance) {
      if (!productGroupId) {
        if (loadingInstance) loadingInstance.close()
        this.$message.warning('请选择商品组1！')
        return
      }

      // 如果没有传入loading实例，创建一个新的
      if (!loadingInstance) {
        loadingInstance = this.$loading({
          lock: true,
          text: '正在加载ProcessTimeMatrix数据...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.3)'
        })
      } else {
        // 更新loading文本
        loadingInstance.text = '正在加载ProcessTimeMatrix数据...'
      }

      // 查询该商品组下所有PTM条件及其参数（一次查询）
      const queryData = {
        site: this.$store.state.user.site,
        buNo: this.ptmCurrentBuNo,
        productGroupId: productGroupId
      }

      batchSearchProductGroupPtmConditionsWithItems(queryData).then(({data}) => {
        loadingInstance.close()

        if (data && data.code === 0) {
          const ptmConditions = data.conditions || []
          const allItems = data.items || []

          if (ptmConditions.length === 0) {
            this.$message.info('该商品组下未配置PTM参数')
            // 清空数据
            this.ptmDataList = []
            this.filteredPtmDataList = []
            this.ptmColumnList = []
            // 打开对话框（显示空表格）
            this.ptmDialogVisible = true
            return
          }

          if (allItems.length === 0) {
            this.$message.info('该商品组的PTM配置中没有参数')
            // 清空数据
            this.ptmDataList = []
            this.filteredPtmDataList = []
            this.ptmColumnList = []
            // 打开对话框（显示空表格）
            this.ptmDialogVisible = true
            return
          }

          // 处理数据：将items按conditionId分组
          this.processPtmData(ptmConditions, allItems)

        } else {
          this.$alert(data.msg || '查询PTM条件失败', '错误', {
            confirmButtonText: '确定'
          })
        }
      }).catch(error => {
        loadingInstance.close()
        this.$message.error('查询PTM条件异常')
        console.error(error)
      })
    },

    /**
     * 处理商品组切换事件
     * @param productGroupId 新选中的商品组ID
     */
    handleProductGroupChange(productGroupId) {
      if (!productGroupId) {
        // 清空数据
        this.ptmDataList = []
        this.filteredPtmDataList = []
        this.ptmColumnList = []
        return
      }

      // 重新加载PTM数据
      this.loadPtmDataByProductGroup(productGroupId)
    },

    /**
     * 处理PTM数据（横向展示）
     * 将后端返回的数据处理成表格展示格式
     * @param ptmConditions PTM条件列表
     * @param allItems 所有参数列表
     */
    processPtmData(ptmConditions, allItems) {
      const flatDataList = []
      const columnSet = new Set()
      const columnMap = new Map()

      // 将items按conditionId分组
      const itemsByCondition = {}
      allItems.forEach(item => {
        if (!itemsByCondition[item.conditionId]) {
          itemsByCondition[item.conditionId] = []
        }
        itemsByCondition[item.conditionId].push(item)

        // 收集唯一的列信息
        if (!columnSet.has(item.itemNo)) {
          columnSet.add(item.itemNo)
          columnMap.set(item.itemNo, {
            itemNo: item.itemNo,
            itemDesc: item.itemDesc,
            valueType: item.valueTypeDb,
            valueChooseFlag: item.valueChooseFlag
          })
        }
      })

      // 构建表格数据
      ptmConditions.forEach(condition => {
        const items = itemsByCondition[condition.conditionId] || []

        if (items.length === 0) {
          return
        }

        // 构建一行数据：包含conditionDesc和所有参数的值
        const rowData = {
          conditionId: condition.conditionId,
          conditionDesc: condition.conditionDesc,
          seqNo: condition.seqNo,
          site: condition.site,
          buNo: condition.buNo,
          productGroupId: condition.productGroupId,
          items: items  // 保存原始items数据，用于后续添加操作
        }

        // 将每个参数转换为列数据
        items.forEach(item => {
          const propName = `param_${item.itemNo}`
          const displayValue = item.valueTypeDb === 'T' ? item.textValue : item.numValue
          rowData[propName] = displayValue || '-'
        })

        flatDataList.push(rowData)
      })

      // 构建动态列配置
      const columns = []
      columnMap.forEach((colInfo, itemNo) => {
        columns.push({
          prop: `param_${itemNo}`,
          label: colInfo.itemDesc || itemNo,
          itemNo: itemNo,
          valueType: colInfo.valueType,
          width: 110,
          align: colInfo.valueType === 'N' ? 'right' : 'left'
        })
      })

      // 按itemNo排序列
      columns.sort((a, b) => a.itemNo.localeCompare(b.itemNo))

      // 设置数据并打开对话框
      this.ptmDataList = flatDataList
      this.filteredPtmDataList = flatDataList
      this.ptmColumnList = columns
      this.ptmSearchCode = ''
      this.ptmDialogVisible = true

      this.$message.success(`已加载 ${flatDataList.length} 个 ProcessTimeMatrix（共 ${columns.length} 个参数列）`)
    },

    /**
     * 处理双击PTM行事件
     * @param row 双击的行数据
     */
    handlePtmRowDoubleClick(row) {
      if (!row || !row.items || row.items.length === 0) {
        this.$message.warning('该ProcessTimeMatrix没有参数！')
        return
      }

      // 显示loading
      const loadingInstance = this.$loading({
        lock: true,
        text: '正在添加参数...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.3)'
      })

      // 直接添加该行的参数
      this.addPtmItemsFromRow(row, loadingInstance)
    },

    /**
     * 筛选PTM列表（按Code条件描述）
     */
    filterPtmList() {
      if (!this.ptmSearchCode || this.ptmSearchCode.trim() === '') {
        this.filteredPtmDataList = this.ptmDataList
        return
      }

      const searchText = this.ptmSearchCode.trim().toLowerCase()
      this.filteredPtmDataList = this.ptmDataList.filter(row => {
        return row.conditionDesc && row.conditionDesc.toLowerCase().includes(searchText)
      })

      if (this.filteredPtmDataList.length === 0) {
        this.$message.info('没有找到匹配的ProcessTimeMatrix')
      } else {
        this.$message.success(`找到 ${this.filteredPtmDataList.length} 条匹配的ProcessTimeMatrix`)
      }
    },

    /**
     * 重置PTM筛选
     */
    resetPtmFilter() {
      this.ptmSearchCode = ''
      this.filteredPtmDataList = this.ptmDataList
      this.$message.info('已重置筛选条件')
    },

    /**
     * 添加选中的PTM行的参数到物料属性列表
     * @param row 双击的行数据
     * @param loadingInstance loading实例
     */
    addPtmItemsFromRow(row, loadingInstance) {
      // 从行中提取参数，并转换为后端期望的格式
      const allItems = []

      if (row.items && row.items.length > 0) {
        row.items.forEach(item => {
          // 转换为后端期望的格式
          const itemData = {
            itNo: item.itemNo,  // 属性编码（后端接口字段名为itNo）
            valueTypeDb: item.valueTypeDb,
            itemDesc: item.itemDesc
          }

          // 根据类型设置值
          if (item.valueTypeDb === 'T') {
            itemData.textValue = item.textValue || null
            itemData.numValue = null
          } else if (item.valueTypeDb === 'N') {
            itemData.textValue = null
            // 确保numValue是数值类型
            itemData.numValue = item.numValue !== null && item.numValue !== undefined && item.numValue !== ''
              ? (typeof item.numValue === 'number' ? item.numValue : parseFloat(item.numValue))
              : null
          }

          allItems.push(itemData)
        })
      }

      if (allItems.length === 0) {
        loadingInstance.close()
        this.$message.warning('选中的ProcessTimeMatrix中没有参数！')
        return
      }

      // 使用与addItem1相同的逻辑
      const partList = this.partList1.filter(item =>
        item.partNo && item.partNo !== '' && item.buNo && item.buNo === this.searchData.buNo
      )

      if (partList.length === 0) {
        loadingInstance.close()
        this.$message.warning('没有符合条件的物料！')
        return
      }
      const inDataList = []

      for (let i = 0; i < partList.length; i++) {
        if (!partList[i].codeNo || partList[i].codeNo === '') {
          continue
        }

        inDataList.push({
          site: partList[i].site,
          buNo: partList[i].buNo,
          partNo: partList[i].partNo,
          codeNo: partList[i].codeNo,
          codeDesc: partList[i].codeDesc,
          recordType: 'IP',
          itemList: allItems
        })
      }

      if (inDataList.length === 0) {
        loadingInstance.close()
        this.$message.warning('请确保物料已配置属性模板(codeNo)！')
        return
      }

      // 调用批量添加接口（与addItem1相同的逻辑）
      addPartsItem(inDataList).then(({data}) => {
        if (data && data.code === 0) {
          // 更新可选属性列表和已有属性列表
          getItemLists(inDataList[0]).then(({data}) => {
            this.itemList1 = data.row1
            this.itemList2 = data.row2
            loadingInstance.close()
            // 刷新物料属性列表
            this.getPartItem2()

            this.$message.success(`成功添加 ${allItems.length} 个参数（ProcessTimeMatrix: ${row.conditionDesc}）`)

            // 关闭对话框
            this.ptmDialogVisible = false

            // 清空数据
            this.ptmDataList = []
            this.filteredPtmDataList = []
            this.ptmColumnList = []
          }).catch(error => {
            loadingInstance.close()
            this.getPartItem2()
            this.$message.success(`成功添加 ${allItems.length} 个参数（ProcessTimeMatrix: ${row.conditionDesc}）`)
            this.ptmDialogVisible = false
            this.ptmDataList = []
            this.filteredPtmDataList = []
            this.ptmColumnList = []
          })
        } else {
          loadingInstance.close()
          this.$alert(data.msg || '添加属性失败', '错误', {
            confirmButtonText: '确定'
          })
        }
      }).catch(error => {
        loadingInstance.close()
        this.$message.error('添加属性异常: ' + error.message)
        console.error(error)
      })
    },

  },
}
</script>

<style lang="scss" scoped>
.ndoe-list__input {
  > .el-input__inner {
    cursor: pointer;
  }
}
.white-body-view {
  width: 100%;
  min-width: 320px;
}
// 单元格编辑样式
::v-deep .el-table__body-wrapper {
  .el-table__row {
    .cell {
      div[style*="cursor: pointer"] {
        &:hover {
          background-color: #f5f7fa;
          border-radius: 2px;
          transition: background-color 0.2s;
        }
      }
    }
  }
}
.structure-tree {
  .el-scrollbar .el-scrollbar__wrap {
    overflow-x: hidden;
  }
  #my-tree .el-tree > .el-tree-node {
    min-width: 100%;
    display: inline-block;
  }
  .el-tree-node__content {
    margin-bottom: 10px;
  }
  .tooltip {
    margin-right: 5px;
    font-size: 13px;
    border-radius: 4px;
    box-sizing: border-box;
    white-space: nowrap;
    padding: 4px;
  }
  .operation-view {
    display: inline-block;
    padding: 0px 5px;
    margin-left: 5px;
    color: #777777;
  }
  .small-operation-btn {
    margin: 0px 3px;
  }
}
.el-icon-plus:hover {
  color: #1c92e0;
}
.el-icon-edit:hover {
  color: #1c92e0;
}
.el-icon-delete:hover {
  color: #1c92e0;
}
::v-deep .el-tree {
  color: #333333;
}
.el-table /deep/ .cell{
  height: auto;
  line-height: 1.5;
}
/deep/ .customer-tab .el-tabs__item {
  height: 35px;
  line-height: 38px;
  font-size: 13px;
}
.down-tree{
  //height: 470px;
  display: block;
  overflow-y: scroll;
}
</style>


