update code

master
bettleChen 1 year ago
parent 4cbbdf88f6
commit 30697a8483

@ -11,6 +11,7 @@
"axios": "^1.5.0", "axios": "^1.5.0",
"core-js": "^3.8.3", "core-js": "^3.8.3",
"element-ui": "^2.15.14", "element-ui": "^2.15.14",
"js-cookie": "^3.0.5",
"vue": "^2.6.14", "vue": "^2.6.14",
"vue-router": "^3.0.2" "vue-router": "^3.0.2"
}, },
@ -6782,6 +6783,14 @@
"@sideway/pinpoint": "^2.0.0" "@sideway/pinpoint": "^2.0.0"
} }
}, },
"node_modules/js-cookie": {
"version": "3.0.5",
"resolved": "https://registry.npmmirror.com/js-cookie/-/js-cookie-3.0.5.tgz",
"integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==",
"engines": {
"node": ">=14"
}
},
"node_modules/js-message": { "node_modules/js-message": {
"version": "1.0.7", "version": "1.0.7",
"resolved": "https://registry.npmmirror.com/js-message/-/js-message-1.0.7.tgz", "resolved": "https://registry.npmmirror.com/js-message/-/js-message-1.0.7.tgz",

@ -11,6 +11,7 @@
"axios": "^1.5.0", "axios": "^1.5.0",
"core-js": "^3.8.3", "core-js": "^3.8.3",
"element-ui": "^2.15.14", "element-ui": "^2.15.14",
"js-cookie": "^3.0.5",
"vue": "^2.6.14", "vue": "^2.6.14",
"vue-router": "^3.0.2" "vue-router": "^3.0.2"
}, },

