zs 1 rok temu
rodzic
commit
1e5059f3f5
2 zmienionych plików z 59 dodań i 14 usunięć
  1. 8 11
      src/views/match/course/detail.vue
  2. 51 3
      src/views/match/course/index.vue

+ 8 - 11
src/views/match/course/detail.vue

@@ -13,12 +13,6 @@
             <template #blue_team_id>
               <el-option v-for="i in applicationList" :key="i.team_id" :label="i.team_name" :value="i.team_id"></el-option>
             </template>
-            <template #winner>
-              <el-option v-for="i in applicationList" :key="i.team_id" :label="i.team_name" :value="i.team_id"></el-option>
-            </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>
@@ -57,12 +51,8 @@ const rules = reactive<FormRules>({
 let fields: Ref<any[]> = ref([
   { label: '比赛名称', model: 'match_name', options: { disabled: true } },
   { label: '红方团队名称', model: 'red_team_id', type: 'select' },
-  { label: '红方分数', model: 'red_score' },
   { label: '蓝方团队名称', model: 'blue_team_id', type: 'select' },
-  { label: '蓝方分数', model: 'blue_score' },
-  { label: '胜者', model: 'winner', type: 'select' },
-  { label: '比赛时间', model: 'match_time', type: 'datetime' },
-  { label: '状态', model: 'status', type: 'select' }
+  { label: '比赛时间', model: 'match_time', type: 'datetime' }
 ]);
 // 字典表
 const statusList: Ref<any> = ref([]);
@@ -77,6 +67,13 @@ onMounted(async () => {
 const search = async () => {
   let id = route.query.id;
   if (id) {
+    const list = [
+      { label: '比赛名称', model: 'match_name', options: { disabled: true } },
+      { label: '红方团队名称', model: 'red_team_id', type: 'select' },
+      { label: '蓝方团队名称', model: 'blue_team_id', type: 'select' },
+      { label: '比赛时间', model: 'match_time', type: 'datetime' }
+    ];
+    fields.value = list;
     let res: IQueryResult = await courseAxios.fetch(id);
     if (res.errcode == '0') {
       let info: any = res.data as {};

+ 51 - 3
src/views/match/course/index.vue

@@ -17,10 +17,24 @@
           </cButton>
         </el-col>
         <el-col :span="24" class="thr">
-          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @edit="toEdit" @del="toDel"> </cTable>
+          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @status="toStatus" @edit="toEdit" @del="toDel"> </cTable>
         </el-col>
       </el-col>
     </el-row>
+    <cDialog :dialog="dialog" @toClose="toClose">
+      <template v-slot:info>
+        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
+          <cForm :span="24" :fields="formFields" :form="form" :rules="{}" @save="toSave" label-width="auto">
+            <template #winner>
+              <el-option v-for="i in applicationList" :key="i.team_id" :label="i.team_name" :value="i.team_id"></el-option>
+            </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>
+      </template>
+    </cDialog>
   </div>
 </template>
 
@@ -60,14 +74,24 @@ let fields: Ref<any[]> = ref([
 ]);
 // 操作
 let opera: Ref<any[]> = ref([
-  { label: '修改', method: 'edit' },
-  { label: '删除', method: 'del', confirm: true, type: 'danger' }
+  { label: '赛程状态', method: 'status' },
+  { label: '修改', method: 'edit', display: (i) => i.status == '0' },
+  { label: '删除', method: 'del', confirm: true, type: 'danger', display: (i) => i.status == '0' }
 ]);
 // 查询数据
 let searchForm: Ref<any> = ref({});
 // 字典表
 const statusList: Ref<any> = ref([]);
 const applicationList: Ref<any> = ref([]);
+// 弹框
+const dialog: Ref<any> = ref({ title: '赛程状态', show: false, type: '1' });
+const form: Ref<any> = ref({ file: [] });
+const formFields: Ref<any> = ref([
+  { label: '红方分数', model: 'red_score' },
+  { label: '蓝方分数', model: 'blue_score' },
+  { label: '胜者', model: 'winner', type: 'select' },
+  { label: '状态', model: 'status', type: 'select' }
+]);
 // 请求
 onMounted(async () => {
   loading.value = true;
@@ -98,6 +122,14 @@ const getDict = (e, model) => {
     else return '暂无';
   }
 };
+// 赛程状态
+const toStatus = async (data) => {
+  let res: IQueryResult = await courseAxios.fetch(data._id);
+  if (res.errcode == '0') {
+    form.value = res.data;
+    dialog.value = { title: '赛程状态', show: true, type: '1' };
+  }
+};
 // 添加
 const toAdd = () => {
   router.push({ path: '/match/course/detail', query: { match_id: id.value } });
@@ -124,6 +156,22 @@ const searchOther = async () => {
   res = await applicationAxios.query({ match_id: id.value, status: '1' });
   if (res.errcode == '0') applicationList.value = res.data;
 };
+// 提交保存
+const toSave = async (data) => {
+  let res: IQueryResult = await courseAxios.update(data);
+  if (res.errcode == '0') {
+    ElMessage({ message: '信息审核成功', type: 'success' });
+    toClose();
+  } else {
+    ElMessage({ message: `${res.errmsg}`, type: 'error' });
+  }
+};
+// 关闭弹框
+const toClose = () => {
+  form.value = {};
+  dialog.value = { show: false };
+  search({ skip, limit });
+};
 // 返回上一页
 const toBack = () => {
   window.history.go(-1);