|
|
@@ -8,9 +8,8 @@
|
|
|
</el-button>
|
|
|
<div v-else>
|
|
|
<el-button v-if="!groupData" class="tabs-function-button"
|
|
|
- :disabled="!isRuleExisted"
|
|
|
- plain type="primary" @click="createGroupDialog=true">
|
|
|
- 创建队伍
|
|
|
+ plain type="primary" @click="handleCreateGroupClick">
|
|
|
+ {{ isRuleExisted ? "创建队伍" : "创建队伍(未开放)" }}
|
|
|
</el-button>
|
|
|
<div v-else>
|
|
|
<el-button class="tabs-function-button"
|
|
|
@@ -174,21 +173,35 @@ export default {
|
|
|
async init() {
|
|
|
const _this = this;
|
|
|
_this.groupTableData = []; // init前置空
|
|
|
- const ruleRes = (await _this.$apis.findGroupRule(_this.courseId)).data;
|
|
|
- _this.isRuleExisted = !ruleRes.code;
|
|
|
- if (_this.isRuleExisted) {
|
|
|
- _this.maxNameLen=ruleRes.data.maxNameLen;
|
|
|
- const groupsRes = (await _this.$apis.findAllGroupsByCourse(_this.courseId)).data;
|
|
|
- if (!groupsRes.code) {
|
|
|
- _this.groupTableData = groupsRes.data;
|
|
|
- }
|
|
|
- const groupRes = (await _this.$apis.findGroup(_this.courseId)).data;
|
|
|
- if (!groupRes.code) {
|
|
|
- _this.groupData = groupRes.data;
|
|
|
+ _this.groupData = null;
|
|
|
+ _this.isRuleExisted = false;
|
|
|
+ try {
|
|
|
+ const ruleRes = (await _this.$apis.findGroupRule(_this.courseId)).data;
|
|
|
+ _this.isRuleExisted = !ruleRes.code;
|
|
|
+ if (_this.isRuleExisted) {
|
|
|
+ _this.maxNameLen = ruleRes.data.maxNameLen;
|
|
|
+ const groupsRes = (await _this.$apis.findAllGroupsByCourse(_this.courseId)).data;
|
|
|
+ if (!groupsRes.code) {
|
|
|
+ _this.groupTableData = groupsRes.data;
|
|
|
+ }
|
|
|
+ const groupRes = (await _this.$apis.findGroup(_this.courseId)).data;
|
|
|
+ if (!groupRes.code) {
|
|
|
+ _this.groupData = groupRes.data;
|
|
|
+ }
|
|
|
}
|
|
|
+ } catch (e) {
|
|
|
+ _this.isRuleExisted = false;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ handleCreateGroupClick() {
|
|
|
+ if (!this.isRuleExisted) {
|
|
|
+ ElMessage.warning("当前课程尚未开放组队,请联系教师先开放组队规则。");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.createGroupDialog = true;
|
|
|
+ },
|
|
|
+
|
|
|
beforeRuleFormClose() {
|
|
|
const _this = this;
|
|
|
_this.ruleFormDialog = false;
|
|
|
@@ -235,12 +248,18 @@ export default {
|
|
|
},
|
|
|
|
|
|
handleCreateGroupConfirm() {
|
|
|
- if (this.createGroupForm.name.length===0){
|
|
|
- return ;
|
|
|
+ if (!this.isRuleExisted) {
|
|
|
+ ElMessage.warning("当前课程尚未开放组队,请联系教师先开放组队规则。");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.createGroupForm.name || this.createGroupForm.name.length === 0) {
|
|
|
+ ElMessage.error("队伍名称不能为空");
|
|
|
+ return;
|
|
|
}
|
|
|
if (this.createGroupForm.name.length>this.maxNameLen){
|
|
|
this.createGroupForm.name="";
|
|
|
ElMessage.error("创建队伍失败!队伍名称长度不能超过"+this.maxNameLen+"!");
|
|
|
+ return;
|
|
|
}
|
|
|
this.$refs.createGroupFormRef.validate((valid) => {
|
|
|
if (valid) {
|
|
|
@@ -302,4 +321,4 @@ export default {
|
|
|
|
|
|
<style scoped>
|
|
|
@import "tabs.css";
|
|
|
-</style>
|
|
|
+</style>
|