|
@@ -11,6 +11,8 @@ import com.pan_american.android.base.BaseResponse
|
|
|
import com.pan_american.android.base.ListAdapter
|
|
|
import com.pan_american.android.data.model.common.entity.Selector
|
|
|
import com.pan_american.android.data.model.resource_management.guide_resource.entity.GuideResource
|
|
|
+import com.pan_american.android.data.model.resource_management.guide_resource.network.GuideResourceDetailRequest
|
|
|
+import com.pan_american.android.data.model.resource_management.guide_resource.network.GuideResourceDetailResponse
|
|
|
import com.pan_american.android.data.network.APIService
|
|
|
import com.pan_american.android.data.network.ServiceCreator
|
|
|
import com.pan_american.android.databinding.ActivityAddGuideResourceBinding
|
|
@@ -31,13 +33,21 @@ class AddGuideResourceActivity : BaseActivity<ActivityAddGuideResourceBinding>()
|
|
|
|
|
|
private var guideTypeId = -1
|
|
|
|
|
|
+ private val apiService = ServiceCreator.create<APIService>()
|
|
|
+
|
|
|
+ private var resourceId = 0
|
|
|
+
|
|
|
override fun getViewBinding() = ActivityAddGuideResourceBinding.inflate(layoutInflater)
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
screenAdaptation(binding)
|
|
|
|
|
|
- fromList = intent.getBooleanExtra("fromList", false)
|
|
|
+ intent.apply {
|
|
|
+ fromList = intent.getBooleanExtra("fromList", false)
|
|
|
+ resourceId = intent.getIntExtra("resource_id", 0)
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
initTitle()
|
|
|
initViews()
|
|
@@ -64,8 +74,6 @@ class AddGuideResourceActivity : BaseActivity<ActivityAddGuideResourceBinding>()
|
|
|
|
|
|
if (fromList) {
|
|
|
|
|
|
- guideResource = intent.getSerializableExtra("guideResource") as GuideResource
|
|
|
-
|
|
|
initGuideResourceDetail()
|
|
|
|
|
|
binding.commit.setText(resources.getString(R.string.update))
|
|
@@ -240,73 +248,97 @@ class AddGuideResourceActivity : BaseActivity<ActivityAddGuideResourceBinding>()
|
|
|
}
|
|
|
|
|
|
private fun initGuideResourceDetail() {
|
|
|
- binding.apply {
|
|
|
- for (item in OASystem.guideType) {
|
|
|
- if (item.id == guideResource.staffType) {
|
|
|
- guideType.text = item.name
|
|
|
- guideTypeId = item.id
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- //老数据没有选择评分,更新数据时需要选择评分
|
|
|
- for (item in OASystem.score) {
|
|
|
- if (guideResource.score.toString() == item) {
|
|
|
- serviceScore.text = item
|
|
|
- isChose = true
|
|
|
- }
|
|
|
- }
|
|
|
+ apiService.getLocalGuideDetailById(GuideResourceDetailRequest(resourceId)).enqueue(object : Callback<GuideResourceDetailResponse> {
|
|
|
+ override fun onResponse(
|
|
|
+ call: Call<GuideResourceDetailResponse>,
|
|
|
+ response: Response<GuideResourceDetailResponse>
|
|
|
+ ) {
|
|
|
+ val resourceDetailResponse = response.body()
|
|
|
|
|
|
- unitArea.setText(guideResource.unitArea)
|
|
|
- departmentName.setText(guideResource.unitName)
|
|
|
- supplierLocation.setText(guideResource.address)
|
|
|
- contactsName.setText(guideResource.contact)
|
|
|
- contactsPhone.setText(guideResource.contactTel)
|
|
|
- contactsEmail.setText(guideResource.contactEmail)
|
|
|
- contactsFax.setText(guideResource.contactFax)
|
|
|
- otherInfo.setText(guideResource.otherInfo)
|
|
|
- }
|
|
|
+ if (resourceDetailResponse != null) {
|
|
|
+ if (resourceDetailResponse.code == 200) {
|
|
|
|
|
|
- when (guideResource.suitScore) {
|
|
|
- "A" -> binding.dressA.isChecked = true
|
|
|
- "B" -> binding.dressB.isChecked = true
|
|
|
- "C" -> binding.dressC.isChecked = true
|
|
|
- }
|
|
|
+ guideResource = resourceDetailResponse.data
|
|
|
|
|
|
- when (guideResource.serveScore) {
|
|
|
- "A" -> binding.awarenessA.isChecked = true
|
|
|
- "B" -> binding.awarenessB.isChecked = true
|
|
|
- "C" -> binding.awarenessC.isChecked = true
|
|
|
- }
|
|
|
+ binding.apply {
|
|
|
+ for (item in OASystem.guideType) {
|
|
|
+ if (item.id == guideResource.staffType) {
|
|
|
+ guideType.text = item.name
|
|
|
+ guideTypeId = item.id
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- when (guideResource.talkProScore) {
|
|
|
- "A" -> binding.expertiseA.isChecked = true
|
|
|
- "B" -> binding.expertiseB.isChecked = true
|
|
|
- "C" -> binding.expertiseC.isChecked = true
|
|
|
- }
|
|
|
+ //老数据没有选择评分,更新数据时需要选择评分
|
|
|
+ for (item in OASystem.score) {
|
|
|
+ if (guideResource.score.toString() == item) {
|
|
|
+ serviceScore.text = item
|
|
|
+ isChose = true
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- when (guideResource.timeScore) {
|
|
|
- "A" -> binding.timeConceptA.isChecked = true
|
|
|
- "B" -> binding.timeConceptB.isChecked = true
|
|
|
- "C" -> binding.timeConceptC.isChecked = true
|
|
|
- }
|
|
|
+ unitArea.setText(guideResource.unitArea)
|
|
|
+ departmentName.setText(guideResource.unitName)
|
|
|
+ supplierLocation.setText(guideResource.address)
|
|
|
+ contactsName.setText(guideResource.contact)
|
|
|
+ contactsPhone.setText(guideResource.contactTel)
|
|
|
+ contactsEmail.setText(guideResource.contactEmail)
|
|
|
+ contactsFax.setText(guideResource.contactFax)
|
|
|
+ otherInfo.setText(guideResource.otherInfo)
|
|
|
+ }
|
|
|
|
|
|
- when (guideResource.fitScore) {
|
|
|
- "A" -> binding.cooperationA.isChecked = true
|
|
|
- "B" -> binding.cooperationB.isChecked = true
|
|
|
- "C" -> binding.cooperationC.isChecked = true
|
|
|
- }
|
|
|
+ when (guideResource.suitScore) {
|
|
|
+ "A" -> binding.dressA.isChecked = true
|
|
|
+ "B" -> binding.dressB.isChecked = true
|
|
|
+ "C" -> binding.dressC.isChecked = true
|
|
|
+ }
|
|
|
|
|
|
- when (guideResource.strainScore) {
|
|
|
- "A" -> binding.adaptabilityA.isChecked = true
|
|
|
- "B" -> binding.adaptabilityB.isChecked = true
|
|
|
- "C" -> binding.adaptabilityC.isChecked = true
|
|
|
- }
|
|
|
+ when (guideResource.serveScore) {
|
|
|
+ "A" -> binding.awarenessA.isChecked = true
|
|
|
+ "B" -> binding.awarenessB.isChecked = true
|
|
|
+ "C" -> binding.awarenessC.isChecked = true
|
|
|
+ }
|
|
|
|
|
|
- when (guideResource.localAndChineseScore) {
|
|
|
- "A" -> binding.expressionA.isChecked = true
|
|
|
- "B" -> binding.expressionB.isChecked = true
|
|
|
- "C" -> binding.expressionC.isChecked = true
|
|
|
- }
|
|
|
+ when (guideResource.talkProScore) {
|
|
|
+ "A" -> binding.expertiseA.isChecked = true
|
|
|
+ "B" -> binding.expertiseB.isChecked = true
|
|
|
+ "C" -> binding.expertiseC.isChecked = true
|
|
|
+ }
|
|
|
+
|
|
|
+ when (guideResource.timeScore) {
|
|
|
+ "A" -> binding.timeConceptA.isChecked = true
|
|
|
+ "B" -> binding.timeConceptB.isChecked = true
|
|
|
+ "C" -> binding.timeConceptC.isChecked = true
|
|
|
+ }
|
|
|
+
|
|
|
+ when (guideResource.fitScore) {
|
|
|
+ "A" -> binding.cooperationA.isChecked = true
|
|
|
+ "B" -> binding.cooperationB.isChecked = true
|
|
|
+ "C" -> binding.cooperationC.isChecked = true
|
|
|
+ }
|
|
|
+
|
|
|
+ when (guideResource.strainScore) {
|
|
|
+ "A" -> binding.adaptabilityA.isChecked = true
|
|
|
+ "B" -> binding.adaptabilityB.isChecked = true
|
|
|
+ "C" -> binding.adaptabilityC.isChecked = true
|
|
|
+ }
|
|
|
+
|
|
|
+ when (guideResource.localAndChineseScore) {
|
|
|
+ "A" -> binding.expressionA.isChecked = true
|
|
|
+ "B" -> binding.expressionB.isChecked = true
|
|
|
+ "C" -> binding.expressionC.isChecked = true
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ showMessage(resourceDetailResponse.msg)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onFailure(call: Call<GuideResourceDetailResponse>, t: Throwable) {
|
|
|
+ showErrorInfo(R.string.guide_resource_detail_get_failed)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
/**
|