客户只读

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> <template>
<!-- 客户选择器 - uv-picker -->
<uv-picker
ref="customerPickerRef"
:columns="customerColumns"
keyName="name"
@confirm="onCustomerConfirm"
@cancel="closeCustomerPicker"
></uv-picker>
<!-- 客户状态选择器 - uv-picker --> <!-- 客户状态选择器 - uv-picker -->
<uv-picker <uv-picker
ref="statusPickerRef" ref="statusPickerRef"
@ -40,11 +31,9 @@
import { ref, watch, nextTick } from 'vue'; import { ref, watch, nextTick } from 'vue';
const props = defineProps({ const props = defineProps({
showCustomerPicker: Boolean,
showStatusPicker: Boolean, showStatusPicker: Boolean,
showIntentLevelPicker: Boolean, showIntentLevelPicker: Boolean,
showFollowTypePicker: Boolean, showFollowTypePicker: Boolean,
customerList: Array,
statusOptions: Array, statusOptions: Array,
intentLevelOptions: Array, intentLevelOptions: Array,
followTypeOptions: Array, followTypeOptions: Array,
@ -54,36 +43,16 @@ const props = defineProps({
const emit = defineEmits(['update:formData', 'close-picker']); const emit = defineEmits(['update:formData', 'close-picker']);
// ref // ref
const customerPickerRef = ref(null);
const statusPickerRef = ref(null); const statusPickerRef = ref(null);
const intentLevelPickerRef = ref(null); const intentLevelPickerRef = ref(null);
const followTypePickerRef = ref(null); const followTypePickerRef = ref(null);
// 使 ref columns // 使 ref columns
const customerColumns = ref([[]]);
const statusColumns = ref([[]]); const statusColumns = ref([[]]);
const intentLevelColumns = ref([[]]); const intentLevelColumns = ref([[]]);
const followTypeColumns = ref([[]]); const followTypeColumns = ref([[]]);
// prop // 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) => { watch(() => props.showStatusPicker, async (val) => {
if (val && statusPickerRef.value) { if (val && statusPickerRef.value) {
// //
@ -140,15 +109,6 @@ watch(() => props.showFollowTypePicker, async (val) => {
}); });
// columns // 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) => { watch(() => props.statusOptions, (newOptions) => {
if (newOptions && newOptions.length > 0) { if (newOptions && newOptions.length > 0) {
statusColumns.value = [newOptions]; statusColumns.value = [newOptions];
@ -177,10 +137,6 @@ watch(() => props.followTypeOptions, (newOptions) => {
}, { immediate: true, deep: true }); }, { immediate: true, deep: true });
// //
const closeCustomerPicker = () => {
emit('close-picker', 'customer');
};
const closeStatusPicker = () => { const closeStatusPicker = () => {
emit('close-picker', 'status'); emit('close-picker', 'status');
}; };
@ -193,22 +149,6 @@ const closeFollowTypePicker = () => {
emit('close-picker', 'followType'); 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 onStatusConfirm = (e) => {
const selectedItems = e.value; const selectedItems = e.value;

View File

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