From fe285713f52314ced23d1a5aa2654d8eaab522f9 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期五, 08 三月 2024 14:47:05 +0800
Subject: [PATCH] 部门增加管理员,管理员修改

---
 src/views/education/department/edit.vue |   70 +++++++++++++++++++++-------------
 1 files changed, 43 insertions(+), 27 deletions(-)

diff --git a/src/views/education/department/edit.vue b/src/views/education/department/edit.vue
index 9cf1ea9..ea06fa2 100644
--- a/src/views/education/department/edit.vue
+++ b/src/views/education/department/edit.vue
@@ -10,6 +10,16 @@
 <!--          <el-option v-for="item in levelEnum" :key="item.key" :value="item.key" :label="item.value"></el-option>-->
 <!--        </el-select>-->
 <!--      </el-form-item>-->
+      <el-form-item label="绠$悊鍛橈細" required>
+        <el-select v-model="form.adminId" filterable placeholder="閫夋嫨绠$悊鍛�">
+          <el-option
+            v-for="item in deptUserList"
+            :key="item.id"
+            :label="item.value"
+            :value="item.id">
+          </el-option>
+        </el-select>
+      </el-form-item>
       <el-form-item>
         <el-button type="primary" @click="submitForm">鎻愪氦</el-button>
         <el-button @click="resetForm">閲嶇疆</el-button>
@@ -20,16 +30,17 @@
 
 <script>
 import { mapGetters, mapState, mapActions } from 'vuex'
-import subjectApi from '@/api/subject'
 import departmentApi from '@/api/department'
-import enumItem from '@/store/modules/enumItem'
 export default {
   data () {
     return {
-      depart:[],
+      // 閮ㄩ棬浜哄憳
+      deptUserList: [],
+      depart: [],
       form: {
         id: null,
         name: '',
+        adminId: null
         // level: 1,
         // levelName: ''
       },
@@ -39,7 +50,6 @@
   },
   created () {
     let id = this.$route.query.id
-    console.log(id)
     let _this = this
     if (id && parseInt(id) !== 0) {
       _this.formLoading = true
@@ -47,43 +57,49 @@
         _this.form = re.response
         _this.formLoading = false
       })
+      // 鑾峰彇閮ㄩ棬浜哄憳
+      _this.getUserSelect(id)
     }
-    if (id == undefined) {
-      _this.fig = 1 //鏄柊澧�
+    if (id === undefined) {
+      _this.fig = 1 // 鏄柊澧�
     } else {
-      _this.fig = 0 //鏄紪杈�
+      _this.fig = 0 // 鏄紪杈�
     }
   },
   methods: {
+    getUserSelect (id) {
+      departmentApi.getDeptUserList(id).then(res => {
+        this.deptUserList = res.response
+      })
+    },
     submitForm () {
       let _this = this
       this.formLoading = true
       // this.form.levelName = this.enumFormat(this.levelEnum, this.form.level)
-      let obj = {
-        name:this.form.name
-      }
-      if (_this.fig==1){
-        departmentApi.addData(this.form.name).then(res=>{
+      // let obj = {
+      //   name: this.form.name
+      // }
+      if (_this.fig === 1) {
+        departmentApi.addData(this.form.name).then(res => {
           console.log(res)
-          if (res.code ==1){
-
-            _this.$message.success(res.message)
-                _this.delCurrentView(_this).then(() => {
-                  _this.$router.push('/education/department/list')
-                })
-          }else {
-            _this.$message.error(res.message)
-          }
-        })
-      }else {
-        departmentApi.edit(this.form).then(res=>{
-          console.log(res)
-          if (res.code ==1){
+          if (res.code === 1) {
             _this.$message.success(res.message)
             _this.delCurrentView(_this).then(() => {
               _this.$router.push('/education/department/list')
             })
-          }else {
+          } else {
+            _this.$message.error(res.message)
+          }
+        })
+      } else {
+        departmentApi.edit(this.form).then(res => {
+          console.log(res)
+          if (res.code === 1) {
+            _this.$message.success(res.message)
+            _this.delCurrentView(_this).then(() => {
+              _this.$router.push('/education/department/list')
+            })
+          } else {
             _this.$message.error(res.message)
           }
         })

--
Gitblit v1.8.0