package com.lukouguoji.aerologic.page.gnj.unload.add.dialog

import android.content.Context
import androidx.lifecycle.MutableLiveData
import com.lukouguoji.aerologic.R
import com.lukouguoji.aerologic.databinding.DialogGnjUnloadAddBinding
import com.lukouguoji.module_base.base.BaseDialogModel
import com.lukouguoji.module_base.ktx.formatDate
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
import com.lukouguoji.module_base.util.DictUtils
import dev.utils.common.DateUtils

class GnjUnloadAddSetFlightDialogModel(
    private val callBack: () -> Unit
) : BaseDialogModel<DialogGnjUnloadAddBinding>(
    DIALOG_TYPE_CENTER
) {

    val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())

    val fno = MutableLiveData("")

    //货物类型：0“国际货”，1“活体鲜活”，2“贵重物品”，3“其他特货”
    var cargoType: String = ""

    val cargoTypeList = DictUtils.airCargoTypeList

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

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

    fun onConfirmClick() {
        if ((date.value.verifyNullOrEmpty("请选择航班日期")
                    || fno.value.verifyNullOrEmpty("请输入航班号"))
        ) {
            return
        }
        dismiss()
        callBack()
    }
}