Vue3 重构:流程定义列表

This commit is contained in:
YunaiV 2023-03-26 08:46:04 +08:00
parent b587d7634c
commit 3c6bf37879
7 changed files with 153 additions and 189 deletions

View File

@ -1,19 +1,19 @@
import request from '@/config/axios' import request from '@/config/axios'
export const getProcessDefinitionBpmnXMLApi = async (id: number) => { export const getProcessDefinitionBpmnXML = async (id: number) => {
return await request.get({ return await request.get({
url: '/bpm/process-definition/get-bpmn-xml?id=' + id url: '/bpm/process-definition/get-bpmn-xml?id=' + id
}) })
} }
export const getProcessDefinitionPageApi = async (params) => { export const getProcessDefinitionPage = async (params) => {
return await request.get({ return await request.get({
url: '/bpm/process-definition/page', url: '/bpm/process-definition/page',
params params
}) })
} }
export const getProcessDefinitionListApi = async (params) => { export const getProcessDefinitionList = async (params) => {
return await request.get({ return await request.get({
url: '/bpm/process-definition/list', url: '/bpm/process-definition/list',
params params

View File

@ -1,79 +0,0 @@
import type { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas'
// CrudSchema
const crudSchemas = reactive<VxeCrudSchema>({
primaryKey: 'id',
primaryType: null,
action: true,
columns: [
{
title: '定义编号',
field: 'id',
table: {
width: 360
}
},
{
title: '定义名称',
field: 'name',
table: {
// width: 120,
slots: {
default: 'name_default'
}
}
},
{
title: '定义分类',
field: 'category',
// dictType: DICT_TYPE.BPM_MODEL_CATEGORY,
// dictClass: 'number',
table: {
// width: 120,
slots: {
default: 'category_default'
}
}
},
{
title: '表单信息',
field: 'formId',
table: {
// width: 200,
slots: {
default: 'formId_default'
}
}
},
{
title: '流程版本',
field: 'version',
table: {
// width: 80,
slots: {
default: 'version_default'
}
}
},
{
title: '激活状态',
field: 'suspensionState',
table: {
// width: 80,
slots: {
default: 'suspensionState_default'
}
}
},
{
title: '部署时间',
field: 'deploymentTime',
isForm: false,
formatter: 'formatDate'
// table: {
// width: 180
// }
}
]
})
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)

View File

@ -1,92 +1,138 @@
<template> <template>
<ContentWrap> <ContentWrap>
<!-- 列表 --> <el-table v-loading="loading" :data="list">
<XTable @register="registerTable"> <el-table-column label="定义编号" align="center" prop="id" width="400" />
<!-- 流程名称 --> <el-table-column label="流程名称" align="center" prop="name" width="200">
<template #name_default="{ row }"> <template #default="scope">
<XTextButton :title="row.name" @click="handleBpmnDetail(row.id)" /> <el-button type="text" @click="handleBpmnDetail(scope.row)">
</template> <span>{{ scope.row.name }}</span>
<!-- 流程分类 --> </el-button>
<template #category_default="{ row }"> </template>
<DictTag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="Number(row?.category)" /> </el-table-column>
</template> <el-table-column label="定义分类" align="center" prop="category" width="100">
<!-- 表单信息 --> <template #default="scope">
<template #formId_default="{ row }"> <dict-tag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="scope.row.category" />
<XTextButton </template>
v-if="row.formType === 10" </el-table-column>
:title="row.formName" <el-table-column label="表单信息" align="center" prop="formType" width="200">
@click="handleFormDetail(row)" <template #default="scope">
/> <el-button
<XTextButton v-else :title="row.formCustomCreatePath" @click="handleFormDetail(row)" /> v-if="scope.row.formType === 10"
</template> type="text"
<!-- 流程版本 --> @click="handleFormDetail(scope.row)"
<template #version_default="{ row }"> >
<el-tag>v{{ row.version }}</el-tag> <span>{{ scope.row.formName }}</span>
</template> </el-button>
<!-- 激活状态 --> <el-button v-else type="text" @click="handleFormDetail(scope.row)">
<template #suspensionState_default="{ row }"> <span>{{ scope.row.formCustomCreatePath }}</span>
<el-tag type="success" v-if="row.suspensionState === 1">激活</el-tag> </el-button>
<el-tag type="warning" v-if="row.suspensionState === 2">挂起</el-tag> </template>
</template> </el-table-column>
<!-- 操作 --> <el-table-column label="流程版本" align="center" prop="processDefinition.version" width="80">
<template #actionbtns_default="{ row }"> <template #default="scope">
<XTextButton <el-tag v-if="scope.row">v{{ scope.row.version }}</el-tag>
preIcon="ep:user" <el-tag type="warning" v-else>未部署</el-tag>
title="分配规则" </template>
v-hasPermi="['bpm:task-assign-rule:query']" </el-table-column>
@click="handleAssignRule(row)" <el-table-column label="状态" align="center" prop="version" width="80">
/> <template #default="scope">
</template> <el-tag type="success" v-if="scope.row.suspensionState === 1">激活</el-tag>
</XTable> <el-tag type="warning" v-if="scope.row.suspensionState === 2">挂起</el-tag>
</template>
<!-- 表单详情的弹窗 --> </el-table-column>
<XModal v-model="formDetailVisible" width="800" title="表单详情" :show-footer="false"> <el-table-column
<form-create label="部署时间"
:rule="formDetailPreview.rule" align="center"
:option="formDetailPreview.option" prop="deploymentTime"
v-if="formDetailVisible" width="180"
:formatter="dateFormatter"
/> />
</XModal> <el-table-column
<!-- 流程模型图的预览 --> label="定义描述"
<XModal title="流程图" v-model="showBpmnOpen" width="80%" height="90%"> align="center"
<my-process-viewer prop="description"
key="designer" width="300"
v-model="bpmnXML" show-overflow-tooltip
:value="bpmnXML"
v-bind="bpmnControlForm"
:prefix="bpmnControlForm.prefix"
/> />
</XModal> <el-table-column label="操作" align="center" width="150" fixed="right">
<template #default="scope">
<el-button
link
type="primary"
@click="handleAssignRule(scope.row)"
v-hasPermi="['bpm:task-assign-rule:query']"
>
分配规则
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap> </ContentWrap>
</template>
<script setup lang="ts">
// import
import * as DefinitionApi from '@/api/bpm/definition'
// import * as ModelApi from '@/api/bpm/model'
import { allSchemas } from './definition.data'
import { setConfAndFields2 } from '@/utils/formCreate'
import { DICT_TYPE } from '@/utils/dict'
const bpmnXML = ref(null) <!-- 弹窗表单详情 -->
const showBpmnOpen = ref(false) <Dialog title="表单详情" v-model="formDetailVisible" width="800">
const bpmnControlForm = ref({ <form-create :rule="formDetailPreview.rule" :option="formDetailPreview.option" />
prefix: 'flowable' </Dialog>
})
// const message = useMessage() // <!-- 弹窗流程模型图的预览 -->
const router = useRouter() // <Dialog title="流程图" v-model="bpmnDetailVisible" width="800">
<my-process-viewer
key="designer"
v-model="bpmnXML"
:value="bpmnXML"
v-bind="bpmnControlForm"
:prefix="bpmnControlForm.prefix"
/>
</Dialog>
</template>
<script setup lang="ts" name="Form">
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import * as DefinitionApi from '@/api/bpm/definition'
import { setConfAndFields2 } from '@/utils/formCreate'
const { push } = useRouter() //
const { query } = useRoute() // const { query } = useRoute() //
// ========== ========== const loading = ref(true) //
const total = ref(0) //
const list = ref([]) //
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1,
pageSize: 10,
key: query.key key: query.key
}) })
const [registerTable] = useXTable({
allSchemas: allSchemas,
getListApi: DefinitionApi.getProcessDefinitionPageApi,
params: queryParams
})
// /** 查询参数列表 */
const getList = async () => {
loading.value = true
try {
const data = await DefinitionApi.getProcessDefinitionPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 点击任务分配按钮 */
const handleAssignRule = (row) => {
push({
name: 'BpmTaskAssignRuleList',
query: {
modelId: row.id
}
})
}
/** 流程表单的详情按钮操作 */
const formDetailVisible = ref(false) const formDetailVisible = ref(false)
const formDetailPreview = ref({ const formDetailPreview = ref({
rule: [], rule: [],
@ -99,32 +145,25 @@ const handleFormDetail = async (row) => {
// //
formDetailVisible.value = true formDetailVisible.value = true
} else { } else {
await router.push({ await push({
path: row.formCustomCreatePath path: row.formCustomCreatePath
}) })
} }
} }
// /** 流程图的详情按钮操作 */
const handleBpmnDetail = (row) => { const bpmnDetailVisible = ref(false)
// TODO const bpmnXML = ref(null)
console.log(row) const bpmnControlForm = ref({
DefinitionApi.getProcessDefinitionBpmnXMLApi(row).then((response) => { prefix: 'flowable'
console.log(response, 'response') })
bpmnXML.value = response const handleBpmnDetail = async (row) => {
// bpmnXML.value = await DefinitionApi.getProcessDefinitionBpmnXML(row.id)
showBpmnOpen.value = true bpmnDetailVisible.value = true
})
// message.success(' 2 ')
} }
// /** 初始化 **/
const handleAssignRule = (row) => { onMounted(() => {
router.push({ getList()
name: 'BpmTaskAssignRuleList', })
query: {
processDefinitionId: row.id
}
})
}
</script> </script>

View File

@ -62,7 +62,7 @@
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column label="流程标识" align="center" prop="key" /> <el-table-column label="流程标识" align="center" prop="key" width="200" />
<el-table-column label="流程名称" align="center" prop="name" width="200"> <el-table-column label="流程名称" align="center" prop="name" width="200">
<template #default="scope"> <template #default="scope">
<el-button type="text" @click="handleBpmnDetail(scope.row)"> <el-button type="text" @click="handleBpmnDetail(scope.row)">
@ -77,11 +77,15 @@
</el-table-column> </el-table-column>
<el-table-column label="表单信息" align="center" prop="formType" width="200"> <el-table-column label="表单信息" align="center" prop="formType" width="200">
<template #default="scope"> <template #default="scope">
<el-button v-if="scope.row.formId" type="text" @click="handleFormDetail(scope.row)"> <el-button
v-if="scope.row.formType === 10"
type="text"
@click="handleFormDetail(scope.row)"
>
<span>{{ scope.row.formName }}</span> <span>{{ scope.row.formName }}</span>
</el-button> </el-button>
<el-button <el-button
v-else-if="scope.row.formCustomCreatePath" v-else-if="scope.row.formType === 20"
type="text" type="text"
@click="handleFormDetail(scope.row)" @click="handleFormDetail(scope.row)"
> >
@ -94,6 +98,7 @@
label="创建时间" label="创建时间"
align="center" align="center"
prop="createTime" prop="createTime"
width="180"
:formatter="dateFormatter" :formatter="dateFormatter"
/> />
<el-table-column label="最新部署的流程定义" align="center"> <el-table-column label="最新部署的流程定义" align="center">
@ -114,7 +119,7 @@
label="激活状态" label="激活状态"
align="center" align="center"
prop="processDefinition.version" prop="processDefinition.version"
width="80" width="85"
> >
<template #default="scope"> <template #default="scope">
<el-switch <el-switch
@ -134,7 +139,7 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" fixed="right" class-name="fixed-width"> <el-table-column label="操作" align="center" width="240" fixed="right">
<template #default="scope"> <template #default="scope">
<el-button <el-button
link link

View File

@ -72,7 +72,7 @@ const [registerTable] = useXTable({
params: { params: {
suspensionState: 1 suspensionState: 1
}, },
getListApi: DefinitionApi.getProcessDefinitionListApi, getListApi: DefinitionApi.getProcessDefinitionList,
isList: true isList: true
}) })
@ -99,7 +99,7 @@ const handleSelect = async (row) => {
setConfAndFields2(detailForm, row.formConf, row.formFields) setConfAndFields2(detailForm, row.formConf, row.formFields)
// //
DefinitionApi.getProcessDefinitionBpmnXMLApi(row.id).then((response) => { DefinitionApi.getProcessDefinitionBpmnXML(row.id).then((response) => {
bpmnXML.value = response bpmnXML.value = response
}) })
// //

View File

@ -411,7 +411,7 @@ const getDetail = () => {
} }
// //
DefinitionApi.getProcessDefinitionBpmnXMLApi(processDefinition.id).then((data) => { DefinitionApi.getProcessDefinitionBpmnXML(processDefinition.id).then((data) => {
bpmnXML.value = data bpmnXML.value = data
}) })

View File

@ -169,7 +169,6 @@
<el-table-column <el-table-column
label="操作" label="操作"
align="center" align="center"
class-name="fixed-width"
width="210" width="210"
fixed="right" fixed="right"
> >