"use strict";const e=require("../../../common/vendor.js"),o=require("../../../gen/Apis.js"),l=require("../../../common/libraries/apiLoading.js"),a=require("../../../common/libraries/userUserLogin.js"),s=require("../../../common/libraries/naviHelper.js");require("../../../common/libraries/request.js");const i=require("../../../common/store/useWeAppAuthStore.js"),u=require("../../../common/store/useWorkStore.js"),n=require("./model.js"),t=u.useWorkStore(),d=i.useWeAppAuthStore(),v=()=>{var e,a;l.getApiLoading(o.Apis.Activity.ActivityEnrolls.List,null==(a=null==(e=n.useModel)?void 0:e.formData)?void 0:a.value).then((e=>{n.useModel.listData.value=[...n.useModel.listData.value,...e.data],n.useModel.metaData.value=e.meta,console.log(e)}))},r={getList:v,init(e){var o,l,a,s,i,u,v,r,m,_,p,h,f,D,M,g,c,A,j,T,y,q,L,b,k,w,W,S;if(console.log(e,"e"),"share"===(null==e?void 0:e.page_type)||"share"===(null==(a=null==(l=null==(o=n.useModel)?void 0:o.formData)?void 0:l.value)?void 0:a.page_type))return n.useModel.formData.value={...n.useModel.formData.value,asset_houses_id:(null==e?void 0:e.id)||(null==(u=null==(i=null==(s=n.useModel)?void 0:s.formData)?void 0:i.value)?void 0:u.asset_houses_id),full_name:(null==e?void 0:e.full_name)||(null==(m=null==(r=null==(v=n.useModel)?void 0:v.formData)?void 0:r.value)?void 0:m.full_name),page_type:(null==e?void 0:e.page_type)||(null==(h=null==(p=null==(_=n.useModel)?void 0:_.formData)?void 0:p.value)?void 0:h.page_type),visitor_phone:n.useModel.formData.value.visitor_phone||(null==(D=null==(f=null==d?void 0:d.data)?void 0:f.user)?void 0:D.phone)||"",visitor_name:n.useModel.formData.value.visitor_name||(null==(g=null==(M=null==d?void 0:d.data)?void 0:M.user)?void 0:g.name)||"",companions_json:[{name:""}]},!1;"share"!==(null==(j=null==(A=null==(c=n.useModel)?void 0:c.formData)?void 0:A.value)?void 0:j.page_type)&&((null==(T=null==t?void 0:t.selectWorkHouse)?void 0:T.asset_house)?n.useModel.formData.value={...n.useModel.formData.value,asset_houses_id:null==(q=null==(y=null==t?void 0:t.selectWorkHouse)?void 0:y.asset_house)?void 0:q.id,full_name:null==(b=null==(L=null==t?void 0:t.selectWorkHouse)?void 0:L.asset_house)?void 0:b.full_name,visitor_phone:n.useModel.formData.value.visitor_phone||"",visitor_name:n.useModel.formData.value.visitor_name||""}:n.useModel.formData.value={...n.useModel.formData.value,asset_houses_id:null==(w=null==(k=null==d?void 0:d.data)?void 0:k.selected_house)?void 0:w.id,full_name:null==(S=null==(W=null==d?void 0:d.data)?void 0:W.selected_house)?void 0:S.full_name,visitor_phone:n.useModel.formData.value.visitor_phone||"",visitor_name:n.useModel.formData.value.visitor_name||""})},loadMore(e){n.useModel.formData.value.page=e,this.getList()},handleTabsChange(e,o){n.useModel.currentTabs.value=e,n.useModel.formData.value={page:1,status:null==o?void 0:o.value},n.useModel.listData.value=[],v(),console.log(e,"e")},handleToSelectHouse(){e.index.navigateTo({url:"/INDEX/asset_houses/index?type=work_add"})},handleSubmit(){var e,i,u,t,d,v,r,m;let _=null==(i=null==(e=n.useModel)?void 0:e.formData)?void 0:i.value;return!!(null==(u=a.getUserLogin)?void 0:u.onBindPhone())&&((null==_?void 0:_.asset_houses_id)?(null==_?void 0:_.visitor_name)?(null==_?void 0:_.visitor_phone)?(null==_?void 0:_.visit_reason)?(null==_?void 0:_.visit_start_time)&&(null==_?void 0:_.visit_end_time)?void l.getApiLoading("share"===(null==(v=null==(d=null==(t=n.useModel)?void 0:t.formData)?void 0:d.value)?void 0:v.page_type)?o.Apis.Visitor.VisitorApplies.Register:o.Apis.Visitor.VisitorApplies.Invite,null==(m=null==(r=n.useModel)?void 0:r.formData)?void 0:m.value).then((e=>{s.showToastBack("提交成功！",1,!0),console.log(e)})):s.showToast("请选择到访时间-离开时间!"):s.showToast("请添加来访事由!"):s.showToast("请设置访客手机号!"):s.showToast("请设置访客姓名!"):s.showToast("请选择房屋!"))},handleAddGoods(){n.useModel.formData.value.companions_json.push({name:""})},handleDeleteGoods(e){n.useModel.formData.value.companions_json.splice(e,1)},handleToApplyRecords(){var o;if(!(null==(o=a.getUserLogin)?void 0:o.onBindPhone()))return!1;e.index.navigateTo({url:"/INDEX/visitor_applies/list/index"})}};exports.method=r;
