refactor(imWorkOrder): 优化工单分类和目标类型的展示逻辑
将工单分类和目标类型的格式化逻辑抽离到model文件中,统一处理字典映射展示,替换原有的硬编码空值占位,同时修复列表页和详情页的展示不一致问题
This commit is contained in:
@@ -14,6 +14,37 @@ export const workOrderTypeOptions = [
|
||||
{ label: '反馈', value: 'feedback' },
|
||||
];
|
||||
|
||||
// 目标类型映射
|
||||
const targetTypeMap: Record<string, string> = {
|
||||
user: '用户',
|
||||
group: '群聊',
|
||||
message: '消息',
|
||||
};
|
||||
|
||||
// 分类映射:举报按 reason_code,反馈按 category
|
||||
const abuseCategoryMap: Record<string, string> = {
|
||||
spam: '垃圾广告',
|
||||
harassment: '骚扰辱骂',
|
||||
illegal: '违法违规',
|
||||
fraud: '诈骗欺诈',
|
||||
other: '其他',
|
||||
};
|
||||
const feedbackCategoryMap: Record<string, string> = {
|
||||
bug: '功能异常',
|
||||
suggestion: '功能建议',
|
||||
complaint: '投诉',
|
||||
other: '其他',
|
||||
};
|
||||
|
||||
export function categoryLabelOf(type: string, category: string) {
|
||||
const map = type === 'abuse' ? abuseCategoryMap : feedbackCategoryMap;
|
||||
return map[category] || category || '-';
|
||||
}
|
||||
|
||||
export function targetTypeLabel(targetType: string) {
|
||||
return targetTypeMap[targetType] || (targetType || '-');
|
||||
}
|
||||
|
||||
export class State {
|
||||
public tenantId = 0;
|
||||
public tenantName = '';
|
||||
@@ -118,9 +149,25 @@ export const columns = [
|
||||
{ title: 'ID', key: 'id', align: 'left', width: 80 },
|
||||
{ title: '工单ID', key: 'orderId', align: 'left', width: 180 },
|
||||
{ title: '提交人ID', key: 'userId', align: 'left', width: 120 },
|
||||
{ title: '目标类型', key: 'targetType', align: 'left', width: 110 },
|
||||
{
|
||||
title: '目标类型',
|
||||
key: 'targetType',
|
||||
align: 'left',
|
||||
width: 110,
|
||||
render(row: State) {
|
||||
return targetTypeLabel(row.targetType);
|
||||
},
|
||||
},
|
||||
{ title: '目标摘要', key: 'targetSummary', align: 'left', width: 220 },
|
||||
{ title: '分类', key: 'category', align: 'left', width: 130 },
|
||||
{
|
||||
title: '分类',
|
||||
key: 'category',
|
||||
align: 'left',
|
||||
width: 130,
|
||||
render(row: State) {
|
||||
return categoryLabelOf(row.type, row.category);
|
||||
},
|
||||
},
|
||||
{ title: '内容', key: 'content', align: 'left', width: 260 },
|
||||
{
|
||||
title: '状态',
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
<n-descriptions-item label="工单ID">{{ formValue.orderId }}</n-descriptions-item>
|
||||
<n-descriptions-item label="状态">{{ statusLabel }}</n-descriptions-item>
|
||||
<n-descriptions-item label="提交人ID">{{ formValue.userId }}</n-descriptions-item>
|
||||
<n-descriptions-item label="分类">{{ formValue.category || '-' }}</n-descriptions-item>
|
||||
<n-descriptions-item label="分类">{{
|
||||
categoryLabelOf(formValue.type, formValue.category)
|
||||
}}</n-descriptions-item>
|
||||
<n-descriptions-item label="目标类型">{{
|
||||
formValue.targetType || '-'
|
||||
targetTypeLabel(formValue.targetType)
|
||||
}}</n-descriptions-item>
|
||||
<n-descriptions-item label="目标摘要">{{
|
||||
formValue.targetSummary || '-'
|
||||
@@ -67,7 +69,7 @@
|
||||
import { computed, ref } from 'vue';
|
||||
import { useDictStore } from '@/store/modules/dict';
|
||||
import { View } from '@/api/imWorkOrder';
|
||||
import { newState, State } from './model';
|
||||
import { categoryLabelOf, newState, State, targetTypeLabel } from './model';
|
||||
import { useProjectSettingStore } from '@/store/modules/projectSetting';
|
||||
import { adaModalWidth } from '@/utils/hotgo';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user