Browse Source

处理员工管理搜索功能

wangcz 7 years ago
parent
commit
26cc0a0933
2 changed files with 132 additions and 53 deletions
  1. 132 51
      components/mobile/staffManagement/StaffList.vue
  2. 0 2
      store/staff.js

+ 132 - 51
components/mobile/staffManagement/StaffList.vue

@@ -13,24 +13,18 @@
       <div class="staff-record" v-if="switchType === 'info'">
         <div class="search-content clearfix">
           <div class="search">
-            <!--<input type="text" placeholder="卖家名称/订单号" v-model="filterParams.keyword" @keyup.13="filterRecord">-->
-            <input type="text" placeholder="人员姓名、电话号码、邮箱或UU" class="staff-search">
-            <!--<span @click="filterRecord"><i class="iconfont icon-sousuo"></i></span>-->
-            <span><i class="iconfont icon-sousuo"></i></span>
+            <input type="text" placeholder="人员姓名、电话号码、邮箱或UU" v-model="staffSearch" class="staff-search" @keyup.13="staffRecord()">
+            <span @click="staffRecord()"><i class="iconfont icon-sousuo"></i></span>
           </div>
           <div class="search-filter">
-            <div class="select-wrap">全部角色<i class="iconfont icon-arrow-down"></i></div>
-            <ul class="select-list" v-if="false">
-              <li>全部角色</li>
-              <li>管理员</li>
-              <li>店长</li>
-              <li>普通用户</li>
-              <li>销售员</li>
-              <li>任意测试</li>
+            <div class="select-wrap" @click="showRoleEvent($event)"><strong v-text="role"></strong><i class="iconfont icon-arrow-down"></i></div>
+            <ul class="select-list" v-if="showRole">
+              <li @click="rolesEvent()">全部角色</li>
+              <li v-for="item in roles" v-text="item.desc" @click="rolesEvent(item)">全部角色</li>
             </ul>
           </div>
         </div>
-        <div class="list-content">
+        <div class="list-content" v-if="staffData && staffData.length">
           <div class="bg" v-for="item in staffData">
             <div class="staff-list">
               <div class="list-item"><span>UU账号:</span><span v-text="item.userUU">100000721</span></div>
@@ -46,17 +40,16 @@
             </div>
           </div>
         </div>
+        <empty-status :type="'collect'" :showLink="true" :text="'抱歉,没有相关信息'" v-else></empty-status>
         <nuxt-link class="staff-add" :to="'/mobile/user/staff/add'"><i class="iconfont icon-add"></i>新增用户</nuxt-link>
       </div>
       <div class="staff-record" v-if="switchType === 'Audit'">
         <div class="search-content">
-          <!--<input type="text" placeholder="卖家名称/订单号" v-model="filterParams.keyword" @keyup.13="filterRecord">-->
-          <input type="text" placeholder="人员姓名、电话号码、邮箱或UU" v-model="auditSearch">
-          <!--<span @click="filterRecord"><i class="iconfont icon-sousuo"></i></span>-->
-          <span><i class="iconfont icon-sousuo"></i></span>
+          <input type="text" placeholder="人员姓名、电话号码、邮箱或UU" v-model="auditSearch" @keyup.13="auditRecord()">
+          <span @click="auditRecord()"><i class="iconfont icon-sousuo"></i></span>
         </div>
-        <div class="list-content">
-          <div class="bg" v-for="item in auditBind.content">
+        <div class="list-content" id="auditFixContent" v-if="AuditList && AuditList.length">
+          <div class="bg" v-for="item in AuditList">
             <div class="staff-list">
               <div class="list-item"><span>用户名:</span><span v-text="item.user.vipName"></span></div>
               <div class="list-item"><span>UU账号:</span><span v-text="item.user.userUU">100000721</span></div>
@@ -69,11 +62,9 @@
             </div>
           </div>
         </div>
