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

    <!-- 物料列表 -->
    <el-table
      :height="height"
      :data="dataList"
      border
      ref="partTable"
      :row-style="rowStyle"
      @row-click="partClickRow"
      @selection-change="selectionPart"
      @current-change="changeCurrentRow"
      style="width: 100%;">
      <el-table-column
        type="selection"
        header-align="center"
        align="center"
        width="50">
      </el-table-column>
      <el-table-column
        v-for="(item,index) in columnList" :key="index"
        :sortable="item.columnSortable"
        :prop="item.columnProp"
        :header-align="item.headerAlign"
        :show-overflow-tooltip="item.showOverflowTooltip"
        :align="item.align"
        :fixed="item.fixed === ''?false:item.fixed"
        :min-width="item.columnWidth"
        :label="item.columnLabel">
        <template slot-scope="scope">
          <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
          <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="100"
        label="操作">
        <template slot-scope="scope">
          <el-link style="cursor: pointer" @click="updateModal(scope.row)">编辑</el-link>
        </template>
      </el-table-column>
    </el-table>

    <selectDiv ref="selectDiv"></selectDiv>

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

    <!-- 物料新增/编辑模态框 -->
    <el-dialog :title="modalData.title" top="29vh" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="737px">
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="物料编码" prop="partNo" :rules="rules.partNo">
          <el-input v-model="modalData.partNo" clearable style="width: 120px" :disabled="modalDisableFlag"></el-input>
        </el-form-item>
        <el-form-item label="物料描述" prop="partDesc" :rules="rules.partDesc" style="margin-left: -10px">
          <el-input v-model="modalData.partDesc" clearable style="width: 330px"></el-input>
        </el-form-item>
        <el-form-item style="margin-top: 20px">
          <el-checkbox v-model="modalData.conditionCodeUsageDb" true-label="Y">允许条件代码</el-checkbox><br>
          <el-checkbox v-model="modalData.multilevelTrackingDb" true-label="Y">多级跟踪</el-checkbox><br>
          <el-checkbox v-model="modalData.allowAsNotConsumedDb" true-label="Y">允许为未使用</el-checkbox>
        </el-form-item>
<!--        <el-form-item v-if="modalData.flag === '2' && modalData.officialFlag !== 'Y'">-->
<!--          <el-button type="primary" @click="toBecomeOfficialPart" style="margin-top: 62px;margin-left: 10px;width: 110px">转正式物料</el-button>-->
<!--        </el-form-item>-->
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item prop="umId" :rules="rules.umId">
          <span style="cursor: pointer" slot="label" @click="getBaseList(1007)"><a herf="#">计量单位</a></span>
          <el-input v-model="modalData.umId" @blur="umIdBlur(1007)" style="width: 120px"></el-input>
          <el-input v-model="modalData.umName" disabled style="width: 330px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item>
          <span style="cursor: pointer" slot="label" @click="getBaseList(22)"><a herf="#">属性模板</a></span>
          <el-input v-model="modalData.codeNo" @blur="codeNoBlur(20)" style="width: 120px"></el-input>
          <el-input v-model="modalData.codeDesc" disabled style="width: 330px"></el-input>
        </el-form-item>
        <el-form-item label="批次/批次跟踪">
          <el-select v-model="modalData.lotTrackingCode" style="width: 230px">
            <el-option label="Lot Tracking" value="Lot Tracking"></el-option>
            <el-option label="Not Lot Tracking" value="Not Lot Tracking"></el-option>
            <el-option label="Order Based" value="Order Based"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="净重">
          <el-input-number :controls="false" :step="0" v-model="modalData.weightNet" style="width: 120px"></el-input-number>
        </el-form-item>
        <el-form-item label="净重单位" style="margin-left: -10px">
          <dict-data-select v-if="modalFlag" v-model="modalData.uomForWeightNet" style="width: 330px" :use-default-value="false" dict-type="part_uom_for_weight_net"></dict-data-select>
        </el-form-item>
