|
|
@@ -106,6 +106,7 @@ const personalOwnerFields = [ |
|
|
|
value: "userPosImgUrl", |
|
|
|
required: true, |
|
|
|
show: false, |
|
|
|
componentKey: Date.now(), |
|
|
|
}, |
|
|
|
{ |
|
|
|
placeholderImg: "image/applyCard/guohui.png", |
|
|
@@ -120,6 +121,7 @@ const personalOwnerFields = [ |
|
|
|
value: "userNegImgUrl", |
|
|
|
required: true, |
|
|
|
show: false, |
|
|
|
componentKey: Date.now(), |
|
|
|
}, |
|
|
|
{ |
|
|
|
placeholderImg: "image/applyCard/weituoshu.png", |
|
|
@@ -134,6 +136,7 @@ const personalOwnerFields = [ |
|
|
|
value: "proxyUrl", |
|
|
|
required: true, |
|
|
|
show: false, |
|
|
|
componentKey: Date.now(), |
|
|
|
}, |
|
|
|
{ |
|
|
|
underline: true, |
|
|
@@ -238,6 +241,7 @@ const enterpriseOwnerFields = [ |
|
|
|
value: "businessLicenseUrl", |
|
|
|
required: true, |
|
|
|
show: false, |
|
|
|
componentKey: Date.now(), |
|
|
|
}, |
|
|
|
{ |
|
|
|
placeholderImg: "image/applyCard/weituoshu.png", |
|
|
@@ -252,6 +256,7 @@ const enterpriseOwnerFields = [ |
|
|
|
value: "proxyUrl", |
|
|
|
required: true, |
|
|
|
show: false, |
|
|
|
componentKey: Date.now(), |
|
|
|
}, |
|
|
|
{ |
|
|
|
underline: true, |
|
|
@@ -459,6 +464,9 @@ function switchOwnerType(type: number) { |
|
|
|
const ownerInfoIndex = formData.value.findIndex(item => item.title === "车主信息"); |
|
|
|
|
|
|
|
if (ownerInfoIndex !== -1) { |
|
|
|
// 先清除当前车主信息相关数据(在移除表单项之前) |
|
|
|
clearOwnerData(type); |
|
|
|
|
|
|
|
// 移除现有的车主信息相关表单项 |
|
|
|
let removeCount = 0; |
|
|
|
for (let i = ownerInfoIndex; i < formData.value.length; i++) { |
|
|
@@ -473,19 +481,113 @@ function switchOwnerType(type: number) { |
|
|
|
// 移除旧的车主信息表单项 |
|
|
|
formData.value.splice(ownerInfoIndex, removeCount); |
|
|
|
|
|
|
|
// 根据类型添加对应的表单项 |
|
|
|
// 根据类型添加对应的表单项,并强制更新componentKey |
|
|
|
const fieldsToAdd = type === 0 ? personalOwnerFields : enterpriseOwnerFields; |
|
|
|
formData.value.splice(ownerInfoIndex, 0, ...fieldsToAdd); |
|
|
|
// 为每个图片组件生成新的componentKey |
|
|
|
const updatedFields = fieldsToAdd.map(field => { |
|
|
|
if (field.type === "14") { // 图片组件 |
|
|
|
return { ...field, componentKey: Date.now() + Math.random() }; |
|
|
|
} |
|
|
|
return field; |
|
|
|
}); |
|
|
|
formData.value.splice(ownerInfoIndex, 0, ...updatedFields); |
|
|
|
|
|
|
|
// 强制清除所有相关数据 |
|
|
|
nextTick(() => { |
|
|
|
// 清除formData中的字段 |
|
|
|
clearOwnerData(type); |
|
|
|
|
|
|
|
// 强制清除submitQuery中的数据 |
|
|
|
if (submitQuery) { |
|
|
|
// 清除所有可能的图片相关数据 |
|
|
|
submitQuery.ownerPosImgUrl = ''; |
|
|
|
submitQuery.ownerNegImgUrl = ''; |
|
|
|
submitQuery.proxyUrl = ''; |
|
|
|
submitQuery.businessLicenseUrl = ''; |
|
|
|
submitQuery.idName = ''; |
|
|
|
submitQuery.mobile = ''; |
|
|
|
submitQuery.idno = ''; |
|
|
|
submitQuery.ownerIdAddress = ''; |
|
|
|
submitQuery.companyName = ''; |
|
|
|
submitQuery.socialCreditCode = ''; |
|
|
|
submitQuery.companyAddress = ''; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
//单位订单不需要委托书,个人需要 |
|
|
|
if(orderType != "PERSONAL_USER"){ |
|
|
|
// 找到委托书的位置 |
|
|
|
const weiTuoIndex = formData.value.findIndex(item => item.title === "委托书"); |
|
|
|
formData.value.splice(weiTuoIndex,1) |
|
|
|
if (weiTuoIndex !== -1) { |
|
|
|
formData.value.splice(weiTuoIndex,1) |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(type, "type") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 清除车主信息相关数据 |
|
|
|
function clearOwnerData(type: number) { |
|
|
|
// 通用清除函数 |
|
|
|
const clearFields = (fields: string[]) => { |
|
|
|
fields.forEach(field => { |
|
|
|
const index = formData.value.findIndex(item => item.value === field); |
|
|
|
if (index !== -1) { |
|
|
|
// 清除字段值 |
|
|
|
formData.value[index][field] = ''; |
|
|
|
// 如果是图片字段,还需要清除imgUrl属性并强制重新渲染 |
|
|
|
if (field.includes('ImgUrl') || field === 'proxyUrl') { |
|
|
|
formData.value[index].imgUrl = ''; |
|
|
|
// 通过修改key来强制重新渲染组件 |
|
|
|
formData.value[index].componentKey = Date.now() + Math.random(); |
|
|
|
console.log(`清除图片字段: ${field}, 新componentKey: ${formData.value[index].componentKey}`); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
// 清除所有可能的图片字段,不管是什么类型 |
|
|
|
const allImageFields = ['userPosImgUrl', 'userNegImgUrl', 'proxyUrl', 'businessLicenseUrl']; |
|
|
|
allImageFields.forEach(field => { |
|
|
|
const index = formData.value.findIndex(item => item.value === field); |
|
|
|
if (index !== -1) { |
|
|
|
formData.value[index][field] = ''; |
|
|
|
formData.value[index].imgUrl = ''; |
|
|
|
formData.value[index].componentKey = Date.now() + Math.random(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 清除submitQuery中的相关数据 |
|
|
|
if (type === 0) { |
|
|
|
// 清除个人车主信息相关数据 |
|
|
|
const personalFields = ['userPosImgUrl', 'userNegImgUrl', 'proxyUrl', 'userName', 'mobile', 'userIdNum', 'address']; |
|
|
|
clearFields(personalFields); |
|
|
|
|
|
|
|
// 清除submitQuery中的个人相关数据 |
|
|
|
if (submitQuery) { |
|
|
|
submitQuery.ownerPosImgUrl = ''; |
|
|
|
submitQuery.ownerNegImgUrl = ''; |
|
|
|
submitQuery.proxyUrl = ''; |
|
|
|
submitQuery.idName = ''; |
|
|
|
submitQuery.mobile = ''; |
|
|
|
submitQuery.idno = ''; |
|
|
|
submitQuery.ownerIdAddress = ''; |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 清除企业车主信息相关数据 |
|
|
|
const enterpriseFields = ['businessLicenseUrl', 'proxyUrl', 'unitName', 'screditCode', 'adress']; |
|
|
|
clearFields(enterpriseFields); |
|
|
|
|
|
|
|
// 清除submitQuery中的企业相关数据 |
|
|
|
if (submitQuery) { |
|
|
|
submitQuery.businessLicenseUrl = ''; |
|
|
|
submitQuery.proxyUrl = ''; |
|
|
|
submitQuery.companyName = ''; |
|
|
|
submitQuery.socialCreditCode = ''; |
|
|
|
submitQuery.companyAddress = ''; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//有哪些字段隐藏哪些字段 |
|
|
|
function handleHide() { |
|
|
|
if (formData.value[Index("道路运输证", formData.value)]) { |