From 78a9096e16ae5353bf2cec2f5ebaefc5e49d0d1c Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期四, 16 五月 2024 18:11:19 +0800
Subject: [PATCH] feat:部门管理员功能权限控制

---
 src/api/department.js                          |    2 +
 src/views/exam/paper/list.vue                  |    8 +++-
 src/views/answer/sheetStatistics.vue           |   12 ++++--
 src/views/exam/personalRandomTemplate/edit.vue |   13 ++++++
 src/api/dashboard.js                           |    3 -
 src/router.js                                  |   40 +++++++++++++++++++
 src/views/exam/paper/edit.vue                  |   12 ++++++
 src/views/user/student/edit.vue                |   16 ++++++--
 8 files changed, 92 insertions(+), 14 deletions(-)

diff --git a/src/api/dashboard.js b/src/api/dashboard.js
index 40292f8..bbd6429 100644
--- a/src/api/dashboard.js
+++ b/src/api/dashboard.js
@@ -2,8 +2,7 @@
 
 export default {
   index: () => post('/api/admin/dashboard/index'),
-  getData: query => get('/api/admin/examPaperAnswer/statistic', query),
-  getData: query => get('/api/admin/examPaperAnswer/statistic', query),
+  getData: query => post('/api/admin/examPaperAnswer/statistic', query),
   examPaperList: query => get('/api/admin/exam/paper/list', query),
   page: query => post('/api/admin/examPaperAnswer/page', query)
 }
diff --git a/src/api/department.js b/src/api/department.js
index cd3e8ec..35f9158 100644
--- a/src/api/department.js
+++ b/src/api/department.js
@@ -12,6 +12,8 @@
   addData: query => post('/api/admin/department/add', query),
   // 鑾峰彇閮ㄩ棬鐢ㄦ埛涓嬫媺鍒楄〃
   getDeptUserList: id => get('/api/admin/department/' + id + '/user-list'),
+  // 鑾峰彇褰撳墠鐢ㄦ埛绠$悊鐨勯儴闂�
+  getDeptAdmins: id => get('/api/admin/department/getDeptAdmins'),
   // 淇敼閮ㄩ棬绠$悊鍛�
   updateDeptAdmin: data => post('/api/admin/department/update-admin', data)
 }
diff --git a/src/router.js b/src/router.js
index f6a77e5..23690a2 100644
--- a/src/router.js
+++ b/src/router.js
@@ -463,6 +463,24 @@
     ]
   },
   {
+    path: '/user',
+    component: Layout,
+    name: 'UserPage',
+    meta: {
+      title: '鐢ㄦ埛绠$悊',
+      icon: 'users'
+    },
+    alwaysShow: true,
+    children: [
+      {
+        path: 'student/list',
+        component: () => import('@/views/user/student/list'),
+        name: 'UserStudentPageList',
+        meta: { title: '瀛︾敓鍒楄〃', noCache: true }
+      },
+    ]
+  },
+  {
     path: '/exam',
     component: Layout,
     name: 'ExamPage',
@@ -470,7 +488,21 @@
       title: '鍗烽绠$悊',
       icon: 'exam'
     },
+    alwaysShow: true,
     children: [
+      {
+        path: 'paper/list',
+        component: () => import('@/views/exam/paper/list'),
+        name: 'ExamPaperPageList',
+        meta: { title: '璇曞嵎鍒楄〃', noCache: true }
+      },
+      {
+        path: 'paper/edit',
+        component: () => import('@/views/exam/paper/edit'),
+        name: 'ExamPaperEdit',
+        meta: { title: '璇曞嵎缂栬緫', noCache: true, activeMenu: '/exam/paper/list' },
+        hidden: true
+      },
       {
         path: 'personalRandomTemplate/list',
         component: () => import('@/views/exam/personalRandomTemplate/list'),
@@ -515,7 +547,13 @@
         name: 'AnswerPageList',
         meta: { title: '鎴愮哗缁熻璇︽儏', noCache: true, activeMenu: '/exam/gradeDetails/list' },
         hidden: true
-      }
+      },
+      {
+        path: 'sheetStatistics',
+        component: () => import('@/views/answer/sheetStatistics.vue'),
+        name: 'AnswerPageList',
+        meta: { title: '绛斿嵎缁熻', noCache: true }
+      },
     ]
   },
   {
diff --git a/src/views/answer/sheetStatistics.vue b/src/views/answer/sheetStatistics.vue
index b83fdfb..3ceb157 100644
--- a/src/views/answer/sheetStatistics.vue
+++ b/src/views/answer/sheetStatistics.vue
@@ -6,8 +6,8 @@
           <el-option v-for="item in examPaperList" :key="item.id" :value="item.id" :label="item.name" />
         </el-select>
       </el-form-item>
-      <el-form-item label="閮ㄩ棬锛�" v-if="true">
-        <el-select v-model="queryParam.departmentId" filterable placeholder="閮ㄩ棬" clearable>
+      <el-form-item label="閮ㄩ棬锛�" v-if="admin">
+        <el-select v-model="queryParam.departmentId" multiple filterable placeholder="閮ㄩ棬" clearable>
           <el-option v-for="item in levelEnum" :key="item.key" :value="item.key" :label="item.value" />
         </el-select>
       </el-form-item>
@@ -83,11 +83,15 @@
       chartLoading3: false,
       queryParam: {
         examPaperId: '',
-        departmentId: ''
-      }
+        departmentId: []
+      },
+      admin: true
     };
   },
   mounted() {
+    if (sessionStorage.getItem('deptAdmin') == 1) {
+      this.admin = false;
+    }
     ageChart = echarts.init(this.$refs.ageChart);
     scroeChart = echarts.init(this.$refs.scoreChart);
     peopleChart = echarts.init(this.$refs.peopleChart);
diff --git a/src/views/exam/paper/edit.vue b/src/views/exam/paper/edit.vue
index ed5dbd1..b6542b6 100644
--- a/src/views/exam/paper/edit.vue
+++ b/src/views/exam/paper/edit.vue
@@ -12,6 +12,11 @@
                      :label="item.name+' '"></el-option>
         </el-select>
       </el-form-item>
+      <el-form-item label="閮ㄩ棬锛�" prop="deptId" required>
+        <el-select v-model="form.deptId" collapse-tags placeholder="閮ㄩ棬">
+          <el-option v-for="item in depts" :key="item.id" :value="item.id" :label="item.name"></el-option>
+        </el-select>
+      </el-form-item>
       <el-form-item label="璇曞嵎绫诲瀷锛�" prop="paperType" required>
         <el-select v-model="form.paperType" placeholder="璇曞嵎绫诲瀷"  @visible-change="subjectIdEvent">
           <el-option v-for="item in paperTypeEnum" :key="item.key" :value="item.key" :label="item.value" ></el-option>
@@ -135,6 +140,7 @@
   components: { Pagination, QuestionShow },
   data () {
     return {
+      depts: [],
       props: {
         multiple: true
         // lazy: true,
@@ -177,6 +183,9 @@
         ],
         subjectId: [
           { required: true, message: '璇烽�夋嫨璇剧洰', trigger: 'change' }
+          ],
+        deptId: [
+          { required: true, message: '璇烽�夋嫨閮ㄩ棬', trigger: 'change' }
         ],
         paperType: [
           { required: true, message: '璇烽�夋嫨璇曞嵎绫诲瀷', trigger: 'change' }
@@ -225,6 +234,9 @@
 
       _this.options = res.response.map(x=>{return{value:x.department.id,label:x.department.name,children:x.userList.map(xx=>{return{value: xx.id,label: xx.realName}})}})
     })
+    departmentApi.getDeptAdmins().then(res => {
+      this.depts = res.response
+    })
   },
   methods: {
     handleChange(val){
diff --git a/src/views/exam/paper/list.vue b/src/views/exam/paper/list.vue
index c8a00de..a4d2e75 100644
--- a/src/views/exam/paper/list.vue
+++ b/src/views/exam/paper/list.vue
@@ -3,8 +3,8 @@
     <el-form :model="queryParam" ref="queryForm" :inline="true">
 
       <el-form-item label="閮ㄩ棬锛�">
-        <el-select v-model="queryParam.level" placeholder="閮ㄩ棬" @change="levelChange" clearable>
-          <el-option v-for="item in levelEnum" :key="item.key" :value="item.key" :label="item.value"></el-option>
+        <el-select v-model="queryParam.level" clearable placeholder="閮ㄩ棬">
+          <el-option v-for="item in depts" :key="item.id" :value="item.id" :label="item.name"></el-option>
         </el-select>
       </el-form-item>
       <el-form-item label="璇剧洰锛�" >
@@ -68,6 +68,7 @@
   components: { Pagination },
   data () {
     return {
+      depts: [],
       form: {
         menuIds: [],
         userIds: [],
@@ -103,6 +104,9 @@
     this.search()
     this.queryParam.subjectId = null
     this.subjectFilter = this.subjects
+    departmentApi.getDeptAdmins().then(res => {
+      this.depts = res.response
+    })
   },
   methods: {
     handleExport(row){
diff --git a/src/views/exam/personalRandomTemplate/edit.vue b/src/views/exam/personalRandomTemplate/edit.vue
index 3009191..b662d7b 100644
--- a/src/views/exam/personalRandomTemplate/edit.vue
+++ b/src/views/exam/personalRandomTemplate/edit.vue
@@ -16,6 +16,11 @@
                      :label="item.name+' '"></el-option>
         </el-select>
       </el-form-item>
+      <el-form-item label="閮ㄩ棬锛�" prop="deptId" required>
+        <el-select v-model="form.deptId" collapse-tags placeholder="閮ㄩ棬">
+          <el-option v-for="item in depts" :key="item.id" :value="item.id" :label="item.name"></el-option>
+        </el-select>
+      </el-form-item>
       <el-form-item label="璇曞嵎绫诲瀷锛�" prop="paperType" required >
         <el-select v-model="form.paperType" placeholder="璇曞嵎绫诲瀷"  @visible-change="subjectIdEvent" disabled>
           <el-option v-for="item in paperTypeEnum" :key="item.key" :value="item.key" :label="item.value" ></el-option>
@@ -157,6 +162,7 @@
         //   })
         // }
       },
+      depts: [],
       options: [],
       optionsData:[],
       departCascaderProps:{
@@ -180,9 +186,11 @@
       subjectFilter: null,
       formLoading: false,
       rules: {
-
         subjectId: [
           { required: true, message: '璇烽�夋嫨璇剧洰', trigger: 'change' }
+        ],
+        deptId: [
+          { required: true, message: '璇烽�夋嫨閮ㄩ棬', trigger: 'change' }
         ],
         paperType: [
           { required: true, message: '璇烽�夋嫨璇曞嵎绫诲瀷', trigger: 'change' }
@@ -216,6 +224,9 @@
       console.log(res)
       this.subjectFilter = res.response
     })
+    departmentApi.getDeptAdmins().then(res => {
+      this.depts = res.response
+    })
   },
    async mounted () {
 
diff --git a/src/views/user/student/edit.vue b/src/views/user/student/edit.vue
index 864743b..4d97bbb 100644
--- a/src/views/user/student/edit.vue
+++ b/src/views/user/student/edit.vue
@@ -26,8 +26,8 @@
         <el-input v-model="form.phone"></el-input>
       </el-form-item>
       <el-form-item label="閮ㄩ棬锛�" prop="deptIds" required>
-        <el-select v-model="form.deptIds" multiple  collapse-tags placeholder="閮ㄩ棬">
-          <el-option v-for="item in levelEnum" :key="item.key" :value="item.key" :label="item.value"></el-option>
+        <el-select v-model="form.deptIds" collapse-tags placeholder="閮ㄩ棬">
+          <el-option v-for="item in depts" :key="item.id" :value="item.id" :label="item.name"></el-option>
         </el-select>
       </el-form-item>
       <el-form-item label="鏍囩锛�" prop="tagIds">
@@ -51,10 +51,12 @@
 <script>
 import { mapGetters, mapState, mapActions } from 'vuex'
 import userApi from '@/api/user'
+import departmentApi from '@/api/department'
 
 export default {
   data () {
     return {
+      depts: [],
       tags: [],
       value2:[],
       form: {
@@ -68,7 +70,7 @@
         sex: '',
         birthDay: null,
         phone: null,
-        deptIds: [],
+        deptIds: '',
         tagIds: []
       },
       formLoading: false,
@@ -90,7 +92,8 @@
   },
   created () {
     this.getTags();
-    
+    this.getDepts();
+
     console.log(this.levelEnum)
     let id = this.$route.query.id
     let _this = this
@@ -119,6 +122,11 @@
         this.tags = data.response
       })
     },
+    getDepts () {
+      departmentApi.getDeptAdmins().then(res => {
+        this.depts = res.response
+      })
+    },
     submitForm () {
       console.log("this.form", this.form)
       let _this = this

--
Gitblit v1.8.0