<template>
  <div class="app-container">
    <el-card style="height: 950px">
      <el-row>
        <div style="margin-top: 7px; margin-bottom: 7px">
          <el-select  v-model="partNameValue3" style="width:400px;margin-left: 10px"  placeholder="物料名称" size="small" filterable clearable remote :remote-method="searchTable" @change="searchTable1">
            <el-option
              v-for="item in tableData3"
              :key="item.物料编码"
              :label="item.物料编码"
              :value="item.物料编码">
              
            </el-option>
          </el-select>
          
          <el-button  icon="el-icon-search" type="primary" plain size="small" style="margin-left: 10px;padding: 8px 15px;" @click="searchTable1()">查询</el-button>
          <!-- <el-button  icon="el-icon-document-copy" type="warning" plain size="small" style="margin-left: 10px;padding: 8px 15px;"  @click="copyData()">拷贝</el-button> -->
          <el-button  icon="el-icon-search" type="primary" plain size="small" style="margin-left: 10px;padding: 8px 15px;"  @click="getNum()">图纸</el-button>
          <!-- <el-button  icon="el-icon-document-copy" v-if="processStatus" type="success" plain size="small" style="margin-left: 10px;padding: 8px 15px;" >已保存</el-button> -->
          <el-button  icon="el-icon-document-copy" type="success" plain size="small" style="margin-left: 10px;padding: 8px 15px;"  @click="saveProcess()">保存</el-button>
          <!-- <el-button  type="success" plain icon="el-icon-check" size="small" style="margin-left: 10px" @click="preservation1()">保存</el-button> -->
          
          <!-- <el-button type="success" plain icon="el-icon-download" size="small" style="margin-left: 760px" @click="exportExcel()">导出</el-button>-->
        </div>
        <!-- <div style="margin: 7px;">
          原料:<span v-for="(item, index) in itemdata" :key="index">{{ item.子件编码 }}&nbsp;&nbsp;&nbsp;{{ item.子件名称 }}({{ item.子件数量 }}) &nbsp;&nbsp;&nbsp;&nbsp;{{item.子件材质}}&nbsp;&nbsp;&nbsp;&nbsp;</span>
        </div> -->
        <div style="display: flex;">
          <el-col style="margin-left: 7px;width: 158px">
            <div style="margin-top: 10px">
              <el-input
                v-model="processSearchName"
                placeholder="请输入工序名称"
                size="small"
                clearable
                style="width: 158px; margin-bottom: 10px"
                @input="filterProcess"
              />
              <el-table :data="filteredTableData4" :header-cell-style="{background: '#2283D4',color: 'white'}" highlight-current-row border size="mini" style="width: 158px;margin-top: 10px" height="700" @row-click="editProcedure">
                <el-table-column :width="setColumnWidth('日期时间')" label="工序" align="center" prop="" show-overflow-tooltip>
                  <template slot-scope="scope">
                    {{ scope.row.工艺名称 }}
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-col>

          <el-col >
            <div style="margin-top: 10px">
              
              <el-table v-loading="loading"  :data="tableData5" :header-cell-style="{background: '#19466E',color: 'white'}" highlight-current-row border size="mini" style="margin-top: 10px;width:90%" height="730" >
                <el-table-column  width="50px" label="序号" align="center" prop="工艺顺序" show-overflow-tooltip fixed>
                  <template slot-scope="scope">
                    {{ scope.row.工艺顺序 }}
                  </template>
                </el-table-column>
                <el-table-column  width="130px" label="工序名称" align="center" prop="工艺名称" show-overflow-tooltip fixed>
                  <template slot-scope="scope">
                    {{ scope.row.工艺名称 }}
                  </template>
                </el-table-column>
                
                <el-table-column label="准备工时" align="center" prop="准备工时" show-overflow-tooltip>
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.准备工时" size="mini" style="margin: 0;width: 100%" @change="updateProcess(scope.row)"/>
                  </template>
                </el-table-column>
                <el-table-column  label="标准工时" align="center" prop="标准工时" show-overflow-tooltip>
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.标准工时" size="mini" style="margin: 0;width: 100%" @change="updateProcess(scope.row)"/>
                  </template>
                </el-table-column>
                <el-table-column label="工时合计" align="center" prop="工时合计" show-overflow-tooltip>
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.工时合计" size="mini" style="margin: 0;width: 100%" @change="updateProcess(scope.row)"/>
                  </template>
                </el-table-column>
                <el-table-column  label="工装量具" align="center" width="150px">
                  <template slot-scope="scope">
                    <el-select  v-model="scope.row.工卡量具" multiple placeholder="工装量具" size="small" filterable clearable @change="updateProcess(scope.row)">
                      <el-option
                        v-for="item in basedatagj"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id">
                      </el-option>
                    </el-select>
                  </template>
                </el-table-column>
                <el-table-column label="指定机床" align="center" width="150px" >
                  <template slot-scope="scope">
                    <el-select  v-model="scope.row.指定机床" multiple placeholder="指定机床" size="small" filterable clearable @change="updateProcess(scope.row)">
                      <el-option
                        v-for="item in basedatajc"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id">
                      </el-option>
                    </el-select>
                  </template>
                </el-table-column>
                <el-table-column label="车间" align="center" width="150px">
                  <template slot-scope="scope">
                    <el-select  v-model="scope.row.车间"  placeholder="车间" size="small" filterable clearable @change="updateProcess(scope.row)">
                      <el-option
                        v-for="item in basedatacj"
                        :key="item.id"
                        :label="item.name"
                        :value="item.name">
                      </el-option>
                    </el-select>
                  </template>
                </el-table-column>
                <el-table-column width="330px" label="工序说明" align="center" prop="" show-overflow-tooltip>
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.工艺要求" size="mini" style="margin: 0;width: 100%" @change="updateProcess(scope.row)"/>
                  </template>
                </el-table-column>
                <el-table-column width="200px" label="备注" align="center" prop="" show-overflow-tooltip>
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.备注" size="mini" style="margin: 0;width: 100%" @change="updateProcess(scope.row)"/>
                  </template>
                </el-table-column>
                <el-table-column label="操作" align="center" width="200px"  fixed="right">
                  <template slot-scope="scope">
                    <el-tooltip :open-delay="700" effect="dark" content="下移工序" placement="top">
                      <el-button type="text" icon="el-icon-bottom" size="mini" style="margin-right: 5px" @click="downOne(scope.row)"/>
                    </el-tooltip>
                    <el-tooltip :open-delay="700" effect="dark" content="上移工序" placement="top">
                      <el-button type="text" icon="el-icon-top" size="mini" style="margin-right: 5px" @click="upOne(scope.row)"/>
                    </el-tooltip>
                    <el-tooltip :open-delay="700" effect="dark" content="插入工序" placement="top">
                      <el-button type="text" icon="el-icon-plus" size="mini" style="margin-right: 5px" @click="insertOne(scope.row)"/>
                    </el-tooltip>
                    <el-tooltip :open-delay="700" effect="dark" content="删除工序" placement="top">
                      <el-button type="text" icon="el-icon-minus" size="mini" style="margin-right: 5px" @click="deleteOne(scope.row)"/>
                    </el-tooltip>
                    <!-- <el-tooltip :open-delay="700" effect="dark" content="上传工艺指导" placement="top">
                      <el-button :disabled="!scope.row.工艺名称" type="text" icon="el-icon-upload2" size="mini" style="margin-right: 5px" @click="ProcessTool(scope.row)"/>
                    </el-tooltip> -->
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-col>
        </div>
        <el-dialog :visible.sync="dialogFormVisible" title="工艺拷贝" center style="min-height: 300px;" width="1100px">
      <el-row style="margin-bottom: 10px">
        <template>
          <el-checkbox v-model="processprodutc" @change = 'copyData'>生产工艺</el-checkbox>
        </template>
        <el-select v-if ="processprodutc" v-model="partNameValue2" style="width:400px;margin-left: 10px" placeholder="生产工艺物料名称" size="small" filterable clearable clea @change="searchTable3" >
          <el-option
            v-for="item in tableData7"
            :key="item.AID"
            :label="item.物料编号"
            :value="item.物料编号">
           
          </el-option>
        </el-select>
        <el-select v-else v-model="partNameValue2" style="width:400px;margin-left: 10px" placeholder="物料名称" size="small" filterable clearable  @change="searchTable2" >
          <el-option
            v-for="item in tableData7"
            :key="item.id"
            :label="item.零件图号"
            :value="item.零件图号">
            
          </el-option>
        </el-select>
      </el-row>
      <el-table :data="tableData6" :header-cell-style="{background: '#383E4B',color: 'white'}" size="mini" style="width: 100%;margin-top:15px" height="500px" border highlight-current-row>
        <el-table-column label="序号" align="center" prop="工艺顺序"  show-overflow-tooltip>

        </el-table-column>
        <el-table-column label="工序名称" align="center" prop="工艺名称" show-overflow-tooltip>

        </el-table-column>
        <el-table-column label="工序说明" align="center" prop="工艺要求" show-overflow-tooltip>

        </el-table-column>
        <el-table-column label="准备工时" align="center" prop="准备工时" show-overflow-tooltip>

        </el-table-column>
        <el-table-column  label="标准工时" align="center" prop="标准工时" show-overflow-tooltip>

        </el-table-column>
        <el-table-column label="工时合计" align="center" prop="工时合计" show-overflow-tooltip>

        </el-table-column>
        <el-table-column  label="工装量具" align="center" width="150px">
          <template slot-scope="scope">
            <el-select  v-model="scope.row.工卡量具" disabled multiple placeholder="工装量具" size="small" filterable clearable >
              <el-option
                v-for="item in basedatagj"
                :key="item.id"
                :label="item.name"
                :value="Number(item.id)">
              </el-option>
            </el-select>
          </template>
        </el-table-column>
        <el-table-column label="指定机床" align="center" width="150px" >
            <template slot-scope="scope">
              <el-select  v-model="scope.row.指定机床" disabled multiple placeholder="指定机床" size="small" filterable clearable >
                <el-option
                  v-for="item in basedatajc"
                  :key="item.id"
                  :label="item.name"
                  :value="Number(item.id)">
                </el-option>
              </el-select>
            </template>
          </el-table-column>
        <el-table-column label="车间" align="center" prop="车间" width="150px">
          <template slot-scope="scope">
            <el-select  v-model="scope.row.车间"  placeholder="车间" size="small" disabled filterable clearable >
              <el-option
                v-for="item in basedatacj"
                :key="item.id"
                :label="item.name"
                :value="item.name">
              </el-option>
            </el-select>
          </template>
        </el-table-column>
        <el-table-column width="200px" label="备注" align="center" prop="备注" >
                  
         </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" style="margin-left: 10px;padding: 8px 15px;" @click="dialogFormVisible=false">取消</el-button>
        <el-button type="primary" size="small" style="margin-left: 10px;padding: 8px 15px;" @click="submitCopy">确定</el-button>
      </div>
    </el-dialog>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { MESDownFile } from '@/utils/request'
