| | |
| | | import axios from "axios"; |
| | | import router from "../router"; |
| | | import { Message } from 'element-ui'; |
| | | import {Message} from 'element-ui'; |
| | | import vue from "vue"; |
| | | |
| | | const instance = axios.create({ |
| | | baseURL: process.env.VUE_APP_URL, |
| | | timeout: 50000, |
| | | // 不携带cookie |
| | | withCredentials: true, |
| | | headers: { |
| | | "Content-Type": "application/json" |
| | | } |
| | | }); |
| | | baseURL: process.env.VUE_APP_URL, |
| | | timeout: 50000, |
| | | // 不携带cookie |
| | | withCredentials: true, |
| | | headers: { |
| | | "Content-Type": "application/json" |
| | | } |
| | | }); |
| | | |
| | | // 添加请求拦截器 |
| | | instance.interceptors.request.use(function (config) { |
| | | return config; |
| | | }, function (error) { |
| | | Message.error("请求存在问题,请检查") |
| | | return Promise.reject(error); |
| | | }); |
| | | return config; |
| | | }, function (error) { |
| | | Message.error("请求存在问题,请检查") |
| | | return Promise.reject(error); |
| | | }); |
| | | |
| | | // 添加响应拦截器 |
| | | instance.interceptors.response.use(function (response) { |
| | | // 处理自定义状态码 |
| | | if(response.data.code === 1) { |
| | | return response; |
| | | // 验证码错误放行,以便刷新验证码 |
| | | } else if (response.data.code === 1998) { |
| | | return response; |
| | | } else { |
| | | Message.error(response.data.msg); |
| | | return Promise.reject(response.data.msg); |
| | | } |
| | | if (response.data.code === 1) { |
| | | return response; |
| | | // 验证码错误放行,以便刷新验证码 |
| | | } |
| | | // 处理自定义状态码 |
| | | else if (response.data.code === 1998) { |
| | | return response; |
| | | } else { |
| | | Message.error(response.data.msg); |
| | | return Promise.reject(response.data.msg); |
| | | } |
| | | |
| | | }, function (error) { |
| | | // 处理http状态码 |
| | | if(error.response.data) { |
| | | error.message = error.response.data.msg; |
| | | } |
| | | if(error.response.status === 401) { |
| | | error.message = "登录已过期,请重新登录"; |
| | | // 删掉sessionStorage中过期token |
| | | sessionStorage.clear(); |
| | | router.push("/login"); |
| | | } |
| | | if(error.response.status === 403) { |
| | | error.message = "权限不足"; |
| | | } |
| | | Message.error(error.message); |
| | | return Promise.reject(error); |
| | | }); |
| | | }, function (error) { |
| | | // 处理http状态码 |
| | | if (error.response.data) { |
| | | error.message = error.response.data.msg; |
| | | } |
| | | if (error.response.code === 401) { |
| | | error.message = "登录已过期,请重新登录"; |
| | | vue.prototype.$$router.push({path: '/login'}) |
| | | } |
| | | if (error.response.code === 403) { |
| | | error.message = "权限不足"; |
| | | } |
| | | Message.error(error.message); |
| | | return Promise.reject(error); |
| | | }); |
| | | |
| | | export default instance; |
| | |
| | | <template slot-scope="scope"> |
| | | <el-button size="small" @click="handlerEdit(scope.row)" type="primary">修改</el-button> |
| | | <el-button size="small" type="warning">班级验证</el-button> |
| | | <el-button size="small" type="info">通知</el-button> |
| | | <el-button size="small" @click="handlerOpenNotify(scope.row)" type="info">通知</el-button> |
| | | <el-button @click="studentManager(scope.row.id)" size="small" type="success">成员管理</el-button> |
| | | <el-button v-if="scope.row.status !== '解散'" @click="dissolution(scope.row.id)" type="danger" size="small">解散</el-button> |
| | | </template> |
| | |
| | | |
| | | </div> |
| | | |
| | | <el-dialog |
| | | title="班级通知" |
| | | :visible.sync="notifyOpen" |
| | | width="600px" |
| | | :before-close="handleClose"> |
| | | <el-form :model="notifyForm" :rules="notifyRules" ref="notifyForm" label-width="100px" class="demo-ruleForm"> |
| | | <el-form-item label="通知班级:" prop="className"> |
| | | <span>{{notifyForm.className}}</span> |
| | | </el-form-item> |
| | | <el-form-item label="通知内容:" prop="notifyContent"> |
| | | <el-input type="textarea" v-model="notifyForm.notifyContent" size="small"></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="handleNotifyClose">取 消</el-button> |
| | | <el-button type="primary" @click="submitNotifyForm">确 定</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | |
| | | <el-dialog |
| | | :title="title" |
| | |
| | | |
| | | <script> |
| | | import { addClasses, editClasses, getClassess, dissolution } from "@/api/classes"; |
| | | import { addClassesNotify } from "@/api/classesNotify"; |
| | | import Pagination from "@/components/Pagination" |
| | | export default { |
| | | components: {Pagination}, |
| | | data() { |
| | | return { |
| | | notifyOpen: false, |
| | | notifyForm: { |
| | | className: '', |
| | | notifyContent: '', |
| | | classesId: null |
| | | }, |
| | | loading: true, |
| | | total: 0, |
| | | open: false, |
| | |
| | | endTime: null, |
| | | remark: "" |
| | | }, |
| | | notifyRules: { |
| | | notifyContent: [ |
| | | { required: true, message: '请输入通知内容', trigger: 'blur' }, |
| | | { min: 1, max: 500, message: '长度在 1 到 500 个字符', trigger: 'blur' } |
| | | ], |
| | | }, |
| | | rules: { |
| | | className: [ |
| | | { required: true, message: '请输入班级名称', trigger: 'blur' }, |
| | |
| | | }; |
| | | }, |
| | | methods: { |
| | | handlerOpenNotify(row) { |
| | | this.notifyOpen = true |
| | | this.notifyForm.className = row.className |
| | | this.notifyForm.classesId = row.id |
| | | }, |
| | | submitNotifyForm() { |
| | | this.$refs['notifyForm'].validate((valid) => { |
| | | if (valid) { |
| | | let _this = this |
| | | addClassesNotify(_this.notifyForm).then(res => { |
| | | this.$message.success(res.data.message) |
| | | this.notifyOpen = false |
| | | this.clearNotifyForm() |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | clearNotifyForm() { |
| | | this.notifyForm = { |
| | | className: '', |
| | | notifyContent: '' |
| | | } |
| | | }, |
| | | handleNotifyClose() { |
| | | this.notifyOpen = false |
| | | this.clearNotifyForm() |
| | | }, |
| | | page() { |
| | | getClassess(this.searchForm).then(res => { |
| | | this.tableData = res.data.data |