班级管理管理成员设置

This commit is contained in:
2025-08-25 11:14:22 +08:00
parent a8f17dde98
commit ce6f877d4a
2 changed files with 192 additions and 169 deletions

View File

@@ -23,7 +23,7 @@ module.exports = {
}, },
// Various Dev Server settings // Various Dev Server settings
host: '192.168.110.162', // can be overwritten by process.env.HOST host: '192.168.110.160', // can be overwritten by process.env.HOST
port: 8001, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined port: 8001, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: true, autoOpenBrowser: true,
errorOverlay: true, errorOverlay: true,

View File

@@ -68,7 +68,6 @@
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item label="微信群二维码" prop="qrcode"> <el-form-item label="微信群二维码" prop="qrcode">
<el-upload <el-upload
class="avatar-uploader icon-uploader" class="avatar-uploader icon-uploader"
:action="baseUrl + '/oss/fileoss'" :action="baseUrl + '/oss/fileoss'"
@@ -110,13 +109,17 @@
<el-button type="primary" @click="saveAdd" v-if="!miniClassForm.id" <el-button type="primary" @click="saveAdd" v-if="!miniClassForm.id"
>创建班级</el-button >创建班级</el-button
> >
<el-button type="primary" @click="saveAdd" v-else> </el-button <el-button type="primary" @click="saveAdd" v-else> </el-button>
>
<template v-if="miniClassForm.id"> <template v-if="miniClassForm.id">
<el-button type="success" @click="kaiban" v-if="miniClassForm.state == '0' "> </el-button <el-button
type="success"
@click="kaiban"
v-if="miniClassForm.state == '0'"
> </el-button
><el-button type="warning" @click="jieban" v-if="showOverbtn" ><el-button type="warning" @click="jieban" v-if="showOverbtn"
> </el-button> > </el-button
>
</template> </template>
</div> </div>
</div> </div>
@@ -268,7 +271,9 @@ export default {
miniClassRules: { miniClassRules: {
modelId: [{ required: true, message: "必填项", trigger: "blur" }], modelId: [{ required: true, message: "必填项", trigger: "blur" }],
title: [{ required: true, message: "必填项", trigger: "blur" }], title: [{ required: true, message: "必填项", trigger: "blur" }],
number: [{ required: true, message: "请填入招收的学员人数", trigger: "blur" }], number: [
{ required: true, message: "请填入招收的学员人数", trigger: "blur" }
]
}, },
memberRules: { memberRules: {
monitor: [{ required: true, message: "必填项", trigger: "blur" }], monitor: [{ required: true, message: "必填项", trigger: "blur" }],
@@ -287,7 +292,7 @@ export default {
content: "", content: "",
icon: "", icon: "",
state: "0", state: "0",
qrcode:'', qrcode: "",
modelId: undefined modelId: undefined
}, },
member: { member: {
@@ -324,15 +329,13 @@ export default {
}, },
placeholder: "请输入正文" placeholder: "请输入正文"
}, },
showOverbtn: false, // 是否显示结班按钮 showOverbtn: false // 是否显示结班按钮
}; };
}, },
mounted() { mounted() {
if (this.miniClass) { if (this.miniClass) {
console.log("编辑小班", this.miniClass); console.log("编辑小班", this.miniClass);
this.getClassInfo() this.getClassInfo();
if (this.miniClass.classModel.id) { if (this.miniClass.classModel.id) {
this.modelList.push(this.miniClass.classModel); this.modelList.push(this.miniClass.classModel);
} }
@@ -344,35 +347,39 @@ export default {
} }
this.miniClassForm = this.miniClass; this.miniClassForm = this.miniClass;
if (this.miniClass.classUsers.length > 0) { if (this.miniClass.classUsers.length > 0) {
var list = [...this.miniClass.classUsers] var list = [...this.miniClass.classUsers];
// this.userList = [...this.miniClass.classUsers] // this.userList = [...this.miniClass.classUsers]
list.forEach(item => { list.forEach(item => {
let name = ''; let name = "";
if (item.name) { if (item.name) {
name = item.name name = item.name;
} else if (item.nickname) { } else if (item.nickname) {
name = item.nickname name = item.nickname;
} }
if(item.role == '1'){ if (item.role == "1") {
this.member.monitor = item.tel + '(' +name+')' this.member.monitor = item.userId;
} }
if(item.role == '2'){ if (item.role == "2") {
this.member.dmonitor = item.tel + '(' +name+')' this.member.dmonitor = item.userId ;
} }
if(item.role == '3'){ if (item.role == "3") {
this.member.learner = item.tel + '(' +name+')' this.member.learner = item.userId;
} }
if(item.role == '4'){ if (item.role == "4") {
this.member.scorer.push(item.tel + '(' +name+')') this.member.scorer.push(item.userId );
} }
if(item.role == '5'){ if (item.role == "5") {
this.member.counter.push(item.tel + '(' +name+')') this.member.counter.push(item.userId);
} }
item.id = item.userId item.id = item.userId;
this.userList.push(item) this.userList.push(item);
}) });
console.log("处理后的开班日期",this.miniClassForm.mstartseconds, this.miniClassForm.nowseconds); console.log(
"处理后的开班日期",
this.miniClassForm.mstartseconds,
this.miniClassForm.nowseconds
);
} }
} else { } else {
console.log("添加小班"); console.log("添加小班");
@@ -381,101 +388,116 @@ export default {
methods: { methods: {
// 获取小班详情 // 获取小班详情
async getClassInfo() { async getClassInfo() {
console.log('班级详情') console.log("班级详情");
this.$http({ this.$http({
url: this.$http.adornUrl("/common/class/getClassInfo"), url: this.$http.adornUrl("/common/class/getClassInfo"),
method: "post", method: "post",
data: this.$http.adornData({ data: this.$http.adornData({
classId: this.miniClass.id classId: this.miniClass.id
}) })
}) }).then(async ({ data }) => {
.then(async ({ data }) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.miniClassForm.startTime = data.result.class.startTime; this.miniClassForm.startTime = data.result.class.startTime;
var strStartTime = new Date(this.miniClassForm.startTime) var strStartTime = new Date(this.miniClassForm.startTime);
var StartTime = strStartTime.getTime() var StartTime = strStartTime.getTime();
console.log(';shijia',StartTime, data.result.class.startTime) console.log(";shijia", StartTime, data.result.class.startTime);
var nowTime = await this.getServerTime() // 服务器当前时间 var nowTime = await this.getServerTime(); // 服务器当前时间
console.log('服务器时间',nowTime) console.log("服务器时间", nowTime);
this.miniClassForm.mstartseconds = StartTime this.miniClassForm.mstartseconds = StartTime;
this.miniClassForm.nowseconds = nowTime this.miniClassForm.nowseconds = nowTime;
// if(this.miniClass.classModel.isExam == 0){ // 没有考试模块 // if(this.miniClass.classModel.isExam == 0){ // 没有考试模块
// var off70 = undefined // 时长过70%显示结班按钮天数 // var off70 = undefined // 时长过70%显示结班按钮天数
// off70 = Math.ceil(parseInt(this.miniClass.classModel.days) * 0.7) // off70 = Math.ceil(parseInt(this.miniClass.classModel.days) * 0.7)
var endminiSecond = this.miniClass.classModel.days * 1000 * 60 * 60 * 24 var endminiSecond =
console.log('时间比较', (endminiSecond + StartTime), nowTime) this.miniClass.classModel.days * 1000 * 60 * 60 * 24;
if (StartTime > 0 && (endminiSecond + StartTime) <= nowTime) { console.log("时间比较", endminiSecond + StartTime, nowTime);
console.log('显示结班按钮'); if (StartTime > 0 && endminiSecond + StartTime <= nowTime) {
this.showOverbtn = true console.log("显示结班按钮");
this.showOverbtn = true;
} else { } else {
this.showOverbtn = false this.showOverbtn = false;
console.log('不显示'); console.log("不显示");
} }
} else { } else {
this.showOverbtn = false this.showOverbtn = false;
} }
// }else{ // }else{
// this.miniClassForm.startTime = undefined // this.miniClassForm.startTime = undefined
// } // }
}) });
}, },
// 获取服务器时间 // 获取服务器时间
async getServerTime() { async getServerTime() {
var time = undefined var time = undefined;
await this.$http({ await this.$http({
url: this.$http.adornUrl("/common/classExam/getServerTime"), url: this.$http.adornUrl("/common/classExam/getServerTime"),
method: "post", method: "post",
data: this.$http.adornData({}) data: this.$http.adornData({})
}) }).then(async ({ data }) => {
.then( async ({ data }) => {
if (data && data.code === 0) { if (data && data.code === 0) {
time = data.serverTime; time = data.serverTime;
}} }
) });
return time return time;
}, },
// 开班 // 开班
kaiban() { kaiban() {
if (this.miniClass.classUsers.length == 0 || !this.miniClass.classUsers) { if (this.miniClass.classUsers.length == 0 || !this.miniClass.classUsers) {
this.$message.error('请先设置管理成员后再进行开班操作') this.$message.error("请先设置管理成员后再进行开班操作");
return return;
} }
this.$http({ this.$http({
url: this.$http.adornUrl('/common/class/updateClassState'), url: this.$http.adornUrl("/common/class/updateClassState"),
method: "post", method: "post",
data: this.$http.adornData({ data: this.$http.adornData({
classId: this.miniClassForm.id, classId: this.miniClassForm.id,
state: '1' state: "1"
}) })
}) }).then(({ data }) => {
.then(({ data }) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.$message.success("操作成功"); this.$message.success("操作成功");
this.handleClose(); this.handleClose();
} else { } else {
this.$message.error(data.msg); this.$message.error(data.msg);
} }
}) });
}, },
// 结班 // 结班
jieban() { jieban() {
this.$http({ this.$http({
url: this.$http.adornUrl('/common/class/updateClassState'), url: this.$http.adornUrl("/common/class/updateClassState"),
method: "post", method: "post",
data: this.$http.adornData({ data: this.$http.adornData({
classId: this.miniClassForm.id, classId: this.miniClassForm.id,
state: '2' state: "2"
}) })
}) }).then(({ data }) => {
.then(({ data }) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.$message.success("操作成功"); this.$message.success("操作成功");
this.handleClose(); this.handleClose();
} else { } else {
this.$message.error(data.msg); this.$message.error(data.msg);
} }
}) });
},
safeProcessData(obj) {
const processed = {};
const pattern = /\([^)]*\)/g; // 匹配括号及内容的正则
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
const value = obj[key];
// 只对字符串类型进行处理,其他类型保持原样
if (typeof value === "string") {
processed[key] = value.replace(pattern, "");
} else {
// 非字符串类型数字、null、undefined等直接保留
processed[key] = value;
}
}
}
return processed;
}, },
// 保存成员信息 // 保存成员信息
saveMember() { saveMember() {
@@ -487,28 +509,30 @@ export default {
// _myist.push(...this.member.scorer) // _myist.push(...this.member.scorer)
// _myist.push(...this.member.counter) // _myist.push(...this.member.counter)
// console.log('_Str',_myist,this.member.scorer,this.member.counter) // console.log('_Str',_myist,this.member.scorer,this.member.counter)
var url = '' var url = "";
this.$http({ this.$http({
url: this.$http.adornUrl("/common/class/setUserRole"), url: this.$http.adornUrl("/common/class/setUserRole"),
method: "post", method: "post",
data: this.$http.adornData({ data: this.$http.adornData(
{
classId: this.miniClassForm.id, classId: this.miniClassForm.id,
monitor: this.member.monitor+'', //班长 monitor: this.member.monitor + "", //班长
dmonitor: this.member.dmonitor+'', //2班长 dmonitor: this.member.dmonitor + "", //2班长
learner: this.member.learner+'', //学习委员 learner: this.member.learner + "", //学习委员
scorer: this.member.scorer.join(','), //评分员 scorer: this.member.scorer.join(","), //评分员
counter: this.member.counter.join(',') //记分员 counter: this.member.counter.join(",") //记分员
}) }
}) )
.then(({ data }) => { }).then(({ data }) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.$message.success("设置成功"); this.$message.success("设置成功");
this.handleClose(); this.handleClose();
} else { } else {
this.$message.error(data.msg); this.$message.error(data.msg);
} }
}) });
}}) }
});
}, },
// 创建/编辑班级 // 创建/编辑班级
saveAdd() { saveAdd() {
@@ -533,15 +557,14 @@ export default {
number: Number(this.miniClassForm.number) number: Number(this.miniClassForm.number)
// createUserid: "10185" // createUserid: "10185"
}) })
}) }).then(({ data }) => {
.then(({ data }) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.$message.success("操作成功"); this.$message.success("操作成功");
this.handleClose(); this.handleClose();
} else { } else {
this.$message.error("提交失败"); this.$message.error("提交失败");
} }
}) });
} else { } else {
this.$message.error("请完成表单的填写"); this.$message.error("请完成表单的填写");
} }
@@ -558,7 +581,7 @@ export default {
page: 1, page: 1,
limit: 10, limit: 10,
title: query, title: query,
type:'' type: ""
}) })
}) })
.then(({ data }) => { .then(({ data }) => {
@@ -652,9 +675,9 @@ export default {
}, },
handleClose() { handleClose() {
// this.$nextTick(() => {555 // this.$nextTick(() => {555
this.userList = [] this.userList = [];
this.imageUrl = '' this.imageUrl = "";
this.qrcodeUrl = '' this.qrcodeUrl = "";
this.$refs["miniClassForm"].resetFields(); this.$refs["miniClassForm"].resetFields();
// }); // });
this.$emit("handleClose"); this.$emit("handleClose");