jingshuyong 11 месяцев назад
Родитель
Сommit
4d5328a56e

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

@@ -34,7 +34,6 @@ export async function listByWorkCenterId(workCenterId) {
 }
 
 // 根据班组ids查所有人信息
-
 export async function listUserByIds(data) {
   const res = await request.post('/main/team/listUserByIds', data);
   if (res.data.code == 0) {

+ 10 - 1
src/api/workOrder/index.js

@@ -43,4 +43,13 @@ export async function splitBatch(data) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
-}
+}
+
+// 删除拆单数据 
+export async function unpackDel(id) {
+  const res = await request.delete(`/aps/workorder/delById/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 0 - 69
src/views/workOrder/components/releaseDialog.vue

@@ -298,18 +298,6 @@
                   value-format="yyyy-MM-dd HH:mm:ss"
                   placeholder="开始时间"
                   @change="handleStartTimeChange(row, item)"
-                  :picker-options="{
-                    disabledDate: (time) => {
-                      const end = row.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点更晚时禁用
-                    }
-                  }"
                 ></el-date-picker>
               </template>
               <template v-slot:endTime="{ row }">
@@ -321,63 +309,6 @@
                   value-format="yyyy-MM-dd HH:mm:ss"
                   @change="handleEndTimeChange(row, item)"
                   placeholder="完成时间"
-                  :picker-options="{
-                    disabledDate: (time) => {
-                      const start = row.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点更早时禁用
-                    },
-                    // 新增:限制同一天内的时间必须晚于开始时间
-                    disabledTime: (date) => {
-                      const start = row.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: () => []
-                        };
-                      }
-                    }
-                  }"
                 ></el-date-picker>
               </template>
 

+ 71 - 47
src/views/workOrder/components/unpackDialog.vue

@@ -164,7 +164,6 @@
               :rules="{
                 required: true,
                 message: '请选择开始计划时间',
-
                 trigger: 'change'
               }"
             >
@@ -285,8 +284,10 @@
       </el-form>
     </div>
     <div slot="footer">
-      <el-button plain @click="cancel">取消</el-button>
-      <el-button type="primary" @click="confirm">确定</el-button>
+      <el-button plain @click="cancel" :loading="loading">取消</el-button>
+      <el-button type="primary" @click="confirm" :loading="loading"
+        >确定</el-button
+      >
     </div>
   </ele-modal>
 </template>
@@ -300,7 +301,6 @@
     data() {
       return {
         visible: false,
-
         formData: {},
         requestData: {
           deviceCode: '',
@@ -308,7 +308,7 @@
           deviceId: ''
         },
         formingNum: 0,
-
+        storageNum: 0,
         form: {
           surplusUnpack: [],
           unpackList: []
@@ -324,7 +324,6 @@
             }
           }
         },
-
         pickerOptionsEnd: {
           disabledDate: (time) => {
             // 根据某个条件动态设置最大日期
@@ -336,9 +335,7 @@
             }
           }
         },
-
         rules: {},
-
         columns: [
           {
             prop: 'originalCode',
@@ -368,7 +365,6 @@
             minWidth: 200
           }
         ],
-
         columns2: [
           {
             prop: 'originalCode',
@@ -407,20 +403,32 @@
             slot: 'action',
             showOverflowTooltip: true
           }
-        ]
+        ],
+        loading: false
       };
     },
     methods: {
       open(row) {
         this.visible = true;
         this.formData = deepClone(row);
-        this.formingNum = this.formData.formingNum;
-
+        this.formingNum = this.residualVal();
+        this.storageNum = this.residualVal();
         this.form.surplusUnpack = [];
         this.form.unpackList = [];
         this.setSurplus();
       },
 
+      // 要求生产数量( 剩余值 )
+      residualVal() {
+        if (this.formData.splitResidue) {
+          return this.formData.splitResidue;
+        }
+        if (this.formData.splitResidue === 0) {
+          return 0;
+        }
+        return this.formData.formingNum;
+      },
+
       checkEndTimeValid(row) {
         const { planStartTime: start, planCompleteTime: end } = row;
         if (!start || !end) return; // 开始/结束时间未填,跳过
@@ -445,7 +453,8 @@
       setSurplus() {
         this.form.surplusUnpack.push({
           originalCode: this.formData.code,
-          formingNum: this.formData.formingNum,
+          // formingNum: this.formData.formingNum,
+          formingNum: this.residualVal(),
           planStartTime: this.formData.planStartTime,
           planCompleteTime: this.formData.planCompleteTime,
           isCopy: 1
@@ -463,11 +472,11 @@
 
       surplusUnpackFn(index) {
         console.log(this.form.unpackList);
-        console.log(index, '------------------');
       },
 
       changeNum(index) {
-        let num = this.formData.formingNum;
+        // let num = this.formData.formingNum;
+        let num = this.storageNum;
         this.form.unpackList.forEach((e) => {
           if (e.formingNum != null && e.formingNum != undefined) {
             num = num - Number(e.formingNum);
@@ -496,17 +505,15 @@
             }
           });
           if (total == 0) {
-            this.formingNum = this.formData.formingNum;
+            this.formingNum = this.storageNum;
           }
-          console.log(this.formData.formingNum, '-----');
-          console.log(total, 'total 1234');
         });
       },
 
       remove(index) {
         this.form.unpackList.splice(index, 1);
         if (this.form.unpackList.length == 0) {
-          this.formingNum = this.formData.formingNum;
+          this.formingNum = this.storageNum;
         } else {
           this.changeNum(index);
         }
@@ -519,37 +526,54 @@
       },
 
       confirm() {
+        if (this.form.unpackList.length === 0) {
+          return this.$message.warning('请至少有一条拆单数据');
+        }
         this.$refs.form.validate(async (value) => {
           if (value) {
-            if (
-              this.form.unpackList.length == 1 &&
-              this.form.unpackList[0].formingNum == this.formData.formingNum
-            ) {
-              this.$message.info('拆单数要大于1');
-              return false;
+            // if (
+            //   this.form.unpackList.length == 1 &&
+            //   this.form.unpackList[0].formingNum == this.formData.formingNum
+            // ) {
+            //   this.$message.info('拆单数要大于1');
+            //   return false;
+            // }
+
+            // if (
+            //   this.form.surplusUnpack.length == 1 &&
+            //   this.form.unpackList.length == 0
+            // ) {
+            //   this.$message.info('拆单数要大于1');
+            //   return false;
+            // }
+
+            // let params = [];
+            // if (this.formingNum != 0) {
+            //   this.form.surplusUnpack[0].formingNum = this.formingNum;
+            //   params = [...this.form.unpackList, ...this.form.surplusUnpack];
+            // } else {
+            //   params = this.form.unpackList;
+            // }
+            for (let i = 0; i < this.form.unpackList.length; i++) {
+              let item = this.form.unpackList[i];
+              if (item.formingNum == 0) {
+                this.$message.warning(`第${i + 1}条拆单要求生产数据不能为0`);
+                return;
+              }
             }
-
-            if (
-              this.form.surplusUnpack.length == 1 &&
-              this.form.unpackList.length == 0
-            ) {
-              this.$message.info('拆单数要大于1');
-              return false;
-            }
-
-            let params = [];
-            if (this.formingNum != 0) {
-              this.form.surplusUnpack[0].formingNum = this.formingNum;
-              params = [...this.form.unpackList, ...this.form.surplusUnpack];
-            } else {
-              params = this.form.unpackList;
-            }
-
-            const res = await splitBatch(params);
-            if (res) {
-              this.$message.success('拆分成功!');
-              this.$emit('success');
-              this.cancel();
+            this.form.surplusUnpack[0].formingNum = this.formingNum;
+            let params = [...this.form.unpackList, ...this.form.surplusUnpack];
+            try {
+              this.loading = true;
+              const res = await splitBatch(params);
+              this.loading = false;
+              if (res) {
+                this.$message.success('拆分成功!');
+                this.$emit('success');
+                this.cancel();
+              }
+            } catch (err) {
+              this.loading = false;
             }
           }
         });

+ 46 - 47
src/views/workOrder/index.vue

@@ -57,7 +57,12 @@
           ></el-checkbox>
         </template>
         <template v-slot:code="{ row }">
-          {{ row.code }}
+          <el-link type="primary" :underline="false" style="padding-left: 16px">
+            <el-tag type="success" size="mini" v-if="row.originalCode">
+              拆</el-tag
+            >
+            {{ row.code }}
+          </el-link>
         </template>
         <template v-slot:formingWeight="{ row }">
           {{ row.formingWeight }} {{ row.newWeightUnit }}
@@ -95,52 +100,13 @@
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
           <el-link
-            v-if="
-              (clientEnvironmentId != '4' && row.status == 8) ||
-              (clientEnvironmentId == '4' &&
-                !row.productName.includes('板材') &&
-                row.status == 8)
-            "
+            v-if="unpackShow(row)"
             :underline="false"
             type="primary"
             @click="toUnpack(row)"
           >
             拆单
           </el-link>
-
-          <!-- <el-link
-            type="primary"
-            :underline="false"
-            icon="el-icon-truck"
-            @click="toRelease(row)"
-            v-if="
-              (row.isSplit != 1 &&
-                clientEnvironmentId != '4' &&
-                row.status == 8) ||
-              (clientEnvironmentId == '4' &&
-                !row.productName.includes('板材') &&
-                row.status == 8)
-            "
-          >
-            派单
-          </el-link> -->
-          <!-- <el-link
-            type="primary"
-            :underline="false"
-            icon="el-icon-truck"
-            @click="toRelease(row)"
-            v-if="
-              (row.isSplit != 1 &&
-                clientEnvironmentId != '4' &&
-                row.status == 8) ||
-              (clientEnvironmentId == '4' &&
-                !row.productName.includes('板材') &&
-                row.status == 8)
-            "
-          >
-            派单12
-          </el-link> -->
-
           <el-link
             v-if="dispatchPermission(row)"
             :underline="false"
@@ -150,6 +116,18 @@
           >
             派单
           </el-link>
+          <el-popconfirm
+            class="ele-action"
+            title="确定要删除此子单吗?"
+            @confirm="remove(row)"
+            v-if="row.originalCode"
+          >
+            <template v-slot:reference>
+              <el-link type="danger" :underline="false" icon="el-icon-delete">
+                删除
+              </el-link>
+            </template>
+          </el-popconfirm>
         </template>
       </ele-pro-table>
     </el-card>
@@ -265,7 +243,8 @@
   import {
     getList,
     releaseWorkOrder,
-    updatePriority
+    updatePriority,
+    unpackDel
   } from '@/api/workOrder/index.js';
   import {
     listByFirstTaskId,
@@ -357,6 +336,18 @@
           );
         };
       },
+      // 拆单按钮显示
+      unpackShow() {
+        return (row) => {
+          if (row.originalCode) return false;
+          return (
+            (this.clientEnvironmentId != '4' && row.status == 8) ||
+            (this.clientEnvironmentId == '4' &&
+              !row.productName.includes('板材') &&
+              row.status == 8)
+          );
+        };
+      },
       teamId() {
         return this.$store.state.user.info.teamId;
       },
@@ -394,7 +385,7 @@
             slot: 'code',
             label: '生产订单号',
             align: 'center',
-            minWidth: 210,
+            minWidth: 220,
             sortable: true
           },
           {
@@ -542,7 +533,6 @@
           }
         ];
       },
-
       checkRowData() {
         return (row) => {
           return row.checkedata ? true : false;
@@ -552,7 +542,6 @@
     created() {
       this.getFieldModel();
     },
-
     methods: {
       // 单选数据
       selectRow(e, row) {
@@ -581,7 +570,17 @@
         }
         this.$refs.batchRef.open(list);
       },
-      assignTypeFn(e) {},
+
+      // 删除拆单数据
+      remove(row) {
+        unpackDel(row.id).then((res) => {
+          if (res) {
+            this.$message.success('操作成功');
+            this.createSuccess();
+          }
+        });
+      },
+      // assignTypeFn(e) {},
       statusFormatter(status) {
         const obj = this.statusOpt.find((i) => i.value == status);
         return obj && obj.label;
@@ -622,7 +621,7 @@
             {
               columnKey: 'action',
               label: '操作',
-              width: 120,
+              width: 140,
               align: 'center',
               resizable: false,
               fixed: 'right',