bpm:流程分配任务的列表 50%

This commit is contained in:
YunaiV 2023-01-19 17:11:31 +08:00
parent 62a86fdff1
commit fabdccd981
4 changed files with 378 additions and 2 deletions

View File

@ -52,6 +52,7 @@
"vue-i18n": "9.2.2",
"vue-router": "^4.1.6",
"vue-types": "^5.0.2",
"vue3-treeselect": "^0.1.10",
"vxe-table": "^4.3.9",
"web-storage-cache": "^1.1.1",
"xe-utils": "^3.5.7"

View File

@ -177,6 +177,39 @@ const remainingRouter: AppRouteRecordRaw[] = [
title: '500',
noTagsView: true
}
},
{
path: '/bpm',
component: Layout,
name: 'bpm',
meta: {
hidden: true
},
children: [
{
path: '/manager/definition',
component: () => import('@/views/bpm/definition/index.vue'),
name: 'BpmProcessDefinitionList',
meta: {
noCache: true,
hidden: true,
canTo: true,
title: '流程定义',
activeMenu: 'bpm/definition/index'
}
},
{
path: '/manager/task-assign-rule',
component: () => import('@/views/bpm/taskAssignRule/index.vue'),
name: 'BpmTaskAssignRuleList',
meta: {
noCache: true,
hidden: true,
canTo: true,
title: '任务分配规则'
}
}
]
}
]

View File

