|
@@ -1,10 +1,8 @@
|
|
|
package com.pan_american.android.ui.efficiency_tools.daily_payment
|
|
|
|
|
|
import android.content.Intent
|
|
|
-import android.graphics.Color
|
|
|
import android.os.Bundle
|
|
|
import android.view.View
|
|
|
-import android.widget.ImageView
|
|
|
import android.widget.TextView
|
|
|
import androidx.core.content.res.ResourcesCompat
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
@@ -13,12 +11,13 @@ import com.pan_american.android.R
|
|
|
import com.pan_american.android.base.BaseActivity
|
|
|
import com.pan_american.android.base.BaseRequest
|
|
|
import com.pan_american.android.base.BaseResponse
|
|
|
-import com.pan_american.android.base.CardAdapter
|
|
|
import com.pan_american.android.base.CustomAlertDialog
|
|
|
import com.pan_american.android.base.ListAdapter
|
|
|
import com.pan_american.android.data.model.common.entity.Selector
|
|
|
import com.pan_american.android.data.model.common.network.DeleteRequest
|
|
|
+import com.pan_american.android.data.model.daily_payment.adapter.DailyPaymentListAdapter
|
|
|
import com.pan_american.android.data.model.daily_payment.entity.DailyPaymentCardListItem
|
|
|
+import com.pan_american.android.data.model.daily_payment.network.DailyPaymentApprovalRequest
|
|
|
import com.pan_american.android.data.model.daily_payment.network.DailyPaymentListRequest
|
|
|
import com.pan_american.android.data.model.daily_payment.network.DailyPaymentListResponse
|
|
|
import com.pan_american.android.data.model.daily_payment.network.DailyPaymentSiftResponse
|
|
@@ -499,94 +498,12 @@ class DailyPaymentListActivity : BaseActivity<ActivityDaliyPaymentListBinding>()
|
|
|
val layoutManager = LinearLayoutManager(OASystem.context)
|
|
|
binding.dailyPaymentList.layoutManager = layoutManager
|
|
|
|
|
|
- val adapter = CardAdapter.Builder<DailyPaymentCardListItem>().apply {
|
|
|
- setLayoutId(R.layout.item_daily_payment)
|
|
|
- setData(dailyPaymentCardListItems)
|
|
|
- setCanDelete(OASystem.authorization(OASystem.DAILY_PAYMENT, OASystem.DELETE))
|
|
|
- addBindView { itemView, data ->
|
|
|
- itemView.findViewById<TextView>(R.id.payment_name).text = data.instructions
|
|
|
- itemView.findViewById<TextView>(R.id.payment_revert).text = data.companyName
|
|
|
- itemView.findViewById<TextView>(R.id.payment_creator).text = data.createUser
|
|
|
- itemView.findViewById<TextView>(R.id.total_payment).text =
|
|
|
- String.format(resources.getString(R.string.rmb_price), data.sumPrice)
|
|
|
- itemView.findViewById<TextView>(R.id.create_time).text = data.createTime
|
|
|
- itemView.findViewById<TextView>(R.id.finance_status).text = data.fAuditDesc
|
|
|
- itemView.findViewById<TextView>(R.id.general_status).text = data.mAuditDesc
|
|
|
- itemView.findViewById<TextView>(R.id.finance_reviewer).text = data.fAuditName
|
|
|
- itemView.findViewById<TextView>(R.id.general_reviewer).text = data.mAuditName
|
|
|
-
|
|
|
- when (data.fAudit) {
|
|
|
- 0 -> {
|
|
|
- itemView.findViewById<ImageView>(R.id.finance_icon)
|
|
|
- .setImageResource(R.mipmap.icon_wait)
|
|
|
- itemView.findViewById<TextView>(R.id.finance_status)
|
|
|
- .setTextColor(Color.rgb(23, 171, 227))
|
|
|
- }
|
|
|
-
|
|
|
- 1 -> {
|
|
|
- itemView.findViewById<ImageView>(R.id.finance_icon)
|
|
|
- .setImageResource(R.mipmap.icon_passed)
|
|
|
- itemView.findViewById<TextView>(R.id.finance_status)
|
|
|
- .setTextColor(Color.rgb(84, 213, 77))
|
|
|
- }
|
|
|
-
|
|
|
- 2 -> {
|
|
|
- itemView.findViewById<ImageView>(R.id.finance_icon)
|
|
|
- .setImageResource(R.mipmap.icon_reject)
|
|
|
- itemView.findViewById<TextView>(R.id.finance_status)
|
|
|
- .setTextColor(Color.rgb(210, 45, 34))
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- when (data.mAudit) {
|
|
|
- 0 -> {
|
|
|
- itemView.findViewById<ImageView>(R.id.general_icon)
|
|
|
- .setImageResource(R.mipmap.icon_wait)
|
|
|
- itemView.findViewById<TextView>(R.id.general_status)
|
|
|
- .setTextColor(Color.rgb(23, 171, 227))
|
|
|
- }
|
|
|
-
|
|
|
- 1 -> {
|
|
|
- itemView.findViewById<ImageView>(R.id.general_icon)
|
|
|
- .setImageResource(R.mipmap.icon_passed)
|
|
|
- itemView.findViewById<TextView>(R.id.general_status)
|
|
|
- .setTextColor(Color.rgb(84, 213, 77))
|
|
|
- }
|
|
|
-
|
|
|
- 2 -> {
|
|
|
- itemView.findViewById<ImageView>(R.id.general_icon)
|
|
|
- .setImageResource(R.mipmap.icon_reject)
|
|
|
- itemView.findViewById<TextView>(R.id.general_status)
|
|
|
- .setTextColor(Color.rgb(210, 45, 34))
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- when (data.isPay) {
|
|
|
- 0 -> {
|
|
|
- itemView.findViewById<TextView>(R.id.is_pay).apply {
|
|
|
- text = resources.getString(R.string.not_pay)
|
|
|
- setTextColor(Color.rgb(23, 171, 227))
|
|
|
- }
|
|
|
- itemView.findViewById<ImageView>(R.id.is_pay_icon)
|
|
|
- .setImageResource(R.mipmap.icon_wait)
|
|
|
- }
|
|
|
-
|
|
|
- 1 -> {
|
|
|
- itemView.findViewById<TextView>(R.id.is_pay).apply {
|
|
|
- text = resources.getString(R.string.paid)
|
|
|
- setTextColor(Color.rgb(84, 213, 77))
|
|
|
- }
|
|
|
- itemView.findViewById<ImageView>(R.id.is_pay_icon)
|
|
|
- .setImageResource(R.mipmap.icon_passed)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }.create()
|
|
|
+ val adapter = DailyPaymentListAdapter(dailyPaymentCardListItems)
|
|
|
|
|
|
binding.dailyPaymentList.adapter = adapter
|
|
|
|
|
|
- adapter.onRecyclerViewItemClick =
|
|
|
- object : CardAdapter.OnRecyclerViewItemClick<DailyPaymentCardListItem> {
|
|
|
+ adapter.onItemClick =
|
|
|
+ object : DailyPaymentListAdapter.OnItemClick {
|
|
|
override fun onItemClick(position: Int) {
|
|
|
|
|
|
val intent =
|
|
@@ -613,6 +530,34 @@ class DailyPaymentListActivity : BaseActivity<ActivityDaliyPaymentListBinding>()
|
|
|
setCancelable(false)
|
|
|
}.show()
|
|
|
}
|
|
|
+
|
|
|
+ override fun onDisapprovalClick(position: Int) {
|
|
|
+ CustomAlertDialog.Builder(OASystem.context).apply {
|
|
|
+ setTitle(resources.getString(R.string.hint))
|
|
|
+ setMessage(String.format(resources.getString(R.string.disapproval_hint), dailyPaymentCardListItems[position].instructions))
|
|
|
+ setNegativeButtonAndListener(resources.getString(R.string.cancel)) { dialog, _ ->
|
|
|
+ dialog.dismiss()
|
|
|
+ }
|
|
|
+ setPositiveButtonAndListener(resources.getString(R.string.confirm)) { dialog, _ ->
|
|
|
+ dailyPaymentAuditOperation(position, 2)
|
|
|
+ dialog.dismiss()
|
|
|
+ }
|
|
|
+ }.show()
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onApprovalClick(position: Int) {
|
|
|
+ CustomAlertDialog.Builder(OASystem.context).apply {
|
|
|
+ setTitle(resources.getString(R.string.hint))
|
|
|
+ setMessage(String.format(resources.getString(R.string.approval_hint), dailyPaymentCardListItems[position].instructions))
|
|
|
+ setNegativeButtonAndListener(resources.getString(R.string.cancel)) { dialog, _ ->
|
|
|
+ dialog.dismiss()
|
|
|
+ }
|
|
|
+ setPositiveButtonAndListener(resources.getString(R.string.confirm)) { dialog, _ ->
|
|
|
+ dailyPaymentAuditOperation(position, 1)
|
|
|
+ dialog.dismiss()
|
|
|
+ }
|
|
|
+ }.show()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
binding.dailyPaymentContainer.setOnRefreshLoadMoreListener(object :
|
|
@@ -674,4 +619,73 @@ class DailyPaymentListActivity : BaseActivity<ActivityDaliyPaymentListBinding>()
|
|
|
|
|
|
initDailyPaymentList(1)
|
|
|
}
|
|
|
+
|
|
|
+ private fun dailyPaymentAuditOperation(position: Int, operation: Int) {
|
|
|
+ val dailyPaymentApprovalRequest = DailyPaymentApprovalRequest().apply {
|
|
|
+ id = dailyPaymentCardListItems[position].id
|
|
|
+ when(OASystem.userInfo.userId) {
|
|
|
+ 21 -> {
|
|
|
+ auditType = 2
|
|
|
+ }
|
|
|
+
|
|
|
+ 22 -> {
|
|
|
+ auditType = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ auditStatus = operation
|
|
|
+ }
|
|
|
+
|
|
|
+ apiService.dailyPaymentApproval(dailyPaymentApprovalRequest).enqueue(object : Callback<BaseResponse> {
|
|
|
+ override fun onResponse(call: Call<BaseResponse>, response: Response<BaseResponse>) {
|
|
|
+ val approvalResponse = response.body()
|
|
|
+
|
|
|
+ if (approvalResponse != null) {
|
|
|
+ if (approvalResponse.code == 200) {
|
|
|
+
|
|
|
+ when(dailyPaymentApprovalRequest.auditStatus) {
|
|
|
+ 1 -> {
|
|
|
+ dailyPaymentCardListItems[position].fAudit = operation
|
|
|
+
|
|
|
+ when(operation) {
|
|
|
+ 1 -> {
|
|
|
+ dailyPaymentCardListItems[position].fAuditDesc = resources.getString(R.string.verify_passed)
|
|
|
+ }
|
|
|
+
|
|
|
+ 2 -> {
|
|
|
+ dailyPaymentCardListItems[position].fAuditDesc = resources.getString(R.string.verify_reject)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ 2 -> {
|
|
|
+ dailyPaymentCardListItems[position].mAudit = operation
|
|
|
+
|
|
|
+ when(operation) {
|
|
|
+ 1 -> {
|
|
|
+ dailyPaymentCardListItems[position].mAuditDesc = resources.getString(R.string.verify_passed)
|
|
|
+ }
|
|
|
+
|
|
|
+ 2 -> {
|
|
|
+ dailyPaymentCardListItems[position].mAuditDesc = resources.getString(R.string.verify_reject)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ binding.dailyPaymentList.adapter!!.notifyItemChanged(position)
|
|
|
+
|
|
|
+ showMessage(resources.getString(R.string.approval_success))
|
|
|
+
|
|
|
+ } else {
|
|
|
+ showMessage(approvalResponse.msg)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onFailure(call: Call<BaseResponse>, t: Throwable) {
|
|
|
+ showErrorInfo(R.string.approval_error)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|