@ -67,7 +67,7 @@
const that = this const that = this
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
this.$axios.post("http://127.0.0.1:8000/login", { this.$axios.post("/login", {
username: this.ruleForm.username, username: this.ruleForm.username,
password: this.ruleForm.password, password: this.ruleForm.password,
type: this.ruleForm.type type: this.ruleForm.type

@ -3,10 +3,23 @@ import App from './App.vue'
import router from './router' import router from './router'
import ElementUI from 'element-ui'; import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'; import 'element-ui/lib/theme-chalk/index.css';
import './plugins/axios' import axios from "axios";
import Cookies from 'js-cookie';
// axios.defaults.withCredentials = true;
let config = {
baseURL: "http://127.0.0.1:8080",
withCredentials: true, // Check cross-site Access-Control,
};
const axiosInstance = axios.create(config);
axiosInstance.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(ElementUI); Vue.use(ElementUI);
Vue.prototype.$axios = axiosInstance
new Vue({ new Vue({
router, router,

@ -1,4 +1,3 @@
import Vue from 'vue';
import axios from "axios"; import axios from "axios";
// Full config: https://github.com/axios/axios#request-config // Full config: https://github.com/axios/axios#request-config
@ -6,56 +5,16 @@ import axios from "axios";
// axios.defaults.headers.common['Authorization'] = AUTH_TOKEN; // axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; // axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
axios.defaults.withCredentials = true;
let config = { let config = {
// bashURL: "http://127.0.0.1:8000", baseURL: "http://127.0.0.1:8080",
// timeout: 60 * 1000, // Timeout withCredentials: true, // Check cross-site Access-Control,
withCredentials: true, // Check cross-site Access-Control
}; };
const _axios = axios.create(config);
_axios.defaults.withCredentials = true;
const axiosInstance = axios.create(config);
axiosInstance.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
_axios.interceptors.request.use(
function(config) {
// Do something before request is sent
return config;
},
function(error) {
// Do something with request error
return Promise.reject(error);
}
);
// Add a response interceptor export default axiosInstance;
_axios.interceptors.response.use(
function(response) {
// Do something with response data
return response;
},
function(error) {
// Do something with response error
return Promise.reject(error);
}
);
Plugin.install = function(Vue, options) {
Vue.axios = _axios;
window.axios = _axios;
Object.defineProperties(Vue.prototype, {
axios: {
get() {
return _axios;
}
},
$axios: {
get() {
return _axios;
}
},
});
};
Vue.use(Plugin)
export default Plugin;

@ -1,46 +1,93 @@
<template> <template>
<el-table <el-table
ref="filterTable" ref="tableData"
:data="tableData" :data="tableData"
style="width: 100%"> style="width: 100%">
<el-table-column <el-table-column
prop="c_name" prop="cid__name"
label="课程名称" label="课程名称"
width="220" width="220"
> >
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="c_type" prop="cid__type"
label="课程类型" label="课程类型"
width="300"> width="220">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="t_name" prop="cid__tid__name"
label="任课老师" label="任课老师"
width="150">
</el-table-column>
<el-table-column
prop="cid__tid__title"
label="老师职称"
width="150">
</el-table-column>
<el-table-column
prop="cid__tid__dept"
label="老师院系"
width="220"> width="220">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="credit" prop="cid__credit"
width="150" width="150"
label="课程学分"> label="课程学分">
</el-table-column> </el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.$index, scope.row)">退课</el-button>
</template>
</el-table-column>
</el-table> </el-table>
</template> </template>
<script> <script>
import axios from 'axios'
export default { export default {
data() { data() {
return { return {
tableData: [{ tableData: [{
c_name: 'python',
c_type: '计算机科学与技术',
credit: 10,
t_name: "乔布斯",
}] }]
} }
}, },
methods: { methods: {
getSelectCourse() {
this.$axios.get("/course/getCourseById?username="+sessionStorage.getItem("username")).then(resp => {
if (resp.data.code === 0){
this.tableData = resp.data.data
}else{
this.$message({message: resp.data.message, type: "error"})
}
})
},
handleDelete(index, row) {
console.log(index, row)
this.$confirm('是否退出选课?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$axios.get("/course/deleteSelectCourse?sid="+row.sid+"&cid="+row.cid).then(resp => {
this.$message({
type: resp.data.code === 0 ? "success" : "error",
message: resp.data.message
})
})
this.getSelectCourse()
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
}
},
mounted(){
this.getSelectCourse()
} }
} }
</script> </script>

@ -1,52 +1,133 @@
<template> <template>
<div style="text-align: center;margin-top: 50px;"> <div>
<el-transfer <el-card class="box-card">
style="text-align: left; display: inline-block" <el-form ref="form" :model="form" label-width="80px" class="demo-form-inline" :inline="true">
v-model="value4" <el-form-item label="课程名称">
filterable <el-input v-model="form.cName" ></el-input>
:left-default-checked="[2, 3]" </el-form-item>
:right-default-checked="[1]" <el-form-item label="课程类型">
:titles="['Source', 'Target']" <el-input v-model="form.cType" ></el-input>
:button-texts="['到左边', '到右边']" </el-form-item>
:format="{ <el-form-item label="老师名称">
noChecked: '${total}', <el-input v-model="form.tName" ></el-input>
hasChecked: '${checked}/${total}' </el-form-item>
}" <el-form-item size="large">
@change="handleChange" <el-button type="primary" @click="search"></el-button>
:data="data"> </el-form-item>
<span slot-scope="{ option }"> {{ option.label }}</span> </el-form>
</el-transfer> </el-card>
<el-card class="box-card" style="margin-top: 20px;">
<el-table
:data="tableData"
border
show-header
stripe
style="width: 100%">
<el-table-column
fixed
prop="tid__course__name"
label="课程名称"
width="200">
</el-table-column>
<el-table-column
prop="tid__course__type"
label="课程类型"
width="180">
</el-table-column>
<el-table-column
prop="tid__course__credit"
label="课程学分"
width="150">
</el-table-column>
<el-table-column
prop="tid__name"
label="教师名称"
width="180">
</el-table-column>
<el-table-column
prop="tid__title"
label="教师职称"
width="180">
</el-table-column>
<el-table-column
prop="tid__dept"
label="教师院系"
width="220">
</el-table-column>
<el-table-column
label="操作"
width="150">
<template slot-scope="scope">
<el-popconfirm
confirm-button-text='选择'
cancel-button-text='取消'
icon="el-icon-info"
title="确定选择该教师开设的课程?"
@confirm="select(scope.row)"
>
<el-button slot="reference" type="text" size="small">选择</el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<el-pagination
background
style="text-align: center;"
layout="prev, pager, next"
:total="total"
:page-size="10"
@current-change="changePage"
>
</el-pagination>
</el-card>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
const generateData = _ => {
const data = [];
for (let i = 1; i <= 15; i++) {
data.push({
key: i,
label: `备选项 ${ i }`,
disabled: i % 4 === 0
});
}
return data;
};
return { return {
data: generateData(), total: 0,
value: [1], currentPage: 1,
value4: [1], form: {
renderFunc(h, option) { cName: "",
return <span>{ option.key } - { option.label }</span>; tName: "",
cType: ""
},
tableData: [{
}]
} }
};
}, },
methods: { methods: {
handleChange(value, direction, movedKeys) { getAllCourse() {
console.log(value, direction, movedKeys); this.$axios.get("/course/seacherCourse?currentPage=" + this.currentPage + "&cName=" + this.form.cName
+ "&tName="+ this.form.tName + "&cType=" + this.form.cType).then(resp => {
if (resp.data.code === 0){
this.tableData = resp.data.data
}else {
this.$message({message: resp.data.message, type: "error"})
} }
})
},
search() {
this.getAllCourse()
},
changePage(val) {
this.currentPage = val
},
select(row) {
console.log(row)
row.username = sessionStorage.getItem("username")
this.$axios.post("/student/selectCourse", row).then(resp => {
this.$message({message: resp.data.message, type: resp.data.code===0 ? "success" : "error"})
})
}
},
mounted() {
this.getAllCourse()
} }
} }
</script> </script>

@ -4,23 +4,23 @@
:data="tableData" :data="tableData"
style="width: 100%"> style="width: 100%">
<el-table-column <el-table-column
prop="c_name" prop="cid__name"
label="课程名称" label="课程名称"
width="220" width="220"
> >
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="c_type" prop="cid__type"
label="课程类型" label="课程类型"
width="300"> width="300">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="t_name" prop="cid__tid__name"
label="任课老师" label="任课老师"
width="220"> width="220">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="credit" prop="cid__credit"
width="150" width="150"
label="课程学分"> label="课程学分">
</el-table-column> </el-table-column>
@ -55,17 +55,22 @@ export default {
data() { data() {
return { return {
tableData: [{ tableData: [{
c_name: 'python',
c_type: '计算机科学与技术',
credit: 10,
t_name: "乔布斯",
middle_grade: 80,
end_grade: 50
}] }]
} }
}, },
methods: { methods: {
getGrade(){
this.$axios.get("/student/getGrade?username="+sessionStorage.getItem("username")).then(resp => {
if (resp.data.code === 0){
this.tableData = resp.data.data
}else {
this.$message({message: resp.data.message, type: "error"})
}
})
}
},
mounted() {
this.getGrade()
} }
} }
</script> </script>

