<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="'ERP物料编码'">
        <el-input v-model="searchData.erpPartNo" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'录入时间'">
        <el-date-picker
          style="width: 120px"
          v-model="searchData.startDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item style="margin-top: 23px;">
        <laber style="margin-left: 0px;font-size: 19px">&#10142</laber>
      </el-form-item>
      <el-form-item :label="' '">
        <el-date-picker
          style="width: 120px"
          v-model="searchData.endDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="'材料描述'">
        <el-input v-model="searchData.partDesc" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'材料规格型号'">
        <el-input v-model="searchData.spec" clearable style="width: 120px"></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-click="partClickRow"
      @selection-change="selectionPart"
      @current-change="changeCurrentRow"
      v-loading="dataListLoading"
      style="width: 100%;">
      <el-table-column
        type="selection"
        header-align="center"
        align="center"
        :selectable="selectFlag"
        width="50">
      </el-table-column>
      <el-table-column
        v-for="(item,index) in columnList" :key="index"
        :sortable="item.columnSortable"
        :prop="item.columnProp"
        :header-align="item.headerAlign"
        :show-overflow-tooltip="item.showOverflowTooltip"
        :align="item.align"
        :fixed="item.fixed === ''?false:item.fixed"
        :min-width="item.columnWidth"
        :label="item.columnLabel">
        <template slot-scope="scope">
          <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
          <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="100"
        label="操作">
        <template slot-scope="scope">
          <a type="text" size="small" @click="updateModal(scope.row)">编辑</a>
        </template>
      </el-table-column>
    </el-table>

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

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

    <!-- 材料新增/编辑模态框 -->
    <el-dialog :title="modalData.title" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="495px">
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="材料描述" prop="partDesc" :rules="rules.partDesc">
          <el-input v-model="modalData.partDesc" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item label="ERP物料编码">
          <el-input v-model="modalData.erpPartNo" style="width: 221px"></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 label="规格型号" prop="spec" :rules="rules.spec">
          <el-input v-model="modalData.spec" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item prop="umName" :rules="rules.umName">
          <span slot="label" @click="getBaseList(107)"><a herf="#">计量单位</a></span>
          <el-input v-model="modalData.umName" style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item prop="familyName" :rules="rules.familyName">
          <span slot="label" @click="getBaseList(108)"><a herf="#">材料分类1</a></span>
          <el-input v-model="modalData.familyName" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item prop="groupName" :rules="rules.groupName">
          <span slot="label" @click="getBaseList(109)"><a herf="#">材料分类2</a></span>
          <el-input v-model="modalData.groupName" style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item>
          <span slot="label" @click="getBaseList(110)"><a herf="#">商品组1</a></span>
          <el-input v-model="modalData.productGroupName1" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item>
          <span slot="label" @click="getBaseList(111)"><a herf="#">商品组2</a></span>
          <el-input v-model="modalData.productGroupName2" style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item>
          <span slot="label" @click="getBaseList(112)"><a herf="#">商品组3</a></span>
          <el-input v-model="modalData.productGroupName3" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item>
          <span slot="label" @click="getBaseList(113)"><a herf="#">商品组4</a></span>
          <el-input v-model="modalData.productGroupName4" style="width: 221px"></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 prop="codeDesc" :rules="rules.codeDesc">
          <span slot="label" @click="getBaseList(20)"><a herf="#">属性模板</a></span>
          <el-input v-model="modalData.codeDesc" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item prop="manufacturerName" :rules="rules.manufacturerName">
          <span slot="label" @click="getBaseList(114)"><a herf="#">制造商</a></span>
          <el-input v-model="modalData.manufacturerName" style="width: 221px"></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 label="是否在用" prop="active" :rules="rules.active">
          <el-select v-model="modalData.active" style="width: 221px">
            <el-option label="是" value="Y"></el-option>
            <el-option label="否" value="N"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="agentName" :rules="rules.agentName">
          <span slot="label" @click="getAgentList()"><a>代理商</a></span>
          <el-input v-model="modalData.agentName" style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="备注">
          <el-input
            type="textarea"
            v-model="modalData.remark"
            :rows="1"
            resize='none'
            maxlength="300"
            show-word-limit
            style="width: 456px;height: 20px">
          </el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:30px;margin-top: 20px;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="margin-top: 0px; width: 100%; min-height: 294px" type="border-card" @tab-click="tabClick" class="customer-tab">
      <!-- 材料属性页签 -->
      <el-tab-pane label="材料属性" name="part_item">
        <el-table
          :data="partItemList"
          :height="secondHeight"
          border
          v-loading="dataListLoading"
          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">
              <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
            header-align="center"
            align="center"
            width="150"
            fixed="right"
            label="操作">
            <template slot-scope="scope">
              <a type="text" size="small" @click="updateItemModal(scope.row)">编辑</a>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <!-- 代理商页签 -->
      <el-tab-pane label="代理商" name="part_agent">
        <el-table
          :data="partAgentList"
          :height="secondHeight"
          border
          v-loading="dataListLoading"
          style="width: 100%;">
          <el-table-column
            v-for="(item,index) in columnAgentList" :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-->
