feat: 国内进港移库 ui
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package com.lukouguoji.gnj.page.yiku.details
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gnj.R
|
||||
import com.lukouguoji.gnj.databinding.ActivityGnjYikuDetailsBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
/**
|
||||
* 国内进港移库详情页
|
||||
*/
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GNJ_YIKU_DETAILS)
|
||||
class GnjYiKuDetailsActivity :
|
||||
BaseBindingActivity<ActivityGnjYikuDetailsBinding, GnjYiKuDetailsViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gnj_yiku_details
|
||||
|
||||
override fun viewModelClass() = GnjYiKuDetailsViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内进港移库记录")
|
||||
|
||||
viewModel.initOnCreated(intent)
|
||||
binding.viewModel = viewModel
|
||||
|
||||
// 监听图片列表变化并更新adapter
|
||||
viewModel.imageList.observe(this) { images ->
|
||||
binding.rvImages.commonAdapter()?.refresh(images)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, id: String) {
|
||||
val starter = Intent(context, GnjYiKuDetailsActivity::class.java)
|
||||
.putExtra(Constant.Key.ID, id)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.lukouguoji.gnj.page.yiku.details
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gnj.R
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.FileBean
|
||||
import com.lukouguoji.module_base.bean.GnjYiKuBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.impl.ImageSelectViewHolder
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
|
||||
/**
|
||||
* 国内进港移库详情 ViewModel
|
||||
*/
|
||||
class GnjYiKuDetailsViewModel : BaseViewModel() {
|
||||
|
||||
var id = ""
|
||||
|
||||
val dataBean = MutableLiveData<GnjYiKuBean>()
|
||||
|
||||
// 图片列表
|
||||
val imageList = MutableLiveData<MutableList<FileBean>>(mutableListOf())
|
||||
|
||||
// 图片适配器配置
|
||||
val imageItemLayoutId = R.layout.item_image_select
|
||||
val imageItemViewHolder = ImageSelectViewHolder::class.java
|
||||
|
||||
fun initOnCreated(intent: Intent) {
|
||||
id = intent.getStringExtra(Constant.Key.ID) ?: ""
|
||||
getData()
|
||||
}
|
||||
|
||||
private fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGnjYiKuDetails(id)
|
||||
}) {
|
||||
onSuccess = {
|
||||
val bean = it.data ?: GnjYiKuBean()
|
||||
dataBean.value = bean
|
||||
|
||||
// 处理图片列表
|
||||
val images = bean.getImageList().map { url ->
|
||||
FileBean(path = url)
|
||||
}
|
||||
imageList.value = images.toMutableList()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.lukouguoji.gnj.page.yiku.edit
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gnj.R
|
||||
import com.lukouguoji.gnj.databinding.ActivityGnjYikuEditBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.DetailsPageType
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
/**
|
||||
* 国内进港移库编辑页
|
||||
*/
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GNJ_YIKU_EDIT)
|
||||
class GnjYiKuEditActivity :
|
||||
BaseBindingActivity<ActivityGnjYikuEditBinding, GnjYiKuEditViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gnj_yiku_edit
|
||||
|
||||
override fun viewModelClass() = GnjYiKuEditViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
viewModel.initOnCreated(intent)
|
||||
|
||||
// 根据页面类型设置标题
|
||||
when (viewModel.pageType.value) {
|
||||
DetailsPageType.Add -> setBackArrow("国内进港移库新增")
|
||||
DetailsPageType.Modify -> setBackArrow("国内进港移库编辑")
|
||||
DetailsPageType.Details -> setBackArrow("国内进港移库详情")
|
||||
}
|
||||
|
||||
binding.viewModel = viewModel
|
||||
|
||||
// 绑定图片列表点击事件
|
||||
binding.rvImages.addOnItemClickListener(viewModel)
|
||||
|
||||
// 监听图片列表变化并更新adapter
|
||||
viewModel.imageList.observe(this) { images ->
|
||||
binding.rvImages.commonAdapter()?.refresh(images)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun startForAdd(context: Context) {
|
||||
val starter = Intent(context, GnjYiKuEditActivity::class.java)
|
||||
.putExtra(Constant.Key.PAGE_TYPE, DetailsPageType.Add.name)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun startForEdit(context: Context, id: String) {
|
||||
val starter = Intent(context, GnjYiKuEditActivity::class.java)
|
||||
.putExtra(Constant.Key.PAGE_TYPE, DetailsPageType.Modify.name)
|
||||
.putExtra(Constant.Key.ID, id)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun startForDetails(context: Context, id: String) {
|
||||
val starter = Intent(context, GnjYiKuEditActivity::class.java)
|
||||
.putExtra(Constant.Key.PAGE_TYPE, DetailsPageType.Details.name)
|
||||
.putExtra(Constant.Key.ID, id)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.lukouguoji.gnj.page.yiku.edit
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.gnj.R
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.FileBean
|
||||
import com.lukouguoji.module_base.bean.GnjYiKuBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.common.DetailsPageType
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.impl.ImageSelectViewHolder
|
||||
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
|
||||
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.UploadUtil
|
||||
import dev.utils.app.info.KeyValue
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* 国内进港移库编辑 ViewModel
|
||||
*/
|
||||
class GnjYiKuEditViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
|
||||
val pageType = MutableLiveData(DetailsPageType.Add)
|
||||
var id = ""
|
||||
|
||||
val dataBean = MutableLiveData(GnjYiKuBean())
|
||||
|
||||
// 运单类型下拉列表
|
||||
val waybillTypeList = MutableLiveData(
|
||||
listOf(
|
||||
KeyValue("转国际进港", "CIII"),
|
||||
KeyValue("转国内出港", "CICO"),
|
||||
KeyValue("转国际出港", "CIIO"),
|
||||
)
|
||||
)
|
||||
|
||||
// 图片列表(初始添加一个空的FileBean用于显示"添加图片"按钮)
|
||||
val imageList = MutableLiveData<MutableList<FileBean>>(
|
||||
mutableListOf(FileBean())
|
||||
)
|
||||
|
||||
// 图片适配器配置
|
||||
val imageItemLayoutId = R.layout.item_image_select
|
||||
val imageItemViewHolder = ImageSelectViewHolder::class.java
|
||||
|
||||
fun initOnCreated(intent: Intent) {
|
||||
// 获取页面类型
|
||||
pageType.value = DetailsPageType.valueOf(
|
||||
intent.getStringExtra(Constant.Key.PAGE_TYPE) ?: DetailsPageType.Add.name
|
||||
)
|
||||
|
||||
// 如果是编辑或详情,加载数据
|
||||
if (pageType.value != DetailsPageType.Add) {
|
||||
id = intent.getStringExtra(Constant.Key.ID) ?: ""
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGnjYiKuDetails(id)
|
||||
}) {
|
||||
onSuccess = {
|
||||
val bean = it.data ?: GnjYiKuBean()
|
||||
dataBean.value = bean
|
||||
|
||||
// 处理图片列表
|
||||
val images = bean.getImageList().map { url ->
|
||||
FileBean(path = url)
|
||||
}.toMutableList()
|
||||
|
||||
// 如果是编辑模式,添加一个空的FileBean用于添加新图片
|
||||
if (pageType.value == DetailsPageType.Modify) {
|
||||
images.add(FileBean())
|
||||
}
|
||||
|
||||
imageList.value = images
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交保存
|
||||
*/
|
||||
fun submit() {
|
||||
val bean = dataBean.value ?: return
|
||||
|
||||
// 验证必填项
|
||||
if (bean.wbNo.verifyNullOrEmpty("请输入运单号")) return
|
||||
if (bean.pc.verifyNullOrEmpty("请输入件数")) return
|
||||
if (bean.weight.verifyNullOrEmpty("请输入重量")) return
|
||||
|
||||
// 获取所有非空图片
|
||||
val images = imageList.value!!.filter { it.path.isNotEmpty() }
|
||||
|
||||
// 检查图片数量限制(最多7张)
|
||||
if (images.size > 7) {
|
||||
showToast("最多上传7张图片")
|
||||
return
|
||||
}
|
||||
|
||||
launchLoadingCollect({
|
||||
// 1. 上传图片
|
||||
val uploadedUrls = mutableListOf<String>()
|
||||
images.forEach { fileBean ->
|
||||
// 判断是否为已上传的图片(在线URL)
|
||||
if (fileBean.path.startsWith("http")) {
|
||||
uploadedUrls.add(fileBean.path)
|
||||
} else {
|
||||
// 本地图片需要上传
|
||||
val result = UploadUtil.upload(fileBean.path)
|
||||
if (result.verifySuccess()) {
|
||||
uploadedUrls.add(result.data?.newName ?: "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
||||
NetApply.api.saveGnjYiKu(params)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(if (pageType.value == DetailsPageType.Add) "新增成功" else "保存成功")
|
||||
|
||||
// 发送刷新事件
|
||||
viewModelScope.launch {
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH_GNJ_YIKU_LIST).emit("refresh")
|
||||
}
|
||||
|
||||
// 关闭页面
|
||||
getTopActivity().finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理图片删除点击事件
|
||||
*/
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
val list = imageList.value!!
|
||||
if (type == R.id.iv_delete && position < list.size) {
|
||||
list.removeAt(position)
|
||||
imageList.value = list
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.lukouguoji.gnj.page.yiku.list
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gnj.R
|
||||
import com.lukouguoji.gnj.databinding.ActivityGnjYikuListBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.impl.observe
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
/**
|
||||
* 国内进港移库列表页
|
||||
*/
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GNJ_YIKU_LIST)
|
||||
class GnjYiKuListActivity :
|
||||
BaseBindingActivity<ActivityGnjYikuListBinding, GnjYiKuListViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gnj_yiku_list
|
||||
|
||||
override fun viewModelClass() = GnjYiKuListViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内进港移库")
|
||||
|
||||
binding.viewModel = viewModel
|
||||
|
||||
// 绑定分页逻辑
|
||||
viewModel.pageModel
|
||||
.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, getLifecycleOwner())
|
||||
|
||||
// 监听刷新事件
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH_GNJ_YIKU_LIST)
|
||||
.observe(this) {
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
// 初始加载
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GnjYiKuListActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.lukouguoji.gnj.page.yiku.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnj.databinding.ItemGnjYikuListBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GnjYiKuBean
|
||||
|
||||
/**
|
||||
* 国内进港移库列表 ViewHolder
|
||||
*/
|
||||
class GnjYiKuListViewHolder(view: View) :
|
||||
BaseViewHolder<GnjYiKuBean, ItemGnjYikuListBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean
|
||||
|
||||
// 点击checkbox切换选中状态
|
||||
binding.ivIcon.setOnClickListener {
|
||||
bean.checked.set(!bean.checked.get())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
package com.lukouguoji.gnj.page.yiku.list
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.lukouguoji.gnj.R
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GnjYiKuBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showConfirmDialog
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.util.CheckUtil
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import okhttp3.RequestBody
|
||||
|
||||
/**
|
||||
* 国内进港移库列表 ViewModel
|
||||
*/
|
||||
class GnjYiKuListViewModel : BasePageViewModel() {
|
||||
|
||||
// 搜索条件
|
||||
val waybillType = MutableLiveData("") // 运单类型
|
||||
val carrier = MutableLiveData("") // 承运人
|
||||
val waybillNo = MutableLiveData("") // 运单号
|
||||
val handoverStatus = MutableLiveData("") // 移交状态
|
||||
|
||||
// 运单号列表(用于多条结果选择)
|
||||
val wbNoList = MutableLiveData<List<String>>()
|
||||
|
||||
// 运单类型下拉列表
|
||||
val waybillTypeList = MutableLiveData(
|
||||
listOf(
|
||||
KeyValue("全部", ""),
|
||||
KeyValue("转国际进港", "CIII"),
|
||||
KeyValue("转国内出港", "CICO"),
|
||||
KeyValue("转国际出港", "CIIO"),
|
||||
)
|
||||
)
|
||||
|
||||
// 移交状态下拉列表
|
||||
val handoverStatusList = MutableLiveData(
|
||||
listOf(
|
||||
KeyValue("全部", ""),
|
||||
KeyValue("未移交", "0"),
|
||||
KeyValue("已移交", "1"),
|
||||
)
|
||||
)
|
||||
|
||||
// 适配器配置
|
||||
val itemViewHolder = GnjYiKuListViewHolder::class.java
|
||||
val itemLayoutId = R.layout.item_gnj_yiku_list
|
||||
|
||||
// 统计数据
|
||||
val count = MutableLiveData(0) // 总票数
|
||||
val totalPc = MutableLiveData("0") // 总件数
|
||||
val totalWeight = MutableLiveData("0") // 总重量
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 扫码输入运单号
|
||||
*/
|
||||
fun waybillScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.WAYBILL)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取运单号列表(用于扫码或输入后模糊查询)
|
||||
*/
|
||||
fun getWayBillList() {
|
||||
val requestBody = mapOf(
|
||||
"page" to pageModel.page,
|
||||
"limit" to pageModel.limit,
|
||||
"awbType" to waybillType.value!!.ifEmpty { null },
|
||||
"wbNo" to waybillNo.value!!.ifEmpty { null },
|
||||
"carrier" to carrier.value!!.ifEmpty { null },
|
||||
"handoverStatus" to handoverStatus.value!!.ifEmpty { null },
|
||||
).toRequestBody()
|
||||
|
||||
launchCollect({
|
||||
NetApply.api.getGnjMoveStashWbNoList(requestBody)
|
||||
}) {
|
||||
onSuccess = {
|
||||
val results = it.data!!
|
||||
when {
|
||||
results.size == 1 -> {
|
||||
waybillNo.value = results[0]
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
results.size > 1 -> {
|
||||
wbNoList.value = results
|
||||
showWbNoListSelect()
|
||||
}
|
||||
else -> {
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
onFailed = { i: Int, s: String ->
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表数据
|
||||
*/
|
||||
override fun getData() {
|
||||
val body = mapOf(
|
||||
"page" to pageModel.page,
|
||||
"limit" to pageModel.limit,
|
||||
"awbType" to waybillType.value!!.ifEmpty { null },
|
||||
"wbNo" to waybillNo.value!!.ifEmpty { null },
|
||||
"carrier" to carrier.value!!.ifEmpty { null },
|
||||
"handoverStatus" to handoverStatus.value!!.ifEmpty { null },
|
||||
).toRequestBody()
|
||||
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGnjMoveStashList(body)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total
|
||||
}
|
||||
}
|
||||
getCountData(body)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取统计数据
|
||||
*/
|
||||
private fun getCountData(body: RequestBody) {
|
||||
launchCollect({
|
||||
NetApply.api.simplePost("DomImpMove/searchTotal", body)
|
||||
}) {
|
||||
onSuccess = {
|
||||
totalPc.value = it.data?.totalPc.noNull("0")
|
||||
totalWeight.value = it.data?.totalWeight.noNull("0")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理扫码结果
|
||||
*/
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.WAYBILL -> {
|
||||
waybillNo.value = data.getStringExtra(Constant.Result.CODED_CONTENT)
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量移库操作
|
||||
*/
|
||||
fun moveStashClick() {
|
||||
val list = pageModel.rv!!.commonAdapter()!!.items as List<GnjYiKuBean>
|
||||
val filter = list.filter { it.checked.get() }
|
||||
if (filter.isEmpty()) {
|
||||
showToast("请选择数据")
|
||||
return
|
||||
}
|
||||
getTopActivity().showConfirmDialog("确定要移库选中的 ${filter.size} 条数据吗?") {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.transferGnjYiKu(
|
||||
mapOf(
|
||||
"fid" to "0",
|
||||
"ids" to filter.map { it.mawbId },
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("移库成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 全选/全不选
|
||||
*/
|
||||
fun checkAllClick() {
|
||||
val list = pageModel.rv!!.commonAdapter()!!.items as List<GnjYiKuBean>
|
||||
CheckUtil.handleAllCheck(list)
|
||||
}
|
||||
|
||||
/**
|
||||
* 运单号选择弹窗
|
||||
*/
|
||||
private fun showWbNoListSelect() {
|
||||
Common.singleSelect(
|
||||
DevUtils.getTopActivity(),
|
||||
"选择运单号",
|
||||
JSONArray.parseArray(wbNoList.value!!.map {
|
||||
mapOf(
|
||||
"name" to it,
|
||||
"code" to it,
|
||||
)
|
||||
}.toList().toJson(false)),
|
||||
null
|
||||
) { position, _ ->
|
||||
waybillNo.value = wbNoList.value!![position]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user