|
@@ -1,229 +0,0 @@
|
|
|
-<template>
|
|
|
- <div id="index">
|
|
|
- <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">
|
|
|
- <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()">
|
|
|
- <template v-slot:custom>
|
|
|
- <el-button type="primary" @click="toBack">返回</el-button>
|
|
|
- </template>
|
|
|
- </cButton>
|
|
|
- </el-col>
|
|
|
- <el-col :span="24" class="thr">
|
|
|
- <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" @dataChange="dataChange" label-width="auto">
|
|
|
- <template #winner>
|
|
|
- <el-option v-for="item in winnerList" :key="item._id" :label="item.name" :value="item._id">
|
|
|
- <span style="float: left">{{ item.name }}</span>
|
|
|
- <span style="float: right; color: #8492a6; font-size: 13px">{{ item.color }}</span>
|
|
|
- </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>
|
|
|
-
|
|
|
-<script setup lang="ts">
|
|
|
-// 基础
|
|
|
-import type { Ref } from 'vue';
|
|
|
-import { onMounted, ref, getCurrentInstance } from 'vue';
|
|
|
-import { ElMessage } from 'element-plus';
|
|
|
-import { useRouter, useRoute } from 'vue-router';
|
|
|
-// 接口
|
|
|
-import { CourseStore } from '@/stores/match/course';
|
|
|
-import { TeamStore } from '@/stores/team/team';
|
|
|
-import { ApplicationStore } from '@/stores/match/application';
|
|
|
-import { DictDataStore } from '@/stores/dict/dictData'; // 字典表
|
|
|
-import type { IQueryResult } from '@/util/types.util';
|
|
|
-const courseAxios = CourseStore();
|
|
|
-const dictAxios = DictDataStore();
|
|
|
-const teamAxios = TeamStore();
|
|
|
-const applicationAxios = ApplicationStore();
|
|
|
-const { proxy } = getCurrentInstance() as any;
|
|
|
-// 路由
|
|
|
-const router = useRouter();
|
|
|
-const route = useRoute();
|
|
|
-// 加载中
|
|
|
-const loading: Ref<any> = ref(false);
|
|
|
-let id: Ref<any> = ref(route.query.id);
|
|
|
-let list: Ref<any> = ref([]);
|
|
|
-let total: Ref<number> = ref(0);
|
|
|
-let skip = 0;
|
|
|
-let limit: number = proxy.$limit;
|
|
|
-let fields: Ref<any[]> = ref([
|
|
|
- { label: '红方团队名称', model: 'red_team_name', isSearch: true },
|
|
|
- { label: '红方分数', model: 'red_score' },
|
|
|
- { label: '蓝方团队名称', model: 'blue_team_name' },
|
|
|
- { label: '蓝方分数', model: 'blue_score' },
|
|
|
- { label: '比赛时间', model: 'match_time' },
|
|
|
- { label: '胜者', model: 'winner', format: (i: any) => getDict(i, 'winner') },
|
|
|
- { label: '状态', model: 'status', type: 'select', isSearch: true, format: (i: any) => getDict(i, 'status') }
|
|
|
-]);
|
|
|
-// 操作
|
|
|
-let opera: Ref<any[]> = ref([
|
|
|
- { 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 applicaList: Ref<any> = ref([]);
|
|
|
-const winnerList: 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: 'status', type: 'select' }]);
|
|
|
-// 请求
|
|
|
-onMounted(async () => {
|
|
|
- loading.value = true;
|
|
|
- await searchOther();
|
|
|
- await search({ skip, limit });
|
|
|
- loading.value = false;
|
|
|
-});
|
|
|
-const search = async (e: { skip: number; limit: number }) => {
|
|
|
- const info = { skip: e.skip, limit: e.limit, ...searchForm.value, match_id: id.value };
|
|
|
- const res: IQueryResult = await courseAxios.query(info);
|
|
|
- if (res.errcode == '0') {
|
|
|
- list.value = res.data;
|
|
|
- total.value = res.total;
|
|
|
- }
|
|
|
-};
|
|
|
-const toSearch = (query) => {
|
|
|
- searchForm.value = query;
|
|
|
- search({ skip, limit });
|
|
|
-};
|
|
|
-// 选择
|
|
|
-const dataChange = ({ model, value }) => {
|
|
|
- if (model == 'status') {
|
|
|
- if (value == '-1') {
|
|
|
- formFields.value.splice(
|
|
|
- 3,
|
|
|
- 0,
|
|
|
- { label: '红方分数', model: 'red_score' },
|
|
|
- { label: '蓝方分数', model: 'blue_score' },
|
|
|
- { label: '胜者', model: 'winner', type: 'select' }
|
|
|
- );
|
|
|
- } else {
|
|
|
- formFields.value = [{ label: '状态', model: 'status', type: 'select' }];
|
|
|
- }
|
|
|
- }
|
|
|
-};
|
|
|
-const getDict = (e, model) => {
|
|
|
- if (model == 'status') {
|
|
|
- let data: any = statusList.value.find((i: any) => i.value == e);
|
|
|
- if (data) return data.label;
|
|
|
- else return '暂无';
|
|
|
- } else if (model == 'winner') {
|
|
|
- let name = '暂无';
|
|
|
- if (e) {
|
|
|
- let data: any = applicaList.value.find((i: any) => i.team_id == e);
|
|
|
- if (data) name = data.team_name;
|
|
|
- }
|
|
|
- return name;
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
-// 赛程状态
|
|
|
-const toStatus = async (data) => {
|
|
|
- let res: any = await courseAxios.fetch(data._id);
|
|
|
- if (res.errcode == '0') {
|
|
|
- form.value = res.data;
|
|
|
- // 胜者
|
|
|
- const { red_team_id, blue_team_id } = res.data;
|
|
|
- const red: any = await teamAxios.fetch(red_team_id);
|
|
|
- const blue: any = await teamAxios.fetch(blue_team_id);
|
|
|
- let list = [];
|
|
|
- red.data.color = '红方';
|
|
|
- blue.data.color = '蓝方';
|
|
|
- list.push(red.data);
|
|
|
- list.push(blue.data);
|
|
|
- winnerList.value = list;
|
|
|
- if (res.data.status == '-1') {
|
|
|
- formFields.value.splice(
|
|
|
- 3,
|
|
|
- 0,
|
|
|
- { label: '红方分数', model: 'red_score' },
|
|
|
- { label: '蓝方分数', model: 'blue_score' },
|
|
|
- { label: '胜者', model: 'winner', type: 'select' }
|
|
|
- );
|
|
|
- } else {
|
|
|
- formFields.value = [{ label: '状态', model: 'status', type: 'select' }];
|
|
|
- }
|
|
|
- dialog.value = { title: '赛程状态', show: true, type: '1' };
|
|
|
- }
|
|
|
-};
|
|
|
-// 添加
|
|
|
-const toAdd = () => {
|
|
|
- router.push({ path: '/match/course/detail', query: { match_id: id.value } });
|
|
|
-};
|
|
|
-// 修改
|
|
|
-const toEdit = (data) => {
|
|
|
- router.push({ path: '/match/course/detail', query: { id: data._id, match_id: id.value } });
|
|
|
-};
|
|
|
-// 删除
|
|
|
-const toDel = async (data: any) => {
|
|
|
- let res: IQueryResult = await courseAxios.del(data._id);
|
|
|
- if (res.errcode == 0) {
|
|
|
- ElMessage({ type: `success`, message: `刪除信息成功` });
|
|
|
- search({ skip, limit });
|
|
|
- }
|
|
|
-};
|
|
|
-// 查询其他信息
|
|
|
-const searchOther = async () => {
|
|
|
- let res: IQueryResult;
|
|
|
- // 状态
|
|
|
- res = await dictAxios.query({ type: 'course_status' });
|
|
|
- if (res.errcode == '0') statusList.value = res.data;
|
|
|
- // 报名团队
|
|
|
- res = await applicationAxios.query({ match_id: id.value });
|
|
|
- if (res.errcode == '0') applicaList.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 = {};
|
|
|
- formFields.value = [{ label: '状态', model: 'status', type: 'select' }];
|
|
|
- dialog.value = { show: false };
|
|
|
- search({ skip, limit });
|
|
|
-};
|
|
|
-// 返回上一页
|
|
|
-const toBack = () => {
|
|
|
- window.history.go(-1);
|
|
|
-};
|
|
|
-</script>
|
|
|
-<style scoped lang="scss">
|
|
|
-.main {
|
|
|
- .two {
|
|
|
- margin: 0 0 10px 0;
|
|
|
- }
|
|
|
-}
|
|
|
-</style>
|