diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/TakeOverReasonWindow.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/TakeOverReasonWindow.kt index 3e8428af81..1664c9b777 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/TakeOverReasonWindow.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/TakeOverReasonWindow.kt @@ -19,11 +19,9 @@ import android.view.animation.ScaleAnimation import android.widget.EditText import android.widget.ImageView import android.widget.TextView -import android.widget.ToggleButton import androidx.appcompat.widget.AppCompatEditText import androidx.appcompat.widget.AppCompatTextView import androidx.constraintlayout.widget.ConstraintLayout -import androidx.constraintlayout.widget.Group import androidx.core.content.ContextCompat import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -82,28 +80,28 @@ class TakeOverReasonWindow constructor(activity: Activity) : View.OnTouchListene private var clickListener: ClickListener? = null private lateinit var tvTakeOverTime: TextView - private lateinit var tbTakeOverType: ToggleButton - private lateinit var tbTakeOverReason: ToggleButton - private lateinit var viewTakeOverReason: View - private lateinit var ivTakeOverReason: ImageView + private lateinit var tvTakeOverType: AppCompatTextView + private lateinit var tvTakeOverReason: AppCompatTextView private lateinit var etNoteInput: AppCompatEditText private lateinit var ivNoteAudio: ImageView private lateinit var tvTakeOverSave: TextView private lateinit var tvTakeOverCancel: TextView private lateinit var rvTakeOverList: RecyclerView - private lateinit var tvUploadSuccess: AppCompatTextView - private lateinit var takeOverReasonGroup: Group private lateinit var orderReasonAdapter: OrderReasonAdapter private lateinit var mTakeOverRecordInfo: TakeOverRecordInfo private val type = 2 //接管类接口请求Type值为2 private var source: Int = 0 //操作源,0:默认,一级分类 1:类型,二级分类;2:原因,三级分类 + private var hasLevel2: Boolean = false //是否有二级分类 private var hasLevel3: Boolean = false //是否有三级分类 private var typeList: List ?= null //故障类型列表 private var reasonList: List ?= null //故障原因列表 + private var faultTypeSelectStatus: Boolean = false //故障类型选择状态 + private var faultReasonSelectStatus: Boolean = false //故障原因选择状态 + private var level1Id: Int = 0 //一级分类ID private var level2Id: Int = 0 //二级分类ID private var level3Id: Int = 0 //三级分类ID @@ -139,17 +137,13 @@ class TakeOverReasonWindow constructor(activity: Activity) : View.OnTouchListene private fun initView(){ tvTakeOverTime = mFloatLayout.findViewById(R.id.tvTakeOverTime) - tbTakeOverType = mFloatLayout.findViewById(R.id.tbTakeOverType) - tbTakeOverReason = mFloatLayout.findViewById(R.id.tbTakeOverReason) - viewTakeOverReason = mFloatLayout.findViewById(R.id.viewTakeOverReason) - ivTakeOverReason = mFloatLayout.findViewById(R.id.ivTakeOverReason) + tvTakeOverType = mFloatLayout.findViewById(R.id.tvTakeOverType) + tvTakeOverReason = mFloatLayout.findViewById(R.id.tvTakeOverReason) etNoteInput = mFloatLayout.findViewById(R.id.etNoteInput) ivNoteAudio = mFloatLayout.findViewById(R.id.ivNoteAudio) tvTakeOverSave = mFloatLayout.findViewById(R.id.tvTakeOverSave) tvTakeOverCancel = mFloatLayout.findViewById(R.id.tvTakeOverCancel) rvTakeOverList = mFloatLayout.findViewById(R.id.rvTakeOverList) - tvUploadSuccess = mFloatLayout.findViewById(R.id.tvUploadSuccess) - takeOverReasonGroup = mFloatLayout.findViewById(R.id.takeOverReasonGroup) val linearLayoutManager = LinearLayoutManager(mActivity) linearLayoutManager.orientation = LinearLayoutManager.VERTICAL rvTakeOverList.layoutManager = linearLayoutManager @@ -158,30 +152,23 @@ class TakeOverReasonWindow constructor(activity: Activity) : View.OnTouchListene override fun onSelectReason(reason: CategoryInfo, mSource: Int) { if(mSource == 1){ //类型 - tbTakeOverType.textOn = reason.name - tbTakeOverType.textOff = reason.name - //选择了故障类型 - tbTakeOverReason.visibility = View.VISIBLE - viewTakeOverReason.visibility = View.GONE - ivTakeOverReason.visibility = View.GONE - tbTakeOverType.performClick() + tvTakeOverType.text = reason.name + //选择了接管类型 + tvTakeOverType.performClick() if(level2Id != 0 && level2Id == reason.id){ //故障类型选择没有变化 reasonList?.let { orderReasonAdapter.setData(it,2) } }else{ level2Id = reason.id level2Name = reason.name - tbTakeOverReason.textOn = "" - tbTakeOverReason.textOff = "" source = 2 //获取故障三级分类即故障原因 CallerDevaToolsManager.getCategories(BadCaseConfig.tenantId,3,level2Id,type,0) } }else{ //原因 - tbTakeOverReason.textOn = reason.name - tbTakeOverReason.textOff = reason.name - tbTakeOverReason.performClick() + tvTakeOverReason.text = reason.name + tvTakeOverReason.performClick() level3Id = reason.id level3Name = reason.name } @@ -200,47 +187,60 @@ class TakeOverReasonWindow constructor(activity: Activity) : View.OnTouchListene //获取一级分类 CallerDevaToolsManager.getCategories(BadCaseConfig.tenantId,1,0,type,0) //接管类型选择 - tbTakeOverType.setOnCheckedChangeListener { buttonView, isChecked -> - if (isChecked) { - buttonView.setCompoundDrawables(null, null, iconUp, null) + tvTakeOverType.setOnClickListener { + if(!hasLevel2){ + ToastUtils.showShort("运营后台没有配置接管类型") + return@setOnClickListener + } + if(faultTypeSelectStatus){ + //关闭 + faultTypeSelectStatus = false + tvTakeOverType.setCompoundDrawables(null, null, iconDown, null) + //隐藏列表 + rvTakeOverList.visibility = View.GONE + }else{ + //如果故障原因此时为打开状态,则关闭 + if(faultReasonSelectStatus){ + tvTakeOverReason.performClick() + } + //打开 + faultTypeSelectStatus = true + tvTakeOverType.setCompoundDrawables(null, null, iconUp, null) //展示列表 rvTakeOverList.visibility = View.VISIBLE - (rvTakeOverList.layoutParams as ConstraintLayout.LayoutParams).topToBottom = R.id.tbTakeOverType - tbTakeOverReason.visibility = View.INVISIBLE - + (rvTakeOverList.layoutParams as ConstraintLayout.LayoutParams).topToBottom = R.id.tvTakeOverType source = 1 if(typeList.isNullOrEmpty()){ - //获取故障二级分类即故障类型 + //获取故障二级分类即接管类型 CallerDevaToolsManager.getCategories(BadCaseConfig.tenantId,2,level1Id,type,0) }else{ orderReasonAdapter.setData(typeList!!,source) } - } else { - buttonView.setCompoundDrawables(null, null, iconDown, null) - //隐藏列表 - rvTakeOverList.visibility = View.GONE } } - viewTakeOverReason.setOnClickListener { - ToastUtils.showShort("请先选择接管类型") - } - ivTakeOverReason.setOnClickListener { - ToastUtils.showShort("请先选择接管类型") - } //接管原因选择 - tbTakeOverReason.setOnCheckedChangeListener { buttonView, isChecked -> - if (isChecked) { - buttonView.setCompoundDrawables(null, null, iconUp, null) - //展示列表 - rvTakeOverList.visibility = View.VISIBLE - (rvTakeOverList.layoutParams as ConstraintLayout.LayoutParams).topToBottom = R.id.tbTakeOverReason - } else { - buttonView.setCompoundDrawables(null, null, iconDown, null) + tvTakeOverReason.setOnClickListener { + if(tvTakeOverType.text.isEmpty()){ + ToastUtils.showShort("请先选择接管类型") + return@setOnClickListener + } + if(faultReasonSelectStatus){ + //关闭 + faultReasonSelectStatus = false + tvTakeOverReason.setCompoundDrawables(null, null, iconDown, null) //隐藏列表 rvTakeOverList.visibility = View.GONE + }else{ + //打开 + faultReasonSelectStatus = true + tvTakeOverReason.setCompoundDrawables(null, null, iconUp, null) + //展示列表 + rvTakeOverList.visibility = View.VISIBLE + (rvTakeOverList.layoutParams as ConstraintLayout.LayoutParams).topToBottom = R.id.tvTakeOverReason } } + //补充描述 etNoteInput.onFocusChangeListener = OnFocusChangeListener { v, hasFocus -> val edit = v as EditText @@ -477,11 +477,12 @@ class TakeOverReasonWindow constructor(activity: Activity) : View.OnTouchListene level1Name = list[0].name source = 1 - //获取故障二级分类即故障类型 + //获取故障二级分类即接管类型 CallerDevaToolsManager.getCategories(BadCaseConfig.tenantId,2,level1Id,type,0) }else{ if(source == 1){ typeList = list + hasLevel2 = true }else{ reasonList = list hasLevel3 = true @@ -492,6 +493,7 @@ class TakeOverReasonWindow constructor(activity: Activity) : View.OnTouchListene if(source == 2){ hasLevel3 = false }else{ + hasLevel2 = false ToastUtils.showShort("接管类型列表为空") } } diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/layout/view_take_over_reason.xml b/core/function-impl/mogo-core-function-devatools/src/main/res/layout/view_take_over_reason.xml index 6edb6f615f..19b481445b 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/res/layout/view_take_over_reason.xml +++ b/core/function-impl/mogo-core-function-devatools/src/main/res/layout/view_take_over_reason.xml @@ -65,8 +65,8 @@ android:layout_marginStart="@dimen/dp_14" /> - - - - - - @@ -160,7 +132,7 @@ android:layout_width="@dimen/dp_6" android:layout_height="@dimen/dp_29" android:background="#FF0176FF" - app:layout_constraintTop_toBottomOf="@id/tbTakeOverReason" + app:layout_constraintTop_toBottomOf="@id/tvTakeOverReason" app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="@dimen/dp_32" android:layout_marginTop="@dimen/dp_47" @@ -260,9 +232,9 @@ android:id="@+id/rvTakeOverList" android:layout_width="@dimen/dp_0" android:layout_height="@dimen/dp_0" - app:layout_constraintLeft_toLeftOf="@id/tbTakeOverType" - app:layout_constraintRight_toRightOf="@id/tbTakeOverType" - app:layout_constraintTop_toBottomOf="@id/tbTakeOverType" + app:layout_constraintLeft_toLeftOf="@id/tvTakeOverType" + app:layout_constraintRight_toRightOf="@id/tvTakeOverType" + app:layout_constraintTop_toBottomOf="@id/tvTakeOverType" app:layout_constraintBottom_toBottomOf="parent" android:layout_marginBottom="@dimen/dp_39" android:background="@drawable/bg_reason_list" @@ -271,32 +243,4 @@ android:paddingTop="@dimen/dp_5" /> - - - - - \ No newline at end of file