Jelajahi Sumber

feat: 子表单为空时,清空actioUrl字段

luoyali 1 tahun lalu
induk
melakukan
f22a6b2a42

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

@@ -68,8 +68,7 @@ export default {
 					directorMode: 0, //连续主管审批方式
 					childNode: this.modelValue,
 					typeOfApprover: '1', // 审批类型 1:人工审批 2:自动通过 3:自动拒绝
-					actionUrl: undefined, // 子表单, 到时候缓存后台需要的 'id:name'格式
-					subform: [] // 子表单
+					actionUrl: [] // 子表单, 到时候缓存后台需要的 'id:name'格式
 				}
 			} else if (type === 2) {
 				node = {

+ 22 - 18
src/components/scWorkflow/nodes/approver.vue

@@ -4,7 +4,7 @@
 			<div class="title" style="background: var(--el-color-warning)">
 				<el-icon class="icon"><user-filled /></el-icon>
 				<span v-show="!isEditTitle" class="title_label" @click="editTitle('box_nodeTitle')"
-					>{{ nodeConfig.nodeName }}<el-icon v-if="!disabled" class="edit-icon"><edit /></el-icon
+				>{{ nodeConfig.nodeName }}<el-icon v-if="!disabled" class="edit-icon"><edit /></el-icon
 				></span>
 				<el-input
 					v-show="isEditTitle"
@@ -27,7 +27,7 @@
 			<template #header>
 				<div class="node-wrap-drawer__title">
 					<label v-show="!isEditTitle" @click="editTitle('nodeTitle')"
-						>{{ form.nodeName }}<el-icon class="node-wrap-drawer__title-edit"><edit /></el-icon
+					>{{ form.nodeName }}<el-icon class="node-wrap-drawer__title-edit"><edit /></el-icon
 					></label>
 					<el-input
 						v-show="isEditTitle"
@@ -89,8 +89,8 @@
 								<el-button type="primary" icon="plus" round @click="selectHandle(3, form.nodeAssigneeList)">选择角色</el-button>
 								<div class="tags-list">
 									<el-tag v-for="(role, index) in form.nodeAssigneeList" :key="role.id" type="info" closable @close="delRole(index)">{{
-										role.name
-									}}</el-tag>
+											role.name
+										}}</el-tag>
 								</div>
 							</el-form-item>
 
@@ -142,11 +142,11 @@
 							<el-form label-position="top" class="aForm">
 								<el-form-item label="添加子表单">
 									<div class="flex flex-align-center">
-										<el-button type="primary" icon="plus" round @click="selectHandle(5, form.subform)">选择子表单</el-button>
+										<el-button type="primary" icon="plus" round @click="selectHandle(5, form.actionUrl)">选择子表单</el-button>
 										<div class="tags-list inline">
-											<el-tag v-for="(user, index) in form.subform" :key="user.id" closable @close="delFormTemplate(index)">{{ user.name }}</el-tag>
+											<el-tag v-for="(user, index) in form.actionUrl" :key="user.id" closable @close="delFormTemplate(index)">{{ user.name }}</el-tag>
 										</div>
-										<div v-if="form.subform.length" class="tags-list inline">
+										<div v-if="form.actionUrl.length" class="tags-list inline">
 											<el-link :underline="false" @click.stop="showFormEv">
 												表单预览<el-icon class="el-icon--right"><View /></el-icon>
 											</el-link>
@@ -261,13 +261,14 @@ export default {
 		},
 		'form.setType': {
 			handler(type, oldType) {
+				// console.error(type, 'type, oldType', oldType)
 				if ([1, 3].includes(oldType)) {
 					// 上次setType 为 选择成员 or 角色时 对 nodeAssigneeList 重置
 					this.form.nodeAssigneeList = []
 				}
 				if ([5].includes(oldType)) {
 					// 上次setType 为 选择成员 or 角色时 对 nodeAssigneeList 重置
-					this.form.subform = []
+					this.form.actionUrl = []
 				}
 			}
 		}
@@ -291,12 +292,13 @@ export default {
 				return { label: item.label, id: item.id, opera: opera }
 			})
 			this.form.extendConfig = { formConfig: operateTable }
-			const actionUrl = this.form?.actionUrl
-			if (actionUrl) {
-				const val = actionUrl.split(':')
-				this.form.subform = [{ id: val[0], name: val[1] }]
+			// 将后台给的 actionUrl 重新组装
+			const newActionUrl = this.form?.actionUrl
+			if (newActionUrl && newActionUrl.length !== 0) {
+				const val = newActionUrl.split(':')
+				this.form.actionUrl = [{ id: val[0], name: val[1] }]
 			} else {
-				this.form.subform = []
+				this.form.actionUrl = []
 			}
 			this.drawer = true
 		},
@@ -344,9 +346,12 @@ export default {
 				// 选择角色
 				if (!_form.nodeAssigneeList || !_form.nodeAssigneeList.length) return this.$message.warning('请选择角色')
 			}
-			if (_form.subform && _form.subform.length) {
-				const { id, name } = _form.subform[0]
+			if (_form.actionUrl && _form.actionUrl.length) {
+				// _form.actionUrl = _form.actionUrl[0]
+				const { id, name } = _form.actionUrl[0]
 				_form.actionUrl = `${id}:${name}`
+			} else {
+				_form.actionUrl = undefined
 			}
 			this.emit(_form)
 			this.drawer = false
@@ -361,8 +366,7 @@ export default {
 			this.form.nodeAssigneeList.splice(index, 1)
 		},
 		delFormTemplate(index) {
-			this.form.subform.splice(index, 1)
-			this.form.actionUrl = undefined
+			this.form.actionUrl.splice(index, 1)
 		},
 		selectHandle(type, data) {
 			// type: 1人员, 3角色 5子表单
@@ -396,7 +400,7 @@ export default {
 			}*/
 		},
 		showFormEv() {
-			this.templateId = this.form.subform[0].id
+			this.templateId = this.form.actionUrl[0].id
 			this.visibleFormDetail = !this.visibleFormDetail
 		}
 	}