Commit 5063db47 by GoldenZqqq

feat: 将流程模型新增/修改/设计整合到同一个页面中,分三个步骤进行;跳转传参逻辑与页面绘制

parent 295a43d5
......@@ -330,6 +330,18 @@ const remainingRouter: AppRouteRecordRaw[] = [
title: '查看 OA 请假',
activeMenu: '/bpm/oa/leave'
}
},
{
path: 'manager/model/create-update',
component: () => import('@/views/bpm/model/CreateUpdate.vue'),
name: 'BpmModelCreateUpdate',
meta: {
noCache: true,
hidden: true,
canTo: true,
title: '创建/修改流程',
activeMenu: '/bpm/manager/model'
}
}
]
},
......
......@@ -339,21 +339,22 @@ const handleChangeState = async (row: any) => {
/** 设计流程 */
const handleDesign = (row: any) => {
if (row.type == BpmModelType.BPMN) {
push({
name: 'BpmModelEditor',
query: {
modelId: row.id
}
})
} else {
push({
name: 'SimpleModelDesign',
query: {
modelId: row.id
}
})
}
// if (row.type == BpmModelType.BPMN) {
// push({
// name: 'BpmModelEditor',
// query: {
// modelId: row.id
// }
// })
// } else {
// push({
// name: 'SimpleModelDesign',
// query: {
// modelId: row.id
// }
// })
// }
push(`/bpm/manager/model/create-update?id=${row.id}`)
}
/** 发布流程 */
......@@ -496,7 +497,11 @@ const handleDeleteCategory = async () => {
/** 添加流程模型弹窗 */
const modelFormRef = ref()
const openModelForm = (type: string, id?: number) => {
modelFormRef.value.open(type, id)
if (type === 'create') {
push('/bpm/manager/model/create-update')
} else {
push(`/bpm/manager/model/create-update?id=${id}`)
}
}
watch(() => props.categoryInfo.modelList, updateModeList, { immediate: true })
......
......@@ -34,6 +34,10 @@ import * as ModelApi from '@/api/bpm/model'
defineOptions({ name: 'BpmModelEditor' })
const props = defineProps<{
modelId: string
}>()
const emit = defineEmits(['success'])
const router = useRouter() // 路由
const { query } = useRoute() // 路由的查询
const message = useMessage() // 国际化
......@@ -59,36 +63,28 @@ const initModeler = (item) => {
/** 添加/修改模型 */
const save = async (bpmnXml: string) => {
try {
const data = {
...model.value,
bpmnXml: bpmnXml // bpmnXml 只是初始化流程图,后续修改无法通过它获得
bpmnXml: bpmnXml
} as unknown as ModelApi.ModelVO
// 提交
if (data.id) {
await ModelApi.updateModelBpmn(data)
message.success('修改成功')
} else {
await ModelApi.updateModelBpmn(data)
message.success('新增成功')
emit('success')
} catch (error) {
console.error('保存失败:', error)
message.error('保存失败')
}
// 跳转回去
close()
}
/** 关闭按钮 */
const close = () => {
router.push({ path: '/bpm/manager/model' })
}
/** 初始化 */
onMounted(async () => {
const modelId = query.modelId as unknown as number
if (!modelId) {
if (!props.modelId) {
message.error('缺少模型 modelId 编号')
return
}
// 查询模型
const data = await ModelApi.getModel(modelId)
const data = await ModelApi.getModel(String(props.modelId))
if (!data.bpmnXml) {
// 首次创建的 Model 模型,它是没有 bpmnXml,此时需要给它一个默认的
data.bpmnXml = ` <?xml version="1.0" encoding="UTF-8"?>
......
......@@ -106,6 +106,7 @@ import CategoryDraggableModel from './CategoryDraggableModel.vue'
defineOptions({ name: 'BpmModel' })
const { push } = useRouter()
const message = useMessage() // 消息弹窗
const loading = ref(true) // 列表的加载中
const isCategorySorting = ref(false) // 是否 category 正处于排序状态
......@@ -124,7 +125,11 @@ const handleQuery = () => {
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
if (type === 'create') {
push('/bpm/manager/model/create-update')
} else {
push(`/bpm/manager/model/create-update?id=${id}`)
}
}
/** 流程表单的详情按钮操作 */
......
<template>
<ContentWrap :bodyStyle="{ padding: '20px 16px' }">
<SimpleProcessDesigner :model-id="modelId" @success="close" />
<SimpleProcessDesigner :model-id="modelId" @success="handleSuccess" />
</ContentWrap>
</template>
<script setup lang="ts">
......@@ -9,11 +9,16 @@ import { SimpleProcessDesigner } from '@/components/SimpleProcessDesignerV2/src/
defineOptions({
name: 'SimpleModelDesign'
})
const router = useRouter() // 路由
const { query } = useRoute() // 路由的查询
const modelId = query.modelId as string
const close = () => {
router.push({ path: '/bpm/manager/model' })
defineProps<{
modelId: string
}>()
const emit = defineEmits(['success'])
// 修改成功回调
const handleSuccess = () => {
emit('success')
}
</script>
<style lang="scss" scoped></style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment