mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 22:59:19 +08:00
feat: 新增意见反馈功能
This commit is contained in:
@@ -0,0 +1,149 @@
|
|||||||
|
-- 系统-意见反馈域设计(已落地 migration: V20260915__sys_feedback.sql)
|
||||||
|
-- sys_feedback / sys_feedback_images
|
||||||
|
-- sys_feedback_message / sys_feedback_message_images
|
||||||
|
--
|
||||||
|
-- 产品约定(已拍板):
|
||||||
|
-- 1) 处理侧:超管 + 公司有 handle 权限者(本公司);超管可看全部公司
|
||||||
|
-- 2) 用户侧列表:本公司全员互看
|
||||||
|
-- 3) 用户侧可互相留言回复;处理侧回复仅 assignee
|
||||||
|
-- 4) 留言允许多层树
|
||||||
|
-- 5) 用户仅可关闭 OPEN 单;RESOLVED 后再留言不重开
|
||||||
|
-- 6) 删除需 sys:feedback:delete
|
||||||
|
-- 7) 处理侧菜单挂系统设置;用户侧独立菜单 + 工作台/个人中心入口
|
||||||
|
-- 8) 关联菜单由用户手选(menu_id 选填)
|
||||||
|
--
|
||||||
|
-- 边界:
|
||||||
|
-- - 按公司隔离(company_id);提交人为公司成员(create_by)
|
||||||
|
-- - 正文可选关联 sys_menu(menu_id 选填)
|
||||||
|
-- - 多图不落 URL:一律 sys_file.id,经关联表挂接
|
||||||
|
-- - 反馈正文图 → sys_feedback_images
|
||||||
|
-- - 留言/回复图 → sys_feedback_message_images
|
||||||
|
-- - 留言支持树形回复(parent_id);root_id 便于按楼聚合
|
||||||
|
-- ========================================
|
||||||
|
|
||||||
|
-- ========================================
|
||||||
|
-- 意见反馈主表
|
||||||
|
-- ========================================
|
||||||
|
DROP TABLE IF EXISTS `sys_feedback_message_images`;
|
||||||
|
DROP TABLE IF EXISTS `sys_feedback_message`;
|
||||||
|
DROP TABLE IF EXISTS `sys_feedback_images`;
|
||||||
|
DROP TABLE IF EXISTS `sys_feedback`;
|
||||||
|
|
||||||
|
CREATE TABLE `sys_feedback` (
|
||||||
|
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '反馈ID',
|
||||||
|
`company_id` bigint UNSIGNED NOT NULL COMMENT '所属公司ID',
|
||||||
|
`title` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '标题',
|
||||||
|
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '正文',
|
||||||
|
`type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'OTHER' COMMENT '类型:BUG/FEATURE/QUESTION/COMPLAINT/OTHER',
|
||||||
|
`status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'OPEN' COMMENT '状态:OPEN/PROCESSING/RESOLVED/CLOSED/REJECTED',
|
||||||
|
`priority` tinyint UNSIGNED NOT NULL DEFAULT 2 COMMENT '优先级:1高 2中 3低',
|
||||||
|
`contact` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系方式(选填:手机/微信/邮箱)',
|
||||||
|
`menu_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '关联菜单ID(选填,对应 sys_menu.id)',
|
||||||
|
`page_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '提交时页面路径/URL(便于复现;可与 menu_id 并存)',
|
||||||
|
`client_info` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '客户端摘要(UA/端类型等,可选)',
|
||||||
|
`assignee_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '处理人用户ID(可空)',
|
||||||
|
`image_count` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '正文附图数量(冗余)',
|
||||||
|
`message_count` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '留言+回复总数(冗余,不含正文)',
|
||||||
|
`last_message_at` timestamp NULL DEFAULT NULL COMMENT '最近一条留言时间(列表排序用)',
|
||||||
|
`submitter_unread` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '提交人未读:0否 1是(处理方新留言后置1)',
|
||||||
|
`handler_unread` tinyint UNSIGNED NOT NULL DEFAULT 1 COMMENT '处理方未读:0否 1是(新建/用户新留言置1)',
|
||||||
|
`resolved_at` timestamp NULL DEFAULT NULL COMMENT '首次标记已解决时间',
|
||||||
|
`closed_at` timestamp NULL DEFAULT NULL COMMENT '关闭时间',
|
||||||
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`create_by` bigint UNSIGNED NOT NULL COMMENT '提交人用户ID',
|
||||||
|
`update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人用户ID',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_company_status` (`company_id` ASC, `status` ASC, `update_time` DESC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_company_create_by` (`company_id` ASC, `create_by` ASC, `id` DESC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_menu` (`menu_id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_assignee` (`assignee_id` ASC, `status` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_last_message` (`company_id` ASC, `last_message_at` DESC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_handler_unread` (`company_id` ASC, `handler_unread` ASC, `id` DESC) USING BTREE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_menu` FOREIGN KEY (`menu_id`) REFERENCES `sys_menu` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_assignee` FOREIGN KEY (`assignee_id`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||||
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '系统-意见反馈主表' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ========================================
|
||||||
|
-- 反馈正文多图(关联 sys_file)
|
||||||
|
-- ========================================
|
||||||
|
CREATE TABLE `sys_feedback_images` (
|
||||||
|
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`feedback_id` bigint UNSIGNED NOT NULL COMMENT '反馈ID',
|
||||||
|
`file_id` bigint UNSIGNED NOT NULL COMMENT '系统文件ID',
|
||||||
|
`sort_order` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '展示顺序(小在前)',
|
||||||
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`create_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '上传人(通常=反馈提交人)',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
|
UNIQUE INDEX `uk_sys_feedback_images_fb_file` (`feedback_id` ASC, `file_id` ASC) USING BTREE COMMENT '同一反馈内文件不重复',
|
||||||
|
INDEX `idx_sys_feedback_images_feedback` (`feedback_id` ASC, `sort_order` ASC, `id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_images_file` (`file_id` ASC) USING BTREE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_images_feedback` FOREIGN KEY (`feedback_id`) REFERENCES `sys_feedback` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_images_file` FOREIGN KEY (`file_id`) REFERENCES `sys_file` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_images_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||||
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '系统-意见反馈正文图片关联表' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ========================================
|
||||||
|
-- 反馈留言 / 回复
|
||||||
|
-- parent_id IS NULL = 顶层留言
|
||||||
|
-- parent_id 非空 = 回复某条留言(可多层;产品可限深)
|
||||||
|
-- root_id = 所属顶层留言ID(顶层时 root_id = 自身 id,插入后回写或应用层写入)
|
||||||
|
-- ========================================
|
||||||
|
CREATE TABLE `sys_feedback_message` (
|
||||||
|
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '留言ID',
|
||||||
|
`feedback_id` bigint UNSIGNED NOT NULL COMMENT '所属反馈ID',
|
||||||
|
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID(冗余,便于权限过滤)',
|
||||||
|
`parent_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '父留言ID;NULL=顶层留言',
|
||||||
|
`root_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '顶层留言ID;顶层留言可等于自身id',
|
||||||
|
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '留言正文',
|
||||||
|
`author_role` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'USER' COMMENT '发言角色:USER提交侧 / HANDLER处理侧 / SYSTEM系统',
|
||||||
|
`image_count` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '本条附图数量(冗余)',
|
||||||
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`create_by` bigint UNSIGNED NOT NULL COMMENT '发言人用户ID',
|
||||||
|
`update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_message_feedback` (`feedback_id` ASC, `id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_message_root` (`feedback_id` ASC, `root_id` ASC, `id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_message_parent` (`parent_id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_message_company_author` (`company_id` ASC, `create_by` ASC) USING BTREE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_feedback` FOREIGN KEY (`feedback_id`) REFERENCES `sys_feedback` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_parent` FOREIGN KEY (`parent_id`) REFERENCES `sys_feedback_message` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_root` FOREIGN KEY (`root_id`) REFERENCES `sys_feedback_message` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||||
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '系统-意见反馈留言/回复表' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ========================================
|
||||||
|
-- 留言多图(关联 sys_file)
|
||||||
|
-- ========================================
|
||||||
|
CREATE TABLE `sys_feedback_message_images` (
|
||||||
|
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`message_id` bigint UNSIGNED NOT NULL COMMENT '留言ID',
|
||||||
|
`feedback_id` bigint UNSIGNED NOT NULL COMMENT '反馈ID(冗余,便于按单清理/查询)',
|
||||||
|
`file_id` bigint UNSIGNED NOT NULL COMMENT '系统文件ID',
|
||||||
|
`sort_order` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '展示顺序(小在前)',
|
||||||
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`create_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '上传人',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
|
UNIQUE INDEX `uk_sys_feedback_message_images_msg_file` (`message_id` ASC, `file_id` ASC) USING BTREE COMMENT '同一留言内文件不重复',
|
||||||
|
INDEX `idx_sys_feedback_message_images_msg` (`message_id` ASC, `sort_order` ASC, `id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_message_images_feedback` (`feedback_id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_message_images_file` (`file_id` ASC) USING BTREE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_images_msg` FOREIGN KEY (`message_id`) REFERENCES `sys_feedback_message` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_images_feedback` FOREIGN KEY (`feedback_id`) REFERENCES `sys_feedback` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_images_file` FOREIGN KEY (`file_id`) REFERENCES `sys_file` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_images_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||||
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '系统-意见反馈留言图片关联表' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ========================================
|
||||||
|
-- 权限码建议(落地时写入 sys_permission / 菜单,非本文件建表)
|
||||||
|
-- sys:feedback:create 提交反馈
|
||||||
|
-- sys:feedback:read 查看本公司反馈(普通用户仅自己的;管理员看全部——应用层区分)
|
||||||
|
-- sys:feedback:handle 处理/回复/改状态(公司管理员或平台超管)
|
||||||
|
-- sys:feedback:delete 删除反馈(建议仅管理员;已有留言时需确认策略)
|
||||||
|
-- ========================================
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
-- 意见反馈:主表 / 正文图 / 留言 / 留言图 + 权限与菜单
|
||||||
|
-- 用户侧菜单 SysFeedbackUser;处理侧菜单 SysFeedbackHandle(系统设置下)
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `sys_feedback` (
|
||||||
|
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '反馈ID',
|
||||||
|
`company_id` bigint UNSIGNED NOT NULL COMMENT '所属公司ID',
|
||||||
|
`title` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '标题',
|
||||||
|
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '正文',
|
||||||
|
`type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'OTHER' COMMENT '类型:BUG/FEATURE/QUESTION/COMPLAINT/OTHER',
|
||||||
|
`status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'OPEN' COMMENT '状态:OPEN/PROCESSING/RESOLVED/CLOSED/REJECTED',
|
||||||
|
`priority` tinyint UNSIGNED NOT NULL DEFAULT 2 COMMENT '优先级:1高 2中 3低',
|
||||||
|
`contact` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系方式(选填)',
|
||||||
|
`menu_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '关联菜单ID(选填)',
|
||||||
|
`page_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '提交时页面路径/URL',
|
||||||
|
`client_info` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '客户端摘要',
|
||||||
|
`assignee_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '处理人用户ID',
|
||||||
|
`image_count` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '正文附图数量',
|
||||||
|
`message_count` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '留言+回复总数',
|
||||||
|
`last_message_at` timestamp NULL DEFAULT NULL COMMENT '最近留言时间',
|
||||||
|
`submitter_unread` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '提交人未读',
|
||||||
|
`handler_unread` tinyint UNSIGNED NOT NULL DEFAULT 1 COMMENT '处理方未读',
|
||||||
|
`resolved_at` timestamp NULL DEFAULT NULL COMMENT '首次已解决时间',
|
||||||
|
`closed_at` timestamp NULL DEFAULT NULL COMMENT '关闭时间',
|
||||||
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`create_by` bigint UNSIGNED NOT NULL COMMENT '提交人',
|
||||||
|
`update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_company_status` (`company_id` ASC, `status` ASC, `update_time` DESC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_company_create_by` (`company_id` ASC, `create_by` ASC, `id` DESC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_menu` (`menu_id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_assignee` (`assignee_id` ASC, `status` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_last_message` (`company_id` ASC, `last_message_at` DESC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_handler_unread` (`company_id` ASC, `handler_unread` ASC, `id` DESC) USING BTREE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_menu` FOREIGN KEY (`menu_id`) REFERENCES `sys_menu` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_assignee` FOREIGN KEY (`assignee_id`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||||
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '系统-意见反馈主表' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `sys_feedback_images` (
|
||||||
|
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`feedback_id` bigint UNSIGNED NOT NULL COMMENT '反馈ID',
|
||||||
|
`file_id` bigint UNSIGNED NOT NULL COMMENT '系统文件ID',
|
||||||
|
`sort_order` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '展示顺序',
|
||||||
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`create_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '上传人',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
|
UNIQUE INDEX `uk_sys_feedback_images_fb_file` (`feedback_id` ASC, `file_id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_images_feedback` (`feedback_id` ASC, `sort_order` ASC, `id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_images_file` (`file_id` ASC) USING BTREE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_images_feedback` FOREIGN KEY (`feedback_id`) REFERENCES `sys_feedback` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_images_file` FOREIGN KEY (`file_id`) REFERENCES `sys_file` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_images_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||||
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '系统-意见反馈正文图片' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `sys_feedback_message` (
|
||||||
|
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '留言ID',
|
||||||
|
`feedback_id` bigint UNSIGNED NOT NULL COMMENT '所属反馈ID',
|
||||||
|
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
||||||
|
`parent_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '父留言ID',
|
||||||
|
`root_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '顶层留言ID',
|
||||||
|
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '留言正文',
|
||||||
|
`author_role` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'USER' COMMENT 'USER/HANDLER/SYSTEM',
|
||||||
|
`image_count` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '附图数量',
|
||||||
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`create_by` bigint UNSIGNED NOT NULL COMMENT '发言人',
|
||||||
|
`update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_message_feedback` (`feedback_id` ASC, `id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_message_root` (`feedback_id` ASC, `root_id` ASC, `id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_message_parent` (`parent_id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_message_company_author` (`company_id` ASC, `create_by` ASC) USING BTREE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_feedback` FOREIGN KEY (`feedback_id`) REFERENCES `sys_feedback` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_parent` FOREIGN KEY (`parent_id`) REFERENCES `sys_feedback_message` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_root` FOREIGN KEY (`root_id`) REFERENCES `sys_feedback_message` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||||
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '系统-意见反馈留言' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `sys_feedback_message_images` (
|
||||||
|
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`message_id` bigint UNSIGNED NOT NULL COMMENT '留言ID',
|
||||||
|
`feedback_id` bigint UNSIGNED NOT NULL COMMENT '反馈ID',
|
||||||
|
`file_id` bigint UNSIGNED NOT NULL COMMENT '系统文件ID',
|
||||||
|
`sort_order` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '展示顺序',
|
||||||
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`create_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '上传人',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
|
UNIQUE INDEX `uk_sys_feedback_message_images_msg_file` (`message_id` ASC, `file_id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_message_images_msg` (`message_id` ASC, `sort_order` ASC, `id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_message_images_feedback` (`feedback_id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_sys_feedback_message_images_file` (`file_id` ASC) USING BTREE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_images_msg` FOREIGN KEY (`message_id`) REFERENCES `sys_feedback_message` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_images_feedback` FOREIGN KEY (`feedback_id`) REFERENCES `sys_feedback` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_images_file` FOREIGN KEY (`file_id`) REFERENCES `sys_file` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_sys_feedback_message_images_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||||
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '系统-意见反馈留言图片' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- 权限:sys:feedback*
|
||||||
|
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||||
|
SELECT 1600, (SELECT id FROM `sys_permission` WHERE `code` = 'sys' LIMIT 1), 'sys:feedback', '意见反馈', 'module', 1, '', 60
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1600 OR `code` = 'sys:feedback');
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||||
|
SELECT 1601, (SELECT id FROM `sys_permission` WHERE `code` = 'sys:feedback' LIMIT 1), 'sys:feedback:read', '查看', 'api', 1, '用户侧本公司全员;处理侧超管/有权用户', 1
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1601 OR `code` = 'sys:feedback:read');
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||||
|
SELECT 1602, (SELECT id FROM `sys_permission` WHERE `code` = 'sys:feedback' LIMIT 1), 'sys:feedback:create', '提交', 'api', 1, '', 2
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1602 OR `code` = 'sys:feedback:create');
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||||
|
SELECT 1603, (SELECT id FROM `sys_permission` WHERE `code` = 'sys:feedback' LIMIT 1), 'sys:feedback:handle', '处理', 'api', 1, '改状态/指派;回复仅 assignee', 3
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1603 OR `code` = 'sys:feedback:handle');
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||||
|
SELECT 1604, (SELECT id FROM `sys_permission` WHERE `code` = 'sys:feedback' LIMIT 1), 'sys:feedback:delete', '删除', 'api', 1, '仅管理员(公司已分配权限的角色)', 4
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = 1604 OR `code` = 'sys:feedback:delete');
|
||||||
|
|
||||||
|
-- 用户侧菜单(顶级独立入口)
|
||||||
|
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `route_name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||||
|
SELECT 12100,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
'SysFeedbackUser',
|
||||||
|
'意见反馈',
|
||||||
|
'/feedback',
|
||||||
|
'/sys/feedback/user/index',
|
||||||
|
'',
|
||||||
|
'lucide:message-square-plus',
|
||||||
|
'menu',
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
12
|
||||||
|
FROM DUAL
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 12100 OR `route_name` = 'SysFeedbackUser');
|
||||||
|
|
||||||
|
-- 处理侧菜单(系统设置下)
|
||||||
|
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `route_name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||||
|
SELECT 12101,
|
||||||
|
(SELECT id FROM `sys_menu` WHERE `id` = 1 OR `title` = '系统设置' OR `route_name` = 'SysSettings' LIMIT 1),
|
||||||
|
1,
|
||||||
|
'SysFeedbackHandle',
|
||||||
|
'反馈处理',
|
||||||
|
'/sys/feedback/handle',
|
||||||
|
'/sys/feedback/handle/index',
|
||||||
|
'',
|
||||||
|
'lucide:messages-square',
|
||||||
|
'menu',
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
6
|
||||||
|
FROM DUAL
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 12101 OR `route_name` = 'SysFeedbackHandle');
|
||||||
|
|
||||||
|
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||||
|
SELECT m.id, p.id
|
||||||
|
FROM `sys_menu` m
|
||||||
|
JOIN `sys_permission` p ON p.code IN ('sys:feedback:read', 'sys:feedback:create')
|
||||||
|
WHERE m.route_name = 'SysFeedbackUser';
|
||||||
|
|
||||||
|
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||||
|
SELECT m.id, p.id
|
||||||
|
FROM `sys_menu` m
|
||||||
|
JOIN `sys_permission` p ON p.code IN ('sys:feedback:read', 'sys:feedback:handle', 'sys:feedback:delete')
|
||||||
|
WHERE m.route_name = 'SysFeedbackHandle';
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
-- 反馈附图:文件可被多条反馈引用(sys_file 按哈希去重时同图同 id)
|
||||||
|
-- 唯一约束改为「同一反馈/留言内不重复」
|
||||||
|
-- MySQL:uk 被 FK 占用时,需先删 FK → 改索引 → 重建 FK
|
||||||
|
|
||||||
|
ALTER TABLE `sys_feedback_images`
|
||||||
|
DROP FOREIGN KEY `fk_sys_feedback_images_file`;
|
||||||
|
|
||||||
|
ALTER TABLE `sys_feedback_images`
|
||||||
|
DROP INDEX `uk_sys_feedback_images_file`,
|
||||||
|
ADD UNIQUE INDEX `uk_sys_feedback_images_fb_file` (`feedback_id` ASC, `file_id` ASC) USING BTREE,
|
||||||
|
ADD INDEX `idx_sys_feedback_images_file` (`file_id` ASC) USING BTREE;
|
||||||
|
|
||||||
|
ALTER TABLE `sys_feedback_images`
|
||||||
|
ADD CONSTRAINT `fk_sys_feedback_images_file`
|
||||||
|
FOREIGN KEY (`file_id`) REFERENCES `sys_file` (`id`)
|
||||||
|
ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
ALTER TABLE `sys_feedback_message_images`
|
||||||
|
DROP FOREIGN KEY `fk_sys_feedback_message_images_file`;
|
||||||
|
|
||||||
|
ALTER TABLE `sys_feedback_message_images`
|
||||||
|
DROP INDEX `uk_sys_feedback_message_images_file`,
|
||||||
|
ADD UNIQUE INDEX `uk_sys_feedback_message_images_msg_file` (`message_id` ASC, `file_id` ASC) USING BTREE,
|
||||||
|
ADD INDEX `idx_sys_feedback_message_images_file` (`file_id` ASC) USING BTREE;
|
||||||
|
|
||||||
|
ALTER TABLE `sys_feedback_message_images`
|
||||||
|
ADD CONSTRAINT `fk_sys_feedback_message_images_file`
|
||||||
|
FOREIGN KEY (`file_id`) REFERENCES `sys_file` (`id`)
|
||||||
|
ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
+80
@@ -0,0 +1,80 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.controller;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.annotation.RequirePermission;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.dto.CreateFeedbackMessageDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.dto.FeedbackFilterDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.dto.UpdateFeedbackAssigneeDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.dto.UpdateFeedbackStatusDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo.FeedbackDetailVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo.FeedbackMessageVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo.FeedbackVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.service.FeedbackService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 意见反馈-处理侧接口(超管全量 / 公司用户本公司)。
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/sys/feedback/handle")
|
||||||
|
public class FeedbackHandleController {
|
||||||
|
|
||||||
|
private final FeedbackService feedbackService;
|
||||||
|
|
||||||
|
public FeedbackHandleController(FeedbackService feedbackService) {
|
||||||
|
this.feedbackService = feedbackService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/list")
|
||||||
|
@RequirePermission(value = "sys:feedback:handle", description = "处理侧反馈列表", allowSuper = true)
|
||||||
|
public ApiResponse<PageResultVO<FeedbackVO>> list(
|
||||||
|
@Valid @RequestBody PageQueryDTO<FeedbackFilterDTO> query) {
|
||||||
|
return ApiResponse.success("获取反馈列表成功", feedbackService.listForHandle(query));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
@RequirePermission(value = "sys:feedback:handle", description = "处理侧反馈详情", allowSuper = true)
|
||||||
|
public ApiResponse<FeedbackDetailVO> detail(@PathVariable Long id) {
|
||||||
|
return ApiResponse.success("获取反馈详情成功", feedbackService.getDetailForHandle(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}/status")
|
||||||
|
@RequirePermission(value = "sys:feedback:handle", description = "更新反馈状态", allowSuper = true)
|
||||||
|
public ApiResponse<Void> updateStatus(
|
||||||
|
@PathVariable Long id, @Valid @RequestBody UpdateFeedbackStatusDTO dto) {
|
||||||
|
feedbackService.updateStatus(id, dto);
|
||||||
|
return ApiResponse.success("状态更新成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}/assignee")
|
||||||
|
@RequirePermission(value = "sys:feedback:handle", description = "指派处理人", allowSuper = true)
|
||||||
|
public ApiResponse<Void> updateAssignee(
|
||||||
|
@PathVariable Long id, @Valid @RequestBody UpdateFeedbackAssigneeDTO dto) {
|
||||||
|
feedbackService.updateAssignee(id, dto);
|
||||||
|
return ApiResponse.success("指派成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/{id}/messages")
|
||||||
|
@RequirePermission(value = "sys:feedback:handle", description = "处理人回复", allowSuper = true)
|
||||||
|
public ApiResponse<FeedbackMessageVO> addMessage(
|
||||||
|
@PathVariable Long id, @Valid @RequestBody CreateFeedbackMessageDTO dto) {
|
||||||
|
return ApiResponse.success("回复成功", feedbackService.addHandlerMessage(id, dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
@RequirePermission(value = "sys:feedback:delete", description = "删除反馈", allowSuper = true)
|
||||||
|
public ApiResponse<Void> delete(@PathVariable Long id) {
|
||||||
|
feedbackService.delete(id);
|
||||||
|
return ApiResponse.success("删除成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/{id}/read")
|
||||||
|
@RequirePermission(value = "sys:feedback:handle", description = "标记处理方已读", allowSuper = true)
|
||||||
|
public ApiResponse<Void> markRead(@PathVariable Long id) {
|
||||||
|
feedbackService.markHandlerRead(id);
|
||||||
|
return ApiResponse.success("已读成功");
|
||||||
|
}
|
||||||
|
}
|
||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.controller;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.annotation.RequirePermission;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.dto.CreateFeedbackDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.dto.CreateFeedbackMessageDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.dto.FeedbackFilterDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo.FeedbackDetailVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo.FeedbackMessageVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo.FeedbackVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.service.FeedbackService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 意见反馈-用户侧接口(本公司可见)。
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/sys/feedback")
|
||||||
|
public class FeedbackUserController {
|
||||||
|
|
||||||
|
private final FeedbackService feedbackService;
|
||||||
|
|
||||||
|
public FeedbackUserController(FeedbackService feedbackService) {
|
||||||
|
this.feedbackService = feedbackService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/list")
|
||||||
|
@RequirePermission(value = "sys:feedback:read", description = "查看意见反馈", allowSuper = true)
|
||||||
|
public ApiResponse<PageResultVO<FeedbackVO>> list(
|
||||||
|
@Valid @RequestBody PageQueryDTO<FeedbackFilterDTO> query) {
|
||||||
|
return ApiResponse.success("获取反馈列表成功", feedbackService.listForUser(query));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
@RequirePermission(value = "sys:feedback:read", description = "查看意见反馈详情", allowSuper = true)
|
||||||
|
public ApiResponse<FeedbackDetailVO> detail(@PathVariable Long id) {
|
||||||
|
return ApiResponse.success("获取反馈详情成功", feedbackService.getDetailForUser(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@RequirePermission(value = "sys:feedback:create", description = "提交意见反馈", allowSuper = true)
|
||||||
|
public ApiResponse<FeedbackDetailVO> create(@Valid @RequestBody CreateFeedbackDTO dto) {
|
||||||
|
return ApiResponse.success("提交反馈成功", feedbackService.create(dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/{id}/messages")
|
||||||
|
@RequirePermission(value = "sys:feedback:read", description = "反馈留言/回复", allowSuper = true)
|
||||||
|
public ApiResponse<FeedbackMessageVO> addMessage(
|
||||||
|
@PathVariable Long id, @Valid @RequestBody CreateFeedbackMessageDTO dto) {
|
||||||
|
return ApiResponse.success("留言成功", feedbackService.addUserMessage(id, dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/{id}/close")
|
||||||
|
@RequirePermission(value = "sys:feedback:create", description = "关闭自己的反馈", allowSuper = true)
|
||||||
|
public ApiResponse<Void> close(@PathVariable Long id) {
|
||||||
|
feedbackService.closeByUser(id);
|
||||||
|
return ApiResponse.success("关闭成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/{id}/read")
|
||||||
|
@RequirePermission(value = "sys:feedback:read", description = "标记提交人已读", allowSuper = true)
|
||||||
|
public ApiResponse<Void> markRead(@PathVariable Long id) {
|
||||||
|
feedbackService.markSubmitterRead(id);
|
||||||
|
return ApiResponse.success("已读成功");
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.po.FeedbackImagePO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反馈正文图片 Mapper。
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface FeedbackImageMapper extends BaseMapper<FeedbackImagePO> {
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.po.FeedbackPO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 意见反馈主表 Mapper。
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface FeedbackMapper extends BaseMapper<FeedbackPO> {
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.po.FeedbackMessageImagePO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 留言图片 Mapper。
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface FeedbackMessageImageMapper extends BaseMapper<FeedbackMessageImagePO> {
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.po.FeedbackMessagePO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反馈留言 Mapper。
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface FeedbackMessageMapper extends BaseMapper<FeedbackMessagePO> {
|
||||||
|
}
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.model.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交意见反馈。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CreateFeedbackDTO {
|
||||||
|
|
||||||
|
@NotBlank(message = "标题不能为空")
|
||||||
|
@Size(max = 200, message = "标题最长200字")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@NotBlank(message = "正文不能为空")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/** BUG/FEATURE/QUESTION/COMPLAINT/OTHER,默认 OTHER */
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/** 1高 2中 3低,默认 2 */
|
||||||
|
private Integer priority;
|
||||||
|
|
||||||
|
@Size(max = 100, message = "联系方式最长100字")
|
||||||
|
private String contact;
|
||||||
|
|
||||||
|
private Long menuId;
|
||||||
|
|
||||||
|
@Size(max = 500, message = "页面路径最长500字")
|
||||||
|
private String pageUrl;
|
||||||
|
|
||||||
|
@Size(max = 500, message = "客户端信息最长500字")
|
||||||
|
private String clientInfo;
|
||||||
|
|
||||||
|
/** 正文附图 fileId 列表 */
|
||||||
|
private List<Long> fileIds;
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.model.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增反馈留言/回复。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CreateFeedbackMessageDTO {
|
||||||
|
|
||||||
|
@NotBlank(message = "留言内容不能为空")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/** 父留言ID;空则为顶层留言 */
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
/** 附图 fileId 列表 */
|
||||||
|
private List<Long> fileIds;
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.model.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反馈列表筛选条件。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FeedbackFilterDTO {
|
||||||
|
|
||||||
|
/** 超管处理侧可按公司过滤 */
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private Integer priority;
|
||||||
|
|
||||||
|
private Long createBy;
|
||||||
|
|
||||||
|
private Long assigneeId;
|
||||||
|
|
||||||
|
private Long menuId;
|
||||||
|
|
||||||
|
/** 标题模糊 */
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/** 处理方未读:0/1 */
|
||||||
|
private Integer handlerUnread;
|
||||||
|
|
||||||
|
/** 提交人未读:0/1 */
|
||||||
|
private Integer submitterUnread;
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.model.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理侧指派处理人。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UpdateFeedbackAssigneeDTO {
|
||||||
|
|
||||||
|
@NotNull(message = "处理人不能为空")
|
||||||
|
private Long assigneeId;
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.model.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理侧更新反馈状态。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UpdateFeedbackStatusDTO {
|
||||||
|
|
||||||
|
/** PROCESSING / RESOLVED / CLOSED / REJECTED(及 OPEN) */
|
||||||
|
@NotBlank(message = "状态不能为空")
|
||||||
|
private String status;
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.model.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反馈正文图片关联(sys_file.id)。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("sys_feedback_images")
|
||||||
|
public class FeedbackImagePO {
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@TableField("feedback_id")
|
||||||
|
private Long feedbackId;
|
||||||
|
|
||||||
|
@TableField("file_id")
|
||||||
|
private Long fileId;
|
||||||
|
|
||||||
|
@TableField("sort_order")
|
||||||
|
private Integer sortOrder;
|
||||||
|
|
||||||
|
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@TableField("create_by")
|
||||||
|
private Long createBy;
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.model.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 留言图片关联(sys_file.id)。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("sys_feedback_message_images")
|
||||||
|
public class FeedbackMessageImagePO {
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@TableField("message_id")
|
||||||
|
private Long messageId;
|
||||||
|
|
||||||
|
@TableField("feedback_id")
|
||||||
|
private Long feedbackId;
|
||||||
|
|
||||||
|
@TableField("file_id")
|
||||||
|
private Long fileId;
|
||||||
|
|
||||||
|
@TableField("sort_order")
|
||||||
|
private Integer sortOrder;
|
||||||
|
|
||||||
|
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@TableField("create_by")
|
||||||
|
private Long createBy;
|
||||||
|
}
|
||||||
+59
@@ -0,0 +1,59 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.model.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反馈留言/回复;parent_id + root_id 组成树。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("sys_feedback_message")
|
||||||
|
public class FeedbackMessagePO {
|
||||||
|
|
||||||
|
public static final String AUTHOR_ROLE_USER = "USER";
|
||||||
|
public static final String AUTHOR_ROLE_HANDLER = "HANDLER";
|
||||||
|
public static final String AUTHOR_ROLE_SYSTEM = "SYSTEM";
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@TableField("feedback_id")
|
||||||
|
private Long feedbackId;
|
||||||
|
|
||||||
|
@TableField("company_id")
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
/** NULL=顶层留言 */
|
||||||
|
@TableField("parent_id")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
/** 顶层留言ID;顶层时等于自身 id */
|
||||||
|
@TableField("root_id")
|
||||||
|
private Long rootId;
|
||||||
|
|
||||||
|
@TableField("content")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/** USER / HANDLER / SYSTEM */
|
||||||
|
@TableField("author_role")
|
||||||
|
private String authorRole;
|
||||||
|
|
||||||
|
@TableField("image_count")
|
||||||
|
private Integer imageCount;
|
||||||
|
|
||||||
|
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
@TableField("create_by")
|
||||||
|
private Long createBy;
|
||||||
|
|
||||||
|
@TableField("update_by")
|
||||||
|
private Long updateBy;
|
||||||
|
}
|
||||||
+101
@@ -0,0 +1,101 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.model.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 意见反馈主表实体。
|
||||||
|
* 公司隔离;未读与计数字段由业务维护。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("sys_feedback")
|
||||||
|
public class FeedbackPO {
|
||||||
|
|
||||||
|
public static final String STATUS_OPEN = "OPEN";
|
||||||
|
public static final String STATUS_PROCESSING = "PROCESSING";
|
||||||
|
public static final String STATUS_RESOLVED = "RESOLVED";
|
||||||
|
public static final String STATUS_CLOSED = "CLOSED";
|
||||||
|
public static final String STATUS_REJECTED = "REJECTED";
|
||||||
|
|
||||||
|
public static final String TYPE_BUG = "BUG";
|
||||||
|
public static final String TYPE_FEATURE = "FEATURE";
|
||||||
|
public static final String TYPE_QUESTION = "QUESTION";
|
||||||
|
public static final String TYPE_COMPLAINT = "COMPLAINT";
|
||||||
|
public static final String TYPE_OTHER = "OTHER";
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@TableField("company_id")
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
@TableField("title")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@TableField("content")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/** BUG/FEATURE/QUESTION/COMPLAINT/OTHER */
|
||||||
|
@TableField("type")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/** OPEN/PROCESSING/RESOLVED/CLOSED/REJECTED */
|
||||||
|
@TableField("status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/** 1高 2中 3低 */
|
||||||
|
@TableField("priority")
|
||||||
|
private Integer priority;
|
||||||
|
|
||||||
|
@TableField("contact")
|
||||||
|
private String contact;
|
||||||
|
|
||||||
|
@TableField("menu_id")
|
||||||
|
private Long menuId;
|
||||||
|
|
||||||
|
@TableField("page_url")
|
||||||
|
private String pageUrl;
|
||||||
|
|
||||||
|
@TableField("client_info")
|
||||||
|
private String clientInfo;
|
||||||
|
|
||||||
|
@TableField("assignee_id")
|
||||||
|
private Long assigneeId;
|
||||||
|
|
||||||
|
@TableField("image_count")
|
||||||
|
private Integer imageCount;
|
||||||
|
|
||||||
|
@TableField("message_count")
|
||||||
|
private Integer messageCount;
|
||||||
|
|
||||||
|
@TableField("last_message_at")
|
||||||
|
private LocalDateTime lastMessageAt;
|
||||||
|
|
||||||
|
@TableField("submitter_unread")
|
||||||
|
private Integer submitterUnread;
|
||||||
|
|
||||||
|
@TableField("handler_unread")
|
||||||
|
private Integer handlerUnread;
|
||||||
|
|
||||||
|
@TableField("resolved_at")
|
||||||
|
private LocalDateTime resolvedAt;
|
||||||
|
|
||||||
|
@TableField("closed_at")
|
||||||
|
private LocalDateTime closedAt;
|
||||||
|
|
||||||
|
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
@TableField("create_by")
|
||||||
|
private Long createBy;
|
||||||
|
|
||||||
|
@TableField("update_by")
|
||||||
|
private Long updateBy;
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 意见反馈详情(含留言树)。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class FeedbackDetailVO extends FeedbackVO {
|
||||||
|
|
||||||
|
/** 留言树(顶层节点含 children) */
|
||||||
|
private List<FeedbackMessageVO> messages;
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反馈附图(含访问地址,详情接口直接下发)。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FeedbackFileVO {
|
||||||
|
private Long fileId;
|
||||||
|
private String accessUrl;
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反馈留言/回复节点。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FeedbackMessageVO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private Long feedbackId;
|
||||||
|
private Long companyId;
|
||||||
|
private Long parentId;
|
||||||
|
private Long rootId;
|
||||||
|
private String content;
|
||||||
|
private String authorRole;
|
||||||
|
private Integer imageCount;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private Long createBy;
|
||||||
|
private String creatorName;
|
||||||
|
private List<Long> fileIds;
|
||||||
|
/** 附图含访问地址 */
|
||||||
|
private List<FeedbackFileVO> images;
|
||||||
|
private List<FeedbackMessageVO> children;
|
||||||
|
}
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 意见反馈列表项。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FeedbackVO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private Long companyId;
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private String type;
|
||||||
|
private String status;
|
||||||
|
private Integer priority;
|
||||||
|
private String contact;
|
||||||
|
private Long menuId;
|
||||||
|
private String menuTitle;
|
||||||
|
private String pageUrl;
|
||||||
|
private String clientInfo;
|
||||||
|
private Long assigneeId;
|
||||||
|
private String assigneeName;
|
||||||
|
private Integer imageCount;
|
||||||
|
private Integer messageCount;
|
||||||
|
private LocalDateTime lastMessageAt;
|
||||||
|
private Integer submitterUnread;
|
||||||
|
private Integer handlerUnread;
|
||||||
|
private LocalDateTime resolvedAt;
|
||||||
|
private LocalDateTime closedAt;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
private Long createBy;
|
||||||
|
private String creatorName;
|
||||||
|
/** 附图 fileId(兼容) */
|
||||||
|
private List<Long> fileIds;
|
||||||
|
/** 附图含访问地址(详情优先用) */
|
||||||
|
private List<FeedbackFileVO> images;
|
||||||
|
}
|
||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.service;
|
||||||
|
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.dto.*;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo.FeedbackDetailVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo.FeedbackMessageVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo.FeedbackVO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 意见反馈用例:用户侧提交/留言与处理侧指派/状态/回复。
|
||||||
|
*/
|
||||||
|
public interface FeedbackService {
|
||||||
|
|
||||||
|
PageResultVO<FeedbackVO> listForUser(PageQueryDTO<FeedbackFilterDTO> query);
|
||||||
|
|
||||||
|
FeedbackDetailVO getDetailForUser(Long id);
|
||||||
|
|
||||||
|
FeedbackDetailVO create(CreateFeedbackDTO dto);
|
||||||
|
|
||||||
|
FeedbackMessageVO addUserMessage(Long feedbackId, CreateFeedbackMessageDTO dto);
|
||||||
|
|
||||||
|
void closeByUser(Long id);
|
||||||
|
|
||||||
|
void markSubmitterRead(Long id);
|
||||||
|
|
||||||
|
PageResultVO<FeedbackVO> listForHandle(PageQueryDTO<FeedbackFilterDTO> query);
|
||||||
|
|
||||||
|
FeedbackDetailVO getDetailForHandle(Long id);
|
||||||
|
|
||||||
|
void updateStatus(Long id, UpdateFeedbackStatusDTO dto);
|
||||||
|
|
||||||
|
void updateAssignee(Long id, UpdateFeedbackAssigneeDTO dto);
|
||||||
|
|
||||||
|
FeedbackMessageVO addHandlerMessage(Long feedbackId, CreateFeedbackMessageDTO dto);
|
||||||
|
|
||||||
|
void delete(Long id);
|
||||||
|
|
||||||
|
void markHandlerRead(Long id);
|
||||||
|
}
|
||||||
+672
@@ -0,0 +1,672 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.sys.feedback.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.mapper.FeedbackImageMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.mapper.FeedbackMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.mapper.FeedbackMessageImageMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.mapper.FeedbackMessageMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.dto.*;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.po.FeedbackImagePO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.po.FeedbackMessageImagePO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.po.FeedbackMessagePO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.po.FeedbackPO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo.FeedbackDetailVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo.FeedbackFileVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo.FeedbackMessageVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.model.vo.FeedbackVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.feedback.service.FeedbackService;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.file.mapper.SysFileMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.file.model.po.SysFilePO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.menu.mapper.MenuMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.menu.model.po.MenuPO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.user.mapper.UserMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.sys.user.model.po.UserPO;
|
||||||
|
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||||
|
import top.xyquan.ecomdmbbackend.utils.SysFileUtils;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 意见反馈业务实现:公司隔离、未读与留言树维护。
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class FeedbackServiceImpl implements FeedbackService {
|
||||||
|
|
||||||
|
private static final Set<String> ALLOWED_TYPES = Set.of(
|
||||||
|
FeedbackPO.TYPE_BUG, FeedbackPO.TYPE_FEATURE, FeedbackPO.TYPE_QUESTION,
|
||||||
|
FeedbackPO.TYPE_COMPLAINT, FeedbackPO.TYPE_OTHER);
|
||||||
|
|
||||||
|
private static final Set<String> HANDLE_STATUSES = Set.of(
|
||||||
|
FeedbackPO.STATUS_OPEN, FeedbackPO.STATUS_PROCESSING, FeedbackPO.STATUS_RESOLVED,
|
||||||
|
FeedbackPO.STATUS_CLOSED, FeedbackPO.STATUS_REJECTED);
|
||||||
|
|
||||||
|
private final FeedbackMapper feedbackMapper;
|
||||||
|
private final FeedbackImageMapper feedbackImageMapper;
|
||||||
|
private final FeedbackMessageMapper feedbackMessageMapper;
|
||||||
|
private final FeedbackMessageImageMapper feedbackMessageImageMapper;
|
||||||
|
private final MenuMapper menuMapper;
|
||||||
|
private final UserMapper userMapper;
|
||||||
|
private final SysFileMapper sysFileMapper;
|
||||||
|
private final CurrentUserContext currentUserContext;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResultVO<FeedbackVO> listForUser(PageQueryDTO<FeedbackFilterDTO> query) {
|
||||||
|
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||||
|
return pageFeedback(query, companyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeedbackDetailVO getDetailForUser(Long id) {
|
||||||
|
FeedbackPO po = requireVisibleForUser(id);
|
||||||
|
return toDetailVO(po);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public FeedbackDetailVO create(CreateFeedbackDTO dto) {
|
||||||
|
Long userId = currentUserContext.getCurrentUserId();
|
||||||
|
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||||
|
validateMenuId(dto.getMenuId());
|
||||||
|
|
||||||
|
FeedbackPO po = new FeedbackPO();
|
||||||
|
po.setCompanyId(companyId);
|
||||||
|
po.setTitle(dto.getTitle().trim());
|
||||||
|
po.setContent(dto.getContent());
|
||||||
|
po.setType(normalizeType(dto.getType()));
|
||||||
|
po.setStatus(FeedbackPO.STATUS_OPEN);
|
||||||
|
po.setPriority(dto.getPriority() != null ? dto.getPriority() : 2);
|
||||||
|
po.setContact(dto.getContact());
|
||||||
|
po.setMenuId(dto.getMenuId());
|
||||||
|
po.setPageUrl(dto.getPageUrl());
|
||||||
|
po.setClientInfo(dto.getClientInfo());
|
||||||
|
po.setImageCount(0);
|
||||||
|
po.setMessageCount(0);
|
||||||
|
po.setSubmitterUnread(0);
|
||||||
|
po.setHandlerUnread(1);
|
||||||
|
po.setCreateBy(userId);
|
||||||
|
po.setUpdateBy(userId);
|
||||||
|
feedbackMapper.insert(po);
|
||||||
|
|
||||||
|
int imageCount = saveFeedbackImages(po.getId(), dto.getFileIds(), userId);
|
||||||
|
if (imageCount > 0) {
|
||||||
|
po.setImageCount(imageCount);
|
||||||
|
feedbackMapper.updateById(po);
|
||||||
|
}
|
||||||
|
return toDetailVO(feedbackMapper.selectById(po.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public FeedbackMessageVO addUserMessage(Long feedbackId, CreateFeedbackMessageDTO dto) {
|
||||||
|
FeedbackPO feedback = requireVisibleForUser(feedbackId);
|
||||||
|
FeedbackMessagePO message = insertMessage(
|
||||||
|
feedback, dto, FeedbackMessagePO.AUTHOR_ROLE_USER, currentUserContext.getCurrentUserId());
|
||||||
|
|
||||||
|
// 用户留言:处理方未读;已解决后不重开状态
|
||||||
|
int nextCount = (feedback.getMessageCount() != null ? feedback.getMessageCount() : 0) + 1;
|
||||||
|
LambdaUpdateWrapper<FeedbackPO> uw = new LambdaUpdateWrapper<>();
|
||||||
|
uw.eq(FeedbackPO::getId, feedbackId)
|
||||||
|
.set(FeedbackPO::getHandlerUnread, 1)
|
||||||
|
.set(FeedbackPO::getMessageCount, nextCount)
|
||||||
|
.set(FeedbackPO::getLastMessageAt, message.getCreateTime() != null
|
||||||
|
? message.getCreateTime() : LocalDateTime.now())
|
||||||
|
.set(FeedbackPO::getUpdateBy, currentUserContext.getCurrentUserId());
|
||||||
|
feedbackMapper.update(null, uw);
|
||||||
|
return toMessageVO(message, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void closeByUser(Long id) {
|
||||||
|
FeedbackPO po = requireVisibleForUser(id);
|
||||||
|
Long userId = currentUserContext.getCurrentUserId();
|
||||||
|
if (!Objects.equals(po.getCreateBy(), userId)) {
|
||||||
|
throw new BusinessException("仅提交人可关闭自己的反馈");
|
||||||
|
}
|
||||||
|
if (!FeedbackPO.STATUS_OPEN.equals(po.getStatus())) {
|
||||||
|
throw new BusinessException("仅未开始处理的反馈可关闭");
|
||||||
|
}
|
||||||
|
LambdaUpdateWrapper<FeedbackPO> uw = new LambdaUpdateWrapper<>();
|
||||||
|
uw.eq(FeedbackPO::getId, id)
|
||||||
|
.set(FeedbackPO::getStatus, FeedbackPO.STATUS_CLOSED)
|
||||||
|
.set(FeedbackPO::getClosedAt, LocalDateTime.now())
|
||||||
|
.set(FeedbackPO::getUpdateBy, userId);
|
||||||
|
feedbackMapper.update(null, uw);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void markSubmitterRead(Long id) {
|
||||||
|
FeedbackPO po = requireVisibleForUser(id);
|
||||||
|
if (!Objects.equals(po.getCreateBy(), currentUserContext.getCurrentUserId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LambdaUpdateWrapper<FeedbackPO> uw = new LambdaUpdateWrapper<>();
|
||||||
|
uw.eq(FeedbackPO::getId, id).set(FeedbackPO::getSubmitterUnread, 0);
|
||||||
|
feedbackMapper.update(null, uw);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResultVO<FeedbackVO> listForHandle(PageQueryDTO<FeedbackFilterDTO> query) {
|
||||||
|
Long companyScope = resolveHandleCompanyScope(query != null ? query.getFilters() : null);
|
||||||
|
return pageFeedback(query, companyScope);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeedbackDetailVO getDetailForHandle(Long id) {
|
||||||
|
FeedbackPO po = requireVisibleForHandle(id);
|
||||||
|
return toDetailVO(po);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateStatus(Long id, UpdateFeedbackStatusDTO dto) {
|
||||||
|
FeedbackPO po = requireVisibleForHandle(id);
|
||||||
|
String status = dto.getStatus().trim().toUpperCase(Locale.ROOT);
|
||||||
|
if (!HANDLE_STATUSES.contains(status)) {
|
||||||
|
throw new BusinessException("无效的反馈状态");
|
||||||
|
}
|
||||||
|
Long userId = currentUserContext.getCurrentUserId();
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
LambdaUpdateWrapper<FeedbackPO> uw = new LambdaUpdateWrapper<>();
|
||||||
|
uw.eq(FeedbackPO::getId, id)
|
||||||
|
.set(FeedbackPO::getStatus, status)
|
||||||
|
.set(FeedbackPO::getUpdateBy, userId);
|
||||||
|
if (FeedbackPO.STATUS_RESOLVED.equals(status) && po.getResolvedAt() == null) {
|
||||||
|
uw.set(FeedbackPO::getResolvedAt, now);
|
||||||
|
}
|
||||||
|
if (FeedbackPO.STATUS_CLOSED.equals(status) || FeedbackPO.STATUS_REJECTED.equals(status)) {
|
||||||
|
uw.set(FeedbackPO::getClosedAt, now);
|
||||||
|
}
|
||||||
|
feedbackMapper.update(null, uw);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateAssignee(Long id, UpdateFeedbackAssigneeDTO dto) {
|
||||||
|
requireVisibleForHandle(id);
|
||||||
|
UserPO assignee = userMapper.selectById(dto.getAssigneeId());
|
||||||
|
if (assignee == null) {
|
||||||
|
throw new BusinessException("处理人不存在");
|
||||||
|
}
|
||||||
|
LambdaUpdateWrapper<FeedbackPO> uw = new LambdaUpdateWrapper<>();
|
||||||
|
uw.eq(FeedbackPO::getId, id)
|
||||||
|
.set(FeedbackPO::getAssigneeId, dto.getAssigneeId())
|
||||||
|
.set(FeedbackPO::getUpdateBy, currentUserContext.getCurrentUserId());
|
||||||
|
feedbackMapper.update(null, uw);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public FeedbackMessageVO addHandlerMessage(Long feedbackId, CreateFeedbackMessageDTO dto) {
|
||||||
|
FeedbackPO feedback = requireVisibleForHandle(feedbackId);
|
||||||
|
Long userId = currentUserContext.getCurrentUserId();
|
||||||
|
if (feedback.getAssigneeId() == null || !Objects.equals(feedback.getAssigneeId(), userId)) {
|
||||||
|
throw new BusinessException("仅当前处理人可回复");
|
||||||
|
}
|
||||||
|
FeedbackMessagePO message = insertMessage(
|
||||||
|
feedback, dto, FeedbackMessagePO.AUTHOR_ROLE_HANDLER, userId);
|
||||||
|
|
||||||
|
int nextCount = (feedback.getMessageCount() != null ? feedback.getMessageCount() : 0) + 1;
|
||||||
|
LambdaUpdateWrapper<FeedbackPO> uw = new LambdaUpdateWrapper<>();
|
||||||
|
uw.eq(FeedbackPO::getId, feedbackId)
|
||||||
|
.set(FeedbackPO::getSubmitterUnread, 1)
|
||||||
|
.set(FeedbackPO::getMessageCount, nextCount)
|
||||||
|
.set(FeedbackPO::getLastMessageAt, message.getCreateTime() != null
|
||||||
|
? message.getCreateTime() : LocalDateTime.now())
|
||||||
|
.set(FeedbackPO::getUpdateBy, userId);
|
||||||
|
feedbackMapper.update(null, uw);
|
||||||
|
return toMessageVO(message, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void delete(Long id) {
|
||||||
|
requireVisibleForHandle(id);
|
||||||
|
// 关联图与留言由 FK CASCADE 清理
|
||||||
|
feedbackMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void markHandlerRead(Long id) {
|
||||||
|
requireVisibleForHandle(id);
|
||||||
|
LambdaUpdateWrapper<FeedbackPO> uw = new LambdaUpdateWrapper<>();
|
||||||
|
uw.eq(FeedbackPO::getId, id).set(FeedbackPO::getHandlerUnread, 0);
|
||||||
|
feedbackMapper.update(null, uw);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- 可见性 ----------
|
||||||
|
|
||||||
|
private FeedbackPO requireVisibleForUser(Long id) {
|
||||||
|
FeedbackPO po = feedbackMapper.selectById(id);
|
||||||
|
if (po == null) {
|
||||||
|
throw new BusinessException("反馈不存在");
|
||||||
|
}
|
||||||
|
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||||
|
if (!Objects.equals(po.getCompanyId(), companyId)) {
|
||||||
|
throw new BusinessException("无权查看该反馈");
|
||||||
|
}
|
||||||
|
return po;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FeedbackPO requireVisibleForHandle(Long id) {
|
||||||
|
FeedbackPO po = feedbackMapper.selectById(id);
|
||||||
|
if (po == null) {
|
||||||
|
throw new BusinessException("反馈不存在");
|
||||||
|
}
|
||||||
|
if (currentUserContext.isCurrentUserSuper()) {
|
||||||
|
return po;
|
||||||
|
}
|
||||||
|
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||||
|
if (!Objects.equals(po.getCompanyId(), companyId)) {
|
||||||
|
throw new BusinessException("无权查看该反馈");
|
||||||
|
}
|
||||||
|
return po;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理侧公司范围:超管可看全部(filters.companyId 可选);公司用户仅本公司。
|
||||||
|
*/
|
||||||
|
private Long resolveHandleCompanyScope(FeedbackFilterDTO filters) {
|
||||||
|
if (currentUserContext.isCurrentUserSuper()) {
|
||||||
|
return filters != null ? filters.getCompanyId() : null;
|
||||||
|
}
|
||||||
|
return currentUserContext.getCurrentCompanyId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- 查询 ----------
|
||||||
|
|
||||||
|
private PageResultVO<FeedbackVO> pageFeedback(
|
||||||
|
PageQueryDTO<FeedbackFilterDTO> query, Long companyScope) {
|
||||||
|
int pageNum = query.getPage() != null ? query.getPage() : 1;
|
||||||
|
int pageSize = query.getPageSize() != null ? query.getPageSize() : 10;
|
||||||
|
Page<FeedbackPO> page = new Page<>(pageNum, pageSize);
|
||||||
|
LambdaQueryWrapper<FeedbackPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (companyScope != null) {
|
||||||
|
wrapper.eq(FeedbackPO::getCompanyId, companyScope);
|
||||||
|
}
|
||||||
|
FeedbackFilterDTO filter = query.getFilters();
|
||||||
|
if (filter != null) {
|
||||||
|
if (StringUtils.hasText(filter.getStatus())) {
|
||||||
|
wrapper.eq(FeedbackPO::getStatus, filter.getStatus().trim());
|
||||||
|
}
|
||||||
|
if (StringUtils.hasText(filter.getType())) {
|
||||||
|
wrapper.eq(FeedbackPO::getType, filter.getType().trim());
|
||||||
|
}
|
||||||
|
if (filter.getPriority() != null) {
|
||||||
|
wrapper.eq(FeedbackPO::getPriority, filter.getPriority());
|
||||||
|
}
|
||||||
|
if (filter.getCreateBy() != null) {
|
||||||
|
wrapper.eq(FeedbackPO::getCreateBy, filter.getCreateBy());
|
||||||
|
}
|
||||||
|
if (filter.getAssigneeId() != null) {
|
||||||
|
wrapper.eq(FeedbackPO::getAssigneeId, filter.getAssigneeId());
|
||||||
|
}
|
||||||
|
if (filter.getMenuId() != null) {
|
||||||
|
wrapper.eq(FeedbackPO::getMenuId, filter.getMenuId());
|
||||||
|
}
|
||||||
|
if (StringUtils.hasText(filter.getTitle())) {
|
||||||
|
wrapper.like(FeedbackPO::getTitle, filter.getTitle().trim());
|
||||||
|
}
|
||||||
|
if (filter.getHandlerUnread() != null) {
|
||||||
|
wrapper.eq(FeedbackPO::getHandlerUnread, filter.getHandlerUnread());
|
||||||
|
}
|
||||||
|
if (filter.getSubmitterUnread() != null) {
|
||||||
|
wrapper.eq(FeedbackPO::getSubmitterUnread, filter.getSubmitterUnread());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.orderByDesc(FeedbackPO::getUpdateTime).orderByDesc(FeedbackPO::getId);
|
||||||
|
IPage<FeedbackPO> result = feedbackMapper.selectPage(page, wrapper);
|
||||||
|
List<FeedbackVO> vos = result.getRecords().stream()
|
||||||
|
.map(po -> toListVO(po, false))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
fillNames(vos);
|
||||||
|
return PageResultVO.create(vos, result.getTotal(), (int) result.getCurrent(), (int) result.getSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- 留言 ----------
|
||||||
|
|
||||||
|
private FeedbackMessagePO insertMessage(
|
||||||
|
FeedbackPO feedback, CreateFeedbackMessageDTO dto, String authorRole, Long userId) {
|
||||||
|
Long parentId = dto.getParentId();
|
||||||
|
Long rootId = null;
|
||||||
|
if (parentId != null) {
|
||||||
|
FeedbackMessagePO parent = feedbackMessageMapper.selectById(parentId);
|
||||||
|
if (parent == null || !Objects.equals(parent.getFeedbackId(), feedback.getId())) {
|
||||||
|
throw new BusinessException("父留言不存在或不属于该反馈");
|
||||||
|
}
|
||||||
|
rootId = parent.getRootId() != null ? parent.getRootId() : parent.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
FeedbackMessagePO message = new FeedbackMessagePO();
|
||||||
|
message.setFeedbackId(feedback.getId());
|
||||||
|
message.setCompanyId(feedback.getCompanyId());
|
||||||
|
message.setParentId(parentId);
|
||||||
|
message.setRootId(rootId);
|
||||||
|
message.setContent(dto.getContent());
|
||||||
|
message.setAuthorRole(authorRole);
|
||||||
|
message.setImageCount(0);
|
||||||
|
message.setCreateBy(userId);
|
||||||
|
message.setUpdateBy(userId);
|
||||||
|
feedbackMessageMapper.insert(message);
|
||||||
|
|
||||||
|
// 顶层留言:插入后回写 root_id = id
|
||||||
|
if (parentId == null) {
|
||||||
|
message.setRootId(message.getId());
|
||||||
|
feedbackMessageMapper.updateById(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
int imageCount = saveMessageImages(message.getId(), feedback.getId(), dto.getFileIds(), userId);
|
||||||
|
if (imageCount > 0) {
|
||||||
|
message.setImageCount(imageCount);
|
||||||
|
feedbackMessageMapper.updateById(message);
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- 图片 ----------
|
||||||
|
|
||||||
|
private int saveFeedbackImages(Long feedbackId, List<Long> fileIds, Long userId) {
|
||||||
|
List<Long> distinct = distinctFileIds(fileIds);
|
||||||
|
if (distinct.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int order = 0;
|
||||||
|
for (Long fileId : distinct) {
|
||||||
|
FeedbackImagePO image = new FeedbackImagePO();
|
||||||
|
image.setFeedbackId(feedbackId);
|
||||||
|
image.setFileId(fileId);
|
||||||
|
image.setSortOrder(order++);
|
||||||
|
image.setCreateBy(userId);
|
||||||
|
feedbackImageMapper.insert(image);
|
||||||
|
}
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int saveMessageImages(Long messageId, Long feedbackId, List<Long> fileIds, Long userId) {
|
||||||
|
List<Long> distinct = distinctFileIds(fileIds);
|
||||||
|
if (distinct.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int order = 0;
|
||||||
|
for (Long fileId : distinct) {
|
||||||
|
FeedbackMessageImagePO image = new FeedbackMessageImagePO();
|
||||||
|
image.setMessageId(messageId);
|
||||||
|
image.setFeedbackId(feedbackId);
|
||||||
|
image.setFileId(fileId);
|
||||||
|
image.setSortOrder(order++);
|
||||||
|
image.setCreateBy(userId);
|
||||||
|
feedbackMessageImageMapper.insert(image);
|
||||||
|
}
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 去重并去掉空 id,保持首次出现顺序 */
|
||||||
|
private static List<Long> distinctFileIds(List<Long> fileIds) {
|
||||||
|
if (CollectionUtils.isEmpty(fileIds)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
LinkedHashSet<Long> set = new LinkedHashSet<>();
|
||||||
|
for (Long fileId : fileIds) {
|
||||||
|
if (fileId != null) {
|
||||||
|
set.add(fileId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ArrayList<>(set);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateMenuId(Long menuId) {
|
||||||
|
if (menuId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MenuPO menu = menuMapper.selectById(menuId);
|
||||||
|
if (menu == null) {
|
||||||
|
throw new BusinessException("关联菜单不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String normalizeType(String type) {
|
||||||
|
if (!StringUtils.hasText(type)) {
|
||||||
|
return FeedbackPO.TYPE_OTHER;
|
||||||
|
}
|
||||||
|
String normalized = type.trim().toUpperCase(Locale.ROOT);
|
||||||
|
if (!ALLOWED_TYPES.contains(normalized)) {
|
||||||
|
throw new BusinessException("无效的反馈类型");
|
||||||
|
}
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- VO 组装 ----------
|
||||||
|
|
||||||
|
private FeedbackDetailVO toDetailVO(FeedbackPO po) {
|
||||||
|
FeedbackDetailVO vo = new FeedbackDetailVO();
|
||||||
|
BeanCopyUtils.copyProperties(toListVO(po, true), vo);
|
||||||
|
List<FeedbackMessageVO> messages = loadMessageTree(po.getId());
|
||||||
|
vo.setMessages(messages);
|
||||||
|
fillNames(List.of(vo));
|
||||||
|
// 正文 + 留言附图统一补访问地址
|
||||||
|
Set<Long> allFileIds = new LinkedHashSet<>();
|
||||||
|
if (vo.getFileIds() != null) {
|
||||||
|
allFileIds.addAll(vo.getFileIds());
|
||||||
|
}
|
||||||
|
collectMessageFileIds(messages, allFileIds);
|
||||||
|
Map<Long, String> urlMap = loadFileAccessUrls(allFileIds);
|
||||||
|
vo.setImages(toFileVos(vo.getFileIds(), urlMap));
|
||||||
|
fillMessageImages(messages, urlMap);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FeedbackVO toListVO(FeedbackPO po, boolean withFileIds) {
|
||||||
|
FeedbackVO vo = new FeedbackVO();
|
||||||
|
BeanCopyUtils.copyProperties(po, vo);
|
||||||
|
if (withFileIds) {
|
||||||
|
vo.setFileIds(listFeedbackFileIds(po.getId()));
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Long> listFeedbackFileIds(Long feedbackId) {
|
||||||
|
return feedbackImageMapper.selectList(new LambdaQueryWrapper<FeedbackImagePO>()
|
||||||
|
.eq(FeedbackImagePO::getFeedbackId, feedbackId)
|
||||||
|
.orderByAsc(FeedbackImagePO::getSortOrder, FeedbackImagePO::getId))
|
||||||
|
.stream()
|
||||||
|
.map(FeedbackImagePO::getFileId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<FeedbackMessageVO> loadMessageTree(Long feedbackId) {
|
||||||
|
List<FeedbackMessagePO> all = feedbackMessageMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<FeedbackMessagePO>()
|
||||||
|
.eq(FeedbackMessagePO::getFeedbackId, feedbackId)
|
||||||
|
.orderByAsc(FeedbackMessagePO::getId));
|
||||||
|
if (all.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
Map<Long, List<Long>> messageFileIds = loadMessageFileIds(
|
||||||
|
all.stream().map(FeedbackMessagePO::getId).collect(Collectors.toList()));
|
||||||
|
Set<Long> authorIds = all.stream().map(FeedbackMessagePO::getCreateBy).collect(Collectors.toSet());
|
||||||
|
Map<Long, String> nameMap = loadUserNames(authorIds);
|
||||||
|
|
||||||
|
Map<Long, FeedbackMessageVO> byId = new LinkedHashMap<>();
|
||||||
|
for (FeedbackMessagePO msg : all) {
|
||||||
|
FeedbackMessageVO mvo = toMessageVO(msg, false);
|
||||||
|
mvo.setFileIds(messageFileIds.getOrDefault(msg.getId(), Collections.emptyList()));
|
||||||
|
mvo.setCreatorName(nameMap.get(msg.getCreateBy()));
|
||||||
|
mvo.setChildren(new ArrayList<>());
|
||||||
|
byId.put(msg.getId(), mvo);
|
||||||
|
}
|
||||||
|
List<FeedbackMessageVO> roots = new ArrayList<>();
|
||||||
|
for (FeedbackMessageVO mvo : byId.values()) {
|
||||||
|
if (mvo.getParentId() == null) {
|
||||||
|
roots.add(mvo);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
FeedbackMessageVO parent = byId.get(mvo.getParentId());
|
||||||
|
if (parent != null) {
|
||||||
|
parent.getChildren().add(mvo);
|
||||||
|
} else {
|
||||||
|
roots.add(mvo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clearEmptyChildren(roots);
|
||||||
|
return roots;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void collectMessageFileIds(List<FeedbackMessageVO> messages, Set<Long> out) {
|
||||||
|
if (CollectionUtils.isEmpty(messages)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (FeedbackMessageVO msg : messages) {
|
||||||
|
if (msg.getFileIds() != null) {
|
||||||
|
out.addAll(msg.getFileIds());
|
||||||
|
}
|
||||||
|
collectMessageFileIds(msg.getChildren(), out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillMessageImages(List<FeedbackMessageVO> messages, Map<Long, String> urlMap) {
|
||||||
|
if (CollectionUtils.isEmpty(messages)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (FeedbackMessageVO msg : messages) {
|
||||||
|
msg.setImages(toFileVos(msg.getFileIds(), urlMap));
|
||||||
|
fillMessageImages(msg.getChildren(), urlMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<FeedbackFileVO> toFileVos(List<Long> fileIds, Map<Long, String> urlMap) {
|
||||||
|
if (CollectionUtils.isEmpty(fileIds)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
List<FeedbackFileVO> list = new ArrayList<>(fileIds.size());
|
||||||
|
for (Long fileId : fileIds) {
|
||||||
|
FeedbackFileVO f = new FeedbackFileVO();
|
||||||
|
f.setFileId(fileId);
|
||||||
|
f.setAccessUrl(urlMap.get(fileId));
|
||||||
|
list.add(f);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<Long, String> loadFileAccessUrls(Collection<Long> fileIds) {
|
||||||
|
if (CollectionUtils.isEmpty(fileIds)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
List<SysFilePO> files = sysFileMapper.selectBatchIds(fileIds);
|
||||||
|
Map<Long, String> map = new HashMap<>();
|
||||||
|
for (SysFilePO file : files) {
|
||||||
|
if (file == null || file.getId() == null || file.getDeleteTime() != null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String url = SysFileUtils.getFileAccessUrl(file.getStoragePath(), file.getStorageType());
|
||||||
|
if (StringUtils.hasText(url)) {
|
||||||
|
map.put(file.getId(), url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearEmptyChildren(List<FeedbackMessageVO> nodes) {
|
||||||
|
if (nodes == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (FeedbackMessageVO node : nodes) {
|
||||||
|
if (node.getChildren() == null || node.getChildren().isEmpty()) {
|
||||||
|
node.setChildren(null);
|
||||||
|
} else {
|
||||||
|
clearEmptyChildren(node.getChildren());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private FeedbackMessageVO toMessageVO(FeedbackMessagePO po, boolean withFilesAndName) {
|
||||||
|
FeedbackMessageVO vo = new FeedbackMessageVO();
|
||||||
|
BeanCopyUtils.copyProperties(po, vo);
|
||||||
|
if (withFilesAndName) {
|
||||||
|
List<Long> ids = loadMessageFileIds(List.of(po.getId())).getOrDefault(po.getId(), Collections.emptyList());
|
||||||
|
vo.setFileIds(ids);
|
||||||
|
vo.setImages(toFileVos(ids, loadFileAccessUrls(ids)));
|
||||||
|
Map<Long, String> names = loadUserNames(Set.of(po.getCreateBy()));
|
||||||
|
vo.setCreatorName(names.get(po.getCreateBy()));
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<Long, List<Long>> loadMessageFileIds(List<Long> messageIds) {
|
||||||
|
if (CollectionUtils.isEmpty(messageIds)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
List<FeedbackMessageImagePO> images = feedbackMessageImageMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<FeedbackMessageImagePO>()
|
||||||
|
.in(FeedbackMessageImagePO::getMessageId, messageIds)
|
||||||
|
.orderByAsc(FeedbackMessageImagePO::getSortOrder, FeedbackMessageImagePO::getId));
|
||||||
|
Map<Long, List<Long>> map = new HashMap<>();
|
||||||
|
for (FeedbackMessageImagePO image : images) {
|
||||||
|
map.computeIfAbsent(image.getMessageId(), k -> new ArrayList<>()).add(image.getFileId());
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillNames(List<? extends FeedbackVO> vos) {
|
||||||
|
if (CollectionUtils.isEmpty(vos)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Set<Long> userIds = new HashSet<>();
|
||||||
|
Set<Long> menuIds = new HashSet<>();
|
||||||
|
for (FeedbackVO vo : vos) {
|
||||||
|
if (vo.getCreateBy() != null) {
|
||||||
|
userIds.add(vo.getCreateBy());
|
||||||
|
}
|
||||||
|
if (vo.getAssigneeId() != null) {
|
||||||
|
userIds.add(vo.getAssigneeId());
|
||||||
|
}
|
||||||
|
if (vo.getMenuId() != null) {
|
||||||
|
menuIds.add(vo.getMenuId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<Long, String> userNames = loadUserNames(userIds);
|
||||||
|
Map<Long, String> menuTitles = loadMenuTitles(menuIds);
|
||||||
|
for (FeedbackVO vo : vos) {
|
||||||
|
vo.setCreatorName(userNames.get(vo.getCreateBy()));
|
||||||
|
vo.setAssigneeName(userNames.get(vo.getAssigneeId()));
|
||||||
|
vo.setMenuTitle(menuTitles.get(vo.getMenuId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<Long, String> loadUserNames(Set<Long> userIds) {
|
||||||
|
if (CollectionUtils.isEmpty(userIds)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
return userMapper.selectByIds(userIds).stream()
|
||||||
|
.collect(Collectors.toMap(UserPO::getId, u -> {
|
||||||
|
if (StringUtils.hasText(u.getRealName())) {
|
||||||
|
return u.getRealName();
|
||||||
|
}
|
||||||
|
return u.getLoginCode() != null ? u.getLoginCode() : String.valueOf(u.getId());
|
||||||
|
}, (a, b) -> a));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<Long, String> loadMenuTitles(Set<Long> menuIds) {
|
||||||
|
if (CollectionUtils.isEmpty(menuIds)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
return menuMapper.selectByIds(menuIds).stream()
|
||||||
|
.collect(Collectors.toMap(MenuPO::getId, MenuPO::getTitle, (a, b) -> a));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||||
|
|
||||||
|
import type { FeedbackDTO, FeedbackVO } from './types';
|
||||||
|
|
||||||
|
/** 用户侧 */
|
||||||
|
export async function listFeedbackApi(
|
||||||
|
params: PageQueryDTO<FeedbackDTO.Filters>,
|
||||||
|
) {
|
||||||
|
return requestClient.post<PageResultVO<FeedbackVO.Item>>(
|
||||||
|
'/sys/feedback/list',
|
||||||
|
params,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getFeedbackDetailApi(id: number) {
|
||||||
|
return requestClient.get<FeedbackVO.Detail>(`/sys/feedback/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createFeedbackApi(data: FeedbackDTO.Create) {
|
||||||
|
return requestClient.post<FeedbackVO.Detail>('/sys/feedback/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function addFeedbackMessageApi(
|
||||||
|
id: number,
|
||||||
|
data: FeedbackDTO.CreateMessage,
|
||||||
|
) {
|
||||||
|
return requestClient.post<FeedbackVO.Message>(
|
||||||
|
`/sys/feedback/${id}/messages`,
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function closeFeedbackApi(id: number) {
|
||||||
|
return requestClient.post<void>(`/sys/feedback/${id}/close`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function markFeedbackSubmitterReadApi(id: number) {
|
||||||
|
return requestClient.post<void>(`/sys/feedback/${id}/read`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理侧 */
|
||||||
|
export async function listHandleFeedbackApi(
|
||||||
|
params: PageQueryDTO<FeedbackDTO.Filters>,
|
||||||
|
) {
|
||||||
|
return requestClient.post<PageResultVO<FeedbackVO.Item>>(
|
||||||
|
'/sys/feedback/handle/list',
|
||||||
|
params,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getHandleFeedbackDetailApi(id: number) {
|
||||||
|
return requestClient.get<FeedbackVO.Detail>(`/sys/feedback/handle/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateFeedbackStatusApi(
|
||||||
|
id: number,
|
||||||
|
data: FeedbackDTO.UpdateStatus,
|
||||||
|
) {
|
||||||
|
return requestClient.put<void>(`/sys/feedback/handle/${id}/status`, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateFeedbackAssigneeApi(
|
||||||
|
id: number,
|
||||||
|
data: FeedbackDTO.UpdateAssignee,
|
||||||
|
) {
|
||||||
|
return requestClient.put<void>(`/sys/feedback/handle/${id}/assignee`, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function addHandleFeedbackMessageApi(
|
||||||
|
id: number,
|
||||||
|
data: FeedbackDTO.CreateMessage,
|
||||||
|
) {
|
||||||
|
return requestClient.post<FeedbackVO.Message>(
|
||||||
|
`/sys/feedback/handle/${id}/messages`,
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteFeedbackApi(id: number) {
|
||||||
|
return requestClient.delete<void>(`/sys/feedback/handle/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function markFeedbackHandlerReadApi(id: number) {
|
||||||
|
return requestClient.post<void>(`/sys/feedback/handle/${id}/read`);
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './apis';
|
||||||
|
export * from './types';
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
/** 意见反馈 API 类型 */
|
||||||
|
export namespace FeedbackDTO {
|
||||||
|
export interface Filters {
|
||||||
|
companyId?: number;
|
||||||
|
status?: string;
|
||||||
|
type?: string;
|
||||||
|
keyword?: string;
|
||||||
|
assigneeId?: number;
|
||||||
|
createBy?: number;
|
||||||
|
menuId?: number;
|
||||||
|
handlerUnread?: number;
|
||||||
|
submitterUnread?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Create {
|
||||||
|
title: string;
|
||||||
|
content: string;
|
||||||
|
type?: string;
|
||||||
|
priority?: number;
|
||||||
|
contact?: string;
|
||||||
|
menuId?: number;
|
||||||
|
pageUrl?: string;
|
||||||
|
clientInfo?: string;
|
||||||
|
fileIds?: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateMessage {
|
||||||
|
content: string;
|
||||||
|
parentId?: number;
|
||||||
|
fileIds?: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateStatus {
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateAssignee {
|
||||||
|
assigneeId?: number | null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace FeedbackVO {
|
||||||
|
export interface FileItem {
|
||||||
|
fileId: number;
|
||||||
|
accessUrl?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Item {
|
||||||
|
id: number;
|
||||||
|
companyId?: number;
|
||||||
|
title: string;
|
||||||
|
content?: string;
|
||||||
|
type?: string;
|
||||||
|
status: string;
|
||||||
|
priority?: number;
|
||||||
|
contact?: string;
|
||||||
|
menuId?: number;
|
||||||
|
menuTitle?: string;
|
||||||
|
pageUrl?: string;
|
||||||
|
clientInfo?: string;
|
||||||
|
assigneeId?: number;
|
||||||
|
assigneeName?: string;
|
||||||
|
imageCount?: number;
|
||||||
|
messageCount?: number;
|
||||||
|
lastMessageAt?: string;
|
||||||
|
submitterUnread?: number;
|
||||||
|
handlerUnread?: number;
|
||||||
|
resolvedAt?: string;
|
||||||
|
closedAt?: string;
|
||||||
|
createTime?: string;
|
||||||
|
updateTime?: string;
|
||||||
|
createBy?: number;
|
||||||
|
creatorName?: string;
|
||||||
|
fileIds?: number[];
|
||||||
|
images?: FileItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Message {
|
||||||
|
id: number;
|
||||||
|
feedbackId: number;
|
||||||
|
companyId?: number;
|
||||||
|
parentId?: number;
|
||||||
|
rootId?: number;
|
||||||
|
content: string;
|
||||||
|
authorRole?: string;
|
||||||
|
imageCount?: number;
|
||||||
|
createTime?: string;
|
||||||
|
createBy?: number;
|
||||||
|
creatorName?: string;
|
||||||
|
fileIds?: number[];
|
||||||
|
images?: FileItem[];
|
||||||
|
children?: Message[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Detail extends Item {
|
||||||
|
messages?: Message[];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -84,6 +84,8 @@ const SwitchCompanyIcon = createIconifyIcon('lucide:building-2');
|
|||||||
const SwitchAccountIcon = createIconifyIcon('lucide:arrow-left-right');
|
const SwitchAccountIcon = createIconifyIcon('lucide:arrow-left-right');
|
||||||
// 用户图标
|
// 用户图标
|
||||||
const UserIcon = createIconifyIcon('lucide:user');
|
const UserIcon = createIconifyIcon('lucide:user');
|
||||||
|
// 意见反馈图标
|
||||||
|
const FeedbackIcon = createIconifyIcon('lucide:message-square-plus');
|
||||||
// 锁图标
|
// 锁图标
|
||||||
const LockIcon = createIconifyIcon('lucide:lock');
|
const LockIcon = createIconifyIcon('lucide:lock');
|
||||||
|
|
||||||
@@ -104,6 +106,14 @@ const menus = computed(() => {
|
|||||||
icon: UserIcon,
|
icon: UserIcon,
|
||||||
text: '个人信息',
|
text: '个人信息',
|
||||||
});
|
});
|
||||||
|
// 意见反馈
|
||||||
|
menuItems.push({
|
||||||
|
handler: () => {
|
||||||
|
router.push('/feedback');
|
||||||
|
},
|
||||||
|
icon: FeedbackIcon,
|
||||||
|
text: '意见反馈',
|
||||||
|
});
|
||||||
// 修改密码
|
// 修改密码
|
||||||
menuItems.push({
|
menuItems.push({
|
||||||
handler: () => {
|
handler: () => {
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ const ReceiptIcon = createIconifyIcon('lucide:receipt');
|
|||||||
const CalendarIcon = createIconifyIcon('lucide:calendar');
|
const CalendarIcon = createIconifyIcon('lucide:calendar');
|
||||||
const RefreshIcon = createIconifyIcon('lucide:refresh-cw');
|
const RefreshIcon = createIconifyIcon('lucide:refresh-cw');
|
||||||
const CheckIcon = createIconifyIcon('lucide:check');
|
const CheckIcon = createIconifyIcon('lucide:check');
|
||||||
|
const FeedbackIcon = createIconifyIcon('lucide:message-square-plus');
|
||||||
|
|
||||||
/** 快捷区间 + 自定义 RangePicker */
|
/** 快捷区间 + 自定义 RangePicker */
|
||||||
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
||||||
@@ -850,6 +851,23 @@ onUnmounted(() => {
|
|||||||
@update:open="(val: boolean) => handlePopoverOpen('biHealth', val)"
|
@update:open="(val: boolean) => handlePopoverOpen('biHealth', val)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<div
|
||||||
|
:class="[toolbarShellClass, 'cursor-pointer']"
|
||||||
|
title="意见反馈"
|
||||||
|
@click="router.push('/feedback')"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
:class="[toolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
||||||
|
>
|
||||||
|
<FeedbackIcon class="h-4 w-4 shrink-0" />
|
||||||
|
<span
|
||||||
|
class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300"
|
||||||
|
>
|
||||||
|
意见反馈
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Popover
|
<Popover
|
||||||
trigger="click"
|
trigger="click"
|
||||||
:open="openPopover === 'taxRate'"
|
:open="openPopover === 'taxRate'"
|
||||||
|
|||||||
+232
@@ -0,0 +1,232 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
/**
|
||||||
|
* 提交意见反馈:Vben 可拖拽 Modal + 用户可见菜单级联选择。
|
||||||
|
*/
|
||||||
|
import { reactive, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Cascader,
|
||||||
|
Form,
|
||||||
|
FormItem,
|
||||||
|
Input,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
message,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { getUserMenuApi } from '#/api/core/user';
|
||||||
|
import { createFeedbackApi } from '#/api/sys/feedback';
|
||||||
|
|
||||||
|
import FeedbackImageUpload from './FeedbackImageUpload.vue';
|
||||||
|
import {
|
||||||
|
FEEDBACK_PRIORITY_OPTIONS,
|
||||||
|
FEEDBACK_TYPE_OPTIONS,
|
||||||
|
} from '../constants';
|
||||||
|
|
||||||
|
defineOptions({ name: 'FeedbackCreateModal' });
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
success: [id?: number];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
type MenuCascaderOption = {
|
||||||
|
label: string;
|
||||||
|
value: number;
|
||||||
|
children?: MenuCascaderOption[];
|
||||||
|
};
|
||||||
|
|
||||||
|
const formRef = ref();
|
||||||
|
const imageUploadRef = ref<InstanceType<typeof FeedbackImageUpload> | null>(
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
const menuCascaderOptions = ref<MenuCascaderOption[]>([]);
|
||||||
|
const menuPath = ref<number[]>([]);
|
||||||
|
|
||||||
|
const form = reactive({
|
||||||
|
title: '',
|
||||||
|
content: '',
|
||||||
|
type: 'OTHER' as string,
|
||||||
|
priority: 2 as number,
|
||||||
|
contact: '',
|
||||||
|
menuId: undefined as number | undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
title: '提交反馈',
|
||||||
|
draggable: true,
|
||||||
|
class: 'w-[640px]',
|
||||||
|
contentClass: 'px-6 py-4',
|
||||||
|
confirmText: '提交',
|
||||||
|
onConfirm: handleSubmit,
|
||||||
|
onOpenChange: (isOpen: boolean) => {
|
||||||
|
if (!isOpen) {
|
||||||
|
resetForm();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 将用户菜单树转为 Cascader 选项(仅带 id+title 的节点) */
|
||||||
|
function buildMenuCascaderOptions(routes: any[]): MenuCascaderOption[] {
|
||||||
|
const result: MenuCascaderOption[] = [];
|
||||||
|
for (const r of routes ?? []) {
|
||||||
|
const id = r?.meta?.id;
|
||||||
|
const title = r?.meta?.title;
|
||||||
|
const children = buildMenuCascaderOptions(r?.children ?? []);
|
||||||
|
if (id == null || !title) {
|
||||||
|
// 无 id 的中间层:提升子节点
|
||||||
|
result.push(...children);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
result.push({
|
||||||
|
label: String(title),
|
||||||
|
value: Number(id),
|
||||||
|
children: children.length > 0 ? children : undefined,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadMenuOptions() {
|
||||||
|
try {
|
||||||
|
const menus = await getUserMenuApi();
|
||||||
|
menuCascaderOptions.value = buildMenuCascaderOptions(menus ?? []);
|
||||||
|
} catch {
|
||||||
|
menuCascaderOptions.value = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetForm() {
|
||||||
|
form.title = '';
|
||||||
|
form.content = '';
|
||||||
|
form.type = 'OTHER';
|
||||||
|
form.priority = 2;
|
||||||
|
form.contact = '';
|
||||||
|
form.menuId = undefined;
|
||||||
|
menuPath.value = [];
|
||||||
|
imageUploadRef.value?.clear();
|
||||||
|
formRef.value?.clearValidate?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMenuPathChange(value: (number | string)[]) {
|
||||||
|
const path = (value ?? []).map(Number).filter((n) => Number.isFinite(n));
|
||||||
|
menuPath.value = path;
|
||||||
|
form.menuId = path.length > 0 ? path[path.length - 1] : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
await formRef.value?.validate();
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
const fileIds = (await imageUploadRef.value?.persist()) ?? [];
|
||||||
|
const created = await createFeedbackApi({
|
||||||
|
title: form.title.trim(),
|
||||||
|
content: form.content.trim(),
|
||||||
|
type: form.type,
|
||||||
|
priority: form.priority,
|
||||||
|
contact: form.contact?.trim() || undefined,
|
||||||
|
menuId: form.menuId,
|
||||||
|
pageUrl: typeof window !== 'undefined' ? window.location.href : undefined,
|
||||||
|
fileIds: fileIds.length ? fileIds : undefined,
|
||||||
|
});
|
||||||
|
message.success('提交成功');
|
||||||
|
emit('success', created?.id);
|
||||||
|
modalApi.close();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.error('提交失败');
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function open() {
|
||||||
|
resetForm();
|
||||||
|
modalApi.open();
|
||||||
|
await loadMenuOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ open });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal>
|
||||||
|
<Form ref="formRef" :model="form" layout="vertical">
|
||||||
|
<FormItem
|
||||||
|
label="标题"
|
||||||
|
name="title"
|
||||||
|
:rules="[{ required: true, message: '请输入标题' }]"
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
v-model:value="form.title"
|
||||||
|
:maxlength="200"
|
||||||
|
placeholder="简要概括问题或建议"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem
|
||||||
|
label="正文"
|
||||||
|
name="content"
|
||||||
|
:rules="[{ required: true, message: '请输入正文' }]"
|
||||||
|
>
|
||||||
|
<Input.TextArea
|
||||||
|
v-model:value="form.content"
|
||||||
|
:rows="4"
|
||||||
|
:maxlength="5000"
|
||||||
|
placeholder="请描述现象、复现步骤或期望"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<Space class="w-full" :size="16">
|
||||||
|
<FormItem label="类型" name="type" class="mb-0">
|
||||||
|
<Select
|
||||||
|
v-model:value="form.type"
|
||||||
|
:options="FEEDBACK_TYPE_OPTIONS"
|
||||||
|
class="w-44"
|
||||||
|
:dropdown-match-select-width="false"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="优先级" name="priority" class="mb-0">
|
||||||
|
<Select
|
||||||
|
v-model:value="form.priority"
|
||||||
|
:options="FEEDBACK_PRIORITY_OPTIONS"
|
||||||
|
class="w-32"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
</Space>
|
||||||
|
<FormItem label="联系方式" name="contact" class="mt-4">
|
||||||
|
<Input
|
||||||
|
v-model:value="form.contact"
|
||||||
|
placeholder="手机 / 微信 / 邮箱(选填)"
|
||||||
|
:maxlength="100"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="关联菜单" name="menuId">
|
||||||
|
<Cascader
|
||||||
|
:value="menuPath"
|
||||||
|
:options="menuCascaderOptions"
|
||||||
|
allow-clear
|
||||||
|
change-on-select
|
||||||
|
expand-trigger="hover"
|
||||||
|
placeholder="选填,按菜单层级选择"
|
||||||
|
class="w-full"
|
||||||
|
:show-search="{
|
||||||
|
filter: (inputValue, path) =>
|
||||||
|
path.some((o) =>
|
||||||
|
String(o.label ?? '')
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(inputValue.toLowerCase()),
|
||||||
|
),
|
||||||
|
}"
|
||||||
|
@change="(v) => onMenuPathChange((v || []) as (number | string)[])"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="附图">
|
||||||
|
<FeedbackImageUpload ref="imageUploadRef" />
|
||||||
|
</FormItem>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
+463
@@ -0,0 +1,463 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
/**
|
||||||
|
* 反馈详情抽屉:用户侧查看/回复/关闭;处理侧改状态/指派/回复/删除。
|
||||||
|
*/
|
||||||
|
import type { FeedbackDTO, FeedbackVO } from '#/api/sys/feedback';
|
||||||
|
import type { AccountVO } from '#/api/company/account';
|
||||||
|
|
||||||
|
import { computed, reactive, ref, watch } from 'vue';
|
||||||
|
|
||||||
|
import { useUserStore } from '@vben/stores';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Button,
|
||||||
|
Descriptions,
|
||||||
|
DescriptionsItem,
|
||||||
|
Drawer,
|
||||||
|
Form,
|
||||||
|
FormItem,
|
||||||
|
Image,
|
||||||
|
Input,
|
||||||
|
Popconfirm,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
Tag,
|
||||||
|
message,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { admin_getAccountPageApi } from '#/api/company/account';
|
||||||
|
import {
|
||||||
|
addFeedbackMessageApi,
|
||||||
|
addHandleFeedbackMessageApi,
|
||||||
|
closeFeedbackApi,
|
||||||
|
deleteFeedbackApi,
|
||||||
|
getFeedbackDetailApi,
|
||||||
|
getHandleFeedbackDetailApi,
|
||||||
|
markFeedbackHandlerReadApi,
|
||||||
|
markFeedbackSubmitterReadApi,
|
||||||
|
updateFeedbackAssigneeApi,
|
||||||
|
updateFeedbackStatusApi,
|
||||||
|
} from '#/api/sys/feedback';
|
||||||
|
import { PermissionGate } from '#/components/permission';
|
||||||
|
|
||||||
|
import {
|
||||||
|
FEEDBACK_PRIORITY_COLOR,
|
||||||
|
FEEDBACK_PRIORITY_LABEL,
|
||||||
|
FEEDBACK_STATUS_COLOR,
|
||||||
|
FEEDBACK_STATUS_LABEL,
|
||||||
|
FEEDBACK_STATUS_OPTIONS,
|
||||||
|
FEEDBACK_TYPE_COLOR,
|
||||||
|
FEEDBACK_TYPE_LABEL,
|
||||||
|
} from '../constants';
|
||||||
|
import FeedbackImageUpload from './FeedbackImageUpload.vue';
|
||||||
|
import FeedbackMessageTree from './FeedbackMessageTree.vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'FeedbackDetailDrawer' });
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
open?: boolean;
|
||||||
|
feedbackId?: number | null;
|
||||||
|
mode?: 'handle' | 'user';
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
open: false,
|
||||||
|
feedbackId: null,
|
||||||
|
mode: 'user',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:open': [boolean];
|
||||||
|
changed: [];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const loading = ref(false);
|
||||||
|
const saving = ref(false);
|
||||||
|
const detail = ref<FeedbackVO.Detail | null>(null);
|
||||||
|
const accountOptions = ref<{ label: string; value: number }[]>([]);
|
||||||
|
|
||||||
|
const editStatus = ref<string>();
|
||||||
|
const editAssigneeId = ref<number | undefined>();
|
||||||
|
|
||||||
|
const replyParentId = ref<number | undefined>();
|
||||||
|
const replyImageUploadRef = ref<InstanceType<
|
||||||
|
typeof FeedbackImageUpload
|
||||||
|
> | null>(null);
|
||||||
|
const replyForm = reactive<{ content: string }>({
|
||||||
|
content: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 当前登录用户 id(store.userId 为字符串,兼容 id) */
|
||||||
|
const currentUserId = computed(() => {
|
||||||
|
const info = userStore.userInfo as null | { id?: number; userId?: string };
|
||||||
|
if (info?.id != null) return Number(info.id);
|
||||||
|
if (info?.userId) return Number(info.userId);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
const isHandle = computed(() => props.mode === 'handle');
|
||||||
|
|
||||||
|
const canClose = computed(() => {
|
||||||
|
if (isHandle.value || !detail.value) return false;
|
||||||
|
return (
|
||||||
|
detail.value.status === 'OPEN' &&
|
||||||
|
detail.value.createBy === currentUserId.value
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const canReply = computed(() => {
|
||||||
|
if (!detail.value) return false;
|
||||||
|
if (!isHandle.value) {
|
||||||
|
return ['OPEN', 'PROCESSING', 'RESOLVED'].includes(detail.value.status);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
detail.value.assigneeId != null &&
|
||||||
|
detail.value.assigneeId === currentUserId.value
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const replyDisabledTip = computed(() => {
|
||||||
|
if (!isHandle.value || canReply.value) return '';
|
||||||
|
if (!detail.value?.assigneeId) return '请先指派处理人后再回复';
|
||||||
|
return '仅当前指派处理人可回复';
|
||||||
|
});
|
||||||
|
|
||||||
|
function setOpen(v: boolean) {
|
||||||
|
emit('update:open', v);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadAccounts() {
|
||||||
|
if (accountOptions.value.length) return;
|
||||||
|
try {
|
||||||
|
const page = await admin_getAccountPageApi({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 200,
|
||||||
|
filters: {},
|
||||||
|
});
|
||||||
|
accountOptions.value = (page.records ?? []).map(
|
||||||
|
(a: AccountVO.AccountInfoVO) => ({
|
||||||
|
value: a.id,
|
||||||
|
label: a.realName
|
||||||
|
? `${a.realName}${a.loginCode ? `(${a.loginCode})` : ''}`
|
||||||
|
: a.loginCode || `用户#${a.id}`,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
/* 无账户权限时静默 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadDetail() {
|
||||||
|
if (!props.feedbackId) return;
|
||||||
|
loading.value = true;
|
||||||
|
detail.value = null;
|
||||||
|
replyParentId.value = undefined;
|
||||||
|
replyForm.content = '';
|
||||||
|
replyImageUploadRef.value?.clear();
|
||||||
|
try {
|
||||||
|
const id = props.feedbackId;
|
||||||
|
detail.value = isHandle.value
|
||||||
|
? await getHandleFeedbackDetailApi(id)
|
||||||
|
: await getFeedbackDetailApi(id);
|
||||||
|
editStatus.value = detail.value.status;
|
||||||
|
editAssigneeId.value = detail.value.assigneeId ?? undefined;
|
||||||
|
if (isHandle.value) {
|
||||||
|
await markFeedbackHandlerReadApi(id);
|
||||||
|
await loadAccounts();
|
||||||
|
} else {
|
||||||
|
await markFeedbackSubmitterReadApi(id);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.error('加载反馈详情失败');
|
||||||
|
setOpen(false);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [props.open, props.feedbackId, props.mode] as const,
|
||||||
|
([open, id]) => {
|
||||||
|
if (open && id) loadDetail();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
function onReply(parentId: number) {
|
||||||
|
replyParentId.value = parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearReplyParent() {
|
||||||
|
replyParentId.value = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitReply() {
|
||||||
|
if (!props.feedbackId || !canReply.value) return;
|
||||||
|
const content = replyForm.content.trim();
|
||||||
|
if (!content) {
|
||||||
|
message.warning('请输入回复内容');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
saving.value = true;
|
||||||
|
try {
|
||||||
|
const fileIds = (await replyImageUploadRef.value?.persist()) ?? [];
|
||||||
|
const data: FeedbackDTO.CreateMessage = {
|
||||||
|
content,
|
||||||
|
parentId: replyParentId.value,
|
||||||
|
fileIds: fileIds.length ? fileIds : undefined,
|
||||||
|
};
|
||||||
|
if (isHandle.value) {
|
||||||
|
await addHandleFeedbackMessageApi(props.feedbackId, data);
|
||||||
|
} else {
|
||||||
|
await addFeedbackMessageApi(props.feedbackId, data);
|
||||||
|
}
|
||||||
|
message.success('回复成功');
|
||||||
|
replyForm.content = '';
|
||||||
|
replyImageUploadRef.value?.clear();
|
||||||
|
replyParentId.value = undefined;
|
||||||
|
await loadDetail();
|
||||||
|
emit('changed');
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.error('回复失败');
|
||||||
|
} finally {
|
||||||
|
saving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleClose() {
|
||||||
|
if (!props.feedbackId) return;
|
||||||
|
saving.value = true;
|
||||||
|
try {
|
||||||
|
await closeFeedbackApi(props.feedbackId);
|
||||||
|
message.success('已关闭');
|
||||||
|
await loadDetail();
|
||||||
|
emit('changed');
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.error('关闭失败');
|
||||||
|
} finally {
|
||||||
|
saving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveStatus() {
|
||||||
|
if (!props.feedbackId || !editStatus.value) return;
|
||||||
|
saving.value = true;
|
||||||
|
try {
|
||||||
|
await updateFeedbackStatusApi(props.feedbackId, {
|
||||||
|
status: editStatus.value,
|
||||||
|
});
|
||||||
|
message.success('状态已更新');
|
||||||
|
await loadDetail();
|
||||||
|
emit('changed');
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.error('更新状态失败');
|
||||||
|
} finally {
|
||||||
|
saving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveAssignee() {
|
||||||
|
if (!props.feedbackId) return;
|
||||||
|
saving.value = true;
|
||||||
|
try {
|
||||||
|
await updateFeedbackAssigneeApi(props.feedbackId, {
|
||||||
|
assigneeId: editAssigneeId.value ?? null,
|
||||||
|
});
|
||||||
|
message.success('处理人已更新');
|
||||||
|
await loadDetail();
|
||||||
|
emit('changed');
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.error('更新处理人失败');
|
||||||
|
} finally {
|
||||||
|
saving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete() {
|
||||||
|
if (!props.feedbackId) return;
|
||||||
|
saving.value = true;
|
||||||
|
try {
|
||||||
|
await deleteFeedbackApi(props.feedbackId);
|
||||||
|
message.success('已删除');
|
||||||
|
setOpen(false);
|
||||||
|
emit('changed');
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.error('删除失败');
|
||||||
|
} finally {
|
||||||
|
saving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Drawer
|
||||||
|
:open="open"
|
||||||
|
:title="detail?.title || '反馈详情'"
|
||||||
|
width="720"
|
||||||
|
destroy-on-close
|
||||||
|
:loading="loading"
|
||||||
|
@update:open="setOpen"
|
||||||
|
>
|
||||||
|
<template v-if="detail">
|
||||||
|
<Descriptions bordered :column="2" size="small" class="mb-4">
|
||||||
|
<DescriptionsItem label="状态">
|
||||||
|
<Tag :color="FEEDBACK_STATUS_COLOR[detail.status] || 'default'">
|
||||||
|
{{ FEEDBACK_STATUS_LABEL[detail.status] || detail.status }}
|
||||||
|
</Tag>
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="类型">
|
||||||
|
<Tag :color="FEEDBACK_TYPE_COLOR[detail.type || ''] || 'default'">
|
||||||
|
{{ FEEDBACK_TYPE_LABEL[detail.type || ''] || detail.type || '-' }}
|
||||||
|
</Tag>
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="优先级">
|
||||||
|
<Tag
|
||||||
|
:color="
|
||||||
|
FEEDBACK_PRIORITY_COLOR[detail.priority ?? 2] || 'default'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{ FEEDBACK_PRIORITY_LABEL[detail.priority ?? 2] || '-' }}
|
||||||
|
</Tag>
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="提交人">
|
||||||
|
{{ detail.creatorName || '-' }}
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="处理人">
|
||||||
|
{{ detail.assigneeName || '-' }}
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="关联菜单">
|
||||||
|
{{ detail.menuTitle || '-' }}
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="联系方式">
|
||||||
|
{{ detail.contact || '-' }}
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="提交时间">
|
||||||
|
{{ detail.createTime || '-' }}
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="正文" :span="2">
|
||||||
|
<div class="whitespace-pre-wrap">{{ detail.content || '-' }}</div>
|
||||||
|
</DescriptionsItem>
|
||||||
|
</Descriptions>
|
||||||
|
|
||||||
|
<div v-if="detail.images?.length" class="mb-4">
|
||||||
|
<div class="mb-2 text-sm font-medium">附图</div>
|
||||||
|
<Image.PreviewGroup>
|
||||||
|
<Space wrap>
|
||||||
|
<Image
|
||||||
|
v-for="img in detail.images"
|
||||||
|
:key="img.fileId"
|
||||||
|
:src="img.accessUrl"
|
||||||
|
:width="80"
|
||||||
|
:height="80"
|
||||||
|
class="rounded object-cover"
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
</Image.PreviewGroup>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 处理侧:状态 / 指派 -->
|
||||||
|
<div
|
||||||
|
v-if="isHandle"
|
||||||
|
class="mb-4 flex flex-wrap items-end gap-3 rounded border border-slate-200 p-3 dark:border-slate-600"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<div class="mb-1 text-xs text-slate-500">状态</div>
|
||||||
|
<Space>
|
||||||
|
<Select
|
||||||
|
v-model:value="editStatus"
|
||||||
|
:options="FEEDBACK_STATUS_OPTIONS"
|
||||||
|
class="w-36"
|
||||||
|
/>
|
||||||
|
<Button :loading="saving" @click="saveStatus">
|
||||||
|
保存状态
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="mb-1 text-xs text-slate-500">处理人</div>
|
||||||
|
<Space>
|
||||||
|
<Select
|
||||||
|
v-model:value="editAssigneeId"
|
||||||
|
:options="accountOptions"
|
||||||
|
allow-clear
|
||||||
|
show-search
|
||||||
|
option-filter-prop="label"
|
||||||
|
placeholder="选择处理人"
|
||||||
|
class="w-48"
|
||||||
|
/>
|
||||||
|
<Button :loading="saving" @click="saveAssignee">
|
||||||
|
保存指派
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
</div>
|
||||||
|
<PermissionGate code="sys:feedback:delete">
|
||||||
|
<Popconfirm title="确认删除该反馈?" @confirm="handleDelete">
|
||||||
|
<Button danger :loading="saving">删除</Button>
|
||||||
|
</Popconfirm>
|
||||||
|
</PermissionGate>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-2 flex items-center justify-between">
|
||||||
|
<div class="text-sm font-medium">留言对话</div>
|
||||||
|
<Button
|
||||||
|
v-if="canClose"
|
||||||
|
size="small"
|
||||||
|
:loading="saving"
|
||||||
|
@click="handleClose"
|
||||||
|
>
|
||||||
|
关闭反馈
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<FeedbackMessageTree
|
||||||
|
:messages="detail.messages || []"
|
||||||
|
:allow-reply="canReply"
|
||||||
|
@reply="onReply"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="mt-4 border-t border-slate-100 pt-4 dark:border-slate-700">
|
||||||
|
<Alert
|
||||||
|
v-if="replyDisabledTip"
|
||||||
|
type="info"
|
||||||
|
show-icon
|
||||||
|
class="mb-3"
|
||||||
|
:message="replyDisabledTip"
|
||||||
|
/>
|
||||||
|
<Form v-else-if="canReply" layout="vertical">
|
||||||
|
<div v-if="replyParentId" class="mb-2 text-xs text-slate-500">
|
||||||
|
回复留言 #{{ replyParentId }}
|
||||||
|
<Button type="link" size="small" @click="clearReplyParent">
|
||||||
|
取消
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<FormItem label="回复内容" required>
|
||||||
|
<Input.TextArea
|
||||||
|
v-model:value="replyForm.content"
|
||||||
|
:rows="3"
|
||||||
|
:maxlength="2000"
|
||||||
|
placeholder="请输入回复内容"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="附图">
|
||||||
|
<FeedbackImageUpload
|
||||||
|
ref="replyImageUploadRef"
|
||||||
|
:max-count="6"
|
||||||
|
:disabled="saving"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<Button type="primary" :loading="saving" @click="submitReply">
|
||||||
|
发送回复
|
||||||
|
</Button>
|
||||||
|
</Form>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Drawer>
|
||||||
|
</template>
|
||||||
+216
@@ -0,0 +1,216 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
/**
|
||||||
|
* 反馈多图:先本地预览(可选/粘贴),提交时由 persist() 调 uploadFiles 批量上传。
|
||||||
|
*/
|
||||||
|
import type { UploadFile } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
|
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||||
|
import { Upload, message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { FileCategory } from '#/constants/file-category';
|
||||||
|
import { uploadFiles } from '#/utils/upload-file';
|
||||||
|
|
||||||
|
defineOptions({ name: 'FeedbackImageUpload' });
|
||||||
|
|
||||||
|
type PendingItem = {
|
||||||
|
uid: string;
|
||||||
|
file: File;
|
||||||
|
previewUrl: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
/** 最大张数 */
|
||||||
|
maxCount?: number;
|
||||||
|
disabled?: boolean;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
maxCount: 9,
|
||||||
|
disabled: false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const rootRef = ref<HTMLElement | null>(null);
|
||||||
|
const pending = ref<PendingItem[]>([]);
|
||||||
|
const persisting = ref(false);
|
||||||
|
|
||||||
|
const canAdd = computed(
|
||||||
|
() => !props.disabled && pending.value.length < props.maxCount,
|
||||||
|
);
|
||||||
|
|
||||||
|
const fileList = computed<UploadFile[]>(() =>
|
||||||
|
pending.value.map((p) => ({
|
||||||
|
uid: p.uid,
|
||||||
|
name: p.file.name,
|
||||||
|
status: 'done' as const,
|
||||||
|
url: p.previewUrl,
|
||||||
|
thumbUrl: p.previewUrl,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
|
function revokeAll() {
|
||||||
|
for (const p of pending.value) {
|
||||||
|
URL.revokeObjectURL(p.previewUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function clear() {
|
||||||
|
revokeAll();
|
||||||
|
pending.value = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function addFiles(files: File[]) {
|
||||||
|
if (props.disabled) return;
|
||||||
|
let remain = props.maxCount - pending.value.length;
|
||||||
|
if (remain <= 0) {
|
||||||
|
message.warning(`最多选择 ${props.maxCount} 张图片`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const next = [...pending.value];
|
||||||
|
for (const raw of files) {
|
||||||
|
if (remain <= 0) {
|
||||||
|
message.warning(`最多选择 ${props.maxCount} 张图片`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!raw.type?.startsWith('image/')) {
|
||||||
|
message.error('只能选择图片');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (raw.size > 5 * 1024 * 1024) {
|
||||||
|
message.error(`「${raw.name || '图片'}」超过 5MB`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const named =
|
||||||
|
raw.name && raw.name.trim()
|
||||||
|
? raw
|
||||||
|
: new File(
|
||||||
|
[raw],
|
||||||
|
`paste-${Date.now()}-${remain}.${raw.type.split('/')[1] || 'png'}`,
|
||||||
|
{ type: raw.type },
|
||||||
|
);
|
||||||
|
next.push({
|
||||||
|
uid: `local-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
||||||
|
file: named,
|
||||||
|
previewUrl: URL.createObjectURL(named),
|
||||||
|
});
|
||||||
|
remain -= 1;
|
||||||
|
}
|
||||||
|
pending.value = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 拦截自动上传:只入本地预览列表 */
|
||||||
|
function beforeUpload(file: File) {
|
||||||
|
addFiles([file]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRemove(file: UploadFile) {
|
||||||
|
const idx = pending.value.findIndex((p) => p.uid === file.uid);
|
||||||
|
if (idx >= 0) {
|
||||||
|
URL.revokeObjectURL(pending.value[idx]!.previewUrl);
|
||||||
|
pending.value = pending.value.filter((_, i) => i !== idx);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractClipboardImages(event: ClipboardEvent): File[] {
|
||||||
|
const files: File[] = [];
|
||||||
|
const items = event.clipboardData?.items;
|
||||||
|
if (items) {
|
||||||
|
for (const item of Array.from(items)) {
|
||||||
|
if (item.kind === 'file' && item.type.startsWith('image/')) {
|
||||||
|
const f = item.getAsFile();
|
||||||
|
if (f) files.push(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (files.length === 0 && event.clipboardData?.files?.length) {
|
||||||
|
for (const f of Array.from(event.clipboardData.files)) {
|
||||||
|
if (f.type.startsWith('image/')) files.push(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onPaste(event: ClipboardEvent) {
|
||||||
|
if (props.disabled || persisting.value) return;
|
||||||
|
const images = extractClipboardImages(event);
|
||||||
|
if (images.length === 0) return;
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
addFiles(images);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onWindowPaste(event: ClipboardEvent) {
|
||||||
|
const root = rootRef.value;
|
||||||
|
if (!root || props.disabled) return;
|
||||||
|
const active = document.activeElement as Node | null;
|
||||||
|
if (!active) return;
|
||||||
|
if (root === active || root.contains(active)) {
|
||||||
|
onPaste(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const form = root.closest('form');
|
||||||
|
if (form && form.contains(active) && extractClipboardImages(event).length > 0) {
|
||||||
|
onPaste(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量上传本地待传图,返回 fileId 列表;无图返回 []。
|
||||||
|
* 上传成功后不清空本地预览(由父级关闭/重置时 clear)。
|
||||||
|
*/
|
||||||
|
async function persist(): Promise<number[]> {
|
||||||
|
if (pending.value.length === 0) return [];
|
||||||
|
persisting.value = true;
|
||||||
|
try {
|
||||||
|
const infos = await uploadFiles(
|
||||||
|
pending.value.map((p) => p.file),
|
||||||
|
{
|
||||||
|
category: FileCategory.IMAGE,
|
||||||
|
errorMessage: '图片上传失败',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return [...new Set(infos.map((i) => i.id).filter(Boolean))];
|
||||||
|
} finally {
|
||||||
|
persisting.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
window.addEventListener('paste', onWindowPaste);
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
window.removeEventListener('paste', onWindowPaste);
|
||||||
|
revokeAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
defineExpose({ persist, clear, getPendingCount: () => pending.value.length });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
ref="rootRef"
|
||||||
|
tabindex="0"
|
||||||
|
class="feedback-image-upload outline-none"
|
||||||
|
@paste="onPaste"
|
||||||
|
>
|
||||||
|
<Upload
|
||||||
|
list-type="picture-card"
|
||||||
|
:file-list="fileList"
|
||||||
|
:disabled="disabled || persisting"
|
||||||
|
accept="image/*"
|
||||||
|
:max-count="maxCount"
|
||||||
|
:before-upload="beforeUpload"
|
||||||
|
@remove="handleRemove"
|
||||||
|
>
|
||||||
|
<div v-if="canAdd">
|
||||||
|
<PlusOutlined />
|
||||||
|
<div class="mt-1 text-xs">上传/ctrl+v</div>
|
||||||
|
</div>
|
||||||
|
</Upload>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
+89
@@ -0,0 +1,89 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
/**
|
||||||
|
* 反馈留言树:递归展示 + 回复(向上抛 parentId);图片 URL 用详情接口下发的 images。
|
||||||
|
*/
|
||||||
|
import type { FeedbackVO } from '#/api/sys/feedback';
|
||||||
|
|
||||||
|
import { Button, Image, Space, Tag } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { AUTHOR_ROLE_LABEL } from '../constants';
|
||||||
|
|
||||||
|
defineOptions({ name: 'FeedbackMessageTree' });
|
||||||
|
|
||||||
|
withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
messages?: FeedbackVO.Message[];
|
||||||
|
/** 是否展示回复按钮 */
|
||||||
|
allowReply?: boolean;
|
||||||
|
depth?: number;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
messages: () => [],
|
||||||
|
allowReply: true,
|
||||||
|
depth: 0,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
reply: [parentId: number];
|
||||||
|
}>();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
v-if="!messages?.length && depth === 0"
|
||||||
|
class="py-4 text-center text-slate-400"
|
||||||
|
>
|
||||||
|
暂无留言
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-for="msg in messages"
|
||||||
|
:key="msg.id"
|
||||||
|
class="border-l border-slate-200 pl-3 dark:border-slate-600"
|
||||||
|
:class="depth > 0 ? 'mt-3 ml-2' : 'mt-3'"
|
||||||
|
>
|
||||||
|
<div class="flex flex-wrap items-center gap-2 text-xs text-slate-500">
|
||||||
|
<span class="font-medium text-slate-700 dark:text-slate-200">
|
||||||
|
{{ msg.creatorName || `用户#${msg.createBy}` }}
|
||||||
|
</span>
|
||||||
|
<Tag v-if="msg.authorRole">
|
||||||
|
{{ AUTHOR_ROLE_LABEL[msg.authorRole] || msg.authorRole }}
|
||||||
|
</Tag>
|
||||||
|
<span>{{ msg.createTime || '' }}</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="mt-1 whitespace-pre-wrap text-sm text-slate-800 dark:text-slate-100"
|
||||||
|
>
|
||||||
|
{{ msg.content }}
|
||||||
|
</div>
|
||||||
|
<div v-if="msg.images?.length" class="mt-2 flex flex-wrap gap-2">
|
||||||
|
<Image.PreviewGroup>
|
||||||
|
<Image
|
||||||
|
v-for="img in msg.images"
|
||||||
|
:key="img.fileId"
|
||||||
|
:src="img.accessUrl"
|
||||||
|
:width="56"
|
||||||
|
:height="56"
|
||||||
|
class="rounded object-cover"
|
||||||
|
/>
|
||||||
|
</Image.PreviewGroup>
|
||||||
|
</div>
|
||||||
|
<Space v-if="allowReply" class="mt-1">
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
size="small"
|
||||||
|
class="!px-0"
|
||||||
|
@click="emit('reply', msg.id)"
|
||||||
|
>
|
||||||
|
回复
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
<FeedbackMessageTree
|
||||||
|
v-if="msg.children?.length"
|
||||||
|
:messages="msg.children"
|
||||||
|
:allow-reply="allowReply"
|
||||||
|
:depth="depth + 1"
|
||||||
|
@reply="(id) => emit('reply', id)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/** 意见反馈:状态 / 类型 / 优先级展示映射 */
|
||||||
|
|
||||||
|
export const FEEDBACK_STATUS_LABEL: Record<string, string> = {
|
||||||
|
OPEN: '待处理',
|
||||||
|
PROCESSING: '处理中',
|
||||||
|
RESOLVED: '已解决',
|
||||||
|
CLOSED: '已关闭',
|
||||||
|
REJECTED: '已拒绝',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const FEEDBACK_STATUS_COLOR: Record<string, string> = {
|
||||||
|
OPEN: 'orange',
|
||||||
|
PROCESSING: 'blue',
|
||||||
|
RESOLVED: 'green',
|
||||||
|
CLOSED: 'default',
|
||||||
|
REJECTED: 'red',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const FEEDBACK_TYPE_LABEL: Record<string, string> = {
|
||||||
|
BUG: '缺陷',
|
||||||
|
FEATURE: '功能建议',
|
||||||
|
QUESTION: '咨询',
|
||||||
|
COMPLAINT: '投诉',
|
||||||
|
OTHER: '其他',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const FEEDBACK_TYPE_COLOR: Record<string, string> = {
|
||||||
|
BUG: 'error',
|
||||||
|
FEATURE: 'processing',
|
||||||
|
QUESTION: 'cyan',
|
||||||
|
COMPLAINT: 'warning',
|
||||||
|
OTHER: 'default',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const FEEDBACK_PRIORITY_LABEL: Record<number, string> = {
|
||||||
|
1: '高',
|
||||||
|
2: '中',
|
||||||
|
3: '低',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const FEEDBACK_PRIORITY_COLOR: Record<number, string> = {
|
||||||
|
1: 'red',
|
||||||
|
2: 'orange',
|
||||||
|
3: 'default',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const FEEDBACK_STATUS_OPTIONS = Object.entries(FEEDBACK_STATUS_LABEL).map(
|
||||||
|
([value, label]) => ({ value, label }),
|
||||||
|
);
|
||||||
|
|
||||||
|
export const FEEDBACK_TYPE_OPTIONS = Object.entries(FEEDBACK_TYPE_LABEL).map(
|
||||||
|
([value, label]) => ({ value, label }),
|
||||||
|
);
|
||||||
|
|
||||||
|
export const FEEDBACK_PRIORITY_OPTIONS = Object.entries(
|
||||||
|
FEEDBACK_PRIORITY_LABEL,
|
||||||
|
).map(([value, label]) => ({ value: Number(value), label }));
|
||||||
|
|
||||||
|
export const AUTHOR_ROLE_LABEL: Record<string, string> = {
|
||||||
|
USER: '提交人',
|
||||||
|
HANDLER: '处理人',
|
||||||
|
SYSTEM: '系统',
|
||||||
|
};
|
||||||
@@ -0,0 +1,324 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
/**
|
||||||
|
* 反馈处理(管理侧):列表 / 指派回复 / 删除。
|
||||||
|
*/
|
||||||
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
|
import type { FeedbackDTO, FeedbackVO } from '#/api/sys/feedback';
|
||||||
|
import type { PageQueryDTO } from '#/types/common';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Badge,
|
||||||
|
Button,
|
||||||
|
Popconfirm,
|
||||||
|
Space,
|
||||||
|
Tag,
|
||||||
|
message,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
deleteFeedbackApi,
|
||||||
|
listHandleFeedbackApi,
|
||||||
|
} from '#/api/sys/feedback';
|
||||||
|
import { PermissionGate } from '#/components/permission';
|
||||||
|
import {
|
||||||
|
syncVxeGridColumns,
|
||||||
|
useActionColumnVisible,
|
||||||
|
} from '#/composables/use-vxe-action-column';
|
||||||
|
|
||||||
|
import FeedbackDetailDrawer from '../components/FeedbackDetailDrawer.vue';
|
||||||
|
import {
|
||||||
|
FEEDBACK_PRIORITY_COLOR,
|
||||||
|
FEEDBACK_PRIORITY_LABEL,
|
||||||
|
FEEDBACK_STATUS_COLOR,
|
||||||
|
FEEDBACK_STATUS_LABEL,
|
||||||
|
FEEDBACK_STATUS_OPTIONS,
|
||||||
|
FEEDBACK_TYPE_COLOR,
|
||||||
|
FEEDBACK_TYPE_LABEL,
|
||||||
|
FEEDBACK_TYPE_OPTIONS,
|
||||||
|
} from '../constants';
|
||||||
|
|
||||||
|
defineOptions({ name: 'SysFeedbackHandle' });
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
const detailOpen = ref(false);
|
||||||
|
const detailId = ref<number | null>(null);
|
||||||
|
|
||||||
|
const actionCodes = ['sys:feedback:handle', 'sys:feedback:delete'];
|
||||||
|
const showActionColumn = useActionColumnVisible(actionCodes);
|
||||||
|
|
||||||
|
const baseColumns: VxeGridProps<FeedbackVO.Item>['columns'] = [
|
||||||
|
{ type: 'seq', width: 56, title: '序号' },
|
||||||
|
{
|
||||||
|
field: 'title',
|
||||||
|
title: '标题',
|
||||||
|
minWidth: 180,
|
||||||
|
showOverflow: 'tooltip',
|
||||||
|
slots: { default: 'title' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'type',
|
||||||
|
title: '类型',
|
||||||
|
width: 100,
|
||||||
|
slots: { default: 'type' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '状态',
|
||||||
|
width: 100,
|
||||||
|
slots: { default: 'status' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'priority',
|
||||||
|
title: '优先级',
|
||||||
|
width: 80,
|
||||||
|
slots: { default: 'priority' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'creatorName',
|
||||||
|
title: '提交人',
|
||||||
|
minWidth: 100,
|
||||||
|
showOverflow: 'tooltip',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'assigneeName',
|
||||||
|
title: '处理人',
|
||||||
|
minWidth: 100,
|
||||||
|
showOverflow: 'tooltip',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'handlerUnread',
|
||||||
|
title: '未读',
|
||||||
|
width: 72,
|
||||||
|
slots: { default: 'unread' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'messageCount',
|
||||||
|
title: '留言',
|
||||||
|
width: 70,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '提交时间',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const actionColumn: NonNullable<
|
||||||
|
VxeGridProps<FeedbackVO.Item>['columns']
|
||||||
|
>[number] = {
|
||||||
|
title: '操作',
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'action' },
|
||||||
|
};
|
||||||
|
|
||||||
|
const tableColumns = computed(() =>
|
||||||
|
showActionColumn.value
|
||||||
|
? [...(baseColumns ?? []), actionColumn]
|
||||||
|
: (baseColumns ?? []),
|
||||||
|
);
|
||||||
|
|
||||||
|
const gridOptions: VxeGridProps<FeedbackVO.Item> = {
|
||||||
|
columns: tableColumns.value,
|
||||||
|
height: 'auto',
|
||||||
|
border: true,
|
||||||
|
stripe: true,
|
||||||
|
rowConfig: { isHover: true },
|
||||||
|
showOverflow: true,
|
||||||
|
size: 'small',
|
||||||
|
toolbarConfig: { custom: true, refresh: true, zoom: true },
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: true,
|
||||||
|
pageSizes: [10, 20, 50, 100],
|
||||||
|
layouts: [
|
||||||
|
'PrevJump',
|
||||||
|
'PrevPage',
|
||||||
|
'Number',
|
||||||
|
'NextPage',
|
||||||
|
'NextJump',
|
||||||
|
'Sizes',
|
||||||
|
'FullJump',
|
||||||
|
'Total',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues: Record<string, any> = {}) => {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const params: PageQueryDTO<FeedbackDTO.Filters> = {
|
||||||
|
page: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
filters: {
|
||||||
|
status: formValues.status || undefined,
|
||||||
|
type: formValues.type || undefined,
|
||||||
|
keyword: formValues.keyword?.trim() || undefined,
|
||||||
|
handlerUnread:
|
||||||
|
formValues.handlerUnread === 1 || formValues.handlerUnread === 0
|
||||||
|
? formValues.handlerUnread
|
||||||
|
: undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const data = await listHandleFeedbackApi(params);
|
||||||
|
return {
|
||||||
|
items: data.records ?? [],
|
||||||
|
total: data.total ?? 0,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.error('获取反馈列表失败');
|
||||||
|
return { items: [], total: 0 };
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const formOptions = computed(() => ({
|
||||||
|
schema: [
|
||||||
|
{
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '全部',
|
||||||
|
options: FEEDBACK_STATUS_OPTIONS,
|
||||||
|
},
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '状态',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '全部',
|
||||||
|
options: FEEDBACK_TYPE_OPTIONS,
|
||||||
|
},
|
||||||
|
fieldName: 'type',
|
||||||
|
label: '类型',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '全部',
|
||||||
|
options: [
|
||||||
|
{ label: '未读', value: 1 },
|
||||||
|
{ label: '已读', value: 0 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
fieldName: 'handlerUnread',
|
||||||
|
label: '处理未读',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '标题 / 正文关键词',
|
||||||
|
},
|
||||||
|
fieldName: 'keyword',
|
||||||
|
label: '关键词',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
showDefaultActions: true,
|
||||||
|
collapsed: true,
|
||||||
|
collapsedRows: 1,
|
||||||
|
submitOnChange: true,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
gridOptions,
|
||||||
|
formOptions: formOptions.value,
|
||||||
|
showSearchForm: true,
|
||||||
|
tableTitle: '反馈处理',
|
||||||
|
});
|
||||||
|
syncVxeGridColumns(gridApi, tableColumns);
|
||||||
|
|
||||||
|
function openDetail(row: FeedbackVO.Item) {
|
||||||
|
detailId.value = row.id;
|
||||||
|
detailOpen.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(row: FeedbackVO.Item) {
|
||||||
|
try {
|
||||||
|
await deleteFeedbackApi(row.id);
|
||||||
|
message.success('已删除');
|
||||||
|
gridApi.reload();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.error('删除失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page title="反馈处理" auto-content-height>
|
||||||
|
<Grid :loading="loading">
|
||||||
|
<template #title="{ row }">
|
||||||
|
<Badge :dot="!!row.handlerUnread">
|
||||||
|
<a class="cursor-pointer text-primary" @click="openDetail(row)">
|
||||||
|
{{ row.title }}
|
||||||
|
</a>
|
||||||
|
</Badge>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #type="{ row }">
|
||||||
|
<Tag :color="FEEDBACK_TYPE_COLOR[row.type || ''] || 'default'">
|
||||||
|
{{ FEEDBACK_TYPE_LABEL[row.type || ''] || row.type || '-' }}
|
||||||
|
</Tag>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #status="{ row }">
|
||||||
|
<Tag :color="FEEDBACK_STATUS_COLOR[row.status] || 'default'">
|
||||||
|
{{ FEEDBACK_STATUS_LABEL[row.status] || row.status }}
|
||||||
|
</Tag>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #priority="{ row }">
|
||||||
|
<Tag :color="FEEDBACK_PRIORITY_COLOR[row.priority ?? 2] || 'default'">
|
||||||
|
{{ FEEDBACK_PRIORITY_LABEL[row.priority ?? 2] || '-' }}
|
||||||
|
</Tag>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #unread="{ row }">
|
||||||
|
<Badge
|
||||||
|
v-if="row.handlerUnread"
|
||||||
|
status="processing"
|
||||||
|
text="未读"
|
||||||
|
/>
|
||||||
|
<span v-else class="text-slate-400">已读</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-if="showActionColumn" #action="{ row }">
|
||||||
|
<Space>
|
||||||
|
<PermissionGate code="sys:feedback:handle">
|
||||||
|
<Button type="link" size="small" @click="openDetail(row)">
|
||||||
|
处理
|
||||||
|
</Button>
|
||||||
|
</PermissionGate>
|
||||||
|
<PermissionGate code="sys:feedback:delete">
|
||||||
|
<Popconfirm
|
||||||
|
title="确认删除该反馈?"
|
||||||
|
@confirm="handleDelete(row)"
|
||||||
|
>
|
||||||
|
<Button type="link" danger size="small">删除</Button>
|
||||||
|
</Popconfirm>
|
||||||
|
</PermissionGate>
|
||||||
|
</Space>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<FeedbackDetailDrawer
|
||||||
|
v-model:open="detailOpen"
|
||||||
|
:feedback-id="detailId"
|
||||||
|
mode="handle"
|
||||||
|
@changed="() => gridApi.reload()"
|
||||||
|
/>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,262 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
/**
|
||||||
|
* 意见反馈(用户侧):列表 / 提交 / 详情。
|
||||||
|
*/
|
||||||
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
|
import type { FeedbackDTO, FeedbackVO } from '#/api/sys/feedback';
|
||||||
|
import type { PageQueryDTO } from '#/types/common';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
|
import { Badge, Button, Tag, message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { listFeedbackApi } from '#/api/sys/feedback';
|
||||||
|
import { PermissionGate } from '#/components/permission';
|
||||||
|
|
||||||
|
import FeedbackCreateModal from '../components/FeedbackCreateModal.vue';
|
||||||
|
import FeedbackDetailDrawer from '../components/FeedbackDetailDrawer.vue';
|
||||||
|
import {
|
||||||
|
FEEDBACK_PRIORITY_COLOR,
|
||||||
|
FEEDBACK_PRIORITY_LABEL,
|
||||||
|
FEEDBACK_STATUS_COLOR,
|
||||||
|
FEEDBACK_STATUS_LABEL,
|
||||||
|
FEEDBACK_STATUS_OPTIONS,
|
||||||
|
FEEDBACK_TYPE_COLOR,
|
||||||
|
FEEDBACK_TYPE_LABEL,
|
||||||
|
FEEDBACK_TYPE_OPTIONS,
|
||||||
|
} from '../constants';
|
||||||
|
|
||||||
|
defineOptions({ name: 'SysFeedbackUser' });
|
||||||
|
|
||||||
|
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
const detailOpen = ref(false);
|
||||||
|
const detailId = ref<number | null>(null);
|
||||||
|
const createModalRef = ref<InstanceType<typeof FeedbackCreateModal> | null>(
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
|
||||||
|
const gridOptions: VxeGridProps<FeedbackVO.Item> = {
|
||||||
|
columns: [
|
||||||
|
{ type: 'seq', width: 56, title: '序号' },
|
||||||
|
{
|
||||||
|
field: 'title',
|
||||||
|
title: '标题',
|
||||||
|
minWidth: 180,
|
||||||
|
showOverflow: 'tooltip',
|
||||||
|
slots: { default: 'title' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'type',
|
||||||
|
title: '类型',
|
||||||
|
width: 100,
|
||||||
|
slots: { default: 'type' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '状态',
|
||||||
|
width: 100,
|
||||||
|
slots: { default: 'status' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'priority',
|
||||||
|
title: '优先级',
|
||||||
|
width: 80,
|
||||||
|
slots: { default: 'priority' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'assigneeName',
|
||||||
|
title: '处理人',
|
||||||
|
minWidth: 100,
|
||||||
|
showOverflow: 'tooltip',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'messageCount',
|
||||||
|
title: '留言',
|
||||||
|
width: 70,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '提交时间',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 88,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'action' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
height: 'auto',
|
||||||
|
border: true,
|
||||||
|
stripe: true,
|
||||||
|
rowConfig: { isHover: true },
|
||||||
|
showOverflow: true,
|
||||||
|
size: 'small',
|
||||||
|
toolbarConfig: { custom: true, refresh: true, zoom: true },
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: true,
|
||||||
|
pageSizes: [10, 20, 50, 100],
|
||||||
|
layouts: [
|
||||||
|
'PrevJump',
|
||||||
|
'PrevPage',
|
||||||
|
'Number',
|
||||||
|
'NextPage',
|
||||||
|
'NextJump',
|
||||||
|
'Sizes',
|
||||||
|
'FullJump',
|
||||||
|
'Total',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues: Record<string, any> = {}) => {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const params: PageQueryDTO<FeedbackDTO.Filters> = {
|
||||||
|
page: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
filters: {
|
||||||
|
status: formValues.status || undefined,
|
||||||
|
type: formValues.type || undefined,
|
||||||
|
keyword: formValues.keyword?.trim() || undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const data = await listFeedbackApi(params);
|
||||||
|
return {
|
||||||
|
items: data.records ?? [],
|
||||||
|
total: data.total ?? 0,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.error('获取反馈列表失败');
|
||||||
|
return { items: [], total: 0 };
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const formOptions = computed(() => ({
|
||||||
|
schema: [
|
||||||
|
{
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '全部',
|
||||||
|
options: FEEDBACK_STATUS_OPTIONS,
|
||||||
|
},
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '状态',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '全部',
|
||||||
|
options: FEEDBACK_TYPE_OPTIONS,
|
||||||
|
},
|
||||||
|
fieldName: 'type',
|
||||||
|
label: '类型',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '标题 / 正文关键词',
|
||||||
|
},
|
||||||
|
fieldName: 'keyword',
|
||||||
|
label: '关键词',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
showDefaultActions: true,
|
||||||
|
collapsed: true,
|
||||||
|
collapsedRows: 1,
|
||||||
|
submitOnChange: true,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
gridOptions,
|
||||||
|
formOptions: formOptions.value,
|
||||||
|
showSearchForm: true,
|
||||||
|
tableTitle: '我的反馈',
|
||||||
|
});
|
||||||
|
|
||||||
|
function openDetail(row: FeedbackVO.Item) {
|
||||||
|
detailId.value = row.id;
|
||||||
|
detailOpen.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCreate() {
|
||||||
|
createModalRef.value?.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCreateSuccess(id?: number) {
|
||||||
|
gridApi.reload();
|
||||||
|
if (id) {
|
||||||
|
detailId.value = id;
|
||||||
|
detailOpen.value = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page title="意见反馈" auto-content-height>
|
||||||
|
<Grid :loading="loading">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<PermissionGate code="sys:feedback:create">
|
||||||
|
<Button type="primary" @click="openCreate">
|
||||||
|
<PlusIcon class="size-4" />
|
||||||
|
提交反馈
|
||||||
|
</Button>
|
||||||
|
</PermissionGate>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #title="{ row }">
|
||||||
|
<Badge :dot="!!row.submitterUnread">
|
||||||
|
<a class="cursor-pointer text-primary" @click="openDetail(row)">
|
||||||
|
{{ row.title }}
|
||||||
|
</a>
|
||||||
|
</Badge>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #type="{ row }">
|
||||||
|
<Tag :color="FEEDBACK_TYPE_COLOR[row.type || ''] || 'default'">
|
||||||
|
{{ FEEDBACK_TYPE_LABEL[row.type || ''] || row.type || '-' }}
|
||||||
|
</Tag>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #status="{ row }">
|
||||||
|
<Tag :color="FEEDBACK_STATUS_COLOR[row.status] || 'default'">
|
||||||
|
{{ FEEDBACK_STATUS_LABEL[row.status] || row.status }}
|
||||||
|
</Tag>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #priority="{ row }">
|
||||||
|
<Tag :color="FEEDBACK_PRIORITY_COLOR[row.priority ?? 2] || 'default'">
|
||||||
|
{{ FEEDBACK_PRIORITY_LABEL[row.priority ?? 2] || '-' }}
|
||||||
|
</Tag>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action="{ row }">
|
||||||
|
<Button type="link" size="small" @click="openDetail(row)">详情</Button>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<FeedbackCreateModal ref="createModalRef" @success="onCreateSuccess" />
|
||||||
|
|
||||||
|
<FeedbackDetailDrawer
|
||||||
|
v-model:open="detailOpen"
|
||||||
|
:feedback-id="detailId"
|
||||||
|
mode="user"
|
||||||
|
@changed="() => gridApi.reload()"
|
||||||
|
/>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
import type { UserDTO, UserVO } from '#/api/sys/user/types';
|
import type { UserDTO, UserVO } from '#/api/sys/user/types';
|
||||||
|
|
||||||
import { computed, reactive, ref } from 'vue';
|
import { computed, reactive, ref } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
import { Page } from '@vben/common-ui';
|
||||||
|
|
||||||
@@ -13,6 +14,8 @@ import { uploadFile } from '#/utils/upload-file';
|
|||||||
|
|
||||||
defineOptions({ name: 'PersonalProfile' });
|
defineOptions({ name: 'PersonalProfile' });
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const submitting = ref(false);
|
const submitting = ref(false);
|
||||||
const userInfo = ref<UserVO.UserInfoVO | null>(null);
|
const userInfo = ref<UserVO.UserInfoVO | null>(null);
|
||||||
@@ -141,12 +144,19 @@ fetchUserInfo();
|
|||||||
>
|
>
|
||||||
<!-- 头部 -->
|
<!-- 头部 -->
|
||||||
<div class="border-b border-slate-100 bg-slate-50/50 px-8 py-6 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/30%)]">
|
<div class="border-b border-slate-100 bg-slate-50/50 px-8 py-6 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/30%)]">
|
||||||
<h2 class="text-xl font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
<div class="flex items-start justify-between gap-3">
|
||||||
个人信息
|
<div>
|
||||||
</h2>
|
<h2 class="text-xl font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||||
<p class="mt-1 text-sm text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
个人信息
|
||||||
编辑您的个人信息和头像
|
</h2>
|
||||||
</p>
|
<p class="mt-1 text-sm text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||||
|
编辑您的个人信息和头像
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Button type="link" class="!px-0" @click="router.push('/feedback')">
|
||||||
|
意见反馈
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 表单 -->
|
<!-- 表单 -->
|
||||||
|
|||||||
Reference in New Issue
Block a user