<template>
  <div>
    <fieldset class="customer-field" style="width: 100%; padding: 0.35em 0.75em 0.425em;">
      <el-row>
        <el-col :span="24">
          <el-button @click="initToolHeaderModel('Y')" type="primary">{{ buttons.add }}</el-button>
          <el-button @click="initToolHeaderModel('N')" type="primary">{{ buttons.edit }}</el-button>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form :inline="true" label-position="top" label-width="100px">
            <el-form-item>
              <el-link slot="label" @click="getBaseList(70)"> {{inputLabel.headerInput.label1}}</el-link>
              <el-input style="width: 100px;"
                        @keyup.enter.native="getHeaderData"
                        v-model="headerData.toolId"></el-input> <!---->
            </el-form-item>
            <el-form-item :label="inputLabel.headerInput.label2">
              <el-input style="width: 100px;" readonly v-model="headerData.toolDescription"></el-input>
            </el-form-item>
            <el-form-item :label="inputLabel.headerInput.label3">
              <el-input style="width: 100px;" readonly v-model="headerData.spec"></el-input>
            </el-form-item>
            <el-form-item :label="inputLabel.headerInput.label4">
              <el-input style="width: 100px;" readonly v-model="headerData.site"></el-input>
            </el-form-item>
            <el-form-item :label="inputLabel.headerInput.label5">
              <el-input style="width: 100px;" readonly v-model="headerData.familyId"></el-input>
            </el-form-item>
            <el-form-item :label="inputLabel.headerInput.label6">
              <el-input style="width: 100px;" readonly v-model="headerData.familyName"></el-input>
            </el-form-item>
            <el-form-item :label="inputLabel.headerInput.label7">
              <el-input style="width: 100px;" readonly v-model="headerData.umid"></el-input>
            </el-form-item>
            <el-form-item :label="inputLabel.headerInput.label8">
              <el-input style="width: 100px;" readonly v-model="headerData.strActive"></el-input>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form :inline="true" label-position="top" label-width="100px">
            <el-form-item :label="inputLabel.headerInput.label9">
              <el-input style="width: 100px;" readonly v-model="headerData.codeNo"></el-input>
            </el-form-item>
            <el-form-item :label="inputLabel.headerInput.label10">
              <el-input style="width: 100px;" readonly v-model="headerData.defaultLocationId"></el-input>
            </el-form-item>
            <el-form-item :label="inputLabel.headerInput.label11">
              <el-input style="width: 100px;" readonly v-model="headerData.strPartCreated"></el-input>
            </el-form-item>
            <el-form-item :label="inputLabel.headerInput.label12">
              <el-input style="width: 100px;" readonly v-model="headerData.partNo"></el-input>
            </el-form-item>
            <el-form-item :label="inputLabel.headerInput.label14">
              <el-input style="width: 100px;" readonly v-model="headerData.strCreateDate"></el-input>
            </el-form-item>
            <el-form-item :label="inputLabel.headerInput.label15">
              <el-input style="width: 100px;" readonly v-model="headerData.createdBy"></el-input>
            </el-form-item>
            <el-form-item :label="inputLabel.headerInput.label13">
              <el-input style="width: 215px;" readonly v-model="headerData.remark"></el-input>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
    </fieldset>

    <el-tabs style="font-size: 12px" class="customer-tab" v-model="activeName" type="border-card">
      <el-tab-pane :label="'工具实例'" name="toolInfo">
        <el-row>
          <el-col :span="7">
            <fieldset class="customer-field" style="width: 98%;">
              <legend>数据明细/编辑</legend>
              <el-form :inline="true" label-position="top" label-width="95px" style="padding: 5px;">
                <el-form-item>
                  <el-button @click="initToolModel('Y')" type="primary">{{ buttons.add }}</el-button>
                  <el-button @click="initToolModel('N')" type="primary">{{ buttons.edit }}</el-button>
                  <el-button @click="printMethod('Y')" type="primary">{{ '工具标签' }}</el-button>
                  <el-button @click="printMethod('N')" type="primary">{{ '网版' }}</el-button>
                </el-form-item>
              </el-form>
              <el-form :inline="true" label-position="top" label-width="95px">
                <el-row>
                  <el-col :span="12">
                    <el-form-item :label="inputLabel.leftInput.label1">
                      <el-select @change="toolInstanceIdChange(currentDetailData.toolInstanceId)"
                                 v-model="currentDetailData.toolInstanceId" placeholder="请选择" style="width: 150px;">
                        <el-option
                          v-for="item in selectList.select4"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item :label="inputLabel.leftInput.label2">
                      <el-input style="width: 150px;" readonly v-model="currentDetailData.status"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item :label="inputLabel.leftInput.label3">
                      <el-input style="width: 150px;" readonly v-model="currentDetailData.supplierId"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item :label="inputLabel.leftInput.label4">
                      <el-input style="width: 150px;" readonly v-model="currentDetailData.supplierName"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item :label="inputLabel.leftInput.label5">
                      <el-input style="width: 150px;" readonly v-model="currentDetailData.strPurchaseDate"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item :label="inputLabel.leftInput.label6">
                      <el-input style="width: 150px;" readonly v-model="currentDetailData.steelSeal"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item :label="inputLabel.leftInput.label7">
                      <el-input style="width: 150px;" readonly v-model="currentDetailData.strPhaseInDate"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item :label="inputLabel.leftInput.label8">
                      <el-input style="width: 150px;" readonly v-model="currentDetailData.strPhaseOutDate"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item :label="inputLabel.leftInput.label9">
                      <el-input style="width: 150px;" readonly v-model="currentDetailData.estUseQty"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item :label="inputLabel.leftInput.label10">
                      <el-input style="width: 150px;" readonly v-model="currentDetailData.actualUseQty"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item :label="inputLabel.leftInput.label11">
                      <el-input style="width: 150px;" readonly v-model="currentDetailData.strCreateDate"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item :label="inputLabel.leftInput.label12">
                      <el-input style="width: 150px;" readonly v-model="currentDetailData.createdBy"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item :label="inputLabel.leftInput.label13">
                      <el-input style="width: 150px;" readonly v-model="currentDetailData.orderNo"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item :label="'库位编码'">
                      <el-input style="width: 150px;" readonly v-model="currentDetailData.locationId"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <el-form-item :label="inputLabel.leftInput.label14">
                      <el-input style="width: 300px;" readonly v-model="currentDetailData.remark"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </fieldset>
          </el-col>
          <el-col :span="17">
            <fieldset class="customer-field" style="width: 100%;  ">
              <legend>{{inputLabel.rightInput.label1}}</legend>
              <el-table
                width="100%"
                :height="height/2"
                :data="sfdcToolingHistList"
                border
                v-loading="dataListLoading"
                @selection-change="selectionChangeHandle"
                style="width: 100%;">
                <el-table-column
                  v-for="(item,index) in columnList" :key="index"
                  :sortable="item.columnSortable"
                  :prop="item.columnProp"
                  :header-align="item.headerAlign"
                  :show-overflow-tooltip="item.showOverflowTooltip"
                  :align="item.align"
                  :fixed="item.fixed==''?false:item.fixed"
                  :width="item.columnWidth"
                  :label="item.columnLabel">
                  <template slot-scope="scope">
                    <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
                    <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                                       style="width: 100px; height: 80px"/></span>
                  </template>
                </el-table-column>
              </el-table>
            </fieldset>
            <fieldset class="customer-field" style="width: 100%;  ">
              <legend>{{inputLabel.rightInput.label2}}</legend>
              <el-table
                width="100%"
                :height="height/2"
                :data="toolInstanceIdUseHist"
                border
                v-loading="dataListLoading"
                @selection-change="selectionChangeHandle"
                style="width: 100%;">
                <el-table-column
                  v-for="(item,index) in columnList1" :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"
                  :width="item.columnWidth"
                  :label="item.columnLabel">
                  <template slot-scope="scope">
                    <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
                    <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                                       style="width: 100px; height: 80px"/></span>
                  </template>
                </el-table-column>
              </el-table>
            </fieldset>
          </el-col>
        </el-row>
      </el-tab-pane>
      <el-tab-pane :label="'使用该工具的产品清单'" name="tool">
      </el-tab-pane>
    </el-tabs>

    <column v-if="visible" ref="column" @refreshData="getTableUserColumn"></column>
    <!--新增或编辑 工具信息-->
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" v-drag
               :title="'工具信息'" :visible.sync="toolHeaderShow" width="473px">
      <el-form :inline="true" label-position="top" label-width="100px">
        <el-form-item :label="inputLabel.headerInput.label1">
          <el-input style="width: 100px;" :readonly="!this.toolDetailAddOrEdit"
                    v-model="editHeaderData.toolId"></el-input>
        </el-form-item>
        <el-form-item :label="inputLabel.headerInput.label2">
          <el-input style="width: 100px;" v-model="editHeaderData.toolDescription"></el-input>
        </el-form-item>
        <el-form-item :label="inputLabel.headerInput.label3">
          <el-input style="width: 100px;" v-model="editHeaderData.spec"></el-input>
        </el-form-item>
        <el-form-item>
          <el-link slot="label" @click="getBaseList(23)"> {{inputLabel.headerInput.label5}}</el-link>
          <el-input style="width: 100px;" v-model="editHeaderData.familyId"></el-input>
        </el-form-item>
        <el-form-item :label="inputLabel.headerInput.label6">
          <el-input style="width: 100px;" class="customer-input-color-red" readonly
                    v-model="editHeaderData.familyName"></el-input>
        </el-form-item>
        <el-form-item>
          <el-link slot="label" @click="getBaseList(7)"> {{inputLabel.headerInput.label7}}</el-link>
          <el-input style="width: 100px;" readonly v-model="editHeaderData.umid"></el-input>
        </el-form-item>
        <el-form-item :label="inputLabel.headerInput.label9">
          <el-input style="width: 100px;" v-model="editHeaderData.codeNo"></el-input>
        </el-form-item>
        <el-form-item :label="inputLabel.headerInput.label8">
          <el-checkbox style="width: 100px;" v-model="editHeaderData.active"></el-checkbox>
        </el-form-item>
        <el-form-item :label="inputLabel.headerInput.label10">
          <el-input style="width: 100px;" v-model="editHeaderData.defaultLocationId"></el-input>
        </el-form-item>
        <el-form-item :label="inputLabel.headerInput.label13">
          <el-input style="width: 215px;" v-model="editHeaderData.remark"></el-input>
        </el-form-item>
        <el-form-item :label="inputLabel.headerInput.label11">
          <el-checkbox style="width: 100px;" v-model="editHeaderData.strPartCreated"></el-checkbox>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="saveAndUpdateToolHeader()">确定</el-button>
        <el-button type="primary" @click="toolHeaderShow = false">取消</el-button>
    </span>
    </el-dialog>
    <!--新增或编辑实例-->
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" v-drag
               :title="inputLabel.leftInput.label15" :visible.sync="setUp.toolEditFlag" width="736px">
      <el-form :inline="true" label-position="top">
        <el-form-item :label="inputLabel.leftInput.label1">
          <el-input style="width: 130px;" :readonly="toolDetailAddOrEdit" v-model="editData.toolInstanceId"></el-input>
        </el-form-item>
        <el-form-item :label="inputLabel.leftInput.label2">
          <el-select style="width: 130px;" v-model="editData.status">
            <el-option label="未投用" value="未投用"></el-option>
            <el-option label="已投用" value="已投用"></el-option>
            <el-option label="停用" value="停用"></el-option>
          </el-select>
          <!--          <el-input style="width: 130px;" :readonly="toolDetailAddOrEdit" v-model="editData.status"></el-input>-->
        </el-form-item>
        <el-form-item>
          <span slot="label" @click="getBaseList(3)"><el-link>{{'供应商编码'}}</el-link> </span>
          <el-input style="width: 130px;" v-model="editData.supplierId"></el-input>
        </el-form-item>
        <el-form-item :label="inputLabel.leftInput.label4">
          <el-input style="width: 274px;" class="customer-input-color-red" readonly
                    v-model="editData.supplierName"></el-input>
        </el-form-item>
        <el-form-item :label="inputLabel.leftInput.label5" style="height: 28px;">
          <el-date-picker
            v-model="editData.strPurchaseDate"
            value-format='yyyy-MM-dd'
            format='yyyy-MM-dd'
            placeholder="选择日期"
            style="width: 130px;">
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="inputLabel.leftInput.label6">
          <el-input style="width: 130px;" v-model="editData.steelSeal"></el-input>
        </el-form-item>
        <el-form-item :label="inputLabel.leftInput.label7">
          <el-date-picker
            v-model="editData.strPhaseInDate"
            value-format='yyyy-MM-dd '
            format='yyyy-MM-dd'
            placeholder="选择日期"
            style="width: 130px;">
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="inputLabel.leftInput.label8">
          <el-date-picker
            v-model="editData.strPhaseOutDate"
            placeholder="选择日期"
            value-format='yyyy-MM-dd'
            format='yyyy-MM-dd'
            style="width: 130px;">
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="inputLabel.leftInput.label9">
          <el-input oninput="value=value.replace(/[^0-9]/g,'')" style="width: 130px;"
                    v-model="editData.estUseQty"></el-input>
        </el-form-item>
        <el-form-item :label="inputLabel.leftInput.label10">
          <el-input oninput="value=value.replace(/[^0-9]/g,'')" style="width: 130px;"
                    v-model="editData.actualUseQty"></el-input>
        </el-form-item>
        <el-form-item :label="'库位编码'">
          <el-input style="width: 130px;" v-model="editData.locationId"></el-input>
        </el-form-item>
        <el-form-item :label="inputLabel.leftInput.label14">
          <el-input style="width: 418px;" v-model="editData.remark"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" :disabled="setUp.saveToolFlag" @click="saveAndUpdateToolDetail()">确定</el-button>
        <el-button type="primary" @click="setUp.toolEditFlag = false">取消</el-button>
    </span>
    </el-dialog>

    <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>

  </div>


