Эх сурвалжийг харах

添加流程图任务行业分类/添加节点名和script脚本表单校验

lph 1 жил өмнө
parent
commit
09bf067813

+ 21 - 3
ruoyi-ui/src/utils/bpmn/formDataValidate.js

@@ -1,13 +1,31 @@
+import { customTranslate } from "@packages/additional-modules/Translate";
+
 export function formDataValidate(obj) {
+  let res = {
+    flag: true
+  };
   let { rootElements } = obj.rootElement
+  // 流程名称不能为空
   if (!rootElements[0].name) {
     return {
       flag: false,
       msg: '流程名称为必填项!'
     }
   }
-
-  return {
-    flag: true,
+  // 校验节点名不能为空
+  try {
+    rootElements[0].flowElements.forEach(item => {
+      console.log(item);
+      if (!item.name) {
+        res.flag = false;
+        res.msg = `${customTranslate(item.$type.split(':')[1])}的节点名不能为空!`
+        console.log(res);
+        throw 'find Error'
+      }
+    })
+  } catch (error) {
+    console.log(error);
   }
+
+  return res
 }

+ 43 - 5
ruoyi-ui/src/views/bpmprocess/scriptManage.vue

@@ -123,6 +123,11 @@
           {{ getDictLabel(scope.row.scriptType, dict.type.bpm_script_type) }}
         </template>
       </el-table-column>
+      <el-table-column label="行业类型" align="center" prop="industryType">
+        <template slot-scope="scope">
+          {{ getDictLabel(scope.row.industryType, dict.type.industry_type) }}
+        </template>
+      </el-table-column>
       <el-table-column
         label="脚本描述"
         align="center"
@@ -164,19 +169,18 @@
 
     <!-- 添加或修改流程节点脚本对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
-      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
         <!-- <el-form-item label="脚本编码:" prop="scriptKey">
           <el-input v-model="form.scriptKey" placeholder="请输入脚本编码" />
         </el-form-item> -->
         <el-form-item label="脚本名称:" prop="scriptName">
           <el-input v-model="form.scriptName" placeholder="请输入脚本名称" />
         </el-form-item>
-        <el-form-item label="脚本类型:" prop="scriptName">
+        <el-form-item label="脚本类型:" prop="scriptType">
           <!-- <el-input v-model="form.scriptName" placeholder="请输入脚本名称" /> -->
           <el-select
             v-model="form.scriptType"
             placeholder="请选择脚本类型"
-            clearable
             filterable
           >
             <el-option
@@ -188,6 +192,21 @@
             </el-option>
           </el-select>
         </el-form-item>
+        <el-form-item label="行业类型:" prop="industryType">
+          <el-select
+            v-model="form.industryType"
+            placeholder="请选择行业类型"
+            filterable
+          >
+            <el-option
+              v-for="item in dict.type.industry_type"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value"
+            >
+            </el-option>
+          </el-select>
+        </el-form-item>
         <el-form-item label="方法名:" prop="scriptFunctionName">
           <el-input
             v-model="form.scriptFunctionName"
@@ -229,7 +248,7 @@ import uuid from "@/utils/bpmn/uuid";
 
 export default {
   name: "Script",
-  dicts: ["bpm_script_type"],
+  dicts: ["bpm_script_type", "industry_type"],
   data() {
     return {
       // 遮罩层
@@ -259,12 +278,29 @@ export default {
         scriptName: null,
         scriptFunctionCode: null,
         scriptType: null,
+        industryType: null,
         scriptDescription: null,
       },
       // 表单参数
       form: {},
       // 表单校验
-      rules: {},
+      rules: {
+        scriptName: [
+          { required: true, message: "请输入脚本名称", trigger: "blur" },
+        ],
+        scriptFunctionName: [
+          { required: true, message: "请输入脚本函数名", trigger: "blur" },
+        ],
+        scriptFunctionCode: [
+          { required: true, message: "请输入脚本函数体", trigger: "blur" },
+        ],
+        scriptType: [
+          { required: true, message: "请选择脚本类型", trigger: "change" },
+        ],
+        industryType: [
+          { required: true, message: "请选择脚本类型", trigger: "change" },
+        ],
+      },
     };
   },
   created() {
@@ -294,6 +330,7 @@ export default {
         scriptName: null,
         scriptFunctionCode: null,
         scriptType: null,
+        industryType: null,
         scriptDescription: null,
         delFlag: null,
         createBy: null,
@@ -330,6 +367,7 @@ export default {
       this.reset();
       const id = row.id || this.ids;
       getScript(id).then((response) => {
+        response.data.scriptType = response.data.scriptType.toString();
         this.form = response.data;
         this.open = true;
         this.title = "修改流程节点脚本";

+ 5 - 5
ruoyi-ui/src/views/system/bpmnPro/components/Panel/components/ElementGenerations.vue

@@ -155,11 +155,11 @@ export default {
           { required: true, message: "请输入流程别名/ID", trigger: "blur" },
         ],
       };
-      if (this.isProcess) {
-        res.elementName = [
-          { required: true, message: "请输入流程名称/名称", trigger: "blur" },
-        ];
-      }
+      // if (this.isProcess) {
+      res.elementName = [
+        { required: true, message: "请输入流程/节点名称", trigger: "blur" },
+      ];
+      // }
       return res;
     },
   },

+ 11 - 3
ruoyi-ui/src/views/system/bpmnPro/components/Panel/components/ElementNormalTask.vue

@@ -6,7 +6,7 @@
       </collapse-title>
     </template>
     <div class="element-normal-task">
-      <edit-item label="任务类型" :label-width="100">
+      <edit-item label="任务行业" :label-width="100">
         <el-select
           v-model="industryType"
           value-key="value"
@@ -30,6 +30,7 @@
         /> -->
         <el-select
           v-model="normalScriptKey"
+          :disabled="!industryType"
           value-key="value"
           placeholder="请选择执行任务"
           clearable
@@ -104,15 +105,22 @@ export default {
   },
   methods: {
     async initFormData() {
-      this.getScriptList();
       this.industryType = getIndustryType(getActive());
+      await this.getScriptList(this.industryType);
       this.normalScriptKey = getNormalScriptKey(getActive());
       this.scriptTriggerType = getNormalScriptTriggerType(getActive());
     },
     updateIndustryType(value) {
       setIndustryType(getActive(), value);
+      this.getScriptList(value);
+      this.normalScriptKey = "";
     },
-    async getScriptList() {
+    async getScriptList(industryType) {
+      let res = await listScript({
+        isEnablePaging: false,
+        scriptType: 1,
+        industryType,
+      });
       this.scriptList = res.rows.map((item) => ({
         value: item.scriptKey,
         label: item.scriptName,

+ 28 - 13
ruoyi-ui/src/views/system/bpmnPro/components/Panel/components/ElementUnusualTasks.vue

@@ -78,8 +78,11 @@
         class="need-filled"
         aria-modal="true"
       >
-        <el-form-item path="industryType" label="行业类型">
-          <el-select v-model="newUnusualTask.industryType">
+        <el-form-item prop="industryType" label="行业类型">
+          <el-select
+            v-model="newUnusualTask.industryType"
+            @change="industryTypeChangeHandler"
+          >
             <el-option
               v-for="{ label, value } in dict.type.industry_type"
               :label="label"
@@ -88,7 +91,7 @@
             />
           </el-select>
         </el-form-item>
-        <el-form-item path="scriptKey" label="任务脚本">
+        <el-form-item prop="scriptKey" label="任务脚本">
           <el-select
             v-model="newUnusualTask.scriptKey"
             @change="scriptKeyChange"
@@ -102,7 +105,7 @@
             />
           </el-select>
         </el-form-item>
-        <el-form-item path="scriptTriggerType" label="事件触发机制">
+        <el-form-item prop="scriptTriggerType" label="事件触发机制">
           <el-select v-model="newUnusualTask.scriptTriggerType">
             <el-option
               v-for="item in dict.type.script_trigger_type"
@@ -152,7 +155,7 @@ export default {
         scriptKey: {
           required: true,
           trigger: ["blur", "change"],
-          message: "异常任务不能为空",
+          message: "任务脚本不能为空",
         },
         scriptTriggerType: {
           required: true,
@@ -193,7 +196,6 @@ export default {
       this.scriptForm.scriptTriggerType = getScriptTriggerType(getActive());
 
       this.listeners = getUnusualTaskTableData(this._listenersRaw);
-      console.log(this.listeners);
     },
 
     updateScriptType(value) {
@@ -209,7 +211,6 @@ export default {
     },
     async saveUnusualTask(index) {
       await this.$refs.formRef.validate();
-      console.log(this.newUnusualTask);
       this.activeIndex === -1
         ? addUnusualTask(getActive(), this.newUnusualTask)
         : updateUnusualTask(
@@ -222,14 +223,9 @@ export default {
 
     async openScriptModel(index, TaskData) {
       this.activeIndex = index;
-      console.log(TaskData);
       TaskData && (this.newUnusualTask = JSON.parse(JSON.stringify(TaskData)));
+      this.getScriptList(this.newUnusualTask.industryType);
       this.modelVisible = true;
-      let res = await listScript({ isEnablePaging: false, scriptType: 0 });
-      this.scriptKeyList = res.rows.map((item) => ({
-        value: item.scriptKey,
-        label: item.scriptName,
-      }));
       await this.$nextTick();
       this.$refs.formRef && this.$refs.formRef.clearValidate();
     },
@@ -249,6 +245,25 @@ export default {
         return item.value == value;
       })?.label;
     },
+
+    // 行业改变回调
+    industryTypeChangeHandler(value) {
+      this.getScriptList(value);
+      this.newUnusualTask.scriptKey = "";
+    },
+
+    // 获取脚本列表
+    async getScriptList(industryType = "0") {
+      let res = await listScript({
+        isEnablePaging: false,
+        scriptType: "0",
+        industryType,
+      });
+      this.scriptKeyList = res.rows.map((item) => ({
+        value: item.scriptKey,
+        label: item.scriptName,
+      }));
+    },
   },
 };
 </script>

+ 4 - 4
ruoyi-ui/src/views/system/bpmnPro/components/Toolbar/tools/Save.vue

@@ -99,14 +99,14 @@ export default {
       }
     },
     async saveHandler() {
-      // let formValidate = await EventEmitter.emit("formValidate");
-      // if (!formValidate) {
-      //   return;
-      // }
+      //校验字段合法性
+      // let validateRes = validateBPMNFields();
       let _this = this;
       let formData = _this.formData() || {}; // 当前流程表单详细数据
       let processJsonObj = await this.getProcessJson(); // xml标签转换json
       let validateRes = formDataValidate(processJsonObj);
+      console.log(validateRes);
+      return;
       if (!validateRes.flag) {
         this.$message.error(validateRes.msg);
         return;

+ 0 - 1
ruoyi-ui/src/views/system/bpmnPro/components/bo-utils/myFieldUtil.js

@@ -210,7 +210,6 @@ export function addUnusualTask(element, props) {
 // 获取异常任务表数据
 export function getUnusualTaskTableData(moddleList = []) {
   const prefix = getProcessEngine();
-  console.log(moddleList);
   let res = moddleList.map(item => {
     return {
       scriptKey: item?.$attrs.scriptKey || '',