<!--        <el-form-item>-->
<!--          <span style="cursor: pointer" slot="label" @click="getBaseList(109)"><a herf="#">物料分组</a></span>-->
<!--          <el-input v-model="modalData.partMainGroup" @blur="groupIdBlur(109)" style="width: 120px"></el-input>-->
<!--          <el-input v-model="modalData.groupName" disabled style="width: 330px"></el-input>-->
<!--        </el-form-item>-->
        <el-form-item label="批量规则">
          <el-select v-model="modalData.lotQuantityRule" :disabled="modalData.lotTrackingCode === 'Not Lot Tracking'" style="width: 230px">
            <el-option label="One Lot Per Production Order" value="One Lot Per Production Order"></el-option>
            <el-option label="Many Lots Per Production Order" value="Many Lots Per Production Order"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="体积">
          <el-input-number :controls="false" :step="0" v-model="modalData.volumeNet" style="width: 120px"></el-input-number>
        </el-form-item>
        <el-form-item label="体积单位" style="margin-left: -10px">
          <dict-data-select v-if="modalFlag" v-model="modalData.uomForVolumeNet" style="width: 330px" dict-type="part_uom_for_volume_net"></dict-data-select>
        </el-form-item>
        <el-form-item label="子批次规则">
          <el-select v-model="modalData.subLotRule" :disabled="modalData.lotTrackingCode === 'Not Lot Tracking'" style="width: 230px">
            <el-option label="Sub Lots Allowed" value="Sub Lots Allowed"></el-option>
            <el-option label="No Sub Lots Allowed" value="No Sub Lots Allowed"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">

        <el-form-item label="组件批次规则" style="margin-left: 468px">
          <el-select v-model="modalData.componentLotRule" :disabled="modalData.lotTrackingCode === 'Not Lot Tracking'" style="width: 230px">
            <el-option label="Many Lots Allowed" value="Many Lots Allowed"></el-option>
            <el-option label="One Lot Allowed" value="One Lot Allowed"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-footer style="height:35px;margin-top: 25px;text-align:center">
        <el-button type="primary" @click="saveData()">保存</el-button>
        <el-button type="primary" @click="modalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 页签 -->
    <el-tabs v-model="activeTable" style="width: 100%" :style="{height: this.secondHeight + 'px'}" type="border-card" @tab-click="tabClick" class="customer-tab">
      <!-- 物料属性页签 -->
      <el-tab-pane label="物料属性" name="part_item">
        <el-form label-position="top" style="margin-top: 2px; margin-left: 2px;">
          <el-button type="primary" @click="addOrDelItem">新增</el-button>
<!--          <el-button type="primary" @click="updateItemValue">编辑</el-button>-->
          <el-button type="primary" :loading="loading" @click="clickSave">{{ attributeDialog?'编辑':'保存' }}</el-button>
        </el-form>
        <div class="rq" v-if="attributeDialog">
          <el-table
            :data="partItemList"
            :height="secondHeight - 60"
            border
            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>
                  {{scope.row.textValue?scope.row.textValue:scope.row.numValue}}
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="rq" v-else>
          <el-table
            :data="copyAttributeList"
            :height="secondHeight - 60"
            border
            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.list" :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.list" :key="key"></el-option>
                    </el-select>
                  </div>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-tab-pane>
    </el-tabs>

    <!-- 物料属性值编辑模态框 -->
    <el-dialog title="物料属性" :close-on-click-modal="false" v-drag :visible.sync="updateItemModelFlag" width="1000px">
      <div class="rq ">
        <el-table
          :data="updatePartItemList"
          height="350px"
          border
          style="width: 100%;">
          <el-table-column
            v-for="(item,index) in updateColumnItemList" :key="index"
            :sortable="item.columnSortable"
            :prop="item.columnProp"
            :header-align="item.headerAlign"
            :show-overflow-tooltip="item.showOverflowTooltip"
            :align="item.align"
            :fixed="item.fixed==''?false:item.fixed"
            :min-width="item.columnWidth"
            :label="item.columnLabel">
            <template slot-scope="scope">
              <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
              <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
            </template>
          </el-table-column>
          <el-table-column
            prop="textValue"
            header-align="center"
            align="right"
            min-width="80"
            label="文本值">
            <template slot-scope="scope">
              <el-input v-if="scope.row.valueTypeDb === 'T' && scope.row.valueChooseFlag === 'N'" v-model="scope.row.textValue" style="height: 11px;padding: 0px " allow-create>;width:98%"></el-input>
              <el-select v-if="scope.row.valueTypeDb === 'T' && scope.row.valueChooseFlag === 'Y'" v-model="scope.row.textValue" style="width: 180px" placeholder="请选择">
                <el-option v-for="item in scope.row.availableValueList" :key="index" :label="item.availableValue" :value="item.availableValue"></el-option>
              </el-select>
              <el-input v-if="scope.row.valueTypeDb !== 'T'" v-model="scope.row.textValue" disabled style="height: 11px;padding: 0px " allow-create>;width:98%"></el-input>
            </template>
          </el-table-column>
          <el-table-column
            prop="numValue"
            header-align="center"
            align="right"
            min-width="80"
            label="数字值">
            <template slot-scope="scope">
              <el-input v-if="scope.row.valueTypeDb === 'N' && scope.row.valueChooseFlag === 'N'" v-model="scope.row.numValue" style="height: 11px;padding: 0px " allow-create>;width:98%"></el-input>
              <el-select v-if="scope.row.valueTypeDb === 'N' && scope.row.valueChooseFlag === 'Y'" v-model="scope.row.numValue" style="width: 180px" placeholder="请选择">
                <el-option v-for="item in scope.row.availableValueList" :key="index" :label="item.availableValue" :value="item.availableValue"></el-option>
              </el-select>
              <el-input v-if="scope.row.valueTypeDb !== 'N'" v-model="scope.row.numValue" disabled style="height: 11px;padding: 0px " allow-create>;width:98%"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="commitItemValue()">保存</el-button>
        <el-button type="primary" @click="updateItemModelFlag=false">关闭</el-button>
      </span>
    </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="queryMasterPartItem()">查询</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" @click="addItem()">添加>></el-button>
          </div>
          <div style="margin-top: 15px;margin-left: 18px">
            <el-button type="primary" @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>

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

