Browse Source

最新修改

e 4 years ago
parent
commit
8e56135ef5
5 changed files with 73 additions and 55 deletions
  1. 1 1
      .eslintrc.js
  2. 12 12
      src/sdk/ajax.js
  3. 8 8
      src/views/Home/Home.vue
  4. 22 22
      src/views/Login/Login.vue
  5. 30 12
      src/views/systemAdmin/authAdmin.vue

+ 1 - 1
.eslintrc.js

@@ -5,7 +5,7 @@ module.exports = {
   },
   extends: ['plugin:vue/essential'],
   rules: {
-    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
+    'no-console': 'off',
     'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
   },
   parserOptions: {

+ 12 - 12
src/sdk/ajax.js

@@ -29,12 +29,12 @@ export const ajax = function (type = "post", url, params) {
                     'x-auth-token': token
                 }
             }).then((res) => {
-                switch (res.data.errCode) {
-                    case 'request_not_authorize': // 登录过期
-                        let url = window.location.protocol + "//" + window.location.host + "/#/login"
-                        window.location.replace(url)
-                        break;
-                }
+                // switch (res.data.errCode) {
+                //     case 'request_not_authorize': // 登录过期
+                //         let url = window.location.protocol + "//" + window.location.host + "/#/login"
+                //         window.location.replace(url)
+                //         break;
+                // }
                 resole(res.data);
             }).catch((err) => {
                 reject(err);
@@ -51,12 +51,12 @@ export const ajax = function (type = "post", url, params) {
                     'x-auth-token': token
                 }
             }).then((res) => {
-                switch (res.data.errCode) {
-                    case 'request_not_authorize': // 登录过期
-                        let url = window.location.protocol + "//" + window.location.host + "/#/login"
-                        window.location.replace(url)
-                        break;
-                }
+                // switch (res.data.errCode) {
+                //     case 'request_not_authorize': // 登录过期
+                //         let url = window.location.protocol + "//" + window.location.host + "/#/login"
+                //         window.location.replace(url)
+                //         break;
+                // }
                 resole(res.data);
             }).catch((err) => {
                 reject(err);

+ 8 - 8
src/views/Home/Home.vue

@@ -53,7 +53,7 @@
                         text-color="#fff"
                         active-text-color="#ffd04b"
                     >
-                        <div v-for="(item, index1) in menuData " :key="index1">
+                        <div v-for="(item, index1) in menu " :key="index1">
                             <el-submenu
                                 v-if="item.children && item.children.length > 0"
                                 :index="`${index1}`"
@@ -96,16 +96,16 @@
 </template>
 
 <script>
-import { menuData } from "./mencCofig.js";
+// import { menuData } from "./mencCofig.js";
 import { mapState } from 'vuex';
 
 export default {
     data() {
         return {
             // 菜单配置
-            menuData: menuData,
+            menuData: [],
             menuCollapse: false, //是否水平折叠收起菜单
-            defaultUnfoldedMenu: [menuData[0], 1], // 默认展开第一项
+            defaultUnfoldedMenu: [], // 默认展开第一项
         };
     },
     created() {
@@ -117,12 +117,12 @@ export default {
     },
     computed: {
       ...mapState(['typeCode']),
-      // menu() {
-      //   return this.menuData
-      // }
+      menu() {
+        return this.menuData
+      }
     },
     mounted() {
-        // this.init();
+        this.init();
         // 获取员工列表 给后面下拉选择器使用
         this.$store.dispatch('getWorkerList')
         // 获取栋舍列表 给后面下拉选择器使用

+ 22 - 22
src/views/Login/Login.vue

@@ -62,28 +62,28 @@ export default {
                 spinner: "el-icon-loading",
                 background: "rgba(0, 0, 0, 0.7)"
             });
-            reqLogin(this.form)
-                .then(res => {
-                    loading.close();
-                    localStorage.setItem("token", res.token);
-                    this.doOrganizationChoose();
-                })
-                .catch(err => {
-                    console.log("登录失败", err);
-                    this.$message.error("登录失败:" + err);
-                });
-            // this.$axios.post(`http://121.37.169.186:8081/my/login?accountName=${this.form.userName}&password=${this.form.userPwd}`)
-            // .then(res => {
-            //     loading.close();
-            //     if(res.data.code === 10000) {
-            //         // localStorage.setItem("token", res.data.token);
-            //         // localStorage.setItem("token", res.token);
-            //         localStorage.setItem('accountName', res.data.accountName);
-            //         // this.$router.replace ("/home/dashboard");
-            //     } else {
-            //         this.$message.error(res.data.message);
-            //     }
-            // })
+            // reqLogin(this.form)
+            //     .then(res => {
+            //         loading.close();
+            //         localStorage.setItem("token", res.token);
+            //         this.doOrganizationChoose();
+            //     })
+            //     .catch(err => {
+            //         console.log("登录失败", err);
+            //         this.$message.error("登录失败:" + err);
+            //     });
+            this.$axios.post(`http://121.37.169.186:8081/my/login?accountName=${this.form.userName}&password=${this.form.userPwd}`)
+            .then(res => {
+                loading.close();
+                if(res.data.code === 10000) {
+                    localStorage.setItem("token", res.data.token);
+                    // localStorage.setItem("token", res.token);
+                    localStorage.setItem('accountName', res.data.accountName);
+                    this.$router.replace ("/home/dashboard");
+                } else {
+                    this.$message.error(res.data.message);
+                }
+            })
         },
         handleSet: function() {
             if (!this.orgSelected) {

+ 30 - 12
src/views/systemAdmin/authAdmin.vue

@@ -98,9 +98,9 @@
                 show-checkbox
                 node-key="id"
                 default-expand-all
-                :default-checked-keys="selectList"
+                :default-checked-keys="defaultList"
                 :props="defaultProps"
-                @check="selectTable"
+                @check-change="handleCheckChange"
                 ref="tree">
         </el-tree>
       </div>
@@ -168,6 +168,8 @@
           children: 'children',
           label: 'menuName'
         },
+        // 默认选择的参数
+        defaultList: [],
         // 选择得参数
         selectList: [],
         keyword: '',
@@ -178,7 +180,10 @@
         // 用户列表
         userList: [],
         dialogUsers: false,
+        // 选择的列表
         userSelect: [],
+        // 默认选择的列表
+        defaultUserList: [],
       }
     },
     computed: {
@@ -209,13 +214,13 @@
       handleLimits(data) {
         this.dialogLimits = true;
         this.selectId = data.id;
-        this.selectList = [];
+        this.defaultList = [];
         this.$axios.post(`http://121.37.169.186:8081/auth/getMenuByGroup?groupId=${data.id}`)
         .then(res => {
           if(res.data.code === 10005) {
-            this.selectList = [];
+            this.defaultList = [];
           } else {
-            this.selectList = res.data.data.split(',');
+            this.defaultList = res.data.data.split(',');
             this.$forceUpdate();
           }
         })
@@ -224,16 +229,22 @@
       handleUser(data) {
         this.dialogUsers = true;
         this.selectId = data.id;
+        this.defaultUserList = [];
         this.$axios.post(`http://121.37.169.186:8081/auth/getAcountByGroup?groupId=${data.id}`)
         .then(res => {
           if(res.data.code === 10006) {
-            this.userSelect = [];
+            this.defaultUserList = [];
+            this.$nextTick(() => {
+              this.$refs.multipleTable.clearSelection();
+            })
           } else {
-            let arr = res.data.data.split(',');
+            this.defaultUserList = res.data.data.split(',');
+            console.log(this.defaultUserList);
             this.$nextTick(() => {
+              this.$refs.multipleTable.clearSelection();
               for (let key in this.userList) {
-                for(let i in arr) {
-                  if(this.userList[key]['id'] == arr[i]) {
+                for(let i in this.defaultUserList) {
+                  if(this.userList[key]['id'] == this.defaultUserList[i]) {
                     this.$refs.multipleTable.toggleRowSelection(this.userList[key], true);
                   }
                 }
@@ -263,8 +274,9 @@
         });
         this.dialogUsers = false;
       },
-      selectTable(data, checked, ) {
-        this.selectList = checked.checkedKeys.concat(checked.halfCheckedKeys);
+      handleCheckChange() {
+        this.selectList = [];
+        this.selectList = this.$refs.tree.getCheckedKeys().concat(this.$refs.tree.getHalfCheckedKeys());
       },
       // 新增角色
       onSubmit() {
@@ -295,7 +307,13 @@
       init() {
         this.$axios.post(`http://121.37.169.186:8081/group/list?pageNum=${this.pageNum}&pageSize=${this.size}&searchStr=${this.keyword}`)
         .then(res => {
-          this.tableData = res.data.content;
+          let arr = [];
+          res.data.content.forEach(item => {
+            if(item.remark === this.typeCode) {
+              arr.push(item);
+            }
+          });
+          this.tableData = arr;
           this.total = res.data.totalElements;
         })
       },