feat(projects): 增加意见反馈
This commit is contained in:
@@ -27,7 +27,7 @@ export function setupElegantRouter() {
|
|||||||
onRouteMetaGen(routeName) {
|
onRouteMetaGen(routeName) {
|
||||||
const key = routeName as RouteKey;
|
const key = routeName as RouteKey;
|
||||||
|
|
||||||
const constantRoutes: RouteKey[] = ['login', '403', '404', '500', 'workbench'];
|
const constantRoutes: RouteKey[] = ['login', '403', '404', '500', 'workbench', 'feedback'];
|
||||||
const routeMetaMap: Partial<Record<RouteKey, Partial<RouteMeta>>> = {
|
const routeMetaMap: Partial<Record<RouteKey, Partial<RouteMeta>>> = {
|
||||||
workbench: {
|
workbench: {
|
||||||
icon: 'mdi:view-dashboard-outline',
|
icon: 'mdi:view-dashboard-outline',
|
||||||
@@ -200,6 +200,11 @@ export function setupElegantRouter() {
|
|||||||
roles: ['R_ADMIN'],
|
roles: ['R_ADMIN'],
|
||||||
activeMenu: 'system_user'
|
activeMenu: 'system_user'
|
||||||
},
|
},
|
||||||
|
feedback: {
|
||||||
|
icon: 'mdi:message-alert-outline',
|
||||||
|
order: 10,
|
||||||
|
keepAlive: true
|
||||||
|
},
|
||||||
infra: {
|
infra: {
|
||||||
icon: 'ep:monitor',
|
icon: 'ep:monitor',
|
||||||
order: 20
|
order: 20
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"generatedAt": "2026-06-25T05:22:43.905Z",
|
"generatedAt": "2026-06-27T00:49:28.085Z",
|
||||||
"description": "Frontend visible page resource whitelist for backend route/menu configuration.",
|
"description": "Frontend visible page resource whitelist for backend route/menu configuration.",
|
||||||
"rules": {
|
"rules": {
|
||||||
"directoryComponent": "layout.base",
|
"directoryComponent": "layout.base",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onBeforeUnmount, reactive, ref } from 'vue';
|
import { computed, onBeforeUnmount, reactive, ref } from 'vue';
|
||||||
import { ArrowDown, Delete, Document, Loading, Picture, QuestionFilled, Upload } from '@element-plus/icons-vue';
|
import { ArrowDown, Delete, Document, Loading, Picture, QuestionFilled, Upload } from '@element-plus/icons-vue';
|
||||||
import { deleteFile, downloadFile, uploadFile } from '@/service/api/file';
|
import { buildFileProxyUrl, deleteFile, downloadFile, uploadFile } from '@/service/api/file';
|
||||||
|
|
||||||
defineOptions({ name: 'BusinessAttachmentUploader' });
|
defineOptions({ name: 'BusinessAttachmentUploader' });
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ async function uploadOne(file: File) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { id, url } = result.data;
|
const { id, configId, path, url } = result.data;
|
||||||
|
|
||||||
// 组件已卸载(用户上传过程中关弹层):onBeforeUnmount 已跑过且看不到这个 id,
|
// 组件已卸载(用户上传过程中关弹层):onBeforeUnmount 已跑过且看不到这个 id,
|
||||||
// 这里立刻调删除,避免孤儿文件
|
// 这里立刻调删除,避免孤儿文件
|
||||||
@@ -251,7 +251,9 @@ async function uploadOne(file: File) {
|
|||||||
url,
|
url,
|
||||||
name: file.name,
|
name: file.name,
|
||||||
size: file.size,
|
size: file.size,
|
||||||
contentType: file.type || undefined
|
contentType: file.type || undefined,
|
||||||
|
configId,
|
||||||
|
path
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
session.addedIds.add(id);
|
session.addedIds.add(id);
|
||||||
@@ -422,6 +424,16 @@ defineExpose({
|
|||||||
/** 父组件在提交前可读此值判断是否还有 pending 上传 */
|
/** 父组件在提交前可读此值判断是否还有 pending 上传 */
|
||||||
get hasUploading() {
|
get hasUploading() {
|
||||||
return hasUploading.value;
|
return hasUploading.value;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回当前已选附件的「永久代理 URL」数组(私有/公开桶都不过期)。
|
||||||
|
* 缺 configId/path 时回退 item.url。供反馈等"按 URL 字符串存储"的场景使用。
|
||||||
|
*/
|
||||||
|
getPermanentUrls(): string[] {
|
||||||
|
return model.value.map(item =>
|
||||||
|
item.configId && item.path ? buildFileProxyUrl(item.configId, item.path) : item.url
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,9 @@ const toolbarConfig: Partial<IToolbarConfig> = {
|
|||||||
'insertLink',
|
'insertLink',
|
||||||
'editLink',
|
'editLink',
|
||||||
'unLink',
|
'unLink',
|
||||||
'viewLink'
|
'viewLink',
|
||||||
|
// 全屏:弹层内全屏体验割裂,隐藏
|
||||||
|
'fullScreen'
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -129,6 +129,22 @@ export const RDMS_OVERTIME_DURATION_DICT_CODE = 'rdms_overtime_duration';
|
|||||||
*/
|
*/
|
||||||
export const NOTIFY_MESSAGE_LEVEL_DICT_CODE = 'notify_message_level';
|
export const NOTIFY_MESSAGE_LEVEL_DICT_CODE = 'notify_message_level';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 意见反馈分类字典编码
|
||||||
|
*
|
||||||
|
* 对应业务字段:意见反馈 type(1 缺陷 / 2 体验问题 / 3 功能建议)
|
||||||
|
* 来源口径:`2026-06-25-意见反馈-前端API.html` 明确分类字典为 feedback_type,后端已落库。
|
||||||
|
*/
|
||||||
|
export const FEEDBACK_TYPE_DICT_CODE = 'feedback_type';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 意见反馈处理状态字典编码
|
||||||
|
*
|
||||||
|
* 对应业务字段:意见反馈 status(1 待处理 / 2 处理中 / 3 已处理 / 4 已忽略)
|
||||||
|
* 来源口径:同上,后端已落库。提交不传 status,后端强制「待处理」。
|
||||||
|
*/
|
||||||
|
export const FEEDBACK_STATUS_DICT_CODE = 'feedback_status';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统用户类型字典编码
|
* 系统用户类型字典编码
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ export type StatusDomain =
|
|||||||
| 'workReport'
|
| 'workReport'
|
||||||
| 'performanceSheet'
|
| 'performanceSheet'
|
||||||
| 'personalItem'
|
| 'personalItem'
|
||||||
| 'overtimeApplication';
|
| 'overtimeApplication'
|
||||||
|
| 'feedback';
|
||||||
|
|
||||||
const statusTagTypeRegistry: Record<StatusDomain, Record<string, StatusTagType>> = {
|
const statusTagTypeRegistry: Record<StatusDomain, Record<string, StatusTagType>> = {
|
||||||
// 项目-执行
|
// 项目-执行
|
||||||
@@ -108,6 +109,13 @@ const statusTagTypeRegistry: Record<StatusDomain, Record<string, StatusTagType>>
|
|||||||
pending: 'warning',
|
pending: 'warning',
|
||||||
approved: 'success',
|
approved: 'success',
|
||||||
rejected: 'danger'
|
rejected: 'danger'
|
||||||
|
},
|
||||||
|
// 意见反馈
|
||||||
|
feedback: {
|
||||||
|
'1': 'warning', // 待处理
|
||||||
|
'2': 'primary', // 处理中
|
||||||
|
'3': 'success', // 已处理
|
||||||
|
'4': 'info' // 已忽略
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -122,3 +130,10 @@ export function getStatusTagType(domain: StatusDomain, statusCode: string | null
|
|||||||
export function getPersonalItemStatusTagType(statusCode: string | null | undefined) {
|
export function getPersonalItemStatusTagType(statusCode: string | null | undefined) {
|
||||||
return getStatusTagType('personalItem', statusCode);
|
return getStatusTagType('personalItem', statusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getFeedbackStatusTagType(statusCode: string | number | null | undefined) {
|
||||||
|
return getStatusTagType(
|
||||||
|
'feedback',
|
||||||
|
statusCode === null || statusCode === undefined ? statusCode : String(statusCode)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ const local: App.I18n.Schema = {
|
|||||||
'personal-center_my-application': 'My Application',
|
'personal-center_my-application': 'My Application',
|
||||||
'personal-center_overtime-application': 'Overtime Application',
|
'personal-center_overtime-application': 'Overtime Application',
|
||||||
'personal-center_pending-approval': 'Pending Approval',
|
'personal-center_pending-approval': 'Pending Approval',
|
||||||
|
feedback: 'Feedback',
|
||||||
infra: 'Infra',
|
infra: 'Infra',
|
||||||
'infra_state-machine': 'State Machine',
|
'infra_state-machine': 'State Machine',
|
||||||
'infra_log-management': 'Log Management',
|
'infra_log-management': 'Log Management',
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ const local: App.I18n.Schema = {
|
|||||||
'personal-center_my-application': '我的申请',
|
'personal-center_my-application': '我的申请',
|
||||||
'personal-center_overtime-application': '加班申请',
|
'personal-center_overtime-application': '加班申请',
|
||||||
'personal-center_pending-approval': '待我审批',
|
'personal-center_pending-approval': '待我审批',
|
||||||
|
feedback: '意见反馈',
|
||||||
infra: '基础设施',
|
infra: '基础设施',
|
||||||
'infra_state-machine': '状态机管理',
|
'infra_state-machine': '状态机管理',
|
||||||
'infra_log-management': '日志管理',
|
'infra_log-management': '日志管理',
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export const views: Record<LastLevelRouteKey, RouteComponent | (() => Promise<Ro
|
|||||||
500: () => import("@/views/_builtin/500/index.vue"),
|
500: () => import("@/views/_builtin/500/index.vue"),
|
||||||
"iframe-page": () => import("@/views/_builtin/iframe-page/[url].vue"),
|
"iframe-page": () => import("@/views/_builtin/iframe-page/[url].vue"),
|
||||||
login: () => import("@/views/_builtin/login/index.vue"),
|
login: () => import("@/views/_builtin/login/index.vue"),
|
||||||
|
feedback: () => import("@/views/feedback/index.vue"),
|
||||||
"infra_log-management_api-access-log": () => import("@/views/infra/log-management/api-access-log/index.vue"),
|
"infra_log-management_api-access-log": () => import("@/views/infra/log-management/api-access-log/index.vue"),
|
||||||
"infra_log-management_api-error-log": () => import("@/views/infra/log-management/api-error-log/index.vue"),
|
"infra_log-management_api-error-log": () => import("@/views/infra/log-management/api-error-log/index.vue"),
|
||||||
"infra_log-management": () => import("@/views/infra/log-management/index.vue"),
|
"infra_log-management": () => import("@/views/infra/log-management/index.vue"),
|
||||||
|
|||||||
@@ -39,6 +39,19 @@ export const generatedRoutes: GeneratedRoute[] = [
|
|||||||
hideInMenu: true
|
hideInMenu: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'feedback',
|
||||||
|
path: '/feedback',
|
||||||
|
component: 'layout.base$view.feedback',
|
||||||
|
meta: {
|
||||||
|
title: 'feedback',
|
||||||
|
i18nKey: 'route.feedback',
|
||||||
|
icon: 'mdi:message-alert-outline',
|
||||||
|
order: 10,
|
||||||
|
keepAlive: true,
|
||||||
|
constant: true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'iframe-page',
|
name: 'iframe-page',
|
||||||
path: '/iframe-page/:url',
|
path: '/iframe-page/:url',
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ const routeMap: RouteMap = {
|
|||||||
"403": "/403",
|
"403": "/403",
|
||||||
"404": "/404",
|
"404": "/404",
|
||||||
"500": "/500",
|
"500": "/500",
|
||||||
|
"feedback": "/feedback",
|
||||||
"iframe-page": "/iframe-page/:url",
|
"iframe-page": "/iframe-page/:url",
|
||||||
"infra": "/infra",
|
"infra": "/infra",
|
||||||
"infra_log-management": "/infra/log-management",
|
"infra_log-management": "/infra/log-management",
|
||||||
|
|||||||
34
src/service/api/feedback-normalize.ts
Normal file
34
src/service/api/feedback-normalize.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/** 后端统计原始返回(type/status 可能为 number 或 string,count 为整数) */
|
||||||
|
export type FeedbackStatResponse = {
|
||||||
|
total: number;
|
||||||
|
typeCounts?: Array<{ type: string | number; count: number }> | null;
|
||||||
|
statusCounts?: Array<{ status: string | number; count: number }> | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 后端统计原始返回 → 业务层(type/status 一律 String 化为 Record 键,count 缺省兜底 0;data 为空全兜底 0) */
|
||||||
|
export function normalizeFeedbackStat(data: FeedbackStatResponse | null | undefined): Api.Feedback.FeedbackStat {
|
||||||
|
const typeCounts: Record<string, number> = {};
|
||||||
|
(data?.typeCounts ?? []).forEach(item => {
|
||||||
|
typeCounts[String(item.type)] = item.count ?? 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
const statusCounts: Record<string, number> = {};
|
||||||
|
(data?.statusCounts ?? []).forEach(item => {
|
||||||
|
statusCounts[String(item.status)] = item.count ?? 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
const total = data?.total ?? 0;
|
||||||
|
|
||||||
|
// 契约约定 total == sum(typeCounts) == sum(statusCounts);dev 下做一致性自检,便于尽早发现后端统计口径错位
|
||||||
|
if (import.meta.env.DEV) {
|
||||||
|
const typeSum = Object.values(typeCounts).reduce((sum, count) => sum + count, 0);
|
||||||
|
const statusSum = Object.values(statusCounts).reduce((sum, count) => sum + count, 0);
|
||||||
|
if (total !== typeSum || total !== statusSum) {
|
||||||
|
console.warn(
|
||||||
|
`[feedback-stat] total=${total} 与分类合计=${typeSum}、状态合计=${statusSum} 不一致,后端统计口径可能有误`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { total, typeCounts, statusCounts };
|
||||||
|
}
|
||||||
185
src/service/api/feedback.ts
Normal file
185
src/service/api/feedback.ts
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
import { SYSTEM_SERVICE_PREFIX } from '@/constants/service';
|
||||||
|
import { request } from '../request';
|
||||||
|
import { type ServiceRequestResult, mapServiceResult, normalizeStringId, safeJsonRequestConfig } from './shared';
|
||||||
|
import { type FeedbackStatResponse, normalizeFeedbackStat } from './feedback-normalize';
|
||||||
|
|
||||||
|
const FEEDBACK_PREFIX = `${SYSTEM_SERVICE_PREFIX}/feedback`;
|
||||||
|
|
||||||
|
type FeedbackResponse = Omit<Api.Feedback.FeedbackItem, 'id' | 'creator' | 'attachments' | 'contentPreview'> & {
|
||||||
|
id: string | number;
|
||||||
|
creator: string | number;
|
||||||
|
/** 后端原始:附件的 JSON 数组字符串(前端约定存完整附件对象,兼容历史纯 URL 数组) */
|
||||||
|
attachmentUrls?: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
type FeedbackPageResponse = {
|
||||||
|
total: number;
|
||||||
|
list: FeedbackResponse[];
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 从代理 URL 末段拆出文件名(兜底历史纯 URL 附件的展示名) */
|
||||||
|
function deriveAttachmentName(url: string): string {
|
||||||
|
try {
|
||||||
|
const path = decodeURI(url.split('?')[0]);
|
||||||
|
const idx = path.lastIndexOf('/');
|
||||||
|
return idx >= 0 ? path.slice(idx + 1) : path;
|
||||||
|
} catch {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单个附件归一化为业务层 AttachmentItem(ID 铁律:fileId/configId 一律 String)。
|
||||||
|
* - 对象形态(新版存储):按字段对齐;
|
||||||
|
* - 字符串形态(历史仅存 URL):补出 url + 派生 name,fileId 缺省空串(不可下载/清理,仅展示)。
|
||||||
|
*/
|
||||||
|
function normalizeAttachment(raw: unknown): Api.Project.AttachmentItem | null {
|
||||||
|
if (typeof raw === 'string') {
|
||||||
|
return { fileId: '', url: raw, name: deriveAttachmentName(raw) };
|
||||||
|
}
|
||||||
|
if (raw && typeof raw === 'object') {
|
||||||
|
const item = raw as Record<string, unknown>;
|
||||||
|
const url = typeof item.url === 'string' ? item.url : '';
|
||||||
|
return {
|
||||||
|
fileId: item.fileId === null || item.fileId === undefined ? '' : String(item.fileId),
|
||||||
|
url,
|
||||||
|
name: typeof item.name === 'string' && item.name ? item.name : deriveAttachmentName(url),
|
||||||
|
size: typeof item.size === 'number' ? item.size : undefined,
|
||||||
|
contentType: typeof item.contentType === 'string' ? item.contentType : undefined,
|
||||||
|
configId: item.configId === null || item.configId === undefined ? undefined : String(item.configId),
|
||||||
|
path: typeof item.path === 'string' ? item.path : undefined
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 把后端 attachmentUrls(JSON 字符串) 安全解析成附件对象数组;空 / 异常兜底为 [] */
|
||||||
|
function parseAttachments(raw?: string | null): Api.Project.AttachmentItem[] {
|
||||||
|
if (!raw) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(raw);
|
||||||
|
if (!Array.isArray(parsed)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return parsed.map(normalizeAttachment).filter((item): item is Api.Project.AttachmentItem => item !== null);
|
||||||
|
} catch {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表「内容」列去富文本标签,取纯文本预览(content 为 HTML,预算一次免每次渲染重扫) */
|
||||||
|
function stripHtml(html: string | null | undefined): string {
|
||||||
|
if (!html) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return html
|
||||||
|
.replace(/<[^>]+>/g, '')
|
||||||
|
.replace(/ /g, ' ')
|
||||||
|
.replace(/\s+/g, ' ')
|
||||||
|
.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 后端记录 → 业务层口径(ID 铁律 String 兜底 + 附件 parse + 内容纯文本预览预算) */
|
||||||
|
function normalizeFeedback(data: FeedbackResponse): Api.Feedback.FeedbackItem {
|
||||||
|
const { attachmentUrls, ...rest } = data;
|
||||||
|
return {
|
||||||
|
...rest,
|
||||||
|
id: normalizeStringId(data.id),
|
||||||
|
creator: normalizeStringId(data.creator),
|
||||||
|
attachments: parseAttachments(attachmentUrls),
|
||||||
|
contentPreview: stripHtml(data.content)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 附件对象数组 → attachmentUrls JSON 字符串(无附件传空串) */
|
||||||
|
function serializeAttachments(attachments: Api.Project.AttachmentItem[]): string {
|
||||||
|
return attachments.length ? JSON.stringify(attachments) : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 分页(全量,不按提交人过滤;默认 createTime 倒序由后端保证) */
|
||||||
|
export async function fetchGetFeedbackPage(params: Api.Feedback.FeedbackSearchParams) {
|
||||||
|
const result = await request<FeedbackPageResponse>({
|
||||||
|
...safeJsonRequestConfig,
|
||||||
|
url: `${FEEDBACK_PREFIX}/page`,
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
});
|
||||||
|
|
||||||
|
return mapServiceResult(result as ServiceRequestResult<FeedbackPageResponse>, data => ({
|
||||||
|
total: data.total,
|
||||||
|
list: data.list.map(normalizeFeedback)
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 统计聚合(左侧分面面板;全量口径,无业务筛选入参) */
|
||||||
|
export async function fetchGetFeedbackStat() {
|
||||||
|
const result = await request<FeedbackStatResponse>({
|
||||||
|
...safeJsonRequestConfig,
|
||||||
|
url: `${FEEDBACK_PREFIX}/stat`,
|
||||||
|
method: 'get'
|
||||||
|
});
|
||||||
|
|
||||||
|
return mapServiceResult(result as ServiceRequestResult<FeedbackStatResponse>, normalizeFeedbackStat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 详情 */
|
||||||
|
export async function fetchGetFeedback(id: string) {
|
||||||
|
const result = await request<FeedbackResponse>({
|
||||||
|
...safeJsonRequestConfig,
|
||||||
|
url: `${FEEDBACK_PREFIX}/get`,
|
||||||
|
method: 'get',
|
||||||
|
params: { id }
|
||||||
|
});
|
||||||
|
|
||||||
|
return mapServiceResult(result as ServiceRequestResult<FeedbackResponse>, normalizeFeedback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交反馈(attachments 对象数组在此 stringify 成 attachmentUrls;无附件传空串;返回新建 id,ID 铁律 String 化) */
|
||||||
|
export async function fetchCreateFeedback(params: Api.Feedback.FeedbackSubmitParams) {
|
||||||
|
const { attachments, ...rest } = params;
|
||||||
|
const result = await request<string | number>({
|
||||||
|
...safeJsonRequestConfig,
|
||||||
|
url: `${FEEDBACK_PREFIX}/create`,
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
...rest,
|
||||||
|
attachmentUrls: serializeAttachments(attachments)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return mapServiceResult(result as ServiceRequestResult<string | number>, normalizeStringId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新反馈(编辑态;attachments 对象数组在此 stringify 成 attachmentUrls;无附件传空串) */
|
||||||
|
export function fetchUpdateFeedback(params: Api.Feedback.FeedbackUpdateParams) {
|
||||||
|
const { attachments, ...rest } = params;
|
||||||
|
return request<boolean>({
|
||||||
|
...safeJsonRequestConfig,
|
||||||
|
url: `${FEEDBACK_PREFIX}/update`,
|
||||||
|
method: 'put',
|
||||||
|
data: {
|
||||||
|
...rest,
|
||||||
|
attachmentUrls: serializeAttachments(attachments)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改处理状态(仅超管;状态可任意改,不校验流转) */
|
||||||
|
export function fetchUpdateFeedbackStatus(id: string, status: number) {
|
||||||
|
return request<boolean>({
|
||||||
|
url: `${FEEDBACK_PREFIX}/${id}/status`,
|
||||||
|
method: 'put',
|
||||||
|
data: { status }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除反馈(软删除;后端按归属二次校验) */
|
||||||
|
export function fetchDeleteFeedback(id: string) {
|
||||||
|
return request<boolean>({
|
||||||
|
url: `${FEEDBACK_PREFIX}/delete`,
|
||||||
|
method: 'delete',
|
||||||
|
params: { id }
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
export * from './auth';
|
export * from './auth';
|
||||||
export * from './dict';
|
export * from './dict';
|
||||||
|
export * from './feedback';
|
||||||
export * from './file';
|
export * from './file';
|
||||||
export * from './infra';
|
export * from './infra';
|
||||||
export * from './notice';
|
export * from './notice';
|
||||||
|
|||||||
82
src/typings/api/feedback.d.ts
vendored
Normal file
82
src/typings/api/feedback.d.ts
vendored
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
declare namespace Api {
|
||||||
|
/**
|
||||||
|
* namespace Feedback
|
||||||
|
*
|
||||||
|
* backend api module: "feedback"(用户意见反馈)
|
||||||
|
*/
|
||||||
|
namespace Feedback {
|
||||||
|
/** 反馈分页查询参数(GET query;type/status 传字符串即可,后端按 Integer 解析) */
|
||||||
|
interface FeedbackSearchParams {
|
||||||
|
pageNo: number;
|
||||||
|
pageSize: number;
|
||||||
|
/** 反馈分类,字典 feedback_type */
|
||||||
|
type?: string | number | null;
|
||||||
|
/** 处理状态,字典 feedback_status */
|
||||||
|
status?: string | number | null;
|
||||||
|
/** 标题关键词,模糊匹配 */
|
||||||
|
title?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反馈记录。
|
||||||
|
* - id/creator 在 API 适配层已统一为 string;
|
||||||
|
* - content 为富文本 HTML 字符串(详细描述支持图文);
|
||||||
|
* - attachments 由后端 attachmentUrls(JSON 字符串) 解析为完整附件对象数组,与任务附件同构。
|
||||||
|
*/
|
||||||
|
interface FeedbackItem {
|
||||||
|
id: string;
|
||||||
|
/** 反馈分类,字典 feedback_type */
|
||||||
|
type: number;
|
||||||
|
title: string;
|
||||||
|
/** 详细描述,富文本 HTML */
|
||||||
|
content: string;
|
||||||
|
/** 内容纯文本预览(API 适配层预算,列表列直接取,免每次渲染重跑去标签正则) */
|
||||||
|
contentPreview: string;
|
||||||
|
/** 附件对象列表(含 fileId/url/name 等,支持下载与会话级清理) */
|
||||||
|
attachments: Api.Project.AttachmentItem[];
|
||||||
|
/** 联系方式(选填) */
|
||||||
|
contact?: string;
|
||||||
|
/** 处理状态,字典 feedback_status */
|
||||||
|
status: number;
|
||||||
|
/** 提交人用户 id(字符串) */
|
||||||
|
creator: string;
|
||||||
|
/** 提交人姓名(后端回填,缺失时前端回退展示 creator) */
|
||||||
|
creatorName?: string;
|
||||||
|
createTime: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交反馈参数(页面层传 attachments 对象数组,api 层 stringify 成 attachmentUrls) */
|
||||||
|
interface FeedbackSubmitParams {
|
||||||
|
type: number;
|
||||||
|
title: string;
|
||||||
|
content: string;
|
||||||
|
attachments: Api.Project.AttachmentItem[];
|
||||||
|
contact?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新反馈参数(编辑态;后端更新接口待提供,见根目录后端诉求文档) */
|
||||||
|
interface FeedbackUpdateParams extends FeedbackSubmitParams {
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 分页返回(后端 { list, total } 形态) */
|
||||||
|
interface FeedbackListResult {
|
||||||
|
total: number;
|
||||||
|
list: FeedbackItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反馈统计聚合(左侧分面面板用;全量口径,不随筛选变化)。
|
||||||
|
* typeCounts / statusCounts 已在 API 适配层归一化为 Record<码值字符串, 数量>,
|
||||||
|
* 由后端覆盖各自字典的全部码值(无数据为 0)。
|
||||||
|
*/
|
||||||
|
interface FeedbackStat {
|
||||||
|
/** 全部反馈总数 */
|
||||||
|
total: number;
|
||||||
|
/** 各分类计数:key=分类码值字符串(feedback_type) */
|
||||||
|
typeCounts: Record<string, number>;
|
||||||
|
/** 各状态计数:key=状态码值字符串(feedback_status) */
|
||||||
|
statusCounts: Record<string, number>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
4
src/typings/api/project.d.ts
vendored
4
src/typings/api/project.d.ts
vendored
@@ -170,6 +170,10 @@ declare namespace Api {
|
|||||||
name: string;
|
name: string;
|
||||||
size?: number;
|
size?: number;
|
||||||
contentType?: string;
|
contentType?: string;
|
||||||
|
/** 对象存储配置编号(上传返回),与 path 一起拼永久代理 URL */
|
||||||
|
configId?: string;
|
||||||
|
/** 文件相对路径(上传返回),与 configId 一起拼永久代理 URL */
|
||||||
|
path?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 任务详情 / 分页响应里嵌入的活跃协办人引用(按加入时间正序) */
|
/** 任务详情 / 分页响应里嵌入的活跃协办人引用(按加入时间正序) */
|
||||||
|
|||||||
2
src/typings/components.d.ts
vendored
2
src/typings/components.d.ts
vendored
@@ -130,6 +130,7 @@ declare module 'vue' {
|
|||||||
IconMdiFolderOpen: typeof import('~icons/mdi/folder-open')['default']
|
IconMdiFolderOpen: typeof import('~icons/mdi/folder-open')['default']
|
||||||
IconMdiFolderOutline: typeof import('~icons/mdi/folder-outline')['default']
|
IconMdiFolderOutline: typeof import('~icons/mdi/folder-outline')['default']
|
||||||
IconMdiFolderPlusOutline: typeof import('~icons/mdi/folder-plus-outline')['default']
|
IconMdiFolderPlusOutline: typeof import('~icons/mdi/folder-plus-outline')['default']
|
||||||
|
IconMdiInboxMultipleOutline: typeof import('~icons/mdi/inbox-multiple-outline')['default']
|
||||||
IconMdiInformationOutline: typeof import('~icons/mdi/information-outline')['default']
|
IconMdiInformationOutline: typeof import('~icons/mdi/information-outline')['default']
|
||||||
IconMdiKeyboardEsc: typeof import('~icons/mdi/keyboard-esc')['default']
|
IconMdiKeyboardEsc: typeof import('~icons/mdi/keyboard-esc')['default']
|
||||||
IconMdiKeyboardReturn: typeof import('~icons/mdi/keyboard-return')['default']
|
IconMdiKeyboardReturn: typeof import('~icons/mdi/keyboard-return')['default']
|
||||||
@@ -137,6 +138,7 @@ declare module 'vue' {
|
|||||||
IconMdiPencilOutline: typeof import('~icons/mdi/pencil-outline')['default']
|
IconMdiPencilOutline: typeof import('~icons/mdi/pencil-outline')['default']
|
||||||
IconMdiPlus: typeof import('~icons/mdi/plus')['default']
|
IconMdiPlus: typeof import('~icons/mdi/plus')['default']
|
||||||
IconMdiRefresh: typeof import('~icons/mdi/refresh')['default']
|
IconMdiRefresh: typeof import('~icons/mdi/refresh')['default']
|
||||||
|
IconMdiTagOutline: typeof import('~icons/mdi/tag-outline')['default']
|
||||||
IconMdiUpload: typeof import('~icons/mdi/upload')['default']
|
IconMdiUpload: typeof import('~icons/mdi/upload')['default']
|
||||||
IconUilSearch: typeof import('~icons/uil/search')['default']
|
IconUilSearch: typeof import('~icons/uil/search')['default']
|
||||||
LangSwitch: typeof import('./../components/common/lang-switch.vue')['default']
|
LangSwitch: typeof import('./../components/common/lang-switch.vue')['default']
|
||||||
|
|||||||
3
src/typings/elegant-router.d.ts
vendored
3
src/typings/elegant-router.d.ts
vendored
@@ -24,6 +24,7 @@ declare module "@elegant-router/types" {
|
|||||||
"403": "/403";
|
"403": "/403";
|
||||||
"404": "/404";
|
"404": "/404";
|
||||||
"500": "/500";
|
"500": "/500";
|
||||||
|
"feedback": "/feedback";
|
||||||
"iframe-page": "/iframe-page/:url";
|
"iframe-page": "/iframe-page/:url";
|
||||||
"infra": "/infra";
|
"infra": "/infra";
|
||||||
"infra_log-management": "/infra/log-management";
|
"infra_log-management": "/infra/log-management";
|
||||||
@@ -111,6 +112,7 @@ declare module "@elegant-router/types" {
|
|||||||
| "403"
|
| "403"
|
||||||
| "404"
|
| "404"
|
||||||
| "500"
|
| "500"
|
||||||
|
| "feedback"
|
||||||
| "iframe-page"
|
| "iframe-page"
|
||||||
| "infra"
|
| "infra"
|
||||||
| "login"
|
| "login"
|
||||||
@@ -143,6 +145,7 @@ declare module "@elegant-router/types" {
|
|||||||
| "500"
|
| "500"
|
||||||
| "iframe-page"
|
| "iframe-page"
|
||||||
| "login"
|
| "login"
|
||||||
|
| "feedback"
|
||||||
| "infra_log-management_api-access-log"
|
| "infra_log-management_api-access-log"
|
||||||
| "infra_log-management_api-error-log"
|
| "infra_log-management_api-error-log"
|
||||||
| "infra_log-management"
|
| "infra_log-management"
|
||||||
|
|||||||
328
src/views/feedback/index.vue
Normal file
328
src/views/feedback/index.vue
Normal file
@@ -0,0 +1,328 @@
|
|||||||
|
<script setup lang="tsx">
|
||||||
|
import { computed, onMounted, reactive, ref } from 'vue';
|
||||||
|
import { ElMessageBox } from 'element-plus';
|
||||||
|
import { FEEDBACK_STATUS_DICT_CODE, FEEDBACK_TYPE_DICT_CODE } from '@/constants/dict';
|
||||||
|
import { getFeedbackStatusTagType } from '@/constants/status-tag';
|
||||||
|
import { fetchDeleteFeedback, fetchGetFeedbackPage, fetchGetFeedbackStat } from '@/service/api';
|
||||||
|
import { useAuthStore } from '@/store/modules/auth';
|
||||||
|
import { useUIPaginatedTable } from '@/hooks/common/table';
|
||||||
|
import DictTag from '@/components/custom/dict-tag.vue';
|
||||||
|
import BusinessTableActionCell, { type BusinessTableAction } from '@/components/custom/business-table-action-cell';
|
||||||
|
import FeedbackFacet from './modules/feedback-facet.vue';
|
||||||
|
import FeedbackSearch from './modules/feedback-search.vue';
|
||||||
|
import FeedbackOperateDialog from './modules/feedback-operate-dialog.vue';
|
||||||
|
import FeedbackDetailDialog from './modules/feedback-detail-dialog.vue';
|
||||||
|
import FeedbackStatusDialog from './modules/feedback-status-dialog.vue';
|
||||||
|
import IconMdiDeleteOutline from '~icons/mdi/delete-outline';
|
||||||
|
import IconMdiEyeOutline from '~icons/mdi/eye-outline';
|
||||||
|
import IconMdiProgressCheck from '~icons/mdi/progress-check';
|
||||||
|
import IconMdiPencilOutline from '~icons/mdi/pencil-outline';
|
||||||
|
|
||||||
|
defineOptions({ name: 'Feedback' });
|
||||||
|
|
||||||
|
const authStore = useAuthStore();
|
||||||
|
|
||||||
|
// 动态路由模式下后端不返回 R_SUPER,超管按固定登录名 admin 识别(写操作放开依据)
|
||||||
|
const isSuper = computed(() => authStore.userInfo.userName === 'admin');
|
||||||
|
|
||||||
|
// 后端已移除反馈相关权限码:提交对所有登录用户开放;写操作纯前端按「归属 + 超管」控制
|
||||||
|
/** 是否本人提交 */
|
||||||
|
function isOwn(row: Api.Feedback.FeedbackItem) {
|
||||||
|
return authStore.userInfo.userId === row.creator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改状态:仅超管 */
|
||||||
|
const canUpdateStatus = computed(() => isSuper.value);
|
||||||
|
|
||||||
|
/** 删除按钮逐行显隐:自己提交的,或超管 */
|
||||||
|
function canDeleteRow(row: Api.Feedback.FeedbackItem) {
|
||||||
|
return isOwn(row) || isSuper.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑按钮逐行显隐:自己提交的,或超管 */
|
||||||
|
function canEditRow(row: Api.Feedback.FeedbackItem) {
|
||||||
|
return isOwn(row) || isSuper.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInitSearchParams(): Api.Feedback.FeedbackSearchParams {
|
||||||
|
return { pageNo: 1, pageSize: 20, type: undefined, status: undefined, title: undefined };
|
||||||
|
}
|
||||||
|
|
||||||
|
function transformPageResult(
|
||||||
|
response: Awaited<ReturnType<typeof fetchGetFeedbackPage>>,
|
||||||
|
pageNo: number,
|
||||||
|
pageSize: number
|
||||||
|
) {
|
||||||
|
if (!response.error) {
|
||||||
|
return { data: response.data.list, pageNum: pageNo, pageSize, total: response.data.total };
|
||||||
|
}
|
||||||
|
return { data: [], pageNum: pageNo, pageSize, total: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
const searchParams = reactive(getInitSearchParams());
|
||||||
|
|
||||||
|
// 弹层 / 抽屉开关与上下文
|
||||||
|
const operateVisible = ref(false);
|
||||||
|
const operateMode = ref<'create' | 'edit'>('create');
|
||||||
|
const operateRow = ref<Api.Feedback.FeedbackItem | null>(null);
|
||||||
|
const detailVisible = ref(false);
|
||||||
|
const detailId = ref<string | null>(null);
|
||||||
|
const statusVisible = ref(false);
|
||||||
|
const statusId = ref<string | null>(null);
|
||||||
|
const statusCurrent = ref<number | null>(null);
|
||||||
|
|
||||||
|
function openCreate() {
|
||||||
|
operateMode.value = 'create';
|
||||||
|
operateRow.value = null;
|
||||||
|
operateVisible.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function openEdit(row: Api.Feedback.FeedbackItem) {
|
||||||
|
operateMode.value = 'edit';
|
||||||
|
operateRow.value = row;
|
||||||
|
operateVisible.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function openDetail(row: Api.Feedback.FeedbackItem) {
|
||||||
|
detailId.value = row.id;
|
||||||
|
detailVisible.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function openStatus(row: Api.Feedback.FeedbackItem) {
|
||||||
|
statusId.value = row.id;
|
||||||
|
statusCurrent.value = row.status;
|
||||||
|
statusVisible.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { columns, data, loading, getData, getDataByPage, mobilePagination } = useUIPaginatedTable({
|
||||||
|
paginationProps: {
|
||||||
|
currentPage: searchParams.pageNo,
|
||||||
|
pageSize: searchParams.pageSize
|
||||||
|
},
|
||||||
|
api: () => fetchGetFeedbackPage(searchParams),
|
||||||
|
transform: response => transformPageResult(response, searchParams.pageNo, searchParams.pageSize),
|
||||||
|
onPaginationParamsChange: params => {
|
||||||
|
searchParams.pageNo = params.currentPage ?? 1;
|
||||||
|
searchParams.pageSize = params.pageSize ?? 20;
|
||||||
|
},
|
||||||
|
columns: () => [
|
||||||
|
{ prop: 'index', type: 'index', label: '序号', width: 64, align: 'center' },
|
||||||
|
{ prop: 'title', label: '标题', minWidth: 180, showOverflowTooltip: true },
|
||||||
|
{
|
||||||
|
prop: 'content',
|
||||||
|
label: '内容',
|
||||||
|
minWidth: 260,
|
||||||
|
showOverflowTooltip: true,
|
||||||
|
formatter: row => <span>{row.contentPreview}</span>
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'type',
|
||||||
|
label: '分类',
|
||||||
|
width: 110,
|
||||||
|
align: 'center',
|
||||||
|
formatter: row => <DictTag dictCode={FEEDBACK_TYPE_DICT_CODE} value={row.type} />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'status',
|
||||||
|
label: '状态',
|
||||||
|
width: 110,
|
||||||
|
align: 'center',
|
||||||
|
formatter: row => (
|
||||||
|
<DictTag dictCode={FEEDBACK_STATUS_DICT_CODE} value={row.status} type={getFeedbackStatusTagType(row.status)} />
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'creatorName',
|
||||||
|
label: '提交人',
|
||||||
|
width: 140,
|
||||||
|
formatter: row => <span>{row.creatorName || row.creator}</span>
|
||||||
|
},
|
||||||
|
{ prop: 'createTime', label: '提交时间', width: 180 },
|
||||||
|
{
|
||||||
|
prop: 'operate',
|
||||||
|
label: '操作',
|
||||||
|
width: 140,
|
||||||
|
align: 'center',
|
||||||
|
fixed: 'right',
|
||||||
|
formatter: row => <BusinessTableActionCell variant="icon" actions={getRowActions(row)} />
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// 左侧分面统计(全量口径,不随筛选变化;仅在进入页面与写操作后刷新)
|
||||||
|
const facetStat = ref<Api.Feedback.FeedbackStat>({ total: 0, typeCounts: {}, statusCounts: {} });
|
||||||
|
const facetLoading = ref(false);
|
||||||
|
|
||||||
|
async function loadFacet() {
|
||||||
|
facetLoading.value = true;
|
||||||
|
try {
|
||||||
|
const { data: stat, error } = await fetchGetFeedbackStat();
|
||||||
|
if (!error && stat) {
|
||||||
|
facetStat.value = stat;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// 统计接口异常(含 normalize 解引用空数据抛错)也要复位,避免分面面板 v-loading 永久转圈
|
||||||
|
facetLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(row: Api.Feedback.FeedbackItem) {
|
||||||
|
const confirmed = await ElMessageBox.confirm('确认删除该意见反馈?', '提示', { type: 'warning' })
|
||||||
|
.then(() => true)
|
||||||
|
.catch(() => false);
|
||||||
|
if (!confirmed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { error } = await fetchDeleteFeedback(row.id);
|
||||||
|
if (error) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.$message?.success('删除成功');
|
||||||
|
await Promise.all([getData(), loadFacet()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRowActions(row: Api.Feedback.FeedbackItem): BusinessTableAction[] {
|
||||||
|
const actions: BusinessTableAction[] = [
|
||||||
|
{ key: 'detail', label: '查看详情', buttonType: 'primary', icon: IconMdiEyeOutline, onClick: () => openDetail(row) }
|
||||||
|
];
|
||||||
|
if (canEditRow(row)) {
|
||||||
|
actions.push({
|
||||||
|
key: 'edit',
|
||||||
|
label: '编辑',
|
||||||
|
buttonType: 'primary',
|
||||||
|
icon: IconMdiPencilOutline,
|
||||||
|
onClick: () => openEdit(row)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (canUpdateStatus.value) {
|
||||||
|
actions.push({
|
||||||
|
key: 'status',
|
||||||
|
label: '处理',
|
||||||
|
buttonType: 'warning',
|
||||||
|
icon: IconMdiProgressCheck,
|
||||||
|
onClick: () => openStatus(row)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (canDeleteRow(row)) {
|
||||||
|
actions.push({
|
||||||
|
key: 'delete',
|
||||||
|
label: '删除',
|
||||||
|
buttonType: 'danger',
|
||||||
|
icon: IconMdiDeleteOutline,
|
||||||
|
onClick: () => handleDelete(row)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSearch() {
|
||||||
|
searchParams.pageNo = 1;
|
||||||
|
getDataByPage(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 搜索区「重置」只清搜索区自有字段(标题);左侧分面选中的 type/status 由分面单独控制,不在此连带清除
|
||||||
|
function resetSearchParams() {
|
||||||
|
searchParams.title = undefined;
|
||||||
|
searchParams.pageNo = 1;
|
||||||
|
getDataByPage(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSubmitted() {
|
||||||
|
// 新增回到首页看最新;编辑只刷新当前页,避免跳页
|
||||||
|
if (operateMode.value === 'edit') {
|
||||||
|
getData();
|
||||||
|
} else {
|
||||||
|
getDataByPage(1);
|
||||||
|
}
|
||||||
|
loadFacet();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleStatusUpdated() {
|
||||||
|
getData();
|
||||||
|
loadFacet();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 左侧分面点击:单选切换 toggle 由面板内部处理,这里只接收最终值并刷新列表
|
||||||
|
function handleSelectType(value?: string | number) {
|
||||||
|
searchParams.type = value ?? undefined;
|
||||||
|
handleSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSelectStatus(value?: string | number) {
|
||||||
|
searchParams.status = value ?? undefined;
|
||||||
|
handleSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSelectAll() {
|
||||||
|
searchParams.type = undefined;
|
||||||
|
searchParams.status = undefined;
|
||||||
|
handleSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(loadFacet);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="h-full flex gap-16px overflow-hidden">
|
||||||
|
<FeedbackFacet
|
||||||
|
class="w-200px shrink-0"
|
||||||
|
:total="facetStat.total"
|
||||||
|
:type-counts="facetStat.typeCounts"
|
||||||
|
:status-counts="facetStat.statusCounts"
|
||||||
|
:selected-type="searchParams.type"
|
||||||
|
:selected-status="searchParams.status"
|
||||||
|
:loading="facetLoading"
|
||||||
|
@select-type="handleSelectType"
|
||||||
|
@select-status="handleSelectStatus"
|
||||||
|
@select-all="handleSelectAll"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="flex-col-stretch flex-1-hidden gap-16px">
|
||||||
|
<FeedbackSearch v-model:model="searchParams" @reset="resetSearchParams" @search="handleSearch" />
|
||||||
|
|
||||||
|
<ElCard class="flex-1-hidden card-wrapper" body-class="business-table-card-body">
|
||||||
|
<template #header>
|
||||||
|
<div class="flex items-center justify-between gap-12px">
|
||||||
|
<div class="flex items-center gap-10px">
|
||||||
|
<p>意见反馈</p>
|
||||||
|
<ElTag effect="plain">{{ mobilePagination.total || data.length }}</ElTag>
|
||||||
|
</div>
|
||||||
|
<ElButton plain type="primary" @click="openCreate">提交反馈</ElButton>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="flex-1">
|
||||||
|
<ElTable v-loading="loading" height="100%" border row-key="id" :data="data">
|
||||||
|
<ElTableColumn v-for="col in columns" :key="String(col.prop)" v-bind="col" />
|
||||||
|
</ElTable>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-20px flex justify-end">
|
||||||
|
<ElPagination
|
||||||
|
v-if="mobilePagination.total"
|
||||||
|
layout="total,prev,pager,next,sizes"
|
||||||
|
v-bind="mobilePagination"
|
||||||
|
@current-change="mobilePagination['current-change']"
|
||||||
|
@size-change="mobilePagination['size-change']"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</ElCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<FeedbackOperateDialog
|
||||||
|
v-model:visible="operateVisible"
|
||||||
|
:mode="operateMode"
|
||||||
|
:row-data="operateRow"
|
||||||
|
@submitted="handleSubmitted"
|
||||||
|
/>
|
||||||
|
<FeedbackDetailDialog :id="detailId" v-model:visible="detailVisible" />
|
||||||
|
<FeedbackStatusDialog
|
||||||
|
:id="statusId"
|
||||||
|
v-model:visible="statusVisible"
|
||||||
|
:current-status="statusCurrent"
|
||||||
|
@submitted="handleStatusUpdated"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
115
src/views/feedback/modules/feedback-detail-dialog.vue
Normal file
115
src/views/feedback/modules/feedback-detail-dialog.vue
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, watch } from 'vue';
|
||||||
|
import { FEEDBACK_STATUS_DICT_CODE, FEEDBACK_TYPE_DICT_CODE } from '@/constants/dict';
|
||||||
|
import { getFeedbackStatusTagType } from '@/constants/status-tag';
|
||||||
|
import { fetchGetFeedback } from '@/service/api';
|
||||||
|
import BusinessAttachmentUploader from '@/components/custom/business-attachment-uploader.vue';
|
||||||
|
import BusinessFormDialog from '@/components/custom/business-form-dialog.vue';
|
||||||
|
import BusinessFormSection from '@/components/custom/business-form-section.vue';
|
||||||
|
import BusinessRichTextEditor from '@/components/custom/business-rich-text-editor.vue';
|
||||||
|
import DictTag from '@/components/custom/dict-tag.vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'FeedbackDetailDialog' });
|
||||||
|
|
||||||
|
const visible = defineModel<boolean>('visible', { default: false });
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
id?: string | null;
|
||||||
|
}
|
||||||
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
const detail = ref<Api.Feedback.FeedbackItem | null>(null);
|
||||||
|
|
||||||
|
async function loadDetail() {
|
||||||
|
if (!props.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loading.value = true;
|
||||||
|
const { error, data } = await fetchGetFeedback(props.id);
|
||||||
|
loading.value = false;
|
||||||
|
if (!error) {
|
||||||
|
detail.value = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(visible, value => {
|
||||||
|
if (value) {
|
||||||
|
detail.value = null;
|
||||||
|
loadDetail();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<BusinessFormDialog
|
||||||
|
v-model="visible"
|
||||||
|
title="反馈详情"
|
||||||
|
width="980px"
|
||||||
|
max-body-height="76vh"
|
||||||
|
:loading="loading"
|
||||||
|
:show-footer="false"
|
||||||
|
>
|
||||||
|
<div v-if="detail" class="feedback-detail__grid">
|
||||||
|
<div class="feedback-detail__col-left">
|
||||||
|
<BusinessFormSection title="反馈信息">
|
||||||
|
<ElDescriptions :column="1" border>
|
||||||
|
<ElDescriptionsItem label="分类">
|
||||||
|
<DictTag :dict-code="FEEDBACK_TYPE_DICT_CODE" :value="detail.type" />
|
||||||
|
</ElDescriptionsItem>
|
||||||
|
<ElDescriptionsItem label="状态">
|
||||||
|
<DictTag
|
||||||
|
:dict-code="FEEDBACK_STATUS_DICT_CODE"
|
||||||
|
:value="detail.status"
|
||||||
|
:type="getFeedbackStatusTagType(detail.status)"
|
||||||
|
/>
|
||||||
|
</ElDescriptionsItem>
|
||||||
|
<ElDescriptionsItem label="标题">{{ detail.title }}</ElDescriptionsItem>
|
||||||
|
<ElDescriptionsItem label="联系方式">{{ detail.contact || '--' }}</ElDescriptionsItem>
|
||||||
|
<ElDescriptionsItem label="提交人">{{ detail.creatorName || detail.creator }}</ElDescriptionsItem>
|
||||||
|
<ElDescriptionsItem label="提交时间">{{ detail.createTime }}</ElDescriptionsItem>
|
||||||
|
</ElDescriptions>
|
||||||
|
</BusinessFormSection>
|
||||||
|
|
||||||
|
<BusinessFormSection title="附件">
|
||||||
|
<BusinessAttachmentUploader :model-value="detail.attachments" disabled directory="feedback" />
|
||||||
|
</BusinessFormSection>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="feedback-detail__col-right">
|
||||||
|
<BusinessFormSection title="详细描述">
|
||||||
|
<BusinessRichTextEditor
|
||||||
|
:model-value="detail.content"
|
||||||
|
disabled
|
||||||
|
:height="380"
|
||||||
|
upload-directory="feedback"
|
||||||
|
placeholder="--"
|
||||||
|
/>
|
||||||
|
</BusinessFormSection>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</BusinessFormDialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.feedback-detail__grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 320px 1fr;
|
||||||
|
gap: 24px;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.feedback-detail__col-left,
|
||||||
|
.feedback-detail__col-right {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (width <= 1024px) {
|
||||||
|
.feedback-detail__grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
303
src/views/feedback/modules/feedback-facet.vue
Normal file
303
src/views/feedback/modules/feedback-facet.vue
Normal file
@@ -0,0 +1,303 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { type Component, computed } from 'vue';
|
||||||
|
import { FEEDBACK_STATUS_DICT_CODE, FEEDBACK_TYPE_DICT_CODE } from '@/constants/dict';
|
||||||
|
import { getFeedbackStatusTagType } from '@/constants/status-tag';
|
||||||
|
import { useDict } from '@/hooks/business/dict';
|
||||||
|
import IconBugOutline from '~icons/mdi/bug-outline';
|
||||||
|
import IconEmoticonSadOutline from '~icons/mdi/emoticon-sad-outline';
|
||||||
|
import IconLightbulbOnOutline from '~icons/mdi/lightbulb-on-outline';
|
||||||
|
import IconTagOutline from '~icons/mdi/tag-outline';
|
||||||
|
|
||||||
|
defineOptions({ name: 'FeedbackFacet' });
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
/** 全部反馈总数 */
|
||||||
|
total: number;
|
||||||
|
/** 各分类计数:key=分类码值字符串 */
|
||||||
|
typeCounts: Record<string, number>;
|
||||||
|
/** 各状态计数:key=状态码值字符串 */
|
||||||
|
statusCounts: Record<string, number>;
|
||||||
|
/** 当前选中的分类码值(来自列表搜索参数) */
|
||||||
|
selectedType?: string | number | null;
|
||||||
|
/** 当前选中的状态码值 */
|
||||||
|
selectedStatus?: string | number | null;
|
||||||
|
/** 统计加载态 */
|
||||||
|
loading?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
selectedType: undefined,
|
||||||
|
selectedStatus: undefined,
|
||||||
|
loading: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
/** 切换分类筛选(已处理单选 toggle,传最终值或 undefined) */
|
||||||
|
selectType: [value: string | number | undefined];
|
||||||
|
/** 切换状态筛选 */
|
||||||
|
selectStatus: [value: string | number | undefined];
|
||||||
|
/** 清空分类 + 状态筛选 */
|
||||||
|
selectAll: [];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const { dictData: typeDictData } = useDict(FEEDBACK_TYPE_DICT_CODE);
|
||||||
|
const { dictData: statusDictData } = useDict(FEEDBACK_STATUS_DICT_CODE);
|
||||||
|
|
||||||
|
// 统计接口按字典全集返回计数,分面也使用全集,避免停用码值的历史数据被隐藏。
|
||||||
|
const typeOptions = computed(() => typeDictData.value.map(item => ({ label: item.label, value: item.value })));
|
||||||
|
const statusOptions = computed(() => statusDictData.value.map(item => ({ label: item.label, value: item.value })));
|
||||||
|
|
||||||
|
// ElTag type → 主题色变量,用于状态色点(颜色语义来源仍是 status-tag.ts)
|
||||||
|
// 注意:本主题把 --el-color-info 设成了蓝色(settings.ts otherColor.info=#2080f0),
|
||||||
|
// 与「处理中」的 primary 蓝撞色;故分面里 info(已忽略/兜底)单独落真实灰,仅作用于左侧圆点,
|
||||||
|
// 右侧表格状态标签仍走主题色不受影响。
|
||||||
|
const TAG_TYPE_COLOR_VAR: Record<string, string> = {
|
||||||
|
primary: 'var(--el-color-primary)',
|
||||||
|
success: 'var(--el-color-success)',
|
||||||
|
warning: 'var(--el-color-warning)',
|
||||||
|
danger: 'var(--el-color-danger)',
|
||||||
|
info: 'var(--el-text-color-secondary)'
|
||||||
|
};
|
||||||
|
|
||||||
|
function statusDotColor(value: string | number) {
|
||||||
|
return TAG_TYPE_COLOR_VAR[getFeedbackStatusTagType(value)] ?? TAG_TYPE_COLOR_VAR.info;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分类图标按字典码值映射(feedback_type:1 缺陷 / 2 体验问题 / 3 功能建议,口径见 constants/dict.ts)
|
||||||
|
const TYPE_ICON_MAP: Record<string, Component> = {
|
||||||
|
'1': IconBugOutline,
|
||||||
|
'2': IconEmoticonSadOutline,
|
||||||
|
'3': IconLightbulbOnOutline
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 分类前导图标,未匹配码值回退通用标签图标 */
|
||||||
|
function typeIcon(value: string | number): Component {
|
||||||
|
return TYPE_ICON_MAP[String(value)] ?? IconTagOutline;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 未选任何分类 / 状态时,「全部」高亮 */
|
||||||
|
const isAllActive = computed(
|
||||||
|
() =>
|
||||||
|
(props.selectedType === undefined || props.selectedType === null) &&
|
||||||
|
(props.selectedStatus === undefined || props.selectedStatus === null)
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 选中值与候选项是否同一码值(统一 String 比较,兼容字典 value 的 number/string 形态) */
|
||||||
|
function isSame(selected: string | number | null | undefined, value: string | number) {
|
||||||
|
return selected !== undefined && selected !== null && String(selected) === String(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleType(value: string | number) {
|
||||||
|
emit('selectType', isSame(props.selectedType, value) ? undefined : value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleStatus(value: string | number) {
|
||||||
|
emit('selectStatus', isSame(props.selectedStatus, value) ? undefined : value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleAll() {
|
||||||
|
emit('selectAll');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ElCard class="feedback-facet card-wrapper">
|
||||||
|
<div v-loading="loading" class="feedback-facet__scroll">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="facet-item facet-item--all"
|
||||||
|
:class="{ 'is-active': isAllActive }"
|
||||||
|
:aria-pressed="isAllActive"
|
||||||
|
@click="handleAll"
|
||||||
|
>
|
||||||
|
<span class="facet-item__lead" aria-hidden="true"><icon-mdi-inbox-multiple-outline /></span>
|
||||||
|
<span class="facet-item__label">全部</span>
|
||||||
|
<span class="facet-item__count" :class="{ 'is-zero': total === 0 }">{{ total }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="facet-group">
|
||||||
|
<p class="facet-group__title">分类</p>
|
||||||
|
<button
|
||||||
|
v-for="opt in typeOptions"
|
||||||
|
:key="opt.value"
|
||||||
|
type="button"
|
||||||
|
class="facet-item"
|
||||||
|
:class="{ 'is-active': isSame(selectedType, opt.value) }"
|
||||||
|
:aria-pressed="isSame(selectedType, opt.value)"
|
||||||
|
@click="handleType(opt.value)"
|
||||||
|
>
|
||||||
|
<span class="facet-item__lead" aria-hidden="true"><component :is="typeIcon(opt.value)" /></span>
|
||||||
|
<span class="facet-item__label">{{ opt.label }}</span>
|
||||||
|
<span class="facet-item__count" :class="{ 'is-zero': (typeCounts[String(opt.value)] ?? 0) === 0 }">
|
||||||
|
{{ typeCounts[String(opt.value)] ?? 0 }}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<p v-if="!typeOptions.length" class="facet-empty">分类字典未加载</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="facet-group">
|
||||||
|
<p class="facet-group__title">状态</p>
|
||||||
|
<button
|
||||||
|
v-for="opt in statusOptions"
|
||||||
|
:key="opt.value"
|
||||||
|
type="button"
|
||||||
|
class="facet-item"
|
||||||
|
:class="{ 'is-active': isSame(selectedStatus, opt.value) }"
|
||||||
|
:aria-pressed="isSame(selectedStatus, opt.value)"
|
||||||
|
@click="handleStatus(opt.value)"
|
||||||
|
>
|
||||||
|
<span class="facet-item__lead" aria-hidden="true">
|
||||||
|
<span class="facet-item__dot" :style="{ backgroundColor: statusDotColor(opt.value) }" />
|
||||||
|
</span>
|
||||||
|
<span class="facet-item__label">{{ opt.label }}</span>
|
||||||
|
<span class="facet-item__count" :class="{ 'is-zero': (statusCounts[String(opt.value)] ?? 0) === 0 }">
|
||||||
|
{{ statusCounts[String(opt.value)] ?? 0 }}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<p v-if="!statusOptions.length" class="facet-empty">状态字典未加载</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ElCard>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.feedback-facet {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
:deep(.el-card__body) {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.feedback-facet__scroll {
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding-right: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.facet-item--all {
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.facet-group + .facet-group {
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.facet-group__title {
|
||||||
|
margin: 14px 10px 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.04em;
|
||||||
|
color: var(--el-text-color-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.facet-empty {
|
||||||
|
margin: 4px 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--el-text-color-placeholder);
|
||||||
|
}
|
||||||
|
|
||||||
|
.facet-item {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 7px 10px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--el-text-color-regular);
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.4;
|
||||||
|
text-align: left;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.18s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.facet-item:hover {
|
||||||
|
background: var(--el-fill-color-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 键盘聚焦可见环(offset 内缩,避免被圆角裁切)
|
||||||
|
.facet-item:focus-visible {
|
||||||
|
outline: 2px solid var(--el-color-primary);
|
||||||
|
outline-offset: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.facet-item.is-active {
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
background: var(--el-color-primary-light-9);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 选中项左侧主题色强调条
|
||||||
|
.facet-item.is-active::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 3px;
|
||||||
|
width: 3px;
|
||||||
|
height: 14px;
|
||||||
|
border-radius: 2px;
|
||||||
|
background: var(--el-color-primary);
|
||||||
|
transform: translateY(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 前导标记列:全部=收件箱图标 / 状态=语义色点,对齐同一宽度
|
||||||
|
.facet-item__lead {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-shrink: 0;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 18px;
|
||||||
|
font-size: 16px;
|
||||||
|
color: var(--el-text-color-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.facet-item:hover .facet-item__lead,
|
||||||
|
.facet-item.is-active .facet-item__lead {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.facet-item__dot {
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.facet-item__label {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.facet-item__count {
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-size: 12px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
color: var(--el-text-color-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计数为 0 的项弱化,避免一排 0 抢视线
|
||||||
|
.facet-item__count.is-zero {
|
||||||
|
color: var(--el-text-color-placeholder);
|
||||||
|
}
|
||||||
|
|
||||||
|
.facet-item.is-active .facet-item__count {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 尊重系统「减少动态效果」偏好
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.facet-item {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
252
src/views/feedback/modules/feedback-operate-dialog.vue
Normal file
252
src/views/feedback/modules/feedback-operate-dialog.vue
Normal file
@@ -0,0 +1,252 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, nextTick, reactive, ref, watch } from 'vue';
|
||||||
|
import { FEEDBACK_TYPE_DICT_CODE } from '@/constants/dict';
|
||||||
|
import { fetchCreateFeedback, fetchUpdateFeedback } from '@/service/api';
|
||||||
|
import { useForm, useFormRules } from '@/hooks/common/form';
|
||||||
|
import BusinessAttachmentUploader from '@/components/custom/business-attachment-uploader.vue';
|
||||||
|
import BusinessFormDialog from '@/components/custom/business-form-dialog.vue';
|
||||||
|
import BusinessFormSection from '@/components/custom/business-form-section.vue';
|
||||||
|
import BusinessRichTextEditor from '@/components/custom/business-rich-text-editor.vue';
|
||||||
|
import DictSelect from '@/components/custom/dict-select.vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'FeedbackOperateDialog' });
|
||||||
|
|
||||||
|
type OperateMode = 'create' | 'edit';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
mode: OperateMode;
|
||||||
|
rowData?: Api.Feedback.FeedbackItem | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
rowData: null
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
submitted: [];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const visible = defineModel<boolean>('visible', { default: false });
|
||||||
|
|
||||||
|
const { formRef, validate } = useForm();
|
||||||
|
const { createRequiredRule } = useFormRules();
|
||||||
|
|
||||||
|
const submitting = ref(false);
|
||||||
|
const attachmentUploaderRef = ref<InstanceType<typeof BusinessAttachmentUploader> | null>(null);
|
||||||
|
const richTextEditorRef = ref<InstanceType<typeof BusinessRichTextEditor> | null>(null);
|
||||||
|
|
||||||
|
interface FormModel {
|
||||||
|
/** DictSelect 选中后为字符串;提交时 Number() 转字典 Integer(非 ID,允许转 number) */
|
||||||
|
type: string | number | null;
|
||||||
|
title: string;
|
||||||
|
content: string;
|
||||||
|
contact: string;
|
||||||
|
attachments: Api.Project.AttachmentItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const model = reactive<FormModel>({
|
||||||
|
type: null,
|
||||||
|
title: '',
|
||||||
|
content: '',
|
||||||
|
contact: '',
|
||||||
|
attachments: []
|
||||||
|
});
|
||||||
|
|
||||||
|
const dialogTitle = computed(() => (props.mode === 'create' ? '提交意见反馈' : '编辑意见反馈'));
|
||||||
|
|
||||||
|
/** 富文本是否为空:去标签去 后无文本,且无图片 */
|
||||||
|
function isEmptyRichText(html: string | null | undefined) {
|
||||||
|
if (!html) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const text = html
|
||||||
|
.replace(/<[^>]+>/g, '')
|
||||||
|
.replace(/ /g, '')
|
||||||
|
.trim();
|
||||||
|
if (text) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !/<img\b/i.test(html);
|
||||||
|
}
|
||||||
|
|
||||||
|
const rules = computed(
|
||||||
|
() =>
|
||||||
|
({
|
||||||
|
type: [createRequiredRule('请选择反馈分类')],
|
||||||
|
title: [createRequiredRule('请输入标题')],
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
validator: (_rule, _value, callback) => {
|
||||||
|
if (isEmptyRichText(model.content)) {
|
||||||
|
callback(new Error('请输入详细描述'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callback();
|
||||||
|
},
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}) satisfies Record<string, App.Global.FormRule[]>
|
||||||
|
);
|
||||||
|
|
||||||
|
function applyRowDataToModel() {
|
||||||
|
const row = props.rowData;
|
||||||
|
if (props.mode === 'edit' && row) {
|
||||||
|
// 字典选项 value 为字符串,回显需转字符串才能与下拉项严格匹配(否则显示原始数字)
|
||||||
|
model.type = row.type === null || row.type === undefined ? null : String(row.type);
|
||||||
|
model.title = row.title ?? '';
|
||||||
|
model.content = row.content ?? '';
|
||||||
|
model.contact = row.contact ?? '';
|
||||||
|
model.attachments = row.attachments ? [...row.attachments] : [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
model.type = null;
|
||||||
|
model.title = '';
|
||||||
|
model.content = '';
|
||||||
|
model.contact = '';
|
||||||
|
model.attachments = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleConfirm() {
|
||||||
|
await validate();
|
||||||
|
|
||||||
|
if (attachmentUploaderRef.value?.hasUploading) {
|
||||||
|
window.$message?.warning('附件还在上传中,请稍候');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
submitting.value = true;
|
||||||
|
|
||||||
|
const basePayload: Api.Feedback.FeedbackSubmitParams = {
|
||||||
|
type: Number(model.type),
|
||||||
|
title: model.title.trim(),
|
||||||
|
content: model.content,
|
||||||
|
contact: model.contact.trim() || undefined,
|
||||||
|
attachments: [...model.attachments]
|
||||||
|
};
|
||||||
|
|
||||||
|
const { error } =
|
||||||
|
props.mode === 'edit' && props.rowData
|
||||||
|
? await fetchUpdateFeedback({ id: props.rowData.id, ...basePayload })
|
||||||
|
: await fetchCreateFeedback(basePayload);
|
||||||
|
|
||||||
|
submitting.value = false;
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 成功后先 commit,置 committed=true,避免 destroy-on-close 触发 rollback 误删已存文件/图片
|
||||||
|
await Promise.all([attachmentUploaderRef.value?.commit(), richTextEditorRef.value?.commit()]);
|
||||||
|
window.$message?.success(props.mode === 'edit' ? '保存成功' : '提交成功');
|
||||||
|
visible.value = false;
|
||||||
|
emit('submitted');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleCancel() {
|
||||||
|
await Promise.all([attachmentUploaderRef.value?.rollback(), richTextEditorRef.value?.rollback()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(visible, async value => {
|
||||||
|
if (!value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
applyRowDataToModel();
|
||||||
|
await nextTick();
|
||||||
|
// 让附件 / 富文本组件把当前 model 视作 original,必须在 model 填充之后
|
||||||
|
attachmentUploaderRef.value?.initSession();
|
||||||
|
richTextEditorRef.value?.initSession();
|
||||||
|
formRef.value?.clearValidate();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<BusinessFormDialog
|
||||||
|
v-model="visible"
|
||||||
|
:title="dialogTitle"
|
||||||
|
width="980px"
|
||||||
|
max-body-height="76vh"
|
||||||
|
:confirm-loading="submitting"
|
||||||
|
@confirm="handleConfirm"
|
||||||
|
@cancel="handleCancel"
|
||||||
|
>
|
||||||
|
<ElForm
|
||||||
|
ref="formRef"
|
||||||
|
:model="model"
|
||||||
|
:rules="rules"
|
||||||
|
label-position="top"
|
||||||
|
:validate-on-rule-change="false"
|
||||||
|
class="feedback-operate-dialog__form"
|
||||||
|
>
|
||||||
|
<div class="feedback-operate-dialog__grid">
|
||||||
|
<div class="feedback-operate-dialog__col-left">
|
||||||
|
<BusinessFormSection title="反馈信息">
|
||||||
|
<ElFormItem label="反馈分类" prop="type">
|
||||||
|
<DictSelect v-model="model.type" :dict-code="FEEDBACK_TYPE_DICT_CODE" placeholder="请选择反馈分类" />
|
||||||
|
</ElFormItem>
|
||||||
|
|
||||||
|
<ElFormItem label="标题" prop="title">
|
||||||
|
<ElInput v-model="model.title" maxlength="100" show-word-limit placeholder="请输入标题" />
|
||||||
|
</ElFormItem>
|
||||||
|
|
||||||
|
<ElFormItem label="联系方式">
|
||||||
|
<ElInput v-model="model.contact" maxlength="100" placeholder="选填,方便我们联系你" />
|
||||||
|
</ElFormItem>
|
||||||
|
</BusinessFormSection>
|
||||||
|
|
||||||
|
<BusinessFormSection title="附件">
|
||||||
|
<ElFormItem class="feedback-operate-dialog__attachment-item">
|
||||||
|
<BusinessAttachmentUploader
|
||||||
|
ref="attachmentUploaderRef"
|
||||||
|
v-model="model.attachments"
|
||||||
|
directory="feedback"
|
||||||
|
/>
|
||||||
|
</ElFormItem>
|
||||||
|
</BusinessFormSection>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="feedback-operate-dialog__col-right">
|
||||||
|
<BusinessFormSection title="详细描述">
|
||||||
|
<ElFormItem prop="content" class="feedback-operate-dialog__desc-item">
|
||||||
|
<BusinessRichTextEditor
|
||||||
|
ref="richTextEditorRef"
|
||||||
|
v-model="model.content"
|
||||||
|
:height="380"
|
||||||
|
upload-directory="feedback"
|
||||||
|
placeholder="请输入详细描述"
|
||||||
|
/>
|
||||||
|
</ElFormItem>
|
||||||
|
</BusinessFormSection>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ElForm>
|
||||||
|
</BusinessFormDialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.feedback-operate-dialog__grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 320px 1fr;
|
||||||
|
gap: 24px;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.feedback-operate-dialog__col-left,
|
||||||
|
.feedback-operate-dialog__col-right {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.feedback-operate-dialog__desc-item,
|
||||||
|
.feedback-operate-dialog__attachment-item {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (width <= 1024px) {
|
||||||
|
.feedback-operate-dialog__grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
31
src/views/feedback/modules/feedback-search.vue
Normal file
31
src/views/feedback/modules/feedback-search.vue
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import TableSearchFields, { type SearchField } from '@/components/custom/table-search-fields.vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'FeedbackSearch' });
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
reset: [];
|
||||||
|
search: [];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const model = defineModel<Api.Feedback.FeedbackSearchParams>('model', { required: true });
|
||||||
|
|
||||||
|
// 分类 / 状态筛选已迁移至左侧分面面板,搜索区只保留标题关键词
|
||||||
|
const fields: SearchField[] = [{ key: 'title', label: '标题', type: 'input', placeholder: '请输入标题关键词' }];
|
||||||
|
|
||||||
|
function reset() {
|
||||||
|
emit('reset');
|
||||||
|
}
|
||||||
|
|
||||||
|
function search() {
|
||||||
|
// 输入期不实时 trim(避免受控 input 吃掉词间空格);提交前规整一次,空串归一为 undefined
|
||||||
|
model.value.title = model.value.title?.trim() || undefined;
|
||||||
|
emit('search');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<TableSearchFields v-model="model" :fields="fields" :columns="2" @reset="reset" @search="search" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
74
src/views/feedback/modules/feedback-status-dialog.vue
Normal file
74
src/views/feedback/modules/feedback-status-dialog.vue
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, ref, watch } from 'vue';
|
||||||
|
import { FEEDBACK_STATUS_DICT_CODE } from '@/constants/dict';
|
||||||
|
import { fetchUpdateFeedbackStatus } from '@/service/api';
|
||||||
|
import BusinessFormDialog from '@/components/custom/business-form-dialog.vue';
|
||||||
|
import DictSelect from '@/components/custom/dict-select.vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'FeedbackStatusDialog' });
|
||||||
|
|
||||||
|
const visible = defineModel<boolean>('visible', { default: false });
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
id?: string | null;
|
||||||
|
currentStatus?: number | null;
|
||||||
|
}
|
||||||
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
submitted: [];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const submitting = ref(false);
|
||||||
|
const status = ref<string | number | null>(null);
|
||||||
|
|
||||||
|
const confirmDisabled = computed(() => status.value === null || status.value === undefined || status.value === '');
|
||||||
|
|
||||||
|
async function handleConfirm() {
|
||||||
|
if (!props.id || confirmDisabled.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
submitting.value = true;
|
||||||
|
// status 是字典编码(非 ID),DictSelect 选中为字符串,转 Integer 提交
|
||||||
|
const { error } = await fetchUpdateFeedbackStatus(props.id, Number(status.value));
|
||||||
|
submitting.value = false;
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.$message?.success('状态已更新');
|
||||||
|
visible.value = false;
|
||||||
|
emit('submitted');
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(visible, value => {
|
||||||
|
if (value) {
|
||||||
|
// 字典选项 value 为字符串,回显需转字符串才能与下拉项严格匹配(否则显示原始数字)
|
||||||
|
const current = props.currentStatus;
|
||||||
|
status.value = current === null || current === undefined ? null : String(current);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<BusinessFormDialog
|
||||||
|
v-model="visible"
|
||||||
|
title="修改处理状态"
|
||||||
|
preset="sm"
|
||||||
|
:confirm-loading="submitting"
|
||||||
|
:confirm-disabled="confirmDisabled"
|
||||||
|
@confirm="handleConfirm"
|
||||||
|
>
|
||||||
|
<ElForm label-position="top">
|
||||||
|
<ElFormItem label="处理状态">
|
||||||
|
<DictSelect
|
||||||
|
v-model="status"
|
||||||
|
:dict-code="FEEDBACK_STATUS_DICT_CODE"
|
||||||
|
:clearable="false"
|
||||||
|
placeholder="请选择处理状态"
|
||||||
|
/>
|
||||||
|
</ElFormItem>
|
||||||
|
</ElForm>
|
||||||
|
</BusinessFormDialog>
|
||||||
|
</template>
|
||||||
48
tests/feedback-stat-normalization.test.ts
Normal file
48
tests/feedback-stat-normalization.test.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { describe, it } from 'node:test';
|
||||||
|
import { normalizeFeedbackStat } from '../src/service/api/feedback-normalize';
|
||||||
|
|
||||||
|
describe('normalizeFeedbackStat', () => {
|
||||||
|
it('maps backend type/status count arrays to code-keyed records', () => {
|
||||||
|
const result = normalizeFeedbackStat({
|
||||||
|
total: 128,
|
||||||
|
typeCounts: [
|
||||||
|
{ type: 1, count: 52 },
|
||||||
|
{ type: 2, count: 31 },
|
||||||
|
{ type: 3, count: 45 }
|
||||||
|
],
|
||||||
|
statusCounts: [
|
||||||
|
{ status: 1, count: 40 },
|
||||||
|
{ status: 2, count: 33 },
|
||||||
|
{ status: 3, count: 50 },
|
||||||
|
{ status: 4, count: 5 }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(result, {
|
||||||
|
total: 128,
|
||||||
|
typeCounts: {
|
||||||
|
'1': 52,
|
||||||
|
'2': 31,
|
||||||
|
'3': 45
|
||||||
|
},
|
||||||
|
statusCounts: {
|
||||||
|
'1': 40,
|
||||||
|
'2': 33,
|
||||||
|
'3': 50,
|
||||||
|
'4': 5
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps zero-count dictionary codes visible to the facet panel', () => {
|
||||||
|
const result = normalizeFeedbackStat({
|
||||||
|
total: 0,
|
||||||
|
typeCounts: [{ type: '1', count: 0 }],
|
||||||
|
statusCounts: [{ status: '4', count: 0 }]
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(result.typeCounts, { '1': 0 });
|
||||||
|
assert.deepEqual(result.statusCounts, { '4': 0 });
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user