<template>
  <div class="app-container">
    <el-card class="topCard">
      <el-row>
        <el-col :span="7">
          <div class="topDiv">
            <el-row style="margin-top: 10px">
              <span style="margin-left: 10px">工位号：</span>
              <el-select v-model="stationNumberValue" placeholder="请选择工位号" size="small" style="width: 240px;margin-left: 13px">
                <el-option
                  v-for="item in stationNumber"
                  :key="item.value"
                  :label="`【${item.value}】${item.label}`"
                  :value="item.value"
                  size="mini"/>
              </el-select>
            </el-row>
            <el-row style="margin-top: 10px">
              <span style="margin-left: 10px">产品型号：</span>
              <el-select v-model="engineTypeValue" placeholder="请选择产品型号" size="small" style="width: 240px">
                <el-option
                  v-for="item in engineType"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                  size="mini"/>
              </el-select>
              <el-button type="primary" icon="el-icon-search" plain size="small" style="" @click="searchTable();searchTable1()">查询</el-button>
            </el-row>
            <div style="border: 1px solid #bfbfbf;margin-top: 20px;padding-bottom: 10px;border-radius: 5px;">
              <div style="height: 40px;display: flex;align-items: center;justify-content: center;margin-top: -20px;">
                <span style="background: #fff;padding: 0 10px">控件设定</span>
              </div>
              <div>
                <el-form ref="form" :model="form" :rules="rules" label-position="right" label-width="120px">
                  <el-row>
                    <el-col :span="12">
                      <el-form-item label="工作顺序：" prop="groupNumber" style="display: inline-block">
                        <el-input-number v-model="form.groupNumber" :min="1" size="mini" controls-position="right" style="width: 120px"/>
                      </el-form-item>
                    </el-col>
                    <el-col :span="10">
                      <el-form-item label="套筒号：" prop="sleeveNumber:" style="display: inline-block">
                        <el-input-number v-model="form.sleeveNumber" :min="1" size="mini" controls-position="right" style="width: 120px"/>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-form-item label="控件类型：" prop="measureType" style="display: inline-block">
                    <el-radio-group v-model="form.measureType" size="mini">
                      <el-radio :label="1">样式1</el-radio>
                      <el-radio :label="2">样式2</el-radio>
                      <el-radio :label="3">样式3</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="控件位置(XY)：" prop="positionX" style="display: inline-block">
                    <el-input-number v-model="form.positionX" :min="0" size="mini" controls-position="right" style="width: 120px"/>
                    <el-input-number v-model="form.positionY" :min="0" size="mini" controls-position="right" style="width: 120px"/>
                  </el-form-item>
                  <el-form-item label="控件宽高(WH)：" prop="measureWidth" style="display: inline-block">
                    <el-input-number v-model="form.measureWidth" :min="0" size="mini" controls-position="right" style="width: 120px"/>
                    <el-input-number v-model="form.measureHeight" :min="0" size="mini" controls-position="right" style="width: 120px"/>
                  </el-form-item>
                  <el-form-item label="工作说明：" prop="explain" style="display: inline-block">
                    <el-input v-model="form.explain" clearable size="small"/>
                  </el-form-item>
                  <el-form-item>
                    <el-button :disabled="!showFunButton" type="success" plain icon="el-icon-edit" size="small" style="" @click="submitUpdate">修改</el-button>
                    <el-button :disabled="!showFunButton" type="danger" plain icon="el-icon-delete" size="small" style="" @click="deleteInformation">删除</el-button>
                  </el-form-item>
                </el-form>
              </div>
            </div>
          </div>
        </el-col>
        <el-col :span="16" style="margin-left: 10px">
          <div v-if="showFunButton">
            <el-button v-if="urls.length === 0" type="primary" size="mini" icon="el-icon-plus" @click="addTo">增加</el-button>
            <el-button v-if="urls.length > 0" type="warning" size="mini" icon="el-icon-edit" @click="addTo">修改</el-button>
            <el-button v-if="urls.length > 0" type="danger" size="mini" icon="el-icon-delete" @click="deletePic">删除</el-button>
            <span>建议图片尺寸：宽*高（817*460）</span>
          </div>
          <div v-else style="height: 29px">
            <span>建议图片尺寸：宽*高（817*460）</span>
          </div>
          <div style="border: 1px solid #bfbfbf;width: 830px;height: 470px;margin-top: 10px;border-radius: 5px;padding: 4px">
            <div v-for="(url, key) in urls" :key="key" style="position: absolute;z-index: 1;" @click="getMouseXY($event)">
              <img :key="urls[0].url" :src="urls[0].url" width="817px" height="460px">
            </div>
            <div v-for="(item, index) in tableData" v-show="allowView" :key="item + index" style="position: absolute;z-index: 2;text-align: center">
              <img
                v-if="Number(item.控件类型) === 1"
                :style="{width: item.控件宽度 + 'px', height:item.控件高度 + 'px',left: item.测量位置X + 'px', top: item.测量位置Y + 'px'}"
                :src="require('@/assets/img/green.png')"
                style="position: absolute">
              <img
                v-if="Number(item.控件类型) === 2"
                :style="{width: item.控件宽度 + 'px', height:item.控件高度 + 'px',left: item.测量位置X + 'px', top: item.测量位置Y + 'px'}"
                :src="require('@/assets/img/gray.png')"
                style="position: absolute">
              <img
                v-if="Number(item.控件类型) === 3"
                :style="{width: item.控件宽度 + 'px', height:item.控件高度 + 'px',left: item.测量位置X + 'px', top: item.测量位置Y + 'px'}"
                :src="require('@/assets/img/init1.png')"
                style="position: absolute">
              <div :style="{left: (item.测量位置X + item.控件宽度 / 3) + 'px', top: (item.测量位置Y + item.控件高度 / 4) + 'px'}" style="position: absolute;color: #fff">{{ item.组号 }}</div>
            </div>
            <div v-show="singleView" style="position: absolute;z-index: 2;">
              <img
                v-if="Number(form.measureType) === 1"
                :style="{width: form.measureWidth + 'px', height:form.measureHeight + 'px',left: form.positionX + 'px', top: form.positionY + 'px'}"
                :src="require('@/assets/img/green.png')"
                style="position: absolute">
              <img
                v-if="Number(form.measureType) === 2"
                :style="{width: form.measureWidth + 'px', height:form.measureHeight + 'px',left: form.positionX + 'px', top: form.positionY + 'px'}"
                :src="require('@/assets/img/gray.png')"
                style="position: absolute">
              <img
                v-if="Number(form.measureType) === 3"
                :style="{width: form.measureWidth + 'px', height:form.measureHeight + 'px',left: form.positionX + 'px', top: form.positionY + 'px'}"
                :src="require('@/assets/img/init1.png')"
                style="position: absolute">
              <div :style="{left: (form.positionX + form.measureWidth / 3) + 'px', top: (form.positionY + form.measureHeight / 5) + 'px', fontSize: form.measureHeight / 2 + 'px'}" style="position: absolute;color: #fff">{{ form.groupNumber }}</div>
            </div>
          </div>
        </el-col>
      </el-row>
      <el-row style="">
        <el-button :disabled="!showFunButton" type="primary" icon="el-icon-circle-plus-outline" size="small" @click="submitAdd('form')">新建拧紧操作</el-button>
        <el-button :disabled="!showFunButton" type="success" size="small" plain icon="el-icon-document-copy" @click="copyOrder('form4')">复制工步</el-button>
        <el-button :disabled="!showFunButton" type="warning" plain size="small" icon="el-icon-view" @click="viewAllow()">预览全部</el-button>
        <el-button :disabled="!showFunButton" type="danger" plain size="small" icon="el-icon-delete" @click="clearAll()">清除预览</el-button>
        <el-table
          ref="multipleTable"
          :data="tableData"
          :cell-class-name="tableRowClassName"
          highlight-current-row
          height="300px"
          style="width: 1300px"
          border
          size="mini"
          @row-click="rowClick">
          <!--          <el-table-column align="center" width="70px" label="序号">-->
          <!--            <template slot-scope="scope">-->
          <!--              {{ scope.row.序号 }}-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column align="center" width="120px" label="工作顺序">
            <template slot-scope="scope">
              {{ scope.row.组号 }}
            </template>
          </el-table-column>
          <!--          <el-table-column align="center" width="80px" label="工作顺序">-->
          <!--            <template slot-scope="scope">-->
          <!--              {{ scope.row.工作顺序 }}-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column align="center" label="套筒号" width="120px">
            <template slot-scope="scope">
              {{ scope.row.套筒号 }}
            </template>
          </el-table-column>
          <el-table-column align="center" label="控件位置X" width="150px">
            <template slot-scope="scope">
              {{ scope.row.测量位置X }}
            </template>
          </el-table-column>
          <el-table-column align="center" label="控件位置Y" width="150px">
            <template slot-scope="scope">
              {{ scope.row.测量位置Y }}
            </template>
          </el-table-column>
          <el-table-column align="center" label="控件高度W" width="150px">
            <template slot-scope="scope">
              {{ scope.row.控件高度 }}
            </template>
          </el-table-column>
          <el-table-column align="center" label="控件宽度H" width="150px">
            <template slot-scope="scope">
              {{ scope.row.控件宽度 }}
            </template>
          </el-table-column>
          <!--          <el-table-column align="center" label="扭矩">-->
          <!--            <template slot-scope="scope">-->
          <!--              {{ scope.row.扭矩 }}-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column align="center" label="工作说明">
            <template slot-scope="scope">
              {{ scope.row.说明 }}
            </template>
          </el-table-column>
        </el-table>
      </el-row>
    </el-card>
    <el-dialog :visible.sync="dialogFormVisible4" title="数据复制" center style="min-height: 200px" width="400px">
      <el-form ref="form1" :model="form4" :rules="rules4" label-position="right" label-width="110px">
        <el-form-item label="工位号" prop="stationNumberValue" style="display: inline-block">
          <el-select v-model="form4.stationNumberValue" placeholder="请选择工位号" size="small" style="width: 240px">
            <el-option
              v-for="item in stationNumber"
              :key="item.value"
              :label="`【${item.value}】${item.label}`"
              :value="item.value"
              size="mini"/>
          </el-select>
        </el-form-item>
        <el-form-item label="产品型号" prop="engineTypeValue" style="display: inline-block">
          <el-select v-model="form4.engineTypeValue" placeholder="请选择产品型号" size="small">
            <el-option
              v-for="item in engineType"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              size="mini"/>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="callOff4()">取消</el-button>
        <el-button type="primary" size="small" @click="submitAdd4()">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog v-el-drag-dialog :visible.sync="dialogFormVisible" title="上传图片" center width="300px">
      <el-upload
        id="invoiceScan"
        ref="upload"
        :on-remove="handelLimitStyle"
        :on-change="handelLimit"
        :multiple="true"
        :auto-upload="false"
        :on-success="uploadSuccess"
        :on-preview="handlePictureCardPreview"
        :before-upload="beforeUpload"
        :on-exceed="warningExceed"
        :limit="limit"
        :data="Data"
        :action="upload"
        accept=".png,.jpg"
        style="margin-left: 60px"
        list-type="picture-card">
        <i class="el-icon-plus"/>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible=false">取消</el-button>
        <el-button type="primary" style="width: 70px" @click="submitPicture()">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible2" center title="预览图片">
      <img :src="dialogImageUrl" width="100%" alt="">
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { url } from '@/utils/request'
export default {
  data() {
    return {
      urls: [], // 图片数组
      urls1: [], // 图片数组
      action: '',
      showFunButton: false,
      showFileList: false,
      hadFile: [
      ],
      fileList: [],
      fileName: '',
      fileName1: '',
      tableData: [], // 总数据数组
      stationNumber: [],
      stationNumberValue: '',
      stationName: '',
      moduleDescription: [],
      moduleDescriptionValue: '',
      engineTypeValue: '',
      engineTypeValue1: '',
      engineTypeName: '',
      engineType: [],
      isDisableValue: 0,
      labelText: '',
      labelNumber: '',
      title: '',
      allowView: false,
      singleView: false,
      MID: '',
      form: {
        serialNumber: 1,
        groupNumber: 1,
        orderNumber: 1,
        sleeveNumber: 1,
        torque: '105N.m',
        positionX: 100,
        positionY: 100,
        measureWidth: 30,
        measureHeight: 30,
        measureType: 1,
        explain: ''
      },
      rules: {
      },
      upload: url,
      limit: 1,
      Data: {},
      dialogFormVisible: false,
      dialogFormVisible2: false,
      dialogFormVisible4: false,
      dialogImageUrl: [],
      form4: {
        engineTypeValue: '',
        stationNumberValue: ''
      },
      rules4: { // 订单下发验证
        engineTypeValue: [{ required: true, message: '请选择机型', trigger: 'blur' }],
        stationNumberValue: [{ required: true, message: '请选择工位号', trigger: 'blur' }]
      }
    }
  },
  computed: {
    ...mapGetters([
      'id',
      'token',
      'departmentName'
    ])
  },
  watch: {
  },
  created() {
    this.getStationNumber()
    this.getEndStation()
  },
  methods: {
    getStationNumber() {
      this.stationNumber = []
      var param = []
      var Data = this.CreateData('11', 'MES_计划BOM_工位与名称_查询', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          this.stationNumberValue = response.data[0].工位号
        }
        for (let i = 0; i < response.data.length; i++) {
          this.stationNumber.push({
            label: response.data[i].工位名称,
            value: response.data[i].工位号
          })
        }
      })
    },
    // 初始化获取产品型号
    getEndStation() {
      this.engineType = []
      var param = []
      var Data = this.CreateData('11', 'MES_基本变量_机型代码_查询', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          this.engineTypeValue = response.data[0].发动机机型标志
        }
        for (let i = 0; i < response.data.length; i++) {
          this.engineType.push({
            label: response.data[i].发动机型号,
            value: response.data[i].发动机机型标志
          })
        }
      })
    },
    searchTable() {
      this.showFunButton = false
      this.urls = []
      this.urls1 = []
      var param = []
      param[0] = ['产品型号代码', this.engineTypeValue]
      param[1] = ['工位号', this.stationNumberValue]
      var Data = this.CreateData('11', '电子看板_工位机型_质量数据测量位置_图片_查询', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          if (response.data[0].产品图片) {
            this.urls.push({
              url: 'data:image/png;base64,' + response.data[0].产品图片,
              id: response.data[0].id
            })
            this.urls1.push('data:image/png;base64,' + response.data[0].产品图片)
          }
        }
        this.showFunButton = true
      })
    },
    searchTable1() {
      this.tableData = []
      var param = []
      param[0] = ['产品型号代码', this.engineTypeValue]
      param[1] = ['工位号', this.stationNumberValue]
      var Data = this.CreateData('11', '电子看板_工位机型_质量数据测量位置_查询', param)
      this.ExecDatabase(Data).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          console.log(response.data, 'response.data')
          if (response.data) {
            this.tableData = response.data
          }
        }
      })
    },
    copyOrder(formName) {
      if (this.tableData.length) {
        if (this.$refs[formName] !== undefined) {
          this.$refs[formName].resetFields()
        }
        this.dialogFormVisible4 = true
      } else {
        this.$message({
          message: '暂无可复制的数据！',
          type: 'error'
        })
      }
    },
    async submitAdd4() {
      let serialNumber, positionX, positionY, measureWidth, measureHeight, groupNumber, orderNumber, sleeveNumber, torque, measureType, explain
      for (let i = 0; i < this.tableData.length; i++) {
        serialNumber = this.tableData[i].序号
        positionX = this.tableData[i].测量位置X
        positionY = this.tableData[i].测量位置Y
        measureWidth = this.tableData[i].控件宽度
        measureHeight = this.tableData[i].控件高度
        groupNumber = this.tableData[i].组号
        orderNumber = this.tableData[i].工作顺序
        sleeveNumber = this.tableData[i].套筒号
        torque = this.tableData[i].扭矩
        measureType = this.tableData[i].控件类型
        explain = this.tableData[i].说明
        await this.submitAdd5(serialNumber, positionX, positionY, measureWidth, measureHeight, groupNumber, orderNumber, sleeveNumber, torque, measureType, explain)
      }
      this.$message({
        message: '增加成功',
        type: 'success'
      })
      this.dialogFormVisible4 = false
      this.engineTypeValue = this.form4.engineTypeValue
      this.stationNumberValue = this.form4.stationNumberValue
      this.searchTable()
      this.searchTable1()
    },
    async submitAdd5(serialNumber, positionX, positionY, measureWidth, measureHeight, groupNumber, orderNumber, sleeveNumber, torque, measureType, explain) {
      var param = []
      param[0] = ['工位号', this.form4.stationNumberValue]
      param[1] = ['产品型号代码', this.form4.engineTypeValue]
      param[2] = ['序号', serialNumber]
      param[3] = ['测量位置X', positionX]
      param[4] = ['测量位置Y', positionY]
      param[5] = ['控件宽度', measureWidth]
      param[6] = ['控件高度', measureHeight]
      param[7] = ['组号', groupNumber]
      param[8] = ['工作顺序', orderNumber]
      param[9] = ['套筒号', sleeveNumber]
      param[10] = ['扭矩', torque]
      param[11] = ['控件类型', measureType]
      param[12] = ['说明', explain]
      console.log(param)
      var Data = this.CreateData('12', '电子看板_工位机型_质量数据测量位置_增加', param)
      return new Promise((resolve, reject) => {
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            resolve(1)
          } else {
            reject(2)
          }
        })
      })
    },
    callOff4() {
      this.dialogFormVisible4 = false
    },
    submitAdd(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$confirm('您正在添加拧紧位置信息, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            let isHave = false
            for (let i = 0; i < this.tableData.length; i++) {
              if (this.form.groupNumber === this.tableData[i].组号) {
                isHave = true
                break
              }
            }
            if (isHave) {
              this.$message({
                message: '工作顺序重复，请重新输入！',
                type: 'error'
              })
              return false
            }

            var param = []
            param[0] = ['工位号', this.stationNumberValue]
            param[1] = ['产品型号代码', this.engineTypeValue]
            param[2] = ['序号', this.form.serialNumber]
            param[3] = ['测量位置X', this.form.positionX]
            param[4] = ['测量位置Y', this.form.positionY]
            param[5] = ['控件宽度', this.form.measureWidth]
            param[6] = ['控件高度', this.form.measureHeight]
            param[7] = ['组号', this.form.groupNumber]
            param[8] = ['工作顺序', this.form.orderNumber]
            param[9] = ['套筒号', this.form.sleeveNumber]
            param[10] = ['扭矩', this.form.torque]
            param[11] = ['控件类型', this.form.measureType]
            param[12] = ['说明', this.form.explain]
            console.log(param)
            var Data = this.CreateData('12', '电子看板_工位机型_质量数据测量位置_增加', param)
            this.ExecDatabase(Data).then(response => {
              if (response.data[0].result === '1') {
                this.$message({
                  message: '增加成功',
                  type: 'success'
                })
                this.dialogFormVisible = false
                this.searchTable1()
              } else {
                this.$message.error('增加失败！')
              }
            })
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消增加'
            })
          })
        } else {
          return false
        }
      })
    },
    submitUpdate() {
      if (this.MID) {
        this.$confirm('您正在修改拧紧位置信息, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          var param = []
          param[0] = ['工位号', this.stationNumberValue]
          param[1] = ['产品型号代码', this.engineTypeValue]
          param[2] = ['序号', this.form.serialNumber]
          param[3] = ['测量位置X', this.form.positionX]
          param[4] = ['测量位置Y', this.form.positionY]
          param[5] = ['控件宽度', this.form.measureWidth]
          param[6] = ['控件高度', this.form.measureHeight]
          param[7] = ['组号', this.form.groupNumber]
          param[8] = ['工作顺序', this.form.orderNumber]
          param[9] = ['套筒号', this.form.sleeveNumber]
          param[10] = ['扭矩', this.form.torque]
          param[11] = ['控件类型', this.form.measureType]
          param[12] = ['说明', this.form.explain]
          param[13] = ['ID', this.MID]
          console.log(param)
          var Data = this.CreateData('12', '电子看板_工位机型_质量数据测量位置_修改', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: '修改成功',
                type: 'success'
              })
              this.dialogFormVisible = false
              this.searchTable1()
              this.MID = ''
            } else {
              this.$message.error('修改失败！')
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消修改'
          })
        })
      } else {
        this.$message.error('请选择信息后修改！')
      }
    },
    deleteInformation() {
      if (this.MID) {
        this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          var param = []
          param[0] = ['ID', this.MID]
          var Data = this.CreateData('12', '电子看板_工位机型_质量数据测量位置_删除', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: '删除成功',
                type: 'success'
              })
              this.searchTable1()
              this.MID = ''
            } else {
              this.$message.error('删除失败！')
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      } else {
        this.$message.error('请选择信息后删除！')
      }
    },
    viewAllow() {
      this.allowView = true
      this.singleView = false
      this.MID = ''
    },
    clearAll() {
      this.allowView = false
      this.singleView = false
      this.MID = ''
    },
    getMouseXY(e) {
      if (this.allowView) {
        return
      } else {
        // console.log(e, 'e')
        console.log(e.offsetX, e.offsetY)
        this.form.positionX = e.offsetX
        this.form.positionY = e.offsetY
      }
    },
    // 表格颜色变
    tableRowClassName({ row, rowIndex }) {
      // console.log(row, rowIndex)
      if (rowIndex % 2 === 0) {
        return 'black'
      } else {
        return 'red'
      }
    },
    rowClick(row) {
      this.form.serialNumber = row.序号
      this.form.groupNumber = row.组号
      this.form.orderNumber = row.工作顺序
      this.form.sleeveNumber = row.套筒号
      this.form.torque = row.扭矩
      this.form.positionX = row.测量位置X
      this.form.positionY = row.测量位置Y
      this.form.measureWidth = row.控件宽度
      this.form.measureHeight = row.控件高度
      this.form.measureType = row.控件类型
      this.form.explain = row.说明
      this.allowView = false
      this.singleView = true
      this.MID = row.ID
    },
    addTo() {
      this.dialogFormVisible = true
      var obj = document.getElementsByClassName('el-upload--picture-card')
      for (var i = 0; i < obj.length; i++) {
        obj[i].style.display = 'block'
      }
    },
    deletePic() {
      // 提示是否需要删除
      this.$confirm('此操作将永久删除该图片, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var param = []
        param[0] = ['发动机型号代码', this.engineTypeValue]
        param[1] = ['工位号', this.stationNumberValue]
        var Data = this.CreateData('12', '电子看板_工位机型_质量数据测量位置_图片_删除', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
            this.urls = []
            this.urls1 = []
            this.searchTable()
            this.searchTable1()
          } else {
            this.$message.error('删除失败！')
          }
        })
      })
    },
    handelLimit() {
      var obj = document.getElementsByClassName('el-upload--picture-card')
      if (obj[0].style.display === 'block' || obj[0].style.display === '') {
        for (var i = 0; i < obj.length; i++) {
          obj[i].style.display = 'none'
        }
      }
    },
    handelLimitStyle() {
      var obj = document.getElementsByClassName('el-upload--picture-card')
      if (obj[0].style.display === 'none') {
        for (var i = 0; i < obj.length; i++) {
          obj[i].style.display = 'block'
        }
      }
    },
    warningExceed() {
      this.$message.error('仅可上传一张照片')
    },
    beforeUpload(file) { // 上传前检测
      const isJPG = /^image\/.*/.test(file.type)
      if (!isJPG) {
        this.$message.error('只能上传图片。。')
      }
      return isJPG
    },
    uploadSuccess(res) { // 上传成功回调
      console.log('syccess')
      this.$refs.upload.clearFiles()
      var obj = document.getElementsByClassName('el-upload--picture-card')
      for (var i = 0; i < obj.length; i++) {
        obj[i].style.display = 'block'
      }
      this.searchTable()
      this.dialogFormVisible = false
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url
      this.dialogFormVisible2 = true
    },
    submitPicture() {
      var param = []
      param[0] = ['发动机型号代码', this.engineTypeValue]
      param[1] = ['工位号', this.stationNumberValue]
      param[2] = ['文件名称', '']
      param[3] = ['文件后缀', '']
      param[4] = ['文件内容', null]
      var Data1 = this.CreateData('15', '电子看板_工位机型_质量数据测量位置_图片_增加', param)
      this.Data.param = Data1
      this.$refs.upload.submit()
    }
  }
}
</script>

<style scoped>
  .topCard{
    margin: 5px;
  }
  .topDiv{
    margin-bottom: 10px;
  }

</style>
