<template>
  <div class="app-container">
    <el-card>
      <el-select v-model="plantValue" placeholder="工厂" clearable size="small" style="width:100px">
        <el-option
          v-for="item in plant"
          :key="item.value"
          :label="item.label"
          :value="item.value"/>
      </el-select>
      <el-select v-model="workCenterValue" placeholder="工作中心" clearable size="small" style="width:100px">
        <el-option
          v-for="item in workCenter"
          :key="item.value"
          :label="item.label"
          :value="item.value"/>
      </el-select>
      <el-select v-model="opnameValue" placeholder="工位号" clearable size="small" style="width:100px">
        <el-option
          v-for="item in opname"
          :key="item.value"
          :label="item.label"
          :value="item.value"/>
      </el-select>
      <el-select v-model="recipeValue" placeholder="配方号" clearable size="small" style="width:100px">
        <el-option
          v-for="item in recipe"
          :key="item.value"
          :label="item.label"
          :value="item.value"/>
      </el-select>
      <el-date-picker
        v-model="dateRange"
        size="small"
        type="daterange"
        align="center"
        style="width: 240px;"
        value-format="yyyy-MM-dd"
        format="yyyy-MM-dd"
        range-separator="～"
        start-placeholder="开始日期"
        end-placeholder="结束日期"/>
      <el-button type="primary" icon="el-icon-search" size="small" style="margin-left: 15px" plain @click="pageSize=20;pageCurrent=1;searchTable()">查询</el-button>
      <el-button type="distribution" icon="el-icon-circle-plus-outline" size="small" @click="addShiftTable('form')">配方增加</el-button>
      <el-button type="success" icon="el-icon-edit" plain size="small" @click="editTable('form')">配方调整</el-button>
      <el-button type="success" icon="el-icon-cope" plain size="small" @click="copeTable('form')">配方拷贝</el-button>
      <el-table
        :data="tableData"
        border
        highlight-current-row
        size="mini"
        height="750"
        center
        style="width: 100%"
        @row-click="rowClick">
        <el-table-column label="工厂" align="center">
          <template slot-scope="scope">
            {{ scope.row.plant }}
          </template>
        </el-table-column>
        <el-table-column label="工作中心" align="center">
          <template slot-scope="scope">
            {{ scope.row.work_center }}
          </template>
        </el-table-column>
        <el-table-column label="工位号" align="center">
          <template slot-scope="scope">
            {{ scope.row.op_no }}
          </template>
        </el-table-column>
        <el-table-column label="配方号" align="center">
          <template slot-scope="scope">
            {{ scope.row.recipe_no }}
          </template>
        </el-table-column>
        <el-table-column disabled label="序号" align="center">
          <template slot-scope="scope">
            {{ scope.row.seq_no }}
          </template>
        </el-table-column>
        <el-table-column label="动作流程描述" align="center">
          <template slot-scope="scope">
            {{ scope.row.para_name }}
          </template>
        </el-table-column>
        <el-table-column label="动作流程号" align="center">
          <template slot-scope="scope">
            {{ scope.row.para_value }}
          </template>
        </el-table-column>
        <el-table-column label="动作流程说明" align="center">
          <template slot-scope="scope">
            {{ scope.row.para_comments }}
          </template>
        </el-table-column>
        <el-table-column label="创建人" align="center">
          <template slot-scope="scope">
            {{ scope.row.create_user }}
          </template>
        </el-table-column>
        <el-table-column label="创建时间" align="center">
          <template slot-scope="scope">
            {{ scope.row.create_date }}
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top: 10px;">
        <el-pagination
          :current-page="pageCurrent"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="20"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"/>
      </div>
    </el-card>
    <el-dialog :visible.sync="dialogFormVisible" :title="title" center style="min-height: 200px;" width="1400px">
      <el-form ref="form" :model="form" :rules="rules" label-position="right" label-width="110px">
        <el-form-item label="工厂" prop="plantValue" style="display: inline-block">
          <el-select v-model="form.plantValue" :disabled="title === '编辑'" placeholder="工厂" clearable size="mini" style="width:200px">
            <el-option
              v-for="item in plant"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
          </el-select>
        </el-form-item>
        <el-form-item label="工作中心" prop="workCenterValue" style="display: inline-block">
          <el-select v-model="form.workCenterValue" :disabled="title === '编辑'" placeholder="工作中心" clearable size="mini" style="width:200px">
            <el-option
              v-for="item in workCenter"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
          </el-select>
        </el-form-item>
        <el-form-item label="工位号" prop="opnameValue" style="display: inline-block">
          <el-select v-model="form.opnameValue" :disabled="title === '编辑'" placeholder="工位号" clearable size="mini" style="width:200px">
            <el-option
              v-for="item in opname"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
          </el-select>
        </el-form-item>
        <el-form-item label="配方号" prop="recipeValue" style="display: inline-block">
          <el-select v-model="form.recipeValue" :disabled="title === '编辑'" placeholder="配方号" clearable size="mini" style="width:200px">
            <el-option
              v-for="item in recipe"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
          </el-select>
        </el-form-item>
        <el-row style="margin-left: 60px">
          <el-col style="width: 600px">
            <el-row>
              <el-col :span="2" style="text-align: center">序号</el-col>
              <el-col :span="8" style="text-align: center">动作流程</el-col>
              <el-col :span="6" style="text-align: center">动作参数</el-col>
              <el-col :span="8" style="text-align: center">参数说明</el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">1</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value1" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(1,form.value1)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter1" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(1,form.parameter1)">
                  <el-option
                    v-for="item in dataType1"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name1"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">2</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value2" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(2,form.value2)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter2" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(2,form.parameter2)">
                  <el-option
                    v-for="item in dataType2"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name2"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">3</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value3" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(3,form.value3)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter3" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(3,form.parameter3)">
                  <el-option
                    v-for="item in dataType3"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name3"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">4</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value4" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(4,form.value4)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter4" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(4,form.parameter4)">
                  <el-option
                    v-for="item in dataType4"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name4"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">5</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value5" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(5,form.value5)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter5" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(5,form.parameter5)">
                  <el-option
                    v-for="item in dataType5"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name5"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">6</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value6" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(6,form.value6)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter6" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(6,form.parameter6)">
                  <el-option
                    v-for="item in dataType6"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name6"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">7</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value7" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(7,form.value7)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter7" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(7,form.parameter7)">
                  <el-option
                    v-for="item in dataType7"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name7"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">8</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value8" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(8,form.value8)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter8" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(8,form.parameter8)">
                  <el-option
                    v-for="item in dataType8"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name8"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">9</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value9" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(9,form.value9)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter9" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(9,form.parameter9)">
                  <el-option
                    v-for="item in dataType9"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name9"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">10</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value10" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(10,form.value10)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter10" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(10,form.parameter10)">
                  <el-option
                    v-for="item in dataType10"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name10"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
          </el-col>
          <el-col style="width: 600px;margin-left: 20px">
            <el-row>
              <el-col :span="2" style="text-align: center">序号</el-col>
              <el-col :span="8" style="text-align: center">动作流程</el-col>
              <el-col :span="6" style="text-align: center">动作参数</el-col>
              <el-col :span="8" style="text-align: center">参数说明</el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">11</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value11" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(11,form.value11)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter11" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(11,form.parameter11)">
                  <el-option
                    v-for="item in dataType11"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name11"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">12</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value12" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(12,form.value12)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter12" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(12,form.parameter12)">
                  <el-option
                    v-for="item in dataType12"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name12"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">13</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value13" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(13,form.value13)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter13" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(13,form.parameter13)">
                  <el-option
                    v-for="item in dataType13"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name13"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">14</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value14" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(14,form.value14)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter14" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(14,form.parameter14)">
                  <el-option
                    v-for="item in dataType14"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name14"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">15</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value15" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(15,form.value15)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter15" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(15,form.parameter15)">
                  <el-option
                    v-for="item in dataType15"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name15"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">16</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value16" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(16,form.value16)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter16" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(16,form.parameter16)">
                  <el-option
                    v-for="item in dataType16"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name16"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">17</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value17" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(17,form.value17)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter17" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(17,form.parameter17)">
                  <el-option
                    v-for="item in dataType17"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name17"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">18</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value18" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(18,form.value18)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter18" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(18,form.parameter18)">
                  <el-option
                    v-for="item in dataType18"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name18"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">19</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value19" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(19,form.value19)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter19" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(19,form.parameter19)">
                  <el-option
                    v-for="item in dataType19"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name19"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
            <el-row style="margin-top: 10px">
              <el-col :span="2" style="text-align: center">
                <span style="line-height: 28px">20</span>
              </el-col>
              <el-col :span="8">
                <el-select v-model="form.value20" placeholder="请选择" clearable size="mini" style="width:95%" @change="getNumber1(20,form.value20)">
                  <el-option
                    v-for="item in dataType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="form.parameter20" placeholder="请选择" clearable size="mini" style="width:95%" @change="writeValue(20,form.parameter20)">
                  <el-option
                    v-for="item in dataType20"
                    :key="item.value"
                    :label="item.value"
                    :value="item.value">
                    <span style="float: left">{{ item.value }}</span>
                    <span style="float: right">{{ item.label }}</span>
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8">
                <el-input
                  v-model="form.name20"
                  clearable
                  size="mini"
                  placeholder="描述"
                  style="width: 95%"/>
              </el-col>
            </el-row>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="callOff('form')">取消</el-button>
        <el-button v-if="title === '增加'" type="primary" size="small" @click="submitAdd('form')">确定</el-button>
        <el-button v-if="title === '编辑'" type="primary" size="small" @click="submitAdd1('form')">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible1" title="配方拷贝" center style="min-height: 200px;" width="800px">
      <el-form ref="form1" :model="form1" :rules="rules1" label-position="left" label-width="110px">
        <el-form-item label="原配方号：" prop="primaryRecipe" style="display: inline-block">
          <el-select v-model="form1.primaryRecipe" placeholder="原配方号" clearable size="mini" style="width:200px">
            <el-option
              v-for="item in recipe"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
          </el-select>
          <el-button type="text" size="mini" @click="selectOp">全选</el-button>
        </el-form-item>
        <el-form-item label="工位号：" prop="recipeValue" style="display: inline-block">
          <el-checkbox-group v-model="form1.checkListDepartment">
            <el-checkbox v-for="(item, index) in opname" :label="item.label" :key="index"/>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="目标配方：" prop="targetRecipe" style="display: inline-block">
          <el-select v-model="form1.targetRecipe" placeholder="目标配方" clearable size="mini" style="width:200px">
            <el-option
              v-for="item in recipe"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="dialogFormVisible1 = false">取消</el-button>
        <el-button type="primary" size="small" @click="submitCope('form1')">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import request from '@/utils/request'
