update code

master
bettleChen 1 year ago
parent 4cbbdf88f6
commit 30697a8483

@ -11,6 +11,7 @@
"axios": "^1.5.0",
"core-js": "^3.8.3",
"element-ui": "^2.15.14",
"js-cookie": "^3.0.5",
"vue": "^2.6.14",
"vue-router": "^3.0.2"
},
@ -6782,6 +6783,14 @@
"@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": {
"version": "1.0.7",
"resolved": "https://registry.npmmirror.com/js-message/-/js-message-1.0.7.tgz",

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

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

@ -3,10 +3,23 @@ import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui';
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.use(ElementUI);
Vue.prototype.$axios = axiosInstance
new Vue({
router,

@ -1,4 +1,3 @@
import Vue from 'vue';
import axios from "axios";
// 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.post['Content-Type'] = 'application/x-www-form-urlencoded';
axios.defaults.withCredentials = true;
let config = {
// bashURL: "http://127.0.0.1:8000",
// timeout: 60 * 1000, // Timeout
withCredentials: true, // Check cross-site Access-Control
baseURL: "http://127.0.0.1:8080",
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
_axios.interceptors.response.use(
function(response) {
// Do something with response data
return response;
},
function(error) {
// Do something with response error
return Promise.reject(error);
}
);
export default axiosInstance;
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>
<el-table
ref="filterTable"
ref="tableData"
:data="tableData"
style="width: 100%">
<el-table-column
prop="c_name"
prop="cid__name"
label="课程名称"
width="220"
>
</el-table-column>
<el-table-column
prop="c_type"
prop="cid__type"
label="课程类型"
width="300">
width="220">
</el-table-column>
<el-table-column
prop="t_name"
prop="cid__tid__name"
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">
</el-table-column>
<el-table-column
prop="credit"
prop="cid__credit"
width="150"
label="课程学分">
</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>
</template>
<script>
import axios from 'axios'
export default {
data() {
return {
tableData: [{
c_name: 'python',
c_type: '计算机科学与技术',
credit: 10,
t_name: "乔布斯",
}]
}
},
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>

@ -1,52 +1,133 @@
<template>
<div style="text-align: center;margin-top: 50px;">
<el-transfer
style="text-align: left; display: inline-block"
v-model="value4"
filterable
:left-default-checked="[2, 3]"
:right-default-checked="[1]"
:titles="['Source', 'Target']"
:button-texts="['到左边', '到右边']"
:format="{
noChecked: '${total}',
hasChecked: '${checked}/${total}'
}"
@change="handleChange"
:data="data">
<span slot-scope="{ option }"> {{ option.label }}</span>
</el-transfer>
<div>
<el-card class="box-card">
<el-form ref="form" :model="form" label-width="80px" class="demo-form-inline" :inline="true">
<el-form-item label="课程名称">
<el-input v-model="form.cName" ></el-input>
</el-form-item>
<el-form-item label="课程类型">
<el-input v-model="form.cType" ></el-input>
</el-form-item>
<el-form-item label="老师名称">
<el-input v-model="form.tName" ></el-input>
</el-form-item>
<el-form-item size="large">
<el-button type="primary" @click="search"></el-button>
</el-form-item>
</el-form>
</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>
</template>
<script>
export default {
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 {
data: generateData(),
value: [1],
value4: [1],
renderFunc(h, option) {
return <span>{ option.key } - { option.label }</span>;
total: 0,
currentPage: 1,
form: {
cName: "",
tName: "",
cType: ""
},
tableData: [{
}]
}
};
},
methods: {
handleChange(value, direction, movedKeys) {
console.log(value, direction, movedKeys);
getAllCourse() {
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>

@ -4,23 +4,23 @@
:data="tableData"
style="width: 100%">
<el-table-column
prop="c_name"
prop="cid__name"
label="课程名称"
width="220"
>
</el-table-column>
<el-table-column
prop="c_type"
prop="cid__type"
label="课程类型"
width="300">
</el-table-column>
<el-table-column
prop="t_name"
prop="cid__tid__name"
label="任课老师"
width="220">
</el-table-column>
<el-table-column
prop="credit"
prop="cid__credit"
width="150"
label="课程学分">
</el-table-column>
@ -55,17 +55,22 @@ export default {
data() {
return {
tableData: [{
c_name: 'python',
c_type: '计算机科学与技术',
credit: 10,
t_name: "乔布斯",
middle_grade: 80,
end_grade: 50
}]
}
},
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>

@ -68,7 +68,7 @@ export default {
}
},
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 ){
const data = resp.data.data
this.sid = data.sid

@ -58,7 +58,7 @@ export default {
},
methods: {
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 ){
this.$message({message: resp.data.message, type: "success"})
sessionStorage.clear()
@ -70,7 +70,7 @@ export default {
}
},
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 ){
const data = resp.data.data
this.form.sid = data.sid

@ -70,7 +70,7 @@
}
},
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 ){
this.info = resp.data.data
}else {

@ -220,7 +220,7 @@ import axios from 'axios';
cancelButtonText: '取消',
type: 'warning'
}).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){
this.$message({
type: 'success',
@ -247,7 +247,7 @@ import axios from 'axios';
this.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) {
this.total = resp.data.pageTotal
this.tableData = resp.data.data
@ -266,7 +266,7 @@ import axios from 'axios';
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 => {
this.$axios.post(this.addForm.sid === '' ? "/student/add" : "/student/", this.addForm).then(resp => {
if(resp.data.code === 0){
this.$message({message: resp.data.message, type: "sucess"})
this.getAllStudent()

@ -57,7 +57,7 @@ export default {
},
methods: {
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 ){
this.$message({message: resp.data.message, type: "success"})
sessionStorage.clear()
@ -69,7 +69,7 @@ export default {
}
},
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 ){
this.form = resp.data.data
}else {

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

Loading…
Cancel
Save