export default {
  data() {
    return {
      processprodutc:false,
      partTool: '',
      state: 1,
      form:{
        物料编号:'',
      },
      productNameValue: '', // 产品部件名称
      productName: [], // 产品部件名称数组
      partNameValue: '', // 零件名称
      partNameLabel: '', // 零件名称
      partName: [], // 零件名称数组
      partNameValue1: '', // 零件名称
      productValue1: '',
      partName1: [], // 零件名称数组
      partName2: [], // 零件名称数组
      partNameValue2: '', // copy零件名称
      partNameLabel2: '',
      partNameValue3:'',// 零件名称
      partNameValue4:'',// 计划数
      dateRange: '', // 提交日期
      dialogVisible: false,
      dialogVisible1: false,
      dialogFormVisible: false,
      disabled: true,
      checked: false,
      hadFile: [],
      fileList: [],
      hadFile1: [],
      processValue: '',
      dialogName: true,
      showFileList: false,
      action: '',
      product1: [], // 产品名称数组
      loading: false, // 数据加载
      total: 0, // 分页总数
      tableData4: [], // 工艺列表
      tableData3: [], // 零件列表
      filteredTableData4: [], // 过滤后的工艺列表
      processSearchName: '', // 工序搜索框内容
      tableData5: [], // 工艺内容
      tableData6: [],
      tableData7: [],// 有工艺的物料组
      pageCurrent: 1, // 分页当前页
      pageSize: 100, // 分页每页显示条数
      orderName: '', // 排序列名
      order: '', // 排序方式
      materialarr:[],
      basedata:[],
      basedatagj:[],
      basedatajc:[],
      basedatacj:[],
      basedatavalue1:'',
      basedatavalue2:'',
      basedatavalue3:'',
      downPDF:MESDownFile,
      insertidx:0,
      processStatus:0,
      itemdata:[]
    }
  },
  computed: {
    ...mapGetters([
      'id',
      'token'
    ])
  },
  watch: {
    partNameValue(val) {
      if (val) {
        this.disabled = false
      } else {
        this.disabled = true
      }
    }
  },
  created() {
    this.searchTable()
    this.getProcess()
    this.getbasedata()
    
  },
  methods: {
    getitemdata(item){
      var param = []
      this.itemdata = []
      param.push(["订单编号",item])
      var Data = this.CreateData('11', '工艺管理_获取物料原料信息',param)
      this.ExecDatabase(Data).then(response => {
        response.data.forEach(element => {
          if(element.U_MoType  == '机加件'){
            this.itemdata.push({
              '子件编码':element.子件编码,
              '子件名称':element.子件名称,
              '计划数量':element.计划数量,
              '材质':element.材质,
              '基本数量':element.基本数量,
              '存货量':element.存货量,
              '待出数量':element.待出数量,
              '拣配数量':element.拣配数量,
            })
          }
        })
      })
    },
    getbasedata(){
      var Data = this.CreateData('11', '设备管理_设备信息_查询')
      this.ExecDatabase(Data).then(response => {
        response.data.forEach(element => {
          if(element.设备类型名称 == '量具'){
            this.basedatagj.push({
              name:element.设备名称,
              id:element.设备流水号
            })
          }
          if(element.设备类型名称 == '机床'){
            this.basedatajc.push({
              name:element.设备名称,
              id:element.设备流水号
            })
          }
          if(element.设备类型名称 == '车间'){
            this.basedatacj.push({
              name:element.设备名称,
              id:element.设备流水号
            })
          }
          
        });
        this.basedata = response.data
        this.loading = false
        console.log(this.basedatajc)
      })
    },
    searchTable(query='') {

      this.loading = true
      var param = []
      param.push(["过滤",query])
      var Data = this.CreateData('11', '工艺管理_生产计划物料查询', param)
      this.ExecDatabase(Data).then(response => {
        this.tableData3 = response.data
        this.loading = false
        console.log(this.tableData3)
      })

    },
    copyData() {
      if(!this.partNameValue3){
        this.$message.error('请先选择物料')
        return
      }
      this.dialogFormVisible = true
      this.loading = true
      this.partNameValue2 = ''
      if(this.processprodutc){
        var Data = this.CreateData('11', '工艺管理_生产工艺_生产工艺拷贝')
        this.ExecDatabase(Data).then(response => {
          this.tableData7 = response.data
          this.loading = false
          console.log(this.tableData7)
        })
      }else{
        var Data = this.CreateData('11', '工艺管理_生产工艺_标准工艺拷贝')
        this.ExecDatabase(Data).then(response => {
          this.tableData7 = response.data
          this.loading = false
          console.log(this.tableData7)
        })
      }
      
      
    },

    // ordernum(val){
    //   this.partNameValue3 = ''
    //   this.materialarr = []
    //   this.form = []
    //   this.tableData3.forEach(item => {
    //     console.log(item.订单编号,val)
    //     if (item.订单编号 == val){
    //       this.materialarr.push(item)
    //       this.form = {
    //         物料编号:item.物料编号,
    //         工序状态:'',
    //         下达时间:item.下达日期,
    //         要求完成时间:item.计划完成,
    //         零件材质:'',
    //         成活尺寸:'',
    //         数量:item.计划数量,
    //         备注:item.备注,
    //       }
    //     }
    //   });
    //   console.log(this.form)
    // },
    searchTable1(val) {
      // this.materialarr.forEach(item => {
      //   if (item.物料编号 == val){
      //     this.partNameValue4 = item.计划数量
      //   }
      // });
      this.loading = true
      var param = []
      param[0] = ['物料编号',this.partNameValue3]
      // this.getitemdata(this.partNameValue3)
      var Data = this.CreateData('11', 'MES_ProcessManagement_ProcessBindGet', param)
      this.ExecDatabase(Data).then(response => {
        // if(response.data[0].length>0){
          // this.getPartProcess(response.data)
          this.loading = false
          this.tableData5 = response.data
          this.processStatus = 0
          this.fninsertidx()
          console.log(response.data)
        // }
      })
    },
    searchTable2() {
      this.loading = true
      var param = []
      param[0] = ['物料编号',this.partNameValue2]
      var Data = this.CreateData('11', 'MES_ProcessManagement_ProcessBindGet', param)
      this.ExecDatabase(Data).then(response => {
        // if(response.data[0].length>0){
          // this.getPartProcess(response.data)
          this.loading = false
          this.tableData6 = response.data
          this.datadoing()
          
      })
    },
    searchTable3() {
      this.loading = true
      var param = []
      param[0] = ['物料编号',this.partNameValue2]
      var Data = this.CreateData('11', '工艺管理_制定标准工艺_拷贝生产工艺', param)
      this.ExecDatabase(Data).then(response => {
        // if(response.data[0].length>0){
          // this.getPartProcess(response.data)
          this.loading = false
          this.tableData6 = response.data
          this.datadoing()
          
      })
    },
    datadoing(){
      this.tableData6.forEach(item => {
        if(item.工卡量具){
          item.工卡量具 = item.工卡量具.split(",").map(Number)
          console.log(item.工卡量具)
        }
        if(item.指定机床){
          item.指定机床 = item.指定机床.split(",").map(Number)
        }
      });
    },
    // getPartProcess(Processid) {
    //   var param = []
    //   var Processids = ''
    //   Processid.forEach(item => {
    //     if(item.工艺编号){
    //       Processids = Processids + item.工艺编号 +","
    //     } 
    //   })
    //   console.log(Processids)
    //   param[0] = ['工艺编号',Processids]
    //   var Data = this.CreateData('11', 'MES_ProcessManagement_ProcessGet', param)
    //   this.ExecDatabase(Data).then(response => {
    //     const result1 = this.tableData5.map(item1 => {
    //       const matchedItem = response.data.find(item2 => item2.工艺编号 === item1.工艺编号);
    //         if(matchedItem){
    //           return {
    //             ...item1,
    //             工艺名称: matchedItem.工艺名称 
    //           };
    //         }else{
    //           return {
    //             ...item1,
    //             工艺名称: ""
    //           };
    //         }
    //       });
    //     this.tableData5 = result1
    //     this.loading = false
    //   })
      
    // },
    getProcess() {
      var param = []
      // 参数数量与名称要与存储过程对应
      param[0] = ['工艺编号','']
      var Data = this.CreateData('11', 'MES_ProcessManagement_ProcessGet', param)
      this.ExecDatabase(Data).then(response => {
        this.tableData4 = response.data
        this.filteredTableData4 = response.data
      })
    },
    // 过滤工序
    filterProcess() {
      if (this.processSearchName) {
        this.filteredTableData4 = this.tableData4.filter(item => {
          return item.工艺名称.includes(this.processSearchName)
        })
      } else {
        this.filteredTableData4 = this.tableData4
      }
    },
    submitCopy() {
      if (this.partNameValue2 == '') {
        this.$message.warning('请先选择零件')
        return
      }
      var processtype = 0
      if(this.processprodutc){
        processtype = 1
      }
        var param1 = []
        param1[0] = ['物料编号', this.partNameValue3]
        param1[1] = ['零件图号', this.partNameValue2]
        param1[2] = ['工艺类型', processtype]
        // 参数数量与名称要与存储过程对应
        var Data1 = this.CreateData('12', '工艺管理_制定标准工艺_拷贝工艺保存', param1)
        this.ExecDatabase(Data1).then(response => {
          if (response.data[0].result === '1') {
            this.$message.success('拷贝成功')
            this.searchTable1()
            this.dialogFormVisible = false
          } else {
            this.$message.error('拷贝失败')
          }
        })
      
    },

    getNum() {
      var param = []
      if(!this.partNameValue3){
        this.$message.error('请先选择物料')
      }
      param[0] = ['物料编号',this.partNameValue3]
      var Data = this.CreateData('11', '工艺管理_工艺维护_查看图纸', param)
      this.ExecDatabase(Data).then(response => {
        console.log(response)
        if (response.data.length > 0) {
          var pdfSrc =""+this.downPDF+""+ response.data[0].uid+".pdf"
          console.log(this.downPDF)
          console.log(response.data[0].uid)
          console.log(pdfSrc)
          window.open(pdfSrc,'_blank')
        }else{
          this.$message.error('未上传图纸')
        }
      })
    },
    fninsertidx(){

      this.tableData5.forEach(item => {
        if(!item.工艺名称){
          this.insertidx = item.id
        }
        if(item.工卡量具){
          item.工卡量具 = item.工卡量具.split(",").map(Number)
          console.log(item.工卡量具)
        }
        if(item.指定机床){
          item.指定机床 = item.指定机床.split(",").map(Number)
        }
      });
    },
    editProcedure(row) {
      if(!this.partNameValue3){
        this.$message.error('请先选择物料')
        return
      }
      console.log(this.insertidx)
      if(this.insertidx){
        var param1 = []
        param1[0] = ['工艺编号', row.工艺编号]
        param1[1] = ['idd', this.insertidx]
        param1[2] = ['物料编号', this.partNameValue3]
        this.updateProcess2(param1)
      }else{
        var param1 = []
        param1[0] = ['工艺编号', row.工艺编号]
        param1[1] = ['物料编号', this.partNameValue3]
        // param1[2] = ['计划数量', this.partNameValue4]
        // 参数数量与名称要与存储过程对应
        var Data1 = this.CreateData('11', '车间生产管理工艺_零件工序_修改数据_工艺库', param1)
        this.ExecDatabase(Data1).then(response => {
          var param = []
          param[0] = ['物料编号', this.partNameValue3]
          var Data = this.CreateData('11', '车间生产管理工艺_零件工序_查询工序信息_工艺库', param)
          this.ExecDatabase(Data).then(response => {
            this.tableData5 = response.data
            this.fninsertidx()
            this.processStatus = 0
          })
        })
      }
      
    },

    updateProcess(row) {
      
        var param1 = []
        let 工卡量具 = []
        if (row.工卡量具) {
          if (Array.isArray(row.工卡量具)) {
            // 如果已经是数组，直接使用
            工卡量具 = row.工卡量具
          } else if (typeof row.工卡量具 === 'object' && row.工卡量具 !== null) {
            // 如果是对象，转换为数组
            工卡量具 = Object.values(row.工卡量具)
          } else if (typeof row.工卡量具 === 'string') {
            // 如果是字符串，尝试解析或分割
            工卡量具 = row.工卡量具.split(',').filter(item => item.trim() !== '')
          }
        }
        
        // 安全处理指定机床
        let 指定机床 = []
        if (row.指定机床) {
          if (Array.isArray(row.指定机床)) {
            指定机床 = row.指定机床
          } else if (typeof row.指定机床 === 'object' && row.指定机床 !== null) {
            指定机床 = Object.values(row.指定机床)
          } else if (typeof row.指定机床 === 'string') {
            指定机床 = row.指定机床.split(',').filter(item => item.trim() !== '')
          }
        }
        param1[0] = ['idd', row.id]
        param1[1] = ['工艺要求', row.工艺要求]
        param1[2] = ['准备工时', row.准备工时]
        param1[3] = ['标准工时', row.标准工时]
        param1[4] = ['工时合计', row.工时合计]
        param1[5] = ['工卡量具', 工卡量具]
        param1[6] = ['指定机床', 指定机床]
        param1[7] = ['车间', row.车间]
        param1[8] = ['备注', row.备注]
        console.log(param1[5])
        var Data1 = this.CreateData('11', '车间生产管理工艺_零件工序_编辑_工艺库', param1)
        this.ExecDatabase(Data1).then(response => {
          
        })
      
    },
    updateProcess2(row) {
      console.log(row)
      var Data1 = this.CreateData('11', '车间生产管理工艺_零件工序_编辑插入行', row)
      this.ExecDatabase(Data1).then(response => {
        var param1 = []
        param1[0] = ['物料编号', this.partNameValue3]
        // 参数数量与名称要与存储过程对应
        var Data1 = this.CreateData('11', '车间生产管理工艺_零件工序_查询工序信息_工艺库', param1)
        this.ExecDatabase(Data1).then(response => {
          this.tableData5 = response.data
          this.fninsertidx()
          this.insertidx = 0
          this.processStatus = 0
        })
      })
      
    },
    deleteOne(row) { // 删除行
        var param1 = []
        param1[0] = ['物料编号', this.partNameValue3]
        param1[1] = ['idd', row.id]
        // 参数数量与名称要与存储过程对应
        var Data1 = this.CreateData('11', '车间生产管理工艺_零件工序_删除工序_工艺库', param1)
        this.ExecDatabase(Data1).then(response => {
          var param1 = []
          param1[0] = ['物料编号', this.partNameValue3]
          // 参数数量与名称要与存储过程对应
          var Data1 = this.CreateData('11', '车间生产管理工艺_零件工序_查询工序信息_工艺库', param1)
          this.ExecDatabase(Data1).then(response => {
            this.tableData5 = response.data
            this.fninsertidx()
            this.processStatus = 0
          })
        })
    },
    upOne(row) { // 上移
      
        var param1 = []
        param1[0] = ['物料编号', this.partNameValue3]
        param1[1] = ['idd', row.id]
        // 参数数量与名称要与存储过程对应
        var Data1 = this.CreateData('11', '车间生产管理工艺_零件工序_上移工序_工艺库', param1)
        this.ExecDatabase(Data1).then(response => {
          var param1 = []
          param1[0] = ['物料编号', this.partNameValue3]
          // 参数数量与名称要与存储过程对应
          var Data1 = this.CreateData('11', '车间生产管理工艺_零件工序_查询工序信息_工艺库', param1)
          this.ExecDatabase(Data1).then(response => {
            this.tableData5 = response.data
            this.fninsertidx()
            this.processStatus = 0
          })
        })
      
    },
    downOne(row) { // 下移
      
        var param1 = []
        param1[0] = ['物料编号', this.partNameValue3]
        param1[1] = ['idd', row.id]
        // 参数数量与名称要与存储过程对应
        var Data1 = this.CreateData('11', '车间生产管理工艺_零件工序_下移工序_工艺库', param1)
        this.ExecDatabase(Data1).then(response => {
          var param1 = []
          param1[0] = ['物料编号', this.partNameValue3]
          // 参数数量与名称要与存储过程对应
          var Data1 = this.CreateData('11', '车间生产管理工艺_零件工序_查询工序信息_工艺库', param1)
          this.ExecDatabase(Data1).then(response => {
            this.tableData5 = response.data
            this.fninsertidx()
            this.processStatus = 0
          })
        })
      
    },

    insertOne(row) { // 插入行
      console.log(row)
      var param1 = []
      param1[0] = ['零件图号', this.partNameValue3]
      param1[1] = ['idd', row.id]
      var Data1 = this.CreateData('11', '车间生产管理工艺_零件工序_插入工序_工艺库', param1)
      this.ExecDatabase(Data1).then(response => {
        this.insertidx = response.data.Column1
        var param3 = []
        param3[0] = ['物料编号', this.partNameValue3]
        // 参数数量与名称要与存储过程对应
        var Data3 = this.CreateData('11', '车间生产管理工艺_零件工序_查询工序信息_工艺库', param3)
        this.ExecDatabase(Data3).then(response => {
          this.tableData5 = response.data
          this.fninsertidx()
          this.processStatus = 0
        })
      })
    },
    saveProcess(){
      if(!this.partNameValue3){
        this.$message.error('请先选择物料')
        return
      }
      var param1 = []
      param1[0] = ['物料编号', this.partNameValue3]
      var Data1 = this.CreateData('11', '车间生产管理工艺_零件工序_启用', param1)
      this.ExecDatabase(Data1).then(response => {
        var param3 = []
        param3[0] = ['物料编号', this.partNameValue3]
        this.$message.success('保存成功')
        // 参数数量与名称要与存储过程对应
        // var Data3 = this.CreateData('11', '车间生产管理工艺_零件工序_查询工序信息_工艺库', param3)
        // this.ExecDatabase(Data3).then(response => {
        //   this.tableData5 = response.data
        //   this.fninsertidx()
        //   this.processStatus = 0
        // })
      })
    }
    
  }
}
</script>

<style scoped>
  .topplanbox{
    display: flex;
    justify-content: left;
    flex-wrap: wrap;
    align-items: center;
  }
  .topplanbox .el-form-item{
    display: inline-block;
    width: 26%;
  }
  .el-form--label-left >>> .el-form-item__label {
    text-align: right;
  }
  .el-button{
    width: auto;
    padding: 0px;
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }

  /* >>>.el-dialog--center .el-dialog__body {
    text-align: initial;
    padding: 20px 30px 20px
  }
  >>>.el-dialog__header {
    padding: 20px 20px 0px;
  }
  >>>.el-dialog__footer {
    padding: 0px 20px 20px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }
  >>>.el-form-item {
    margin-bottom: 13px;
  } */
  .wrapper{
    width: 90%;
    height: 50px;
    overflow: hidden;
    border: 1px solid #b8c7d9;
    /*float: left;*/
    margin: 10px;
  }
  .content{
    position: relative;
    padding: 8px 8px 0 8px;
  }
  .action{
    position: absolute;
    top: 2px;
    right: 8px;
  }
  .delete{
    padding: 0 5px;
    border-radius: 3px;
    color: #0f84b0;
    font-size: 12px;
  }
  .delete:hover{
    background: -webkit-linear-gradient(top,#0ba9e3,#0099d3);
    color: #fff;
  }
  a{
    text-decoration: none;
  }
  .icon{
    width: 30px;
    height: 30px;
    display: inline-block;
    margin-right: 7px;
    margin-top: 2px;
    font-size: 26px;
  }
  .info{
    width: 160px;
    height: 50px;
    position: absolute;
    left: 44px;
    line-height: 30px;
    display: inline-block;
    color: #999;
  }
  ::v-deep .el-table__body-wrapper,::v-deep .el-table__footer-wrapper,::v-deep .el-table__header-wrapper {
    width: 90%;
}
</style>
