Browse Source

处理员工管理搜索功能BUG

wangcz 7 years ago
parent
commit
d0d82cd875
2 changed files with 11 additions and 12 deletions
  1. 9 10
      components/mobile/staffManagement/StaffList.vue
  2. 2 2
      store/staff/infoList.js

+ 9 - 10
components/mobile/staffManagement/StaffList.vue

@@ -192,7 +192,7 @@
     },
     computed: {
       staffData () {
-        return this.$store.state.staff.infoList.info.data
+        return this.$store.state.staff.infoList.info.data.content ? this.$store.state.staff.infoList.info.data : {content:[]}
       },
       fetching () {
         return this.staffData.fetching
@@ -201,7 +201,7 @@
         return Math.floor(this.staffData.totalElements / this.staffData.size) + Math.floor(this.staffData.totalElements % this.staffData.size > 0 ? 1 : 0)
       },
       auditBind () {
-        return this.$store.state.staff.infoList.audit.data || {content:[]}
+        return this.$store.state.staff.infoList.audit.data.content ? this.$store.state.staff.infoList.audit.data : {content:[]}
       },
       fetch () {
         return this.$store.state.staff.infoList.audit.fetching
@@ -240,10 +240,8 @@
       },
       // 员工列表搜索
       staffRecord () {
-        this.role = '全部角色'
         this.showRole = false
-        this.isChange = true
-        this.$store.dispatch('staff/loadStaffList', {count: this.count, page: this.page, enuu: this.user.data.enterprise.uu, keyword: this.staffSearch})
+        this.rolesEvent()
       },
       // 员工列表删除员工
       openDelete (item) {
@@ -274,16 +272,19 @@
       },
       // 选择性搜索
       rolesEvent (type) {
+        this.isChange = true
         this.showRole = !this.showRole
+        this.role = type ? type.desc : '全部角色'
         this.page = 1
-        if (type) {
-          this.role = type.desc
+        if (!type && !this.staffSearch) {
+          this.$store.dispatch('staff/loadStaffList', {count: this.count, page: this.page, enuu: this.user.data.enterprise.uu, keyword: this.staffSearch})
+        } else {
           let params = {
             count: this.count,
             page: this.page,
             enuu: this.user.data.enterprise.uu,
             keyword: this.staffSearch,
-            roleId: type.id
+            roleId: type ? type.id : null
           }
           this.isChange = true
           this.$store.commit('staff/infoList/REQUEST_INFO_LIST')
@@ -293,8 +294,6 @@
             }, err => {
               this.$store.commit('staff/infoList/GET_INFO_LIST_FAILURE', err)
             })
-        } else {
-          this.staffRecord()
         }
       },
       // 获取角色

+ 2 - 2
store/staff/infoList.js

@@ -1,11 +1,11 @@
 export const state = () => ({
   info: {
     fetching: false,
-    data: []
+    data: {}
   },
   audit: {
     fetching: false,
-    data: []
+    data: {}
   },
   edit: {
     fetching: false,