Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-boutique-work-wechat
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2fb695a7
authored
Jan 26, 2026
by
cen
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: 二手车提单优化
1 parent
9e518ed5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
154 additions
and
51 deletions
packageUsedCar/pages/evaluationForm/addEvaluationForm/addEvaluationForm.js
packageUsedCar/pages/evaluationForm/components/ThirdStep/ThirdStep.js
packageUsedCar/pages/evaluationForm/addEvaluationForm/addEvaluationForm.js
View file @
2fb695a
...
@@ -484,6 +484,12 @@ Page({
...
@@ -484,6 +484,12 @@ Page({
// 转换每个图片/视频
// 转换每个图片/视频
images
.
forEach
((
image
)
=>
{
images
.
forEach
((
image
)
=>
{
// 跳过没有 URL 或状态不是 done 的文件
if
(
!
image
.
url
||
(
image
.
status
&&
image
.
status
!==
"done"
))
{
console
.
warn
(
"跳过无效或未完成的文件:"
,
image
);
return
;
}
const
fileItem
=
{
const
fileItem
=
{
fileType
,
fileType
,
fileSubtype
,
fileSubtype
,
...
@@ -494,6 +500,10 @@ Page({
...
@@ -494,6 +500,10 @@ Page({
if
(
fileType
===
3
)
{
if
(
fileType
===
3
)
{
fileItem
.
fileFormat
=
"mp4"
;
fileItem
.
fileFormat
=
"mp4"
;
fileItem
.
fileName
=
image
.
name
||
this
.
getImageNameByKey
(
keyNum
);
fileItem
.
fileName
=
image
.
name
||
this
.
getImageNameByKey
(
keyNum
);
// 如果有封面图,也添加到提交数据中
if
(
image
.
coverUrl
)
{
fileItem
.
coverUrl
=
image
.
coverUrl
;
}
}
}
// 如果是检测报告,添加额外字段
// 如果是检测报告,添加额外字段
...
@@ -869,7 +879,11 @@ Page({
...
@@ -869,7 +879,11 @@ Page({
// 处理详情数据
// 处理详情数据
handleDetailData
(
data
,
evalOrderNo
)
{
handleDetailData
(
data
,
evalOrderNo
)
{
const
{
basic
=
{},
carInfo
=
{},
carLicense
=
{},
images
=
[]
}
=
data
;
const
{
basic
=
{},
carInfo
=
{},
carLicense
=
{},
images
}
=
data
;
// 确保 images 是数组,如果为 null 或 undefined,设置为空数组
const
imageList
=
Array
.
isArray
(
images
)
?
images
:
[];
console
.
log
(
"handleDetailData - 原始 images:"
,
images
,
"处理后:"
,
imageList
);
// 处理地区显示格式:确保是 "省份 城市" 格式
// 处理地区显示格式:确保是 "省份 城市" 格式
// 车辆所在地
// 车辆所在地
...
@@ -1072,10 +1086,16 @@ Page({
...
@@ -1072,10 +1086,16 @@ Page({
};
};
// 处理图片数据
// 处理图片数据
const
i
mageList
=
{};
const
processedI
mageList
=
{};
images
.
forEach
((
image
)
=>
{
imageList
.
forEach
((
image
)
=>
{
const
{
fileType
,
fileSubtype
,
fileUrl
}
=
image
;
const
{
fileType
,
fileSubtype
,
fileUrl
,
coverUrl
}
=
image
;
// 检查 fileUrl 是否为空
if
(
!
fileUrl
)
{
console
.
warn
(
"图片数据中 fileUrl 为空,跳过:"
,
image
);
return
;
}
// 根据 fileType 和 fileSubtype 映射到对应的 key
// 根据 fileType 和 fileSubtype 映射到对应的 key
// fileType: 1-车辆图片, 2-证件资料, 3-车辆视频, 4-其他图片, 5-车辆检测报告
// fileType: 1-车辆图片, 2-证件资料, 3-车辆视频, 4-其他图片, 5-车辆检测报告
...
@@ -1103,18 +1123,36 @@ Page({
...
@@ -1103,18 +1123,36 @@ Page({
}
}
if
(
key
)
{
if
(
key
)
{
if
(
!
imageList
[
key
])
{
if
(
!
processedImageList
[
key
])
{
imageList
[
key
]
=
[];
processedImageList
[
key
]
=
[];
}
// 根据 fileType 构造不同的数据结构
if
(
fileType
===
3
)
{
// 视频文件:需要 videoUrl、coverUrl 和 isVideo 标识
processedImageList
[
key
].
push
({
url
:
fileUrl
,
// 视频 URL
thumb
:
coverUrl
||
""
,
// 封面图(van-uploader 使用 thumb 作为预览图)
coverUrl
:
coverUrl
||
""
,
// 保存封面图 URL,用于预览
isVideo
:
true
,
name
:
this
.
getImageNameByKey
(
key
),
key
:
key
,
status
:
"done"
,
});
}
else
{
// 普通图片
processedImageList
[
key
].
push
({
url
:
fileUrl
,
isVideo
:
false
,
name
:
this
.
getImageNameByKey
(
key
),
key
:
key
,
status
:
"done"
,
});
}
}
imageList
[
key
].
push
({
url
:
fileUrl
,
name
:
this
.
getImageNameByKey
(
key
),
key
:
key
,
});
}
}
});
});
updateData
[
"formData.imageList"
]
=
i
mageList
;
updateData
[
"formData.imageList"
]
=
processedI
mageList
;
// 一次性更新所有数据
// 一次性更新所有数据
console
.
log
(
console
.
log
(
...
...
packageUsedCar/pages/evaluationForm/components/ThirdStep/ThirdStep.js
View file @
2fb695a
...
@@ -29,19 +29,37 @@ Component({
...
@@ -29,19 +29,37 @@ Component({
imageData
:
function
(
newImageData
)
{
imageData
:
function
(
newImageData
)
{
// 监听 imageData 变化,重新初始化图片列表
// 监听 imageData 变化,重新初始化图片列表
console
.
log
(
"imageData 变化:"
,
newImageData
);
console
.
log
(
"imageData 变化:"
,
newImageData
);
if
(
newImageData
&&
Object
.
keys
(
newImageData
).
length
>
0
)
{
// 处理回显数据:确保所有文件都有 status 字段和 isVideo 字段
// 如果 newImageData 为 null 或 undefined,设置为空对象
const
processedImageList
=
{};
if
(
!
newImageData
)
{
const
{
uploadVideoFields
}
=
this
.
data
;
this
.
setData
({
// 获取所有视频字段的 key 集合
imageList
:
{},
const
videoKeys
=
new
Set
(
});
uploadVideoFields
.
map
((
field
)
=>
String
(
field
.
key
))
return
;
);
}
for
(
const
key
in
newImageData
)
{
// 处理回显数据:确保所有文件都有 status 字段和 isVideo 字段
const
fileList
=
newImageData
[
key
];
const
processedImageList
=
{};
if
(
Array
.
isArray
(
fileList
))
{
const
{
uploadVideoFields
}
=
this
.
data
;
processedImageList
[
key
]
=
fileList
.
map
((
file
)
=>
{
// 获取所有视频字段的 key 集合
const
videoKeys
=
new
Set
(
uploadVideoFields
.
map
((
field
)
=>
String
(
field
.
key
))
);
for
(
const
key
in
newImageData
)
{
const
fileList
=
newImageData
[
key
];
if
(
Array
.
isArray
(
fileList
)
&&
fileList
.
length
>
0
)
{
// 过滤掉 url 为空的文件,并处理每个文件
processedImageList
[
key
]
=
fileList
.
filter
((
file
)
=>
{
// 过滤掉没有 url 的文件
if
(
!
file
||
!
file
.
url
)
{
console
.
warn
(
"过滤掉无效文件(url 为空):"
,
file
);
return
false
;
}
return
true
;
})
.
map
((
file
)
=>
{
const
processedFile
=
{
...
file
};
const
processedFile
=
{
...
file
};
// 如果文件没有 status 字段,说明是编辑回显的数据,设置为 'done'
// 如果文件没有 status 字段,说明是编辑回显的数据,设置为 'done'
if
(
!
processedFile
.
status
)
{
if
(
!
processedFile
.
status
)
{
...
@@ -71,15 +89,18 @@ Component({
...
@@ -71,15 +89,18 @@ Component({
}
}
return
processedFile
;
return
processedFile
;
});
});
}
else
{
processedImageList
[
key
]
=
fileList
;
// 如果过滤后数组为空,不添加到 processedImageList
if
(
processedImageList
[
key
].
length
===
0
)
{
delete
processedImageList
[
key
];
}
}
}
}
this
.
setData
({
imageList
:
processedImageList
,
});
console
.
log
(
"已更新 imageList:"
,
this
.
data
.
imageList
);
}
}
this
.
setData
({
imageList
:
processedImageList
,
});
console
.
log
(
"已更新 imageList:"
,
this
.
data
.
imageList
);
},
},
},
},
...
@@ -170,18 +191,36 @@ Component({
...
@@ -170,18 +191,36 @@ Component({
// 初始化图片列表
// 初始化图片列表
initImageList
()
{
initImageList
()
{
const
{
imageData
,
uploadVideoFields
}
=
this
.
data
;
const
{
imageData
,
uploadVideoFields
}
=
this
.
data
;
if
(
imageData
&&
Object
.
keys
(
imageData
).
length
>
0
)
{
// 处理回显数据:确保所有文件都有 status 字段和 isVideo 字段
// 如果 imageData 为空,设置为空对象
const
processedImageList
=
{};
if
(
!
imageData
||
Object
.
keys
(
imageData
).
length
===
0
)
{
// 获取所有视频字段的 key 集合
this
.
setData
({
const
videoKeys
=
new
Set
(
imageList
:
{},
uploadVideoFields
.
map
((
field
)
=>
String
(
field
.
key
))
});
);
return
;
}
for
(
const
key
in
imageData
)
{
const
fileList
=
imageData
[
key
];
// 处理回显数据:确保所有文件都有 status 字段和 isVideo 字段
if
(
Array
.
isArray
(
fileList
))
{
const
processedImageList
=
{};
processedImageList
[
key
]
=
fileList
.
map
((
file
)
=>
{
// 获取所有视频字段的 key 集合
const
videoKeys
=
new
Set
(
uploadVideoFields
.
map
((
field
)
=>
String
(
field
.
key
))
);
for
(
const
key
in
imageData
)
{
const
fileList
=
imageData
[
key
];
if
(
Array
.
isArray
(
fileList
)
&&
fileList
.
length
>
0
)
{
// 过滤掉 url 为空的文件,并处理每个文件
processedImageList
[
key
]
=
fileList
.
filter
((
file
)
=>
{
// 过滤掉没有 url 的文件
if
(
!
file
||
!
file
.
url
)
{
console
.
warn
(
"initImageList - 过滤掉无效文件(url 为空):"
,
file
);
return
false
;
}
return
true
;
})
.
map
((
file
)
=>
{
const
processedFile
=
{
...
file
};
const
processedFile
=
{
...
file
};
// 如果文件没有 status 字段,说明是编辑回显的数据,设置为 'done'
// 如果文件没有 status 字段,说明是编辑回显的数据,设置为 'done'
if
(
!
processedFile
.
status
)
{
if
(
!
processedFile
.
status
)
{
...
@@ -211,14 +250,17 @@ Component({
...
@@ -211,14 +250,17 @@ Component({
}
}
return
processedFile
;
return
processedFile
;
});
});
}
else
{
processedImageList
[
key
]
=
fileList
;
// 如果过滤后数组为空,不添加到 processedImageList
if
(
processedImageList
[
key
].
length
===
0
)
{
delete
processedImageList
[
key
];
}
}
}
}
this
.
setData
({
imageList
:
processedImageList
,
});
}
}
this
.
setData
({
imageList
:
processedImageList
,
});
},
},
// 处理上传
// 处理上传
...
@@ -836,13 +878,36 @@ Component({
...
@@ -836,13 +878,36 @@ Component({
// 校验必填项
// 校验必填项
validate
()
{
validate
()
{
const
{
imageList
,
uploadFields
}
=
this
.
data
;
const
{
imageList
,
uploadFields
,
uploadCertificateFields
,
uploadVideoFields
,
uploadReportFields
,
uploadOtherFields
}
=
this
.
data
;
// 合并所有字段
const
allFields
=
[
...
uploadFields
,
...
uploadCertificateFields
,
...
uploadVideoFields
,
...
uploadReportFields
,
...
uploadOtherFields
,
];
// 1. 检查是否有正在上传的文件
for
(
let
field
of
allFields
)
{
const
list
=
imageList
[
field
.
key
]
||
[];
const
uploadingFiles
=
list
.
filter
(
file
=>
file
.
status
===
'uploading'
);
if
(
uploadingFiles
.
length
>
0
)
{
return
{
message
:
`
${
field
.
label
}
正在上传中,请稍候...`
,
};
}
}
//
检查必填的车辆图片
//
2. 检查必填的车辆图片(只检查状态为 done 的文件)
for
(
let
field
of
uploadFields
)
{
for
(
let
field
of
uploadFields
)
{
if
(
field
.
required
)
{
if
(
field
.
required
)
{
console
.
log
(
imageList
[
field
.
key
],
'imageList[field.key]'
);
const
list
=
imageList
[
field
.
key
]
||
[];
const
list
=
imageList
[
field
.
key
]
||
[];
if
(
list
.
length
===
0
)
{
// 只统计上传完成的文件
const
doneFiles
=
list
.
filter
(
file
=>
!
file
.
status
||
file
.
status
===
'done'
);
if
(
doneFiles
.
length
===
0
)
{
return
{
return
{
message
:
`请上传
${
field
.
label
}
`
,
message
:
`请上传
${
field
.
label
}
`
,
};
};
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment