refactor: bpm

This commit is contained in:
xingyu4j
2025-06-06 20:45:45 +08:00
parent 7e8f2a1328
commit 2c3dd668e3
47 changed files with 1454 additions and 1898 deletions

View File

@@ -152,7 +152,7 @@ function onBack() {
// ============================== 审核流程相关 ==============================
/** 审批相关:获取审批详情 */
const getApprovalDetail = async () => {
async function getApprovalDetail() {
try {
const data = await getApprovalDetailApi({
processDefinitionId: processDefinitionId.value,
@@ -188,13 +188,12 @@ const getApprovalDetail = async () => {
: [];
}
}
} finally {
}
};
} finally {}
}
/** 审批相关:选择发起人 */
const selectUserConfirm = (id: string, userList: any[]) => {
function selectUserConfirm(id: string, userList: any[]) {
startUserSelectAssignees.value[id] = userList?.map((item: any) => item.id);
};
}
/** 审批相关:预测流程节点会因为输入的参数值而产生新的预测结果值,所以需重新预测一次, formData.value可改成实际业务中的特定字段 */
watch(

View File

@@ -1,18 +1,14 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
import type { BpmCategoryApi } from '#/api/bpm/category';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { DescriptionItemSchema } from '#/components/description';
import { h } from 'vue';
import { useAccess } from '@vben/access';
import dayjs from 'dayjs';
import { DictTag } from '#/components/dict-tag';
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
const { hasAccessByCodes } = useAccess();
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
return [
@@ -118,9 +114,7 @@ export function GridFormSchema(): VbenFormSchema[] {
}
/** 列表的字段 */
export function useGridColumns<T = BpmCategoryApi.CategoryVO>(
onActionClick: OnActionClickFn<T>,
): VxeTableGridOptions['columns'] {
export function useGridColumns(): VxeTableGridOptions['columns'] {
return [
{
field: 'id',
@@ -168,39 +162,11 @@ export function useGridColumns<T = BpmCategoryApi.CategoryVO>(
minWidth: 180,
formatter: 'formatDateTime',
},
{
field: 'operation',
title: '操作',
minWidth: 180,
align: 'center',
width: 180,
fixed: 'right',
cellRender: {
attrs: {
nameField: 'name',
nameTitle: '请假',
onClick: onActionClick,
},
name: 'CellOperation',
options: [
{
code: 'detail',
text: '详情',
show: hasAccessByCodes(['bpm:oa-leave:query']),
},
{
code: 'progress',
text: '进度',
show: hasAccessByCodes(['bpm:oa-leave:query']),
},
{
code: 'cancel',
text: '取消',
show: (row: any) =>
row.status === 1 && hasAccessByCodes(['bpm:oa-leave:query']),
},
],
},
slots: { default: 'actions' },
},
];
}

View File

@@ -19,14 +19,14 @@ const detailData = ref<BpmOALeaveApi.LeaveVO>();
const { query } = useRoute();
const queryId = computed(() => query.id as string);
const getDetailData = async () => {
async function getDetailData() {
try {
datailLoading.value = true;
detailData.value = await getLeave(Number(props.id || queryId.value));
} finally {
datailLoading.value = false;
}
};
}
onMounted(() => {
getDetailData();

View File

@@ -1,20 +1,14 @@
<script lang="ts" setup>
import type { PageParam } from '@vben/request';
import type {
OnActionClickParams,
VxeTableGridOptions,
} from '#/adapter/vxe-table';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { BpmOALeaveApi } from '#/api/bpm/oa/leave';
import { h } from 'vue';
import { Page, prompt } from '@vben/common-ui';
import { Plus } from '@vben/icons';
import { Button, message, Textarea } from 'ant-design-vue';
import { message, Textarea } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getLeavePage } from '#/api/bpm/oa/leave';
import { cancelProcessInstanceByStartUser } from '#/api/bpm/processInstance';
import { DocAlert } from '#/components/doc-alert';
@@ -27,12 +21,12 @@ const [Grid, gridApi] = useVbenVxeGrid({
schema: GridFormSchema(),
},
gridOptions: {
columns: useGridColumns(onActionClick),
columns: useGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }: PageParam, formValues: any) => {
query: async ({ page }, formValues) => {
return await getLeavePage({
pageNo: page.currentPage,
pageSize: page.pageSize,
@@ -52,7 +46,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
});
/** 创建请假 */
function onCreate() {
function handleCreate() {
router.push({
name: 'OALeaveCreate',
query: {
@@ -62,15 +56,15 @@ function onCreate() {
}
/** 查看请假详情 */
const onDetail = (row: BpmOALeaveApi.LeaveVO) => {
function handleDetail(row: BpmOALeaveApi.LeaveVO) {
router.push({
name: 'OALeaveDetail',
query: { id: row.id },
});
};
}
/** 取消请假 */
const onCancel = (row: BpmOALeaveApi.LeaveVO) => {
function handleCancel(row: BpmOALeaveApi.LeaveVO) {
prompt({
async beforeClose(scope) {
if (scope.isConfirm) {
@@ -100,35 +94,14 @@ const onCancel = (row: BpmOALeaveApi.LeaveVO) => {
title: '取消流程',
modelPropName: 'value',
});
};
}
/** 审批进度 */
const onProgress = (row: BpmOALeaveApi.LeaveVO) => {
function handleProgress(row: BpmOALeaveApi.LeaveVO) {
router.push({
name: 'BpmProcessInstanceDetail',
query: { id: row.processInstanceId },
});
};
/** 表格操作按钮的回调函数 */
function onActionClick({
code,
row,
}: OnActionClickParams<BpmOALeaveApi.LeaveVO>) {
switch (code) {
case 'cancel': {
onCancel(row);
break;
}
case 'detail': {
onDetail(row);
break;
}
case 'progress': {
onProgress(row);
break;
}
}
}
/** 刷新表格 */
@@ -146,25 +119,48 @@ function onRefresh() {
<Grid table-title="请假列表">
<template #toolbar-tools>
<Button
type="primary"
@click="onCreate"
v-access:code="['bpm:category:create']"
>
<Plus class="size-5" />
发起请假
</Button>
<TableAction
:actions="[
{
label: '发起请假',
type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['bpm:oa-leave:create'],
onClick: handleCreate,
},
]"
/>
</template>
<template #userIds-cell="{ row }">
<span
v-for="(userId, index) in row.userIds"
:key="userId"
class="pr-5px"
>
{{ dataList.find((user) => user.id === userId)?.nickname }}
<span v-if="index < row.userIds.length - 1"></span>
</span>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.detail'),
type: 'link',
icon: ACTION_ICON.VIEW,
auth: ['bpm:oa-leave:query'],
onClick: handleDetail.bind(null, row),
},
{
label: '审批进度',
type: 'link',
icon: ACTION_ICON.VIEW,
auth: ['bpm:oa-leave:query'],
onClick: handleProgress.bind(null, row),
},
{
label: '取消',
type: 'link',
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['bpm:user-group:query'],
popConfirm: {
title: '取消流程',
confirm: handleCancel.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</Page>