<template>
    <div>
      <el-card style="height: 958px">
        <el-col :span="16">
          <span>设备名称</span>
          <el-input v-model="deviceName" style="width:250px;margin-left: 10px" clearable placeholder="设备名称"></el-input>
          <span style="margin-left: 5px">日期：</span>
          <el-date-picker v-model="deliveryDate" type="daterange" range-separator="至" start-placeholder="开始日期" value-format="yyyy-MM-dd" end-placeholder="结束日期" style="width:250px"/>
          <el-button :disabled="loading" type="success" plain icon="el-icon-search" style="margin-left: 10px" @click="searchTable()">查询</el-button>
          <el-button :disabled="loading" type="warning" plain icon="el-icon-plus" style="margin-left: 10px" @click="addMeasureData1">录入</el-button>
          <!--            <el-button :disabled="loading" type="warning" plain icon="el-icon-download" style="margin-left: 10px" @click="searchTable1()">导出</el-button>-->
          <div style="margin-top: 10px">
            <el-table
                v-loading="loading"
                :data="tableData"
                :header-cell-style="{background:'#F5F5F5'}"
                element-loading-text="数据加载中"
                element-loading-spinner="el-icon-loading"
                element-loading-background="rgba(0, 0, 0, 0.2)"
                tooltip-effect="dark"
                style="width: 100%"
                height="740"
                border
                highlight-current-row
                stripe>
              <el-table-column
                  type="index"
                  align="center"
                  width="50">
              </el-table-column>
              <el-table-column align="center" label="设备名称" width="90">
                <template slot-scope="scope">
                  {{ scope.row.设备名称 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="半壳零件号" min-width="80">
                <template slot-scope="scope">
                  {{ scope.row.半壳零件号 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="品种" min-width="60">
                <template slot-scope="scope">
                  {{ scope.row.半壳品种 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="测量项目名称" min-width="120">
                <template slot-scope="scope">
                  {{ scope.row.测量项目名称 }}
                  <br>
                  【{{ scope.row.下限 }} {{ scope.row.单位 }} ～ {{ scope.row.上限 }} {{ scope.row.单位 }}】
                </template>
              </el-table-column>
              <el-table-column align="center" label="测量值" min-width="80">
                <template slot-scope="scope">
                  {{ scope.row.测量值 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="首/中/末" min-width="80">
                <template slot-scope="scope">
                  {{ scope.row.测量模式 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="测量人员" min-width="80">
                <template slot-scope="scope">
                  {{ scope.row.测量人员 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="异常记录" min-width="80" show-overflow-tooltip>
                <template slot-scope="scope">
                  {{ scope.row.异常记录 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="其他类记录" min-width="90" show-overflow-tooltip>
                <template slot-scope="scope">
                  {{ scope.row.其他类记录 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="测量时间" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.操作时间 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="操作" width="80">
                <template slot-scope="scope">
                  <el-button type="text" icon="el-icon-edit" @click="addMeasureData2(scope.row)"></el-button>
                  <el-button type="text" style="color: #ff2b2b" icon="el-icon-delete" @click="deleteInformation2(scope.row)"></el-button>
                </template>
              </el-table-column>
            </el-table>
            <div class="block" style="margin-top: 10px;">
              <el-pagination
                  v-if="!loading"
                  :current-page="PageCurrent"
                  :page-sizes="[50, 70, 100, 150]"
                  :page-size="pageSize"
                  :total="total"
                  layout="total, sizes, prev, pager, next, jumper"
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"/>
            </div>
          </div>
        </el-col>
        <el-col :span="7" style="margin-left: 10px">
          <span>名称</span>
          <el-input v-model="measureDataName" style="width:200px;margin-left: 10px" clearable placeholder="测量项目名称"></el-input>
          <el-button :disabled="loading1" type="success" plain icon="el-icon-search" style="margin-left: 10px" @click="searchMeasureDataName()">查询</el-button>
          <el-button type="warning" plain icon="el-icon-plus" style="margin-left: 10px" @click="addMeasureData3">增加</el-button>
          <div style="margin-top: 10px">
            <el-table
                v-loading="loading1"
                :data="tableData1"
                :header-cell-style="{background:'#F5F5F5'}"
                element-loading-text="数据加载中"
                element-loading-spinner="el-icon-loading"
                element-loading-background="rgba(0, 0, 0, 0.2)"
                tooltip-effect="dark"
                style="width: 100%"
                height="740"
                border
                highlight-current-row
                stripe>
              <el-table-column
                  type="index"
                  align="center"
                  width="50">
              </el-table-column>
              <el-table-column align="center" label="测量项目名称" min-width="120">
                <template slot-scope="scope">
                  {{ scope.row.测量项目名称 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="单位" min-width="60">
                <template slot-scope="scope">
                  {{ scope.row.单位 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="上限" min-width="60">
                <template slot-scope="scope">
                  {{ scope.row.上限 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="下限" min-width="60">
                <template slot-scope="scope">
                  {{ scope.row.下限 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="操作" width="80">
                <template slot-scope="scope">
                  <el-button type="text" icon="el-icon-edit" @click="addMeasureData4(scope.row)"></el-button>
                  <el-button type="text" style="color: #ff2b2b" icon="el-icon-delete" @click="deleteInformation4(scope.row)"></el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-col>
      </el-card>
      <el-dialog :visible.sync="dialogFormVisible1" title="新增检测数据" center style="min-height: 200px;" width="750px">
        <el-form ref="form1" :model="form1" :rules="rules1" label-position="right" label-width="110px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="设备名称" prop="设备名称" style="display: inline-block">
                <el-select v-model="form1.设备编码" style="width:200px" placeholder="设备名称" @change="changeDeviceName">
                  <el-option
                      v-for="item in deviceNameList"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"/>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="测量人员" prop="测量人员" style="display: inline-block">
                <el-input v-model="form1.测量人员" style="width:200px;" clearable placeholder="请输入测量人员"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="半壳零件号" prop="半壳零件号" style="display: inline-block">
                <el-input v-model="form1.半壳零件号" style="width:200px;" clearable placeholder="请输入半壳零件号"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="半壳品种" prop="半壳品种" style="display: inline-block">
                <el-select v-model="form1.半壳品种" style="width:200px" placeholder="半壳品种">
                  <el-option
                      v-for="item in productList"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"/>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-form-item label="测量项目名称" prop="测量项目名称" style="display: inline-block">
              <el-select v-model="form1.测量项目代码" style="width:200px" placeholder="测量项目名称" @change="changeMeasureName">
                <el-option
                    v-for="item in measureDataList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
              </el-select>
              【{{form1.下限}} {{form1.单位}} ～ {{form1.上限}} {{form1.单位}}】
            </el-form-item>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="测量值" prop="测量值" style="display: inline-block">
                <el-input v-model="form1.测量值" style="width:200px;" clearable placeholder="请输入测量值"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="测量模式" prop="测量模式" style="display: inline-block">
                <el-radio-group v-model="form1.测量模式">
                  <el-radio-button size="mini" label="首件">首件</el-radio-button>
                  <el-radio-button size="mini" label="中件">中件</el-radio-button>
                  <el-radio-button size="mini" label="尾件">尾件</el-radio-button>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="异常记录" prop="异常记录" style="display: inline-block">
                <el-input v-model="form1.异常记录" style="width:200px;" clearable placeholder="请输入异常记录"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="其他类记录" prop="其他类记录" style="display: inline-block">
                <el-input v-model="form1.其他类记录" style="width:200px;" clearable placeholder="请输入其他类记录"/>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="callOff1('form1')">取消</el-button>
          <el-button type="success" plain @click="submitAdd1('form1')">确定</el-button>
        </div>
      </el-dialog>
      <el-dialog :visible.sync="dialogFormVisible2" title="编辑检测数据" center style="min-height: 200px;" width="750px">
        <el-form ref="form2" :model="form2" :rules="rules2" label-position="right" label-width="110px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="设备名称" prop="设备名称" style="display: inline-block">
                <el-select v-model="form2.设备编码" disabled style="width:200px" placeholder="设备名称" @change="changeDeviceName">
                  <el-option
                      v-for="item in deviceNameList"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"/>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="测量人员" prop="测量人员" style="display: inline-block">
                <el-input v-model="form2.测量人员" style="width:200px;" clearable placeholder="请输入测量人员"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="半壳零件号" prop="半壳零件号" style="display: inline-block">
                <el-input v-model="form2.半壳零件号" disabled style="width:200px;" clearable placeholder="请输入半壳零件号"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="半壳品种" prop="半壳品种" style="display: inline-block">
                <el-select v-model="form2.半壳品种" disabled style="width:200px" placeholder="半壳品种">
                  <el-option
                      v-for="item in productList"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"/>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-form-item label="测量项目名称" prop="测量项目名称" style="display: inline-block">
              <el-select v-model="form2.测量项目代码" disabled style="width:200px" placeholder="测量项目名称" @change="changeMeasureName">
                <el-option
                    v-for="item in measureDataList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
              </el-select>
              【{{form2.下限}} {{form2.单位}} ～ {{form2.上限}} {{form2.单位}}】
            </el-form-item>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="测量值" prop="测量值" style="display: inline-block">
                <el-input v-model="form2.测量值" style="width:200px;" clearable placeholder="请输入测量值"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="测量模式" prop="测量模式" style="display: inline-block">
                <el-radio-group disabled v-model="form2.测量模式">
                  <el-radio-button size="mini" label="首件">首件</el-radio-button>
                  <el-radio-button size="mini" label="中件">中件</el-radio-button>
                  <el-radio-button size="mini" label="尾件">尾件</el-radio-button>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="异常记录" prop="异常记录" style="display: inline-block">
                <el-input v-model="form2.异常记录" style="width:200px;" clearable placeholder="请输入异常记录"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="其他类记录" prop="其他类记录" style="display: inline-block">
                <el-input v-model="form2.其他类记录" style="width:200px;" clearable placeholder="请输入其他类记录"/>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="callOff2('form2')">取消</el-button>
          <el-button type="success" plain @click="submitAdd2('form2')">确定</el-button>
        </div>
      </el-dialog>
      <el-dialog :visible.sync="dialogFormVisible3" title="新增测量项目" center style="min-height: 200px;" width="400px">
        <el-form ref="form3" :model="form3" :rules="rules3" label-position="right" label-width="110px">
          <el-form-item label="测量项目名称" prop="测量项目名称" style="display: inline-block">
            <el-input v-model="form3.测量项目名称" style="width:200px;" clearable placeholder="请输入测量项目名称"/>
          </el-form-item>
          <el-form-item label="单位" prop="单位" style="display: inline-block">
            <el-input v-model="form3.单位" style="width:200px;" clearable placeholder="请输入单位"/>
          </el-form-item>
          <el-form-item label="上限" prop="上限" style="display: inline-block">
            <el-input v-model="form3.上限" style="width:200px;" clearable placeholder="请输入上限"/>
          </el-form-item>
          <el-form-item label="下限" prop="下限" style="display: inline-block">
            <el-input v-model="form3.下限" style="width:200px;" clearable placeholder="请输入下限"/>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="callOff3('form3')">取消</el-button>
          <el-button type="success" plain @click="submitAdd3('form3')">确定</el-button>
        </div>
      </el-dialog>
      <el-dialog :visible.sync="dialogFormVisible4" title="编辑测量项目" center style="min-height: 200px;" width="400px">
        <el-form ref="form4" :model="form4" :rules="rules4" label-position="right" label-width="110px">
          <el-form-item label="测量项目名称" prop="测量项目名称" style="display: inline-block">
            <el-input v-model="form4.测量项目名称" style="width:200px;" clearable placeholder="请输入测量项目名称"/>
          </el-form-item>
          <el-form-item label="单位" prop="单位" style="display: inline-block">
            <el-input v-model="form4.单位" style="width:200px;" clearable placeholder="请输入单位"/>
          </el-form-item>
          <el-form-item label="上限" prop="上限" style="display: inline-block">
            <el-input v-model="form4.上限" style="width:200px;" clearable placeholder="请输入上限"/>
          </el-form-item>
          <el-form-item label="下限" prop="下限" style="display: inline-block">
            <el-input v-model="form4.下限" style="width:200px;" clearable placeholder="请输入下限"/>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="callOff4('form4')">取消</el-button>
          <el-button type="success" plain @click="submitAdd4('form4')">确定</el-button>
        </div>
      </el-dialog>
    </div>
</template>
<script>
import { getNowTime2 } from '@/utils/tool'

export default {
  data() {
    return {
      dialogFormVisible1: false,
      dialogFormVisible2: false,
      dialogFormVisible3: false,
      dialogFormVisible4: false,
      deviceName: '',
      deviceNameList: [],
      productList: [],
      measureDataName: '',
      measureDataList: [],
      measureDataId: '',
      form1: {
        设备名称: '',
        设备编码: '',
        半壳零件号: '2401016-',
        半壳品种: '',
        测量项目名称: '',
        测量项目代码: '',
        单位: '',
        上限: '',
        下限: '',
        测量值: '',
        测量模式: '首件',
        测量人员: '',
        异常记录: '',
        其他类记录: ''
      },
      rules1: {
        设备名称: [{ required: true, message: '请输入设备名称', trigger: 'blur' }],
        半壳零件号: [{ required: true, message: '请输入半壳零件号', trigger: 'blur' }],
        半壳品种: [{ required: true, message: '请输入半壳品种', trigger: 'blur' }],
        测量项目名称: [{ required: true, message: '请输入测量项目名称', trigger: 'blur' }],
        测量值: [{ required: true, message: '请输入测量值', trigger: 'blur' }],
        测量模式: [{ required: true, message: '请输入测量模式', trigger: 'blur' }],
        测量人员: [{ required: true, message: '请输入测量人员', trigger: 'blur' }]
      },
      form2: {
        ID: '',
        设备名称: '',
        设备编码: '',
        半壳零件号: '2401016-',
        半壳品种: '',
        测量项目名称: '',
        测量项目代码: '',
        单位: '',
        上限: '',
        下限: '',
        测量值: '',
        测量模式: '首件',
        测量人员: '',
        异常记录: '',
        其他类记录: ''
      },
      rules2: {
        设备名称: [{ required: true, message: '请输入设备名称', trigger: 'blur' }],
        半壳零件号: [{ required: true, message: '请输入半壳零件号', trigger: 'blur' }],
        半壳品种: [{ required: true, message: '请输入半壳品种', trigger: 'blur' }],
        测量项目名称: [{ required: true, message: '请输入测量项目名称', trigger: 'blur' }],
        测量值: [{ required: true, message: '请输入测量值', trigger: 'blur' }],
        测量模式: [{ required: true, message: '请输入测量模式', trigger: 'blur' }],
        测量人员: [{ required: true, message: '请输入测量人员', trigger: 'blur' }]
      },
      form3: {
        测量项目名称: '',
        单位: '',
        上限: '',
        下限: ''
      },
      rules3: {
        测量项目名称: [{ required: true, message: '请输入测量项目名称', trigger: 'blur' }],
        单位: [{ required: true, message: '请输入单位', trigger: 'blur' }],
        上限: [{ required: true, message: '请输入上限', trigger: 'blur' }],
        下限: [{ required: true, message: '请输入下限', trigger: 'blur' }]
      },
      form4: {
        测量项目代码: '',
        测量项目名称: '',
        单位: '',
        上限: '',
        下限: ''
      },
      rules4: {
        测量项目名称: [{ required: true, message: '请输入测量项目名称', trigger: 'blur' }],
        单位: [{ required: true, message: '请输入单位', trigger: 'blur' }],
        上限: [{ required: true, message: '请输入上限', trigger: 'blur' }],
        下限: [{ required: true, message: '请输入下限', trigger: 'blur' }]
      },
      opMeasureRangeData: {
        name: '',
        min1: 0,
        max1: 0,
        min2: 0,
        max2: 0
      },
      upValue: 0,
      downValue: 0,
      daliyOutPutData_X: [],
      daliyOutPutData_Y: [],
      daliyOutPutData_Average: [],
      daliyOutPutData1_X: [],
      daliyOutPutData1_Y: [],
      daliyOutPutData1_Average: [],
      opnames: [],
      opnameThis: '',
      opnameThisName: '',
      ymin: 0,
      ymax: 100,
      listOP: [],
      deliveryDate: [],
      loading: false,
      loading1: false,
      tableData: [],
      tableData1: [],
      total: 0, // 总条数
      pageSize: 50, // 每页显示条数
      PageCurrent: 1 // 后台获取页
    }
  },
  props: ['opname'],
  computed: {},
  mounted() {
    // this.searchTable()
  },
  created() {
    const start = new Date()
    const end = new Date(start.getTime() - 3600 * 1000 * 24 * 15)
    this.deliveryDate[1] = getNowTime2(start)
    this.deliveryDate[0] = getNowTime2(end)
    this.searchMeasureDataName()
    this.searchProductName()
    this.searchTable()
    this.searchDeviceName()
  },
  methods: {
    searchDeviceName() {
      var param = []
      this.deviceNameList = []
      param[0] = ['设备类型代码', 3]
      var Data = this.CreateData('11', '基础数据_设备信息_查询', param)
      this.ExecDatabase(Data).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.deviceNameList.push({
            label: response.data[i].设备名称,
            value: response.data[i].设备编号
          })
        }
      })
    },
    searchProductName() {
      var param = []
      this.productList = []
      var Data = this.CreateData('11', '基础数据_产品型号_查询', param)
      this.ExecDatabase(Data).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.productList.push({
            label: response.data[i].品种,
            value: response.data[i].品种
          })
        }
      })
    },
    searchMeasureDataName() {
      var param = []
      this.tableData1 = []
      this.measureDataList = []
      param[0] = ['测量项目名称', this.measureDataName]
      var Data = this.CreateData('11', '质量管理_测量项目_查询', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          this.tableData1 = response.data
          for (let i = 0; i < response.data.length; i++) {
            this.measureDataList.push({
              label: response.data[i].测量项目名称,
              value: response.data[i].测量项目代码,
              unit: response.data[i].单位,
              up: response.data[i].上限,
              down: response.data[i].下限
            })
          }
        }
      })
    },
    changeDeviceName(val) {
      for (const valElement of this.deviceNameList) {
        if (val === valElement.value) {
          this.form1.设备名称 = valElement.label
        }
      }
    },
    changeMeasureName(val) {
      for (const valElement of this.measureDataList) {
        if (val === valElement.value) {
          this.form1.测量项目名称 = valElement.label
          this.form1.上限 = valElement.up
          this.form1.下限 = valElement.down
          this.form1.单位 = valElement.unit
        }
      }
    },
    // 获取测量数据上下线
    searchTableMeasureDataRange() {
      var param = []
      this.machineInfo_state = {}
      param[0] = ['opname', this.opnameThis]
      var Data = this.CreateData('11', '[LG_临工看板_产量管理_测量数据设置查询]', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          this.opMeasureRangeData.max1 = response.data[0].上限1
          this.opMeasureRangeData.min1 = response.data[0].下限1
          this.opMeasureRangeData.name = response.data[0].name
        } else {
          this.opMeasureRangeData.max1 = 0
          this.opMeasureRangeData.min1 = 0
          this.opMeasureRangeData.name = ''
        }
      })
    },
    // 修改数据上下线
    editMeasureDataRange() {
      var param = []
      this.machineInfo_state = {}
      param[0] = ['opname', this.opnameThis]
      param[1] = ['@上限1', this.opMeasureRangeData.max1]
      param[2] = ['@下限1', this.opMeasureRangeData.min1]
      var Data = this.CreateData('11', '[LG_临工看板_产量管理_测量数据设置编辑]', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          if (response.data[0]['result'] === 1) {
            this.$message.success('修改成功')
          } else {
            this.$message.error('修改失败')
          }
        }
        this.searchTable()
      })
    },
    searchTable1() {},
    searchTable() {
      this.searchTableMeasureDataRange()
      if (!this.deliveryDate) {
        this.$message.warning('请选择查询时间')
        return
      }
      if (this.deliveryDate.length < 2) {
        this.$message.warning('请选择查询时间')
        return
      }
      if (this.deliveryDate[0] === '') {
        this.$message.warning('请选择查询时间')
        return
      }
      this.loading = true
      this.tableData = []
      var param = []
      param[0] = ['开始时间', this.deliveryDate[0]]
      param[1] = ['结束时间', this.deliveryDate[1]]
      param[2] = ['PageCurrent', this.PageCurrent]
      param[3] = ['PageSize', this.pageSize]
      param[4] = ['PageCount', '1111', 'int', '1']
      param[5] = ['ItemCount', '1111', 'int', '1']
      param[6] = ['设备名称', this.deviceName]
      var Data = this.CreateData('11', '质量管理_产品测量数据_查询', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          this.tableData = response.data.result
          this.total = parseInt(response.data.output[0].ItemCount)
        }
        this.loading = false
      })
    },
    addMeasureData1() {
      this.dialogFormVisible1 = true
      this.form1 = {
        设备名称: '',
        设备编码: '',
        半壳零件号: '2401016-',
        半壳品种: '',
        测量项目名称: '',
        测量项目代码: '',
        单位: '',
        上限: '',
        下限: '',
        测量值: '',
        测量模式: '首件',
        测量人员: '',
        异常记录: '',
        其他类记录: ''
      }
    },
    submitAdd1(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['设备名称', this.form1.设备名称]
          param[1] = ['设备编码', this.form1.设备编码]
          param[2] = ['半壳零件号', this.form1.半壳零件号]
          param[3] = ['半壳品种', this.form1.半壳品种]
          param[4] = ['测量项目名称', this.form1.测量项目名称]
          param[5] = ['测量项目代码', this.form1.测量项目代码]
          param[6] = ['单位', this.form1.单位]
          param[7] = ['上限', this.form1.上限]
          param[8] = ['下限', this.form1.下限]
          param[9] = ['测量值', this.form1.测量值]
          param[10] = ['测量模式', this.form1.测量模式]
          param[11] = ['测量人员', this.form1.测量人员]
          param[12] = ['异常记录', this.form1.异常记录]
          param[13] = ['其他类记录', this.form1.其他类记录]
          var Data = this.CreateData('12', '质量管理_产品测量数据_增加', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: '增加成功',
                type: 'success'
              })
              this.dialogFormVisible1 = false
              this.searchTable()
            } else {
              this.$message.error('增加失败！')
            }
          })
        } else {
          return false
        }
      })
    },
    callOff1(formName) {
      this.dialogFormVisible1 = false
      this.$refs[formName].resetFields()
    },
    addMeasureData2(row) {
      console.log(row)
      this.form2 = {
        ID: row['ID'],
        设备名称: row['设备名称'],
        设备编码: row['设备编码'],
        半壳零件号: row['半壳零件号'],
        半壳品种: row['半壳品种'],
        测量项目名称: row['测量项目名称'],
        测量项目代码: row['测量项目代码'],
        单位: row['单位'],
        上限: row['上限'],
        下限: row['下限'],
        测量值: row['测量值'],
        测量模式: row['测量模式'],
        测量人员: row['测量人员'],
        异常记录: row['异常记录'],
        其他类记录: row['其他类记录']
      }
      this.dialogFormVisible2 = true
    },
    submitAdd2(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['ID', this.form2.ID]
          param[1] = ['测量值', this.form2.测量值]
          param[2] = ['测量人员', this.form2.测量人员]
          param[3] = ['异常记录', this.form2.异常记录]
          param[4] = ['其他类记录', this.form2.其他类记录]
          var Data = this.CreateData('12', '质量管理_产品测量数据_编辑', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: '编辑成功',
                type: 'success'
              })
              this.dialogFormVisible2 = false
              this.searchTable()
            } else {
              this.$message.error('编辑失败！')
            }
          })
        } else {
          return false
        }
      })
    },
    callOff2(formName) {
      this.dialogFormVisible1 = false
      this.$refs[formName].resetFields()
    },
    deleteInformation2(row) {
      this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        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: '删除成功！',
              type: 'success'
            })
            this.searchTable()
          } else {
            this.$message.error('删除失败！')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    addMeasureData3() {
      this.dialogFormVisible3 = true
      this.form3 = {
        测量项目名称: '',
        单位: '',
        上限: '',
        下限: ''
      }
    },
    submitAdd3(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['测量项目名称', this.form3.测量项目名称]
          param[1] = ['单位', this.form3.单位]
          param[2] = ['上限', this.form3.上限]
          param[3] = ['下限', this.form3.下限]
          var Data = this.CreateData('12', '质量管理_测量项目_增加', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: '增加成功',
                type: 'success'
              })
              this.dialogFormVisible3 = false
              this.searchMeasureDataName()
            } else {
              this.$message.error('增加失败！')
            }
          })
        } else {
          return false
        }
      })
    },
    callOff3(formName) {
      this.dialogFormVisible3 = false
      this.$refs[formName].resetFields()
    },
    addMeasureData4(row) {
      this.form4 = {
        测量项目代码: row['测量项目代码'],
        测量项目名称: row['测量项目名称'],
        单位: row['单位'],
        上限: row['上限'],
        下限: row['下限']
      }
      this.dialogFormVisible4 = true
    },
    submitAdd4(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['测量项目名称', this.form4.测量项目名称]
          param[1] = ['单位', this.form4.单位]
          param[2] = ['上限', this.form4.上限]
          param[3] = ['下限', this.form4.下限]
          param[4] = ['测量项目代码', this.form4.测量项目代码]
          var Data = this.CreateData('12', '质量管理_测量项目_编辑', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: '编辑成功',
                type: 'success'
              })
              this.dialogFormVisible4 = false
              this.searchMeasureDataName()
            } else {
              this.$message.error('编辑失败！')
            }
          })
        } else {
          return false
        }
      })
    },
    callOff4(formName) {
      this.dialogFormVisible4 = false
      this.$refs[formName].resetFields()
    },
    deleteInformation4(row) {
      this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var param = []
        param[0] = ['测量项目代码', row.测量项目代码]
        var Data = this.CreateData('12', '质量管理_测量项目_删除', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message({
              message: '删除成功！',
              type: 'success'
            })
            this.searchMeasureDataName()
          } else {
            this.$message.error('删除失败！')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    searchTableMeasureDataName() {
      var param = []
      var Data = this.CreateData('11', '[LG_临工看板_产量管理_测量数据设置查询]', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          this.opMeasureRangeData.max1 = response.data[0].上限1
          this.opMeasureRangeData.min1 = response.data[0].下限1
          this.opMeasureRangeData.name = response.data[0].name
        } else {
          this.opMeasureRangeData.max1 = 0
          this.opMeasureRangeData.min1 = 0
          this.opMeasureRangeData.name = ''
        }
      })
    },
    handleSizeChange(val) {
      this.PageCurrent = 1
      this.pageSize = val
      this.searchTable()
    },
    handleCurrentChange(val) {
      this.PageCurrent = val
      this.searchTable()
    }
  }
}
</script>
<style scoped>
    .div1{
        width: 140px;
        height: 105px;
        margin-left:15px;
        margin-top:15px;
        background: green;
        color: white;
        font-size: 25px;
    }
    .div2{
        width: 140px;
        height: 105px;
        margin-left:15px;
        margin-top:15px;
        background: #60839e;
        color: white;
        font-size: 25px;
    }
    .Checkbox {
        position: absolute;
        visibility: hidden;
    }
</style>
