<template>
  <div class="app-container">
    <el-card class="topCard">
      <el-col :span="16">
        <div class="topDiv">
          <span style="margin-left: 10px">附件类型：</span>
          <el-input v-model="equipmentType" clearable placeholder="附件名称" size="small" style="width:150px;"/>
          <el-button
            icon="el-icon-search"
            plain
            size="small"
            style="margin-left: 10px"
            type="primary"
            @click="searchOrder()">查询
          </el-button>
          <el-button icon="el-icon-circle-plus" size="small" type="distribution" @click="creatOrder('form')">
            新增附件类型
          </el-button>
        </div>
        <el-table
          v-loading="loading"
          ref="multipleTable"
          :data="tableData"
          :header-cell-style="{background:'#eef1f6',color:'#606266'}"
          border
          class="main"
          element-loading-background="rgba(0, 0, 0, 0.2)"
          element-loading-spinner="el-icon-loading"
          element-loading-text="数据加载中"
          height="770px"
          highlight-current-row
          size="mini"
          style="width: 97%;"
          tooltip-effect="dark"
          @current-change="handleCurrentChange">
          <el-table-column align="center" label="序号" type="index" width="60"/>
          <el-table-column align="center" label="附件类型">
            <template slot-scope="scope">
              {{ scope.row.附件类型 }}
            </template>
          </el-table-column>
          <!--<el-table-column align="center" label="图号名称">-->
          <!--  <template slot-scope="scope">-->
          <!--    {{ scope.row.图号名称 }}-->
          <!--  </template>-->
          <!--</el-table-column>-->
          <!--<el-table-column align="center" label="物料名简称">-->
          <!--  <template slot-scope="scope">-->
          <!--    {{ scope.row.工厂编号2 }}-->
          <!--  </template>-->
          <!--</el-table-column>-->
          <el-table-column align="center" label="总装线配方名称">
            <template slot-scope="scope">
              {{ scope.row.总装名称 }}
            </template>
          </el-table-column>
          <el-table-column align="center" label="总装线机型代码">
            <template slot-scope="scope">
              {{ scope.row.总装代码 }}
            </template>
          </el-table-column>
          <!--        <el-table-column align="center" label="配方号">-->
          <!--          <template slot-scope="scope">-->
          <!--            {{ scope.row.配方号 }}-->
          <!--          </template>-->
          <!--        </el-table-column>-->
          <!--        <el-table-column align="center" label="桥壳">-->
          <!--          <template slot-scope="scope">-->
          <!--            {{ scope.row.机型_桥壳 }}-->
          <!--          </template>-->
          <!--        </el-table-column>-->
          <!--        <el-table-column align="center" label="轮毂">-->
          <!--          <template slot-scope="scope">-->
          <!--            {{ scope.row.机型_轮毂 }}-->
          <!--          </template>-->
          <!--        </el-table-column>-->
          <!--        <el-table-column align="center" label="规格(大机型)">-->
          <!--          <template slot-scope="scope">-->
          <!--            {{ scope.row.箱体名称 }}-->
          <!--          </template>-->
          <!--        </el-table-column>-->
          <!--        <el-table-column align="center" label="型号(小机型)">-->
          <!--          <template slot-scope="scope">-->
          <!--            {{ scope.row.吨位名称 }}-->
          <!--          </template>-->
          <!--        </el-table-column>-->
          <!--          <el-table-column align="center" label="是否禁用">-->
          <!--            <template slot-scope="scope">-->
          <!--              <span v-if="Number(scope.row.是否禁用) === 1"> 是 </span>-->
          <!--              <span v-if="Number(scope.row.是否禁用) === 0"> 否 </span>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column align="center" label="操作" width="150">
            <template slot-scope="scope">
              <el-button
                icon="el-icon-edit"
                size="mini"
                type="text"
                @click="handleEdit(scope.row)">修改
              </el-button>
              <el-button
                icon="el-icon-delete"
                size="mini"
                style="color: #ff0000"
                type="text"
                @click="deleteOrder(scope.row)">删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
      <el-col :span="8">
        <el-row>
          <div class="topDiv">
            <span style="margin-left: 10px">本体型号：</span>
            <el-input v-model="equipmentType2" clearable placeholder="总装机型" size="small" style="width:150px;"/>
            <el-button
              icon="el-icon-search"
              plain
              size="small"
              style="margin-left: 10px"
              type="primary"
              @click="searchOrder2()">查询
            </el-button>
            <!--<el-button icon="el-icon-circle-plus" size="small" type="distribution" @click="creatOrder2('form3')">-->
            <!--  新增桥壳配方-->
            <!--</el-button>-->
          </div>
          <el-table
            v-loading="loading2"
            ref="QiaoKeTable"
            :data="tableData2"
            :header-cell-style="{background:'#eef1f6',color:'#606266'}"
            border
            class="main"
            element-loading-background="rgba(0, 0, 0, 0.2)"
            element-loading-spinner="el-icon-loading"
            element-loading-text="数据加载中"
            height="365px"
            highlight-current-row
            size="mini"
            style="width: 98%;"
            tooltip-effect="dark">
            <el-table-column align="center" label="序号" type="index" width="60"/>
            <el-table-column align="center" label="本体名称" width="180">
              <template slot-scope="scope">
                {{ scope.row.壳体编号型号 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="本体代码">
              <template slot-scope="scope">
                {{ scope.row.发动机机型标志 }}
              </template>
            </el-table-column>

            <el-table-column align="center" label="操作" width="150">
              <template slot-scope="scope">
                <el-button
                  disabled
                  icon="el-icon-delete"
                  size="mini"
                  style="color: #ff0000"
                  type="text"
                  @click="deleteOrder_QiaoKe(scope.row)">删除
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-row>
        <!--<el-row style="margin-top: 10px">-->
        <!--  <div class="topDiv">-->
        <!--    <span style="margin-left: 10px">轮毂号：</span>-->
        <!--    <el-input v-model="equipmentType1" style="width:150px;" clearable placeholder="轮毂号" size="small"/>-->
        <!--    <el-button type="primary" plain size="small" icon="el-icon-search" style="margin-left: 10px" @click="searchOrder1()">查询</el-button>-->
        <!--    <el-button type="distribution" size="small" icon="el-icon-circle-plus" @click="creatOrder1('form')">新增轮毂配方</el-button>-->
        <!--  </div>-->
        <!--  <el-table-->
        <!--    v-loading="loading1"-->
        <!--    ref="LunGuTable"-->
        <!--    :data="tableData1"-->
        <!--    highlight-current-row-->
        <!--    :header-cell-style="{background:'#eef1f6',color:'#606266'}"-->
        <!--    element-loading-text="数据加载中"-->
        <!--    element-loading-spinner="el-icon-loading"-->
        <!--    element-loading-background="rgba(0, 0, 0, 0.2)"-->
        <!--    class="main"-->
        <!--    tooltip-effect="dark"-->
        <!--    height="365px"-->
        <!--    style="width: 98%;"-->
        <!--    border-->
        <!--    size="mini">-->
        <!--    <el-table-column type="index" width="60" label="序号" align="center"/>-->
        <!--    <el-table-column align="center" label="轮毂号">-->
        <!--      <template slot-scope="scope">-->
        <!--        {{ scope.row.机型_轮毂 }}-->
        <!--      </template>-->
        <!--    </el-table-column>-->
        <!--    <el-table-column align="center" label="轮毂线配方">-->
        <!--      <template slot-scope="scope">-->
        <!--        {{ scope.row.机型代码_轮毂 }}-->
        <!--      </template>-->
        <!--    </el-table-column>-->
        <!--    <el-table-column align="center" label="轮毂线MES配方" width="120">-->
        <!--      <template slot-scope="scope">-->
        <!--        {{ scope.row.机型代码_轮毂_MES }}-->
        <!--      </template>-->
        <!--    </el-table-column>-->
        <!--    <el-table-column align="center" label="操作" width="150">-->
        <!--      <template slot-scope="scope">-->
        <!--        <el-button-->
        <!--          size="mini"-->
        <!--          type="text"-->
        <!--          icon="el-icon-delete"-->
        <!--          style="color: #ff0000"-->
        <!--          @click="deleteOrder_Lungu(scope.row)">删除</el-button>-->
        <!--      </template>-->
        <!--    </el-table-column>-->
        <!--  </el-table>-->
        <!--</el-row>-->
      </el-col>
    </el-card>
    <el-dialog :visible.sync="dialogFormVisible" center style="min-height: 200px;" title="新增总装配方" width="400px">
      <el-form ref="form" :model="form" :rules="rules" label-position="right" label-width="120px">
        <el-form-item label="物料号" prop="equipmentType" style="display: inline-block">
          <el-input
            v-model="form.equipmentType"
            clearable
            placeholder="物料号"
            size="small"/>
        </el-form-item>
        <el-form-item label="物料名" prop="equipmentTypeName" style="display: inline-block">
          <el-input
            v-model="form.equipmentTypeName"
            clearable
            placeholder="物料名"
            size="small"/>
        </el-form-item>
        <el-form-item label="物料名简称" prop="equipmentTypeName2" style="display: inline-block">
          <el-input
            v-model="form.equipmentTypeName2"
            clearable
            placeholder="物料名简称"
            size="small"/>
        </el-form-item>
        <el-form-item label="总装线配方号" prop="equipmentSign" style="display: inline-block">
          <el-input-number
            v-model="form.equipmentSign"
            :min="1"
            :step="1"
            placeholder="总装线配方号"
            size="small"
            style="width: 200px"/>
        </el-form-item>
        <el-form-item label="轮毂线配方号" prop="equipmentSign2" style="display: inline-block">
          <el-select
            v-model="form.equipmentSign2"
            placeholder="请选择轮毂线配方号"
            size="small"
            style="display: inline-block">
            <el-option
              v-for="item in LunGuList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              size="mini"/>
          </el-select>
        </el-form-item>
        <el-form-item label="桥壳线配方号" prop="equipmentSign2" style="display: inline-block">
          <el-select
            v-model="form.equipmentSign3"
            placeholder="请选择桥壳线配方号"
            size="small"
            style="display: inline-block">
            <el-option
              v-for="item in QiaoKeList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              size="mini"/>
          </el-select>
        </el-form-item>
        <!--        <el-form-item label="总成物料号" prop="itemNo" style="display: inline-block">-->
        <!--          <el-input-->
        <!--            v-model="form.itemNo"-->
        <!--            clearable-->
        <!--            size="small"-->
        <!--            placeholder="总成物料号"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="规格(大机型)" prop="boxSign" style="display: inline-block">-->
        <!--          <el-select v-model="form.boxSign" placeholder="请选择" size="small" style="display: inline-block">-->
        <!--            <el-option-->
        <!--              v-for="item in boxSign"-->
        <!--              :key="item.value"-->
        <!--              :label="item.label"-->
        <!--              :value="item.value"-->
        <!--              size="mini"/>-->
        <!--          </el-select>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="型号(小机型)" prop="tonnageSign" style="display: inline-block">-->
        <!--          <el-select v-model="form.tonnageSign" placeholder="请选择" size="small" style="display: inline-block">-->
        <!--            <el-option-->
        <!--              v-for="item in tonnageSign"-->
        <!--              :key="item.value"-->
        <!--              :label="item.label"-->
        <!--              :value="item.value"-->
        <!--              size="mini"/>-->
        <!--          </el-select>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="是否禁用" prop="enDisable" style="display: inline-block">-->
        <!--          <el-select v-model="form.enDisable" placeholder="请选择" size="small" style="display: inline-block">-->
        <!--            <el-option-->
        <!--              v-for="item in disableArr"-->
        <!--              :key="item.value"-->
        <!--              :label="item.label"-->
        <!--              :value="item.value"-->
        <!--              size="mini"/>-->
        <!--          </el-select>-->
        <!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="callOff('form')">取消</el-button>
        <el-button size="small" type="primary" @click="submitAdd('form')">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible2" center style="min-height: 200px;" title="编辑物料图号" width="400px">
      <el-form ref="form2" :model="form2" :rules="rules2" label-position="right" label-width="120px">
        <el-form-item label="物料号" prop="equipmentType" style="display: inline-block">
          <el-input
            v-model="form2.equipmentType"
            placeholder="物料号"
            readonly
            size="small"/>
        </el-form-item>
        <el-form-item label="物料名" prop="equipmentTypeName" style="display: inline-block">
          <el-input
            v-model="form2.equipmentTypeName"
            clearable
            placeholder="物料名"
            size="small"/>
        </el-form-item>
        <el-form-item label="物料名简称" prop="equipmentTypeName2" style="display: inline-block">
          <el-input
            v-model="form2.equipmentTypeName2"
            clearable
            placeholder="物料名简称"
            size="small"/>
        </el-form-item>
        <el-form-item label="总装线配方号" prop="equipmentSign" style="display: inline-block">
          <el-input
            v-model="form2.equipmentSign"
            placeholder="总装线配方号"
            readonly
            size="small"/>
        </el-form-item>
        <el-form-item label="轮毂线配方号" prop="equipmentSign2" style="display: inline-block">
          <el-select
            v-model="form2.equipmentSign2"
            placeholder="请选择轮毂线配方号"
            size="small"
            style="display: inline-block">
            <el-option
              v-for="item in LunGuList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              size="mini"/>
          </el-select>
        </el-form-item>
        <el-form-item label="桥壳线配方号" prop="equipmentSign2" style="display: inline-block">
          <el-select
            v-model="form2.equipmentSign3"
            placeholder="请选择桥壳线配方号"
            size="small"
            style="display: inline-block">
            <el-option
              v-for="item in QiaoKeList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              size="mini"/>
          </el-select>
        </el-form-item>
        <!--        <el-form-item label="总成物料号" prop="itemNo" style="display: inline-block">-->
        <!--          <el-input-->
        <!--            v-model="form.itemNo"-->
        <!--            clearable-->
        <!--            size="small"-->
        <!--            placeholder="总成物料号"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="规格(大机型)" prop="boxSign" style="display: inline-block">-->
        <!--          <el-select v-model="form.boxSign" placeholder="请选择" size="small" style="display: inline-block">-->
        <!--            <el-option-->
        <!--              v-for="item in boxSign"-->
        <!--              :key="item.value"-->
        <!--              :label="item.label"-->
        <!--              :value="item.value"-->
        <!--              size="mini"/>-->
        <!--          </el-select>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="型号(小机型)" prop="tonnageSign" style="display: inline-block">-->
        <!--          <el-select v-model="form.tonnageSign" placeholder="请选择" size="small" style="display: inline-block">-->
        <!--            <el-option-->
        <!--              v-for="item in tonnageSign"-->
        <!--              :key="item.value"-->
        <!--              :label="item.label"-->
        <!--              :value="item.value"-->
        <!--              size="mini"/>-->
        <!--          </el-select>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="是否禁用" prop="enDisable" style="display: inline-block">-->
        <!--          <el-select v-model="form.enDisable" placeholder="请选择" size="small" style="display: inline-block">-->
        <!--            <el-option-->
        <!--              v-for="item in disableArr"-->
        <!--              :key="item.value"-->
        <!--              :label="item.label"-->
        <!--              :value="item.value"-->
        <!--              size="mini"/>-->
        <!--          </el-select>-->
        <!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="callOff('form2')">取消</el-button>
        <el-button size="small" type="primary" @click="submitAdd1('form2')">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible1" center style="min-height: 200px;" title="新增轮毂配方" width="400px">
      <el-form ref="form1" :model="form1" :rules="rules1" label-position="right" label-width="120px">
        <el-form-item label="轮毂号" prop="equipmentTypeName" style="display: inline-block">
          <el-input
            v-model="form1.equipmentTypeName"
            clearable
            placeholder="轮毂号"
            size="small"/>
        </el-form-item>
        <el-form-item label="轮毂线配方号" prop="equipmentType" style="display: inline-block">
          <el-input-number
            v-model="form1.equipmentType"
            :min="1"
            :step="1"
            placeholder="轮毂线配方号"
            size="small"
            style="width: 200px"/>
        </el-form-item>
      </el-form>
      <el-row style="text-align: center">
        <el-button size="small" @click="callOff_Lungu('form1')">取消</el-button>
        <el-button size="small" type="primary" @click="submitAdd_Lungu('form1')">确定</el-button>
      </el-row>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible3" center style="min-height: 200px;" title="新增桥壳配方" width="400px">
      <el-form ref="form3" :model="form3" :rules="rules3" label-position="right" label-width="120px">
        <el-form-item label="桥壳号" prop="equipmentTypeName" style="display: inline-block">
          <el-input
            v-model="form3.equipmentTypeName"
            clearable
            placeholder="桥壳号"
            size="small"/>
        </el-form-item>
        <el-form-item label="桥壳线配方号" prop="equipmentType" style="display: inline-block">
          <el-input-number
            v-model="form3.equipmentType"
            :min="1"
            :step="1"
            placeholder="桥壳线配方号"
            size="small"
            style="width: 200px"/>
        </el-form-item>
      </el-form>
      <el-row style="text-align: center">
        <el-button size="small" @click="callOff_QiaoKe('form3')">取消</el-button>
        <el-button size="small" type="primary" @click="submitAdd_QiaoKe('form3')">确定</el-button>
      </el-row>
    </el-dialog>
  </div>
</template>

<script>
import request from '@/utils/request'

export default {
  data() {
    return {
      equipmentType: '',
      equipmentType1: '', // 轮毂
      equipmentType2: '', // 桥壳
      title: '',
      title1: '',
      boxSign: [],
      tonnageSign: [],
      LunGuList: [],
      QiaoKeList: [],
      disableArr: [
        {
          label: '是',
          value: 1
        }, {
          label: '否',
          value: 0
        }
      ],
      form: { // 创建订单
        equipmentType: '',
        equipmentTypeName: '',
        equipmentTypeName2: '',
        equipmentSign: 1,
        equipmentSign2: '',
        equipmentSign3: '',
        itemNo: '',
        boxSign: '',
        tonnageSign: '',
        enDisable: 0,
        formula: '',
        ID: ''
      },
      rules: { // 创建订单验证
        equipmentSign: [{ required: true, message: '请输入总装线配方号', trigger: 'blur' }],
        equipmentSign2: [{ required: true, message: '请输入轮毂线配方号', trigger: 'blur' }],
        enDisable: [{ required: true, message: '请选择', trigger: 'change' }],
        // tonnageSign: [{ required: true, message: '请选择', trigger: 'change' }],
        // boxSign: [{ required: true, message: '请选择', trigger: 'change' }],
        equipmentType: [{ required: true, message: '请输入物料号', trigger: 'blur' }],
        equipmentTypeName: [{ required: true, message: '请输入物料名', trigger: 'blur' }],
        equipmentTypeName2: [{ required: true, message: '请输入物料名简称', trigger: 'blur' }],
        formula: [{ required: true, message: '请输入', trigger: 'blur' }]
      },
      form2: { // 创建订单
        equipmentType: '',
        equipmentTypeName: '',
        equipmentTypeName2: '',
        equipmentSign: 1,
        equipmentSign2: '',
        equipmentSign3: '',
        itemNo: '',
        boxSign: '',
        tonnageSign: '',
        enDisable: 0,
        formula: '',
        ID: ''
      },
      rules2: { // 创建订单验证
        equipmentSign: [{ required: true, message: '请输入总装线配方号', trigger: 'blur' }],
        equipmentSign2: [{ required: true, message: '请输入轮毂线配方号', trigger: 'blur' }],
        enDisable: [{ required: true, message: '请选择', trigger: 'change' }],
        // tonnageSign: [{ required: true, message: '请选择', trigger: 'change' }],
        // boxSign: [{ required: true, message: '请选择', trigger: 'change' }],
        equipmentType: [{ required: true, message: '请输入物料号', trigger: 'blur' }],
        equipmentTypeName: [{ required: true, message: '请输入物料名', trigger: 'blur' }],
        equipmentTypeName2: [{ required: true, message: '请输入物料名简称', trigger: 'blur' }],
        formula: [{ required: true, message: '请输入', trigger: 'blur' }]
      },
      form1: { // 创建订单
        equipmentType: 1,
        equipmentTypeName: '',
        ID: ''
      },
      rules1: { // 创建订单验证
        equipmentType: [{ required: true, message: '请输入轮毂配方号', trigger: 'blur' }],
        equipmentTypeName: [{ required: true, message: '请输入轮毂号', trigger: 'blur' }]
      },
      form3: { // 创建订单
        equipmentType: 1,
        equipmentTypeName: '',
        ID: ''
      },
      rules3: { // 创建订单验证
        equipmentType: [{ required: true, message: '请输入轮毂配方号', trigger: 'blur' }],
        equipmentTypeName: [{ required: true, message: '请输入轮毂号', trigger: 'blur' }]
      },
      tableData: [],
      tableData1: [],
      tableData2: [],
      dialogFormVisible: false, // 创建订单
      dialogFormVisible1: false, // 创建订单
      dialogFormVisible2: false, // 创建订单
      dialogFormVisible3: false, // 创建订单
      // total: 0, // 总条数
      // pageList: 15, // 每页显示条数
      // pageSize: 15, // 每页显示条数
      // pageCurrent: 1, // 后台获取页
      loading: false,
      loading1: false,
      loading2: false

    }
  },
  watch: {},
  created() {
    this.getBox()
    this.getTonnageSign()
    this.searchOrder()
    // this.searchOrder1()
    this.searchOrder2()
  },
  methods: {
    getBox() {
      this.boxSign = []
      request({
        url: '',
        method: 'post',
        data: {
          type: '3',
          name: `SELECT [箱体标志],[箱体名称] FROM [MES_基本变量_机型代码_箱体标志]`
        }
      }).then(response => {
        if (response.data.length) {
          for (let i = 0; i < response.data.length; i++) {
            this.boxSign.push({
              label: response.data[i].箱体名称,
              value: response.data[i].箱体标志
            })
          }
        }
      })
    },
    getTonnageSign() {
      this.tonnageSign = []
      request({
        url: '',
        method: 'post',
        data: {
          type: '3',
          name: `SELECT [吨位标志],[吨位名称]FROM [MES_基本变量_机型代码_吨位标志]`
        }
      }).then(response => {
        if (response.data.length) {
          for (let i = 0; i < response.data.length; i++) {
            this.tonnageSign.push({
              label: response.data[i].吨位名称,
              value: response.data[i].吨位标志
            })
          }
        }
      })
    },
    // 查询订单
    searchOrder() {
      this.loading = true
      this.tableData = []
      let equipmentType_check
      this.equipmentType ? (equipmentType_check = 1) : (equipmentType_check = 0)
      var param = []
      param[0] = ['发动机型号_check', equipmentType_check]
      param[1] = ['发动机型号', this.equipmentType]
      var Data = this.CreateData('11', 'MES_基本变量_机型代码_查询数据_图号', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          this.tableData = response.data
        }
        this.loading = false
      })
    },
    searchOrder2() {
      this.loading2 = true
      this.tableData2 = []
      this.QiaoKeList = []
      let equipmentType_check
      this.equipmentType2 ? (equipmentType_check = 1) : (equipmentType_check = 0)
      var param = []
      param[0] = ['发动机型号_check', equipmentType_check]
      param[1] = ['发动机型号', this.equipmentType2]
      var Data = this.CreateData('11', 'MES_基本变量_机型代码_查询数据', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          this.tableData2 = response.data
          for (let i = 0; i < response.data.length; i++) {
            this.QiaoKeList.push({
              label: response.data[i]['壳体编号型号'],
              value: response.data[i]['发动机机型标志']
            })
          }
        }
        this.loading2 = false
      })
    },
    // 创建订单
    creatOrder(formName) {
      if (this.$refs[formName] !== undefined) {
        this.$refs[formName].resetFields()
      }
      this.form.equipmentType = ''
      this.form.formula = ''
      this.form.equipmentSign = ''
      this.form.itemNo = ''
      this.form.boxSign = ''
      this.form.tonnageSign = ''
      this.form.enDisable = 0
      this.dialogFormVisible = true
    },
    // 创建订单
    creatOrder1(formName) {
      if (this.$refs[formName] !== undefined) {
        this.$refs[formName].resetFields()
      }
      this.dialogFormVisible1 = true
    },
    // 创建订单
    creatOrder2(formName) {
      if (this.$refs[formName] !== undefined) {
        this.$refs[formName].resetFields()
      }
      this.dialogFormVisible3 = true
    },
    // 提交新增订单
    submitAdd(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['发动机型号', this.form.equipmentType]
          param[1] = ['发动机机型标志', this.form.equipmentSign]
          param[2] = ['标识字符', this.form.equipmentTypeName]
          param[3] = ['工厂编号2', this.form.equipmentTypeName2]
          param[4] = ['机型代码_轮毂', this.form.equipmentSign2]
          param[5] = ['机型代码_桥壳', this.form.equipmentSign3]
          var Data = this.CreateData('11', 'MES_基本变量_机型代码_增加数据', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === 1) {
              this.$message({
                message: '增加成功',
                type: 'success'
              })
              this.dialogFormVisible = false
              this.searchOrder()
            } else {
              this.$message.error('增加失败，有重复型号！！')
            }
          })
        } else {
          return false
        }
      })
    },
    // 取消新增订单
    callOff(formName) {
      this.dialogFormVisible = false
      this.dialogFormVisible2 = false
      this.dialogFormVisible3 = false
      this.$refs[formName].resetFields()
    },
    // 删除订单
    deleteOrder(row) {
      this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var param = []
        param[0] = ['序号', row.序号]
        var Data = this.CreateData('12', 'MES_基本变量_机型代码_删除数据', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
            this.searchOrder()
          } else {
            this.$message.error('删除失败！')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 修改订单
    handleEdit(row) {
      if (this.$refs['form2'] !== undefined) {
        this.$refs['form2'].resetFields()
      }
      this.form2.equipmentType = row.发动机型号
      this.form2.equipmentSign = row.发动机机型标志
      this.form2.equipmentTypeName = row.标识字符
      this.form2.equipmentTypeName2 = row.工厂编号2
      this.form2.equipmentSign2 = row.机型代码_轮毂
      this.form2.equipmentSign3 = row.机型代码_桥壳
      this.form2.ID = row.序号
      this.dialogFormVisible2 = true
    },
    // 提交修改订单
    submitAdd1() {
      this.$refs['form2'].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['标识字符', this.form2.equipmentTypeName]
          param[1] = ['工厂编号2', this.form2.equipmentTypeName2]
          param[2] = ['机型代码_轮毂', this.form2.equipmentSign2]
          param[3] = ['机型代码_桥壳', this.form2.equipmentSign3]
          param[4] = ['序号', this.form2.ID]
          var Data = this.CreateData('12', 'MES_基本变量_机型代码_编辑数据', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: '修改成功',
                type: 'success'
              })
              this.searchOrder()
            } else {
              this.$message.error('修改失败！')
            }
          })
          this.dialogFormVisible2 = false
        } else {
          return false
        }
      })
    },
    // 提交新增订单
    submitAdd_Lungu(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['轮毂型号', this.form1.equipmentTypeName]
          param[1] = ['轮毂机型标志', this.form1.equipmentType]
          var Data = this.CreateData('11', 'MES_基本变量_机型代码_增加数据_轮毂', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === 1) {
              this.$message({
                message: '增加成功',
                type: 'success'
              })
              this.dialogFormVisible1 = false
              this.searchOrder1()
            } else {
              this.$message.error('增加失败，有重复型号！')
            }
          })
        } else {
          return false
        }
      })
    },
    // 取消新增订单
    callOff_Lungu(formName) {
      this.dialogFormVisible1 = false
      this.$refs[formName].resetFields()
    },
    // 删除订单
    deleteOrder_Lungu(row) {
      this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var param = []
        param[0] = ['序号', row.机型代码_轮毂]
        var Data = this.CreateData('11', 'MES_基本变量_机型代码_删除数据_轮毂', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
            this.searchOrder1()
          } else {
            this.$message.error('删除失败，已被使用！')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 提交新增订单
    submitAdd_QiaoKe(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['桥壳型号', this.form3.equipmentTypeName]
          param[1] = ['桥壳机型标志', this.form3.equipmentType]
          var Data = this.CreateData('11', 'MES_基本变量_机型代码_增加数据_桥壳', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === 1) {
              this.$message({
                message: '增加成功',
                type: 'success'
              })
              this.dialogFormVisible3 = false
              this.searchOrder2()
            } else {
              this.$message.error('增加失败，有重复型号！')
            }
          })
        } else {
          return false
        }
      })
    },
    // 取消新增订单
    callOff_QiaoKe(formName) {
      this.dialogFormVisible3 = false
      this.$refs[formName].resetFields()
    },
    // 删除订单
    deleteOrder_QiaoKe(row) {
      this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var param = []
        param[0] = ['序号', row.机型代码_桥壳]
        var Data = this.CreateData('11', 'MES_基本变量_机型代码_删除数据_桥壳', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
            this.searchOrder2()
          } else {
            this.$message.error('删除失败，已被使用！')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // // 分页
    // handleSizeChange(val) {
    //   this.pageCurrent = 1
    //   this.pageSize = val
    //   this.searchOrder()
    // },
    handleCurrentChange(val) {
      console.log(val)
      // this.$refs.LunGuTable.setCurrentRow()
      this.$refs.QiaoKeTable.setCurrentRow()

      // // 轮毂
      // for (const item of this.tableData1) {
      //   if (item.ID == val.机型代码_轮毂) {
      //     console.log('轮毂匹配', item.ID, val.机型代码_轮毂)
      //     this.$refs.LunGuTable.setCurrentRow(item)
      //   }
      // }

      // 桥壳
      for (const item of this.tableData2) {
        if (item.发动机机型标志 == val.总装代码) {
          console.log('桥壳匹配', item.ID, val.机型代码_桥壳)
          this.$refs.QiaoKeTable.setCurrentRow(item)
        }
      }
    }
  }
}
</script>

<style scoped>
.topCard {
  margin: 5px;
}

.topDiv {
  margin-bottom: 10px;
}

.el-select {
  width: 200px
}

.el-input {
  width: 200px
}

.text {
  font-size: 14px;
}

.item {
  padding: 18px 0;
}

.box-card {
  position: absolute;
  right: 6px;
  top: 80px;
  width: 300px;
}

.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}

/deep/ .el-input.is-disabled .el-input__inner {
  color: #606266 !important;
}

/deep/ .el-input.is-disabled .el-input__inner {
  background-color: white !important;
}
</style>

