feat: 员工端流程筛选改从后端字典加载(保留静态兜底)

This commit is contained in:
weicw
2026-10-31 08:23:06 +08:00
parent 3d4f1949be
commit 9d287b4f32
2 changed files with 36 additions and 4 deletions
+13
View File
@@ -15,3 +15,16 @@ export async function getOrganizations() {
}
return Promise.reject(new Error(res.data.message));
}
/**
* 流程类型选项(flowCode → 流程名称),新增单据自动出现
*/
export async function getFlowOptions() {
const res = await request.get<ApiResult<Array<{ flowCode: string; flowName: string }>>>(
THINK_API_URL + '/approval/directory/flows'
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
+23 -4
View File
@@ -106,6 +106,7 @@ import {
onShow
} from '@dcloudio/uni-app';
import { pageDone, pageMine, pageTodo } from '@/api/approval/instance';
import { getFlowOptions } from '@/api/approval/directory';
import type { ApprovalItem, ApprovalTaskListParam } from '@/api/approval/model';
import { hasPermission } from '@/utils/permission';
@@ -129,12 +130,29 @@ const createOptions: CreateOption[] = [
{ flowCode: 'facility', label: '设施价格表', page: 'form-facility', query: '' }
];
/** 流程筛选项:标签取流程名(ADR 0008),空值表示全部 */
const flowOptions = [
/** 流程筛选项:标签取流程名(ADR 0008),空值表示全部;名称以后端字典为准 */
const flowOptions = ref<Array<{ value: string; label: string }>>([
{ value: '', label: '全部类型' },
...createOptions.map(item => ({ value: item.flowCode, label: item.label }))
];
const flowLabels = flowOptions.map(item => item.label);
]);
const flowLabels = computed(() => flowOptions.value.map(item => item.label));
/** 用后端流程字典覆盖筛选项名称(新增单据不必再改本页) */
async function loadFlowOptions() {
try {
const flows = await getFlowOptions();
const names = new Map(flows.map(flow => [flow.flowCode, flow.flowName]));
flowOptions.value = [
{ value: '', label: '全部类型' },
...createOptions.map(item => ({
value: item.flowCode,
label: names.get(item.flowCode) || item.label
}))
];
} catch {
// 字典不可用时保留静态标签,筛选仍可用
}
}
const tabs: Array<{ key: TabKey; label: string }> = [
{ key: 'todo', label: '待办' },
@@ -177,6 +195,7 @@ const finished = ref(false);
let requestSeq = 0;
onLoad(() => {
loadFlowOptions();
load(true);
});