Преглед на файлове

feat(tournaments): 添加复制比赛功能

- 在比赛列表中增加复制按钮
- 实现复制比赛的功能,包括复制基本信息和奖励设置- 优化表单数据的处理,确保正确复制数值类型的数据
fugui001 преди 5 месеца
родител
ревизия
b30609ff80
променени са 1 файла, в които са добавени 44 реда и са изтрити 0 реда
  1. 44 0
      src/views/system/business/tournaments/index.vue

+ 44 - 0
src/views/system/business/tournaments/index.vue

@@ -114,6 +114,11 @@
               <el-tooltip content="编辑" placement="top">
                 <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row, 'edit')">编辑</el-button>
               </el-tooltip>
+
+              <el-tooltip content="复制" placement="top">
+                <el-button link type="primary" icon="Copy" @click="handleCopy(scope.row)">复制</el-button>
+              </el-tooltip>
+
               <el-tooltip content="领奖审核" placement="top">
                 <el-button link type="primary" icon="Edit" @click="openAuditDialog(scope.row.id, 'audit')">领奖审核</el-button>
               </el-tooltip>
@@ -1185,4 +1190,43 @@ const handleViewLevelsSee = (tournamentsVO: TournamentsVO | undefined | null) =>
   dialogParams.value.name = tournamentsVO.blindStructuresName ?? '';
   levelsDialogVisible.value = true;
 };
+
+/** 修改按钮操作 */
+const handleCopy = async (row?: TournamentsVO) => {
+  reset(); // 重置表单
+
+  const _id = row?.id || ids.value[0];
+  const res = await getTournaments(_id);
+  // 确保 gameType 是 number 类型
+  const gameType = Number(res.data.gameType);
+  const signTime = Number(res.data.signTime);
+  debugger;
+  // 设置表单数据
+  res.data.id = null;
+  Object.assign(form.value, res.data);
+  form.value.gameType = gameType; // 确保赋值正确
+  form.value.signTime = signTime;
+
+  competitionIcon.value = res.data.competitionIcon;
+  // 处理奖励表单数据
+  const prizeItems = res.data.itemsPrizeList || [];
+  if (prizeItems.length > 0) {
+    formPrize.rewards = prizeItems.map((item, index) => ({
+      ranking: item.ranking || index + 1,
+      itemId: Number(item.itemId),
+      quantity: Number(item.quantity)
+    }));
+  } else {
+    formPrize.rewards = [
+      {
+        ranking: 1,
+        itemId: null,
+        quantity: null
+      }
+    ];
+  }
+
+  dialog.visible = true;
+  dialog.title = '创建比赛';
+};
 </script>