-        <empty-status :type="'collect'" :showLink="true" :text="'抱歉,没有相关信息'"></empty-status>
+        <empty-status :type="'collect'" :showLink="true" :text="'抱歉,没有相关信息'" v-else></empty-status>
       </div>
-      <!--<seek-list :keyword="remindKeyword" :isSearch="isSearch" :userType="userType" :seekType="seekType" :purchaseManList="purchaseManListData"></seek-list>-->
-      <!--<pull-up :fixId="'mobileFixContent'" :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="onPullUpAction"></pull-up>-->
-      <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
+      <pull-up :fixId="'auditFixContent'" :searchMore="fetching" :allPage="allPageAudit" :page="page" @pullUpAction="onPullUpAction"></pull-up>
     </div>
     <!--删除员工-->
     <div class="deleteKuang" v-if="showDelete">
@@ -86,6 +77,7 @@
         </div>
       </div>
     </div>
+    <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
   </div>
 </template>
 <script>
@@ -99,10 +91,16 @@
         timeoutCount: 0,
         page: 1,
         count: 10,
+        staffSearch: '',
         auditSearch: '',
+        AuditList: [],
+        isChange: false,
         switchType: 'info',
         showDelete: false,
-        currentObject: ''
+        currentObject: '',
+        role: '全部角色',
+        roles: [],
+        showRole: false
       }
     },
     components: {
@@ -111,6 +109,22 @@
       EmptyStatus,
       BaseFilter
     },
