create vue project

master
bettleChen 1 year ago
parent d8f0ac6b88
commit 7614aa0d70

23
front/.gitignore vendored

@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

@ -0,0 +1,24 @@
# front
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}

11075
front/package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,46 @@
{
"name": "front",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^1.5.0",
"core-js": "^3.8.3",
"element-ui": "^2.15.14",
"vue": "^2.6.14",
"vue-router": "^3.0.2"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"vue-template-compiler": "^2.6.14"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

@ -0,0 +1,17 @@
<template>
<router-view></router-view>
</template>
<script>
export default {
name: 'App',
components: {
}
}
</script>
<style>
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

@ -0,0 +1,121 @@
<template>
<div>
<el-container>
<el-header >
<div style="text-align: center; font-size: 25px; font-weight: bolder">
<i class="el-icon-s-home" style="margin-right: 25px"></i>
教务管理系统
</div>
</el-header>
<el-main>
<el-card class="login-module" shadow="hover">
<div slot="header" class="clearfix">
<span style="text-align: center; font-size: 20px; font-family: 'Microsoft YaHei'">
<p><i class="el-icon-office-building" style="margin-right: 18px"></i>登陆</p>
</span>
</div>
<div>
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="账号" prop="username">
<el-input v-model.number="ruleForm.username" placeholder="请输入账号" prefix-icon="el-icon-lollipop"></el-input>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input v-model="ruleForm.password" placeholder="请输入密码" show-password prefix-icon="el-icon-ice-cream-round"></el-input>
</el-form-item>
<el-form-item label="用户类型" prop="type">
<el-radio-group v-model="ruleForm.type">
<el-radio label="student" value="student">学生</el-radio>
<el-radio label="teacher" value="teacher">老师</el-radio>
<el-radio label="admin" value="admin">管理员</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm('ruleForm')"></el-button>
<el-button @click="resetForm('ruleForm')"></el-button>
</el-form-item>
</el-form>
</div>
</el-card>
</el-main>
</el-container>
</div>
</template>
<script>
export default {
data() {
return {
ruleForm: {
username: null,
password: null,
type: null,
},
rules: {
username: [
{ required: true, message: '请输入用户 id', trigger: 'blur' },
],
password: [
{ required: true, message: '请输入密码', trigger: 'blur' }
],
type: [
{ required: true, message: '请选择', trigger: 'change' }
],
}
};
},
methods: {
submitForm(formName) {
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", {
username: this.ruleForm.username,
password: this.ruleForm.password,
type: this.ruleForm.type
}).then(resp => {
if (resp.data.code === 0){
sessionStorage.setItem("username", this.ruleForm.username)
sessionStorage.setItem("type", this.ruleForm.type)
sessionStorage.setItem("name", resp.data.data.name)
this.$router.push("/student/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;
}
});
},
resetForm(formName) {
this.$refs[formName].resetFields();
},
}
}
</script>
<style>
.login-module {
/*width: 380px;*/
/*height: 325px;*/
margin-top: 60px;
/*border: none;*/
position: absolute;
right: 500px;
text-align: center;
width: 30%;
}
.el-header {
background-color: #B3C0D1;
color: #333;
line-height: 60px;
}
</style>

@ -0,0 +1,14 @@
import Vue from 'vue'
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'
Vue.config.productionTip = false
Vue.use(ElementUI);
new Vue({
router,
render: h => h(App),
}).$mount('#app')

@ -0,0 +1,61 @@
import Vue from 'vue';
import axios from "axios";
// Full config: https://github.com/axios/axios#request-config
// axios.defaults.baseURL = process.env.baseURL || process.env.apiUrl || '';
// axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
let config = {
// timeout: 60 * 1000, // Timeout
withCredentials: true, // Check cross-site Access-Control
};
const _axios = axios.create(config);
_axios.defaults.withCredentials = true;
_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);
}
);
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;

