Files
ys-app/src/pages/business/CRM/chooseCus.vue

211 lines
4.6 KiB
Vue
Raw Normal View History

2025-08-25 16:41:33 +08:00
<template>
2025-08-29 14:43:12 +08:00
<view class="con-body">
<view class="con-bg">
<!-- 头部 -->
<customHeader ref="customHeaderRef" :title="'客户名称列表'" :leftFlag="true" :rightFlag="false">
<template #right>
<view class="head-right" @click="handleAdd">
<uni-icons type="plus" size="24" color="#B7D2FF"></uni-icons>
新增
</view>
</template>
</customHeader>
<!-- 高度来避免头部遮挡 -->
<view class="top-height" :style="{ paddingTop: navBarPaddingTop + 'px' }"></view>
<!-- 正文内容 -->
<view class="all-body">
2025-08-29 17:31:05 +08:00
<!-- 搜索框 -->
2025-08-29 14:43:12 +08:00
<view class="search">
<uni-search-bar class="custom-search" radius="28" placeholder="请输入客户名称" clearButton="auto"
cancelButton="none" bgColor="#6FA2F8" textColor="#ffffff"
v-model="searchValue" @clear="searchValue=''"
/>
2025-08-25 16:41:33 +08:00
</view>
2025-08-29 14:43:12 +08:00
2025-08-29 17:31:05 +08:00
<!-- 列表区域 -->
<view class="scroll-h" :class="{'loading-scroll':cssFlag}">
2025-08-29 14:43:12 +08:00
<radio-group class="block" @change="radioChange">
<view class="white-bg" v-for="(item, index) in list" :key="index" @click="handleDetail(item)">
<radio class='radio'
:class="index === selectIndex ? 'checked' : ''"
:checked="index === selectIndex"
:value="index+''">
</radio>
<view class="report-list">
<view class="title">{{ item.cusName }}</view>
2025-08-29 17:31:05 +08:00
<view class="r-name">{{ item.shortName }}</view>
2025-08-29 14:43:12 +08:00
</view>
</view>
</radio-group>
2025-08-29 17:31:05 +08:00
</view>
2025-08-29 14:43:12 +08:00
</view>
2025-08-25 16:41:33 +08:00
</view>
2025-08-29 14:43:12 +08:00
</view>
2025-08-25 16:41:33 +08:00
</template>
<script setup>
2025-08-29 14:43:12 +08:00
import customHeader from '@/components/customHeader.vue'
2025-08-29 17:31:05 +08:00
import { getYsCustomerList } from '../../../api/crm/api_ys.js'
import { onMounted, reactive, ref, watch } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useMessage } from '../../../utils/message.js'
const message = useMessage();
2025-08-29 14:43:12 +08:00
// 获取导航栏高度用于内容区域padding
const navBarPaddingTop = ref(0);
2025-08-29 17:31:05 +08:00
// 点击查询客户单位
const queryParams = ref({
cusName: '',
nickName:'',
pageNum: 1,
pageSize: 10
})
2025-08-25 16:41:33 +08:00
2025-08-29 17:31:05 +08:00
onLoad(options => {
queryParams.value.cusName = options.cusName
2025-08-25 16:41:33 +08:00
})
2025-08-29 17:31:05 +08:00
const dataList = ref([])
2025-08-25 16:41:33 +08:00
2025-08-29 17:31:05 +08:00
// 搜索内容
let searchContent = ref('')
2025-08-25 16:41:33 +08:00
2025-08-29 17:31:05 +08:00
// 选中项的索引号
const selectIndex = ref(null);
2025-08-25 16:41:33 +08:00
2025-08-29 14:43:12 +08:00
let timerId = null;
2025-08-29 17:31:05 +08:00
// 监视查询的内容的变化
let queryCusForm = reactive({})
watch(searchContent, (newValue, oldValue) => {
if(timerId) clearTimeout(timerId);
timerId = setTimeout(async ()=>{
queryCusForm.cusName = newValue;
const res = await getYsCustomerList(queryCusForm);
dataList.value = res.rows;
clearTimeout(timerId);
timerId = null;
}, 500);
2025-08-29 14:43:12 +08:00
});
2025-08-29 17:31:05 +08:00
function radioChange(event) {
const selectedIndex = event.detail.value
let test = dataList.value[selectedIndex]
// 发送全局事件
uni.$emit('onCustomerSelected', test)
let cusName = test.cusName;//客户名称
let cusId = test.cusId;//客户ID
uni.navigateBack()//返回上一页
2025-08-25 16:41:33 +08:00
}
2025-08-29 17:31:05 +08:00
onMounted(() => {
navBarPaddingTop.value = 80; // 简化处理实际应根据getNavBarPaddingTop()计算
})
2025-08-25 16:41:33 +08:00
2025-08-29 17:31:05 +08:00
</script>
<style lang="scss" scoped>
.con-body {
background: white;
height: 100vh;
2025-08-25 16:41:33 +08:00
}
2025-08-29 17:31:05 +08:00
.con-bg {
background: #f5f5f5;
height: 100%;
2025-08-25 16:41:33 +08:00
}
2025-08-29 17:31:05 +08:00
.top-height {
height: 80rpx;
2025-08-25 16:41:33 +08:00
}
2025-08-29 17:31:05 +08:00
.head-right {
display: flex;
align-items: center;
color: #B7D2FF;
font-size: 14px;
padding-right: 20rpx;
}
2025-08-25 16:41:33 +08:00
2025-08-29 14:43:12 +08:00
.all-body {
2025-08-29 17:31:05 +08:00
padding: 0 20rpx;
box-sizing: border-box;
}
.search {
display: flex;
align-items: center;
margin-bottom: 20rpx;
}
.custom-search {
flex: 1;
2025-08-25 16:41:33 +08:00
}
2025-08-29 14:43:12 +08:00
2025-08-29 17:31:05 +08:00
.btn-search {
2025-08-29 14:43:12 +08:00
border: none;
background: none;
line-height: normal;
color: #fff;
line-height: 56rpx !important;
padding: 10rpx 0 0;
text-align: left;
cursor: pointer;
2025-08-25 16:41:33 +08:00
}
2025-08-29 14:43:12 +08:00
.scroll-h {
2025-08-29 17:31:05 +08:00
height: calc(100vh - 250rpx);
overflow-y: auto;
2025-08-25 16:41:33 +08:00
}
2025-08-29 14:43:12 +08:00
.white-bg {
2025-08-29 17:31:05 +08:00
background-color: #fff;
border-radius: 12rpx;
padding: 24rpx;
margin-bottom: 20rpx;
2025-08-25 16:41:33 +08:00
display: flex;
align-items: center;
2025-08-29 17:31:05 +08:00
box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.05);
2025-08-25 16:41:33 +08:00
}
.radio {
2025-08-29 17:31:05 +08:00
margin-right: 20rpx;
}
.report-list {
flex: 1;
2025-08-29 14:43:12 +08:00
}
.title {
font-size: 32rpx;
2025-08-29 17:31:05 +08:00
color: #333;
font-weight: bold;
margin-bottom: 8rpx;
2025-08-25 16:41:33 +08:00
}
2025-08-29 17:31:05 +08:00
.r-name {
font-size: 26rpx;
color: #666;
2025-08-25 16:41:33 +08:00
}
2025-08-29 17:31:05 +08:00
.checked {
color: #007AFF;
}
/* 适配不同平台 */
/* #ifdef APP-PLUS */
.all-body {
top: 150rpx;
height: calc(100vh - 75px);
}
/* #endif */
/* #ifndef APP-PLUS */
.all-body {
top: 120rpx;
height: calc(100vh);
2025-08-25 16:41:33 +08:00
}
2025-08-29 17:31:05 +08:00
/* #endif */
2025-08-25 16:41:33 +08:00
</style>