Forráskód Böngészése

feat(system): 添加用户申诉管理功能

- 新增用户申诉管理页面和相关 API
- 实现用户申诉列表查询、详情查看、处理和删除功能
- 添加申诉状态字典和时间范围筛选功能- 优化历史记录页面查询逻辑
fugui001 4 hónapja
szülő
commit
5a16873eaf

+ 62 - 0
src/api/system/business/complaints/index.ts

@@ -0,0 +1,62 @@
+import request from '@/utils/request';
+import { AxiosPromise } from 'axios';
+import { ComplaintsVO, ComplaintsForm, ComplaintsQuery } from '@/api/system/business/complaints/types';
+
+/**
+ * 查询用户申诉列表
+ * @param query
+ * @returns {*}
+ */
+export const listComplaints = (query?: ComplaintsQuery): AxiosPromise<ComplaintsVO[]> => {
+  return request({
+    url: '/business/complaints/list',
+    method: 'get',
+    params: query
+  });
+};
+
+/**
+ * 查询用户申诉详细
+ * @param id
+ */
+export const getComplaints = (id: string | number): AxiosPromise<ComplaintsVO> => {
+  return request({
+    url: '/business/complaints/' + id,
+    method: 'get'
+  });
+};
+
+/**
+ * 新增用户申诉
+ * @param data
+ */
+export const addComplaints = (data: ComplaintsForm) => {
+  return request({
+    url: '/business/complaints',
+    method: 'post',
+    data: data
+  });
+};
+
+/**
+ * 修改用户申诉
+ * @param data
+ */
+export const updateComplaints = (data: ComplaintsForm) => {
+  return request({
+    url: '/business/complaints',
+    method: 'put',
+    data: data
+  });
+};
+
+/**
+ * 删除用户申诉
+ * @param id
+ */
+export const delComplaints = (id: string | number | Array<string | number>) => {
+  return request({
+    url: '/business/complaints/' + id,
+    method: 'delete'
+  });
+};

+ 152 - 0
src/api/system/business/complaints/types.ts

@@ -0,0 +1,152 @@
+export interface ComplaintsVO {
+  /**
+   *
+   */
+  id: string | number;
+
+  /**
+   * 申诉用户
+   */
+  userId: string | number;
+
+  /**
+   * 比赛ID
+   */
+  tournamentId: string | number;
+
+  /**
+   * 最终名次
+   */
+  finalRank: number;
+
+  /**
+   * 申述原因
+   */
+  complaintReason: string;
+
+  /**
+   * 创建时间/申述时间
+   */
+  createAt: string;
+
+  /**
+   * 修改时间/处理时间
+   */
+  updateAt: string;
+
+  /**
+   * '1申诉中', '2已处理', '3不处理'
+   */
+  status: number;
+
+  /**
+   * 申诉状态
+   */
+  statusText: string;
+}
+
+export interface ComplaintsForm extends BaseEntity {
+  /**
+   *
+   */
+  id?: string | number;
+
+  /**
+   * 申诉用户
+   */
+  userId?: string | number;
+
+  /**
+   * 比赛ID
+   */
+  tournamentId?: string | number;
+
+  /**
+   * 最终名次
+   */
+  finalRank?: number;
+
+  /**
+   * 申述原因
+   */
+  complaintReason?: string;
+
+  /**
+   * 创建时间/申述时间
+   */
+  createAt?: string;
+
+  /**
+   * 修改时间/处理时间
+   */
+  updateAt?: string;
+
+  /**
+   * '1申诉中', '2已处理', '3不处理'
+   */
+  status?: number;
+
+  /**
+   * 申诉状态
+   */
+  statusText?: string;
+  /**
+   * 处理建议
+   */
+  advice?: string;
+
+  operateName?: string;
+}
+
+export interface ComplaintsQuery extends PageQuery {
+  /**
+   * 申诉用户
+   */
+  userId?: string | number;
+
+  /**
+   * 比赛ID
+   */
+  tournamentId?: string | number;
+
+  /**
+   * 最终名次
+   */
+  finalRank?: number;
+
+  /**
+   * 申述原因
+   */
+  complaintReason?: string;
+
+  /**
+   * 创建时间/申述时间
+   */
+  createAt?: string;
+
+  /**
+   * 修改时间/处理时间
+   */
+  updateAt?: string;
+
+  /**
+   * '1申诉中', '2已处理', '3不处理'
+   */
+  status?: number;
+
+  /**
+   * 申诉状态
+   */
+  statusText?: string;
+
+  /**
+   * 日期范围参数
+   */
+  params?: any;
+
+  userIds?: string;
+
+  complaintTimeRange?: string;
+  tournamentBeginTime?: string;
+  tournamentEndTime?: string;
+}

