|
|
|
@ -1,7 +1,32 @@ |
|
|
|
|
<template> |
|
|
|
|
<view> |
|
|
|
|
<uni-search-bar class="uni-mt-10" radius="100" placeholder="请输入姓名" cancelButton="auto" @confirm="search" /> |
|
|
|
|
<uni-mall-list ref='nameList' :dataList="dataList" :defaultHeadList="defaultHeadList" @change="handleChange"></uni-mall-list> |
|
|
|
|
<uni-search-bar class="uni-mt-10" radius="100" placeholder="请输入姓名" cancelButton="auto" @confirm="search" @cancel="getAddressBookData" /> |
|
|
|
|
<uni-mall-list v-if="show" ref='nameList' :dataList="dataList" :defaultHeadList="defaultHeadList" @change="handleChange"></uni-mall-list> |
|
|
|
|
|
|
|
|
|
<view class="box-list" v-if="!show"> |
|
|
|
|
<template v-for="item in currentData"> |
|
|
|
|
<view |
|
|
|
|
class="box-list-item" |
|
|
|
|
|
|
|
|
|
@click="handleChanges(item.userId)" |
|
|
|
|
> |
|
|
|
|
<view class="box-list-item-department-pic" v-if="item.type === 'department'"><image src="../../static/department-icon.png"></image></view> |
|
|
|
|
<view class="box-list-item-user-pic" v-else> |
|
|
|
|
<image v-if="item.pic" :src="item.pic"></image> |
|
|
|
|
<text v-else>{{ getUserName(item.name) }}</text> |
|
|
|
|
</view> |
|
|
|
|
<view class="box-list-item-right"> |
|
|
|
|
<view class="box-list-item-text">{{ item.name }} {{ item.children && item.children.length > 0 ? `(${item.children.length})` : '' }}</view> |
|
|
|
|
<view class="box-list-item-phone" v-if="!item.children">电话:{{item.phone || '暂无'}}</view> |
|
|
|
|
<!-- <view class="box-list-item-user-tag" v-if="item.type === 'user' && item.tag && item.type.length > 0">--> |
|
|
|
|
<!-- <text v-for="(tag, tagIndex) in item.tag">{{ tag }}</text>--> |
|
|
|
|
<!-- </view>--> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</template> |
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</view> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
@ -19,11 +44,19 @@ |
|
|
|
|
defaultHeadList: { |
|
|
|
|
name: '组织架构' |
|
|
|
|
}, |
|
|
|
|
dataList: [] |
|
|
|
|
dataList: [], |
|
|
|
|
currentData:[ |
|
|
|
|
|
|
|
|
|
], |
|
|
|
|
show:true |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
onShow() { |
|
|
|
|
this.getAddressBookData(); |
|
|
|
|
if(this.show){ |
|
|
|
|
this.getAddressBookData(); |
|
|
|
|
}else{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
onLoad() {}, |
|
|
|
|
mounted() { |
|
|
|
@ -39,26 +72,48 @@ |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
handleChanges(item) { |
|
|
|
|
console.log(item) |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url: '/subPackIndex/addressBook/datails?userId=' + item |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
search(res) { |
|
|
|
|
// uni.showToast({ |
|
|
|
|
// title: '搜索:' + res.value, |
|
|
|
|
// icon: 'none' |
|
|
|
|
// }) |
|
|
|
|
let this_ = this |
|
|
|
|
this_.defaultHeadList ={} |
|
|
|
|
searchName(res.value).then(res =>{ |
|
|
|
|
this.$nextTick(()=>{ |
|
|
|
|
this_.dataList = res.data |
|
|
|
|
// this_.$refs.nameList.tabChange() |
|
|
|
|
this_.show = false |
|
|
|
|
this_.currentData = JSON.parse(JSON.stringify(res.data)) |
|
|
|
|
console.log(this_.currentData) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
getAddressBookData() { |
|
|
|
|
let this_ = this |
|
|
|
|
getAddressBookData().then(res => { |
|
|
|
|
this_.show = true |
|
|
|
|
this.dataList = res.data |
|
|
|
|
this_.$refs.nameList.tabChange(this_.defaultHeadList) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
handelClickItem(item) { |
|
|
|
|
console.log(item) |
|
|
|
|
if (item.type === 'department') { |
|
|
|
|
if (item.children && item.children.length > 0) { |
|
|
|
|
this.currentData = item.children; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.$emit('change', item); |
|
|
|
|
}, |
|
|
|
|
getUserName(name) { |
|
|
|
|
if (name.length === 0) { |
|
|
|
|
return ''; |
|
|
|
|
} else if (name.length <= 2) { |
|
|
|
|
return name; |
|
|
|
|
} else if (name.length >= 3) { |
|
|
|
|
return name.substring(name.length - 2); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
@ -68,4 +123,103 @@ |
|
|
|
|
::v-deep .uni-searchbar { |
|
|
|
|
background-color: #fff; |
|
|
|
|
} |
|
|
|
|
.box-list { |
|
|
|
|
.box-list-item { |
|
|
|
|
position: relative; |
|
|
|
|
height: 60px; |
|
|
|
|
display: flex; |
|
|
|
|
align-items: center; |
|
|
|
|
padding: 0 14px; |
|
|
|
|
box-sizing: border-box; |
|
|
|
|
background: #ffffff; |
|
|
|
|
margin-bottom: 1px; |
|
|
|
|
&:active { |
|
|
|
|
background: #f2f3f4; |
|
|
|
|
} |
|
|
|
|
&:last-child { |
|
|
|
|
margin-bottom: 0px; |
|
|
|
|
} |
|
|
|
|
.box-list-item-department-pic { |
|
|
|
|
width: 40px; |
|
|
|
|
height: 40px; |
|
|
|
|
background: rgba(55, 127, 255, 0.1); |
|
|
|
|
border-radius: 10px; |
|
|
|
|
display: flex; |
|
|
|
|
align-items: center; |
|
|
|
|
justify-content: center; |
|
|
|
|
margin-right: 14px; |
|
|
|
|
overflow: hidden; |
|
|
|
|
image { |
|
|
|
|
width: 20px; |
|
|
|
|
height: 20px; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.box-list-item-user-pic { |
|
|
|
|
width: 40px; |
|
|
|
|
height: 40px; |
|
|
|
|
background: #377fff; |
|
|
|
|
border-radius: 10px; |
|
|
|
|
display: flex; |
|
|
|
|
align-items: center; |
|
|
|
|
justify-content: center; |
|
|
|
|
margin-right: 14px; |
|
|
|
|
overflow: hidden; |
|
|
|
|
image { |
|
|
|
|
width: 40px; |
|
|
|
|
height: 40px; |
|
|
|
|
} |
|
|
|
|
text { |
|
|
|
|
color: #ffffff; |
|
|
|
|
font-size: 12px; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.box-list-item-right { |
|
|
|
|
display: flex; |
|
|
|
|
justify-content: space-between; |
|
|
|
|
flex-direction: column; |
|
|
|
|
font-size: 24rpx; |
|
|
|
|
} |
|
|
|
|
.box-list-item-text { |
|
|
|
|
color: #333333; |
|
|
|
|
font-size: 16px; |
|
|
|
|
} |
|
|
|
|
.box-list-item-user-tag { |
|
|
|
|
text { |
|
|
|
|
box-sizing: border-box; |
|
|
|
|
border-radius: 8px; |
|
|
|
|
padding: 4px 8px; |
|
|
|
|
font-size: 10px; |
|
|
|
|
margin-left: 5px; |
|
|
|
|
&:first-child { |
|
|
|
|
margin-left: 0px; |
|
|
|
|
} |
|
|
|
|
&:nth-child(1) { |
|
|
|
|
background: rgba(49, 210, 144, 0.05); |
|
|
|
|
border: 1px solid #31d290; |
|
|
|
|
color: #31d290; |
|
|
|
|
} |
|
|
|
|
&:nth-child(2) { |
|
|
|
|
background: rgba(55, 127, 255, 0.05); |
|
|
|
|
border: 1px solid #377fff; |
|
|
|
|
color: #377fff; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
&.box-list-item-department-icon { |
|
|
|
|
&::after { |
|
|
|
|
content: ''; |
|
|
|
|
position: absolute; |
|
|
|
|
width: 5px; |
|
|
|
|
height: 10px; |
|
|
|
|
top: 26px; |
|
|
|
|
right: 15px; |
|
|
|
|
background: url(../../static/more.png) no-repeat; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.box-list-item-department + .box-list-item-user { |
|
|
|
|
margin-top: 10px; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
</style> |
|
|
|
|