Procházet zdrojové kódy

feat: 模型数据 保存

luoyali před 1 rokem
rodič
revize
0a9e09f0a9

+ 40 - 4
src/store/modules/flow.ts

@@ -1,15 +1,43 @@
 import { defineStore } from 'pinia'
 
+interface BasicInfoIndex {
+	[key: string]: any
+}
+
+const basicInfo: BasicInfoIndex = {
+	processKey: '', // 唯一标识
+	processName: '', // 流程定义名称
+	displayName: '', // 流程显示名称
+	processIcon: 'https://lf3-ea.bytetos.com/obj/goofy/ee/approval/approval-admin/image/iconLib/v5/cart.svg', // 流程图标
+	categoryId: '', // 流程组分类ID
+	remark: '', // 备注说明
+	useScope: 0, // 使用范围 0,全员 1,指定人员(业务关联) 2,均不可提交
+	processActorList: [
+		{
+			actorId: 0, // 参与者ID
+			actorName: '', // 参与者
+			actorType: 0 // 参与者类型 0,用户 1,部门 2,用户组
+		}
+	], // 流程参与者,当使用范围为指定人员时候设置
+	processPermissionList: [
+		{
+			userId: 0, // 用户ID
+			userName: '', // 用户名
+			operateApproval: 0, // 允许编辑/停用/删除审批 0,否 1,
+			operateOwner: 0, // 允许添加/移除审批负责人 0,否 1,是
+			operateData: 0 // 允许审批数据查询与操作 0,否 1,是
+		}
+	] // 流程定义权限
+}
 // 审核条目
 export const useFlowStore = defineStore({
 	id: 'flow',
 	state: () => {
 		return {
 			storeInfoName: '',
-			categoryId: '', // 分类ID
-			processKey: '', // 流程定义KEY
-			flowProcessId: '', // 流程定义ID
-			flowName: '流程名称', // 流程名称
+			flowProcessId: '',
+			flowName: '', //头部展示的流程名称
+			basicInfo,
 			cacheSwitch: false, // 缓存开关
 			modelContent: '', // 流程模型定义JSON内容
 			processForm: '', // 流程定义表单
@@ -29,6 +57,14 @@ export const useFlowStore = defineStore({
 		initState(title: string) {
 			console.log('init materialInfoStore')
 			this.storeInfoName = title || '流程审核'
+		},
+		// 基本信息
+		setKeysBasicInfo(key: string, value: any) {
+			this.basicInfo[key] = value
+		},
+		// 表单信息
+		setProcessForm(value: any) {
+			this.processForm = value
 		}
 	},
 	persist: true

+ 10 - 10
src/views/flow/create/components/BasicInfo.vue

@@ -8,7 +8,7 @@ import process from '@/api/flow/process'
 // 缓存 start
 import { EVENT_ENUM, EVENT_BUS, cacheTriggerFunc } from '@/utils/cacheHelper'
 const flowStore = useFlowStore()
-const { flowName, flowProcessId, processKey, categoryId } = storeToRefs(flowStore)
+const { flowName, flowProcessId } = storeToRefs(flowStore)
 const cacheLoading = ref(false)
 const cacheLoadingNum = ref(600)
 const cacheLoadingFr = 1000
@@ -22,7 +22,6 @@ const useSelectRef = ref(null)
 const nodeRoleList = ref([])
 const nodeRoleManageList = ref([])
 const currentNode = ref('nodeRoleList')
-const processId = ref('') // 流程定义ID
 const formRef = ref()
 const options = ref([])
 const flowInfo = ref({
@@ -148,11 +147,12 @@ const getGroupList = async () => {
 // 更新申请信息缓存
 const updateRemoteCache = async () => {
 	try {
-		const params = processId.value ? { ...flowInfo.value, processId: processId.value } : flowInfo.value
-		const res = await process.progressCreateApi(params)
-		flowProcessId.value = processId.value = res
-		processKey.value = flowInfo.value.processKey
-		categoryId.value = flowInfo.value.categoryId
+		const params = flowProcessId.value ? { ...flowInfo.value, processId: flowProcessId.value } : flowInfo.value
+		const data = await process.progressCreateApi(params)
+		flowProcessId.value = data
+		Object.keys(flowInfo.value).forEach(key => {
+			flowStore.setKeysBasicInfo(key, flowInfo.value[key])
+		})
 		console.log('updateRemoteCache 实际调用接口, params = ', params, new Date().getTime())
 	} catch (e) {
 		console.log(e)
@@ -216,7 +216,7 @@ watch(
 	flowBaseInfoWatcher,
 	(newVal, oldVal) => {
 		console.log('第二步:执行同步emit方法 ------', newVal, oldVal)
-		// cacheTriggerFunc()
+		cacheTriggerFunc()
 	},
 	{ deep: true }
 )
@@ -253,8 +253,8 @@ defineExpose({
 			{{ cacheLoadingNum }}秒之后开启自动缓存...
 		</div>
 
-		<div class="base-info-panel" style="position: relative;">
-			<div style="font-size: 18px; position: absolute; right: 10px; top: 20px; z-index: 9999;">
+		<div class="base-info-panel" style="position: relative">
+			<div style="font-size: 18px; position: absolute; right: 10px; top: 20px; z-index: 9999">
 				<el-button type="primary" @click="updateRemoteCache">暂存</el-button>
 			</div>
 			<el-form ref="formRef" :model="flowInfo" :rules="rules" label-position="top">

+ 8 - 3
src/views/flow/create/components/FormDesign.vue

@@ -4,14 +4,19 @@ import useFlowStore from '@/store/modules/flow'
 import { storeToRefs } from 'pinia'
 import process from '@/api/flow/process'
 const flowStore = useFlowStore()
-const { flowProcessId, processKey, categoryId } = storeToRefs(flowStore)
+const { flowProcessId, basicInfo } = storeToRefs(flowStore)
 
 const exportJsonEv = async json => {
 	console.log(json)
-
 	try {
-		const params = flowProcessId.value ? { processForm: JSON.stringify(json), processId: flowProcessId.value, processKey: processKey.value, categoryId: categoryId.value } : { processForm: JSON.stringify(json) }
+		const _json = JSON.stringify(json)
+		const params = {
+			processId: flowProcessId.value,
+			processForm: JSON.stringify(json),
+			...basicInfo.value
+		}
 		const res = await process.progressCreateApi(params)
+		flowStore.setProcessForm(_json)
 		flowProcessId.value = res
 	} catch (e) {
 		console.log(e)