From 7b4983738f986bf28cb12c9a30dcbc4d593ad6a5 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期四, 06 六月 2024 10:47:00 +0800
Subject: [PATCH] 班级通知

---
 src/api/request.js                         |   82 +++++++++++++-------------
 src/views/Manage/ClassManagement/Class.vue |   60 +++++++++++++++++++
 2 files changed, 100 insertions(+), 42 deletions(-)

diff --git a/src/api/request.js b/src/api/request.js
index 449cac1..947c2e5 100644
--- a/src/api/request.js
+++ b/src/api/request.js
@@ -1,54 +1,54 @@
 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,
-    // 涓嶆惡甯ookie
-    withCredentials: true,
-    headers: {
-      "Content-Type": "application/json"
-    }
-  });
+  baseURL: process.env.VUE_APP_URL,
+  timeout: 50000,
+  // 涓嶆惡甯ookie
+  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涓繃鏈焧oken
-      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;
diff --git a/src/views/Manage/ClassManagement/Class.vue b/src/views/Manage/ClassManagement/Class.vue
index 1662931..db5b41d 100644
--- a/src/views/Manage/ClassManagement/Class.vue
+++ b/src/views/Manage/ClassManagement/Class.vue
@@ -94,7 +94,7 @@
                   <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 !== '瑙f暎'" @click="dissolution(scope.row.id)" type="danger" size="small">瑙f暎</el-button>
                   </template>
@@ -114,6 +114,24 @@
 
     </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"
@@ -163,11 +181,18 @@
 
 <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,
@@ -189,6 +214,12 @@
         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' },
@@ -207,6 +238,33 @@
     };
   },
   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

--
Gitblit v1.8.0