feat: 员工端流程筛选改从后端字典加载(保留静态兜底)
This commit is contained in:
@@ -15,3 +15,16 @@ export async function getOrganizations() {
|
|||||||
}
|
}
|
||||||
return Promise.reject(new Error(res.data.message));
|
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));
|
||||||
|
}
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ import {
|
|||||||
onShow
|
onShow
|
||||||
} from '@dcloudio/uni-app';
|
} from '@dcloudio/uni-app';
|
||||||
import { pageDone, pageMine, pageTodo } from '@/api/approval/instance';
|
import { pageDone, pageMine, pageTodo } from '@/api/approval/instance';
|
||||||
|
import { getFlowOptions } from '@/api/approval/directory';
|
||||||
import type { ApprovalItem, ApprovalTaskListParam } from '@/api/approval/model';
|
import type { ApprovalItem, ApprovalTaskListParam } from '@/api/approval/model';
|
||||||
import { hasPermission } from '@/utils/permission';
|
import { hasPermission } from '@/utils/permission';
|
||||||
|
|
||||||
@@ -129,12 +130,29 @@ const createOptions: CreateOption[] = [
|
|||||||
{ flowCode: 'facility', label: '设施价格表', page: 'form-facility', query: '' }
|
{ flowCode: 'facility', label: '设施价格表', page: 'form-facility', query: '' }
|
||||||
];
|
];
|
||||||
|
|
||||||
/** 流程筛选项:标签取流程名(ADR 0008),空值表示全部 */
|
/** 流程筛选项:标签取流程名(ADR 0008),空值表示全部;名称以后端字典为准 */
|
||||||
const flowOptions = [
|
const flowOptions = ref<Array<{ value: string; label: string }>>([
|
||||||
{ value: '', label: '全部类型' },
|
{ value: '', label: '全部类型' },
|
||||||
...createOptions.map(item => ({ value: item.flowCode, label: item.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 }> = [
|
const tabs: Array<{ key: TabKey; label: string }> = [
|
||||||
{ key: 'todo', label: '待办' },
|
{ key: 'todo', label: '待办' },
|
||||||
@@ -177,6 +195,7 @@ const finished = ref(false);
|
|||||||
let requestSeq = 0;
|
let requestSeq = 0;
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
|
loadFlowOptions();
|
||||||
load(true);
|
load(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user