<script>
  import {
    masterPartSearch, // 物料信息列表查询
    masterPartInformationSave, // 物料信息新增
    masterPartInformationEdit, // 物料信息编辑
    masterPartInformationDelete, // 物料信息删除
    getMasterPartItem, // 查询物料属性
    commitItemValue, // 修改物料属性值
    getItemLists, // 获取模板属性
    addMasterPartItem, // 新增物料属性
    deleteMasterPartItem, // 删除物料属性
    queryMasterPartItem,
    toBecomeOfficialMasterPart, // 转正式物料
  } from '@/api/part/masterPartInformation.js'
  import {getChooselistData, verifyData} from "@/api/chooselist/chooselist.js"
  import {getProjectPartNo} from '@/api/part/partInformation.js'
  import Chooselist from '@/views/modules/common/Chooselist'
  import DictDataSelect from '../sys/dict-data-select.vue'
  export default {
    components: {
      DictDataSelect,
      Chooselist
    },
    watch: {
      searchData: {
        deep: true,
        handler: function (newV, oldV) {
          this.searchData.partNo = this.searchData.partNo.toUpperCase()
        }
      },
      modalData: {
        deep: true,
        handler: function (newV, oldV) {
          this.modalData.partNo = this.modalData.partNo.toUpperCase()
          //this.modalData.umId = this.modalData.umId.toUpperCase()
          this.modalData.codeNo = this.modalData.codeNo.toUpperCase()
        }
      },
      itemData: {
        deep: true,
        handler: function (newV, oldV) {
          this.itemData.propertiesItemNo = this.itemData.propertiesItemNo.toUpperCase()
        }
      }
    },
    data () {
      return {
        // 导出
        exportData: [],
        exportName: '物料档案管理' + this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ['物料档案管理'],
        exportFooter: [],
        resultList: [],
        // ======== 行高 ========
        height: 200,
        secondHeight: 200,
        // ======== 分页 ========
        pageIndex: 1,
        pageSize: 50,
        totalPage: 0,
        selectedDataNum: 0,
        tempCodeNo: '',
        // 条件查询
        searchData: {
          site: '*',
          partNo: '',
          partDesc: '',
          page: 1,
          limit: 10
        },
        // 其它
        // 初始页签
        activeTable: 'part_item',
        // ======== 数据对象 ========
        modalData: {
          flag: '',
          site: '',
          title: '',
          partNo: '',
          partDesc: '',
          umId: '',
          umName: '',
          partMainGroup: '',
          groupName: '',
          weightNet: '',
          uomForWeightNet: '',
          volumeNet: '',
          uomForVolumeNet: '',
          codeNo: '',
          codeDesc: '',
          conditionCodeUsageDb: '',
          multilevelTrackingDb: '',
          allowAsNotConsumedDb: '',
          lotTrackingCode: '',
          lotQuantityRule: '',
          subLotRule: '',
          componentLotRule: '',
          createDate: '',
          createBy: '',
          updateDate: '',
          updateBy: '',
          officialFlag: ''
        },
        itemData: {
          site: '*',
          partNo: '',
          propertiesItemNo: '',
          codeNo: '',
          itemDesc: '',
          textValue: '',
          numValue: '',
          recordType: 'MP'
        },
        // ======== 数据列表 ========
        dataList: [],
        partItemList: [],
        updatePartItemList: [],
        availableValueList:[],
        itemSelections1: [],
        itemSelections2: [],
        itemList1:[],
        itemList2:[],
        copyAttributeList: [],
        // ======== 列表表头 ========
        columnList: [
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table1PartNo',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'partNo',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '物料编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table1PartDesc',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'partDesc',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '物料描述',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table1OfficialFlag',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'officialFlagDesc',
            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: 104001,
            serialNumber: '104001Table1OfficialFlag',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'umId',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '计量单位',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table1WeightNet',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'weightNet',
            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: 104001,
            serialNumber: '104001Table1UomForWeightNet',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'uomForWeightNet',
            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: 104001,
            serialNumber: '104001Table1VolumeNet',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'volumeNet',
            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: 104001,
            serialNumber: '104001Table1UomForVolumeNet',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'uomForVolumeNet',
            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: 104001,
            serialNumber: '104001Table1GroupName',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'groupName',
            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: 104001,
            serialNumber: '104001Table1CodeDesc',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'codeDesc',
            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: 104001,
            serialNumber: '104001Table1ConditionCodeUsageDb',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'conditionCodeUsageDb',
            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: 104001,
            serialNumber: '104001Table1MultilevelTrackingDb',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'multilevelTrackingDb',
            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: 104001,
            serialNumber: '104001Table1AllowAsNotConsumedDb',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'allowAsNotConsumedDb',
            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: 104001,
            serialNumber: '104001Table1LotTrackingCode',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'lotTrackingCode',
            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: 104001,
            serialNumber: '104001Table1LotQuantityRule',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'lotQuantityRule',
            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: 104001,
            serialNumber: '104001Table1SubLotRule',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'subLotRule',
            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: 104001,
            serialNumber: '104001Table1ComponentLotRule',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'componentLotRule',
            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: 104001,
            serialNumber: '104001Table1CreateDate',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'createDate',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '创建时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 160
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table1CreateBy',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'createBy',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '创建人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table1UpdateDate',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'updateDate',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '更新时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 160
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table1UpdateBy',
            tableId: '104001Table1',
            tableName: '物料信息表',
            columnProp: 'updateBy',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '更新人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          }
        ],
        columnItemList:  [
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table2PropertiesItemID',
            tableId: "104001Table2",
            tableName: "物料属性表",
            columnProp: 'propertiesItemNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '属性编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table2PropertiesItemDesc',
            tableId: "104001Table2",
            tableName: "物料属性表",
            columnProp: 'itemDesc',
            headerAlign: "center",
            align: "left",
            columnLabel: '属性名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table2ValueType',
            tableId: "104001Table2",
            tableName: "物料属性表",
            columnProp: 'valueType',
            headerAlign: "center",
            align: "center",
            columnLabel: '属性类型',
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table2ValueChooseFlag',
            tableId: "104001Table2",
            tableName: "物料属性表",
            columnProp: 'textValue',
            headerAlign: "center",
            align: "left",
            columnLabel: '属性值',
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          // {
          //   userId: this.$store.state.user.name,
          //   functionId: 104001,
          //   serialNumber: '104001Table2ValueChooseFlag',
          //   tableId: "104001Table2",
          //   tableName: "物料属性表",
          //   columnProp: 'numValue',
          //   headerAlign: "center",
          //   align: "center",
          //   columnLabel: '数字值',
          //   columnHidden: false,
          //   columnImage: false,
          //   columnSortable: true,
          //   sortLv: 0,
          //   status: true,
          //   fixed: '',
          //   columnWidth: 70,
          // },
        ],
        updateColumnItemList: [
          {
          userId: this.$store.state.user.name,
          functionId: 104001,
          serialNumber: '104001Table6PropertiesItemID',
          tableId: "104001Table6",
          tableName: "物料属性表",
          columnProp: 'propertiesItemNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '属性编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: true,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 90,
        },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table6PropertiesItemDesc',
            tableId: "104001Table6",
            tableName: "物料属性表",
            columnProp: 'itemDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '属性名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 90,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table6ValueType',
            tableId: "104001Table6",
            tableName: "物料属性表",
            columnProp: 'valueType',
            headerAlign: "center",
            align: "center",
            columnLabel: '属性类型',
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
        ],
        // ======== 必填规则 ========
        rules: {
          partNo: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          partDesc: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          umId: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          codeDesc: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ]
        },
        // ======== 复选数据集 ========
        partSelections: [],
        // ======== 选中的当前行数据 ========
        partCurrentRow: {},
        // ======== 模态框开关控制 ========
        modalFlag: false,
        modalDisableFlag: false,
        itemChooseFlag: false,
        itemTextDisableFlag: false,
        itemNumberDisableFlag: false,
        itemModalDisableFlag: false,
        itemModalFlag: false,
        agentModelFlag: false,
        manufacturerModelFlag: false,
        updateItemModelFlag: false,
        fastAddFlag: false,
        loading: false,
        attributeDialog: true,
      }
    },

    mounted () {
      this.$nextTick(() => {
        this.height = window.innerHeight / 2 - 30
        /*第二个表格高度的动态调整*/
        this.secondHeight = window.innerHeight - this.height - 175
      })
    },

    created () {
      this.getDataList()
    },

    methods: {

      focusNextInput (index, type) {
        let aaa = ''
        if (this.updatePartItemList.length - 1 === index) {
          aaa = `${type}0`
        } else {
          aaa = `${type}${index + 1}`
        }
        this.$nextTick(() => {
          this.$refs[aaa].focus()
        })
      },

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

      // 编辑物料属性
      updateItemValue () {
        this.loading = true
        let tempData = {
          itemList: JSON.parse(JSON.stringify(this.copyAttributeList))
        }
        commitItemValue(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.getMasterPartItem()
            this.attributeDialog = true
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
          this.loading = false
        }).catch((error) => {
          this.$message.error(error)
          this.loading = false
        })
      },

      // 新增/删除物料属性
      addOrDelItem () {
        if (!this.attributeDialog) {
          this.$message.warning('请保存更改！')
          return
        }
        this.itemSelections1 = null
        this.itemSelections2 = null
        this.itemData.propertiesItemNo = ''
        this.itemData.itemDesc = ''
        let tempData = {
          site: '*',
          partNo: this.partCurrentRow.partNo,
          codeNo: this.partCurrentRow.codeNo,
          recordType: 'MP'
        }
        getItemLists(tempData).then(({data}) => {
          this.itemList1 = data.rows.row1
          this.itemList2 = data.rows.row2
        })
        this.fastAddFlag = true
      },

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

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

      selectionItem1 (val) {
        this.itemSelections1 = val
      },

      selectionItem2 (val) {
        this.itemSelections2 = val
      },

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

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

      // 查询物料项目
      queryMasterPartItem () {
        this.itemData.partNo = this.partCurrentRow.partNo
        this.itemData.codeNo = this.partCurrentRow.codeNo
        this.itemData.partNo = this.partCurrentRow.partNo
        queryMasterPartItem(this.itemData).then(({data}) => {
          if (data && data.code === 0) {
            this.itemList1 = data.rows
          } else {
            this.itemList1 = []
          }
        })
      },

      // 确认修改物料属性
      commitItemValue () {
        let tempData = {
          itemList: JSON.parse(JSON.stringify(this.updatePartItemList))
        }
        commitItemValue(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.getMasterPartItem()
            this.updateItemModelFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // ======== 分页相关方法 ========
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },

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

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

      // 当前值发生变化的时候修改
      changeCurrentRow (row, oldRow) {
        // 判断是否是获取焦点的事件
        if (row) {
          this.partCurrentRow = JSON.parse(JSON.stringify(row))
          // 刷新当前页表
          this.refreshCurrentTabTable()
        }
      },

      // 刷新页签的table数据
      refreshCurrentTabTable () {
        if (this.activeTable === 'part_item') {
          this.getMasterPartItem()
        }
      },

      // ======== 列表数据刷新方法 ========
      // 查询物料属性
      getMasterPartItem () {
        let tempData = {
          site: '*',
          partNo: this.partCurrentRow.partNo,
          codeNo: this.partCurrentRow.codeNo,
          recordType: 'MP'
        }
        getMasterPartItem(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.partItemList = data.rows
          } else {
            this.partItemList = []
          }
        })
      },

      // ======== 列表数据刷新方法 ========
      // 获取数据列表
      getDataList () {
        this.searchData.site = this.$store.state.user.site
        this.searchData.limit = this.pageSize
        this.searchData.page = this.pageIndex
        masterPartSearch(this.searchData).then(({data}) => {
          if (data.code === 0) {
            this.dataList = data.page.list
            this.pageIndex = data.page.currPage
            this.pageSize = data.page.pageSize
            this.totalPage = data.page.totalCount
            this.$refs.selectDiv.setLengthAll( this.dataList.length)
            // 判断是否全部存在数据
            if (this.dataList.length > 0) {
              // 设置选中行
              this.$refs.partTable.setCurrentRow(this.dataList[0])
              this.partClickRow(this.dataList[0])
            } else {
              this.partCurrentRow = {}
            }
            // 加载当前的页签的table
            this.refreshCurrentTabTable()
          }
        })
      },

      // ======== 新增/编辑模态框 ========
      // 物料信息新增模态框
      addModal () {
        getProjectPartNo(this.searchData).then(({data}) => {
          if (data && data.code === 0) {
            this.modalData = {
              flag: '1',
              site: '*',
              title: '物料新增',
              partNo: data.partNo,
              partDesc: '',
              umId: '',
              umName: '',
              partMainGroup: '',
              groupName: '',
              weightNet: '',
              uomForWeightNet: '',
              volumeNet: '',
              uomForVolumeNet: '',
              codeNo: '',
              codeDesc: '',
              conditionCodeUsageDb: '',
              multilevelTrackingDb: '',
              allowAsNotConsumedDb: '',
              lotTrackingCode: 'Not Lot Tracking',
              lotQuantityRule: 'One Lot Per Production Order',
              subLotRule: 'No Sub Lots Allowed',
              componentLotRule: 'Many Lots Allowed',
              createBy: this.$store.state.user.name,
              officialFlag: 'N'
            }
            this.modalDisableFlag = false
            this.modalFlag = true
          } else {
            this.$message.error(data.msg)
          }
        })
      },

      // 物料信息编辑模态框
      updateModal (row) {
        this.modalData = {
          flag: '2',
          title: '物料编辑',
          site: '*',
          partNo: row.partNo,
          partDesc: row.partDesc,
          umId: row.umId,
          umName: row.umName,
          partMainGroup: row.partMainGroup,
          groupName: row.groupName,
          weightNet: row.weightNet,
          uomForWeightNet: row.uomForWeightNet,
          volumeNet: row.volumeNet,
          uomForVolumeNet: row.uomForVolumeNet,
          codeNo: row.codeNo,
          codeDesc: row.codeDesc,
          conditionCodeUsageDb: row.conditionCodeUsageDb,
          multilevelTrackingDb: row.multilevelTrackingDb,
          allowAsNotConsumedDb: row.allowAsNotConsumedDb,
          lotTrackingCode: row.lotTrackingCode,
          lotQuantityRule: row.lotQuantityRule,
          subLotRule: row.subLotRule,
          componentLotRule: row.componentLotRule,
          updateBy: this.$store.state.user.name,
          officialFlag: row.officialFlag
        }
        this.modalDisableFlag = true
        this.modalFlag = true
      },

      // ======== 新增/编辑/删除方法 ========
      // 物料信息新增/编辑
      saveData () {
        if (this.modalData.partNo === '' || this.modalData.partNo == null) {
          this.$message.warning('请填写物料编码！')
          return
        }
        if (this.modalData.partDesc === '' || this.modalData.partDesc == null) {
          this.$message.warning('请填写物料描述！')
          return
        }
        if (this.modalData.umId === '' || this.modalData.umId == null) {
          this.$message.warning('请选择计量单位！')
          return
        }
        if (this.modalData.flag === '1') {
          masterPartInformationSave(this.modalData).then(({data}) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.modalFlag = false
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        } else {
          masterPartInformationEdit(this.modalData).then(({data}) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.modalFlag = false
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }
      },

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

      // ======== 列表操作方法 ========
      // 单机选中物料信息
      partClickRow (row) {
        // this.$refs.partTable.toggleRowSelection(row)
        this.partCurrentRow = JSON.parse(JSON.stringify(row))
      },

      // 复选物料信息
      selectionPart (val) {
        this.partSelections = val
        this.$refs.selectDiv.setLengthselected(this.partSelections.length)
      },

      // 转正式物料
      toBecomeOfficialPart () {
        toBecomeOfficialMasterPart(this.modalData).then(({data}) => {
          if (data && data.code === 0) {
            this.getDataList()
            this.modalFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // ======== chooseList相关方法 ========
      // 获取基础数据列表S
      getBaseList (val, type) {
        this.tagNo = val
        this.tempCodeNo = this.modalData.codeNo
        this.$nextTick(() => {
          let strVal = ''
          if (val === 1007) {
            strVal = this.modalData.umId
          } else if (val === 109) {
            strVal = this.modalData.partMainGroup
          } else if (val === 22) {
            strVal = this.modalData.codeNo
          }
          this.$refs.baseList.init(val, strVal)
        })
      },

      // 列表方法的回调
      getBaseData (val) {
        if (this.tagNo === 1007) {
          this.modalData.umId = val.um_id
          this.modalData.umName = val.um_name
        } else if (this.tagNo === 109) {
          this.modalData.partMainGroup = val.group_id
          this.modalData.groupName = val.group_name
        } else if (this.tagNo === 22) {
          if (this.modalData.flag === '2') {
            if (val.Code_no != this.tempCodeNo) {
              this.$confirm(`更换属性模板将替换下方物料属性数据，请确认?`, '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                this.modalData.codeNo = val.Code_no
                this.$set(this.modalData, 'codeDesc', val.Code_desc)
              }).catch(() => {
              })
            }
          } else {
            this.modalData.codeNo = val.Code_no
            this.$set(this.modalData, 'codeDesc', val.Code_desc)
          }
        }
      },

      // 计量单位输入校验
      umIdBlur (tagNo) {
        if (this.modalData.umId != null && this.modalData.umId !== '') {
          let tempData = {
            tagno: tagNo,
            conditionSql: " and um_id = '" + this.modalData.umId + "'"
          }
          verifyData(tempData).then(({data}) => {
            if (data && data.code === 0) {
              if (data.baseListData.length > 0) {
                this.modalData.umId = data.baseListData[0].um_id
                this.modalData.umName = data.baseListData[0].um_name
                return
              }
            }
          })
        }
        this.modalData.umName = ''
      },

      // 产品代码输入校验
      groupIdBlur (tagNo) {
        if (this.modalData.partMainGroup != null && this.modalData.partMainGroup !== '') {
          let tempData = {
            tagno: tagNo,
            conditionSql: " and group_id = '" + this.modalData.partMainGroup + "'"
          }
          verifyData(tempData).then(({data}) => {
            if (data && data.code === 0) {
              if (data.baseListData.length > 0) {
                this.modalData.partMainGroup = data.baseListData[0].group_id
                this.modalData.groupName = data.baseListData[0].group_name
                return
              }
            }
          })
        }
        this.modalData.groupName = ''
      },

      // 属性模板输入校验
      codeNoBlur (tagNo) {
        if (this.modalData.codeNo != null && this.modalData.codeNo !== '') {
          let tempData = {
            tagno: tagNo,
            conditionSql: " and Code_no = '" + this.modalData.codeNo + "'"
          }
          verifyData(tempData).then(({data}) => {
            if (data && data.code === 0) {
              if (data.baseListData.length > 0) {
                this.modalData.codeNo = data.baseListData[0].Code_no
                this.modalData.codeDesc = data.baseListData[0].Code_desc
                return
              }
            }
          })
        }
        this.modalData.codeDesc = ''
      },

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

      startDownload () {},

      finishDownload () {},

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

      rowStyle ({row}) {
        if (this.partCurrentRow.partNo === row.partNo) {
          return { 'background-color': '#E8F7F6', cursor: 'pointer' };
        }
      },
    }
  }
</script>

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

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

