瀏覽代碼

feat(system): 添加牌局测试工具功能

- 新增 cardTools API 接口,包括列表、详情、新增、修改、删除等功能- 实现牌局测试工具页面,支持整牌设置和生效操作
- 添加 CardTools 类型定义,包括 VO、Form 和 Query接口
fugui001 4 月之前
父節點
當前提交
1d9209200d

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

@@ -0,0 +1,72 @@
+import request from '@/utils/request';
+import { AxiosPromise } from 'axios';
+import { CardToolsVO, CardToolsForm, CardToolsQuery } from '@/api/system/business/cardTools/types';
+
+/**
+ * 查询配牌记录列表
+ * @param query
+ * @returns {*}
+ */
+
+export const listCardTools = (query?: CardToolsQuery): AxiosPromise<CardToolsVO[]> => {
+  return request({
+    url: '/business/cardTools/list',
+    method: 'get',
+    params: query
+  });
+};
+
+/**
+ * 查询配牌记录详细
+ * @param id
+ */
+export const getCardTools = (id: string | number): AxiosPromise<CardToolsVO> => {
+  return request({
+    url: '/business/cardTools/' + id,
+    method: 'get'
+  });
+};
+
+/**
+ * 新增配牌记录
+ * @param data
+ */
+export const addCardTools = (data: CardToolsForm) => {
+  return request({
+    url: '/business/cardTools',
+    method: 'post',
+    data: data
+  });
+};
+
+/**
+ * 修改配牌记录
+ * @param data
+ */
+export const updateCardTools = (data: CardToolsForm) => {
+  return request({
+    url: '/business/cardTools',
+    method: 'put',
+    data: data
+  });
+};
+
+/**
+ * 删除配牌记录
+ * @param id
+ */
+export const delCardTools = (id: string | number | Array<string | number>) => {
+  return request({
+    url: '/business/cardTools/' + id,
+    method: 'delete'
+  });
+};
+/**
+ * 查询最新配牌记录
+ */
+export const selectBusinessCardToolsMaxNew = (): AxiosPromise<CardToolsVO> => {
+  return request({
+    url: '/business/cardTools/selectBusinessCardToolsMaxNew',
+    method: 'get'
+  });
+};

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

@@ -0,0 +1,82 @@
+export interface CardToolsVO {
+  /**
+   * 配牌记录ID
+   */
+  id: string | number;
+
+  /**
+   * 操作人
+   */
+  operateName: string;
+
+  /**
+   * 整副牌内容
+   */
+  content: string;
+
+  /**
+   * 创建时间
+   */
+  createAt: string;
+
+  /**
+   * 更新时间
+   */
+  updateAt: string;
+}
+
+export interface CardToolsForm extends BaseEntity {
+  /**
+   * 配牌记录ID
+   */
+  id?: string | number;
+
+  /**
+   * 操作人
+   */
+  operateName?: string;
+
+  /**
+   * 整副牌内容
+   */
+  content?: string;
+
+  /**
+   * 创建时间
+   */
+  createAt?: string;
+
+  /**
+   * 更新时间
+   */
+  updateAt?: string;
+
+  handCards?: string;
+}
+
+export interface CardToolsQuery extends PageQuery {
+  /**
+   * 操作人
+   */
+  operateName?: string;
+
+  /**
+   * 整副牌内容
+   */
+  content?: string;
+
+  /**
+   * 创建时间
+   */
+  createAt?: string;
+
+  /**
+   * 更新时间
+   */
+  updateAt?: string;
+
+  /**
+   * 日期范围参数
+   */
+  params?: any;
+}

+ 97 - 0
src/views/system/business/cardTools/index.vue

@@ -0,0 +1,97 @@
+<template>
+  <div class="p-2">
+    <el-card shadow="hover">
+      <!-- 页面标题 -->
+      <div class="mb-[10px] text-sm font-medium">牌局测试工具</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>
+      </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>-->
+      </div>
+    </el-card>
+  </div>
+</template>
+
+<script setup name="CardTools" lang="ts">
+import { ref, reactive } from 'vue';
+import { addCardTools, selectBusinessCardToolsMaxNew } from '@/api/system/business/cardTools';
+import { CardToolsForm } from '@/api/system/business/cardTools/types';
+
+// 设置默认值
+const defaultContent = 'AS,AH,KS,KH,QS,QH,JSJH,TS,TH,9S,9H,8S,8H,7S,7H,6S,6H,5S,5H,5D,5C,4H';
+
+const form = reactive<CardToolsForm>({
+  content: defaultContent // 设置默认值
+});
+
+/** 提交表单 */
+const submitForm = () => {
+  // 调用 addCardTools 接口
+  addCardTools({
+    content: form.content
+  })
+    .then(() => {
+      proxy?.$modal.msgSuccess('生效成功');
+    })
+    .catch(() => {
+      let proxy;
+      proxy?.$modal.msgError('生效失败');
+    });
+};
+
+/** 重置表单 */
+const resetForm = () => {
+  form.content = defaultContent; // 重置为默认值
+};
+
+/** 获取上一次写入的数据 */
+const loadLastContent = async () => {
+  try {
+    const res = await selectBusinessCardToolsMaxNew();
+    if (res.data && res.data.content) {
+      form.content = res.data.content;
+    }
+  } catch (error) {
+    console.error('获取上一次数据失败:', error);
+    // 如果获取失败,使用默认值
+    form.content = defaultContent;
+  }
+};
+
+// 页面加载时获取上一次的数据
+onMounted(() => {
+  loadLastContent();
+});
+</script>
+
+<style scoped>
+.flex {
+  display: flex;
+}
+.justify-center {
+  justify-content: center;
+}
+.items-center {
+  align-items: center;
+}
+.space-x-4 {
+  gap: 1rem;
+}
+.mb-4 {
+  margin-bottom: 1rem;
+}
+.text-center {
+  text-align: center;
+}
+.font-bold {
+  font-weight: bold;
+}
+</style>