package com.lukouguoji.module_base.bean

import androidx.databinding.BaseObservable
import androidx.databinding.ObservableArrayList
import androidx.databinding.ObservableBoolean
import dev.utils.common.NumberUtils

class GjcBoxAddListBean(
    // 运单信息
    var waybillBean: GjcWaybillBean = GjcWaybillBean()
) : BaseObservable() {

    val show = ObservableBoolean(false)

    // 件号列表
    var jianList: ObservableArrayList<JianBean> = ObservableArrayList<JianBean>()

    // 件号表ID
    var pcID = ""

}

class JianBean(
    val code: String,
    val value: String,
) {
    val checked: ObservableBoolean = ObservableBoolean(false)

    companion object {
        fun create(value: String): JianBean {
            return JianBean(getCode(value), value)
        }

        fun getCode(code: String): String {
            val replace = code.replace("-", "")
            return if (NumberUtils.isNumber(code) && code.length == 5) {
                code.toInt().toString()
            } else if (replace.length < 5) {
                code
            } else {
                replace.substring(replace.length-5)
            }
        }
    }
}