183 lines
4.2 KiB
Vue
183 lines
4.2 KiB
Vue
<template>
|
||
<div class="list">
|
||
<!-- <Header :title="title" @onClickLeft="onClickLeft" /> -->
|
||
<van-search
|
||
placeholder="请输入客户名称/联系人/联系电话/地址"
|
||
v-model="value"
|
||
@search="search"
|
||
/>
|
||
<div class="container">
|
||
<van-radio-group v-model="radio">
|
||
<van-cell-group>
|
||
<van-list
|
||
v-model="loading"
|
||
:finished="finished"
|
||
finished-text="没有更多了"
|
||
@load="onLoad"
|
||
>
|
||
<van-cell
|
||
v-for="(item, index) in client"
|
||
:key="index"
|
||
clickable
|
||
@click="clickRadio(item, index)"
|
||
>
|
||
<p>{{item.customerName}}</p>
|
||
用电户号:{{ item.consNo }}
|
||
<!-- <van-radio :name="index" /> -->
|
||
</van-cell>
|
||
</van-list>
|
||
</van-cell-group>
|
||
</van-radio-group>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
// import Header from "@/components/headerNew";
|
||
import { getUserInfo } from "@/api/api.js";
|
||
export default {
|
||
name: "burstingList",
|
||
components: {
|
||
// Header,
|
||
},
|
||
beforeRouteEnter(to, from, next) {
|
||
next((vm) => {
|
||
vm.title = to.meta.title;
|
||
});
|
||
},
|
||
data() {
|
||
return {
|
||
// 搜索框
|
||
value: "",
|
||
// 标题
|
||
title: "客户选择",
|
||
// 单选框
|
||
radio: "",
|
||
client: [],
|
||
loading: false, //加载
|
||
finished: false, //完成
|
||
pageNum: 1, //当前页数
|
||
pageSize: 10, //每页多少条
|
||
allPage: 0, //总共多少条
|
||
pages: 1, // 页数
|
||
};
|
||
},
|
||
mounted() {
|
||
this.getData();
|
||
},
|
||
methods: {
|
||
// 滚动加载
|
||
onLoad() {
|
||
// 异步更新数据
|
||
setTimeout(async () => {
|
||
this.pageNum++;
|
||
// 数据全部加载完成
|
||
this.getData();
|
||
if (this.pageNum>this.pages) {
|
||
this.finished = true;
|
||
return;
|
||
}
|
||
}, 1000);
|
||
},
|
||
// 获取数据
|
||
async getData() {
|
||
this.loading = true;
|
||
try {
|
||
const res = await getUserInfo({
|
||
pageNum: this.pageNum,
|
||
pageSize: this.pageSize,
|
||
customerName: this.value,
|
||
});
|
||
if (res.code == 0) {
|
||
this.allPage = res.data.total;
|
||
this.pages = res.data.pages
|
||
this.client.push(...res.data.list);
|
||
if(!res.data.hasNextPage){
|
||
this.finished = true;
|
||
}else {
|
||
this.finished = false
|
||
}
|
||
// 加载状态结束
|
||
}
|
||
} finally {
|
||
this.loading = false;
|
||
}
|
||
},
|
||
// 选择客户数据处理
|
||
clickRadio(item, index) {
|
||
this.radio = index;
|
||
sessionStorage.setItem("customer", JSON.stringify(item))
|
||
this.$router.push('/Initiateappointment')
|
||
},
|
||
//搜索
|
||
search() {
|
||
let customerName = this.value;
|
||
this.pageNum = 1
|
||
let params = {
|
||
customerName: customerName,
|
||
pageNum: this.pageNum,
|
||
pageSize: this.pageSize,
|
||
};
|
||
getUserInfo(params)
|
||
.then((res) => {
|
||
this.allPage = res.data.total;
|
||
this.pages = res.data.pages
|
||
this.client = res.data.list;
|
||
if (this.pageNum>this.pages) {
|
||
this.finished = true;
|
||
}else {
|
||
this.finished = false
|
||
}
|
||
})
|
||
.catch(() => {
|
||
this.$toast("失败");
|
||
});
|
||
},
|
||
// 获取用户列表
|
||
// async getUserInfo() {
|
||
// const res = await getUserInfo({ pageNum: 1, pageSize: 10 })
|
||
// .then((res) => {
|
||
// this.client = res.data.list;
|
||
// this.allPage = res.data.total;
|
||
// })
|
||
// .catch((error) => {
|
||
// this.$toast("失败");
|
||
// });
|
||
// },
|
||
},
|
||
};
|
||
</script>
|
||
|
||
<style lang="less" scoped>
|
||
.container {
|
||
height: calc(100vh - 50px);
|
||
overflow-y: auto;
|
||
.van-cell {
|
||
padding: 20px;
|
||
font-size: 17px;
|
||
opacity: 0.9;
|
||
}
|
||
.item {
|
||
background: #fff;
|
||
padding: 30px;
|
||
box-sizing: border-box;
|
||
font-size: 18px;
|
||
color: #797b7b;
|
||
border-bottom: 1px solid #e9e9e9;
|
||
}
|
||
}
|
||
|
||
::v-deep .van-radio__icon {
|
||
-webkit-box-flex: 0;
|
||
-webkit-flex: none;
|
||
flex: none;
|
||
height: 1em;
|
||
font-size: 0.533333rem;
|
||
line-height: 1em;
|
||
cursor: pointer;
|
||
position: absolute;
|
||
right: 0;
|
||
top: 0px;
|
||
}
|
||
</style>
|