+ 314 - 0
src/views/system/business/complaints/index.vue

@@ -0,0 +1,314 @@
+<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="userIds">
+              <el-input v-model="queryParams.userIds" placeholder="请输入用户名/手机号" clearable @keyup.enter="handleQuery" />
+            </el-form-item>
+
+            <el-form-item label="申诉状态" prop="status">
+              <el-select aria-required="true" v-model="queryParams.status" placeholder="请选择">
+                <el-option v-for="dict in complaints_status" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
+              </el-select>
+            </el-form-item>
+
+            <el-form-item label="申诉时间">
+              <el-date-picker
+                v-model="data.queryParams.complaintTimeRange"
+                type="datetimerange"
+                range-separator="至"
+                start-placeholder="开始时间"
+                end-placeholder="结束时间"
+                value-format="YYYY-MM-DD HH:mm:ss"
+                format="YYYY-MM-DD HH:mm:ss"
+              />
+            </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="never">
+      <!--      <template #header>
+        <el-row :gutter="10" class="mb8">
+          <el-col :span="1.5">
+            <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:complaints:add']">新增</el-button>
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:complaints:edit']"
+              >修改</el-button
+            >
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:complaints:remove']"
+              >删除</el-button
+            >
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:complaints:export']">导出</el-button>
+          </el-col>
+          <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
+        </el-row>
+      </template>-->
+
+      <el-table v-loading="loading" border :data="complaintsList" @selection-change="handleSelectionChange">
+        <el-table-column label="序号" width="60" align="center">
+          <template #default="{ $index }">
+            {{ $index + 1 + (queryParams.pageNum - 1) * queryParams.pageSize }}
+          </template>
+        </el-table-column>
+        <!--        <el-table-column label="" align="center" prop="id" v-if="false" />-->
+        <el-table-column label="用户名" align="center" prop="nickName" />
+        <el-table-column label="用户手机号" align="center" prop="phone" />
+        <el-table-column label="所属比赛" align="center" prop="tournamentName" />
+        <el-table-column label="最终名次" align="center" prop="finalRank" />
+        <el-table-column label="申述原因" align="center" prop="complaintReason" />
+        <el-table-column label="申述时间" align="center" prop="createAt" width="180">
+          <template #default="scope">
+            <span>{{ parseTime(scope.row.createAt, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="处理时间" align="center" prop="updateAt" width="180">
+          <template #default="scope">
+            <span>{{ parseTime(scope.row.updateAt, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="申诉状态" align="center" prop="statusText" />
+        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+          <template #default="scope">
+            <el-tooltip content="查看比赛结果" placement="top">
+              <el-button link type="primary" icon="View" v-hasPermi="['system:complaints:edit']"> 查看比赛结果 </el-button>
+            </el-tooltip>
+            <!-- status 为 1:显示“处理”按钮 -->
+            <el-tooltip v-if="scope.row.status === 1" content="处理" placement="top">
+              <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:complaints:edit']"> 处理 </el-button>
+            </el-tooltip>
+
+            <!-- status 为 2 或 3:显示“查看处理结果”按钮 -->
+            <el-tooltip v-else content="处理结果" placement="top">
+              <el-button link type="primary" icon="View" @click="handleUpdate2(scope.row)" v-hasPermi="['system:complaints:edit']">
+                处理结果
+              </el-button>
+            </el-tooltip>
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
+    </el-card>
+    <!-- 添加或修改用户申诉对话框 -->
+    <!-- 添加或修改用户申诉对话框 -->
+    <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
+      <el-form ref="complaintsFormRef" :model="form" :rules="rules" label-width="80px">
+        <el-form-item label="申诉状态" prop="advice">
+          <el-select v-model="form.status" placeholder="处理结果" clearable :disabled="dialog.title === '处理结果'">
+            <el-option label="已处理" :value="2" />
+            <el-option label="不处理" :value="3" />
+          </el-select>
+        </el-form-item>
+        <!-- 查看处理结果时显示处理人和处理时间 -->
+        <template v-if="dialog.title === '处理结果'">
+          <el-form-item label="处理人" prop="operateName"> <el-input v-model="form.operateName" disabled /> </el-form-item>
+          <el-form-item label="处理时间" prop="updateAt"> <el-input v-model="form.updateAt" disabled /> </el-form-item>
+        </template>
+        <!-- 处理建议 - 文本域 -->
+        <el-form-item label="处理建议" prop="advice">
+          <el-input
+            v-model="form.advice"
+            type="textarea"
+            :rows="4"
+            :autosize="{ minRows: 4, maxRows: 8 }"
+            placeholder="请输入处理建议,最多200字"
+            maxlength="200"
+            show-word-limit
+            :disabled="dialog.title === '处理结果'"
+          />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button :loading="buttonLoading" type="primary" @click="submitForm" v-if="dialog.title !== '处理结果'">确 定</el-button>
+          <el-button @click="cancel">取 消</el-button>
+        </div>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script setup name="Complaints" lang="ts">
+import { listComplaints, getComplaints, delComplaints, addComplaints, updateComplaints } from '@/api/system/business/complaints';
+import { ComplaintsVO, ComplaintsQuery, ComplaintsForm } from '@/api/system/business/complaints/types';
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
+const { complaints_status } = toRefs<any>(proxy?.useDict('complaints_status'));
+
+const complaintsList = ref<ComplaintsVO[]>([]);
+const buttonLoading = ref(false);
+const loading = ref(true);
+const showSearch = ref(true);
+const ids = ref<Array<string | number>>([]);
+const single = ref(true);
+const multiple = ref(true);
+const total = ref(0);
+
+const queryFormRef = ref<ElFormInstance>();
+const complaintsFormRef = ref<ElFormInstance>();
+
+const dialog = reactive<DialogOption>({
+  visible: false,
+  title: ''
+});
+
+const initFormData: ComplaintsForm = {
+  id: undefined,
+  userId: undefined,
+  tournamentId: undefined,
+  finalRank: undefined,
+  complaintReason: undefined,
+  createAt: undefined,
+  updateAt: undefined,
+  status: 2,
+  statusText: undefined
+};
+const data = reactive<PageData<ComplaintsForm, ComplaintsQuery>>({
+  form: { ...initFormData },
+  queryParams: {
+    pageNum: 1,
+    pageSize: 10,
+    userId: undefined,
+    tournamentId: undefined,
+    finalRank: undefined,
+    complaintReason: undefined,
+    createAt: undefined,
+    updateAt: undefined,
+    status: undefined,
+    statusText: undefined,
+    params: {}
+  },
+  rules: {
+    id: [{ required: true, message: '不能为空', trigger: 'blur' }]
+  }
+});
+
+const { queryParams, form, rules } = toRefs(data);
+
+/** 查询用户申诉列表 */
+const getList = async () => {
+  loading.value = true;
+  const res = await listComplaints(queryParams.value);
+  complaintsList.value = res.rows;
+  total.value = res.total;
+  loading.value = false;
+};
+
+/** 取消按钮 */
+const cancel = () => {
+  reset();
+  dialog.visible = false;
+};
+
+/** 表单重置 */
+const reset = () => {
+  form.value = { ...initFormData };
+  complaintsFormRef.value?.resetFields();
+};
+
+/** 搜索按钮操作 */
+const handleQuery = () => {
+  queryParams.value.pageNum = 1;
+  const timeRange = data.queryParams.complaintTimeRange;
+  if (timeRange && timeRange.length === 2) {
+    data.queryParams.tournamentBeginTime = timeRange[0];
+    data.queryParams.tournamentEndTime = timeRange[1];
+  } else {
+    data.queryParams.tournamentBeginTime = null;
+    data.queryParams.tournamentEndTime = null;
+  }
+  getList();
+};
+
+/** 重置按钮操作 */
+const resetQuery = () => {
+  queryFormRef.value?.resetFields();
+  handleQuery();
+};
+
+/** 多选框选中数据 */
+const handleSelectionChange = (selection: ComplaintsVO[]) => {
+  ids.value = selection.map((item) => item.id);
+  single.value = selection.length != 1;
+  multiple.value = !selection.length;
+};
+
+/** 新增按钮操作 */
+const handleAdd = () => {
+  reset();
+  dialog.visible = true;
+  dialog.title = '处理结果';
+};
+
+/** 修改按钮操作 */
+const handleUpdate = async (row?: ComplaintsVO) => {
+  reset();
+  const _id = row?.id || ids.value[0];
+  const res = await getComplaints(_id);
+  Object.assign(form.value, res.data);
+  dialog.visible = true;
+  dialog.title = '处理申诉';
+};
+const handleUpdate2 = async (row?: ComplaintsVO) => {
+  reset();
+  const _id = row?.id || ids.value[0];
+  const res = await getComplaints(_id);
+  Object.assign(form.value, res.data);
+  dialog.visible = true;
+  dialog.title = '处理结果';
+};
+
+/** 提交按钮 */
+const submitForm = () => {
+  complaintsFormRef.value?.validate(async (valid: boolean) => {
+    if (valid) {
+      buttonLoading.value = true;
+      if (form.value.id) {
+        await updateComplaints(form.value).finally(() => (buttonLoading.value = false));
+      } else {
+        await addComplaints(form.value).finally(() => (buttonLoading.value = false));
+      }
+      proxy?.$modal.msgSuccess('操作成功');
+      dialog.visible = false;
+      await getList();
+    }
+  });
+};
+
+/** 删除按钮操作 */
+const handleDelete = async (row?: ComplaintsVO) => {
+  const _ids = row?.id || ids.value;
+  await proxy?.$modal.confirm('是否确认删除用户申诉编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
+  await delComplaints(_ids);
+  proxy?.$modal.msgSuccess('删除成功');
+  await getList();
+};
+
+/** 导出按钮操作 */
+const handleExport = () => {
+  proxy?.download(
+    'system/complaints/export',
+    {
+      ...queryParams.value
+    },
+    `complaints_${new Date().getTime()}.xlsx`
+  );
+};
+
+onMounted(() => {
+  getList();
+});
+</script>

+ 30 - 6
src/views/system/business/history/index.vue

@@ -342,10 +342,8 @@ const getList = async () => {
   }
   loading.value = true;
   if (queryParams.value.startLateRegistrationLevel != undefined && queryParams.value.startLateRegistrationLevel != null) {
-    debugger;
     queryParams.value.blindStructureId = blindStructureId.value;
   } else {
-    debugger;
     queryParams.value.blindStructureId = null;
   }
 
@@ -366,7 +364,7 @@ const getList = async () => {
   }
 
   if (res.rows && res.rows.length > 0 && res.rows[0]?.handStartTime) {
-    beginTimeOrEndTime.value = res.rows[0].handStartTime + '-' + res.rows[0].handEndTime;
+    beginTimeOrEndTime.value = res.rows[0].handStartTime + ' ~ ' + res.rows[0].handEndTime;
   } else {
     beginTimeOrEndTime.value = '';
   }
@@ -406,6 +404,26 @@ const reset = () => {
   historyFormRef.value?.resetFields();
 };
 
+const resetQueryParams = () => {
+/*  const defaults = {
+    pageNum: 1,
+    pageSize: 10,
+    handId: undefined,
+    //tournamentId: undefined,
+    involvedPlayers: undefined,
+    handNumber: undefined,
+    boardCards: undefined,
+    totalPot: undefined,
+    handStartTime: undefined,
+    handEndTime: undefined,
+    handDetails: undefined,
+    createdAt: undefined,
+    historyId: undefined,
+    params: {},
+    playerNameOrId: undefined
+  };
+  Object.assign(data.queryParams, defaults);*/
+};
 /** 搜索按钮操作 */
 const handleQuery = () => {
   queryParams.value.pageNum = 1;
@@ -511,6 +529,7 @@ const getTableData = async (playerId: string | number, tournamentId: string | nu
         selectedTableHandNumberId.value = firstHandTable.handNumber;
         if (!isNaN(playerIdNum)) {
           queryParams.value.historyId = firstHandTable.id;
+          queryParams.value.handId = null;
         } else {
           //拼接handId
           const tid = tournamentId ?? 'unknown';
@@ -524,6 +543,8 @@ const getTableData = async (playerId: string | number, tournamentId: string | nu
         }
         queryParams.value.tournamentId = String(tournamentId);
       }
+    } else {
+      resetQueryParams();
     }
     /*   } else {
       console.error('Invalid playerId or tournamentId');
@@ -729,12 +750,16 @@ const handlePlayerSearch = async () => {
             queryParams.value.historyId = null;
           }
         }
+        // 刷新历史列表
+        await getList();
       } else {
         tableNumberData.value = [];
+        historyList.value = [];
+        resetQueryParams();
       }
-      // 刷新历史列表
-      await getList();
     } else {
+      historyList.value = [];
+      //resetQueryParams();
       proxy?.$modal.msgError('获取桌次数据失败');
     }
   } catch (error) {
@@ -776,7 +801,6 @@ const handleBlindStructureChange = async (value: number) => {
 
       for (let i = 0; i < data.length; i++) {
         const item = data[i];
-        debugger;
         let smallBlind=item.smallBlind;
         let bigBlind=item.bigBlind;
         let ante=item.ante;