@ -1,4 +1,309 @@
<template>
<div>index</div>
<ContentWrap>
<!-- 列表 -->
<XTable @register="registerTable">
<template #options_default="{ row }">
<el-tag :key="option" v-for="option in row.options">
{{ getAssignRuleOptionName(row.type, option) }}
</el-tag>
</template>
<!-- 操作 -->
<template #actionbtns_default="{ row }" v-if="modelId">
<vxe-button
type="text"
status="primary"
content="修改"
icon="vxe-icon-edit"
@click="handleUpdate(row)"
/>
</template>
</XTable>
<!-- 添加/修改弹窗 -->
<XModal v-model="openVisible" title="修改任务规则" width="800" height="35%" resize>
<el-form
ref="xForm"
:model="formData"
:rules="formRules"
label-width="120px"
class="demo-ruleForm"
size="default"
status-icon
>
<el-form-item label="任务名称" prop="taskDefinitionName">
<el-input -model="formData.taskDefinitionName" placeholder="请输入流标标识" disabled />
</el-form-item>
<el-form-item label="任务标识" prop="taskDefinitionKey">
<el-input v-model="formData.taskDefinitionKey" placeholder="请输入任务标识" disabled />
</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 taskAssignRuleTypeDictDatas"
:key="parseInt(dict.value)"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select>
</el-form-item>
<el-form-item v-if="formData.type === 10" label="指定角色" prop="roleIds">
<el-select v-model="formData.roleIds" multiple clearable style="width: 100%">
<el-option
v-for="item in roleOptions"
:key="parseInt(item.id)"
:label="item.name"
:value="parseInt(item.id)"
/>
</el-select>
</el-form-item>
<el-form-item
label="指定部门"
prop="deptIds"
span="24"
v-if="formData.type === 20 || formData.type === 21"
>
<treeselect
v-model="formData.deptIds"
:options="deptTreeOptions"
multiple
flat
:defaultExpandLevel="3"
placeholder="请选择指定部门"
:normalizer="normalizer"
/>
</el-form-item>
<el-form-item label="指定岗位" prop="postIds" span="24" v-if="formData.type === 22">
<el-select v-model="formData.postIds" multiple clearable 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
label="指定用户"
prop="userIds"
span="24"
v-if="formData.type === 30 || formData.type === 31 || formData.type === 32"
>
<el-select v-model="formData.userIds" multiple clearable 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 label="指定用户组" prop="userGroupIds" v-if="formData.type === 40">
<el-select v-model="formData.userGroupIds" multiple clearable 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 label="指定脚本" prop="scripts" v-if="formData.type === 50">
<el-select v-model="formData.scripts" multiple clearable style="width: 100%">
<el-option
v-for="dict in taskAssignScriptDictDatas"
:key="parseInt(dict.value)"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<XButton type="primary" title="保存" :loading="loading" @click="submitEvent(xForm)" />
<XButton title="关闭" @click="resetEvent(xForm)" />
</template>
</XModal>
</ContentWrap>
</template>
<script setup lang="ts" name="TaskAssignRule"></script>
<script setup lang="ts" name="TaskAssignRule">
// import
import { onMounted, reactive, ref } from 'vue'
import { ElInput, ElTag, ElOption, ElSelect, ElForm, ElFormItem } from 'element-plus'
import type { FormInstance } from 'element-plus'
// import
import Treeselect from 'vue3-treeselect'
import 'vue3-treeselect/dist/vue3-treeselect.css'
import { useXTable } from '@/hooks/web/useXTable'
import { allSchemas } from './taskAssignRule.data'
import * as TaskAssignRuleApi from '@/api/bpm/taskAssignRule'
import { listSimpleRolesApi } from '@/api/system/role'
import { handleTree } from '@/utils/tree'
import { listSimplePostsApi } from '@/api/system/post'
import { getListSimpleUsersApi } from '@/api/system/user'
import { listSimpleUserGroupsApi } from '@/api/bpm/userGroup'
import { listSimpleDeptApi } from '@/api/system/dept'
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
// import {useI18n} from "@/hooks/web/useI18n";
// import {useMessage} from "@/hooks/web/useMessage";
import { useRoute } from 'vue-router'
// const { t } = useI18n() //
// const message = useMessage() //
// const router = useRouter() //
const { query } = useRoute()
// ========== ==========
// modelId
const modelId = query.modelId
// processDefinitionId
const processDefinitionId = query.processDefinitionId
//
const queryParams = reactive({
modelId: modelId,
processDefinitionId: processDefinitionId
})
const [registerTable] = useXTable({
allSchemas: allSchemas,
params: queryParams,
getListApi: TaskAssignRuleApi.getTaskAssignRuleList,
isList: false // TODO isList true
})
//
const xForm = ref<FormInstance>()
const formData = ref()
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 loading = ref(false)
const roleOptions = ref() //
const deptOptions = ref() //
const deptTreeOptions = ref()
const postOptions = ref() //
const userOptions = ref() //
const userGroupOptions = ref() //
const taskAssignScriptDictDatas = getDictOptions(DICT_TYPE.BPM_TASK_ASSIGN_SCRIPT)
const taskAssignRuleTypeDictDatas = getDictOptions(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE)
//
const openVisible = ref(false)
//
const submitEvent = async (formEl: FormInstance | undefined) => {
console.log('确认')
if (!formEl) return
loading.value = true
await formEl.validate((valid, fields) => {
if (valid) {
console.log('submit!')
loading.value = false
openVisible.value = false
} else {
console.log('error submit!', fields)
loading.value = false
}
})
}
const resetEvent = (formEl: FormInstance | undefined) => {
if (!formEl) return
formEl.resetFields()
openVisible.value = false
}
//
const handleUpdate = (row) => {
console.log(row, '修改i数据')
openVisible.value = true
formData.value = { ...row }
}
//
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 normalizer = (node) => {
return {
id: node.id,
label: node.name,
children: node.children
}
}
// ========== ==========
onMounted(() => {
//
roleOptions.value = []
listSimpleRolesApi().then((data) => {
roleOptions.value.push(...data)
})
//
deptOptions.value = []
deptTreeOptions.value = []
listSimpleDeptApi().then((data) => {
deptOptions.value.push(...data)
deptTreeOptions.value.push(...handleTree(data, 'id'))
})
//
postOptions.value = []
listSimplePostsApi().then((data) => {
postOptions.value.push(...data)
})
//
userOptions.value = []
getListSimpleUsersApi().then((data) => {
userOptions.value.push(...data)
})
//
userGroupOptions.value = []
listSimpleUserGroupsApi().then((data) => {
userGroupOptions.value.push(...data)
})
})
</script>

View File

@ -0,0 +1,37 @@
import { reactive } from 'vue'
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
import { DICT_TYPE } from '@/utils/dict'
// CrudSchema
const crudSchemas = reactive<VxeCrudSchema>({
primaryKey: 'id',
primaryType: null,
action: true,
actionWidth: '200px',
columns: [
{
title: '任务名',
field: 'taskDefinitionName'
},
{
title: '任务标识',
field: 'taskDefinitionKey'
},
{
title: '规则类型',
field: 'category',
dictType: DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE,
dictClass: 'number'
},
{
title: '规则范围',
field: 'options',
table: {
slots: {
default: 'options_default'
}
}
}
]
})
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)