Răsfoiți Sursa

新增批量发布

695593266@qq.com 1 lună în urmă
părinte
comite
4582c66845
1 a modificat fișierele cu 60 adăugiri și 0 ștergeri
  1. 60 0
      src/views/productionPlan/index.vue

+ 60 - 0
src/views/productionPlan/index.vue

@@ -146,6 +146,16 @@
           @click="handleMerge"
           @click="handleMerge"
           >合批</el-button
           >合批</el-button
         >
         >
+        <el-button
+          type="primary"
+          size="mini"
+          v-if="
+            activeName == 'first' &&
+            $hasPermission('aps:productionplan:batchRelease')
+          "
+          @click="handleBatchRelease"
+          >批量发布</el-button
+        >
         <el-button
         <el-button
           type="danger"
           type="danger"
           size="mini"
           size="mini"
@@ -1180,6 +1190,56 @@
           ...this.sort
           ...this.sort
         });
         });
       },
       },
+      // 批量发布
+      handleBatchRelease() {
+        if (!this.selection || this.selection.length <= 0) {
+          return this.$message.warning('请至少勾选一条计划!');
+        }
+        const invalid = this.selection.filter(
+          (item) => Number(item.requiredFormingNum) < 0
+        );
+        if (invalid.length > 0) {
+          const codes = invalid
+            .map((item) => item.code)
+            .filter((c) => c != null && c !== '')
+            .join('、');
+          return this.$message.warning(
+            `计划编码【${codes || '未知'}】计划生产数量不能小于0!`
+          );
+        }
+
+        const titleText = this.isReview
+          ? '是否发起流程'
+          : '发布工单后不可撤回,确定批量发布吗?';
+        const title = this.isReview ? '流程确认' : '发布确认';
+        const text = this.isReview ? '流程发布中...' : '工单发布中...';
+
+        this.$confirm(titleText, title)
+          .then(async () => {
+            const loading = this.$loading({
+              lock: true,
+              fullscreen: true,
+              text
+            });
+            try {
+              const URL = this.isReview ? releaseByApproval : release;
+              const ids = this.selection.map((item) => item.id);
+              const data = await URL(ids);
+              if (data || data === 0) {
+                this.$message.success('发布成功!');
+              } else {
+                this.$message.error('发布失败,请重新发布!');
+              }
+              this.reload();
+            } catch (error) {
+              console.error(error);
+            }
+            loading.close();
+          })
+          .catch((err) => {
+            console.error(err);
+          });
+      },
       // 发布工单
       // 发布工单
       handleOrderPublish(type, row) {
       handleOrderPublish(type, row) {
         if (!row.produceRoutingName) {
         if (!row.produceRoutingName) {