|
@@ -63,9 +63,65 @@ class AddCarResourceActivity : BaseActivity<ActivityAddCarResourceBinding>() {
|
|
|
if (fromList) {
|
|
|
|
|
|
carResource = intent.getSerializableExtra("carResource", CarResource::class.java) as CarResource
|
|
|
+
|
|
|
initCarResourceInfo()
|
|
|
|
|
|
- binding.commit.text = resources.getString(R.string.update)
|
|
|
+ binding.commit.setText(resources.getString(R.string.update))
|
|
|
+
|
|
|
+ if (!OASystem.authorization(OASystem.CAR_RESOURCE, OASystem.EDIT)) {
|
|
|
+ binding.apply {
|
|
|
+ carCompany.inputType = InputType.TYPE_NULL
|
|
|
+ companyScore.isEnabled = false
|
|
|
+ departmentArea.inputType = InputType.TYPE_NULL
|
|
|
+ departmentLocation.setInputType(InputType.TYPE_NULL)
|
|
|
+ contactsName.inputType = InputType.TYPE_NULL
|
|
|
+ contactsPhone.inputType = InputType.TYPE_NULL
|
|
|
+ contactsEmail.inputType = InputType.TYPE_NULL
|
|
|
+ contactsFax.inputType = InputType.TYPE_NULL
|
|
|
+ carDescription.setInputType(InputType.TYPE_NULL)
|
|
|
+ otherInfo.setInputType(InputType.TYPE_NULL)
|
|
|
+ otherInfo.setSingleLine(false)
|
|
|
+
|
|
|
+ carQualificationA.isEnabled = false
|
|
|
+ carQualificationB.isEnabled = false
|
|
|
+ carQualificationC.isEnabled = false
|
|
|
+
|
|
|
+ carAgeA.isEnabled = false
|
|
|
+ carAgeB.isEnabled = false
|
|
|
+ carAgeC.isEnabled = false
|
|
|
+
|
|
|
+ carSurfaceA.isEnabled = false
|
|
|
+ carSurfaceB.isEnabled = false
|
|
|
+ carSurfaceC.isEnabled = false
|
|
|
+
|
|
|
+ carInnerA.isEnabled = false
|
|
|
+ carInnerB.isEnabled = false
|
|
|
+ carInnerC.isEnabled = false
|
|
|
+
|
|
|
+ carPrepareA.isEnabled = false
|
|
|
+ carPrepareB.isEnabled = false
|
|
|
+ carPrepareC.isEnabled = false
|
|
|
+
|
|
|
+ carDisposeA.isEnabled = false
|
|
|
+ carDisposeB.isEnabled = false
|
|
|
+ carDisposeC.isEnabled = false
|
|
|
+
|
|
|
+ timeConceptA.isEnabled = false
|
|
|
+ timeConceptB.isEnabled = false
|
|
|
+ timeConceptC.isEnabled = false
|
|
|
+
|
|
|
+ safetyConceptA.isEnabled = false
|
|
|
+ safetyConceptB.isEnabled = false
|
|
|
+ safetyConceptC.isEnabled = false
|
|
|
+
|
|
|
+ driverA.isEnabled = false
|
|
|
+ driverB.isEnabled = false
|
|
|
+ driverC.isEnabled = false
|
|
|
+
|
|
|
+ commit.setText(resources.getString(R.string.back))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
|
|
|
carResource = CarResource()
|
|
@@ -108,14 +164,46 @@ class AddCarResourceActivity : BaseActivity<ActivityAddCarResourceBinding>() {
|
|
|
}
|
|
|
|
|
|
binding.commit.setOnClickListener {
|
|
|
+
|
|
|
if (fromList) {
|
|
|
- updateCarResource()
|
|
|
- } else {
|
|
|
- if (isChose) {
|
|
|
- addCarResource()
|
|
|
- } else {
|
|
|
+ if (OASystem.authorization(OASystem.CAR_RESOURCE, OASystem.EDIT)) {
|
|
|
+ back()
|
|
|
+ return@setOnClickListener
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ when {
|
|
|
+ binding.carCompany.text.isNullOrBlank() -> {
|
|
|
+ showMessage(resources.getString(R.string.department_name_hint))
|
|
|
+ }
|
|
|
+
|
|
|
+ !isChose -> {
|
|
|
showMessage(resources.getString(R.string.score_select_hint))
|
|
|
}
|
|
|
+
|
|
|
+ binding.departmentArea.text.isNullOrBlank() -> {
|
|
|
+ showMessage(resources.getString(R.string.department_location_input_hint))
|
|
|
+ }
|
|
|
+
|
|
|
+ binding.contactsName.text.isNullOrBlank() -> {
|
|
|
+ showMessage(resources.getString(R.string.connector_name_input_hint))
|
|
|
+ }
|
|
|
+
|
|
|
+ binding.contactsPhone.text.isNullOrBlank() -> {
|
|
|
+ showMessage(resources.getString(R.string.connector_phone_input_hint))
|
|
|
+ }
|
|
|
+
|
|
|
+ else -> {
|
|
|
+ binding.commit.setButtonStatus(1)
|
|
|
+
|
|
|
+ initCarResource()
|
|
|
+
|
|
|
+ if (fromList) {
|
|
|
+ updateCarResource()
|
|
|
+ } else {
|
|
|
+ addCarResource()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -187,73 +275,12 @@ class AddCarResourceActivity : BaseActivity<ActivityAddCarResourceBinding>() {
|
|
|
"B" -> binding.driverB.isChecked = true
|
|
|
"C" -> binding.driverC.isChecked = true
|
|
|
}
|
|
|
-
|
|
|
- if (!OASystem.authorization(OASystem.CAR_RESOURCE, OASystem.EDIT)) {
|
|
|
- binding.apply {
|
|
|
- carCompany.inputType = InputType.TYPE_NULL
|
|
|
- companyScore.isEnabled = false
|
|
|
- departmentArea.inputType = InputType.TYPE_NULL
|
|
|
- departmentLocation.setInputType(InputType.TYPE_NULL)
|
|
|
- contactsName.inputType = InputType.TYPE_NULL
|
|
|
- contactsPhone.inputType = InputType.TYPE_NULL
|
|
|
- contactsEmail.inputType = InputType.TYPE_NULL
|
|
|
- contactsFax.inputType = InputType.TYPE_NULL
|
|
|
- carDescription.setInputType(InputType.TYPE_NULL)
|
|
|
- otherInfo.setInputType(InputType.TYPE_NULL)
|
|
|
- otherInfo.setSingleLine(false)
|
|
|
-
|
|
|
- carQualificationA.isEnabled = false
|
|
|
- carQualificationB.isEnabled = false
|
|
|
- carQualificationC.isEnabled = false
|
|
|
-
|
|
|
- carAgeA.isEnabled = false
|
|
|
- carAgeB.isEnabled = false
|
|
|
- carAgeC.isEnabled = false
|
|
|
-
|
|
|
- carSurfaceA.isEnabled = false
|
|
|
- carSurfaceB.isEnabled = false
|
|
|
- carSurfaceC.isEnabled = false
|
|
|
-
|
|
|
- carInnerA.isEnabled = false
|
|
|
- carInnerB.isEnabled = false
|
|
|
- carInnerC.isEnabled = false
|
|
|
-
|
|
|
- carPrepareA.isEnabled = false
|
|
|
- carPrepareB.isEnabled = false
|
|
|
- carPrepareC.isEnabled = false
|
|
|
-
|
|
|
- carDisposeA.isEnabled = false
|
|
|
- carDisposeB.isEnabled = false
|
|
|
- carDisposeC.isEnabled = false
|
|
|
-
|
|
|
- timeConceptA.isEnabled = false
|
|
|
- timeConceptB.isEnabled = false
|
|
|
- timeConceptC.isEnabled = false
|
|
|
-
|
|
|
- safetyConceptA.isEnabled = false
|
|
|
- safetyConceptB.isEnabled = false
|
|
|
- safetyConceptC.isEnabled = false
|
|
|
-
|
|
|
- driverA.isEnabled = false
|
|
|
- driverB.isEnabled = false
|
|
|
- driverC.isEnabled = false
|
|
|
-
|
|
|
- commit.visibility = View.GONE
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改车辆资源数据
|
|
|
*/
|
|
|
private fun updateCarResource() {
|
|
|
- initCarResource()
|
|
|
-
|
|
|
- binding.commit.isEnabled = false
|
|
|
-
|
|
|
- binding.commit.visibility = View.GONE
|
|
|
-
|
|
|
- binding.updateLoading.visibility = View.VISIBLE
|
|
|
|
|
|
val apiService = ServiceCreator.create<APIService>()
|
|
|
apiService.updateCarData(carResource).enqueue(object : Callback<BaseResponse> {
|
|
@@ -269,22 +296,14 @@ class AddCarResourceActivity : BaseActivity<ActivityAddCarResourceBinding>() {
|
|
|
} else {
|
|
|
showMessage(baseResponse.msg)
|
|
|
|
|
|
- binding.commit.isEnabled = true
|
|
|
-
|
|
|
- binding.commit.visibility = View.VISIBLE
|
|
|
-
|
|
|
- binding.updateLoading.visibility = View.GONE
|
|
|
+ binding.commit.setButtonStatus(0)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
override fun onFailure(call: Call<BaseResponse>, t: Throwable) {
|
|
|
|
|
|
- binding.commit.isEnabled = true
|
|
|
-
|
|
|
- binding.commit.visibility = View.VISIBLE
|
|
|
-
|
|
|
- binding.updateLoading.visibility = View.GONE
|
|
|
+ binding.commit.setButtonStatus(0)
|
|
|
|
|
|
showErrorInfo(R.string.update_error)
|
|
|
}
|
|
@@ -295,13 +314,6 @@ class AddCarResourceActivity : BaseActivity<ActivityAddCarResourceBinding>() {
|
|
|
* 新增车辆资源数据
|
|
|
*/
|
|
|
private fun addCarResource() {
|
|
|
- initCarResource()
|
|
|
-
|
|
|
- binding.commit.isEnabled = false
|
|
|
-
|
|
|
- binding.commit.visibility = View.GONE
|
|
|
-
|
|
|
- binding.updateLoading.visibility = View.VISIBLE
|
|
|
|
|
|
val apiService = ServiceCreator.create<APIService>()
|
|
|
apiService.addCarData(carResource).enqueue(object : Callback<BaseResponse> {
|
|
@@ -317,22 +329,14 @@ class AddCarResourceActivity : BaseActivity<ActivityAddCarResourceBinding>() {
|
|
|
} else {
|
|
|
showMessage(baseResponse.msg)
|
|
|
|
|
|
- binding.commit.isEnabled = true
|
|
|
-
|
|
|
- binding.commit.visibility = View.VISIBLE
|
|
|
-
|
|
|
- binding.updateLoading.visibility = View.GONE
|
|
|
+ binding.commit.setButtonStatus(0)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
override fun onFailure(call: Call<BaseResponse>, t: Throwable) {
|
|
|
|
|
|
- binding.commit.isEnabled = true
|
|
|
-
|
|
|
- binding.commit.visibility = View.VISIBLE
|
|
|
-
|
|
|
- binding.updateLoading.visibility = View.GONE
|
|
|
+ binding.commit.setButtonStatus(0)
|
|
|
|
|
|
showErrorInfo(R.string.update_error)
|
|
|
}
|