<script>
import {
  removeBatchTestSoRouting,
  saveTestSoRouting,
  selectTestSoRoutingList,
  updateTestSoRouting
} from "../../../../api/test/testSoRouting";
import {searchWorkCenter} from "../../../../api/part/workCenter";
import {Decimal} from "decimal.js";

export default {
  name:"testRoutingTable",
  props:{
    dataList:{
      type: Array,
      default:()=>[]
    },
    testNo:{
      type: String,
      request: true
    },
    columnList:{
      type: Array,
      default: ()=>[],
    },
    height:{
      type:[Number,String],
      default:300
    },
    disabled:{
      type: Boolean,
      default: false
    },
  },
  model:{
    prop:"dataList",
    event:"change",
  },
  data(){
    return{
      workCenter:{
        workCenterNo:undefined,
        workCenterDesc:undefined,
        workCenterType:undefined,
      },
      workCenterList:[],
      workCenterDialogFlag:false,
      saveStatus:true,
      saveFlag:false,
      testSoRoutingLabel:{
        itemNo:"工序号",
        itemDesc:"工序名称",
        workCenterNo:"加工中心",
        workCenterDesc:"加工中心名称",
        workCenterType:"加工中心类别",
        machSetupTime:"准备时间",
        factorUnit:'产出单位',
        machRunFactor:'单位产出量',
        efficiency:'效率',
        requiredTime:'需求时间(h)',
        requiredQty:'需求数量',
        reportedQty:'报告数量',
        approveQty:'合格数量',
        planStartTime:'计划开工时间',
        planFinishTime:'计划完工时间',
      },
      testSoRouting:{
        itemNo:10,
        itemDesc:undefined,
        site:this.$store.state.user.site,
        testNo:undefined,
        workCenterNo:undefined,
        workCenterDesc:undefined,
        workCenterType:undefined,
        machSetupTime:0,
        factorUnit:'单位/小时',
        machRunFactor:0,
        efficiency:100,
        requiredTime:0,
        requiredQty:0,
        reportedQty:0,
        approveQty:0,
        planStartTime:undefined,
        planFinishTime:undefined,
        remark:undefined,
      },
      testSoRoutingRule:{
        itemNo:[{required: true,message: ' ',trigger: ['change','blur']}],
        itemDesc:[{required: true,message: ' ',trigger: ['change','blur']}],
        workCenterNo:[{required: true,message: ' ',trigger: ['change','blur']}],
        workCenterDesc:[{required: true,message: ' ',trigger: ['change','blur']}],
        workCenterType:[{required: true,message: ' ',trigger: ['change','blur']}],
        machSetupTime:[{required: true,message: ' ',trigger: ['change','blur']}],
        factorUnit:[{required: true,message: ' ',trigger: ['change','blur']}],
        machRunFactor:[{required: true,message: ' ',trigger: ['change','blur']}],
        efficiency:[{required: true,message: ' ',trigger: ['change','blur']}],
        requiredTime:[{required: true,message: ' ',trigger: ['change','blur']}],
        requiredQty:[{required: true,message: ' ',trigger: ['change','blur']}],
        reportedQty:[{required: true,message: ' ',trigger: ['change','blur']}],
        approveQty:[{required: true,message: ' ',trigger: ['change','blur']}],
        planStartTime:[{required: true,message: ' ',trigger: ['change','blur']}],
        planFinishTime:[{required: true,message: ' ',trigger: ['change','blur']}],
      },
      selectionTestSoRoutingList:[],
      testSoRoutingColumnList:[
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table3ItemNo',
          tableId: '102001Table3',
          tableName: '测试工艺路线',
          columnProp: 'itemNo',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '工序号',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table3ItemDesc',
          tableId: '102001Table3',
          tableName: '测试工艺路线',
          columnProp: 'itemDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '工序描述',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 200
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table3WorkCenterNo',
          tableId: '102001Table3',
          tableName: '测试工艺路线',
          columnProp: 'workCenterNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '加工中心',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table3WorkCenterDesc',
          tableId: '102001Table3',
          tableName: '测试工艺路线',
          columnProp: 'workCenterDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '加工中心名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 150
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table3WorkCenterType',
          tableId: '102001Table3',
          tableName: '测试工艺路线',
          columnProp: 'workCenterType',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '加工中心类别',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        // {
        //   userId: this.$store.state.user.name,
        //   functionId: 102001,
        //   serialNumber: '102001Table3MachSetupTime',
        //   tableId: '102001Table3',
        //   tableName: '测试工艺路线',
        //   columnProp: 'machSetupTime',
        //   headerAlign: 'center',
        //   align: 'center',
        //   columnLabel: '准备时间',
        //   columnHidden: false,
        //   columnImage: false,
        //   columnSortable: false,
        //   sortLv: 0,
        //   status: true,
        //   fixed: '',
        //   columnWidth: 100
        // },
        // {
        //   userId: this.$store.state.user.name,
        //   functionId: 102001,
        //   serialNumber: '102001Table3MachRunFactor',
        //   tableId: '102001Table3',
        //   tableName: '测试工艺路线',
        //   columnProp: 'machRunFactor',
        //   headerAlign: 'center',
        //   align: 'center',
        //   columnLabel: '单位产出量',
        //   columnHidden: false,
        //   columnImage: false,
        //   columnSortable: false,
        //   sortLv: 0,
        //   status: true,
        //   fixed: '',
        //   columnWidth: 100
        // },
        // {
        //   userId: this.$store.state.user.name,
        //   functionId: 102001,
        //   serialNumber: '102001Table3Efficiency',
        //   tableId: '102001Table3',
        //   tableName: '测试工艺路线',
        //   columnProp: 'efficiency',
        //   headerAlign: 'center',
        //   align: 'center',
        //   columnLabel: '效率%',
        //   columnHidden: false,
        //   columnImage: false,
        //   columnSortable: false,
        //   sortLv: 0,
        //   status: true,
        //   fixed: '',
        //   columnWidth: 100
        // },
        // {
        //   userId: this.$store.state.user.name,
        //   functionId: 102001,
        //   serialNumber: '102001Table3FactorUnit',
        //   tableId: '102001Table3',
        //   tableName: '测试工艺路线',
        //   columnProp: 'factorUnit',
        //   headerAlign: 'center',
        //   align: 'center',
        //   columnLabel: '产出单位',
        //   columnHidden: false,
        //   columnImage: false,
        //   columnSortable: false,
        //   sortLv: 0,
        //   status: true,
        //   fixed: '',
        //   columnWidth: 100
        // },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table3RequiredTime',
          tableId: '102001Table3',
          tableName: '测试工艺路线',
          columnProp: 'requiredTime',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '需求时间(h)',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        // {
        //   userId: this.$store.state.user.name,
        //   functionId: 102001,
        //   serialNumber: '102001Table3RequiredQty',
        //   tableId: '102001Table3',
        //   tableName: '测试工艺路线',
        //   columnProp: 'requiredQty',
        //   headerAlign: 'center',
        //   align: 'center',
        //   columnLabel: '需求数量',
        //   columnHidden: false,
        //   columnImage: false,
        //   columnSortable: false,
        //   sortLv: 0,
        //   status: true,
        //   fixed: '',
        //   columnWidth: 100
        // },
        // {
        //   userId: this.$store.state.user.name,
        //   functionId: 102001,
        //   serialNumber: '102001Table3ReportedQty',
        //   tableId: '102001Table3',
        //   tableName: '测试工艺路线',
        //   columnProp: 'reportedQty',
        //   headerAlign: 'center',
        //   align: 'center',
        //   columnLabel: '报告数量',
        //   columnHidden: false,
        //   columnImage: false,
        //   columnSortable: false,
        //   sortLv: 0,
        //   status: true,
        //   fixed: '',
        //   columnWidth: 100
        // },
        // {
        //   userId: this.$store.state.user.name,
        //   functionId: 102001,
        //   serialNumber: '102001Table3ApproveQty',
        //   tableId: '102001Table3',
        //   tableName: '测试工艺路线',
        //   columnProp: 'approveQty',
        //   headerAlign: 'center',
        //   align: 'center',
        //   columnLabel: '合格数量',
        //   columnHidden: false,
        //   columnImage: false,
        //   columnSortable: false,
        //   sortLv: 0,
        //   status: true,
        //   fixed: '',
        //   columnWidth: 100
        // },
        // {
        //   userId: this.$store.state.user.name,
        //   functionId: 102001,
        //   serialNumber: '102001Table3PlanStartTime',
        //   tableId: '102001Table3',
        //   tableName: '测试工艺路线',
        //   columnProp: 'planStartTime',
        //   headerAlign: 'center',
        //   align: 'center',
        //   columnLabel: '计划开工时间',
        //   columnHidden: false,
        //   columnImage: false,
        //   columnSortable: false,
        //   sortLv: 0,
        //   status: true,
        //   fixed: '',
        //   columnWidth: 100
        // },
        // {
        //   userId: this.$store.state.user.name,
        //   functionId: 102001,
        //   serialNumber: '102001Table3PlanFinishTime',
        //   tableId: '102001Table3',
        //   tableName: '测试工艺路线',
        //   columnProp: 'planFinishTime',
        //   headerAlign: 'center',
        //   align: 'center',
        //   columnLabel: '计划完工时间',
        //   columnHidden: false,
        //   columnImage: false,
        //   columnSortable: false,
        //   sortLv: 0,
        //   status: true,
        //   fixed: '',
        //   columnWidth: 100
        // },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table3Remark',
          tableId: '102001Table3',
          tableName: '测试工艺路线',
          columnProp: 'remark',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '备注',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 140
        },
      ],
    }
  },
  created() {
    if (this.columnList.length !== 0){
      this.testSoRoutingColumnList = [...this.columnList]
    }
  },
  methods: {
    dblClickWorkCenterTable(row){
      this.testSoRouting.workCenterNo = row.workCenterNo
      this.testSoRouting.workCenterDesc = row.workCenterDesc
      this.testSoRouting.workCenterType = row.workCenterType
      this.workCenterDialogFlag = false
    },
    searchWorkCenter(flag){
      let params = {
        site:this.$store.state.user.site,
        workCenterNo:this.workCenter.workCenterNo,
        workCenterDesc:this.workCenter.workCenterDesc,
        workCenterType:this.workCenter.workCenterType,
      };
      this.workCenterList = []
      searchWorkCenter(params).then(({data})=>{
        if (data && data.code === 200){
          this.workCenterList = data.data;
          if (flag === true){
            if (this.workCenterList.length === 1 && this.workCenterList[0].workCenterNo === this.testSoRouting.workCenterNo){
              this.dblClickWorkCenterTable(this.workCenterList[0])
            }else {
              let workCenter = {
                workCenterNo:this.testSoRouting.workCenterNo,
                workCenterDesc:'',
                workCenterType:''
              }
              this.dblClickWorkCenterTable(workCenter)
            }
          }
        }
      })
    },
    saveTestSoRoutingBtn(row){
      if (row){
        this.saveStatus = false
        this.testSoRouting = {...row}
      }else {
        this.testSoRouting.testNo = this.testNo
        this.testSoRouting.planStartTime = new Date()
        this.testSoRouting.planFinishTime = new Date()
      }
      this.saveFlag = true;
    },
    closeWorkCenterDialog(){
      this.workCenter = {
        workCenterNo:undefined,
        workCenterDesc:undefined,
        workCenterType:undefined,
      }
    },
    closeTestSoRoutingDialog(){
      this.saveStatus = true;
      this.$refs.saveForm.resetFields();
      this.testSoRouting = {
        itemNo:10,
        itemDesc:undefined,
        site:this.$store.state.user.site,
        testNo: this.testNo,
        workCenterNo:undefined,
        workCenterDesc:undefined,
        workCenterType:undefined,
        machSetupTime:0,
        factorUnit:'单位/小时',
        machRunFactor:0,
        efficiency:100,
        requiredTime:0,
        requiredQty:0,
        reportedQty:0,
        approveQty:0,
        planStartTime:undefined,
        planFinishTime:undefined,
        remark:undefined,
      }
    },
    selectTestSoRoutingList(){
      let params = {
        site:this.$store.state.user.site,
        testNo: this.testNo,
      }
      selectTestSoRoutingList(params).then(({data})=>{
        if (data && data.code === 0){
          this.$emit("change",data.rows);
          this.$nextTick(()=>{
            this.testSoRouting = {
              itemNo:data.rows.length > 0?this.dataList[data.rows.length-1].itemNo +10:10,
              itemDesc:undefined,
              site:this.$store.state.user.site,
              testNo:this.testNo,
              workCenterNo:undefined,
              workCenterDesc:undefined,
              workCenterType:undefined,
              machSetupTime:0,
              factorUnit:'单位/小时',
              machRunFactor:0,
              efficiency:100,
              requiredTime:0,
              requiredQty:0,
              reportedQty:0,
              approveQty:0,
              planStartTime:this.dayjs(new Date(this.testSoRouting.planFinishTime)).format("YYYY-MM-DD HH:mm:ss"),
              planFinishTime:this.dayjs(new Date(this.testSoRouting.planFinishTime)).format("YYYY-MM-DD HH:mm:ss"),
              remark:undefined,
            }
          })
        }
      })
    },
    saveTestSoRouting(isClose){
      this.$refs.saveForm.validate((validate,objects)=>{
        if (validate){
          this.testSoRouting.planStartTime = this.dayjs(new Date(this.testSoRouting.planStartTime)).format("YYYY-MM-DD HH:mm:ss")
          this.testSoRouting.planFinishTime = this.dayjs(new Date(this.testSoRouting.planFinishTime)).format("YYYY-MM-DD HH:mm:ss")
          if (!this.saveStatus){
            // 修改
            updateTestSoRouting(this.testSoRouting).then(({data})=>{
              if (data && data.code === 0){
                this.selectTestSoRoutingList();
                this.$message.success(data.msg)
                this.saveFlag = false
              }else {
                this.$message.warning(data.msg)
              }
            }).catch((error)=>{
              this.$message.error(error)
            })
          }else {
            // 新增
            saveTestSoRouting(this.testSoRouting).then(({data})=>{
              if (data && data.code === 0){
                this.selectTestSoRoutingList();
                this.$message.success(data.msg)
                if (!isClose){
                  this.saveFlag = false
                }
              }else {
                this.$message.warning(data.msg)
              }
            }).catch((error)=>{
              this.$message.error(error)
            })
          }
        }else {
          for (let key in objects) {
            this.$message.error(this.testSoRoutingLabel[key]+"不能为空")
          }
        }
      })

    },
    testSoRoutingClickRow(row,column){
      if (column.label !== '操作'){
        this.$refs.testSoRoutingTable.toggleRowSelection(row,true)
      }
    },
    selectionTestSoRouting(val){
      this.selectionTestSoRoutingList = val
    },
    removeTestSoRouting(){
      if (this.selectionTestSoRoutingList.length === 0){
        this.$message.warning("请选择要删除的工艺路线")
        return
      }
      this.$confirm('确定要删除该记录吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        removeBatchTestSoRouting(this.selectionTestSoRoutingList).then(({data}) => {
          if (data && data.code === 0) {
            this.selectTestSoRoutingList();
            this.$message.success(data.msg)
          } else {
            this.$message.warning(data.msg)
          }
        }).catch((error) => {
          this.$message.error(error)
        })
      }).catch(()=>{})
    },
    computeRequiredTime(){
      // 1、计算效率
      let total = new Decimal(this.testSoRouting.efficiency).div(new Decimal(100))
      // 2、计算单位生产时间
      let time = new Decimal(0);
      switch (this.testSoRouting.factorUnit){
        case "小时":
          time = new Decimal(this.testSoRouting.machRunFactor)
          break
        case "单位/小时":
          if (new Decimal(this.testSoRouting.machRunFactor).toNumber() !== 0){
            time = new Decimal(1).div(new Decimal(this.testSoRouting.machRunFactor))
          }
          break
        case "小时/单位":
          time = new Decimal(this.testSoRouting.machRunFactor).mul(new Decimal(1))
          break
      }
      total = total.mul(time)
      total = Decimal.add(new Decimal(this.testSoRouting.machSetupTime),total)
      this.testSoRouting.requiredTime = total;
      if (this.testSoRouting.requiredTime.toNumber !== 0){
        this.testSoRouting.requiredTime = new Decimal(total.toFixed(3,Decimal.ROUND_FLOOR)).toSignificantDigits().toNumber();
      }
    },
    openRouting(){
      if (this.saveStatus){
        this.testSoRouting.itemNo = this.dataList.length > 0?this.dataList[this.dataList.length-1].itemNo +10:10;
      }
    },
    changeWorkCenter(val){
      this.workCenter.workCenterNo = val
      this.searchWorkCenter(true)
    },
    openWorkCenterDialog(){
      this.workCenter.workCenterNo = this.testSoRouting.workCenterNo;
      this.searchWorkCenter()
    }
  },
}
</script>