export default {
  data() {
    return {
      tableData: [],
      plantValue: '', // 工厂
      plant: [],
      workCenterValue: '', // 工作中心
      workCenter: [],
      opnameValue: '', // 工位号
      opname: [],
      recipeValue: '', // 配方
      recipe: [],
      dataType: [],
      dataType1: [],
      dataType2: [],
      dataType3: [],
      dataType4: [],
      dataType5: [],
      dataType6: [],
      dataType7: [],
      dataType8: [],
      dataType9: [],
      dataType10: [],
      dataType11: [],
      dataType12: [],
      dataType13: [],
      dataType14: [],
      dataType15: [],
      dataType16: [],
      dataType17: [],
      dataType18: [],
      dataType19: [],
      dataType20: [],
      dateRange: '',
      pageCurrent: 1,
      pageSize: 20,
      total: 0,
      dialogFormVisible: false,
      title: '',
      form: {
        plantValue: '',
        enginetype: '',
        workCenterValue: '',
        opnameValue: '',
        recipeValue: '',
        value1: '',
        value2: '',
        value3: '',
        value4: '',
        value5: '',
        value6: '',
        value7: '',
        value8: '',
        value9: '',
        value10: '',
        value11: '',
        value12: '',
        value13: '',
        value14: '',
        value15: '',
        value16: '',
        value17: '',
        value18: '',
        value19: '',
        value20: '',
        parameter1: '',
        parameter2: '',
        parameter3: '',
        parameter4: '',
        parameter5: '',
        parameter6: '',
        parameter7: '',
        parameter8: '',
        parameter9: '',
        parameter10: '',
        parameter11: '',
        parameter12: '',
        parameter13: '',
        parameter14: '',
        parameter15: '',
        parameter16: '',
        parameter17: '',
        parameter18: '',
        parameter19: '',
        parameter20: '',
        name1: '',
        name2: '',
        name3: '',
        name4: '',
        name5: '',
        name6: '',
        name7: '',
        name8: '',
        name9: '',
        name10: '',
        name11: '',
        name12: '',
        name13: '',
        name14: '',
        name15: '',
        name16: '',
        name17: '',
        name18: '',
        name19: '',
        name20: '',
        id1: '',
        id2: '',
        id3: '',
        id4: '',
        id5: '',
        id6: '',
        id7: '',
        id8: '',
        id9: '',
        id10: '',
        id11: '',
        id12: '',
        id13: '',
        id14: '',
        id15: '',
        id16: '',
        id17: '',
        id18: '',
        id19: '',
        id20: ''
      },
      rules: {
        plantValue: [{ required: true, message: '请选择', trigger: 'change' }],
        workCenterValue: [{ required: true, message: '请选择', trigger: 'change' }],
        opnameValue: [{ required: true, message: '请选择', trigger: 'change' }],
        recipeValue: [{ required: true, message: '请选择', trigger: 'change' }]
      },
      dialogFormVisible1: false,
      form1: {
        checkListDepartment: [],
        primaryRecipe: '',
        targetRecipe: ''
      },
      checkListDepartment_variable: '',
      rules1: {
        primaryRecipe: [{ required: true, message: '请选择', trigger: 'change' }],
        targetRecipe: [{ required: true, message: '请选择', trigger: 'change' }]
      }

    }
  },
  created() {
    this.getPlant()
    this.getWorkCenter()
    this.getOpname()
    this.getRecipe()
    this.getNumber()
    this.searchTable()
  },
  methods: {
    getPlant() {
      this.plant = []
      request({
        url: '',
        method: 'post',
        data: {
          type: '3',
          name: `SELECT [id],[name]  FROM [dbo].[Recipe_Work_Book] where [type]='工厂'`
        }
      }).then(response => {
        if (response.data.length) {
          for (let i = 0; i < response.data.length; i++) {
            this.plant.push({
              label: response.data[i].name,
              value: response.data[i].name
            })
          }
        }
      })
    },
    getWorkCenter() {
      this.workCenter = []
      request({
        url: '',
        method: 'post',
        data: {
          type: '3',
          name: `SELECT [id],[name]  FROM [dbo].[Recipe_Work_Book] where [type]='工作中心'`
        }
      }).then(response => {
        if (response.data.length) {
          for (let i = 0; i < response.data.length; i++) {
            this.workCenter.push({
              label: response.data[i].name,
              value: response.data[i].name
            })
          }
        }
      })
    },
    getOpname() {
      this.opname = []
      request({
        url: '',
        method: 'post',
        data: {
          type: '3',
          name: `SELECT [id],[name]  FROM [dbo].[Recipe_Work_Book] where [type]='工位号'`
        }
      }).then(response => {
        if (response.data.length) {
          for (let i = 0; i < response.data.length; i++) {
            this.opname.push({
              label: response.data[i].name,
              value: response.data[i].name
            })
          }
        }
      })
    },
    getRecipe() {
      this.recipe = []
      request({
        url: '',
        method: 'post',
        data: {
          type: '3',
          name: `SELECT [name],[value]  FROM [dbo].[Recipe_Work_Book] where [type]='配方号'`
        }
      }).then(response => {
        if (response.data.length) {
          for (let i = 0; i < response.data.length; i++) {
            this.recipe.push({
              label: response.data[i].name,
              value: response.data[i].value
            })
          }
        }
      })
    },
    getNumber() {
      this.dataType = []
      request({
        url: '',
        method: 'post',
        data: {
          type: '3',
          name: `SELECT [id],[name]  FROM [dbo].[Recipe_Work_Book] where [type]='电气元器件动作'`
        }
      }).then(response => {
        if (response.data.length) {
          for (let i = 0; i < response.data.length; i++) {
            this.dataType.push({
              label: response.data[i].name,
              value: response.data[i].name
            })
          }
        }
      })
    },
    searchTable() {
      this.tableData = []
      console.log(this.dateRange, 'this.dateRange')
      if (this.dateRange === null) this.dateRange = ''
      let plantValue_check, checkbox_workcenter, checkbox_opno, checkbox_recipe, checkbox_date
      this.plantValue ? plantValue_check = 1 : plantValue_check = 0
      this.workCenterValue ? checkbox_workcenter = 1 : checkbox_workcenter = 0
      this.opnameValue ? checkbox_opno = 1 : checkbox_opno = 0
      this.recipeValue ? checkbox_recipe = 1 : checkbox_recipe = 0
      this.dateRange ? checkbox_date = 1 : checkbox_date = 0
      var param = []
      param[0] = ['checkbox_plant', plantValue_check]
      param[1] = ['plant', this.plantValue]
      param[2] = ['checkbox_workcenter', checkbox_workcenter]
      param[3] = ['workcenter', this.workCenterValue]
      param[4] = ['checkbox_opno', checkbox_opno]
      param[5] = ['opno', this.opnameValue]
      param[6] = ['checkbox_recipe', checkbox_recipe]
      param[7] = ['recipe', this.recipeValue]
      param[8] = ['checkbox_date', checkbox_date]
      param[9] = ['startdate', this.dateRange[0]]
      param[10] = ['enddate', this.plantValue[1]]
      param[11] = ['PageCurrent', this.pageCurrent]
      param[12] = ['PageSize', this.pageSize]
      param[13] = ['PageCount', '1111', 'int', '1']
      param[14] = ['ItemCount', '1111', 'int', '1']
      var Data = this.CreateData('11', 'Recipe_Main_Query', param)
      this.ExecDatabase(Data).then(response => {
        console.log(response, 66)
        if (response.data.result.length !== 0) {
          this.tableData = response.data.result
        }
        this.total = parseInt(response.data.output[0].ItemCount)
        this.loading = false
        console.log(this.tableData, 'this.tableData')
      })
    },
    searchTable1(plant, workcenter, opno, recipe) {
      this.tableData1 = []
      var param = []
      param[0] = ['checkbox_plant', 1]
      param[1] = ['plant', plant]
      param[2] = ['checkbox_workcenter', 1]
      param[3] = ['workcenter', workcenter]
      param[4] = ['checkbox_opno', 1]
      param[5] = ['opno', opno]
      param[6] = ['checkbox_recipe', 1]
      param[7] = ['recipe', recipe]
      param[8] = ['checkbox_date', 0]
      param[9] = ['startdate', this.dateRange[0]]
      param[10] = ['enddate', this.plantValue[1]]
      param[11] = ['PageCurrent', this.pageCurrent]
      param[12] = ['PageSize', this.pageSize]
      param[13] = ['PageCount', '1111', 'int', '1']
      param[14] = ['ItemCount', '1111', 'int', '1']
      var Data = this.CreateData('11', 'Recipe_Main_Query', param)
      this.ExecDatabase(Data).then(response => {
        console.log(response, 66)
        if (response.data.result.length !== 0) {
          this.tableData1 = response.data.result
          this.form.plantValue = response.data.result[0].plant
          this.form.workCenterValue = response.data.result[0].work_center
          this.form.opnameValue = response.data.result[0].op_no
          this.form.recipeValue = response.data.result[0].recipe_no
          this.form.id1 = response.data.result[0].id
          this.form.value1 = response.data.result[0].para_name
          this.form.parameter1 = response.data.result[0].para_value
          this.form.name1 = response.data.result[0].para_comments
          this.form.id2 = response.data.result[1].id
          this.form.value2 = response.data.result[1].para_name
          this.form.parameter2 = response.data.result[1].para_value
          this.form.name2 = response.data.result[1].para_comments
          this.form.id3 = response.data.result[2].id
          this.form.value3 = response.data.result[2].para_name
          this.form.parameter3 = response.data.result[2].para_value
          this.form.name3 = response.data.result[2].para_comments
          this.form.id4 = response.data.result[3].id
          this.form.value4 = response.data.result[3].para_name
          this.form.parameter4 = response.data.result[3].para_value
          this.form.name4 = response.data.result[3].para_comments
          this.form.id5 = response.data.result[4].id
          this.form.value5 = response.data.result[4].para_name
          this.form.parameter5 = response.data.result[4].para_value
          this.form.name5 = response.data.result[4].para_comments
          this.form.id6 = response.data.result[5].id
          this.form.value6 = response.data.result[5].para_name
          this.form.parameter6 = response.data.result[5].para_value
          this.form.name6 = response.data.result[5].para_comments
          this.form.id7 = response.data.result[6].id
          this.form.value7 = response.data.result[6].para_name
          this.form.parameter7 = response.data.result[6].para_value
          this.form.name7 = response.data.result[6].para_comments
          this.form.id8 = response.data.result[7].id
          this.form.value8 = response.data.result[7].para_name
          this.form.parameter8 = response.data.result[7].para_value
          this.form.name8 = response.data.result[7].para_comments
          this.form.id9 = response.data.result[8].id
          this.form.value9 = response.data.result[8].para_name
          this.form.parameter9 = response.data.result[8].para_value
          this.form.name9 = response.data.result[8].para_comments
          this.form.id10 = response.data.result[9].id
          this.form.value10 = response.data.result[9].para_name
          this.form.parameter10 = response.data.result[9].para_value
          this.form.name10 = response.data.result[9].para_comments
          this.form.id11 = response.data.result[10].id
          this.form.value11 = response.data.result[10].para_name
          this.form.parameter11 = response.data.result[10].para_value
          this.form.name11 = response.data.result[10].para_comments
          this.form.id12 = response.data.result[11].id
          this.form.value12 = response.data.result[11].para_name
          this.form.parameter12 = response.data.result[11].para_value
          this.form.name12 = response.data.result[11].para_comments
          this.form.id13 = response.data.result[12].id
          this.form.value13 = response.data.result[12].para_name
          this.form.parameter13 = response.data.result[12].para_value
          this.form.name13 = response.data.result[12].para_comments
          this.form.id14 = response.data.result[13].id
          this.form.value14 = response.data.result[13].para_name
          this.form.parameter14 = response.data.result[13].para_value
          this.form.name14 = response.data.result[13].para_comments
          this.form.id15 = response.data.result[14].id
          this.form.value15 = response.data.result[14].para_name
          this.form.parameter15 = response.data.result[14].para_value
          this.form.name15 = response.data.result[14].para_comments
          this.form.id16 = response.data.result[15].id
          this.form.value16 = response.data.result[15].para_name
          this.form.parameter16 = response.data.result[15].para_value
          this.form.name16 = response.data.result[15].para_comments
          this.form.id17 = response.data.result[16].id
          this.form.value17 = response.data.result[16].para_name
          this.form.parameter17 = response.data.result[16].para_value
          this.form.name17 = response.data.result[16].para_comments
          this.form.id18 = response.data.result[17].id
          this.form.value18 = response.data.result[17].para_name
          this.form.parameter18 = response.data.result[17].para_value
          this.form.name18 = response.data.result[17].para_comments
          this.form.id19 = response.data.result[18].id
          this.form.value19 = response.data.result[18].para_name
          this.form.parameter19 = response.data.result[18].para_value
          this.form.name19 = response.data.result[18].para_comments
          this.form.id20 = response.data.result[19].id
          this.form.value20 = response.data.result[19].para_name
          this.form.parameter20 = response.data.result[19].para_value
          this.form.name20 = response.data.result[19].para_comments
        }
        console.log(this.tableData1, 'this.tableData1')
      }).then(() => {
        for (let i = 0; i < this.tableData1.length; i++) {
          this.getNumber1(i + 1, this.tableData1[i].para_name)
        }
      })
    },
    getNumber1(number, val) {
      this.dataType1 = []
      this.dataType2 = []
      this.dataType3 = []
      this.dataType4 = []
      this.dataType5 = []
      this.dataType6 = []
      this.dataType7 = []
      this.dataType8 = []
      this.dataType9 = []
      this.dataType10 = []
      this.dataType11 = []
      this.dataType12 = []
      this.dataType13 = []
      this.dataType14 = []
      this.dataType15 = []
      this.dataType16 = []
      this.dataType17 = []
      this.dataType18 = []
      this.dataType19 = []
      this.dataType20 = []
      var param = []
      param[0] = ['machineName', val]
      var Data = this.CreateData('11', 'Recipe_Machine_Query_NoPage', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length) {
          for (let i = 0; i < response.data.length; i++) {
            switch (number) {
              case 1 : {
                this.dataType1.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 2 : {
                this.dataType2.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 3 : {
                this.dataType3.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 4 : {
                this.dataType4.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 5 : {
                this.dataType5.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 6 : {
                this.dataType6.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 7 : {
                this.dataType7.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 8 : {
                this.dataType8.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 9 : {
                this.dataType9.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 10 : {
                this.dataType10.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 11 : {
                this.dataType11.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 12 : {
                this.dataType12.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 13 : {
                this.dataType13.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 14 : {
                this.dataType14.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 15 : {
                this.dataType15.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 16 : {
                this.dataType16.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 17 : {
                this.dataType17.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 18 : {
                this.dataType18.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 19 : {
                this.dataType19.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
              case 20 : {
                this.dataType20.push({
                  label: response.data[i].Described,
                  label1: response.data[i].Comments,
                  value: response.data[i].MachineNum
                })
                break
              }
            }
          }
        }
        console.log(this.dataType1, 'this.dataType1')
      })
    },
    writeValue(number, val) {
      switch (number) {
        case 1: {
          for (let i = 0; i < this.dataType1.length; i++) {
            if (val === this.dataType1[i].value) this.form.name1 = this.dataType1[i].label
          }
          break
        }
        case 2: {
          for (let i = 0; i < this.dataType2.length; i++) {
            if (val === this.dataType2[i].value) this.form.name2 = this.dataType2[i].label
          }
          break
        }
        case 3: {
          for (let i = 0; i < this.dataType3.length; i++) {
            if (val === this.dataType3[i].value) this.form.name3 = this.dataType3[i].label
          }
          break
        }
        case 4: {
          for (let i = 0; i < this.dataType4.length; i++) {
            if (val === this.dataType4[i].value) this.form.name4 = this.dataType4[i].label
          }
          break
        }
        case 5: {
          for (let i = 0; i < this.dataType5.length; i++) {
            if (val === this.dataType5[i].value) this.form.name5 = this.dataType5[i].label
          }
          break
        }
        case 6: {
          for (let i = 0; i < this.dataType6.length; i++) {
            if (val === this.dataType6[i].value) this.form.name6 = this.dataType6[i].label
          }
          break
        }
        case 7: {
          for (let i = 0; i < this.dataType7.length; i++) {
            if (val === this.dataType7[i].value) this.form.name7 = this.dataType7[i].label
          }
          break
        }
        case 8: {
          for (let i = 0; i < this.dataType8.length; i++) {
            if (val === this.dataType8[i].value) this.form.name8 = this.dataType8[i].label
          }
          break
        }
        case 9: {
          for (let i = 0; i < this.dataType9.length; i++) {
            if (val === this.dataType9[i].value) this.form.name9 = this.dataType9[i].label
          }
          break
        }
        case 10: {
          for (let i = 0; i < this.dataType10.length; i++) {
            if (val === this.dataType10[i].value) this.form.name10 = this.dataType10[i].label
          }
          break
        }
        case 11: {
          for (let i = 0; i < this.dataType11.length; i++) {
            if (val === this.dataType11[i].value) this.form.name11 = this.dataType11[i].label
          }
          break
        }
        case 12: {
          for (let i = 0; i < this.dataType12.length; i++) {
            if (val === this.dataType12[i].value) this.form.name12 = this.dataType12[i].label
          }
          break
        }
        case 13: {
          for (let i = 0; i < this.dataType13.length; i++) {
            if (val === this.dataType13[i].value) this.form.name13 = this.dataType13[i].label
          }
          break
        }
        case 14: {
          for (let i = 0; i < this.dataType14.length; i++) {
            if (val === this.dataType14[i].value) this.form.name14 = this.dataType14[i].label
          }
          break
        }
        case 15: {
          for (let i = 0; i < this.dataType15.length; i++) {
            if (val === this.dataType15[i].value) this.form.name15 = this.dataType15[i].label
          }
          break
        }
        case 16: {
          for (let i = 0; i < this.dataType16.length; i++) {
            if (val === this.dataType16[i].value) this.form.name16 = this.dataType16[i].label
          }
          break
        }
        case 17: {
          for (let i = 0; i < this.dataType17.length; i++) {
            if (val === this.dataType17[i].value) this.form.name17 = this.dataType17[i].label
          }
          break
        }
        case 18: {
          for (let i = 0; i < this.dataType18.length; i++) {
            if (val === this.dataType18[i].value) this.form.name18 = this.dataType18[i].label
          }
          break
        }
        case 19: {
          for (let i = 0; i < this.dataType19.length; i++) {
            if (val === this.dataType19[i].value) this.form.name19 = this.dataType19[i].label
          }
          break
        }
        case 20: {
          for (let i = 0; i < this.dataType20.length; i++) {
            if (val === this.dataType20[i].value) this.form.name20 = this.dataType20[i].label
          }
          break
        }
      }
    },
    addShiftTable() {
      this.dialogFormVisible = true
      this.title = '增加'
      this.form.parameter1 = ''
      this.form.value1 = ''
      this.form.name1 = ''
      this.form.parameter2 = ''
      this.form.value2 = ''
      this.form.name2 = ''
      this.form.parameter3 = ''
      this.form.value3 = ''
      this.form.name3 = ''
      this.form.parameter4 = ''
      this.form.value4 = ''
      this.form.name4 = ''
      this.form.parameter5 = ''
      this.form.value5 = ''
      this.form.name5 = ''
      this.form.parameter6 = ''
      this.form.value6 = ''
      this.form.name6 = ''
      this.form.parameter7 = ''
      this.form.value7 = ''
      this.form.name7 = ''
      this.form.parameter8 = ''
      this.form.value8 = ''
      this.form.name8 = ''
      this.form.parameter9 = ''
      this.form.value9 = ''
      this.form.name9 = ''
      this.form.parameter10 = ''
      this.form.value10 = ''
      this.form.name10 = ''
      this.form.parameter11 = ''
      this.form.value11 = ''
      this.form.name11 = ''
      this.form.parameter12 = ''
      this.form.value12 = ''
      this.form.name12 = ''
      this.form.parameter13 = ''
      this.form.value13 = ''
      this.form.name13 = ''
      this.form.parameter14 = ''
      this.form.value14 = ''
      this.form.name14 = ''
      this.form.parameter15 = ''
      this.form.value15 = ''
      this.form.name15 = ''
      this.form.parameter16 = ''
      this.form.value16 = ''
      this.form.name16 = ''
      this.form.parameter17 = ''
      this.form.value17 = ''
      this.form.name17 = ''
      this.form.parameter18 = ''
      this.form.value18 = ''
      this.form.name18 = ''
      this.form.parameter19 = ''
      this.form.value19 = ''
      this.form.name19 = ''
      this.form.parameter20 = ''
      this.form.value20 = ''
      this.form.name20 = ''
    },
    submitAdd(formName) {
      if (!this.form.parameter1) {
        this.form.parameter1 = '0'
        this.form.value1 = '电缸'
        this.form.name1 = '空位'
      }
      if (!this.form.parameter2) {
        this.form.parameter2 = '0'
        this.form.value2 = '电缸'
        this.form.name2 = '空位'
      }
      if (!this.form.parameter2) {
        this.form.parameter2 = '0'
        this.form.value2 = '电缸'
        this.form.name2 = '空位'
      }
      if (!this.form.parameter3) {
        this.form.parameter3 = '0'
        this.form.value3 = '电缸'
        this.form.name3 = '空位'
      }
      if (!this.form.parameter4) {
        this.form.parameter4 = '0'
        this.form.value4 = '电缸'
        this.form.name4 = '空位'
      }
      if (!this.form.parameter5) {
        this.form.parameter5 = '0'
        this.form.value5 = '电缸'
        this.form.name5 = '空位'
      }
      if (!this.form.parameter6) {
        this.form.parameter6 = '0'
        this.form.value6 = '电缸'
        this.form.name6 = '空位'
      }
      if (!this.form.parameter7) {
        this.form.parameter7 = '0'
        this.form.value7 = '电缸'
        this.form.name7 = '空位'
      }
      if (!this.form.parameter8) {
        this.form.parameter8 = '0'
        this.form.value8 = '电缸'
        this.form.name8 = '空位'
      }
      if (!this.form.parameter9) {
        this.form.parameter9 = '0'
        this.form.value9 = '电缸'
        this.form.name9 = '空位'
      }
      if (!this.form.parameter10) {
        this.form.parameter10 = '0'
        this.form.value10 = '电缸'
        this.form.name10 = '空位'
      }
      if (!this.form.parameter11) {
        this.form.parameter11 = '0'
        this.form.value11 = '电缸'
        this.form.name11 = '空位'
      }
      if (!this.form.parameter12) {
        this.form.parameter12 = '0'
        this.form.value12 = '电缸'
        this.form.name12 = '空位'
      }
      if (!this.form.parameter13) {
        this.form.parameter13 = '0'
        this.form.value13 = '配方'
        this.form.name13 = '空位'
      }
      if (!this.form.parameter14) {
        this.form.parameter14 = '0'
        this.form.value14 = '电缸'
        this.form.name14 = '空位'
      }
      if (!this.form.parameter15) {
        this.form.parameter15 = '0'
        this.form.value15 = '电缸'
        this.form.name15 = '空位'
      }
      if (!this.form.parameter16) {
        this.form.parameter16 = '0'
        this.form.value16 = '电缸'
        this.form.name16 = '空位'
      }
      if (!this.form.parameter17) {
        this.form.parameter17 = '0'
        this.form.value17 = '电缸'
        this.form.name17 = '空位'
      }
      if (!this.form.parameter18) {
        this.form.parameter18 = '0'
        this.form.value18 = '电缸'
        this.form.name18 = '空位'
      }
      if (!this.form.parameter19) {
        this.form.parameter19 = '0'
        this.form.value19 = '电缸'
        this.form.name19 = '空位'
      }
      if (!this.form.parameter20) {
        this.form.parameter20 = '0'
        this.form.value20 = '电缸'
        this.form.name20 = '空位'
      }
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['plant', this.form.plantValue]
          param[1] = ['workcenter', this.form.workCenterValue]
          param[2] = ['enginetype', this.form.enginetype]
          param[3] = ['opname', this.form.opnameValue]
          param[4] = ['recipeno', this.form.recipeValue]
          param[5] = ['actions', 1 + '_' + this.form.parameter1 + '_' + this.form.value1 + '_' + this.form.name1 + '|' +
            2 + '_' + this.form.parameter2 + '_' + this.form.value2 + '_' + this.form.name2 + '|' +
            3 + '_' + this.form.parameter3 + '_' + this.form.value3 + '_' + this.form.name3 + '|' +
            4 + '_' + this.form.parameter4 + '_' + this.form.value4 + '_' + this.form.name4 + '|' +
            5 + '_' + this.form.parameter5 + '_' + this.form.value5 + '_' + this.form.name5 + '|' +
            6 + '_' + this.form.parameter6 + '_' + this.form.value6 + '_' + this.form.name6 + '|' +
            7 + '_' + this.form.parameter7 + '_' + this.form.value7 + '_' + this.form.name7 + '|' +
            8 + '_' + this.form.parameter8 + '_' + this.form.value8 + '_' + this.form.name8 + '|' +
            9 + '_' + this.form.parameter9 + '_' + this.form.value9 + '_' + this.form.name9 + '|' +
            10 + '_' + this.form.parameter10 + '_' + this.form.value10 + '_' + this.form.name10 + '|' +
            11 + '_' + this.form.parameter11 + '_' + this.form.value11 + '_' + this.form.name11 + '|' +
            12 + '_' + this.form.parameter12 + '_' + this.form.value12 + '_' + this.form.name12 + '|' +
            13 + '_' + this.form.parameter13 + '_' + this.form.value13 + '_' + this.form.name13 + '|' +
            14 + '_' + this.form.parameter14 + '_' + this.form.value14 + '_' + this.form.name14 + '|' +
            15 + '_' + this.form.parameter15 + '_' + this.form.value15 + '_' + this.form.name15 + '|' +
            16 + '_' + this.form.parameter16 + '_' + this.form.value16 + '_' + this.form.name16 + '|' +
            17 + '_' + this.form.parameter17 + '_' + this.form.value17 + '_' + this.form.name17 + '|' +
            18 + '_' + this.form.parameter18 + '_' + this.form.value18 + '_' + this.form.name18 + '|' +
            19 + '_' + this.form.parameter19 + '_' + this.form.value19 + '_' + this.form.name19 + '|' +
            20 + '_' + this.form.parameter20 + '_' + this.form.value20 + '_' + this.form.name20]
          param[6] = ['createuser', 'admin']
          console.log(param, 'addParam')
          var Data = this.CreateData('12', 'Recipe_Main_Add', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: '配方创建成功',
                type: 'success'
              })
              this.pageCurrent = 1
              this.pageSize = 20
              this.searchTable()
              this.dialogFormVisible = false
            } else {
              this.$message.error('配方创建失败！')
            }
          })
        } else {
          return false
        }
      })
    },
    editTable() {
      if (this.form.plantValue) {
        this.title = '编辑'
        this.dialogFormVisible = true
      } else {
        this.$message.error('请选择要编辑的信息！')
      }
    },
    rowClick(row) {
      if (row.plant) {
        this.searchTable1(row.plant, row.work_center, row.op_no, row.recipe_no)
      } else {
        this.$message.error('请选择要编辑的信息！')
      }
    },
    submitAdd1(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['plant', this.form.plantValue]
          param[1] = ['workcenter', this.form.workCenterValue]
          param[2] = ['enginetype', this.form.enginetype]
          param[3] = ['opname', this.form.opnameValue]
          param[4] = ['recipeno', this.form.recipeValue]
          // param[5] = ['actions', '']
          param[5] = ['actions', 1 + '_' + this.form.parameter1 + '_' + this.form.value1 + '_' + this.form.name1 + '_' + this.form.id1 + '|' +
            2 + '_' + this.form.parameter2 + '_' + this.form.value2 + '_' + this.form.name2 + '_' + this.form.id2 + '|' +
            3 + '_' + this.form.parameter3 + '_' + this.form.value3 + '_' + this.form.name3 + '_' + this.form.id3 + '|' +
            4 + '_' + this.form.parameter4 + '_' + this.form.value4 + '_' + this.form.name4 + '_' + this.form.id4 + '|' +
            5 + '_' + this.form.parameter5 + '_' + this.form.value5 + '_' + this.form.name5 + '_' + this.form.id5 + '|' +
            6 + '_' + this.form.parameter6 + '_' + this.form.value6 + '_' + this.form.name6 + '_' + this.form.id6 + '|' +
            7 + '_' + this.form.parameter7 + '_' + this.form.value7 + '_' + this.form.name7 + '_' + this.form.id7 + '|' +
            8 + '_' + this.form.parameter8 + '_' + this.form.value8 + '_' + this.form.name8 + '_' + this.form.id8 + '|' +
            9 + '_' + this.form.parameter9 + '_' + this.form.value9 + '_' + this.form.name9 + '_' + this.form.id9 + '|' +
            10 + '_' + this.form.parameter10 + '_' + this.form.value10 + '_' + this.form.name10 + '_' + this.form.id10 + '|' +
            11 + '_' + this.form.parameter11 + '_' + this.form.value11 + '_' + this.form.name11 + '_' + this.form.id11 + '|' +
            12 + '_' + this.form.parameter12 + '_' + this.form.value12 + '_' + this.form.name12 + '_' + this.form.id12 + '|' +
            13 + '_' + this.form.parameter13 + '_' + this.form.value13 + '_' + this.form.name13 + '_' + this.form.id13 + '|' +
            14 + '_' + this.form.parameter14 + '_' + this.form.value14 + '_' + this.form.name14 + '_' + this.form.id14 + '|' +
            15 + '_' + this.form.parameter15 + '_' + this.form.value15 + '_' + this.form.name15 + '_' + this.form.id15 + '|' +
            16 + '_' + this.form.parameter16 + '_' + this.form.value16 + '_' + this.form.name16 + '_' + this.form.id16 + '|' +
            17 + '_' + this.form.parameter17 + '_' + this.form.value17 + '_' + this.form.name17 + '_' + this.form.id17 + '|' +
            18 + '_' + this.form.parameter18 + '_' + this.form.value18 + '_' + this.form.name18 + '_' + this.form.id18 + '|' +
            19 + '_' + this.form.parameter19 + '_' + this.form.value19 + '_' + this.form.name19 + '_' + this.form.id19 + '|' +
            20 + '_' + this.form.parameter20 + '_' + this.form.value20 + '_' + this.form.name20 + '_' + this.form.id20]
          param[6] = ['createuser', 'admin']
          console.log(param, 'addParam')
          var Data = this.CreateData('12', 'Recipe_Main_Edit', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: '配方调整成功',
                type: 'success'
              })
              this.pageCurrent = 1
              this.pageSize = 20
              this.searchTable()
              this.dialogFormVisible = false
            } else {
              this.$message.error('配方调整失败！')
            }
          })
        } else {
          return false
        }
      })
    },
    callOff() {
      this.dialogFormVisible = false
    },
    copeTable() {
      this.dialogFormVisible1 = true
    },
    selectOp() {
      console.log(this.form1.checkListDepartment.length)
      if (this.form1.checkListDepartment.length > 0) {
        this.form1.checkListDepartment = []
      } else {
        for (let i = 0; i < this.opname.length; i++) {
          this.form1.checkListDepartment.push(this.opname[i].label)
        }
      }
    },
    submitCope(formName) {
      const NumberData = []
      this.checkListDepartment_variable = this.form1.checkListDepartment
      for (let i = 0; i < this.checkListDepartment_variable.length; i++) {
        NumberData[i] = this.checkListDepartment_variable[i]
      }
      if (NumberData) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            var param1 = []
            param1[0] = ['recipeno', this.form1.targetRecipe]
            param1[1] = ['opno', NumberData]
            param1[2] = ['errordes', '1', 'nvarchar(1)', '1']
            param1[3] = ['errorcode', '1', 'nvarchar(1)', '1']
            var Data1 = this.CreateData('12', 'Recipe_Main_CheckRepeat', param1)
            this.ExecDatabase(Data1).then(response => {
              console.log(response, 'response')
              // eslint-disable-next-line no-unused-vars
              var op_na
              op_na = this.checkListDepartment_variable.toString()
              if (response.data.output[0].errorcode === '2') {
                console.log(op_na, 'op_na')
                this.$message.error('工位' + op_na + '中已有' + this.form1.targetRecipe + '配方号存在！')
              } else {
                var param = []
                param[0] = ['copyno', this.form1.primaryRecipe]
                param[1] = ['copyopno', NumberData]
                param[2] = ['copytono', this.form1.targetRecipe]
                param[3] = ['createuser', 'admin']
                console.log(param, 'CopeParam')
                var Data = this.CreateData('12', 'Recipe_Main_Copy', param)
                this.ExecDatabase(Data).then(response => {
                  if (response.data[0].result === '1') {
                    this.$message({
                      message: '提交数据成功',
                      type: 'success'
                    })
                    this.pageCurrent = 1
                    this.pageSize = 20
                    this.searchTable()
                    this.dialogFormVisible1 = false
                  } else {
                    this.$message.error('提交数据失败！')
                  }
                })
              }
            })
          } else {
            return false
          }
        })
      } else {
        this.$message.error('至少选择一个工位号！')
      }
    },
    editShiftTable() {},
    handleDelete() {},
    handleSizeChange(val) {
      this.pageSize = val
      this.pageCurrent = 1
      this.searchTable()
    },
    handleCurrentChange(val) {
      this.pageCurrent = val
      this.searchTable()
    }
  }
}
</script>

<style scoped>

</style>
