"use strict";
const common_vendor = require("../../../../common/vendor.js");
const gen_Enums = require("../../../../gen/Enums.js");
const BILL_outstanding_fee_show_model = require("../model.js");
const BILL_outstanding_fee_show_method = require("../method.js");
require("../../../../common/libraries/day.js");
require("../../../../common/libraries/request.js");
require("../../../../common/store/useWeAppAuthStore.js");
require("../../../../gen/Apis.js");
require("../../../../common/store/useWatermarkStore.js");
require("../../../../common/store/useWorkStore.js");
require("../../../../common/libraries/apiLoading.js");
require("../../../../common/libraries/naviHelper.js");
require("../../../../common/libraries/sendWxWork.js");
if (!Array) {
  const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  const _easycom_hs_enum_tag2 = common_vendor.resolveComponent("hs-enum-tag");
  (_easycom_uni_icons2 + _easycom_hs_enum_tag2)();
}
const _easycom_uni_icons = () => "../../../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
const _easycom_hs_enum_tag = () => "../../../../components/hs-enum-tag/hs-enum-tag.js";
if (!Math) {
  (_easycom_uni_icons + _easycom_hs_enum_tag)();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "BillItem",
  props: ["item", "index"],
  setup(__props) {
    const props = __props;
    const billsShow = common_vendor.ref(false);
    const handleCollapseAllCheckedBtn = () => {
      var _a, _b, _c, _d, _e, _f;
      let checked = (_a = props == null ? void 0 : props.item) == null ? void 0 : _a.checked;
      BILL_outstanding_fee_show_model.useModel.houseBillsData.value[props == null ? void 0 : props.index].checked = !checked;
      (_e = (_d = (_c = (_b = BILL_outstanding_fee_show_model.useModel) == null ? void 0 : _b.houseBillsData) == null ? void 0 : _c.value[props == null ? void 0 : props.index]) == null ? void 0 : _d.bills) == null ? void 0 : _e.map((i) => {
        i.checked = !checked;
      });
      (_f = BILL_outstanding_fee_show_method.method) == null ? void 0 : _f.setCalculateTotalPrice();
    };
    const handleCalculatePrice = (res, index) => {
      var _a, _b;
      let checked = res == null ? void 0 : res.checked;
      BILL_outstanding_fee_show_model.useModel.houseBillsData.value[props == null ? void 0 : props.index].bills[index].checked = !checked;
      if (checked) {
        BILL_outstanding_fee_show_model.useModel.houseBillsData.value[props == null ? void 0 : props.index].checked = false;
      } else {
        let allChecked = (_a = BILL_outstanding_fee_show_model.useModel.houseBillsData.value[props == null ? void 0 : props.index].bills) == null ? void 0 : _a.every(
          (item) => item == null ? void 0 : item.checked
        );
        BILL_outstanding_fee_show_model.useModel.houseBillsData.value[props == null ? void 0 : props.index].checked = allChecked;
        console.log(allChecked);
      }
      (_b = BILL_outstanding_fee_show_method.method) == null ? void 0 : _b.setCalculateTotalPrice();
    };
    return (_ctx, _cache) => {
      var _a, _b, _c, _d, _e;
      return common_vendor.e({
        a: (_a = props == null ? void 0 : props.item) == null ? void 0 : _a.checked
      }, ((_b = props == null ? void 0 : props.item) == null ? void 0 : _b.checked) ? {
        b: common_vendor.p({
          type: "checkbox-filled",
          size: "20",
          color: "#2A7EFB"
        })
      } : {
        c: common_vendor.p({
          type: "circle",
          size: "20",
          color: "#888"
        })
      }, {
        d: common_vendor.t((_c = props == null ? void 0 : props.item) == null ? void 0 : _c.display_text),
        e: common_vendor.o(handleCollapseAllCheckedBtn),
        f: common_vendor.t((_d = props == null ? void 0 : props.item) == null ? void 0 : _d.pending_amount),
        g: common_vendor.p({
          type: "down",
          size: "15",
          color: "#666"
        }),
        h: common_vendor.o(($event) => billsShow.value = !billsShow.value),
        i: billsShow.value
      }, billsShow.value ? {
        j: common_vendor.f((_e = props == null ? void 0 : props.item) == null ? void 0 : _e.bills, (i, index, i0) => {
          return common_vendor.e({
            a: i == null ? void 0 : i.checked
          }, (i == null ? void 0 : i.checked) ? {
            b: "8af7247a-3-" + i0,
            c: common_vendor.p({
              type: "checkbox-filled",
              size: "20",
              color: "#2A7EFB"
            })
          } : {
            d: "8af7247a-4-" + i0,
            e: common_vendor.p({
              type: "circle",
              size: "20",
              color: "#888"
            })
          }, {
            f: "8af7247a-5-" + i0,
            g: common_vendor.p({
              value: i == null ? void 0 : i.type,
              Enums: common_vendor.unref(gen_Enums.HouseBillsTypeEnum)
            }),
            h: common_vendor.o(($event) => handleCalculatePrice(i, index), `fid_items_${index}`),
            i: common_vendor.t(i == null ? void 0 : i.total_payable_amount),
            j: `fid_items_${index}`
          });
        })
      } : {});
    };
  }
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-8af7247a"], ["__file", "/Users/zsq/Sources/github/2025property-pay/pay-employee/src/BILL/outstanding_fee/show/components/BillItem.vue"]]);
wx.createComponent(Component);