<template>
  <div>
    <div style="margin-bottom: 5px">
      <el-button type="primary" v-if="!disabled" @click="saveTestSoRoutingBtn()">新增</el-button>
      <el-button type="primary" v-if="!disabled" @click="removeTestSoRouting">删除</el-button>
    </div>
    <el-table
      :height="height" border
      :data="dataList"
      ref="testSoRoutingTable"
      @row-click="testSoRoutingClickRow"
      @selection-change="selectionTestSoRouting">
      <el-table-column
        type="selection"
        header-align="center"
        align="center"
        width="50">
      </el-table-column>
      <el-table-column
        v-for="(item,index) in testSoRoutingColumnList" :key="index"
        :sortable="item.columnSortable"
        :prop="item.columnProp"
        :header-align="item.headerAlign"
        :show-overflow-tooltip="item.showOverflowTooltip"
        :align="item.align"
        :fixed="item.fixed===''?false:item.fixed"
        :min-width="item.columnWidth"
        :label="item.columnLabel">
        <template slot-scope="scope">
          <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
          <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" fixed="right">
        <template slot-scope="{row,$index}">
          <a type="text" style="cursor:pointer;" v-if="!disabled" @click="saveTestSoRoutingBtn(row)">编辑</a>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog :close-on-click-modal="false" :title="(saveStatus?'新增':'编辑')+'-工艺路线'" :visible.sync="saveFlag" @open="openRouting" v-drag append-to-body @close="closeTestSoRoutingDialog">
      <el-form :model="testSoRouting" label-position="top" ref="saveForm" :rules="testSoRoutingRule">
        <el-row :gutter="10">
          <el-col :span="8">
            <el-form-item label="工序号" prop="itemNo">
              <el-input-number style="width: 100%;margin-top: -5px;" :disabled="!saveStatus" :min="0" v-model="testSoRouting.itemNo" :controls="false"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="工序名称" prop="itemDesc">
              <el-input v-model="testSoRouting.itemDesc"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="8">
            <el-form-item label="加工中心" prop="workCenterNo">
              <span slot="label" style="cursor:pointer;" @click="workCenterDialogFlag = true"><a>加工中心</a></span>
              <el-input @change="changeWorkCenter" v-model="testSoRouting.workCenterNo"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="加工中心名称" prop="workCenterDesc">
              <el-input disabled v-model="testSoRouting.workCenterDesc"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="加工中心类别" prop="workCenterType">
              <el-input disabled v-model="testSoRouting.workCenterType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" v-if="false">
            <el-form-item label="准备时间" prop="machSetupTime">
              <el-input-number @input="computeRequiredTime" style="width: 100%;margin-top: -5px;" :min="0" v-model="testSoRouting.machSetupTime" :controls="false"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="8" v-if="false">
            <el-form-item label="单位产出量" prop="machRunFactor">
              <el-input-number @input="computeRequiredTime" style="width: 100%;margin-top: -5px;" :min="0" v-model="testSoRouting.machRunFactor" :controls="false"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="8" v-if="false">
            <el-form-item label="效率%" prop="efficiency">
              <el-input-number @input="computeRequiredTime" style="width: 100%;margin-top: -5px;" :min="0" v-model="testSoRouting.efficiency" :controls="false"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="8" v-if="false">
            <el-form-item label="产出单位" prop="factorUnit">
              <el-select v-model="testSoRouting.factorUnit" @change="computeRequiredTime"
                         style="width: 100%" placeholder="请选择" default-first-option>
                <el-option label="单位/小时" :value="'单位/小时'"></el-option>
                <el-option label="小时/单位" :value="'小时/单位'"></el-option>
                <el-option label="小时" :value="'小时'"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="8">
            <el-form-item label="需求时间(h)" prop="requiredTime">
              <el-input-number style="width: 100%;margin-top: -5px;" :min="0" v-model="testSoRouting.requiredTime" :controls="false"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="8" v-if="false">
            <el-form-item label="需求数量" prop="requiredQty">
              <el-input-number style="width: 100%;margin-top: -5px;" :min="0" v-model="testSoRouting.requiredQty" :controls="false"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10" v-if="false">
          <el-col :span="8">
            <el-form-item label="报告数量" prop="reportedQty">
              <el-input-number style="width: 100%;margin-top: -5px;" :min="0" v-model="testSoRouting.reportedQty" :controls="false"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="8" v-if="false">
            <el-form-item label="合格数量" prop="approveQty">
              <el-input-number style="width: 100%;margin-top: -5px;" :min="0" v-model="testSoRouting.approveQty" :controls="false"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="8" v-if="false">
            <el-form-item label="计划开工时间" prop="planStartTime">
              <el-date-picker
                style="width: 100%"
                v-model="testSoRouting.planStartTime"
                type="datetime"
                placeholder="选择日期时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8" v-if="false">
            <el-form-item label="计划完工时间" prop="planFinishTime">
              <el-date-picker
                style="width: 100%"
                v-model="testSoRouting.planFinishTime"
                type="datetime"
                placeholder="选择日期时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark" style="height: 90px">
              <el-input type="textarea" resize='none' :autosize="{ minRows: 3, maxRows: 3 }" v-model="testSoRouting.remark"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button v-if="saveStatus" type="primary" @click="saveTestSoRouting(true)">应 用</el-button>
        <el-button type="primary" @click="saveTestSoRouting(false)">确 定</el-button>
        <el-button @click="saveFlag = false">取 消</el-button>
      </span>
    </el-dialog>

    <el-dialog title="加工中心信息" v-drag @open="openWorkCenterDialog" :visible.sync="workCenterDialogFlag" width="40%" append-to-body @close="closeWorkCenterDialog">
      <el-form :model="workCenter" label-position="top">
        <el-row :gutter="10">
          <el-col :span="6">
            <el-form-item label="加工中心">
              <el-input v-model="workCenter.workCenterNo"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="加工中心名称">
              <el-input v-model="workCenter.workCenterDesc"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="加工中心类别">
              <el-input v-model="workCenter.workCenterType"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="6">
            <el-button type="primary" @click="searchWorkCenter">查询</el-button>
          </el-col>
        </el-row>
      </el-form>
      <el-table border height="200px" stripe
      :data="workCenterList" @row-dblclick="dblClickWorkCenterTable">
        <el-table-column label="加工中心" prop="workCenterNo"></el-table-column>
        <el-table-column label="加工中心名称" prop="workCenterDesc"></el-table-column>
        <el-table-column label="加工中心类别" prop="workCenterType"></el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<style scoped>
.el-input-number /deep/ .el-input__inner{
  text-align: right;
  padding-right: 5px !important;
}
</style>
