luoyali 1 жил өмнө
parent
commit
102e86847d

+ 12 - 2
src/api/flow/process.ts

@@ -9,7 +9,8 @@ const api = {
 	clone: '/v1/process/clone', // 复制流程
 	updateProcessState: 'v1/process/update-state', // 更新流程状态
 	detailProcess: '/v1/process/get', // 流程详情
-	launchProcessList: '/v1/process/list-launch' // 发起审批流程列表
+	launchProcessList: '/v1/process/list-launch', // 发起审批流程列表
+	releaseProcess: '/v1/process/release' // 发布流程
 }
 
 function progressCreateApi(data: any): AxiosPromise {
@@ -42,6 +43,14 @@ function launchProcessListApi(data: any): AxiosPromise {
 	})
 }
 
+function releaseProcessApi(data: any): AxiosPromise {
+	return request({
+		url: api.releaseProcess,
+		method: 'post',
+		data
+	})
+}
+
 function progressCloneApi(data: any): AxiosPromise {
 	return request({
 		url: api.clone + '?id=' + data.id,
@@ -69,5 +78,6 @@ export default {
 	progressCloneApi,
 	processUpdateStateApi,
 	processDetailApi,
-	launchProcessListApi
+	launchProcessListApi,
+	releaseProcessApi
 }

+ 0 - 5
src/store/modules/flow.ts

@@ -66,11 +66,6 @@ export const useFlowStore = defineStore({
 			}
 			this.basicInfo[key] = value
 		},
-		// 流程ID
-		setFlowProcessId(value: string) {
-			console.log(value, '=======///////===');
-			this.flowProcessId = value
-		},
 		// 表单信息
 		setProcessForm(value: any) {
 			this.processForm = value

+ 24 - 17
src/views/flow/create/components/BasicInfo.vue

@@ -12,7 +12,7 @@ const route = useRoute()
 // 缓存 start
 import { EVENT_ENUM, EVENT_BUS, cacheTriggerFunc } from '@/utils/cacheHelper'
 const flowStore = useFlowStore()
-const { flowName, flowProcessId, processForm, modelContent } = storeToRefs(flowStore)
+const { flowName, flowProcessId } = storeToRefs(flowStore)
 const cacheLoading = ref(false)
 const cacheLoadingNum = ref(600)
 const cacheLoadingFr = 1000
@@ -179,12 +179,25 @@ const getGroupList = async () => {
 }
 
 const initBaseicInfEv = item => {
+	// item = {
+	// 	processId: '1728240012964925441',
+	// 	processForm:yu
+	// 		'[{"type":"input","field":"userName","title":"输入框","info":"","$required":false,"_fc_drag_tag":"input","hidden":false,"display":true}]',
+	// 	processKey: '003key',
+	// 	processName: '003名称',
+	// 	processIcon: 'https://lf3-ea.bytetos.com/obj/goofy/ee/approval/approval-admin/image/iconLib/v5/cart',
+	// 	categoryId: '1725778939021541378',
+	// 	remark: '003说明',
+	// 	useScope: 1,
+	// 	processActorList: [{ actorId: '1705067852272607233', actorName: 'lanceJiang', actorType: 0 }],
+	// 	processPermissionList: [{ userId: '1705067852272607233', userName: 'lanceJiang', operateApproval: 0, operateOwner: 0, operateData: 0 }]
+	// }
 	const { processForm, modelContent, ...rest } = item
 	flowInfo.value = rest
 	flowStore.setProcessForm(processForm)
 	flowStore.setModelContent(modelContent)
-	updateRemoteCache()
-	flowStore.setFlowProcessId(queryObj.value.id)
+	// updateRemoteCache()
+	flowProcessId.value = queryObj.value.id // 赋值流程id
 	if (item.useScope === 1) {
 		nodeRoleList.value = item.processActorList.map(item => {
 			return {
@@ -211,16 +224,9 @@ const initBaseicInfEv = item => {
 // 更新申请信息缓存
 const updateRemoteCache = async () => {
 	try {
-		const commonParam = {
-			processForm: processForm.value,
-			modelContent: modelContent.value,
-			...flowInfo.value
-		}
-		const params = flowProcessId.value ? { processId: flowProcessId.value, ...commonParam } : commonParam
-		console.error(params, 'params=======')
-		// return
+		const params = flowProcessId.value ? { ...flowInfo.value, processId: flowProcessId.value } : flowInfo.value
 		const data = await process.progressCreateApi(params)
-		flowStore.setFlowProcessId(data)
+		flowProcessId.value = data
 		Object.keys(flowInfo.value).forEach(key => {
 			flowStore.setKeysBasicInfo(key, flowInfo.value[key])
 		})
@@ -233,7 +239,7 @@ const updateRemoteCache = async () => {
 const handleRemoteCacheRefresh = () => {
 	cacheIndex.value && clearTimeout(cacheIndex.value)
 	cacheIndex.value = setTimeout(() => {
-		updateRemoteCache()
+		// updateRemoteCache()
 	}, cacheUpdateFr)
 }
 
@@ -274,6 +280,7 @@ const getCurrentProcessDetailEv = id => {
 
 // icon图标点击保存
 const chooseIconEv = item => {
+	// flowStore.setKeysBasicInfo('processIcon', item)
 	flowInfo.value.processIcon = item
 	visiblePopover.value = !visiblePopover.value
 }
@@ -340,13 +347,13 @@ defineExpose({
 
 <template>
 	<div class="base-info">
-		<div style="font-size: 18px; position: absolute; left: 10px; top: 20px; z-index: 9999; color: red">
+		<div v-if="false" style="font-size: 18px; position: absolute; left: 10px; top: 20px; z-index: 9999; color: red">
 			{{ cacheLoadingNum }}秒之后开启自动缓存...
 		</div>
 
 		<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>
+				<el-button type="primary" @click="updateRemoteCache">下一步</el-button>
 			</div>
 			<el-form ref="formRef" :model="flowInfo" :rules="rules" label-position="top">
 				<el-form-item label="图标" prop="processIcon">
@@ -397,7 +404,7 @@ defineExpose({
 							closable
 							style="margin-right: 8px"
 							@close="delRole(index, 'nodeRoleList')"
-							>{{ role.name }}</el-tag
+						>{{ role.name }}</el-tag
 						>
 					</div>
 				</el-form-item>
@@ -413,7 +420,7 @@ defineExpose({
 							closable
 							style="margin-right: 8px"
 							@close="delRole(index, 'nodeRoleManageList')"
-							>{{ role.name }}</el-tag
+						>{{ role.name }}</el-tag
 						>
 					</div>
 				</el-form-item>

+ 2 - 1
src/views/flow/create/components/FlowDesign.vue

@@ -48,13 +48,14 @@ const validate = () => {
 const saveDesign = async jsonStr => {
 	try {
 		const params = {
-      ...basicInfo.value,
+			...basicInfo.value,
 			processId: flowProcessId.value,
 			processForm: processForm.value,
 			modelContent: JSON.stringify(jsonStr)
 		}
 		const res = await process.progressCreateApi(params)
 		flowProcessId.value = res
+		await process.releaseProcessApi({ id: flowProcessId.value })
 	} catch (e) {
 		console.log(e)
 	}

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

@@ -3,64 +3,38 @@ import FcDesigner from '@/components/FormCreateDesigner/FcDesigner.vue'
 import useFlowStore from '@/store/modules/flow'
 import { storeToRefs } from 'pinia'
 import process from '@/api/flow/process'
-import { onMounted, computed, ref, onBeforeUnmount } from 'vue'
+import { onMounted, computed, ref } from 'vue'
 import { useRoute } from 'vue-router'
 const route = useRoute()
 
-const designer = ref()
 const flowStore = useFlowStore()
 const { flowProcessId, basicInfo, processForm } = storeToRefs(flowStore)
-const cacheLoadingIndex = ref(null)
-const cacheIndex = ref(null) // 缓存索引
-const cacheInterView = ref(null)
-const cacheUpdateFr = 3000 // 缓存更新频率
-
-// 当前是否是编辑
-const queryObj = computed(() => route.query)
-
-/* 自动缓存 - 使用定时器 */
+const designer = ref()
 const exportJsonEv = async json => {
-	console.log(json, '每 3s保存 一下 json', flowProcessId.value, basicInfo.value)
+	console.log(json)
 	try {
 		const _json = JSON.stringify(json)
 		const params = {
+			processId: flowProcessId.value,
 			processForm: JSON.stringify(json),
-			...basicInfo.value,
-			processId: flowProcessId.value
+			...basicInfo.value
 		}
 		const res = await process.progressCreateApi(params)
 		flowStore.setProcessForm(_json)
-		flowStore.setFlowProcessId(res)
+		flowProcessId.value = res
 	} catch (e) {
 		console.log(e)
 	}
 }
 
-const closeCacheLoading = () => {
-	cacheLoadingIndex.value && clearInterval(cacheLoadingIndex.value)
-}
-
-const handleRemoteCacheRefresh = () => {
-	cacheIndex.value && clearTimeout(cacheIndex.value)
-	cacheIndex.value = setTimeout(() => {
-		// 调子组件 获取最新的数据,缓存
-		cacheInterView.value && clearInterval(cacheInterView.value)
-		cacheInterView.value = setInterval(() => {
-			designer.value.saveFormJson()
-		}, cacheUpdateFr)
-	}, cacheUpdateFr)
-}
+// 当前是否是编辑
+const queryObj = computed(() => route.query)
 
 onMounted(() => {
-	// handleRemoteCacheRefresh()
 	if (queryObj.value.id) {
 		designer.value.initForm(processForm.value || [])
 	}
 })
-
-onBeforeUnmount(() => {
-	closeCacheLoading()
-})
 </script>
 
 <template>

+ 2 - 5
src/views/flow/create/index.vue

@@ -6,7 +6,7 @@
 			</div>
 			<div class="create-approval-header-left-zh">
 				<div class="create-approval-header-name">{{ flowName }}</div>
-				<div class="create-approval-header-time">最近保存:6 分钟前</div>
+				<div class="create-approval-header-time" v-if="false">最近保存:6 分钟前</div>
 			</div>
 			<div class="create-approval-header-tab-list">
 				<div
@@ -21,7 +21,6 @@
 				</div>
 			</div>
 			<div class="create-approval-header-right">
-				<el-button @click="saveHandler">暂存</el-button>
 				<el-button type="primary" @click="submitHandler">发布</el-button>
 			</div>
 		</div>
@@ -73,9 +72,7 @@ const componentsArr = [
 ]
 const activeName = ref('基础信息')
 
-const submitHandler = () => {}
-
-const saveHandler = () => {
+const submitHandler = () => {
 	// 基础信息
 	// 表单设计
 	// 流程设计