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: '状态',
|
||||
|
||||
Reference in New Issue
Block a user