Преглед на файлове

生产订单增加加工方式跟BOM版本 是否必填配置 工艺路线增加选择按钮

jingshuyong преди 1 година
родител
ревизия
d98ee9e4ce

+ 9 - 0
src/api/mainData/index.js

@@ -189,3 +189,12 @@ export async function checkExists(params) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+//获取系统参数
+export async function parameterGetByCode(data) {
+  const res = await request.post('/sys/parameter/getByCode', data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 15 - 6
src/components/selectionDialog/processRoute.vue

@@ -95,13 +95,22 @@
             slot: 'status',
             showOverflowTooltip: true,
             minWidth: 110,
-            filters: [
-              { text: '草稿', value: -1 },
-              { text: '失效', value: 0 },
-              { text: '生效', value: 1 }
-            ],
+            // filters: [
+            //   { text: '草稿', value: -1 },
+            //   { text: '失效', value: 0 },
+            //   { text: '生效', value: 1 }
+            // ],
             filterMultiple: false,
-            columnKey: 'status'
+            columnKey: 'status',
+            formatter:(row)=>{
+              if(row.status == -1){
+                return '草稿'
+              }else if(row.status == 0){
+                return '失效'
+              }else{
+                return '生效'
+              }
+            }
           },
           {
             prop: 'approvalStatus',

+ 77 - 0
src/utils/date.js

@@ -0,0 +1,77 @@
+// 开始时间禁用范围(日期)
+// data 是表单数据 time 是当前时间 endTime 结束时间
+function startDisabledDate(data, endTime, time) {
+  const end = data[endTime];
+  if (!end) return false; // 无结束时间,不禁用
+  // 将结束时间和当前时间都转换为“当天0点”,仅比较年月日
+  const endDay = new Date(end);
+  endDay.setHours(0, 0, 0, 0);
+  const currentDay = new Date(time);
+  currentDay.setHours(0, 0, 0, 0);
+  return currentDay > endDay; // 仅当天0点更晚时禁用
+}
+
+// 结束时间禁用范围(日期)
+// data 是表单数据 time 是当前时间 startTime 开始时间
+function endDisabledDate(data, startTime, time) {
+  const start = data[startTime];
+  if (!start) return false; // 无开始时间,不禁用
+  // 将开始时间和当前时间都转换为“当天0点”,仅比较年月日
+  const startDay = new Date(start);
+  startDay.setHours(0, 0, 0, 0);
+  const currentDay = new Date(time);
+  currentDay.setHours(0, 0, 0, 0);
+  return currentDay < startDay; // 仅当天0点更早时禁用
+}
+
+// 新增:限制同一天内的时间必须晚于开始时间
+function endDisabledTime(data, startTime, date) {
+  const start = data[startTime];
+  if (!start) {
+    return {
+      disabledHours: () => [],
+      disabledMinutes: () => [],
+      disabledSeconds: () => []
+    };
+  }
+  const startDate = new Date(start);
+  const currentDate = new Date(date);
+
+  // 判断是否是同一天
+  if (
+    currentDate.getFullYear() === startDate.getFullYear() &&
+    currentDate.getMonth() === startDate.getMonth() &&
+    currentDate.getDate() === startDate.getDate()
+  ) {
+    const startHour = startDate.getHours();
+    const startMinute = startDate.getMinutes();
+    const startSecond = startDate.getSeconds();
+    return {
+      // 禁用比 startHour 早的小时
+      disabledHours: () => Array.from({ length: startHour }, (_, i) => i),
+      // 若小时相同,禁用比 startMinute 早的分钟
+      disabledMinutes: (hour) =>
+        hour === startHour
+          ? Array.from({ length: startMinute }, (_, i) => i)
+          : [],
+      // 若小时和分钟都相同,禁用比 startSecond 早的秒
+      disabledSeconds: (hour, minute) =>
+        hour === startHour && minute === startMinute
+          ? Array.from({ length: startSecond }, (_, i) => i)
+          : []
+    };
+  } else {
+    // 不同天,时间无限制
+    return {
+      disabledHours: () => [],
+      disabledMinutes: () => [],
+      disabledSeconds: () => []
+    };
+  }
+}
+
+export default {
+  startDisabledDate,
+  endDisabledDate,
+  endDisabledTime
+}

+ 184 - 60
src/views/productionPlan/components/factoryAdd/index.vue

@@ -250,8 +250,12 @@
               v-slot:produceRoutingId="{ row, $index }"
               v-if="clientEnvironmentId != 4"
             >
-              <div style="display: flex" >
-                <el-select v-model="row.produceRoutingId">
+              <!-- <el-form-item required> -->
+              <div style="display: flex">
+                <el-select
+                  v-model="row.produceRoutingId"
+                  v-show="isRouteSelect(row)"
+                >
                   <el-option
                     v-for="item of row.routingList"
                     :key="item.id"
@@ -260,13 +264,22 @@
                   ></el-option>
                 </el-select>
 
-                <!-- <div style="display: flex">
-                  <el-input disabled v-model="row.produceRoutingName"></el-input>
-                  <el-button type="primary" size="mini" @click="openDialog"
+                <div style="display: flex">
+                  <el-input
+                    v-show="!isRouteSelect(row)"
+                    disabled
+                    v-model="row.produceRoutingName"
+                  ></el-input>
+                  <el-button
+                    v-show="isSelectShow"
+                    type="primary"
+                    size="mini"
+                    @click="openDialog($index)"
                     >选择</el-button
                   >
-                </div> -->
+                </div>
               </div>
+              <!-- </el-form-item> -->
             </template>
 
             <template v-slot:produceRoutingId="{ row, $index }" v-else>
@@ -351,6 +364,16 @@
                 >删除</el-button
               >
             </template>
+            <template v-slot:headerProduceRoutingId="{ column }">
+              <div class="header_required"
+                ><span class="is-required">{{ column.label }}</span></div
+              >
+            </template>
+            <template v-slot:headerProcessingBOM="{ column }">
+              <div :class="isRequired ? 'header_required' : ''"
+                ><span class="is-required">{{ column.label }}</span></div
+              >
+            </template>
           </ele-pro-table>
           <div class="add-product" @click="addEquipment">
             <i class="el-icon-circle-plus-outline"></i>
@@ -363,6 +386,7 @@
         @choose="confirmChoose"
         :selectList="[]"
         ref="equipmentRefs"
+        isMultiple="0"
       >
       </EquipmentDialog>
     </div>
@@ -381,6 +405,7 @@
   import EquipmentDialog from '@/views/saleOrder/components/EquipmentDialog';
   import { getCode } from '@/api/codeManagement';
   import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
+  import { parameterGetByCode } from '@/api/mainData/index';
   import {
     bomRoutingList,
     bomListByPlan,
@@ -423,8 +448,43 @@
       // }
     },
     computed: {
+      // 是否必填 字段 ( 首先看计划类型 如果是返工返修)
+      // 就不是必填 否则就看配置参数
+
+      // 必填的时候 不显示选择按钮 跟 展示输入框 只能有下拉选择框 ( 选择了加工方式 带出 BOM 版本 带出 工艺路线 工艺路线不能选择)
+      // 不必填的时候 显示 选择按钮跟 展示输入框 并且可以存在选择框 一开始默认展示选择框
+      //   选择按钮选择数据后 隐藏选择框 显示展示框(input) 情况 加工方式 跟 BOM版本
+      //   选择了加工方式 清空 选择框选择的工艺路线
+
+      // 是否必填字段
+      isRequired() {
+        if (this.form.planType == 5) {
+          return false;
+        }
+        return this.processingRequired == 1;
+      },
+      // 工艺路线 输入框展示跟选择框判断
+      isRouteSelect() {
+        return (row) => {
+          if (this.isRequired) {
+            return true;
+          }
+          if (!row.selectionRowShow) {
+            return true;
+          }
+
+          return false;
+        };
+      },
+
+      // 选择按钮的显示
+      isSelectShow() {
+        if (this.form.planType == 5) {
+          return true;
+        }
+        return this.processingRequired == 0;
+      },
       clientEnvironmentId() {
-        console.log(this.$store.state.user.info, 'info --');
         return this.$store.state.user.info.clientEnvironmentId;
       },
       columns() {
@@ -506,20 +566,23 @@
             slot: 'productType',
             prop: 'productType',
             label: '加工方式',
+            headerSlot: 'headerProcessingBOM',
             align: 'center',
-            minWidth: 140
+            minWidth: 180
           },
           {
             slot: 'bomCategoryId',
             prop: 'bomCategoryId',
             label: 'BOM版本',
+            headerSlot: 'headerProcessingBOM',
             align: 'center',
-            minWidth: 140,
+            minWidth: 180,
             show: this.clientEnvironmentId !== 4
           },
           {
             slot: 'produceRoutingId',
             prop: 'produceRoutingId',
+            headerSlot: 'headerProduceRoutingId',
             label: '工艺路线',
             align: 'center',
             minWidth: 240
@@ -592,7 +655,8 @@
             prop: 'set',
             label: '操作',
             align: 'center',
-            minWidth: 140
+            minWidth: 140,
+            fixed: 'right'
           }
         ];
       }
@@ -620,7 +684,6 @@
           { label: '返工返修计划', value: '5' }
         ],
         loading: false,
-
         form: {
           timeDimensionPlanType: 3,
           categoryId: '',
@@ -642,7 +705,6 @@
           requiredFormingNum: '',
           productInfoList: []
         },
-
         disabledList: [],
         bomVersionList: [],
         routingList: [],
@@ -670,11 +732,13 @@
             { required: true, message: '请输入生产数量', trigger: 'blur' }
           ]
         },
-
         producedList: [
           { code: 2, name: '加工(MBOM)' },
           { code: 3, name: '装配(ABOM)' }
-        ]
+        ],
+        selectIndex: 0, // 选择工艺路线的当前数据下标
+        processingRequired: 0 // 加工方式跟BOM 版本是否必填 1:是 0:否
+        // selectionRowShow: false // 工艺路线输入框展示 状态
       };
     },
 
@@ -683,6 +747,16 @@
     //     return this.$store.state.user.info.clientEnvironmentId;
     //   }
     // },
