zuobijiancedaima
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

339 lines
8.8 KiB

9 months ago
<template>
9 months ago
<el-row>
<el-col :span="16">
<div style="margin-bottom: 4px;">
<el-button icon="Plus" type="primary" @click="addUserData">
add User
</el-button>
<el-button icon="Delete" type="danger" @click="delUserData">
delete User
</el-button>
<el-button icon="Refresh" type="info" @click="init({})" text>
refresh
</el-button>
</div>
<div>
<vueTable ref="userTableParent" :refName="refName" :tableHeader="tableHeader" :tableData="tableData"
@detailInfo="detailInfo" @editInfo="editInfo" @updateMima="updateMima">
</vueTable>
</div>
9 months ago
</el-col>
9 months ago
<el-col :span="8">
监控画面
9 months ago
</el-col>
</el-row>
9 months ago
<el-dialog v-model="addDialog.show" :title="addDialog.title" width="80%" draggable
:close-on-click-modal="formDisabled">
9 months ago
<changeItem :formData="formData" :formDisabled="formDisabled" :type="addDialog.type" :formHeader="formHeader">
9 months ago
</changeItem>
<template #footer v-if="!formDisabled">
<div class="dialog-footer">
<el-button @click="closeDialog(addDialog)" type="info" plain>
取消
</el-button>
<el-button type="primary" @click="submitAdd" plain> 提交 </el-button>
</div>
</template>
</el-dialog>
</template>
<script>
import md5 from "md5";
import vueTable from "../component/table.vue";
import changeItem from "../component/changeItem.vue";
9 months ago
import _ from "lodash";
9 months ago
import {
addUser, //新增user信息
delUser, //删除user信息
9 months ago
updateUser, //修改user信息
getUser, //获取user信息
9 months ago
updatePassword,//修改密码
9 months ago
} from "@/api/teacher";
9 months ago
export default {
9 months ago
name: "teacher",
9 months ago
components: { vueTable, changeItem },
data() {
return {
9 months ago
_: _,
9 months ago
refName: "userTable",
9 months ago
localComponent: [
{
prop: "xuexiaomingcheng",
label: "学校名称",
type: "text",
9 months ago
tableShow: false,
9 months ago
formShow: true
},
{
prop: "xuexiaodaihao",
label: "学校代号",
type: "text",
9 months ago
tableShow: false,
9 months ago
formShow: true
},
{
prop: "zhuanyemingcheng",
label: "专业名称",
type: "text",
tableShow: true,
formShow: true
},
{
prop: "zhuanyedaihao",
label: "专业代号",
type: "text",
9 months ago
tableShow: false,
9 months ago
formShow: true
},
{
prop: "nianji",
label: "年级",
type: "text",
9 months ago
tableShow: false,
9 months ago
formShow: true
},
{
prop: "banji",
label: "班级",
type: "text",
tableShow: true,
formShow: true
},
{
prop: "xueshengxingming",
label: "学生姓名",
type: "text",
tableShow: true,
formShow: true
},
{
prop: "xuehao",
label: "学号",
type: "text",
tableShow: true,
formShow: true
},
{
prop: "mima",
label: "密码",
type: "text",
9 months ago
tableShow: false,
9 months ago
formShow: true
},
{
prop: "chengji",
label: "成绩",
type: "text",
tableShow: true,
formShow: true
},
{
prop: "zuobiqingkuang",
label: "作弊情况",
type: "text",
9 months ago
tableShow: false,
9 months ago
formShow: true
},
{
prop: "kaoshileixing",
label: "考试类型",
type: "text",
tableShow: true,
formShow: true
},
{
prop: "kaoshikemu",
label: "考试科目",
type: "text",
tableShow: true,
formShow: true
},
9 months ago
{
prop: "kaoshilianjie",
label: "考试链接",
type: "link",
tableShow: true,
formShow: true
},
9 months ago
{
prop: "kaoshishijianduan",
label: "考试时间段",
type: "datetimerange",
tableShow: true,
formShow: true
},
{
prop: "chuangjianshijian",
label: "创建时间",
type: "text",
tableShow: false,
formShow: false
},
{
prop: "gengxinshijian",
label: "更新时间",
type: "text",
tableShow: false,
formShow: false
},
9 months ago
],
9 months ago
tableHeader: [],
9 months ago
tableData: [],
addDialog: {
type: "add",
show: false,
title: "新增用户",
},
9 months ago
formData: {},
formDataLocal: {},
formHeader: [],
9 months ago
formHeaderLocal: [],
formDisabled: false,
};
},
watch: {},
computed: {},
async mounted() {
9 months ago
this.dealTableHeader()
this.dealFormHeader()
9 months ago
await this.init();
},
9 months ago
beforeUnmount() { },
9 months ago
methods: {
9 months ago
dealTableHeader() {
9 months ago
this.tableHeader = _.filter(this.localComponent, o => {
o.minWidth = o.label.length * 17 + 5
return o.tableShow
})
9 months ago
},
9 months ago
// 处理
9 months ago
dealFormHeader() {
9 months ago
this.formHeaderLocal = []
this.formDataLocal = {}
for (let i = 0; i < this.localComponent.length; i++) {
let element = this.localComponent[i];
if (element.formShow) {
this.formHeaderLocal.push({ ...element })
if (["text"].indexOf(element.type) !== -1) {
this.formDataLocal[element.prop] = ""
} else if (["datetimerange"].indexOf(element.type) !== -1) {
this.formDataLocal[element.prop] = []
}
}
}
9 months ago
},
9 months ago
// 初始化表格
9 months ago
async init(params = {}) {
9 months ago
let res = await getUser({
...params,
});
this.tableData = res.list;
},
9 months ago
// 打开新增学生的模态框
9 months ago
async addUserData() {
this.addDialog = {
type: "add",
show: true,
9 months ago
title: "新增学生",
9 months ago
};
9 months ago
this.formData = { ...this.formDataLocal };
this.formHeader = _.cloneDeep(this.formHeaderLocal)
9 months ago
this.formDisabled = false;
},
closeDialog(addDialog) {
addDialog.show = false;
},
9 months ago
// 新增学生和编辑学生的提交
9 months ago
async submitAdd() {
9 months ago
let subData = {};
9 months ago
for (let i = 0; i < this.formHeader.length; i++) {
let elei = this.formHeader[i];
if (elei.type !== "time") {
9 months ago
subData[elei.prop] = this.formData[elei.prop];
9 months ago
}
}
if (this.addDialog.type === "edit") {
9 months ago
subData["userid"] = this.formData._id;
9 months ago
}
9 months ago
let res = {}
9 months ago
try {
9 months ago
if (this.addDialog.type === "edit") {
res = await updateUser(subData);
} else {
res = await addUser(subData);
}
9 months ago
ElMessage({
message: res.msg,
type: "success",
});
} catch (error) {
} finally {
this.closeDialog(this.addDialog);
await this.init();
}
},
9 months ago
// 删除学生信息
9 months ago
async delUserData() {
let rowList =
this.$refs[`${this.refName}Parent`].$refs[
this.refName
].getSelectionRows();
let delData = [];
let delDispalyData = [];
for (let i = 0; i < rowList.length; i++) {
let elei = rowList[i];
delData.push(elei._id);
9 months ago
delDispalyData.push(`${elei.xueshengxingming}`);
9 months ago
}
ElMessageBox.confirm(`${delDispalyData.join("、")}`, "删除", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "error",
}).then(async () => {
9 months ago
let res = await delUser({ ids: delData });
9 months ago
await this.init();
ElMessage({
message: res.msg,
type: "success",
});
});
},
9 months ago
// 查看学生
9 months ago
detailInfo(item) {
this.addDialog = {
type: "info",
show: true,
9 months ago
title: `查看${item.name || ""}`,
9 months ago
};
this.formDisabled = true;
9 months ago
this.formHeader = _.cloneDeep(_.filter(this.formHeaderLocal, o => o.prop !== "mima"))
this.formData = { ...item };
9 months ago
},
9 months ago
// 编辑学生
9 months ago
editInfo(item) {
this.addDialog = {
type: "edit",
show: true,
9 months ago
title: `编辑${item.name || ""}`,
9 months ago
};
this.formDisabled = false;
9 months ago
this.formHeader = _.cloneDeep(_.filter(this.formHeaderLocal, o => o.prop !== "mima"))
9 months ago
this.formData = { ...item };
},
9 months ago
//更新密码
updateMima(item) {
ElMessageBox.prompt("请输入新密码", "修改密码", {
confirmButtonText: "确认",
cancelButtonText: "取消",
}).then(async (value) => {
let res = await updatePassword({ userid: item._id, mima: value.value });
ElMessage({
message: res.msg,
type: "success",
});
})
9 months ago
},
},
};
</script>
<style scoped></style>