</template>

<script>

  import Chooselist from '@/views/modules/common/Chooselist'

  import column from "../common/column";
  import {
    searchSysLanguagePackList,
    searchSysLanguageParam,
    searchFunctionButtonList,
    saveButtonList,
    searchSysLanguage,
    searchLanguageListByLanguageCode,
    saveSysLanguageOne
  } from "@/api/sysLanguage.js"
  import getLodop from '@/utils/LodopFuncs.js'
  import {
    saveTableDefaultList,
    saveTableUser,
    getTableDefaultListLanguage,
    getTableUserListLanguage
  } from "@/api/table.js"
  import {
    userFavoriteList,
    saveUserFavorite,
    removeUserFavorite,
  } from '@/api/userFavorite.js'
  import {
    getToolHeaderData,
    getToolDetailList,
    getToolInstanceIdUseHist,
    getSfdcToolingHistList,
    getToolHeaderList,
    updateToolDetail,
    saveToolInfoDetail,
    editToolHeader,
    saveToolHeader
  } from '@/api/knifemold/tool-info.js'
  import {
    printToolData
  } from "@/api/knifemold/receive.js"


  export default {
    components: {
      column,
      Chooselist
    },
    data() {
      return {
        activeName: 'toolInfo',
        toolHeaderShow: false,
        toolHeaderAddOrEdit: false,
        toolDetailAddOrEdit: false,
        toolHeaderList: [],
        queryHeaderData: {
          site: this.$store.state.user.site,
          toolId: '',
          toolDescription: ''
        },
        editData: {
          actualUseQty: 0,
          createDate: "",
          createdBy: this.$store.state.user.name,
          description: null,
          estUseQty: 0,
          inspectDuration: null,
          lastUpdateBy: null,
          latestInspectDate: null,
          latestUseDate: null,
          locationId: null,
          phaseInDate: "",
          phaseOutDate: "",
          purchaseDate: "",
          remark: "",
          site: this.$store.state.user.site,
          status: "",
          statusRef: null,
          steelSeal: null,
          strCreateDate: "",
          strLatestInspectDate: null,
          strLatestUseDate: null,
          strPhaseInDate: "",
          strPhaseOutDate: "",
          strPurchaseDate: "",
          supplierId: "",
          supplierName: "",
          toolDescription: null,
          toolId: "",
          toolIndex: null,
          toolInstanceId: "",
          torNumacc: null,
          torNumdown: null,
          workCenterNo: null,

        },
        setUp: {
          toolEditFlag: false,
          saveToolFlag: false,
          toolHeaderFlag: false,
        },
        toolInstanceIdUseHist: [],
        sfdcToolingHistList: [],
        selectList: {
          select1: [{
            value: 'Y',
            label: '启用'
          }, {
            value: 'N',
            label: '禁用'
          }],
          select2: [{
            value: 'Y',
            label: '是'
          }, {
            value: 'N',
            label: '否'
          }],
          select3: [{
            value: 'P',
            label: '个人'
          }, {
            value: 'G',
            label: '组'
          }],
          select4: [],
          select5: [],
        },
        inputLabel: {
          headerInput: {
            label1: '工具编码',
            label2: '工具名称',
            label3: '规格型号',
            label4: '工厂编号',
            label5: '工具分类',
            label6: '工具分类名称',
            label7: '计量单位',
            label8: '在用',
            label9: '属性模块',
            label10: '默认库位',
            label11: '创建物料编码',
            label12: '物料编码',
            label13: '说明',
            label14: '新增日期',
            label15: '录入人',
          },
          leftInput: {
            label1: '实例编码',
            label2: '状态',
            label3: '供应商编码',
            label4: '供应商名称',
            label5: '采购日期',
            label6: '钢印编码',
            label7: '入库日期',
            label8: '终止日期',
            label9: '预计刀模寿命',
            label10: '使用寿命',
            label11: '录入日期',
            label12: '录入人',
            label13: '采购订单号',
            label14: '备注',
            label15: '工具实例信息',
          },
          rightInput: {
            label1: '工具使用记录:',
            label2: '工具维修记录:',
          },
        },
        currentDetailData: {
          actualUseQty: '',
          createDate: '',
          createdBy: '',
          description: '',
          estUseQty: '',
          inspectDuration: '',
          lastUpdateBy: '',
          latestInspectDate: '',
          latestUseDate: '',
          locationId: '',
          phaseInDate: '',
          phaseOutDate: '',
          purchaseDate: '',
          remark: '',
          site: '',
          status: '',
          statusRef: '',
          supplierId: '',
          supplierName: '',
          toolDescription: '',
          toolId: '',
          toolIndex: '',
          toolInstanceId: '',
          torNumacc: '',
          torNumdown: '',
          workCenterNo: '',
          steelSeal: '',
          strCreateDate: '',
          strLatestInspectDate: '',
          strLatestUseDate: '',
          strPhaseInDate: '',
          strPhaseOutDate: '',
          strPurchaseDate: '',
        },
        detailList: [],
        headerData: {
          active: "",
          codeNo: null,
          createDate: "",
          createdBy: "",
          defaultLocationId: null,
          defaultWarehouseId: null,
          familyId: null,
          familyName: null,
          lastUpdateBy: null,
          partCreatedFlag: null,
          partNo: null,
          remark: null,
          site: this.$store.state.user.site,
          spec: null,
          standardCost: null,
          strActive: "",
          strCreateDate: "",
          strPartCreated: "",
          toolDescription: "",
          toolId: "",
          umid: null
        },
        editHeaderData: {
          active: "",
          codeNo: null,
          createDate: "",
          createdBy: "",
          defaultLocationId: null,
          defaultWarehouseId: null,
          familyId: null,
          familyName: null,
          lastUpdateBy: null,
          partCreatedFlag: null,
          partNo: null,
          remark: null,
          site: this.$store.state.user.site,
          spec: null,
          standardCost: null,
          strActive: "",
          strCreateDate: "",
          strPartCreated: "",
          toolDescription: "",
          toolId: "",
          umid: null
        },
        site: this.$store.state.user.site,
        // table高度
        height: 450,
        // 是否收藏
        favorite: false,
        addLanguage: false,
        functionId: 2501,
        tableId: "toolInfo2501",
        value1: true,
        visible: false,
        showDefault: false,
        // 默认table 查询参数
        queryTable: {
          functionId: 2501,
          tableId: "toolInfo2501",
          languageCode: this.$i18n.locale
        },
        // 用户table 查询参数
        queryTableUser: {
          userId: this.$store.state.user.name,
          functionId: 2501,
          tableId: "toolInfo2501",
          status: true,
          languageCode: this.$i18n.locale
        },
        // 语言词典查询参数
        querySysLanguageParam: {
          languageCode: this.$i18n.locale
        },
        // 语言词典集合
        sysLanguageParams: [],
        // 用户table 配置集合
        userColumnList: [],
        // 展示列集
        columnList: [
          {
            userId: this.$store.state.user.name,
            functionId: 2501,
            serialNumber: 'toolUseHist2501OrderNo',
            tableId: "toolUseHist2501",
            tableName: "toolUseHist",
            columnProp: "orderNo",
            headerAlign: "center",
            align: "center",
            columnLabel: "生产订单号",
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: false
          },
          {
            userId: this.$store.state.user.name,
            functionId: 2501,
            serialNumber: 'toolUseHist2501FinishQty',
            tableId: "toolUseHist2501",
            tableName: "toolUseHist",
            columnProp: "finishQty",
            headerAlign: "center",
            align: "center",
            columnLabel: "使用寿命",
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: false,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 2501,
            serialNumber: 'toolUseHist2501OStrReportDate',
            tableId: "toolUseHist2501",
            tableName: "toolUseHist",
            columnProp: "strReportDate",
            headerAlign: "center",
            align: "center",
            columnLabel: "录入日期",
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: false,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 2501,
            serialNumber: 'toolUseHist2501Reportedby',
            tableId: "toolUseHist2501",
            tableName: "toolUseHist",
            columnProp: "reportedby",
            headerAlign: "center",
            align: "center",
            columnLabel: "录入人",
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: false,
          }
        ],
        // 展示列集
        columnList1: [
          {
            userId: this.$store.state.user.name,
            functionId: 2501,
            tableId: "service2501",
            tableName: "service",
            columnProp: "strDeliveryDate",
            headerAlign: "center",
            align: "center",
            columnLabel: "送修日期",
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: false
          },
          {
            userId: this.$store.state.user.name,
            functionId: 2501,
            tableId: "service2501",
            tableName: "service",
            columnProp: "supplierName",
            headerAlign: "center",
            align: "center",
            columnLabel: "供应商",
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: false,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 2501,
            tableId: "service2501",
            tableName: "service",
            columnProp: "strReturnDate",
            headerAlign: "center",
            align: "center",
            columnLabel: "返回日期",
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: false,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 2501,
            tableId: "service2501",
            tableName: "service",
            columnProp: "createdBy",
            headerAlign: "center",
            align: "center",
            columnLabel: "接收人",
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: false,
          },
          // {
          //   userId: this.$store.state.user.name,
          //   functionId: 2501,
          //   tableId: "common1002",
          //   tableName: "commonLanguage",
          //   columnProp: "languageCode",
          //   headerAlign: "center",
          //   align: "center",
          //   columnLabel: "语言编码",
          //   columnHidden: false,
          //   columnImage: false,
          //   columnSortable: true,
          //   sortLv: 0,
          //   status: true,
          //   fixed: false,
          // }
        ],
        columnList2: [
          {
            userId: this.$store.state.user.name,
            functionId: 2501,
            tableId: "toolHeader2501",
            tableName: "toolHeader",
            columnProp: "toolId",
            headerAlign: "center",
            align: "center",
            columnLabel: "工具编码",
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: false
          },
          {
            userId: this.$store.state.user.name,
            functionId: 2501,
            tableId: "toolHeader2501",
            tableName: "toolHeader",
            columnProp: "toolDescription",
            headerAlign: "center",
            align: "center",
            columnLabel: "工具名称",
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: false
          },
        ],
        // 数据集
        dataList: [],
        queryButton: {
          functionId: 2501,
          table_id: 'toolInfo2501',
          languageCode: this.$i18n.locale,
          objectType: 'button'
        },
        buttons: {
          add: '添加',
          edit: '编辑',
          delete: '删除',
          deleteList: '批量删除',
          cz: '操作',
          search: '查询',
          download: '导出',
          settingTable: '设置列表',
          defaultTable: '设置默认配置'
        },
        // 导出 start
        exportData: [],
        exportName: "页面功能语言",
        exportHeader: ["页面功能语言"],
        exportFooter: [],
        exportDefaultValue: "这一行这一列没有数据",
        // 导出 end
        buttonList: [
          // {
          //   functionId: "2501",
          //   languageValue: '添加',
          //   objectId: 'add',
          //   objectType: "button",
          //   tableId: "toolInfo2501"
          // },
          // {
          //   functionId: "2501",
          //   languageValue: '编辑',
          //   objectId: 'edit',
          //   objectType: "button",
          //   tableId: "toolInfo2501"
          // },
          // {
          //   functionId: "2501",
          //   languageValue: '删除',
          //   objectId: 'delete',
          //   objectType: "button",
          //   tableId: "toolInfo2501"
          // },
          // {
          //   functionId: "2501",
          //   languageValue: '批量删除',
          //   objectId: 'deleteList',
          //   objectType: "button",
          //   tableId: "toolInfo2501"
          // },
          // {
          //   functionId: "2501",
          //   languageValue: '操作',
          //   objectId: 'cz',
          //   objectType: "button",
          //   tableId: "toolInfo2501"
          // },
          // {
          //   functionId: "2501",
          //   languageValue: '查询',
          //   objectId: 'search',
          //   objectType: "button",
          //   tableId: "toolInfo2501"
          // },
          // {
          //   functionId: "2501",
          //   languageValue: '导出',
          //   objectId: 'download',
          //   objectType: "button",
          //   tableId: "toolInfo2501"
          // },
          // {
          //   functionId: "2501",
          //   languageValue: '设置列表',
          //   objectId: 'settingTable',
          //   objectType: "button",
          //   tableId: "toolInfo2501"
          // },
          // {
          //   functionId: "2501",
          //   languageValue: '设置默认配置',
          //   objectId: 'defaultTable',
          //   objectType: "button",
          //   tableId: "toolInfo2501"
          // }
        ],
        languageList: [],
        languageColumnList: [],
        languageDataList: [],
        queryLanguage: {},
        // 数据集条件
        querySysLanguagePack: {
          page: 1,
          limit: 1,
          languageValue: '',
          objectType: '',
          objectId: ''
        },
        // 分页
        pageIndex: 1,
        pageSize: 20,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false
      }
    },
    watch: {
      editData: {
        deep: true,
        handler: function (newV, oldV) {
          if (this.editData.locationId) {
            this.editData.locationId = this.editData.locationId.toUpperCase()
          }
        }
      },
      editHeaderData: {
        deep: true,
        handler: function (newV, oldV) {
          if (this.editHeaderData.toolId) {
            this.editHeaderData.toolId = this.editHeaderData.toolId.toUpperCase()
          }
        }
      },
    },
    mounted() {
      this.$nextTick(() => {
        this.height = window.innerHeight - 310;
      })
    },
    activated() {
      this.getHeaderData()
      // this.getDataList()
      this.getLanguageList()
    },
    methods: {
      printMethod(val) {
        if (!this.currentDetailData.toolInstanceId) {
          this.$alert('请选择工具信息！', '操作提示', {
            confirmButtonText: '确定',
            callback: action => {
              this.bannersBut = false
            }
          });
          return
        }
        let dto = {
          site: this.currentDetailData.site,
          toolInstanceId: this.currentDetailData.toolInstanceId
        }
        printToolData(dto).then(({data}) => {
          if (data.code == 0) {
            let printDataList = []
            let printData = {
              SupplierName: data.data.SupplierName,
              createDate: data.data.createDate,
              createdBy: data.data.createdBy,
              estUseQty: data.data.estUseQty,
              locationId: data.data.locationId,
              phaseInDate: data.data.phaseInDate,
              site: data.data.site,
              spec: data.data.spec,
              status: data.data.status,
              supplierId: data.data.supplierId,
              toolDescription: data.data.toolDescription,
              toolId: data.data.toolId,
              toolInstanceId: this.currentDetailData.toolInstanceId
            }
            printDataList.push(printData)
            if (val == 'Y') {
              this.labelPrintGJ(printDataList)
            } else {
              this.labelPrintWB(printDataList)
            }
          }
        })

      },
      labelPrintWB(printDataList) {
        const LODOP = getLodop()
        if (LODOP) {
          //LODOP.SET_LICENSES("", "13F0BE83846277CB60918577C6281375", "", "");
          LODOP.SET_LICENSES("", "7B5624CC84E599D6B17F27DF40F4310C", "", "");
          //循环调用打印机
          for (let i = 0; i < printDataList.length; i++) {
            let printData = printDataList[i]
            LODOP.NewPage();
            LODOP.SET_PRINT_PAGESIZE(0, 700, 180, "");
            LODOP.SET_PRINT_MODE("PRINT_NOCOLLATE", 1);
            LODOP.ADD_PRINT_RECT(2, 5, 250, 67, 0, 1);
            LODOP.ADD_PRINT_LINE(19, 5, 18, 255, 0, 1);
            LODOP.ADD_PRINT_LINE(36, 5, 35, 205, 0, 1);
            LODOP.ADD_PRINT_LINE(54, 5, 53, 205, 0, 1);
            LODOP.ADD_PRINT_LINE(2, 65, 69, 66, 0, 1);
            LODOP.ADD_PRINT_LINE(68, 205, 18, 206, 0, 1);
            LODOP.ADD_PRINT_BARCODE(21, 208, 90, 60, "QRCode", printData.toolInstanceId);
            LODOP.ADD_PRINT_TEXT(5, 9, 60, 14, "工具名称");
            LODOP.ADD_PRINT_TEXT(21, 9, 60, 15, "工具编号");
            LODOP.ADD_PRINT_TEXT(38, 9, 60, 15, "实例编号");
            LODOP.ADD_PRINT_TEXT(55, 9, 60, 15, "经办人");
            LODOP.ADD_PRINT_TEXT(4, 70, 180, 14, printData.toolDescription);
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
            LODOP.ADD_PRINT_TEXT(21, 71, 133, 14, printData.toolId);
            LODOP.ADD_PRINT_TEXT(39, 71, 133, 14, printData.toolInstanceId);
            LODOP.ADD_PRINT_TEXT(55, 71, 133, 14, printData.createdBy);
          }
          //LODOP.PRINT_DESIGN();
          //LODOP.PREVIEW();
          LODOP.PRINT();

        }
      },
      labelPrintGJ(printDataList) {
        const LODOP = getLodop()
        if (LODOP) {
          //LODOP.SET_LICENSES("", "13F0BE83846277CB60918577C6281375", "", "");
          LODOP.SET_LICENSES("", "7B5624CC84E599D6B17F27DF40F4310C", "", "");
          //循环调用打印机
          for (let i = 0; i < printDataList.length; i++) {
            let printData = printDataList[i]
            LODOP.NewPage();
            LODOP.SET_PRINT_PAGESIZE(0, 700, 540, "");
            LODOP.ADD_PRINT_RECT(6, 5, 250, 190, 0, 1);
            LODOP.ADD_PRINT_LINE(24, 5, 23, 255, 0, 1);
            LODOP.ADD_PRINT_LINE(41, 5, 40, 255, 0, 1);
            LODOP.ADD_PRINT_LINE(58, 5, 57, 255, 0, 1);
            LODOP.ADD_PRINT_LINE(75, 5, 74, 255, 0, 1);
            LODOP.ADD_PRINT_LINE(92, 5, 91, 255, 0, 1);
            LODOP.ADD_PRINT_LINE(109, 5, 108, 255, 0, 1);
            LODOP.ADD_PRINT_LINE(126, 5, 125, 178, 0, 1);
            LODOP.ADD_PRINT_LINE(144, 5, 143, 178, 0, 1);
            LODOP.ADD_PRINT_LINE(162, 5, 161, 178, 0, 1);
            LODOP.ADD_PRINT_LINE(179, 5, 178, 255, 0, 1);
            LODOP.ADD_PRINT_LINE(23, 65, 195, 66, 0, 1);
            LODOP.ADD_PRINT_LINE(178, 177, 108, 178, 0, 1);
            LODOP.ADD_PRINT_BARCODE(110, 183, 110, 85, "QRCode", printData.toolInstanceId);
            LODOP.ADD_PRINT_TEXT(9, 94, 100, 14, "工具标签");
            LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
            LODOP.ADD_PRINT_TEXT(26, 9, 60, 14, "工具名称");
            LODOP.ADD_PRINT_TEXT(43, 9, 60, 15, "规格型号");
            LODOP.ADD_PRINT_TEXT(60, 9, 60, 15, "工具编号");
            LODOP.ADD_PRINT_TEXT(77, 9, 60, 15, "实例编号");
            LODOP.ADD_PRINT_TEXT(94, 9, 60, 15, "厂商");
            LODOP.ADD_PRINT_TEXT(111, 9, 60, 15, "入库日期");
            LODOP.ADD_PRINT_TEXT(129, 9, 60, 15, "库位");
            LODOP.ADD_PRINT_TEXT(147, 9, 60, 15, "经办人");
            LODOP.ADD_PRINT_TEXT(181, 9, 60, 15, "检验签章");
            LODOP.ADD_PRINT_TEXT(25, 72, 180, 14, printData.toolDescription);
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
            LODOP.ADD_PRINT_TEXT(42, 72, 180, 14, ""); // 规格
            LODOP.ADD_PRINT_TEXT(60, 72, 180, 14, printData.toolId);
            LODOP.ADD_PRINT_TEXT(78, 71, 180, 14, printData.toolInstanceId);
            LODOP.ADD_PRINT_TEXT(94, 71, 180, 14, printData.SupplierName);
            LODOP.ADD_PRINT_TEXT(111, 71, 95, 14, this.dayjs(printData.createDate).format("YYYY-MM-DD"));
            LODOP.ADD_PRINT_TEXT(130, 71, 95, 14, printData.locationId);
            LODOP.ADD_PRINT_TEXT(148, 71, 95, 14, printData.createdBy);


          }
          //LODOP.PRINT_DESIGN();
          //LODOP.PREVIEW();
          LODOP.PRINT();
        }
      },
      getBaseData(val) {
        if (this.tagNo === 70) {
          this.headerData.toolId = val.ToolID
          // this.headerData.toolDescription = val.ToolDescription
          this.getHeaderData()
        }
        if (this.tagNo === 3) {
          this.editData.supplierId = val.SupplierID
          this.editData.supplierName = val.SupplierName
        }
        if (this.tagNo === 23) {
          this.editHeaderData.familyId = val.FamilyID
          this.editHeaderData.familyName = val.FamilyName
        }
        if (this.tagNo === 7) {
          this.editHeaderData.umid = val.UMID
        }
      },
      // 获取基础数据列表
      getBaseList(val, number) {
        this.number = number
        this.tagNo = val
        this.$nextTick(() => {
          let strVal = "";
          if (val === 3) {
            strVal = this.editData.supplierId
          }
          if (val === 70) {
            strVal = this.headerData.toolId
          }
          if (val === 23) {
            strVal = this.editHeaderData.familyId
          }
          if (val === 7) {
            strVal = this.editHeaderData.umid
          }
          this.$refs.baseList.init(val, strVal)
        })
      },
      getTime(date) {
        var json_date = new Date(date).toJSON();
        return new Date(new Date(json_date) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
      },
      // toolDetail
      initToolModel(val) {
        this.setUp.toolEditFlag = true
        this.setUp.saveToolFlag = false
        if (val != 'Y') {
          this.toolDetailAddOrEdit = true
          this.editData = JSON.parse(JSON.stringify(this.currentDetailData))
        } else {
          Object.assign(this.$data.editData, this.$options.data.call(this).editData);
          this.toolDetailAddOrEdit = false
          this.editData.toolInstanceId = this.headerData.toolId
          this.editData.locationId = this.headerData.defaultLocationId
          this.editData.toolId = this.headerData.toolId
          this.editData.status = '未投用'
        }
      },
      async saveAndUpdateToolDetail() {
        this.setUp.saveToolFlag = true
        this.editData.purchaseDate = this.editData.strPurchaseDate
        this.editData.phaseInDate = this.editData.strPhaseInDate
        this.editData.phaseOutDate = this.editData.strPhaseOutDate
        if (!this.editData.estUseQty || this.editData.estUseQty == 0) {
          this.$message.warning('预计使用寿命必须大于0')
        }
        if (this.toolDetailAddOrEdit) {
          await updateToolDetail(this.editData).then(({data}) => {
            if (data.code == 0) {
              this.$message.success(data.msg)
              this.setUp.toolEditFlag = false
            } else {
              this.$message.error(data.msg)
            }
            this.setUp.saveToolFlag = false
          })

        } else {
          await saveToolInfoDetail(this.editData).then(({data}) => {
            if (data.code == 0) {
              this.$message.success(data.msg)
              this.setUp.toolEditFlag = false
            } else {
              this.$message.error(data.msg)
            }
            this.setUp.saveToolFlag = false
          })
        }
        await this.getDetailList()
        this.currentDetailData.toolInstanceId = this.editData.toolInstanceId
        this.toolInstanceIdChange()
      },
      // toolHeader
      initToolHeaderModel(val) {
        this.toolHeaderShow = true
        if (val == 'Y') {
          this.toolDetailAddOrEdit = true
          Object.assign(this.$data.editHeaderData, this.$options.data.call(this).editHeaderData);
        } else {
          this.toolDetailAddOrEdit = false
          this.editHeaderData = JSON.parse(JSON.stringify(this.headerData))
          this.editHeaderData.active = this.headerData.active == 'Y' ? true : false
        }
      },
      saveAndUpdateToolHeader() {
        if (!this.editHeaderData.toolId) {
          this.$message.warning('工具编号不能为空,请选择')
        }
        if (!this.editHeaderData.familyId) {
          this.$message.warning('工具分类不能为空,请选择')
        }
        if (!this.editHeaderData.umid) {
          this.$message.warning('计量单位不能为空,请选择')
        }
        this.editHeaderData.active = this.editHeaderData.active ? 'Y' : 'N'
        if (this.toolDetailAddOrEdit) {
          this.editHeaderData.createdBy = this.$store.state.user.name
          saveToolHeader(this.editHeaderData).then(({data}) => {
            if (data.code == 0) {
              this.toolHeaderShow = false
              this.headerData.toolId = this.editHeaderData.toolId
              this.getHeaderData()
              this.$message.success(data.msg)
            } else {
              this.$message.warning(data.msg)
            }
          })
        } else {
          editToolHeader(this.editHeaderData).then(({data}) => {
            if (data.code == 0) {
              this.$message.success(data.msg)
              this.toolHeaderShow = false
              this.headerData.toolId = this.editHeaderData.toolId
              this.getHeaderData()
            } else {
              this.$message.warning(data.msg)
            }
          })
        }


      },
      getToolHeaderList() {
        getToolHeaderList(this.queryHeaderData).then(({data}) => {
          this.toolHeaderList = data.rows
        })
      },
      //获取工具使用记录
      getSfdcToolingHistList() {
        let queryData = {
          site: this.site,
          toolInstanceId: this.currentDetailData.toolInstanceId
        }
        getSfdcToolingHistList(queryData).then(({data}) => {
          this.sfdcToolingHistList = data.rows
        })
      },
      //获取工具使用记录
      getToolInstanceIdUseHist() {
        let queryData = {
          site: this.site,
          toolInstanceId: this.currentDetailData.toolInstanceId
        }
        getToolInstanceIdUseHist(queryData).then(({data}) => {
          this.toolInstanceIdUseHist = data.rows
        })
      },
      toolInstanceIdChange() {
        this.sfdcToolingHistList = []
        this.toolInstanceIdUseHist = []
        let queryData = {
          site: this.site,
          toolInstanceId: this.currentDetailData.toolInstanceId,
        }
        getToolDetailList(queryData).then(({data}) => {
          let list = data.rows
          if (list.length > 0) {
            this.currentDetailData = list[0]
            this.getToolInstanceIdUseHist()
            this.getSfdcToolingHistList()
          }
        })
      },
      async getDetailList() {
        this.currentDetailData = {}
        this.selectList.select4 = []
        this.sfdcToolingHistList = []
        this.toolInstanceIdUseHist = []
        let queryData = {
          site: this.site,
          toolId: this.headerData.toolId,
          toolDescription: this.headerData.toolDescription,
        }
        await getToolDetailList(queryData).then(({data}) => {
          let list = data.rows
          for (let i = 0; i < list.length; i++) {
            let selectData = {
              value: list[i].toolInstanceId,
              label: list[i].toolInstanceId,
            }
            this.selectList.select4.push(selectData);
          }
          if (list.length > 0) {
            this.currentDetailData = list[0]
            this.toolInstanceIdChange()
          }
        })
      },
      //获取主记录信息
      getHeaderData() {
        let queryData = {
          site: this.site,
          toolId: this.headerData.toolId,
          // toolDescription: this.headerData.toolDescription,
        }
        getToolHeaderData(queryData).then(({data}) => {
          if (data.code == 0) {
            this.headerData = data.row ? data.row : this.headerData
            this.getDetailList()
          }

        })
      },
      // 打印方式
      printReport() {
        alert(this.$store.state.user.site)
        //
        // const LODOP = getLodop()
        // if (LODOP) {
        //   var strBodyStyle = '<style>'
        //   strBodyStyle += 'table { border-top: 1 solid #000000; border-left: 1 solid #000000;  border-collapse:collapse;  border-spacing:0;}'
        //   strBodyStyle += 'caption {  line-height:2em; }'
        //   strBodyStyle += 'td { border-right: 1 solid #000000; border-bottom: 1 solid #000000; text-align:center; padding:2px 3px; font-size:11px;}'
        //   strBodyStyle += '</style>' //设置打印样式
        //   var strFormHtml = strBodyStyle + '<body>' + document.getElementById('commmon').innerHTML + '</body>'   //获取打印内容
        //
        //   LODOP.PRINT_INIT('')  //初始化
        //   LODOP.PRINT_DESIGN();
        //   //LODOP.PREVIEW();
        //   //LODOP.PRINT();
        //
        //   LODOP.SET_PRINT_PAGESIZE(2, 0, 0, 'A4')  //设置横向
        //   LODOP.ADD_PRINT_HTM('1%', '1%', '98%', '98%', strFormHtml)    //设置打印内容
        //   LODOP.SET_PREVIEW_WINDOW(2, 0, 0, 800, 600, '')  //设置预览窗口模式和大小
        //   LODOP.PREVIEW()
        // }
      },
      // 校验用户是否收藏
      favoriteIsOk() {
        let userFavorite = {
          userId: this.$store.state.user.id,
          languageCode: this.$i18n.locale
        }
        userFavoriteList(userFavorite).then(({data}) => {
          let size = data.list.filter(item => item.menuId == this.$route.meta.menuId).length;
          if (size > 0) {
            this.favorite = true
          } else {
            this.favorite = false
          }
        })
      },
      // 收藏 OR 取消收藏
      favoriteFunction() {
        let userFavorite = {
          userId: this.$store.state.user.id,
          functionId: this.$route.meta.menuId,
        }
        if (this.favorite) {
          // 取消收藏
          this.$confirm(`确定取消收藏`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            removeUserFavorite(userFavorite).then(({data}) => {
              this.$message.success(data.msg)
              this.favorite = false
            })
          })
        } else {
          // 收藏
          saveUserFavorite(userFavorite).then(({data}) => {
            this.$message.success(data.msg)
            this.favorite = true
          })
        }

      },
      // 保存语言编辑
      saveLanguageList(val) {
        saveSysLanguageOne(val).then(({data}) => {
          if (data.code == 0) {
            this.$message.success(data.msg)
          } else {
            this.$message.error(data.msg)
          }
        })
      },
      // 编辑语言
      addLanguageFun() {
        if (this.querySysLanguagePack.languageCode) {
          this.addLanguage = true
          this.languageColumnList = []
          let query = {
            functionId: 2501,
            tableId: "common1002",
            languageCode: this.$i18n.locale
          }
          getTableDefaultListLanguage(query).then(({data}) => {
            if (data.rows.length > 0) {
              this.languageColumnList = data.rows
            }
          })
          this.languageColumnList = this.columnList
          searchLanguageListByLanguageCode(this.querySysLanguagePack).then(({data}) => {
            this.languageDataList = data.rows
          })
        } else {
          this.$message("请选中一种语言")
        }
      },
      // 获取多语言列表
      getLanguageList() {
        searchSysLanguage(this.queryLanguage).then(({data}) => {
          this.languageList = data.rows
        })
      },
      // 获取button的词典
      getFunctionButtonList() {
        searchFunctionButtonList(this.queryButton).then(({data}) => {
          if (JSON.stringify(data.data) !== '{}') {
            this.buttons = data.data
          } else {
            saveButtonList(this.buttonList).then(({data}) => {
            })
          }
        })
      },
      // 获取语言词典
      getSysLanguageParamList() {
        searchSysLanguageParam(this.querySysLanguageParam).then(({data}) => {
          this.sysLanguageParams = data.rows
        })
      },
      // 打开页面设置
      userSetting() {
        this.visible = true;
        let queryTable = {
          userId: this.$store.state.user.name,
          functionId: 2501,
          tableId: "toolInfo2501",
          languageCode: this.$i18n.locale
        }
        this.$nextTick(() => {
          this.$refs.column.init(queryTable);
        });
      },
      // 获取 用户保存的 格式列
      getTableUserColumn() {
        getTableUserListLanguage(this.queryTableUser).then(({data}) => {
          if (data.rows.length > 0) {
            //this.columnList = []
            this.columnList = data.rows
          } else {
            this.getColumnList()
          }

        })
      },
      // 保存 默认配置 列
      saveColumnList() {

        saveTableDefaultList(this.columnList).then(({data}) => {
          if (data.code == 0) {
            this.$message.success(data.msg)
            // this.showDefault = false
          } else {
            this.$message.error(data.msg)
          }
        })
        saveTableDefaultList(this.columnList1).then(({data}) => {
          if (data.code == 0) {
            this.$message.success(data.msg)
            // this.showDefault = false
          } else {
            this.$message.error(data.msg)
          }
        })
        this.getFunctionButtonList();
        this.getColumnList()
      },
      // 获取 tableDefault 列
      getColumnList() {
        getTableDefaultListLanguage(this.queryTable).then(({data}) => {
          if (!data.rows.length == 0) {
            // this.showDefault = false
            this.columnList = data.rows
          } else {
            // this.showDefault = true
          }
        })
      },
      // 获取数据列表
      getDataList() {
        this.dataListLoading = true
        searchSysLanguagePackList(this.querySysLanguagePack).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle(val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle(val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      selectionChangeHandle(val) {
        this.dataListSelections = val
      },
      // 删除
      deleteHandle(id) {
        var ids = id ? [id] : this.dataListSelections.map(item => {
          return item.id
        })
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl('//prd/delete'),
            method: 'post',
            data: this.$http.adornData(ids, false)
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.$message.success('操作成功')
              this.getDataList()
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      },
      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
      },
      createExportData() {
        // 点击导出按钮之后,开始导出数据之前的执行函数,返回值为需要下载的数据
        // TODO:构造需要下载的数据返回
        if (this.dataListSelections.length > 0) {
          return this.dataListSelections;
        }
        return this.dataList;
      },
      startDownload() {
        //  this.exportData = this.dataList

      },
      finishDownload() {
      }
    },
    created() {
      this.getTableUserColumn()
      this.getSysLanguageParamList()
      this.getFunctionButtonList()
      this.favoriteIsOk()
    }
  }
</script>

<style scoped>
  .el-header, .el-footer {
    background-color: #B3C0D1;
    color: #333;
    text-align: center;
    line-height: 60px;
    height: 300px;
  }

  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    /*text-align: center;*/
    /*line-height: 200px;*/
  }

  .el-main {
    background-color: #E9EEF3;
    color: #333;

  }

  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }

  /deep/ .customer-tab .el-tabs__content {
    padding: 3px !important;

  }

  /deep/ .customer-tab .el-tabs__item {
    padding: 0 20px;
    height: 30px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    line-height: 30px;
    display: inline-block;
    list-style: none;
    font-size: 12px;
    font-weight: 500;
    color: #303133;
    position: relative;
  }

  /*统一的input内容颜色样式*/
  .customer-input-color-red /deep/ .el-input__inner {
    color: red;
  }
</style>
