<template>
  <div class="mod-config">
    <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
      <el-form-item :label="labels.site">
        <el-input v-model="searchData.site" style="width: 130px"></el-input>
      </el-form-item>
      <el-form-item :label="labels.coNo">
        <el-input v-model="searchData.orderNo" style="width: 130px"></el-input>
      </el-form-item>
      <el-form-item :label="labels.orderDate">
        <el-date-picker
          style="width: 130px"
          v-model="searchData.date1"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="labels.to">
        <el-date-picker
          style="width: 130px"
          v-model="searchData.date2"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="labels.isRolls">
        <el-select filterable v-model="searchData.slittedFlag" style="width: 130px">
          <el-option :label="labels.yes" value="Y"></el-option>
          <el-option :label="labels.no" value="N"></el-option>
        </el-select>
        <el-button @click="getData()" type="primary" style="margin-left: 10px;margin-top: 0px">{{ buttons.search }}
        </el-button>
        <download-excel
          :fields="fields()"
          :data="exportData"
          type="xls"
          :name="exportName"
          :header="exportHeader"
          :footer="exportFooter"
          :fetch="createExportData"
          :before-generate="startDownload"
          :before-finish="finishDownload"
          worksheet="导出信息"
          class="el-button el-button--primary el-button--medium">
          {{ buttons.download }}
        </download-excel>
      </el-form-item>
    </el-form>
    <el-table
      :height="height"
      :data="dataList"
      border
      v-loading="dataListLoading"
      style="width: 100%;">
      <el-table-column
        header-align="center"
        align="center"
        width="70"
        label="操作">
        <template slot-scope="scope">
          <a type="text" size="small" v-if="!authAdd" @click="showModel(scope.row)">{{ buttons.addRoll }}</a>
        </template>
      </el-table-column>
      <el-table-column
        v-for="(item,index) in columnList" :key="index"
        :sortable="item.columnSortable"
        :prop="item.columnProp"
        :header-align="item.headerAlign"
        :show-overflow-tooltip="item.showOverflowTooltip"
        :align="item.align"
        :fixed="item.fixed==''?false:item.fixed"
        :width="item.columnWidth"
        :label="item.columnLabel">
        <template slot-scope="scope">
          <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
          <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                             style="width: 100px; height: 80px"/></span>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog width="800px" :title="buttons.addRoll" :close-on-click-modal="false" v-drag :visible.sync="modelFlag">
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -10px;">
        <el-form-item :label="labels.site">
          <el-input v-model="dataForm.site" readonly style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="labels.orderRef1">
          <el-input v-model="dataForm.orderNo" readonly style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="labels.orderRef3">
          <el-input v-model="dataForm.orderItemNo" readonly style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item style="margin-top: 30px">
          <el-button @click="saveCRoll()" type="primary" style="width: 108px;margin-left: 142px;">
            {{ buttons.addRoll }}
          </el-button>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -15px;">
        <el-form-item :label="labels.supplierID">
          <el-input v-model="dataForm.supplierID" readonly style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="labels.supplierName">
          <el-input v-model="dataForm.supplierName" readonly style="width: 255px;"></el-input>
        </el-form-item>
        <el-form-item style="margin-top: 30px">
          <el-button @click="modelFlag=false" type="primary" style="width: 108px;margin-left: 142px;">
            {{ buttons.close }}
          </el-button>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -15px;">
        <el-form-item :label="labels.partNo">
          <el-input v-model="dataForm.partNo" readonly style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="labels.partDescription">
          <el-input v-model="dataForm.partDescription" readonly style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="labels.spec">
          <el-input v-model="dataForm.spec" readonly style="width: 180px;"></el-input>
        </el-form-item>
        <el-form-item style="margin-top: 30px">
          <el-button @click="getSaveModel()" type="primary" style="margin-left: 82px;">{{ buttons.supplierBatchIn }}
          </el-button>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -15px;">
        <el-form-item :label="labels.receive">
          <el-date-picker
            style="width: 120px"
            v-model="dataForm.receive"
            value-format="yyyy-MM-dd"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="labels.suppDeliveryNote">
          <el-input v-model="dataForm.suppDeliveryNote" style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="labels.suppRollNo">
          <el-input v-model="dataForm.suppRollNo" style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="labels.quantity">
          <el-input v-model="dataForm.quantity" readonly style="width: 120px;"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -10px;">
        <el-form-item :label="labels.rollQty">
          <el-input v-model="dataForm.rollQty" type="number" style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="labels.rollNumber">
          <el-input v-model="dataForm.rollNumber" type="number" style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button style="margin-top: 24px" @click="insertData()" type="primary">{{ buttons.insert }}</el-button>
        </el-form-item>
        <el-form-item :label="labels.C_No" style="margin-left: 208px">
          <el-input v-model="dataForm.XX" style="width: 120px;"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -10px;">
        <el-form-item>
          <span slot="label" style="" @click="getBaseList(92)"><a herf="#">{{ labels.customerID }}</a></span>
          <el-input v-model="dataForm.customerID" style="width: 120px;" @change="getReferenceData();"></el-input>
        </el-form-item>
        <el-form-item>
          <span slot="label" style="" @click="getBaseList(5)"><a herf="#">{{ labels.fGPartNo }}</a></span>
          <el-input v-model="dataForm.fGPartNo" style="width: 120px;" @change="getReferenceData();"></el-input>
        </el-form-item>
        <el-form-item :label="labels.referencePartDesc">
          <el-input v-model="dataForm.referencePartDesc" readonly style="width: 220px;"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -10px;">
        <el-form-item :label="labels.referenceSupplierID">
          <el-input v-model="dataForm.referenceSupplierID" readonly style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item :label="labels.referenceSupplierName">
          <el-input v-model="dataForm.referenceSupplierName" readonly style="width: 220px;"></el-input>
        </el-form-item>
      </el-form>
      <el-tabs v-model="activeName" style="font-size: 12px" class="customer-tab" type="border-card">
        <el-tab-pane :label="labels.toRoll" name="first">
          <el-row>
            <el-col :span="10">
              <el-table
                height="200"
                :data="dataList1"
                border
                :vertical-align="'middle'"
                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-column
                  header-align="center"
                  align="center"
                  width="50"
                  :label="labels.case">
                  <template slot-scope="scope">
                    <a type="text" size="small" @click="remove(scope.row)" herf="#">{{ labels.deleteRoll }}</a>
                  </template>
                </el-table-column>
              </el-table>
              <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
                <span style="margin-left: 5px">{{ labels.sumQty }}</span>
                <el-input v-model="sum1" style="width: 50px;" readonly></el-input>
                <span>{{ labels.allQty }}</span>
                <el-input v-model="sum2" style="width: 80px;" readonly></el-input>
              </el-form>
            </el-col>
            <el-col :span="14">
              <el-table
                height="200"
                :data="dataList2"
                border
                @row-dblclick="changeData"
                :vertical-align="'middle'"
                style="width: 120%;">
                <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>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane :label="labels.hasRoll" name="second">
          <div style="width: 760px;margin-top: 0px">
            <el-table
              height="195"
              :data="dataList3"
              border
              :vertical-align="'middle'"
              style="width: 100%;">
              <el-table-column
                v-for="(item,index) in columnList3" :key="index"
                :prop="item.columnProp"
                :header-align="item.headerAlign"
                :align="item.align"
                :vertical-align="'middle'"
                :min-width="item.columnWidth"
                :label="item.columnLabel">
              </el-table-column>

            </el-table>
            <el-form :inline="true" label-position="top" label-width="100px">
              <div style="margin-top: 8px">
                <span style="margin-left: 5px">{{ labels.sumQty }}</span>
                <el-input v-model="sum3" style="width: 50px;" readonly></el-input>
                <span>{{ labels.allQty }}</span>
                <el-input v-model="sum4" style="width: 80px;" readonly></el-input>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
      </el-tabs>
      <el-footer style="height:10px;margin-top: 0px;text-align:center">

      </el-footer>
    </el-dialog>
    <el-dialog width="430px" :title="labels.supplierBatchIn" :close-on-click-modal="false" v-drag
               :visible.sync="modelFlag2">
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
        <el-form-item :label="labels.site">
          <el-input v-model="saveData.site" style="width: 80px"></el-input>
        </el-form-item>
        <el-form-item :label="labels.rollNo">
          <el-input v-model="saveData.rollNo" style="width: 150px"></el-input>
          <el-button @click="goSaveSuppRollNo()" type="primary" style="margin-left: 10px;">{{ buttons.save }}
          </el-button>
          <el-button @click="modelFlag2=false" type="primary" style="margin-left: 10px;">{{ buttons.close }}</el-button>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
        <el-form-item :label="labels.suppRollNo">
          <el-input v-model="saveData.suppRollNo" style="width: 369px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:10px;margin-top: 20px;text-align:center">
      </el-footer>
    </el-dialog>
    <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  </div>
