Browse Source

2024-10-14 修改

修改:
1. 完善费用审核界面
2. 部分UI逻辑修改
zhaiy 5 months ago
parent
commit
836f472e64

+ 9 - 0
app/src/main/java/com/pan_american/android/data/model/financial_module/expense_approval/network/UpdatePaymentListExpenseApprovalRequest.kt

@@ -0,0 +1,9 @@
+package com.pan_american.android.data.model.financial_module.expense_approval.network
+
+import com.pan_american.android.OASystem
+import com.pan_american.android.base.BaseRequest
+
+class UpdatePaymentListExpenseApprovalRequest(val creditIdStr: String, val auditCode: Int): BaseRequest() {
+    val userId = OASystem.userInfo.userId
+    val pageId = OASystem.EXPENSE_APPROVAL
+}

+ 7 - 0
app/src/main/java/com/pan_american/android/data/network/APIService.kt

@@ -80,6 +80,7 @@ import com.pan_american.android.data.model.financial_module.expense_approval.net
 import com.pan_american.android.data.model.financial_module.expense_approval.network.ExpenseApprovalPaymentListRequest
 import com.pan_american.android.data.model.financial_module.expense_approval.network.ExpenseApprovalPaymentListResponse
 import com.pan_american.android.data.model.financial_module.expense_approval.network.ExpenseApprovalPaymentTypeResponse
+import com.pan_american.android.data.model.financial_module.expense_approval.network.UpdatePaymentListExpenseApprovalRequest
 import com.pan_american.android.data.model.group_airplane_ticket.airplane_payment_insert.network.AirplaneCostDetailResponse
 import com.pan_american.android.data.model.group_airplane_ticket.airplane_payment_insert.network.AirplaneTicketDetailRequest
 import com.pan_american.android.data.model.group_airplane_ticket.airplane_payment_insert.network.AirplaneTicketDetailResponse
@@ -1112,4 +1113,10 @@ interface APIService {
      */
     @POST("/api/Business/PostShareGroupInfo")
     fun getBaseGroupInfo(@Body baseGroupInfoRequest: BaseGroupInfoRequest): Call<BaseGroupInfoResponse>
+
+    /**
+     * 费用审核,批量更改费用状态
+     */
+    @POST("/api/Groups/PostAuditGrpCreditCardPayment")
+    fun updatePaymentListApproval(@Body updatePaymentListApprovalRequest: UpdatePaymentListExpenseApprovalRequest): Call<BaseResponse>
 }

+ 175 - 3
app/src/main/java/com/pan_american/android/ui/financial_module/expense_approval/ExpenseApprovalFragment.kt

@@ -1,14 +1,20 @@
 package com.pan_american.android.ui.financial_module.expense_approval
 
 import android.os.Bundle
+import android.text.Html
+import android.view.Gravity
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import android.widget.CheckedTextView
+import android.widget.PopupWindow
+import android.widget.TextView
 import androidx.recyclerview.widget.LinearLayoutManager
 import com.pan_american.android.OASystem
 import com.pan_american.android.R
 import com.pan_american.android.base.BaseFragment
+import com.pan_american.android.base.BaseResponse
+import com.pan_american.android.base.CustomAlertDialog
 import com.pan_american.android.base.ListAdapter
 import com.pan_american.android.data.model.common.entity.SiftListItem
 import com.pan_american.android.data.model.financial_module.expense_approval.adapter.ExpenseApprovalPaymentListAdapter
@@ -18,9 +24,11 @@ import com.pan_american.android.data.model.financial_module.expense_approval.net
 import com.pan_american.android.data.model.financial_module.expense_approval.network.ExpenseApprovalPaymentListRequest
 import com.pan_american.android.data.model.financial_module.expense_approval.network.ExpenseApprovalPaymentListResponse
 import com.pan_american.android.data.model.financial_module.expense_approval.network.ExpenseApprovalPaymentTypeResponse
+import com.pan_american.android.data.model.financial_module.expense_approval.network.UpdatePaymentListExpenseApprovalRequest
 import com.pan_american.android.data.network.APIService
 import com.pan_american.android.data.network.ServiceCreator
 import com.pan_american.android.databinding.FragmentExpenseApprovalBinding
+import com.pan_american.android.util.CommitButton
 import retrofit2.Call
 import retrofit2.Callback
 import retrofit2.Response
