Explorar o código

修改比赛管理

zs %!s(int64=2) %!d(string=hai) anos
pai
achega
6b5235559b
Modificáronse 3 ficheiros con 80 adicións e 26 borrados
  1. 71 17
      src/views/match/detail.vue
  2. 9 5
      src/views/match/index.vue
  3. 0 4
      src/views/team/examine/detail.vue

+ 71 - 17
src/views/match/detail.vue

@@ -1,8 +1,20 @@
 <template>
-  <div id="index">
+  <div id="detail">
     <el-row>
       <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
-        <el-col :span="24" class="one">系统首页</el-col>
+        <el-col :span="24" class="one">
+          <cSearch :is_title="false" :is_back="true" @toBack="toBack"></cSearch>
+        </el-col>
+        <el-col :span="24" class="two">
+          <cForm :span="24" :fields="fields" :form="form" :rules="rules" @save="toSave" label-width="auto">
+            <template #information>
+              <cEditor v-model="form.information" url="/files/ball/match/upload"></cEditor>
+            </template>
+            <template #status>
+              <el-option v-for="i in statusList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </cForm>
+        </el-col>
       </el-col>
     </el-row>
   </div>
@@ -11,28 +23,70 @@
 <script setup lang="ts">
 // 基础
 import type { Ref } from 'vue';
-// reactive,
-import { onMounted, ref, getCurrentInstance } from 'vue';
+import { ref, reactive, onMounted } from 'vue';
+import type { FormRules } from 'element-plus';
+import { ElMessage } from 'element-plus';
+import { useRoute } from 'vue-router';
 // 接口
-//import { TestStore } from '@common/src/stores/test';
-//import type { IQueryResult } from '@/util/types.util';
-//const testAxios = TestStore();
-const { proxy } = getCurrentInstance() as any;
+import { MatchStore } from '@/stores/match/match';
+import { DictDataStore } from '@/stores/dict/dictData'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+const matchAxios = MatchStore();
+const dictAxios = DictDataStore();
+const route = useRoute();
 // 加载中
 const loading: Ref<any> = ref(false);
-// 分页数据
-//  const skip = 0;
-//  const limit = proxy.limit;;
+// 表单
+let form: Ref<any> = ref({});
+const rules = reactive<FormRules>({});
+let fields: Ref<any[]> = ref([
+  { label: '比赛名称', model: 'name' },
+  { label: '开始时间', model: 'start_time', type: 'datetime' },
+  { label: '结束时间', model: 'end_time', type: 'datetime' },
+  { label: '比赛地点', model: 'address' },
+  { label: '报名截止时间', model: 'sign_deadline', type: 'datetime' },
+  { label: '比赛信息', model: 'information', custom: true },
+  { label: '状态', model: 'status', type: 'select' }
+]);
+// 字典表
+const statusList: Ref<any> = ref([]);
 // 请求
 onMounted(async () => {
   loading.value = true;
-  //  await search({ skip, limit });
+  await searchOther();
+  await search();
   loading.value = false;
 });
-//const search = async (e: { skip: number; limit: number }) => {
-//  const info = { skip: e.skip, limit: e.limit, ...searchInfo.value  };
-//  const res: IQueryResult = await testAxios.query(info);
-//  console.log(res);
-//};
+const search = async () => {
+  let id = route.query.id;
+  if (id) {
+    let res: IQueryResult = await matchAxios.fetch(id);
+    if (res.errcode == '0') {
+      let info: any = res.data as {};
+      form.value = info;
+    }
+  }
+};
+// 保存
+const toSave = async (data) => {
+  let res: IQueryResult;
+  if (data._id) res = await matchAxios.update(data);
+  else res = await matchAxios.create(data);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `维护信息成功` });
+    toBack();
+  }
+};
+// 查询其他信息
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 性别
+  res = await dictAxios.query({ type: 'match_status' });
+  if (res.errcode == '0') statusList.value = res.data;
+};
+// 返回上一页
+const toBack = () => {
+  window.history.go(-1);
+};
 </script>
 <style scoped lang="scss"></style>

+ 9 - 5
src/views/match/index.vue

@@ -3,13 +3,17 @@
     <el-row>
       <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
         <el-col :span="24" class="one">
-          <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch"> </cSearch>
+          <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch">
+            <template #status>
+              <el-option v-for="(i, index) in statusList" :key="index" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </cSearch>
         </el-col>
         <el-col :span="24" class="two">
           <cButton @toAdd="toAdd()"> </cButton>
         </el-col>
         <el-col :span="24" class="thr">
-          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @view="toView" @del="toDel"> </cTable>
+          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @edit="toEdit" @del="toDel"> </cTable>
         </el-col>
       </el-col>
     </el-row>
@@ -43,11 +47,11 @@ let fields: Ref<any[]> = ref([
   { label: '结束时间', model: 'end_time' },
   { label: '比赛地点', model: 'address' },
   { label: '报名截止时间', model: 'sign_deadline' },
-  { label: '状态', model: 'status', format: (i: any) => getDict(i, 'status') }
+  { label: '状态', model: 'status', type: 'select', isSearch: true, format: (i: any) => getDict(i, 'status') }
 ]);
 // 操作
 let opera: Ref<any[]> = ref([
-  { label: '查看', method: 'view', tpye: 'Info' },
+  { label: '修改', method: 'edit' },
   { label: '删除', method: 'del', confirm: true, type: 'danger' }
 ]);
 // 查询数据
@@ -85,7 +89,7 @@ const toAdd = () => {
   router.push({ path: '/match/detail' });
 };
 // 查看
-const toView = (data) => {
+const toEdit = (data) => {
   router.push({ path: '/match/detail', query: { id: data._id } });
 };
 // 删除

+ 0 - 4
src/views/team/examine/detail.vue

@@ -119,10 +119,6 @@ const searchOther = async () => {
   res = await dictAxios.query({ type: 'gender' });
   if (res.errcode == '0') genderList.value = res.data;
 };
-// 图片预览
-const imgView = (url: any) => {
-  window.open(url);
-};
 // 返回上一页
 const toBack = () => {
   window.history.go(-1);