Browse Source

2024-07-18 修改

1. 部分UI逻辑代码修改
zhaiy 8 months ago
parent
commit
76591c2dff

+ 1 - 2
app/src/main/java/com/pan_american/android/data/model/resource_management/airplane_three_code/entity/AirplaneThreeCode.kt

@@ -1,9 +1,8 @@
 package com.pan_american.android.data.model.resource_management.airplane_three_code.entity
 
 import com.pan_american.android.OASystem
-import java.io.Serializable
 
-class AirplaneThreeCode: Serializable {
+class AirplaneThreeCode {
 
     var three = ""
     var four = ""

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

@@ -140,6 +140,8 @@ import com.pan_american.android.data.model.message.network.MessageUnReadCountReq
 import com.pan_american.android.data.model.message.network.MessageUnReadCountResponse
 import com.pan_american.android.data.model.message.network.MessageUnReadTotalResponse
 import com.pan_american.android.data.model.resource_management.airplane_three_code.entity.AirplaneThreeCode
+import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeDetailRequest
+import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeDetailResponse
 import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeRequest
 import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeResponse
 import com.pan_american.android.data.model.resource_management.car_resource.entity.CarResource
@@ -299,6 +301,12 @@ interface APIService {
     @POST("/api/Resource/QueryThreeCode")
     fun getAirplaneThreeCodeData(@Body airplaneThreeCodeRequest: AirplaneThreeCodeRequest): Call<AirplaneThreeCodeResponse>
 
+    /**
+     * 机场三字码资料数据,根据ID查询三字码详情
+     */
+    @POST("api/Resource/QuerySingleThreeCode")
+    fun getAirplaneThreeCodeDetailById(@Body airplaneThreeCodeDetailRequest: AirplaneThreeCodeDetailRequest): Call<AirplaneThreeCodeDetailResponse>
+
     /**
      * 机场三字码资料数据,机场三字码信息操作
      * status: 1.新增     2.修改

+ 58 - 11
app/src/main/java/com/pan_american/android/ui/resource_management/airplane_three_code/AddAirplaneThreeCodeActivity.kt

@@ -1,12 +1,13 @@
 package com.pan_american.android.ui.resource_management.airplane_three_code
 
 import android.os.Bundle
-import android.view.View
 import com.pan_american.android.OASystem
 import com.pan_american.android.R
 import com.pan_american.android.base.BaseActivity
 import com.pan_american.android.base.BaseResponse
 import com.pan_american.android.data.model.resource_management.airplane_three_code.entity.AirplaneThreeCode
+import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeDetailRequest
+import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeDetailResponse
 import com.pan_american.android.data.network.APIService
 import com.pan_american.android.data.network.ServiceCreator
 import com.pan_american.android.databinding.ActivityAddAirplaneThreeCodeBinding
@@ -19,7 +20,11 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
 
     private lateinit var titleBinding: LayoutTitleBinding
 
-    private lateinit var airplaneThreeCode: AirplaneThreeCode
+    private var threeCodeId = 0
+
+    private val apiService = ServiceCreator.create<APIService>()
+
+    private val airplaneThreeCode = AirplaneThreeCode()
 
     private var fromList = false
 
@@ -29,7 +34,13 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
         super.onCreate(savedInstanceState)
         screenAdaptation(binding)
 
-        fromList = intent.getBooleanExtra("fromList", false)
+        intent.apply {
+            fromList = getBooleanExtra("fromList", false)
+
+            if (fromList) {
+                threeCodeId = getIntExtra("id", 0)
+            }
+        }
 
         initTitle()
         initViews()
@@ -55,22 +66,25 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
 
         if (fromList) {
 
-            airplaneThreeCode =
-                intent.getSerializableExtra("airplaneResource") as AirplaneThreeCode
-            initAirplaneResourceInfo()
+            getAirplaneThreeCodeById()
 
             binding.commit.setText(resources.getString(R.string.update))
+
         } else {
 
             binding.commit.setText(resources.getString(R.string.add))
-
-            airplaneThreeCode = AirplaneThreeCode()
         }
     }
 
     override fun initEvents() {
 
         binding.commit.setOnClickListener {
+
+            if (!OASystem.authorization(OASystem.THREE_CODE_RESOURCE, OASystem.EDIT)) {
+                back()
+                return@setOnClickListener
+            }
+
             if (intent.getBooleanExtra("fromList", false)) {
                 initAirplaneResource(2)
                 updateAirplaneResource()
@@ -81,7 +95,42 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
         }
     }
 
+    private fun getAirplaneThreeCodeById() {
+
+        apiService.getAirplaneThreeCodeDetailById(AirplaneThreeCodeDetailRequest(threeCodeId)).enqueue(object : Callback<AirplaneThreeCodeDetailResponse> {
+            override fun onResponse(
+                call: Call<AirplaneThreeCodeDetailResponse>,
+                response: Response<AirplaneThreeCodeDetailResponse>
+            ) {
+                val detailResponse = response.body()
+
+                if (detailResponse != null) {
+                    if (detailResponse.code == 200) {
+                        airplaneThreeCode.apply {
+                            id = threeCodeId
+                            three = detailResponse.data.three
+                            four = detailResponse.data.four
+                            airPort = detailResponse.data.airPort
+                            airPort_En = detailResponse.data.airPort_En
+                            city = detailResponse.data.city
+                            remark = detailResponse.data.remark
+                        }
+
+                        initAirplaneResourceInfo()
+                    } else {
+                        showMessage(detailResponse.msg)
+                    }
+                }
+            }
+
+            override fun onFailure(p0: Call<AirplaneThreeCodeDetailResponse>, p1: Throwable) {
+                showErrorInfo(R.string.airplane_three_code_detail_get_failed)
+            }
+        })
+    }
+
     private fun initAirplaneResourceInfo() {
+
         binding.apply {
             threeCode.setText(airplaneThreeCode.three)
             fourCode.setText(airplaneThreeCode.four)
@@ -100,7 +149,7 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
                 airplaneNameEn.isEnabled(false)
                 otherInfo.isEnabled(false)
 
-                commit.visibility = View.GONE
+                commit.setText(resources.getString(R.string.back))
             }
         }
     }
@@ -123,8 +172,6 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
 
         binding.commit.setButtonStatus(1)
 
-        val apiService = ServiceCreator.create<APIService>()
-
         apiService.airplaneThreeCodeOperation(airplaneThreeCode)
             .enqueue(object : Callback<BaseResponse> {
                 override fun onResponse(

+ 1 - 1
app/src/main/java/com/pan_american/android/ui/resource_management/airplane_three_code/AirplaneThreeCodeListFragment.kt

@@ -173,7 +173,7 @@ class AirplaneThreeCodeListFragment : BaseFragment<FragmentAirplaneThreeCodeList
                 override fun onItemClick(position: Int) {
                     val intent =
                         Intent(OASystem.context, AddAirplaneThreeCodeActivity::class.java).apply {
-                            putExtra("airplaneResource", airplaneList[position])
+                            putExtra("id", airplaneList[position].id)
                             putExtra("fromList", true)
                         }
 

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -444,6 +444,7 @@
 
     <!-- 机场三字码,错误信息-->
     <string name="airplane_three_code_list_get_failed">机场三字码列表获取失败</string>
+    <string name="airplane_three_code_detail_get_failed">机场三字码详情获取失败</string>
 
     <!-- 团组资料-->
     <string name="group_status">团组状态</string>