index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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" label-width="100px">
  7. <el-form-item label="赛事编号" prop="eventCode">
  8. <el-input v-model="queryParams.eventCode" placeholder="请输入赛事编号" clearable @keyup.enter="handleQuery" />
  9. </el-form-item>
  10. <el-form-item label="赛事名称" prop="eventName">
  11. <el-input v-model="queryParams.eventName" placeholder="请输入赛事名称" clearable @keyup.enter="handleQuery" />
  12. </el-form-item>
  13. <el-form-item label="赛事类型" prop="eventType">
  14. <el-select v-model="queryParams.eventType" placeholder="请选择赛事类型" clearable>
  15. <el-option v-for="dict in game_event_type" :key="dict.value" :label="dict.label" :value="dict.value" />
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="开始时间" prop="startTime">
  19. <el-date-picker clearable v-model="queryParams.startTime" type="date" value-format="YYYY-MM-DD" placeholder="请选择开始时间" />
  20. </el-form-item>
  21. <el-form-item label="是否默认赛事" prop="isDefault">
  22. <el-select v-model="queryParams.isDefault" placeholder="请选择是否默认赛事" clearable>
  23. <el-option v-for="dict in sys_yes_no" :key="dict.value" :label="dict.label" :value="dict.value" />
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="状态" prop="status">
  27. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
  28. <el-option v-for="dict in game_event_status" :key="dict.value" :label="dict.label" :value="dict.value" />
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  33. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  34. </el-form-item>
  35. </el-form>
  36. </el-card>
  37. </div>
  38. </transition>
  39. <el-card shadow="never">
  40. <template #header>
  41. <el-row :gutter="10" class="mb8">
  42. <el-col :span="1.5">
  43. <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:gameEvent:add']">新增 </el-button>
  44. </el-col>
  45. <el-col :span="1.5">
  46. <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:gameEvent:edit']"
  47. >修改
  48. </el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:gameEvent:remove']"
  52. >删除
  53. </el-button>
  54. </el-col>
  55. <el-col :span="1.5">
  56. <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:gameEvent:export']">导出 </el-button>
  57. </el-col>
  58. <right-toolbar v-model:showSearch="showSearch" :columns="columns" @queryTable="getList"></right-toolbar>
  59. </el-row>
  60. </template>
  61. <el-table v-loading="loading" border :data="gameEventList" @selection-change="handleSelectionChange">
  62. <el-table-column type="selection" width="55" align="center" />
  63. <el-table-column label="主键" align="center" prop="eventId" v-if="columns[0].visible" />
  64. <el-table-column label="赛事编号" align="center" prop="eventCode" v-if="columns[1].visible" />
  65. <el-table-column label="赛事名称" align="center" prop="eventName" v-if="columns[2].visible" />
  66. <el-table-column label="赛事类型" align="center" prop="eventType" v-if="columns[3].visible">
  67. <template #default="scope">
  68. <dict-tag :options="game_event_type" :value="scope.row.eventType" />
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="举办地点" align="center" prop="location" v-if="columns[4].visible" />
  72. <el-table-column label="用途" align="center" prop="purpose" v-if="columns[5].visible">
  73. <template #default="scope">
  74. <dict-tag :options="game_event_purpose" :value="scope.row.purpose" />
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="开始时间" align="center" prop="startTime" width="180" v-if="columns[6].visible">
  78. <template #default="scope">
  79. <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="结束时间" align="center" prop="endTime" width="180" v-if="columns[7].visible">
  83. <template #default="scope">
  84. <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="赛事链接" align="center" prop="eventUrlUrl" width="100" v-if="columns[8].visible">
  88. <template #default="scope">
  89. <image-preview :src="scope.row.eventUrlUrl" :width="50" :height="50" />
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="裁判码" align="center" prop="refereeUrlUrl" width="100" v-if="columns[9].visible">
  93. <template #default="scope">
  94. <image-preview :src="scope.row.refereeUrlUrl" :width="50" :height="50" />
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="举办单位" align="center" prop="unit" v-if="columns[10].visible" />
  98. <el-table-column label="是否默认赛事" align="center" prop="isDefault" v-if="columns[11].visible">
  99. <template #default="scope">
  100. <el-switch v-model="scope.row.isDefault" active-value="0" inactive-value="1" @change="handleStatusChange(scope.row)"></el-switch>
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="创建时间" align="center" prop="createTime" width="180" v-if="columns[12].visible">
  104. <template #default="scope">
  105. <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="更新时间" align="center" prop="updateTime" width="180" v-if="columns[13].visible">
  109. <template #default="scope">
  110. <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
  111. </template>
  112. </el-table-column>
  113. <el-table-column label="状态" align="center" prop="status" v-if="columns[14].visible">
  114. <template #default="scope">
  115. <dict-tag :options="game_event_status" :value="scope.row.status" />
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="备注" align="center" prop="remark" v-if="columns[15].visible" />
  119. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
  120. <template #default="scope">
  121. <el-tooltip content="修改" placement="top">
  122. <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:gameEvent:edit']"></el-button>
  123. </el-tooltip>
  124. <!-- 删除操作 -->
  125. <el-tooltip :content="getDeleteTooltip(scope.row)" placement="top">
  126. <el-button
  127. link
  128. type="primary"
  129. icon="Delete"
  130. :disabled="!canDelete(scope.row)"
  131. @click="handleDelete(scope.row)"
  132. v-hasPermi="['system:event:remove']"
  133. >
  134. </el-button>
  135. </el-tooltip>
  136. <!-- 下载模板 -->
  137. <el-tooltip content="下载报名信息模板" placement="top">
  138. <el-button link type="primary" icon="Download" @click="handleDownloadTemplate(scope.row)"></el-button>
  139. </el-tooltip>
  140. <el-tooltip content="导入报名信息" placement="top">
  141. <el-button
  142. link
  143. type="primary"
  144. icon="FolderOpened"
  145. @click="handleImportRegistration(scope.row)"
  146. v-hasPermi="['system:gameEvent:import']"
  147. ></el-button>
  148. </el-tooltip>
  149. <el-tooltip content="添加参赛者" placement="top">
  150. <el-button
  151. link
  152. type="primary"
  153. icon="User"
  154. @click="handleAddParticipant(scope.row)"
  155. v-hasPermi="['system:gameEvent:addParticipant']"
  156. ></el-button>
  157. </el-tooltip>
  158. <el-tooltip content="添加裁判" placement="top">
  159. <el-button
  160. link
  161. type="primary"
  162. icon="Avatar"
  163. @click="handleAddReferee(scope.row)"
  164. v-hasPermi="['system:gameEvent:addReferee']"
  165. ></el-button>
  166. </el-tooltip>
  167. <!-- 新增预览按钮 -->
  168. <el-tooltip content="预览" placement="top">
  169. <el-button link type="primary" icon="View" @click="handlePreview(scope.row)" v-hasPermi="['system:gameEvent:view']"></el-button>
  170. </el-tooltip>
  171. <!-- 新增比赛数据按钮 -->
  172. <el-tooltip content="比赛数据" placement="top">
  173. <el-button
  174. link
  175. type="primary"
  176. icon="DataAnalysis"
  177. @click="handleGameData(scope.row)"
  178. v-hasPermi="['system:gameEvent:gameData']"
  179. ></el-button>
  180. </el-tooltip>
  181. </template>
  182. </el-table-column>
  183. </el-table>
  184. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
  185. </el-card>
  186. <!-- 注册 RefereeForm 组件 -->
  187. <RefereeForm ref="refereeFormRef" />
  188. <!-- 排行榜对话框 -->
  189. <el-dialog :title="`赛事 ${currentEventId} 排行榜`" v-model="rankingBoardVisible" width="800px" append-to-body>
  190. <RankingBoard :eventId="currentEventId" v-if="rankingBoardVisible" />
  191. </el-dialog>
  192. <!-- 用户导入对话框 -->
  193. <el-dialog v-model="upload.open" :title="upload.title" width="400px" append-to-body>
  194. <el-upload
  195. ref="uploadRef"
  196. :limit="1"
  197. accept=".xlsx"
  198. :headers="upload.headers"
  199. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  200. :disabled="upload.isUploading"
  201. :on-progress="handleFileUploadProgress"
  202. :on-success="handleFileSuccess"
  203. :auto-upload="false"
  204. drag
  205. >
  206. <el-icon class="el-icon--upload">
  207. <i-ep-upload-filled />
  208. </el-icon>
  209. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  210. <template #tip>
  211. <div class="text-center el-upload__tip">
  212. <!-- <div class="el-upload__tip">-->
  213. <!-- <el-checkbox v-model="upload.updateSupport" />-->
  214. <!-- 是否更新已经存在的用户数据-->
  215. <!-- </div>-->
  216. <span>仅允许导入.xlsx格式文件。</span>
  217. </div>
  218. </template>
  219. </el-upload>
  220. <template #footer>
  221. <div class="dialog-footer">
  222. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  223. <el-button @click="upload.open = false">取 消</el-button>
  224. </div>
  225. </template>
  226. </el-dialog>
  227. </div>
  228. </template>
  229. <script setup name="GameEvent" lang="ts">
  230. import { listGameEvent, changeEventDefault, delGameEvent, addGameEvent, updateGameEvent } from '@/api/system/gameEvent';
  231. import { GameEventVO, GameEventQuery, GameEventForm } from '@/api/system/gameEvent/types';
  232. import { useRouter } from 'vue-router';
  233. import { ref } from 'vue';
  234. import RefereeForm from '@/views/system/gameEvent/RefereeForm.vue';
  235. import RankingBoard from './RankingBoard.vue';
  236. import { useTagsViewStore } from '@/store/modules/tagsView';
  237. import { globalHeaders } from '@/utils/request';
  238. const router = useRouter();
  239. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  240. const { game_event_type, game_event_status, sys_yes_no, game_event_purpose } = toRefs<any>(
  241. proxy?.useDict('game_event_type', 'game_event_status', 'sys_yes_no', 'game_event_purpose')
  242. );
  243. // 定义 RefereeForm 组件的类型
  244. interface RefereeFormInstance {
  245. openDialog: (eventId: string) => void;
  246. }
  247. const refereeFormRef = ref<(InstanceType<typeof RefereeForm> & RefereeFormInstance) | null>(null);
  248. const gameEventList = ref<GameEventVO[]>([]);
  249. const buttonLoading = ref(false);
  250. const loading = ref(true);
  251. const showSearch = ref(true);
  252. const ids = ref<Array<string | number>>([]);
  253. const single = ref(true);
  254. const multiple = ref(true);
  255. const total = ref(0);
  256. // 列显隐数据
  257. const columns = ref<FieldOption[]>([
  258. { key: 0, label: '主键', visible: false },
  259. { key: 1, label: '赛事编号', visible: true },
  260. { key: 2, label: '赛事名称', visible: true },
  261. { key: 3, label: '赛事类型', visible: true },
  262. { key: 4, label: '举办地点', visible: true },
  263. { key: 5, label: '用途', visible: true },
  264. { key: 6, label: '开始时间', visible: true },
  265. { key: 7, label: '结束时间', visible: true },
  266. { key: 8, label: '赛事链接', visible: true },
  267. { key: 9, label: '裁判码', visible: true },
  268. { key: 10, label: '举办单位', visible: true },
  269. { key: 11, label: '是否默认赛事', visible: true },
  270. { key: 12, label: '创建时间', visible: true },
  271. { key: 13, label: '更新时间', visible: true },
  272. { key: 14, label: '状态', visible: true },
  273. { key: 15, label: '备注', visible: true }
  274. ]);
  275. const queryFormRef = ref<ElFormInstance>();
  276. const gameEventFormRef = ref<ElFormInstance>();
  277. const dialog = reactive<DialogOption>({
  278. visible: false,
  279. title: ''
  280. });
  281. const uploadRef = ref<ElUploadInstance>();
  282. /*** 用户导入参数 */
  283. const upload = reactive<ImportOption>({
  284. // 是否显示弹出层(用户导入)
  285. open: false,
  286. // 弹出层标题(用户导入)
  287. title: '',
  288. // 是否禁用上传
  289. isUploading: false,
  290. // 是否更新已经存在的用户数据
  291. updateSupport: 0,
  292. // 设置上传的请求头部
  293. headers: globalHeaders()
  294. // 上传的地址
  295. // url: import.meta.env.VITE_APP_BASE_API + '/system/enroll/importData'
  296. });
  297. const initFormData: GameEventForm = {
  298. eventId: undefined,
  299. eventCode: undefined,
  300. eventName: undefined,
  301. eventType: undefined,
  302. location: undefined,
  303. purpose: undefined,
  304. startTime: undefined,
  305. endTime: undefined,
  306. eventUrl: undefined,
  307. refereeUrl: undefined,
  308. registerUrl: undefined,
  309. unit: undefined,
  310. isDefault: undefined,
  311. status: undefined,
  312. remark: undefined
  313. };
  314. const data = reactive<PageData<GameEventForm, GameEventQuery>>({
  315. form: { ...initFormData },
  316. queryParams: {
  317. pageNum: 1,
  318. pageSize: 10,
  319. eventCode: undefined,
  320. eventName: undefined,
  321. eventType: undefined,
  322. purpose: undefined,
  323. startTime: undefined,
  324. isDefault: undefined,
  325. status: undefined,
  326. params: {},
  327. orderByColumn: '',
  328. isAsc: ''
  329. },
  330. rules: {
  331. eventCode: [{ required: true, message: '赛事编号不能为空', trigger: 'blur' }],
  332. eventName: [{ required: true, message: '赛事名称不能为空', trigger: 'blur' }],
  333. eventType: [{ required: true, message: '赛事类型不能为空', trigger: 'change' }]
  334. }
  335. });
  336. const { queryParams, form, rules } = toRefs(data);
  337. /** 查询赛事基本信息列表 */
  338. const getList = async () => {
  339. loading.value = true;
  340. const res = await listGameEvent(queryParams.value);
  341. gameEventList.value = res.rows;
  342. total.value = res.total;
  343. loading.value = false;
  344. };
  345. /** 取消按钮 */
  346. const cancel = () => {
  347. reset();
  348. dialog.visible = false;
  349. };
  350. /** 表单重置 */
  351. const reset = () => {
  352. form.value = { ...initFormData };
  353. gameEventFormRef.value?.resetFields();
  354. };
  355. /** 搜索按钮操作 */
  356. const handleQuery = () => {
  357. queryParams.value.pageNum = 1;
  358. getList();
  359. };
  360. /** 重置按钮操作 */
  361. const resetQuery = () => {
  362. queryFormRef.value?.resetFields();
  363. handleQuery();
  364. };
  365. /** 多选框选中数据 */
  366. const handleSelectionChange = (selection: GameEventVO[]) => {
  367. ids.value = selection.map((item) => item.eventId);
  368. single.value = selection.length != 1;
  369. multiple.value = !selection.length;
  370. };
  371. /** 新增按钮操作 */
  372. const handleAdd = () => {
  373. router.push('/system/gameEvent/add');
  374. };
  375. /** 修改按钮操作 */
  376. const handleUpdate = async (row?: GameEventVO) => {
  377. const _eventId = row?.eventId || ids.value[0];
  378. router.push(`/system/gameEvent/edit/${_eventId}`);
  379. };
  380. /** 提交按钮 */
  381. const submitForm = () => {
  382. gameEventFormRef.value?.validate(async (valid: boolean) => {
  383. if (valid) {
  384. buttonLoading.value = true;
  385. if (form.value.eventId) {
  386. await updateGameEvent(form.value).finally(() => (buttonLoading.value = false));
  387. } else {
  388. await addGameEvent(form.value).finally(() => (buttonLoading.value = false));
  389. }
  390. proxy?.$modal.msgSuccess('操作成功');
  391. dialog.visible = false;
  392. await getList();
  393. }
  394. });
  395. };
  396. /** 删除按钮操作 */
  397. const handleDelete = async (row?: GameEventVO) => {
  398. const _ids = row?.eventId || ids.value;
  399. if (!_ids || (Array.isArray(_ids) && _ids.length === 0)) {
  400. proxy?.$modal.msgError('请选择要删除的赛事');
  401. return;
  402. }
  403. // 如果是单个删除,需要检查时间限制
  404. if (row) {
  405. const endTime = new Date(row.endTime);
  406. const currentTime = new Date();
  407. const daysDiff = Math.floor((currentTime.getTime() - endTime.getTime()) / (1000 * 60 * 60 * 24));
  408. if (daysDiff < 100) {
  409. proxy?.$modal.msgError(`该赛事结束时间不足100天,无法删除。距离可删除时间还有 ${100 - daysDiff} 天。`);
  410. return;
  411. }
  412. await proxy?.$modal.confirm('是否确认删除赛事编号为"' + row.eventCode + '"的数据项?').finally(() => (loading.value = false));
  413. await delGameEvent(row.eventId);
  414. proxy?.$modal.msgSuccess('删除成功');
  415. } else {
  416. // 批量删除
  417. const selectedEvents = gameEventList.value.filter((event) => ids.value.includes(event.eventId));
  418. const invalidEvents = selectedEvents.filter((event) => {
  419. const endTime = new Date(event.endTime);
  420. const currentTime = new Date();
  421. const daysDiff = Math.floor((currentTime.getTime() - endTime.getTime()) / (1000 * 60 * 60 * 24));
  422. return daysDiff < 100;
  423. });
  424. if (invalidEvents.length > 0) {
  425. const eventNames = invalidEvents.map((event) => event.eventName).join('、');
  426. proxy?.$modal.msgError(`以下赛事结束时间不足100天,无法删除:${eventNames}`);
  427. return;
  428. }
  429. const eventCodes = selectedEvents.map((event) => event.eventCode).join('、');
  430. await proxy?.$modal.confirm(`是否确认删除以下赛事:${eventCodes}?`).finally(() => (loading.value = false));
  431. await delGameEvent(ids.value);
  432. proxy?.$modal.msgSuccess(`成功删除 ${selectedEvents.length} 个赛事`);
  433. }
  434. await getList();
  435. };
  436. /** 判断是否可以删除赛事 */
  437. const canDelete = (row: GameEventVO): boolean => {
  438. const endTime = new Date(row.endTime);
  439. const currentTime = new Date();
  440. const daysDiff = Math.floor((currentTime.getTime() - endTime.getTime()) / (1000 * 60 * 60 * 24));
  441. return daysDiff >= 100;
  442. };
  443. /** 获取删除按钮的提示信息 */
  444. const getDeleteTooltip = (row: GameEventVO): string => {
  445. if (canDelete(row)) {
  446. return '删除';
  447. } else {
  448. const endTime = new Date(row.endTime);
  449. const currentTime = new Date();
  450. const daysDiff = Math.floor((currentTime.getTime() - endTime.getTime()) / (1000 * 60 * 60 * 24));
  451. return `赛事结束时间不足100天,无法删除。距离可删除时间还有 ${100 - daysDiff} 天。`;
  452. }
  453. };
  454. /** 导出按钮操作 */
  455. const handleExport = () => {
  456. proxy?.download(
  457. 'system/gameEvent/export',
  458. {
  459. ...queryParams.value
  460. },
  461. `gameEvent_${new Date().getTime()}.xlsx`
  462. );
  463. };
  464. /* 下载模板 */
  465. const handleDownloadTemplate = (row: GameEventVO) => {
  466. proxy?.download(
  467. 'system/enroll/importTemplate',
  468. {
  469. eventId: row.eventId
  470. },
  471. `event_enroll_template_${new Date().getTime()}.xlsx`
  472. );
  473. };
  474. // 导入报名表逻辑
  475. const handleImportRegistration = (row) => {
  476. upload.url = import.meta.env.VITE_APP_BASE_API + `/system/enroll/importData/${row.eventId}`;
  477. upload.title = '报名表导入';
  478. upload.open = true;
  479. };
  480. /**文件上传中处理 */
  481. const handleFileUploadProgress = () => {
  482. upload.isUploading = true;
  483. };
  484. /** 文件上传成功处理 */
  485. const handleFileSuccess = (response: any, file: UploadFile) => {
  486. upload.open = false;
  487. upload.isUploading = false;
  488. uploadRef.value?.handleRemove(file);
  489. ElMessageBox.alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + '</div>', '导入结果', {
  490. dangerouslyUseHTMLString: true
  491. });
  492. getList();
  493. };
  494. /** 提交上传文件 */
  495. function submitFileForm() {
  496. uploadRef.value?.submit();
  497. }
  498. // 添加参赛者操作
  499. const handleAddParticipant = (row: GameEventVO) => {
  500. // 跳转到新增或编辑参赛者信息页面,并传递 eventName 参数
  501. router.push({
  502. name: 'GameEventAthlete',
  503. params: { eventId: row.eventId, eventName: row.eventName }
  504. });
  505. };
  506. // 添加裁判按钮操作 1
  507. const handleAddReferee = async (row: GameEventVO) => {
  508. // 打开裁判表单对话框并传递 eventId
  509. refereeFormRef.value?.openDialog(String(row.eventId));
  510. };
  511. // 预览按钮点击事件
  512. const handlePreview = (row: GameEventVO) => {
  513. // 跳转到赛事详情页面
  514. router.push({
  515. name: 'GameEventDetail',
  516. params: { eventId: row.eventId }
  517. });
  518. };
  519. // 比赛成绩按钮点击事件
  520. const handleGameData = (row: GameEventVO) => {
  521. router.push({
  522. name: 'RankingBoardPage',
  523. params: { eventId: row.eventId }
  524. });
  525. };
  526. const rankingBoardVisible = ref(false);
  527. const currentEventId = ref<string | undefined>();
  528. // 打开排行榜组件并传递赛事ID
  529. const openRankingBoard = (eventId: string) => {
  530. currentEventId.value = eventId;
  531. rankingBoardVisible.value = true;
  532. };
  533. /** 状态修改 */
  534. const handleStatusChange = async (row: GameEventVO) => {
  535. const text = row.isDefault === '0' ? '启用' : '停用';
  536. try {
  537. await proxy?.$modal.confirm('确认要"' + text + '""' + row.eventName + '"为默认赛事吗?');
  538. await changeEventDefault(row.eventId, row.isDefault);
  539. await getList();
  540. // localStorage.setItem('defaultEventId', row.eventId);
  541. proxy?.$modal.msgSuccess(text + '成功');
  542. // 刷新当前标签页
  543. await useTagsViewStore().delOthersViews(router.currentRoute.value);
  544. } catch {
  545. return;
  546. } finally {
  547. row.isDefault = row.isDefault === '0' ? '1' : '0';
  548. }
  549. };
  550. onMounted(() => {
  551. getList();
  552. });
  553. // 监听路由变化,当从编辑页返回时检查是否需要刷新列表
  554. onActivated(() => {
  555. // 检查是否有需要刷新的标识
  556. const needRefresh = sessionStorage.getItem('needRefreshGameEventList');
  557. if (needRefresh === 'true') {
  558. // 清除标识
  559. sessionStorage.removeItem('needRefreshGameEventList');
  560. // 刷新列表数据
  561. getList();
  562. }
  563. });
  564. </script>