import 'package:cs_resources/constants/color_constants.dart';
import 'package:domain/entity/response/labour_report_v_n_entity.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:plugin_basic/basic_export.dart';
import 'package:widgets/ext/ex_widget.dart';

import 'package:widgets/my_text_view.dart';

/// 越南的用工报表的Item控件
class ReportLabourVNItem extends StatelessWidget {
  LabourReportVNEntity? entity; //主体数据
  int type; //0  1  2

  ReportLabourVNItem({
    required this.entity,
    required this.type,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      padding: const EdgeInsets.only(top: 16, bottom: 20,left: 15,right: 15),
      margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 15),
      decoration: BoxDecoration(
        color: const Color(0xFF4DCFF6).withOpacity(0.2), // 设置背景颜色和不透明度
        borderRadius: BorderRadius.circular(5), // 设置圆角
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          MyTextView(
            type == 0
                ? "Completed".tr
                : type == 1
                    ? "Incomplete".tr
                    : "Completed + Incomplete".tr,
            fontSize: 14,
            isFontBold: true,
            marginBottom: 15,
            marginLeft: 5,
            marginRight: 20,
            textColor: type == 0
                ? ColorConstants.textGreen0AC074
                : type == 1
                    ? ColorConstants.textBlue06D9FF
                    : ColorConstants.textRedFF6262,
          ),
          const Divider(height: 0.5, color: ColorConstants.dividerBar),
          SingleChildScrollView(
            scrollDirection: Axis.horizontal,
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                //第一列 部门
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    MyTextView(
                      "Outlet".tr,
                      fontSize: 14,
                      textColor: Colors.white,
                      isFontRegular: true,
                    ),
                    MyTextView(
                      "-",
                      textColor: Colors.transparent,
                      fontSize: 14,
                      isFontRegular: true,
                    ),
                    ...(entity?.rows.map((item) {
                          return MyTextView(
                            item.outletName ?? "-",
                            fontSize: 14,
                            maxLines: 1,
                            isTextEllipsis: true,
                            textColor: Colors.white,
                            isFontRegular: true,
                            marginTop: 6,
                            marginBottom: 6,
                          );
                        }).toList() ??
                        []),
                  ],
                ).constrained(maxWidth: 100),

                //第二列 小时
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    MyTextView("Hours".tr, textColor: Colors.white, fontSize: 14, isFontRegular: true),
                    MyTextView(
                      "(${entity?.total?.hrs})",
                      textColor: type == 0
                          ? ColorConstants.textGreen0AC074
                          : type == 1
                              ? ColorConstants.textBlue06D9FF
                              : ColorConstants.textRedFF6262,
                      fontSize: 14,
                      isFontRegular: true,
                    ),
                    ...(entity?.rows.map((item) {
                          return MyTextView(
                            "${type == 0 ? item.hrs ?? "0" : type == 1 ? item.inHrs ?? "0" : item.totHrs ?? "0"} H",
                            fontSize: 14,
                            textColor: Colors.white,
                            isFontRegular: true,
                            marginTop: 6,
                            marginBottom: 6,
                          );
                        }).toList() ??
                        []),
                  ],
                ).constrained(maxWidth: 100).marginOnly(left: 25),

                //第三列 房间
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    MyTextView("Rooms".tr, textColor: Colors.white, fontSize: 14, isFontRegular: true),
                    MyTextView(
                      "(${entity?.total?.rms})",
                      textColor: type == 0
                          ? ColorConstants.textGreen0AC074
                          : type == 1
                              ? ColorConstants.textBlue06D9FF
                              : ColorConstants.textRedFF6262,
                      fontSize: 14,
                      isFontRegular: true,
                    ),
                    ...(entity?.rows.map((item) {
                          return MyTextView(
                            type == 0
                                ? item.rms ?? ""
                                : type == 1
                                    ? item.inRms ?? ""
                                    : item.totRms ?? "",
                            fontSize: 14,
                            textColor: Colors.white,
                            isFontRegular: true,
                            marginTop: 6,
                            marginBottom: 6,
                          );
                        }).toList() ??
                        []),
                  ],
                ).constrained(maxWidth: 100).marginOnly(left: 25),

                //第四列 数量
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    MyTextView("Count".tr, textColor: Colors.white, fontSize: 14, isFontRegular: true),
                    MyTextView(
                      "(${entity?.total?.num})",
                      textColor: type == 0
                          ? ColorConstants.textGreen0AC074
                          : type == 1
                              ? ColorConstants.textBlue06D9FF
                              : ColorConstants.textRedFF6262,
                      fontSize: 14,
                      isFontRegular: true,
                    ),
                    ...(entity?.rows.map((item) {
                          return MyTextView(
                            type == 0
                                ? item.num ?? ""
                                : type == 1
                                    ? item.inNum ?? ""
                                    : item.totNum ?? "",
                            fontSize: 14,
                            textColor: Colors.white,
                            isFontRegular: true,
                            marginTop: 6,
                            marginBottom: 6,
                          );
                        }).toList() ??
                        []),
                  ],
                ).constrained(maxWidth: 100).marginOnly(left: 25),

                //第五列 总金额
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    MyTextView("TotalAmt".tr, textColor: Colors.white, fontSize: 14, isFontRegular: true),
                    MyTextView(
                      "(${entity?.total?.totAmt})",
                      textColor: type == 0
                          ? ColorConstants.textGreen0AC074
                          : type == 1
                              ? ColorConstants.textBlue06D9FF
                              : ColorConstants.textRedFF6262,
                      fontSize: 14,
                      isFontRegular: true,
                    ),
                    ...(entity?.rows.map((item) {
                          return MyTextView(
                            "₫ ${type == 0 ? item.amt ?? "0" : type == 1 ? item.inAmt ?? "0" : item.totAmt ?? "0"}",
                            fontSize: 14,
                            textColor: Colors.white,
                            isFontRegular: true,
                            marginTop: 6,
                            marginBottom: 6,
                          );
                        }).toList() ??
                        []),
                  ],
                ).constrained(maxWidth: 100).marginOnly(left: 25),
              ],
            ).marginOnly(left: 5, right: 5, top: 18, bottom: 2),
          ),
        ],
      ),
    );
  }
}
