<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <import type="android.view.View" />

        <import type="com.lukouguoji.module_base.ui.weight.data.layout.DataLayoutType" />

        <import type="com.lukouguoji.module_base.common.DetailsPageType" />

        <variable
            name="viewModel"
            type="com.lukouguoji.gjj.viewModel.IntImpAccidentVisaEditViewModel" />
    </data>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/color_f2"
        android:orientation="vertical">

        <include layout="@layout/title_tool_bar" />

        <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:padding="15dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/bg_white_radius_8"
                    android:orientation="vertical"
                    android:padding="15dp">

                    <!-- Row 1: 航班日期 | 航班号 -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal">

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请选择航班日期"}'
                            setRefreshCallBack="@{viewModel::onFlightDateInputComplete}"
                            title='@{"航班日期"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.DATE}"
                            value='@={viewModel.dataBean.fdate}' />

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:id="@+id/fnoInput"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请输入航班号"}'
                            setRefreshCallBack="@{viewModel::onFlightNoInputComplete}"
                            title='@{"航班号"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.INPUT}"
                            value='@={viewModel.dataBean.fno}' />

                    </LinearLayout>

                    <!-- Row 2: 始发站 | 目的站 -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:orientation="horizontal">

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{false}"
                            hint='@{"航班信息自动填充"}'
                            title='@{"始发站"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.INPUT}"
                            value='@{viewModel.dataBean.dep}' />

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{false}"
                            hint='@{"航班信息自动填充"}'
                            title='@{"目的站"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.INPUT}"
                            value='@{viewModel.dataBean.dest}' />

                    </LinearLayout>

                    <!-- Row 3: 运单号 | 不正常件数 -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:orientation="horizontal">

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:id="@+id/wbNoInput"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请输入运单号"}'
                            title='@{"运单号"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.INPUT}"
                            value='@={viewModel.dataBean.wbNo}' />

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请输入不正常件数"}'
                            title='@{"不正常件数"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.INPUT}"
                            value='@={viewModel.dataBean.dpc}' />

                    </LinearLayout>

                    <!-- Row 4: 运单总件数 | 运单总重量 -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:orientation="horizontal">

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请输入运单总件数"}'
                            title='@{"运单总件数"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.INPUT}"
                            value='@={viewModel.dataBean.pc}' />

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请输入运单总重量"}'
                            title='@{"运单总重量"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.INPUT}"
                            value='@={viewModel.dataBean.weight}' />

                    </LinearLayout>

                    <!-- Row 5: 复称重量 | 品名 -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:orientation="horizontal">

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请输入复称重量"}'
                            title='@{"复称重量"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.INPUT}"
                            value='@={viewModel.dataBean.reWeight}' />

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请输入品名"}'
                            title='@{"品名"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.INPUT}"
                            value='@={viewModel.dataBean.goods}' />

                    </LinearLayout>

                    <!-- Row 6: 外包装 | 包装破损情况 -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:orientation="horizontal">

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请选择外包装"}'
                            list="@{viewModel.outerPackageList}"
                            title='@{"外包装"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.SPINNER}"
                            value='@={viewModel.dataBean.opacking}' />

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请选择破损情况"}'
                            list="@{viewModel.damageTypeList}"
                            title='@{"包装破损情况"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.SPINNER}"
                            value='@={viewModel.dataBean.damage}' />

                    </LinearLayout>

                    <!-- Row 7: 内容物情况 | 不正常类型 -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:orientation="horizontal">

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请选择内容物情况"}'
                            list="@{viewModel.contentTypeList}"
                            title='@{"内容物情况"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.SPINNER}"
                            value='@={viewModel.dataBean.condition}' />

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请选择不正常类型"}'
                            list="@{viewModel.unusualTypeList}"
                            title='@{"不正常类型"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.SPINNER}"
                            value='@={viewModel.dataBean.kdamage}' />

                    </LinearLayout>

                    <!-- Row 8: 发现时间 | 图片是否留底 -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:orientation="horizontal">

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请选择发现时间"}'
                            title='@{"发现时间"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.DATE}"
                            value='@={viewModel.dataBean.seachDate}' />

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请选择"}'
                            list="@{viewModel.photoList}"
                            title='@{"图片是否留底"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.SPINNER}"
                            value='@={viewModel.dataBean.photo}' />

                    </LinearLayout>

                    <!-- Row 9: 备注（整行） -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:orientation="horizontal">

                        <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            enable="@{!viewModel.isDetailMode}"
                            hint='@{"请输入备注"}'
                            inputHeight="@{80}"
                            title='@{"备注"}'
                            titleLength="@{6}"
                            type="@{DataLayoutType.INPUT}"
                            value='@={viewModel.dataBean.remarks}' />

                    </LinearLayout>

                    <!-- 图片区域：label 在左，图片在右 -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="15dp"
                        android:layout_marginStart="4dp"
                        android:orientation="horizontal">

                        <TextView
                            android:id="@+id/tv_image_title"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:text='@{viewModel.isDetailMode ? "图片" : "上传图像"}'
                            android:textColor="@color/text_gray"
                            completeSpace="@{6}" />

                        <androidx.recyclerview.widget.RecyclerView
                            android:id="@+id/rv"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:layout_marginStart="10dp"
                            android:overScrollMode="never"
                            itemLayoutId="@{viewModel.itemLayoutId}"
                            viewHolder="@{viewModel.itemViewHolder}"
                            app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
                            app:spanCount="9"
                            tools:listitem="@layout/item_image_select_new" />

                    </LinearLayout>

                    <!-- 详情模式下无图片时的占位提示 -->
                    <TextView
                        android:id="@+id/tv_no_image"
                        android:layout_width="match_parent"
                        android:layout_height="60dp"
                        android:gravity="center"
                        android:text="暂无图片"
                        android:textColor="@color/text_gray"
                        android:textSize="14sp"
                        android:visibility="@{viewModel.showNoImage ? View.VISIBLE : View.GONE}" />

                </LinearLayout>

                <!-- 底部按钮（详情模式隐藏） -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="24dp"
                    android:layout_marginBottom="15dp"
                    android:gravity="center"
                    android:orientation="horizontal"
                    android:visibility="@{viewModel.isDetailMode ? View.GONE : View.VISIBLE}">

                    <TextView
                        style="@style/tv_bottom_btn"
                        android:layout_width="120dp"
                        android:onClick="@{()-> viewModel.onCancelClick()}"
                        android:text="取消" />

                    <TextView
                        style="@style/tv_bottom_btn"
                        android:layout_width="120dp"
                        android:layout_marginLeft="20dp"
                        android:onClick="@{()-> viewModel.onSaveClick()}"
                        android:text="保存" />

                </LinearLayout>

            </LinearLayout>

        </androidx.core.widget.NestedScrollView>

    </LinearLayout>

</layout>
