fix: 修复图片上传字段、航班查询接口及图片鉴权加载问题
- 国际进港舱单列表页航班查询接口改为 /flt/searchFlightList,支持多航班校验 - 修复国内进港移库编辑/交接页图片上传缺少 pic、picNumber 字段 - 国际进港舱单详情页对接交接图片展示 - 图片缩略图和大图预览加载带 Authorization header 解决 403 - CLAUDE.md 新增图片上传与展示规范 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import com.lukouguoji.module_base.util.MediaUtil
|
||||
import com.lukouguoji.module_base.util.UploadUtil
|
||||
import dev.utils.app.info.KeyValue
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -71,9 +72,18 @@ class GnjYiKuEditViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
val bean = it.data ?: GnjYiKuBean()
|
||||
dataBean.value = bean
|
||||
|
||||
// 处理图片列表
|
||||
val images = bean.getImageList().map { url ->
|
||||
FileBean(path = url)
|
||||
// 处理图片列表:pic=缩略图(newName),originalPic=原图(zipFileName)
|
||||
val picList = bean.pic.split(",").filter { it.isNotEmpty() }
|
||||
val originalPicList = bean.originalPic.split(",").filter { it.isNotEmpty() }
|
||||
val images = picList.mapIndexed { index, picUrl ->
|
||||
val fb = FileBean(
|
||||
path = MediaUtil.fillUrl(picUrl),
|
||||
url = picUrl
|
||||
)
|
||||
if (index < originalPicList.size) {
|
||||
fb.originalPic = MediaUtil.fillUrl(originalPicList[index])
|
||||
}
|
||||
fb
|
||||
}.toMutableList()
|
||||
|
||||
// 如果是编辑模式,添加一个空的FileBean用于添加新图片
|
||||
@@ -108,38 +118,24 @@ class GnjYiKuEditViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
|
||||
launchLoadingCollect({
|
||||
// 1. 上传图片
|
||||
val uploadedUrls = mutableListOf<String>()
|
||||
images.forEach { fileBean ->
|
||||
// 判断是否为已上传的图片(在线URL)
|
||||
if (fileBean.path.startsWith("http")) {
|
||||
uploadedUrls.add(fileBean.path)
|
||||
if (fileBean.url.isNotEmpty()) {
|
||||
// 已上传的图片,保持原有的 url 和 originalPic
|
||||
} else {
|
||||
// 本地图片需要上传
|
||||
val result = UploadUtil.upload(fileBean.path)
|
||||
if (result.verifySuccess()) {
|
||||
uploadedUrls.add(result.data?.newName ?: "")
|
||||
}
|
||||
// 本地新图片需要上传
|
||||
val data = UploadUtil.upload(fileBean.path).data
|
||||
fileBean.url = data?.newName ?: ""
|
||||
fileBean.originalPic = data?.zipFileName ?: ""
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 提交表单数据
|
||||
val params = mapOf(
|
||||
"id" to id,
|
||||
"wbNo" to bean.wbNo,
|
||||
"pc" to bean.pc,
|
||||
"weight" to bean.weight,
|
||||
"spCode" to bean.spCode,
|
||||
"agentCode" to bean.agentCode,
|
||||
"goods" to bean.goods,
|
||||
"flight" to bean.flight,
|
||||
"route" to bean.route,
|
||||
"awbType" to bean.awbType,
|
||||
"telegramNo" to bean.telegramNo,
|
||||
"remark" to bean.remark,
|
||||
"images" to uploadedUrls.joinToString(","),
|
||||
).toRequestBody(removeEmptyOrNull = true)
|
||||
// 2. 设置图片字段
|
||||
bean.picNumber = images.size.toString()
|
||||
bean.pic = images.joinToString(",") { MediaUtil.removeUrl(it.url) }
|
||||
bean.originalPic = images.joinToString(",") { MediaUtil.removeUrl(it.originalPic) }
|
||||
|
||||
NetApply.api.saveGnjYiKu(params)
|
||||
// 3. 提交表单数据
|
||||
NetApply.api.saveGnjYiKu(bean.toRequestBody())
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(if (pageType.value == DetailsPageType.Add) "新增成功" else "保存成功")
|
||||
|
||||
@@ -100,16 +100,14 @@ class GnjYiKuHandoverViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
|
||||
launchLoadingCollect({
|
||||
// 上传图片
|
||||
val uploadedUrls = mutableListOf<String>()
|
||||
images.forEach { fileBean ->
|
||||
if (fileBean.url.isNotEmpty()) {
|
||||
// 已上传的图片,直接用文件名
|
||||
uploadedUrls.add(fileBean.url)
|
||||
// 已上传的图片,保持原有的 url 和 originalPic
|
||||
} else {
|
||||
val result = UploadUtil.upload(fileBean.path)
|
||||
if (result.verifySuccess()) {
|
||||
uploadedUrls.add(result.data?.newName ?: "")
|
||||
}
|
||||
// 本地新图片需要上传
|
||||
val data = UploadUtil.upload(fileBean.path).data
|
||||
fileBean.url = data?.newName ?: ""
|
||||
fileBean.originalPic = data?.zipFileName ?: ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +115,9 @@ class GnjYiKuHandoverViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
val params = mapOf(
|
||||
"mawbId" to mawbId,
|
||||
"remark" to bean.remark,
|
||||
"originalPic" to uploadedUrls.joinToString(","),
|
||||
"picNumber" to images.size.toString(),
|
||||
"pic" to images.joinToString(",") { MediaUtil.removeUrl(it.url) },
|
||||
"originalPic" to images.joinToString(",") { MediaUtil.removeUrl(it.originalPic) },
|
||||
).toRequestBody(removeEmptyOrNull = true)
|
||||
|
||||
NetApply.api.modifyGnjMoveStash(params)
|
||||
|
||||
Reference in New Issue
Block a user