@@ -43,6 +51,8 @@ class ExpenseApprovalFragment : BaseFragment<FragmentExpenseApprovalBinding>() {
 
     private var groupBaseInfoShown = false
 
+    private var paymentIdList = ArrayList<Int>()
+
     override fun getViewBinding(
         inflater: LayoutInflater,
         container: ViewGroup?,
@@ -80,6 +90,18 @@ class ExpenseApprovalFragment : BaseFragment<FragmentExpenseApprovalBinding>() {
                 groupBaseInfoShown = true
             }
         }
+
+        binding.revoke.setOnClickListener {
+            showListUpdateAlertDialog(2)
+        }
+
+        binding.pass.setOnClickListener {
+            showListUpdateAlertDialog(1)
+        }
+
+        binding.reject.setOnClickListener {
+            showListUpdateAlertDialog(2)
+        }
     }
 
     private fun getPaymentType() {
@@ -162,6 +184,10 @@ class ExpenseApprovalFragment : BaseFragment<FragmentExpenseApprovalBinding>() {
                         paymentList.clear()
                     }
 
+                    if (paymentIdList.size != 0) {
+                        paymentIdList.clear()
+                    }
+
                     expenseApprovalPaymentListRequest.label = labelId
 
                     getPaymentItemByLabel()
@@ -215,23 +241,56 @@ class ExpenseApprovalFragment : BaseFragment<FragmentExpenseApprovalBinding>() {
 
         adapter.onItemClick = object : ExpenseApprovalPaymentListAdapter.OnItemClick {
             override fun onItemCheck(position: Int) {
-
+                paymentList[position].apply {
+                    if (isChecked) {
+                        paymentIdList.add(id)
+                    } else {
+                        paymentIdList.remove(id)
+                    }
+                }
             }
 
             override fun onItemClick(position: Int) {
+                val detailPopup = View.inflate(OASystem.context, R.layout.popup_expense_approval_paayment_detail, null)
+                popupWindow = PopupWindow(detailPopup, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
+
+                showPopupWindow {
+                    val detailText = detailPopup.findViewById<TextView>(R.id.payment_detail)
+                    val commitButton = detailPopup.findViewById<CommitButton>(R.id.commit)
+
+                    detailText.text = Html.fromHtml(paymentList[position].priceMsgContent.trimIndent(), Html.FROM_HTML_MODE_LEGACY)
+                    commitButton.apply {
+                        setText(resources.getString(R.string.confirm))
 
+                        setOnClickListener {
+                            popupWindow.dismiss()
+                        }
+                    }
+
+                    popupWindow.showAtLocation(binding.root, Gravity.CENTER, 0, 0)
+                }
             }
 
             override fun onItemReject(position: Int) {
-
+                showSingleUpdateAlertDialog(
+                    String.format(resources.getString(R.string.approval_reject_hint), paymentList[position].priceNameContent),
+                    position, 2
+                )
             }
 
             override fun onItemPass(position: Int) {
+                showSingleUpdateAlertDialog(
+                    String.format(resources.getString(R.string.approval_pass_hint), paymentList[position].priceNameContent),
+                    position, 1
+                )
 
             }
 
             override fun onItemRevoke(position: Int) {
-
+                showSingleUpdateAlertDialog(
+                    String.format(resources.getString(R.string.approval_revoke_hint), paymentList[position].priceNameContent),
+                    position, 2
+                )
             }
         }
     }
@@ -270,4 +329,117 @@ class ExpenseApprovalFragment : BaseFragment<FragmentExpenseApprovalBinding>() {
             }
         })
     }
