Browse Source

:sparkles: 添加新特性。 终端管理可选配,支持手机号脱敏

冷冷 6 years ago
parent
commit
52971394f1

File diff suppressed because it is too large
+ 1 - 1
public/cdn/avue/index.js


+ 0 - 2
src/const/crud/admin/user.js

@@ -14,7 +14,6 @@
  * this software without specific prior written permission.
  * Author: lengleng (wangiegie@gmail.com)
  */
-import {rule} from "@/util/rule"
 import {getDetails} from '@/api/admin/user'
 
 
@@ -65,7 +64,6 @@ export const tableOption = {
         message: '长度在 3 到 20 个字符',
         trigger: 'blur'
       },
-      {validator: rule.validatorName, trigger: 'blur'},
       {validator: validateUsername, trigger: 'blur'}
     ]
   }, {

+ 119 - 115
src/page/index/index.vue

@@ -36,132 +36,136 @@
 </template>
 
 <script>
-import { mapGetters } from 'vuex'
-import tags from './tags'
-import top from './top/'
-import sidebar from './sidebar/'
-import admin from '@/util/admin'
-import { getStore } from '@/util/store.js'
-import * as SockJS from 'sockjs-client'
-import Stomp from 'stomp-websocket'
-import store from '@/store'
+  import {mapGetters} from 'vuex'
+  import tags from './tags'
+  import top from './top/'
+  import sidebar from './sidebar/'
+  import admin from '@/util/admin'
+  import {getStore} from '@/util/store.js'
+  import * as SockJS from 'sockjs-client'
+  import Stomp from 'stomp-websocket'
+  import store from '@/store'
 
-export default {
-  name: 'Index',
-  components: {
-    top,
-    tags,
-    sidebar
-  },
-  data() {
-    return {
-      // 刷新token锁
-      refreshLock: false,
-      // 刷新token的时间
-      refreshTime: '',
-      // 计时器
-      timer: ''
-    }
-  },
-  created() {
-    // 实时检测刷新token
-    this.refreshToken()
-  },
-  destroyed() {
-    clearInterval(this.refreshTime)
-    clearInterval(this.timer)
-    this.disconnect()
-  },
-  mounted() {
-    this.init()
-   /*
-    * 默认关闭websocket,如需工作流通知,则开启
-    * this.initWebSocket()
-   */
-  },
-  computed: mapGetters(['userInfo', 'isLock', 'isCollapse', 'website', 'expires_in']),
-  methods: {
-    showCollapse() {
-      this.$store.commit('SET_COLLAPSE')
+  export default {
+    name: 'Index',
+    components: {
+      top,
+      tags,
+      sidebar
     },
-    // 屏幕检测
-    init() {
-      this.$store.commit('SET_SCREEN', admin.getScreen())
-      window.onresize = () => {
-        setTimeout(() => {
-          this.$store.commit('SET_SCREEN', admin.getScreen())
-        }, 0)
+    data() {
+      return {
+        // 刷新token锁
+        refreshLock: false,
+        // 刷新token的时间
+        refreshTime: '',
+        // 计时器
+        timer: ''
       }
     },
-    // 实时检测刷新token
-    refreshToken() {
-      this.refreshTime = setInterval(() => {
-        const token = getStore({
-          name: 'access_token',
-          debug: true
-        })
+    created() {
+      // 实时检测刷新token
+      this.refreshToken()
+    },
+    destroyed() {
+      clearInterval(this.refreshTime)
+      clearInterval(this.timer)
+      /*
+      * 默认关闭websocket,如需工作流通知,则开启
+      * this.disconnect()
+      */
 
-        if (this.validatenull(token)) {
-          return
+    },
+    mounted() {
+      this.init()
+      /*
+       * 默认关闭websocket,如需工作流通知,则开启
+       * this.initWebSocket()
+      */
+    },
+    computed: mapGetters(['userInfo', 'isLock', 'isCollapse', 'website', 'expires_in']),
+    methods: {
+      showCollapse() {
+        this.$store.commit('SET_COLLAPSE')
+      },
+      // 屏幕检测
+      init() {
+        this.$store.commit('SET_SCREEN', admin.getScreen())
+        window.onresize = () => {
+          setTimeout(() => {
+            this.$store.commit('SET_SCREEN', admin.getScreen())
+          }, 0)
         }
+      },
+      // 实时检测刷新token
+      refreshToken() {
+        this.refreshTime = setInterval(() => {
+          const token = getStore({
+            name: 'access_token',
+            debug: true
+          })
 
-        if (this.expires_in <= 1000 && !this.refreshLock) {
-          this.refreshLock = true
-          this.$store
-            .dispatch('RefreshToken')
-            .catch(() => {
-              clearInterval(this.refreshTime)
-            })
-          this.refreshLock = false
-        }
-        this.$store.commit('SET_EXPIRES_IN', this.expires_in - 10)
-      }, 10000)
-    },
-    initWebSocket() {
-      this.connection()
-      const self = this
-      // 断开重连机制,尝试发送消息,捕获异常发生时重连
-      this.timer = setInterval(() => {
-        try {
-          self.stompClient.send('test')
-        } catch (err) {
-          console.log('断线了: ' + err)
-          self.connection()
+          if (this.validatenull(token)) {
+            return
+          }
+
+          if (this.expires_in <= 1000 && !this.refreshLock) {
+            this.refreshLock = true
+            this.$store
+              .dispatch('RefreshToken')
+              .catch(() => {
+                clearInterval(this.refreshTime)
+              })
+            this.refreshLock = false
+          }
+          this.$store.commit('SET_EXPIRES_IN', this.expires_in - 10)
+        }, 10000)
+      },
+      initWebSocket() {
+        this.connection()
+        const self = this
+        // 断开重连机制,尝试发送消息,捕获异常发生时重连
+        this.timer = setInterval(() => {
+          try {
+            self.stompClient.send('test')
+          } catch (err) {
+            console.log('断线了: ' + err)
+            self.connection()
+          }
+        }, 5000)
+      },
+      connection() {
+        const token = store.getters.access_token
+        const TENANT_ID = getStore({name: 'tenantId'}) ? getStore({name: 'tenantId'}) : '1'
+        const headers = {
+          'Authorization': 'Bearer ' + token
         }
-      }, 5000)
-    },
-    connection() {
-      const token = store.getters.access_token
-      const TENANT_ID = getStore({ name: 'tenantId' }) ? getStore({ name: 'tenantId' }) : '1'
-      const headers = {
-        'Authorization': 'Bearer ' + token
-      }
-      // 建立连接对象
-      this.socket = new SockJS('/act/ws')// 连接服务端提供的通信接口,连接以后才可以订阅广播消息和个人消息
-      // 获取STOMP子协议的客户端对象
-      this.stompClient = Stomp.over(this.socket)
-      this.stompClient.debug = null
-      // 向服务器发起websocket连接
-      this.stompClient.connect(headers, () => {
-        this.stompClient.subscribe('/task/' + this.userInfo.username + '-' + TENANT_ID + '/remind', (msg) => { // 订阅服务端提供的某个topic;
-          this.$notify({
-            title: '协同提醒',
-            type: 'warning',
-            dangerouslyUseHTMLString: true,
-            message: msg.body + '任务,请及时处理',
-            offset: 60
+        // 建立连接对象
+        this.socket = new SockJS('/act/ws')// 连接服务端提供的通信接口,连接以后才可以订阅广播消息和个人消息
+        // 获取STOMP子协议的客户端对象
+        this.stompClient = Stomp.over(this.socket)
+        this.stompClient.debug = null
+        // 向服务器发起websocket连接
+        this.stompClient.connect(headers, () => {
+          this.stompClient.subscribe('/task/' + this.userInfo.username + '-' + TENANT_ID + '/remind', (msg) => { // 订阅服务端提供的某个topic;
+            this.$notify({
+              title: '协同提醒',
+              type: 'warning',
+              dangerouslyUseHTMLString: true,
+              message: msg.body + '任务,请及时处理',
+              offset: 60
+            })
           })
-        })
-      }, (err) => {
+        }, (err) => {
 
-      })
-    },
-    disconnect() {
-      if (this.stompClient != null) {
-        this.stompClient.disconnect()
-        console.log('Disconnected')
+        })
+      },
+      disconnect() {
+        if (this.stompClient != null) {
+          this.stompClient.disconnect()
+          console.log('Disconnected')
+        }
       }
     }
   }
-}
 </script>

+ 2 - 2
src/store/modules/user.js

@@ -101,7 +101,7 @@ const user = {
       return new Promise((resolve, reject) => {
         getUserInfo().then((res) => {
           const data = res.data.data || {}
-          commit('SET_USERIFNO', data.sysUser)
+          commit('SET_USER_INFO', data.sysUser)
           commit('SET_ROLES', data.roles || [])
           commit('SET_PERMISSIONS', data.permissions || [])
           resolve(data)
@@ -201,7 +201,7 @@ const user = {
         type: 'session'
       })
     },
-    SET_USERIFNO: (state, userInfo) => {
+    SET_USER_INFO: (state, userInfo) => {
       state.userInfo = userInfo
     },
     SET_MENU: (state, menu) => {

+ 2 - 0
src/views/admin/client/index.vue

@@ -99,6 +99,7 @@
         })
       },
       handleUpdate: function (row, index, done) {
+        row.authorizedGrantTypes = row.authorizedGrantTypes.join(',')
         putObj(row).then(() => {
           this.tableData.splice(index, 1, Object.assign({}, row))
           this.$message({
@@ -111,6 +112,7 @@
         })
       },
       handleSave: function (row, done) {
+        row.authorizedGrantTypes = row.authorizedGrantTypes.join(',')
         addObj(row).then(() => {
           this.tableData.push(Object.assign({}, row))
           this.$message({

+ 168 - 162
src/views/admin/user/index.vue

@@ -130,186 +130,192 @@
 </template>
 
 <script>
-import { addObj, delObj, fetchList, putObj } from '@/api/admin/user'
-import { deptRoleList } from '@/api/admin/role'
-import { fetchTree } from '@/api/admin/dept'
-import { tableOption } from '@/const/crud/admin/user'
-import { mapGetters } from 'vuex'
+  import {addObj, delObj, fetchList, putObj} from '@/api/admin/user'
+  import {deptRoleList} from '@/api/admin/role'
+  import {fetchTree} from '@/api/admin/dept'
+  import {tableOption} from '@/const/crud/admin/user'
+  import {mapGetters} from 'vuex'
 
-export default {
-  name: 'SysUser',
-  data() {
-    return {
-      searchForm: {},
-      treeOption: {
-        nodeKey: 'id',
-        addBtn: false,
-        menu: false,
-        props: {
+  export default {
+    name: 'SysUser',
+    data() {
+      return {
+        searchForm: {},
+        treeOption: {
+          nodeKey: 'id',
+          addBtn: false,
+          menu: false,
+          props: {
+            label: 'name',
+            value: 'id'
+          }
+        },
+        treeData: [],
+        option: tableOption,
+        treeDeptData: [],
+        checkedKeys: [],
+        roleProps: {
+          label: 'roleName',
+          value: 'roleId'
+        },
+        defaultProps: {
           label: 'name',
           value: 'id'
-        }
-      },
-      treeData: [],
-      option: tableOption,
-      treeDeptData: [],
-      checkedKeys: [],
-      roleProps: {
-        label: 'roleName',
-        value: 'roleId'
-      },
-      defaultProps: {
-        label: 'name',
-        value: 'id'
-      },
-      page: {
-        total: 0, // 总页数
-        currentPage: 1, // 当前页数
-        pageSize: 20, // 每页显示多少条,
-        isAsc: false// 是否倒序
-      },
-      list: [],
-      listLoading: true,
-      role: [],
-      form: {},
-      rolesOptions: []
-    }
-  },
-  computed: {
-    ...mapGetters(['permissions'])
-  },
-  watch: {
-    role() {
-      this.form.role = this.role
-    }
-  },
-  created() {
-    this.sys_user_add = this.permissions['sys_user_add']
-    this.sys_user_edit = this.permissions['sys_user_edit']
-    this.sys_user_del = this.permissions['sys_user_del']
-    this.init()
-  },
-  methods: {
-    init() {
-      fetchTree().then(response => {
-        this.treeData = response.data.data
-      })
-    },
-    nodeClick(data) {
-      this.page.page = 1
-      this.getList(this.page, { deptId: data.id })
-    },
-    getList(page, params) {
-      this.listLoading = true
-      fetchList(Object.assign({
-        current: page.currentPage,
-        size: page.pageSize
-      }, params, this.searchForm)).then(response => {
-        this.list = response.data.data.records
-        this.page.total = response.data.data.total
-        this.listLoading = false
-      })
-    },
-    getNodeData() {
-      deptRoleList().then(response => {
-        this.rolesOptions = response.data.data
-      })
-    },
-    handleDept() {
-      fetchTree().then(response => {
-        this.treeDeptData = response.data.data
-      })
+        },
+        page: {
+          total: 0, // 总页数
+          currentPage: 1, // 当前页数
+          pageSize: 20, // 每页显示多少条,
+          isAsc: false// 是否倒序
+        },
+        list: [],
+        listLoading: true,
+        role: [],
+        form: {},
+        rolesOptions: []
+      }
     },
-    handleFilter(param) {
-      this.searchForm = param
-      this.getList(this.page, param)
+    computed: {
+      ...mapGetters(['permissions'])
     },
-    handleRefreshChange() {
-      this.getList(this.page)
+    watch: {
+      role() {
+        this.form.role = this.role
+      }
     },
-    handleCreate() {
-      this.$refs.crud.rowAdd()
+    created() {
+      this.sys_user_add = this.permissions['sys_user_add']
+      this.sys_user_edit = this.permissions['sys_user_edit']
+      this.sys_user_del = this.permissions['sys_user_del']
+      this.init()
     },
-    handleOpenBefore(show, type) {
-      window.boxType = type
-      this.handleDept()
-      if (['edit', 'views'].includes(type)) {
-        this.role = []
-        for (var i = 0; i < this.form.roleList.length; i++) {
-          this.role[i] = this.form.roleList[i].roleId
-        }
+    methods: {
+      init() {
+        fetchTree().then(response => {
+          this.treeData = response.data.data
+        })
+      },
+      nodeClick(data) {
+        this.page.page = 1
+        this.getList(this.page, {deptId: data.id})
+      },
+      getList(page, params) {
+        this.listLoading = true
+        fetchList(Object.assign({
+          current: page.currentPage,
+          size: page.pageSize
+        }, params, this.searchForm)).then(response => {
+          this.list = response.data.data.records
+          this.page.total = response.data.data.total
+          this.listLoading = false
+        })
+      },
+      getNodeData() {
         deptRoleList().then(response => {
           this.rolesOptions = response.data.data
         })
-      } else if (type === 'add') {
-        this.role = []
-      }
-      show()
-    },
-    handleUpdate(row, index) {
-      this.$refs.crud.rowEdit(row, index)
-      this.form.password = undefined
-    },
-    create(row, done, loading) {
-      addObj(this.form).then(() => {
-        this.getList(this.page)
-        done()
-        this.$notify({
-          title: '成功',
-          message: '创建成功',
-          type: 'success',
-          duration: 2000
+      },
+      handleDept() {
+        fetchTree().then(response => {
+          this.treeDeptData = response.data.data
         })
-      }).catch(() => {
-        loading()
-      })
-    },
-    update(row, index, done, loading) {
-      putObj(this.form).then(() => {
+      },
+      handleFilter(param) {
+        this.searchForm = param
+        this.getList(this.page, param)
+      },
+      handleRefreshChange() {
         this.getList(this.page)
-        done()
-        this.$notify({
-          title: '成功',
-          message: '修改成功',
-          type: 'success',
-          duration: 2000
+      },
+      handleCreate() {
+        this.$refs.crud.rowAdd()
+      },
+      handleOpenBefore(show, type) {
+        window.boxType = type
+        this.handleDept()
+        if (['edit', 'views'].includes(type)) {
+          this.role = []
+          for (var i = 0; i < this.form.roleList.length; i++) {
+            this.role[i] = this.form.roleList[i].roleId
+          }
+          deptRoleList().then(response => {
+            this.rolesOptions = response.data.data
+          })
+        } else if (type === 'add') {
+          this.role = []
+        }
+        show()
+      },
+      handleUpdate(row, index) {
+        this.$refs.crud.rowEdit(row, index)
+        this.form.password = undefined
+      },
+      create(row, done, loading) {
+        if (this.form.phone.indexOf('*') > 0) {
+          this.form.phone = undefined
+        }
+        addObj(this.form).then(() => {
+          this.getList(this.page)
+          done()
+          this.$notify({
+            title: '成功',
+            message: '创建成功',
+            type: 'success',
+            duration: 2000
+          })
+        }).catch(() => {
+          loading()
         })
-      }).catch(() => {
-        loading()
-      })
-    },
-    deletes(row, index) {
-      this.$confirm(
-        '此操作将永久删除该用户(用户名:' + row.username + '), 是否继续?',
-        '提示',
-        {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
+      },
+      update(row, index, done, loading) {
+        if (this.form.phone.indexOf('*') > 0) {
+          this.form.phone = undefined
         }
-      ).then(() => {
-        delObj(row.userId)
-          .then(() => {
-            this.list.splice(index, 1)
-            this.$notify({
-              title: '成功',
-              message: '删除成功',
-              type: 'success',
-              duration: 2000
-            })
+        putObj(this.form).then(() => {
+          this.getList(this.page)
+          done()
+          this.$notify({
+            title: '成功',
+            message: '修改成功',
+            type: 'success',
+            duration: 2000
           })
-          .cache(() => {
-            this.$notify({
-              title: '失败',
-              message: '删除失败',
-              type: 'error',
-              duration: 2000
+        }).catch(() => {
+          loading()
+        })
+      },
+      deletes(row, index) {
+        this.$confirm(
+          '此操作将永久删除该用户(用户名:' + row.username + '), 是否继续?',
+          '提示',
+          {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+          }
+        ).then(() => {
+          delObj(row.userId)
+            .then(() => {
+              this.list.splice(index, 1)
+              this.$notify({
+                title: '成功',
+                message: '删除成功',
+                type: 'success',
+                duration: 2000
+              })
             })
-          })
-      })
+            .cache(() => {
+              this.$notify({
+                title: '失败',
+                message: '删除失败',
+                type: 'error',
+                duration: 2000
+              })
+            })
+        })
+      }
     }
   }
-}
 </script>
 <style lang="scss">
   .user {