2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
|
import{_ as F,a as v,S as u}from"./main-9b36f05f.js";import{r as I,a as r,o as U,s as B,b as e,w as o,F as $,_ as L,d as p,t as c,C as P,c as R}from"./vendor-adef9cb4.js";const G={name:"insert",data(){return{tabs:"0",prelabels:[],loading:!1,selectedTypes:[],person:{nikename:"",name:"",des:"",tel:"",mobile:"",mobile2:"",address:"",company:"",shenasemeli:"",codeeghtesadi:"",sabt:"",keshvar:"",ostan:"",shahr:"",postalcode:"",email:"",website:"",fax:"",code:0,types:[],accounts:[],prelabel:I(null),speedAccess:!1}}},mounted(){this.loadData(this.$route.params.id)},beforeRouteUpdate(s){this.loadData(s.params.id)},watch:{selectedTypes(s){this.person.types.forEach(l=>{l.checked=s.includes(l.label)})},"person.types":{handler(s){this.selectedTypes=s.filter(l=>l.checked).map(l=>l.label)},deep:!0,immediate:!0}},methods:{addNewCard(){this.person.accounts.push({bank:"",accountNum:"",cardNum:"",shabaNum:""})},removeCard(s){this.person.accounts.splice(s,1)},loadData(s=""){this.loading=!0,v.post("/api/person/prelabels/list").then(l=>{this.prelabels=l.data}).catch(l=>{u.fire({text:this.$t("pages.person.load_error")+l.message,icon:"error",confirmButtonText:this.$t("dialog.confirm")})}),s?v.post("/api/person/info/"+s).then(l=>{this.person=l.data,this.loading=!1}).catch(l=>{this.loading=!1,u.fire({text:this.$t("pages.person.load_error")+l.message,icon:"error",confirmButtonText:this.$t("dialog.confirm")})}):(v.post("/api/person/types/get").then(l=>{this.person.types=l.data,this.loading=!1}).catch(l=>{this.loading=!1,u.fire({text:this.$t("pages.person.load_error")+l.message,icon:"error",confirmButtonText:this.$t("dialog.confirm")})}),this.person.code=0)},async save(){let s=!0;if(this.person.mobile&&!/^(\+98|0)?9\d{9}$/.test(this.person.mobile)&&(s=!1,u.fire({text:this.$t("pages.person.invalid_mobile"),icon:"error",confirmButtonText:this.$t("dialog.confirm")})),this.person.nikename||(s=!1,u.fire({text:this.$t("pages.person.nickname_required"),icon:"error",confirmButtonText:this.$t("dialog.confirm")})),this.person.accounts.some(l=>!l.bank)&&(s=!1,u.fire({text:this.$t("pages.person.bank_required"),icon:"error",confirmButtonText:this.$t("dialog.confirm")})),s){this.loading=!0;try{const l=await v.post("/api/person/mod/"+this.person.code,this.person);this.loading=!1,l.data.result===2?u.fire({text:this.$t("pages.person.already_exists"),icon:"error",confirmButtonText:this.$t("dialog.confirm")}):u.fire({text:this.$t("pages.person.saved"),icon:"success",confirmButtonText:this.$t("dialog.confirm")}).then(()=>{this.$router.push("/acc/persons/list")})}catch(l){this.loading=!1,u.fire({text:this.$t("pages.person.save_error")+l.message,icon:"error",confirmButtonText:this.$t("dialog.confirm")})}}}}};function H(s,l,J,K,a,h){const V=r("v-btn"),w=r("v-tooltip"),T=r("v-spacer"),k=r("v-icon"),_=r("v-tab"),x=r("v-tabs"),C=r("v-toolbar"),q=r("v-switch"),t=r("v-col"),N=r("v-select"),d=r("v-text-field"),m=r("v-row"),f=r("v-card-text"),b=r("v-card"),g=r("v-tabs-window-item"),D=r("v-textarea"),S=r("v-toolbar-title"),A=r("v-tabs-window"),j=r("v-container"),z=r("v-progress-circular"),E=r("v-overlay");return U(),B($,null,[e(C,{color:"toolbar",title:s.$t("drawer.person_info")},{prepend:o(()=>[e(w,{text:s.$t("dialog.back"),location:"bottom"},{activator:o(({props:n})=>[e(V,L(n,{onClick:l[0]||(l[0]=y=>s.$router.back()),class:"d-none d-sm-flex",variant:"text",icon:"mdi-arrow-right"}),null,16)]),_:1},8,["text"])]),extension:o(()=>[e(x,{modelValue:a.tabs,"onUpdate:modelValue":l[1]||(l[1]=n=>a.tabs=n),color:"primary",grow:"",class:"bg-light"},{default:o(()=>[e(_,{value:"0"},{default:o(()=>[p(c(s.$t("pages.person.basic_info")),1)]),_:1}),e(_,{value:"1"},{default:o(()=>[p(c(s.$t("pages.person.eco_info")),1)]),_:1}),e(_,{value:"2"},{default:o(()=>[p(c(s.$t("pages.person.contact_info")),1)]),_:1}),e(_,{value:"3"},{default:o(()=>[p(c(s.$t("pages.person.address")),1)]),_:1}),e(_,{value:"4"},{default:o(()=>[p(c(s.$t("pages.person.banks_accounts")),1)]),_:1})]),_:1},8,["modelValue"])]),default:o(()=>[e(T),e(V,{loading:a.loading,onClick:h.save,icon:"",color:"green"},{default:o(()=>[e(k,null,
|