BPM:重构审批人的分配规则实现,移除 bpm_task_assign_rule 表,存储在 bpmn 的 userTask 中

This commit is contained in:
YunaiV 2024-03-13 21:18:26 +08:00
parent c89941d435
commit feadd022e7
13 changed files with 210 additions and 530 deletions

View File

@ -1,29 +0,0 @@
import request from '@/config/axios'
export type TaskAssignVO = {
id: number
modelId: string
processDefinitionId: string
taskDefinitionKey: string
taskDefinitionName: string
options: string[]
type: number
}
export const getTaskAssignRuleList = async (params) => {
return await request.get({ url: '/bpm/task-assign-rule/list', params })
}
export const createTaskAssignRule = async (data: TaskAssignVO) => {
return await request.post({
url: '/bpm/task-assign-rule/create',
data: data
})
}
export const updateTaskAssignRule = async (data: TaskAssignVO) => {
return await request.put({
url: '/bpm/task-assign-rule/update',
data: data
})
}

View File

@ -332,6 +332,16 @@
"name": "multiinstance_condition", "name": "multiinstance_condition",
"isAttr": true, "isAttr": true,
"type": "String" "type": "String"
},
{
"name": "assignType",
"isAttr": true,
"type": "String"
},
{
"name": "assignOptions",
"isAttr": true,
"type": "String"
} }
] ]
}, },

View File

@ -319,6 +319,16 @@
"name": "priority", "name": "priority",
"isAttr": true, "isAttr": true,
"type": "String" "type": "String"
},
{
"name": "assignType",
"isAttr": true,
"type": "String"
},
{
"name": "assignOptions",
"isAttr": true,
"type": "String"
} }
] ]
}, },

View File

@ -319,6 +319,16 @@
"name": "priority", "name": "priority",
"isAttr": true, "isAttr": true,
"type": "String" "type": "String"
},
{
"name": "assignType",
"isAttr": true,
"type": "String"
},
{
"name": "assignOptions",
"isAttr": true,
"type": "String"
} }
] ]
}, },

View File

@ -32,7 +32,7 @@
替代提供更好的表单设计功能 替代提供更好的表单设计功能
</el-collapse-item> </el-collapse-item>
<el-collapse-item name="task" v-if="elementType.indexOf('Task') !== -1" key="task"> <el-collapse-item name="task" v-if="elementType.indexOf('Task') !== -1" key="task">
<template #title><Icon icon="ep:checked" />任务</template> <template #title><Icon icon="ep:checked" />任务审批人</template>
<element-task :id="elementId" :type="elementType" /> <element-task :id="elementId" :type="elementType" />
</el-collapse-item> </el-collapse-item>
<el-collapse-item <el-collapse-item
@ -40,7 +40,7 @@
v-if="elementType.indexOf('Task') !== -1" v-if="elementType.indexOf('Task') !== -1"
key="multiInstance" key="multiInstance"
> >
<template #title><Icon icon="ep:help-filled" />多实例</template> <template #title><Icon icon="ep:help-filled" />多实例会签配置</template>
<element-multi-instance :business-object="elementBusinessObject" :type="elementType" /> <element-multi-instance :business-object="elementBusinessObject" :type="elementType" />
</el-collapse-item> </el-collapse-item>
<el-collapse-item name="listeners" key="listeners"> <el-collapse-item name="listeners" key="listeners">

View File

