<template>
  <div class="mod-config">
    <el-row>
      <el-col :span="24">
        <el-button @click="initViewIfsTable('Y')" type="primary">{{ buttons.search }}</el-button>
        <el-button @click="saveColumnList()" type="primary" v-show="showDefault">{{ buttons.defaultTable }}
        </el-button>
        <el-button @click="userSetting" type="primary">{{ buttons.settingTable }}</el-button>
        <download-excel
          :fields="fields()"
          :data="exportData"
          type="xls"
          :name="exportName"
          :header="exportHeader"
          :footer="exportFooter"
          :defaultValue="exportDefaultValue"
          :fetch="createExportData"
          :before-generate="startDownload"
          :before-finish="finishDownload"
          worksheet="导出信息"
          class="el-button el-button--primary el-button--medium">
          {{ buttons.download }}
        </download-excel>
        <el-button v-if="isAuth(':prd:delete')" type="danger" @click="deleteHandle()"
                   :disabled="dataListSelections.length <= 0">{{ buttons.deleteList }}
        </el-button>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-form :inline="true" label-position="top">
          <el-form-item :label="inputSearch10">
            <el-input style="width: 110px;" placeholder="" v-model="queryViewIfs.transactionId"></el-input>
          </el-form-item>
          <el-form-item :label="inputSearch1">
            <el-input style="width: 110px;" placeholder="" v-model="queryViewIfs.toolId"></el-input>
          </el-form-item>
          <el-form-item :label="inputSearch2">
            <el-input style="width: 110px;" placeholder="" v-model="queryViewIfs.description"></el-input>
          </el-form-item>
          <el-form-item :label="inputSearch12">
            <el-select v-model="queryViewIfs.receiveFlag" placeholder="请选择" style="width: 75px;">
              <el-option
                v-for="item in selectList.select1"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-table
          :height="height"
          :data="dataList"
          border
          v-loading="dataListLoading"
          @selection-change="selectionChangeHandle"
          highlight-current-row
          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-column
            fixed="right"
            header-align="center"
            align="center"
            width="100"
            :label="buttons.operating">
            <template slot-scope="scope">
              <a @click="closeReceive(scope.row)">{{'关闭'}}</a>
              <a @click="initBannersFlag(scope.row)">{{buttons.receive}}</a>
              <a @click="initFileModel(scope.row)">{{buttons.appendixInfo}}</a>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          @size-change="sizeChangeHandle"
          @current-change="currentChangeHandle"
          :current-page="pageIndex"
          :page-sizes="[100, 200, 500]"
          :page-size="pageSize"
          :total="totalPage"
          layout="total, sizes, prev, pager, next, jumper">
        </el-pagination>
      </el-col>
    </el-row>


    <column v-if="visible" ref="column" @refreshData="getTableUserColumn"></column>


    <el-dialog title="横幅宽幅设定" :visible.sync="bannersFlag" width="325px">
      <el-form :inline="true">
        <el-form-item :label="inputSearch8">
          <el-input style="width: 90px;text-align: left;padding: 0px 5px;"
                    oninput="value=value.replace(/^\.+|[^\d.]/g,'')" v-model="torNumacc"></el-input>
        </el-form-item>
        <el-form-item :label="inputSearch9">
          <el-input style="width: 90px;text-align: left;padding: 0px 5px;"
                    oninput="value=value.replace(/^\.+|[^\d.]/g,'')" v-model="torNumdown"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="bannersFlag = false">取消</el-button>
      <el-button type="primary" :disabled="bannersBut" @click="saveBanners()">确定</el-button>
      </span>
    </el-dialog>

    <el-dialog v-drag :close-on-click-modal="false" :visible.sync="poToolFlag" width="770px">
      <span style="font-size: 13px" slot="title">  {{'接收单号:'+this.ifsToolData.transactionId + ' - 工具编码: ' + this.ifsToolData.toolId}}</span>
      <el-row>
        <el-col :span="24">
          <el-button type="primary" :disabled="generateFlag" @click="initMailFlag()">{{buttons.generate}}</el-button>
          <el-button type="primary" @click="printMethod('Y')">{{buttons.toolLabel}}</el-button>
          <el-button type="primary" @click="printMethod('N')">{{buttons.screenLabel}}</el-button>
          <el-button type="primary" :disabled="receiveQuantity>1" @click="setToolInstanceId()">
            {{buttons.manualGenerate}}
          </el-button>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form :inline="true" label-position="top">
            <el-form-item :label="inputSearch3">
              <el-input type="number" @change="initQtyAlert()" oninput="value=value.replace(/^\.+|[^\d.]/g,'')"
                        v-model="receiveQuantity"></el-input>
            </el-form-item>
            <el-form-item :label="inputSearch4">
              <el-input type="number" oninput="value=value.replace(/^\.+|[^\d.]/g,'')" v-model="serviceLife"></el-input>
            </el-form-item>
            <el-form-item :label="inputSearch11">
              <el-input type="number" oninput="value=value.replace(/^\.+|[^\d.]/g,'')"
                        v-model="invoicePrice"></el-input>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-table
            :data="poToolList"
            height="290"
            border
            v-loading="dataListLoading"
            @selection-change="getCurrSelectList"
            style="width: 100%;">
            <el-table-column
              type="selection"
              header-align="center"
              width="40"
              align="center">
            </el-table-column>
            <el-table-column
              v-for="(item,index) in poToolColumnList" :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-column
              header-align="center"
              width="60"
              fixed="right"
              :label="buttons.cz"
              align="center">
              <template slot-scope="scope">
                <el-link v-if="scope.row.status == '已接收'" @click="editToolDetail(scope.row)">{{buttons.edit}}</el-link>
              </template>
            </el-table-column>
          </el-table>
        </el-col>
      </el-row>
    </el-dialog>

    <el-dialog v-drag :close-on-click-modal="false" :visible.sync="toolCodeFlag" width="335px">
      <span style="font-size: 13px" slot="title">手工设置工具实例编码</span>
      <el-row>
        <el-col :span="24">
          <el-form :inline="true" label-position="top">
            <el-form-item :label="'工具实例编码'">
              <el-input v-model="toolInstanceId"></el-input>
            </el-form-item>
            <el-form-item :label="inputSearch3">
              <el-input type="number" @change="initQtyAlert()" oninput="value=value.replace(/^\.+|[^\d.]/g,'')"
                        v-model="receiveQuantity"></el-input>
            </el-form-item>
            <el-form-item :label="inputSearch4">
              <el-input type="number" oninput="value=value.replace(/^\.+|[^\d.]/g,'')" v-model="serviceLife"></el-input>
            </el-form-item>
            <el-form-item :label="inputSearch11">
              <el-input type="number" oninput="value=value.replace(/^\.+|[^\d.]/g,'')"
                        v-model="invoicePrice"></el-input>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="manualInitMailFlag()">{{'确定'}}</el-button>
        <el-button type="primary" @click="toolCodeFlag=false">{{'关闭'}}</el-button>
    </span>
    </el-dialog>
    <el-dialog title="附件信息" :visible.sync="setUp.fileFlag" width="672px" :close-on-click-modal="false"
               :close-on-press-escape="false" v-drag>
      <el-form :inline="true" label-position="top">
        <el-form-item style="margin-top: 10px">
          <upload v-on:childByValue="childByValue"></upload>
        </el-form-item>
        <el-table
          height="170"
          :data="fileList"
          border
          v-loading="dataListLoading"
          @selection-change="selectionChangeHandle"
          style="width: 100%;">
          <el-table-column
            v-for="(item,index) in columnList2" :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-column
            header-align="center"
            align="center"
            width="50"
            :label="buttons.operating">
            <template slot-scope="scope">
              <a @click="fileDownload(scope.row)">{{ buttons.fileDownload }}</a>
              <a @click="filePreview(scope.row)">{{ buttons.preview }}</a>
            </template>
          </el-table-column>
        </el-table>
      </el-form>
    </el-dialog>

    <el-dialog title="预览" :visible.sync="pdfVisible" center width="60%">
      <iframe :src="this.pdfUrl" frameborder="0" width="100%" height="400px"></iframe>
    </el-dialog>

    <!--新增或编辑实例-->
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" v-drag
               :title="'修改接收工具信息'" :visible.sync="toolEditFlag" width="197px">
      <el-form :inline="true" label-position="top">
        <el-form-item label="工具实例编码">
          <el-input v-model="editToolData.newToolInstanceId">
          </el-input>
        </el-form-item>
        <el-form-item label="使用寿命">
          <el-input v-model="editToolData.estUseQty">
          </el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="updateToolDetail()">修改</el-button>
        <el-button type="primary" @click="toolEditFlag = false">取消</el-button>
    </span>
    </el-dialog>
  </div>
