Selaa lähdekoodia

feat(cardTools): 优化牌局测试工具功能

- 增加整牌设置功能,支持2人到9人的牌局配置- 添加取消生效按钮,可恢复为上次保存的状态
- 完善数据加载逻辑,支持加载不同人数的牌局数据
-优化页面样式,调整表单布局和样式
fugui001 3 kuukautta sitten
vanhempi
commit
0f5b969a85

+ 6 - 0
src/api/system/business/cardTools/index.ts

@@ -70,3 +70,9 @@ export const selectBusinessCardToolsMaxNew = (): AxiosPromise<CardToolsVO> => {
     method: 'get'
   });
 };
+export const removeRedisPokerHands = () => {
+  return request({
+    url: '/business/cardTools/removeRedisPokerHands',
+    method: 'GET'
+  });
+};

+ 90 - 0
src/api/system/business/cardTools/types.ts

@@ -23,6 +23,51 @@ export interface CardToolsVO {
    * 更新时间
    */
   updateAt: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentTwo?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentThree?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentFour?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentFive?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentSex?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentSeven?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentEight?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentNine?: string;
+
+  /**
+   *  '0 正常  1已删除'
+   */
+  isDelete: string | number;
 }
 
 export interface CardToolsForm extends BaseEntity {
@@ -52,6 +97,51 @@ export interface CardToolsForm extends BaseEntity {
   updateAt?: string;
 
   handCards?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentTwo?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentThree?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentFour?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentFive?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentSex?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentSeven?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentEight?: string;
+
+  /**
+   * 整副牌内容
+   */
+  contentNine?: string;
+
+  /**
+   *  '0 正常  1已删除'
+   */
+  isDelete: string | number;
 }
 
 export interface CardToolsQuery extends PageQuery {

+ 138 - 14
src/views/system/business/cardTools/index.vue

@@ -2,19 +2,50 @@
   <div class="p-2">
     <el-card shadow="hover">
       <!-- 页面标题 -->
-      <div class="mb-[10px] text-sm font-medium">牌局测试工具</div>
-
+      <div class="mb-[10px] text-sm font-medium">
+        牌局测试工具,是否生效 <span class="text-red-500 text-lg font-bold">{{ effectiveText }}</span>
+      </div>
+      <div class="mb-[10px] text-sm font-medium">
+        <p>S黑、H红、D方、C梅代表四种花色/ AKQJT98765432 代表13个点数/ AS,黑桃A/ D,方块2</p>
+      </div>
       <!-- 表单区域 -->
       <el-form ref="cardToolsFormRef" :model="form" label-width="80px">
-        <el-form-item label="整牌设置">
-          <el-input v-model="form.content" type="textarea" :rows="3" placeholder="请按输入" />
+        <el-form-item label="整牌(2人)">
+          <el-input v-model="form.contentTwo" type="textarea" :rows="3" placeholder="请按输入" />
+        </el-form-item>
+
+        <el-form-item label="整牌(3人)">
+          <el-input v-model="form.contentThree" type="textarea" :rows="3" placeholder="请按输入" />
+        </el-form-item>
+
+        <el-form-item label="整牌(4人)">
+          <el-input v-model="form.contentFour" type="textarea" :rows="3" placeholder="请按输入" />
+        </el-form-item>
+        <el-form-item label="整牌(5人)">
+          <el-input v-model="form.contentFive" type="textarea" :rows="3" placeholder="请按输入" />
+        </el-form-item>
+
+        <el-form-item label="整牌(6人)">
+          <el-input v-model="form.contentSex" type="textarea" :rows="3" placeholder="请按输入" />
+        </el-form-item>
+
+        <el-form-item label="整牌(7人)">
+          <el-input v-model="form.contentSeven" type="textarea" :rows="3" placeholder="请按输入" />
+        </el-form-item>
+
+        <el-form-item label="整牌(8人)">
+          <el-input v-model="form.contentEight" type="textarea" :rows="3" placeholder="请按输入" />
+        </el-form-item>
+
+        <el-form-item label="整牌(9人)">
+          <el-input v-model="form.contentNine" type="textarea" :rows="3" placeholder="请按输入" />
         </el-form-item>
       </el-form>
 
       <!-- 操作按钮 -->
       <div class="flex justify-center items-center space-x-4 mb-4">
         <el-button type="primary" @click="submitForm">生 效</el-button>
-        <!--        <el-button @click="resetForm">取消生效</el-button>-->
+        <el-button @click="removeRedisPokerHands2">取消生效</el-button>
       </div>
     </el-card>
   </div>
@@ -22,22 +53,48 @@
 
 <script setup name="CardTools" lang="ts">
 import { ref, reactive } from 'vue';
-import { addCardTools, selectBusinessCardToolsMaxNew } from '@/api/system/business/cardTools';
+import { addCardTools, selectBusinessCardToolsMaxNew, removeRedisPokerHands } from '@/api/system/business/cardTools';
 import { CardToolsForm } from '@/api/system/business/cardTools/types';
-
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 // 设置默认值
-const defaultContent = 'AS,AH,KS,KH,QS,QH,JS,JH,TS,TH,9S,9H,8S,8H,7S,7H,6S,6H,5S,5H,5D,5C,4H';
+const defaultContent = 'AS,AH,KS,KH,QS,QH,JS,JH,TS,TH,9S,9H,8S,8H,7S,7H,6S,6H,2H,5S,5H,5D,2C,5C,2D,4H';
+const defaultContentTwo = 'AS,AH,KS,KH,2H,5S,5H,5D,2C,5C,2D,4H';
+const defaultContentThree = 'AS,AH,KS,KH,QS,QH,2H,5S,5H,5D,2C,5C,2D,4H';
+const defaultContentFour = 'AS,AH,KS,KH,QS,QH,JS,JH,2H,5S,5H,5D,2C,5C,2D,4H';
+const defaultContentFive = 'AS,AH,KS,KH,QS,QH,JS,JH,TS,TH,2H,5S,5H,5D,2C,5C,2D,4H';
+const defaultContentSex = 'AS,AH,KS,KH,QS,QH,JS,JH,TS,TH,9S,9H,2H,5S,5H,5D,2C,5C,2D,4H';
+const defaultContentSeven = 'AS,AH,KS,KH,QS,QH,JS,JH,TS,TH,9S,9H,8S,8H,2H,5S,5H,5D,2C,5C,2D,4H';
+const defaultContentEight = 'AS,AH,KS,KH,QS,QH,JS,JH,TS,TH,9S,9H,8S,8H,7S,7H,2H,5S,5H,5D,2C,5C,2D,4H';
+const defaultContentNine = 'AS,AH,KS,KH,QS,QH,JS,JH,TS,TH,9S,9H,8S,8H,7S,7H,6S,6H,2H,5S,5H,5D,2C,5C,2D,4H';
 
 const form = reactive<CardToolsForm>({
-  content: defaultContent // 设置默认值
+  contentNine: defaultContentNine,
+  contentEight: defaultContentEight,
+  contentSeven: defaultContentSeven,
+  contentSex: defaultContentSex,
+  contentFive: defaultContentFive,
+  contentFour: defaultContentFour,
+  contentThree: defaultContentThree,
+  contentTwo: defaultContentTwo,
+  isDelete: 0
 });
 
 /** 提交表单 */
 const submitForm = () => {
+  // 构建要提交的数据
+  const formData = {
+    contentTwo: form.contentTwo,
+    contentThree: form.contentThree,
+    contentFour: form.contentFour,
+    contentFive: form.contentFive,
+    contentSex: form.contentSex,
+    contentSeven: form.contentSeven,
+    contentEight: form.contentEight,
+    contentNine: form.contentNine,
+    isDelete: 0
+  };
   // 调用 addCardTools 接口
-  addCardTools({
-    content: form.content
-  })
+  addCardTools(formData)
     .then(() => {
       proxy?.$modal.msgSuccess('生效成功');
     })
@@ -45,8 +102,11 @@ const submitForm = () => {
       let proxy;
       proxy?.$modal.msgError('生效失败');
     });
+  loadLastContent();
 };
-
+const effectiveText = computed(() => {
+  return form.isDelete === 0 ? '已生效' : '未生效';
+});
 /** 重置表单 */
 const resetForm = () => {
   form.content = defaultContent; // 重置为默认值
@@ -55,9 +115,21 @@ const resetForm = () => {
 /** 获取上一次写入的数据 */
 const loadLastContent = async () => {
   try {
+    //TODO完善
     const res = await selectBusinessCardToolsMaxNew();
-    if (res.data && res.data.content) {
+    if (res.data && res.data.contentTwo) {
       form.content = res.data.content;
+      form.contentTwo = res.data.contentTwo;
+      form.contentThree = res.data.contentThree;
+      form.contentFour = res.data.contentFour;
+      form.contentFive = res.data.contentFive;
+      form.contentSex = res.data.contentSex;
+      form.contentSeven = res.data.contentSeven;
+      form.contentEight = res.data.contentEight;
+      form.contentNine = res.data.contentNine;
+      form.isDelete = res.data.isDelete;
+    } else {
+      form.isDelete = 1;
     }
   } catch (error) {
     console.error('获取上一次数据失败:', error);
@@ -66,6 +138,19 @@ const loadLastContent = async () => {
   }
 };
 
+const removeRedisPokerHands2 = async () => {
+  try {
+    await proxy?.$modal.confirm('是否确认取消当前牌局配置的生效?此操作将恢复为上次保存的状态。');
+
+    await removeRedisPokerHands();
+    await loadLastContent();
+
+    proxy?.$modal.msgSuccess('已取消生效');
+  } catch (error) {
+    proxy?.$modal.msgError('操作失败,请稍后重试');
+  }
+};
+
 // 页面加载时获取上一次的数据
 onMounted(() => {
   loadLastContent();
@@ -94,4 +179,43 @@ onMounted(() => {
 .font-bold {
   font-weight: bold;
 }
+
+/* 添加新的样式来控制表单宽度 */
+.el-form {
+  max-width: 100%;
+  width: 100%;
+}
+
+.el-form-item {
+  margin-bottom: 16px;
+}
+
+.el-form-item__label {
+  width: 80px !important;
+  text-align: right;
+  padding-right: 12px;
+}
+
+.el-form-item__content {
+  flex: 1;
+  min-width: 0;
+}
+
+.el-input--textarea {
+  width: 100% !important;
+  max-width: 100%;
+}
+
+/* 确保输入框不会超出父容器 */
+.el-textarea {
+  width: 100% !important;
+  max-width: 100%;
+}
+
+/* 调整卡片容器的宽度 */
+.el-card {
+  max-width: 100%;
+  width: 100%;
+  box-sizing: border-box;
+}
 </style>

+ 13 - 6
src/views/system/business/tournaments/index.vue

@@ -280,11 +280,11 @@
           <el-input v-model="form.startingChips" placeholder="请输入起始记分牌数量" :disabled="dialog.mode === 'view'" />
         </el-form-item>
 
-        <el-form-item label="级别持续时间" prop="levelDuration">
-          <el-input v-model="form.levelDuration" placeholder="请输入级别持续时间" :disabled="dialog.mode === 'view'" />
+        <el-form-item label="级别持续时间" prop="levelDuration" v-if="dialog.mode === 'edit'">
+          <el-input v-model="form.levelDuration" placeholder="请输入级别持续时间" />
         </el-form-item>
 
-        <el-form-item label="机器人数" prop="robotCount">
+        <el-form-item label="机器人数" prop="robotCount" v-if="!isProdEnvironment">
           <el-input v-model="form.robotCount" placeholder="请输入机器人数" :disabled="dialog.mode === 'view'" />
         </el-form-item>
 
@@ -495,7 +495,7 @@ const iconFile = ref<File | null>(null); // 存储选中的图标文件
 const dialog = reactive<{
   visible: boolean;
   title: string;
-  mode: 'edit' | 'view'; // 新增字段
+  mode: 'edit' | 'view' | 'add'; // 新增字段
 }>({
   visible: false,
   title: '',
@@ -787,7 +787,7 @@ const handleAdd = () => {
   competitionIcon.value = ''; // 如果需要清除后台加载的图标,可以在这里设置为空字符串
   dialog.visible = true;
   dialog.title = '创建比赛';
-  dialog.mode = 'edit'; // 设置模式
+  dialog.mode = 'add'; // 设置模式
 };
 // 重置函数
 const resetFormPrize = () => {
@@ -1232,6 +1232,7 @@ const handleCopy = async (row?: TournamentsVO) => {
   form.value.gameType = String(res.data.gameType); // 转为字符串
   form.value.status = 0;
   form.value.id = null;
+  form.value.levelDuration = null;
   competitionIcon.value = res.data.competitionIcon;
   // 处理奖励表单数据
   const prizeItems = res.data.itemsPrizeList || [];
@@ -1250,7 +1251,7 @@ const handleCopy = async (row?: TournamentsVO) => {
       }
     ];
   }
-
+  dialog.mode = 'add'; // 设置为新增模式
   dialog.visible = true;
   dialog.title = '创建比赛';
 };
@@ -1285,4 +1286,10 @@ const handleGoToStructures = () => {
     proxy?.$router.push('/business/structures');
   });
 };
+
+// 判断是否为正式环境
+const isProdEnvironment = computed(() => {
+  // 根据实际项目中的环境变量判断是否为正式环境
+  return import.meta.env.MODE === 'production' || import.meta.env.VITE_APP_ENV === 'prod';
+});
 </script>