Compare commits
2 Commits
4117cbb489
...
60478327e2
| Author | SHA1 | Date | |
|---|---|---|---|
| 60478327e2 | |||
| 1d2b11bfd2 |
@@ -373,11 +373,10 @@ class GjjManifestAddViewModel : BaseViewModel() {
|
||||
return
|
||||
}
|
||||
|
||||
val params = mapOf(
|
||||
"mfId" to if (pageType.value == DetailsPageType.Modify) mfId else null,
|
||||
val isModify = pageType.value == DetailsPageType.Modify
|
||||
|
||||
val paramsMap = mutableMapOf<String, Any?>(
|
||||
"fid" to fid,
|
||||
"no" to if (pageType.value == DetailsPageType.Modify) no else null,
|
||||
"prefix" to if (pageType.value == DetailsPageType.Modify) prefix else null,
|
||||
"wbNo" to waybillNo.value,
|
||||
"agentCode" to agent.value,
|
||||
"spCode" to specialCode.value.let { if (it.isNullOrEmpty()) "NOR" else it },
|
||||
@@ -386,19 +385,30 @@ class GjjManifestAddViewModel : BaseViewModel() {
|
||||
"pc" to actualNum.value,
|
||||
"weight" to actualWeight.value,
|
||||
"cashWeight" to billingWeight.value,
|
||||
"packageType" to packageType.value,
|
||||
"origin" to departure.value,
|
||||
"dest" to destination.value,
|
||||
"goods" to goodsNameEn.value,
|
||||
"goodsCn" to goodsNameCn.value,
|
||||
"awbType" to waybillType.value,
|
||||
"cargoType" to goodsType.value,
|
||||
"unNumber" to unNumber.value,
|
||||
"remark" to remark.value,
|
||||
).toRequestBody(removeEmptyOrNull = true)
|
||||
)
|
||||
|
||||
// 可选字段:非空时才传
|
||||
if (!packageType.value.isNullOrEmpty()) paramsMap["packageType"] = packageType.value
|
||||
if (!goodsType.value.isNullOrEmpty()) paramsMap["cargoType"] = goodsType.value
|
||||
if (!unNumber.value.isNullOrEmpty()) paramsMap["unNumber"] = unNumber.value
|
||||
if (!remark.value.isNullOrEmpty()) paramsMap["remark"] = remark.value
|
||||
|
||||
// 编辑模式:必须传 mfId、no、prefix(不受空字符串过滤影响)
|
||||
if (isModify) {
|
||||
paramsMap["mfId"] = mfId
|
||||
paramsMap["no"] = no
|
||||
paramsMap["prefix"] = prefix
|
||||
}
|
||||
|
||||
val params = paramsMap.toRequestBody()
|
||||
|
||||
launchLoadingCollect({
|
||||
if (pageType.value == DetailsPageType.Modify) {
|
||||
if (isModify) {
|
||||
NetApply.api.gjjManifestUpdate(params)
|
||||
} else {
|
||||
NetApply.api.gjjManifestInsert(params)
|
||||
@@ -406,7 +416,7 @@ class GjjManifestAddViewModel : BaseViewModel() {
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (it.verifySuccess()) {
|
||||
val successMsg = if (pageType.value == DetailsPageType.Modify) "修改成功" else "保存成功"
|
||||
val successMsg = if (isModify) "修改成功" else "保存成功"
|
||||
showToast(successMsg)
|
||||
|
||||
// 发送刷新事件
|
||||
|
||||
@@ -144,20 +144,19 @@ class IntImpAccidentVisaEditViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
onSuccess = {
|
||||
dataBean.value = it.data ?: GjAccidentVisaEditBean()
|
||||
|
||||
// 渲染图片
|
||||
// 渲染图片:path 取原图 URL 确保预览清晰,url 取缩略图用于提交
|
||||
val bean = dataBean.value!!
|
||||
val picList = bean.pic.split(",")
|
||||
.filter { url -> url.isNotEmpty() }
|
||||
.map { url -> FileBean(MediaUtil.fillUrl(url), url) }
|
||||
val originalList = bean.originalPic.split(",")
|
||||
.filter { url -> url.isNotEmpty() }
|
||||
.map { url -> FileBean(MediaUtil.fillUrl(url)) }
|
||||
for ((index, fileBean) in picList.withIndex()) {
|
||||
if (index < originalList.size) {
|
||||
picList[index].originalPic = originalList[index].path
|
||||
val picList = bean.pic.split(",").filter { it.isNotEmpty() }
|
||||
val originalList = bean.originalPic.split(",").filter { it.isNotEmpty() }
|
||||
val images = picList.mapIndexed { index, picUrl ->
|
||||
val originalUrl = originalList.getOrElse(index) { picUrl }
|
||||
FileBean(
|
||||
path = MediaUtil.fillUrl(originalUrl),
|
||||
url = picUrl,
|
||||
originalPic = originalUrl
|
||||
)
|
||||
}
|
||||
}
|
||||
rv?.commonAdapter()?.loadMore(picList)
|
||||
rv?.commonAdapter()?.loadMore(images)
|
||||
|
||||
// 详情模式下无图片时显示占位提示
|
||||
if (isDetailMode.value == true && picList.isEmpty()) {
|
||||
@@ -292,8 +291,8 @@ class IntImpAccidentVisaEditViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
val list = (rv?.commonAdapter()?.items as List<FileBean>)
|
||||
.filter { it.path.isNotEmpty() }
|
||||
bean.picNumber = list.size.toString()
|
||||
bean.originalPic = list.joinToString(separator = ",") { MediaUtil.removeUrl(it.url) }
|
||||
bean.pic = list.joinToString(separator = ",") { MediaUtil.removeUrl(it.originalPic) }
|
||||
bean.pic = list.joinToString(separator = ",") { MediaUtil.removeUrl(it.url) }
|
||||
bean.originalPic = list.joinToString(separator = ",") { MediaUtil.removeUrl(it.originalPic) }
|
||||
bean.idFlag = "1"
|
||||
|
||||
if (pageType.value == DetailsPageType.Add) {
|
||||
|
||||
@@ -62,10 +62,23 @@ class GnjYiKuHandoverViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
val bean = it.data ?: GnjYiKuBean()
|
||||
dataBean.value = bean
|
||||
|
||||
// 处理图片列表(拼接完整 URL)
|
||||
val images = bean.getImageList().map { url ->
|
||||
FileBean(path = MediaUtil.fillUrl(url), url = url)
|
||||
// 处理图片列表(同时保留缩略图和原图信息,确保二次编辑时不丢失)
|
||||
val picList = bean.pic.split(",").filter { it.isNotEmpty() }
|
||||
val originalPicList = bean.originalPic.split(",").filter { it.isNotEmpty() }
|
||||
val images = if (picList.isNotEmpty()) {
|
||||
picList.mapIndexed { index, picUrl ->
|
||||
val originalUrl = originalPicList.getOrElse(index) { picUrl }
|
||||
FileBean(
|
||||
path = MediaUtil.fillUrl(originalUrl),
|
||||
url = picUrl,
|
||||
originalPic = originalUrl
|
||||
)
|
||||
}.toMutableList()
|
||||
} else {
|
||||
originalPicList.map { url ->
|
||||
FileBean(path = MediaUtil.fillUrl(url), url = url, originalPic = url)
|
||||
}.toMutableList()
|
||||
}
|
||||
|
||||
// 编辑模式添加空 FileBean 用于显示"添加照片"按钮
|
||||
if (pageType.value == DetailsPageType.Modify) {
|
||||
@@ -75,7 +88,7 @@ class GnjYiKuHandoverViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
imageList.value = images
|
||||
|
||||
// 详情模式下无图片时显示占位提示
|
||||
if (pageType.value == DetailsPageType.Details && bean.getImageList().isEmpty()) {
|
||||
if (pageType.value == DetailsPageType.Details && images.isEmpty()) {
|
||||
showNoImage.value = true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user