Commit dd858657 by Sweet Zhang

修改新单跟进

parent 46bfb32b
......@@ -579,7 +579,7 @@ async function loadRemoteOptionsForInit(item) {
// ==================== 加载远程 API 选项(首次 focus 时加载,无搜索词) ====================
async function loadRemoteOptions(item) {
const { prop, api, requestParams, keywordField, debounceWait, ...rest } = item
if (!api || remoteOptions.value[prop]?.length > 0) return
if (!api ) return
try {
remoteLoading.value[prop] = true
......@@ -728,6 +728,43 @@ defineExpose({
})
localModel.value = { ...resetData }
nextTick(() => formRef.value?.clearValidate())
},
// ✅ 新增:强制刷新某个字段的远程选项
async refreshRemoteOptions(targetProp) {
console.log(`[SearchForm] 收到刷新请求: ${targetProp}`)
// 1. 查找配置项
const item = internalConfig.value.find(i => i.prop === targetProp)
if (!item) {
console.warn(`[SearchForm] 未找到 prop 为 ${targetProp} 的配置项`)
return
}
if (item.type !== 'select' || !item.api) {
console.warn(`[SearchForm] 字段 ${targetProp} 不是远程 Select 或没有 API`)
return
}
console.log(`[SearchForm] 开始强制加载 ${targetProp} 的数据,API: ${item.api}`)
// 2. 关键:在调用前,先清空旧数据,防止子组件内部的 "已加载则跳过" 逻辑生效
// 如果你的 loadRemoteOptions 里有 "if (remoteOptions.value[prop]?.length > 0) return"
// 这里必须先清空
remoteOptions.value[targetProp] = []
remoteLoading.value[targetProp] = true // 手动开启 loading
try {
// 3. 调用内部加载函数
// 注意:直接调用 loadRemoteOptions,它会读取最新的 requestParams
await loadRemoteOptions(item)
console.log(`[SearchForm] ${targetProp} 加载完成`)
} catch (error) {
console.error(`[SearchForm] ${targetProp} 加载失败`, error)
throw error
} finally {
remoteLoading.value[targetProp] = false
}
}
})
</script>
......
......@@ -593,8 +593,6 @@ const remittanceConfig = [
validator: (rule, value, callback) => {
if (value === '' || value == null) {
callback(new Error('请输入付款金额'))
} else if (!/^\d+$/.test(String(value))) {
callback(new Error('只能输入正整数'))
} else {
callback()
}
......@@ -636,7 +634,7 @@ const remittanceConfig = [
label: '付款银行',
api: '/base/api/bank/page',
keywordField: 'policyNo',
requestParams: { pageNo: 1, pageSize: 20 },
requestParams: { pageNo: 1, pageSize: 50 },
debounceWait: 500, // 自定义防抖时间
valueKey: 'bankBizId',
......
......@@ -497,7 +497,8 @@ const policyInfoFormConfig = ref([
reconciliationCompany: 'name',
reconciliationCode:'code',
}
},
rules: [{ required: true, message: '请选择出单经纪公司', trigger: 'blur' }],
},
{
type: 'input',
......@@ -649,7 +650,7 @@ const basicPlanFormConfig = ref([
valueKey: 'productName',
labelKey: 'productName',
transform: res => {
console.log('======子组件选择选项后,父组件接收的值 :', res?.data.records || [])
console.log('======子组件选择选项后,父组件接收的值产品名称:', res?.data.records || [])
return res?.data.records || []
},
onChangeExtraFields: {
......@@ -1204,21 +1205,47 @@ const viewRecordDetail = e => {
})
}
const handleSelectChange = async (prop, value, item, type) => {
await nextTick()
// console.log('======子组件选择选项后,父组件接收的值 :', basicPlanFormData.value)
console.log('🔔 父组件收到 selectChange:', prop, value, type)
await nextTick() // 确保 DOM 和响应式数据更新
if (type === 'basicPlan') {
const params = {
tenantBizId: userStore.projectInfo.tenantBizId,
projectBizId: userStore.projectInfo.projectBizId,
fieldBizId: 'field_olk1qZe81qHHKXbw',
fieldValueBizId: 'field_value_uOfJH5ucA2YwJpbn',
insuranceCompanyBizIdList: [basicPlanFormData.value.insuranceCompanyBizId],
categoryCodeList: [basicPlanFormData.value.insuranceCategoryCode],
pageNo: 1,
pageSize: 100
// 只有当改变的是“保险公司”时,才刷新“产品名称”
if (prop === 'insuranceCompanyBizId') {
console.log('🔄 检测到保险公司变更,准备刷新产品列表...')
// 1. 检查 Ref 是否存在
if (!basicPlanFormRef.value) {
console.error('❌ basicPlanFormRef 为空,无法调用方法')
return
}
// 2. 检查方法是否存在
if (typeof basicPlanFormRef.value.refreshRemoteOptions !== 'function') {
console.error('❌ refreshRemoteOptions 方法未暴露或不存在')
console.log('当前暴露的方法:', Object.keys(basicPlanFormRef.value))
return
}
try {
// 3. 可选:先清空产品字段的值,避免选中了旧公司的产品
basicPlanFormData.value.productName = ''
basicPlanFormData.value.productLaunchBizId = ''
basicPlanFormData.value.insuranceCategoryCode = '' // 如果分类也依赖公司,可能也要清空
console.log('🚀 正在调用子组件 refreshRemoteOptions...')
// 4. 调用刷新
await basicPlanFormRef.value.refreshRemoteOptions('productName')
console.log('✅ 产品列表刷新指令执行完毕')
// ElMessage.success('产品列表已更新')
} catch (err) {
console.error('💥 刷新产品列表出错:', err)
ElMessage.error('产品列表更新失败,请重试')
}
}
console.log('====父组件拿到值,去调用产品列表查询接口', params)
getProductLists(params)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment