<template>
  <div class="app-container">

    <el-card>
      <el-radio-group v-model="radio" size="small" style="margin: 10px;" @change="CraftmenValue = '';checked = false;partNumValue = '';typeValue = '';partName = '';material = '';materialName = '';prepareMateriel = '';spec = '';batchNum = '';searchParts()">
        <el-radio v-model="radio" :label="1">未编制</el-radio>
        <el-radio v-model="radio" :label="2">已编制</el-radio>
      </el-radio-group>
      <span>工艺员:</span>
      <el-select v-model="CraftmenValue" placeholder="工艺员" size="small" style="width:100px" @change="clearDetail();searchParts()">
        <el-option
          v-for="item in Craftmen"
          :key="item.value"
          :label="item.label"
          :value="item.value"/>
      </el-select>
      <span>零件号:</span>
      <el-select v-model="partNumValue" filterable clearable placeholder="零件号" size="small" @clear="clearDetail" @change="searchParts();searchDetail()">
        <el-option
          v-for="item in partNum"
          :key="item.value"
          :label="item.label"
          :value="item.value"/>
      </el-select>
      <el-button type="success" icon="el-icon-search" style="margin: 10px;" size="small" @click="searchDetail">查询</el-button>
      <el-checkbox v-model="checked" :disabled="isShow2" size="small" style="margin:10px">是否核准</el-checkbox>
      <el-button v-show="isShow2" type="danger" icon="el-icon-edit" size="small" @click="returnEdit">在制零件工艺调整</el-button>
      <el-button v-show="false" plain size="small" style="margin: 10px;float:right" @click="switchEdit()">切换编辑模式</el-button>
      <div v-show="isShow">
        <span>种类:</span>
        <el-input v-model="typeValue" placeholder="种类" size="small" readonly style="width:100px"/>
        <span>零件名称:</span>
        <el-input v-model="partName" placeholder="零件名称" size="small" readonly style="width:115px"/>
        <span>投产总数量:</span>
        <el-input v-model="batchNum" readonly size="small" style="width:80px;margin-top:10px;"/>
        <span>物料:</span>
        <el-input v-model="materialName" placeholder="物料" size="small" style="width:215px" readonly>
          <el-button slot="prepend" icon="el-icon-search" @click="dialogMaterial=true"/>
          <el-button slot="append" icon="el-icon-cjn-09" @click="saveMaterial"/>
        </el-input>
        <!--<span>规格:</span>-->
        <!--<el-input v-model="spec" :readonly="isShow2" style="width:100px" size="small" placeholder="规格"/>-->
      </div>
      <div>
        <el-row>
          <el-col :span="4">
            <span>物料类型:</span>
            <el-select v-model="materielValue" size="small" style="margin-top: 20px;width:120px" placeholder="物料类型" @change="clear()">
              <el-option
                v-for="item in materiel"
                :key="item.value"
                :label="item.label"
                :value="item.value"/>
            </el-select>
          </el-col>

          <el-col v-show="materielValue==='1'||materielValue==='6'||materielValue==='7'||materielValue==='8'" :span="20">
            <span>直径:</span>
            <el-input-number v-model="diameter" size="small" controls-position="right" style="width:100px;margin-top:20px;"/>
            <span>长度:</span>
            <el-input-number v-model="height2" size="small" controls-position="right" style="width:100px;margin-top:20px;"/>
            <el-button style="margin-top: 20px;margin-left: 10px;" type="primary" size="small" @click="Calculation1()">计算重量</el-button>
            <span>重量:</span>
            <el-input v-model="weight" style="width:150px" size="small" placeholder="重量">
              <el-button slot="append" icon="el-icon-cjn-09" @click="saveWeight"/>
            </el-input>
            <!--∮ ° # □ ∥ ± × Ⅰ Ⅱ Ⅲ ⊥ ％ ■ ∠ mm ◎ ○ δ μm ／ ◇ ()-->
            <!--<el-button style="margin-top: 20px;margin-left: 10px;" type="primary" size="small" @click="insertThestring()">计算重量</el-button>-->
          </el-col>

          <el-col v-show="materielValue==='2'||materielValue==='9'||materielValue==='10'||materielValue==='11'" :span="20">
            <span>长:</span>
            <el-input-number v-model="Length" size="small" controls-position="right" style="width:100px;margin-top:20px;"/>
            <span>宽:</span>
            <el-input-number v-model="Width" size="small" controls-position="right" style="width:100px;margin-top:20px;"/>
            <span>厚:</span>
            <el-input-number v-model="height1" size="small" controls-position="right" style="width:100px;margin-top:20px;"/>
            <el-button style="margin-top: 20px;margin-left: 10px;" type="primary" size="small" @click="Calculation2()">计算重量</el-button>
            <span>重量:</span>
            <el-input v-model="weight" style="width:150px" size="small" placeholder="重量">
              <el-button slot="append" icon="el-icon-cjn-09" @click="saveWeight"/>
            </el-input>
          </el-col>

          <el-col v-show="materielValue==='3'" :span="20">
            <span>对边宽:</span>
            <el-input-number v-model="OppositeSideWidth" size="small" controls-position="right" style="width:100px;margin-top:20px;"/>
            <span>长度:</span>
            <el-input-number v-model="length2" size="small" controls-position="right" style="width:100px;margin-top:20px;"/>
            <el-button style="margin-top: 20px;margin-left: 10px;" type="primary" size="small" @click="Calculation3()">计算重量</el-button>
            <span>重量:</span>
            <el-input v-model="weight" style="width:150px" size="small" placeholder="重量">
              <el-button slot="append" icon="el-icon-cjn-09" @click="saveWeight"/>
            </el-input>
          </el-col>

          <el-col v-show="materielValue==='4'" :span="20">
            <span>边宽:</span>
            <el-input-number v-model="biankuan" size="small" controls-position="right" style="width:100px;margin-top:20px;"/>
            <span>边厚:</span>
            <el-input-number v-model="bianhou" size="small" controls-position="right" style="width:100px;margin-top:20px;"/>
            <span>长度:</span>
            <el-input-number v-model="changdu" size="small" controls-position="right" style="width:100px;margin-top:20px;"/>
            <el-button style="margin-top: 20px;margin-left: 10px;" type="primary" size="small" @click="Calculation4()">计算重量</el-button>
            <span>重量:</span>
            <el-input v-model="weight" style="width:150px" size="small" placeholder="重量">
              <el-button slot="append" icon="el-icon-cjn-09" @click="saveWeight"/>
            </el-input>
          </el-col>

          <el-col v-show="materielValue==='5'" :span="20">
            <span>壁厚:</span>
            <el-input-number v-model="bihou" size="small" controls-position="right" style="width:100px;margin-top:20px;"/>
            <span>外径:</span>
            <el-input-number v-model="waijing" size="small" controls-position="right" style="width:100px;margin-top:20px;"/>
            <span>长度:</span>
            <el-input-number v-model="changdu2" size="small" controls-position="right" style="width:100px;margin-top:20px;"/>
            <el-button style="margin-top: 20px;margin-left: 10px;" type="primary" size="small" @click="Calculation5()">计算重量</el-button>
            <span>重量:</span>
            <el-input v-model="weight" style="width:150px" size="small" placeholder="重量">
              <el-button slot="append" icon="el-icon-cjn-09" @click="saveWeight"/>
            </el-input>
          </el-col>

        </el-row>
      </div>
    </el-card>

    <el-card>
      <el-row>
        <span>输入数值:</span>
        <el-input v-model="numVal" size="small" style="width:100px" placeholder="输入数值"/>
        <span>选择参数:</span>
        <el-select v-model="selParaValue" size="small" style="width:100px" placeholder="选择参数">
          <el-option
            v-for="item in selPara"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
        </el-select>
        <span>公差:</span>
        <el-input v-model="tolerance" size="small" style="width:150px" placeholder="公差"/>
        <el-button style="margin:10px" type="primary" size="small" @click="calTol()">计算公差</el-button>
        <el-button-group v-if="isShow1" style="margin: 10px">
          <el-button v-if="isShow1" type="info" size="small" icon="el-icon-document" @click="pasteTable">粘贴</el-button>
          <el-button v-if="true" :disabled="disabled" type="warning" size="small" icon="el-icon-tickets" @click="DYbtn">原有</el-button>
          <el-button :disabled="disabled" type="warning" size="small" icon="el-icon-tickets" @click="WYbtn">完艺</el-button>
          <el-button :disabled="disabled" type="danger" size="small" icon="el-icon-delete" @click="deleteTable">删除</el-button>
          <el-button v-if="isShow1" type="primary" size="small" icon="el-icon-tickets" @click="copyAndSave">复制并保存</el-button>
          <el-button :disabled="disabled" type="primary" size="small" icon="el-icon-tickets" @click="saveApprove">保存</el-button>
        </el-button-group>
      </el-row>
      <el-table
        v-loading="loading0"
        :data="tableData"
        border
        style="width: 100%;max-height: 550px;"
        size="mini"
        height="550px">
        <el-table-column prop="num" label="序号" width="50" align="center" type="index"/>
        <el-table-column prop="name" label="工艺名称" width="230" align="center">
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.工艺名称"
              :disabled="disabled"
              size="mini"
              readonly
              style="width:200px"
              @dblclick.native="tableSearch(scope.$index)"/>
          </template>
        </el-table-column>
        <el-table-column prop="hard" label="难度等级" width="110" align="center">
          <template slot-scope="scope">
            <el-select
              v-model="scope.row.工艺难度等级"
              :disabled="disabled"
              size="mini"
              @change="hardEdit(scope.row)">
              <el-option v-for="item in hard" :key="item.value" :label="item.label" :value="item.value">
                <span style="color: #8492a6; font-size: 13px">{{ item.value }}</span>
              </el-option>
            </el-select>
          </template>
        </el-table-column>
        <el-table-column prop="request" label="工艺要求" align="center" min-width="350">
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.工艺要求"
              :rows="1"
              :disabled="disabled"
              size="mini"
              type="textarea"
              @dblclick.native="tableSearch(scope.$index)"
              @change="requestEdit(scope.row)"/>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="300" align="center" fixed="right">
          <template slot-scope="scope">
            <div>
              <el-button
                :disabled="disabled"
                size="mini"
                icon="el-icon-arrow-up"
                type="primary"
                @click="upOne(scope.row)"/>
              <el-button
                :disabled="disabled"
                size="mini"
                icon="el-icon-arrow-down"
                type="primary"
                @click="downOne(scope.row)"/>
              <el-button
                :disabled="disabled"
                size="mini"
                icon="el-icon-circle-plus-outline"
                type="primary"
                @click="insertOne(scope.row)"/>
              <el-button
                :disabled="disabled"
                size="mini"
                icon="el-icon-delete"
                type="danger"
                @click="deleteOne(scope.row)"/>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </el-card>

    <el-dialog :visible.sync="dialogMaterial" title="物料选择" center width="400px">
      <el-input v-model="input" placeholder="材质" size="small" style="width:200px"/>
      <el-button type="success" size="small" icon="el-icon-search" style="margin: 0 0 10px 10px" @click="total=0;pageCurrent=1;pageSize=10;searchMaterial()">查询</el-button>
      <el-table :data="tableMaterial" size="mini" highlight-current-row border @row-click="selectMaterial">
        <el-table-column align="center" label="材质名称">
          <template slot-scope="scope">
            {{ scope.row.材料 }}
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top: 10px;">
        <el-pagination
          :current-page="1"
          :page-sizes="[10, 20]"
          :page-size="10"
          :pager-count="5"
          :total="total"
          small
          layout="sizes, prev, pager, next"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"/>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" size="small" @click="selectMaterial2()">提交</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible2" title="工艺名称、工艺要求选择" center width="400px">
      <el-form ref="form2" :model="form2" label-position="left" label-width="125px" class="demo-ruleForm">
        <el-form-item label="工艺名称分类">
          <el-select v-model="processNameClassValue" filterable placeholder="分类" size="small" @change="cChange()">
            <el-option
              v-for="item in processNameClass"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
          </el-select>
        </el-form-item>
        <el-form-item label="工艺名称">
          <el-select v-model="processNameValue" filterable placeholder="名称" size="small" @change="nChange()">
            <el-option
              v-for="item in processName"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
          </el-select>
        </el-form-item>
        <el-form-item label="工艺要求">
          <el-select v-model="processRequestValue" placeholder="要求" size="small">
            <el-option
              v-for="item in processRequest"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button size="mini" type="primary" @click="confirmSelect()">确定选择</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <el-dialog :visible.sync="dialogFormVisible" title="工艺选择" center width="800px">
      <el-form ref="form" :model="form" label-position="left" label-width="125px" class="demo-ruleForm">
        <el-row>
          <el-col :span="24">
            <el-form-item label="零件图号">
              <el-input v-model="partNameValue1" size="small" placeholder="输入零件图号" style="width: 150px" clearable/>
              <el-button type="success" size="small" icon="el-icon-search" style="margin-left: 20px" @click="searchProcess()">查询</el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="零件图号">
              <el-select id="num" v-model="processNumValue" placeholder="零件图号" style="width:150px" size="small" @change="numChange()">
                <el-option
                  v-for="item in partName1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
              <el-button size="small" style="margin-left: 20px" @click="processCopy()">工艺拷贝</el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-table
          :data="tableData2"
          style="width: 97%;max-height: 300px;margin-top:15px"
          height="300px"
          border
          size="mini">
          <el-table-column align="center" label="工艺序号" width="80">
            <template slot-scope="scope">
              {{ scope.row.工序顺序 }}
            </template>
          </el-table-column>
          <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="80">
            <template slot-scope="scope">
              {{ scope.row.工艺难度等级 }}
            </template>
          </el-table-column>
        </el-table>
      </el-form>
    </el-dialog>

    <el-dialog :visible.sync="dialogFormVisible1" title="已完工艺选择" center width="800px">
      <el-form ref="form1" :model="form1" label-position="left" label-width="140px" class="demo-ruleForm">
        <el-row>
          <el-col :span="10">
            <el-form-item label="工艺员">
              <el-input v-model="CraftmanValue" clearable size="small" readonly style="width: 150px;">
                <el-button slot="append" icon="el-icon-search" @click="dialogFormVisible3=true"/>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="零件号">
              <el-input v-model="PN" size="small" placeholder="输入零件号" style="width: 150px" clearable @change="inputChange"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item label="工艺定制开始日期">
              <el-date-picker
                v-model="date01"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-dd"
                type="date"
                size="small"
                placeholder="选择开始日期"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="工艺定制结束日期">
              <el-date-picker
                v-model="date02"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-dd"
                type="date"
                size="small"
                placeholder="选择结束日期"/>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-button size="small" type="success" icon="el-icon-search" @click="searchProcess1()">查询</el-button>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item label="零件图号">
              <el-select
                v-model="tuhaoValue"
                placeholder="零件图号"
                size="small"
                filterable
                style="width:150px"
                @change="numChange1()">
                <el-option
                  v-for="item in tuhao"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="零件名称">
              <el-input v-model="remark1" size="small" readonly style="width: 150px;"/>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-button size="small" @click="processCopy1()">工艺拷贝</el-button>
          </el-col>
        </el-row>
        <el-table :data="tableData4" style="width: 97%;max-height: 250px;margin-top: 15px" size="mini" border height="250px">
          <el-table-column align="center" label="工艺序号" width="80">
            <template slot-scope="scope">
              {{ scope.row.工序顺序 }}
            </template>
          </el-table-column>
          <el-table-column align="center" label="工艺名称" width="120">
            <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="110">
            <template slot-scope="scope">
              {{ scope.row.单件定额工时 }}
            </template>
          </el-table-column>
          <el-table-column align="center" label="准结定额工时" width="110">
            <template slot-scope="scope">
              {{ scope.row.准结定额工时 }}
            </template>
          </el-table-column>
        </el-table>
      </el-form>
    </el-dialog>

    <el-dialog :visible.sync="dialogFormVisible3" title="工艺定额人员" center style="min-height: 300px">
      <el-table :data="tableData3" size="mini" style="width: 97%;max-height: 300px" height="300" highlight-current-row border @row-click="selectPerson">
        <el-table-column align="center" label="考勤编号" width="150">
          <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">
            {{ scope.row.性别 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="工作岗位" width="150">
          <template slot-scope="scope">
            {{ scope.row.岗位名称 }}
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="tijiao()">提交</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import '@/icon/iconfont.css'
import {
  saveWeight,
  numChange,
  searchProcess11,
  WeightCopy,
  initCraftmen,
  getPartnames1,
  getPartnames2,
  detailInfo,
  mainTable,
  getMaterial,
  searchMaterial,
  typicalProcess,
  initTolerance,
  searchWYgongyi,
  gongyiCopy,
  initPerson,
  gongyiYQ,
  hardEdit,
  requestEdit,
  processNameClick,
  processNameSelect,
  processRequestSelect,
  searchTolerance,
  insertOne,
  deleteOne,
  upOne,
  downOne,
  saveMaterial,
  saveApprove,
  selectRequest,
  pasteTable,
  deleteTable,
  returnEdit
} from '@/api/ManufacturingCenter/ProcessPlanning'
import elInput from 'element-ui/packages/input'
import { mapGetters } from 'vuex'

export default {
  components: {
    elInput
  },
  data() {
    return {
      weight: '',
      dialogMateria2: false,
      prepareMateriel: '',
      lastFocusText: '',
      Result1: '',
      Result2: '',
      Result3: '',
      Result4: '',
      Result5: '',
      Length: '',
      Width: '',
      height1: '',
      diameter: '',
      height2: '',
      OppositeSideWidth: '',
      length2: '',
      biankuan: '',
      bianhou: '',
      changdu: '',
      bihou: '',
      waijing: '',
      changdu2: '',
      materielValue: '1',
      materiel: [{
        value: '1',
        label: '园钢'
      }, {
        value: '2',
        label: '钢板'
      }, {
        value: '3',
        label: '六角钢'
      }, {
        value: '4',
        label: '角钢'
      }, {
        value: '5',
        label: '钢管'
      }, {
        value: '6',
        label: '园紫铜棒'
      }, {
        value: '7',
        label: '园黄铜棒'
      }, {
        value: '8',
        label: '园铝棒'
      }, {
        value: '9',
        label: '紫铜板'
      }, {
        value: '10',
        label: '黄铜板'
      }, {
        value: '11',
        label: '6061铝板'
      }],
      total: 0,
      pageCurrent: 1,
      pageSize: 10,
      input: '', // 材质对话框查询1
      tableMaterial: [],
      dialogMaterial: false,
      loading0: false,
      radio: 1, // 第一组
      partNumValue: '', // 零件号值
      partNum: [], // 零件号
      typeValue: '', // 种类
      CraftmenValue: '', // 工艺员值
      Craftmen: [], // 工艺员
      CraftmanValue: '', // 完艺表单工艺员值
      CraftmanValue2: '', // 完艺表单工艺员值中间变量
      Craftman: [], // 完艺表单工艺员
      partName: '', // 零件名称
      batchNum: '', // 投产总数量
      material: '', // 材质流水号
      materialName: '', // 材质名称
      materialClass: [], // 材质类
      typicalClassValue: '', // 典型工艺零件分类值
      typicalClass: [], // 典型工艺零件分类
      partNameValue1: '', // 典型工艺零件名称值
      partName1: [], // 典型工艺零件名称
      partNameValue1check: false, // 典型工艺零件名称check
      processNumValue: '', // 典型工艺号值
      processNum: [], // 典型工艺号
      processNumValuecheck: false, // 典型工艺号check
      remark: '', // 备注
      remark1: '', // 完艺零件名称
      dialogFormVisible: false, // 典艺对话框可见性
      dialogFormVisible1: false, // 完艺对话框可见性
      dialogFormVisible2: false, // 主界面查询工艺名称要求对话框可见性
      dialogFormVisible3: false, // 完艺对话框中选择工艺员可见性
      form: null, // 典艺表单
      form1: null, // 完艺表单
      form2: null, // 主界面查询表单
      serialNum1: [], // 典型工艺名称分类流水号
      serialNumValue1: '1', // 典型工艺名称分类流水号值,初值1否则置空时无参数
      serialNumValue1check: false, // 典型工艺名称分类流水号check
      serialNum2: [], // 典型工艺流水号
      serialNumValue2: '1', // 典型工艺流水号值，初值1否则置空时无参数
      numVal: '', // 输入数值
      selPara: [], // 选择参数数组
      selParaValue: '', // 选择参数值
      tolerance: '', // 公差
      tableData: [], // 主表
      tableData2: [], // 典艺内的表格
      tableData3: [], // 工艺定额人员
      tableData4: [], // 完艺表格
      processSelect: [], // 工艺分类流水号
      processNameClass: [], // 工艺名称分类
      processNameClassValue: '',
      processName: [], // 工艺名称
      processNameValue: '',
      processRequest: [], // 工艺要求
      processRequestValue: '',
      processN1: '', // 工艺编号
      str: '', // 拼接字符串用的
      value: '', // 第一个select的
      checked: false, // 是否核准
      checked1: false, // 修改
      spec: '', // 规格
      isShow: true, // '编辑模式'可见性
      isShow1: true, // “复制并保存”“粘贴”按钮的可见性
      isShow2: false, // 修改的可见性
      date01: '', // 完艺开始时间
      date02: '', // 完艺结束时间
      PN: '', // 零件号
      num: '', // 工艺计划流水号
      perNum: '',
      perNum2: '',
      tuhao: [],
      tuhaoValue: '',
      check1: 0,
      check2: 0,
      check3: 0,
      check4: 0,
      hard: [{ value: 'A' }, { value: 'B' }, { value: 'C' }],
      disabled: false,
      result: 0,
      oldNum: '',
      newNum: '',
      // tableRecord: [],
      materialName2: '',
      material2: ''
    }
  },
  computed: {
    ...mapGetters([
      'sidebar',
      'avatar',
      'name',
      'id'
    ])
  },
  created() {
    this.fetchData()
    this.initPerson()
    this.getList()
  },
  methods: {
    saveWeight() {
      if (this.partNumValue === '' || this.material === '') {
        this.$message.error('请选择一个零件')
      } else {
        saveWeight(this.partNumValue, this.weight).then(response => {
          if (response.data[0].result === '1') {
            this.$message.success('保存成功')
          } else {
            this.$message.error('保存失败')
          }
        })
      }
    },
    clear() {
      this.weight = ''
      this.Length = ''
      this.Width = ''
      this.height1 = ''
      this.diameter = ''
      this.height2 = ''
      this.OppositeSideWidth = ''
      this.biankuan = ''
      this.bianhou = ''
      this.changdu = ''
      this.bihou = ''
      this.waijing = ''
      this.changdu2 = ''
    },
    // 直径高计算
    Calculation1() {
      if (this.partNumValue === '' || this.partNumValue === null) {
        this.$message.error('请先选择一个零件')
      } else {
        if (this.materielValue === '1') {
          this.Result2 = '物料:' + this.materiel[1].label + ' 直径:' + this.diameter + 'mm  长度:' + this.height2
          // + 'mm  重量:' + 0.00617 * 0.001 * parseInt(this.diameter) * parseInt(this.diameter) * parseFloat(this.height2) + 'kg'
          this.weight = 0.00617 * 0.001 * parseInt(this.diameter) * parseInt(this.diameter) * parseFloat(this.height2)
          WeightCopy(this.partNumValue, this.Result2).then(response => {
            this.searchDetai2()
          })
        }
        if (this.materielValue === '6') {
          this.Result2 = '物料:' + this.materiel[6].label + ' 直径:' + this.diameter + 'mm  长度:' + this.height2
          // + 'mm  重量:' + 0.00698 * 0.001 * parseInt(this.diameter) * parseInt(this.diameter) * parseFloat(this.height2) + 'kg'
          this.weight = 0.00698 * 0.001 * parseInt(this.diameter) * parseInt(this.diameter) * parseFloat(this.height2)
          WeightCopy(this.partNumValue, this.Result2).then(response => {
            this.searchDetai2()
          })
        }
        if (this.materielValue === '7') {
          this.Result2 = '物料:' + this.materiel[7].label + ' 直径:' + this.diameter + 'mm  长度:' + this.height2
          // + 'mm  重量:' + 0.00668 * 0.001 * parseInt(this.diameter) * parseInt(this.diameter) * parseFloat(this.height2) + 'kg'
          this.weight = 0.00668 * 0.001 * parseInt(this.diameter) * parseInt(this.diameter) * parseFloat(this.height2)
          WeightCopy(this.partNumValue, this.Result2).then(response => {
            this.searchDetai2()
          })
        }
        if (this.materielValue === '8') {
          this.Result2 = '物料:' + this.materiel[8].label + ' 直径:' + this.diameter + 'mm  长度:' + this.height2
          // + 'mm  重量:' + 0.0022 * 0.001 * parseInt(this.diameter) * parseInt(this.diameter) * parseFloat(this.height2) + 'kg'
          this.weight = 0.0022 * 0.001 * parseInt(this.diameter) * parseInt(this.diameter) * parseFloat(this.height2)
          WeightCopy(this.partNumValue, this.Result2).then(response => {
            this.searchDetai2()
          })
        }
      }
    },
    // 长宽高计算
    Calculation2() {
      if (this.partNumValue === '' || this.partNumValue === null) {
        this.$message.error('请先选择一个零件')
      } else {
        if (this.materielValue === '2') {
          this.Result1 = '物料:' + this.materiel[2].label + ' 长:' + this.Length + 'mm  宽:' + this.Width + 'mm  厚:' + this.height1
          // + 'mm  重量:' + 0.001 * 0.00785 * parseInt(this.Length) * parseInt(this.Width) * parseFloat(this.height1) + 'kg'
          this.weight = 0.001 * 0.00785 * parseInt(this.Length) * parseInt(this.Width) * parseFloat(this.height1)
          WeightCopy(this.partNumValue, this.Result1).then(response => {
            this.searchDetai2()
          })
        }
        if (this.materielValue === '9') {
          this.Result1 = '物料:' + this.materiel[9].label + ' 长:' + this.Length + 'mm  宽:' + this.Width + 'mm  厚:' + this.height1
          // + 'mm  重量:' + 0.001 * 0.0089 * parseInt(this.Length) * parseInt(this.Width) * parseFloat(this.height1) + 'kg'
          this.weight = 0.001 * 0.0089 * parseInt(this.Length) * parseInt(this.Width) * parseFloat(this.height1)
          WeightCopy(this.partNumValue, this.Result1).then(response => {
            this.searchDetai2()
          })
        }
        if (this.materielValue === '10') {
          this.Result1 = '物料:' + this.materiel[10].label + ' 长:' + this.Length + 'mm  宽:' + this.Width + 'mm  厚:' + this.height1
          // + 'mm  重量:' + 0.001 * 0.0085 * parseInt(this.Length) * parseInt(this.Width) * parseFloat(this.height1) + 'kg'
          this.weight = 0.001 * 0.0085 * parseInt(this.Length) * parseInt(this.Width) * parseFloat(this.height1)
          WeightCopy(this.partNumValue, this.Result1).then(response => {
            this.searchDetai2()
          })
        }
        if (this.materielValue === '11') {
          this.Result1 = '物料:' + this.materiel[11].label + ' 长:' + this.Length + 'mm  宽:' + this.Width + 'mm  厚:' + this.height1
          // + 'mm  重量:' + 0.001 * 0.0028 * parseInt(this.Length) * parseInt(this.Width) * parseFloat(this.height1) + 'kg'
          this.weight = 0.001 * 0.0028 * parseInt(this.Length) * parseInt(this.Width) * parseFloat(this.height1)
          WeightCopy(this.partNumValue, this.Result1).then(response => {
            this.searchDetai2()
          })
        }
      }
    },
    // 对边宽*对边宽*长度
    Calculation3() {
      if (this.partNumValue === '' || this.partNumValue === null) {
        this.$message.error('请先选择一个零件')
      } else {
        if (this.materielValue === '3') {
          this.Result3 = '物料:' + this.materiel[3].label + ' 对边宽:' + this.OppositeSideWidth + 'mm  长度:' + this.length2
          // + 'mm  重量:' + 0.001 * 0.0068 * parseInt(this.OppositeSideWidth) * parseInt(this.OppositeSideWidth) * parseInt(this.length2) + 'kg'
          this.weight = 0.001 * 0.0068 * parseInt(this.OppositeSideWidth) * parseInt(this.OppositeSideWidth) * parseInt(this.length2)
          WeightCopy(this.partNumValue, this.Result3).then(response => {
            this.searchDetai2()
          })
        }
      }
    },
    // （边宽+边宽-边厚）×边厚×长度÷1000
    Calculation4() {
      if (this.partNumValue === '' || this.partNumValue === null) {
        this.$message.error('请先选择一个零件')
      } else {
        if (this.materielValue === '4') {
          this.Result4 = '物料:' + this.materiel[4].label + ' 边宽:' + this.biankuan + 'mm  边厚:' + this.bianhou + 'mm  长度:' + this.changdu
          // + 'mm  重量:' + 0.001 * 0.00785 * (parseInt(this.biankuan) + parseInt(this.biankuan) - parseInt(this.bianhou)) * parseInt(this.bianhou) * parseInt(this.changdu) + 'kg'
          this.weight = 0.001 * 0.00785 * (parseInt(this.biankuan) + parseInt(this.biankuan) - parseInt(this.bianhou)) * parseInt(this.bianhou) * parseInt(this.changdu)
          WeightCopy(this.partNumValue, this.Result4).then(response => {
            this.searchDetai2()
          })
        }
      }
    },
    Calculation5() {
      if (this.partNumValue === '' || this.partNumValue === null) {
        this.$message.error('请先选择一个零件')
      } else {
        if (this.materielValue === '5') {
          this.Result5 = '物料:' + this.materiel[5].label + ' 壁厚:' + this.bihou + 'mm  外径:' + this.waijing + 'mm  长度:' + this.changdu2
          // + 'mm  重量:' + 0.001 * 0.02466 * parseInt(this.bihou) * (parseInt(this.waijing) - parseInt(this.bihou)) * parseInt(this.changdu2) + 'kg'
          this.weight = 0.001 * 0.02466 * parseInt(this.bihou) * (parseInt(this.waijing) - parseInt(this.bihou)) * parseInt(this.changdu2)
          WeightCopy(this.partNumValue, this.Result5).then(response => {
            this.searchDetai2()
          })
        }
      }
    },
    insertThestring(NewCode) {
      this.lastFocusText = event.srcElement
      this.lastFocusText.focus()
      var sel = document.selection.createRange()
      sel.text = NewCode
      return
    },
    clearDetail() {
      this.checked = false
      this.weight = ''
      this.partNumValue = ''
      this.typeValue = ''
      this.partName = ''
      this.material = ''
      this.materialName = ''
      this.spec = ''
      this.batchNum = ''
    },
    returnEdit() { // 在制零件工艺修改
      if (this.partNumValue === '' || this.partNumValue === null) {
        this.$message.error('请选择零件')
      } else {
        this.$confirm('此操作会将该零件打回至未编制状态, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          returnEdit(this.partNumValue).then(response => {
            if (response.data[0].result === '1') {
              this.$message.success('打回成功')
              this.partNumValue = ''
              this.tableData = []
            } else {
              this.$message.error('打回失败')
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消操作'
          })
        })
      }
    },
    handleCurrentChange(val) { // 材质分页
      this.pageCurrent = val
      if (this.input === '' || this.input === null) {
        this.getList()
      } else {
        this.searchMaterial()
      }
    },
    handleSizeChange(val) { // 材质分页
      this.pageCurrent = 1
      this.pageSize = val
      if (this.input === '' || this.input === null) {
        this.getList()
      } else {
        this.searchMaterial()
      }
    },
    selectMaterial(row) { // 选择材质
      this.materialName2 = ''
      this.material2 = ''
      this.materialName2 = row.材料
      this.material2 = row.材料流水号
    },
    selectMaterial2() {
      this.materialName = ''
      this.material = ''
      this.materialName = this.materialName2
      this.material = this.material2
      this.dialogMaterial = false
    },
    fetchData() {
      this.materialClass = []
      getMaterial().then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.materialClass.push({
            label: response.data[i].材料,
            value: response.data[i].材料流水号
          })
        }
      })
      initCraftmen().then(response => { // 初始化工艺员
        for (let i = 0; i < response.data.length; i++) {
          this.Craftmen.push({
            label: response.data[i].姓名,
            value: response.data[i].人员编号
          })
        }
      })
      typicalProcess().then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.typicalClass.push({
            value: response.data[i].典型工艺名称分类
          })
          this.serialNum1.push({
            value: response.data[i].典型工艺名称分类流水号
          })
        }
      })
      initTolerance().then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.selPara.push({
            value: response.data[i].参数
          })
        }
      })
    },
    initPerson() { // 初始化工艺员
      initPerson().then(response => {
        this.tableData3 = response.data
      })
    },
    getList() { // 往材质对话框中放
      this.tableMaterial = []
      getMaterial(this.pageCurrent, this.pageSize).then(response => {
        this.total = response.data.total
        this.tableMaterial = response.data.rows
      })
    },
    searchMaterial() { // 材质查询
      searchMaterial(this.pageCurrent, this.pageSize, this.input).then(response => {
        this.total = response.data.total
        this.tableMaterial = response.data.rows
      })
    },
    searchParts() { // 根据条件查零件号
      this.tableData = []
      this.partNum = []
      if (this.radio === 1) { // 未编制
        this.disabled = false
        this.isShow1 = true
        this.isShow2 = false
        this.checked1 = true
        getPartnames1(this.CraftmenValue, this.partNumValue).then(response => {
          for (let i = 0; i < response.data.length; i++) {
            this.partNum.push({
              label: response.data[i].零件图号,
              value: response.data[i].工艺计划流水号
            })
          }
        })
      } else { // 已编制
        this.isShow = true
        this.isShow1 = false
        this.isShow2 = true
        this.disabled = true
        this.checked1 = false
        getPartnames2(this.CraftmenValue, this.partNumValue).then(response => {
          for (let i = 0; i < response.data.length; i++) {
            this.partNum.push({
              label: response.data[i].零件图号,
              value: response.data[i].工艺计划流水号
            })
          }
        })
      }
    },
    switchEdit() { // 切换编辑模式
      if (this.radio === 1) {
        this.isShow = !this.isShow
      } else {
        this.isShow = true
      }
    },
    // 查主表和上面显示的信息
    searchDetail() {
      if (this.partNumValue !== '' && this.partNumValue !== null) {
        this.loading0 = true
        detailInfo(this.partNumValue).then(response => {
          if (response.data.length !== 0) {
            this.typeValue = response.data[0].零件类型名称
            this.partName = response.data[0].零件名称
            this.batchNum = response.data[0].批次数量
            this.material = response.data[0].材料流水号
            this.materialName = response.data[0].材料
            this.spec = response.data[0].原材料规格
            if (response.data[0].重量 === null) {
              this.weight = ''
            } else {
              this.weight = response.data[0].重量
            }
          }
        })
        // this.tableRecord = []
        // searchRecord(this.partNumValue).then(response => {
        //   this.tableRecord = response.data
        // })
        mainTable(this.partNumValue).then(response => {
          this.tableData = []
          for (let i = 0; i < response.data.length; i++) {
            if (response.data[i].工艺编号 === null) {
              response.data[i].工艺编号 = 0
            }
            if (response.data[i].工艺要求 === null) {
              response.data[i].工艺要求 = ''
            }
          }
          this.tableData = response.data
          this.newNum = this.partNumValue
        }).then(() => {
          this.loading0 = false
        })
      }
    },
    searchDetai2() {
      if (this.partNumValue !== '' && this.partNumValue !== null) {
        this.loading0 = true
        mainTable(this.partNumValue).then(response => {
          this.tableData = []
          for (let i = 0; i < response.data.length; i++) {
            if (response.data[i].工艺编号 === null) {
              response.data[i].工艺编号 = 0
            }
            if (response.data[i].工艺要求 === null) {
              response.data[i].工艺要求 = ''
            }
          }
          this.tableData = response.data
          this.newNum = this.partNumValue
        }).then(() => {
          this.loading0 = false
        })
      }
    },
    DYbtn() { // 典艺按钮
      this.dialogFormVisible = true
      this.processNumValue = ''
      this.partNameValue1 = ''
      this.typicalClassValue = ''
      this.remark = ''
      this.serialNumValue1 = '1' // 有默认值
      this.serialNumValue2 = '1' // 有默认值
      this.tableData2 = null
    },
    WYbtn() { // 完艺按钮
      this.tableData4 = []
      this.tuhaoValue = ''
      this.remark1 = ''
      this.dialogFormVisible1 = true
    },
    selectPerson(row) { // 选择工艺员
      this.CraftmanValue2 = row.姓名
      this.perNum2 = row.人员编号
    },
    tijiao() { // 提交完艺表单中工艺定额人员的选择
      this.dialogFormVisible3 = false
      this.CraftmanValue = this.CraftmanValue2
      this.perNum = this.perNum2
      this.remark1 = ''
      this.tuhaoValue = ''
    },
    inputChange() { // 零件号改变
      this.remark1 = ''
      this.tuhaoValue = ''
    },
    // 典艺工艺查询
    searchProcess() {
      this.processNumValue = ''
      this.partName1 = []
      this.tableData2 = []
      searchProcess11(this.partNameValue1).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.partName1.push({
            label: response.data[i].零件图号,
            value: response.data[i].典艺流水号
          })
        }
      })
    },
    // 典艺选择查表格
    numChange() {
      numChange(this.processNumValue).then(response => {
        this.tableData2 = response.data
      })
    },
    // 典艺工艺拷贝
    processCopy() {
      if (this.partNumValue === '') {
        this.$message.error('请在主界面选择一个零件作为被拷贝对象')
        this.dialogFormVisible = false
      } else if (this.processNumValue === '') {
        this.$message.error('请选择零件图号')
      } else {
        for (let i = 0; i < this.tableData2.length; i++) {
          this.tableData[i].工艺名称 = this.tableData2[i].工艺名称
          this.tableData[i].工艺难度等级 = this.tableData2[i].工艺难度等级
          this.tableData[i].工艺要求 = this.tableData2[i].工艺要求
          selectRequest(this.tableData[i].工序流水号, this.tableData[i].工艺计划流水号, this.tableData2[i].工艺编号, this.tableData2[i].工序顺序, this.tableData2[i].工艺要求)
          hardEdit(this.tableData[i].工序流水号, this.tableData2[i].工艺难度等级)
        }
        this.dialogFormVisible = false
      }
    },
    searchProcess1() { // 完艺工艺查询
      this.tuhao = []
      if (this.PN === '') { // 零件号
        this.check1 = 0
      } else {
        this.check1 = 1
      }
      if (this.perNum === '') { // 工艺员编号
        this.check2 = 0
      } else {
        this.check2 = 1
      }
      if (this.remark1 === '') { // 零件名称
        this.check4 = 0
      } else {
        this.check4 = 1
      }
      if (this.date01 === '' || this.date02 === '' || this.date01 === null || this.date02 === null) { // 日期
        this.check3 = 0
      } else {
        this.check3 = 1
      }
      searchWYgongyi(this.check1, this.PN, this.check2, this.perNum, this.check3, this.date01, this.date02, this.check4, this.remark1).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.tuhao.push({
            value: response.data[i].零件图号,
            name: response.data[i].零件名称,
            num: response.data[i].工艺计划流水号
          })
        }
      })
    },
    // 完艺工艺拷贝
    processCopy1() {
      this.dialogFormVisible1 = false
      if (this.partNumValue === '') {
        this.$message.error('请在主界面选择一个零件作为被拷贝对象')
      } else {
        gongyiCopy(this.num, this.partNumValue).then(res => { // 工艺计划流水号_完成工艺, 工艺计划流水号_被拷工艺
          this.searchDetail()
        })
      }
    },
    // 当完成工艺号改变时，零件名称改变，并获取工艺要求
    numChange1() {
      this.remark1 = ''
      this.tableData4 = null
      for (let i = 0; i < this.tuhao.length; i++) {
        if (this.tuhaoValue === this.tuhao[i].value) {
          this.remark1 = this.tuhao[i].name
          this.num = this.tuhao[i].num
        }
      }
      gongyiYQ(this.num).then(response => {
        this.tableData4 = response.data
      })
    },
    hardEdit(row) { // 修改难度等级
      hardEdit(row.工序流水号, row.工艺难度等级).then(response => {
      })
    },
    // 修改工艺要求
    requestEdit(row) {
      requestEdit(row.工序流水号, row.工艺要求)
    },
    tableSearch(index) { // 主界面工艺名称分类、工艺名称及工艺要求后续查询
      if (this.checked1 === false) {
        this.dialogFormVisible2 = false
      } else {
        this.dialogFormVisible2 = true
        if (index !== this.index) {
          this.str = '' // 清字符串
        }
        this.index = index
        this.processNameClassValue = ''
        this.processNameValue = ''
        this.processRequestValue = ''
        this.processNameClass = []
        this.processName = []
        this.processRequest = []
        processNameClick().then(response => { // 初始化工艺名称的
          for (let i = 0; i < response.data.length; i++) {
            this.processNameClass.push({ // 工艺名称分类
              value: response.data[i].工艺分类名称
            })
            this.processSelect.push({ // 工艺分类流水号
              value: response.data[i].工艺分类流水号
            })
          }
        })
      }
    },
    cChange() { // 工艺名称分类改变
      this.processNameValue = ''
      this.processName = []
      this.processRequestValue = ''
      this.processRequest = []
      for (let i = 0; i < this.processNameClass.length; i++) {
        if (this.processNameClassValue === this.processNameClass[i].value) {
          processNameSelect(this.processSelect[i].value).then(response => { // 查询工艺名称
            for (let j = 0; j < response.data.length; j++) {
              this.processName.push({
                value: response.data[j].工艺名称,
                num: response.data[j].工艺编号
              })
            }
          })
        }
      }
    },
    nChange() { // 工艺名称改变
      this.processRequestValue = ''
      this.processRequest = []
      for (let i = 0; i < this.processName.length; i++) {
        if (this.processNameValue === this.processName[i].value) {
          this.processN1 = this.processName[i].num // 工艺编号
          processRequestSelect(this.processName[i].num).then(response => { // 查询工艺名称
            for (let j = 0; j < response.data.length; j++) {
              this.processRequest.push({
                value: response.data[j].工艺要求
              })
            }
          })
        }
      }
    },
    // 确定选择主表的工艺名称及要求
    confirmSelect() {
      this.tableData[this.index].工艺编号 = this.processN1
      this.tableData[this.index].工艺名称 = this.processNameValue
      this.str = this.str + this.processRequestValue
      this.tableData[this.index].工艺要求 = this.str
      this.dialogFormVisible2 = false
      selectRequest(this.tableData[this.index].工序流水号, this.tableData[this.index].工艺计划流水号, this.tableData[this.index].工艺编号, this.tableData[this.index].工序顺序, this.tableData[this.index].工艺要求)
    },
    calTol() { // 计算公差
      this.tolerance = ''
      for (let i = 0; i < this.selPara.length; i++) {
        if (this.selParaValue === this.selPara[i].value) {
          break
        }
      }
      searchTolerance(this.numVal, this.selParaValue).then(response => {
        if (response.data.length !== 0) { // 防止超出范围报错
          this.tolerance = response.data[0].公差
        } else {
          this.$message.error('输入的数值不对！')
        }
      })
    },
    copyAndSave() { // 复制并保存
      if (this.tableData.length !== 0) {
        this.oldNum = this.tableData[0].工艺计划流水号
        this.saveApprove()
      } else {
        this.$message.error('当前没有可以被复制的工艺')
      }
    },
    saveApprove() { // 核准保存
      if (this.checked === true) {
        for (let i = 0; i < 30; i++) {
          saveApprove(this.tableData[i].工艺计划流水号, this.tableData[i].工艺编号, this.tableData[i].工艺要求, this.spec, this.tableData[i].工序顺序, this.tableData[i].工序间是否外协, this.tableData[i].工序流水号, this.material, '', '', this.CraftmenValue, this.tableData[i].工艺难度等级)
        }
        this.checked = false
        this.partNumValue = ''
        this.typeValue = ''
        this.partName = ''
        this.batchNum = ''
        this.material = ''
        this.materialName = ''
        this.spec = ''
        this.newNum = ''
        this.$message.success('保存成功')
        this.searchParts()
      } else {
        this.$message.error('请核准后保存')
      }
    },
    insertOne(row) { // 插入行
      if (this.partNumValue === '') {
        this.$message.error('请先选择一个零件')
      } else {
        insertOne(this.partNumValue, row.工序流水号).then(response => {
          this.searchDetail()
        })
      }
    },
    deleteOne(row) { // 删除行
      if (this.partNumValue === '') {
        this.$message.error('请先选择一个零件')
      } else {
        this.$confirm('此操作将永久删除该行工艺, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteOne(this.partNumValue, row.工序流水号).then(() => {
            this.$message.success('删除成功')
            this.searchDetail()
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      }
    },
    upOne(row) { // 上移
      if (this.partNumValue === '') {
        this.$message.error('请先选择一个零件')
      } else {
        upOne(this.partNumValue, row.工序流水号).then(response => {
          this.searchDetail()
        })
      }
    },
    downOne(row) { // 下移
      if (this.partNumValue === '') {
        this.$message.error('请先选择一个零件')
      } else {
        downOne(this.partNumValue, row.工序流水号).then(response => {
          this.searchDetail()
        })
      }
    },
    saveMaterial() { // 保存材质
      if (this.partNumValue === '' || this.material === '') {
        this.$message.error('请选择一个零件')
      } else {
        saveMaterial(this.partNumValue, this.material).then(response => {
          if (response.data[0].result === '1') {
            this.$message.success('保存成功')
          } else {
            this.$message.error('保存失败')
          }
        })
      }
    },
    pasteTable() { // 粘贴
      if (this.partNumValue === '' || this.partNumValue === null) {
        this.$message.error('请选择零件作为被粘贴对象')
      } else {
        pasteTable(this.oldNum, this.newNum).then(response => {
          if (response.data[0].result === '1') {
            this.$message.success('粘贴成功')
            this.searchDetail()
          } else {
            this.$message.error('粘贴失败')
          }
        })
      }
    },
    deleteTable() { // 删除
      if (this.newNum === '') {
        this.$message.error('请选择一个零件')
      } else {
        this.$confirm('此操作将永久删除该零件的工艺, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          for (let i = 0; i < 30; i++) {
            hardEdit(this.tableData[i].工序流水号, '').then(response => {
            })
          }
          deleteTable(this.newNum).then(response => {
            if (response.data[0].result === '1') {
              this.$message.success('删除成功')
              this.searchDetail()
            } else {
              this.$message.error('删除失败')
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      }
    }
  }
}
</script>

<style scoped>
  .doing-row4 {
    background: #f0f9eb;
  }
  .el-card {
    margin-bottom: 15px;
  }
  .el-date-editor {
    width: 150px
  }
  span {
    margin: 10px 0 10px 10px;
  }
  .el-table .change {
    background: oldlace;
  }
</style>
