|
|
@@ -86,11 +86,38 @@
|
|
|
<script>
|
|
|
import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
|
|
|
+<<<<<<< HEAD
|
|
|
export default {
|
|
|
name: "GroupTab",
|
|
|
props: {
|
|
|
courseId: {
|
|
|
required: true,
|
|
|
+=======
|
|
|
+export default {
|
|
|
+ name: "GroupTab",
|
|
|
+ props: {
|
|
|
+ courseId: {
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ teacherId: {
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ groupTableData: [],
|
|
|
+ groupData: null,
|
|
|
+
|
|
|
+ isRuleExisted: false,
|
|
|
+ ruleFormDialog: false,
|
|
|
+ maxNameLen:10,
|
|
|
+ ruleForm: {
|
|
|
+ dialogTitle: "制定组队规则",
|
|
|
+ courseVO: null,
|
|
|
+ id: null,
|
|
|
+ maxSize: null,
|
|
|
+ maxNameLen: null,
|
|
|
+>>>>>>> efe3831aac9edd6d113ed30d273ebeb3776bb381
|
|
|
},
|
|
|
teacherId: {
|
|
|
required: true,
|
|
|
@@ -111,6 +138,7 @@
|
|
|
maxSize: null,
|
|
|
maxNameLen: null,
|
|
|
},
|
|
|
+<<<<<<< HEAD
|
|
|
ruleFormRule: {
|
|
|
maxSize: {
|
|
|
required: true, message: "请选择小组最大成员人数", trigger: "change",
|
|
|
@@ -132,6 +160,158 @@
|
|
|
} else {
|
|
|
return Number(value);
|
|
|
}
|
|
|
+=======
|
|
|
+ maxNameLen: {
|
|
|
+ required: true, message: "请选择组名最大长度", trigger: "change",
|
|
|
+ }
|
|
|
+ },
|
|
|
+ addMemberRule: {
|
|
|
+ phone: [{required: true, message: "手机号不能为空"},
|
|
|
+ {
|
|
|
+ type: "number",
|
|
|
+ message: "手机号格式不正确",
|
|
|
+ trigger: "blur",
|
|
|
+ transform(value) {
|
|
|
+ var phonereg = 11 && /^((13|14|15|16|17|18|19)[0-9]{1}\d{8})$/;
|
|
|
+ if (!phonereg.test(value)) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return Number(value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ },
|
|
|
+
|
|
|
+ createGroupDialog: false,
|
|
|
+ createGroupForm: {
|
|
|
+ dialogTitle: "队伍信息",
|
|
|
+ courseId: null,
|
|
|
+ name: null,
|
|
|
+ },
|
|
|
+
|
|
|
+ addMemberDialog: false,
|
|
|
+ addMemberForm: {
|
|
|
+ dialogTitle: "组员信息",
|
|
|
+ phone: null,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ isCreator() {
|
|
|
+ return Number(this.teacherId) === Number(this.$store.state.user.id);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async init() {
|
|
|
+ const _this = this;
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ beforeRuleFormClose() {
|
|
|
+ const _this = this;
|
|
|
+ _this.ruleFormDialog = false;
|
|
|
+ _this.$refs.ruleFormRef.resetFields();
|
|
|
+ },
|
|
|
+
|
|
|
+ handleCreateRuleConfirm() {
|
|
|
+ this.$refs.ruleFormRef.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ let RuleVO = {
|
|
|
+ courseVO: {id: this.courseId},
|
|
|
+ maxSize: this.ruleForm.maxSize,
|
|
|
+ maxNameLen: this.ruleForm.maxNameLen,
|
|
|
+ };
|
|
|
+ this.$apis.createGroupRule(RuleVO)
|
|
|
+ .then(res => {
|
|
|
+ if (res.data.code) {
|
|
|
+ ElMessage.error(res.data.message);
|
|
|
+ } else {
|
|
|
+ this.isRuleExisted = true;
|
|
|
+ this.ruleFormDialog = false;
|
|
|
+ this.$refs.ruleFormRef.resetFields();
|
|
|
+ ElMessage.success("创建规则成功");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ beforeGroupFormClose() {
|
|
|
+ this.createGroupDialog = false;
|
|
|
+ this.$refs.createGroupFormRef.resetFields();
|
|
|
+ },
|
|
|
+
|
|
|
+ handleCreateGroupConfirm() {
|
|
|
+ if (this.createGroupForm.name.length===0){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ if (this.createGroupForm.name.length>this.maxNameLen){
|
|
|
+ this.createGroupForm.name="";
|
|
|
+ ElMessage.error("创建队伍失败!队伍名称长度不能超过"+this.maxNameLen+"!");
|
|
|
+ }
|
|
|
+ this.$refs.createGroupFormRef.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ let GroupVO = {
|
|
|
+ courseId: this.courseId,
|
|
|
+ name: this.createGroupForm.name,
|
|
|
+ };
|
|
|
+ this.$apis.createGroup(GroupVO)
|
|
|
+ .then(res => {
|
|
|
+ if (res.data.code) {
|
|
|
+ ElMessage.error(res.data.message);
|
|
|
+ } else {
|
|
|
+ this.groupData = res.data.data;
|
|
|
+ this.groupTableData.push(res.data.data);
|
|
|
+ this.createGroupDialog = false;
|
|
|
+ this.$refs.createGroupFormRef.resetFields();
|
|
|
+ ElMessage.success("创建队伍成功");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ beforeGroupMemberFormClose() {
|
|
|
+ this.addMemberDialog = false;
|
|
|
+ this.$refs.addMemberFormRef.resetFields();
|
|
|
+ },
|
|
|
+
|
|
|
+ handleAddMemberConfirm() {
|
|
|
+ const _this = this;
|
|
|
+ this.$refs.addMemberFormRef.validate(async (valid) => {
|
|
|
+ if (valid) {
|
|
|
+ const userIdRes = (await _this.$apis.findUserIdByPhone(_this.addMemberForm.phone)).data;
|
|
|
+ if (userIdRes.code) {
|
|
|
+ ElMessage.error(userIdRes.message);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let groupMemberVO = {
|
|
|
+ userId: userIdRes.data,
|
|
|
+ groupId: _this.groupData["groupVO"].id,
|
|
|
+ courseId: _this.courseId,
|
|
|
+ };
|
|
|
+ this.$apis.sendInvitation(groupMemberVO)
|
|
|
+ .then(res => {
|
|
|
+ if (res.data.code) {
|
|
|
+ ElMessage.error(res.data.message);
|
|
|
+ } else {
|
|
|
+ ElMessage.success("已发送邀请,请等候其同意。");
|
|
|
+>>>>>>> efe3831aac9edd6d113ed30d273ebeb3776bb381
|
|
|
}
|
|
|
}],
|
|
|
},
|
|
|
@@ -273,7 +453,13 @@
|
|
|
},
|
|
|
|
|
|
},
|
|
|
+<<<<<<< HEAD
|
|
|
};
|
|
|
+=======
|
|
|
+
|
|
|
+ },
|
|
|
+};
|
|
|
+>>>>>>> efe3831aac9edd6d113ed30d273ebeb3776bb381
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|