+    mounted() {
+      // 加工方式跟BOM版本字段是否必填
+      parameterGetByCode({
+        code: 'production_plan_code'
+      }).then((res) => {
+        if (res) {
+          this.processingRequired = res.value;
+        }
+      });
+    },
     methods: {
       selectFactory(e, row) {
         let data = this.factoryList.find((item) => item.id === e);
@@ -690,12 +764,23 @@
       },
 
       // 打开工艺路线
-      openDialog() {
-        console.log(this.$refs.processRouteRef, '热反射');
+      openDialog(index) {
+        this.selectIndex = index;
         this.$refs.processRouteRef.open();
       },
+
+      // 选择工艺路线
       changeParent(item) {
-        console.log(item, '12345');
+        let data = this.form.productInfoList[this.selectIndex];
+        this.$set(data, 'bomVersionList', []);
+        this.$set(data, 'bomCategoryId', '');
+        this.$set(data, 'model', '');
+        this.$set(data, 'routingList', []);
+        this.$set(data, 'productType', '');
+        this.$set(data, 'produceRoutingName', item.name);
+        this.$set(data, 'produceRoutingId', item.id);
+        this.$set(data, 'selectionRowShow', true);
+        // this.selectionRowShow = true;
       },
       async getFactoryList() {
         this.factoryList = await getFactoryList();
@@ -714,6 +799,12 @@
               val.productInfoList.length
             ) {
               this.form.productInfoList.map(async (v, index) => {
+                if (!v.bomCategoryId) {
+                  v.productType = '';
+                  v.selectionRowShow = true;
+                } else {
+                  v.selectionRowShow = false;
+                }
                 if (v.productType) {
                   this.$set(
                     this.form.productInfoList[index],
@@ -731,7 +822,6 @@
               });
             }
           }
-          console.log(this.form, 'this.form 1111');
           this.$forceUpdate();
         }
         this.visible = true;
@@ -756,6 +846,7 @@
       },
 
       confirmChoose(list) {
+        list.map((el) => (el.selectionRowShow = false));
         if (this.clientEnvironmentId == 4) {
           list.map((v) => {
             if (v.name.includes('板材')) {
@@ -900,75 +991,109 @@
         });
       },
 
+      // 选择BOM
       changeBomId(row, index) {
-        console.log(row, '-------');
         // row.routingList = []
-
         bomRoutingList(row.bomCategoryId).then((res) => {
           let arr = res || [];
-          console.log(arr);
-          if (arr.length == 0) {
-            row.produceRoutingId = '';
+          if (arr.length > 0) {
+            this.$nextTick(() => {
+              row.produceRoutingName = arr[0].name;
+              row.produceVersionName = arr[0].version;
+              row.routingList = arr;
+              this.$set(
+                this.form.productInfoList[index],
+                'produceRoutingId',
+                arr[0].id
+              );
+              // this.selectionRowShow = false;
+              row.selectionRowShow = false;
+              this.$set(this.form.productInfoList[index], 'routingList', arr);
+            });
           }
-          this.$nextTick(() => {
-            this.$set(this.form.productInfoList[index], 'routingList', arr);
-
-            row.routingList = arr;
-          });
-
-          console.log();
           this.$forceUpdate();
         });
       },
 
+      // 清空BOM 跟工艺路线
+      wipeData(index) {
+        let row = this.form.productInfoList[index];
+        row.bomCategoryId = '';
+        row.routingList = [];
+        row.bomVersionList = [];
+        row.produceRoutingId = '';
+        row.produceRoutingName = '';
+        row.produceVersionName = '';
+        row.selectionRowShow = false;
+        // this.selectionRowShow = false;
+      },
+
+      // 选择加工方式
       changeProductType(row, index) {
         let param = {
           bomType: row.productType,
           categoryId: row.categoryId
         };
+
+        this.wipeData(index);
+        // row.bomCategoryId = '';
+        // this.form.productInfoList[index].bomVersionList = [];
         bomListByPlan(param).then((res) => {
           let arr = res || [];
-          console.log(arr, 'arr');
-          if (arr.length == 0) {
-            row.bomCategoryId = '';
-          }
-
           this.$nextTick(() => {
             if (arr.length) {
               row.bomVersionList = arr;
               this.form.productInfoList[index].bomVersionList = arr;
+              row.bomCategoryId = arr[0].id;
+              this.changeBomId(row, index);
               let arrAll = JSON.parse(JSON.stringify(this.form));
               this.$set(this, 'form', arrAll);
-            } else {
-              this.form.productInfoList[index].bomVersionList = [];
             }
           });
 
           // this.$set(this.form.productInfoList[index], 'bomVersionList', arr);
         });
-        console.log(row, 'row ===');
       },
 
+      // 参数校验
+      parameterVerification() {
+        let flag = true;
+        this.form.productInfoList.forEach((v) => {
+          if (this.isRequired) {
+            if (!v.productType) {
+              flag = false;
+              this.$message.warning('请选择加工方式');
+              return;
+            }
+
+            if (!v.bomCategoryId) {
+              flag = false;
+              this.$message.warning('请选择BOM版本');
+              return;
+            }
+          }
+
+          if (!v.produceRoutingId) {
+            flag = false;
+            this.$message.warning('请选择工艺路线');
+            return;
+          }
+        });
+        return flag;
+      },
       save() {
         this.$refs.form.validate(async (valid) => {
-          console.log(this.form, 'validvalid', valid);
           if (!valid) {
             return false;
           }
 
-          console.log(this.form);
-          let flag = true;
-          this.form.productInfoList.forEach((v) => {
-            if (!v.produceRoutingId) {
-              flag = false;
-              return this.$message.error('请选择工艺路线');
-            }
-          });
-          // 工艺路线必填
+          let flag = this.parameterVerification();
+          // 必填参数校验
           if (!flag) return;
           if (!this.form.id) {
             if (this.form.productInfoList.length) {
               this.form.productInfoList.map((item, index) => {
+                delete item.selectionRowShow;
                 if (item.bomVersionList && item.bomVersionList.length) {
                   item.bomCategoryName = item.bomVersionList[0].name;
                   item.bomCategoryVersions = item.bomVersionList[0].versions;
@@ -981,6 +1106,8 @@
             await this.getPlanCode();
             this.loading = true;
 
+            // console.log(this.form,'this.form 1+1 ')
+            // return
             temporaryPlanSave(this.form)
               .then((res) => {
                 this.$message.success('新增成功!');
@@ -1027,8 +1154,6 @@
         bomListByPlan(param).then((res) => {
           this.$nextTick(() => {
             this.bomVersionList = res || [];
-
-            console.log(this.bomVersionList);
           });
         });
       },
@@ -1060,8 +1185,6 @@
           let modeWide = modelArr[1]; // model规格宽度
           let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
           modeHight = Number(modeHight);
-
-          console.log(modeHight, '111111');
           if (name === 'moCount') {
             // 模数
 
@@ -1108,8 +1231,6 @@
             row['requiredFormingNum'] = numNew;
           } else if (name === 'sum') {
             let e = row.requiredFormingNum;
-            console.log('方数');
-
             //方数
             row.planProductNum = e;
 
@@ -1165,14 +1286,12 @@
               (Number(row.blockCount) * modelLong * modeWide * modeHight) /
               1000000
             ).toFixed(5);
-            console.log(a, 'dsds');
-
             row.requiredFormingNum = a;
           }
         }
       },
 
-      changeProduceType() {
+      changeProduceType(e) {
         if (this.clientEnvironmentId !== 4) {
           this.form.bomCategoryId = '';
           this.form['bomCategoryName'] = '';
@@ -1205,7 +1324,6 @@
       // },
 
       changeRoute() {
-        console.log(this.routingList, this.form.produceRoutingId);
         this.$forceUpdate();
         this.routingList.forEach((f) => {
           if (f.id == this.form.produceRoutingId) {
@@ -1217,9 +1335,7 @@
       },
 
       cancel() {
-        console.log('取消');
         this.visible = false;
-
         this.initForm();
         this.$emit('close');
       }
@@ -1242,4 +1358,12 @@
     margin: 10px 0;
     cursor: pointer;
   }
+
+  .header_required {
+    .is-required:before {
+      content: '*';
+      color: #f56c6c;
+      margin-right: 4px;
+    }
+  }
 </style>

+ 21 - 12
src/views/saleOrder/components/EquipmentDialog.vue

@@ -36,7 +36,7 @@
                   size="small"
                 ></el-input>
               </el-col>
-              
+
               <el-col :span="4" style="margin-left: 10px">
                 <el-button type="primary" size="small" @click="reload"
                   >搜索</el-button
@@ -84,9 +84,15 @@
       AssetTree
     },
     props: {
-      selectList: Array
+      selectList: Array,
+      // 是否多选 1:是 0:否
+      isMultiple: {
+        type: String,
+        default: '1'
+      }
     },
-    data () {
+
+    data() {
       return {
         equipmentdialog: false,
         columns: [
@@ -153,7 +159,7 @@
 
     watch: {},
     methods: {
-      async datasource ({ page, limit }) {
+      async datasource({ page, limit }) {
         const params = {
           code: this.code,
           name: this.name,
@@ -167,28 +173,28 @@
         this.tableList = data.list;
         return data;
       },
-      open () {
+      open() {
         this.equipmentdialog = true;
         this.setSelect();
       },
-      handleNodeClick (data) {
+      handleNodeClick(data) {
         this.categoryLevelId = data.id;
         this.reload();
       },
-      reload () {
+      reload() {
         this.$refs.equiTable.reload();
       },
-      handleClose () {
+      handleClose() {
         this.equipmentdialog = false;
         this.code = '';
         this.$refs.equiTable.clearSelection();
       },
-      reset () {
+      reset() {
         this.code = null;
         this.reload();
       },
       // 设置选中
-      setSelect () {
+      setSelect() {
         this.$nextTick(() => {
           this.tableList.forEach((row) => {
             this.selectList.forEach((selected, index) => {
@@ -200,7 +206,7 @@
         });
       },
       // 取消选中
-      handleSelect (selection, row) {
+      handleSelect(selection, row) {
         if (!selection.find((i) => i.id === row.id)) {
           const index = this.selectList.findIndex(
             (itm) => row.code == itm.productCode
@@ -212,7 +218,10 @@
         }
       },
       // 选择
-      selected () {
+      selected() {
+        if (this.isMultiple == '0' && this.selection.length > 1) {
+          return this.$message.warning('生产计划只能选择一条产品');
+        }
         this.$emit('choose', [
           ...this.selection,
           ...this.selectList.filter(

+ 892 - 520
src/views/saleOrder/components/create-order.vue

@@ -1,48 +1,90 @@
 <template>
   <div>
-    <ele-modal :visible.sync="visible" :title="title" width="80vw" append-to-body :maxable="true">
-      <el-form ref="form" :model="form" :rules="rules" label-width="90px" class="create-form" :maxable="true">
+    <ele-modal
+      :visible.sync="visible"
+      :title="title"
+      width="80vw"
+      append-to-body
+      :maxable="true"
+    >
+      <el-form
+        ref="form"
+        :model="form"
+        :rules="rules"
+        label-width="90px"
+        class="create-form"
+        :maxable="true"
+      >
         <el-row :gutter="24">
           <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
             <el-form-item label="销售订单号:">
-              <el-input clearable :maxlength="20" v-model="form.code" disabled />
+              <el-input
+                clearable
+                :maxlength="20"
+                v-model="form.code"
+                disabled
+              />
             </el-form-item>
           </el-col>
           <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
             <el-form-item label="订单类型:" prop="orderType">
-              <el-select v-model="form.orderType" style="width: 100%;">
-                <el-option v-for="item of orderTypeList" :key="item.id" :label="item.label"
-                  :value="item.id"></el-option>
+              <el-select v-model="form.orderType" style="width: 100%">
+                <el-option
+                  v-for="item of orderTypeList"
+                  :key="item.id"
+                  :label="item.label"
+                  :value="item.id"
+                ></el-option>
               </el-select>
             </el-form-item>
           </el-col>
           <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
             <el-form-item label="销售类型:">
-              <DictSelection dictName="订单类型" clearable v-model="form.saleType">
+              <DictSelection
+                dictName="订单类型"
+                clearable
+                v-model="form.saleType"
+              >
               </DictSelection>
             </el-form-item>
           </el-col>
           <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
             <el-form-item label="按单按库:">
-              <DictSelection dictName="按单按库" clearable v-model="form.orderLibraryType">
+              <DictSelection
+                dictName="按单按库"
+                clearable
+                v-model="form.orderLibraryType"
+              >
               </DictSelection>
             </el-form-item>
           </el-col>
           <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
             <el-form-item label="客户名称:">
-              <el-input clearable v-model="form.customerName" :disabled="form.saleType == 3" />
+              <el-input
+                clearable
+                v-model="form.customerName"
+                :disabled="form.saleType == 3"
+              />
             </el-form-item>
           </el-col>
 
           <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
             <el-form-item label="客户简称:">
-              <el-input clearable v-model="form.simpleName" :disabled="form.saleType == 3" />
+              <el-input
+                clearable
+                v-model="form.simpleName"
+                :disabled="form.saleType == 3"
+              />
             </el-form-item>
           </el-col>
 
           <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
             <el-form-item label="客户代号:">
-              <el-input clearable v-model="form.serialNo" :disabled="form.saleType == 3" />
+              <el-input
+                clearable
+                v-model="form.serialNo"
+                :disabled="form.saleType == 3"
+              />
             </el-form-item>
           </el-col>
 
@@ -54,8 +96,14 @@
 
           <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
             <el-form-item label="交付日期:" prop="deliveryTime">
-              <el-date-picker :picker-options="pickerOptions" style="width: 100%" v-model="form.deliveryTime"
-                type="date" placeholder="选择日期" value-format="yyyy-MM-dd">
+              <el-date-picker
+                :picker-options="pickerOptions"
+                style="width: 100%"
+                v-model="form.deliveryTime"
+                type="date"
+                placeholder="选择日期"
+                value-format="yyyy-MM-dd"
+              >
               </el-date-picker>
             </el-form-item>
           </el-col>
@@ -74,7 +122,11 @@
           </el-col>
           <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
             <el-form-item label="交付要求:">
-              <DictSelection dictName="紧急程度" clearable v-model="form.deliveryRequirements">
+              <DictSelection
+                dictName="紧急程度"
+                clearable
+                v-model="form.deliveryRequirements"
+              >
               </DictSelection>
             </el-form-item>
           </el-col>
@@ -102,134 +154,287 @@
           </el-table-column>
           <el-table-column label="重量单位" align="center" prop="weightUnit">
           </el-table-column>
-          <el-table-column label="生产编号" align="center" prop="productionCodes" width="140">
+          <el-table-column
+            label="生产编号"
+            align="center"
+            prop="productionCodes"
+            width="140"
+          >
             <template slot-scope="scope">
-              <el-form-item label-width="0px" :prop="'productInfoList.' + scope.$index + '.productionCodes'">
-                <el-input style="width: 100%" size="small" v-model="scope.row.productionCodes" placeholder="请输入">
-              </el-input>
-            </el-form-item>
+              <el-form-item
+                label-width="0px"
+                :prop="'productInfoList.' + scope.$index + '.productionCodes'"
+              >
+                <el-input
+                  style="width: 100%"
+                  size="small"
+                  v-model="scope.row.productionCodes"
+                  placeholder="请输入"
+                >
+                </el-input>
+              </el-form-item>
             </template>
           </el-table-column>
-          <el-table-column label="批次号" align="center" prop="batchNo" width="140">
+          <el-table-column
+            label="批次号"
+            align="center"
+            prop="batchNo"
+            width="140"
+          >
             <template slot-scope="scope">
-              <el-form-item label-width="0px" :prop="'productInfoList.' + scope.$index + '.batchNo'">
-                <el-input style="width: 100%" size="small" v-model="scope.row.batchNo" placeholder="请输入" @input="(value) =>
-                (scope.row.batchNo = value.replace(
-                 /[^a-zA-Z0-9_-]/g, ''
-                ))">
-              </el-input>
-            </el-form-item>
+              <el-form-item
+                label-width="0px"
+                :prop="'productInfoList.' + scope.$index + '.batchNo'"
+              >
+                <el-input
+                  style="width: 100%"
+                  size="small"
+                  v-model="scope.row.batchNo"
+                  placeholder="请输入"
+                  @input="
+                    (value) =>
+                      (scope.row.batchNo = value.replace(/[^a-zA-Z0-9_-]/g, ''))
+                  "
+                >
+                </el-input>
+              </el-form-item>
             </template>
           </el-table-column>
-          <el-table-column label="订单数量" width="140" align="center" prop="contractNum">
+          <el-table-column
+            label="订单数量"
+            width="140"
+            align="center"
+            prop="contractNum"
+          >
             <template slot-scope="scope">
-              <el-form-item label-width="0px" :prop="'productInfoList.' + scope.$index + '.contractNum'" :rules="{
-                required: true,
-                message: '请输入订单数量',
-                trigger: 'blur'
-              }">
-                <el-input v-model.number="scope.row.contractNum" size="small" type="number" style="width: 100%"
-                  placeholder="输入数量" @input="inputNumber(scope.row, scope.$index)"></el-input>
+              <el-form-item
+                label-width="0px"
+                :prop="'productInfoList.' + scope.$index + '.contractNum'"
+                :rules="{
+                  required: true,
+                  message: '请输入订单数量',
+                  trigger: 'blur'
+                }"
+              >
+                <el-input
+                  v-model.number="scope.row.contractNum"
+                  size="small"
+                  type="number"
+                  style="width: 100%"
+                  placeholder="输入数量"
+                  @input="inputNumber(scope.row, scope.$index)"
+                ></el-input>
               </el-form-item>
             </template>
           </el-table-column>
 
-
-
-          <el-table-column label="加工方式" width="140" align="center" prop="productType">
+          <el-table-column
+            label="加工方式"
+            width="140"
+            align="center"
+            prop="productType"
+          >
+            <template slot="header" slot-scope="scope">
+              <div :class="isRequired ? 'header_required' : ''"
+                ><span class="is-required">加工方式</span></div
+              >
+            </template>
             <template slot-scope="scope">
-              <el-form-item label-width="0px" :prop="'productInfoList.' + scope.$index + '.productType'">
-
-                <el-select v-model="scope.row.productType" @change="changeProductType(scope.row, scope.$index)"
-                  :key="scope.$index">
-                  <el-option v-for="item of producedList" :key="scope.$index + item.code" :label="item.name"
-                    :value="item.code"></el-option>
+              <el-form-item
+                label-width="0px"
+                :prop="'productInfoList.' + scope.$index + '.productType'"
+              >
+                <el-select
+                  v-model="scope.row.productType"
+                  @change="changeProductType(scope.row, scope.$index)"
+                  :key="scope.$index"
+                >
+                  <el-option
+                    v-for="item of producedList"
+                    :key="scope.$index + item.code"
+                    :label="item.name"
+                    :value="item.code"
+                  ></el-option>
                 </el-select>
-
               </el-form-item>
             </template>
           </el-table-column>
 
-
-
-          <el-table-column label="BOM版本" width="140" align="center" prop="bomCategoryId"
-            v-if="clientEnvironmentId != 4">
+          <el-table-column
+            :label-class-name="isRequired ? 'header_required' : ''"
+            label="BOM版本"
+            width="140"
+            align="center"
+            prop="bomCategoryId"
+            v-if="clientEnvironmentId != 4"
+          >
+            <template slot="header" slot-scope="scope">
+              <div :class="isRequired ? 'header_required' : ''"
+                ><span class="is-required">BOM版本</span></div
+              >
+            </template>
             <template slot-scope="scope">
-              <el-form-item label-width="0px" :prop="'productInfoList.' + scope.$index + '.bomCategoryId'"
-                :key="scope.$index">
-
-                <el-select v-model="scope.row.bomCategoryId" @change="changeBomId(scope.row, scope.$index)">
-                  <el-option v-for="item of scope.row.bomVersionList" :key="item.id"
-                    :label="item.name + '(V' + item.versions + '.0)'" :value="item.id"></el-option>
+              <el-form-item
+                label-width="0px"
+                :prop="'productInfoList.' + scope.$index + '.bomCategoryId'"
+                :key="scope.$index"
+              >
+                <el-select
+                  v-model="scope.row.bomCategoryId"
+                  @change="changeBomId(scope.row, scope.$index)"
+                >
+                  <el-option
+                    v-for="item of scope.row.bomVersionList"
+                    :key="item.id"
+                    :label="item.name + '(V' + item.versions + '.0)'"
+                    :value="item.id"
+                  ></el-option>
                 </el-select>
-
               </el-form-item>
             </template>
           </el-table-column>
 
-          <el-table-column label="工艺路线" width="140" align="center" prop="produceRoutingId"
-            v-if="clientEnvironmentId != 4">
+          <el-table-column
+            label="工艺路线"
+            width="240"
+            align="center"
+            prop="produceRoutingId"
+            v-if="clientEnvironmentId != 4"
+          >
+            <template slot="header" slot-scope="scope">
+              <div class="header_required"
+                ><span class="is-required">工艺路线</span></div
+              >
+            </template>
             <template slot-scope="scope">
-              <el-form-item label-width="0px" :prop="'productInfoList.' + scope.$index + '.produceRoutingId'">
-                <el-select v-model="scope.row.produceRoutingId" @change="changeRoutingList(scope.row, scope.$index)">
-                  <el-option v-for="item of scope.row.routingList" :key="item.id" :label="item.name"
-                    :value="item.id"></el-option>
-                </el-select>
-
+              <el-form-item
+                label-width="0px"
+                :prop="'productInfoList.' + scope.$index + '.produceRoutingId'"
+              >
+                <div style="display: flex">
+                  <el-select
+                    v-model="scope.row.produceRoutingId"
+                    @change="changeRoutingList(scope.row, scope.$index)"
+                    v-show="isRouteSelect(scope.row)"
+                  >
+                    <el-option
+                      v-for="item of scope.row.routingList"
+                      :key="item.id"
+                      :label="item.name"
+                      :value="item.id"
+                    ></el-option>
+                  </el-select>
+                  <div style="display: flex">
+                    <el-input
+                      v-show="!isRouteSelect(scope.row)"
+                      disabled
+                      v-model="scope.row.produceRoutingName"
+                    ></el-input>
+                    <el-button
+                      v-show="isSelectShow"
+                      type="primary"
+                      size="mini"
+                      @click="openDialog(scope.$index)"
+                      >选择</el-button
+                    >
+                  </div>
+                </div>
               </el-form-item>
             </template>
           </el-table-column>
 
-          <el-table-column label="工艺路线" align="center" prop="produceRoutingName" v-if="clientEnvironmentId == 4">
+          <el-table-column
+            label="工艺路线"
+            align="center"
+            prop="produceRoutingName"
+            v-if="clientEnvironmentId == 4"
+          >
             <template slot-scope="scope">
-              <el-form-item label-width="0px" :prop="'productInfoList.' + scope.$index + '.produceRoutingName'">
-                <el-input v-model="form.produceRoutingName" style="width: 100%" readonly></el-input>
-
+              <el-form-item
+                label-width="0px"
+                :prop="
+                  'productInfoList.' + scope.$index + '.produceRoutingName'
+                "
+              >
+                <el-input
+                  v-model="form.produceRoutingName"
+                  style="width: 100%"
+                  readonly
+                ></el-input>
               </el-form-item>
             </template>
           </el-table-column>
 
-          <el-table-column label="所属工厂" width="140" align="center" prop="factoriesId">
+          <el-table-column
+            label="所属工厂"
+            width="140"
+            align="center"
+            prop="factoriesId"
+          >
             <template slot-scope="scope">
               <el-form-item label-width="0px">
-
-                <el-select v-model="scope.row.factoriesId" :key="scope.row.factoriesId">
-                  <el-option v-for="item of factoryList" :key="item.id" :label="item.name" :value="item.id"></el-option>
+                <el-select
+                  v-model="scope.row.factoriesId"
+                  :key="scope.row.factoriesId"
+                >
+                  <el-option
+                    v-for="item of factoryList"
+                    :key="item.id"
+                    :label="item.name"
+                    :value="item.id"
+                  ></el-option>
                 </el-select>
-
               </el-form-item>
             </template>
           </el-table-column>
 
-
-
-
           <el-table-column label="计量单位" align="center" prop="measuringUnit">
-
           </el-table-column>
-          <el-table-column label="模数" align="center" width="100" v-if="clientEnvironmentId == '4'">
+          <el-table-column
+            label="模数"
+            align="center"
+            width="100"
+            v-if="clientEnvironmentId == '4'"
+          >
             <template slot-scope="scope">
               <div>
-                <el-input style="width: 100%" size="small" v-model="scope.row.moCount"
-                  oninput="value=value.replace(/[^0-9.]/g,'')" @input="
+                <el-input
+                  style="width: 100%"
+                  size="small"
+                  v-model="scope.row.moCount"
+                  oninput="value=value.replace(/[^0-9.]/g,'')"
+                  @input="
                     tableHandleKeyUp(scope.row, scope.$index, $event, 'moCount')
-                    " placeholder="请输入">
+                  "
+                  placeholder="请输入"
+                >
                 </el-input>
               </div>
             </template>
           </el-table-column>
 
-          <el-table-column align="center" width="100" label="块数" v-if="clientEnvironmentId == '4'">
+          <el-table-column
+            align="center"
+            width="100"
+            label="块数"
+            v-if="clientEnvironmentId == '4'"
+          >
             <template slot-scope="scope">
               <div>
-                <el-input size="small" style="width: 100%" @input="
-                  tableHandleKeyUp(
-                    scope.row,
-                    scope.$index,
-                    $event,
-                    'blockCount'
-                  )
-                  " v-model="scope.row.blockCount" placeholder="请输入"></el-input>
+                <el-input
+                  size="small"
+                  style="width: 100%"
+                  @input="
+                    tableHandleKeyUp(
+                      scope.row,
+                      scope.$index,
+                      $event,
+                      'blockCount'
+                    )
+                  "
+                  v-model="scope.row.blockCount"
+                  placeholder="请输入"
+                ></el-input>
               </div>
             </template>
           </el-table-column>
@@ -238,14 +443,22 @@
               <span>{{ row.productWeight ? row.productWeight : '-' }}</span>
             </template>
           </el-table-column>
-          <el-table-column label="操作" align="center" width="70">
+          <el-table-column label="操作" align="center" width="160">
             <template slot-scope="scope">
-              <el-link type="primary" :underline="false" @click="homogeneityInspect(scope.row)">
+              <el-link
+                type="primary"
+                :underline="false"
+                @click="homogeneityInspect(scope.row)"
+              >
                 齐套性检查
               </el-link>
-              <el-button type="text" @click="handleDeleteItem(scope.$index)" v-if="!scope.row.id">删除</el-button>
+              <el-button
+                type="text"
+                @click="handleDeleteItem(scope.$index)"
+                v-if="!scope.row.id"
+                >删除</el-button
+              >
             </template>
-
           </el-table-column>
         </el-table>
         <div class="add-product" @click="addEquipment">
@@ -258,480 +471,639 @@
           确定
         </el-button>
       </template>
-
+      <!-- 选择工艺路线 -->
+      <ProcessRoute ref="processRouteRef" @changeParent="changeParent" />
       <!-- 选择产品 -->
-      <EquipmentDialog ref="equipmentRefs" @choose="confirmChoose" :selectList="form.productInfoList.filter(
-        (i) => !disabledList.find((p) => p.productCode === i.productCode)
-      )
-        ">
+      <EquipmentDialog
+        ref="equipmentRefs"
+        @choose="confirmChoose"
+        :selectList="
+          form.productInfoList.filter(
+            (i) => !disabledList.find((p) => p.productCode === i.productCode)
+          )
+        "
+      >
       </EquipmentDialog>
-
-
-
     </ele-modal>
-    <orderHomogeneityInspectDialog ref="orderHomogeneityInspectDialog"></orderHomogeneityInspectDialog>
-    <orderHomogeneityInspectInstallDialog ref="orderHomogeneityInspectInstallDialog">
+    <orderHomogeneityInspectDialog
+      ref="orderHomogeneityInspectDialog"
+    ></orderHomogeneityInspectDialog>
+    <orderHomogeneityInspectInstallDialog
+      ref="orderHomogeneityInspectInstallDialog"
+    >
     </orderHomogeneityInspectInstallDialog>
-
   </div>
 </template>
 
 <script>
-import { getCode } from '@/api/codeManagement';
-import EquipmentDialog from '../components/EquipmentDialog.vue';
-import orderHomogeneityInspectDialog from "./orderHomogeneityInspectDialog";
-import orderHomogeneityInspectInstallDialog from "./orderHomogeneityInspectInstallDialog";
-import { createOrUpdate, getOrderDetail, bomListByPlan, bomRoutingList, getFactoryList } from '@/api/saleOrder';
-
-import dayjs from 'dayjs';
-import { multiply } from '@/utils/math';
-export default {
-  components: {
-    EquipmentDialog,
-    orderHomogeneityInspectDialog,
-    orderHomogeneityInspectInstallDialog
-  },
-  data() {
-    return {
-      visible: false,
-      loading: false,
-      disabledList: [], //已保存数据不做删除
-      form: {
-        productInfoList: [],
-        deliveryRequirements: 1,
-        saleType: 1,
-        orderLibraryType: 2,
-        productType: 2,
-        bomCategoryId: '',
-        produceRoutingId: '',
-        factoriesId: '',
-        deliveryTime: dayjs(
-          new Date().getTime() + 3600 * 1000 * 24 * 10
-        ).format('YYYY-MM-DD'),
-        orderType: 0
-      },
-      // 表单验证规则
-      rules: {
-        deliveryTime: [
-          { required: true, message: '请选择交付日期', trigger: 'change' }
-        ],
-        orderType: [
-          { required: true, message: '请选择订单类型', trigger: 'blur' }
-        ]
-
-      },
-      typeList: [
-        { id: 1, label: '内销订单' },
-        { id: 2, label: '外销订单' },
-        { id: 3, label: '预制订单' }
-      ],
-
-      producedList: [
-        { code: 2, name: '加工(MBOM)' },
-        { code: 3, name: '装配(ABOM)' }
-      ],
-
-      completeList: [
-        { code: 1, name: '齐套' },
-        { code: 2, name: '缺料' }
-      ],
-
-
-      routingList: [],
-      factoryList: [],
-
-
-      title: '创建订单',
-      pickerOptions: {
-        disabledDate: (time) => {
-          // 禁用日期
-          let nowData = new Date();
-          nowData = new Date(nowData.setDate(nowData.getDate() - 1));
-          return time < nowData;
-        }
-      },
-      // 订单类型
-      orderTypeList: [ 
-        {
-          id: 0, label: '库存性订单'
-        },
-        {
-          id: 1, label: '生产性订单'
-        },
-        {
-          id: 2, label: '无客户生产性订单'
+  import { getCode } from '@/api/codeManagement';
+  import EquipmentDialog from '../components/EquipmentDialog.vue';
+  import orderHomogeneityInspectDialog from './orderHomogeneityInspectDialog';
+  import orderHomogeneityInspectInstallDialog from './orderHomogeneityInspectInstallDialog';
+  import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
+  import {
+    createOrUpdate,
+    getOrderDetail,
+    bomListByPlan,
+    bomRoutingList,
+    getFactoryList
+  } from '@/api/saleOrder';
+  import { parameterGetByCode } from '@/api/mainData/index';
+  import dayjs from 'dayjs';
+  import { multiply } from '@/utils/math';
+  export default {
+    components: {
+      EquipmentDialog,
+      orderHomogeneityInspectDialog,
+      orderHomogeneityInspectInstallDialog,
+      ProcessRoute
+    },
+    data() {
+      return {
+        visible: false,
+        loading: false,
+        disabledList: [], //已保存数据不做删除
+        form: {
+          productInfoList: [],
+          deliveryRequirements: 1,
+          saleType: 1,
+          orderLibraryType: 2,
+          productType: 2,
+          bomCategoryId: '',
+          produceRoutingId: '',
+          factoriesId: '',
+          deliveryTime: dayjs(
+            new Date().getTime() + 3600 * 1000 * 24 * 10
+          ).format('YYYY-MM-DD'),
+          orderType: 0
         },
-        {
-          id: 4, label: '不定向订单'
+        // 表单验证规则
+        rules: {
+          deliveryTime: [
+            { required: true, message: '请选择交付日期', trigger: 'change' }
+          ],
+          orderType: [
+            { required: true, message: '请选择订单类型', trigger: 'blur' }
+          ]
         },
-      ],
-    };
-  },
-  watch: {
-    disabledList() {
-      console.log(this.disabledList, 'disabledList');
-    }
-  },
-  computed: {
-    // 是否开启响应式布局
-    styleResponsive() {
-      return this.$store.state.theme.styleResponsive;
-    },
-    clientEnvironmentId() {
-      return this.$store.state.user.info.clientEnvironmentId;
-    }
-  },
-  created() { },
-  mounted() {
-    this.getFactoryList();
-  },
-  methods: {
-    filterInput(value) {
-      console.log('cccccc',value)
-      let aaa= value.replace(/[^a-zA-Z0-9]/g, '');
-      console.log('cccaaaaaaaccc',aaa)
-    },
-    changeRoutingList(row, index) {
-      const obj = row.routingList?.find(item => item.id === row.produceRoutingId);
-      if (obj) {
-        row.produceRoutingName = obj.name;
-      }
-    },
-    async getFactoryList() {
-      this.factoryList = await getFactoryList();
-    },
-    open(row) {
-      this.visible = true;
-      console.log('entry,,,,,,,,,,,,,', row);
-      if (row) {
-        this.title = '修改订单';
-        this.getDetail(row.code);
-      } else {
-        this.title = '创建订单';
-        this.getSaleCode();
-      }
+        typeList: [
+          { id: 1, label: '内销订单' },
+          { id: 2, label: '外销订单' },
+          { id: 3, label: '预制订单' }
+        ],
 
+        producedList: [
+          { code: 2, name: '加工(MBOM)' },
+          { code: 3, name: '装配(ABOM)' }
+        ],
 
+        completeList: [
+          { code: 1, name: '齐套' },
+          { code: 2, name: '缺料' }
+        ],
 
-    },
-    getDetail(code) {
-      getOrderDetail(code).then((res) => {
-        if (res.productInfoList) {
-          for (let item of res.productInfoList) {
-            if (item.productType) {
-              item.productType = parseInt(item.productType);
-            }
+        routingList: [],
+        factoryList: [],
 
+        title: '创建订单',
+        pickerOptions: {
+          disabledDate: (time) => {
+            // 禁用日期
+            let nowData = new Date();
+            nowData = new Date(nowData.setDate(nowData.getDate() - 1));
+            return time < nowData;
           }
-        }
-        this.disabledList = res.productInfoList;
-        this.form = res;
-      });
-    },
-    cancel() {
-      this.form = {
-        productInfoList: [],
-        deliveryRequirements: 1,
-        saleType: 1,
-        orderLibraryType: 2,
-        deliveryTime: dayjs(
-          new Date().getTime() + 3600 * 1000 * 24 * 10
-        ).format('YYYY-MM-DD')
+        },
+        // 订单类型
+        orderTypeList: [
+          {
+            id: 0,
+            label: '库存性订单'
+          },
+          {
+            id: 1,
+            label: '生产性订单'
+          },
+          {
+            id: 2,
+            label: '无客户生产性订单'
+          },
+          {
+            id: 4,
+            label: '不定向订单'
+          }
+        ],
+        selectIndex: 0, // 选择工艺路线的当前数据下标
+        processingRequired: 0 // 加工方式跟BOM 版本是否必填 1:是 0:否
       };
-      this.$refs.form.clearValidate();
-      this.visible = false;
     },
+    watch: {
+      disabledList() {
+        console.log(this.disabledList, 'disabledList');
+      }
+    },
+    computed: {
+      // 是否开启响应式布局
+      styleResponsive() {
+        return this.$store.state.theme.styleResponsive;
+      },
+      clientEnvironmentId() {
+        return this.$store.state.user.info.clientEnvironmentId;
+      },
+      // 是否必填字段
+      isRequired() {
+        // if (this.form.planType == 5) {
+        //   return false;
+        // }
+        return this.processingRequired == 1;
+      },
+      // 工艺路线 输入框展示跟选择框判断
+      isRouteSelect() {
+        return (row) => {
+          if (this.isRequired) {
+            return true;
+          }
+          if (!row.selectionRowShow) {
+            return true;
+          }
 
-    // 表格:模数、数量(方)、块数输入框 输入事件
-    tableHandleKeyUp(row, index, e, name) {
-      let modelArr = row.specification.split('*');
-      let modelLong = modelArr[0]; // model规格长度
-      let modeWide = modelArr[1]; // model规格宽度
-      let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
-      modeHight = Number(modeHight);
-      if (name === 'moCount') {
-        // 模数
-        row.moCount = e;
-        // 计算块数的公式:
-        // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
-        // 每一模的块数*模数moCount = 总块数
-        if (row.productName.includes('板材')) {
-          row.blockCount =
-            Math.floor(600 / modelLong) *
-            Math.floor(120 / modeHight) *
-            Math.floor(60 / modeWide) *
-            row.moCount;
-        } else if (row.productName.includes('砌块')) {
-          let modelLongFixed = (600 / modelLong).toFixed(2);
-          modelLongFixed = modelLongFixed.substring(
-            0,
-            modelLongFixed.length - 1
-          );
-          let modeWideFixed = (120 / modeWide).toFixed(2);
-          modeWideFixed = modeWideFixed.substring(0, modeWideFixed.length - 1);
-          let modeHightFixed = (60 / modeHight).toFixed(2);
-          modeHightFixed = modeHightFixed.substring(
-            0,
-            modeHightFixed.length - 1
-          );
-          row.blockCount =
-            Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
-            row.moCount;
-        }
-
-        row.contractNum =
-          ((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
-          row.blockCount;
-      } else if (name === 'sum') {
-        //方数
-        row.contractNum = e;
+          return false;
+        };
+      },
 
-        row.blockCount = Math.floor(
-          e / ((modelLong * modeWide * modeHight) / 1000000)
+      // 选择按钮的显示
+      isSelectShow() {
+        // if (this.form.planType == 5) {
+        //   return true;
+        // }
+        return this.processingRequired == 0;
+      }
+    },
+    created() {},
+    mounted() {
+      this.mandatoryField();
+      this.getFactoryList();
+    },
+    methods: {
+      // 是否必填
+      mandatoryField() {
+        parameterGetByCode({
+          code: 'production_plan_code'
+        }).then((res) => {
+          if (res) {
+            this.processingRequired = res.value;
+          }
+        });
+      },
+      // filterInput(value) {
+      //   let aaa = value.replace(/[^a-zA-Z0-9]/g, '');
+      //   console.log('cccaaaaaaaccc', aaa);
+      // },
+      changeRoutingList(row, index) {
+        const obj = row.routingList?.find(
+          (item) => item.id === row.produceRoutingId
         );
-        if (row.productName.includes('板材')) {
-          row.moCount = Math.ceil(
-            row.blockCount /
-            (Math.floor(600 / modelLong) *
-              Math.floor(120 / modeHight) *
-              Math.floor(60 / modeWide))
-          );
-        } else if (row.productName.includes('砌块')) {
-          row.moCount = Math.ceil(
-            row.blockCount /
-            Math.floor(
-              (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
-            )
-          );
+        if (obj) {
+          row.produceRoutingName = obj.name;
         }
-      } else if (name === 'blockCount') {
-        //块数
-        row.blockCount = e;
-
-        if (row.productName.includes('板材')) {
-          row.moCount = Math.ceil(
-            row.blockCount /
-            (Math.floor(600 / modelLong) *
-              Math.floor(120 / modeHight) *
-              Math.floor(60 / modeWide))
-          );
-        } else if (row.productName.includes('砌块')) {
-          row.moCount = Math.ceil(
-            row.blockCount /
-            Math.floor(
-              (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
-            )
-          );
+      },
+      async getFactoryList() {
+        this.factoryList = await getFactoryList();
+      },
+      open(row) {
+        this.visible = true;
+        if (row) {
+          this.title = '修改订单';
+          this.getDetail(row.code);
+        } else {
+          this.title = '创建订单';
+          this.getSaleCode();
         }
-        row.contractNum =
-          (Number(e) * modelLong * modeWide * modeHight) / 1000000;
+      },
+      getDetail(code) {
+        getOrderDetail(code).then((res) => {
+          if (res.productInfoList) {
+            for (let item of res.productInfoList) {
+              if (!item.bomCategoryId) {
+                item.productType = '';
+                item.selectionRowShow = true;
+              } else {
+                item.selectionRowShow = false;
+              }
+              if (item.productType) {
+                item.productType = parseInt(item.productType);
+              }
+            }
+          }
+          this.disabledList = res.productInfoList;
+          this.form = res;
+        });
+      },
+      cancel() {
+        this.form = {
+          productInfoList: [],
+          deliveryRequirements: 1,
+          saleType: 1,
+          orderLibraryType: 2,
+          deliveryTime: dayjs(
+            new Date().getTime() + 3600 * 1000 * 24 * 10
+          ).format('YYYY-MM-DD')
+        };
+        this.$refs.form.clearValidate();
+        this.visible = false;
+      },
 
-      }
-      row.contractNum = Number(row.contractNum.toFixed(5))
+      // 表格:模数、数量(方)、块数输入框 输入事件
+      tableHandleKeyUp(row, index, e, name) {
+        let modelArr = row.specification.split('*');
+        let modelLong = modelArr[0]; // model规格长度
+        let modeWide = modelArr[1]; // model规格宽度
+        let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
+        modeHight = Number(modeHight);
+        if (name === 'moCount') {
+          // 模数
+          row.moCount = e;
+          // 计算块数的公式:
+          // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
+          // 每一模的块数*模数moCount = 总块数
+          if (row.productName.includes('板材')) {
+            row.blockCount =
+              Math.floor(600 / modelLong) *
+              Math.floor(120 / modeHight) *
+              Math.floor(60 / modeWide) *
+              row.moCount;
+          } else if (row.productName.includes('砌块')) {
+            let modelLongFixed = (600 / modelLong).toFixed(2);
+            modelLongFixed = modelLongFixed.substring(
+              0,
+              modelLongFixed.length - 1
+            );
+            let modeWideFixed = (120 / modeWide).toFixed(2);
+            modeWideFixed = modeWideFixed.substring(
+              0,
+              modeWideFixed.length - 1
+            );
+            let modeHightFixed = (60 / modeHight).toFixed(2);
+            modeHightFixed = modeHightFixed.substring(
+              0,
+              modeHightFixed.length - 1
+            );
+            row.blockCount =
+              Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
+              row.moCount;
+          }
 
-    },
+          row.contractNum =
+            ((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
+            row.blockCount;
+        } else if (name === 'sum') {
+          //方数
+          row.contractNum = e;
 
-    // 删除产品
-    handleDeleteItem(index) {
-      this.form.productInfoList.splice(index, 1);
-      this.changeLineNumber();
-    },
-    addEquipment() {
-      this.$refs.equipmentRefs.open();
-    },
-    /* 保存编辑 */
-    save() {
-      this.$refs.form.validate((valid) => {
-        if (!valid) {
-          return false;
-        }
-        if (!this.form.productInfoList.length) {
-          return this.$message.warning('产品列表不能为空!');
+          row.blockCount = Math.floor(
+            e / ((modelLong * modeWide * modeHight) / 1000000)
+          );
+          if (row.productName.includes('板材')) {
+            row.moCount = Math.ceil(
+              row.blockCount /
+                (Math.floor(600 / modelLong) *
+                  Math.floor(120 / modeHight) *
+                  Math.floor(60 / modeWide))
+            );
+          } else if (row.productName.includes('砌块')) {
+            row.moCount = Math.ceil(
+              row.blockCount /
+                Math.floor(
+                  (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
+                )
+            );
+          }
+        } else if (name === 'blockCount') {
+          //块数
+          row.blockCount = e;
+
+          if (row.productName.includes('板材')) {
+            row.moCount = Math.ceil(
+              row.blockCount /
+                (Math.floor(600 / modelLong) *
+                  Math.floor(120 / modeHight) *
+                  Math.floor(60 / modeWide))
+            );
+          } else if (row.productName.includes('砌块')) {
+            row.moCount = Math.ceil(
+              row.blockCount /
+                Math.floor(
+                  (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
+                )
+            );
+          }
+          row.contractNum =
+            (Number(e) * modelLong * modeWide * modeHight) / 1000000;
         }
-        this.loading = true;
-        console.log(this.form);
-        createOrUpdate(this.form)
-          .then((res) => {
-            this.loading = false;
-            this.$message.success('成功');
-            this.cancel();
-            this.$emit('refresh');
-          })
-          .catch((e) => {
-            this.loading = false;
-          });
-      });
-    },
+        row.contractNum = Number(row.contractNum.toFixed(5));
+      },
 
-    // 选择订单类型
-    chooseType(val) {
-      if (val == 2) {
-        this.$set(this.form, 'orderLibraryType', 1);
-      } else {
-        this.$set(this.form, 'orderLibraryType', 2);
-      }
-      this.$set(this.form, 'customerName', '');
-    },
+      // 删除产品
+      handleDeleteItem(index) {
+        this.form.productInfoList.splice(index, 1);
+        this.changeLineNumber();
+      },
+      addEquipment() {
+        this.$refs.equipmentRefs.open();
+      },
+      /* 保存编辑 */
+      save() {
+        this.$refs.form.validate((valid) => {
+          if (!valid) {
+            return false;
+          }
 
-    async getSaleCode() {
-      const res = await getCode('order_sale_code');
-      if (res) {
-        this.$set(this.form, 'code', res);
-      }
-    },
-    // 确定选择
-    confirmChoose(list) {
-      list = list
-        .filter(
-          (i) =>
-            !this.disabledList.find(
-              (p) => p.productCode == i.code || p.productCode == i.productCode
-            )
-        )
-        .map((item, index) => {
-          if (item.productCode) {
-            return item;
-          } else {
-            return {
-              categoryId: item.id,
-              productCode: item.code,
-              productName: item.name,
-              productUnitWeight: item.netWeight,
-              weightUnit: item.weightUnit,
-              model: item.modelType,
-              specification: item.specification,
-              brandNo: item.brandNum,
-              measuringUnit: item.measuringUnit
-            };
+          if (!this.form.productInfoList.length) {
+            return this.$message.warning('产品列表不能为空!');
           }
-        })
-        .concat(this.disabledList);
-      console.log('list', list);
-      // 取出在弹窗中选中并且不在表格中的数据
-      const result = list.filter(
-        (i) =>
-          this.form.productInfoList.findIndex(
-            (p) => p.productCode === i.productCode
-          ) === -1
-      );
-      console.log('result', result);
-      // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
-      const del = this.form.productInfoList.filter(
-        (i) => list.findIndex((p) => p.productCode === i.productCode) === -1
-      );
-      console.log('del', del);
-      for (let i = this.form.productInfoList.length - 1; i >= 0; i--) {
-        for (let j in del) {
-          console.log(
-            this.form.productInfoList[i].productCode,
-            del[j].productCode
-          );
-          if (this.form.productInfoList[i].productCode === del[j].productCode) {
-            this.form.productInfoList.splice(i, 1);
+          let flag = this.parameterVerification();
+          // 必填参数校验
+          if (!flag) return;
+          this.loading = true;
+          createOrUpdate(this.form)
+            .then((res) => {
+              this.loading = false;
+              this.$message.success('成功');
+              this.cancel();
+              this.$emit('refresh');
+            })
+            .catch((e) => {
+              this.loading = false;
+            });
+        });
+      },
+      // 参数校验
+      parameterVerification() {
+        let flag = true;
+        for (let i = 0; i < this.form.productInfoList.length; i++) {
+          let v = this.form.productInfoList[i];
+          if (this.isRequired) {
+            if (!v.productType) {
+              flag = false;
+              this.$message.warning('请选择加工方式');
+              break;
+            }
+
+            if (!v.productType) {
+              flag = false;
+              this.$message.warning('请选择BOM版本');
+              break;
+            }
+          }
+
+          if (!v.produceRoutingId) {
+            flag = false;
+            this.$message.warning('请选择工艺路线');
             break;
           }
         }
-      }
-
-      this.form.productInfoList = this.form.productInfoList.concat(result);
-      this.changeLineNumber();
-    },
+        // this.form.productInfoList.forEach((v) => {
+        //   if (this.isRequired) {
+        //     if (!v.productType) {
+        //       flag = false;
+        //       this.$message.warning('请选择加工方式');
+        //       return;
+        //     }
+
+        //     if (!v.productType) {
+        //       flag = false;
+        //       this.$message.warning('请选择BOM版本');
+        //       return;
+        //     }
+        //   }
+
+        //   if (!v.produceRoutingId) {
+        //     flag = false;
+        //     this.$message.warning('请选择工艺路线');
+        //     return;
+        //   }
+        // });
+        return flag;
+      },
+      // 选择订单类型
+      chooseType(val) {
+        if (val == 2) {
+          this.$set(this.form, 'orderLibraryType', 1);
+        } else {
+          this.$set(this.form, 'orderLibraryType', 2);
+        }
+        this.$set(this.form, 'customerName', '');
+      },
 
-    changeLineNumber() {
-      this.form.productInfoList.map((item, index) => {
-        item.lineNumber = 10 * (index + 1);
-      });
-    },
+      async getSaleCode() {
+        const res = await getCode('order_sale_code');
+        if (res) {
+          this.$set(this.form, 'code', res);
+        }
+      },
+      // 确定选择
+      confirmChoose(list) {
+        list.map((el) => (el.selectionRowShow = false));
+        list = list
+          .filter(
+            (i) =>
+              !this.disabledList.find(
+                (p) => p.productCode == i.code || p.productCode == i.productCode
+              )
+          )
+          .map((item, index) => {
+            if (item.productCode) {
+              return item;
+            } else {
+              return {
+                categoryId: item.id,
+                productCode: item.code,
+                productName: item.name,
+                productUnitWeight: item.netWeight,
+                weightUnit: item.weightUnit,
+                model: item.modelType,
+                specification: item.specification,
+                brandNo: item.brandNum,
+                measuringUnit: item.measuringUnit
+              };
+            }
+          })
+          .concat(this.disabledList);
+        // 取出在弹窗中选中并且不在表格中的数据
+        const result = list.filter(
+          (i) =>
+            this.form.productInfoList.findIndex(
+              (p) => p.productCode === i.productCode
+            ) === -1
+        );
+        // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
+        const del = this.form.productInfoList.filter(
+          (i) => list.findIndex((p) => p.productCode === i.productCode) === -1
+        );
+        for (let i = this.form.productInfoList.length - 1; i >= 0; i--) {
+          for (let j in del) {
+            if (
+              this.form.productInfoList[i].productCode === del[j].productCode
+            ) {
+              this.form.productInfoList.splice(i, 1);
+              break;
+            }
+          }
+        }
 
-    inputNumber(row, index) {
-      const pos = this.form.productInfoList;
-      if (pos[index].productUnitWeight) {
-        const number = multiply(row.contractNum, row.productUnitWeight);
+        this.form.productInfoList = this.form.productInfoList.concat(result);
+        this.changeLineNumber();
+      },
 
-        this.$set(pos[index], 'productWeight', number);
-      }
-      if (this.clientEnvironmentId == 4) {
-        this.tableHandleKeyUp(row, '', row.contractNum, 'sum');
+      changeLineNumber() {
+        this.form.productInfoList.map((item, index) => {
+          item.lineNumber = 10 * (index + 1);
+        });
+      },
 
-      }
+      inputNumber(row, index) {
+        const pos = this.form.productInfoList;
+        if (pos[index].productUnitWeight) {
+          const number = multiply(row.contractNum, row.productUnitWeight);
 
-    },
+          this.$set(pos[index], 'productWeight', number);
+        }
+        if (this.clientEnvironmentId == 4) {
+          this.tableHandleKeyUp(row, '', row.contractNum, 'sum');
+        }
+      },
 
+      // 清空BOM 跟工艺路线
+      wipeData(index) {
+        let row = this.form.productInfoList[index];
+        row.bomCategoryId = '';
+        row.routingList = [];
+        row.bomVersionList = [];
+        row.produceRoutingId = '';
+        row.produceRoutingName = '';
+        // row.produceVersionName = '';
+        row.selectionRowShow = false;
+        // this.selectionRowShow = false;
+      },
 
-    changeProductType(row, index) {
-      let param = {
-        bomType: row.productType,
-        categoryId: row.categoryId
-      }
-      bomListByPlan(param).then(res => {
-        let arr = res || [];
-        if (arr.length == 0) {
-          row.bomCategoryId = '';
-        }
-        console.log(arr);
-        this.$set(this.form.productInfoList[index], 'bomVersionList', arr);
-        this.$forceUpdate()
-      })
+      // 选择加工方式
+      changeProductType(row, index) {
+        let param = {
+          bomType: row.productType,
+          categoryId: row.categoryId
+        };
+        this.wipeData(index);
+        bomListByPlan(param).then((res) => {
+          let arr = res || [];
+          let data = this.form.productInfoList[index];
+          if (arr.length) {
+            this.form.productInfoList[index].bomVersionList = arr;
+            row.bomCategoryId = arr[0].id;
+            this.changeBomId(row, index);
+            let arrAll = JSON.parse(JSON.stringify(this.form));
+            this.$set(this, 'form', arrAll);
+          }
+          this.$forceUpdate();
 
-    },
+          // let arr = res || [];
+          // if (arr.length == 0) {
+          //   row.bomCategoryId = '';
+          // }
 
-    changeBomId(row, index) {
-      bomRoutingList(row.bomCategoryId).then((res) => {
-        let arr = res || [];
-        if (arr.length == 0) {
-          row.produceRoutingId = '';
-        }
-        this.$set(this.form.productInfoList[index], 'routingList', arr);
-        this.$forceUpdate()
-      })
-    },
+          // this.$set(this.form.productInfoList[index], 'bomVersionList', arr);
+          // this.$forceUpdate();
 
-    homogeneityInspect(row) {
-      if (!row.productType) {
-        this.$message.warning('请选择加工方式');
-        return;
-      }
-      if (!row.bomCategoryId) {
-        this.$message.warning('请选择BOM版本');
-        return;
-      }
-      if (row.productType == 2) {
-        let data = [];
-        data.push(row);
-        this.$refs.orderHomogeneityInspectDialog.open(data, this.form);
-      } else if (row.productType == 3) {
-        this.$refs.orderHomogeneityInspectInstallDialog.open([row.id]);
-      } else {
-        this.$message.warning('请确认加工方式!');
-      }
+          // console.log(this.form,'this.formthis.form')
+        });
+      },
 
+      // 选择BOM
+      changeBomId(row, index) {
+        bomRoutingList(row.bomCategoryId).then((res) => {
+          let arr = res || [];
+          // if (arr.length == 0) {
+          //   row.produceRoutingId = '';
+          // }
+          if (arr.length > 0) {
+            this.$set(this.form.productInfoList[index], 'routingList', arr);
+            row.produceRoutingName = arr[0].name;
+            this.$set(
+              this.form.productInfoList[index],
+              'produceRoutingId',
+              arr[0].id
+            );
+          }
+          this.$forceUpdate();
+        });
+      },
 
+      homogeneityInspect(row) {
+        if (!row.productType) {
+          this.$message.warning('请选择加工方式');
+          return;
+        }
+        if (!row.bomCategoryId) {
+          this.$message.warning('请选择BOM版本');
+          return;
+        }
+        if (row.productType == 2) {
+          let data = [];
+          data.push(row);
+          this.$refs.orderHomogeneityInspectDialog.open(data, this.form);
+        } else if (row.productType == 3) {
+          this.$refs.orderHomogeneityInspectInstallDialog.open([row.id]);
+        } else {
+          this.$message.warning('请确认加工方式!');
+        }
+      },
 
+      // 打开工艺路线
+      openDialog(index) {
+        this.selectIndex = index;
+        this.$refs.processRouteRef.open();
+      },
 
-    },
+      // 选择工艺路线
+      changeParent(item) {
+        let data = this.form.productInfoList[this.selectIndex];
+        this.$set(data, 'bomVersionList', []);
+        this.$set(data, 'bomCategoryId', '');
+        this.$set(data, 'model', '');
+        this.$set(data, 'routingList', []);
+        this.$set(data, 'productType', '');
+        this.$set(data, 'produceRoutingName', item.name);
+        this.$set(data, 'produceRoutingId', item.id);
+        this.$set(data, 'selectionRowShow', true);
+        // this.selectionRowShow = true;
+      }
+    }
+  };
+</script>
+<style lang="scss" scoped>
+  .basic-details-title {
+    margin: 10px 0;
+  }
 
+  .add-product {
+    width: 100%;
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    font-size: 30px;
+    color: #1890ff;
+    margin: 10px 0;
+    cursor: pointer;
+  }
 
+  .create-form .el-form-item {
+    margin-bottom: 15px !important;
+  }
 
+  .header_required {
+    .is-required:before {
+      content: '*';
+      color: #f56c6c;
+      margin-right: 4px;
+    }
   }
-};
-</script>
-<style lang="scss" scoped>
-.basic-details-title {
-  margin: 10px 0;
-}
-
-.add-product {
-  width: 100%;
-  display: flex;
-  align-items: center;
-  justify-content: flex-end;
-  font-size: 30px;
-  color: #1890ff;
-  margin: 10px 0;
-  cursor: pointer;
-}
-
-.create-form .el-form-item {
-  margin-bottom: 15px !important;
-}
 </style>

+ 662 - 674
src/views/saleOrder/salesToProduction.vue

@@ -1,744 +1,732 @@
 <template>
   <div class="ele-body">
-    <salesToProductionNewTwo @cancel="cancel" :objData="objData"  v-if="isNewShow"></salesToProductionNewTwo>
-    <salesToProductionNew @cancel="cancel" :formData="form" v-else></salesToProductionNew>
-
+    <salesToProductionNewTwo
+      @cancel="cancel"
+      :objData="objData"
+      v-if="isNewShow && startRequest"
+    ></salesToProductionNewTwo>
+    <salesToProductionNew
+      @cancel="cancel"
+      :formData="form"
+      v-if="!isNewShow && startRequest"
+    ></salesToProductionNew>
   </div>
 </template>
 <script>
-import AdditionalOrder from './components/AdditionalOrder.vue';
-import PlanSubmit from './components/plan-submit.vue';
-import ProductionVersion from '@/components/CreatePlan/ProductionVersion2.vue';
-import salesToProductionNewTwo from './salesToProductionNewTwo.vue';
-import salesToProductionNew from './salesToProductionNew.vue';
-import {
-  productionToPlan,
-  saveSaleToPlan,
-  updateSaleToPlan,
-  releaseSave,
-  getInventory,
-  getUpdateInfoById,
-  bomRoutingList,
-  bomListByPlan,
-  getFactoryList,
-} from '@/api/saleOrder';
-
-import { getByCode } from '@/api/system/dictionary-data';
-
-import dictMixins from '@/mixins/dictMixins';
-import { deepClone } from '@/utils/index';
-import { getRouteTabKey, removePageTab } from '@/utils/page-tab-util';
-import { getCode } from '@/api/codeManagement';
-import dayjs from 'dayjs';
-import { debounce } from 'lodash';
-export default {
-  mixins: [dictMixins],
-  components: {
-    salesToProductionNewTwo,
-    AdditionalOrder,
-    ProductionVersion,
-    salesToProductionNew,
-    PlanSubmit
-  },
-  data() {
-    return {
-      type: this.$route.query.type,
-      id : this.$route.query.id,
-      objData:{},
-      weightList: [
-        { code: 1, name: 'A' },
-        { code: 2, name: 'B' },
-        { code: 3, name: 'C' }
-      ],
-      isSlotting: [
-        { code: 1, name: '是' },
-        { code: 2, name: '否' }
-      ], //是否开槽
-
-
-      producedList: [
-        { code: 2, name: '加工(MBOM)' }, //2 待确认
-        { code: 3, name: '装配(ABOM)' }
-      ],
-      isNewShow:true,
-      form: {
-        planType: 1,
-        produceRoutingId: '',
-        stockCountBase: '',
-        salesOrders: [],
-        produceRoutingName: '',
-        marginCoefficient: '1.0',
-        batchNo: null,
-        produceType: 2,
-        bomCategoryId: '',
-        factoriesId: '',
-      },
-
-      marginList: [],
-
-      bomVersionList: [],
-      routingList: [],
-      factoryList: [],
-
-      // 表单验证规则
-      rules: {
-
-        produceRoutingId: [
-          { required: true, message: '请选择工艺路线', trigger: 'blur' }
-        ],
-
-        produceType: [
-          { required: true, message: '请选择加工方式', trigger: 'blur' }
-        ],
-        bomCategoryId: [
-          { required: true, message: '请选择BOM版本', trigger: 'blur' }
+  import AdditionalOrder from './components/AdditionalOrder.vue';
+  import PlanSubmit from './components/plan-submit.vue';
+  import ProductionVersion from '@/components/CreatePlan/ProductionVersion2.vue';
+  import salesToProductionNewTwo from './salesToProductionNewTwo.vue';
+  import salesToProductionNew from './salesToProductionNew.vue';
+  import {
+    productionToPlan,
+    saveSaleToPlan,
+    updateSaleToPlan,
+    releaseSave,
+    getInventory,
+    getUpdateInfoById,
+    bomRoutingList,
+    bomListByPlan,
+    getFactoryList
+  } from '@/api/saleOrder';
+
+  import { getByCode } from '@/api/system/dictionary-data';
+
+  import dictMixins from '@/mixins/dictMixins';
+  import { deepClone } from '@/utils/index';
+  import { getRouteTabKey, removePageTab } from '@/utils/page-tab-util';
+  import { getCode } from '@/api/codeManagement';
+  import dayjs from 'dayjs';
+  import { debounce } from 'lodash';
+  export default {
+    mixins: [dictMixins],
+    components: {
+      salesToProductionNewTwo,
+      AdditionalOrder,
+      ProductionVersion,
+      salesToProductionNew,
+      PlanSubmit
+    },
+    data() {
+      return {
+        type: this.$route.query.type,
+        id: this.$route.query.id,
+        objData: {},
+        weightList: [
+          { code: 1, name: 'A' },
+          { code: 2, name: 'B' },
+          { code: 3, name: 'C' }
         ],
-        factoriesId: [
-          { required: true, message: '请选择所属工厂', trigger: 'change' }
+        isSlotting: [
+          { code: 1, name: '是' },
+          { code: 2, name: '否' }
+        ], //是否开槽
+
+        producedList: [
+          { code: 2, name: '加工(MBOM)' }, //2 待确认
+          { code: 3, name: '装配(ABOM)' }
         ],
-      },
-      // selection: [],
-      loading: false
-    };
-  },
-  computed: {
-    clientEnvironmentId() {
-      return this.$store.state.user.info.clientEnvironmentId;
-    },
-    // 是否开启响应式布局
-    styleResponsive() {
-      return this.$store.state.theme.styleResponsive;
-    }
-  },
-  created() {
-
-    this.requestDict('按单按库');
-    this.requestDict('订单类型');
-    this.requestDict('交付要求');
-
-    this.getByCodeFn();
-    this.getFactoryList();
-
-    this.objData = {
-      id:this.id,
-      type:this.type
-    } 
-
-    if (this.type == 'edit') {
-
-      this.getPlanInfo(this.$route.query.id);
-
-    } else {
-      this.getSaleInfo();
-
-    }
-
-
-  },
-
-  methods: {
-
-    // 验证时间是否超期
-    changeDate(item, i) {
-      console.log(this.isTimeAGreaterThanB(item.deliveryTime, item.reqMoldTime));
-      if (this.isTimeAGreaterThanB(item.deliveryTime, item.reqMoldTime)) {
-        this.$message.error('交付时间大于了要求完成日期')
-      }
-
-    },
-    isTimeAGreaterThanB(timeA, timeB) {
-      return new Date(timeA) > new Date(timeB);
+        isNewShow: true,
+        form: {
+          planType: 1,
+          produceRoutingId: '',
+          stockCountBase: '',
+          salesOrders: [],
+          produceRoutingName: '',
+          marginCoefficient: '1.0',
+          batchNo: null,
+          produceType: 2,
+          bomCategoryId: '',
+          factoriesId: ''
+        },
+
+        marginList: [],
+        startRequest: false,
+        bomVersionList: [],
+        routingList: [],
+        factoryList: [],
+
+        // 表单验证规则
+        rules: {
+          produceRoutingId: [
+            { required: true, message: '请选择工艺路线', trigger: 'blur' }
+          ],
+
+          produceType: [
+            { required: true, message: '请选择加工方式', trigger: 'blur' }
+          ],
+          bomCategoryId: [
+            { required: true, message: '请选择BOM版本', trigger: 'blur' }
+          ],
+          factoriesId: [
+            { required: true, message: '请选择所属工厂', trigger: 'change' }
+          ]
+        },
+        // selection: [],
+        loading: false
+      };
     },
-
-
-    async getFactoryList() {
-      this.factoryList = await getFactoryList();
-    },
-    async getPlanInfo(id) {
-      const data = await getUpdateInfoById(id);
-      this.form = data;
-
-
-      if(this.form.salesOrders.length){
-        console.log(1);
-      //   this.isNewShow = true;
-      }else{
-        console.log(2);
-        this.isNewShow = false;
-      }
-
-
-      if (this.clientEnvironmentId != 4) {
-        this.bomListVersion()
-        this.getPlanRouting()
-      }
-
-
-
-    },
-    async _getInventory() {
-      const res = await getInventory(this.form.productCode, this.form.planType);
-
-      this.form.stockCountBase = res;
-    },
-
-    getByCodeFn() {
-      getByCode('margin_code').then((res) => {
-        let _arr = [];
-        res.data.map((item) => {
-          const key = Object.keys(item)[0];
-          const value = item[key];
-
-          _arr.push({ name: key, value: value });
-        });
-        this.marginList = _arr;
-      });
-    },
-
-
-    getPlanRouting() {
-
-      if (this.form.bomCategoryId) {
-        bomRoutingList(this.form.bomCategoryId).then((res) => {
-          this.routingList = res || []
-        })
+    computed: {
+      clientEnvironmentId() {
+        return this.$store.state.user.info.clientEnvironmentId;
+      },
+      // 是否开启响应式布局
+      styleResponsive() {
+        return this.$store.state.theme.styleResponsive;
       }
-
     },
+    created() {
+      this.requestDict('按单按库');
+      this.requestDict('订单类型');
+      this.requestDict('交付要求');
 
-    bomListVersion() {
-      let categoryId = '';
-      if (this.form.salesOrders.length) {
-        categoryId = this.form.salesOrders[0].categoryId;
-      }else if (this.form.categoryId) {
-        categoryId = this.form.categoryId
-      }else{
-        new Error('缺少产品信息')
-      }
+      this.getByCodeFn();
+      this.getFactoryList();
 
-    
+      this.objData = {
+        id: this.id,
+        type: this.type
+      };
 
-      let param = {
-        bomType: this.form.produceType,
-        categoryId: categoryId
+      if (this.type == 'edit') {
+        this.getPlanInfo(this.$route.query.id);
+      } else {
+        this.getSaleInfo();
       }
-      bomListByPlan(param).then(res => {
-        this.bomVersionList = res || []
-      })
     },
 
+    methods: {
+      // 验证时间是否超期
+      changeDate(item, i) {
+        if (this.isTimeAGreaterThanB(item.deliveryTime, item.reqMoldTime)) {
+          this.$message.error('交付时间大于了要求完成日期');
+        }
+      },
+      isTimeAGreaterThanB(timeA, timeB) {
+        return new Date(timeA) > new Date(timeB);
+      },
 
-    changeProduceType() {
-      if (this.clientEnvironmentId == 4) {
-        return false
-      }
-      this.form.bomCategoryId = '';
-      this.form['bomCategoryName'] = '';
-      this.form['bomCategoryVersions'] = '';
-
+      async getFactoryList() {
+        this.factoryList = await getFactoryList();
+      },
+      async getPlanInfo(id) {
+        try {
+          this.startRequest = false;
+          const data = await getUpdateInfoById(id);
+          this.startRequest = true;
+          this.form = data;
+          if (!data.bomCategoryId || data.bomCategoryId == null) {
+            this.form.produceType = '';
+            // this.selectionRowShow = true;
+          } else {
+            // this.selectionRowShow = false;
+          }
+          if (this.form.salesOrders.length) {
+            // console.log(1);
+            this.isNewShow = true;
+          } else {
+            this.isNewShow = false;
+          }
 
-      this.bomVersionList = [];
+          if (this.clientEnvironmentId != 4) {
+            // this.bomListVersion()
+            // this.getPlanRouting()
+          }
+        } catch (err) {
+          this.startRequest = true;
+        }
+      },
+      async _getInventory() {
+        const res = await getInventory(
+          this.form.productCode,
+          this.form.planType
+        );
 
-      this.routingList = [];
-      this.form.produceRoutingId = '';
-      this.form.produceRoutingName = '';
-      this.form.produceVersionName = '';
+        this.form.stockCountBase = res;
+      },
 
-      this.bomListVersion()
+      getByCodeFn() {
+        getByCode('margin_code').then((res) => {
+          let _arr = [];
+          res.data.map((item) => {
+            const key = Object.keys(item)[0];
+            const value = item[key];
 
-    },
+            _arr.push({ name: key, value: value });
+          });
+          this.marginList = _arr;
+        });
+      },
 
-    changeBomId() {
-      this.routingList = []
-      this.form.produceRoutingId = ''
-      this.form.produceRoutingName = ''
-      this.form.produceVersionName = ''
+      getPlanRouting() {
+        if (this.form.bomCategoryId) {
+          bomRoutingList(this.form.bomCategoryId).then((res) => {
+            this.routingList = res || [];
+          });
+        }
+      },
 
-      this.bomVersionList.forEach((f) => {
-        if (f.id == this.form.bomCategoryId) {
-          this.$set(this.form, 'bomCategoryName', f.name);
-          this.$set(this.form, 'bomCategoryVersions', f.versions);
+      bomListVersion() {
+        let categoryId = '';
+        if (this.form.salesOrders.length) {
+          categoryId = this.form.salesOrders[0].categoryId;
+        } else if (this.form.categoryId) {
+          categoryId = this.form.categoryId;
+        } else {
+          new Error('缺少产品信息');
         }
+        let param = {
+          bomType: this.form.produceType || null,
+          categoryId: categoryId
+        };
+        bomListByPlan(param).then((res) => {
+          this.bomVersionList = res || [];
+        });
+      },
 
-      })
+      changeProduceType() {
+        if (this.clientEnvironmentId == 4) {
+          return false;
+        }
+        this.form.bomCategoryId = '';
+        this.form['bomCategoryName'] = '';
+        this.form['bomCategoryVersions'] = '';
 
-      this.getPlanRouting()
-    },
+        this.bomVersionList = [];
 
+        this.routingList = [];
+        this.form.produceRoutingId = '';
+        this.form.produceRoutingName = '';
+        this.form.produceVersionName = '';
 
+        this.bomListVersion();
+      },
 
-    changeRoute() {
+      changeBomId() {
+        this.routingList = [];
+        this.form.produceRoutingId = '';
+        this.form.produceRoutingName = '';
+        this.form.produceVersionName = '';
 
-      console.log(this.routingList);
-      console.log(this.form.produceRoutingId);
-      this.$forceUpdate();
-      this.routingList.forEach((f) => {
-        if (f.id == this.form.produceRoutingId) {
-          this.$set(this.form, 'produceRoutingName', f.name);
-          this.$set(this.form, 'produceVersionName', f.version);
-        }
+        this.bomVersionList.forEach((f) => {
+          if (f.id == this.form.bomCategoryId) {
+            this.$set(this.form, 'bomCategoryName', f.name);
+            this.$set(this.form, 'bomCategoryVersions', f.versions);
+          }
+        });
 
-      })
-    },
+        this.getPlanRouting();
+      },
 
-    getSaleInfo() {
-      let params = JSON.parse(this.$route.query.selection);
-      productionToPlan(params).then((res) => {
-        console.log(res, '555555555555555555');
-        this.form = deepClone(res);
-        if (!this.form.produceType) {
-          this.form.produceType = 2;
-          this.bomListVersion()
-        }
-        this.form.produceRoutingName =
-          res.produceRoutingName || this.$route.query.produceRoutingName;
-        this.form.produceRoutingId =
-          res.produceRoutingId || this.$route.query.produceRoutingId;
-        this.form.factoriesId =
-          res.factoriesId || this.$route.query.factoriesId;
-        console.log(this.form.factoriesId, '99999999999999')
-        if (this.clientEnvironmentId == '4') {
-          if (this.form.salesOrders[0].productName.includes('板材')) {
-            this.changeProduct({
-              id: '1856970794952372226',
-              name: '板材',
-              produceVersionName: '板材'
-            });
-          } else {
-            this.changeProduct({
-              id: '1857313733642596353',
-              name: '砌块',
-              produceVersionName: '砌块'
-            });
+      changeRoute() {
+        this.$forceUpdate();
+        this.routingList.forEach((f) => {
+          if (f.id == this.form.produceRoutingId) {
+            this.$set(this.form, 'produceRoutingName', f.name);
+            this.$set(this.form, 'produceVersionName', f.version);
           }
-        }
-        this.form.salesOrders.map((item, index) => {
-
+        });
+      },
 
+      getSaleInfo() {
+        let params = JSON.parse(this.$route.query.selection);
+        productionToPlan(params).then((res) => {
+          this.form = deepClone(res);
+          if (!this.form.produceType) {
+            this.form.produceType = 2;
+            this.bomListVersion();
+          }
+          this.form.produceRoutingName =
+            res.produceRoutingName || this.$route.query.produceRoutingName;
+          this.form.produceRoutingId =
+            res.produceRoutingId || this.$route.query.produceRoutingId;
+          this.form.factoriesId =
+            res.factoriesId || this.$route.query.factoriesId;
           if (this.clientEnvironmentId == '4') {
-            this.tableHandleKeyUp(item, '', item.lackNum, 'sum');
+            if (this.form.salesOrders[0].productName.includes('板材')) {
+              this.changeProduct({
+                id: '1856970794952372226',
+                name: '板材',
+                produceVersionName: '板材'
+              });
+            } else {
+              this.changeProduct({
+                id: '1857313733642596353',
+                name: '砌块',
+                produceVersionName: '砌块'
+              });
+            }
+          }
+          this.form.salesOrders.map((item, index) => {
+            if (this.clientEnvironmentId == '4') {
+              this.tableHandleKeyUp(item, '', item.lackNum, 'sum');
+            } else {
+              item.planProductNum = item.lackNum;
+              item.requiredFormingNum = item.lackNum;
+            }
+            item.slottingType = item.slottingType && item.slottingType + '';
+            item.priority = index + 1;
+
+            item.reqMoldTime = dayjs(
+              new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
+            ).format('YYYY-MM-DD');
+          });
+          if (this.form.salesOrders.every((itm) => itm.orderType == 2)) {
+            this.form.planType = 2;
+          } else if (this.form.salesOrders.every((itm) => itm.orderType == 1)) {
+            this.form.planType = 1;
           } else {
-            item.planProductNum = item.lackNum;
-            item.requiredFormingNum = item.lackNum;
+            this.form.planType = 3;
           }
-          item.slottingType = item.slottingType && item.slottingType + '';
-          item.priority = index + 1;
-
-          item.reqMoldTime = dayjs(
-            new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
-          ).format('YYYY-MM-DD');
+          this._getInventory();
         });
-        if (this.form.salesOrders.every((itm) => itm.orderType == 2)) {
-          this.form.planType = 2;
-        } else if (this.form.salesOrders.every((itm) => itm.orderType == 1)) {
-          this.form.planType = 1;
-        } else {
-          this.form.planType = 3;
-        }
-        this._getInventory();
-      });
-      this.$forceUpdate();
-    },
-
-    itemChange() {
-      this.form.salesOrders.map((item, index) => {
-        this.$set(
-          item,
-          'requiredFormingNum',
-          item.planProductNum * (this.form.marginCoefficient || 1)
-        );
-      });
-    },
-
-    factoriesIdFn(e) {
-
+        this.$forceUpdate();
+      },
 
+      itemChange() {
+        this.form.salesOrders.map((item, index) => {
+          this.$set(
+            item,
+            'requiredFormingNum',
+            item.planProductNum * (this.form.marginCoefficient || 1)
+          );
+        });
+      },
 
-      this.$forceUpdate()
-    },
+      factoriesIdFn(e) {
+        this.$forceUpdate();
+      },
 
-    toInt(planProductNum) {
-      return planProductNum * (this.form.marginCoefficient || 1);
-    },
+      toInt(planProductNum) {
+        return planProductNum * (this.form.marginCoefficient || 1);
+      },
 
-    cancel() {
+      cancel() {
+        const key = getRouteTabKey();
+        this.$router.go(-1);
+        removePageTab({ key });
+      },
+      toSubmit() {
+        if (!this.form.factoriesId)
+          return this.$message.warning('请选择所属工厂');
 
-      console.log(11111);
-      const key = getRouteTabKey();
-      this.$router.go(-1);
-      removePageTab({ key });
-    },
-    toSubmit() {
-      if (!this.form.factoriesId) return this.$message.warning('请选择所属工厂');
+        this.$refs.form.validate((valid) => {
+          if (valid) {
+            this.mapList();
 
-      this.$refs.form.validate((valid) => {
+            this.$refs.submitRefs.open();
+          }
+        });
+      },
+      // 对比日期,计算要求生产重量
+      mapList() {
+        var _sumOrderWeight = 0;
+        var requiredFormingNum = 0;
+        var productNum = 0;
+        this.form.salesOrders.map((item, index) => {
+          requiredFormingNum =
+            Number(requiredFormingNum) + Number(item.requiredFormingNum);
+
+          if (
+            this.form.weightUnit == 'G' ||
+            this.form.weightUnit == 'g' ||
+            this.form.weightUnit == '克'
+          ) {
+            this.form.newWeightUnit = 'kg';
+            _sumOrderWeight =
+              (this.form.salesOrders[0].requiredFormingNum *
+                Number(this.form.salesOrders[0].productUnitWeight || 1)) /
+              1000;
+          } else {
+            this.form.newWeightUnit = this.form.weightUnit;
+            _sumOrderWeight =
+              this.form.salesOrders[0].requiredFormingNum *
+              Number(this.form.salesOrders[0].productUnitWeight || 1);
+          }
 
-        if (valid) {
-          this.mapList();
+          productNum += Number(item.planProductNum);
+        });
+        this.form.productNum = productNum;
+        this.form.productUnitWeight =
+          this.form.salesOrders[0]?.productUnitWeight;
+        this.form.newSumOrderWeight = _sumOrderWeight.toFixed(2);
+        this.form.requiredFormingNum = requiredFormingNum;
+        const collection = deepClone(this.form.salesOrders);
+        const sortedCollection = collection.sort(
+          (a, b) => new Date(b.reqMoldTime) - new Date(a.reqMoldTime)
+        );
 
-          this.$refs.submitRefs.open();
-        }
-      });
-    },
-    // 对比日期,计算要求生产重量
-    mapList() {
-      var _sumOrderWeight = 0;
-      var requiredFormingNum = 0;
-      var productNum = 0;
-      this.form.salesOrders.map((item, index) => {
-        requiredFormingNum = Number(requiredFormingNum) + Number(item.requiredFormingNum);
-
-        if (this.form.weightUnit == 'G' || this.form.weightUnit == 'g' || this.form.weightUnit == '克') {
-          this.form.newWeightUnit = 'kg';
-          _sumOrderWeight = (this.form.salesOrders[0].requiredFormingNum * Number(this.form.salesOrders[0].productUnitWeight || 1)) / 1000;
-        } else {
-          this.form.newWeightUnit = this.form.weightUnit;
-          _sumOrderWeight = (this.form.salesOrders[0].requiredFormingNum * Number(this.form.salesOrders[0].productUnitWeight || 1));
+        let latestData = {};
+        for (let i = 0; i < sortedCollection.length; i++) {
+          const data = sortedCollection[i];
+          if (
+            !latestData.reqMoldTime ||
+            new Date(data.reqMoldTime) >= new Date(latestData.reqMoldTime)
+          ) {
+            latestData = data;
+          }
         }
+        this.form.reqMoldTime = latestData.reqMoldTime;
+      },
 
-        productNum += Number(item.planProductNum);
-      });
-      this.form.productNum = productNum;
-      this.form.productUnitWeight = this.form.salesOrders[0]?.productUnitWeight;
-      this.form.newSumOrderWeight = _sumOrderWeight.toFixed(2);
-      this.form.requiredFormingNum = requiredFormingNum;
-      const collection = deepClone(this.form.salesOrders);
-      const sortedCollection = collection.sort(
-        (a, b) => new Date(b.reqMoldTime) - new Date(a.reqMoldTime)
-      );
-
-      let latestData = {};
-      for (let i = 0; i < sortedCollection.length; i++) {
-        const data = sortedCollection[i];
-        if (
-          !latestData.reqMoldTime ||
-          new Date(data.reqMoldTime) >= new Date(latestData.reqMoldTime)
-        ) {
-          latestData = data;
+      sortTop(row) {
+        row.priority = Number(row.priority) + 1;
+        this.priorityChange(row);
+      },
+      sortBottom(row) {
+        if (row.priority <= 1) {
+          return;
         }
-      }
-      this.form.reqMoldTime = latestData.reqMoldTime;
-
-      console.log(this.form, '1111111111111');
-
-    },
-
-    sortTop(row) {
-      row.priority = Number(row.priority) + 1;
-      this.priorityChange(row);
-    },
-    sortBottom(row) {
-      if (row.priority <= 1) {
-        return;
-      }
-      row.priority = Number(row.priority) - 1;
-      this.priorityChange(row);
-    },
-
-    priorityChange(row) {
-      if (row.priority > 10) {
-        row.priority = 10; // 如果大于 10,则设置为 10
-      } else if (row.priority < 0) {
-        row.priority = 0; // 如果小于 0,则设置为 0
-      }
-
-      this.priorityFn(row);
-    },
-
-    priorityFn: debounce(function (row) { }, 800),
+        row.priority = Number(row.priority) - 1;
+        this.priorityChange(row);
+      },
 
-    // 删除产品
-    handleDeleteItem(index) {
-      this.form.salesOrders.splice(index, 1);
-    },
-    addEquipment() {
-      this.$refs.additionalRefs.open(this.form.planType);
-    },
-    openVersion() {
-      this.$refs.versionRefs.open();
-    },
-    changeProduct(data) {
-      this.$set(this.form, 'produceRoutingName', data.name);
-      this.$set(this.form, 'produceRoutingId', data.id);
-      this.$set(this.form, 'produceVersionName', data.produceVersionName);
-    },
-    // 表格:模数、数量(方)、块数输入框 输入事件
-    tableHandleKeyUp(row, index, e, name) {
-      if (row.specification && this.clientEnvironmentId == '4') {
-        let modelArr = row.specification.split('*');
-        let modelLong = modelArr[0]; // model规格长度
-        let modeWide = modelArr[1]; // model规格宽度
-        let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
-        modeHight = Number(modeHight);
-        if (name === 'moCount') {
-          // 模数
-          row.moCount = e;
-          // 计算块数的公式:
-          // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
-          // 每一模的块数*模数moCount = 总块数
-          if (row.productName.includes('板材')) {
-            row.blockCount =
-              Math.floor(600 / modelLong) *
-              Math.floor(120 / modeHight) *
-              Math.floor(60 / modeWide) *
-              row.moCount;
-          } else if (row.productName.includes('砌块')) {
-            let modelLongFixed = (600 / modelLong).toFixed(2);
-            modelLongFixed = modelLongFixed.substring(
-              0,
-              modelLongFixed.length - 1
-            );
-            let modeWideFixed = (120 / modeWide).toFixed(2);
-            modeWideFixed = modeWideFixed.substring(
-              0,
-              modeWideFixed.length - 1
-            );
-            let modeHightFixed = (60 / modeHight).toFixed(2);
-            modeHightFixed = modeHightFixed.substring(
-              0,
-              modeHightFixed.length - 1
-            );
-            row.blockCount =
-              Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
-              row.moCount;
-          }
+      priorityChange(row) {
+        if (row.priority > 10) {
+          row.priority = 10; // 如果大于 10,则设置为 10
+        } else if (row.priority < 0) {
+          row.priority = 0; // 如果小于 0,则设置为 0
+        }
 
-          row.planProductNum =
-            Number((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
-            row.blockCount;
-        } else if (name === 'sum') {
+        this.priorityFn(row);
+      },
 
-          //方数
-          row.planProductNum = e;
+      priorityFn: debounce(function (row) {}, 800),
 
-          row.blockCount = Math.floor(
-            e / ((modelLong * modeWide * modeHight) / 1000000)
-          );
-          if (row.productName.includes('板材')) {
-            row.moCount = Math.ceil(
-              row.blockCount /
-              (Math.floor(600 / modelLong) *
-                Math.floor(120 / modeHight) *
-                Math.floor(60 / modeWide))
-            );
-          } else if (row.productName.includes('砌块')) {
-            row.moCount = Math.ceil(
-              row.blockCount /
-              Math.floor(
-                (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
-              )
-            );
-          }
-        } else if (name === 'blockCount') {
-          //块数
-          row.blockCount = e;
-
-          if (row.productName.includes('板材')) {
-            row.moCount = Math.ceil(
-              row.blockCount /
-              (Math.floor(600 / modelLong) *
+      // 删除产品
+      handleDeleteItem(index) {
+        this.form.salesOrders.splice(index, 1);
+      },
+      addEquipment() {
+        this.$refs.additionalRefs.open(this.form.planType);
+      },
+      openVersion() {
+        this.$refs.versionRefs.open();
+      },
+      changeProduct(data) {
+        this.$set(this.form, 'produceRoutingName', data.name);
+        this.$set(this.form, 'produceRoutingId', data.id);
+        this.$set(this.form, 'produceVersionName', data.produceVersionName);
+      },
+      // 表格:模数、数量(方)、块数输入框 输入事件
+      tableHandleKeyUp(row, index, e, name) {
+        if (row.specification && this.clientEnvironmentId == '4') {
+          let modelArr = row.specification.split('*');
+          let modelLong = modelArr[0]; // model规格长度
+          let modeWide = modelArr[1]; // model规格宽度
+          let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
+          modeHight = Number(modeHight);
+          if (name === 'moCount') {
+            // 模数
+            row.moCount = e;
+            // 计算块数的公式:
+            // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
+            // 每一模的块数*模数moCount = 总块数
+            if (row.productName.includes('板材')) {
+              row.blockCount =
+                Math.floor(600 / modelLong) *
                 Math.floor(120 / modeHight) *
-                Math.floor(60 / modeWide))
-            );
-          } else if (row.productName.includes('砌块')) {
-            row.moCount = Math.ceil(
-              row.blockCount /
-              Math.floor(
-                (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
-              )
+                Math.floor(60 / modeWide) *
+                row.moCount;
+            } else if (row.productName.includes('砌块')) {
+              let modelLongFixed = (600 / modelLong).toFixed(2);
+              modelLongFixed = modelLongFixed.substring(
+                0,
+                modelLongFixed.length - 1
+              );
+              let modeWideFixed = (120 / modeWide).toFixed(2);
+              modeWideFixed = modeWideFixed.substring(
+                0,
+                modeWideFixed.length - 1
+              );
+              let modeHightFixed = (60 / modeHight).toFixed(2);
+              modeHightFixed = modeHightFixed.substring(
+                0,
+                modeHightFixed.length - 1
+              );
+              row.blockCount =
+                Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
+                row.moCount;
+            }
+
+            row.planProductNum =
+              Number((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
+              row.blockCount;
+          } else if (name === 'sum') {
+            //方数
+            row.planProductNum = e;
+
+            row.blockCount = Math.floor(
+              e / ((modelLong * modeWide * modeHight) / 1000000)
             );
+            if (row.productName.includes('板材')) {
+              row.moCount = Math.ceil(
+                row.blockCount /
+                  (Math.floor(600 / modelLong) *
+                    Math.floor(120 / modeHight) *
+                    Math.floor(60 / modeWide))
+              );
+            } else if (row.productName.includes('砌块')) {
+              row.moCount = Math.ceil(
+                row.blockCount /
+                  Math.floor(
+                    (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
+                  )
+              );
+            }
+          } else if (name === 'blockCount') {
+            //块数
+            row.blockCount = e;
+
+            if (row.productName.includes('板材')) {
+              row.moCount = Math.ceil(
+                row.blockCount /
+                  (Math.floor(600 / modelLong) *
+                    Math.floor(120 / modeHight) *
+                    Math.floor(60 / modeWide))
+              );
+            } else if (row.productName.includes('砌块')) {
+              row.moCount = Math.ceil(
+                row.blockCount /
+                  Math.floor(
+                    (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
+                  )
+              );
+            }
+
+            row.planProductNum =
+              (Number(e) * modelLong * modeWide * modeHight) / 1000000;
           }
-
-          row.planProductNum =
-            (Number(e) * modelLong * modeWide * modeHight) / 1000000;
         }
-      }
 
-      row.requiredFormingNum = Number(row.planProductNum * (this.form.marginCoefficient || 1)).toFixed(5);
-
-    },
-    confirmChoose(list) {
-      // 取出在弹窗中选中并且不在表格中的数据
-      const result = list.filter(
-        (i) => this.form.salesOrders.findIndex((p) => p.id === i.id) === -1
-      );
-      // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
-      const del = this.form.salesOrders.filter(
-        (i) => list.findIndex((p) => p.id === i.id) === -1
-      );
-      for (let i = this.form.salesOrders.length - 1; i >= 0; i--) {
-        for (let j in del) {
-          if (this.form.salesOrders[i].id === del[j].id) {
-            this.form.salesOrders.splice(i, 1);
+        row.requiredFormingNum = Number(
+          row.planProductNum * (this.form.marginCoefficient || 1)
+        ).toFixed(5);
+      },
+      confirmChoose(list) {
+        // 取出在弹窗中选中并且不在表格中的数据
+        const result = list.filter(
+          (i) => this.form.salesOrders.findIndex((p) => p.id === i.id) === -1
+        );
+        // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
+        const del = this.form.salesOrders.filter(
+          (i) => list.findIndex((p) => p.id === i.id) === -1
+        );
+        for (let i = this.form.salesOrders.length - 1; i >= 0; i--) {
+          for (let j in del) {
+            if (this.form.salesOrders[i].id === del[j].id) {
+              this.form.salesOrders.splice(i, 1);
+            }
           }
         }
-      }
-      let priority =
-        this.form.salesOrders[this.form.salesOrders.length - 1]?.priority || 0;
-      this.form.salesOrders = this.form.salesOrders.concat(
-        result.map((item, index) => {
-          item.priority = ++priority;
-
-          item.planProductNum = item.lackNum;
-          item.requiredFormingNum = item.lackNum;
-          item.reqMoldTime = dayjs(
-            new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
-          ).format('YYYY-MM-DD');
-          return item;
-        })
-      );
-      this.changeData();
-    },
-    changeData() {
-      var planProductNum = 0;
-      var productWeight = 0;
-
-      this.form.salesOrders.map((item, index) => {
-        item.priority = index + 1;
-        planProductNum = planProductNum + item.requiredFormingNum;
-        productWeight = productWeight + Number(item.productSumWeight);
-      });
-      this.$set(this.form, 'codeNum', this.form.salesOrders.length);
-      this.$set(this.form, 'contractNum', planProductNum);
-      this.$set(this.form, 'sumOrderWeight', productWeight.toFixed(2));
-    },
+        let priority =
+          this.form.salesOrders[this.form.salesOrders.length - 1]?.priority ||
+          0;
+        this.form.salesOrders = this.form.salesOrders.concat(
+          result.map((item, index) => {
+            item.priority = ++priority;
 
-    async publishData(type) {
-      const key = getRouteTabKey();
-      let params = deepClone(this.form);
-      params.categoryId = params.salesOrders[0]?.categoryId;
-      if (this.$route.query.type != 'edit') {
-        delete params.id;
-      }
+            item.planProductNum = item.lackNum;
+            item.requiredFormingNum = item.lackNum;
+            item.reqMoldTime = dayjs(
+              new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
+            ).format('YYYY-MM-DD');
+            return item;
+          })
+        );
+        this.changeData();
+      },
+      changeData() {
+        var planProductNum = 0;
+        var productWeight = 0;
 
-      if (type === 2) {
-        this.$confirm('发布工单后不可撤回,确定发布吗?', '发布确认').then(
-          async () => {
-            const loading = this.$loading({
-              lock: true,
-              fullscreen: true,
-              text: '工单发布中...'
-            });
-            try {
-              const code = await getCode('product_order_code');
-              const data = {
-                productionPlan: params,
-                workOrder: {
-                  productionPlanCode: params.code,
-                  code: code,
-                  // formingNum: params.contractNum,
-                  formingNum: this.form.requiredFormingNum,
-                  formingWeight: params.sumOrderWeight,
-                  produceRoutingId: params.produceRoutingId,
-                  status: 4,
-                  model: params.model,
-                  brandNo: params.brandNo,
-                  categoryId: params.categoryId,
-                  productCode: params.productCode,
-                  productName: params.productName,
-
-                  newWeightUnit: this.form.newWeightUnit,
-                  newSumOrderWeight: this.form.newSumOrderWeight
+        this.form.salesOrders.map((item, index) => {
+          item.priority = index + 1;
+          planProductNum = planProductNum + item.requiredFormingNum;
+          productWeight = productWeight + Number(item.productSumWeight);
+        });
+        this.$set(this.form, 'codeNum', this.form.salesOrders.length);
+        this.$set(this.form, 'contractNum', planProductNum);
+        this.$set(this.form, 'sumOrderWeight', productWeight.toFixed(2));
+      },
+
+      async publishData(type) {
+        const key = getRouteTabKey();
+        let params = deepClone(this.form);
+        params.categoryId = params.salesOrders[0]?.categoryId;
+        if (this.$route.query.type != 'edit') {
+          delete params.id;
+        }
+
+        if (type === 2) {
+          this.$confirm('发布工单后不可撤回,确定发布吗?', '发布确认').then(
+            async () => {
+              const loading = this.$loading({
+                lock: true,
+                fullscreen: true,
+                text: '工单发布中...'
+              });
+              try {
+                const code = await getCode('product_order_code');
+                const data = {
+                  productionPlan: params,
+                  workOrder: {
+                    productionPlanCode: params.code,
+                    code: code,
+                    // formingNum: params.contractNum,
+                    formingNum: this.form.requiredFormingNum,
+                    formingWeight: params.sumOrderWeight,
+                    produceRoutingId: params.produceRoutingId,
+                    status: 4,
+                    model: params.model,
+                    brandNo: params.brandNo,
+                    categoryId: params.categoryId,
+                    productCode: params.productCode,
+                    productName: params.productName,
+
+                    newWeightUnit: this.form.newWeightUnit,
+                    newSumOrderWeight: this.form.newSumOrderWeight
+                  }
+                };
+                if (this.$route.query.type == 'edit') {
+                  data.workOrder.productionPlanId = params.id;
                 }
-              };
-              if (this.$route.query.type == 'edit') {
-                data.workOrder.productionPlanId = params.id;
-              }
-              console.log(data);
-              await releaseSave(data)
-                .then((res) => {
-                  if (res === 1) {
-                    this.$message.success('工单已发布!');
-                    this.$router.push({
-                      path: '/productionPlan'
-                    });
-                  } else {
-                    this.$confirm(
-                      '生产计划创建成功,但工单发布失败。请前往【生产计划】列表【重新发布】工单',
-                      '提示',
-                      {
-                        confirmButtonText: '返回',
-                        cancelButtonText: '立即前往',
-                        type: 'warning'
-                      }
-                    )
-                      .then(() => {
-                        this.$router.push({
-                          path: '/productionPlan'
-                        });
-                      })
-                      .catch(() => {
-                        this.$router.go(-1);
+                await releaseSave(data)
+                  .then((res) => {
+                    if (res === 1) {
+                      this.$message.success('工单已发布!');
+                      this.$router.push({
+                        path: '/productionPlan'
                       });
-                  }
-                  removePageTab({ key });
-                })
-                .catch(() => {
-                  this.$message.error('发布失败,请重新发布!');
-                });
-            } catch (error) { }
-
-            loading.close();
-          }
-        );
-      } else {
-        let request =
-          this.$route.query.type == 'edit' ? updateSaleToPlan : saveSaleToPlan;
-
-        request(params)
-          .then(async (res) => {
-            // 提交
-            this.$router.push({
-              path: '/productionPlan'
+                    } else {
+                      this.$confirm(
+                        '生产计划创建成功,但工单发布失败。请前往【生产计划】列表【重新发布】工单',
+                        '提示',
+                        {
+                          confirmButtonText: '返回',
+                          cancelButtonText: '立即前往',
+                          type: 'warning'
+                        }
+                      )
+                        .then(() => {
+                          this.$router.push({
+                            path: '/productionPlan'
+                          });
+                        })
+                        .catch(() => {
+                          this.$router.go(-1);
+                        });
+                    }
+                    removePageTab({ key });
+                  })
+                  .catch(() => {
+                    this.$message.error('发布失败,请重新发布!');
+                  });
+              } catch (error) {}
+
+              loading.close();
+            }
+          );
+        } else {
+          let request =
+            this.$route.query.type == 'edit'
+              ? updateSaleToPlan
+              : saveSaleToPlan;
+
+          request(params)
+            .then(async (res) => {
+              // 提交
+              this.$router.push({
+                path: '/productionPlan'
+              });
+              removePageTab({ key });
+            })
+            .catch(() => {
+              this.$message.error('提交失败,请重新提交!');
             });
-            removePageTab({ key });
-          })
-          .catch(() => {
-            this.$message.error('提交失败,请重新提交!');
-          });
+        }
       }
     }
-  }
-};
+  };
 </script>
 <style lang="scss" scoped>
-.ele-body {
-  background: #fff;
-}
-
-.body-title {
-  width: 100%;
-  display: flex;
-  align-items: center;
-  justify-content: space-between;
-}
-
-.title-left {
-  font-size: 20px;
-  color: #333;
-}
-
-.formbox {
-  margin: 20px auto;
-}
-
-.row-intro {
-  border-bottom: 1px dashed #ccc;
-  margin-bottom: 20px;
-}
-
-.add-product {
-  width: 100%;
-  display: flex;
-  align-items: center;
-  justify-content: flex-end;
-  font-size: 30px;
-  color: #1890ff;
-  margin: 10px 0;
-  cursor: pointer;
-}
-
-.table-item {
-  margin-bottom: 0;
-}
+  .ele-body {
+    background: #fff;
+  }
+
+  .body-title {
+    width: 100%;
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+  }
+
+  .title-left {
+    font-size: 20px;
+    color: #333;
+  }
+
+  .formbox {
+    margin: 20px auto;
+  }
+
+  .row-intro {
+    border-bottom: 1px dashed #ccc;
+    margin-bottom: 20px;
+  }
+
+  .add-product {
+    width: 100%;
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    font-size: 30px;
+    color: #1890ff;
+    margin: 10px 0;
+    cursor: pointer;
+  }
+
+  .table-item {
+    margin-bottom: 0;
+  }
 </style>

+ 887 - 728
src/views/saleOrder/salesToProductionNew.vue

@@ -1,6 +1,5 @@
 <template>
   <div class="ele-body">
-
     <el-card shadow="never">
       <div class="body-title">
         <div class="title-left">{{
@@ -8,67 +7,146 @@
         }}</div>
         <div class="title-right">
           <el-button @click="cancel">取消</el-button>
-          <el-button type="primary" @click="toSubmit">
-            保存
-          </el-button>
+          <el-button type="primary" @click="toSubmit"> 保存 </el-button>
         </div>
       </div>
 
-      <el-form ref="form" :model="form" :rules="rules" label-width="100px" class="formbox">
+      <el-form
+        ref="form"
+        :model="form"
+        :rules="rules"
+        label-width="100px"
+        class="formbox"
+      >
         <el-row :gutter="24">
-
           <el-col :span="6">
             <el-form-item label="计划类型:">
-              <DictSelection dictName="订单计划类型" clearable v-model="form.planType" disabled>
+              <DictSelection
+                dictName="订单计划类型"
+                clearable
+                v-model="form.planType"
+                disabled
+              >
               </DictSelection>
             </el-form-item>
           </el-col>
 
           <el-col :span="6">
-            <el-form-item label="加工方式:" prop="produceType">
-              <el-select v-model="form.produceType" style="width: 100%" @change="changeProduceType">
-                <el-option v-for="item of producedList" :key="item.code" :label="item.name"
-                  :value="item.code"></el-option>
+            <el-form-item
+              :class="isRequired ? 'header_required' : ''"
+              label="加工方式:"
+              prop="produceType"
+            >
+              <el-select
+                v-model="form.produceType"
+                style="width: 100%"
+                @change="changeProduceType"
+              >
+                <el-option
+                  v-for="item of producedList"
+                  :key="item.code"
+                  :label="item.name"
+                  :value="item.code"
+                ></el-option>
               </el-select>
             </el-form-item>
           </el-col>
 
           <el-col :span="6" v-if="clientEnvironmentId != 4">
-            <el-form-item label="BOM版本:" prop="bomCategoryId">
-              <el-select v-model="form.bomCategoryId" style="width: 100%" @change="changeBomId">
-                <el-option v-for="item of bomVersionList" :key="item.id"
-                  :label="item.name + '(V' + item.versions + '.0)'" :value="item.id"></el-option>
+            <el-form-item
+              :class="isRequired ? 'header_required' : ''"
+              label="BOM版本:"
+              prop="bomCategoryId"
+            >
+              <el-select
+                v-model="form.bomCategoryId"
+                style="width: 100%"
+                @change="changeBomId"
+              >
+                <el-option
+                  v-for="item of bomVersionList"
+                  :key="item.id"
+                  :label="item.name + '(V' + item.versions + '.0)'"
+                  :value="item.id"
+                ></el-option>
               </el-select>
             </el-form-item>
           </el-col>
           <el-col :span="6" v-if="clientEnvironmentId != 4">
-
             <el-form-item label="工艺路线:" prop="produceRoutingId">
               <!--  @click.native="openVersion"   -->
-
-              <el-select v-model="form.produceRoutingId" style="width: 100%" @change="changeRoute">
-                <el-option v-for="item of routingList" :key="item.id" :label="item.name" :value="item.id"></el-option>
-              </el-select>
+              <div style="display: flex">
+                <el-select
+                  v-model="form.produceRoutingId"
+                  style="width: 100%"
+                  @change="changeRoute"
+                  v-show="isRouteSelect"
+                >
+                  <el-option
+                    v-for="item of routingList"
+                    :key="item.id"
+                    :label="item.name"
+                    :value="item.id"
+                  ></el-option>
+                </el-select>
+
+                <div
+                  :style="{
+                    display: 'flex',
+                    width: !isRouteSelect ? '100%' : ''
+                  }"
+                >
+                  <el-input
+                    v-show="!isRouteSelect"
+                    disabled
+                    v-model="form.produceRoutingName"
+                    style="width: 100%"
+                  ></el-input>
+                  <el-button
+                    v-show="isSelectShow"
+                    type="primary"
+                    size="mini"
+                    @click="openDialog"
+                    >选择</el-button
+                  >
+                </div>
+              </div>
             </el-form-item>
           </el-col>
           <el-col :span="6" v-if="clientEnvironmentId == 4">
             <el-form-item label="工艺路线:" prop="produceRoutingId">
-              <el-input v-model="form.produceRoutingName" style="width: 100%" readonly></el-input>
+              <el-input
+                v-model="form.produceRoutingName"
+                style="width: 100%"
+                readonly
+              ></el-input>
             </el-form-item>
           </el-col>
-
         </el-row>
         <el-row :gutter="24">
           <el-col :span="6">
             <el-form-item label="余量系数:" prop="marginCoefficient">
-              <el-select v-model="form.marginCoefficient" filterable allow-create @change="itemChange">
-                <el-option v-for="(item, index) in marginList" :key="index" :label="item.name" :value="item.value" />
+              <el-select
+                v-model="form.marginCoefficient"
+                filterable
+                allow-create
+                @change="itemChange"
+              >
+                <el-option
+                  v-for="(item, index) in marginList"
+                  :key="index"
+                  :label="item.name"
+                  :value="item.value"
+                />
               </el-select>
             </el-form-item>
           </el-col>
           <el-col :span="6">
             <el-form-item label="批次号:" prop="batchNo">
-              <el-input placeholder="请输入批次号" v-model="form.batchNo"></el-input>
+              <el-input
+                placeholder="请输入批次号"
+                v-model="form.batchNo"
+              ></el-input>
             </el-form-item>
           </el-col>
 
@@ -92,15 +170,16 @@
               <el-input v-model="form.produceRoutingName" style="width: 100%" readonly></el-input>
             </el-form-item>
           </el-col> -->
-
-
         </el-row>
 
-
         <el-row :gutter="24">
           <el-col :span="6">
             <el-form-item label="计划数量:" prop="batchNo">
-              <el-input placeholder="请输入计划数量" v-model="form.productNum" disabled></el-input>
+              <el-input
+                placeholder="请输入计划数量"
+                v-model="form.productNum"
+                disabled
+              ></el-input>
             </el-form-item>
           </el-col>
 
@@ -112,11 +191,14 @@
 
           <el-col :span="6">
             <el-form-item label="要求生产数量:">
-              <el-input placeholder="请输入要求生产数量" v-model="form.requiredFormingNum" disabled></el-input>
+              <el-input
+                placeholder="请输入要求生产数量"
+                v-model="form.requiredFormingNum"
+                disabled
+              ></el-input>
             </el-form-item>
           </el-col>
 
-
           <!-- <el-col :span="6">
             <el-form-item label="要求生产重量:">
               <el-input placeholder="请输入要求生产重量" v-model="form.newSumOrderWeight" disabled></el-input>
@@ -125,19 +207,31 @@
 
           <el-col :span="6">
             <el-form-item label="名称:">
-              <el-input placeholder="请输入名称" v-model="form.productName" disabled></el-input>
+              <el-input
+                placeholder="请输入名称"
+                v-model="form.productName"
+                disabled
+              ></el-input>
             </el-form-item>
           </el-col>
           <el-col :span="6">
             <el-form-item label="编码:">
-              <el-input placeholder="请输入编码" v-model="form.productCode" disabled></el-input>
+              <el-input
+                placeholder="请输入编码"
+                v-model="form.productCode"
+                disabled
+              ></el-input>
             </el-form-item>
           </el-col>
         </el-row>
         <el-row :gutter="24">
           <el-col :span="6">
             <el-form-item label="计划编号:">
-              <el-input placeholder="请输入计划编号" v-model="form.code" disabled></el-input>
+              <el-input
+                placeholder="请输入计划编号"
+                v-model="form.code"
+                disabled
+              ></el-input>
             </el-form-item>
           </el-col>
 
@@ -156,762 +250,827 @@
               <el-input v-model="form.model" disabled></el-input>
             </el-form-item>
           </el-col>
-
         </el-row>
-
-
-
       </el-form>
-      <AdditionalOrder ref="additionalRefs" :productCode="form.productCode" :selectList="form.salesOrders"
-        @choose="confirmChoose"></AdditionalOrder>
-      <ProductionVersion ref="versionRefs" @changeProduct="changeProduct"></ProductionVersion>
-      <PlanSubmit ref="submitRefs" :type="$route.query.type" :info="form" @publish="publishData"></PlanSubmit>
+      <AdditionalOrder
+        ref="additionalRefs"
+        :productCode="form.productCode"
+        :selectList="form.salesOrders"
+        @choose="confirmChoose"
+      ></AdditionalOrder>
+      <ProductionVersion
+        ref="versionRefs"
+        @changeProduct="changeProduct"
+      ></ProductionVersion>
+      <PlanSubmit
+        ref="submitRefs"
+        :type="$route.query.type"
+        :info="form"
+        @publish="publishData"
+      ></PlanSubmit>
+      <ProcessRoute ref="processRouteRef" @changeParent="changeParent" />
     </el-card>
   </div>
 </template>
 <script>
-import AdditionalOrder from './components/AdditionalOrder.vue';
-import PlanSubmit from './components/plan-submit.vue';
-import ProductionVersion from '@/components/CreatePlan/ProductionVersion2.vue';
-import {
-  productionToPlan,
-  saveSaleToPlan,
-  updateSaleToPlan,
-  releaseSave,
-  getInventory,
-  getUpdateInfoById,
-  bomRoutingList,
-  bomListByPlan,
-  getFactoryList,
-  getGeneratePlan
-} from '@/api/saleOrder';
-
-import { getByCode } from '@/api/system/dictionary-data';
-
-import dictMixins from '@/mixins/dictMixins';
-import { deepClone } from '@/utils/index';
-import { getRouteTabKey, removePageTab } from '@/utils/page-tab-util';
-import { getCode } from '@/api/codeManagement';
-import dayjs from 'dayjs';
-import { debounce } from 'lodash';
-export default {
-  mixins: [dictMixins],
-  components: {
-    AdditionalOrder,
-    ProductionVersion,
-    PlanSubmit
-  },
-  props: {
-    formData: {
-      type: Object,
-      default: {}
-    }
-  },
-  watch: {
-    formData: {
-      handler(val) {
-
-
-        Object.assign(this.form, val);
-        // console.log(this.form,'1111111111122222');
-        this.$nextTick(() => {
-          if (val.produceRoutingId) {
-            this.bomListVersion();
-            this.changeBomId();
-          }
-          this.$set(this.form, 'produceRoutingId', val.produceRoutingId);
-        });
-
-      },
-      deep: true,
-      immediate: true
-    }
-  },
-  data() {
-    return {
-      type: this.$route.query.type,
-      weightList: [
-        { code: 1, name: 'A' },
-        { code: 2, name: 'B' },
-        { code: 3, name: 'C' }
-      ],
-      isSlotting: [
-        { code: 1, name: '是' },
-        { code: 2, name: '否' }
-      ], //是否开槽
-
-      producedList: [
-        { code: 2, name: '加工(MBOM)' },
-        { code: 3, name: '装配(ABOM)' }
-      ],
-
-      form: {
-        planType: 1,
-        produceRoutingId: '',
-
-        stockCountBase: '',
-        salesOrders: [],
-        produceRoutingName: '',
-        marginCoefficient: '1.0',
-        batchNo: null,
-        produceType: 1,
-        bomCategoryId: '',
-        factoriesId: '',
-        productPlanList: []
-      },
-
-      marginList: [],
-
-      bomVersionList: [],
-      routingList: [],
-      factoryList: [],
-
-      // 表单验证规则
-      rules: {
-        produceRoutingId: [
-          { required: true, message: '请选择工艺路线', trigger: 'blur' }
-        ],
-
-        factoriesId: [
-          { required: true, message: '请选择所属工厂', trigger: 'blur' }
-        ]
-      },
-      // selection: [],
-      loading: false
-    };
-  },
-  computed: {
-    clientEnvironmentId() {
-      return this.$store.state.user.info.clientEnvironmentId;
+  import AdditionalOrder from './components/AdditionalOrder.vue';
+  import PlanSubmit from './components/plan-submit.vue';
+  import ProductionVersion from '@/components/CreatePlan/ProductionVersion2.vue';
+  import {
+    productionToPlan,
+    saveSaleToPlan,
+    updateSaleToPlan,
+    releaseSave,
+    getInventory,
+    getUpdateInfoById,
+    bomRoutingList,
+    bomListByPlan,
+    getFactoryList,
+    getGeneratePlan
+  } from '@/api/saleOrder';
+
+  import { getByCode } from '@/api/system/dictionary-data';
+  import { parameterGetByCode } from '@/api/mainData/index';
+  import dictMixins from '@/mixins/dictMixins';
+  import { deepClone } from '@/utils/index';
+  import { getRouteTabKey, removePageTab } from '@/utils/page-tab-util';
+  import { getCode } from '@/api/codeManagement';
+  import dayjs from 'dayjs';
+  import { debounce } from 'lodash';
+  import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
+  export default {
+    mixins: [dictMixins],
+    components: {
+      AdditionalOrder,
+      ProductionVersion,
+      PlanSubmit,
+      ProcessRoute
     },
-    // 是否开启响应式布局
-    styleResponsive() {
-      return this.$store.state.theme.styleResponsive;
-    }
-  },
-  created() {
-    this.requestDict('按单按库');
-    this.requestDict('订单类型');
-    this.requestDict('交付要求');
-    this.getByCodeFn();
-    this.getFactoryList();
-    // if (this.type == 'edit') {
-    //   this.getPlanInfo(this.$route.query.id);
-    // } else {
-    //   this.getSaleInfo();
-    // }
-    this.bomListVersion();
-  },
-  methods: {
-
-    // 验证时间是否超期
-    changeDate(item, i) {
-      console.log(this.isTimeAGreaterThanB(item.deliveryTime, item.reqMoldTime));
-      if (this.isTimeAGreaterThanB(item.deliveryTime, item.reqMoldTime)) {
-        this.$message.error('交付时间大于了要求完成日期')
+    props: {
+      formData: {
+        type: Object,
+        default: {}
       }
-
     },
-    isTimeAGreaterThanB(timeA, timeB) {
-      return new Date(timeA) > new Date(timeB);
-    },
-
-
-    async getFactoryList() {
-      this.factoryList = await getFactoryList();
-      this.$nextTick(() => {
-        this.form.factoriesId = this.factoryList[0].id
-      })
-    },
-    async getPlanInfo(id) {
-      const data = await getUpdateInfoById(id);
-      console.log('wwwwwwwwwwww', data);
-
-      this.form = data;
-
-      if (this.clientEnvironmentId != 4) {
-        this.bomListVersion()
-        this.getPlanRouting()
+    watch: {
+      formData: {
+        handler(val) {
+          Object.assign(this.form, val);
+          // console.log(this.form,'1111111111122222');
+          this.$nextTick(() => {
+            if (val.produceRoutingId) {
+              this.bomListVersion();
+              this.changeBomId();
+            }
+            this.$set(this.form, 'produceRoutingId', val.produceRoutingId);
+          });
+        },
+        deep: true,
+        immediate: true
+      },
+      selectionRowShow(val) {
+        console.log(val, 'val ++++++');
+        this.selectionRowShow = val;
       }
-
-
-
     },
-    async _getInventory() {
-      const res = await getInventory(this.form.productCode, this.form.planType);
-
-      this.form.stockCountBase = res;
-    },
-
-    getByCodeFn() {
-      getByCode('margin_code').then((res) => {
-        let _arr = [];
-        res.data.map((item) => {
-          const key = Object.keys(item)[0];
-          const value = item[key];
+    data() {
+      return {
+        type: this.$route.query.type,
+        weightList: [
+          { code: 1, name: 'A' },
+          { code: 2, name: 'B' },
+          { code: 3, name: 'C' }
+        ],
+        isSlotting: [
+          { code: 1, name: '是' },
+          { code: 2, name: '否' }
+        ], //是否开槽
+
+        producedList: [
+          { code: 2, name: '加工(MBOM)' },
+          { code: 3, name: '装配(ABOM)' }
+        ],
 
-          _arr.push({ name: key, value: value });
-        });
-        this.marginList = _arr;
-      });
+        form: {
+          planType: 1,
+          produceRoutingId: '',
+
+          stockCountBase: '',
+          salesOrders: [],
+          produceRoutingName: '',
+          marginCoefficient: '1.0',
+          batchNo: null,
+          produceType: 1,
+          bomCategoryId: '',
+          factoriesId: '',
+          productPlanList: []
+        },
+
+        marginList: [],
+
+        bomVersionList: [],
+        routingList: [],
+        factoryList: [],
+
+        // 表单验证规则
+        rules: {
+          produceRoutingId: [
+            { required: true, message: '请选择工艺路线', trigger: 'blur' }
+          ],
+
+          factoriesId: [
+            { required: true, message: '请选择所属工厂', trigger: 'blur' }
+          ]
+        },
+        // selection: [],
+        loading: false,
+        processingRequired: 0, // 加工方式跟BOM 版本是否必填 1:是 0:否
+        selectionRowShow: false // 工艺路线输入框展示 状态
+      };
     },
+    computed: {
+      clientEnvironmentId() {
+        return this.$store.state.user.info.clientEnvironmentId;
+      },
+      // 是否开启响应式布局
+      styleResponsive() {
+        return this.$store.state.theme.styleResponsive;
+      },
+      // 是否必填字段
+      isRequired() {
+        // if (this.form.planType == 5) {
+        //   return false;
+        // }
+        return this.processingRequired == 1;
+      },
+      // 工艺路线 输入框展示跟选择框判断
+      isRouteSelect() {
+        if (this.isRequired) {
+          return true;
+        }
+        if (!this.selectionRowShow) {
+          return true;
+        }
+        return false;
+      },
 
-
-    getPlanRouting() {
-
-      if (this.form.bomCategoryId) {
-        bomRoutingList(this.form.bomCategoryId).then((res) => {
-          this.routingList = res || [];
-          if (res.length) {
-            this.$nextTick(() => {
-
-              this.$set(this.form, 'produceRoutingId', res[0].id)
-            })
-
-            console.log(this.form.produceRoutingId, '222222222');
-          }
-        })
+      // 选择按钮的显示
+      isSelectShow() {
+        return this.processingRequired == 0;
       }
-
     },
-
-    bomListVersion() {
-      console.log(this.form, '1111111111');
-      let categoryId = ''
-
-      if (this.form.salesOrders.length) {
-        categoryId = this.form.salesOrders[0].categoryId;
-      } else if (this.form.categoryId) {
-        categoryId = this.form.categoryId
+    created() {
+      this.requestDict('按单按库');
+      this.requestDict('订单类型');
+      this.requestDict('交付要求');
+      this.getByCodeFn();
+      this.getFactoryList();
+      if (this.type == 'edit') {
+        this.getPlanInfo(this.$route.query.id);
       } else {
-        new Error('缺少产品信息')
-      }
-
-
-
-      let param = {
-        bomType: this.form.produceType,
-        categoryId: categoryId
-      }
-      bomListByPlan(param).then(res => {
-        this.bomVersionList = res || []
-      })
-    },
-
-
-    changeProduceType() {
-      if (this.clientEnvironmentId == 4) {
-        return false
+        this.getSaleInfo();
       }
-      this.form.bomCategoryId = '';
-      this.form['bomCategoryName'] = '';
-      this.form['bomCategoryVersions'] = '';
-
-
-      this.bomVersionList = [];
-
-      this.routingList = [];
-      this.form.produceRoutingId = '';
-      this.form.produceRoutingName = '';
-      this.form.produceVersionName = '';
-
-      this.bomListVersion()
-
+      // this.bomListVersion();
+      this.mandatoryField();
     },
-
-    changeBomId() {
-      this.routingList = []
-      this.form.produceRoutingId = ''
-      this.form.produceRoutingName = ''
-      this.form.produceVersionName = ''
-
-      this.bomVersionList.forEach((f) => {
-        if (f.id == this.form.bomCategoryId) {
-
-          this.$set(this.form, 'bomCategoryName', f.name);
-          this.$set(this.form, 'bomCategoryVersions', f.versions);
+    methods: {
+      // 是否必填
+      mandatoryField() {
+        parameterGetByCode({
+          code: 'production_plan_code'
+        }).then((res) => {
+          if (res) {
+            this.processingRequired = res.value;
+          }
+        });
+      },
+      // 验证时间是否超期
+      changeDate(item, i) {
+        console.log(
+          this.isTimeAGreaterThanB(item.deliveryTime, item.reqMoldTime)
+        );
+        if (this.isTimeAGreaterThanB(item.deliveryTime, item.reqMoldTime)) {
+          this.$message.error('交付时间大于了要求完成日期');
         }
+      },
+      isTimeAGreaterThanB(timeA, timeB) {
+        return new Date(timeA) > new Date(timeB);
+      },
 
-      })
-
-      this.getPlanRouting()
-    },
-
+      async getFactoryList() {
+        this.factoryList = await getFactoryList();
+        this.$nextTick(() => {
+          this.form.factoriesId = this.factoryList[0].id;
+        });
+      },
+      async getPlanInfo(id) {
+        const data = await getUpdateInfoById(id);
+        console.log('wwwwwwwwwwww', data);
+
+        this.form = data;
+        if (!data.bomCategoryId || data.bomCategoryId == null) {
+          this.form.produceType = '';
+          this.selectionRowShow = true;
+        } else {
+          this.selectionRowShow = false;
+        }
+        if (this.clientEnvironmentId != 4) {
+          this.bomListVersion();
+          // this.getPlanRouting();
+        }
+      },
+      async _getInventory() {
+        const res = await getInventory(
+          this.form.productCode,
+          this.form.planType
+        );
 
+        this.form.stockCountBase = res;
+      },
 
-    changeRoute() {
+      getByCodeFn() {
+        getByCode('margin_code').then((res) => {
+          let _arr = [];
+          res.data.map((item) => {
+            const key = Object.keys(item)[0];
+            const value = item[key];
 
+            _arr.push({ name: key, value: value });
+          });
+          this.marginList = _arr;
+        });
+      },
 
-      this.$forceUpdate();
-      this.routingList.forEach((f) => {
-        if (f.id == this.form.produceRoutingId) {
-          this.$set(this.form, 'produceRoutingName', f.name);
-          this.$set(this.form, 'produceVersionName', f.version);
+      getPlanRouting() {
+        if (this.form.bomCategoryId) {
+          bomRoutingList(this.form.bomCategoryId).then((res) => {
+            this.routingList = res || [];
+            if (res.length) {
+              this.$nextTick(() => {
+                this.$set(this.form, 'produceRoutingId', res[0].id);
+              });
+
+              console.log(this.form.produceRoutingId, '222222222');
+            }
+          });
         }
+      },
 
-      })
-    },
-
-    getSaleInfo() {
-      let params = JSON.parse(this.$route.query.selection);
-      productionToPlan(params).then((res) => {
-        console.log(res, '555555555555555555');
-        this.form = deepClone(res);
-        if (!this.form.produceType) {
-          this.form.produceType = 2;
-          this.bomListVersion()
+      bomListVersion() {
+        let categoryId = '';
+        if (this.form.salesOrders.length) {
+          categoryId = this.form.salesOrders[0].categoryId;
+        } else if (this.form.categoryId) {
+          categoryId = this.form.categoryId;
+        } else {
+          new Error('缺少产品信息');
         }
-        this.form.produceRoutingName =
-          res.produceRoutingName || this.$route.query.produceRoutingName;
-        this.form.produceRoutingId =
-          res.produceRoutingId || this.$route.query.produceRoutingId;
-        this.form.factoriesId =
-          res.factoriesId || this.$route.query.factoriesId;
-        this.form.bomCategoryId=res.bomCategoryId || this.$route.query.bomCategoryId;
-        this.changeBomId()
-        console.log(this.form.factoriesId, '99999999999999')
-        if (this.clientEnvironmentId == '4') {
-          if (this.form.salesOrders[0].productName.includes('板材')) {
-            this.changeProduct({
-              id: '1856970794952372226',
-              name: '板材',
-              produceVersionName: '板材'
-            });
-          } else {
-            this.changeProduct({
-              id: '1857313733642596353',
-              name: '砌块',
-              produceVersionName: '砌块'
-            });
+        let param = {
+          bomType: this.form.produceType || null,
+          categoryId: categoryId
+        };
+        bomListByPlan(param).then((res) => {
+          this.bomVersionList = res || [];
+          if (res.length) {
+            let o = res[0];
+            this.$set(this.form, 'bomCategoryId', o.id);
+            this.changeBomId();
           }
+        });
+      },
+
+      changeProduceType() {
+        if (this.clientEnvironmentId == 4) {
+          return false;
         }
-        this.form.salesOrders.map((item, index) => {
+        this.form.bomCategoryId = '';
+        this.form['bomCategoryName'] = '';
+        this.form['bomCategoryVersions'] = '';
+
+        this.bomVersionList = [];
+
+        this.routingList = [];
+        this.form.produceRoutingId = '';
+        this.form.produceRoutingName = '';
+        this.form.produceVersionName = '';
+        this.selectionRowShow = false; // ****
+        this.bomListVersion();
+      },
 
+      changeBomId() {
+        this.routingList = [];
+        this.form.produceRoutingId = '';
+        this.form.produceRoutingName = '';
+        this.form.produceVersionName = '';
 
-          if (this.clientEnvironmentId == '4') {
-            this.tableHandleKeyUp(item, '', item.lackNum, 'sum');
-          } else {
-            item.planProductNum = item.lackNum;
-            item.requiredFormingNum = item.lackNum;
+        this.bomVersionList.forEach((f) => {
+          if (f.id == this.form.bomCategoryId) {
+            this.$set(this.form, 'bomCategoryName', f.name);
+            this.$set(this.form, 'bomCategoryVersions', f.versions);
           }
-          item.slottingType = item.slottingType && item.slottingType + '';
-          item.priority = index + 1;
-
-          item.reqMoldTime = dayjs(
-            new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
-          ).format('YYYY-MM-DD');
         });
-        if (this.form.salesOrders.every((itm) => itm.orderType == 2)) {
-          this.form.planType = 2;
-        } else if (this.form.salesOrders.every((itm) => itm.orderType == 1)) {
-          this.form.planType = 1;
-        } else {
-          this.form.planType = 3;
-        }
-        this._getInventory();
-      });
-      this.$forceUpdate();
-    },
-
-    itemChange() {
-      this.form.salesOrders.map((item, index) => {
-        this.$set(
-          item,
-          'requiredFormingNum',
-          item.planProductNum * (this.form.marginCoefficient || 1)
-        );
-      });
-    },
-
-    factoriesIdFn(e) {
-
 
+        this.getPlanRouting();
+      },
 
-      this.$forceUpdate()
-    },
+      changeRoute() {
+        this.$forceUpdate();
+        this.routingList.forEach((f) => {
+          if (f.id == this.form.produceRoutingId) {
+            this.$set(this.form, 'produceRoutingName', f.name);
+            this.$set(this.form, 'produceVersionName', f.version);
+          }
+        });
+      },
 
-    toInt(planProductNum) {
-      return planProductNum * (this.form.marginCoefficient || 1);
-    },
+      getSaleInfo() {
+        let params = JSON.parse(this.$route.query.selection);
+        productionToPlan(params).then((res) => {
+          console.log(res, '555555555555555555');
+          this.form = deepClone(res);
+          // if (!this.form.produceType) {
+          //   this.form.produceType = 2;
+          //   this.bomListVersion();
+          // }
+          this.bomListVersion();
+          this.form.produceRoutingName =
+            res.produceRoutingName || this.$route.query.produceRoutingName;
+          this.form.produceRoutingId =
+            res.produceRoutingId || this.$route.query.produceRoutingId;
+          this.form.factoriesId =
+            res.factoriesId || this.$route.query.factoriesId;
+          this.form.bomCategoryId =
+            res.bomCategoryId || this.$route.query.bomCategoryId;
+          this.changeBomId();
+          console.log(this.form.factoriesId, '99999999999999');
+          if (this.clientEnvironmentId == '4') {
+            if (this.form.salesOrders[0].productName.includes('板材')) {
+              this.changeProduct({
+                id: '1856970794952372226',
+                name: '板材',
+                produceVersionName: '板材'
+              });
+            } else {
+              this.changeProduct({
+                id: '1857313733642596353',
+                name: '砌块',
+                produceVersionName: '砌块'
+              });
+            }
+          }
+          this.form.salesOrders.map((item, index) => {
+            if (this.clientEnvironmentId == '4') {
+              this.tableHandleKeyUp(item, '', item.lackNum, 'sum');
+            } else {
+              item.planProductNum = item.lackNum;
+              item.requiredFormingNum = item.lackNum;
+            }
+            item.slottingType = item.slottingType && item.slottingType + '';
+            item.priority = index + 1;
+
+            item.reqMoldTime = dayjs(
+              new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
+            ).format('YYYY-MM-DD');
+          });
+          if (this.form.salesOrders.every((itm) => itm.orderType == 2)) {
+            this.form.planType = 2;
+          } else if (this.form.salesOrders.every((itm) => itm.orderType == 1)) {
+            this.form.planType = 1;
+          } else {
+            this.form.planType = 3;
+          }
+          this._getInventory();
+        });
+        this.$forceUpdate();
+      },
 
-    cancel() {
-      const key = getRouteTabKey();
-      // this.$router.go(-1);
-      removePageTab({ key });
+      itemChange() {
+        this.form.salesOrders.map((item, index) => {
+          this.$set(
+            item,
+            'requiredFormingNum',
+            item.planProductNum * (this.form.marginCoefficient || 1)
+          );
+        });
+      },
 
-      this.$emit('cancel');
+      factoriesIdFn(e) {
+        this.$forceUpdate();
+      },
 
-    },
-    toSubmit() {
+      toInt(planProductNum) {
+        return planProductNum * (this.form.marginCoefficient || 1);
+      },
 
-      this.$refs.form.validate((valid) => {
+      cancel() {
+        const key = getRouteTabKey();
+        // this.$router.go(-1);
+        removePageTab({ key });
 
-        if (valid) {
-          // this.mapList();
+        this.$emit('cancel');
+      },
+      toSubmit() {
+        this.$refs.form.validate((valid) => {
+          if (valid) {
+            // this.mapList();
 
-          this.$refs.submitRefs.open();
+            this.$refs.submitRefs.open();
+          }
+        });
+      },
+      // // 对比日期,计算要求生产重量
+      // mapList() {
+      //   var _sumOrderWeight = 0;
+      //   var requiredFormingNum = 0;
+      //   var productNum = 0;
+      //   this.form.salesOrders.map((item, index) => {
+      //     requiredFormingNum = Number(requiredFormingNum) + Number(item.requiredFormingNum);
+
+      //     if (this.form.weightUnit == 'G' || this.form.weightUnit == 'g' || this.form.weightUnit == '克') {
+      //       this.form.newWeightUnit = 'kg';
+      //       _sumOrderWeight = (this.form.salesOrders[0].requiredFormingNum * Number(this.form.salesOrders[0].productUnitWeight || 1)) / 1000;
+      //     } else {
+      //       this.form.newWeightUnit = this.form.weightUnit;
+      //       _sumOrderWeight = (this.form.salesOrders[0].requiredFormingNum * Number(this.form.salesOrders[0].productUnitWeight || 1));
+      //     }
+
+      //     productNum += Number(item.planProductNum);
+      //   });
+      //   this.form.productNum = productNum;
+      //   this.form.productUnitWeight = this.form.salesOrders[0]?.productUnitWeight;
+      //   this.form.newSumOrderWeight = _sumOrderWeight.toFixed(2);
+      //   this.form.requiredFormingNum = requiredFormingNum;
+      //   const collection = deepClone(this.form.salesOrders);
+      //   const sortedCollection = collection.sort(
+      //     (a, b) => new Date(b.reqMoldTime) - new Date(a.reqMoldTime)
+      //   );
+
+      //   let latestData = {};
+      //   for (let i = 0; i < sortedCollection.length; i++) {
+      //     const data = sortedCollection[i];
+      //     if (
+      //       !latestData.reqMoldTime ||
+      //       new Date(data.reqMoldTime) >= new Date(latestData.reqMoldTime)
+      //     ) {
+      //       latestData = data;
+      //     }
+      //   }
+      //   this.form.reqMoldTime = latestData.reqMoldTime;
+
+      //   console.log(this.form, '1111111111111');
+
+      // },
+
+      sortTop(row) {
+        row.priority = Number(row.priority) + 1;
+        this.priorityChange(row);
+      },
+      sortBottom(row) {
+        if (row.priority <= 1) {
+          return;
         }
-      });
-    },
-    // // 对比日期,计算要求生产重量
-    // mapList() {
-    //   var _sumOrderWeight = 0;
-    //   var requiredFormingNum = 0;
-    //   var productNum = 0;
-    //   this.form.salesOrders.map((item, index) => {
-    //     requiredFormingNum = Number(requiredFormingNum) + Number(item.requiredFormingNum);
-
-    //     if (this.form.weightUnit == 'G' || this.form.weightUnit == 'g' || this.form.weightUnit == '克') {
-    //       this.form.newWeightUnit = 'kg';
-    //       _sumOrderWeight = (this.form.salesOrders[0].requiredFormingNum * Number(this.form.salesOrders[0].productUnitWeight || 1)) / 1000;
-    //     } else {
-    //       this.form.newWeightUnit = this.form.weightUnit;
-    //       _sumOrderWeight = (this.form.salesOrders[0].requiredFormingNum * Number(this.form.salesOrders[0].productUnitWeight || 1));
-    //     }
-
-    //     productNum += Number(item.planProductNum);
-    //   });
-    //   this.form.productNum = productNum;
-    //   this.form.productUnitWeight = this.form.salesOrders[0]?.productUnitWeight;
-    //   this.form.newSumOrderWeight = _sumOrderWeight.toFixed(2);
-    //   this.form.requiredFormingNum = requiredFormingNum;
-    //   const collection = deepClone(this.form.salesOrders);
-    //   const sortedCollection = collection.sort(
-    //     (a, b) => new Date(b.reqMoldTime) - new Date(a.reqMoldTime)
-    //   );
-
-    //   let latestData = {};
-    //   for (let i = 0; i < sortedCollection.length; i++) {
-    //     const data = sortedCollection[i];
-    //     if (
-    //       !latestData.reqMoldTime ||
-    //       new Date(data.reqMoldTime) >= new Date(latestData.reqMoldTime)
-    //     ) {
-    //       latestData = data;
-    //     }
-    //   }
-    //   this.form.reqMoldTime = latestData.reqMoldTime;
-
-    //   console.log(this.form, '1111111111111');
-
-    // },
-
-    sortTop(row) {
-      row.priority = Number(row.priority) + 1;
-      this.priorityChange(row);
-    },
-    sortBottom(row) {
-      if (row.priority <= 1) {
-        return;
-      }
-      row.priority = Number(row.priority) - 1;
-      this.priorityChange(row);
-    },
-
-    priorityChange(row) {
-      if (row.priority > 10) {
-        row.priority = 10; // 如果大于 10,则设置为 10
-      } else if (row.priority < 0) {
-        row.priority = 0; // 如果小于 0,则设置为 0
-      }
-
-      this.priorityFn(row);
-    },
-
-    priorityFn: debounce(function (row) { }, 800),
+        row.priority = Number(row.priority) - 1;
+        this.priorityChange(row);
+      },
 
-    // 删除产品
-    handleDeleteItem(index) {
-      this.form.salesOrders.splice(index, 1);
-    },
-    addEquipment() {
-      this.$refs.additionalRefs.open(this.form.planType);
-    },
-    openVersion() {
-      this.$refs.versionRefs.open();
-    },
-    changeProduct(data) {
-      this.$set(this.form, 'produceRoutingName', data.name);
-      this.$set(this.form, 'produceRoutingId', data.id);
-      this.$set(this.form, 'produceVersionName', data.produceVersionName);
-    },
-    // 表格:模数、数量(方)、块数输入框 输入事件
-    tableHandleKeyUp(row, index, e, name) {
-      if (row.specification && this.clientEnvironmentId == '4') {
-        let modelArr = row.specification.split('*');
-        let modelLong = modelArr[0]; // model规格长度
-        let modeWide = modelArr[1]; // model规格宽度
-        let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
-        modeHight = Number(modeHight);
-        if (name === 'moCount') {
-          // 模数
-          row.moCount = e;
-          // 计算块数的公式:
-          // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
-          // 每一模的块数*模数moCount = 总块数
-          if (row.productName.includes('板材')) {
-            row.blockCount =
-              Math.floor(600 / modelLong) *
-              Math.floor(120 / modeHight) *
-              Math.floor(60 / modeWide) *
-              row.moCount;
-          } else if (row.productName.includes('砌块')) {
-            let modelLongFixed = (600 / modelLong).toFixed(2);
-            modelLongFixed = modelLongFixed.substring(
-              0,
-              modelLongFixed.length - 1
-            );
-            let modeWideFixed = (120 / modeWide).toFixed(2);
-            modeWideFixed = modeWideFixed.substring(
-              0,
-              modeWideFixed.length - 1
-            );
-            let modeHightFixed = (60 / modeHight).toFixed(2);
-            modeHightFixed = modeHightFixed.substring(
-              0,
-              modeHightFixed.length - 1
-            );
-            row.blockCount =
-              Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
-              row.moCount;
-          }
+      priorityChange(row) {
+        if (row.priority > 10) {
+          row.priority = 10; // 如果大于 10,则设置为 10
+        } else if (row.priority < 0) {
+          row.priority = 0; // 如果小于 0,则设置为 0
+        }
 
-          row.planProductNum =
-            Number((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
-            row.blockCount;
-        } else if (name === 'sum') {
+        this.priorityFn(row);
+      },
 
-          //方数
-          row.planProductNum = e;
+      priorityFn: debounce(function (row) {}, 800),
 
-          row.blockCount = Math.floor(
-            e / ((modelLong * modeWide * modeHight) / 1000000)
-          );
-          if (row.productName.includes('板材')) {
-            row.moCount = Math.ceil(
-              row.blockCount /
-              (Math.floor(600 / modelLong) *
-                Math.floor(120 / modeHight) *
-                Math.floor(60 / modeWide))
-            );
-          } else if (row.productName.includes('砌块')) {
-            row.moCount = Math.ceil(
-              row.blockCount /
-              Math.floor(
-                (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
-              )
-            );
-          }
-        } else if (name === 'blockCount') {
-          //块数
-          row.blockCount = e;
-
-          if (row.productName.includes('板材')) {
-            row.moCount = Math.ceil(
-              row.blockCount /
-              (Math.floor(600 / modelLong) *
+      // 删除产品
+      handleDeleteItem(index) {
+        this.form.salesOrders.splice(index, 1);
+      },
+      addEquipment() {
+        this.$refs.additionalRefs.open(this.form.planType);
+      },
+      openVersion() {
+        this.$refs.versionRefs.open();
+      },
+      changeProduct(data) {
+        this.$set(this.form, 'produceRoutingName', data.name);
+        this.$set(this.form, 'produceRoutingId', data.id);
+        this.$set(this.form, 'produceVersionName', data.produceVersionName);
+      },
+      // 表格:模数、数量(方)、块数输入框 输入事件
+      tableHandleKeyUp(row, index, e, name) {
+        if (row.specification && this.clientEnvironmentId == '4') {
+          let modelArr = row.specification.split('*');
+          let modelLong = modelArr[0]; // model规格长度
+          let modeWide = modelArr[1]; // model规格宽度
+          let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
+          modeHight = Number(modeHight);
+          if (name === 'moCount') {
+            // 模数
+            row.moCount = e;
+            // 计算块数的公式:
+            // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
+            // 每一模的块数*模数moCount = 总块数
+            if (row.productName.includes('板材')) {
+              row.blockCount =
+                Math.floor(600 / modelLong) *
                 Math.floor(120 / modeHight) *
-                Math.floor(60 / modeWide))
-            );
-          } else if (row.productName.includes('砌块')) {
-            row.moCount = Math.ceil(
-              row.blockCount /
-              Math.floor(
-                (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
-              )
+                Math.floor(60 / modeWide) *
+                row.moCount;
+            } else if (row.productName.includes('砌块')) {
+              let modelLongFixed = (600 / modelLong).toFixed(2);
+              modelLongFixed = modelLongFixed.substring(
+                0,
+                modelLongFixed.length - 1
+              );
+              let modeWideFixed = (120 / modeWide).toFixed(2);
+              modeWideFixed = modeWideFixed.substring(
+                0,
+                modeWideFixed.length - 1
+              );
+              let modeHightFixed = (60 / modeHight).toFixed(2);
+              modeHightFixed = modeHightFixed.substring(
+                0,
+                modeHightFixed.length - 1
+              );
+              row.blockCount =
+                Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
+                row.moCount;
+            }
+
+            row.planProductNum =
+              Number((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
+              row.blockCount;
+          } else if (name === 'sum') {
+            //方数
+            row.planProductNum = e;
+
+            row.blockCount = Math.floor(
+              e / ((modelLong * modeWide * modeHight) / 1000000)
             );
+            if (row.productName.includes('板材')) {
+              row.moCount = Math.ceil(
+                row.blockCount /
+                  (Math.floor(600 / modelLong) *
+                    Math.floor(120 / modeHight) *
+                    Math.floor(60 / modeWide))
+              );
+            } else if (row.productName.includes('砌块')) {
+              row.moCount = Math.ceil(
+                row.blockCount /
+                  Math.floor(
+                    (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
+                  )
+              );
+            }
+          } else if (name === 'blockCount') {
+            //块数
+            row.blockCount = e;
+
+            if (row.productName.includes('板材')) {
+              row.moCount = Math.ceil(
+                row.blockCount /
+                  (Math.floor(600 / modelLong) *
+                    Math.floor(120 / modeHight) *
+                    Math.floor(60 / modeWide))
+              );
+            } else if (row.productName.includes('砌块')) {
+              row.moCount = Math.ceil(
+                row.blockCount /
+                  Math.floor(
+                    (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
+                  )
+              );
+            }
+
+            row.planProductNum =
+              (Number(e) * modelLong * modeWide * modeHight) / 1000000;
           }
-
-          row.planProductNum =
-            (Number(e) * modelLong * modeWide * modeHight) / 1000000;
         }
-      }
 
-      row.requiredFormingNum = Number(row.planProductNum * (this.form.marginCoefficient || 1)).toFixed(5);
-
-    },
-    confirmChoose(list) {
-      // 取出在弹窗中选中并且不在表格中的数据
-      const result = list.filter(
-        (i) => this.form.salesOrders.findIndex((p) => p.id === i.id) === -1
-      );
-      // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
-      const del = this.form.salesOrders.filter(
-        (i) => list.findIndex((p) => p.id === i.id) === -1
-      );
-      for (let i = this.form.salesOrders.length - 1; i >= 0; i--) {
-        for (let j in del) {
-          if (this.form.salesOrders[i].id === del[j].id) {
-            this.form.salesOrders.splice(i, 1);
+        row.requiredFormingNum = Number(
+          row.planProductNum * (this.form.marginCoefficient || 1)
+        ).toFixed(5);
+      },
+      confirmChoose(list) {
+        // 取出在弹窗中选中并且不在表格中的数据
+        const result = list.filter(
+          (i) => this.form.salesOrders.findIndex((p) => p.id === i.id) === -1
+        );
+        // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
+        const del = this.form.salesOrders.filter(
+          (i) => list.findIndex((p) => p.id === i.id) === -1
+        );
+        for (let i = this.form.salesOrders.length - 1; i >= 0; i--) {
+          for (let j in del) {
+            if (this.form.salesOrders[i].id === del[j].id) {
+              this.form.salesOrders.splice(i, 1);
+            }
           }
         }
-      }
-      let priority =
-        this.form.salesOrders[this.form.salesOrders.length - 1]?.priority || 0;
-      this.form.salesOrders = this.form.salesOrders.concat(
-        result.map((item, index) => {
-          item.priority = ++priority;
-
-          item.planProductNum = item.lackNum;
-          item.requiredFormingNum = item.lackNum;
-          item.reqMoldTime = dayjs(
-            new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
-          ).format('YYYY-MM-DD');
-          return item;
-        })
-      );
-      this.changeData();
-    },
-    changeData() {
-      var planProductNum = 0;
-      var productWeight = 0;
-
-      this.form.salesOrders.map((item, index) => {
-        item.priority = index + 1;
-        planProductNum = planProductNum + item.requiredFormingNum;
-        productWeight = productWeight + Number(item.productSumWeight);
-      });
-      this.$set(this.form, 'codeNum', this.form.salesOrders.length);
-      this.$set(this.form, 'contractNum', planProductNum);
-      this.$set(this.form, 'sumOrderWeight', productWeight.toFixed(2));
-    },
+        let priority =
+          this.form.salesOrders[this.form.salesOrders.length - 1]?.priority ||
+          0;
+        this.form.salesOrders = this.form.salesOrders.concat(
+          result.map((item, index) => {
+            item.priority = ++priority;
 
-    async publishData(type) {
-      const key = getRouteTabKey();
-      let params = deepClone(this.form);
-      params.categoryId = params.salesOrders[0]?.categoryId;
-      if (this.$route.query.type != 'edit') {
-        delete params.id;
-      }
+            item.planProductNum = item.lackNum;
+            item.requiredFormingNum = item.lackNum;
+            item.reqMoldTime = dayjs(
+              new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
+            ).format('YYYY-MM-DD');
+            return item;
+          })
+        );
+        this.changeData();
+      },
+      changeData() {
+        var planProductNum = 0;
+        var productWeight = 0;
 
-      if (type === 2) {
-        this.$confirm('发布工单后不可撤回,确定发布吗?', '发布确认').then(
-          async () => {
-            const loading = this.$loading({
-              lock: true,
-              fullscreen: true,
-              text: '工单发布中...'
-            });
-            try {
-              const code = await getCode('product_order_code');
-              const data = {
-                productionPlan: params,
-                workOrder: {
-                  productionPlanCode: params.code,
-                  code: code,
-                  // formingNum: params.contractNum,
-                  formingNum: this.form.requiredFormingNum,
-                  formingWeight: params.sumOrderWeight,
-                  produceRoutingId: params.produceRoutingId,
-                  status: 4,
-                  model: params.model,
-                  brandNo: params.brandNo,
-                  categoryId: params.categoryId,
-                  productCode: params.productCode,
-                  productName: params.productName,
-
-                  newWeightUnit: this.form.newWeightUnit,
-                  newSumOrderWeight: this.form.newSumOrderWeight
+        this.form.salesOrders.map((item, index) => {
+          item.priority = index + 1;
+          planProductNum = planProductNum + item.requiredFormingNum;
+          productWeight = productWeight + Number(item.productSumWeight);
+        });
+        this.$set(this.form, 'codeNum', this.form.salesOrders.length);
+        this.$set(this.form, 'contractNum', planProductNum);
+        this.$set(this.form, 'sumOrderWeight', productWeight.toFixed(2));
+      },
+
+      async publishData(type) {
+        const key = getRouteTabKey();
+        let params = deepClone(this.form);
+        params.categoryId = params.salesOrders[0]?.categoryId;
+        if (this.$route.query.type != 'edit') {
+          delete params.id;
+        }
+
+        if (type === 2) {
+          this.$confirm('发布工单后不可撤回,确定发布吗?', '发布确认').then(
+            async () => {
+              const loading = this.$loading({
+                lock: true,
+                fullscreen: true,
+                text: '工单发布中...'
+              });
+              try {
+                const code = await getCode('product_order_code');
+                const data = {
+                  productionPlan: params,
+                  workOrder: {
+                    productionPlanCode: params.code,
+                    code: code,
+                    // formingNum: params.contractNum,
+                    formingNum: this.form.requiredFormingNum,
+                    formingWeight: params.sumOrderWeight,
+                    produceRoutingId: params.produceRoutingId,
+                    status: 4,
+                    model: params.model,
+                    brandNo: params.brandNo,
+                    categoryId: params.categoryId,
+                    productCode: params.productCode,
+                    productName: params.productName,
+
+                    newWeightUnit: this.form.newWeightUnit,
+                    newSumOrderWeight: this.form.newSumOrderWeight
+                  }
+                };
+                if (this.$route.query.type == 'edit') {
+                  data.workOrder.productionPlanId = params.id;
                 }
-              };
-              if (this.$route.query.type == 'edit') {
-                data.workOrder.productionPlanId = params.id;
-              }
-              console.log(data);
-              await releaseSave(data)
-                .then((res) => {
-                  if (res === 1) {
-                    this.$message.success('工单已发布!');
-                    this.$router.push({
-                      path: '/productionPlan'
-                    });
-                  } else {
-                    this.$confirm(
-                      '生产计划创建成功,但工单发布失败。请前往【生产计划】列表【重新发布】工单',
-                      '提示',
-                      {
-                        confirmButtonText: '返回',
-                        cancelButtonText: '立即前往',
-                        type: 'warning'
-                      }
-                    )
-                      .then(() => {
-                        this.$router.push({
-                          path: '/productionPlan'
-                        });
-                      })
-                      .catch(() => {
-                        this.$router.go(-1);
+                console.log(data);
+                await releaseSave(data)
+                  .then((res) => {
+                    if (res === 1) {
+                      this.$message.success('工单已发布!');
+                      this.$router.push({
+                        path: '/productionPlan'
                       });
-                  }
-                  removePageTab({ key });
-                })
-                .catch(() => {
-                  this.$message.error('发布失败,请重新发布!');
-                });
-            } catch (error) { }
-
-            loading.close();
-          }
-        );
-      } else {
-        let request =
-          this.$route.query.type == 'edit' ? updateSaleToPlan : saveSaleToPlan;
-
-        request(params)
-          .then(async (res) => {
-            // 提交
-            this.$router.push({
-              path: '/productionPlan'
+                    } else {
+                      this.$confirm(
+                        '生产计划创建成功,但工单发布失败。请前往【生产计划】列表【重新发布】工单',
+                        '提示',
+                        {
+                          confirmButtonText: '返回',
+                          cancelButtonText: '立即前往',
+                          type: 'warning'
+                        }
+                      )
+                        .then(() => {
+                          this.$router.push({
+                            path: '/productionPlan'
+                          });
+                        })
+                        .catch(() => {
+                          this.$router.go(-1);
+                        });
+                    }
+                    removePageTab({ key });
+                  })
+                  .catch(() => {
+                    this.$message.error('发布失败,请重新发布!');
+                  });
+              } catch (error) {}
+
+              loading.close();
+            }
+          );
+        } else {
+          let request =
+            this.$route.query.type == 'edit'
+              ? updateSaleToPlan
+              : saveSaleToPlan;
+
+          request(params)
+            .then(async (res) => {
+              // 提交
+              this.$router.push({
+                path: '/productionPlan'
+              });
+              removePageTab({ key });
+            })
+            .catch(() => {
+              this.$message.error('提交失败,请重新提交!');
             });
-            removePageTab({ key });
-          })
-          .catch(() => {
-            this.$message.error('提交失败,请重新提交!');
-          });
+        }
+      },
+      // 打开工艺路线
+      openDialog() {
+        // this.selectIndex = index;
+        this.$refs.processRouteRef.open();
+      },
+      // 选择工艺路线
+      changeParent(item) {
+        this.routingList = [];
+        this.bomVersionList = [];
+        this.$set(this.form, 'bomCategoryId', null);
+        this.$set(this.form, 'model', '');
+        this.$set(this.form, 'produceType', '');
+        this.$set(this.form, 'produceRoutingName', item.name);
+        this.$set(this.form, 'produceRoutingId', item.id);
+        this.form.bomCategoryName = '';
+        this.form.bomCategoryVersions = '';
+        this.selectionRowShow = true;
       }
     }
-  }
-};
+  };
 </script>
 <style lang="scss" scoped>
-.ele-body {
-  background: #fff;
-}
-
-.body-title {
-  width: 100%;
-  display: flex;
-  align-items: center;
-  justify-content: space-between;
-}
-
-.title-left {
-  font-size: 20px;
-  color: #333;
-}
-
-.formbox {
-  margin: 20px auto;
-}
-
-.row-intro {
-  border-bottom: 1px dashed #ccc;
-  margin-bottom: 20px;
-}
-
-.add-product {
-  width: 100%;
-  display: flex;
-  align-items: center;
-  justify-content: flex-end;
-  font-size: 30px;
-  color: #1890ff;
-  margin: 10px 0;
-  cursor: pointer;
-}
-
-.table-item {
-  margin-bottom: 0;
-}
+  .ele-body {
+    background: #fff;
+  }
+
+  .body-title {
+    width: 100%;
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+  }
+
+  .title-left {
+    font-size: 20px;
+    color: #333;
+  }
+
+  .formbox {
+    margin: 20px auto;
+  }
+
+  .row-intro {
+    border-bottom: 1px dashed #ccc;
+    margin-bottom: 20px;
+  }
+
+  .add-product {
+    width: 100%;
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    font-size: 30px;
+    color: #1890ff;
+    margin: 10px 0;
+    cursor: pointer;
+  }
+
+  .table-item {
+    margin-bottom: 0;
+  }
+
+    .header_required {
+    position: relative;
+  }
+
+  .header_required:before {
+    content: '*';
+    color: #f56c6c;
+    position: absolute;
+    top: 11px;
+    left: 15px;
+  }
+
 </style>

Файловите разлики са ограничени, защото са твърде много
+ 712 - 410
src/views/saleOrder/salesToProductionNewTwo.vue


+ 16 - 32
src/views/workOrder/components/releaseDialog.vue

@@ -129,11 +129,7 @@
             </el-select>
           </el-form-item>
 
-          <el-form-item
-            label="人员:"
-            prop="crewIds"
-            v-if="form.assignType == 2"
-          >
+          <el-form-item label="人员:" v-if="form.assignType == 2">
             <el-select
               class="ele-block"
               v-model="form.crewIds"
@@ -152,12 +148,7 @@
             </el-select>
           </el-form-item>
 
-          <el-form-item
-            label="产线:"
-            prop="crewIds"
-            v-if="form.assignType == 3"
-            required
-          >
+          <el-form-item label="产线:" v-if="form.assignType == 3" required>
             <el-select
               class="ele-block"
               v-model="form.factoryLineIds"
@@ -302,7 +293,7 @@
                   @change="handleStartTimeChange(row)"
                   :picker-options="{
                     disabledDate: (time) => {
-                      const end = row.planCompleteTime;
+                      const end = row.endTime;
                       if (!end) return false; // 无结束时间,不禁用
                       // 将结束时间和当前时间都转换为“当天0点”,仅比较年月日
                       const endDay = new Date(end);
@@ -325,7 +316,7 @@
                   placeholder="完成时间"
                   :picker-options="{
                     disabledDate: (time) => {
-                      const start = row.planStartTime;
+                      const start = row.startTime;
                       if (!start) return false; // 无开始时间,不禁用
                       // 将开始时间和当前时间都转换为“当天0点”,仅比较年月日
                       const startDay = new Date(start);
@@ -336,7 +327,7 @@
                     },
                     // 新增:限制同一天内的时间必须晚于开始时间
                     disabledTime: (date) => {
-                      const start = row.planStartTime;
+                      const start = row.startTime;
                       if (!start) {
                         return {
                           disabledHours: () => [],
@@ -411,6 +402,7 @@
 </template>
 
 <script>
+
   import {
     listByFirstTaskId,
     listUserByIds,
@@ -538,7 +530,6 @@
             type: 'index',
             width: 55,
             align: 'center',
-            showOverflowTooltip: true,
             fixed: 'left'
           },
           {
@@ -552,21 +543,18 @@
             prop: 'name',
             label: this.dynamicName,
             align: 'center',
-            showOverflowTooltip: true,
             width: 200
           },
           {
             prop: 'code',
             label: '编码',
             align: 'center',
-            showOverflowTooltip: true,
             width: 200
           },
           {
             prop: 'status',
             label: '状态',
             align: 'center',
-            showOverflowTooltip: true,
             width: 150,
             formatter: (row) => {
               if (!row.status) return '';
@@ -578,7 +566,6 @@
             prop: 'quantity',
             label: '数量',
             align: 'center',
-            showOverflowTooltip: true,
             width: 140
           },
           {
@@ -586,7 +573,6 @@
             prop: 'weight',
             label: `重量(${this.current.newWeightUnit})`,
             align: 'center',
-            showOverflowTooltip: true,
             width: 140
           },
           {
@@ -594,15 +580,13 @@
             prop: 'teamTimeDetailId',
             label: '班次',
             align: 'center',
-            showOverflowTooltip: true,
-            minWidth: 140
+            minWidth: 150
           },
           {
             slot: 'startTime',
             prop: 'startTime',
             label: '计划开始时间',
             align: 'center',
-            showOverflowTooltip: true,
             minWidth: 240
           },
           {
@@ -610,7 +594,6 @@
             prop: 'endTime',
             label: '计划完成时间',
             align: 'center',
-            showOverflowTooltip: true,
             minWidth: 240
           },
           {
@@ -1339,14 +1322,15 @@
         this.checkEndTimeValid(row);
       },
 
-      setSurplus() {
-        this.form.surplusUnpack.push({
-          originalCode: this.formData.code,
-          formingNum: this.formData.formingNum,
-          planStartTime: this.formData.planStartTime,
-          planCompleteTime: this.formData.planCompleteTime,
-          isCopy: 1
-        });
+      checkEndTimeValid(row) {
+        const { startTime: start, endTime: end } = row;
+        if (!start || !end) return; // 开始/结束时间未填,跳过
+        const startTime = new Date(start);
+        const endTime = new Date(end);
+        if (endTime < startTime) {
+          row.endTime = new Date(startTime); // 修正为开始时间
+          this.$message.info('结束时间不能早于开始时间,已自动设为开始时间');
+        }
       }
     }
   };

Някои файлове не бяха показани, защото твърде много файлове са промени