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

@@ -39,7 +39,7 @@ const processDefinitionList = ref<
>([]); // 流程定义的列表
// 实现 groupBy 功能
const groupBy = (array: any[], key: string) => {
function groupBy(array: any[], key: string) {
const result: Record<string, any[]> = {};
for (const item of array) {
const groupKey = item[key];
@@ -49,10 +49,10 @@ const groupBy = (array: any[], key: string) => {
result[groupKey].push(item);
}
return result;
};
}
/** 查询列表 */
const getList = async () => {
async function getList() {
loading.value = true;
try {
// 所有流程分类数据
@@ -79,20 +79,20 @@ const getList = async () => {
} finally {
loading.value = false;
}
};
}
/** 获取所有流程分类数据 */
const getCategoryList = async () => {
async function getCategoryList() {
try {
// 流程分类
categoryList.value = await getCategorySimpleList();
} catch {
// 错误处理
}
};
}
/** 获取所有流程定义数据 */
const handleGetProcessDefinitionList = async () => {
async function handleGetProcessDefinitionList() {
try {
// 流程定义
processDefinitionList.value = await getProcessDefinitionList({
@@ -108,7 +108,7 @@ const handleGetProcessDefinitionList = async () => {
} catch {
// 错误处理
}
};
}
/** 用于存储搜索过滤后的流程定义 */
const filteredProcessDefinitionList = ref<
@@ -116,7 +116,7 @@ const filteredProcessDefinitionList = ref<
>([]);
/** 搜索流程 */
const handleQuery = () => {
function handleQuery() {
if (searchName.value.trim()) {
// 如果有搜索关键字,进行过滤
isSearching.value = true;
@@ -141,16 +141,16 @@ const handleQuery = () => {
isSearching.value = false;
filteredProcessDefinitionList.value = processDefinitionList.value;
}
};
}
/** 判断流程定义是否匹配搜索 */
const isDefinitionMatchSearch = (definition: any) => {
function isDefinitionMatchSearch(definition: any) {
if (!isSearching.value) return false;
return definition.name.toLowerCase().includes(searchName.value.toLowerCase());
};
}
/** 流程定义的分组 */
const processDefinitionGroup: any = computed(() => {
const processDefinitionGroup = computed(() => {
if (!processDefinitionList.value?.length) {
return {};
}
@@ -172,26 +172,26 @@ const processDefinitionGroup: any = computed(() => {
});
/** 通过分类 code 获取对应的名称 */
const getCategoryName = (categoryCode: string) => {
function getCategoryName(categoryCode: string) {
return categoryList.value?.find((ctg: any) => ctg.code === categoryCode)
?.name;
};
}
// ========== 表单相关 ==========
const selectProcessDefinition = ref(); // 选择的流程定义
const processDefinitionDetailRef = ref();
/** 处理选择流程的按钮操作 */
const handleSelect = async (
async function handleSelect(
row: BpmProcessDefinitionApi.ProcessDefinitionVO,
formVariables?: any,
) => {
) {
// 设置选择的流程
selectProcessDefinition.value = row;
// 初始化流程定义详情
await nextTick();
processDefinitionDetailRef.value?.initProcessInfo(row, formVariables);
};
}
/** 过滤出有流程的分类列表。目的:只展示有流程的分类 */
const availableCategories = computed(() => {

View File

@@ -91,7 +91,7 @@ const activityNodes = ref<ApprovalNodeInfo[]>([]);
const processInstanceStartLoading = ref(false);
/** 提交按钮 */
const submitForm = async () => {
async function submitForm() {
if (!fApi.value || !props.selectProcessDefinition) {
return;
}
@@ -130,10 +130,10 @@ const submitForm = async () => {
} finally {
processInstanceStartLoading.value = false;
}
};
}
/** 设置表单信息、获取流程图数据 */
const initProcessInfo = async (row: any, formVariables?: any) => {
async function initProcessInfo(row: any, formVariables?: any) {
// 重置指定审批人
startUserSelectTasks.value = [];
startUserSelectAssignees.value = {};
@@ -177,7 +177,7 @@ const initProcessInfo = async (row: any, formVariables?: any) => {
});
// 这里暂时无需加载流程图,因为跳出到另外个 Tab
}
};
}
/** 预测流程节点会因为输入的参数值而产生新的预测结果值,所以需重新预测一次 */
watch(
@@ -200,10 +200,10 @@ watch(
);
/** 获取审批详情 */
const getApprovalDetail = async (row: {
async function getApprovalDetail(row: {
id: string;
processVariablesStr: string;
}) => {
}) {
try {
const data = await getApprovalDetailApi({
processDefinitionId: row.id,
@@ -246,12 +246,12 @@ const getApprovalDetail = async (row: {
message.error('获取审批详情失败');
console.error('获取审批详情失败:', error);
}
};
}
/**
* 设置表单权限
*/
const setFieldPermission = (field: string, permission: string) => {
function setFieldPermission(field: string, permission: string) {
if (permission === BpmFieldPermissionType.READ) {
// @ts-ignore
fApi.value?.disabled(true, field);
@@ -264,18 +264,18 @@ const setFieldPermission = (field: string, permission: string) => {
// @ts-ignore
fApi.value?.hidden(true, field);
}
};
}
/** 取消发起审批 */
const handleCancel = () => {
function handleCancel() {
emit('cancel');
};
}
/** 选择发起人 */
const selectUserConfirm = (activityId: string, userList: any[]) => {
function selectUserConfirm(activityId: string, userList: any[]) {
if (!activityId || !Array.isArray(userList)) return;
startUserSelectAssignees.value[activityId] = userList.map((item) => item.id);
};
}
defineExpose({ initProcessInfo });
</script>
@@ -293,7 +293,7 @@ defineExpose({ initProcessInfo });
<template #extra>
<Space wrap>
<Button plain type="default" @click="handleCancel">
<IconifyIcon icon="mdi:arrow-left" />&nbsp; 返回
<IconifyIcon icon="lucide:arrow-left" />&nbsp; 返回
</Button>
</Space>
</template>
@@ -345,11 +345,11 @@ defineExpose({ initProcessInfo });
<template v-if="activeTab === 'form'">
<Space wrap class="flex w-full justify-center">
<Button plain type="primary" @click="submitForm">
<IconifyIcon icon="icon-park-outline:check" />
<IconifyIcon icon="lucide:check" />
发起
</Button>
<Button plain type="default" @click="handleCancel">
<IconifyIcon icon="icon-park-outline:close" />
<IconifyIcon icon="lucide:x" />
取消
</Button>
</Space>