Jelajahi Sumber

feat: 流程设置 - 子表单默认值

luoyali 1 tahun lalu
induk
melakukan
b5fdfcb640

+ 1 - 8
src/components/scWorkflow/nodes/addNode.vue

@@ -141,14 +141,7 @@ export default {
 					nodeName: '子流程',
 					nodeKey: getNodeKey(),
 					type: 8,
-					delayType: '1', // 延时类型
-					triggerType: '1', // 触发器类型: 立即执行('1') 延时执行('2')
-					// 一小时后触发 {"time": "1:h"} 单位【 d 天 h 时 m 分 】 发起后一小时三十分后触发 {"time": "01:30:00"}
-					extendConfig: {
-						time: '', // 立即执行 time不用设置
-						args: '',
-						trigger: ''
-					},
+          callProcess: undefined, // 设置 id:name  格式
 					childNode: this.modelValue
 				}
 			}

+ 55 - 25
src/components/scWorkflow/nodes/subProcess.vue

@@ -51,8 +51,17 @@
 					<div v-show="radio1 === '1'">
 						<div class=""><el-text class="mx-1">选择子流程</el-text></div>
 						<div>
-							<el-select v-model="subProcessValue" placeholder="选择子流程" style="width: 240px; margin: 10px 20px 10px 0px">
-								<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
+							<el-select
+								v-model="form.subProcessValue"
+								placeholder="选择子流程"
+								filterable
+								remote
+								:remote-method="fetchData"
+								:loading="loading"
+								style="width: 240px; margin: 10px 20px 10px 0px"
+								@change="chooseProcess"
+							>
+								<el-option v-for="item in options" :key="item.id" :label="item.processName" :value="item.id" />
 							</el-select>
 
 							<el-link :underline="false"
@@ -94,6 +103,7 @@ import { subProcessType } from './config'
 import { ElMessage } from 'element-plus'
 import { mapState } from 'pinia'
 import useFlowStore from '@/store/modules/flow'
+import process from '@/api/flow/process'
 
 export default {
 	components: {
@@ -114,8 +124,9 @@ export default {
 			form: {},
 			radio1: '1',
 			subProcessType,
-			subProcessValue: '',
-			options: []
+			options: [],
+			loading: false,
+			processName: ''
 		}
 	},
 	watch: {
@@ -127,6 +138,9 @@ export default {
 		this.nodeConfig = this.modelValue
 	},
 	methods: {
+		chooseProcess(e) {
+			this.processName = this.options.filter(i => i.id === e)[0].processName
+		},
 		show() {
 			if (this.disabled) return
 			this.form = {}
@@ -143,6 +157,18 @@ export default {
 				return { label: item.label, id: item.id, opera: opera }
 			})
 			this.form.extendConfig = { formConfig: operateTable }
+			/**
+			 * 将后台给的 callProcess 重新组装
+			 * 拿着id去获取process值,在塞入子流程下拉列中
+			 * @type {*}
+			 */
+			const newCallProcess = this.form?.callProcess
+			if (newCallProcess) {
+				const val = newCallProcess.split(':')
+				this.form.subProcessValue = val[0]
+				this.processName = val[1]
+				this.getProcessDetail(val[0])
+			}
 			this.drawer = true
 		},
 		editTitle(refName) {
@@ -158,18 +184,10 @@ export default {
 			this.isEditTitle = false
 		},
 		save() {
-			if (!this.form.extendConfig.trigger) {
-				return ElMessage.warning('请填写 TaskTrigger 实现 class')
+			if (!this.form.subProcessValue) {
+				return ElMessage.warning('请设置子流程')
 			}
-			if (this.form.triggerType === '2' && this.form.delayType === '1' && !Number(this.fixedDuration)) {
-				return ElMessage.warning('等待时间数值最小为1')
-			}
-			this.form.extendConfig.time =
-				this.form.triggerType === '2'
-					? this.form.delayType === '1'
-						? `${this.fixedDuration}:${this.fixedDurationType}`
-						: `${this.automaticComputed}`
-					: ''
+			this.form.callProcess = `${this.form.subProcessValue}:${this.processName}`
 			this.$emit('update:modelValue', this.form)
 			this.drawer = false
 		},
@@ -177,19 +195,31 @@ export default {
 			this.$emit('update:modelValue', this.nodeConfig.childNode)
 		},
 		toText(nodeConfig) {
-			const { triggerType, delayType } = nodeConfig
-			if (triggerType === '1') {
-				return `立即执行`
-			} else if (triggerType === '2') {
-				if (delayType === '1') {
-					return `延迟执行,等待${this.fixedDuration}${mapTip[this.fixedDurationType]}`
-				} else if (delayType === '2') {
-					const tip = `延迟执行,至当天`
-					return !this.automaticComputed ? tip : `${tip}${this.automaticComputed}`
-				}
+			const { callProcess } = nodeConfig
+			if (callProcess) {
+				const val = callProcess.split(':')
+				return `${val[1]}`
 			} else {
 				return false
 			}
+		},
+		async fetchData(query) {
+			// 如果输入为空,则不调用接口
+			if (!query) {
+				return
+			}
+			this.loading = true
+			try {
+				const data = await process.childProcessTop10Api({ keyword: query })
+				this.options = data
+				this.loading = false
+			} catch (e) {
+				this.loading = false
+			}
+		},
+		async getProcessDetail(id) {
+			const { processId, processName } = await process.processDetailApi(id)
+			this.options = [{ id: processId, processName }]
 		}
 	},
 	computed: {