</template>

<script>
import Chooselist from '@/views/modules/common/Chooselist'
import {
  searchSAPPurchaseOrder,
  searchCRollInfoDetail,
  saveCRollData,
  saveSuppRollNo,
  doSaveSuppRollNo,
  getReferenceData,
} from "@/api/purchasingManagement/materialSplit.js"

/*打印标签专用的js*/
import {
  printMaterialLabel,
} from "@/views/modules/yieldReport/print_roll_label.js"

import {
  getPartNoDetail,
  checkCustomerID
} from "@/api/base/site.js"
import {

  searchFunctionButtonList,

} from "@/api/sysLanguage.js"
import {
  saveTableDefaultList,
  getTableDefaultListLanguage,
  getTableUserListLanguage,
  removerDefault,
  removerUser
} from "@/api/table.js"

var functionId = '102001002';
export default {
  //查询-SAP采购订单
  name: "searchSAPPurchaseOrder",
  components: {
    Chooselist
  },
  watch: {
    dataForm: {
      deep: true,
      handler: function (newV, oldV) {
        this.dataForm.customerID = this.dataForm.customerID.toUpperCase()
        this.dataForm.fGPartNo = this.dataForm.fGPartNo.toUpperCase()
      }
    }
  },
  data() {
    return {
      tagNo: '',
      // 导出 start
      exportData: [],
      exportName: "SAP采购订单" + this.dayjs().format('YYYYMMDDHHmmss'),
      exportHeader: ["SAP采购订单"],
      exportFooter: [],
      // 导出 end
      height: 200,
      modelFlag: false,
      modelFlag2: false,
      modelInputFlag: true,
      selectList: [],
      activeName: 'first',
      searchData: {
        site: '',
        orderNo: '',
        date1: '',
        date2: '',
        slittedFlag: 'N',
        user: this.$store.state.user.name
      },
      saveData: {
        site: '',
        rollNo: '',
        suppRollNo: '',
      },
      dataForm: {
        site: '',
        orderNo: '',
        orderItemNo: '',
        supplierID: '',
        supplierName: '',
        partNo: '',
        partDescription: '',
        spec: '',
        receive: '',
        suppDeliveryNote: '',
        quantity: '',
        rollQty: '',
        rollNumber: '',
        customerID: '',
        fGPartNo: '',
        referencePartDesc: '',
        checked: true,
        referenceSupplierID: '',
        referenceSupplierName: '',
        XX: '',
        suppRollNo: '',
      },
      sum1: '',
      sum2: '',
      sum3: '',
      sum4: '',
      dataList: [],
      dataList3: [],
      dataList2: [],
      dataList1: [],
      dataListLoading: false,
      columnList: [
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002TableOrderNo',
          tableId: "102001002Table",
          tableName: "查询SAP采购订单表",
          columnProp: "orderNo",
          headerAlign: "center",
          align: "left",
          columnLabel: "采购订单号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002TableOrderDate',
          tableId: "102001002Table",
          tableName: "查询SAP采购订单表",
          columnProp: "orderDate",
          headerAlign: "center",
          align: "left",
          columnLabel: "订单日期",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002TablePlanReceiptDate',
          tableId: "102001002Table",
          tableName: "查询SAP采购订单表",
          columnProp: "planReceiptDate",
          headerAlign: "center",
          align: "left",
          columnLabel: "要求交货日期",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002TableSupplierID',
          tableId: "102001002Table",
          tableName: "查询SAP采购订单表",
          columnProp: "supplierID",
          headerAlign: "center",
          align: "left",
          columnLabel: "供应商编码",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002TableStatus',
          tableId: "102001002Table",
          tableName: "查询SAP采购订单表",
          columnProp: "status",
          headerAlign: "center",
          align: "left",
          columnLabel: "订单状态",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 70
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002TableSupplierName',
          tableId: "102001002Table",
          tableName: "查询SAP采购订单表",
          columnProp: "supplierName",
          headerAlign: "center",
          align: "left",
          columnLabel: "供应商名称",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 300
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002TableOrderItemNo',
          tableId: "102001002Table",
          tableName: "查询SAP采购订单表",
          columnProp: "orderItemNo",
          headerAlign: "center",
          align: "left",
          columnLabel: "订单序号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 70
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002TablePartNo',
          tableId: "102001002Table",
          tableName: "查询SAP采购订单表",
          columnProp: "partNo",
          headerAlign: "center",
          align: "left",
          columnLabel: "物料编码",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 160
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002TablePartDescription',
          tableId: "102001002Table",
          tableName: "查询SAP采购订单表",
          columnProp: "partDescription",
          headerAlign: "center",
          align: "left",
          columnLabel: "物料名称",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 300
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002TableQuantity',
          tableId: "102001002Table",
          tableName: "查询SAP采购订单表",
          columnProp: "quantity",
          headerAlign: "center",
          align: "right",
          columnLabel: "订单数量",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002TableCancelledFlag',
          tableId: "102001002Table",
          tableName: "查询SAP采购订单表",
          columnProp: "cancelledFlag",
          headerAlign: "center",
          align: "left",
          columnLabel: "是否取消",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 70
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002TableSAPOrderNo',
          tableId: "102001002Table",
          tableName: "查询SAP采购订单表",
          columnProp: "sAPOrderNo",
          headerAlign: "center",
          align: "left",
          columnLabel: "SAP订单标识号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002TableSite',
          tableId: "102001002Table",
          tableName: "查询SAP采购订单表",
          columnProp: "site",
          headerAlign: "center",
          align: "left",
          columnLabel: "工厂编号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 70
        }
      ],
      columnList1: [
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table1Number',
          tableId: "102001002Table1",
          tableName: "查询SAP采购订单待分卷左表",
          columnProp: "number",
          headerAlign: "center",
          align: "right",
          columnLabel: "次序号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 50
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table1RollQty',
          tableId: "102001002Table1",
          tableName: "查询SAP采购订单待分卷左表",
          columnProp: "rollQty",
          headerAlign: "center",
          align: "right",
          columnLabel: "每卷数量",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table1RollNumber',
          tableId: "102001002Table1",
          tableName: "查询SAP采购订单待分卷左表",
          columnProp: "rollNumber",
          headerAlign: "center",
          align: "left",
          columnLabel: "卷数",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 50
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table1ALLRollQty',
          tableId: "102001002Table1",
          tableName: "查询SAP采购订单待分卷左表",
          columnProp: "allRollQty",
          headerAlign: "center",
          align: "left",
          columnLabel: "总数量",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        }
      ],
      columnList2: [
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table2PartNo',
          tableId: "102001002Table2",
          tableName: "查询SAP采购订单待分卷右表",
          columnProp: "partNo",
          headerAlign: "center",
          align: "left",
          columnLabel: "物料编码",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table2PartDescription',
          tableId: "102001002Table2",
          tableName: "查询SAP采购订单待分卷右表",
          columnProp: "partDescription",
          headerAlign: "center",
          align: "left",
          columnLabel: "物料名称",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 168
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table2OrderItemNo',
          tableId: "102001002Table2",
          tableName: "查询SAP采购订单待分卷右表",
          columnProp: "orderItemNo",
          headerAlign: "center",
          align: "left",
          columnLabel: "订单序号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table2Quantity',
          tableId: "102001002Table2",
          tableName: "查询SAP采购订单待分卷右表",
          columnProp: "quantity",
          headerAlign: "center",
          align: "left",
          columnLabel: "订单数量",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        }
      ],
      columnList3: [
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table3RollNo',
          tableId: "102001002Table3",
          tableName: "查询SAP采购订单已分卷表",
          columnProp: "rollNo",
          headerAlign: "center",
          align: "left",
          columnLabel: "卷号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table3RollQty',
          tableId: "102001002Table3",
          tableName: "查询SAP采购订单已分卷表",
          columnProp: "rollQty",
          headerAlign: "center",
          align: "right",
          columnLabel: "卷数量",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 60
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table3SuppDeliveryNote',
          tableId: "102001002Table3",
          tableName: "查询SAP采购订单已分卷表",
          columnProp: "suppDeliveryNote",
          headerAlign: "center",
          align: "left",
          columnLabel: "供应商送货单号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table3RollDate',
          tableId: "102001002Table3",
          tableName: "查询SAP采购订单已分卷表",
          columnProp: "rollDate",
          headerAlign: "center",
          align: "left",
          columnLabel: "入库日期",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table3CreatedDate',
          tableId: "102001002Table3",
          tableName: "查询SAP采购订单已分卷表",
          columnProp: "createdDate",
          headerAlign: "center",
          align: "left",
          columnLabel: "分卷日期",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table3CreatedBy',
          tableId: "102001002Table3",
          tableName: "查询SAP采购订单已分卷表",
          columnProp: "createdBy",
          headerAlign: "center",
          align: "left",
          columnLabel: "分卷人",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 60
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table3SuppRollNoFlag',
          tableId: "102001002Table3",
          tableName: "查询SAP采购订单已分卷表",
          columnProp: "suppRollNoFlag",
          headerAlign: "center",
          align: "left",
          columnLabel: "已录入供应商批号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001002,
          serialNumber: '102001002Table3SuppRollNo',
          tableId: "102001002Table3",
          tableName: "查询SAP采购订单已分卷表",
          columnProp: "suppRollNo",
          headerAlign: "center",
          align: "left",
          columnLabel: "供应商批号",
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 300
        }
      ],
      authEdit: false,
      authAdd: false,
      authDelete: false,
      menuId: this.$route.meta.menuId,
      //this.labels
      labels: {
        site: '工厂编码:',
        coNo: '采购订单号:',
        orderDate: '订单日期',
        to: '至',
        isRolls: '是否分卷',
        yes: '是',
        no: '否',
        orderRef1: '关联单号1：',
        orderRef3: '关联单号3：',
        supplierID: '供应商编码:',
        supplierName: '供应商名称:',
        partNo: '物料编码:',
        partDescription: '物料名称:',
        spec: '规格型号:',
        receive: '接收日期:',
        suppRollNo: '供应商批次号:',
        suppDeliveryNote: '送货单号:',
        quantity: '订单数量',
        rollQty: '每卷数量:',
        rollNumber: '卷数:',
        customerID: '客户编号:',
        fGPartNo: '产品编码:',
        C_No: '材料编码',
        referencePartDesc: '参照名称:',
        referenceSupplierID: '供应商编码:',
        referenceSupplierName: '供应商名称:',
        case: '操作',
        toRoll: '待分卷',
        hasRoll: '已分卷',
        deleteRoll: '删除卷',
        sumQty: '合计：卷数',
        allQty: '总数量',
        supplierBatchIn: '供应商批号录入',
        rollNo: '卷号',
        orderNoAsk: '请输入采购订单号！',
        supplierIDAsk: '请输入供应商编码！',
        partNoAsk: '请输入材料编码！',
        suppDeliveryNoteAsk: '请输入送货单号！',
        rollQtyAsk: '请输入正确的每卷数量！',
        rollNumberAsk: '请输入正确的卷数！',
        deleteComfirm: '确认删除记录吗?',
        printBug: '打印机连接失败！',
        noToRoll: '没有待分卷信息！',
        success: '操作成功',
        customerIDBug: '该客户编码不存在或不可用',
        partNoBug: '该物料编码不存在或不可用',
        supplierIDBug: '该供应商不存在或不可用',
        siteAsk: '请输入工厂编码！',
        rollNoAsk: '请输入卷号!',
        suppRollNoAsk: '请输入供应商批号！',
        rollNoBug: '该卷号不存在，请重新输入！',
        suppRollNoConfirm: '该卷已经录入供应商批号，确认要重新录入吗？',
        sumRollQtySmallConfirm: '累计分切数量小于订单数量，是否继续？',
        sumRollQtyBigConfirm: '累计分切数量小于订单数量，是否继续？',
        changeRollConfirm: '切换订单将会清空待分卷信息，是否继续?',
      },
      //this.buttons
      buttons: {
        addRoll: '创建分卷',
        supplierBatchIn: '供应商批号录入',
        insert: '插入',
        autoPrint: '自动打印标签',
        close: '关闭',
        yes: '确定',
        cancel: '取消',
        search: '查询',
        download: '导出',
        save: '保存',
      },
      queryButton: {
        functionId: functionId,
        table_id: '*',
        languageCode: this.$i18n.locale,
        objectType: 'button'
      },
      queryLabel: {
        functionId: functionId,
        table_id: '*',
        languageCode: this.$i18n.locale,
        objectType: 'label'
      },
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.height = window.innerHeight - 160;
    })
  },

  methods: {
    getBaseData(val) {
      if (this.tagNo === 92) {
        this.dataForm.customerID = val.ConfigurationTemplateID
        this.getReferenceData();
      }
      if (this.tagNo === 5) {
        this.dataForm.fGPartNo = val.PartNo;
        this.getReferenceData();
      }
    },
    // 获取基础数据列表
    getBaseList(val) {
      this.tagNo = val
      this.$nextTick(() => {
        let strVal = "";
        if (val === 5) {
          strVal = this.dataForm.fGPartNo
        }
        if (val === 92) {
          strVal = this.dataForm.customerID
        }
        this.$refs.baseList.init(val, strVal)
      })
    },
    showModel(row) {
      this.dataList1 = [];
      this.sum1 = 0;
      this.sum2 = 0;
      this.sum3 = 0;
      this.sum4 = 0;
      // this.dataForm = JSON.parse(JSON.stringify(row))
      this.dataForm = {
        site: row.site,
        orderNo: row.orderNo,
        orderItemNo: row.orderItemNo,
        supplierID: row.supplierID,
        supplierName: row.supplierName,
        partNo: row.partNo,
        partDescription: row.partDescription,
        spec: row.spec,
        receive: row.receive,
        suppDeliveryNote: '*',
        quantity: row.quantity,
        rollQty: row.rollQty,
        rollNumber: row.rollNumber,
        customerID: '无',
        fGPartNo: '无',
        referencePartDesc: '',
        checked: true,
        XX: '',
      };
      // this.dataForm.fGPartNo='无';
      // this.dataForm.customerID='无';
      // this.dataForm.suppDeliveryNote='*';
      var year = new Date().getFullYear(); //获取完整的年份(4位,1970-????)
      var month = new Date().getMonth() + 1; //获取当前月份(0-11,0代表1月)
      var day = new Date().getDate(); //获取当前日(1-31)
      if (month < 10) {
        month = "0" + month;
      }
      if (day < 10) {
        day = "0" + day;
      }
      var dateString = year + "-" + month + "-" + day;
      this.$set(this.dataForm, 'receive', dateString)
      this.getReferenceData();
      let inData = {
        site: row.site,
        orderRef1: row.orderNo,
        orderRef3: row.orderItemNo,
      }
      searchCRollInfoDetail(inData).then(({data}) => {
        this.dataList3 = data.rows
        for (let i = 0; i < data.total; i++) {
          this.sum4 += this.dataList3[i].rollQty;
        }
        this.sum3 = data.total;
      })
      this.getAllThePartNo();
      this.modelFlag = true;
    },
    getData() {
      // if(this.searchData.slittedFlag==null||this.searchData.slittedFlag==''){
      //   this.$alert("数据量过大，请输入采购单号查询！",'错误',{
      //     confirmButtonText:'确定'
      //   })
      //   return false;
      // }
      searchSAPPurchaseOrder(this.searchData).then(({data}) => {
        this.dataList = data.rows
      })
    },
    insertData() {
      if (this.dataForm.suppDeliveryNote == '' || this.dataForm.suppDeliveryNote == null) {
        this.$alert(this.labels.suppDeliveryNoteAsk, '错误', {
          confirmButtonText: this.buttons.yes
        })
        return false;
      }
      if (this.dataForm.rollQty == '' || this.dataForm.rollQty == null || this.dataForm.rollQty <= 0) {
        this.$alert(this.labels.rollQtyAsk, '错误', {
          confirmButtonText: this.buttons.yes
        })
        return false;
      }
      if (this.dataForm.rollNumber == '' || this.dataForm.rollQty == null || this.dataForm.rollNumber <= 0) {
        this.$alert(this.labels.rollNumberAsk, '错误', {
          confirmButtonText: this.buttons.yes
        })
        return false;
      }
      let newDate = {
        number: this.dataList1.length + 1,
        allRollQty: this.dataForm.rollQty * this.dataForm.rollNumber,
        site: this.dataForm.site,
        rollQty: this.dataForm.rollQty,
        rollNumber: this.dataForm.rollNumber,
        partNo: this.dataForm.partNo,
        supplierID: this.dataForm.supplierID,
        orderRef1: this.dataForm.orderNo,
        orderRef2: this.dataForm.orderNo,
        orderRef3: this.dataForm.orderItemNo,
        orderRef4: 'P',
        suppDeliveryNote: this.dataForm.suppDeliveryNote,
        rollDate: this.dataForm.receive,
        createdBy: this.$store.state.user.name,
        statusDb: 'N',
        status: '未入库',
        suppRollNoFlag: 'N',
        sourceType: '采购入库',
        rolltype: '合格卷',
        rolltypeDb: 0,
        parttypeFlag: 'R',
        customerID: this.dataForm.customerID,
        fGPartNo: this.dataForm.fGPartNo,
        refSupplierID: this.dataForm.referenceSupplierID,
        referencePartDesc: this.dataForm.referencePartDesc
      }
      this.dataList1.push(newDate)
      this.sum1 = Number(this.sum1) + Number(newDate.rollNumber);
      this.sum2 = Number(this.sum2) + Number(newDate.allRollQty);
    },
    remove(row) {
      this.$confirm(this.labels.deleteComfirm, '提示', {
        confirmButtonText: this.buttons.yes,
        cancelButtonText: this.buttons.cancel,
        type: 'warning'
      }).then(() => {
        this.sum1 = Number(this.sum1) - Number(row.rollNumber);
        this.sum2 = Number(this.sum2) - Number(row.allRollQty);
        this.dataList1 = this.dataList1.filter(item => item.number != row.number)
      })

    },
    saveCRoll() {
      let inData = {
        site: this.dataForm.site,
        partNo: this.dataForm.fGPartNo
      }
      getPartNoDetail(inData).then(({data}) => {
        if (data.total > 0 || this.dataForm.fGPartNo == '无') {
          let inData2 = {
            site: this.dataForm.site,
            configurationTemplateID: this.dataForm.customerID,
          }
          checkCustomerID(inData2).then(({data}) => {
            if (data.total > 0 || this.dataForm.customerID == '无') {
              if (this.dataList1.length == 0) {
                this.$alert(this.labels.noToRoll, '错误', {
                  confirmButtonText: this.buttons.yes
                })
                return false;
              }
              if (this.sum2 + this.sum4 < this.dataForm.quantity) {
                this.$confirm(this.labels.sumRollQtySmallConfirm, '提示', {
                  confirmButtonText: this.buttons.yes,
                  cancelButtonText: this.buttons.cancel,
                  type: 'warning'
                }).then(() => {
                  this.doSaveCRoll()
                })
              }

              if (this.sum2 + this.sum4 > this.dataForm.quantity) {
                this.$confirm(this.labels.sumRollQtyBigConfirm, '提示', {
                  confirmButtonText: this.buttons.yes,
                  cancelButtonText: this.buttons.cancel,
                  type: 'warning'
                }).then(() => {
                  this.doSaveCRoll()
                })
              }
              if (this.sum2 + this.sum4 === this.dataForm.quantity) {
                this.doSaveCRoll()
              }


            } else {
              this.$alert(this.labels.customerIDBug, '错误', {
                confirmButtonText: this.buttons.yes
              })
              return false;
            }
          })
        } else {
          this.$alert(this.labels.partNoBug, '错误', {
            confirmButtonText: this.buttons.yes
          })
          return false;
        }
      })
    },
    doSaveCRoll() {
      let dto = this.dataList1.map(item => {
        item.suppRollNo = this.dataForm.suppRollNo
        item.suppRollNoFlag = 'Y'
        return item;
      })
      saveCRollData(dto).then(({data}) => {
        if (data && data.code == 200) {
          this.dataList1 = [];
          this.sum1 = 0;
          this.sum2 = 0;
          let inData = {
            site: this.dataForm.site,
            orderRef1: this.dataForm.orderNo,
            orderRef3: this.dataForm.orderItemNo,
          }
          searchCRollInfoDetail(inData).then(({data}) => {
            this.dataList3 = data.rows
            for (let i = 0; i < data.total; i++) {
              this.sum4 = Number(this.sum4) + Number(this.dataList3[i].rollQty);
            }
            this.sum3 = data.total;
          })
          this.$message.success(this.labels.success);
          //打印材料卷标签
          let printList = data.obj;
          //打印标签
          printMaterialLabel(printList);
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: this.buttons.yes
          })
        }
      })
    },
    getPartNo() {
      let inData = {
        site: this.dataForm.site,
        partNo: this.dataForm.fGPartNo
      }
      getPartNoDetail(inData).then(({data}) => {
        if (data.total > 0 || this.dataForm.fGPartNo == '无') {
        } else {
          this.dataForm.fGPartNo = '';
          this.dataForm = JSON.parse(JSON.stringify(this.dataForm));
          this.$alert(this.labels.partNoBug, '错误', {
            confirmButtonText: this.buttons.yes
          })
        }
      })
    },
    getCustomerID() {
      let inData = {
        site: this.dataForm.site,
        configurationTemplateID: this.dataForm.customerID,
      }
      checkCustomerID(inData).then(({data}) => {
        if (data.total > 0 || this.dataForm.customerID == '无') {
        } else {
          this.dataForm.customerID = '';
          this.dataForm = JSON.parse(JSON.stringify(this.dataForm));
          this.$alert(this.labels.customerIDBug, '错误', {
            confirmButtonText: this.buttons.yes
          })
        }
      })
    },
    getAllThePartNo() {
      let list = [];
      for (let i = 0; i < this.dataList.length; i++) {
        if (this.dataList[i].orderNo == this.dataForm.orderNo) {
          list.push(this.dataList[i]);
        }
      }
      this.dataList2 = list;
    },
    //双击切换订单
    changeData(row) {
      if (this.dataList1.length > 0) {
        this.$confirm(this.labels.changeRollConfirm, '提示', {
          confirmButtonText: this.buttons.yes,
          cancelButtonText: this.buttons.cancel,
          type: 'warning'
        }).then(() => {
          this.sum1 = 0;
          this.sum2 = 0;
          this.sum3 = 0;
          this.sum4 = 0;
          this.dataList1 = [];
          this.dataForm = {
            site: row.site,
            orderNo: row.orderNo,
            orderItemNo: row.orderItemNo,
            supplierID: row.supplierID,
            supplierName: row.supplierName,
            partNo: row.partNo,
            partDescription: row.partDescription,
            spec: row.spec,
            receive: row.receive,
            suppDeliveryNote: '*',
            quantity: row.quantity,
            rollQty: row.rollQty,
            rollNumber: row.rollNumber,
            customerID: '无',
            fGPartNo: '无',
            referencePartDesc: '',
            checked: true,
            XX: '',
          };
          this.$set(this.dataForm, 'receive', new Date());
          this.getReferenceData();
          let inData = {
            site: this.dataForm.site,
            orderRef1: this.dataForm.orderNo,
            orderRef3: this.dataForm.orderItemNo,
          }
          searchCRollInfoDetail(inData).then(({data}) => {
            this.dataList3 = data.rows
            for (let i = 0; i < data.total; i++) {
              this.sum4 = Number(this.sum4) + Number(this.dataList3[i].rollQty);
            }
            this.sum3 = data.total;
          })
        })
      } else {
        this.sum1 = 0;
        this.sum2 = 0;
        this.sum3 = 0;
        this.sum4 = 0;
        this.dataList1 = [];
        this.dataForm = {
          site: row.site,
          orderNo: row.orderNo,
          orderItemNo: row.orderItemNo,
          supplierID: row.supplierID,
          supplierName: row.supplierName,
          partNo: row.partNo,
          partDescription: row.partDescription,
          spec: row.spec,
          receive: row.receive,
          suppDeliveryNote: '*',
          quantity: row.quantity,
          rollQty: row.rollQty,
          rollNumber: row.rollNumber,
          customerID: '无',
          fGPartNo: '无',
          referencePartDesc: '',
          checked: true,
          XX: '',
        };
        this.$set(this.dataForm, 'receive', new Date());
        this.getReferenceData();
        let inData = {
          site: this.dataForm.site,
          orderRef1: this.dataForm.orderNo,
          orderRef3: this.dataForm.orderItemNo,
        }
        searchCRollInfoDetail(inData).then(({data}) => {
          this.dataList3 = data.rows
          for (let i = 0; i < data.total; i++) {
            this.sum4 += this.dataList3[i].rollQty;
          }
          this.sum3 = data.total;
        })
      }
    },
    //供应商批号录入
    getSaveModel() {
      this.saveData = {
        site: this.$store.state.user.site,
        rollNo: '',
        suppRollNo: ''
      };
      this.modelFlag2 = true;
    },
    goSaveSuppRollNo() {
      if (this.saveData.site == '' || this.saveData.site == null) {
        this.$alert(this.labels.siteAsk, '错误', {
          confirmButtonText: this.buttons.yes
        })
        return false;
      }
      if (this.saveData.rollNo == '' || this.saveData.rollNo == null) {
        this.$alert(this.labels.rollNoAsk, '错误', {
          confirmButtonText: this.buttons.yes
        })
        return false;
      }
      if (this.saveData.suppRollNo == '' || this.saveData.suppRollNo == null) {
        this.$alert(this.labels.suppRollNoAsk, '错误', {
          confirmButtonText: this.buttons.yes
        })
        return false;
      }
      saveSuppRollNo(this.saveData).then(({data}) => {
          if (data.rows == null) {
            this.$alert(this.labels.rollNoBug, '错误', {
              confirmButtonText: this.buttons.yes
            })
            return false;
          } else {
            if (data.rows.suppRollNoFlag == 'Y') {
              this.$confirm(this.labels.suppRollNoConfirm, '提示', {
                confirmButtonText: this.buttons.yes,
                cancelButtonText: this.buttons.cancel,
                type: 'warning'

              }).then(() => {
                doSaveSuppRollNo(this.saveData).then(({data}) => {
                  if (data && data.code == 200) {
                    this.modelFlag2 = false
                    this.$message({
                      message: this.labels.success,
                      type: 'success',
                      duration: 1500,
                      onClose: () => {
                      }
                    })
                  } else {
                    this.$alert(data.msg, '错误', {
                      confirmButtonText: this.buttons.yes
                    })
                  }
                })
              })
            } else {
              doSaveSuppRollNo(this.saveData).then(({data}) => {
                if (data && data.code == 200) {
                  this.modelFlag2 = false
                  this.$message({
                    message: this.labels.success,
                    type: 'success',
                    duration: 1500,
                    onClose: () => {
                    }
                  })
                } else {
                  this.$alert(data.msg, '错误', {
                    confirmButtonText: this.buttons.yes
                  })
                }
              })
            }
          }
        }
      )
    },
