|
|
|
@ -140,14 +140,22 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</fui-form-item> |
|
|
|
<!-- 上课时间 --> |
|
|
|
<fui-form-item label="上课时间" labelSize='26' prop="optional_class_time" background='#434544' labelColor='#fff' :bottomBorder='false'> |
|
|
|
<!-- 可选上课时间 --> |
|
|
|
<fui-form-item label="可选上课时间" labelSize='26' prop="optional_class_time" background='#434544' labelColor='#fff' :bottomBorder='false'> |
|
|
|
<view class="input-title" style="margin-right:14rpx;"> |
|
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openDate('optional_class_time')"> |
|
|
|
{{ formData.optional_class_time ? formData.optional_class_time : '点击选择' }} |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</fui-form-item> |
|
|
|
<!-- 承诺到访时间 --> |
|
|
|
<fui-form-item label="承诺到访时间" labelSize='26' prop="promised_visit_time" background='#434544' labelColor='#fff' :bottomBorder='false'> |
|
|
|
<view class="input-title" style="margin-right:14rpx;"> |
|
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openDate('promised_visit_time')"> |
|
|
|
{{ formData.promised_visit_time ? formData.promised_visit_time : '点击选择' }} |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</fui-form-item> |
|
|
|
<!-- 距离 --> |
|
|
|
<fui-form-item label="距离" labelSize='26' prop="distance" background='#434544' labelColor='#fff' :bottomBorder='false'> |
|
|
|
<view class="input-title" style="margin-right:14rpx;"> |
|
|
|
@ -577,20 +585,8 @@ |
|
|
|
|
|
|
|
console.log('init - 开始加载字典数据'); |
|
|
|
|
|
|
|
// 先加载所有字典数据 |
|
|
|
const dictPromises = [ |
|
|
|
this.getDict('source_channel'), //获取字典-来源渠道 |
|
|
|
this.getDict('source'), //获取字典-来源 |
|
|
|
this.getDict('purchasing_power'), //获取字典-购买力 |
|
|
|
this.getDict('initial_intent'), //获取字典-客户初步意向度 |
|
|
|
this.getDict('cognitive_idea'), //获取字典-认知理念 |
|
|
|
this.getDict('status'), //获取字典-客户状态 |
|
|
|
this.getDict('decision_maker'), //获取字典-决策人 |
|
|
|
this.getDict('distance'), //获取字典-距离 |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
await Promise.all(dictPromises); |
|
|
|
// 批量加载所有字典数据 |
|
|
|
await this.getBatchDictData(); |
|
|
|
console.log('init - 字典数据加载完成'); |
|
|
|
|
|
|
|
// 加载校区列表 |
|
|
|
@ -614,6 +610,139 @@ |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 批量获取字典数据 |
|
|
|
async getBatchDictData() { |
|
|
|
try { |
|
|
|
// 定义需要的字典keys和对应的本地键名 |
|
|
|
const dictMapping = { |
|
|
|
'SourceChannel': 'source_channel', |
|
|
|
'source': 'source', |
|
|
|
'customer_purchasing_power': 'purchasing_power', |
|
|
|
'preliminarycustomerintention': 'initial_intent', |
|
|
|
'cognitive_concept': 'cognitive_idea', |
|
|
|
'kh_status': 'status', |
|
|
|
'decision_maker': 'decision_maker', |
|
|
|
'distance': 'distance' |
|
|
|
}; |
|
|
|
|
|
|
|
// 获取缓存的字典数据 |
|
|
|
if (!window._dictCache) { |
|
|
|
window._dictCache = {}; |
|
|
|
} |
|
|
|
|
|
|
|
// 处理优先级,先请求用户可能立即需要的字典 |
|
|
|
const criticalDicts = ['source', 'source_channel']; |
|
|
|
const regularDicts = Object.keys(dictMapping).filter(key => !criticalDicts.includes(dictMapping[key])); |
|
|
|
|
|
|
|
// 先获取关键字典 |
|
|
|
for (const dictKey of criticalDicts) { |
|
|
|
const key = Object.keys(dictMapping).find(k => dictMapping[k] === dictKey); |
|
|
|
if (key) { |
|
|
|
await this.loadDictData(key, dictMapping[key]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 异步获取其他字典 |
|
|
|
setTimeout(() => { |
|
|
|
regularDicts.forEach(async (key) => { |
|
|
|
const localKey = dictMapping[key]; |
|
|
|
if (!window._dictCache[key]) { |
|
|
|
await this.loadDictData(key, localKey); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, 100); |
|
|
|
|
|
|
|
console.log('优化的批量字典数据加载初始化完成'); |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
console.error('批量获取字典数据失败:', error); |
|
|
|
// 如果批量获取失败,回退到单个获取 |
|
|
|
await this.fallbackGetDict(); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 加载单个字典数据 |
|
|
|
async loadDictData(key, localKey) { |
|
|
|
try { |
|
|
|
// 检查缓存 |
|
|
|
if (window._dictCache[key]) { |
|
|
|
// 使用缓存数据 |
|
|
|
const dictData = window._dictCache[key]; |
|
|
|
this.processDictData(localKey, dictData); |
|
|
|
return dictData; |
|
|
|
} |
|
|
|
|
|
|
|
// 加载字典数据 |
|
|
|
const dictData = await this.$util.getDict(key); |
|
|
|
|
|
|
|
// 缓存数据 |
|
|
|
if (Array.isArray(dictData) && dictData.length > 0) { |
|
|
|
window._dictCache[key] = dictData; |
|
|
|
this.processDictData(localKey, dictData); |
|
|
|
} |
|
|
|
|
|
|
|
return dictData; |
|
|
|
} catch (error) { |
|
|
|
console.error(`加载字典 ${key} 失败:`, error); |
|
|
|
return []; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 处理字典数据 |
|
|
|
processDictData(localKey, dictData) { |
|
|
|
if (!Array.isArray(dictData) || dictData.length === 0) return; |
|
|
|
|
|
|
|
let formattedOptions = dictData.map(item => ({ |
|
|
|
text: item.name || '', |
|
|
|
value: item.value || '' |
|
|
|
})); |
|
|
|
|
|
|
|
// 特殊处理来源渠道,添加线下选项 |
|
|
|
if (localKey === 'source_channel') { |
|
|
|
formattedOptions.unshift({ |
|
|
|
text: '线下', |
|
|
|
value: '0' |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// 确保 picker_config 存在 |
|
|
|
if (!this.picker_config[localKey]) { |
|
|
|
this.picker_config[localKey] = { options: [], text: '点击选择' }; |
|
|
|
} |
|
|
|
|
|
|
|
this.picker_config[localKey].options = formattedOptions; |
|
|
|
}, |
|
|
|
|
|
|
|
// 回退方案:单个获取字典 |
|
|
|
async fallbackGetDict() { |
|
|
|
console.log('使用回退方案获取字典数据'); |
|
|
|
try { |
|
|
|
// 优先获取关键字典 |
|
|
|
await Promise.all([ |
|
|
|
this.getDict('source_channel'), |
|
|
|
this.getDict('source') |
|
|
|
]); |
|
|
|
|
|
|
|
// 延迟加载其他字典 |
|
|
|
setTimeout(async () => { |
|
|
|
try { |
|
|
|
await Promise.all([ |
|
|
|
this.getDict('purchasing_power'), |
|
|
|
this.getDict('initial_intent'), |
|
|
|
this.getDict('cognitive_idea'), |
|
|
|
this.getDict('status'), |
|
|
|
this.getDict('decision_maker'), |
|
|
|
this.getDict('distance') |
|
|
|
]); |
|
|
|
} catch (error) { |
|
|
|
console.error('回退方案第二阶段失败:', error); |
|
|
|
} |
|
|
|
}, 100); |
|
|
|
} catch (error) { |
|
|
|
console.error('回退方案也失败了:', error); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
async get_campus_list(){ |
|
|
|
|
|
|
|
let res = await apiRoute.common_getCampusesList({}) |
|
|
|
@ -693,7 +822,7 @@ |
|
|
|
customer_type: customerResource.customer_type || '', // 客户分类 |
|
|
|
|
|
|
|
//六要素信息 |
|
|
|
purchasing_power: sixSpeed.purchase_power || '', //购买力 |
|
|
|
purchasing_power: sixSpeed.purchasing_power || '', //购买力 |
|
|
|
cognitive_idea: sixSpeed.concept_awareness || '', //认知理念 |
|
|
|
communication: sixSpeed.communication || '', //沟通备注 |
|
|
|
staff_id: sixSpeed.staff_id || '', //人员ID |
|
|
|
@ -763,7 +892,7 @@ |
|
|
|
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('purchasing_power', this.formData.purchasing_power, sixSpeed.purchasing_power_name); |
|
|
|
this.setPickerTextByValue('cognitive_idea', this.formData.cognitive_idea, sixSpeed.concept_awareness_name); |
|
|
|
this.setPickerTextByValue('distance', this.formData.distance, sixSpeed.distance_name); |
|
|
|
// 不再需要设置call_intent的选择器文本,因为已改为单选组件 |
|
|
|
@ -776,12 +905,26 @@ |
|
|
|
|
|
|
|
// 根据值设置选择器文本 |
|
|
|
setPickerTextByValue(pickerName, value, defaultText) { |
|
|
|
// 使用空值缓存加速处理 |
|
|
|
if (!value) { |
|
|
|
this.picker_config[pickerName] = this.picker_config[pickerName] || {}; |
|
|
|
this.picker_config[pickerName].text = '点击选择'; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 创建映射缓存,避免重复查找 |
|
|
|
if (!this._valueTextMapping) { |
|
|
|
this._valueTextMapping = {}; |
|
|
|
} |
|
|
|
|
|
|
|
// 检查缓存 |
|
|
|
const cacheKey = `${pickerName}_${value}`; |
|
|
|
if (this._valueTextMapping[cacheKey]) { |
|
|
|
this.picker_config[pickerName] = this.picker_config[pickerName] || {}; |
|
|
|
this.picker_config[pickerName].text = this._valueTextMapping[cacheKey]; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 确保 picker_config[pickerName] 存在 |
|
|
|
if (!this.picker_config[pickerName]) { |
|
|
|
this.picker_config[pickerName] = { options: [] }; |
|
|
|
@ -791,14 +934,19 @@ |
|
|
|
const options = this.picker_config[pickerName].options || []; |
|
|
|
const option = options.find(opt => String(opt.value) === String(value)); |
|
|
|
|
|
|
|
let textValue; |
|
|
|
if (option) { |
|
|
|
this.picker_config[pickerName].text = option.text; |
|
|
|
textValue = option.text; |
|
|
|
} else if (defaultText) { |
|
|
|
// 如果找不到匹配的选项但有默认文本,则使用默认文本 |
|
|
|
this.picker_config[pickerName].text = defaultText; |
|
|
|
textValue = defaultText; |
|
|
|
} else { |
|
|
|
this.picker_config[pickerName].text = '点击选择'; |
|
|
|
textValue = '点击选择'; |
|
|
|
} |
|
|
|
|
|
|
|
// 保存到缓存 |
|
|
|
this._valueTextMapping[cacheKey] = textValue; |
|
|
|
this.picker_config[pickerName].text = textValue; |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取资源详情(缓存数据,避免重复请求) |
|
|
|
|