|
@@ -7,6 +7,7 @@ import android.view.ViewGroup
|
|
|
import android.widget.CheckedTextView
|
|
|
import android.widget.PopupWindow
|
|
|
import android.widget.TextView
|
|
|
+import androidx.core.content.res.ResourcesCompat
|
|
|
import androidx.recyclerview.widget.ConcatAdapter
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
|
@@ -81,6 +82,11 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
|
|
|
//2024-04-28 新增OP费用录入详情审核通过后无法再进行修改
|
|
|
private var isAuditGM = -1
|
|
|
|
|
|
+ //2024-04-29 优化地接费用录入存在的卡顿问题
|
|
|
+ private var showItemList = ArrayList<GroundConveyTableItem>()
|
|
|
+
|
|
|
+ private var itemMaxId = 0
|
|
|
+
|
|
|
override fun getViewBinding() = ActivityGroundConveyPaymentDetailBinding.inflate(layoutInflater)
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
@@ -173,16 +179,6 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
|
|
|
updateGroundConveyDetailRequest.payDId = paymentWayId
|
|
|
}
|
|
|
|
|
|
- updateGroundConveyDetailRequest.opContentList = carTouristGuides
|
|
|
-
|
|
|
- val selectCheck = ArrayList<String>()
|
|
|
-
|
|
|
- for (item in checkedItemId) {
|
|
|
- selectCheck.add(item.toString())
|
|
|
- }
|
|
|
-
|
|
|
- updateGroundConveyDetailRequest.selectCheck = selectCheck
|
|
|
-
|
|
|
updateGroundConveyDetail()
|
|
|
|
|
|
}
|
|
@@ -209,6 +205,9 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
|
|
|
}
|
|
|
|
|
|
for (item in resourceResponse.data.carTouristGuides) {
|
|
|
+ if (itemMaxId < item.id) {
|
|
|
+ itemMaxId = item.id
|
|
|
+ }
|
|
|
carTouristGuides.add(item)
|
|
|
}
|
|
|
|
|
@@ -228,15 +227,21 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for (item in carTouristGuides) {
|
|
|
+ for ((i, item) in carTouristGuides.withIndex()) {
|
|
|
+
|
|
|
+ if (item.id == 0) {
|
|
|
+ carTouristGuides[i].id = itemMaxId + i
|
|
|
+ carTouristGuides[i].isNew = true
|
|
|
+ }
|
|
|
+
|
|
|
for (checkedItem in checkedItemId) {
|
|
|
if (item.sId == checkedItem) {
|
|
|
totalPrice += item.price * item.count
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!checkedItemId.contains(item.sId)) {
|
|
|
- item.isVisible = false
|
|
|
+ if (checkedItemId.contains(item.sId)) {
|
|
|
+ showItemList.add(item)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -343,12 +348,18 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
|
|
|
setData(currencyList)
|
|
|
setLayoutId(R.layout.item_selector)
|
|
|
addBindView { itemView, data ->
|
|
|
- itemView.findViewById<TextView>(R.id.selector_item_name).text =
|
|
|
- String.format(
|
|
|
- resources.getString(R.string.currency_name_code_format),
|
|
|
- data.currencyName,
|
|
|
- data.currencyCode
|
|
|
- )
|
|
|
+ itemView.findViewById<TextView>(R.id.selector_item_name).apply {
|
|
|
+ text =
|
|
|
+ String.format(
|
|
|
+ resources.getString(R.string.currency_name_code_format),
|
|
|
+ data.currencyName,
|
|
|
+ data.currencyCode
|
|
|
+ )
|
|
|
+
|
|
|
+ if (currencyId == data.currencyId) {
|
|
|
+ setTextColor(ResourcesCompat.getColor(resources, R.color.text_color_blue, null))
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}.create()
|
|
|
|
|
@@ -367,12 +378,12 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
|
|
|
currencyId = currencyList[position].currencyId
|
|
|
currencySelect = true
|
|
|
|
|
|
- popupWindow.dismiss()
|
|
|
-
|
|
|
for ((i, item) in carTouristGuides.withIndex()) {
|
|
|
item.currencyStr = headerAdapter.getCurrencyCode()
|
|
|
binding.paymentList.adapter!!.notifyItemChanged(i)
|
|
|
}
|
|
|
+
|
|
|
+ popupWindow.dismiss()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -417,23 +428,38 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
|
|
|
|
|
|
for ((i, item) in carTouristGuides.withIndex()) {
|
|
|
if (item.sId == id) {
|
|
|
- carTouristGuides[i].isVisible = false
|
|
|
totalPrice -= carTouristGuides[i].price * carTouristGuides[i].count
|
|
|
- adapter.notifyItemChanged(i)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ for ((i, item) in showItemList.withIndex()) {
|
|
|
+ if (item.sId == id) {
|
|
|
+ adapter.notifyItemRemoved(i)
|
|
|
+ adapter.notifyItemRangeChanged(i, showItemList.size)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ showItemList.removeIf { item ->
|
|
|
+ item.sId == id
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
isChecked = true
|
|
|
checkedItemId.add(id)
|
|
|
|
|
|
+ showItemList.clear()
|
|
|
+
|
|
|
for ((i, item) in carTouristGuides.withIndex()) {
|
|
|
if (item.sId == id) {
|
|
|
- carTouristGuides[i].isVisible = true
|
|
|
totalPrice += carTouristGuides[i].price * carTouristGuides[i].count
|
|
|
- adapter.notifyItemChanged(i)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (checkedItemId.contains(id)) {
|
|
|
+ showItemList.add(item)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ adapter.notifyItemRangeChanged(0, showItemList.size)
|
|
|
}
|
|
|
|
|
|
binding.paymentTotal.text = String.format(
|
|
@@ -456,7 +482,7 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- adapter = GroundConveyTableAdapter(carTouristGuides)
|
|
|
+ adapter = GroundConveyTableAdapter(showItemList)
|
|
|
adapter.setCanBeEdit(canBeEdit())
|
|
|
adapter.setHasStableIds(true)
|
|
|
|
|
@@ -464,39 +490,53 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
|
|
|
object : GroundConveyTableAdapter.OnItemTextChanged {
|
|
|
override fun onPriceTextChanged(position: Int) {
|
|
|
|
|
|
- carTouristGuides[position].apply {
|
|
|
- prePrice = price * count
|
|
|
- price = adapter.price
|
|
|
- }
|
|
|
+ for (item in carTouristGuides) {
|
|
|
+ if (showItemList[position].id == item.id) {
|
|
|
+ item.apply {
|
|
|
+ prePrice = price * count
|
|
|
+ price = adapter.price
|
|
|
+ }
|
|
|
|
|
|
- totalPrice =
|
|
|
- totalPrice - carTouristGuides[position].prePrice + carTouristGuides[position].price * carTouristGuides[position].count
|
|
|
+ totalPrice =
|
|
|
+ totalPrice - item.prePrice + item.price * item.count
|
|
|
|
|
|
- binding.paymentTotal.text = String.format(
|
|
|
- resources.getString(R.string.price_and_currency_format),
|
|
|
- totalPrice,
|
|
|
- headerAdapter.getCurrencyCode()
|
|
|
- )
|
|
|
+ binding.paymentTotal.text = String.format(
|
|
|
+ resources.getString(R.string.price_and_currency_format),
|
|
|
+ totalPrice,
|
|
|
+ headerAdapter.getCurrencyCode()
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
override fun onPriceContentChanged(position: Int) {
|
|
|
- carTouristGuides[position].priceContent = adapter.priceContentText
|
|
|
+
|
|
|
+ for (item in carTouristGuides) {
|
|
|
+ if (showItemList[position].id == item.id) {
|
|
|
+ item.priceContent = adapter.priceContentText
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
override fun onCountChanged(position: Int) {
|
|
|
- carTouristGuides[position].apply {
|
|
|
- prePrice = price * count
|
|
|
- count = adapter.count.toInt()
|
|
|
- }
|
|
|
|
|
|
- totalPrice =
|
|
|
- totalPrice - carTouristGuides[position].prePrice + carTouristGuides[position].price * carTouristGuides[position].count
|
|
|
+ for (item in carTouristGuides) {
|
|
|
+ if (showItemList[position].id == item.id) {
|
|
|
+ item.apply {
|
|
|
+ prePrice = price * count
|
|
|
+ count = adapter.count.toInt()
|
|
|
+ }
|
|
|
+
|
|
|
+ totalPrice =
|
|
|
+ totalPrice - item.prePrice + item.price * item.count
|
|
|
|
|
|
- binding.paymentTotal.text = String.format(
|
|
|
- resources.getString(R.string.price_and_currency_format),
|
|
|
- totalPrice,
|
|
|
- headerAdapter.getCurrencyCode()
|
|
|
- )
|
|
|
+ binding.paymentTotal.text = String.format(
|
|
|
+ resources.getString(R.string.price_and_currency_format),
|
|
|
+ totalPrice,
|
|
|
+ headerAdapter.getCurrencyCode()
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -518,9 +558,12 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
|
|
|
override fun onItemClick(position: Int) {
|
|
|
OASystem.unitList[position].apply {
|
|
|
|
|
|
- carTouristGuides[itemPosition].units = id
|
|
|
- adapter.notifyItemChanged(itemPosition)
|
|
|
-
|
|
|
+ for (item in carTouristGuides) {
|
|
|
+ if (showItemList[position].id == item.id) {
|
|
|
+ item.units = id
|
|
|
+ adapter.notifyItemChanged(itemPosition)
|
|
|
+ }
|
|
|
+ }
|
|
|
popupWindow.dismiss()
|
|
|
}
|
|
|
}
|
|
@@ -596,6 +639,22 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
|
|
|
|
|
|
binding.updateLoading.visibility = View.VISIBLE
|
|
|
|
|
|
+ for (item in carTouristGuides) {
|
|
|
+ if (item.isNew) {
|
|
|
+ item.id = 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ updateGroundConveyDetailRequest.opContentList = carTouristGuides
|
|
|
+
|
|
|
+ val selectCheck = ArrayList<String>()
|
|
|
+
|
|
|
+ for (item in checkedItemId) {
|
|
|
+ selectCheck.add(item.toString())
|
|
|
+ }
|
|
|
+
|
|
|
+ updateGroundConveyDetailRequest.selectCheck = selectCheck
|
|
|
+
|
|
|
// val file = File(filesDir, "data.txt")
|
|
|
// if (file.exists()) {
|
|
|
// file.delete()
|