<template>
  <div class="app-container mes-admin-page">
    <el-card>
      <el-table
        v-loading="loading"
        :data="tableData"
        highlight-current-row
        border
        size="mini"
        height="670"
        center
        style="width: 70%"
        @row-click="rowClick"
      >
        <el-table-column type="index" width="60" :label="$t('stationInformationMaintenance.sequence')" align="center"/>
        <!--        <el-table-column label="MES工序号" width="110" align="center">-->
        <!--          <template slot-scope="scope">-->
        <!--            <template>-->
        <!--              {{ scope.row.文件名称 }}-->
        <!--            </template>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <!--        <el-table-column label="MES资源号" width="110" align="center">-->
        <!--          <template slot-scope="scope">-->
        <!--            <template>-->
        <!--              {{ scope.row.工控机名称 }}-->
        <!--            </template>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <el-table-column :label="$t('stationInformationMaintenance.stationNumber')" width="110" align="center">
          <template slot-scope="scope">
            <template>
              {{ scope.row.工位号 }}
            </template>
          </template>
        </el-table-column>
        <el-table-column :label="$t('stationInformationMaintenance.stationName')" min-width="150px" align="center">
          <template slot-scope="scope">
            <template>
              {{ scope.row.工位名称 }}
            </template>
          </template>
        </el-table-column>

        <el-table-column :label="$t('stationInformationMaintenance.stationMESFunction')" width="110px" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.是否启用MES" size="mini" type="success">{{ $t('stationInformationMaintenance.enabled') }}</el-tag>
            <el-tag v-else size="mini" type="warning">{{ $t('stationInformationMaintenance.disabled') }}</el-tag>
