This commit is contained in:
jiangyinzhi
2025-01-16 16:21:23 +08:00
parent 7f7ff91a5e
commit 561624a90c
17 changed files with 54 additions and 368 deletions
-237
View File
@@ -1,237 +0,0 @@
<template>
<div class="list">
<!-- 搜索框 -->
<!-- <div class="search">
<img src="@/assets/search.png" alt="" />
<input
type="text"
placeholder="请输入搜索文字"
@keydown.enter="searchEveryItem"
v-model="searchValue"
/>
</div> -->
<div class="container">
<van-radio-group v-model="radio">
<van-cell
v-for="(item, index) in client"
:title="item.consName +' '+ item.consNo"
:key="index"
clickable
@click="clickRadio(item, index)"
:style="item.checked ? 'background: #e5f6f3; ' : ''"
>
<!-- <van-radio :name="index" /> -->
</van-cell>
</van-radio-group>
</div>
<div class="btn">
<van-button size="large" class="faqi" @click="sureEle">
确认
</van-button>
</div>
</div>
</template>
<script>
// import Header from "@/components/headerNew";
import { getUseele } from '@/api/customer'
import { Notify } from 'vant'
export default {
name: '',
components: {
// Header,
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.title = to.meta.title
})
},
data() {
return {
// 标题
title: '客户选择',
// 单选框
radio: '',
searchValue:'',
client: [],
loading: false, //加载
finished: false, //完成
pageNum: 1, //当前页数
pageSize: 10, //每页多少条
allPage: 0, //总共多少条
numArr: [],
currentItem: {}
}
},
mounted() {
// this.getData();
},
created() {
// this.getUseele()
this.getUseele()
},
methods: {
//反显数据
editData(data) {
const arr = sessionStorage.getItem('customer')
if(arr) {
this.numArr = JSON.parse(arr).list
data.forEach((ele)=> {
this.numArr.forEach((v)=>{
if(ele.consId == v.consId) {
ele.checked = true
}
})
})
}
},
//获取列表数据
async getUseele() {
const customer = sessionStorage.getItem('customer')
const data = {
pageNum: this.pageNum,
pagesize: this.pageSize,
}
if(customer) {
data.consName = JSON.parse(customer).name
} else {
data.consName = ''
}
const res = await getUseele(data)
if(res.code == 0) {
res.data.records.forEach((v) => {
v.checked = false
})
this.client = res.data.records
this.editData(res.data.records)
} else {
Notify({ type: 'danger', message: res.msg })
}
},
// 滑动加载
// onLoad() {
// // 异步更新数据
// setTimeout(async () => {
// this.pageNum++
// const data = {
// pageNum: this.pageNum,
// pagesize: this.pageSize,
// }
// // 加载状态结束
// this.loading = false
// const res = await getUseele(data)
// if(res.code == 0) {
// res.data.records.forEach((v) => {
// v.checked = false
// })
// // this.client = res.data.records
// this.client.push(...res.data.records)
// this.editData(res.data.records)
// // 数据全部加载完成
// if (this.client.length == res.data.total) {
// this.finished = true
// return
// }
// } else {
// this.finished = true
// }
// }, 1000)
// },
// 选择客户数据处理
clickRadio(item, index) {
item.checked = !item.checked
if(item.checked == true) {
this.numArr.push(item)
} else {
this.numArr.splice(index, 1)
}
console.log(this.numArr);
},
// 点击确认
sureEle() {
if (this.numArr.length == 0 ) {
Notify({ type: 'danger', message: '请至少选择一条' })
return
}
sessionStorage.setItem('numArr', JSON.stringify(this.numArr))
this.$router.go(-1)
}
},
}
</script>
<style lang="less" scoped>
.list {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.container {
height: calc(100vh - 60px);
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;
}
.btn {
padding: 0 20px;
}
.faqi {
background-color: #63cbb6;
color: #fff;
border-radius: 8px;
margin-top: -20px;
}
/deep/ .van-radio-group{
height: 100%;
background: #fff;
}
.search {
width: 100%;
height: 60px;
display: flex;
// border: 1px solid #f2f2f2;
// opacity: 0.5;
border-radius: 6px;
padding: 5px 10px;
box-sizing: border-box;
align-items: center;
background: #fff;
margin-bottom: 10px;
img {
width: 15px;
height: 15px;
margin-right: 10px;
}
}
</style>