|
|
@@ -1,249 +1,303 @@
|
|
|
<template>
|
|
|
- <view class="address-page">
|
|
|
- <view class="search-form">
|
|
|
- <u-search placeholder="请输入隶属组织名称/姓名" v-model="searchKey" :showAction="false" @input="search"></u-search>
|
|
|
- </view>
|
|
|
- <u-loading-page loading-text="加载中..." :loading="loading" font-size="16"></u-loading-page>
|
|
|
- <view class="address__body">
|
|
|
- <view class="address__list">
|
|
|
- <view class="address__group" v-for="(item,key) in transformUserGroupList" :key="key">
|
|
|
- <view class="address__group__header">
|
|
|
- <view class="address__group__title">
|
|
|
- {{orgDataSource[key] && orgDataSource[key].org_name}}
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <view class="address__group__list">
|
|
|
- <view class="address__item" v-for="userItem in item" :key="item.user_id" @click="goToIM(userItem)">
|
|
|
- <view class="address__item__label">{{userItem.real_name}}</view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <view class="empty" v-if="isEmpty">
|
|
|
- 暂无数据
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <!-- <u-list @scrolltolower="scrolltolower">
|
|
|
+ <view class="address-page">
|
|
|
+ <view class="search-form">
|
|
|
+ <u-search
|
|
|
+ placeholder="请输入隶属组织名称/姓名"
|
|
|
+ v-model="searchKey"
|
|
|
+ :showAction="false"
|
|
|
+ @input="search"
|
|
|
+ ></u-search>
|
|
|
+ </view>
|
|
|
+ <u-loading-page
|
|
|
+ loading-text="加载中..."
|
|
|
+ :loading="loading"
|
|
|
+ font-size="16"
|
|
|
+ ></u-loading-page>
|
|
|
+ <view class="address__body">
|
|
|
+ <view class="address__list">
|
|
|
+ <view
|
|
|
+ class="address__group"
|
|
|
+ v-for="(item, key) in transformUserGroupList"
|
|
|
+ :key="key"
|
|
|
+ >
|
|
|
+ <view class="address__group__header">
|
|
|
+ <view class="address__group__title">
|
|
|
+ {{ orgDataSource[key] && orgDataSource[key].org_name }}
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="address__group__list">
|
|
|
+ <view
|
|
|
+ class="address__item"
|
|
|
+ v-for="userItem in item"
|
|
|
+ :key="key + userItem.user_id"
|
|
|
+ @click="goToIM(userItem)"
|
|
|
+ >
|
|
|
+ <view class="address__item__label">{{ userItem.real_name }}</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="empty" v-if="isEmpty"> 暂无数据 </view>
|
|
|
+ </view>
|
|
|
+ <!-- <u-list @scrolltolower="scrolltolower">
|
|
|
<u-list-item v-for="(item, index) in userList" :key="index">
|
|
|
<u-cell :title="`${index+1}:user_id:${item.user_id}-姓名:${item.real_name}`" @click="goToIM(item)">
|
|
|
|
|
|
</u-cell>
|
|
|
</u-list-item>
|
|
|
</u-list> -->
|
|
|
- </view>
|
|
|
- </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import {
|
|
|
- zipObject,
|
|
|
- map,
|
|
|
- concat,
|
|
|
- reduce,
|
|
|
- groupBy,
|
|
|
- uniqBy,
|
|
|
- flatMap,
|
|
|
- debounce
|
|
|
- } from 'lodash-es'
|
|
|
-
|
|
|
- let App = getApp();
|
|
|
- // var API = App.globalData.socketTask;
|
|
|
- var API = App.globalData;
|
|
|
-
|
|
|
- export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
- current: 0,
|
|
|
- loading: false,
|
|
|
- page: 1,
|
|
|
- total: 0,
|
|
|
- pageSize: 100000,
|
|
|
- userList: [],
|
|
|
- currentUserList: [],
|
|
|
- searchKey: ''
|
|
|
- }
|
|
|
- },
|
|
|
- onShow() {
|
|
|
- this.page = 1;
|
|
|
- this.userList = this.currentUserList = [];
|
|
|
- this.indexList = [];
|
|
|
- this.getAddressBookList();
|
|
|
- },
|
|
|
- onReachBottom() {
|
|
|
- console.log('-------------- onReachBottom 121331')
|
|
|
- },
|
|
|
- onPullDownRefresh() {
|
|
|
- console.log('refresh');
|
|
|
- this.page = 1;
|
|
|
- this.userList = this.currentUserList = [];
|
|
|
- this.indexList = [];
|
|
|
- this.getAddressBookList()
|
|
|
- setTimeout(() => {
|
|
|
- uni.stopPullDownRefresh()
|
|
|
- }, 1000)
|
|
|
- },
|
|
|
- computed: {
|
|
|
- transformUserGroupList() {
|
|
|
- const result = groupBy(this.currentUserList, item => {
|
|
|
- return item.org_list[0] && item.org_list[0].org_id
|
|
|
- })
|
|
|
-
|
|
|
- console.log(result, 'transform user group list')
|
|
|
-
|
|
|
- return result
|
|
|
- },
|
|
|
- orgDataSource() {
|
|
|
- const result = uniqBy(flatMap(map(this.currentUserList, 'org_list')), 'org_id');
|
|
|
- console.log(result, 'orgDataSource');
|
|
|
- return zipObject(map(result, 'org_id'), result)
|
|
|
- },
|
|
|
- isEmpty() {
|
|
|
- return this.currentUserList.length < 1
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- getAddressBookList() {
|
|
|
- this.loading = true
|
|
|
- this.$myRequest({
|
|
|
- url: '/api/api_gateway?method=sysmenage.usermanager.user_list',
|
|
|
- data: {
|
|
|
- page: this.page,
|
|
|
- page_item: this.pageSize,
|
|
|
- is_mails: 1,
|
|
|
- // real_name: this.nameVal, // 用户名称
|
|
|
- // mobile: this.phoneVal, //电话
|
|
|
- // org_id: this.org_id, // 组织ID
|
|
|
- }
|
|
|
- }).then(res => {
|
|
|
- this.loading = false;
|
|
|
- this.total = res.total_item;
|
|
|
- this.userList = this.currentUserList = this.page === 1 ? res.page_list : concat(this.userList,
|
|
|
- res.page_list)
|
|
|
-
|
|
|
- console.log(this.orgDataSource, 'load user list org data list')
|
|
|
- })
|
|
|
- },
|
|
|
- scrolltolower() {
|
|
|
- console.log('scroll lower -----121313')
|
|
|
- if (this.page * this.pageSize >= this.total) {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- this.page++
|
|
|
- this.getAddressBookList()
|
|
|
- },
|
|
|
- goToIM(data) {
|
|
|
- var that = this
|
|
|
- console.log('已读-------------', data.user_id)
|
|
|
- var obj = {
|
|
|
- 'action': 'list', // 动作标识,必填
|
|
|
- 'recv_user_id': data.user_id, // 接收人用户id, 非必填
|
|
|
- 'data': {}
|
|
|
- }
|
|
|
-
|
|
|
- API.socketTask.send({
|
|
|
- data: JSON.stringify(obj),
|
|
|
- async success(res) {
|
|
|
- console.log("消息发送成功");
|
|
|
- },
|
|
|
- });
|
|
|
-
|
|
|
- uni.navigateTo({
|
|
|
- url: '/pages/response/details?data=' + data.real_name + '&to=' + data.user_id
|
|
|
- })
|
|
|
- },
|
|
|
- search: debounce(function() {
|
|
|
- console.log('search ----------------------- search result', this.searchKey)
|
|
|
-
|
|
|
- this.currentUserList = this.userList.filter(item => {
|
|
|
- if (item.real_name.includes(this.searchKey)) {
|
|
|
- return true
|
|
|
- } else if (item.org_list) {
|
|
|
- return item.org_list.findIndex(orgItem => orgItem.org_name.includes(this
|
|
|
- .searchKey)) > -1
|
|
|
- } else {
|
|
|
- return false
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- }, 500)
|
|
|
- }
|
|
|
- }
|
|
|
+import {
|
|
|
+ zipObject,
|
|
|
+ map,
|
|
|
+ concat,
|
|
|
+ reduce,
|
|
|
+ groupBy,
|
|
|
+ uniqBy,
|
|
|
+ flatMap,
|
|
|
+ debounce,
|
|
|
+ assign,
|
|
|
+ omit,
|
|
|
+} from 'lodash-es'
|
|
|
+
|
|
|
+let App = getApp()
|
|
|
+// var API = App.globalData.socketTask;
|
|
|
+var API = App.globalData
|
|
|
+
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ current: 0,
|
|
|
+ loading: false,
|
|
|
+ page: 1,
|
|
|
+ total: 0,
|
|
|
+ pageSize: 100000,
|
|
|
+ userList: [],
|
|
|
+ currentUserList: [],
|
|
|
+ searchKey: '',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onShow() {
|
|
|
+ this.searchKey = ''
|
|
|
+ this.page = 1
|
|
|
+ this.userList = this.currentUserList = []
|
|
|
+ this.indexList = []
|
|
|
+ this.getAddressBookList()
|
|
|
+ },
|
|
|
+ onReachBottom() {
|
|
|
+ console.log('-------------- onReachBottom 121331')
|
|
|
+ },
|
|
|
+ onPullDownRefresh() {
|
|
|
+ console.log('refresh')
|
|
|
+ this.page = 1
|
|
|
+ this.userList = this.currentUserList = []
|
|
|
+ this.indexList = []
|
|
|
+ this.getAddressBookList()
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.stopPullDownRefresh()
|
|
|
+ }, 1000)
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ transformUserGroupList() {
|
|
|
+ const concatUserList = reduce(
|
|
|
+ this.currentUserList,
|
|
|
+ (pre, curr) => {
|
|
|
+ return concat(
|
|
|
+ pre,
|
|
|
+ map(curr.org_list || [], (item) =>
|
|
|
+ omit(
|
|
|
+ assign(
|
|
|
+ {
|
|
|
+ org_id: item.org_id,
|
|
|
+ org_name: item.org_name,
|
|
|
+ },
|
|
|
+ curr
|
|
|
+ ),
|
|
|
+ ['org_list']
|
|
|
+ )
|
|
|
+ )
|
|
|
+ )
|
|
|
+ },
|
|
|
+ []
|
|
|
+ )
|
|
|
+
|
|
|
+ const result = groupBy(concatUserList, (item) => {
|
|
|
+ return item.org_id
|
|
|
+ })
|
|
|
+
|
|
|
+ console.log(result, 'transform user group list')
|
|
|
+
|
|
|
+ return result
|
|
|
+ },
|
|
|
+ orgDataSource() {
|
|
|
+ const result = uniqBy(
|
|
|
+ flatMap(map(this.currentUserList, 'org_list')),
|
|
|
+ 'org_id'
|
|
|
+ )
|
|
|
+ console.log(result, 'orgDataSource')
|
|
|
+ return zipObject(map(result, 'org_id'), result)
|
|
|
+ },
|
|
|
+ isEmpty() {
|
|
|
+ return this.currentUserList.length < 1
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getAddressBookList() {
|
|
|
+ this.loading = true
|
|
|
+ this.$myRequest({
|
|
|
+ url: '/api/api_gateway?method=sysmenage.usermanager.user_list',
|
|
|
+ data: {
|
|
|
+ page: this.page,
|
|
|
+ page_item: this.pageSize,
|
|
|
+ is_mails: 1,
|
|
|
+ // real_name: this.nameVal, // 用户名称
|
|
|
+ // mobile: this.phoneVal, //电话
|
|
|
+ // org_id: this.org_id, // 组织ID
|
|
|
+ },
|
|
|
+ }).then((res) => {
|
|
|
+ this.loading = false
|
|
|
+ this.total = res.total_item
|
|
|
+ this.userList = this.currentUserList =
|
|
|
+ this.page === 1 ? res.page_list : concat(this.userList, res.page_list)
|
|
|
+
|
|
|
+ console.log(this.orgDataSource, 'load user list org data list')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ scrolltolower() {
|
|
|
+ console.log('scroll lower -----121313')
|
|
|
+ if (this.page * this.pageSize >= this.total) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.page++
|
|
|
+ this.getAddressBookList()
|
|
|
+ },
|
|
|
+ goToIM(data) {
|
|
|
+ var that = this
|
|
|
+ console.log('已读-------------', data.user_id)
|
|
|
+ var obj = {
|
|
|
+ action: 'list', // 动作标识,必填
|
|
|
+ recv_user_id: data.user_id, // 接收人用户id, 非必填
|
|
|
+ data: {},
|
|
|
+ }
|
|
|
+
|
|
|
+ API.socketTask.send({
|
|
|
+ data: JSON.stringify(obj),
|
|
|
+ async success(res) {
|
|
|
+ console.log('消息发送成功')
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
+ uni.navigateTo({
|
|
|
+ url:
|
|
|
+ '/pages/response/details?data=' +
|
|
|
+ data.real_name +
|
|
|
+ '&to=' +
|
|
|
+ data.user_id,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ search: debounce(function () {
|
|
|
+ console.log(
|
|
|
+ 'search ----------------------- search result',
|
|
|
+ this.searchKey
|
|
|
+ )
|
|
|
+
|
|
|
+ this.currentUserList = this.userList.filter((item) => {
|
|
|
+ if (item.real_name.includes(this.searchKey)) {
|
|
|
+ return true
|
|
|
+ } else if (item.org_list) {
|
|
|
+ return (
|
|
|
+ item.org_list.findIndex((orgItem) =>
|
|
|
+ orgItem.org_name.includes(this.searchKey)
|
|
|
+ ) > -1
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }, 500),
|
|
|
+ },
|
|
|
+}
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
- .search-form {
|
|
|
- position: fixed;
|
|
|
- left: 0;
|
|
|
- right: 0;
|
|
|
- top: 0;
|
|
|
- background-color: #FFFFFF;
|
|
|
- padding: 32rpx 24rpx;
|
|
|
- z-index: 10;
|
|
|
- }
|
|
|
-
|
|
|
- .list-cell {
|
|
|
- display: flex;
|
|
|
- box-sizing: border-box;
|
|
|
- width: 100%;
|
|
|
- padding: 10px 24rpx;
|
|
|
- overflow: hidden;
|
|
|
- color: #323233;
|
|
|
- font-size: 14px;
|
|
|
- line-height: 24px;
|
|
|
- background-color: #fff;
|
|
|
- }
|
|
|
-
|
|
|
- .address-page {
|
|
|
- background-color: #F7F8FB;
|
|
|
- padding-top: 130rpx;
|
|
|
-
|
|
|
- .address {
|
|
|
- &__body {}
|
|
|
-
|
|
|
- &__list {
|
|
|
- width: 100%;
|
|
|
- }
|
|
|
-
|
|
|
- &__group {
|
|
|
- &__header {
|
|
|
- padding: 24rpx;
|
|
|
- color: #1B76FF;
|
|
|
- font-size: 24rpx;
|
|
|
- }
|
|
|
-
|
|
|
- &__list {
|
|
|
- background-color: #fff;
|
|
|
- padding: 0 56rpx 0 32rpx;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- &__item {
|
|
|
- @include hairline-bottom;
|
|
|
-
|
|
|
- &__label {
|
|
|
- color: #333333;
|
|
|
- line-height: 1;
|
|
|
- font-size: 32rpx;
|
|
|
- padding: 30rpx 0;
|
|
|
- }
|
|
|
-
|
|
|
- &:last-child {
|
|
|
- @include hairline-bottom(transparent);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- .empty {
|
|
|
- width: 100%;
|
|
|
- text-align: center;
|
|
|
- font-size: 28rpx;
|
|
|
- height: 100rpx;
|
|
|
- line-height: 100rpx;
|
|
|
- color: #999999;
|
|
|
- }
|
|
|
+.search-form {
|
|
|
+ position: fixed;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ top: 0;
|
|
|
+ background-color: #ffffff;
|
|
|
+ padding: 32rpx 24rpx;
|
|
|
+ z-index: 10;
|
|
|
+}
|
|
|
+
|
|
|
+.list-cell {
|
|
|
+ display: flex;
|
|
|
+ box-sizing: border-box;
|
|
|
+ width: 100%;
|
|
|
+ padding: 10px 24rpx;
|
|
|
+ overflow: hidden;
|
|
|
+ color: #323233;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 24px;
|
|
|
+ background-color: #fff;
|
|
|
+}
|
|
|
+
|
|
|
+.address-page {
|
|
|
+ background-color: #f7f8fb;
|
|
|
+ padding-top: 130rpx;
|
|
|
+
|
|
|
+ .address {
|
|
|
+ &__body {
|
|
|
+ }
|
|
|
+
|
|
|
+ &__list {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__group {
|
|
|
+ &__header {
|
|
|
+ padding: 24rpx;
|
|
|
+ color: #1b76ff;
|
|
|
+ font-size: 24rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__list {
|
|
|
+ background-color: #fff;
|
|
|
+ padding: 0 56rpx 0 32rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &__item {
|
|
|
+ @include hairline-bottom;
|
|
|
+
|
|
|
+ &__label {
|
|
|
+ color: #333333;
|
|
|
+ line-height: 1;
|
|
|
+ font-size: 32rpx;
|
|
|
+ padding: 30rpx 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ &:last-child {
|
|
|
+ @include hairline-bottom(transparent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.empty {
|
|
|
+ width: 100%;
|
|
|
+ text-align: center;
|
|
|
+ font-size: 28rpx;
|
|
|
+ height: 100rpx;
|
|
|
+ line-height: 100rpx;
|
|
|
+ color: #999999;
|
|
|
+}
|
|
|
</style>
|
|
|
<style>
|
|
|
- page {
|
|
|
- background-color: #F7F8FB;
|
|
|
- }
|
|
|
+page {
|
|
|
+ background-color: #f7f8fb;
|
|
|
+}
|
|
|
</style>
|