客户只读

This commit is contained in:
WindowBird 2025-11-10 10:56:20 +08:00
parent 9e9672abda
commit a7292132fd
2 changed files with 11 additions and 93 deletions

View File

@ -1,13 +1,4 @@
<template>
<!-- 客户选择器 - uv-picker -->
<uv-picker
ref="customerPickerRef"
:columns="customerColumns"
keyName="name"
@confirm="onCustomerConfirm"
@cancel="closeCustomerPicker"
></uv-picker>
<!-- 客户状态选择器 - uv-picker -->
<uv-picker
ref="statusPickerRef"
@ -40,11 +31,9 @@
import { ref, watch, nextTick } from 'vue';
const props = defineProps({
showCustomerPicker: Boolean,
showStatusPicker: Boolean,
showIntentLevelPicker: Boolean,
showFollowTypePicker: Boolean,
customerList: Array,
statusOptions: Array,
intentLevelOptions: Array,
followTypeOptions: Array,
@ -54,36 +43,16 @@ const props = defineProps({
const emit = defineEmits(['update:formData', 'close-picker']);
// ref
const customerPickerRef = ref(null);
const statusPickerRef = ref(null);
const intentLevelPickerRef = ref(null);
const followTypePickerRef = ref(null);
// 使 ref columns
const customerColumns = ref([[]]);
const statusColumns = ref([[]]);
const intentLevelColumns = ref([[]]);
const followTypeColumns = ref([[]]);
// prop
watch(() => props.showCustomerPicker, async (val) => {
if (val && customerPickerRef.value) {
//
if (!props.customerList || props.customerList.length === 0) {
console.warn('客户列表数据未加载');
return;
}
await nextTick();
//
if (props.formData?.customerId) {
const index = props.customerList.findIndex(c => c.id === props.formData.customerId);
if (index >= 0 && customerPickerRef.value.setIndexs) {
customerPickerRef.value.setIndexs([index], true);
}
}
customerPickerRef.value.open();
}
});
watch(() => props.showStatusPicker, async (val) => {
if (val && statusPickerRef.value) {
//
@ -140,15 +109,6 @@ watch(() => props.showFollowTypePicker, async (val) => {
});
// columns
watch(() => props.customerList, (newList) => {
if (newList && newList.length > 0) {
customerColumns.value = [newList];
console.log('客户列表 columns 已更新:', customerColumns.value, '数据长度:', newList.length);
} else {
customerColumns.value = [[]];
}
}, { immediate: true, deep: true });
watch(() => props.statusOptions, (newOptions) => {
if (newOptions && newOptions.length > 0) {
statusColumns.value = [newOptions];
@ -177,10 +137,6 @@ watch(() => props.followTypeOptions, (newOptions) => {
}, { immediate: true, deep: true });
//
const closeCustomerPicker = () => {
emit('close-picker', 'customer');
};
const closeStatusPicker = () => {
emit('close-picker', 'status');
};
@ -193,22 +149,6 @@ const closeFollowTypePicker = () => {
emit('close-picker', 'followType');
};
//
const onCustomerConfirm = (e) => {
const selectedItems = e.value;
if (selectedItems && selectedItems.length > 0) {
const selectedCustomer = selectedItems[0];
if (selectedCustomer && selectedCustomer.id) {
emit('update:formData', {
...props.formData,
customerId: selectedCustomer.id,
customerName: selectedCustomer.name
});
}
}
closeCustomerPicker();
};
//
const onStatusConfirm = (e) => {
const selectedItems = e.value;

View File

@ -42,15 +42,14 @@
<!-- 客户 -->
<view class="form-item">
<text class="form-label required">*客户</text>
<view class="form-input-wrapper" @click="openCustomerPicker">
<view class="form-input-wrapper readonly">
<input
v-model="formData.customerName"
class="form-input"
placeholder="请选择客户"
placeholder="客户信息"
disabled
placeholder-style="color: #999;"
/>
<text class="arrow"></text>
</view>
</view>
@ -183,11 +182,9 @@
<!-- 选择器组件 -->
<FollowupPickers
:show-customer-picker="showCustomerPicker"
:show-status-picker="showStatusPicker"
:show-intent-level-picker="showIntentLevelPicker"
:show-follow-type-picker="showFollowTypePicker"
:customer-list="customerList"
:status-options="statusOptions"
:intent-level-options="intentLevelOptions"
:follow-type-options="followTypeOptions"
@ -278,7 +275,6 @@ import { onLoad } from '@dcloudio/uni-app';
import { chooseAndUploadImages, batchUploadFilesToQiniu } from '@/utils/qiniu.js';
import {
createFollowup,
getCustomerList,
getCustomerStatusDict,
getCustomerIntentLevelDict,
getCustomerFollowTypeDict
@ -300,16 +296,13 @@ const formData = ref({
});
//
const showCustomerPicker = ref(false);
const showStatusPicker = ref(false);
const showIntentLevelPicker = ref(false);
const showFollowTypePicker = ref(false);
const showFollowTimePicker = ref(false);
const showNextFollowTimePicker = ref(false);
//
const customerList = ref([]);
const statusOptions = ref([]);
const intentLevelOptions = ref([]);
const followTypeOptions = ref([]);
@ -351,8 +344,6 @@ onLoad((options) => {
//
loadDictData();
//
loadCustomerList();
//
const now = new Date();
@ -393,24 +384,6 @@ const loadDictData = async () => {
}
};
//
const loadCustomerList = async () => {
try {
const res = await getCustomerList({ pageNum: 1, pageSize: 100 });
console.log('@@@@',res);
if (res && res.data && res.data.rows) {
customerList.value = res.data.rows;
}
} catch (err) {
console.error('加载客户列表失败:', err);
}
};
//
const openCustomerPicker = () => {
showCustomerPicker.value = true;
};
//
const openStatusPicker = () => {
showStatusPicker.value = true;
@ -429,9 +402,6 @@ const openFollowTypePicker = () => {
//
const handleClosePicker = (pickerType) => {
switch (pickerType) {
case 'customer':
showCustomerPicker.value = false;
break;
case 'status':
showStatusPicker.value = false;
break;
@ -1163,6 +1133,14 @@ const handleCancel = () => {
background-color: #f5f5f5;
border-radius: 8px;
padding: 12px;
&.readonly {
background-color: #f9f9f9;
.arrow {
display: none;
}
}
}
.form-input {
@ -1201,7 +1179,7 @@ const handleCancel = () => {
}
.upload-area {
width: 100%;
width: 33%;
aspect-ratio: 1;
border: 2px dashed #d0d0d0;
border-radius: 8px;