@ -68,7 +68,7 @@ export default {
} }
}, },
mounted() { mounted() {
axios("http://127.0.0.1:8000/userinfo?username="+sessionStorage.getItem('username')+"&type="+sessionStorage.getItem("type")).then(resp => { this.$axios.get("/userinfo?username="+sessionStorage.getItem('username')+"&type="+sessionStorage.getItem("type")).then(resp => {
if (resp.data.code === 0 ){ if (resp.data.code === 0 ){
const data = resp.data.data const data = resp.data.data
this.sid = data.sid this.sid = data.sid

@ -58,7 +58,7 @@ export default {
}, },
methods: { methods: {
onSubmit() { onSubmit() {
axios.post("http://127.0.0.1:8000/student/", this.form).then(resp => { this.$axios.post("/student/", this.form).then(resp => {
if (resp.data.code === 0 ){ if (resp.data.code === 0 ){
this.$message({message: resp.data.message, type: "success"}) this.$message({message: resp.data.message, type: "success"})
sessionStorage.clear() sessionStorage.clear()
@ -70,7 +70,7 @@ export default {
} }
}, },
mounted() { mounted() {
axios("http://127.0.0.1:8000/userinfo?username="+sessionStorage.getItem('username')+"&type="+sessionStorage.getItem("type")).then(resp => { this.$axios("/userinfo?username="+sessionStorage.getItem('username')+"&type="+sessionStorage.getItem("type")).then(resp => {
if (resp.data.code === 0 ){ if (resp.data.code === 0 ){
const data = resp.data.data const data = resp.data.data
this.form.sid = data.sid this.form.sid = data.sid

@ -70,7 +70,7 @@
} }
}, },
mounted() { mounted() {
axios("http://127.0.0.1:8000/userinfo?username="+sessionStorage.getItem('username')+"&type="+sessionStorage.getItem("type")).then(resp => { this.$axios("/userinfo?username="+sessionStorage.getItem('username')+"&type="+sessionStorage.getItem("type")).then(resp => {
if (resp.data.code === 0 ){ if (resp.data.code === 0 ){
this.info = resp.data.data this.info = resp.data.data
}else { }else {

@ -220,7 +220,7 @@ import axios from 'axios';
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
axios.get("http://127.0.0.1:8000/student/delete?sid=" + row.pk).then(resp => { this.$axios.get("/student/delete?sid=" + row.pk).then(resp => {
if (resp.data.code === 0){ if (resp.data.code === 0){
this.$message({ this.$message({
type: 'success', type: 'success',
@ -247,7 +247,7 @@ import axios from 'axios';
this.getAllStudent() this.getAllStudent()
}, },
getAllStudent() { getAllStudent() {
axios.post("http://127.0.0.1:8000/student/search?currentPage="+this.currentPage+"&pageSize=10", this.form).then(resp => { this.$axios.post("/student/search?currentPage="+this.currentPage+"&pageSize=10", this.form).then(resp => {
if (resp.data.code === 0) { if (resp.data.code === 0) {
this.total = resp.data.pageTotal this.total = resp.data.pageTotal
this.tableData = resp.data.data this.tableData = resp.data.data
@ -266,7 +266,7 @@ import axios from 'axios';
this.loading = true; this.loading = true;
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
done(); 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 => { this.$axios.post(this.addForm.sid === '' ? "/student/add" : "/student/", this.addForm).then(resp => {
if(resp.data.code === 0){ if(resp.data.code === 0){
this.$message({message: resp.data.message, type: "sucess"}) this.$message({message: resp.data.message, type: "sucess"})
this.getAllStudent() this.getAllStudent()

@ -57,7 +57,7 @@ export default {
}, },
methods: { methods: {
onSubmit() { onSubmit() {
axios.post("http://127.0.0.1:8000/teacher/", this.form).then(resp => { this.$axios.post("/teacher/", this.form).then(resp => {
if (resp.data.code === 0 ){ if (resp.data.code === 0 ){
this.$message({message: resp.data.message, type: "success"}) this.$message({message: resp.data.message, type: "success"})
sessionStorage.clear() sessionStorage.clear()
@ -69,7 +69,7 @@ export default {
} }
}, },
mounted() { mounted() {
axios("http://127.0.0.1:8000/userinfo?username="+sessionStorage.getItem('username')+"&type="+sessionStorage.getItem("type")).then(resp => { this.$axios("/userinfo?username="+sessionStorage.getItem('username')+"&type="+sessionStorage.getItem("type")).then(resp => {
if (resp.data.code === 0 ){ if (resp.data.code === 0 ){
this.form = resp.data.data this.form = resp.data.data
}else { }else {

@ -2,7 +2,7 @@ const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({ module.exports = defineConfig({
transpileDependencies: true, transpileDependencies: true,
lintOnSave: false, lintOnSave: false,
// devServer: { devServer: {
// proxy: "http://127.0.0.1:8000" proxy: "http://127.0.0.1:8000"
// } }
}) })

Loading…
Cancel
Save