|
|
@@ -0,0 +1,220 @@
|
|
|
+<template>
|
|
|
+ <div class="p-2">
|
|
|
+ <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
|
|
+ <div v-show="showSearch" class="mb-[10px]">
|
|
|
+ <el-card shadow="hover">
|
|
|
+ <el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
|
|
+ <el-form-item label="用户昵称" prop="nickname">
|
|
|
+ <el-input v-model="queryParams.nickname" placeholder="请输入用户昵称" clearable @keyup.enter="handleQuery" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="手机号" prop="phone">
|
|
|
+ <el-input v-model="queryParams.phone" placeholder="请输入手机号" clearable @keyup.enter="handleQuery" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="反馈内容" prop="content">
|
|
|
+ <el-input v-model="queryParams.content" placeholder="请输入反馈内容" clearable @keyup.enter="handleQuery" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
|
|
+ <el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
+ </transition>
|
|
|
+
|
|
|
+ <el-card shadow="hover">
|
|
|
+ <template #header>
|
|
|
+ <el-row :gutter="10">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button v-hasPermi="['miniapp:feedback:remove']" type="danger" plain icon="Delete" :disabled="multiple" @click="handleDeleteSelected">删除</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button v-hasPermi="['miniapp:feedback:export']" type="warning" plain icon="Download" @click="handleExport">导出</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button type="info" plain icon="Refresh" @click="handleRefresh" :loading="refreshing">刷新</el-button>
|
|
|
+ </el-col>
|
|
|
+ <right-toolbar v-model:show-search="showSearch" @query-table="getList"></right-toolbar>
|
|
|
+ </el-row>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <el-table v-loading="loading" border :data="dataList" stripe @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
+ <el-table-column label="反馈ID" align="center" prop="id" width="80" />
|
|
|
+ <el-table-column label="用户昵称" align="center" prop="nickname" :show-overflow-tooltip="true" />
|
|
|
+ <el-table-column label="手机号" align="center" prop="phone" width="120" />
|
|
|
+ <el-table-column label="反馈内容" align="center" prop="content" :show-overflow-tooltip="true" min-width="200" />
|
|
|
+ <el-table-column label="图片" align="center" width="100">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button v-if="scope.row.images" link type="primary" @click="handleViewImages(scope.row)">查看图片</el-button>
|
|
|
+ <span v-else class="text-gray-400">无</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="创建时间" align="center" prop="createTime" width="170" />
|
|
|
+ <el-table-column label="操作" align="center" width="80">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-tooltip content="删除" placement="top">
|
|
|
+ <el-button v-hasPermi="['miniapp:feedback:remove']" link type="danger" icon="Delete" @click="handleDelete(scope.row)"></el-button>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <pagination
|
|
|
+ v-show="total > 0"
|
|
|
+ v-model:page="queryParams.pageNum"
|
|
|
+ v-model:limit="queryParams.pageSize"
|
|
|
+ :total="total"
|
|
|
+ @pagination="getList"
|
|
|
+ />
|
|
|
+ </el-card>
|
|
|
+
|
|
|
+ <!-- 图片预览对话框 -->
|
|
|
+ <el-dialog v-model="imageDialogVisible" title="反馈图片" width="800px">
|
|
|
+ <div class="image-preview-container">
|
|
|
+ <el-image
|
|
|
+ v-for="(image, index) in currentImages"
|
|
|
+ :key="index"
|
|
|
+ :src="image"
|
|
|
+ :preview-src-list="currentImages"
|
|
|
+ :initial-index="index"
|
|
|
+ fit="cover"
|
|
|
+ class="preview-image"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup name="MiniappFeedback" lang="ts">
|
|
|
+import { ref, onMounted, getCurrentInstance } from 'vue';
|
|
|
+import { listFeedback, getFeedback, delFeedback } from '@/api/miniapp/feedback';
|
|
|
+import request from '@/utils/request';
|
|
|
+
|
|
|
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
+
|
|
|
+const dataList = ref<any[]>([]);
|
|
|
+const loading = ref(true);
|
|
|
+const refreshing = ref(false);
|
|
|
+const showSearch = ref(true);
|
|
|
+const total = ref(0);
|
|
|
+const ids = ref<number[]>([]);
|
|
|
+const multiple = ref(true);
|
|
|
+const imageDialogVisible = ref(false);
|
|
|
+const currentImages = ref<string[]>([]);
|
|
|
+
|
|
|
+const queryFormRef = ref<ElFormInstance>();
|
|
|
+
|
|
|
+const queryParams = ref({
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ nickname: '',
|
|
|
+ phone: '',
|
|
|
+ content: ''
|
|
|
+});
|
|
|
+
|
|
|
+/** 查询列表 */
|
|
|
+const getList = async () => {
|
|
|
+ loading.value = true;
|
|
|
+ try {
|
|
|
+ const res = await request.get('/miniapp/feedback/list', { params: queryParams.value });
|
|
|
+ dataList.value = res.rows || [];
|
|
|
+ total.value = res.total || 0;
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取反馈列表失败:', error);
|
|
|
+ } finally {
|
|
|
+ loading.value = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 手动刷新 */
|
|
|
+const handleRefresh = async () => {
|
|
|
+ refreshing.value = true;
|
|
|
+ try {
|
|
|
+ await getList();
|
|
|
+ } finally {
|
|
|
+ refreshing.value = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 搜索 */
|
|
|
+const handleQuery = () => {
|
|
|
+ queryParams.value.pageNum = 1;
|
|
|
+ getList();
|
|
|
+};
|
|
|
+
|
|
|
+/** 重置 */
|
|
|
+const resetQuery = () => {
|
|
|
+ queryFormRef.value?.resetFields();
|
|
|
+ handleQuery();
|
|
|
+};
|
|
|
+
|
|
|
+/** 多选框选中数据 */
|
|
|
+const handleSelectionChange = (selection: any[]) => {
|
|
|
+ ids.value = selection.map(item => item.id);
|
|
|
+ multiple.value = !selection.length;
|
|
|
+};
|
|
|
+
|
|
|
+/** 查看图片 */
|
|
|
+const handleViewImages = (row: any) => {
|
|
|
+ if (row.images) {
|
|
|
+ // 将逗号分隔的图片URL转换为数组
|
|
|
+ currentImages.value = row.images.split(',').map((url: string) => {
|
|
|
+ // 如果是相对路径,拼接小程序后端代理路径
|
|
|
+ if (url.startsWith('/')) {
|
|
|
+ return '/miniapp-api' + url;
|
|
|
+ }
|
|
|
+ return url;
|
|
|
+ });
|
|
|
+ imageDialogVisible.value = true;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 删除按钮(工具栏) */
|
|
|
+const handleDeleteSelected = async () => {
|
|
|
+ try {
|
|
|
+ await proxy?.$modal.confirm(`确认要删除选中的${ids.value.length}条反馈记录吗?`);
|
|
|
+ await request.delete(`/miniapp/feedback/${ids.value.join(',')}`);
|
|
|
+ proxy?.$modal.msgSuccess('删除成功');
|
|
|
+ getList();
|
|
|
+ } catch {
|
|
|
+ // 取消操作
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 删除 */
|
|
|
+const handleDelete = async (row: any) => {
|
|
|
+ try {
|
|
|
+ await proxy?.$modal.confirm(`确认要删除该反馈记录吗?`);
|
|
|
+ await request.delete(`/miniapp/feedback/${row.id}`);
|
|
|
+ proxy?.$modal.msgSuccess('删除成功');
|
|
|
+ getList();
|
|
|
+ } catch {
|
|
|
+ // 取消操作
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 导出 */
|
|
|
+const handleExport = () => {
|
|
|
+ proxy?.download('miniapp/feedback/export', { ...queryParams.value }, `feedback_${new Date().getTime()}.xlsx`);
|
|
|
+};
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getList();
|
|
|
+});
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.image-preview-container {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ gap: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.preview-image {
|
|
|
+ width: 150px;
|
|
|
+ height: 150px;
|
|
|
+ cursor: pointer;
|
|
|
+ border-radius: 4px;
|
|
|
+}
|
|
|
+</style>
|