mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 23:49:19 +08:00
feat: 新增意见反馈功能
This commit is contained in:
@@ -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 UserIcon = createIconifyIcon('lucide:user');
|
||||
// 意见反馈图标
|
||||
const FeedbackIcon = createIconifyIcon('lucide:message-square-plus');
|
||||
// 锁图标
|
||||
const LockIcon = createIconifyIcon('lucide:lock');
|
||||
|
||||
@@ -104,6 +106,14 @@ const menus = computed(() => {
|
||||
icon: UserIcon,
|
||||
text: '个人信息',
|
||||
});
|
||||
// 意见反馈
|
||||
menuItems.push({
|
||||
handler: () => {
|
||||
router.push('/feedback');
|
||||
},
|
||||
icon: FeedbackIcon,
|
||||
text: '意见反馈',
|
||||
});
|
||||
// 修改密码
|
||||
menuItems.push({
|
||||
handler: () => {
|
||||
|
||||
@@ -111,6 +111,7 @@ const ReceiptIcon = createIconifyIcon('lucide:receipt');
|
||||
const CalendarIcon = createIconifyIcon('lucide:calendar');
|
||||
const RefreshIcon = createIconifyIcon('lucide:refresh-cw');
|
||||
const CheckIcon = createIconifyIcon('lucide:check');
|
||||
const FeedbackIcon = createIconifyIcon('lucide:message-square-plus');
|
||||
|
||||
/** 快捷区间 + 自定义 RangePicker */
|
||||
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
||||
@@ -850,6 +851,23 @@ onUnmounted(() => {
|
||||
@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
|
||||
trigger="click"
|
||||
: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 { computed, reactive, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
@@ -13,6 +14,8 @@ import { uploadFile } from '#/utils/upload-file';
|
||||
|
||||
defineOptions({ name: 'PersonalProfile' });
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const loading = ref(false);
|
||||
const submitting = ref(false);
|
||||
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%)]">
|
||||
<h2 class="text-xl font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
个人信息
|
||||
</h2>
|
||||
<p class="mt-1 text-sm text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
编辑您的个人信息和头像
|
||||
</p>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<h2 class="text-xl font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
个人信息
|
||||
</h2>
|
||||
<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>
|
||||
|
||||
<!-- 表单 -->
|
||||
|
||||
Reference in New Issue
Block a user