@ -0,0 +1,92 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import Router from 'vue-router'
import login from "../components/login.vue"
Vue.use(Router)
const routes = [
{
path: '/login',
name: 'login',
component: login
},
{
path: "/student",
name: "student",
component: require("@/views/student/index.vue").default,
redirect: "/student/home",
children: [
{
path: "home",
name: "主页",
component: require("@/views/student/home.vue").default
},
{
path: "studentInfo",
name: "信息编辑",
component: require("@/views/student/studentInfo.vue").default
},
{
path: "course",
name: "选课编辑",
redirect: "/student/course/info",
component: require("@/views/student/course.vue").default,
children: [
{
path: "info",
name: "我的选课",
component: require("@/views/student/courseInfo.vue").default
},
{
path: "select",
name: "选课",
component: require("@/views/student/courseSelect.vue").default
}
]
},
{
path: "grade",
name: "成绩查询",
component: require("@/views/student/grade.vue").default
}
]
},
{
path: "/teacher",
name: "teacher",
component: require("@/views/teacher/index.vue").default,
redirect: "/teacher/home",
children: [
{
path: "home",
name: "老师主页",
component: require("@/views/teacher/home.vue").default
},
{
path: "teacherInfo",
name: "信息编辑",
component: require("@/views/teacher/teacherInfo.vue").default
},
{
path: "studentManage",
name: "学生管理",
component: require("@/views/teacher/studentManage.vue").default
},
{
path: "courseManage",
name: "课程管理",
component: require("@/views/teacher/courseManage.vue").default
}
]
}
]
const router = new VueRouter({
mode: "hash",
routes
})
export default router

@ -0,0 +1,13 @@
<template>
<h1>管理员界面</h1>
</template>
<script>
export default {
name: "home"
}
</script>
<style>
</style>

@ -0,0 +1,13 @@
<template>
<h1>管理员界面</h1>
</template>
<script>
export default {
name: "home"
}
</script>
<style>
</style>

@ -0,0 +1,32 @@
<template>
<div>
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="我的选课" name="info"></el-tab-pane>
<el-tab-pane label="选课" name="select"></el-tab-pane>
</el-tabs>
<router-view></router-view>
</div>
</template>
<script>
export default {
name: "course",
data(){
return {
activeName: "info"
}
},
methods: {
handleClick(tab, event){
this.$router.push("/student/course/" + this.activeName)
}
}
}
</script>
<style>
.transfer-footer {
margin-left: 20px;
padding: 6px 5px;
}
</style>

@ -0,0 +1,50 @@
<template>
<el-table
ref="filterTable"
:data="tableData"
style="width: 100%">
<el-table-column
prop="c_name"
label="课程名称"
width="220"
>
</el-table-column>
<el-table-column
prop="c_type"
label="课程类型"
width="300">
</el-table-column>
<el-table-column
prop="t_name"
label="任课老师"
width="220">
</el-table-column>
<el-table-column
prop="credit"
width="150"
label="课程学分">
</el-table-column>
</el-table>
</template>
<script>
export default {
data() {
return {
tableData: [{
c_name: 'python',
c_type: '计算机科学与技术',
credit: 10,
t_name: "乔布斯",
}]
}
},
methods: {
}
}
</script>
<style>
</style>

@ -0,0 +1,56 @@
<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>
</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>;
}
};
},
methods: {
handleChange(value, direction, movedKeys) {
console.log(value, direction, movedKeys);
}
}
}
</script>
<style>
</style>

@ -0,0 +1,75 @@
<template>
<el-table
ref="filterTable"
:data="tableData"
style="width: 100%">
<el-table-column
prop="c_name"
label="课程名称"
width="220"
>
</el-table-column>
<el-table-column
prop="c_type"
label="课程类型"
width="300">
</el-table-column>
<el-table-column
prop="t_name"
label="任课老师"
width="220">
</el-table-column>
<el-table-column
prop="credit"
width="150"
label="课程学分">
</el-table-column>
<el-table-column
prop="middle_grade"
label="平时成绩"
sortable
width="150">
<template slot-scope="scope">
<el-tag
:type="scope.row.middle_grade < 60 ? 'danger' : 'success'"
disable-transitions>{{scope.row.middle_grade}}</el-tag>
</template>
</el-table-column>
<el-table-column
prop="end_grade"
label="期末成绩"
sortable
width="150">
<template slot-scope="scope">
<el-tag
:type="scope.row.end_grade < 60 ? 'danger' : 'success'"
disable-transitions>{{scope.row.end_grade}}</el-tag>
</template>
</el-table-column>
</el-table>
</template>
<script>
export default {
name: "grade",
data() {
return {
tableData: [{
c_name: 'python',
c_type: '计算机科学与技术',
credit: 10,
t_name: "乔布斯",
middle_grade: 80,
end_grade: 50
}]
}
},
methods: {
}
}
</script>
<style>
</style>