</template>

<script>
  import column from "../common/column";
  import {
    searchSysLanguagePackList,
    searchSysLanguageParam,
    searchFunctionButtonList,
    saveButtonList,
    searchSysLanguage,
    searchLanguageListByLanguageCode,
    saveSysLanguageOne
  } from "@/api/sysLanguage.js"
  import {
    saveTableDefaultList,
    saveTableUser,
    getTableDefaultListLanguage,
    getTableUserListLanguage,
    removerDefault,
    removerUser
  } from "@/api/table.js"

  import {
    getViewIfsList,
    getPoToolList,
    getLocationList,
    saveToolDetail,
    updateIfsTool,
    exportList,
    getFileList,
    printTool,
    saveFileAssociate,
    printToolData,
    closeReceiveStatus
  } from "@/api/knifemold/receive.js"
  import {
    getToolDetailList,
    updateReceiveToolDetail,
  } from '@/api/knifemold/tool-info.js'

  import getLodop from '@/utils/LodopFuncs.js'
  import axios from "axios";
  import Vue from "vue";
  import upload from "../common/upload";

  export default {
    components: {
      column
      , upload
    },
    data() {
      return {
        toolEditFlag: false,
        editToolData: {
          toolInstanceId: '',
          estUseQty: '',
          site: '',
          newToolInstanceId: ''
        },
        toolCodeFlag: false,
        pdfUrl: '',
        fileList: [],
        //设置
        setUp: {
          fileFlag: false,
        },
        selectList: {
          select1: [{
            value: 'Y',
            label: '显示'
          }, {
            value: 'N',
            label: '不显示'
          }],
          select2: [],
        },
        height: 0,
        //搜索名称
        inputSearch1: "工具编码",
        inputSearch2: "工具名称",
        inputSearch3: "接收数量",
        inputSearch4: "使用寿命",
        inputSearch5: "IQC检验",
        inputSearch6: "上机检验",
        inputSearch7: "录入库位",
        inputSearch8: "横幅",
        inputSearch9: "宽幅",
        inputSearch10: "接收单号",
        inputSearch11: "入库价格",
        inputSearch12: "接收完成",
        //横幅宽幅设定
        bannersFlag: false,
        bannersBut: false,
        pdfVisible: false,
        torNumacc: '',
        torNumdown: '',
        // 生成按钮是否可用
        generateFlag: false,
        // 接收数量
        receiveQuantity: '',
        // 使用寿命
        serviceLife: '',
        // 检验方式
        radio: '',
        // 录入库位
        locationNo: '',
        // 入库价格
        invoicePrice: 0,
        // 手工实例
        toolInstanceId: '',
        manual: 'N',
        site: this.$store.state.user.site,
        addLanguage: false,
        functionId: this.$route.meta.menuId,
        tableId: this.$route.meta.menuId + 'VIFS01',
        value1: true,
        visible: false,
        showDefault: false,
        poToolFlag: false,
        poToolData: {},
        ifsToolData: {},
        queryViewIfs: {
          //接收号
          transactionId: '',
          //工具编码搜索
          toolId: "",
          //工具名称搜索
          description: "",
          //工厂搜索
          site: "",
          //行数
          limit: "",
          //页数
          page: "",
          receiveFlag: 'N',
        },
        // 默认table 查询参数
        queryTable: {
          functionId: this.$route.meta.menuId,
          tableId: this.$route.meta.menuId + 'VIFS01',
          languageCode: this.$i18n.locale
        },
        // 用户table 查询参数
        queryTableUser: {
          userId: this.$store.state.user.name,
          functionId: this.$route.meta.menuId,
          tableId: this.$route.meta.menuId + 'VIFS01',
          status: true,
          languageCode: this.$i18n.locale
        },
        // 语言词典查询参数
        querySysLanguageParam: {
          languageCode: this.$i18n.locale
        },
        // 语言词典集合
        sysLanguageParams: [],
        // 用户table 配置集合
        userColumnList: [],
        // 展示列集
        poToolColumnList: [
          {
            userId: this.$store.state.user.name,
            serialNumber: '1001viewIfsTableTransactionId',
            tableId: this.$route.meta.menuId + 'VIFS01',
            tableName: "poToolTable",
            columnProp: "toolInstanceId",
            headerAlign: "center",
            align: "center",
            columnLabel: "实例编码",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: false
          },
          {
            userId: this.$store.state.user.name,
            serialNumber: '1001viewIfsTableToolDescription',
            tableId: this.$route.meta.menuId + 'VIFS01',
            tableName: "poToolTable",
            columnProp: "toolDescription",
            headerAlign: "center",
            align: "center",
            columnLabel: "实例名称",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: false
          },
          {
            userId: this.$store.state.user.name,
            serialNumber: '1001viewIfsTableToolDescription',
            tableId: this.$route.meta.menuId + 'VIFS01',
            tableName: "poToolTable",
            columnProp: "status",
            headerAlign: "center",
            align: "center",
            columnLabel: "状态",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: false
          },
        ],
        // 展示列集
        columnList: [
          {
            userId: this.$store.state.user.name,
            serialNumber: '1001viewIfsTableTransactionId',
            tableId: this.$route.meta.menuId + 'VIFS01',
            tableName: "viewIfsTable",
            columnProp: "transactionId",
            headerAlign: "center",
            align: "center",
            columnLabel: "接收单号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: false
          },
          {
            userId: this.$store.state.user.name,
            serialNumber: '1001viewIfsTableToolId',
            tableId: this.$route.meta.menuId + 'VIFS01',
            tableName: "viewIfsTable",
            columnProp: "toolId",
            headerAlign: "center",
            align: "center",
            columnLabel: "工具编码",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            userId: this.$store.state.user.name,
            serialNumber: '1001viewIfsTableDescription',
            tableId: this.$route.meta.menuId + 'VIFS01',
            tableName: "viewIfsTable",
            columnProp: "description",
            headerAlign: "center",
            align: "center",
            columnLabel: "工具名称",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            userId: this.$store.state.user.name,
            serialNumber: '1001viewIfsTableVendorNo',
            tableId: this.$route.meta.menuId + 'VIFS01',
            tableName: "viewIfsTable",
            columnProp: "vendorNo",
            headerAlign: "center",
            align: "center",
            columnLabel: "供应商编码",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            userId: this.$store.state.user.name,
            serialNumber: '1001viewIfsTableVendorName',
            tableId: this.$route.meta.menuId + 'VIFS01',
            tableName: "viewIfsTable",
            columnProp: "vendorName",
            headerAlign: "center",
            align: "center",
            columnLabel: "供应商名称",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            userId: this.$store.state.user.name,
            serialNumber: '1001viewIfsTableQuantity',
            tableId: this.$route.meta.menuId + 'VIFS01',
            tableName: "viewIfsTable",
            columnProp: "quantity",
            headerAlign: "center",
            align: "center",
            columnLabel: "数量",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            userId: this.$store.state.user.name,
            serialNumber: '1001viewIfsTableGenerateQuantity',
            tableId: this.$route.meta.menuId + 'VIFS01',
            tableName: "viewIfsTable",
            columnProp: "generateQuantity",
            headerAlign: "center",
            align: "center",
            columnLabel: "已接收数量",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          }, {
            userId: this.$store.state.user.name,
            serialNumber: '1001viewIfsTableGenerateQuantity',
            tableId: this.$route.meta.menuId + 'VIFS01',
            tableName: "viewIfsTable",
            columnProp: "qtyReceived",
            headerAlign: "center",
            align: "center",
            columnLabel: "入库数量",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
        ],
        // 展示列集
        columnList1: [
          // {
          //   userId: this.$store.state.user.name,
          //   functionId: 1001,
          //   tableId: "common1002",
          //   tableName: "commonLanguage",
          //   columnProp: "functionId",
          //   headerAlign: "center",
          //   align: "center",
          //   columnLabel: "功能编码",
          //   columnHidden: false,
          //   columnImage: false,
          //   columnSortable: false,
          //   sortLv: 0,
          //   status: true,
          //   fixed: false
          // },
          // {
          //   userId: this.$store.state.user.name,
          //   functionId: 1001,
          //   tableId: "common1002",
          //   tableName: "commonLanguage",
          //   columnProp: "objectId",
          //   headerAlign: "center",
          //   align: "center",
          //   columnLabel: "序列化编码",
          //   columnHidden: false,
          //   columnImage: false,
          //   columnSortable: false,
          //   sortLv: 0,
          //   status: true,
          //   fixed: '',
          // },
          // {
          //   userId: this.$store.state.user.name,
          //   functionId: 1001,
          //   tableId: "common1002",
          //   tableName: "commonLanguage",
          //   columnProp: "objectType",
          //   headerAlign: "center",
          //   align: "center",
          //   columnLabel: "类型",
          //   columnHidden: false,
          //   columnImage: false,
          //   columnSortable: false,
          //   sortLv: 0,
          //   status: true,
          //   fixed: '',
          // },
          // {
          //   userId: this.$store.state.user.name,
          //   functionId: 1001,
          //   tableId: "common1002",
          //   tableName: "commonLanguage",
          //   columnProp: "languageValue",
          //   headerAlign: "center",
          //   align: "center",
          //   columnLabel: "语言值",
          //   columnHidden: false,
          //   columnImage: false,
          //   columnSortable: false,
          //   sortLv: 0,
          //   status: true,
          //   fixed: '',
          // },
          // {
          //   userId: this.$store.state.user.name,
          //   functionId: 1001,
          //   tableId: "common1002",
          //   tableName: "commonLanguage",
          //   columnProp: "languageCode",
          //   headerAlign: "center",
          //   align: "center",
          //   columnLabel: "语言编码",
          //   columnHidden: false,
          //   columnImage: false,
          //   columnSortable: false,
          //   sortLv: 0,
          //   status: true,
          //   fixed: '',
          // }
        ],
        // 展示列集
        columnList2: [
          {
            userId: this.$store.state.user.name,
            tableId: this.$route.meta.menuId + 'VIFS02',
            tableName: "fileDetailTable",
            columnProp: "fileName",
            headerAlign: "center",
            align: "center",
            columnLabel: "文件名称",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: false
          },
          {
            userId: this.$store.state.user.name,
            tableId: this.$route.meta.menuId + 'VIFS02',
            tableName: "fileDetailTable",
            columnProp: "createDate",
            headerAlign: "center",
            align: "center",
            columnLabel: "创建时间",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 135,
          },
          {
            userId: this.$store.state.user.name,
            tableId: this.$route.meta.menuId + 'VIFS02',
            tableName: "fileDetailTable",
            columnProp: "createdBy",
            headerAlign: "center",
            align: "center",
            columnLabel: "创建人",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
        ],
        // 数据集
        dataList: [],
        currSelectList: [],
        poToolList: [],
        queryButton: {
          functionId: this.$route.meta.menuId,
          tableId: this.$route.meta.menuId + 'VIFS01',
          languageCode: this.$i18n.locale,
          objectType: 'button'
        },
        buttons: {
          cz: '操作',
          receive: '接收',
          add: '添加',
          edit: '编辑',
          delete: '删除',
          deleteList: '批量删除',
          operating: '操作',
          search: '查询',
          download: '导出',
          settingTable: '设置列表',
          defaultTable: '设置默认配置',
          generate: "生成",
          manualGenerate: "手动生成",
          print: '打印',
          appendixInfo: '附件信息',
          fileDownload: '下载',
          toolLabel: '工具标签',
          screenLabel: '网版标签',
        },
        // 导出 start
        exportData: [],
        exportDataStandard: {
          "功能编码": "functionId",
          "序列化编码": "objectId",
          "类型": "objectType",
          "语言值": "languageValue"
        },
        exportName: "工具接收",
        exportHeader: ["工具接收"],
        exportFooter: [],
        exportDefaultValue: "",
        // 导出 end
        buttonList: [
          {
            functionId: this.$route.meta.menuId,
            languageValue: '接收',
            objectId: 'receive',
            objectType: "button",
            tableId: this.$route.meta.menuId + 'VIFS01',
          },
          {
            functionId: this.$route.meta.menuId,
            languageValue: '生成',
            objectId: 'generate',
            objectType: "button",
            tableId: this.$route.meta.menuId + 'VIFS01',
          },
          {
            functionId: this.$route.meta.menuId,
            languageValue: '打印',
            objectId: 'print',
            objectType: "button",
            tableId: this.$route.meta.menuId + 'VIFS01',
          },
          {
            functionId: this.$route.meta.menuId,
            languageValue: '关闭',
            objectId: 'shutSown',
            objectType: "button",
            tableId: this.$route.meta.menuId + 'VIFS01',
          },
          {
            functionId: this.$route.meta.menuId,
            languageValue: '操作',
            objectId: 'operating',
            objectType: "button",
            tableId: this.$route.meta.menuId + 'VIFS01',
          },
          {
            functionId: this.$route.meta.menuId,
            languageValue: '查询',
            objectId: 'search',
            objectType: "button",
            tableId: this.$route.meta.menuId + 'VIFS01',
          },
          {
            functionId: this.$route.meta.menuId,
            languageValue: '导出',
            objectId: 'download',
            objectType: "button",
            tableId: this.$route.meta.menuId + 'VIFS01',
          },
          {
            functionId: this.$route.meta.menuId,
            languageValue: '设置列表',
            objectId: 'settingTable',
            objectType: "button",
            tableId: this.$route.meta.menuId + 'VIFS01',
          },
          {
            functionId: this.$route.meta.menuId,
            languageValue: '设置默认配置',
            objectId: 'defaultTable',
            objectType: "button",
            tableId: this.$route.meta.menuId + 'VIFS01',
          },
        ],
        languageList: [],
        languageColumnList: [],
        languageDataList: [],
        queryLanguage: {},
        // 数据集条件
        querySysLanguagePack: {
          page: 1,
          limit: 1,
          languageValue: '',
          objectType: '',
          objectId: ''
        },
        // 分页
        pageIndex: 1,
        pageSize: 100,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false,
        insertFileList: [],
        currentData: {},
      }
    },
    activated() {
      // this.getDataList()
      this.initViewIfsTable();
      this.getLanguageList()
    },
    mounted() {
      this.$nextTick(() => {
        this.height = window.innerHeight - 220;
      })
    },
    watch: {
      radio() {
        this.locationNo = ''
      },
      editToolData: {
        deep: true,
        handler: function (newV, oldV) {
          if (this.editToolData.newToolInstanceId) {
            this.editToolData.newToolInstanceId = this.editToolData.newToolInstanceId.toUpperCase()
          }
        }
      },
      locationNo() {
        this.locationNo = this.locationNo.toUpperCase()
      },
      toolInstanceId() {
        this.toolInstanceId = this.toolInstanceId.toUpperCase()
      },
      poToolFlag() {
        if (this.poToolFlag == false) {
          this.initViewIfsTable()
        }
      }
    },
    methods: {
      // 编辑工具接收信息
      editToolDetail(row) {
        this.getToolDetailList(row)
        this.toolEditFlag = true
      },
      // 获取工具信息
      getToolDetailList(row) {
        let queryData = {
          site: this.site,
          toolInstanceId: row.toolInstanceId,
        }
        getToolDetailList(queryData).then(({data}) => {
          if (data && data.code == 0 && data.rows) {
            this.editToolData = {
              newToolInstanceId:  data.rows[0].toolInstanceId,
              site:  data.rows[0].site,
              toolInstanceId:  data.rows[0].toolInstanceId,
              estUseQty:  data.rows[0].estUseQty,
            }
          }
        })
      },
      // 修改接收信息
      updateToolDetail() {
        updateReceiveToolDetail(this.editToolData).then(({data}) => {
          if (data.code == 0) {
            this.$message.success(data.msg)
            this.toolEditFlag = false
            this.initPoToolTable()
          } else {
            this.$message.error(data.msg)
          }
        })
      },
      childByValue(childValue) {
        // childValue就是子组件传过来的值
        this.fileList.push(childValue)
        this.saveAssociate(childValue)
      },
      saveAssociate(row) {
        let jsonList = [];
        let jsonData = {
          site: this.site,
          sysOssId: row.id,
          type: 'ReveiveFile',
          associatedField1: this.currentData.transactionId,
        }
        jsonList.push(jsonData)
        saveFileAssociate(jsonList).then(({data}) => {

        })
      },
      async printMethod(val) {
        if (this.currSelectList.length <= 0) {
          this.$alert('请选择工具信息！', '操作提示', {
            confirmButtonText: '确定',
            callback: action => {
              this.bannersBut = false
            }
          });
          return
        }
        let dto = {
          site: this.currSelectList[0].site,
          toolInstanceId: this.currSelectList[0].toolInstanceId
        }
        await printToolData(dto).then(({data}) => {
          if (data.code == 0) {
            let printDataList = []
            for (const item of this.currSelectList) {
              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: item.toolInstanceId
              }
              printDataList.push(printData)
            }
            if (val == 'Y') {
              this.labelPrintGJ(printDataList)
            } else {
              this.labelPrintWB(printDataList)
            }
          }
        })

      },
      labelPrintWB(printDataList) {
        const LODOP = getLodop()
        if (LODOP) {
          //LODOP.SET_LICENSES("","7B5624CC84EF99D6B17F27DF4AF4310C","","");
          //LODOP.SET_LICENSES("", "7B5624CC84EF99D6B17F27DF4AF4310C", "", "");
          //循环调用打印机
          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("","7B5624CC84EF99D6B17F27DF4AF4310C","","");
          //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, printData.spec); // 规格
            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();

        }
      },
      printMethod1(val) {
        if (this.currSelectList.length <= 0) {
          this.$alert('请选择工具信息！', '操作提示', {
            confirmButtonText: '确定',
            callback: action => {
              this.bannersBut = false
            }
          });
          return
        }
        let reportFamily = ''
        if (val == 'Y') {
          reportFamily = '工具标签'
        } else {
          reportFamily = '网版标签'
        }
        let toolInstanceId = ''
        for (let i = 0; i < this.currSelectList.length; i++) {
          toolInstanceId += this.currSelectList[i].toolInstanceId + ";"
        }
        toolInstanceId = toolInstanceId.substring(0, toolInstanceId.length - 1)
        let jsonData = {
          reportFamily: reportFamily,
          toolInstanceId: toolInstanceId,
        }
        printTool(jsonData).then(({data}) => {
          if (data.code != 0) {
            this.$alert(data.msg, '操作提示', {
              confirmButtonText: '确定',
              callback: action => {
                this.bannersBut = false
              }
            });
          }
        })
      },
      // 文件下载
      fileDownload(row) {
        axios.get('/api/ftp/file/downFtpFile/' + row.id, {
          responseType: 'blob',
          headers: {
            'Content-Type': 'application/json',
            'token': Vue.cookie.get('token')
          }
        }).then(({data}) => {
          // 不限制文件下载类型
          const blob = new Blob([data], {type: "application/octet-stream"})
          // 下载文件名称
          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
          // if(val == 'Y'){
          //   this.pdfVisible = true
          //   this.pdfUrl = linkNode.href
          // }else {
          document.body.appendChild(linkNode)
          linkNode.click() // 模拟在按钮上的一次鼠标单击
          URL.revokeObjectURL(linkNode.href) // 释放URL 对象
          document.body.removeChild(linkNode)
          // }
        })
      },
      filePreview(row) {
        this.pdfVisible = true
        this.pdfUrl = 'http://192.168.1.2:9002/file/' + row.newFileName
      },
      //初始化文件信息模态框
      initFileModel(row) {
        this.currentData = row
        this.getFileList(row)
        this.setUp.fileFlag = true
      },
      //获取申请单号文件信息
      getFileList(row) {
        let jsonData = {
          site: row.site,
          // type : 'PRFile',
          associatedField1: row.transactionId
        }
        this.fileList = []
        getFileList(jsonData).then(({data}) => {
          if (data.code == 0) {
            this.fileList = data.row
          }
        })
      },
      getCurrSelectList(row) {
        this.currSelectList = row
      },
      //检验横幅宽幅是否存在
      saveBanners() {
        this.bannersBut = true
        if (this.torNumacc == "" || this.torNumacc <= 0) {
          this.$alert('请输入正确的横幅！', '横幅', {
            confirmButtonText: '确定',
            callback: action => {
              this.bannersBut = false
            }
          });
          return
        } else if (this.torNumdown == "" || this.torNumacc <= 0) {
          this.$alert('请输入正确的宽幅！', '宽幅', {
            confirmButtonText: '确定',
            callback: action => {
              this.bannersBut = false
            }
          });
          return
        }
        let updateData = {
          site: this.site,
          transactionId: this.ifsToolData.transactionId,
          torNumacc: this.torNumacc,
          torNumdown: this.torNumdown,
        }
        updateIfsTool(updateData).then(({data}) => {
          this.bannersBut = false
          if (data.code == 0) {
            this.ifsToolData.torNumacc = this.torNumacc
            this.ifsToolData.torNumacc = this.torNumacc
            this.bannersFlag = false
            this.$message.success(data.msg)
            this.initPoToolTable()
          } else {
            this.$message.error(data.msg)
          }
        })
      },
      // 手工生成
      setToolInstanceId() {
        this.toolCodeFlag = true
        this.toolInstanceId = ''
      },
      manualInitMailFlag() {
        this.generateFlag = true
        if (this.toolInstanceId == null || this.toolInstanceId == '') {
          this.$alert('请输入工具实例编码！', '接收数量', {
            confirmButtonText: '确定',
            callback: action => {
              this.receiveQuantity = this.ifsToolData.quantity - this.ifsToolData.generateQuantity
              this.generateFlag = false
            }
          });
          return
        } else if (this.receiveQuantity == null || this.receiveQuantity == '') {
          this.$alert('请输入接收数量！', '接收数量', {
            confirmButtonText: '确定',
            callback: action => {
              this.receiveQuantity = this.ifsToolData.quantity - this.ifsToolData.generateQuantity
              this.generateFlag = false
            }
          });
          return
        } else if (this.receiveQuantity <= 0) {
          this.$alert('请输入正确的接收数量！', '接收数量', {
            confirmButtonText: '确定',
            callback: action => {
              this.receiveQuantity = this.ifsToolData.quantity - this.ifsToolData.generateQuantity
              this.generateFlag = false
            }
          });
          return
        } else if (this.serviceLife == null || this.serviceLife == '') {
          this.$alert('请输入使用寿命！', '使用寿命', {
            confirmButtonText: '确定',
            callback: action => {
              this.serviceLife = 0
              this.generateFlag = false
            }
          });
          return
        } else if (this.serviceLife <= 0) {
          this.$alert('请输入正确的使用寿命！', '使用寿命', {
            confirmButtonText: '确定',
            callback: action => {
              this.serviceLife = 0
              this.generateFlag = false
            }
          });
          return
        } else if (this.invoicePrice <= 0) {
          this.$alert('请输入入库价格！', '使用寿命', {
            confirmButtonText: '确定',
            callback: action => {
              this.serviceLife = 0
              this.generateFlag = false
            }
          });
          return
        }
        if (this.radio == 'N') {
          this.manualSaveToolInstanceId()
        } else {
          this.manualSaveToolInstanceId()
        }
      },
      manualSaveToolInstanceId() {
        let status;
        if (this.radio == "Y") {
          status = "出库"
        } else {
          status = "未投用"
        }
        let saveData = {
          site: this.site,
          toolId: this.ifsToolData.toolId,
          description: this.ifsToolData.description,
          userName: this.$store.state.user.name,
          locationId: this.locationNo,
          vendorNo: this.ifsToolData.vendorNo,
          status: status,
          estUseQty: this.serviceLife,
          torNumacc: this.ifsToolData.torNumacc,
          torNumdown: this.ifsToolData.torNumdown,
          transactionId: this.ifsToolData.transactionId,
          receiveQuantity: this.receiveQuantity,
          type: this.radio,
          orderNo: this.ifsToolData.orderNo,
          releaseNo: this.ifsToolData.releaseNo,
          sequenceNo: this.ifsToolData.sequenceNo,
          lineItemNo: this.ifsToolData.lineItemNo,
          vendorName: this.ifsToolData.vendorName,
          invoicePrice: this.invoicePrice,
          manual: 'Y',
          toolInstanceId: this.toolInstanceId
        }
        let currQty = this.receiveQuantity
        saveToolDetail(saveData).then(({data}) => {
          this.generateFlag = false
          if (data.code == 0) {
            this.ifsToolData.generateQuantity += parseInt(currQty)
            this.initPoToolTable()
            this.toolCodeFlag = false
            this.$message.success(data.msg)
          } else {
            this.$message.error(data.msg)
          }
        })
      },
      //检验生成事件
      initMailFlag() {
        this.generateFlag = true
        if (this.receiveQuantity == null || this.receiveQuantity == '') {
          this.$alert('请输入接收数量！', '接收数量', {
            confirmButtonText: '确定',
            callback: action => {
              this.receiveQuantity = this.ifsToolData.quantity - this.ifsToolData.generateQuantity
              this.generateFlag = false
            }
          });
          return
        } else if (this.receiveQuantity <= 0) {
          this.$alert('请输入正确的接收数量！', '接收数量', {
            confirmButtonText: '确定',
            callback: action => {
              this.receiveQuantity = this.ifsToolData.quantity - this.ifsToolData.generateQuantity
              this.generateFlag = false
            }
          });
          return
        } else if (this.serviceLife == null || this.serviceLife == '') {
          this.$alert('请输入使用寿命！', '使用寿命', {
            confirmButtonText: '确定',
            callback: action => {
              this.serviceLife = 0
              this.generateFlag = false
            }
          });
          return
        } else if (this.serviceLife <= 0) {
          this.$alert('请输入正确的使用寿命！', '使用寿命', {
            confirmButtonText: '确定',
            callback: action => {
              this.serviceLife = 0
              this.generateFlag = false
            }
          });
          return
        } else if (this.invoicePrice <= 0) {
          this.$alert('请输入入库价格！', '使用寿命', {
            confirmButtonText: '确定',
            callback: action => {
              this.serviceLife = 0
              this.generateFlag = false
            }
          });
          return
        }
        if (this.radio == 'N') {
          this.saveToolInstanceId()
        } else {
          let queryLocation = {
            site: this.site,
            locationid: this.locationNo,
            limit: 1,
            page: 1,
          }
          this.saveToolInstanceId()
          // this.initLocationFlag(queryLocation)
        }
      },
      // 关闭接收
      closeReceive(row){
        this.$confirm(`确定进行关闭接收操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          row.closeFlag = 'Y'
          closeReceiveStatus(row).then(({data}) =>{
            if (data.code == 0){
              this.$message.success(data.msg)
              this.initViewIfsTable('Y')
            }
          })
        })

      },
      //保存接收信息
      saveToolInstanceId() {
        let status;
        if (this.radio == "Y") {
          status = "出库"
        } else {
          status = "未投用"
        }
        let saveData = {
          site: this.site,
          toolId: this.ifsToolData.toolId,
          description: this.ifsToolData.description,
          userName: this.$store.state.user.name,
          locationId: this.locationNo,
          vendorNo: this.ifsToolData.vendorNo,
          status: status,
          estUseQty: this.serviceLife,
          torNumacc: this.ifsToolData.torNumacc,
          torNumdown: this.ifsToolData.torNumdown,
          transactionId: this.ifsToolData.transactionId,
          receiveQuantity: this.receiveQuantity,
          type: this.radio,
          orderNo: this.ifsToolData.orderNo,
          releaseNo: this.ifsToolData.releaseNo,
          sequenceNo: this.ifsToolData.sequenceNo,
          lineItemNo: this.ifsToolData.lineItemNo,
          vendorName: this.ifsToolData.vendorName,
          invoicePrice: this.invoicePrice,
          manual: 'N',
          toolInstanceId: this.toolInstanceId
        }
        let currQty = this.receiveQuantity
        saveToolDetail(saveData).then(({data}) => {
          this.generateFlag = false
          if (data.code == 0) {
            this.ifsToolData.generateQuantity += parseInt(currQty)
            this.initPoToolTable()
          } else {
          }
          this.$alert(data.msg, '操作提示', {
            confirmButtonText: '确定',
            callback: action => {
              this.addPRDetailFlag = false
              this.bannersBut = false
            }
          });
        })
      },
      //校验是否存在库位
      async initLocationFlag(queryLocation) {
        let locationFlag
        await getLocationList(queryLocation).then(({data}) => {
          if (data && data.code === 0) {
            let list = data.rows.list
            if (list.length > 0) {
              this.saveToolInstanceId()
            } else {
              this.$alert('请输入正确的库位！', '录入库位', {
                confirmButtonText: '确定',
                callback: action => {
                  this.serviceLife = 0
                  this.generateFlag = false
                }
              });
            }
          }
        })
        return locationFlag
      },
      //判断是否超过接收总数量
      initQtyAlert() {
        if (this.receiveQuantity > this.ifsToolData.quantity - this.ifsToolData.generateQuantity) {
          this.$alert('超过当前接收数量！', '接收数量', {
            confirmButtonText: '确定',
            callback: action => {
              this.receiveQuantity = this.ifsToolData.quantity - this.ifsToolData.generateQuantity
            }
          });
        }
      },
      //校验横幅宽幅是否存在
      initBannersFlag(row) {
        this.ifsToolData = row
        if (this.ifsToolData.torNumacc == null || this.ifsToolData.torNumacc == "" || this.ifsToolData.torNumdown == null || this.ifsToolData.torNumdown == "") {
          this.torNumacc = ''
          this.torNumdown = ''
          this.bannersFlag = true;
        } else {
          this.torNumacc = this.ifsToolData.torNumacc
          this.torNumdown = this.ifsToolData.torNumdown
          this.initPoToolTable()
        }
      },
      initPoToolTable() {
        //是否显示加载效果
        this.poToolFlag = true
        this.dataListLoading = true
        let queryPoTool = {
          //  工具编码
          toolId: this.ifsToolData.toolId,
          //  工厂
          site: this.site,
          //  接收号
          toolInstanceId: this.ifsToolData.transactionId,
        }
        this.receiveQuantity = this.ifsToolData.quantity - this.ifsToolData.generateQuantity
        this.serviceLife = 0
        this.radio = '0'
        this.invoicePrice = 0
        this.locationNo = ''
        this.generateFlag = false
        getPoToolList(queryPoTool).then(({data}) => {
          if (data && data.code === 0) {
            this.poToolList = data.rows
          } else {
            this.poToolList = []
          }
          this.dataListLoading = false
        })
      },
      // 获取数据列表
      initViewIfsTable(val) {
        if (val == "Y") {
          this.pageIndex = 1
        }
        //是否显示加载效果
        this.dataListLoading = true
        //显示数据条数
        this.queryViewIfs.limit = this.pageSize
        //分页页面
        this.queryViewIfs.page = this.pageIndex
        //设置工厂
        this.queryViewIfs.site = this.site
        //

        getViewIfsList(this.queryViewIfs).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.rows.list
            this.totalPage = data.rows.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 收藏
      favorites() {

      },
      // 获取多语言列表
      getLanguageList() {
        searchSysLanguage(this.queryLanguage).then(({data}) => {
          this.languageList = data.rows
        })
      },
      // 获取button的词典
      getFunctionButtonList() {
        searchFunctionButtonList(this.queryButton).then(({data}) => {
          if (data.data.length > 0) {
            this.buttons = data.data
          } else {
            saveButtonList(this.buttonList).then(({data}) => {
            })
          }
        })
      },
      // 获取语言词典
      getSysLanguageParamList() {
        searchSysLanguageParam(this.querySysLanguageParam).then(({data}) => {
          this.sysLanguageParams = data.rows
        })
      },
      // 打开页面设置
      userSetting() {
        this.visible = true;
        this.getTableUserAll()
      },
      // 获取 用户的配置
      getTableUserAll() {
        let queryTable = {
          userId: this.$store.state.user.name,
          functionId: this.$route.meta.menuId,
          tableId: this.tableId,
          languageCode: this.$i18n.locale
        }
        this.visible = true;
        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()
          }

        })
      },
      // 保存 默认配置 列
      async saveColumnList() {
        // 删除所有的该页面下保存的数据
        if (this.userColumnList) {
          //删除 user自定义的数据
          await removerUser(this.queryTable)
        }
        // 删除默认配置
        await removerDefault(this.queryTable)
        // 保存页面 table属性
        let sumColumnList = this.columnList.concat(this.columnList1);
        sumColumnList = sumColumnList.map(item => {
          return item = {
            tableId: item.tableId,
            tableName: item.tableName,
            columnProp: item.columnProp,
            columnLabel: item.columnLabel,
            columnHidden: false,
            columnImage: false,
            columnSortable: item.columnSortable,
            columnWidth: null,
            format: null,
            functionId: this.$route.meta.menuId,
            sortLv: 0,
            status: true,
            fixed: '',
            serialNumber: null,
            columnType: null,
            align: null
          }
        })

        await saveTableDefaultList(sumColumnList)
        // 保存页面 button label title 属性
        let buttons = this.buttonList.map(item => {
          return item = {
            functionId: this.$route.meta.menuId,
            languageValue: item.languageValue,
            objectId: item.objectId,
            objectType: item.objectType,
            tableId: item.tableId
          }
        })
        await saveButtonList(buttons)
        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
        this.querySysLanguagePack.limit = this.pageSize
        this.querySysLanguagePack.page = this.pageIndex
        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.initViewIfsTable()
      },
      // 当前页
      currentChangeHandle(val) {
        this.pageIndex = val
        this.initViewIfsTable()
      },
      // 多选
      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.initViewIfsTable()
            } 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:构造需要下载的数据返回
        exportList(this.queryViewIfs).then(({data}) => {
          if (data && data.code === 0) {
            return data.rows.list;
          }
        })
        return this.dataList;
      },
      startDownload() {
        //  this.exportData = this.dataList
        console.log("数据开始")
      },
      finishDownload() {
        console.log("数据下载完成")
      }
    },
    created() {
      this.getTableUserColumn()
      this.getSysLanguageParamList()
      this.getFunctionButtonList()
    }
  }
</script>
<style>
  .sl-input {
    background-color: transparent;
    border: 0 !important;
    font-size: 12px !important;
    height: 12px !important;
    line-height: 14px !important;
    background-color: transparent !important;
    width: 140px;
  }

  .sl-input:focus, textarea:focus {

    outline: none;

  }

</style>
