"use strict";const l=require("../../../common/vendor.js"),e=require("./model.js"),u=require("../../../common/libraries/apiLoading.js"),o=require("../../../gen/Apis.js"),i=require("../../../common/libraries/naviHelper.js"),a=()=>{var l,i;e.useModel.billsLength.value=0,u.getApiLoading(o.Apis.Bill.HouseBills.MyBillYearList,null==(i=null==(l=e.useModel)?void 0:l.formData)?void 0:i.value).then((l=>{var u;null==(u=null==l?void 0:l.data)||u.map((l=>{var u,o;e.useModel.billsLength.value+=(null==(u=null==l?void 0:l.bills)?void 0:u.length)||0,null==(o=null==l?void 0:l.bills)||o.map((l=>{var e;l.checked=!0,null==(e=null==l?void 0:l.details)||e.map((l=>{l.checked=!0}))}))})),e.useModel.items.value=[...e.useModel.items.value,...null==l?void 0:l.data],d()}))},d=()=>{var l,u,o;let i=0;null==(o=null==(u=null==(l=e.useModel)?void 0:l.items)?void 0:u.value)||o.map((l=>{var e;null==(e=null==l?void 0:l.bills)||e.map((l=>{i+=parseFloat(l.amount||0)}))})),e.useModel.total_amount.value=parseFloat(i.toFixed(2))},s={handleGetList:a,handleCollapseClick:(l,u,o)=>{var i,a,d,s;let n=null==(s=null==(d=null==(a=null==(i=e.useModel)?void 0:i.items)?void 0:a.value[l])?void 0:d.bills[u])?void 0:s.show;e.useModel.items.value[l].bills[u].show=!n},hanldeSearch:l=>{var u,o;e.useModel.items.value=[],e.useModel.formData.value={...null==(o=null==(u=e.useModel)?void 0:u.formData)?void 0:o.value,...l,page:1},a()},handleCalculatePrice(l,u,o,i){var a,s,n,v,t,r,m,c,h,p,b,M,g;if(e.useModel.currentTabs.value)return;let _=null==i?void 0:i.checked,k=parseFloat(null==(v=null==(n=null==(s=null==(a=e.useModel)?void 0:a.items)?void 0:s.value[l])?void 0:n.bills[u])?void 0:v.amount),y=parseFloat(null==(h=null==(c=null==(m=null==(r=null==(t=e.useModel)?void 0:t.items)?void 0:r.value[l])?void 0:m.bills[u])?void 0:c.details[o])?void 0:h.total_payable_amount);e.useModel.items.value[l].bills[u].details[o].checked=!_,e.useModel.items.value[l].bills[u].amount=_?k-y:k+y,e.useModel.items.value[l].bills[u].amount<=0?e.useModel.items.value[l].bills[u].checked=!1:(null==(g=null==(M=null==(b=null==(p=e.useModel)?void 0:p.items)?void 0:b.value[l])?void 0:M.bills[u])?void 0:g.checked)||(e.useModel.items.value[l].bills[u].checked=!0),d()},handleCollapseAllCheckedBtn:async(l,u,o)=>{var i,a,s,n,v;let t=null==o?void 0:o.checked,r=0;e.useModel.items.value[l].bills[u].checked=!t,t&&(e.useModel.items.value[l].bills[u].amount=0),null==(v=null==(n=null==(s=null==(a=null==(i=e.useModel)?void 0:i.items)?void 0:a.value[l])?void 0:s.bills[u])?void 0:n.details)||v.map((o=>{o.checked=!t,t||(r+=parseFloat(o.total_payable_amount)),e.useModel.items.value[l].bills[u].amount=r})),d(),console.log(l,u)},handleQuery(e){l.index.navigateTo({url:`/INDEX/bill/show/index?asset_houses_id=${null==e?void 0:e.asset_houses_id}&month=${null==e?void 0:e.month}`}),console.log(e,"res")},handleSubmitOrder(){var a,d,s,n,v,t,r;let m=[];null==(s=null==(d=null==(a=e.useModel)?void 0:a.items)?void 0:d.value)||s.map((l=>{var e;null==(e=null==l?void 0:l.bills)||e.map((l=>{var e;null==(e=null==l?void 0:l.details)||e.map((e=>{(null==l?void 0:l.checked)&&m.push(null==e?void 0:e.id)}))}))})),(null==m?void 0:m.length)?u.getApiLoading(o.Apis.HouseOrder.HouseOrders.Store,{bill_ids:m,amount:null==(v=null==(n=e.useModel)?void 0:n.total_amount)?void 0:v.value,total_payable_amount:null==(r=null==(t=e.useModel)?void 0:t.total_amount)?void 0:r.value}).then((e=>{var u;l.index.navigateTo({url:`/INDEX/pay/index?id=${null==(u=null==e?void 0:e.data)?void 0:u.id}`})})):i.showToast("至少选择一个账单！")}};exports.method=s;
