diff --git a/pages/project/list/index.vue b/pages/project/list/index.vue index 0e1507a..ac4d4e4 100644 --- a/pages/project/list/index.vue +++ b/pages/project/list/index.vue @@ -225,19 +225,57 @@ const filterParams = ref({ overdue: '', // ''表示全部, true表示是, false表示否 }); +// 默认状态字典(用于字典数据尚未加载时的兜底) +const fallbackProjectStatusDict = [ + { dictLabel: '前期费用', dictValue: 'DEVELOPMENT_COST', listClass: 'primary', dictSort: 0 }, + { dictLabel: '中期费用', dictValue: 'MIDDLE_COST', listClass: 'success', dictSort: 0 }, + { dictLabel: '后期费用', dictValue: 'AFTER_COST', listClass: 'warning', dictSort: 0 }, + { dictLabel: '待开始', dictValue: 'WAIT_START', listClass: 'info', dictSort: 1 }, + { dictLabel: '开发中', dictValue: 'IN_PROGRESS', listClass: 'warning', dictSort: 100 }, + { dictLabel: '开发完成', dictValue: 'COMPLETED', listClass: 'primary', dictSort: 200 }, + { dictLabel: '已验收', dictValue: 'ACCEPTED', listClass: 'success', dictSort: 300 }, + { dictLabel: '维护中', dictValue: 'MAINTENANCE', listClass: 'warning', dictSort: 400 }, + { dictLabel: '维护到期', dictValue: 'MAINTENANCE_OVERDUE', listClass: 'warning', dictSort: 500 }, + { dictLabel: '开发超期', dictValue: 'DEVELOPMENT_OVERDUE', listClass: 'danger', dictSort: 600 } +]; + // 状态标签(使用字典键值) -const statusTabs = ref([ - { label: '待开始', value: 'WAIT_START' }, - { label: '开发中', value: 'IN_PROGRESS' }, - { label: '开发完成', value: 'COMPLETED' }, - { label: '已验收', value: 'ACCEPTED' }, - { label: '维护中', value: 'MAINTENANCE' }, - { label: '维护到期', value: 'MAINTENANCE_OVERDUE' }, - { label: '开发超期', value: 'DEVELOPMENT_OVERDUE' } -]); +const statusTabs = computed(() => { + const dictItems = typeof dictStore.getDictByType === 'function' + ? dictStore.getDictByType('project_status') + : []; + + const source = Array.isArray(dictItems) && dictItems.length > 0 + ? dictItems + : fallbackProjectStatusDict; + + return source + .slice() + .sort((a, b) => { + const sortA = parseInt(a.dictSort) || 0; + const sortB = parseInt(b.dictSort) || 0; + return sortA - sortB; + }) + .map(item => ({ + label: item.dictLabel || item.label, + value: item.dictValue || item.value, + listClass: item.listClass || item.type || 'primary' + })); +}); const activeStatusTab = ref('IN_PROGRESS'); // 默认选中"开发中" +// 当字典加载完成后确保当前选中状态仍然存在 +watch(statusTabs, (tabs) => { + if (!Array.isArray(tabs) || tabs.length === 0) { + return; + } + const exists = tabs.some(tab => tab.value === activeStatusTab.value); + if (!exists) { + activeStatusTab.value = tabs[0].value; + } +}, { immediate: true }); + // 成员选项 const memberOptions = ref([]); const selectedMemberName = ref(''); @@ -324,6 +362,9 @@ const getStatusText = (status) => { } // 默认映射(兼容字典键值) const statusMap = { + 'DEVELOPMENT_COST': '前期费用', + 'MIDDLE_COST': '中期费用', + 'AFTER_COST': '后期费用', 'WAIT_START': '待开始', 'IN_PROGRESS': '开发中', 'COMPLETED': '开发完成', @@ -348,6 +389,9 @@ const getStatusType = (status) => { if (!status && status !== 0) return 'primary'; const typeMap = { // 字典键值映射 + 'DEVELOPMENT_COST': 'primary', // 前期费用 + 'MIDDLE_COST': 'success', // 中期费用 + 'AFTER_COST': 'warning', // 后期费用 'WAIT_START': 'primary', // 待开始 'IN_PROGRESS': 'warning', // 开发中 'COMPLETED': 'success', // 开发完成 @@ -574,10 +618,10 @@ onPullDownRefresh(async () => { // 跳转到项目详情 const goToProjectDetail = (project) => { // TODO: 跳转到项目详情页面 - uni.showToast({ - title: '项目详情功能开发中', - icon: 'none' - }); + // uni.showToast({ + // title: '项目详情功能开发中', + // icon: 'none' + // }); }; // 加载成员列表