<!--            header-align="center"-->
<!--            align="center"-->
<!--            width="150"-->
<!--            fixed="right"-->
<!--            label="操作">-->
<!--            <template slot-scope="scope">-->
<!--              <a type="text" size="small" @click="updateItemModal(scope.row)">编辑</a>-->
<!--            </template>-->
<!--          </el-table-column>-->
        </el-table>
      </el-tab-pane>
      <!-- 文档页签 -->
      <el-tab-pane label="文档" name="part_file">
        <el-form label-position="top" style="margin-top: 5px; margin-left: 0px;">
          <el-form :inline="true" label-position="top" style="margin-top: 5px">
            <el-button type="primary" @click="uploadFile()">上传文件</el-button>
          </el-form>
        </el-form>
        <el-table
          :data="fileContentList"
          :height="secondHeight"
          border
          v-loading="dataListLoading"
          style="width: 100%; ">
          <el-table-column
            v-for="(item,index) in columnFileList" :key="index"
            :sortable="item.columnSortable"
            :prop="item.columnProp"
            :header-align="item.headerAlign"
            :show-overflow-tooltip="item.showOverflowTooltip"
            :align="item.align"
            :fixed="item.fixed==''?false:item.fixed"
            :min-width="item.columnWidth"
            :label="item.columnLabel">
            <template slot-scope="scope">
              <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
              <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
            </template>
          </el-table-column>
          <el-table-column
            fixed="right"
            header-align="center"
            align="center"
            width="100"
            label="操作">
            <template slot-scope="scope">
              <a @click="downloadFile(scope.row)">下载</a>
              <a type="text" size="small" @click="deleteFile(scope.row)">删除</a>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>

    <!-- 材料属性值编辑模态框 -->
    <el-dialog title="属性项目" :close-on-click-modal="false" v-drag :visible.sync="itemModalFlag" width="310px">
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="属性编码:">
          <el-input v-model="itemData.propertiesItemNo" disabled style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item label="属性名称:">
          <el-input v-model="itemData.itemDesc" disabled style="width: 120px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="文本值:">
          <el-input v-if="!itemChooseFlag" v-model="itemData.textValue" :disabled="itemTextDisableFlag" type="text" style="width: 120px"></el-input>
          <el-select v-if="itemChooseFlag" v-model="itemData.textValue" :disabled="itemTextDisableFlag" style="width: 120px" placeholder="请选择">
            <el-option v-for="item in availableValueList" :key="index" :label="item.availableValue" :value="item.availableValue"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="数字值:">
          <el-input v-if="!itemChooseFlag" v-model="itemData.numValue" :disabled="itemNumberDisableFlag" type="number" style="width: 120px"></el-input>
          <el-select v-if="itemChooseFlag" v-model="itemData.numValue" :disabled="itemNumberDisableFlag" style="width: 120px" placeholder="请选择">
            <el-option v-for="item in availableValueList" :key="index" :label="item.availableValue" :value="item.availableValue"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="itemSaveData()">保存</el-button>
        <el-button type="primary" @click="itemModalFlag=false">关闭</el-button>
      </span>
    </el-dialog>

    <!-- 代理商模态框 -->
    <el-dialog title="代理商清单" :close-on-click-modal="false" v-drag :visible.sync="agentModelFlag" width="520px">
      <div class="rq">
        <el-form :inline="true" label-position="top" :model="agentData">
          <el-form-item :label="'代理商编码'">
            <el-input v-model="agentData.agentId" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'代理商名称'">
            <el-input v-model="agentData.agentName" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="' '">
            <el-button type="primary" @click="getAgentList()">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table
          :height="300"
          :data="agentList"
          ref="agentTable"
          @row-click="agentClickRow"
          @selection-change="selectionAgent"
          :row-key="getRowKeys"
          border
          v-loading="dataListLoading"
          style="width: 100%;">
          <el-table-column
            type="selection"
            header-align="center"
            align="center"
            :reserve-selection="true"
            width="50">
          </el-table-column>
          <el-table-column
            v-for="(item,index) in agentColumnList" :key="index"
            :sortable="item.columnSortable"
            :prop="item.columnProp"
            :header-align="item.headerAlign"
            :show-overflow-tooltip="item.showOverflowTooltip"
            :align="item.align"
            :fixed="item.fixed==''?false:item.fixed"
            :min-width="item.columnWidth"
            :label="item.columnLabel">
            <template slot-scope="scope">
              <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
              <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="confirmAgent()">确认</el-button>
        <el-button type="primary" @click="agentModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

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

    <!-- 上传文件的modal -->
    <partUploadFile ref="partUploadFile" @refreshPageTables="getFileContentData()" v-drag></partUploadFile>
  </div>
