feat: visa delete/detail
This commit is contained in:
@@ -103,7 +103,11 @@
|
||||
"mcp__apifox__read_project_oas_ref_resources_kcl8s7",
|
||||
"mcp__apifox__read_project_oas_x3v6fh",
|
||||
"mcp__apifox__read_project_oas_ref_resources_x3v6fh",
|
||||
"mcp__plugin_claude-mem_mcp-search__smart_outline"
|
||||
"mcp__plugin_claude-mem_mcp-search__smart_outline",
|
||||
"Bash(find /Users/kid/Development/Fusion/Projects/aerologic-app/module_gjj/src/main -type f \\\\\\(-name *IntImpAccidentVisa* -o -name *AccidentVisa* \\\\\\))",
|
||||
"mcp__apifox__read_project_oas_g3xqex",
|
||||
"mcp__apifox__read_project_oas_ref_resources_g3xqex",
|
||||
"mcp__apifox__refresh_project_oas_g3xqex"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
|
||||
@@ -57,13 +57,21 @@ class IntImpAccidentVisaActivity :
|
||||
}
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
when (type) {
|
||||
2000 -> {
|
||||
// 侧滑菜单 - 修改
|
||||
val bean = binding.rv.commonAdapter()?.getItem(position) as? IntImpAccidentVisaBean
|
||||
?: return
|
||||
when (type) {
|
||||
1000 -> {
|
||||
// 点击列表项 - 查看详情
|
||||
IntImpAccidentVisaEditActivity.start(this, bean.id, isDetail = true)
|
||||
}
|
||||
2000 -> {
|
||||
// 侧滑菜单 - 修改
|
||||
IntImpAccidentVisaEditActivity.start(this, bean.id)
|
||||
}
|
||||
3000 -> {
|
||||
// 侧滑菜单 - 删除
|
||||
viewModel.singleDelete(bean)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,17 +34,24 @@ class IntImpAccidentVisaEditActivity :
|
||||
viewModel.initOnCreate(intent)
|
||||
|
||||
viewModel.pageType.observe(this) {
|
||||
val title = if (it == DetailsPageType.Add) "国际事故签证新增" else "国际事故签证修改"
|
||||
val title = when (it) {
|
||||
DetailsPageType.Add -> "国际事故签证新增"
|
||||
DetailsPageType.Details -> "国际事故签证详情"
|
||||
else -> "国际事故签证修改"
|
||||
}
|
||||
setBackArrow(title)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val KEY_IS_DETAIL = "is_detail"
|
||||
|
||||
@JvmStatic
|
||||
fun start(context: Context, id: Long = 0) {
|
||||
fun start(context: Context, id: Long = 0, isDetail: Boolean = false) {
|
||||
context.startActivity(
|
||||
Intent(context, IntImpAccidentVisaEditActivity::class.java)
|
||||
.putExtra(Constant.Key.ID, id)
|
||||
.putExtra(KEY_IS_DETAIL, isDetail)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,21 @@ class IntImpAccidentVisaViewHolder(view: View) :
|
||||
binding.executePendingBindings()
|
||||
}
|
||||
|
||||
// 点击列表项 - 进入详情
|
||||
binding.ll.setOnClickListener {
|
||||
clickListener?.onItemClick(position, 1000) // type=1000表示查看详情
|
||||
}
|
||||
|
||||
// 侧滑菜单 - 修改按钮
|
||||
binding.btnEdit.setOnClickListener {
|
||||
binding.swipeMenu.quickClose()
|
||||
clickListener?.onItemClick(position, 2000) // type=2000表示修改操作
|
||||
}
|
||||
|
||||
// 侧滑菜单 - 删除按钮
|
||||
binding.btnDelete.setOnClickListener {
|
||||
binding.swipeMenu.quickClose()
|
||||
clickListener?.onItemClick(position, 3000) // type=3000表示删除操作
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,9 +69,19 @@ class IntImpAccidentVisaEditViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
// 初始化
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 是否为详情模式(只读)
|
||||
val isDetailMode = MutableLiveData(false)
|
||||
|
||||
fun initOnCreate(intent: Intent) {
|
||||
id = intent.getLongExtra(Constant.Key.ID, 0)
|
||||
pageType.value = if (id == 0L) DetailsPageType.Add else DetailsPageType.Modify
|
||||
val isDetail = intent.getBooleanExtra("is_detail", false)
|
||||
|
||||
pageType.value = when {
|
||||
isDetail && id != 0L -> DetailsPageType.Details
|
||||
id == 0L -> DetailsPageType.Add
|
||||
else -> DetailsPageType.Modify
|
||||
}
|
||||
isDetailMode.value = pageType.value == DetailsPageType.Details
|
||||
|
||||
// 新增模式下默认航班日期为今天
|
||||
if (pageType.value == DetailsPageType.Add) {
|
||||
@@ -86,10 +96,13 @@ class IntImpAccidentVisaEditViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
loadDetail()
|
||||
}
|
||||
|
||||
// 详情模式不添加空白占位图片
|
||||
if (!isDetail) {
|
||||
rv?.post {
|
||||
rv?.commonAdapter()?.addItem(FileBean())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadDropdownLists() {
|
||||
launchCollect({ NetApply.api.getPackTypeList() }) {
|
||||
@@ -263,6 +276,9 @@ class IntImpAccidentVisaEditViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
// 详情模式下不允许长按删除操作
|
||||
if (isDetailMode.value == true) return
|
||||
|
||||
val adapter = rv!!.commonAdapter()!!
|
||||
val bean = adapter.getItem(position) as FileBean
|
||||
when (type) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.ConfirmDialogModel
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
@@ -146,7 +147,25 @@ class IntImpAccidentVisaViewModel : BasePageViewModel() {
|
||||
showToast("请选择要删除的数据")
|
||||
return
|
||||
}
|
||||
launchLoadingCollect({ NetApply.api.deleteIntImpAccidentVisa(selected.toRequestBody()) }) {
|
||||
ConfirmDialogModel(
|
||||
message = "确定要删除选中的 ${selected.size} 条数据吗?",
|
||||
title = "提示"
|
||||
) {
|
||||
doDelete(selected)
|
||||
}.show()
|
||||
}
|
||||
|
||||
fun singleDelete(bean: IntImpAccidentVisaBean) {
|
||||
ConfirmDialogModel(
|
||||
message = "确定要删除运单号 ${bean.wbNo} 的事故签证吗?",
|
||||
title = "提示"
|
||||
) {
|
||||
doDelete(listOf(bean))
|
||||
}.show()
|
||||
}
|
||||
|
||||
private fun doDelete(list: List<IntImpAccidentVisaBean>) {
|
||||
launchLoadingCollect({ NetApply.api.deleteIntImpAccidentVisa(list.toRequestBody()) }) {
|
||||
onSuccess = {
|
||||
showToast("删除成功")
|
||||
viewModelScope.launch {
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
<data>
|
||||
|
||||
<import type="android.view.View" />
|
||||
|
||||
<import type="com.lukouguoji.module_base.ui.weight.data.layout.DataLayoutType" />
|
||||
|
||||
<import type="com.lukouguoji.module_base.common.DetailsPageType" />
|
||||
@@ -50,7 +52,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
enable="@{true}"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请选择航班日期"}'
|
||||
setRefreshCallBack="@{viewModel::onFlightDateInputComplete}"
|
||||
title='@{"航班日期"}'
|
||||
@@ -63,7 +65,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
enable="@{true}"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请输入航班号"}'
|
||||
setRefreshCallBack="@{viewModel::onFlightNoInputComplete}"
|
||||
title='@{"航班号"}'
|
||||
@@ -116,7 +118,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
enable="@{true}"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请输入运单号"}'
|
||||
title='@{"运单号"}'
|
||||
titleLength="@{6}"
|
||||
@@ -127,7 +129,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
enable="@{true}"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请输入不正常件数"}'
|
||||
title='@{"不正常件数"}'
|
||||
titleLength="@{6}"
|
||||
@@ -147,7 +149,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
enable="@{true}"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请输入运单总件数"}'
|
||||
title='@{"运单总件数"}'
|
||||
titleLength="@{6}"
|
||||
@@ -158,7 +160,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
enable="@{true}"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请输入运单总重量"}'
|
||||
title='@{"运单总重量"}'
|
||||
titleLength="@{6}"
|
||||
@@ -178,7 +180,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
enable="@{true}"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请输入复称重量"}'
|
||||
title='@{"复称重量"}'
|
||||
titleLength="@{6}"
|
||||
@@ -189,7 +191,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
enable="@{true}"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请输入品名"}'
|
||||
title='@{"品名"}'
|
||||
titleLength="@{6}"
|
||||
@@ -209,6 +211,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请选择外包装"}'
|
||||
list="@{viewModel.outerPackageList}"
|
||||
title='@{"外包装"}'
|
||||
@@ -220,6 +223,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请选择破损情况"}'
|
||||
list="@{viewModel.damageTypeList}"
|
||||
title='@{"包装破损情况"}'
|
||||
@@ -240,6 +244,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请选择内容物情况"}'
|
||||
list="@{viewModel.contentTypeList}"
|
||||
title='@{"内容物情况"}'
|
||||
@@ -251,6 +256,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请选择不正常类型"}'
|
||||
list="@{viewModel.unusualTypeList}"
|
||||
title='@{"不正常类型"}'
|
||||
@@ -271,7 +277,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
enable="@{true}"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请选择发现时间"}'
|
||||
title='@{"发现时间"}'
|
||||
titleLength="@{6}"
|
||||
@@ -282,6 +288,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请选择"}'
|
||||
list="@{viewModel.photoList}"
|
||||
title='@{"图片是否留底"}'
|
||||
@@ -301,7 +308,7 @@
|
||||
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
enable="@{true}"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请输入备注"}'
|
||||
inputHeight="@{80}"
|
||||
title='@{"备注"}'
|
||||
@@ -313,12 +320,13 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 上传图像区域 -->
|
||||
<!-- 图像区域标题(详情模式无图片时隐藏) -->
|
||||
<TextView
|
||||
android:id="@+id/tv_image_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:text="上传图像"
|
||||
android:text='@{viewModel.isDetailMode ? "图片" : "上传图像"}'
|
||||
android:textColor="@color/text_normal"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
@@ -334,14 +342,15 @@
|
||||
app:spanCount="4"
|
||||
tools:listitem="@layout/item_image_select" />
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<!-- 底部按钮(详情模式隐藏) -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="horizontal"
|
||||
android:visibility="@{viewModel.isDetailMode ? View.GONE : View.VISIBLE}">
|
||||
|
||||
<TextView
|
||||
style="@style/tv_bottom_btn"
|
||||
|
||||
@@ -317,6 +317,13 @@
|
||||
android:background="@color/colorPrimary"
|
||||
android:text="修改" />
|
||||
|
||||
<!-- 删除按钮 -->
|
||||
<TextView
|
||||
android:id="@+id/btn_delete"
|
||||
style="@style/tv_item_action"
|
||||
android:background="@color/red"
|
||||
android:text="删除" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</com.mcxtzhang.swipemenulib.SwipeMenuLayout>
|
||||
|
||||
Reference in New Issue
Block a user