Commit ee6317e9060a4276767926dfd959ffab819a38e8
1 parent
88fc7ed3
feat: bpm api
Showing
20 changed files
with
827 additions
and
15 deletions
yudao-ui-admin-vue3/src/api/bpm/form/index.ts
0 → 100644
| 1 | +import { useAxios } from '@/hooks/web/useAxios' | ||
| 2 | +import { FormVO } from './types' | ||
| 3 | +const request = useAxios() | ||
| 4 | + | ||
| 5 | +// 创建工作流的表单定义 | ||
| 6 | +export const createFormApi = async (data: FormVO) => { | ||
| 7 | + return await request.post({ | ||
| 8 | + url: '/bpm/form/create', | ||
| 9 | + data: data | ||
| 10 | + }) | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +// 更新工作流的表单定义 | ||
| 14 | +export const updateFormApi = async (data: FormVO) => { | ||
| 15 | + return await request.put({ | ||
| 16 | + url: '/bpm/form/update', | ||
| 17 | + data: data | ||
| 18 | + }) | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +// 删除工作流的表单定义 | ||
| 22 | +export const deleteFormApi = async (id: number) => { | ||
| 23 | + return await request.delete({ | ||
| 24 | + url: '/bpm/form/delete?id=' + id | ||
| 25 | + }) | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +// 获得工作流的表单定义 | ||
| 29 | +export const getFormApi = async (id: number) => { | ||
| 30 | + return await request.get({ | ||
| 31 | + url: '/bpm/form/get?id=' + id | ||
| 32 | + }) | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +// 获得工作流的表单定义分页 | ||
| 36 | +export const getFormPageApi = async (params) => { | ||
| 37 | + return await request.get({ | ||
| 38 | + url: '/bpm/form/page', | ||
| 39 | + params | ||
| 40 | + }) | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +// 获得动态表单的精简列表 | ||
| 44 | +export const getSimpleFormsApi = async () => { | ||
| 45 | + return await request.get({ | ||
| 46 | + url: '/bpm/form/list-all-simple' | ||
| 47 | + }) | ||
| 48 | +} |
yudao-ui-admin-vue3/src/api/bpm/form/types.ts
0 → 100644
yudao-ui-admin-vue3/src/api/bpm/leave/index.ts
0 → 100644
| 1 | +import { useAxios } from '@/hooks/web/useAxios' | ||
| 2 | +import { LeaveVO } from './types' | ||
| 3 | +const request = useAxios() | ||
| 4 | + | ||
| 5 | +// 创建请假申请 | ||
| 6 | +export const createLeaveApi = async (data: LeaveVO) => { | ||
| 7 | + return await request.post({ url: '/bpm/oa/leave/create', data: data }) | ||
| 8 | +} | ||
| 9 | + | ||
| 10 | +// 获得请假申请 | ||
| 11 | +export const getLeaveApi = async (id: number) => { | ||
| 12 | + return await request.get({ url: '/bpm/oa/leave/get?id=' + id }) | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +// 获得请假申请分页 | ||
| 16 | +export const getLeavePageApi = async (params) => { | ||
| 17 | + return await request.get({ url: '/bpm/oa/leave/page', params }) | ||
| 18 | +} |
yudao-ui-admin-vue3/src/api/bpm/leave/types.ts
0 → 100644
yudao-ui-admin-vue3/src/api/bpm/model/index.ts
0 → 100644
| 1 | +import { useAxios } from '@/hooks/web/useAxios' | ||
| 2 | +import { ModelVO } from './types' | ||
| 3 | +const request = useAxios() | ||
| 4 | + | ||
| 5 | +export const getModelPage = async (params) => { | ||
| 6 | + return await request.get({ url: '/bpm/model/page', params }) | ||
| 7 | +} | ||
| 8 | + | ||
| 9 | +export const getModel = async (id: number) => { | ||
| 10 | + return await request.get({ url: '/bpm/model/get?id=' + id }) | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +export const updateModel = async (data: ModelVO) => { | ||
| 14 | + return await request.put({ url: '/bpm/model/update', data: data }) | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +// 任务状态修改 | ||
| 18 | +export const updateModelState = async (id: number, state: string) => { | ||
| 19 | + const data = { | ||
| 20 | + id: id, | ||
| 21 | + state: state | ||
| 22 | + } | ||
| 23 | + return await request.put({ url: '/bpm/model/update-state', data: data }) | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +export const createModel = async (data: ModelVO) => { | ||
| 27 | + return await request.post({ url: '/bpm/model/create', data: data }) | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +export const deleteModel = async (id: number) => { | ||
| 31 | + return await request.delete({ url: '/bpm/model/delete?id=' + id }) | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +export const deployModel = async (id: number) => { | ||
| 35 | + return await request.post({ url: '/bpm/model/deploy?id=' + id }) | ||
| 36 | +} |
yudao-ui-admin-vue3/src/api/bpm/model/types.ts
0 → 100644
| 1 | +export type ModelVO = { | ||
| 2 | + id: number | ||
| 3 | + formName: string | ||
| 4 | + key: string | ||
| 5 | + name: string | ||
| 6 | + description: string | ||
| 7 | + category: string | ||
| 8 | + formType: number | ||
| 9 | + formId: number | ||
| 10 | + formCustomCreatePath: string | ||
| 11 | + formCustomViewPath: string | ||
| 12 | + status: number | ||
| 13 | + remark: string | ||
| 14 | + createTime: string | ||
| 15 | +} |
yudao-ui-admin-vue3/src/api/bpm/processInstance/index.ts
0 → 100644
| 1 | +import { useAxios } from '@/hooks/web/useAxios' | ||
| 2 | +import { ProcessInstanceVO } from './types' | ||
| 3 | +const request = useAxios() | ||
| 4 | + | ||
| 5 | +export const getMyProcessInstancePage = async (params) => { | ||
| 6 | + return await request.get({ url: '/bpm/process-instance/my-page', params }) | ||
| 7 | +} | ||
| 8 | + | ||
| 9 | +export const createProcessInstance = async (data: ProcessInstanceVO) => { | ||
| 10 | + return await request.post({ url: '/bpm/process-instance/create', data: data }) | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +export const cancelProcessInstance = async (id: number, reason: string) => { | ||
| 14 | + const data = { | ||
| 15 | + id: id, | ||
| 16 | + reason: reason | ||
| 17 | + } | ||
| 18 | + return await request.delete({ url: '/bpm/process-instance/cancel', data: data }) | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +export const getProcessInstance = async (id: number) => { | ||
| 22 | + return await request.get({ url: '/bpm/process-instance/get?id=' + id }) | ||
| 23 | +} |
yudao-ui-admin-vue3/src/api/bpm/processInstance/types.ts
0 → 100644
| 1 | +export type task = { | ||
| 2 | + id: string | ||
| 3 | + name: string | ||
| 4 | +} | ||
| 5 | +export type ProcessInstanceVO = { | ||
| 6 | + id: number | ||
| 7 | + name: string | ||
| 8 | + processDefinitionId: string | ||
| 9 | + category: string | ||
| 10 | + result: number | ||
| 11 | + tasks: task[] | ||
| 12 | + fields: string[] | ||
| 13 | + status: number | ||
| 14 | + remark: string | ||
| 15 | + businessKey: string | ||
| 16 | + createTime: string | ||
| 17 | + endTime: string | ||
| 18 | +} |
yudao-ui-admin-vue3/src/api/bpm/task/index.ts
0 → 100644
| 1 | +import { useAxios } from '@/hooks/web/useAxios' | ||
| 2 | + | ||
| 3 | +const request = useAxios() | ||
| 4 | + | ||
| 5 | +export const getTodoTaskPage = async (params) => { | ||
| 6 | + return await request.get({ url: '/bpm/task/todo-page', params }) | ||
| 7 | +} | ||
| 8 | + | ||
| 9 | +export const getDoneTaskPage = async (params) => { | ||
| 10 | + return await request.get({ url: '/bpm/task/done-page', params }) | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +export const completeTask = async (data) => { | ||
| 14 | + return await request.put({ url: '/bpm/task/complete', data: data }) | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +export const approveTask = async (data) => { | ||
| 18 | + return await request.put({ url: '/bpm/task/approve', data: data }) | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +export const rejectTask = async (data) => { | ||
| 22 | + return await request.put({ url: '/bpm/task/reject', data: data }) | ||
| 23 | +} | ||
| 24 | +export const backTask = async (data) => { | ||
| 25 | + return await request.put({ url: '/bpm/task/back', data: data }) | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +export const updateTaskAssignee = async (data) => { | ||
| 29 | + return await request.put({ url: '/bpm/task/update-assignee', data: data }) | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +export const getTaskListByProcessInstanceId = async (processInstanceId) => { | ||
| 33 | + return await request.get({ | ||
| 34 | + url: '/bpm/task/list-by-process-instance-id?processInstanceId=' + processInstanceId | ||
| 35 | + }) | ||
| 36 | +} |
yudao-ui-admin-vue3/src/api/bpm/task/types.ts
0 → 100644
yudao-ui-admin-vue3/src/api/bpm/taskAssignRule/index.ts
0 → 100644
| 1 | +import { useAxios } from '@/hooks/web/useAxios' | ||
| 2 | +import { TaskAssignVO } from './types' | ||
| 3 | +const request = useAxios() | ||
| 4 | + | ||
| 5 | +export const getTaskAssignRuleList = async (params) => { | ||
| 6 | + return await request.get({ url: '/bpm/task-assign-rule/list', params }) | ||
| 7 | +} | ||
| 8 | + | ||
| 9 | +export const createTaskAssignRule = async (data: TaskAssignVO) => { | ||
| 10 | + return await request.post({ | ||
| 11 | + url: '/bpm/task-assign-rule/create', | ||
| 12 | + data: data | ||
| 13 | + }) | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +export const updateTaskAssignRule = async (data: TaskAssignVO) => { | ||
| 17 | + return await request.put({ | ||
| 18 | + url: '/bpm/task-assign-rule/update', | ||
| 19 | + data: data | ||
| 20 | + }) | ||
| 21 | +} |
yudao-ui-admin-vue3/src/api/bpm/taskAssignRule/types.ts
0 → 100644
yudao-ui-admin-vue3/src/api/bpm/userGroup/index.ts
0 → 100644
| 1 | +import { useAxios } from '@/hooks/web/useAxios' | ||
| 2 | +import { UserGroupVO } from './types' | ||
| 3 | +const request = useAxios() | ||
| 4 | + | ||
| 5 | +// 创建用户组 | ||
| 6 | +export const createUserGroupApi = async (data: UserGroupVO) => { | ||
| 7 | + return await request.post({ | ||
| 8 | + url: '/bpm/user-group/create', | ||
| 9 | + data: data | ||
| 10 | + }) | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +// 更新用户组 | ||
| 14 | +export const updateUserGroupApi = async (data: UserGroupVO) => { | ||
| 15 | + return await request.put({ | ||
| 16 | + url: '/bpm/user-group/update', | ||
| 17 | + data: data | ||
| 18 | + }) | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +// 删除用户组 | ||
| 22 | +export const deleteUserGroupApi = async (id: number) => { | ||
| 23 | + return await request.delete({ url: '/bpm/user-group/delete?id=' + id }) | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +// 获得用户组 | ||
| 27 | +export const getUserGroupApi = async (id: number) => { | ||
| 28 | + return await request.get({ url: '/bpm/user-group/get?id=' + id }) | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +// 获得用户组分页 | ||
| 32 | +export const getUserGroupPageApi = async (params) => { | ||
| 33 | + return await request.get({ url: '/bpm/user-group/page', params }) | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +// 获取用户组精简信息列表 | ||
| 37 | +export const listSimpleUserGroupsApi = async () => { | ||
| 38 | + return await request.get({ url: '/bpm/user-group/list-all-simple' }) | ||
| 39 | +} |
yudao-ui-admin-vue3/src/api/bpm/userGroup/types.ts
0 → 100644
yudao-ui-admin-vue3/src/api/system/user/index.ts
| @@ -55,3 +55,8 @@ export const updateUserStatusApi = (id: number, status: number) => { | @@ -55,3 +55,8 @@ export const updateUserStatusApi = (id: number, status: number) => { | ||
| 55 | } | 55 | } |
| 56 | return request.put({ url: '/system/user/update-status', data: data }) | 56 | return request.put({ url: '/system/user/update-status', data: data }) |
| 57 | } | 57 | } |
| 58 | + | ||
| 59 | +// 获取用户精简信息列表 | ||
| 60 | +export const getListSimpleUsersApi = () => { | ||
| 61 | + return request.get({ url: '/system/user/list-all-simple' }) | ||
| 62 | +} |
yudao-ui-admin-vue3/src/views/bpm/definition/index.vue deleted
yudao-ui-admin-vue3/src/views/bpm/form/form.data.ts
0 → 100644
| 1 | +import { reactive } from 'vue' | ||
| 2 | +import { useI18n } from '@/hooks/web/useI18n' | ||
| 3 | +import { required } from '@/utils/formRules' | ||
| 4 | +import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas' | ||
| 5 | +import { DICT_TYPE } from '@/utils/dict' | ||
| 6 | +const { t } = useI18n() // 国际化 | ||
| 7 | + | ||
| 8 | +// 表单校验 | ||
| 9 | +export const rules = reactive({ | ||
| 10 | + name: [required] | ||
| 11 | +}) | ||
| 12 | + | ||
| 13 | +// CrudSchema | ||
| 14 | +const crudSchemas = reactive<CrudSchema[]>([ | ||
| 15 | + { | ||
| 16 | + label: t('common.index'), | ||
| 17 | + field: 'id', | ||
| 18 | + type: 'index', | ||
| 19 | + form: { | ||
| 20 | + show: false | ||
| 21 | + }, | ||
| 22 | + detail: { | ||
| 23 | + show: false | ||
| 24 | + } | ||
| 25 | + }, | ||
| 26 | + { | ||
| 27 | + label: '表单名', | ||
| 28 | + field: 'name', | ||
| 29 | + search: { | ||
| 30 | + show: true | ||
| 31 | + } | ||
| 32 | + }, | ||
| 33 | + { | ||
| 34 | + label: t('common.status'), | ||
| 35 | + field: 'status', | ||
| 36 | + dictType: DICT_TYPE.COMMON_STATUS | ||
| 37 | + }, | ||
| 38 | + { | ||
| 39 | + label: '备注', | ||
| 40 | + field: 'remark' | ||
| 41 | + }, | ||
| 42 | + { | ||
| 43 | + label: t('common.createTime'), | ||
| 44 | + field: 'createTime', | ||
| 45 | + form: { | ||
| 46 | + show: false | ||
| 47 | + } | ||
| 48 | + }, | ||
| 49 | + { | ||
| 50 | + label: t('table.action'), | ||
| 51 | + field: 'action', | ||
| 52 | + width: '240px', | ||
| 53 | + form: { | ||
| 54 | + show: false | ||
| 55 | + }, | ||
| 56 | + detail: { | ||
| 57 | + show: false | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | +]) | ||
| 61 | +export const { allSchemas } = useCrudSchemas(crudSchemas) |
yudao-ui-admin-vue3/src/views/bpm/form/index.vue
| 1 | -<script setup lang="ts"></script> | 1 | +<script setup lang="ts"> |
| 2 | +import { ref, unref } from 'vue' | ||
| 3 | +import dayjs from 'dayjs' | ||
| 4 | +import { ElMessage } from 'element-plus' | ||
| 5 | +import { DICT_TYPE } from '@/utils/dict' | ||
| 6 | +import { useTable } from '@/hooks/web/useTable' | ||
| 7 | +import { useI18n } from '@/hooks/web/useI18n' | ||
| 8 | +import { FormExpose } from '@/components/Form' | ||
| 9 | +import type { FormVO } from '@/api/bpm/form/types' | ||
| 10 | +import { rules, allSchemas } from './form.data' | ||
| 11 | +import * as FormApi from '@/api/bpm/form' | ||
| 12 | +const { t } = useI18n() // 国际化 | ||
| 13 | + | ||
| 14 | +// ========== 列表相关 ========== | ||
| 15 | +const { register, tableObject, methods } = useTable<FormVO>({ | ||
| 16 | + getListApi: FormApi.getFormPageApi, | ||
| 17 | + delListApi: FormApi.deleteFormApi | ||
| 18 | +}) | ||
| 19 | +const { getList, setSearchParams, delList } = methods | ||
| 20 | + | ||
| 21 | +// ========== CRUD 相关 ========== | ||
| 22 | +const actionLoading = ref(false) // 遮罩层 | ||
| 23 | +const actionType = ref('') // 操作按钮的类型 | ||
| 24 | +const dialogVisible = ref(false) // 是否显示弹出层 | ||
| 25 | +const dialogTitle = ref('edit') // 弹出层标题 | ||
| 26 | +const formRef = ref<FormExpose>() // 表单 Ref | ||
| 27 | + | ||
| 28 | +// 设置标题 | ||
| 29 | +const setDialogTile = (type: string) => { | ||
| 30 | + dialogTitle.value = t('action.' + type) | ||
| 31 | + actionType.value = type | ||
| 32 | + dialogVisible.value = true | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +// 新增操作 | ||
| 36 | +const handleCreate = () => { | ||
| 37 | + setDialogTile('create') | ||
| 38 | + // 重置表单 | ||
| 39 | + unref(formRef)?.getElFormRef()?.resetFields() | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +// 修改操作 | ||
| 43 | +const handleUpdate = async (row: FormVO) => { | ||
| 44 | + setDialogTile('update') | ||
| 45 | + // 设置数据 | ||
| 46 | + const res = await FormApi.getFormApi(row.id) | ||
| 47 | + unref(formRef)?.setValues(res) | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +// 提交按钮 | ||
| 51 | +const submitForm = async () => { | ||
| 52 | + actionLoading.value = true | ||
| 53 | + // 提交请求 | ||
| 54 | + try { | ||
| 55 | + const data = unref(formRef)?.formModel as FormVO | ||
| 56 | + if (actionType.value === 'create') { | ||
| 57 | + await FormApi.createFormApi(data) | ||
| 58 | + ElMessage.success(t('common.createSuccess')) | ||
| 59 | + } else { | ||
| 60 | + await FormApi.updateFormApi(data) | ||
| 61 | + ElMessage.success(t('common.updateSuccess')) | ||
| 62 | + } | ||
| 63 | + // 操作成功,重新加载列表 | ||
| 64 | + dialogVisible.value = false | ||
| 65 | + await getList() | ||
| 66 | + } finally { | ||
| 67 | + actionLoading.value = false | ||
| 68 | + } | ||
| 69 | +} | ||
| 70 | + | ||
| 71 | +// 删除操作 | ||
| 72 | +const handleDelete = (row: FormVO) => { | ||
| 73 | + delList(row.id, false) | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +// ========== 详情相关 ========== | ||
| 77 | +const detailRef = ref() // 详情 Ref | ||
| 78 | + | ||
| 79 | +// 详情操作 | ||
| 80 | +const handleDetail = async (row: FormVO) => { | ||
| 81 | + // 设置数据 | ||
| 82 | + detailRef.value = row | ||
| 83 | + setDialogTile('detail') | ||
| 84 | +} | ||
| 85 | + | ||
| 86 | +// ========== 初始化 ========== | ||
| 87 | +getList() | ||
| 88 | +</script> | ||
| 2 | 89 | ||
| 3 | <template> | 90 | <template> |
| 4 | - <div>index</div> | ||
| 5 | -</template> | 91 | + <!-- 搜索工作区 --> |
| 92 | + <ContentWrap> | ||
| 93 | + <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> | ||
| 94 | + </ContentWrap> | ||
| 95 | + <ContentWrap> | ||
| 96 | + <!-- 操作工具栏 --> | ||
| 97 | + <div class="mb-10px"> | ||
| 98 | + <el-button type="primary" v-hasPermi="['bpm:form:create']" @click="handleCreate"> | ||
| 99 | + <Icon icon="ep:zoom-in" class="mr-5px" /> {{ t('action.add') }} | ||
| 100 | + </el-button> | ||
| 101 | + </div> | ||
| 102 | + <!-- 列表 --> | ||
| 103 | + <Table | ||
| 104 | + :columns="allSchemas.tableColumns" | ||
| 105 | + :selection="false" | ||
| 106 | + :data="tableObject.tableList" | ||
| 107 | + :loading="tableObject.loading" | ||
| 108 | + :pagination="{ | ||
| 109 | + total: tableObject.total | ||
| 110 | + }" | ||
| 111 | + v-model:pageSize="tableObject.pageSize" | ||
| 112 | + v-model:currentPage="tableObject.currentPage" | ||
| 113 | + @register="register" | ||
| 114 | + > | ||
| 115 | + <template #status="{ row }"> | ||
| 116 | + <DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" /> | ||
| 117 | + </template> | ||
| 118 | + <template #createTime="{ row }"> | ||
| 119 | + <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span> | ||
| 120 | + </template> | ||
| 121 | + <template #action="{ row }"> | ||
| 122 | + <el-button link type="primary" v-hasPermi="['bpm:form:update']" @click="handleUpdate(row)"> | ||
| 123 | + <Icon icon="ep:edit" class="mr-1px" /> {{ t('action.edit') }} | ||
| 124 | + </el-button> | ||
| 125 | + <el-button link type="primary" v-hasPermi="['bpm:form:update']" @click="handleDetail(row)"> | ||
| 126 | + <Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }} | ||
| 127 | + </el-button> | ||
| 128 | + <el-button link type="primary" v-hasPermi="['bpm:form:delete']" @click="handleDelete(row)"> | ||
| 129 | + <Icon icon="ep:delete" class="mr-1px" /> {{ t('action.del') }} | ||
| 130 | + </el-button> | ||
| 131 | + </template> | ||
| 132 | + </Table> | ||
| 133 | + </ContentWrap> | ||
| 6 | 134 | ||
| 7 | -<style scoped></style> | 135 | + <Dialog v-model="dialogVisible" :title="dialogTitle"> |
| 136 | + <!-- 对话框(添加 / 修改) --> | ||
| 137 | + <Form | ||
| 138 | + v-if="['create', 'update'].includes(actionType)" | ||
| 139 | + :schema="allSchemas.formSchema" | ||
| 140 | + :rules="rules" | ||
| 141 | + ref="formRef" | ||
| 142 | + /> | ||
| 143 | + <!-- 对话框(详情) --> | ||
| 144 | + <Descriptions | ||
| 145 | + v-if="actionType === 'detail'" | ||
| 146 | + :schema="allSchemas.detailSchema" | ||
| 147 | + :data="detailRef" | ||
| 148 | + > | ||
| 149 | + <template #status="{ row }"> | ||
| 150 | + <DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" /> | ||
| 151 | + </template> | ||
| 152 | + <template #createTime="{ row }"> | ||
| 153 | + <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span> | ||
| 154 | + </template> | ||
| 155 | + </Descriptions> | ||
| 156 | + <!-- 操作按钮 --> | ||
| 157 | + <template #footer> | ||
| 158 | + <el-button | ||
| 159 | + v-if="['create', 'update'].includes(actionType)" | ||
| 160 | + type="primary" | ||
| 161 | + :loading="actionLoading" | ||
| 162 | + @click="submitForm" | ||
| 163 | + > | ||
| 164 | + {{ t('action.save') }} | ||
| 165 | + </el-button> | ||
| 166 | + <el-button @click="dialogVisible = false">{{ t('dialog.close') }}</el-button> | ||
| 167 | + </template> | ||
| 168 | + </Dialog> | ||
| 169 | +</template> |
yudao-ui-admin-vue3/src/views/bpm/group/group.data.ts
0 → 100644
| 1 | +import { reactive } from 'vue' | ||
| 2 | +import { useI18n } from '@/hooks/web/useI18n' | ||
| 3 | +import { required } from '@/utils/formRules' | ||
| 4 | +import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas' | ||
| 5 | +import { DICT_TYPE } from '@/utils/dict' | ||
| 6 | +const { t } = useI18n() // 国际化 | ||
| 7 | + | ||
| 8 | +// 表单校验 | ||
| 9 | +export const rules = reactive({ | ||
| 10 | + name: [required] | ||
| 11 | +}) | ||
| 12 | + | ||
| 13 | +// CrudSchema | ||
| 14 | +const crudSchemas = reactive<CrudSchema[]>([ | ||
| 15 | + { | ||
| 16 | + label: t('common.index'), | ||
| 17 | + field: 'id', | ||
| 18 | + type: 'index', | ||
| 19 | + form: { | ||
| 20 | + show: false | ||
| 21 | + }, | ||
| 22 | + detail: { | ||
| 23 | + show: false | ||
| 24 | + } | ||
| 25 | + }, | ||
| 26 | + { | ||
| 27 | + label: '组名', | ||
| 28 | + field: 'name', | ||
| 29 | + search: { | ||
| 30 | + show: true | ||
| 31 | + } | ||
| 32 | + }, | ||
| 33 | + { | ||
| 34 | + label: '成员', | ||
| 35 | + field: 'memberUserIds' | ||
| 36 | + }, | ||
| 37 | + { | ||
| 38 | + label: '描述', | ||
| 39 | + field: 'description' | ||
| 40 | + }, | ||
| 41 | + { | ||
| 42 | + label: t('common.status'), | ||
| 43 | + field: 'status', | ||
| 44 | + dictType: DICT_TYPE.COMMON_STATUS | ||
| 45 | + }, | ||
| 46 | + { | ||
| 47 | + label: '备注', | ||
| 48 | + field: 'remark' | ||
| 49 | + }, | ||
| 50 | + { | ||
| 51 | + label: t('common.createTime'), | ||
| 52 | + field: 'createTime', | ||
| 53 | + form: { | ||
| 54 | + show: false | ||
| 55 | + } | ||
| 56 | + }, | ||
| 57 | + { | ||
| 58 | + label: t('table.action'), | ||
| 59 | + field: 'action', | ||
| 60 | + width: '240px', | ||
| 61 | + form: { | ||
| 62 | + show: false | ||
| 63 | + }, | ||
| 64 | + detail: { | ||
| 65 | + show: false | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | +]) | ||
| 69 | +export const { allSchemas } = useCrudSchemas(crudSchemas) |
yudao-ui-admin-vue3/src/views/bpm/group/index.vue
| 1 | -<script setup lang="ts"></script> | 1 | +<script setup lang="ts"> |
| 2 | +import { ref, unref, onMounted } from 'vue' | ||
| 3 | +import dayjs from 'dayjs' | ||
| 4 | +import { ElMessage, ElSelect, ElOption } from 'element-plus' | ||
| 5 | +import { DICT_TYPE } from '@/utils/dict' | ||
| 6 | +import { useTable } from '@/hooks/web/useTable' | ||
| 7 | +import { useI18n } from '@/hooks/web/useI18n' | ||
| 8 | +import { FormExpose } from '@/components/Form' | ||
| 9 | +import type { UserGroupVO } from '@/api/bpm/userGroup/types' | ||
| 10 | +import { rules, allSchemas } from './group.data' | ||
| 11 | +import * as UserGroupApi from '@/api/bpm/userGroup' | ||
| 12 | +import { getListSimpleUsersApi } from '@/api/system/user' | ||
| 13 | +import { UserVO } from '@/api/system/user/types' | ||
| 14 | + | ||
| 15 | +const { t } = useI18n() // 国际化 | ||
| 16 | + | ||
| 17 | +// ========== 列表相关 ========== | ||
| 18 | +const { register, tableObject, methods } = useTable<UserGroupVO>({ | ||
| 19 | + getListApi: UserGroupApi.getUserGroupPageApi, | ||
| 20 | + delListApi: UserGroupApi.deleteUserGroupApi | ||
| 21 | +}) | ||
| 22 | +const { getList, setSearchParams, delList } = methods | ||
| 23 | + | ||
| 24 | +// ========== CRUD 相关 ========== | ||
| 25 | +const actionLoading = ref(false) // 遮罩层 | ||
| 26 | +const actionType = ref('') // 操作按钮的类型 | ||
| 27 | +const dialogVisible = ref(false) // 是否显示弹出层 | ||
| 28 | +const dialogTitle = ref('edit') // 弹出层标题 | ||
| 29 | +const formRef = ref<FormExpose>() // 表单 Ref | ||
| 30 | + | ||
| 31 | +// ========== 用户选择 ========== | ||
| 32 | +const userIds = ref<number[]>([]) | ||
| 33 | +const userOptions = ref<UserVO[]>([]) | ||
| 34 | +const getUserOptions = async () => { | ||
| 35 | + const res = await getListSimpleUsersApi() | ||
| 36 | + userOptions.value.push(...res) | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +// 设置标题 | ||
| 40 | +const setDialogTile = (type: string) => { | ||
| 41 | + dialogTitle.value = t('action.' + type) | ||
| 42 | + actionType.value = type | ||
| 43 | + dialogVisible.value = true | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +// 新增操作 | ||
| 47 | +const handleCreate = () => { | ||
| 48 | + setDialogTile('create') | ||
| 49 | + userIds.value = [] | ||
| 50 | + // 重置表单 | ||
| 51 | + unref(formRef)?.getElFormRef()?.resetFields() | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +// 修改操作 | ||
| 55 | +const handleUpdate = async (row: UserGroupVO) => { | ||
| 56 | + setDialogTile('update') | ||
| 57 | + // 设置数据 | ||
| 58 | + const res = await UserGroupApi.getUserGroupApi(row.id) | ||
| 59 | + userIds.value = res.memberUserIds | ||
| 60 | + unref(formRef)?.setValues(res) | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +// 提交按钮 | ||
| 64 | +const submitForm = async () => { | ||
| 65 | + actionLoading.value = true | ||
| 66 | + // 提交请求 | ||
| 67 | + try { | ||
| 68 | + const data = unref(formRef)?.formModel as UserGroupVO | ||
| 69 | + data.memberUserIds = userIds.value | ||
| 70 | + if (actionType.value === 'create') { | ||
| 71 | + await UserGroupApi.createUserGroupApi(data) | ||
| 72 | + ElMessage.success(t('common.createSuccess')) | ||
| 73 | + } else { | ||
| 74 | + await UserGroupApi.updateUserGroupApi(data) | ||
| 75 | + ElMessage.success(t('common.updateSuccess')) | ||
| 76 | + } | ||
| 77 | + // 操作成功,重新加载列表 | ||
| 78 | + dialogVisible.value = false | ||
| 79 | + await getList() | ||
| 80 | + } finally { | ||
| 81 | + actionLoading.value = false | ||
| 82 | + } | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +// 删除操作 | ||
| 86 | +const handleDelete = (row: UserGroupVO) => { | ||
| 87 | + delList(row.id, false) | ||
| 88 | +} | ||
| 89 | + | ||
| 90 | +// 根据用户名获取用户真实名 | ||
| 91 | +const getUserNickName = (userId: number) => { | ||
| 92 | + for (const user of userOptions.value) { | ||
| 93 | + if (user.id === userId) return user.nickname | ||
| 94 | + } | ||
| 95 | + return '未知(' + userId + ')' | ||
| 96 | +} | ||
| 97 | +// ========== 详情相关 ========== | ||
| 98 | +const detailRef = ref() // 详情 Ref | ||
| 99 | + | ||
| 100 | +// 详情操作 | ||
| 101 | +const handleDetail = async (row: UserGroupVO) => { | ||
| 102 | + // 设置数据 | ||
| 103 | + detailRef.value = row | ||
| 104 | + setDialogTile('detail') | ||
| 105 | +} | ||
| 106 | + | ||
| 107 | +// ========== 初始化 ========== | ||
| 108 | +onMounted(async () => { | ||
| 109 | + await getList() | ||
| 110 | + await getUserOptions() | ||
| 111 | +}) | ||
| 112 | +</script> | ||
| 2 | 113 | ||
| 3 | <template> | 114 | <template> |
| 4 | - <div>index</div> | ||
| 5 | -</template> | 115 | + <!-- 搜索工作区 --> |
| 116 | + <ContentWrap> | ||
| 117 | + <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> | ||
| 118 | + </ContentWrap> | ||
| 119 | + <ContentWrap> | ||
| 120 | + <!-- 操作工具栏 --> | ||
| 121 | + <div class="mb-10px"> | ||
| 122 | + <el-button type="primary" v-hasPermi="['bpm:user-group:create']" @click="handleCreate"> | ||
| 123 | + <Icon icon="ep:zoom-in" class="mr-5px" /> {{ t('action.add') }} | ||
| 124 | + </el-button> | ||
| 125 | + </div> | ||
| 126 | + <!-- 列表 --> | ||
| 127 | + <Table | ||
| 128 | + :columns="allSchemas.tableColumns" | ||
| 129 | + :selection="false" | ||
| 130 | + :data="tableObject.tableList" | ||
| 131 | + :loading="tableObject.loading" | ||
| 132 | + :pagination="{ | ||
| 133 | + total: tableObject.total | ||
| 134 | + }" | ||
| 135 | + v-model:pageSize="tableObject.pageSize" | ||
| 136 | + v-model:currentPage="tableObject.currentPage" | ||
| 137 | + @register="register" | ||
| 138 | + > | ||
| 139 | + <template #status="{ row }"> | ||
| 140 | + <DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" /> | ||
| 141 | + </template> | ||
| 142 | + <template #memberUserIds="{ row }"> | ||
| 143 | + <span v-for="userId in row.memberUserIds" :key="userId"> | ||
| 144 | + {{ getUserNickName(userId) + ' ' }} | ||
| 145 | + </span> | ||
| 146 | + </template> | ||
| 147 | + <template #createTime="{ row }"> | ||
| 148 | + <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span> | ||
| 149 | + </template> | ||
| 150 | + <template #action="{ row }"> | ||
| 151 | + <el-button | ||
| 152 | + link | ||
| 153 | + type="primary" | ||
| 154 | + v-hasPermi="['bpm:user-group:update']" | ||
| 155 | + @click="handleUpdate(row)" | ||
| 156 | + > | ||
| 157 | + <Icon icon="ep:edit" class="mr-1px" /> {{ t('action.edit') }} | ||
| 158 | + </el-button> | ||
| 159 | + <el-button | ||
| 160 | + link | ||
| 161 | + type="primary" | ||
| 162 | + v-hasPermi="['bpm:user-group:update']" | ||
| 163 | + @click="handleDetail(row)" | ||
| 164 | + > | ||
| 165 | + <Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }} | ||
| 166 | + </el-button> | ||
| 167 | + <el-button | ||
| 168 | + link | ||
| 169 | + type="primary" | ||
| 170 | + v-hasPermi="['bpm:user-group:delete']" | ||
| 171 | + @click="handleDelete(row)" | ||
| 172 | + > | ||
| 173 | + <Icon icon="ep:delete" class="mr-1px" /> {{ t('action.del') }} | ||
| 174 | + </el-button> | ||
| 175 | + </template> | ||
| 176 | + </Table> | ||
| 177 | + </ContentWrap> | ||
| 6 | 178 | ||
| 7 | -<style scoped></style> | 179 | + <Dialog v-model="dialogVisible" :title="dialogTitle"> |
| 180 | + <!-- 对话框(添加 / 修改) --> | ||
| 181 | + <Form | ||
| 182 | + v-if="['create', 'update'].includes(actionType)" | ||
| 183 | + :schema="allSchemas.formSchema" | ||
| 184 | + :rules="rules" | ||
| 185 | + ref="formRef" | ||
| 186 | + > | ||
| 187 | + <template #memberUserIds> | ||
| 188 | + <el-select v-model="userIds" multiple> | ||
| 189 | + <el-option | ||
| 190 | + v-for="item in userOptions" | ||
| 191 | + :key="item.id" | ||
| 192 | + :label="item.nickname" | ||
| 193 | + :value="item.id" | ||
| 194 | + /> | ||
| 195 | + </el-select> | ||
| 196 | + </template> | ||
| 197 | + </Form> | ||
| 198 | + <!-- 对话框(详情) --> | ||
| 199 | + <Descriptions | ||
| 200 | + v-if="actionType === 'detail'" | ||
| 201 | + :schema="allSchemas.detailSchema" | ||
| 202 | + :data="detailRef" | ||
| 203 | + > | ||
| 204 | + <template #memberUserIds="{ row }"> | ||
| 205 | + <span v-for="userId in row.memberUserIds" :key="userId"> | ||
| 206 | + {{ getUserNickName(userId) + ' ' }} | ||
| 207 | + </span> | ||
| 208 | + </template> | ||
| 209 | + <template #status="{ row }"> | ||
| 210 | + <DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" /> | ||
| 211 | + </template> | ||
| 212 | + <template #createTime="{ row }"> | ||
| 213 | + <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span> | ||
| 214 | + </template> | ||
| 215 | + </Descriptions> | ||
| 216 | + <!-- 操作按钮 --> | ||
| 217 | + <template #footer> | ||
| 218 | + <el-button | ||
| 219 | + v-if="['create', 'update'].includes(actionType)" | ||
| 220 | + type="primary" | ||
| 221 | + :loading="actionLoading" | ||
| 222 | + @click="submitForm" | ||
| 223 | + > | ||
| 224 | + {{ t('action.save') }} | ||
| 225 | + </el-button> | ||
| 226 | + <el-button @click="dialogVisible = false">{{ t('dialog.close') }}</el-button> | ||
| 227 | + </template> | ||
| 228 | + </Dialog> | ||
| 229 | +</template> |