|
|
@ -134,13 +134,13 @@ |
|
|
</view> |
|
|
</view> |
|
|
</fui-form-item> |
|
|
</fui-form-item> |
|
|
<!-- 客户分类 --> |
|
|
<!-- 客户分类 --> |
|
|
<fui-form-item label="客户分类" labelSize='26' prop="customer_type" background='#434544' labelColor='#fff' :bottomBorder='false'> |
|
|
<!-- <fui-form-item label="客户分类" labelSize='26' prop="customer_type" background='#434544' labelColor='#fff' :bottomBorder='false'> |
|
|
<view class="input-title" style="margin-right:14rpx;"> |
|
|
<view class="input-title" style="margin-right:14rpx;"> |
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openCicker('customer_type')"> |
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openCicker('customer_type')"> |
|
|
{{ formData.customer_type ? picker_config.customer_type.text : '点击选择' }} |
|
|
{{ formData.customer_type ? picker_config.customer_type.text : '点击选择' }} |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</fui-form-item> |
|
|
</fui-form-item> --> |
|
|
<!-- 预约体验课 --> |
|
|
<!-- 预约体验课 --> |
|
|
<!-- <fui-form-item label="预约体验课" labelSize='26' prop="trial_lesson" background='#434544' labelColor='#fff' :bottomBorder='false'> |
|
|
<!-- <fui-form-item label="预约体验课" labelSize='26' prop="trial_lesson" background='#434544' labelColor='#fff' :bottomBorder='false'> |
|
|
<view class="input-title" style="margin-right:14rpx;"> |
|
|
<view class="input-title" style="margin-right:14rpx;"> |
|
|
@ -470,20 +470,50 @@ |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
onLoad(options) { |
|
|
onLoad(options) { |
|
|
this.resource_sharing_id = options.resource_sharing_id //共享资源表id |
|
|
console.log('onLoad - 接收到参数:', options); |
|
|
|
|
|
if (!options || !options.resource_sharing_id) { |
|
|
|
|
|
console.error('缺少必要参数 resource_sharing_id'); |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '缺少必要参数', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}); |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
uni.navigateBack(); |
|
|
|
|
|
}, 1500); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
this.resource_sharing_id = options.resource_sharing_id; //共享资源表id |
|
|
|
|
|
console.log('设置 resource_sharing_id:', this.resource_sharing_id); |
|
|
}, |
|
|
}, |
|
|
onShow() { |
|
|
onShow() { |
|
|
this.init() |
|
|
console.log('onShow - 开始初始化'); |
|
|
|
|
|
this.init(); |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
//初始化 |
|
|
//初始化 |
|
|
async init() { |
|
|
async init() { |
|
|
try { |
|
|
try { |
|
|
|
|
|
console.log('init - 开始初始化流程'); |
|
|
|
|
|
|
|
|
|
|
|
if (!this.resource_sharing_id) { |
|
|
|
|
|
console.error('resource_sharing_id 为空,无法初始化'); |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '缺少必要参数', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}); |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
uni.navigateBack(); |
|
|
|
|
|
}, 1500); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
uni.showLoading({ |
|
|
uni.showLoading({ |
|
|
title: '加载中...', |
|
|
title: '加载中...', |
|
|
mask: true |
|
|
mask: true |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
console.log('init - 开始加载字典数据'); |
|
|
|
|
|
|
|
|
// 先加载所有字典数据 |
|
|
// 先加载所有字典数据 |
|
|
const dictPromises = [ |
|
|
const dictPromises = [ |
|
|
this.getDict('source_channel'), //获取字典-来源渠道 |
|
|
this.getDict('source_channel'), //获取字典-来源渠道 |
|
|
@ -494,15 +524,21 @@ |
|
|
this.getDict('status'), //获取字典-客户状态 |
|
|
this.getDict('status'), //获取字典-客户状态 |
|
|
this.getDict('decision_maker'), //获取字典-决策人 |
|
|
this.getDict('decision_maker'), //获取字典-决策人 |
|
|
this.getDict('distance'), //获取字典-距离 |
|
|
this.getDict('distance'), //获取字典-距离 |
|
|
|
|
|
// this.getDict('customer_type'), //获取字典-客户分类 |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
await Promise.all(dictPromises); |
|
|
await Promise.all(dictPromises); |
|
|
|
|
|
console.log('init - 字典数据加载完成'); |
|
|
|
|
|
|
|
|
// 加载校区列表 |
|
|
// 加载校区列表 |
|
|
|
|
|
console.log('init - 开始加载校区列表'); |
|
|
await this.get_campus_list(); |
|
|
await this.get_campus_list(); |
|
|
|
|
|
console.log('init - 校区列表加载完成'); |
|
|
|
|
|
|
|
|
// 获取资源共享详情并回显数据 |
|
|
// 获取资源共享详情并回显数据 |
|
|
|
|
|
console.log('init - 开始获取客户详情'); |
|
|
await this.getInfo(); |
|
|
await this.getInfo(); |
|
|
|
|
|
console.log('init - 客户详情获取完成'); |
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error('初始化失败:', error); |
|
|
console.error('初始化失败:', error); |
|
|
@ -543,103 +579,160 @@ |
|
|
|
|
|
|
|
|
//获取资源共享-详情(客户资源详情) |
|
|
//获取资源共享-详情(客户资源详情) |
|
|
async getInfo() { |
|
|
async getInfo() { |
|
|
let params = { |
|
|
try { |
|
|
resource_sharing_id: this.resource_sharing_id |
|
|
console.log('getInfo - 开始获取客户详情, resource_sharing_id:', this.resource_sharing_id); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let res = await apiRoute.xs_resourceSharingInfo(params) //资源共享-详情(客户资源详情) |
|
|
if (!this.resource_sharing_id) { |
|
|
if (res.code != 1) { |
|
|
console.error('getInfo - resource_sharing_id 为空,无法获取客户详情'); |
|
|
uni.showToast({ |
|
|
return; |
|
|
title: res.msg, |
|
|
} |
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let customerResource = res.data.customerResource || {} //客户资源详情 |
|
|
let params = { |
|
|
let sixSpeed = res.data.customerResource.sixSpeed || {} //六要素详情 |
|
|
resource_sharing_id: this.resource_sharing_id |
|
|
console.log('12313', sixSpeed) |
|
|
}; |
|
|
console.log('详情', res.data) |
|
|
|
|
|
|
|
|
console.log('getInfo - 发起请求:', params); |
|
|
|
|
|
let res = await apiRoute.xs_resourceSharingInfo(params); //资源共享-详情(客户资源详情) |
|
|
|
|
|
console.log('getInfo - 请求响应:', res); |
|
|
|
|
|
|
|
|
|
|
|
if (res.code != 1) { |
|
|
|
|
|
console.error('getInfo - 请求失败:', res.msg); |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: res.msg, |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let customerResource = res.data.customerResource || {}; //客户资源详情 |
|
|
|
|
|
let sixSpeed = res.data.customerResource.sixSpeed || {}; //六要素详情 |
|
|
|
|
|
console.log('getInfo - 客户资源详情:', customerResource); |
|
|
|
|
|
console.log('getInfo - 六要素详情:', sixSpeed); |
|
|
|
|
|
|
|
|
|
|
|
// 存储原始数据,用于后续回显 |
|
|
|
|
|
this._resourceDetail = res.data; |
|
|
|
|
|
|
|
|
|
|
|
this.formData = { |
|
|
|
|
|
resource_sharing_id: this.resource_sharing_id, //资源共享表id |
|
|
|
|
|
// 客户基础信息 |
|
|
|
|
|
id: customerResource.id || '', //客户资源表id |
|
|
|
|
|
source_channel: customerResource.source_channel || '', //来源渠道 |
|
|
|
|
|
source: customerResource.source || '', //来源 |
|
|
|
|
|
name: customerResource.name || '', //姓名 |
|
|
|
|
|
age: customerResource.age || '', //年龄 |
|
|
|
|
|
gender: customerResource.gender || 'male', //性别|male-男性, female-女性, other-其他 |
|
|
|
|
|
phone_number: customerResource.phone_number || '', //联系电话 |
|
|
|
|
|
demand: customerResource.demand || '', //需求 |
|
|
|
|
|
decision_maker: customerResource.decision_maker || '', //决策人 |
|
|
|
|
|
initial_intent: customerResource.initial_intent || '', //客户初步意向度: high-高, medium-中, low-低 |
|
|
|
|
|
status: customerResource.status || '', //客户状态: active-活跃, inactive-不活跃, pending-待定 |
|
|
|
|
|
campus: customerResource.campus || '', // 校区 |
|
|
|
|
|
customer_type: customerResource.customer_type || '', // 客户分类 |
|
|
|
|
|
|
|
|
|
|
|
//六要素信息 |
|
|
|
|
|
purchasing_power: sixSpeed.purchase_power || '', //购买力 |
|
|
|
|
|
cognitive_idea: sixSpeed.concept_awareness || '', //认知理念 |
|
|
|
|
|
communication: sixSpeed.communication || '', //沟通备注 |
|
|
|
|
|
staff_id: sixSpeed.staff_id || '', //人员ID |
|
|
|
|
|
distance: sixSpeed.distance || '', //距离 |
|
|
|
|
|
promised_visit_time: sixSpeed.promised_visit_time || '', //承诺到访时间 |
|
|
|
|
|
optional_class_time: sixSpeed.preferred_class_time || '', //可选上课时间 |
|
|
|
|
|
first_visit_time: sixSpeed.first_visit_time || '', // 一访时间 |
|
|
|
|
|
first_visit_status: sixSpeed.first_visit_status || '', //一访情况 |
|
|
|
|
|
second_visit_time: sixSpeed.second_visit_time || '', // 二访时间 |
|
|
|
|
|
second_visit_status: sixSpeed.second_visit_status || '', //二访情况 |
|
|
|
|
|
remark: sixSpeed.remark || '', // 备注 |
|
|
|
|
|
consultation_remark: sixSpeed.consultation_remark || '', // 面咨备注 |
|
|
|
|
|
chasing_orders: sixSpeed.chasing_orders || '', // 追单标注 |
|
|
|
|
|
is_bm: sixSpeed.is_bm || 2, // 是否报名,默认未报名 |
|
|
|
|
|
efficacious: sixSpeed.efficacious || '' |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
console.log('getInfo - 表单数据设置完成:', this.formData); |
|
|
|
|
|
|
|
|
|
|
|
// 格式化日期时间 |
|
|
|
|
|
if (sixSpeed.promised_visit_time) { |
|
|
|
|
|
this.formData.promised_visit_time = this.$util.formatToDateTime(sixSpeed.promised_visit_time, 'Y-m-d'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.formData = { |
|
|
if (sixSpeed.preferred_class_time) { |
|
|
resource_sharing_id: this.resource_sharing_id, //资源共享表id |
|
|
this.formData.optional_class_time = this.$util.formatToDateTime(sixSpeed.preferred_class_time, 'Y-m-d'); |
|
|
// 客户基础信息 |
|
|
} |
|
|
id: customerResource.id || '', //客户资源表id |
|
|
|
|
|
source_channel: customerResource.source_channel || '', //来源渠道 |
|
|
|
|
|
source: customerResource.source || '', //来源 |
|
|
|
|
|
name: customerResource.name || '', //姓名 |
|
|
|
|
|
age: customerResource.age || '', //年龄 |
|
|
|
|
|
gender: customerResource.gender || '', //性别|male-男性, female-女性, other-其他 |
|
|
|
|
|
phone_number: customerResource.phone_number || '', //联系电话 |
|
|
|
|
|
demand: customerResource.demand || '', //需求 |
|
|
|
|
|
decision_maker: customerResource.decision_maker || '', //决策人 |
|
|
|
|
|
initial_intent: customerResource.initial_intent || '', //客户初步意向度: high-高, medium-中, low-低 |
|
|
|
|
|
status: customerResource.status || '', //客户状态: active-活跃, inactive-不活跃, pending-待定 |
|
|
|
|
|
campus: customerResource.campus || '', // 校区 |
|
|
|
|
|
|
|
|
|
|
|
//六要素信息 |
|
|
if (sixSpeed.first_visit_time) { |
|
|
purchasing_power: sixSpeed.purchase_power || '', //购买力 |
|
|
this.formData.first_visit_time = this.$util.formatToDateTime(sixSpeed.first_visit_time, 'Y-m-d'); |
|
|
cognitive_idea: sixSpeed.concept_awareness || '', //认知理念 |
|
|
} |
|
|
communication: sixSpeed.communication || '', //沟通备注 |
|
|
|
|
|
staff_id: sixSpeed.staff_id || '', //人员ID |
|
|
if (sixSpeed.second_visit_time) { |
|
|
distance: sixSpeed.distance || '', //距离 |
|
|
this.formData.second_visit_time = this.$util.formatToDateTime(sixSpeed.second_visit_time, 'Y-m-d'); |
|
|
promised_visit_time: sixSpeed.promised_visit_time || '', //承诺到访时间 |
|
|
} |
|
|
optional_class_time: sixSpeed.preferred_class_time || '', //可选上课时间 |
|
|
|
|
|
first_visit_status: sixSpeed.first_visit_status || '', //一访情况 |
|
|
|
|
|
second_visit_status: sixSpeed.second_visit_status || '', //二访情况 |
|
|
|
|
|
efficacious : sixSpeed.efficacious |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.formData.promised_visit_time = this.$util.formatToDateTime(sixSpeed.promised_visit_time, |
|
|
console.log('getInfo - 日期格式化完成'); |
|
|
'Y-m-d'); //格式化时间(Y-m-d H:i) |
|
|
|
|
|
this.formData.optional_class_time = this.$util.formatToDateTime(sixSpeed.preferred_class_time, |
|
|
|
|
|
'Y-m-d'); //格式化时间(Y-m-d H:i) |
|
|
|
|
|
|
|
|
|
|
|
// 获取校区列表,确保校区选择器数据已加载 |
|
|
// 设置选择器文本回显 |
|
|
await this.get_campus_list() |
|
|
console.log('getInfo - 开始设置选择器文本回显'); |
|
|
|
|
|
await this.setPickerText(); |
|
|
|
|
|
console.log('getInfo - 选择器文本回显完成'); |
|
|
|
|
|
|
|
|
// 等待所有字典数据加载完成后再进行回显 |
|
|
} catch (error) { |
|
|
await this.setPickerText() |
|
|
console.error('获取客户详情失败:', error); |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '获取客户详情失败,请重试', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 设置选择器文本回显 |
|
|
// 设置选择器文本回显 |
|
|
async setPickerText() { |
|
|
async setPickerText() { |
|
|
const { customerResource = {}, sixSpeed = {} } = await this.getResourceDetail() || {} |
|
|
try { |
|
|
|
|
|
const { customerResource = {}, sixSpeed = {} } = await this.getResourceDetail() || {}; |
|
|
// 设置选择器文本回显 |
|
|
|
|
|
this.setPickerTextByValue('source_channel', this.formData.source_channel, customerResource.source_channel_name) |
|
|
// 设置选择器文本回显 |
|
|
this.setPickerTextByValue('source', this.formData.source, customerResource.source_name) |
|
|
this.setPickerTextByValue('source_channel', this.formData.source_channel, customerResource.source_channel_name); |
|
|
this.setPickerTextByValue('consultant', this.formData.consultant, customerResource.consultant_name) |
|
|
this.setPickerTextByValue('source', this.formData.source, customerResource.source_name); |
|
|
this.setPickerTextByValue('initial_intent', this.formData.initial_intent, customerResource.initial_intent_name) |
|
|
this.setPickerTextByValue('consultant', this.formData.consultant, customerResource.consultant_name); |
|
|
this.setPickerTextByValue('status', this.formData.status, customerResource.status_name) |
|
|
this.setPickerTextByValue('initial_intent', this.formData.initial_intent, customerResource.initial_intent_name); |
|
|
this.setPickerTextByValue('decision_maker', this.formData.decision_maker, customerResource.decision_maker_name || customerResource.decision_maker) |
|
|
this.setPickerTextByValue('status', this.formData.status, customerResource.status_name); |
|
|
this.setPickerTextByValue('campus', this.formData.campus, customerResource.campus_name) |
|
|
this.setPickerTextByValue('decision_maker', this.formData.decision_maker, customerResource.decision_maker_name); |
|
|
|
|
|
this.setPickerTextByValue('campus', this.formData.campus, customerResource.campus_name); |
|
|
// 六要素相关 |
|
|
this.setPickerTextByValue('customer_type', this.formData.customer_type, customerResource.customer_type_name); |
|
|
this.setPickerTextByValue('purchasing_power', this.formData.purchasing_power, sixSpeed.purchase_power_name) |
|
|
|
|
|
this.setPickerTextByValue('cognitive_idea', this.formData.cognitive_idea, sixSpeed.concept_awareness_name) |
|
|
// 六要素相关 |
|
|
this.setPickerTextByValue('distance', this.formData.distance, sixSpeed.distance_name || sixSpeed.distance) |
|
|
this.setPickerTextByValue('purchasing_power', this.formData.purchasing_power, sixSpeed.purchase_power_name); |
|
|
|
|
|
this.setPickerTextByValue('cognitive_idea', this.formData.cognitive_idea, sixSpeed.concept_awareness_name); |
|
|
|
|
|
this.setPickerTextByValue('distance', this.formData.distance, sixSpeed.distance_name); |
|
|
|
|
|
|
|
|
|
|
|
console.log('选择器文本回显完成'); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('设置选择器文本回显失败:', error); |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 根据值设置选择器文本 |
|
|
// 根据值设置选择器文本 |
|
|
setPickerTextByValue(pickerName, value, defaultText) { |
|
|
setPickerTextByValue(pickerName, value, defaultText) { |
|
|
if (!value) { |
|
|
if (!value) { |
|
|
this.picker_config[pickerName].text = '点击选择' |
|
|
this.picker_config[pickerName] = this.picker_config[pickerName] || {}; |
|
|
return |
|
|
this.picker_config[pickerName].text = '点击选择'; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 确保 picker_config[pickerName] 存在 |
|
|
|
|
|
if (!this.picker_config[pickerName]) { |
|
|
|
|
|
this.picker_config[pickerName] = { options: [] }; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 先尝试从选项中找到匹配的文本 |
|
|
// 先尝试从选项中找到匹配的文本 |
|
|
const options = this.picker_config[pickerName].options || [] |
|
|
const options = this.picker_config[pickerName].options || []; |
|
|
const option = options.find(opt => opt.value == value) |
|
|
const option = options.find(opt => String(opt.value) === String(value)); |
|
|
|
|
|
|
|
|
if (option) { |
|
|
if (option) { |
|
|
this.picker_config[pickerName].text = option.text |
|
|
this.picker_config[pickerName].text = option.text; |
|
|
} else if (defaultText) { |
|
|
} else if (defaultText) { |
|
|
// 如果找不到匹配的选项但有默认文本,则使用默认文本 |
|
|
// 如果找不到匹配的选项但有默认文本,则使用默认文本 |
|
|
this.picker_config[pickerName].text = defaultText |
|
|
this.picker_config[pickerName].text = defaultText; |
|
|
} else { |
|
|
} else { |
|
|
this.picker_config[pickerName].text = '点击选择' |
|
|
this.picker_config[pickerName].text = '点击选择'; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
@ -753,67 +846,91 @@ |
|
|
|
|
|
|
|
|
//获取字典 |
|
|
//获取字典 |
|
|
async getDict(inputName) { |
|
|
async getDict(inputName) { |
|
|
let key = '' |
|
|
try { |
|
|
switch (inputName) { |
|
|
console.log(`getDict - 开始获取字典数据: ${inputName}`); |
|
|
//来源渠道 |
|
|
|
|
|
case 'source_channel': |
|
|
let key = ''; |
|
|
key = 'SourceChannel' |
|
|
switch (inputName) { |
|
|
break; |
|
|
//来源渠道 |
|
|
|
|
|
case 'source_channel': |
|
|
|
|
|
key = 'SourceChannel'; |
|
|
|
|
|
break; |
|
|
//来源 |
|
|
//来源 |
|
|
case 'source': |
|
|
case 'source': |
|
|
key = 'source' |
|
|
key = 'source'; |
|
|
break; |
|
|
break; |
|
|
//购买力 |
|
|
//购买力 |
|
|
case 'purchasing_power': |
|
|
case 'purchasing_power': |
|
|
key = 'customer_purchasing_power' |
|
|
key = 'customer_purchasing_power'; |
|
|
break; |
|
|
break; |
|
|
//认知理念 |
|
|
//认知理念 |
|
|
case 'cognitive_idea': |
|
|
case 'cognitive_idea': |
|
|
key = 'cognitive_concept' |
|
|
key = 'cognitive_concept'; |
|
|
break; |
|
|
break; |
|
|
//决策人 |
|
|
//决策人 |
|
|
case 'decision_maker': |
|
|
case 'decision_maker': |
|
|
key = 'decision_maker' |
|
|
key = 'decision_maker'; |
|
|
break; |
|
|
break; |
|
|
//客户初步意向度 |
|
|
//客户初步意向度 |
|
|
case 'initial_intent': |
|
|
case 'initial_intent': |
|
|
key = 'preliminarycustomerintention' |
|
|
key = 'preliminarycustomerintention'; |
|
|
break; |
|
|
break; |
|
|
//客户状态 |
|
|
//客户状态 |
|
|
case 'status': |
|
|
case 'status': |
|
|
key = 'kh_status' |
|
|
key = 'kh_status'; |
|
|
break; |
|
|
break; |
|
|
//距离 |
|
|
//距离 |
|
|
case 'distance': |
|
|
case 'distance': |
|
|
key = 'distance' |
|
|
key = 'distance'; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
//客户分类 |
|
|
if (!key) { |
|
|
case 'customer_type': |
|
|
return |
|
|
key = 'customer_type'; |
|
|
} |
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
console.warn(`未知的字典类型: ${inputName}`); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 使用 util.getDict 获取并缓存字典 |
|
|
console.log(`getDict - 字典键值映射: ${inputName} -> ${key}`); |
|
|
let dictionary = await this.$util.getDict(key) |
|
|
|
|
|
if(!dictionary || !Array.isArray(dictionary) || dictionary.length === 0){ |
|
|
|
|
|
uni.showToast({ title: '暂无选项', icon: 'none' }) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let arr = [] |
|
|
// 确保 picker_config[inputName] 存在 |
|
|
// 处理接口返回的数据结构 [{name: "抖音", value: "1", sort: 0, memo: ""}, ...] |
|
|
if (!this.picker_config[inputName]) { |
|
|
dictionary.forEach((v) => { |
|
|
this.picker_config[inputName] = { options: [], text: '点击选择' }; |
|
|
arr.push({ text: v.name, value: v.value }) |
|
|
} |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
if (inputName == 'source_channel') { |
|
|
// 使用 util.getDict 获取并缓存字典 |
|
|
//插入到arr的头部 |
|
|
console.log(`getDict - 调用 $util.getDict('${key}')`); |
|
|
arr.unshift({ |
|
|
let dictionary = await this.$util.getDict(key); |
|
|
text: '线下', |
|
|
console.log(`getDict - 字典数据获取结果:`, dictionary); |
|
|
value: '0', |
|
|
|
|
|
}) |
|
|
if(!dictionary || !Array.isArray(dictionary) || dictionary.length === 0){ |
|
|
} |
|
|
console.warn(`字典 ${key} 数据为空`); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.picker_config[inputName].options = arr |
|
|
let arr = []; |
|
|
|
|
|
// 处理接口返回的数据结构 [{name: "抖音", value: "1", sort: 0, memo: ""}, ...] |
|
|
|
|
|
dictionary.forEach((v) => { |
|
|
|
|
|
arr.push({ text: v.name, value: v.value }); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (inputName == 'source_channel') { |
|
|
|
|
|
// 插入到arr的头部 |
|
|
|
|
|
arr.unshift({ |
|
|
|
|
|
text: '线下', |
|
|
|
|
|
value: '0', |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.picker_config[inputName].options = arr; |
|
|
|
|
|
|
|
|
|
|
|
console.log(`getDict - 字典 ${inputName} 加载完成,选项数: ${arr.length}`); |
|
|
|
|
|
return arr; |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error(`获取字典 ${inputName} 失败:`, error); |
|
|
|
|
|
return []; |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
//##### 查重相关 ##### |
|
|
//##### 查重相关 ##### |
|
|
@ -1044,29 +1161,30 @@ |
|
|
}, |
|
|
}, |
|
|
//监听-下拉选择器 |
|
|
//监听-下拉选择器 |
|
|
changeCicker(e) { |
|
|
changeCicker(e) { |
|
|
console.log('监听-下拉选择器', this.picker_input_name, e) |
|
|
console.log('监听-下拉选择器', this.picker_input_name, e); |
|
|
let input_name = this.picker_input_name |
|
|
let input_name = this.picker_input_name; |
|
|
|
|
|
|
|
|
// 更新表单数据 |
|
|
// 更新表单数据 |
|
|
this.formData[input_name] = e.value |
|
|
this.formData[input_name] = e.value; |
|
|
|
|
|
|
|
|
// 更新选择器文本 |
|
|
// 更新选择器文本 |
|
|
this.picker_config[input_name].text = e.text |
|
|
this.picker_config[input_name].text = e.text; |
|
|
|
|
|
|
|
|
// 特殊处理:来源选择 |
|
|
// 特殊处理:来源选择 |
|
|
if (input_name == 'source') { |
|
|
if (input_name === 'source') { |
|
|
if (e.value == 1) { |
|
|
// 如果选择了线上(1),则需要选择来源渠道 |
|
|
// 如果选择了线上,则清空来源渠道,等待用户选择 |
|
|
if (e.value === '1' || e.value === 1) { |
|
|
this.formData.source_channel = '' |
|
|
// 清空来源渠道,等待用户选择 |
|
|
this.picker_config.source_channel.text = '点击选择' |
|
|
this.formData.source_channel = ''; |
|
|
|
|
|
this.picker_config.source_channel.text = '点击选择'; |
|
|
} else { |
|
|
} else { |
|
|
// 如果选择了其他来源,则设置来源渠道为线下 |
|
|
// 如果选择了其他来源,则设置来源渠道为线下 |
|
|
this.formData.source_channel = '0' //0=线下 |
|
|
this.formData.source_channel = '0'; // 0=线下 |
|
|
this.picker_config.source_channel.text = '线下' |
|
|
this.picker_config.source_channel.text = '线下'; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.cancelCicker() |
|
|
this.cancelCicker(); |
|
|
}, |
|
|
}, |
|
|
//关闭下拉选择器 |
|
|
//关闭下拉选择器 |
|
|
cancelCicker() { |
|
|
cancelCicker() { |
|
|
|