index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. <template>
  2. <div class="p-2">
  3. <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
  4. <div v-show="showSearch" class="mb-[10px]">
  5. <el-card shadow="hover">
  6. <el-form ref="queryFormRef" :model="queryParams" :inline="true">
  7. <el-form-item label="" prop="userIds">
  8. <el-input v-model="queryParams.userIds" placeholder="请输入用户名/手机号" clearable @keyup.enter="handleQuery" />
  9. </el-form-item>
  10. <el-form-item label="申诉状态" prop="status">
  11. <el-select aria-required="true" v-model="queryParams.status" placeholder="请选择">
  12. <el-option v-for="dict in complaints_status" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="申诉时间">
  16. <el-date-picker
  17. v-model="data.queryParams.complaintTimeRange"
  18. type="datetimerange"
  19. range-separator="至"
  20. start-placeholder="开始时间"
  21. end-placeholder="结束时间"
  22. value-format="YYYY-MM-DD HH:mm:ss"
  23. format="YYYY-MM-DD HH:mm:ss"
  24. />
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  28. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  29. </el-form-item>
  30. </el-form>
  31. </el-card>
  32. </div>
  33. </transition>
  34. <el-card shadow="never">
  35. <!-- <template #header>
  36. <el-row :gutter="10" class="mb8">
  37. <el-col :span="1.5">
  38. <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:complaints:add']">新增</el-button>
  39. </el-col>
  40. <el-col :span="1.5">
  41. <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:complaints:edit']"
  42. >修改</el-button
  43. >
  44. </el-col>
  45. <el-col :span="1.5">
  46. <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:complaints:remove']"
  47. >删除</el-button
  48. >
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:complaints:export']">导出</el-button>
  52. </el-col>
  53. <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
  54. </el-row>
  55. </template>-->
  56. <el-table v-loading="loading" border :data="complaintsList" @selection-change="handleSelectionChange">
  57. <el-table-column label="序号" width="60" align="center">
  58. <template #default="{ $index }">
  59. {{ $index + 1 + (queryParams.pageNum - 1) * queryParams.pageSize }}
  60. </template>
  61. </el-table-column>
  62. <!-- <el-table-column label="" align="center" prop="id" v-if="false" />-->
  63. <el-table-column label="用户名" align="center" prop="nickName" />
  64. <el-table-column label="用户手机号" align="center" prop="phone" />
  65. <el-table-column label="所属比赛" align="center" prop="tournamentName" />
  66. <el-table-column label="最终名次" align="center" prop="finalRank" />
  67. <el-table-column label="申述原因" align="center" prop="complaintReason" />
  68. <el-table-column label="申述时间" align="center" prop="createAt" width="180">
  69. <template #default="scope">
  70. <span>{{ parseTime(scope.row.createAt, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="处理时间" align="center" prop="updateAt" width="180">
  74. <template #default="scope">
  75. <span>{{ parseTime(scope.row.updateAt, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="申诉状态" align="center" prop="statusText" />
  79. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  80. <template #default="scope">
  81. <el-tooltip content="查看比赛结果" placement="top">
  82. <el-button link type="primary" icon="View" @click="handleSeeRank(scope.row)" v-hasPermi="['business:complaints:query']">
  83. 查看比赛结果
  84. </el-button>
  85. </el-tooltip>
  86. <!-- status 为 1:显示“处理”按钮 -->
  87. <el-tooltip v-if="scope.row.status === 1" content="处理" placement="top">
  88. <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['business:complaints:edit']"> 处理 </el-button>
  89. </el-tooltip>
  90. <!-- status 为 2 或 3:显示“查看处理结果”按钮 -->
  91. <el-tooltip v-else content="处理结果" placement="top">
  92. <el-button link type="primary" icon="View" @click="handleUpdate2(scope.row)" v-hasPermi="['business:complaints:edit']">
  93. 处理结果
  94. </el-button>
  95. </el-tooltip>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
  100. </el-card>
  101. <!-- 添加或修改用户申诉对话框 -->
  102. <!-- 添加或修改用户申诉对话框 -->
  103. <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
  104. <el-form ref="complaintsFormRef" :model="form" :rules="rules" label-width="80px">
  105. <el-form-item label="申诉状态" prop="advice">
  106. <el-select v-model="form.status" placeholder="处理结果" clearable :disabled="dialog.title === '处理结果'">
  107. <el-option label="已处理" :value="2" />
  108. <el-option label="不处理" :value="3" />
  109. </el-select>
  110. </el-form-item>
  111. <!-- 查看处理结果时显示处理人和处理时间 -->
  112. <template v-if="dialog.title === '处理结果'">
  113. <el-form-item label="处理人" prop="operateName"> <el-input v-model="form.operateName" disabled /> </el-form-item>
  114. <el-form-item label="处理时间" prop="updateAt"> <el-input v-model="form.updateAt" disabled /> </el-form-item>
  115. </template>
  116. <!-- 处理建议 - 文本域 -->
  117. <el-form-item label="处理建议" prop="advice">
  118. <el-input
  119. v-model="form.advice"
  120. type="textarea"
  121. :rows="4"
  122. :autosize="{ minRows: 4, maxRows: 8 }"
  123. placeholder="请输入处理建议,最多200字"
  124. maxlength="200"
  125. show-word-limit
  126. :disabled="dialog.title === '处理结果'"
  127. />
  128. </el-form-item>
  129. </el-form>
  130. <template #footer>
  131. <div class="dialog-footer">
  132. <el-button :loading="buttonLoading" type="primary" @click="submitForm" v-if="dialog.title !== '处理结果'">确 定</el-button>
  133. <el-button @click="cancel">取 消</el-button>
  134. </div>
  135. </template>
  136. </el-dialog>
  137. <el-dialog
  138. :title="`${tournamentInfo.name} ${tournamentInfo.tournamentsBiId}`"
  139. v-model="auditDialog.visible"
  140. width="1000px"
  141. append-to-body
  142. @close="cancelAudit"
  143. >
  144. <!-- 查看对局记录按钮 -->
  145. <!-- <div class="dialog-header-actions" v-if="auditDialog.mode === 'view'">
  146. <el-button type="primary">查看对局记录</el-button>
  147. </div>-->
  148. <!-- 比赛信息展示 -->
  149. <div class="tournament-info" v-if="tournamentInfo.id">
  150. <p>比赛时间:{{ tournamentInfo.startTime }} ~ {{ tournamentInfo.endTime }}</p>
  151. <p>参加人数:{{ tournamentInfo.signNum }}人</p>
  152. <p v-if="tournamentInfo.isComplaints" style="color: red">本场比赛仍有选手存在异议,请处理申述后继续授作。</p>
  153. <!-- <p>比赛类型:{{ tournamentInfo.id }}</p>
  154. <p>报名条件:{{ tournamentInfo.itemsName }} x {{ tournamentInfo.itemsNum }}</p>
  155. <p>盲注表:{{ tournamentInfo.blindStructuresName }}</p>
  156. <p>报名截止等级:{{ tournamentInfo.lateRegistrationLevel }}</p>-->
  157. </div>
  158. <!-- 表格内容 -->
  159. <el-table :data="auditData" border style="width: 100%">
  160. <el-table-column prop="id" label="id" align="center" v-if="false"></el-table-column>
  161. <el-table-column prop="rank" label="排名" align="center"></el-table-column>
  162. <el-table-column prop="playerName" label="用户名" align="center"></el-table-column>
  163. <el-table-column prop="phone" label="手机" align="center"></el-table-column>
  164. <el-table-column label="奖励" align="center">
  165. <template #default="scope">
  166. <div v-for="(prize, index) in scope.row.rewardVoList" :key="index">{{ prize.itemName }} {{ prize.quantity }}</div>
  167. </template>
  168. </el-table-column>
  169. <el-table-column label="状态" align="center">
  170. <template #default="scope">
  171. <!-- 只有 claimedText 存在时才显示 -->
  172. <el-tag v-if="scope.row.claimedText" :type="scope.row.claimed === 3 ? 'danger' : 'primary'" size="small">
  173. {{ scope.row.claimedText }}
  174. </el-tag>
  175. <!-- 否则显示空 -->
  176. </template>
  177. </el-table-column>
  178. <el-table-column label="操作" align="center" width="350" class-name="small-padding fixed-width">
  179. <template #default="scope">
  180. <div style="display: flex; justify-content: center; gap: 16px">
  181. <el-tooltip content="查看牌局" placement="top">
  182. <el-button link type="primary" icon="View" @click="handleViewHistory(scope.row)">查看牌局</el-button>
  183. </el-tooltip>
  184. </div>
  185. </template>
  186. </el-table-column>
  187. </el-table>
  188. <!-- 分页组件 -->
  189. <div class="pagination-container" style="margin-top: 20px; text-align: center">
  190. <el-pagination
  191. v-model:current-page="auditQueryParams.pageNum"
  192. v-model:page-size="auditQueryParams.pageSize"
  193. :total="auditTotal"
  194. layout="prev, pager, next"
  195. @current-change="getAuditData"
  196. />
  197. </div>
  198. <!-- 对话框底部按钮 -->
  199. <template #footer>
  200. <div class="dialog-footer">
  201. <el-button @click="cancelAudit">取 消</el-button>
  202. </div>
  203. </template>
  204. </el-dialog>
  205. </div>
  206. </template>
  207. <script setup name="Complaints" lang="ts">
  208. import {
  209. listComplaints,
  210. getComplaints,
  211. delComplaints,
  212. addComplaints,
  213. updateComplaints,
  214. getAllUserRankByTournamentId
  215. } from '@/api/system/business/complaints';
  216. import { ComplaintsVO, ComplaintsQuery, ComplaintsForm } from '@/api/system/business/complaints/types';
  217. import { ref } from 'vue';
  218. import { TournamentsVO } from '@/api/system/business/tournaments/types';
  219. import { ClaimsVO } from '@/api/system/business/claims/types';
  220. import { getTournaments } from '@/api/system/business/tournaments';
  221. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  222. const { complaints_status } = toRefs<any>(proxy?.useDict('complaints_status'));
  223. const complaintsList = ref<ComplaintsVO[]>([]);
  224. const buttonLoading = ref(false);
  225. const loading = ref(true);
  226. const showSearch = ref(true);
  227. const ids = ref<Array<string | number>>([]);
  228. const single = ref(true);
  229. const multiple = ref(true);
  230. const total = ref(0);
  231. const queryFormRef = ref<ElFormInstance>();
  232. const complaintsFormRef = ref<ElFormInstance>();
  233. const dialog = reactive<DialogOption>({
  234. visible: false,
  235. title: ''
  236. });
  237. const initFormData: ComplaintsForm = {
  238. id: undefined,
  239. userId: undefined,
  240. tournamentId: undefined,
  241. finalRank: undefined,
  242. complaintReason: undefined,
  243. createAt: undefined,
  244. updateAt: undefined,
  245. status: 2,
  246. statusText: undefined
  247. };
  248. const data = reactive<PageData<ComplaintsForm, ComplaintsQuery>>({
  249. form: { ...initFormData },
  250. queryParams: {
  251. pageNum: 1,
  252. pageSize: 10,
  253. userId: undefined,
  254. tournamentId: undefined,
  255. finalRank: undefined,
  256. complaintReason: undefined,
  257. createAt: undefined,
  258. updateAt: undefined,
  259. status: undefined,
  260. statusText: undefined,
  261. params: {}
  262. },
  263. rules: {
  264. id: [{ required: true, message: '不能为空', trigger: 'blur' }]
  265. }
  266. });
  267. const tournamentInfo = ref<Partial<TournamentsVO>>({
  268. id: '',
  269. startTime: '',
  270. endTime: '',
  271. itemsNum: 0,
  272. itemsName: '',
  273. blindStructureId: 0,
  274. blindStructuresName: '',
  275. lateRegistrationLevel: 0,
  276. tournamentsBiId: '',
  277. signNum: 0,
  278. isComplaints: false
  279. });
  280. const { queryParams, form, rules } = toRefs(data);
  281. /** 查询用户申诉列表 */
  282. const getList = async () => {
  283. loading.value = true;
  284. const res = await listComplaints(queryParams.value);
  285. complaintsList.value = res.rows;
  286. total.value = res.total;
  287. loading.value = false;
  288. };
  289. /** 取消按钮 */
  290. const cancel = () => {
  291. reset();
  292. dialog.visible = false;
  293. };
  294. /** 表单重置 */
  295. const reset = () => {
  296. form.value = { ...initFormData };
  297. complaintsFormRef.value?.resetFields();
  298. };
  299. /** 搜索按钮操作 */
  300. const handleQuery = () => {
  301. queryParams.value.pageNum = 1;
  302. const timeRange = data.queryParams.complaintTimeRange;
  303. if (timeRange && timeRange.length === 2) {
  304. data.queryParams.tournamentBeginTime = timeRange[0];
  305. data.queryParams.tournamentEndTime = timeRange[1];
  306. } else {
  307. data.queryParams.tournamentBeginTime = null;
  308. data.queryParams.tournamentEndTime = null;
  309. }
  310. getList();
  311. };
  312. /** 重置按钮操作 */
  313. const resetQuery = () => {
  314. queryFormRef.value?.resetFields();
  315. handleQuery();
  316. };
  317. /** 多选框选中数据 */
  318. const handleSelectionChange = (selection: ComplaintsVO[]) => {
  319. ids.value = selection.map((item) => item.id);
  320. single.value = selection.length != 1;
  321. multiple.value = !selection.length;
  322. };
  323. /** 新增按钮操作 */
  324. const handleAdd = () => {
  325. reset();
  326. dialog.visible = true;
  327. dialog.title = '处理结果';
  328. };
  329. /** 修改按钮操作 */
  330. const handleUpdate = async (row?: ComplaintsVO) => {
  331. reset();
  332. const _id = row?.id || ids.value[0];
  333. const res = await getComplaints(_id);
  334. const data = res.data;
  335. Object.assign(form.value, res.data);
  336. // 判断状态:如果是 1,则自动设置为 2(处理中)
  337. if (data.status === 1) {
  338. form.value.status = 2;
  339. } else {
  340. // 否则保持接口返回的状态(或其他默认逻辑)
  341. form.value.status = data.status;
  342. // 或者你希望用户手动选择:form.value.status = null;
  343. }
  344. dialog.visible = true;
  345. dialog.title = '处理申诉';
  346. };
  347. const handleUpdate2 = async (row?: ComplaintsVO) => {
  348. reset();
  349. const _id = row?.id || ids.value[0];
  350. const res = await getComplaints(_id);
  351. Object.assign(form.value, res.data);
  352. dialog.visible = true;
  353. dialog.title = '处理结果';
  354. };
  355. /** 提交按钮 */
  356. const submitForm = () => {
  357. complaintsFormRef.value?.validate(async (valid: boolean) => {
  358. if (valid) {
  359. buttonLoading.value = true;
  360. if (form.value.id) {
  361. await updateComplaints(form.value).finally(() => (buttonLoading.value = false));
  362. } else {
  363. await addComplaints(form.value).finally(() => (buttonLoading.value = false));
  364. }
  365. proxy?.$modal.msgSuccess('操作成功');
  366. dialog.visible = false;
  367. await getList();
  368. }
  369. });
  370. };
  371. /** 删除按钮操作 */
  372. const handleDelete = async (row?: ComplaintsVO) => {
  373. const _ids = row?.id || ids.value;
  374. await proxy?.$modal.confirm('是否确认删除用户申诉编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
  375. await delComplaints(_ids);
  376. proxy?.$modal.msgSuccess('删除成功');
  377. await getList();
  378. };
  379. /** 导出按钮操作 */
  380. const handleExport = () => {
  381. proxy?.download(
  382. 'system/complaints/export',
  383. {
  384. ...queryParams.value
  385. },
  386. `complaints_${new Date().getTime()}.xlsx`
  387. );
  388. };
  389. const auditDialog = ref({
  390. visible: false,
  391. title: '',
  392. mode: 'view' as 'view' | 'audit'
  393. });
  394. const auditData = ref<ClaimsVO[]>([]);
  395. // 创建新的查询参数对象,不影响原始 queryParams
  396. const auditQueryParams = {
  397. pageNum: 1,
  398. pageSize: 10,
  399. tournamentId: null as number | null
  400. };
  401. const auditTotal = ref(0);
  402. // 模拟打开对话框并获取数据
  403. const handleSeeRank = async (row: ComplaintsVO) => {
  404. auditDialog.value.visible = true;
  405. const _id = row?.tournamentId || ids.value[0];
  406. auditQueryParams.tournamentId = Number(_id);
  407. await getAuditData(1);
  408. try {
  409. const res = await getTournaments(_id);
  410. if (res.code === 200) {
  411. tournamentInfo.value = res.data;
  412. }
  413. } catch (error) {
  414. console.error('获取数据失败', error);
  415. }
  416. };
  417. const getAuditData = async (pageNum: number) => {
  418. try {
  419. auditQueryParams.pageNum = pageNum;
  420. const res = await getAllUserRankByTournamentId(auditQueryParams);
  421. auditData.value = res.rows;
  422. auditTotal.value = res.total;
  423. } catch (error) {
  424. console.error('获取审核数据失败', error);
  425. }
  426. };
  427. // 关闭对话框
  428. const cancelAudit = () => {
  429. auditDialog.value.visible = false;
  430. };
  431. const handleViewHistory = (row: ComplaintsVO) => {
  432. const tournamentId = row.tournamentId;
  433. const playerId = row.id;
  434. // 判断 playerId 是否有效(非 null、undefined)
  435. const playerIdStr = playerId != null ? String(playerId) : '';
  436. proxy?.$router.push({
  437. path: '/service/history',
  438. query: {
  439. tournamentId: String(tournamentId),
  440. playerId: playerIdStr
  441. }
  442. });
  443. auditDialog.value.visible = false;
  444. };
  445. onMounted(() => {
  446. getList();
  447. });
  448. </script>