+
+    private fun showSingleUpdateAlertDialog(string: String, position: Int, auditStatus: Int) {
+        CustomAlertDialog.Builder(OASystem.context).apply {
+            setTitle(resources.getString(R.string.alert))
+            setMessage(string)
+            setNegativeButtonAndListener(resources.getString(R.string.cancel)) { dialog, _ ->
+                dialog.dismiss()
+            }
+            setPositiveButtonAndListener(resources.getString(R.string.confirm)) { dialog, _ ->
+                updateExpenseApproval(position, auditStatus)
+                dialog.dismiss()
+            }
+        }.show()
+    }
+
+    private fun updateExpenseApproval(position: Int, auditStatus: Int) {
+        apiService.updatePaymentListApproval(UpdatePaymentListExpenseApprovalRequest(paymentList[position].id.toString(), auditStatus)).enqueue(object : Callback<BaseResponse> {
+            override fun onResponse(call: Call<BaseResponse>, response: Response<BaseResponse>) {
+                val updateResponse = response.body()
+
+                if (updateResponse != null) {
+                    if (updateResponse.code == 200) {
+
+                        binding.segmentPaymentList.adapter!!.notifyItemRangeRemoved(0, paymentList.size)
+
+                        paymentList.clear()
+
+                        getPaymentItemByLabel()
+
+                        showMessage(resources.getString(R.string.update_success))
+
+                    } else {
+                        showMessage(updateResponse.msg)
+                    }
+                }
+            }
+
+            override fun onFailure(call: Call<BaseResponse>, t: Throwable) {
+                showErrorInfo(R.string.update_error)
+            }
+        })
+    }
+
+    private fun showListUpdateAlertDialog(auditStatus: Int) {
+
+        var paymentNameList = ""
+
+        for (id in paymentIdList) {
+            for (item in paymentList) {
+                if (id == item.id) {
+                    paymentNameList += item.priceNameContent
+                    paymentNameList += "\n"
+                }
+            }
+        }
+
+        paymentNameList.trim()
+
+        var modelName = ""
+
+        for (item in filterList) {
+            if (labelId == item.id) {
+                modelName = item.name
+            }
+        }
+
+        val groupName = binding.groupName.text
+
+        CustomAlertDialog.Builder(OASystem.context).apply {
+            setTitle(resources.getString(R.string.alert))
+            setMessage(String.format(resources.getString(R.string.approval_payment_list_update_hint), groupName, modelName, paymentNameList))
+            setNegativeButtonAndListener(resources.getString(R.string.cancel)) { dialog, _ ->
+                dialog.dismiss()
+            }
+            setPositiveButtonAndListener(resources.getString(R.string.confirm)) { dialog, _ ->
+                updatePaymentListApproval(paymentIdList, auditStatus)
+                dialog.dismiss()
+            }
+        }.show()
+    }
+
+    private fun updatePaymentListApproval(idList: ArrayList<Int>, auditStatus: Int) {
+
+        val creditString = idList.toString().replace("[", "").replace("]", "")
+
+        apiService.updatePaymentListApproval(UpdatePaymentListExpenseApprovalRequest(creditString, auditStatus)).enqueue(object : Callback<BaseResponse> {
+            override fun onResponse(call: Call<BaseResponse>, response: Response<BaseResponse>) {
+                val updateResponse = response.body()
+
+                if (updateResponse != null) {
+                    if (updateResponse.code == 200) {
+
+                        binding.segmentPaymentList.adapter!!.notifyItemRangeRemoved(0, paymentList.size)
+
+                        paymentList.clear()
+
+                        getPaymentItemByLabel()
+
+                        showMessage(resources.getString(R.string.update_success))
+
+                    } else {
+                        showMessage(updateResponse.msg)
+                    }
+                }
+            }
+
+            override fun onFailure(call: Call<BaseResponse>, t: Throwable) {
+                showErrorInfo(R.string.update_error)
+            }
+        })
+
+        paymentIdList.clear()
+    }
 }

+ 38 - 0
app/src/main/res/layout/popup_expense_approval_paayment_detail.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:background="@drawable/shape_corner_stroke_white"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <TextView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_margin="@dimen/common_padding"
+        android:gravity="center"
+        android:padding="@dimen/common_padding_small"
+        android:text="@string/payment_detail"
+        android:textSize="@dimen/text_size_large"
+        android:textStyle="bold" />
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/line"
+        android:background="@color/line_color" />
+
+    <TextView
+        android:id="@+id/payment_detail"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_margin="@dimen/common_padding"
+        android:background="@color/white"
+        android:textColor="@color/text_color"
+        android:textSize="@dimen/text_size_medium" />
+
+    <com.pan_american.android.util.CommitButton
+        android:id="@+id/commit"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/button_height"
+        android:layout_margin="@dimen/common_padding" />
+
+</LinearLayout>

+ 8 - 3
app/src/main/res/values/strings.xml

@@ -1212,9 +1212,14 @@
     <string name="over_budget">超支金额</string>
     <string name="revoke">撤销通过</string>
     
-    <string name="batch_revoke">批量撤销审核</string>
-    <string name="batch_reject">批量审核拒绝</string>
-    <string name="batch_pass">批量审核通过</string>
+    <string name="batch_revoke">批量撤销</string>
+    <string name="batch_reject">批量拒绝</string>
+    <string name="batch_pass">批量通过</string>
+
+    <string name="approval_pass_hint">确认审核通过该费用?\n\n费用名称: %s</string>
+    <string name="approval_reject_hint">确认审核拒绝该费用?\n\n费用名称: %s</string>
+    <string name="approval_revoke_hint">确认撤销该费用的审核通过状态?\n\n费用名称: %s</string>
+    <string name="approval_payment_list_update_hint">确认批量审核下列款项?\n\n团组名称: %s \n\n费用模块: %s\n\n费用列表:\n%s</string>
 
     <!-- TODO: Remove or change this placeholder text -->
     <string name="hello_blank_fragment">Hello blank fragment</string>