+    mounted () {
+      this.auditRecord()
+      // 获取角色
+      this.$nextTick(() => {
+        this.getRoles()
+      })
+      let _this = this
+      _this.$nextTick(function () {
+        window.addEventListener('scroll', function () {
+          _this.scroll()
+        }, false)
+        document.body.onclick = () => {
+          this.showRole = false
+        }
+      })
+    },
     watch: {
       // 'buyerAccount': {
       //   handler: function (val) {
@@ -122,6 +136,17 @@
       //       this.accountList = [...this.accountList, ...val.content]
       //     }
       //   }
+      'auditBind': {
+        handler: function (val) {
+          if (this.isChange) {
+            this.AuditList = val.content
+            this.isChange = false
+          } else {
+            this.AuditList = [...this.AuditList, ...val.content]
+          }
+        },
+        immediate: true
+      }
     },
     computed: {
       staffData () {
@@ -130,43 +155,98 @@
       auditBind () {
         return this.$store.state.staff.infoList.audit.data.content ? this.$store.state.staff.infoList.audit.data.content : {}
       },
+      fetching () {
+        return this.$store.state.staff.infoList.audit.fetching
+      },
+      allPageAudit () {
+        return Math.floor(this.auditBind.totalElements / this.auditBind.size) + Math.floor(this.auditBind.totalElements % this.auditBind.size > 0 ? 1 : 0)
+      },
       userInfo () {
         return this.$store.state.option.user.data
       }
     },
-    // fetch ({ store }) {
-    //   return Promise.all([
-    //     store.dispatch('staff/bindAudit', {size: this.count, page: this.page, speaceUU: this.user.userUU, status: 311, keyword: this.auditSearch})
-    //   ])
-    // },
     methods: {
+      onRemind: function (str) {
+        this.remindText = str
+        this.timeoutCount++
+      },
+      // 获取角色信息
+      getRoles () {
+        this.$http.get('/account/role')
+          .then(response => {
+            if (response.data) {
+              this.roles = response.data
+            }
+          })
+          .catch(err => {
+            console.log(err)
+        })
+      },
       goEdit (item) {
         this.$store.commit('staff/infoList/EDIT_DATA_SUCCESS', item)
         this.$router.push('/mobile/user/staff/edit')
       },
       setSwitchType (type) {
         this.switchType = type
-        this.$http({
-          method: 'get',
-          baseURL: process.env.ssoUrl,
-          url: `/api/userspace/apply/info/mall`,
-          data: {
-            count: 10,
-            page: 1,
-            speaceUU: 10049698,
-            status: 311
-          }
-        }).then(res => {
-            console.log('1', res.data)
-          }, err => {
-            console.log('12', err)
-          })
       },
       // 删除员工
       openDelete (item) {
         this.currentObject = item
         this.showDelete = true
       },
+      agreeEvent (type, flag) {
+        this.$http.get(`/basic/enterprise/auditApply?id=${type.id}&status=${Number(flag)}&userUU=${type.userUU}`)
+        this.auditSearch = null
+        this.page = 1
+        this.auditRecord()
+      },
+      // 员工搜索
+      staffRecord () {
+        this.role = '全部角色'
+        this.showRole = false
+        this.$store.dispatch('staff/loadStaffList', {count: this.count, page: this.page, enuu: this.user.data.enterprise.uu, keyword: this.staffSearch})
+      },
+      // 打开选择
+      showRoleEvent (e) {
+        if (e) {
+          e.stopPropagation()
+        }
+        this.showRole = !this.showRole
+      },
+      // 选择性搜索
+      rolesEvent (type) {
+        this.showRole = !this.showRole
+        this.page = 1
+        if (type) {
+          this.role = type.desc
+          let params = {
+            count: this.count,
+            page: this.page,
+            enuu: this.user.data.enterprise.uu,
+            keyword: this.staffSearch,
+            roleId: type.id
+          }
+          this.$store.commit('infoList/REQUEST_INFO_LIST')
+          this.$http.get('/basic/user/enterprise/keywordinfo', {params})
+            .then(response => {
+              this.$store.commit('staff/infoList/GET_INFO_LIST_SUCCESS', response.data ? response.data : {})
+            }, err => {
+              this.$store.commit('staff/infoList/GET_INFO_LIST_FAILURE', err)
+            })
+        } else {
+          this.role = '全部角色'
+          this.staffRecord()
+        }
+      },
+      // 申请绑定搜索
+      auditRecord () {
+        this.isChange = true
+        this.$store.dispatch('staff/loadBindAudit', {count: this.count, page: this.page, speaceUU: this.user.data.enterprise.uu, status: 311, keyword: this.auditSearch})
+      },
+      onPullUpAction () {
+        this.page++
+        this.auditRecord()
+      },
       sureDelete () {
         this.$http.delete('/basic/user/' + this.currentObject.userUU)
           .then(response => {
@@ -175,13 +255,9 @@
             this.onRemind('用户' + this.currentObject.userUU + '删除成功')
             this.staffData()
           }).catch(data => {
-            this.showDelete = false
-            this.onRemind(data.response.data)
-          })
-      },
-      onRemind: function (str) {
-        this.remindText = str
-        this.timeoutCount ++
+          this.showDelete = false
+          this.onRemind(data.response.data)
+        })
       }
     }
   }
@@ -230,7 +306,12 @@
             background-color: #ffffff;
             border-radius: .06rem;
             border: solid 1px #b4b4b4;
+            strong{
+              font-weight: normal;
+            }
             i{
+              float:right;
+              display:inline-block;
               font-size: .1rem;
               font-weight: bold;
               color: $base-color;

+ 0 - 2
store/staff.js

@@ -7,7 +7,6 @@ export const actions = {
     return axios.get('/basic/user/enterprise/info', {params})
       .then(response => {
         commit('infoList/GET_INFO_LIST_SUCCESS', response.data)
-        console.log(response.data, 'staff')
       }, err => {
         commit('infoList/GET_INFO_LIST_FAILURE', err)
       })
@@ -18,7 +17,6 @@ export const actions = {
     return axios.get(`/api/userspace/apply/info/mall`, {params})
       .then(res => {
         commit('infoList/GET_BIND_AUDIT_SUCCESS', res.data)
-        console.log(res.data, 'bind')
       }, err => {
         commit('infoList/GET_BIND_AUDIT_FAILURE', err)
       })