Forráskód Böngészése

fix: 任务制定工作环节预置流转操作显示默认通过、归档点击确定的时候加校验

shiyanyu 1 hónapja
szülő
commit
9f8d857932

+ 51 - 0
src/views/costAudit/projectInfo/auditTaskManage/taskCustomizedRelease/workflowTab.vue

@@ -526,6 +526,26 @@
       handleSaveStep(formName, type) {
         this.$refs[formName].validate((valid) => {
           if (valid) {
+            // 校验当前环节预置流转操作
+            const needKey = this.isArchiveNode(this.formData.currentStep)
+              ? this.getProcessStatusKeyByName('归档')
+              : this.getProcessStatusKeyByName('通过')
+            const needName = this.isArchiveNode(this.formData.currentStep)
+              ? '归档'
+              : '通过'
+            const statusArr = Array.isArray(this.formData.currentStep.status)
+              ? this.formData.currentStep.status
+              : []
+            if (needKey && !statusArr.includes(needKey)) {
+              const stepName =
+                this.formData.currentStep.processNodeValue ||
+                this.formData.currentStep.processNodeKey ||
+                ''
+              this.$message.error(
+                `流程环节【${stepName}】预置流转操作必须包含“${needName}”`
+              )
+              return
+            }
             if (type == 'list') {
               this.workflowData.list = this.workflowData.list.map((item) => {
                 if (
@@ -593,6 +613,37 @@
             }
           }
         }
+
+        // 验证每个环节的预置流转操作(归档需“归档”,其余需“通过”)
+        const listToCheck =
+          type === 'list'
+            ? this.workflowData.list.map((it) => ({
+                ...it,
+                statusArr:
+                  typeof it.status === 'string' && it.status
+                    ? it.status.split(',')
+                    : Array.isArray(it.status)
+                    ? it.status
+                    : [],
+              }))
+            : this.workflowData.stepList.map((it) => ({
+                ...it,
+                statusArr: Array.isArray(it.status) ? it.status : [],
+              }))
+        for (const it of listToCheck) {
+          const needKey = this.isArchiveNode(it)
+            ? this.getProcessStatusKeyByName('归档')
+            : this.getProcessStatusKeyByName('通过')
+          const needName = this.isArchiveNode(it) ? '归档' : '通过'
+          if (needKey && !it.statusArr.includes(needKey)) {
+            const stepName = it.processNodeValue || it.processNodeKey || ''
+            this.$message.error(
+              `流程环节【${stepName}】预置流转操作必须包含“${needName}”`
+            )
+            return
+          }
+        }
+
         this.loading.save = true
         let data = {
           nodeReqList: [