44
44
45
45
<!-- 右侧按钮 -->
46
46
<div class =" w-200px flex items-center justify-end gap-2" >
47
- <el-button v-if =" route.params.id" type =" success" @click =" handleDeploy" >发 布</el-button >
48
- <el-button type =" primary" @click =" handleSave" >保 存</el-button >
47
+ <el-button v-if =" actionType === 'update'" type =" success" @click =" handleDeploy" >
48
+ 发 布
49
+ </el-button >
50
+ <el-button type =" primary" @click =" handleSave" >
51
+ <span v-if =" actionType === 'definition'" >恢 复</span >
52
+ <span v-else >保 存</span >
53
+ </el-button >
49
54
</div >
50
55
</div >
51
56
81
86
<script lang="ts" setup>
82
87
import { useRoute , useRouter } from ' vue-router'
83
88
import { useMessage } from ' @/hooks/web/useMessage'
89
+ import { useTagsViewStore } from ' @/store/modules/tagsView'
90
+ import { useUserStoreWithOut } from ' @/store/modules/user'
84
91
import * as ModelApi from ' @/api/bpm/model'
85
92
import * as FormApi from ' @/api/bpm/form'
86
93
import { CategoryApi , CategoryVO } from ' @/api/bpm/category'
87
94
import * as UserApi from ' @/api/system/user'
88
- import { useUserStoreWithOut } from ' @/store/modules/user '
95
+ import * as DefinitionApi from ' @/api/bpm/definition '
89
96
import { BpmModelFormType , BpmModelType , BpmAutoApproveType } from ' @/utils/constants'
90
97
import BasicInfo from ' ./BasicInfo.vue'
91
98
import FormDesign from ' ./FormDesign.vue'
92
99
import ProcessDesign from ' ./ProcessDesign.vue'
93
- import { useTagsViewStore } from ' @/store/modules/tagsView'
94
100
import ExtraSettings from ' ./ExtraSettings.vue'
101
+ import { useTagsView } from ' @/hooks/web/useTagsView'
95
102
96
103
const router = useRouter ()
97
104
const { delView } = useTagsViewStore () // 视图操作
105
+ const tagsView = useTagsView ()
98
106
const route = useRoute ()
99
107
const message = useMessage ()
100
108
const userStore = useUserStoreWithOut ()
@@ -165,7 +173,7 @@ const formData: any = ref({
165
173
}
166
174
})
167
175
168
- // 流程数据
176
+ // 流程数据
169
177
const processData = ref <any >()
170
178
171
179
provide (' processData' , processData )
@@ -177,20 +185,36 @@ const categoryList = ref<CategoryVO[]>([])
177
185
const userList = ref <UserApi .UserVO []>([])
178
186
179
187
/** 初始化数据 */
188
+ const actionType = route .params .type as string
180
189
const initData = async () => {
181
- const modelId = route .params .id as string
182
- if (modelId ) {
183
- // 修改场景
190
+ if (actionType === ' definition' ) {
191
+ // 情况一:流程定义场景(恢复)
192
+ const definitionId = route .params .id as string
193
+ const data = await DefinitionApi .getProcessDefinition (definitionId )
194
+ // 将 definition => model,最终赋值
195
+ data .type = data .modelType
196
+ delete data .modelType
197
+ data .id = data .modelId
198
+ delete data .modelId
199
+ if (data .simpleModel ) {
200
+ data .simpleModel = JSON .parse (data .simpleModel )
201
+ }
202
+ formData .value = data
203
+ formData .value .startUserType = formData .value .startUserIds ?.length > 0 ? 1 : 0
204
+ } else if ([' update' , ' copy' ].includes (actionType )) {
205
+ // 情况二:修改场景/复制场景
206
+ const modelId = route .params .id as string
184
207
formData .value = await ModelApi .getModel (modelId )
185
208
formData .value .startUserType = formData .value .startUserIds ?.length > 0 ? 1 : 0
186
- // 复制场景
187
- if (route . params . type === ' copy' ) {
209
+ // 特殊: 复制场景
210
+ if (actionType === ' copy' ) {
188
211
delete formData .value .id
189
212
formData .value .name += ' 副本'
190
213
formData .value .key += ' _copy'
214
+ tagsView .setTitle (' 复制流程' )
191
215
}
192
216
} else {
193
- // 新增场景
217
+ // 情况三: 新增场景
194
218
formData .value .startUserType = 0 // 全体
195
219
formData .value .managerUserIds .push (userStore .getUser .id )
196
220
}
@@ -271,37 +295,31 @@ const handleSave = async () => {
271
295
... formData .value
272
296
}
273
297
274
- if (formData .value .id ) {
298
+ if (actionType === ' definition' ) {
299
+ // 情况一:流程定义场景(恢复)
300
+ await ModelApi .updateModel (modelData )
301
+ // 提示成功
302
+ message .success (' 恢复成功,可点击【发布】按钮,进行发布模型' )
303
+ } else if (actionType === ' update' ) {
275
304
// 修改场景
276
305
await ModelApi .updateModel (modelData )
277
- // 询问是否发布流程
278
- try {
279
- await message .confirm (' 修改流程成功,是否发布流程?' )
280
- // 用户点击确认,执行发布
281
- await handleDeploy ()
282
- } catch {
283
- // 用户点击取消,停留在当前页面
284
- }
306
+ // 提示成功
307
+ message .success (' 修改成功,可点击【发布】按钮,进行发布模型' )
308
+ } else if (actionType === ' copy' ) {
309
+ // 情况三:复制场景
310
+ formData .value .id = await ModelApi .createModel (modelData )
311
+ // 提示成功
312
+ message .success (' 复制成功,可点击【发布】按钮,进行发布模型' )
285
313
} else {
286
- // 新增场景
314
+ // 情况四: 新增场景
287
315
formData .value .id = await ModelApi .createModel (modelData )
288
- try {
289
- await message .confirm (' 流程创建成功,是否继续编辑?' )
290
- // 用户点击继续编辑,跳转到编辑页面
291
- await nextTick ()
292
- // 先删除当前页签
293
- delView (unref (router .currentRoute ))
294
- // 跳转到编辑页面
295
- await router .push ({
296
- name: ' BpmModelUpdate' ,
297
- params: { id: formData .value .id }
298
- })
299
- } catch {
300
- // 先删除当前页签
301
- delView (unref (router .currentRoute ))
302
- // 用户点击返回列表
303
- await router .push ({ name: ' BpmModel' })
304
- }
316
+ // 提示成功
317
+ message .success (' 新建成功,可点击【发布】按钮,进行发布模型' )
318
+ }
319
+
320
+ // 返回列表页(排除更新的情况)
321
+ if (actionType !== ' update' ) {
322
+ await router .push ({ name: ' BpmModel' })
305
323
}
306
324
} catch (error : any ) {
307
325
console .error (' 保存失败:' , error )
@@ -346,7 +364,6 @@ const handleDeploy = async () => {
346
364
/** 步骤切换处理 */
347
365
const handleStepClick = async (index : number ) => {
348
366
try {
349
- console .log (' index' , index )
350
367
if (index !== 0 ) {
351
368
await validateBasic ()
352
369
}
0 commit comments