//导出excel
    createExportData() {

      return this.dataList;

    },
    startDownload() {
      //  this.exportData = this.dataList

    },
    //获取按钮的权限数据
    getButtonAuthData() {
      let updateFlag = this.isAuth(this.menuId + ":revise");
      let fullControFlag = this.isAuth(this.menuId + ":fullContro");
      let deleteFlag = this.isAuth(this.menuId + ":remove");
      //处理页面的权限数据
      this.authEdit = !updateFlag || !fullControFlag;
      this.authAdd = !fullControFlag;
      this.authDelete = !deleteFlag;
    },
    finishDownload() {

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

      return s
    },
    getMultiLanguageList() {
      //首先查询当前按钮的多语言
      searchFunctionButtonList(this.queryButton).then(({data}) => {
        if (data.code == 0) {
          this.buttons = data.data
        } else {
        }
      });
      //其次查询当前标签的多语言
      searchFunctionButtonList(this.queryLabel).then(({data}) => {
        if (data.code == 0) {
          this.labels = data.data
        } else {

        }
      });
    },
    // 导出 end
    getReferenceData() {
      let inData = {
        site: this.dataForm.site,
        partNo: this.dataForm.partNo,
        partDescription: this.dataForm.partDescription,
        customerID: this.dataForm.customerID,
        fGPartNo: this.dataForm.fGPartNo,
        supplierID: '*',
      }
      getReferenceData(inData).then(({data}) => {
        if (data.success) {
          if (data.rows.length > 0) {
            this.dataForm.referenceSupplierID = data.rows[0].SupplierID;
            this.dataForm.referencePartDesc = data.rows[0].PartDescription;
            this.dataForm.referenceSupplierName = data.rows[0].SupplierDesc;
          }
        }
      })
    },
    // 获取 用户保存的 格式列
    async getTableUserColumn(tableId, columnId) {
      let queryTableUser = {
        userId: this.$store.state.user.name,
        functionId: this.$route.meta.menuId,
        tableId: tableId,
        status: true,
        languageCode: this.$i18n.locale
      }
      await getTableUserListLanguage(queryTableUser).then(({data}) => {
        if (data.rows.length > 0) {
          //this.columnList = []
          switch (columnId) {
            case 1:
              this.columnList = data.rows
              break;
            case 2:
              this.columnList1 = data.rows
              break;
            case 3:
              this.columnList2 = data.rows
              break;
            case 4:
              this.columnList3 = data.rows
              break;
          }

        } else {
          this.getColumnList(tableId, columnId)
        }
      })

    },
    // 获取 tableDefault 列
    async getColumnList(tableId, columnId) {
      this.queryTable.tableId = tableId
      let   queryTable= {
          functionId: this.$route.meta.menuId,
          tableId: tableId,
          languageCode: this.$i18n.locale
        }
      await getTableDefaultListLanguage(queryTable).then(({data}) => {
        if (!data.rows.length == 0) {
          switch (columnId) {
            case 1:
              this.columnList = data.rows
              break;
            case 2:
              this.columnList1 = data.rows
              break;
            case 3:
              this.columnList2 = data.rows
              break;
            case 4:
              this.columnList3 = data.rows
              break;
          }
        } else {
          // this.showDefault = true
        }
      })

    },

  },
  created() {
    this.getMultiLanguageList()//刷新按钮
    //获取按钮的权限
    this.getButtonAuthData();
    this.getTableUserColumn('102001002Table', 1);
    this.getTableUserColumn('102001002Table1', 2);
    this.getTableUserColumn('102001002Table2', 3);
    this.getTableUserColumn('102001002Table3', 4);
  }
}

</script>

<style scoped>
.el-textarea__inner {
  padding: 5px 5px;
}

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

}

/deep/ .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;
}
</style>

