客户只读
This commit is contained in:
parent
9e9672abda
commit
a7292132fd
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user