index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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="projectName">
  8. <el-input v-model="queryParams.projectName" placeholder="请输入项目名称" clearable @keyup.enter="handleQuery" />
  9. </el-form-item>
  10. <!-- <el-form-item label="项目组别" prop="groupType">
  11. <el-select v-model="queryParams.groupType" placeholder="请选择项目组别" clearable @change="handleQuery">
  12. <el-option v-for="group in gameEventGroupList" :key="group.groupName" :label="group.groupName" :value="group.groupName" />
  13. </el-select>
  14. </el-form-item> -->
  15. <el-form-item>
  16. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  17. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  18. </el-form-item>
  19. </el-form>
  20. </el-card>
  21. </div>
  22. </transition>
  23. <el-card shadow="never">
  24. <template #header>
  25. <el-row :gutter="10" class="mb8">
  26. <el-col :span="1.5">
  27. <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:gameEventProject:add']"> 新增 </el-button>
  28. </el-col>
  29. <el-col :span="1.5">
  30. <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:gameEventProject:edit']"
  31. >修改
  32. </el-button>
  33. </el-col>
  34. <el-col :span="1.5">
  35. <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:gameEventProject:remove']"
  36. >删除
  37. </el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:gameEventProject:export']">导出 </el-button>
  41. </el-col>
  42. <right-toolbar v-model:showSearch="showSearch" :columns="columns" @queryTable="getList"></right-toolbar>
  43. </el-row>
  44. </template>
  45. <el-table v-loading="loading" border :data="gameEventProjectList" @selection-change="handleSelectionChange">
  46. <el-table-column type="selection" width="55" align="center" />
  47. <el-table-column label="主键" align="center" prop="projectId" v-if="columns[0].visible" />
  48. <el-table-column label="项目名称" align="center" prop="projectName" v-if="columns[1].visible" />
  49. <el-table-column label="项目类型" align="center" prop="projectType" v-if="columns[2].visible">
  50. <template #default="scope">
  51. <dict-tag :options="game_project_type" :value="scope.row.projectType || ''" />
  52. </template>
  53. </el-table-column>
  54. <!-- <el-table-column label="项目组别" align="center" prop="groupType" v-if="columns[3].visible" /> -->
  55. <el-table-column label="比赛场地" align="center" prop="location" v-if="columns[4].visible" />
  56. <el-table-column label="计算规则" align="center" prop="scoreRule" v-if="columns[5].visible">
  57. <template #default="scope">
  58. <dict-tag :options="game_score_type" :value="scope.row.scoreRule || ''" />
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="开始时间" align="center" prop="startTime" width="180" v-if="columns[6].visible">
  62. <template #default="scope">
  63. <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="结束时间" align="center" prop="endTime" width="180" v-if="columns[7].visible">
  67. <template #default="scope">
  68. <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="裁判组" align="center" prop="refereeGroup" v-if="columns[8].visible">
  72. <template #default="scope">
  73. <el-button
  74. v-if="scope.row.refereeGroups"
  75. type="primary"
  76. size="small"
  77. @click="handleViewRefereeGroup(scope.row.refereeGroups, scope.row.projectName)"
  78. >
  79. 查看裁判组 ({{ scope.row.refereeGroups.length }}人)
  80. </el-button>
  81. <span v-else style="color: #999;">暂无裁判</span>
  82. </template>
  83. </el-table-column>
  84. <!-- <el-table-column label="参赛组数" align="center" prop="groupNum" />
  85. <el-table-column label="参赛人数" align="center" prop="participateNum" /> -->
  86. <el-table-column label="轮次" align="center" prop="roundType" v-if="columns[9].visible" />
  87. <el-table-column label="排序方式" align="center" prop="orderType" v-if="columns[10].visible">
  88. <template #default="scope">
  89. {{ scope.row.orderType === '0' ? '升序' : '降序' }}
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="积分分值" align="center" prop="scoreValue" v-if="columns[11].visible" />
  93. <!-- <el-table-column label="奖项" align="center" prop="award" />
  94. <el-table-column label="计时点名称" align="center" prop="timePoint" />
  95. <el-table-column label="控制盒编号" align="center" prop="boxCode" />
  96. <el-table-column label="状态" align="center" prop="status" />
  97. <el-table-column label="备注" align="center" prop="remark" /> -->
  98. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  99. <template #default="scope">
  100. <el-tooltip content="修改" placement="top">
  101. <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:gameEventProject:edit']"></el-button>
  102. </el-tooltip>
  103. <el-tooltip content="删除" placement="top">
  104. <el-button
  105. link
  106. type="primary"
  107. icon="Delete"
  108. @click="handleDelete(scope.row)"
  109. v-hasPermi="['system:gameEventProject:remove']"
  110. ></el-button>
  111. </el-tooltip>
  112. </template>
  113. </el-table-column>
  114. </el-table>
  115. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
  116. </el-card>
  117. <!-- 添加或修改赛事项目对话框 -->
  118. <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
  119. <el-form ref="gameEventProjectFormRef" :model="form" :rules="rules" label-width="80px">
  120. <el-form-item label="项目名称" prop="projectName">
  121. <el-input v-model="form.projectName" placeholder="请输入项目名称" />
  122. </el-form-item>
  123. <el-form-item label="项目类型" prop="projectType">
  124. <el-select v-model="form.projectType" placeholder="请选择项目类型">
  125. <el-option v-for="dict in game_project_type" :key="dict.value" :label="dict.label" :value="dict.value" />
  126. </el-select>
  127. </el-form-item>
  128. <el-form-item label="比赛场地" prop="location">
  129. <el-input v-model="form.location" placeholder="请输入比赛场地" />
  130. </el-form-item>
  131. <!-- <el-form-item label="参赛组数" prop="groupNum">
  132. <el-input v-model="form.groupNum" placeholder="请输入参赛组数" />
  133. </el-form-item>
  134. <el-form-item label="参赛人数" prop="participateNum">
  135. <el-input v-model="form.participateNum" placeholder="请输入参赛人数" />
  136. </el-form-item> -->
  137. <el-form-item label="计算规则" prop="scoreRule">
  138. <el-select v-model="form.scoreRule" placeholder="请选择计算规则" style="width: 100%">
  139. <el-option v-for="dict in game_score_type" :key="dict.value" :label="dict.label" :value="dict.value" />
  140. </el-select>
  141. </el-form-item>
  142. <el-form-item label="排序方式" prop="orderType">
  143. <el-radio-group v-model="form.orderType">
  144. <el-radio value="0">升序</el-radio>
  145. <el-radio value="1">降序</el-radio>
  146. </el-radio-group>
  147. </el-form-item>
  148. <el-form-item label="积分分值" prop="scoreValue">
  149. <el-input v-model="form.scoreValue" placeholder="请输入积分分值" />
  150. </el-form-item>
  151. <el-form-item label="轮次" prop="roundType">
  152. <el-input v-model="form.roundType" placeholder="请输入轮次" />
  153. </el-form-item>
  154. <el-form-item label="开始时间" prop="startTime">
  155. <el-date-picker clearable v-model="form.startTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开始时间">
  156. </el-date-picker>
  157. </el-form-item>
  158. <el-form-item label="结束时间" prop="endTime">
  159. <el-date-picker clearable v-model="form.endTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择结束时间">
  160. </el-date-picker>
  161. </el-form-item>
  162. <!-- <el-form-item label="奖项" prop="award">
  163. <el-input v-model="form.award" placeholder="请输入奖项" />
  164. </el-form-item>
  165. <el-form-item label="计时点名称" prop="timePoint">
  166. <el-input v-model="form.timePoint" placeholder="请输入计时点名称" />
  167. </el-form-item>
  168. <el-form-item label="控制盒编号" prop="boxCode">
  169. <el-input v-model="form.boxCode" placeholder="请输入控制盒编号" />
  170. </el-form-item>
  171. <el-form-item label="备注" prop="remark">
  172. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  173. </el-form-item> -->
  174. </el-form>
  175. <template #footer>
  176. <div class="dialog-footer">
  177. <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
  178. <el-button @click="cancel">取 消</el-button>
  179. </div>
  180. </template>
  181. </el-dialog>
  182. <!-- 裁判组查看对话框 -->
  183. <RefereeGroupDialog ref="refereeGroupDialogRef" />
  184. </div>
  185. </template>
  186. <script setup name="GameEventProject" lang="ts">
  187. import {
  188. listGameEventProject,
  189. getGameEventProject,
  190. delGameEventProject,
  191. addGameEventProject,
  192. updateGameEventProject
  193. } from '@/api/system/gameEventProject';
  194. import { listGameEventGroup } from '@/api/system/gameEventGroup';
  195. import { GameEventProjectVO, GameEventProjectQuery, GameEventProjectForm } from '@/api/system/gameEventProject/types';
  196. import RefereeGroupDialog from './RefereeGroupDialog.vue';
  197. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  198. const { game_score_type, game_project_type } = toRefs<any>(proxy?.useDict('game_score_type', 'game_project_type'));
  199. const gameEventGroupList = ref<any[]>([]); // 赛事分组列表
  200. const gameEventProjectList = ref<GameEventProjectVO[]>([]);
  201. const buttonLoading = ref(false);
  202. const loading = ref(true);
  203. const showSearch = ref(true);
  204. const ids = ref<Array<string | number>>([]);
  205. const single = ref(true);
  206. const multiple = ref(true);
  207. const total = ref(0);
  208. const queryFormRef = ref<ElFormInstance>();
  209. const gameEventProjectFormRef = ref<ElFormInstance>();
  210. // 定义 RefereeGroupDialog 组件的类型
  211. interface RefereeGroupDialogInstance {
  212. openDialog: (refereeGroups: string[], projectName: string) => void;
  213. }
  214. const refereeGroupDialogRef = ref<(InstanceType<typeof RefereeGroupDialog> & RefereeGroupDialogInstance) | null>(null);
  215. const dialog = reactive<DialogOption>({
  216. visible: false,
  217. title: ''
  218. });
  219. // 列显隐数据
  220. const columns = ref<FieldOption[]>([
  221. { key: 0, label: '主键', visible: false },
  222. { key: 1, label: '项目名称', visible: true },
  223. { key: 2, label: '项目类型', visible: true },
  224. { key: 3, label: '项目组别', visible: true },
  225. { key: 4, label: '比赛场地', visible: true },
  226. { key: 5, label: '计算规则', visible: true },
  227. { key: 6, label: '开始时间', visible: true },
  228. { key: 7, label: '结束时间', visible: true },
  229. { key: 8, label: '裁判组', visible: true },
  230. { key: 9, label: '轮次', visible: true },
  231. { key: 10, label: '排序方式', visible: true },
  232. { key: 11, label: '积分分值', visible: true },
  233. ]);
  234. const initFormData: GameEventProjectForm = {
  235. projectId: undefined,
  236. eventId: undefined,
  237. projectName: undefined,
  238. projectType: undefined,
  239. groupType: undefined,
  240. refereeGroups: undefined,
  241. location: undefined,
  242. startTime: undefined,
  243. endTime: undefined,
  244. groupNum: undefined,
  245. participateNum: undefined,
  246. roundType: undefined,
  247. orderType: undefined,
  248. scoreRule: undefined,
  249. scoreValue: undefined,
  250. award: undefined,
  251. timePoint: undefined,
  252. boxCode: undefined,
  253. status: undefined,
  254. remark: undefined
  255. };
  256. const data = reactive<PageData<GameEventProjectForm, GameEventProjectQuery>>({
  257. form: { ...initFormData },
  258. queryParams: {
  259. pageNum: 1,
  260. pageSize: 10,
  261. orderByColumn: undefined,
  262. isAsc: undefined,
  263. },
  264. rules: {
  265. projectName: [{ required: true, message: '项目名称不能为空', trigger: 'blur' }],
  266. projectType: [{ required: true, message: '项目类型不能为空', trigger: 'change' }],
  267. groupType: [{ required: true, message: '项目组别不能为空', trigger: 'change' }],
  268. location: [{ required: true, message: '比赛场地不能为空', trigger: 'blur' }]
  269. }
  270. });
  271. const { queryParams, form, rules } = toRefs(data);
  272. /** 查询赛事项目列表 */
  273. const getList = async () => {
  274. loading.value = true;
  275. const res = await listGameEventProject(queryParams.value);
  276. gameEventProjectList.value = res.rows;
  277. total.value = res.total;
  278. loading.value = false;
  279. };
  280. /** 查询赛事分组列表 */
  281. const getGameEventGroupList = async () => {
  282. const res = await listGameEventGroup({
  283. pageNum: 1,
  284. pageSize: 10,
  285. orderByColumn: undefined,
  286. isAsc: undefined,
  287. });
  288. gameEventGroupList.value = res.data;
  289. };
  290. /** 取消按钮 */
  291. const cancel = () => {
  292. reset();
  293. dialog.visible = false;
  294. };
  295. /** 表单重置 */
  296. const reset = () => {
  297. form.value = { ...initFormData };
  298. gameEventProjectFormRef.value?.resetFields();
  299. };
  300. /** 搜索按钮操作 */
  301. const handleQuery = () => {
  302. queryParams.value.pageNum = 1;
  303. getList();
  304. };
  305. /** 重置按钮操作 */
  306. const resetQuery = () => {
  307. queryFormRef.value?.resetFields();
  308. handleQuery();
  309. };
  310. /** 多选框选中数据 */
  311. const handleSelectionChange = (selection: any[]) => {
  312. ids.value = selection.map(item => item.projectId);
  313. single.value = selection.length !== 1;
  314. multiple.value = !selection.length;
  315. };
  316. /** 新增按钮操作 */
  317. const handleAdd = () => {
  318. reset();
  319. dialog.visible = true;
  320. dialog.title = '添加赛事项目';
  321. };
  322. /** 修改按钮操作 */
  323. const handleUpdate = (row?: GameEventProjectVO) => {
  324. reset();
  325. const projectId = row?.projectId || ids.value.at(0);
  326. getGameEventProject(projectId).then(response => {
  327. Object.assign(form.value, response.data);
  328. dialog.visible = true;
  329. dialog.title = '修改赛事项目';
  330. });
  331. };
  332. /** 提交按钮 */
  333. const submitForm = () => {
  334. gameEventProjectFormRef.value?.validate(valid => {
  335. if (valid) {
  336. buttonLoading.value = true;
  337. if (form.value.projectId !== undefined) {
  338. updateGameEventProject(form.value).then(response => {
  339. proxy?.$modal.msgSuccess('修改成功');
  340. dialog.visible = false;
  341. getList();
  342. }).finally(() => {
  343. buttonLoading.value = false;
  344. });
  345. } else {
  346. addGameEventProject(form.value).then(response => {
  347. proxy?.$modal.msgSuccess('新增成功');
  348. dialog.visible = false;
  349. getList();
  350. }).finally(() => {
  351. buttonLoading.value = false;
  352. });
  353. }
  354. }
  355. });
  356. };
  357. /** 删除按钮操作 */
  358. const handleDelete = (row?: GameEventProjectVO) => {
  359. const projectIds = row?.projectId || ids.value;
  360. proxy?.$modal.confirm('是否确认删除赛事项目编号为"' + projectIds + '"的数据项?').then(function () {
  361. return delGameEventProject(projectIds);
  362. }).then(() => {
  363. getList();
  364. proxy?.$modal.msgSuccess('删除成功');
  365. }).catch(() => {proxy?.$modal.msgSuccess('删除失败');});
  366. };
  367. /** 导出按钮操作 */
  368. const handleExport = () => {
  369. proxy?.download(
  370. 'system/gameEventProject/export',
  371. {
  372. ...queryParams.value
  373. },
  374. `gameEventProject_${new Date().getTime()}.xlsx`
  375. );
  376. };
  377. /** 查看裁判组 */
  378. const handleViewRefereeGroup = (refereeGroups: string[], projectName: string) => {
  379. refereeGroupDialogRef.value?.openDialog(refereeGroups, projectName);
  380. };
  381. onMounted(() => {
  382. getList();
  383. getGameEventGroupList();
  384. });
  385. </script>