소스 검색

车主信息bug修改

ms
wangxyi 1 개월 전
부모
커밋
83b4d3a0ae
2개의 변경된 파일107개의 추가작업 그리고 5개의 파일을 삭제
  1. 2
    2
      components/form-builder/form-builder-vue3.vue
  2. 105
    3
      pages/drivingLicense/drivingLicense.vue

+ 2
- 2
components/form-builder/form-builder-vue3.vue 파일 보기

@@ -14,7 +14,7 @@
<!-- 是否显示-->
<view style="min-height: 90rpx" :style="item.vertical == 2 ? 'margin-top: 20rpx' : ''" :class="
item.vertical == 2 ? 'as-layout-vertical' : 'as-layout-horizontal'
" v-if="item.title != '本人办理'">
" v-if="item.title != '本人办理' && item.type != 100">
<!-- 标题 -->
<view v-if="
item.titleShow ||
@@ -201,7 +201,7 @@
</view> -->
<!-- 上传图片,证件照等 -->
<view v-if="item.type == 14" style="width: 100%">
<upload-car-img :dataList="item" @uploadImgHandle="uploadImgHandle($event, item)"
<upload-car-img :key="item.componentKey || item.id" :dataList="item" @uploadImgHandle="uploadImgHandle($event, item)"
:imgUrl='item[item.value]' />
</view>
<!-- <view v-if="item.type == 15" style="width: 100%;">

+ 105
- 3
pages/drivingLicense/drivingLicense.vue 파일 보기

@@ -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)]) {

Loading…
취소
저장