Ver Fonte

feat(tournaments): 增加比赛复制功能并优化操作按钮显示

- 在 tournaments 列表中增加“复制”按钮,支持复制已有比赛配置
- 修改“修改”和“删除”按钮,添加文字标识提升可读性
- 实现 handleCopy 方法用于加载源数据并初始化新表单
- 调整复制逻辑以适配比赛相关字段(如奖励、盲注结构等)
- 更新操作列按钮布局与权限控制
- 优化盲注结构切换逻辑,确保复制后正确加载对应数据
fugui001 há 4 semanas atrás
pai
commit
23d7f00d38

+ 1 - 1
src/views/system/physical/blindLevels/index.vue

@@ -67,7 +67,7 @@
             <span>{{ scope.row.isBreak ? '是' : '否' }}</span>
           </template>
         </el-table-column>
-        <el-table-column label="休息时长" align="center" prop="breakDurationMinutes" />
+        <el-table-column label="休息时长(分钟)" align="center" prop="breakDurationMinutes" />
         <el-table-column label="备注" align="center" prop="remark" />
         <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
           <template #default="scope">

+ 48 - 2
src/views/system/physical/tournaments/index.vue

@@ -122,10 +122,13 @@
         <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="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['physical:tournaments:edit']"></el-button>
+              <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['physical:tournaments:edit']">修改</el-button>
             </el-tooltip>
             <el-tooltip content="删除" placement="top">
-              <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['physical:tournaments:remove']"></el-button>
+              <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['physical:tournaments:remove']">删除</el-button>
+            </el-tooltip>
+            <el-tooltip content="复制" placement="top" v-hasPermi="['business:tournaments:query']">
+              <el-button link type="primary" icon="Files" @click="handleCopy(scope.row)"> 复制 </el-button>
             </el-tooltip>
           </template>
         </el-table-column>
@@ -997,4 +1000,47 @@ const handlePreviewClick2 = () => {
     dialogVisible2.value = true;
   }
 };
+/** 修改按钮操作 */
+const handleCopy = async (row?: TournamentsVO) => {
+  reset(); // 重置表单
+  const _id = row?.id || ids.value[0];
+  const res = await getTournaments(_id);
+  // 设置表单数据
+  res.data.id = null;
+  Object.assign(form.value, res.data);
+  form.value.signTime = String(res.data.signTime);
+  form.value.gameType = String(res.data.gameType); // 转为字符串
+  form.value.status = 0;
+  form.value.id = null;
+  form.value.levelDuration = null;
+
+  form.value.delayCardTime = res.data.delayCardTime;
+  form.value.delayCardNum = res.data.delayCardNum;
+
+  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
+      }
+    ];
+  }
+  // ✅ 主动触发盲注等级加载
+  if (form.value.blindStructureId) {
+    await handleBlindStructureChange(form.value.blindStructureId);
+  }
+  dialog.mode = 'add'; // 设置为新增模式
+  dialog.visible = true;
+  dialog.title = '创建比赛';
+};
 </script>