diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/.idea/EduSystemFront.iml b/.idea/EduSystemFront.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/EduSystemFront.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..266b64e --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ff93ba2 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..775009c --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + 1694139293678 + + + + \ No newline at end of file diff --git a/front/src/components/login.vue b/front/src/components/login.vue index d6fb180..f758df7 100644 --- a/front/src/components/login.vue +++ b/front/src/components/login.vue @@ -67,8 +67,7 @@ const that = this this.$refs[formName].validate((valid) => { if (valid) { - if (that.ruleForm.type == "student"){ - this.$axios.post("http://127.0.0.1:8000/login", { + this.$axios.post("http://127.0.0.1:8000/login", { username: this.ruleForm.username, password: this.ruleForm.password, type: this.ruleForm.type @@ -77,18 +76,18 @@ sessionStorage.setItem("username", this.ruleForm.username) sessionStorage.setItem("type", this.ruleForm.type) sessionStorage.setItem("name", resp.data.data.name) - this.$router.push("/student/home") + if (that.ruleForm.type == "student"){ + this.$router.push("/student/home") + }else if (that.ruleForm.type == "teacher") { + this.$router.push("/teacher/home") + }else{ + this.$router.push("/admin/home") + } this.$message({message: resp.data.message, type: "success"}) }else{ this.$message({message: resp.data.message, type: "error"}) } }) - }else if (that.ruleForm.type == "teacher") { - this.$router.push("/teacher/home") - }else{ - this.$router.push("/admin/home") - } - } else { console.log('error submit!!'); return false; diff --git a/front/src/plugins/axios.js b/front/src/plugins/axios.js index 805f714..ffd6512 100644 --- a/front/src/plugins/axios.js +++ b/front/src/plugins/axios.js @@ -7,7 +7,7 @@ import axios from "axios"; // axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; let config = { - + // bashURL: "http://127.0.0.1:8000", // timeout: 60 * 1000, // Timeout withCredentials: true, // Check cross-site Access-Control }; diff --git a/front/src/router/index.js b/front/src/router/index.js index 33206e1..8c2f8ae 100644 --- a/front/src/router/index.js +++ b/front/src/router/index.js @@ -90,3 +90,17 @@ const router = new VueRouter({ export default router + +router.beforeEach((to, from, next) => { + if (to.path === "/login") { + next() + }else { + if (sessionStorage.getItem("username") && sessionStorage.getItem("type")) { + const _type = sessionStorage.getItem("type") + next() + }else{ + console.log("fdsafd") + next({path: "/login"}) + } + } +}) diff --git a/front/src/views/student/studentInfo.vue b/front/src/views/student/studentInfo.vue index bc72810..97273e0 100644 --- a/front/src/views/student/studentInfo.vue +++ b/front/src/views/student/studentInfo.vue @@ -3,42 +3,43 @@
修改信息
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 保存 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 保存 + + diff --git a/front/src/views/teacher/home.vue b/front/src/views/teacher/home.vue index efaf5d6..f3d0ea5 100644 --- a/front/src/views/teacher/home.vue +++ b/front/src/views/teacher/home.vue @@ -1,10 +1,84 @@ diff --git a/front/src/views/teacher/index.vue b/front/src/views/teacher/index.vue index 4a18e5f..1565f9e 100644 --- a/front/src/views/teacher/index.vue +++ b/front/src/views/teacher/index.vue @@ -19,7 +19,7 @@ - + diff --git a/front/src/views/teacher/studentManage.vue b/front/src/views/teacher/studentManage.vue index 8113de7..a57b959 100644 --- a/front/src/views/teacher/studentManage.vue +++ b/front/src/views/teacher/studentManage.vue @@ -1,13 +1,313 @@ - - \ No newline at end of file +import axios from 'axios'; + export default { + data() { + return { + currentPage: 1, + total: 0, + isAdd: true, + dialog: false, + loading: false, + title: "新增学生", + tableData: [{ + sid: "", + username: "", + password: "", + name: "", + sex: "", + grade: "", + class_name: "", + major: "" + }], + form: { + sid: '', + name: '', + sex: '', + grade: '', + class_name: '', + major: '', + }, + addForm: { + sid: "", + username: '', + password: '', + name: '', + sex: '男', + grade: '', + class_name: '', + major: '', + } + } + }, + methods: { + handleEdit(index, row) { + console.log(row) + this.addForm = new Object(row.fields) + this.addForm.sid = row.pk + this.dialog = true + this.isAdd = false + }, + handleDelete(index, row) { + this.$confirm('此操作将永久删除该学生, 是否继续?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + axios.get("http://127.0.0.1:8000/student/delete?sid=" + row.pk).then(resp => { + if (resp.data.code === 0){ + this.$message({ + type: 'success', + message: resp.data.message + }); + this.getAllStudent() + }else { + this.$message({ + type: 'error', + message: resp.data.message + }); + } + }) + + }).catch(() => { + this.$message({ + type: 'info', + message: '已取消删除' + }); + }); + }, + handleCurrentChange(val){ + this.currentPage = val + this.getAllStudent() + }, + getAllStudent() { + axios.post("http://127.0.0.1:8000/student/search?currentPage="+this.currentPage+"&pageSize=10", this.form).then(resp => { + if (resp.data.code === 0) { + this.total = resp.data.pageTotal + this.tableData = resp.data.data + } + }) + }, + search(){ + this.getAllStudent() + }, + handleClose(done) { + if (this.loading) { + return; + } + this.$confirm('确定要提交表单吗?') + .then(_ => { + this.loading = true; + this.timer = setTimeout(() => { + done(); + axios.post(this.addForm.sid === '' ? "http://127.0.0.1:8000/student/add" : "http://127.0.0.1:8000/student/", this.addForm).then(resp => { + if(resp.data.code === 0){ + this.$message({message: resp.data.message, type: "sucess"}) + this.getAllStudent() + this.loading = false + this.addForm = { + sid: "", + username: '', + password: '', + name: '', + sex: '男', + grade: '', + class_name: '', + major: '', + } + }else{ + this.$message({message: resp.data.message, type: "error"}) + } + }) + }, 1000); + }) + .catch(_ => {}); + console.log("close") + }, + cancelForm() { + this.loading = false; + this.dialog = false; + this.addForm = { + sid: "", + username: '', + password: '', + name: '', + sex: '男', + grade: '', + class_name: '', + major: '', + } + clearTimeout(this.timer); + } + }, + mounted() { + this.getAllStudent() + } + } + \ No newline at end of file diff --git a/front/src/views/teacher/teacherInfo.vue b/front/src/views/teacher/teacherInfo.vue index 7c97168..d921d0c 100644 --- a/front/src/views/teacher/teacherInfo.vue +++ b/front/src/views/teacher/teacherInfo.vue @@ -3,33 +3,33 @@
修改信息
- - - + + + - + - + - + - + - - + + - - + + - - + + 保存 @@ -44,21 +44,38 @@ export default { data() { return { form: { - sid: 1, - s_username: '', - s_password: '', - s_name: '', - s_sex: '男', - s_grade: '', - s_class_name: '', - s_major: '', + tid: "", + username: "", + password: "", + name: "", + sex: "", + title: "", + education: "", + dept: "" } }; }, methods: { onSubmit() { - console.log('submit!'); + axios.post("http://127.0.0.1:8000/teacher/", this.form).then(resp => { + if (resp.data.code === 0 ){ + this.$message({message: resp.data.message, type: "success"}) + sessionStorage.clear() + this.$router.push("/login") + }else { + this.$message({message: resp.data.message, type: "error"}) + } + }) } + }, + mounted() { + axios("http://127.0.0.1:8000/userinfo?username="+sessionStorage.getItem('username')+"&type="+sessionStorage.getItem("type")).then(resp => { + if (resp.data.code === 0 ){ + this.form = resp.data.data + }else { + this.$message({message: resp.data.message, type: "error"}) + } + }) } }