</template>

<script>
  import {
    partInformationSearch, // 材料信息列表查询
    partInformationSave, // 材料信息新增
    partInformationEdit, // 材料信息编辑
    partInformationDelete, // 材料信息删除
    getPartItem, // 查询材料属性
    savePartItemValue, // 编辑属性值
    getAgentList, // 获取代理商列表
    getPartAgent, // 获取材料代理商
  } from '@/api/part/partInformation.js'
  import {
    getFileContentList, // 获取材料单附件列表
    deleteQuotationFile, // 文件删除
    downLoadQuotationFile // 文件下载
  } from '@/api/quotation/quotationInformation.js'
  import Chooselist from '@/views/modules/common/Chooselist'
  import partUploadFile from "./part_upload_file"
  export default {
    components: {
      Chooselist,
      partUploadFile
    },
    watch: {
      searchData: {
        deep: true,
        handler: function (newV, oldV) {
          this.searchData.partNo = this.searchData.partNo.toUpperCase()
          this.searchData.erpPartNo = this.searchData.erpPartNo.toUpperCase()
        }
      }
    },
    data () {
      return {
        // 导出
        exportData: [],
        exportName: '物料档案管理' + this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ['物料档案管理'],
        exportFooter: [],
        resultList: [],
        // ======== 行高 ========
        height: 200,
        secondHeight: 200,
        // ======== 分页 ========
        pageIndex: 1,
        pageSize: 50,
        totalPage: 0,
        selectedDataNum: 0,
        // 条件查询
        searchData: {
          site: this.$store.state.user.site,
          partNo: '',
          erpPartNo: '',
          startDate: '',
          endDate: '',
          partDesc: '',
          spec: '',
          page: 1,
          limit: 10
        },
        // 其它
        dataListLoading: false,
        // 初始页签
        activeTable: 'part_item',
        // ======== 数据对象 ========
        modalData: {
          flag: '',
          title: '',
          site: this.$store.state.user.site,
          partNo: '',
          partDesc: '',
          spec: '',
          partTypeDb: '',
          partType: '',
          familyId: '',
          familyName: '',
          groupId: '',
          groupName: '',
          umId: '',
          umName: '',
          active: '',
          remark: '',
          supplierId: '',
          supplierName: '',
          productGroupId1: '',
          productGroupName1: '',
          productGroupId2: '',
          productGroupName2: '',
          productGroupId3: '',
          productGroupName3: '',
          productGroupId4: '',
          productGroupName4: '',
          erpPartNo: '',
          codeNo: '',
          codeDesc: '',
          manufacturerId: '',
          manufacturerName: '',
          createDate: '',
          createBy: '',
          updateDate: '',
          updateBy: '',
          agentId: '',
          agentName: ''
        },
        itemData:{
          site: '',
          partNo: '',
          propertiesItemNo: '',
          itemDesc: '',
          textValue: '',
          numValue: '',
          recordType: 'B'
        },
        agentData: {
          site: this.$store.state.user.site,
          agentId: '',
          agentName: '',
        },
        // ======== 数据列表 ========
        dataList: [],
        partItemList: [],
        partAgentList: [],
        fileContentList: [],
        availableValueList:[],
        agentList: [],
        agentSelections: [],
        // ======== 列表表头 ========
        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: '104001Table1ERPPartNo',
            tableId: '104001Table1',
            tableName: '材料信息表',
            columnProp: 'erpPartNo',
            headerAlign: 'center',
            align: 'center',
            columnLabel: 'ERP物料编码',
            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: 'center',
            columnLabel: '材料描述',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table1Spec',
            tableId: '104001Table1',
            tableName: '材料信息表',
            columnProp: 'spec',
            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: '104001Table1UmId',
            tableId: '104001Table1',
            tableName: '材料信息表',
            columnProp: 'umName',
            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: 104001,
            serialNumber: '104001Table1FamilyName',
            tableId: '104001Table1',
            tableName: '材料信息表',
            columnProp: 'familyName',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '材料分类1',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table1GroupName',
            tableId: '104001Table1',
            tableName: '材料信息表',
            columnProp: 'groupName',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '材料分类2',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table1OtherGroup1',
            tableId: '104001Table1',
            tableName: '材料信息表',
            columnProp: 'productGroupName1',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '商品组1',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table1OtherGroup2',
            tableId: '104001Table1',
            tableName: '材料信息表',
            columnProp: 'productGroupName2',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '商品组2',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table1OtherGroup3',
            tableId: '104001Table1',
            tableName: '材料信息表',
            columnProp: 'productGroupName3',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '商品组3',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table1OtherGroup4',
            tableId: '104001Table1',
            tableName: '材料信息表',
            columnProp: 'productGroupName4',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '商品组4',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table1ItemNo',
            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: '104001Table1ManufacturerName',
            tableId: '104001Table1',
            tableName: '材料信息表',
            columnProp: 'manufacturerName',
            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: '104001Table1AgentName',
            tableId: '104001Table1',
            tableName: '材料信息表',
            columnProp: 'agentName',
            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: '104001Table1Remark',
            tableId: '104001Table1',
            tableName: '材料信息表',
            columnProp: 'remark',
            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: '104001Table1Active',
            tableId: '104001Table1',
            tableName: '材料信息表',
            columnProp: 'active',
            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: 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: 90,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table2PropertiesItemDesc',
            tableId: "104001Table2",
            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: '104001Table2ValueType',
            tableId: "104001Table2",
            tableName: "材料属性表",
            columnProp: 'valueType',
            headerAlign: "center",
            align: "center",
            columnLabel: '属性类型',
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table2ValueChooseFlag',
            tableId: "104001Table2",
            tableName: "材料属性表",
            columnProp: 'textValue',
            headerAlign: "center",
            align: "center",
            columnLabel: '文本值',
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
          {
            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,
          },
        ],
        columnAgentList:  [
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table3AgentId',
            tableId: "104001Table3",
            tableName: "材料代理商表",
            columnProp: 'agentId',
            headerAlign: "center",
            align: "center",
            columnLabel: '代理商编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table3AgentName',
            tableId: "104001Table3",
            tableName: "材料代理商表",
            columnProp: 'agentName',
            headerAlign: "center",
            align: "center",
            columnLabel: '代理商名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table3Active',
            tableId: '104001Table3',
            tableName: '材料代理商表',
            columnProp: 'active',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '是否在用',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table3CreateDate',
            tableId: '104001Table3',
            tableName: '材料代理商表',
            columnProp: 'createDate',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '创建时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table3CreateBy',
            tableId: '104001Table3',
            tableName: '材料代理商表',
            columnProp: 'createBy',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '创建人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table3UpdateDate',
            tableId: '104001Table3',
            tableName: '材料代理商表',
            columnProp: 'updateDate',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '更新时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table3UpdateBy',
            tableId: '104001Table3',
            tableName: '材料代理商表',
            columnProp: 'updateBy',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '更新人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          }
        ],
        columnFileList: [
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table4FileName',
            tableId: '104001Table4',
            tableName: '文件信息表',
            columnProp: 'fileName',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '文件名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table4FileRemark',
            tableId: '104001Table4',
            tableName: '文件信息表',
            columnProp: 'fileRemark',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '备注',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table4CreateDate',
            tableId: '104001Table4',
            tableName: '文件信息表',
            columnProp: 'createDate',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '上传时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104001,
            serialNumber: '104001Table4CreatedBy',
            tableId: '104001Table4',
            tableName: '文件信息表',
            columnProp: 'createdBy',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '上传人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          }
        ],
        agentColumnList: [
          {
            columnProp: 'agentId',
            headerAlign: "center",
            align: "center",
            columnLabel: '代理商编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnProp: 'agentName',
            headerAlign: "center",
            align: "center",
            columnLabel: '代理商名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
        ],
        // ======== 必填规则 ========
        rules: {
          partDesc: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          spec: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          umName: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          familyName: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          groupName: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          codeDesc: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          manufacturerName: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          active: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          agentName: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
        },
        // ======== 复选数据集 ========
        partSelections: [],
        // ======== 选中的当前行数据 ========
        partCurrentRow: {},
        // ======== 模态框开关控制 ========
        modalFlag: false,
        modalDisableFlag: false,
        itemChooseFlag: false,
        itemTextDisableFlag: false,
        itemNumberDisableFlag: false,
        itemModalDisableFlag: false,
        itemModalFlag: false,
        agentModelFlag: false
      }
    },
    mounted () {
      this.$nextTick(() => {
        this.height = window.innerHeight / 2 - 30
        /*第二个表格高度的动态调整*/
        this.secondHeight = window.innerHeight / 2  - 206
      })
    },
    created () {
      this.getDataList()
    },
    methods: {
      // ======== 分页相关方法 ========
      /**
       * 每页数
       * @param val
       */
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      /**
       * 当前页
       * @param val
       */
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },

      // ======== 页签切换相关方法 ========
      /**
       * 未知
       * @returns {boolean}
       */
      selectFlag () {
        return true;
      },
      /**
       * 列表表格选择替换
       * @param tab
       * @param event
       */
      tabClick (tab, event) {
        // 刷新列表数据
        this.refreshCurrentTabTable()
      },
      /**
       * 当前值发生变化的时候修改
       * @param row
       * @param oldRow
       */
      changeCurrentRow (row, oldRow) {
        // 判断是否是获取焦点的事件
        if (row) {
          this.partCurrentRow = JSON.parse(JSON.stringify(row))
          //刷新当前页表
          this.refreshCurrentTabTable()
        }
      },
      /**
       * 刷新页签的table数据
       */
      refreshCurrentTabTable () {
        if (this.activeTable === 'part_item') {
          this.getPartItem()
        } else if (this.activeTable === 'part_agent') {
          this.getPartAgent()
        } else if (this.activeTable === 'part_file') {
          this.getFileContentData()
        }
      },

      // ======== 列表数据刷新方法 ========
      /**
       * 查询材料属性
       */
      getPartItem () {
        let tempData = {
          site: this.$store.state.user.site,
          partNo: this.partCurrentRow.partNo,
          codeNo: this.partCurrentRow.codeNo,
          recordType: 'B'
        }
        getPartItem(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.partItemList = data.rows
          } else {
            this.partItemList = []
          }
        })
      },
      /**
       * 查询材料代理商
       */
      getPartAgent () {
        let tempData = {
          site: this.$store.state.user.site,
          partNo: this.partCurrentRow.partNo,
          agentId: this.partCurrentRow.agentId
        }
        getPartAgent(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.partAgentList = data.rows
          } else {
            this.partAgentList = []
          }
        })
      },

      // ======== 列表数据刷新方法 ========
      /**
       * 获取数据列表
       */
      getDataList () {
        this.searchData.limit = this.pageSize
        this.searchData.page = this.pageIndex
        partInformationSearch(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.totalPage > 0){
              // 设置选中行
              this.$refs.partTable.setCurrentRow(this.dataList[0])
              // 加载当前的页签的table
              this.refreshCurrentTabTable()
              this.partClickRow(this.dataList[0])
            }
          }
          this.dataListLoading = false
        })
      },

      // ======== 新增/编辑模态框 ========
      /**
       * 材料信息新增模态框
       */
      addModal () {
        this.modalData = {
          flag: '1',
          title: '材料新增',
          site: this.$store.state.user.site,
          partNo: '',
          partDesc: '',
          spec: '',
          partTypeDb: '',
          partType: '',
          familyId: '',
          familyName: '',
          groupId: '',
          groupName: '',
          umId: '',
          umName: '',
          active: 'Y',
          remark: '',
          supplierId: '',
          supplierName: '',
          productGroupId1: '',
          productGroupName1: '',
          productGroupId2: '',
          productGroupName2: '',
          productGroupId3: '',
          productGroupName3: '',
          productGroupId4: '',
          productGroupName4: '',
          erpPartNo: '',
          codeNo: '',
          codeDesc: '',
          manufacturerId: '',
          manufacturerName: '',
          agentId: '',
          agentName: '',
          createBy: this.$store.state.user.name
        }
        this.modalDisableFlag = false
        this.modalFlag = true
      },
      /**
       * 材料信息编辑模态框
       * @param row
       */
      updateModal (row) {
        this.modalData = {
          flag: '2',
          title: '材料编辑',
          site: row.site,
          partNo: row.partNo,
          partDesc: row.partDesc,
          spec: row.spec,
          partTypeDb: row.partTypeDb,
          partType: row.partType,
          familyId: row.familyId,
          familyName: row.familyName,
          groupId: row.groupId,
          groupName: row.groupName,
          umId: row.umId,
          umName: row.umName,
          active: row.active,
          remark: row.remark,
          supplierId: row.supplierId,
          supplierName: row.supplierName,
          productGroupId1: row.productGroupId1,
          productGroupName1: row.productGroupName1,
          productGroupId2: row.productGroupId2,
          productGroupName2: row.productGroupName2,
          productGroupId3: row.productGroupId3,
          productGroupName3: row.productGroupName3,
          productGroupId4: row.productGroupId4,
          productGroupName4: row.productGroupName4,
          erpPartNo: row.erpPartNo,
          codeNo: row.codeNo,
          codeDesc: row.codeDesc,
          manufacturerId: row.manufacturerId,
          manufacturerName: row.manufacturerName,
          agentId: row.agentId,
          agentName: row.agentName,
          updateBy: this.$store.state.user.name
        }
        this.modalDisableFlag = true
        this.modalFlag = true
      },

      /**
       * 选择代理商
       */
      getAgentList () {
        // 先清空缓存选中
        this.$nextTick(() => this.$refs.agentTable.clearSelection())
        // 拿到选中的代理商id
        let tempDataList = this.modalData.agentId.split(';')
        // 查询所有代理商
        getAgentList(this.agentData).then(({data}) => {
          if (data && data.code === 0) {
            this.agentList = data.rows
            this.agentList.forEach(val => {
              // 回显选中的代理商
              if (tempDataList.includes(val.agentId)) {
                this.$nextTick(() => this.$refs.agentTable.toggleRowSelection(val, true))
              }
            })
            this.agentModelFlag = true
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
      /**
       * 代理商多选
       * @param row
       */
      agentClickRow (row) {
        this.$refs.agentTable.toggleRowSelection(row);
      },
      /**
       * 获得选中的代理商
       * @param val
       */
      selectionAgent (val) {
        this.agentSelections = val
      },
      /**
       * 返回列表唯一值
       * @param row
       * @returns {string|[{trigger: string, message: string, required: boolean}]|*}
       */
      getRowKeys (row) {
        // 唯一值，一般都为id
        return row.agentId;
      },
      /**
       * 确认多选代理商
       * @returns {boolean}
       */
      confirmAgent () {
        this.modalData.agentId = ''
        this.modalData.agentName = ''
        for (let i = 0; i < this.agentSelections.length; i++) {
          this.modalData.agentId = this.modalData.agentId + ";" + this.agentSelections[i].agentId
          this.modalData.agentName = this.modalData.agentName + ";" + this.agentSelections[i].agentName
        }
        this.modalData.agentId = this.modalData.agentId.substring(1)
        this.modalData.agentName = this.modalData.agentName.substring(1)
        this.agentModelFlag = false
      },

      // ======== 新增/编辑/删除方法 ========
      /**
       * 材料信息新增/编辑
       */
      saveData () {
        if (this.modalData.partDesc === '' || this.modalData.partDesc == null) {
          this.$message.warning('请填写材料描述！')
          return
        }
        if (this.modalData.spec === '' || this.modalData.spec == null) {
          this.$message.warning('请填写规格型号！')
          return
        }
        if (this.modalData.umId === '' || this.modalData.umId == null) {
          this.$message.warning('请选择计量单位！')
          return
        }
        if (this.modalData.familyId === '' || this.modalData.familyId == null) {
          this.$message.warning('请选择分类！')
          return
        }
        if (this.modalData.groupId === '' || this.modalData.groupId == null) {
          this.$message.warning('请选择分组！')
          return
        }
        if (this.modalData.codeNo === '' || this.modalData.codeNo == null) {
          this.$message.warning('请选择属性模板！')
          return
        }
        if (this.modalData.manufacturerId === '' || this.modalData.manufacturerId == null) {
          this.$message.warning('请选择制造商！')
          return
        }
        if (this.modalData.active === '' || this.modalData.active == null) {
          this.$message.warning('请选择是否在用！')
          return
        }
        if (this.modalData.agentId === '' || this.modalData.agentId == null) {
          this.$message.warning('请选择代理商！')
          return
        }
        if (this.modalData.flag === '1') {
          partInformationSave(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 {
          partInformationEdit(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
          }
          partInformationDelete(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: '确定'
              })
            }
          })
        }).catch(() => {
        })
      },

      // ======== 列表操作方法 ========
      /**
       * 单机选中材料信息
       * @param row
       */
      partClickRow (row) {
        this.$refs.partTable.toggleRowSelection(row)
        this.partCurrentRow = JSON.parse(JSON.stringify(row))
      },
      /**
       * 复选材料信息
       * @param val
       */
      selectionPart (val) {
        this.partSelections = val
        this.$refs.selectDiv.setLengthselected(this.partSelections.length)
      },

      // ======== 属性页签相关方法 ========
      /**
       * 编辑属性值模态框
       */
      updateItemModal (row) {
        this.itemData = {
          site: row.site,
          partNo: row.partNo,
          propertiesItemNo: row.propertiesItemNo,
          itemDesc: row.itemDesc,
          textValue: row.textValue,
          numValue: row.numValue,
          recordType: 'B'
        }
        this.availableValueList = row.availableValueList
        if (row.valueChooseFlag === 'Y') {
          this.itemChooseFlag = true
        } else {
          this.itemChooseFlag = false
        }
        this.itemTextDisableFlag = true
        this.itemNumberDisableFlag = true
        if (row.valueTypeDb !== 'T') {
          this.itemNumberDisableFlag = false
        } else {
          this.itemTextDisableFlag = false
        }
        this.itemModalDisableFlag = true
        this.itemModalFlag = true
      },
      /**
       * 编辑属性值方法
       * @returns {boolean}
       */
      itemSaveData () {
        if(this.itemData.partNo === '' || this.itemData.partNo == null){
          this.$message.warning('未选择物料！')
          return false
        }
        if(this.itemData.propertiesItemNo === ''|| this.itemData.propertiesItemNo == null){
          this.$message.warning('未选择属性！')
          return false
        }
        savePartItemValue(this.itemData).then(({data}) => {
          if (data && data.code === 0) {
            this.itemModalFlag = false
            this.getPartItem()
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // ======== 附件的相关方法 ========
      /**
       * 获取材料附件列表
       */
      getFileContentData () {
        let currentData = {
          orderRef1: this.$store.state.user.site,
          orderRef2: this.partCurrentRow.partNo
        }
        getFileContentList(currentData).then(({data}) => {
          if (data && data.code === 0) {
            this.fileContentList = data.rows
          } else {
            this.fileContentList = []
          }
        })
      },
      /**
       * 上传文件
       */
      uploadFile () {
        let currentData = {
          titleCon: '材料附件上传',
          site: this.$store.state.user.site,
          createBy: this.$store.state.user.name,
          partNo: this.partCurrentRow.partNo
        }
        //打开组件 去做新增业务
        this.$nextTick(() => {
          this.$refs.partUploadFile.init(currentData);
        })
      },
      /**
       * 文件删除
       * @param row
       */
      deleteFile (row) {
        this.$confirm('确定要删除此文件?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteQuotationFile(row).then(({data}) => {
            if (data && data.code === 0) {
              this.getFileContentData()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }).catch(() => {
        })
      },
      /**
       * 文件下载
       * @param row
       */
      downloadFile (row) {
        downLoadQuotationFile(row).then(({data}) => {
          // 不限制文件下载类型
          const blob = new Blob([data], {type:'application/octet-stream;charset=utf-8'})
          // 下载文件名称
          const fileName = row.fileName
          // a标签下载
          const linkNode = document.createElement('a')
          linkNode.download = fileName // a标签的download属性规定下载文件的名称
          linkNode.style.display = 'none'
          linkNode.href = URL.createObjectURL(blob) // 生成一个Blob URL
          document.body.appendChild(linkNode)
          linkNode.click() // 模拟在按钮上的一次鼠标单击
          URL.revokeObjectURL(linkNode.href) // 释放URL 对象
          document.body.removeChild(linkNode)
        })
      },

      // ======== chooseList相关方法 ========
      /**
       * 获取基础数据列表S
       * @param val
       * @param type
       */
      getBaseList (val, type) {
        this.tagNo = val
        this.$nextTick(() => {
          let strVal = ''
          if (val === 107) {
            strVal = this.modalData.umId
          } else if (val === 108) {
            strVal = this.modalData.familyId
          } else if (val === 109) {
            strVal = this.modalData.groupId
          } else if (val === 110) {
            strVal = this.modalData.productGroupId1
          } else if (val === 111) {
            strVal = this.modalData.productGroupId2
          } else if (val === 112) {
            strVal = this.modalData.productGroupId3
          } else if (val === 113) {
            strVal = this.modalData.productGroupId4
          } else if (val === 114) {
            strVal = this.modalData.manufacturerId
          } else if (val === 20) {
            strVal = this.modalData.codeNo
          }
          this.$refs.baseList.init(val, strVal)
        })
      },
      /**
       * 列表方法的回调
       * @param val
       */
      getBaseData (val) {
        if (this.tagNo === 107) {
          this.modalData.umId = val.um_id
          this.modalData.umName = val.um_name
        } else if (this.tagNo === 108) {
          this.modalData.familyId = val.family_id
          this.modalData.familyName = val.family_name
        } else if (this.tagNo === 109) {
          this.modalData.groupId = val.group_id
          this.modalData.groupName = val.group_name
        } else if (this.tagNo === 110) {
          this.modalData.productGroupId1 = val.product_group_id
          this.modalData.productGroupName1 = val.product_group_name
        } else if (this.tagNo === 111) {
          this.modalData.productGroupId2 = val.product_group_id
          this.modalData.productGroupName2 = val.product_group_name
        } else if (this.tagNo === 112) {
          this.modalData.productGroupId3 = val.product_group_id
          this.modalData.productGroupName3 = val.product_group_name
        } else if (this.tagNo === 113) {
          this.modalData.productGroupId4 = val.product_group_id
          this.modalData.productGroupName4 = val.product_group_name
        } else if (this.tagNo === 114) {
          this.modalData.manufacturerId = val.manufacturer_id
          this.modalData.manufacturerName = val.manufacturer_name
        } else if (this.tagNo === 20) {
          this.modalData.codeNo = val.Code_no
          this.$set(this.modalData, 'codeDesc', val.Code_desc)
        }
      },

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

<style scoped lang="scss">
/deep/ .customer-tab .el-tabs__content {
  padding: 0px !important;
  height: 459px;
}
/deep/ .customer-tab .el-tabs__content {
  height: 294px;
}
</style>