<!--            <el-checkbox v-model="scope.row.是否启用MES" @change="updateUsedMes(scope.row)" />-->
          </template>
        </el-table-column>
        <el-table-column :label="$t('stationInformationMaintenance.mesDll')" width="110px" align="center">
          <template slot-scope="scope">
            <template>
              <span v-if="scope.row.是否启用MES">{{ scope.row.MesDll }}</span>
              <span v-else ></span>
            </template>
          </template>
        </el-table-column>
        <el-table-column :label="$t('stationInformationMaintenance.operation')" width="150" align="center">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              plain
              icon="el-icon-edit"
              @click="editShiftTable(scope.row)"
            >{{ $t('stationInformationMaintenance.edit') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-dialog v-el-drag-dialog :visible.sync="dialogFormVisible" :title="translateDialogTitle(title)" center style="min-height: 200px;" width="400px">
      <el-form ref="formData" :model="formData" :rules="rules" label-position="right" label-width="120px">
<!--        <el-form-item label="MES工序号" prop="fileName">-->
<!--          <el-input v-model="formData.fileName" readonly class="myReadOnly-input" size="small" placeholder="指南工位号"/>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="MES资源号" prop="nameIndustrialComputer">-->
<!--          <el-input v-model="formData.nameIndustrialComputer" readonly class="myReadOnly-input" size="small" placeholder="指南工位号"/>-->
<!--        </el-form-item>-->
        <el-form-item :label="$t('stationInformationMaintenance.stationNumber')" prop="stationNumber">
          <el-input v-model="formData.stationNumber" readonly class="myReadOnly-input" size="small" :placeholder="$t('stationInformationMaintenance.stationNumber')"/>
        </el-form-item>

        <el-form-item :label="$t('stationInformationMaintenance.stationName')" prop="stationName">
          <el-input v-model="formData.stationName" clearable size="small" :placeholder="$t('stationInformationMaintenance.stationName')"/>
        </el-form-item>
        <el-form-item :label="$t('stationInformationMaintenance.stationMESFunction')" prop="enableMES">
<!--          <el-checkbox v-model="formData.enableMES" />-->
          <el-tag v-if="formData.enableMES" size="mini" type="success">{{ $t('stationInformationMaintenance.enabled') }}</el-tag>
          <el-tag v-else size="mini" type="warning">{{ $t('stationInformationMaintenance.disabled') }}</el-tag>
        </el-form-item>
        <el-form-item v-if="formData.enableMES" :label="$t('stationInformationMaintenance.mesDll')" prop="MesDll">
          <el-input v-model="formData.MesDll" readonly class="myReadOnly-input" size="small" :placeholder="$t('stationInformationMaintenance.mesDll')"/>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="callOff('formData')">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="submitAdd1('formData')">{{ $t('common.confirm') }}</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible1" :title="translateDialogTitle(title)" center style="min-height: 200px;" width="400px">
      <el-form ref="form" :model="form" :rules="rules" label-position="right" label-width="110px">
        <el-form-item :label="$t('stationInformationMaintenance.electricalComponents')" prop="dataTypeValue">
          <el-select v-model="form.dataTypeValue" :placeholder="$t('stationInformationMaintenance.electricalComponents')" clearable size="small" style="width:200px" @change="changeName(form.dataTypeValue)">
            <el-option
              v-for="item in dataType"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('stationInformationMaintenance.number')" prop="value">
          <el-input v-model="form.value" clearable size="small" :placeholder="$t('stationInformationMaintenance.sequence')"/>
        </el-form-item>
        <el-form-item :label="$t('stationInformationMaintenance.description')" prop="descript">
          <el-input
            v-model="form.descript"
            clearable
            size="small"
            :placeholder="$t('stationInformationMaintenance.description')"
          />
        </el-form-item>
        <el-form-item :label="$t('stationInformationMaintenance.disabledStatus')" prop="active">
          <el-select v-model="form.active" :placeholder="$t('stationInformationMaintenance.disabledStatus')" clearable size="small" style="width:200px">
            <el-option
              v-for="item in activeOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('stationInformationMaintenance.remarks')" prop="comments">
          <el-input
            v-model="form.comments"
            clearable
            size="small"
            :placeholder="$t('stationInformationMaintenance.remarks')"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="callOff('form')">{{ $t('common.cancel') }}</el-button>
        <el-button v-if="title === '增加'" type="primary" size="small" @click="submitAdd('form')">{{ $t('common.confirm') }}</el-button>
        <el-button v-if="title === '编辑'" type="primary" size="small" @click="submitAdd1('form')">{{ $t('common.confirm') }}</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible3" :title="$t('stationInformationMaintenance.import')" center style="min-height: 200px" width="900px">
      <div class="app-container">
        <upload-excel-component style="margin-left: 15%" @on-selected-file="selected"/>
        <div style="margin-left: 395px">
          <span v-show="worksheet.length > 1" style="cursor: pointer;width: 50px;" @click="removeAll"><i class="el-icon-close"/></span>
          <el-upload :on-remove="handleRemove" :file-list="itemFile" style="width: 220px" action=""/>
        </div>
        <div v-if="worksheet.length !== 0" style="margin: 3px 0 0 395px">
          <el-button icon="el-icon-upload2" type="primary" size="small" @click="basicPartsToSQL">{{ $t('stationInformationMaintenance.importToDatabase') }}</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { sleep } from '../../../utils/tool'
import UploadExcelComponent from './UploadExcel.vue'
import request from '@/utils/request'
export default {
  name: 'UploadExcel',
  components: { UploadExcelComponent },
  data() {
    return {
      drawer: false,
      direction: 'rtl',
      loading: true,
      worksheet: [],
      itemFile: [],
      unSpecification: [],
      dataTypeValue: '',
      dataType: [],
      PLCIP: [],
      tableData: [],
      activeValue: '',
      dialogFormVisible: false,
      dialogFormVisible1: false,
      dialogFormVisible3: false,
      form: {
        name: '',
        value: '',
        descript: '',
        comments: '',
        ID: '',
        active: '',
        dataTypeValue: ''
      },
      rules: {},
      formData: {
        ID: '', // ID
        stationCode: '', // 工位代码
        stationNumber: '', // 工位号
        guideStationNumber: '', // 指南工位号
        machineType: '', // 机床类型
        stationName: '', // 工位名称
        lineType: '', // 线体类型
        QRcodeScannGun: '', // 二维码扫描枪
        fixedBarcodeScannGun: '', // 固定条形码扫描枪
        handheldBarcodeScannGun: '', // 手持条形码扫描枪
        PC: '',
        nameIndustrialComputer: '', // 工控机名称
        ipIndustrialComputer: '', // 工控机IP
        communicationPort: '', // 通讯端口
        fileName: '', // 文件名称
        PLC: '',
        PLCCode: '', // PLC代码
        PLCState: '', // PLC加工状态
        PLCCodeState: '', // PLC代码加工状态
        engineModelCodeSynthesis: '', // 发动机型号代码合成
        dailyPlannedOutput: '', // 日计划产量
        preparationTime: '', // 准备时间
        machineTime: '', // 机器时间
        laborTime: '', // 人工时间
        technicalDifficultyCoefficient: '', // 技术难度系数
        whetherLineHead: '', // 是否线首
        branchMaterialTrackingStation: '', // 分线物料追踪工位
        busOnlineStation: '', // 总线上线工位
        busMonitoredStation: '', // 总线被监测工位
        scanningGunType: '', // 扫描枪类型
        stationType: '', // 工位类型
        DFCBMTS: '', // 分线物料追踪工位数据文件连接
        BOSDFC: '', // 总线上线工位数据文件连接
        OpcServer: '',
        OpcServer_MIS: '',
        OpcServer_OPNAME: '',
        TargetCycleTime: '', // 目标循环时间
        WorkpieceType: '', // 工件类型
        basicOperationInstructionsStation: '', // 工位基本操作指导
        stationBasicGuidePicture: '', // 工位基本指导图片
        stationUpperLowerLineType: '', // 工位上下线类型
        largeScreenCode: '', // 大屏幕代码
        largeScreenDisplayOutputPort: '', // 大屏幕显示产量端口
        AndonCode: '', // 大屏幕显示Andon大屏幕代码
        AndonPort: '', // 大屏幕显示Andon端口
        isTherePrinter: '', // 是否有打印机
        printerPort: '', // 打印机通讯端口
        processNo: '', // 工序号
        processName: '', // 工序名称
        isThereComputer: '', // 是否有工位计算机
        isThereData: '', // 是否有测量数据
        enableMES: '', // 是否启用MES
        onlineStatus: '', // 在线状态
        whetherSaveData: '', // 是否通过监控系统保存数据
        whetherMonitor: '', // 是否监控
        repairStationNo: '', // 返修工位号
        workStepAttribute: '', // 工步属性
        MesServerCode: '',
        MesDll: '',
        MesWebCode: '',
        orderSelectionPermission: '', // 订单选择权限
        theServerIP: '', // 服务器IP
        BarVersion: '', // Bar版本号
        monitoringAttributeCode: '', // 监控属性代码
        IP: '',
        numberAlarms: '', //
        numberQualityGroups: ''
      },
      title: '',
      pageCurrent: 1,
      pageSize: 20,
      total: 0
    }
  },
  computed: {
    activeOptions() {
      return [{
        label: this.$t('stationInformationMaintenance.enabled'),
        value: 1
      }, {
        label: this.$t('stationInformationMaintenance.disabled'),
        value: 0
      }]
    }
  },
  watch: {
    '$i18n.locale': {
      immediate: true,
      handler() {
        this.rules = {
          stationName: [{ required: true, message: this.$t('stationInformationMaintenance.enterStationName'), trigger: 'blur' }],
          enableMES: [{ required: true, message: this.$t('stationInformationMaintenance.selectStationMES'), trigger: 'blur' }]
        }
      }
    }
  },
  created() {
    this.getIP()
    this.getNumber()
    this.searchTable()
  },
  methods: {
    updateUsedMes(row) {
      var param = []
      param[0] = ['工位号', row.工位号]
      param[1] = ['是否启用MES', row['是否启用MES'] ? 1 : 0]
      var Data = this.CreateData('12', 'MES_计划BOM_工位与名称_更新_是否启用MES', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].result === '1') {
          this.$message({
            message: this.$t('stationInformationMaintenance.editSuccess'),
            type: 'success'
          })
          this.searchTable()
        } else {
          this.$message.error(this.$t('stationInformationMaintenance.editFailed'))
        }
      })
    },
    selectCode(val) {
      for (let i = 0; i < this.tableData.length; i++) {
        if (val === this.tableData[i].工位代码) {
          this.$message.error(this.$t('stationInformationMaintenance.duplicateStationCode'))
        }
      }
    },
    handleClose(done) {
      this.$confirm(this.$t('stationInformationMaintenance.confirmClose'))
        .then(_ => {
          done()
        })
        .catch(_ => {})
    },
    translateDialogTitle(title) {
      const titleMap = {
        '添加工位信息': this.$t('stationInformationMaintenance.addStationInfo'),
        '编辑工位信息': this.$t('stationInformationMaintenance.editStationInfo'),
        '增加': this.$t('stationInformationMaintenance.add'),
        '编辑': this.$t('stationInformationMaintenance.edit')
      }
      return titleMap[title] || title
    },
    getNumber() {
      this.dataType = []
      request({
        url: '',
        method: 'post',
        data: {
          type: '3',
          name: `SELECT [工位号] FROM [dbo].[MES_计划BOM_工位与名称]`
        }
      }).then(response => {
        if (response.data.length) {
          for (let i = 0; i < response.data.length; i++) {
            this.dataType.push({
              label: response.data[i].工位号,
              value: response.data[i].工位号
            })
          }
        }
      })
    },
    getIP() {
      this.PLCIP = []
      request({
        url: '',
        method: 'post',
        data: {
          type: '3',
          name: `SELECT [设备IP],[ID] FROM [dbo].[MES_基本变量设备类型对应表] ORDER BY ID`
        }
      }).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.PLCIP.push({
            label: response.data[i].设备IP,
            value: response.data[i].设备IP,
            value1: response.data[i].ID
          })
        }
      })
    },
    changeName(val) {
      for (let i = 0; i < this.dataType.length; i++) {
        if (this.dataType[i].value === val) {
          console.log(this.dataType[i].label, 'this.stationNumber[i].label')
          this.form.name = this.dataType[i].label
        }
      }
    },
    searchTable() {
      this.loading = true
      let dataTypeValue_check
      this.dataTypeValue ? dataTypeValue_check = 1 : dataTypeValue_check = 0
      var param = []
      param[0] = ['type_ischeck', dataTypeValue_check]
      param[1] = ['type', this.dataTypeValue]
      var Data = this.CreateData('11', '基础数据_工位信息维护_查询', param)
      this.ExecDatabase(Data).then(response => {
        this.tableData = []
        if (response.data.length !== 0) {
          for (let i = 0; i < response.data.length; i++) {
            this.tableData.push({
              ...response.data[i], ...{
                是否启用MES: parseInt(response.data[i].是否启用MES) === 1,
                edit: false
              }})
          }
        }
        this.loading = false
      })
    },
    exportExcel() {
      if (this.tableData.length !== 0) {
        let dataTypeValue_check
        this.dataTypeValue ? dataTypeValue_check = 1 : dataTypeValue_check = 0
        var param = []
        param[0] = ['type_ischeck', dataTypeValue_check]
        param[1] = ['type', this.dataTypeValue]
        var Data = this.CreateData('2001', '基础数据_工位信息维护_导出', param)
        this.exportExcel_NPOI(Data)
      } else {
        this.$message.warning(this.$t('stationInformationMaintenance.noData'))
      }
    },
    addShiftTable(formName) {
      if (this.$refs[formName] !== undefined) {
        this.$refs[formName].resetFields()
      }
      this.title = '添加工位信息'
      this.formData.stationCode = '' // 工位代码
      this.formData.stationNumber = '' // 工位号
      this.formData.guideStationNumber = '' // 指南工位号
      this.formData.machineType = '' // 机床类型
      this.formData.stationName = '' // 工位名称
      this.formData.lineType = '' // 线体类型
      this.formData.QRcodeScannGun = '' // 二维码扫描枪
      this.formData.fixedBarcodeScannGun = '' // 固定条形码扫描枪
      this.formData.handheldBarcodeScannGun = '' // 手持条形码扫描枪
      this.formData.PC = ''
      this.formData.nameIndustrialComputer = '' // 工控机名称
      this.formData.ipIndustrialComputer = '' // 工控机IP
      this.formData.communicationPort = '' // 通讯端口
      this.formData.fileName = '' // 文件名称
      this.formData.PLC = ''
      this.formData.PLCCode = '' // PLC代码
      this.formData.PLCState = '' // PLC加工状态
      this.formData.PLCCodeState = '' // PLC代码加工状态
      this.formData.engineModelCodeSynthesis = '' // 发动机型号代码合成
      this.formData.dailyPlannedOutput = '' // 日计划产量
      this.formData.preparationTime = '' // 准备时间
      this.formData.machineTime = '' // 机器时间
      this.formData.laborTime = '' // 人工时间
      this.formData.technicalDifficultyCoefficient = '' // 技术难度系数
      this.formData.whetherLineHead = '' // 是否线首
      this.formData.branchMaterialTrackingStation = '' // 分线物料追踪工位
      this.formData.busOnlineStation = '' // 总线上线工位
      this.formData.busMonitoredStation = '' // 总线被监测工位
      this.formData.scanningGunType = '' // 扫描枪类型
      this.formData.stationType = '' // 工位类型
      this.formData.DFCBMTS = '' // 分线物料追踪工位数据文件连接
      this.formData.BOSDFC = '' // 总线上线工位数据文件连接
      this.formData.OpcServer = ''
      this.formData.OpcServer_MIS = ''
      this.formData.OpcServer_OPNAME = ''
      this.formData.TargetCycleTime = '' // 目标循环时间
      this.formData.WorkpieceType = '' // 工件类型
      this.formData.basicOperationInstructionsStation = '' // 工位基本操作指导
      this.formData.stationBasicGuidePicture = '' // 工位基本指导图片
      this.formData.stationUpperLowerLineType = '' // 工位上下线类型
      this.formData.largeScreenCode = '' // 大屏幕代码
      this.formData.largeScreenDisplayOutputPort = '' // 大屏幕显示产量端口
      this.formData.AndonCode = '' // 大屏幕显示Andon大屏幕代码
      this.formData.AndonPort = '' // 大屏幕显示Andon端口
      this.formData.isTherePrinter = '' // 是否有打印机
      this.formData.printerPort = '' // 打印机通讯端口
      this.formData.processNo = '' // 工序号
      this.formData.processName = '' // 工序名称
      this.formData.isThereComputer = '' // 是否有工位计算机
      this.formData.isThereData = '' // 是否有测量数据
      this.formData.enableMES = '' // 是否启用MES
      this.formData.onlineStatus = '' // 在线状态
      this.formData.whetherSaveData = '' // 是否通过监控系统保存数据
      this.formData.whetherMonitor = '' // 是否监控
      this.formData.repairStationNo = '' // 返修工位号
      this.formData.workStepAttribute = '' // 工步属性
      this.formData.MesServerCode = ''
      this.formData.MesDll = ''
      this.formData.MesWebCode = ''
      this.formData.orderSelectionPermission = '' // 订单选择权限
      this.formData.theServerIP = '' // 服务器IP
      this.formData.BarVersion = '' // Bar版本号
      this.formData.monitoringAttributeCode = '' // 监控属性代码
      this.formData.IP = ''
      this.formData.numberAlarms = '' //
      this.formData.numberQualityGroups = ''
      this.drawer = true
    },
    submitAdd() {
      var param = []
      param[0] = ['工位代码', this.formData.stationCode]
      param[1] = ['工位号', this.formData.stationNumber]
      param[2] = ['指南工位号', this.formData.guideStationNumber]
      param[3] = ['机床类型', this.formData.machineType]
      param[4] = ['工位名称', this.formData.stationName]
      param[5] = ['线体类型', this.formData.lineType]
      param[6] = ['二维码扫描枪', this.formData.QRcodeScannGun]
      param[7] = ['固定条形码扫描枪', this.formData.fixedBarcodeScannGun]
      param[8] = ['手持条形码扫描枪', this.formData.handheldBarcodeScannGun]
      param[9] = ['PC', this.formData.PC]
      param[10] = ['工控机名称', this.formData.nameIndustrialComputer]
      param[11] = ['工控机IP', this.formData.ipIndustrialComputer]
      param[12] = ['通讯端口', this.formData.communicationPort]
      param[13] = ['文件名称', this.formData.fileName]
      param[14] = ['PLC', this.formData.PLC]
      param[15] = ['PLC代码', this.formData.PLCCode]
      param[16] = ['PLC加工状态', this.formData.PLCState]
      param[17] = ['PLC代码加工状态', this.formData.PLCCodeState]
      param[18] = ['发动机型号代码合成', this.formData.engineModelCodeSynthesis]
      param[19] = ['日计划产量', this.formData.dailyPlannedOutput]
      param[20] = ['准备时间', this.formData.preparationTime]
      param[21] = ['机器时间', this.formData.machineTime]
      param[22] = ['人工时间', this.formData.laborTime]
      param[23] = ['技术难度系数', this.formData.technicalDifficultyCoefficient]
      param[24] = ['是否线首', this.formData.whetherLineHead]
      param[25] = ['分线物料追踪工位', this.formData.branchMaterialTrackingStation]
      param[26] = ['总线上线工位', this.formData.busOnlineStation]
      param[27] = ['总线被监测工位', this.formData.busMonitoredStation]
      param[28] = ['扫描枪类型', this.formData.scanningGunType]
      param[29] = ['工位类型', this.formData.stationType]
      param[30] = ['分线物料追踪工位数据文件连接', this.formData.DFCBMTS]
      param[31] = ['总线上线工位数据文件连接', this.formData.BOSDFC]
      param[32] = ['OpcServer', this.formData.OpcServer]
      param[33] = ['OpcServer_MIS', this.formData.OpcServer_MIS]
      param[34] = ['OpcServer_OPNAME', this.formData.OpcServer_OPNAME]
      param[35] = ['目标循环时间', this.formData.TargetCycleTime]
      param[36] = ['工件类型', this.formData.WorkpieceType]
      param[37] = ['工位基本操作指导', this.formData.basicOperationInstructionsStation]
      param[38] = ['工位基本指导图片', null]
      param[39] = ['工位上下线类型', this.formData.stationUpperLowerLineType]
      param[40] = ['大屏幕代码', this.formData.largeScreenCode]
      param[41] = ['大屏幕显示产量端口', this.formData.largeScreenDisplayOutputPort]
      param[42] = ['大屏幕显示Andon大屏幕代码', this.formData.AndonCode]
      param[43] = ['大屏幕显示Andon端口', this.formData.AndonPort]
      param[44] = ['是否有打印机', this.formData.isTherePrinter]
      param[45] = ['打印机通讯端口', this.formData.printerPort]
      param[46] = ['工序号', this.formData.processNo]
      param[47] = ['工序名称', this.formData.processName]
      param[48] = ['是否有工位计算机', this.formData.isThereComputer]
      param[49] = ['是否有测量数据', this.formData.isThereData]
      param[50] = ['是否启用MES', this.formData.enableMES]
      param[51] = ['在线状态', this.formData.onlineStatus]
      param[52] = ['是否通过监控系统保存数据', this.formData.whetherSaveData]
      param[53] = ['是否监控', this.formData.whetherMonitor]
      param[54] = ['返修工位号', this.formData.repairStationNo]
      param[55] = ['工步属性', this.formData.workStepAttribute]
      param[56] = ['MesServerCode', this.formData.MesServerCode]
      param[57] = ['MesDll', this.formData.MesDll]
      param[58] = ['MesWebCode', this.formData.MesWebCode]
      param[59] = ['订单选择权限', this.formData.orderSelectionPermission]
      param[60] = ['服务器IP', this.formData.theServerIP]
      param[61] = ['Bar版本号', this.formData.BarVersion]
      param[62] = ['监控属性代码', this.formData.monitoringAttributeCode]
      param[63] = ['IP', this.formData.IP]
      param[64] = ['报警数', this.formData.numberAlarms]
      param[65] = ['质量组数', this.formData.numberQualityGroups]
      var Data = this.CreateData('12', '基础数据_工位信息维护_增加', param)
      this.ExecDatabase(Data).then(response => {
        console.log(response)
        if (response.data[0].result === '1') {
          this.$message({
            message: this.$t('stationInformationMaintenance.addSuccess'),
            type: 'success'
          })
          this.dialogFormVisible = false
          this.searchTable()
        } else {
          this.$message.error(this.$t('stationInformationMaintenance.addFailed'))
        }
      })
      this.drawer = false
    },
    editShiftTable(row) {
      this.title = '编辑工位信息'
      this.formData.ID = row.ID // ID
      this.formData.stationCode = row.工位代码 // 工位代码
      this.formData.stationNumber = row.工位号 // 工位号
      this.formData.guideStationNumber = row.指南工位号 // 指南工位号
      this.formData.machineType = row.机床类型 // 机床类型
      this.formData.stationName = row.工位名称 // 工位名称
      this.formData.lineType = row.线体类型 // 线体类型
      this.formData.QRcodeScannGun = row.二维码扫描枪 // 二维码扫描枪
      this.formData.fixedBarcodeScannGun = row.固定条形码扫描枪 // 固定条形码扫描枪
      this.formData.handheldBarcodeScannGun = row.手持条形码扫描枪 // 手持条形码扫描枪
      this.formData.PC = row.PC
      this.formData.nameIndustrialComputer = row.工控机名称 // 工控机名称
      this.formData.ipIndustrialComputer = row.工控机IP // 工控机IP
      this.formData.communicationPort = row.通讯端口 // 通讯端口
      this.formData.fileName = row.文件名称 // 文件名称
      this.formData.PLC = row.PLC
      this.formData.PLCCode = row.PLC代码 // PLC代码
      this.formData.PLCState = row.PLC加工状态 // PLC加工状态
      this.formData.PLCCodeState = row.PLC代码加工状态 // PLC代码加工状态
      this.formData.engineModelCodeSynthesis = row.发动机型号代码合成 // 发动机型号代码合成
      this.formData.dailyPlannedOutput = row.日计划产量 // 日计划产量
      this.formData.preparationTime = row.准备时间 // 准备时间
      this.formData.machineTime = row.机器时间 // 机器时间
      this.formData.laborTime = row.人工时间 // 人工时间
      this.formData.technicalDifficultyCoefficient = row.技术难度系数 // 技术难度系数
      this.formData.whetherLineHead = row.是否线首 // 是否线首
      this.formData.branchMaterialTrackingStation = row.分线物料追踪工位 // 分线物料追踪工位
      this.formData.busOnlineStation = row.总线上线工位 // 总线上线工位
      this.formData.busMonitoredStation = row.总线被监测工位 // 总线被监测工位
      this.formData.scanningGunType = row.扫描枪类型 // 扫描枪类型
      this.formData.stationType = row.工位类型 // 工位类型
      this.formData.DFCBMTS = row.分线物料追踪工位数据文件连接 // 分线物料追踪工位数据文件连接
      this.formData.BOSDFC = row.总线上线工位数据文件连接 // 总线上线工位数据文件连接
      this.formData.OpcServer = row.OpcServer
      this.formData.OpcServer_MIS = row.OpcServer_MIS
      this.formData.OpcServer_OPNAME = row.OpcServer_OPNAME
      this.formData.TargetCycleTime = row.目标循环时间 // 目标循环时间
      this.formData.WorkpieceType = row.工件类型 // 工件类型
      this.formData.basicOperationInstructionsStation = row.工位基本操作指导 // 工位基本操作指导
      this.formData.stationBasicGuidePicture = row.工位基本指导图片 // 工位基本指导图片
      this.formData.stationUpperLowerLineType = row.工位上下线类型 // 工位上下线类型
      this.formData.largeScreenCode = row.大屏幕代码 // 大屏幕代码
      this.formData.largeScreenDisplayOutputPort = row.大屏幕显示产量端口 // 大屏幕显示产量端口
      this.formData.AndonCode = row.大屏幕显示Andon大屏幕代码 // 大屏幕显示Andon大屏幕代码
      this.formData.AndonPort = row.大屏幕显示Andon端口 // 大屏幕显示Andon端口
      this.formData.isTherePrinter = row.是否有打印机 // 是否有打印机
      this.formData.printerPort = row.打印机通讯端口 // 打印机通讯端口
      this.formData.processNo = row.工序号 // 工序号
      this.formData.processName = row.工序名称 // 工序名称
      this.formData.isThereComputer = row.是否有工位计算机 // 是否有工位计算机
      this.formData.isThereData = row.是否有测量数据 // 是否有测量数据
      this.formData.enableMES = row.是否启用MES // 是否启用MES
      this.formData.onlineStatus = row.在线状态 // 在线状态
      this.formData.whetherSaveData = row.是否通过监控系统保存数据 // 是否通过监控系统保存数据
      this.formData.whetherMonitor = row.是否监控 // 是否监控
      this.formData.repairStationNo = row.返修工位号 // 返修工位号
      this.formData.workStepAttribute = row.工步属性 // 工步属性
      this.formData.MesServerCode = row.MesServerCode
      this.formData.MesDll = row.MesDll
      this.formData.MesWebCode = row.MesWebCode
      this.formData.orderSelectionPermission = row.订单选择权限 // 订单选择权限
      this.formData.theServerIP = row.服务器IP // 服务器IP
      this.formData.BarVersion = row.Bar版本号 // Bar版本号
      this.formData.monitoringAttributeCode = row.监控属性代码 // 监控属性代码
      this.formData.IP = row.IP
      this.formData.numberAlarms = row.报警数 // 报警数
      this.formData.numberQualityGroups = row.质量组数
      this.dialogFormVisible = true
    },
    rowClick(row) {
      this.formData.stationCode = row.工位代码 // 工位代码
      this.formData.stationNumber = row.工位号 // 工位号
      this.formData.guideStationNumber = row.指南工位号 // 指南工位号
      this.formData.machineType = row.机床类型 // 机床类型
      this.formData.stationName = row.工位名称 // 工位名称
      this.formData.lineType = row.线体类型 // 线体类型
      this.formData.QRcodeScannGun = row.二维码扫描枪 // 二维码扫描枪
      this.formData.fixedBarcodeScannGun = row.固定条形码扫描枪 // 固定条形码扫描枪
      this.formData.handheldBarcodeScannGun = row.手持条形码扫描枪 // 手持条形码扫描枪
      this.formData.PC = row.PC
      this.formData.nameIndustrialComputer = row.工控机名称 // 工控机名称
      this.formData.ipIndustrialComputer = row.工控机IP // 工控机IP
      this.formData.communicationPort = row.通讯端口 // 通讯端口
      this.formData.fileName = row.文件名称 // 文件名称
      this.formData.PLC = row.PLC
      this.formData.PLCCode = row.PLC代码 // PLC代码
      this.formData.PLCState = row.PLC加工状态 // PLC加工状态
      this.formData.PLCCodeState = row.PLC代码加工状态 // PLC代码加工状态
      this.formData.engineModelCodeSynthesis = row.发动机型号代码合成 // 发动机型号代码合成
      this.formData.dailyPlannedOutput = row.日计划产量 // 日计划产量
      this.formData.preparationTime = row.准备时间 // 准备时间
      this.formData.machineTime = row.机器时间 // 机器时间
      this.formData.laborTime = row.人工时间 // 人工时间
      this.formData.technicalDifficultyCoefficient = row.技术难度系数 // 技术难度系数
      this.formData.whetherLineHead = row.是否线首 // 是否线首
      this.formData.branchMaterialTrackingStation = row.分线物料追踪工位 // 分线物料追踪工位
      this.formData.busOnlineStation = row.总线上线工位 // 总线上线工位
      this.formData.busMonitoredStation = row.总线被监测工位 // 总线被监测工位
      this.formData.scanningGunType = row.扫描枪类型 // 扫描枪类型
      this.formData.stationType = row.工位类型 // 工位类型
      this.formData.DFCBMTS = row.分线物料追踪工位数据文件连接 // 分线物料追踪工位数据文件连接
      this.formData.BOSDFC = row.总线上线工位数据文件连接 // 总线上线工位数据文件连接
      this.formData.OpcServer = row.OpcServer
      this.formData.OpcServer_MIS = row.OpcServer_MIS
      this.formData.OpcServer_OPNAME = row.OpcServer_OPNAME
      this.formData.TargetCycleTime = row.目标循环时间 // 目标循环时间
      this.formData.WorkpieceType = row.工件类型 // 工件类型
      this.formData.basicOperationInstructionsStation = row.工位基本操作指导 // 工位基本操作指导
      this.formData.stationBasicGuidePicture = row.工位基本指导图片 // 工位基本指导图片
      this.formData.stationUpperLowerLineType = row.工位上下线类型 // 工位上下线类型
      this.formData.largeScreenCode = row.大屏幕代码 // 大屏幕代码
      this.formData.largeScreenDisplayOutputPort = row.大屏幕显示产量端口 // 大屏幕显示产量端口
      this.formData.AndonCode = row.大屏幕显示Andon大屏幕代码 // 大屏幕显示Andon大屏幕代码
      this.formData.AndonPort = row.大屏幕显示Andon端口 // 大屏幕显示Andon端口
      this.formData.isTherePrinter = row.是否有打印机 // 是否有打印机
      this.formData.printerPort = row.打印机通讯端口 // 打印机通讯端口
      this.formData.processNo = row.工序号 // 工序号
      this.formData.processName = row.工序名称 // 工序名称
      this.formData.isThereComputer = row.是否有工位计算机 // 是否有工位计算机
      this.formData.isThereData = row.是否有测量数据 // 是否有测量数据
      this.formData.enableMES = row.是否启用MES // 是否启用MES
      this.formData.onlineStatus = row.在线状态 // 在线状态
      this.formData.whetherSaveData = row.是否通过监控系统保存数据 // 是否通过监控系统保存数据
      this.formData.whetherMonitor = row.是否监控 // 是否监控
      this.formData.repairStationNo = row.返修工位号 // 返修工位号
      this.formData.workStepAttribute = row.工步属性 // 工步属性
      this.formData.MesServerCode = row.MesServerCode
      this.formData.MesDll = row.MesDll
      this.formData.MesWebCode = row.MesWebCode
      this.formData.orderSelectionPermission = row.订单选择权限 // 订单选择权限
      this.formData.theServerIP = row.服务器IP // 服务器IP
      this.formData.BarVersion = row.Bar版本号 // Bar版本号
      this.formData.monitoringAttributeCode = row.监控属性代码 // 监控属性代码
      this.formData.IP = row.IP
      this.formData.numberAlarms = row.报警数 // 报警数
      this.formData.numberQualityGroups = row.质量组数
    },
    copyData() {
      if (this.formData.stationNumber) {
        var param = []
        param[0] = ['工位代码', 'copeData']
        param[1] = ['工位号', 'copeData']
        param[2] = ['指南工位号', this.formData.guideStationNumber]
        param[3] = ['机床类型', this.formData.machineType]
        param[4] = ['工位名称', this.formData.stationName]
        param[5] = ['线体类型', this.formData.lineType]
        param[6] = ['二维码扫描枪', this.formData.QRcodeScannGun]
        param[7] = ['固定条形码扫描枪', this.formData.fixedBarcodeScannGun]
        param[8] = ['手持条形码扫描枪', this.formData.handheldBarcodeScannGun]
        param[9] = ['PC', this.formData.PC]
        param[10] = ['工控机名称', this.formData.nameIndustrialComputer]
        param[11] = ['工控机IP', this.formData.ipIndustrialComputer]
        param[12] = ['通讯端口', this.formData.communicationPort]
        param[13] = ['文件名称', this.formData.fileName]
        param[14] = ['PLC', this.formData.PLC]
        param[15] = ['PLC代码', this.formData.PLCCode]
        param[16] = ['PLC加工状态', this.formData.PLCState]
        param[17] = ['PLC代码加工状态', this.formData.PLCCodeState]
        param[18] = ['发动机型号代码合成', this.formData.engineModelCodeSynthesis]
        param[19] = ['日计划产量', this.formData.dailyPlannedOutput]
        param[20] = ['准备时间', this.formData.preparationTime]
        param[21] = ['机器时间', this.formData.machineTime]
        param[22] = ['人工时间', this.formData.laborTime]
        param[23] = ['技术难度系数', this.formData.technicalDifficultyCoefficient]
        param[24] = ['是否线首', this.formData.whetherLineHead]
        param[25] = ['分线物料追踪工位', this.formData.branchMaterialTrackingStation]
        param[26] = ['总线上线工位', this.formData.busOnlineStation]
        param[27] = ['总线被监测工位', this.formData.busMonitoredStation]
        param[28] = ['扫描枪类型', this.formData.scanningGunType]
        param[29] = ['工位类型', this.formData.stationType]
        param[30] = ['分线物料追踪工位数据文件连接', this.formData.DFCBMTS]
        param[31] = ['总线上线工位数据文件连接', this.formData.BOSDFC]
        param[32] = ['OpcServer', this.formData.OpcServer]
        param[33] = ['OpcServer_MIS', this.formData.OpcServer_MIS]
        param[34] = ['OpcServer_OPNAME', this.formData.OpcServer_OPNAME]
        param[35] = ['目标循环时间', this.formData.TargetCycleTime]
        param[36] = ['工件类型', this.formData.WorkpieceType]
        param[37] = ['工位基本操作指导', this.formData.basicOperationInstructionsStation]
        param[38] = ['工位基本指导图片', null]
        param[39] = ['工位上下线类型', this.formData.stationUpperLowerLineType]
        param[40] = ['大屏幕代码', this.formData.largeScreenCode]
        param[41] = ['大屏幕显示产量端口', this.formData.largeScreenDisplayOutputPort]
        param[42] = ['大屏幕显示Andon大屏幕代码', this.formData.AndonCode]
        param[43] = ['大屏幕显示Andon端口', this.formData.AndonPort]
        param[44] = ['是否有打印机', this.formData.isTherePrinter]
        param[45] = ['打印机通讯端口', this.formData.printerPort]
        param[46] = ['工序号', this.formData.processNo]
        param[47] = ['工序名称', this.formData.processName]
        param[48] = ['是否有工位计算机', this.formData.isThereComputer]
        param[49] = ['是否有测量数据', this.formData.isThereData]
        param[50] = ['是否启用MES', this.formData.enableMES]
        param[51] = ['在线状态', this.formData.onlineStatus]
        param[52] = ['是否通过监控系统保存数据', this.formData.whetherSaveData]
        param[53] = ['是否监控', this.formData.whetherMonitor]
        param[54] = ['返修工位号', this.formData.repairStationNo]
        param[55] = ['工步属性', this.formData.workStepAttribute]
        param[56] = ['MesServerCode', this.formData.MesServerCode]
        param[57] = ['MesDll', this.formData.MesDll]
        param[58] = ['MesWebCode', this.formData.MesWebCode]
        param[59] = ['订单选择权限', this.formData.orderSelectionPermission]
        param[60] = ['服务器IP', this.formData.theServerIP]
        param[61] = ['Bar版本号', this.formData.BarVersion]
        param[62] = ['监控属性代码', this.formData.monitoringAttributeCode]
        param[63] = ['IP', this.formData.IP]
        param[64] = ['报警数', this.formData.numberAlarms]
        param[65] = ['质量组数', this.formData.numberQualityGroups]
        var Data = this.CreateData('12', '基础数据_工位信息维护_增加', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message({
              message: this.$t('stationInformationMaintenance.addSuccess'),
              type: 'success'
            })
            this.dialogFormVisible = false
            this.searchTable()
          } else {
            this.$message.error(this.$t('stationInformationMaintenance.addFailed'))
          }
        })
      } else {
        this.$message.error(this.$t('stationInformationMaintenance.selectRowToCopy'))
      }
    },
    submitAdd1() {
      this.$refs['formData'].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['工位代码', this.formData.stationCode]
          param[1] = ['工位号', this.formData.stationNumber]
          param[2] = ['指南工位号', this.formData.guideStationNumber]
          param[3] = ['机床类型', this.formData.machineType]
          param[4] = ['工位名称', this.formData.stationName]
          param[5] = ['线体类型', this.formData.lineType]
          param[6] = ['二维码扫描枪', this.formData.QRcodeScannGun]
          param[7] = ['固定条形码扫描枪', this.formData.fixedBarcodeScannGun]
          param[8] = ['手持条形码扫描枪', this.formData.handheldBarcodeScannGun]
          param[9] = ['PC', this.formData.PC]
          param[10] = ['工控机名称', this.formData.nameIndustrialComputer]
          param[11] = ['工控机IP', this.formData.ipIndustrialComputer]
          param[12] = ['通讯端口', this.formData.communicationPort]
          param[13] = ['文件名称', this.formData.fileName]
          param[14] = ['PLC', this.formData.PLC]
          param[15] = ['PLC代码', this.formData.PLCCode]
          param[16] = ['PLC加工状态', this.formData.PLCState]
          param[17] = ['PLC代码加工状态', this.formData.PLCCodeState]
          param[18] = ['发动机型号代码合成', this.formData.engineModelCodeSynthesis]
          param[19] = ['日计划产量', this.formData.dailyPlannedOutput]
          param[20] = ['准备时间', this.formData.preparationTime]
          param[21] = ['机器时间', this.formData.machineTime]
          param[22] = ['人工时间', this.formData.laborTime]
          param[23] = ['技术难度系数', this.formData.technicalDifficultyCoefficient]
          param[24] = ['是否线首', this.formData.whetherLineHead]
          param[25] = ['分线物料追踪工位', this.formData.branchMaterialTrackingStation]
          param[26] = ['总线上线工位', this.formData.busOnlineStation]
          param[27] = ['总线被监测工位', this.formData.busMonitoredStation]
          param[28] = ['扫描枪类型', this.formData.scanningGunType]
          param[29] = ['工位类型', this.formData.stationType]
          param[30] = ['分线物料追踪工位数据文件连接', this.formData.DFCBMTS]
          param[31] = ['总线上线工位数据文件连接', this.formData.BOSDFC]
          param[32] = ['OpcServer', this.formData.OpcServer]
          param[33] = ['OpcServer_MIS', this.formData.OpcServer_MIS]
          param[34] = ['OpcServer_OPNAME', this.formData.OpcServer_OPNAME]
          param[35] = ['目标循环时间', this.formData.TargetCycleTime]
          param[36] = ['工件类型', this.formData.WorkpieceType]
          param[37] = ['工位基本操作指导', this.formData.basicOperationInstructionsStation]
          param[38] = ['工位基本指导图片', null]
          param[39] = ['工位上下线类型', this.formData.stationUpperLowerLineType]
          param[40] = ['大屏幕代码', this.formData.largeScreenCode]
          param[41] = ['大屏幕显示产量端口', this.formData.largeScreenDisplayOutputPort]
          param[42] = ['大屏幕显示Andon大屏幕代码', this.formData.AndonCode]
          param[43] = ['大屏幕显示Andon端口', this.formData.AndonPort]
          param[44] = ['是否有打印机', this.formData.isTherePrinter]
          param[45] = ['打印机通讯端口', this.formData.printerPort]
          param[46] = ['工序号', this.formData.processNo]
          param[47] = ['工序名称', this.formData.processName]
          param[48] = ['是否有工位计算机', this.formData.isThereComputer]
          param[49] = ['是否有测量数据', this.formData.isThereData]
          param[50] = ['是否启用MES', this.formData.enableMES ? 1 : 0]
          param[51] = ['在线状态', this.formData.onlineStatus]
          param[52] = ['是否通过监控系统保存数据', this.formData.whetherSaveData]
          param[53] = ['是否监控', this.formData.whetherMonitor]
          param[54] = ['返修工位号', this.formData.repairStationNo]
          param[55] = ['工步属性', this.formData.workStepAttribute]
          param[56] = ['MesServerCode', this.formData.MesServerCode]
          param[57] = ['MesDll', this.formData.MesDll]
          param[58] = ['MesWebCode', this.formData.MesWebCode]
          param[59] = ['订单选择权限', this.formData.orderSelectionPermission]
          param[60] = ['服务器IP', this.formData.theServerIP]
          param[61] = ['Bar版本号', this.formData.BarVersion]
          param[62] = ['监控属性代码', this.formData.monitoringAttributeCode]
          param[63] = ['IP', this.formData.IP]
          param[64] = ['报警数', this.formData.numberAlarms]
          param[65] = ['质量组数', this.formData.numberQualityGroups]
          param[66] = ['ID', this.formData.ID]
          console.log(param, 'param')
          var Data = this.CreateData('12', '基础数据_工位信息维护_修改', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: this.$t('stationInformationMaintenance.editSuccess'),
                type: 'success'
              })
              this.searchTable()
              this.dialogFormVisible = false
            } else {
              this.$message.error(this.$t('stationInformationMaintenance.editFailed'))
            }
          })
        } else {
          return false
        }
      })
    },
    handleDelete(row) {
      this.$confirm(this.$t('stationInformationMaintenance.confirmDelete'), this.$t('stationInformationMaintenance.prompt'), {
        confirmButtonText: this.$t('common.confirm'),
        cancelButtonText: this.$t('common.cancel'),
        type: 'warning'
      }).then(() => {
        var param = []
        param[0] = ['ID', row.ID]
        var Data = this.CreateData('12', '基础数据_工位信息维护_删除', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message({
              message: this.$t('stationInformationMaintenance.deleteSuccess'),
              type: 'success'
            })
            this.searchTable()
          } else {
            this.$message.error(this.$t('stationInformationMaintenance.deleteFailed'))
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: this.$t('stationInformationMaintenance.deleteCanceled')
        })
      })
    },
    callOff() {
      this.dialogFormVisible = false
    },
    importOrder() {
      this.dialogFormVisible3 = true
    },
    removeAll() {
      this.worksheet = []
      this.itemFile = []
    },
    async selected(data) { // 选择需要导入的文件
      console.log(data, 1111)
      this.worksheet = data.worksheet // 获取每个多选文件的表格坐标及值
      this.itemFile = data.itemFile
    },
    handleRemove(file) { // 移除文件
      for (let i = 0; i < this.itemFile.length; i++) {
        if (this.itemFile[i].name === file.name) {
          this.worksheet.splice(i, 1)
          this.itemFile.splice(i, 1)
        }
      }
    },
    async basicPartsToSQL() {
      try {
        this.loading = true
        this.err = 0
        for (let j = this.worksheet.length - 1; j >= 0; j--) {
          let stationCode,
            stationNumber,
            guideStationNumber,
            machineType,
            stationName,
            lineType,
            QRcodeScannGun,
            fixedBarcodeScannGun,
            handheldBarcodeScannGun,
            PC,
            nameIndustrialComputer,
            ipIndustrialComputer,
            communicationPort,
            fileName,
            PLC,
            PLCCode,
            PLCState,
            PLCCodeState,
            engineModelCodeSynthesis,
            dailyPlannedOutput,
            preparationTime,
            machineTime,
            laborTime,
            technicalDifficultyCoefficient,
            whetherLineHead,
            branchMaterialTrackingStation,
            busOnlineStation,
            busMonitoredStation,
            scanningGunType,
            stationType,
            DFCBMTS,
            BOSDFC,
            OpcServer,
            OpcServer_MIS,
            OpcServer_OPNAME,
            TargetCycleTime,
            WorkpieceType,
            basicOperationInstructionsStation,
            stationUpperLowerLineType,
            largeScreenCode,
            largeScreenDisplayOutputPort,
            AndonCode,
            AndonPort,
            isTherePrinter,
            printerPort,
            processNo,
            processName,
            isThereComputer,
            isThereData,
            enableMES,
            onlineStatus,
            whetherSaveData,
            whetherMonitor,
            repairStationNo,
            workStepAttribute,
            MesServerCode,
            MesDll,
            MesWebCode,
            orderSelectionPermission,
            theServerIP,
            BarVersion,
            monitoringAttributeCode,
            IP,
            numberAlarms,
            numberQualityGroups
          var param = []
          param[0] = ['工位号', this.worksheet[j].B2.v]
          console.log('工位号', this.worksheet[j].B2.v)
          var Data = this.CreateData('11', '基础数据_工位信息维护_导入校验', param)
          const response = await this.ExecDatabase(Data)
          const res = response.data
          if (res[0].Column1 !== 0) {
            this.$notify.error(`${this.worksheet[j].B2.v}${this.$t('stationInformationMaintenance.alreadyExistsCheckFile')}`)
            this.loading = false
            this.disabled = false
            return
          } else {
            for (let i = 0; i < 999; i++) {
              const attr = i + 2
              stationCode = this.worksheet[j][`A${attr}`] ? this.worksheet[j][`A${attr}`].v : ''
              stationNumber = this.worksheet[j][`B${attr}`] ? this.worksheet[j][`B${attr}`].v : ''
              guideStationNumber = this.worksheet[j][`C${attr}`] ? this.worksheet[j][`C${attr}`].v : ''
              machineType = this.worksheet[j][`D${attr}`] ? this.worksheet[j][`D${attr}`].v : ''
              stationName = this.worksheet[j][`E${attr}`] ? this.worksheet[j][`E${attr}`].v : ''
              lineType = this.worksheet[j][`F${attr}`] ? this.worksheet[j][`F${attr}`].v : ''
              QRcodeScannGun = this.worksheet[j][`G${attr}`] ? this.worksheet[j][`G${attr}`].v : ''
              fixedBarcodeScannGun = this.worksheet[j][`H${attr}`] ? this.worksheet[j][`H${attr}`].v : ''
              handheldBarcodeScannGun = this.worksheet[j][`I${attr}`] ? this.worksheet[j][`I${attr}`].v : ''
              PC = this.worksheet[j][`J${attr}`] ? this.worksheet[j][`J${attr}`].v : ''
              nameIndustrialComputer = this.worksheet[j][`K${attr}`] ? this.worksheet[j][`K${attr}`].v : ''
              ipIndustrialComputer = this.worksheet[j][`L${attr}`] ? this.worksheet[j][`L${attr}`].v : ''
              communicationPort = this.worksheet[j][`M${attr}`] ? this.worksheet[j][`M${attr}`].v : ''
              fileName = this.worksheet[j][`N${attr}`] ? this.worksheet[j][`N${attr}`].v : ''
              PLC = this.worksheet[j][`O${attr}`] ? this.worksheet[j][`O${attr}`].v : ''
              PLCCode = this.worksheet[j][`P${attr}`] ? this.worksheet[j][`P${attr}`].v : ''
              PLCState = this.worksheet[j][`Q${attr}`] ? this.worksheet[j][`Q${attr}`].v : ''
              PLCCodeState = this.worksheet[j][`R${attr}`] ? this.worksheet[j][`R${attr}`].v : ''
              engineModelCodeSynthesis = this.worksheet[j][`S${attr}`] ? this.worksheet[j][`S${attr}`].v : ''
              dailyPlannedOutput = this.worksheet[j][`T${attr}`] ? this.worksheet[j][`T${attr}`].v : ''
              preparationTime = this.worksheet[j][`U${attr}`] ? this.worksheet[j][`U${attr}`].v : ''
              machineTime = this.worksheet[j][`V${attr}`] ? this.worksheet[j][`V${attr}`].v : ''
              laborTime = this.worksheet[j][`W${attr}`] ? this.worksheet[j][`W${attr}`].v : ''
              technicalDifficultyCoefficient = this.worksheet[j][`X${attr}`] ? this.worksheet[j][`X${attr}`].v : ''
              whetherLineHead = this.worksheet[j][`Y${attr}`] ? this.worksheet[j][`Y${attr}`].v : ''
              branchMaterialTrackingStation = this.worksheet[j][`Z${attr}`] ? this.worksheet[j][`Z${attr}`].v : ''
              busOnlineStation = this.worksheet[j][`AA${attr}`] ? this.worksheet[j][`AA${attr}`].v : ''
              busMonitoredStation = this.worksheet[j][`AB${attr}`] ? this.worksheet[j][`AB${attr}`].v : ''
              scanningGunType = this.worksheet[j][`AC${attr}`] ? this.worksheet[j][`AC${attr}`].v : ''
              stationType = this.worksheet[j][`AD${attr}`] ? this.worksheet[j][`AD${attr}`].v : ''
              DFCBMTS = this.worksheet[j][`AE${attr}`] ? this.worksheet[j][`AE${attr}`].v : ''
              BOSDFC = this.worksheet[j][`AF${attr}`] ? this.worksheet[j][`AF${attr}`].v : ''
              OpcServer = this.worksheet[j][`AG${attr}`] ? this.worksheet[j][`AG${attr}`].v : ''
              OpcServer_MIS = this.worksheet[j][`AH${attr}`] ? this.worksheet[j][`AH${attr}`].v : ''
              OpcServer_OPNAME = this.worksheet[j][`AI${attr}`] ? this.worksheet[j][`AI${attr}`].v : ''
              TargetCycleTime = this.worksheet[j][`AJ${attr}`] ? this.worksheet[j][`AJ${attr}`].v : ''
              WorkpieceType = this.worksheet[j][`AK${attr}`] ? this.worksheet[j][`AK${attr}`].v : ''
              basicOperationInstructionsStation = this.worksheet[j][`AL${attr}`] ? this.worksheet[j][`AL${attr}`].v : ''
              stationUpperLowerLineType = this.worksheet[j][`AM${attr}`] ? this.worksheet[j][`AM${attr}`].v : ''
              largeScreenCode = this.worksheet[j][`AN${attr}`] ? this.worksheet[j][`AN${attr}`].v : ''
              largeScreenDisplayOutputPort = this.worksheet[j][`AO${attr}`] ? this.worksheet[j][`AO${attr}`].v : ''
              AndonCode = this.worksheet[j][`AP${attr}`] ? this.worksheet[j][`AP${attr}`].v : ''
              AndonPort = this.worksheet[j][`AQ${attr}`] ? this.worksheet[j][`AQ${attr}`].v : ''
              isTherePrinter = this.worksheet[j][`AR${attr}`] ? this.worksheet[j][`AR${attr}`].v : ''
              printerPort = this.worksheet[j][`AS${attr}`] ? this.worksheet[j][`AS${attr}`].v : ''
              processNo = this.worksheet[j][`AT${attr}`] ? this.worksheet[j][`AT${attr}`].v : ''
              processName = this.worksheet[j][`AU${attr}`] ? this.worksheet[j][`AU${attr}`].v : ''
              isThereComputer = this.worksheet[j][`AV${attr}`] ? this.worksheet[j][`AV${attr}`].v : ''
              isThereData = this.worksheet[j][`AW${attr}`] ? this.worksheet[j][`AW${attr}`].v : ''
              enableMES = this.worksheet[j][`AX${attr}`] ? this.worksheet[j][`AX${attr}`].v : ''
              onlineStatus = this.worksheet[j][`AY${attr}`] ? this.worksheet[j][`AY${attr}`].v : ''
              whetherSaveData = this.worksheet[j][`AZ${attr}`] ? this.worksheet[j][`AZ${attr}`].v : ''
              whetherMonitor = this.worksheet[j][`BA${attr}`] ? this.worksheet[j][`BA${attr}`].v : ''
              repairStationNo = this.worksheet[j][`BB${attr}`] ? this.worksheet[j][`BB${attr}`].v : ''
              workStepAttribute = this.worksheet[j][`BC${attr}`] ? this.worksheet[j][`BC${attr}`].v : ''
              MesServerCode = this.worksheet[j][`BD${attr}`] ? this.worksheet[j][`BD${attr}`].v : ''
              MesDll = this.worksheet[j][`BE${attr}`] ? this.worksheet[j][`BE${attr}`].v : ''
              MesWebCode = this.worksheet[j][`BF${attr}`] ? this.worksheet[j][`BF${attr}`].v : ''
              orderSelectionPermission = this.worksheet[j][`BG${attr}`] ? this.worksheet[j][`BG${attr}`].v : ''
              theServerIP = this.worksheet[j][`BH${attr}`] ? this.worksheet[j][`BH${attr}`].v : ''
              BarVersion = this.worksheet[j][`BI${attr}`] ? this.worksheet[j][`BI${attr}`].v : ''
              monitoringAttributeCode = this.worksheet[j][`BJ${attr}`] ? this.worksheet[j][`BJ${attr}`].v : ''
              IP = this.worksheet[j][`BK${attr}`] ? this.worksheet[j][`BK${attr}`].v : ''
              numberAlarms = this.worksheet[j][`BL${attr}`] ? this.worksheet[j][`BL${attr}`].v : ''
              numberQualityGroups = this.worksheet[j][`BM${attr}`] ? this.worksheet[j][`BM${attr}`].v : ''
              console.log(stationCode,
                stationNumber,
                guideStationNumber,
                machineType,
                stationName,
                lineType,
                QRcodeScannGun,
                fixedBarcodeScannGun,
                handheldBarcodeScannGun,
                PC,
                nameIndustrialComputer,
                ipIndustrialComputer,
                communicationPort,
                fileName,
                PLC,
                PLCCode,
                PLCState,
                PLCCodeState,
                engineModelCodeSynthesis,
                dailyPlannedOutput,
                preparationTime,
                machineTime,
                laborTime,
                technicalDifficultyCoefficient,
                whetherLineHead,
                branchMaterialTrackingStation,
                busOnlineStation,
                busMonitoredStation,
                scanningGunType,
                stationType,
                DFCBMTS,
                BOSDFC,
                OpcServer,
                OpcServer_MIS,
                OpcServer_OPNAME,
                TargetCycleTime,
                WorkpieceType,
                basicOperationInstructionsStation,
                stationUpperLowerLineType,
                largeScreenCode,
                largeScreenDisplayOutputPort,
                AndonCode,
                AndonPort,
                isTherePrinter,
                printerPort,
                processNo,
                processName,
                isThereComputer,
                isThereData,
                enableMES,
                onlineStatus,
                whetherSaveData,
                whetherMonitor,
                repairStationNo,
                workStepAttribute,
                MesServerCode,
                MesDll,
                MesWebCode,
                orderSelectionPermission,
                theServerIP,
                BarVersion,
                monitoringAttributeCode,
                IP,
                numberAlarms,
                numberQualityGroups)
              if (!stationCode && !stationNumber && !guideStationNumber && !machineType && !stationName && !lineType) {
                break
              } else if (!stationNumber) { // 名称不能为空
                this.$notify.error(this.$t('stationInformationMaintenance.stationNumberRequired'))
                break
              } else {
                if (stationNumber) {
                  await sleep(50)
                  await this.insertToSQL(stationCode,
                    stationNumber,
                    guideStationNumber,
                    machineType,
                    stationName,
                    lineType,
                    QRcodeScannGun,
                    fixedBarcodeScannGun,
                    handheldBarcodeScannGun,
                    PC,
                    nameIndustrialComputer,
                    ipIndustrialComputer,
                    communicationPort,
                    fileName,
                    PLC,
                    PLCCode,
                    PLCState,
                    PLCCodeState,
                    engineModelCodeSynthesis,
                    dailyPlannedOutput,
                    preparationTime,
                    machineTime,
                    laborTime,
                    technicalDifficultyCoefficient,
                    whetherLineHead,
                    branchMaterialTrackingStation,
                    busOnlineStation,
                    busMonitoredStation,
                    scanningGunType,
                    stationType,
                    DFCBMTS,
                    BOSDFC,
                    OpcServer,
                    OpcServer_MIS,
                    OpcServer_OPNAME,
                    TargetCycleTime,
                    WorkpieceType,
                    basicOperationInstructionsStation,
                    stationUpperLowerLineType,
                    largeScreenCode,
                    largeScreenDisplayOutputPort,
                    AndonCode,
                    AndonPort,
                    isTherePrinter,
                    printerPort,
                    processNo,
                    processName,
                    isThereComputer,
                    isThereData,
                    enableMES,
                    onlineStatus,
                    whetherSaveData,
                    whetherMonitor,
                    repairStationNo,
                    workStepAttribute,
                    MesServerCode,
                    MesDll,
                    MesWebCode,
                    orderSelectionPermission,
                    theServerIP,
                    BarVersion,
                    monitoringAttributeCode,
                    IP,
                    numberAlarms,
                    numberQualityGroups)
                } else {
                  this.loading = false
                  this.disabled = false
                  this.$notify.error(this.$t('stationInformationMaintenance.confirmImportFile'))
                  return
                }
              }
            }
          }
          this.itemFile.splice(j, 1)
          this.worksheet.splice(j, 1)
          this.err === 0
            ? this.$message.success(this.$t('stationInformationMaintenance.importCompleted'))
            : this.$message.error(`${this.$t('stationInformationMaintenance.importFailedCountPrefix')}${this.err}${this.$t('stationInformationMaintenance.importFailedCountSuffix')}`)
        }
        this.loading = false
        this.searchTable()
      } catch (e) {
        this.err++
        this.loading = false
        this.$notify.error(this.$t('stationInformationMaintenance.importDataErrorFile'))
        console.log(`导入数据错误${e}`)
      }
    },
    async insertToSQL(stationCode,
      stationNumber,
      guideStationNumber,
      machineType,
      stationName,
      lineType,
      QRcodeScannGun,
      fixedBarcodeScannGun,
      handheldBarcodeScannGun,
      PC,
      nameIndustrialComputer,
      ipIndustrialComputer,
      communicationPort,
      fileName,
      PLC,
      PLCCode,
      PLCState,
      PLCCodeState,
      engineModelCodeSynthesis,
      dailyPlannedOutput,
      preparationTime,
      machineTime,
      laborTime,
      technicalDifficultyCoefficient,
      whetherLineHead,
      branchMaterialTrackingStation,
      busOnlineStation,
      busMonitoredStation,
      scanningGunType,
      stationType,
      DFCBMTS,
      BOSDFC,
      OpcServer,
      OpcServer_MIS,
      OpcServer_OPNAME,
      TargetCycleTime,
      WorkpieceType,
      basicOperationInstructionsStation,
      stationUpperLowerLineType,
      largeScreenCode,
      largeScreenDisplayOutputPort,
      AndonCode,
      AndonPort,
      isTherePrinter,
      printerPort,
      processNo,
      processName,
      isThereComputer,
      isThereData,
      enableMES,
      onlineStatus,
      whetherSaveData,
      whetherMonitor,
      repairStationNo,
      workStepAttribute,
      MesServerCode,
      MesDll,
      MesWebCode,
      orderSelectionPermission,
      theServerIP,
      BarVersion,
      monitoringAttributeCode,
      IP,
      numberAlarms,
      numberQualityGroups) {
      try {
        var param = []
        param[0] = ['工位代码', stationCode]
        param[1] = ['工位号', stationNumber]
        param[2] = ['指南工位号', guideStationNumber]
        param[3] = ['机床类型', machineType]
        param[4] = ['工位名称', stationName]
        param[5] = ['线体类型', lineType]
        param[6] = ['二维码扫描枪', QRcodeScannGun]
        param[7] = ['固定条形码扫描枪', fixedBarcodeScannGun]
        param[8] = ['手持条形码扫描枪', handheldBarcodeScannGun]
        param[9] = ['PC', PC]
        param[10] = ['工控机名称', nameIndustrialComputer]
        param[11] = ['工控机IP', ipIndustrialComputer]
        param[12] = ['通讯端口', communicationPort]
        param[13] = ['文件名称', fileName]
        param[14] = ['PLC', PLC]
        param[15] = ['PLC代码', PLCCode]
        param[16] = ['PLC加工状态', PLCState]
        param[17] = ['PLC代码加工状态', PLCCodeState]
        param[18] = ['发动机型号代码合成', engineModelCodeSynthesis]
        param[19] = ['日计划产量', dailyPlannedOutput]
        param[20] = ['准备时间', preparationTime]
        param[21] = ['机器时间', machineTime]
        param[22] = ['人工时间', laborTime]
        param[23] = ['技术难度系数', technicalDifficultyCoefficient]
        param[24] = ['是否线首', whetherLineHead]
        param[25] = ['分线物料追踪工位', branchMaterialTrackingStation]
        param[26] = ['总线上线工位', busOnlineStation]
        param[27] = ['总线被监测工位', busMonitoredStation]
        param[28] = ['扫描枪类型', scanningGunType]
        param[29] = ['工位类型', stationType]
        param[30] = ['分线物料追踪工位数据文件连接', DFCBMTS]
        param[31] = ['总线上线工位数据文件连接', BOSDFC]
        param[32] = ['OpcServer', OpcServer]
        param[33] = ['OpcServer_MIS', OpcServer_MIS]
        param[34] = ['OpcServer_OPNAME', OpcServer_OPNAME]
        param[35] = ['目标循环时间', TargetCycleTime]
        param[36] = ['工件类型', WorkpieceType]
        param[37] = ['工位基本操作指导', basicOperationInstructionsStation]
        param[38] = ['工位基本指导图片', null]
        param[39] = ['工位上下线类型', stationUpperLowerLineType]
        param[40] = ['大屏幕代码', largeScreenCode]
        param[41] = ['大屏幕显示产量端口', largeScreenDisplayOutputPort]
        param[42] = ['大屏幕显示Andon大屏幕代码', AndonCode]
        param[43] = ['大屏幕显示Andon端口', AndonPort]
        param[44] = ['是否有打印机', isTherePrinter]
        param[45] = ['打印机通讯端口', printerPort]
        param[46] = ['工序号', processNo]
        param[47] = ['工序名称', processName]
        param[48] = ['是否有工位计算机', isThereComputer]
        param[49] = ['是否有测量数据', isThereData]
        param[50] = ['是否启用MES', enableMES]
        param[51] = ['在线状态', onlineStatus]
        param[52] = ['是否通过监控系统保存数据', whetherSaveData]
        param[53] = ['是否监控', whetherMonitor]
        param[54] = ['返修工位号', repairStationNo]
        param[55] = ['工步属性', workStepAttribute]
        param[56] = ['MesServerCode', MesServerCode]
        param[57] = ['MesDll', MesDll]
        param[58] = ['MesWebCode', MesWebCode]
        param[59] = ['订单选择权限', orderSelectionPermission]
        param[60] = ['服务器IP', theServerIP]
        param[61] = ['Bar版本号', BarVersion]
        param[62] = ['监控属性代码', monitoringAttributeCode]
        param[63] = ['IP', IP]
        param[64] = ['报警数', numberAlarms]
        param[65] = ['质量组数', numberQualityGroups]
        param[66] = ['导入类型', '1', 'int', '1']
        var Data = this.CreateData('12', '基础数据_工位信息维护_导入', param)
        const response = await this.ExecDatabase(Data)
        const res = response.data
        if (Object.prototype.hasOwnProperty.call(res, 'output') === false) {
          if (res[0].result === '0') {
            this.$notify.error(`${stationNumber}${this.$t('stationInformationMaintenance.importFailedForStation')}`)
          }
        } else {
          if (res.result[0].result === '0') {
            this.$notify.error(`${stationNumber}${this.$t('stationInformationMaintenance.importFailedForStation')}`)
          }
          if (res.output[0].导入类型 === '2') {
            this.$notify.warning(`${stationNumber}${this.$t('stationInformationMaintenance.duplicateDataForStation')}`)
          }
        }
      } catch (e) {
        this.err++
        this.$message.error(this.$t('stationInformationMaintenance.importDataError'))
        console.log(`导入数据错误${e}`)
      }
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.pageCurrent = 1
      this.searchTable()
    },
    handleCurrentChange(val) {
      this.pageCurrent = val
      this.searchTable()
    }
  }
}
</script>

<style scoped>
::v-deep.el-input__inner{
  padding: 0 3px!important;
}
::v-deep.el-form-item{
  margin-bottom: 15px!important;
}
::v-deep.el-drawer.rtl{
  overflow: scroll;
}
/*1.显示滚动条：当内容超出容器的时候，可以拖动：*/
::v-deep.el-drawer__body {
  overflow: auto;
  /* overflow-x: auto; */
}

/*2.隐藏滚动条，太丑了*/
::v-deep.el-drawer__container ::-webkit-scrollbar{
  display: none;
}
</style>
