Commit 405a38b4 by 前端

Merge branch 'v3.20.0' into 'master'

V3.20.0

See merge request !79
2 parents ac862076 c9b4c36b
...@@ -52,5 +52,42 @@ export default { ...@@ -52,5 +52,42 @@ export default {
url, url,
data data
}) })
} },
/** 获取业主类型列表 */
getOwnerTypeListApi (data) {
data.method = 'entmicro.api.common.dictdata.list'
return window.$HTTP({
url,
data
})
},
/** 查询业主住户和楼栋信息 */
getRoomListApi (data) {
data.method = 'entmicro.api.property.room.page'
return window.$HTTP({
url,
data
})
},
/** 获取业主信息 */
getOwnerInfoApi (data) {
data.method = 'entmicro.api.customer.property.message.get'
return window.$HTTP({
url,
data
})
},
/** 修改业主信息 */
updateOwnerInfoApi (data) {
data.method = 'entmicro.api.customer.property.message.update'
return window.$HTTP({
url,
data
})
},
} }
<template>
<van-popup
v-model="showPopup"
round
position="bottom"
:close-on-click-overlay="false"
:style="{ height: '60%' }"
>
<div class="head-wrap">
<span @click="lastStep">{{curLevel==1 ? '取消' : '上一步'}}</span>
<span class="title">请选择{{curLevel==1 ? '小区': curLevel==2 ? '楼栋': '房号'}}</span>
<span class="confirm" :style="{opacity: isCompleted ? '1' : '0.5'}" @click="confirmFn" >确定</span>
</div>
<search placeholder="请输入关键字" :keyword="keyWord" @search="searchkeyWord"></search>
<div class="list-wrap" ref="list" @scroll.passive ="scroll">
<div class="item" v-for="(item,index) in searchObj[curLevel].areaList" @click="selectItem(item)" ref="item" :key="item.id">
<span>{{ item.name }}</span>
<van-icon v-if="selectInfo[curLevel].id==item.id" name="success icon" />
</div>
<div class="item"></div>
</div>
</van-popup>
</template>
<script>
import { detailApi } from '@/api'
import {throttle} from '@/utils/index'
export default {
name: 'addressPopup',
props: {
show: {
type: Boolean,
default: false
},
info: {
type: Object,
default: ()=>{}
}
},
data() {
return {
showPopup: false,
keyWord: '',
searchObj: {
1: {
pageSize : 10,
pageNum : 1,
loaded: false,
loadFinished: false,
areaList: []
},
2: {
pageSize : 10,
pageNum : 1,
loaded: false,
loadFinished: false,
areaList: []
},
3: {
pageSize : 10,
pageNum : 1,
loaded: false,
loadFinished: false,
areaList: []
}
},
curLevel: 1,
selectInfo: {
1: {
id: '',
name: ''
},
2: {
id: '',
name: ''
},
3: {
id: '',
name: ''
}
},
areaList: []
}
},
created() {
const {building, buildingId, community, communityId, room, roomId, level} = this.info
this.curLevel = level || 1
this.selectInfo = {
1: {
id: communityId,
name: community
},
2: {
id: buildingId,
name: building
},
3: {
id: roomId,
name: room
}
},
this.showPopup = this.show
this.getRoomList()
},
computed: {
isCompleted(){
return !!(this.selectInfo[1].id && this.selectInfo[2].id && this.selectInfo[3].id)
}
},
methods: {
searchkeyWord(e){
this.keyWord = e
this.searchObj[this.curLevel].pageNum = 1
this.searchObj[this.curLevel].loadFinished = false
this.getRoomList()
},
lastStep() {
if(this.curLevel==2 || this.curLevel==3){
this.curLevel = this.curLevel - 1
if(!this.searchObj?.[this.curLevel]?.loaded){
this.getRoomList()
}
}else{
this.$emit('cancelFn')
}
},
selectItem(item){
const { id, name } = item
if(id!= this.selectInfo[this.curLevel]?.id && this.curLevel!=3) {
if(this.curLevel==1){
this.selectInfo['2'] = {
id: '',
name: ''
}
this.searchObj['2'] = {
pageSize : 10,
pageNum : 1,
loaded: false,
loadFinished: false,
areaList: []
}
}
this.selectInfo['3'] = {
id: '',
name: ''
}
this.searchObj['3'] = {
pageSize : 10,
pageNum : 1,
loaded: false,
loadFinished: false,
areaList: []
}
}
this.selectInfo[this.curLevel].id = id
this.selectInfo[this.curLevel].name = name
this.keyWord = ''
if(this.curLevel==3) return;
this.curLevel = this.curLevel + 1
this.getRoomList()
},
getRoomList(isConcat) {
const { pageSize , pageNum } = this.searchObj[this.curLevel]
const params = {
name: this.keyWord,
level: this.curLevel,
firstId: this.selectInfo?.[this.curLevel]?.id,
pageSize,
pageNum,
pid: this.curLevel==1 ? '' : this.selectInfo?.[this.curLevel-1]?.id,
}
if(this.searchObj[this.curLevel].loadFinished) return;
detailApi.getRoomListApi(params).then(res => {
if(res?.list) {
const list = res?.list || []
this.searchObj[this.curLevel].areaList = isConcat ? [...this.searchObj[this.curLevel].areaList, ...list] : list
const len = this.searchObj?.[this.curLevel]?.areaList?.length || 0
this.searchObj[this.curLevel].loadFinished = res.total<=len
this.searchObj[this.curLevel].loaded = true
}
})
},
scroll: throttle(function (e){
let scrollBottom = e.target.scrollHeight - e.target.scrollTop - e.target.clientHeight;
if(scrollBottom < 10){
console.log("滚动条到底了")
this.searchObj[this.curLevel].pageNum++
this.getRoomList(1)
}
},500),
confirmFn(){
if(!this.isCompleted) return;
this.$emit('confirm', this.selectInfo)
}
}
}
</script>
<style scoped lang="scss">
.van-popup{
overflow: hidden;;
}
.head-wrap{
height: 56px;
padding: 0 32px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #EFEFEF;
margin-bottom: 8px;
overflow: hidden;
span{
line-height: 22px;
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 16px;
color: #666666;
letter-spacing: 0;
}
.title{
color: #333333;
}
.confirm{
font-weight: 500;
color: #3975C6;
}
}
.list-wrap{
padding: 8px 0 30px;
max-height: 300px;
overflow: auto;
.item{
padding: 0 20px;
line-height: 20px;
font-weight: 400;
font-family: PingFangSC-Regular;
font-size: 14px;
color: #333333;
margin-bottom: 20px;
display: flex;
justify-content: space-between;
.icon{
color: #3A77C4;
margin-right: 8px;
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -25,7 +25,42 @@ ...@@ -25,7 +25,42 @@
</template> </template>
</template> </template>
</div> </div>
<template v-if="showAddr">
<div class="box">
<div v-for="(item,index) in addressList" :key="index" class="item flex" @click="changeAddress(index+1)">
<div class="label">{{item.name}}</div>
<div class="value">
{{ownerInfoObj[item.key]}}
<van-icon name="arrow" class="arrow"/>
</div>
</div>
</div>
<div class="box">
<div class="item flex" @click="changeOwnerType">
<div class="label">住户类型</div>
<div class="value">
{{ownerInfoObj.ownerTypeName}}
<van-icon name="arrow" class="arrow"/>
</div>
</div>
</div>
</template>
</template>
<template v-if="showDialog">
<addressPopup :show="showDialog" :info="ownerInfoObj" @cancelFn="cancelFn" @confirm="confirmAddress"></addressPopup>
</template> </template>
<van-popup v-model="showType" round position="bottom" :style="{ height: 'auto' }">
<div class="head-wrap">
<span @click="cancelTypeFn">取消</span>
<span class="title">住户类型</span>
<span :style="{opacity: homeownerType ? '1' : '0.5'}" @click="confirmType" class="confirm">确定</span>
</div>
<div class="owner-type-wrap">
<span :class="['type-item',{'active': homeownerType==item.dictValue}]" v-for="item in ownerTypeList" @click="selectOwnerType(item)" :key="item.id">
{{ item.dictLabel }}
</span>
</div>
</van-popup>
<van-dialog <van-dialog
v-model="show" v-model="show"
title="请填写客户手机号" title="请填写客户手机号"
...@@ -48,10 +83,30 @@ ...@@ -48,10 +83,30 @@
</div> </div>
</template> </template>
<script> <script>
import { entmicroApi } from '@/api' const addressList = [
{
name: '所在小区',
key: 'community'
},
{
name: '所在楼栋',
key: 'building'
},
{
name: '所在房号',
key: 'room'
},
]
import { Toast } from 'vant'
import { detailApi, entmicroApi } from '@/api'
import addressPopup from '@/components/addressPopup'
export default { export default {
data () { data () {
return { return {
addressList,
showDialog: false,
showType: false,
ownerTypeList: [],
value: '', value: '',
userInfo: {}, userInfo: {},
userObj: [ userObj: [
...@@ -97,15 +152,103 @@ export default { ...@@ -97,15 +152,103 @@ export default {
} }
} }
], ],
show: false show: false,
homeownerType: '',
showAddr: false,
ownerInfoObj: {}
} }
}, },
components:{
addressPopup
},
activated () { activated () {
const { entmicroId } = this.getLocalStorage('dj_scrm_userInfo') || {}
this.showAddr = window.$fetchConfig.merchantWhiteList?.includes(entmicroId)
let { userInfo, show } = this.getParams() let { userInfo, show } = this.getParams()
this.userInfo = userInfo this.userInfo = userInfo
this.show = show this.show = show
if(this.showAddr) {
this.getOwnerTypeList() //显示才调接口
}
}, },
methods: { methods: {
getOwnerInfo(){
let { userId } = this.getParams()
const params = {
userId,
oneId: this.userInfo?.info?.oneId
}
detailApi.getOwnerInfoApi(params).then(res => {
if(res) {
const _target = this.ownerTypeList.find(item => item.dictValue == res.homeownerType)
res.ownerTypeName = _target ? _target.dictLabel : ''
this.ownerInfoObj = res
}
})
},
changeAddress(level) {
this.showDialog = true
this.ownerInfoObj.level = level
},
confirmAddress(e){
const params = {
oneId: this.userInfo?.info?.oneId,
community: e[1].name,
communityId: e[1].id,
building: e[2].name,
buildingId: e[2].id,
room: e[3].name,
roomId: e[3].id,
}
this.updateOwnerInfo(params)
},
cancelFn() {
this.showDialog = false
},
cancelTypeFn() {
this.showType = false
this.homeownerType = ''
},
updateOwnerInfo(params) {
detailApi.updateOwnerInfoApi(params).then(res => {
console.log(res,'编辑成功')
if(res) {
Toast('编辑成功')
this.cancelTypeFn()
this.cancelFn()
this.getOwnerInfo()
}
})
},
confirmType(){
if(!this.homeownerType) return;
if(this.ownerInfoObj.homeownerType == this.homeownerType) {
this.cancelTypeFn()
return; // 没编辑直接关闭
}
const params = {
oneId: this.userInfo?.info?.oneId,
homeownerType: this.homeownerType
}
this.updateOwnerInfo(params)
},
changeOwnerType(){
this.homeownerType = this.ownerInfoObj.homeownerType
this.showType = true
},
selectOwnerType(item) {
this.homeownerType = item.dictValue
},
getOwnerTypeList(){
detailApi.getOwnerTypeListApi({dictType : 'homeowner_type'}).then(res => {
console.log(res)
if(res?.length){
this.ownerTypeList = res
this.getOwnerInfo()
}
})
},
itemClick (e) { itemClick (e) {
if (this.userInfo.info.customerPhone) return if (this.userInfo.info.customerPhone) return
this.show = e this.show = e
...@@ -147,6 +290,7 @@ export default { ...@@ -147,6 +290,7 @@ export default {
background: #ffffff; background: #ffffff;
box-shadow: 0 4px 8px 0 #e0e0e080; box-shadow: 0 4px 8px 0 #e0e0e080;
border-radius: 4px; border-radius: 4px;
margin-bottom: 8px;
.item { .item {
padding: 5px 16px; padding: 5px 16px;
min-height: 59px; min-height: 59px;
...@@ -188,4 +332,51 @@ export default { ...@@ -188,4 +332,51 @@ export default {
} }
} }
} }
.head-wrap{
height: 56px;
padding: 0 32px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #EFEFEF;
margin-bottom: 8px;
span{
line-height: 22px;
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 16px;
color: #666666;
letter-spacing: 0;
}
.title{
color: #333333;
}
.confirm{
font-weight: 500;
color: #3975C6;
}
}
.owner-type-wrap{
padding: 16px 20px 30px;
height: 250px;
overflow: auto;
.type-item{
height: 28px;
background:#aaaaaa26;
border-radius: 14px;
padding: 0 10px;
font-family: PingFangSC-Regular;
line-height: 28px;
display: inline-block;
margin-right: 8px;
font-weight: 400;
font-size: 14px;
color: #858585;
text-align: center;
}
.active{
background: #3975c626;
color: #3975C6;
}
}
</style> </style>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!