package com.lukouguoji.gjc.dialog

import android.content.Context
import androidx.lifecycle.MutableLiveData
import com.lukouguoji.gjc.R
import com.lukouguoji.gjc.databinding.DialogGjcInspectionRejectBinding
import com.lukouguoji.module_base.base.BaseDialogModel
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty

/**
 * 国际出港收运检查 - 退回原因对话框
 */
class GjcInspectionRejectDialogModel(
    private val callback: (String) -> Unit  // 回调传递退回原因
) : BaseDialogModel<DialogGjcInspectionRejectBinding>(DIALOG_TYPE_CENTER) {

    // 退回原因
    val rejectReason = MutableLiveData("")

    override fun layoutId(): Int {
        return R.layout.dialog_gjc_inspection_reject
    }

    override fun onDialogCreated(context: Context) {
        binding.model = this
    }

    /**
     * 保存按钮点击
     */
    fun onConfirmClick() {
        // 验证退回原因
        if (rejectReason.value.verifyNullOrEmpty("请输入退回原因")) {
            return
        }

        dismiss()
        callback(rejectReason.value!!)
    }
}