@ -138,6 +138,8 @@ const updateBaseInfo = (key) => {
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), attrObj) bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), attrObj)
} }
} }
// TODO userTask usertask id
onMounted(() => { onMounted(() => {
// bpmn 1 key name // bpmn 1 key name
setTimeout(() => { setTimeout(() => {

View File

@ -1,7 +1,8 @@
<template> <template>
<div class="panel-tab__content"> <div class="panel-tab__content">
<el-form size="small" label-width="90px"> <el-form size="small" label-width="90px">
<el-form-item label="异步延续"> <!-- add by 芋艿由于异步延续暂时用不到所以这里 display none -->
<el-form-item label="异步延续" style="display: none">
<el-checkbox <el-checkbox
v-model="taskConfigForm.asyncBefore" v-model="taskConfigForm.asyncBefore"
label="异步前" label="异步前"

View File

@ -1,85 +1,183 @@
<template> <template>
<div style="margin-top: 16px"> <el-form label-width="100px">
<!-- <el-form-item label="处理用户">--> <el-form-item label="规则类型" prop="assignType">
<!-- <el-select v-model="userTaskForm.assignee" @change="updateElementTask('assignee')">--> <el-select
<!-- <el-option v-for="ak in mockData" :key="'ass-' + ak" :label="`用户${ak}`" :value="`user${ak}`" />--> v-model="userTaskForm.assignType"
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="候选用户">-->
<!-- <el-select v-model="userTaskForm.candidateUsers" multiple collapse-tags @change="updateElementTask('candidateUsers')">-->
<!-- <el-option v-for="uk in mockData" :key="'user-' + uk" :label="`用户${uk}`" :value="`user${uk}`" />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="候选分组">-->
<!-- <el-select v-model="userTaskForm.candidateGroups" multiple collapse-tags @change="updateElementTask('candidateGroups')">-->
<!-- <el-option v-for="gk in mockData" :key="'ass-' + gk" :label="`分组${gk}`" :value="`group${gk}`" />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item label="到期时间">
<el-input v-model="userTaskForm.dueDate" clearable @change="updateElementTask('dueDate')" />
</el-form-item>
<el-form-item label="跟踪时间">
<el-input
v-model="userTaskForm.followUpDate"
clearable clearable
@change="updateElementTask('followUpDate')" style="width: 100%"
@change="changeAssignType"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item v-if="userTaskForm.assignType == 10" label="指定角色" prop="assignOptions">
<el-select
v-model="userTaskForm.assignOptions"
clearable
multiple
style="width: 100%"
@change="updateElementTask"
>
<el-option v-for="item in roleOptions" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item
v-if="userTaskForm.assignType == 20 || userTaskForm.assignType == 21"
label="指定部门"
prop="assignOptions"
span="24"
>
<el-tree-select
ref="treeRef"
v-model="userTaskForm.assignOptions"
:data="deptTreeOptions"
:props="defaultProps"
empty-text="加载中,请稍后"
multiple
node-key="id"
show-checkbox
@change="updateElementTask"
/> />
</el-form-item> </el-form-item>
<el-form-item label="优先级"> <el-form-item
<el-input v-model="userTaskForm.priority" clearable @change="updateElementTask('priority')" /> v-if="userTaskForm.assignType == 22"
label="指定岗位"
prop="assignOptions"
span="24"
>
<el-select
v-model="userTaskForm.assignOptions"
clearable
multiple
style="width: 100%"
@change="updateElementTask"
>
<el-option v-for="item in postOptions" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item> </el-form-item>
友情提示任务的分配规则使用 <el-form-item
<router-link target="_blank" :to="{ path: '/bpm/manager/model' }" v-if="
><el-link type="danger">流程模型</el-link> userTaskForm.assignType == 30 ||
</router-link> userTaskForm.assignType == 31 ||
下的分配规则替代提供指定角色部门负责人部门成员岗位工作组自定义脚本等 7 userTaskForm.assignType == 32
种维护的任务分配维度更加灵活 "
</div> label="指定用户"
prop="assignOptions"
span="24"
>
<el-select
v-model="userTaskForm.assignOptions"
clearable
multiple
style="width: 100%"
@change="updateElementTask"
>
<el-option
v-for="item in userOptions"
:key="item.id"
:label="item.nickname"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item v-if="userTaskForm.assignType === 40" label="指定用户组" prop="assignOptions">
<el-select
v-model="userTaskForm.assignOptions"
clearable
multiple
style="width: 100%"
@change="updateElementTask"
>
<el-option
v-for="item in userGroupOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item v-if="userTaskForm.assignType === 50" label="指定脚本" prop="assignOptions">
<el-select
v-model="userTaskForm.assignOptions"
clearable
multiple
style="width: 100%"
@change="updateElementTask"
>
<el-option
v-for="dict in taskAssignScriptDictDatas"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-form>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { defaultProps, handleTree } from '@/utils/tree'
import * as RoleApi from '@/api/system/role'
import * as DeptApi from '@/api/system/dept'
import * as PostApi from '@/api/system/post'
import * as UserApi from '@/api/system/user'
import * as UserGroupApi from '@/api/bpm/userGroup'
defineOptions({ name: 'UserTask' }) defineOptions({ name: 'UserTask' })
const props = defineProps({ const props = defineProps({
id: String, id: String,
type: String type: String
}) })
const defaultTaskForm = ref({ const userTaskForm = ref({
assignee: '', assignType: undefined, //
candidateUsers: [], assignOptions: [] //
candidateGroups: [],
dueDate: '',
followUpDate: '',
priority: ''
}) })
const userTaskForm = ref<any>({})
// const mockData=ref([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) // const mockData=ref([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
const bpmnElement = ref() const bpmnElement = ref()
const bpmnInstances = () => (window as any)?.bpmnInstances const bpmnInstances = () => (window as any)?.bpmnInstances
const roleOptions = ref<RoleApi.RoleVO[]>([]) //
const deptTreeOptions = ref() //
const postOptions = ref<PostApi.PostVO[]>([]) //
const userOptions = ref<UserApi.UserVO[]>([]) //
const userGroupOptions = ref<UserGroupApi.UserGroupVO[]>([]) //
const taskAssignScriptDictDatas = getIntDictOptions(DICT_TYPE.BPM_TASK_ASSIGN_SCRIPT)
const resetTaskForm = () => { const resetTaskForm = () => {
for (let key in defaultTaskForm.value) { const businessObject = bpmnElement.value.businessObject
let value if (!businessObject) {
if (key === 'candidateUsers' || key === 'candidateGroups') { return
value = bpmnElement.value?.businessObject[key]
? bpmnElement.value.businessObject[key].split(',')
: []
} else {
value = bpmnElement.value?.businessObject[key] || defaultTaskForm.value[key]
} }
userTaskForm.value[key] = value if (businessObject.assignType != undefined) {
userTaskForm.value.assignType = parseInt(businessObject.assignType) as any
} else {
userTaskForm.value.assignType = undefined
}
if (businessObject.assignOptions && businessObject.assignOptions.length > 0) {
userTaskForm.value.assignOptions = businessObject.assignOptions?.split(',').map((item) => +item)
} else {
userTaskForm.value.assignOptions = []
} }
} }
const updateElementTask = (key) => {
const taskAttr = Object.create(null) /** 更新 assignType 字段时,需要清空 assignOptions并触发 bpmn 图更新 */
if (key === 'candidateUsers' || key === 'candidateGroups') { const changeAssignType = () => {
taskAttr[key] = userTaskForm.value.assignOptions = []
userTaskForm.value[key] && userTaskForm.value[key].length updateElementTask()
? userTaskForm.value[key].join() }
: null
} else { /** 选中某个 options 时候,更新 bpmn 图 */
taskAttr[key] = userTaskForm.value[key] || null const updateElementTask = () => {
} bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), {
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), taskAttr) assignType: userTaskForm.value.assignType,
assignOptions: userTaskForm.value.assignOptions.join(',')
})
} }
watch( watch(
@ -92,6 +190,21 @@ watch(
}, },
{ immediate: true } { immediate: true }
) )
onMounted(async () => {
//
roleOptions.value = await RoleApi.getSimpleRoleList()
//
const deptOptions = await DeptApi.getSimpleDeptList()
deptTreeOptions.value = handleTree(deptOptions, 'id')
//
postOptions.value = await PostApi.getSimplePostList()
//
userOptions.value = await UserApi.getSimpleUserList()
//
userGroupOptions.value = await UserGroupApi.getSimpleUserGroupList()
})
onBeforeUnmount(() => { onBeforeUnmount(() => {
bpmnElement.value = null bpmnElement.value = null
}) })

View File

@ -278,17 +278,6 @@ const remainingRouter: AppRouteRecordRaw[] = [
activeMenu: '/bpm/manager/model' activeMenu: '/bpm/manager/model'
} }
}, },
{
path: '/manager/task-assign-rule',
component: () => import('@/views/bpm/taskAssignRule/index.vue'),
name: 'BpmTaskAssignRuleList',
meta: {
noCache: true,
hidden: true,
canTo: true,
title: '任务分配规则'
}
},
{ {
path: '/process-instance/create', path: '/process-instance/create',
component: () => import('@/views/bpm/processInstance/create/index.vue'), component: () => import('@/views/bpm/processInstance/create/index.vue'),

View File

@ -57,18 +57,6 @@
width="300" width="300"
show-overflow-tooltip show-overflow-tooltip
/> />
<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> </el-table>
<!-- 分页 --> <!-- 分页 -->
<Pagination <Pagination
@ -129,16 +117,6 @@ const getList = async () => {
} }
} }
/** 点击任务分配按钮 */
const handleAssignRule = (row) => {
push({
name: 'BpmTaskAssignRuleList',
query: {
modelId: row.id
}
})
}
/** 流程表单的详情按钮操作 */ /** 流程表单的详情按钮操作 */
const formDetailVisible = ref(false) const formDetailVisible = ref(false)
const formDetailPreview = ref({ const formDetailPreview = ref({

View File

@ -161,14 +161,6 @@
> >
设计流程 设计流程
</el-button> </el-button>
<el-button
link
type="primary"
@click="handleAssignRule(scope.row)"
v-hasPermi="['bpm:task-assign-rule:query']"
>
分配规则
</el-button>
<el-button <el-button
link link
type="primary" type="primary"
@ -347,16 +339,6 @@ const handleDeploy = async (row) => {
} catch {} } catch {}
} }
/** 点击任务分配按钮 */
const handleAssignRule = (row) => {
push({
name: 'BpmTaskAssignRuleList',
query: {
modelId: row.id
}
})
}
/** 跳转到指定流程定义列表 */ /** 跳转到指定流程定义列表 */
const handleDefinitionList = (row) => { const handleDefinitionList = (row) => {
push({ push({

View File

@ -1,250 +0,0 @@
<template>
<Dialog v-model="dialogVisible" title="修改任务规则" width="600">
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="80px">
<el-form-item label="任务名称" prop="taskDefinitionName">
<el-input v-model="formData.taskDefinitionName" disabled placeholder="请输入流标标识" />
</el-form-item>
<el-form-item label="任务标识" prop="taskDefinitionKey">
<el-input v-model="formData.taskDefinitionKey" disabled placeholder="请输入任务标识" />
</el-form-item>
<el-form-item label="规则类型" prop="type">
<el-select v-model="formData.type" clearable style="width: 100%">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item v-if="formData.type === 10" label="指定角色" prop="roleIds">
<el-select v-model="formData.roleIds" clearable multiple style="width: 100%">
<el-option
v-for="item in roleOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item
v-if="formData.type === 20 || formData.type === 21"
label="指定部门"
prop="deptIds"
span="24"
>
<el-tree-select
ref="treeRef"
v-model="formData.deptIds"
:data="deptTreeOptions"
:props="defaultProps"
empty-text="加载中,请稍后"
multiple
node-key="id"
show-checkbox
/>
</el-form-item>
<el-form-item v-if="formData.type === 22" label="指定岗位" prop="postIds" span="24">
<el-select v-model="formData.postIds" clearable multiple style="width: 100%">
<el-option
v-for="item in postOptions"
:key="parseInt(item.id)"
:label="item.name"
:value="parseInt(item.id)"
/>
</el-select>
</el-form-item>
<el-form-item
v-if="formData.type === 30 || formData.type === 31 || formData.type === 32"
label="指定用户"
prop="userIds"
span="24"
>
<el-select v-model="formData.userIds" clearable multiple style="width: 100%">
<el-option
v-for="item in userOptions"
:key="parseInt(item.id)"
:label="item.nickname"
:value="parseInt(item.id)"
/>
</el-select>
</el-form-item>
<el-form-item v-if="formData.type === 40" label="指定用户组" prop="userGroupIds">
<el-select v-model="formData.userGroupIds" clearable multiple style="width: 100%">
<el-option
v-for="item in userGroupOptions"
:key="parseInt(item.id)"
:label="item.name"
:value="parseInt(item.id)"
/>
</el-select>
</el-form-item>
<el-form-item v-if="formData.type === 50" label="指定脚本" prop="scripts">
<el-select v-model="formData.scripts" clearable multiple style="width: 100%">
<el-option
v-for="dict in taskAssignScriptDictDatas"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-form>
<!-- 操作按钮 -->
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { defaultProps, handleTree } from '@/utils/tree'
import * as TaskAssignRuleApi from '@/api/bpm/taskAssignRule'
import * as RoleApi from '@/api/system/role'
import * as DeptApi from '@/api/system/dept'
import * as PostApi from '@/api/system/post'
import * as UserApi from '@/api/system/user'
import * as UserGroupApi from '@/api/bpm/userGroup'
defineOptions({ name: 'BpmTaskAssignRuleForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const formLoading = ref(false) // 12
const formData = ref({
type: Number(undefined),
modelId: '',
options: [],
roleIds: [],
deptIds: [],
postIds: [],
userIds: [],
userGroupIds: [],
scripts: []
})
const formRules = reactive({
type: [{ required: true, message: '规则类型不能为空', trigger: 'change' }],
roleIds: [{ required: true, message: '指定角色不能为空', trigger: 'change' }],
deptIds: [{ required: true, message: '指定部门不能为空', trigger: 'change' }],
postIds: [{ required: true, message: '指定岗位不能为空', trigger: 'change' }],
userIds: [{ required: true, message: '指定用户不能为空', trigger: 'change' }],
userGroupIds: [{ required: true, message: '指定用户组不能为空', trigger: 'change' }],
scripts: [{ required: true, message: '指定脚本不能为空', trigger: 'change' }]
})
const formRef = ref() // Ref
const roleOptions = ref<RoleApi.RoleVO[]>([]) //
const deptOptions = ref<DeptApi.DeptVO[]>([]) //
const deptTreeOptions = ref() //
const postOptions = ref<PostApi.PostVO[]>([]) //
const userOptions = ref<UserApi.UserVO[]>([]) //
const userGroupOptions = ref<UserGroupApi.UserGroupVO[]>([]) //
const taskAssignScriptDictDatas = getIntDictOptions(DICT_TYPE.BPM_TASK_ASSIGN_SCRIPT)
/** 打开弹窗 */
const open = async (modelId: string, row: TaskAssignRuleApi.TaskAssignVO) => {
// 1.
resetForm()
// 2.
formData.value = {
...row,
modelId: modelId,
options: [],
roleIds: [],
deptIds: [],
postIds: [],
userIds: [],
userGroupIds: [],
scripts: []
}
// options roleIds
if (row.type === 10) {
formData.value.roleIds.push(...row.options)
} else if (row.type === 20 || row.type === 21) {
formData.value.deptIds.push(...row.options)
} else if (row.type === 22) {
formData.value.postIds.push(...row.options)
} else if (row.type === 30 || row.type === 31 || row.type === 32) {
formData.value.userIds.push(...row.options)
} else if (row.type === 40) {
formData.value.userGroupIds.push(...row.options)
} else if (row.type === 50) {
formData.value.scripts.push(...row.options)
}
//
dialogVisible.value = true
//
roleOptions.value = await RoleApi.getSimpleRoleList()
//
deptOptions.value = await DeptApi.getSimpleDeptList()
deptTreeOptions.value = handleTree(deptOptions.value, 'id')
//
postOptions.value = await PostApi.getSimplePostList()
//
userOptions.value = await UserApi.getSimpleUserList()
//
userGroupOptions.value = await UserGroupApi.getSimpleUserGroupList()
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
//
const form = {
...formData.value,
taskDefinitionName: undefined
}
// roleIds options
if (form.type === 10) {
form.options = form.roleIds
} else if (form.type === 20 || form.type === 21) {
form.options = form.deptIds
} else if (form.type === 22) {
form.options = form.postIds
} else if (form.type === 30 || form.type === 31 || form.type === 32) {
form.options = form.userIds
} else if (form.type === 40) {
form.options = form.userGroupIds
} else if (form.type === 50) {
form.options = form.scripts
}
form.roleIds = undefined
form.deptIds = undefined
form.postIds = undefined
form.userIds = undefined
form.userGroupIds = undefined
form.scripts = undefined
//
formLoading.value = true
try {
const data = form as unknown as TaskAssignRuleApi.TaskAssignVO
if (!data.id) {
await TaskAssignRuleApi.createTaskAssignRule(data)
message.success(t('common.createSuccess'))
} else {
await TaskAssignRuleApi.updateTaskAssignRule(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formRef.value?.resetFields()
}
</script>

View File

@ -1,136 +0,0 @@
<template>
<ContentWrap>
<el-table v-loading="loading" :data="list">
<el-table-column label="任务名" align="center" prop="taskDefinitionName" />
<el-table-column label="任务标识" align="center" prop="taskDefinitionKey" />
<el-table-column label="规则类型" align="center" prop="type">
<template #default="scope">
<dict-tag :type="DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE" :value="scope.row.type" />
</template>
</el-table-column>
<el-table-column label="规则范围" align="center" prop="options">
<template #default="scope">
<el-tag class="mr-5px" :key="option" v-for="option in scope.row.options">
{{ getAssignRuleOptionName(scope.row.type, option) }}
</el-tag>
</template>
</el-table-column>
<el-table-column v-if="queryParams.modelId" label="操作" align="center">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm(scope.row)"
v-hasPermi="['bpm:task-assign-rule:update']"
>
修改
</el-button>
</template>
</el-table-column>
</el-table>
</ContentWrap>
<!-- 添加/修改弹窗 -->
<TaskAssignRuleForm ref="formRef" @success="getList" />
</template>
<script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import * as TaskAssignRuleApi from '@/api/bpm/taskAssignRule'
import * as RoleApi from '@/api/system/role'
import * as DeptApi from '@/api/system/dept'
import * as PostApi from '@/api/system/post'
import * as UserApi from '@/api/system/user'
import * as UserGroupApi from '@/api/bpm/userGroup'
import TaskAssignRuleForm from './TaskAssignRuleForm.vue'
defineOptions({ name: 'BpmTaskAssignRule' })
const { query } = useRoute() //
const loading = ref(true) //
const list = ref([]) //
const queryParams = reactive({
modelId: query.modelId, // modelId
processDefinitionId: query.processDefinitionId // processDefinitionId
})
const roleOptions = ref<RoleApi.RoleVO[]>([]) //
const deptOptions = ref<DeptApi.DeptVO[]>([]) //
const postOptions = ref<PostApi.PostVO[]>([]) //
const userOptions = ref<UserApi.UserVO[]>([]) //
const userGroupOptions = ref<UserGroupApi.UserGroupVO[]>([]) //
const taskAssignScriptDictDatas = getIntDictOptions(DICT_TYPE.BPM_TASK_ASSIGN_SCRIPT)
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
list.value = await TaskAssignRuleApi.getTaskAssignRuleList(queryParams)
} finally {
loading.value = false
}
}
/** 翻译规则范围 */
// TODO ts
const getAssignRuleOptionName = (type, option) => {
if (type === 10) {
for (const roleOption of roleOptions.value) {
if (roleOption.id === option) {
return roleOption.name
}
}
} else if (type === 20 || type === 21) {
for (const deptOption of deptOptions.value) {
if (deptOption.id === option) {
return deptOption.name
}
}
} else if (type === 22) {
for (const postOption of postOptions.value) {
if (postOption.id === option) {
return postOption.name
}
}
} else if (type === 30 || type === 31 || type === 32) {
for (const userOption of userOptions.value) {
if (userOption.id === option) {
return userOption.nickname
}
}
} else if (type === 40) {
for (const userGroupOption of userGroupOptions.value) {
if (userGroupOption.id === option) {
return userGroupOption.name
}
}
} else if (type === 50) {
option = option + '' // string
for (const dictData of taskAssignScriptDictDatas) {
if (dictData.value === option) {
return dictData.label
}
}
}
return '未知(' + option + ')'
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (row: TaskAssignRuleApi.TaskAssignVO) => {
formRef.value.open(queryParams.modelId, row)
}
/** 初始化 */
onMounted(async () => {
await getList()
//
roleOptions.value = await RoleApi.getSimpleRoleList()
//
deptOptions.value = await DeptApi.getSimpleDeptList()
//
postOptions.value = await PostApi.getSimplePostList()
//
userOptions.value = await UserApi.getSimpleUserList()
//
userGroupOptions.value = await UserGroupApi.getSimpleUserGroupList()
})
</script>