@ -0,0 +1,92 @@
<template>
<el-descriptions class="margin-top" :column="3" border>
<el-descriptions-item>
<template slot="label">
<i class="el-icon-user"></i>
学号
</template>
{{ sid }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
<i class="el-icon-user"></i>
用户名
</template>
{{ username }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
<i class="el-icon-mobile-phone"></i>
姓名
</template>
{{ name }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
<i class="el-icon-location-outline"></i>
年级
</template>
{{ grade }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
<i class="el-icon-tickets"></i>
性别
</template>
<el-tag size="small">{{ sex }}</el-tag>
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
<i class="el-icon-office-building"></i>
班级
</template>
{{ class_name }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
<i class="el-icon-office-building"></i>
专业
</template>
{{ major }}
</el-descriptions-item>
</el-descriptions>
</template>
<script>
export default {
name: "home",
data() {
return {
sid: "",
username: "",
password: "",
name: "",
sex: "",
grade: "",
class_name: "",
major: ""
}
},
mounted() {
axios("http://127.0.0.1:8000/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
this.username = data.username
this.name = data.name
this.sex = data.sex
this.grade = data.grade
this.class_name = data.class_name
this.major = data.major
}else {
this.$message({message: resp.data.message, type: "error"})
}
})
}
}
</script>
<style>
</style>

@ -0,0 +1,56 @@
<template>
<div>
<el-container>
<el-header style="text-align: right; font-size: 18px; background-color: #409EFF; border-radius: 3px">
<div style="text-align: center; display: inline-block;margin-right: 40%;">
<span style="font-size: 25px;">教务管理系统学生端</span>
</div>
<div style="display: inline-block;">
<i class="el-icon-s-custom" style="margin-right: 5px"></i>
<span style="margin-right: 15px">{{ name }}</span>
<el-button type="text" icon="el-icon-switch-button" style="color: #333333; font-size: 18px;" @click="out()">
logout
</el-button>
</div>
</el-header>
<el-container>
<el-aside width="200px" style="background-color: rgb(238, 241, 246); height: 810px; border: 1px solid #eee">
<el-menu router :default-active="this.$route.path">
<el-menu-item index="/student/home"><template slot="title"><i class="el-icon-info"></i>学生主页</template></el-menu-item>
<el-menu-item index="/student/studentInfo"><template slot="title"><i class="el-icon-setting"></i>学生编辑</template></el-menu-item>
<el-menu-item index="/student/course"><template slot="title"><i class="el-icon-menu"></i>选课管理</template></el-menu-item>
<el-menu-item index="/student/grade"><template slot="title"><i class="el-icon-tickets"></i>查询成绩</template></el-menu-item>
</el-menu>
</el-aside>
<el-main>
<router-view></router-view>
</el-main>
</el-container>
</el-container>
</div>
</template>
<script>
export default {
name: "index",
data() {
return{
name: "张三",
currentTerm: "123"
}
},
mounted(){
this.name = sessionStorage.getItem("name")
},
methods: {
out() {
sessionStorage.clear();
this.$router.push('/login')
}
}
}
</script>
<style scoped>
</style>

@ -0,0 +1,68 @@
<template>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>修改信息</span>
</div>
<el-form ref="form" :model="form" label-width="80px" size="mini">
<el-form-item label="学号">
<el-input v-model="form.sid" disabled></el-input>
</el-form-item>
<el-form-item label="账号">
<el-input v-model="form.username" disabled></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input v-model="form.password"></el-input>
</el-form-item>
<el-form-item label="姓名">
<el-input v-model="form.name" disabled></el-input>
</el-form-item>
<el-form-item label="性别">
<el-radio-group v-model="form.sex" size="medium" disabled>
<el-radio border label="男" icon="el-icon-female"></el-radio>
<el-radio border label="女" icon="el-icon-male"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="班级">
<el-input v-model="form.class_name" disabled></el-input>
</el-form-item>
<el-form-item label="年级">
<el-input v-model="form.grade" disabled></el-input>
</el-form-item>
<el-form-item label="专业">
<el-input v-model="form.major" disabled></el-input>
</el-form-item>
<el-form-item size="large">
<el-button type="primary" @click="onSubmit"></el-button>
</el-form-item>
</el-form>
</el-card>
</template>
<script>
export default {
name: "studentInfo",
data() {
return {
form: {
sid: 1,
username: '',
password: '',
name: '',
sex: '男',
grade: '',
class_name: '',
major: '',
}
};
},
methods: {
onSubmit() {
console.log('submit!');
}
}
}
</script>
<style>
</style>

@ -0,0 +1,13 @@
<template>
<h1>课程管理</h1>
</template>
<script>
export default {
}
</script>
<style>
</style>

@ -0,0 +1,13 @@
<template>
<h1>老师界面</h1>
</template>
<script>
export default {
name: "home"
}
</script>
<style>
</style>

@ -0,0 +1,56 @@
<template>
<div>
<el-container>
<el-header style="text-align: right; font-size: 18px; background-color: #409EFF; border-radius: 3px">
<div style="text-align: center; display: inline-block;margin-right: 40%;">
<span style="font-size: 25px;">教务管理系统老师端</span>
</div>
<div style="display: inline-block;">
<i class="el-icon-s-custom" style="margin-right: 5px"></i>
<span style="margin-right: 15px">{{ name }}</span>
<el-button type="text" icon="el-icon-switch-button" style="color: #333333; font-size: 18px;" @click="out()">
logout
</el-button>
</div>
</el-header>
<el-container>
<el-aside width="200px" style="background-color: rgb(238, 241, 246); height: 810px; border: 1px solid #eee">
<el-menu router :default-active="this.$route.path">
<el-menu-item index="/teacher/home"><template slot="title"><i class="el-icon-info"></i>老师主页</template></el-menu-item>
<el-menu-item index="/teacher/teacherInfo"><template slot="title"><i class="el-icon-setting"></i>信息编辑</template></el-menu-item>
<el-menu-item index="/teacher/studentManage"><template slot="title"><i class="el-icon-menu"></i>学生管理</template></el-menu-item>
<el-menu-item index="/teacher/courseManage"><template slot="title"><i class="el-icon-tickets"></i>课程管理</template></el-menu-item>
</el-menu>
</el-aside>
<el-main>
<router-view></router-view>
</el-main>
</el-container>
</el-container>
</div>
</template>
<script>
export default {
name: "index",
data() {
return{
name: "张三",
currentTerm: "123"
}
},
mounted(){
this.name = sessionStorage.getItem("name")
},
methods: {
out() {
sessionStorage.clear();
this.$router.push('/login')
}
}
}
</script>
<style scoped>
</style>

@ -0,0 +1,13 @@
<template>
<h1>学生管理</h1>
</template>
<script>
export default {
}
</script>
<style>
</style>

@ -0,0 +1,68 @@
<template>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>修改信息</span>
</div>
<el-form-item label="学号">
<el-input v-model="form.sid"></el-input>
</el-form-item>
<el-form ref="form" :model="form" label-width="80px" size="mini">
<el-form-item label="账号">
<el-input v-model="form.s_username" disabled></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input v-model="form.s_password"></el-input>
</el-form-item>
<el-form-item label="姓名">
<el-input v-model="form.s_name" disabled></el-input>
</el-form-item>
<el-form-item label="性别">
<el-radio-group v-model="form.s_sex" size="medium" disabled>
<el-radio border label="男" icon="el-icon-female"></el-radio>
<el-radio border label="女" icon="el-icon-male"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="班级">
<el-input v-model="form.s_class_name" disabled></el-input>
</el-form-item>
<el-form-item label="年级">
<el-input v-model="form.s_grade" disabled></el-input>
</el-form-item>
<el-form-item label="专业">
<el-input v-model="form.s_major" disabled></el-input>
</el-form-item>
<el-form-item size="large">
<el-button type="primary" @click="onSubmit"></el-button>
</el-form-item>
</el-form>
</el-card>
</template>
<script>
export default {
name: "studentInfo",
data() {
return {
form: {
sid: 1,
s_username: '',
s_password: '',
s_name: '',
s_sex: '男',
s_grade: '',
s_class_name: '',
s_major: '',
}
};
},
methods: {
onSubmit() {
console.log('submit!');
}
}
}
</script>
<style>
</style>

@ -0,0 +1,8 @@
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
lintOnSave: false,
// devServer: {
// proxy: "http://127.0.0.1:8000"
// }
})
Loading…
Cancel
Save