芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/public_html/invoicer.pulsehost.co.uk/public/build/assets/NoteModal-CwF9gy7n.js
import{a4 as T,s as g,a1 as $,F as X,u as A,aq as H,as as J,L as O,v as R,f as P,H as K,k as B,g as _,h as b,I as Q,j as W,z as Y,X as Z,r as v,o as ee,m as te,w as p,b as I,p as S,t as C,l as o,a as l,q as ae,J as oe}from"./main-WS8l16KQ.js";import{u as ne}from"./payment-DKm7vv1R.js";const se=(M=!1)=>(M?window.pinia.defineStore:T)({id:"notes",state:()=>({notes:[],currentNote:{id:null,type:"",name:"",notes:""}}),getters:{isEdit:n=>!!n.currentNote.id},actions:{resetCurrentNote(){this.currentNote={type:"",name:"",notes:""}},fetchNotes(n){return new Promise((e,u)=>{g.get("/api/v1/notes",{params:n}).then(t=>{this.notes=t.data.data,e(t)}).catch(t=>{$(t),u(t)})})},fetchNote(n){return new Promise((e,u)=>{g.get(`/api/v1/notes/${n}`).then(t=>{this.currentNote=t.data.data,e(t)}).catch(t=>{$(t),u(t)})})},addNote(n){return new Promise((e,u)=>{g.post("/api/v1/notes",n).then(t=>{this.notes.push(t.data),e(t)}).catch(t=>{$(t),u(t)})})},updateNote(n){return new Promise((e,u)=>{g.put(`/api/v1/notes/${n.id}`,n).then(t=>{if(t.data){let N=this.notes.findIndex(s=>s.id===t.data.data.id);this.notes[N]=n.notes}e(t)}).catch(t=>{$(t),u(t)})})},deleteNote(n){return new Promise((e,u)=>{g.delete(`/api/v1/notes/${n}`).then(t=>{let N=this.notes.findIndex(s=>s.id===n);this.notes.splice(N,1),e(t)}).catch(t=>{$(t),u(t)})})}}})(),re={class:"flex justify-between w-full"},ie={class:"px-8 py-8 sm:p-6"},ue={class:"z-0 flex justify-end px-4 py-4 border-t border-solid border-gray-light"},de={__name:"NoteModal",setup(M){const c=X(),n=A(),e=se(),u=H(),t=ne(),N=J(),s=O(),{t:d}=R.useI18n();let f=P(!1);const E=K([{label:d("settings.customization.notes.types.invoice"),value:"Invoice"},{label:d("settings.customization.notes.types.estimate"),value:"Estimate"},{label:d("settings.customization.notes.types.payment"),value:"Payment"}]);let y=P(["customer","customerCustom"]);const x=B(()=>c.active&&c.componentName==="NoteModal"),k=B(()=>({currentNote:{name:{required:_.withMessage(d("validation.required"),b),minLength:_.withMessage(d("validation.name_min_length",{count:3}),Q(3))},notes:{required:_.withMessage(d("validation.required"),b)},type:{required:_.withMessage(d("validation.required"),b)}}})),r=W(k,B(()=>e));Y(()=>e.currentNote.type,a=>{V()}),Z(()=>{s.name==="estimates.create"?e.currentNote.type="Estimate":s.name==="invoices.create"||s.name==="recurring-invoices.create"?e.currentNote.type="Invoice":e.currentNote.type="Payment"});function V(){y.value=["customer","customerCustom"],e.currentNote.type=="Invoice"&&y.value.push("invoice","invoiceCustom"),e.currentNote.type=="Estimate"&&y.value.push("estimate","estimateCustom"),e.currentNote.type=="Payment"&&y.value.push("payment","paymentCustom")}async function D(){if(r.value.currentNote.$touch(),r.value.currentNote.$invalid)return!0;if(f.value=!0,e.isEdit){let a={id:e.currentNote.id,...e.currentNote};await e.updateNote(a).then(i=>{f.value=!1,i.data&&(n.showNotification({type:"success",message:d("settings.customization.notes.note_updated")}),c.refreshData&&c.refreshData(),h())}).catch(i=>{f.value=!1})}else await e.addNote(e.currentNote).then(a=>{f.value=!1,a.data&&(n.showNotification({type:"success",message:d("settings.customization.notes.note_added")}),(s.name==="invoices.create"&&a.data.data.type==="Invoice"||s.name==="invoices.edit"&&a.data.data.type==="Invoice")&&u.selectNote(a.data.data),(s.name==="estimates.create"&&a.data.data.type==="Estimate"||s.name==="estimates.edit"&&a.data.data.type==="Estimate")&&N.selectNote(a.data.data),(s.name==="payments.create"&&a.data.data.type==="Payment"||s.name==="payments.edit"&&a.data.data.type==="Payment")&&t.selectNote(a.data.data)),c.refreshData&&c.refreshData(),h()}).catch(a=>{f.value=!1})}function h(){c.closeModal(),setTimeout(()=>{e.resetCurrentNote(),r.value.$reset()},300)}return(a,i)=>{const q=v("BaseIcon"),j=v("BaseInput"),w=v("BaseInputGroup"),F=v("BaseMultiselect"),G=v("BaseCustomInput"),L=v("BaseInputGrid"),z=v("BaseButton"),U=v("BaseModal");return ee(),te(U,{show:x.value,onClose:h,onOpen:V},{header:p(()=>[I("div",re,[S(C(o(c).title)+" ",1),l(q,{name:"XIcon",class:"h-6 w-6 text-gray-500 cursor-pointer",onClick:h})])]),default:p(()=>[I("form",{action:"",onSubmit:ae(D,["prevent"])},[I("div",ie,[l(L,{layout:"one-column"},{default:p(()=>[l(w,{label:a.$t("settings.customization.notes.name"),variant:"vertical",error:o(r).currentNote.name.$error&&o(r).currentNote.name.$errors[0].$message,required:""},{default:p(()=>[l(j,{modelValue:o(e).currentNote.name,"onUpdate:modelValue":i[0]||(i[0]=m=>o(e).currentNote.name=m),invalid:o(r).currentNote.name.$error,type:"text",onInput:i[1]||(i[1]=m=>o(r).currentNote.name.$touch())},null,8,["modelValue","invalid"])]),_:1},8,["label","error"]),l(w,{label:a.$t("settings.customization.notes.type"),error:o(r).currentNote.type.$error&&o(r).currentNote.type.$errors[0].$message,required:""},{default:p(()=>[l(F,{modelValue:o(e).currentNote.type,"onUpdate:modelValue":i[2]||(i[2]=m=>o(e).currentNote.type=m),options:E,"value-prop":"value",class:"mt-2"},null,8,["modelValue","options"])]),_:1},8,["label","error"]),l(w,{label:a.$t("settings.customization.notes.notes"),error:o(r).currentNote.notes.$error&&o(r).currentNote.notes.$errors[0].$message,required:""},{default:p(()=>[l(G,{modelValue:o(e).currentNote.notes,"onUpdate:modelValue":i[3]||(i[3]=m=>o(e).currentNote.notes=m),invalid:o(r).currentNote.notes.$error,fields:o(y),onInput:i[4]||(i[4]=m=>o(r).currentNote.notes.$touch())},null,8,["modelValue","invalid","fields"])]),_:1},8,["label","error"])]),_:1})]),I("div",ue,[l(z,{class:"mr-2",variant:"primary-outline",type:"button",onClick:h},{default:p(()=>[S(C(a.$t("general.cancel")),1)]),_:1}),l(z,{loading:o(f),disabled:o(f),variant:"primary",type:"submit"},{left:p(m=>[l(q,{name:"SaveIcon",class:oe(m.class)},null,8,["class"])]),default:p(()=>[S(" "+C(o(e).isEdit?a.$t("general.update"):a.$t("general.save")),1)]),_:1},8,["loading","disabled"])])],32)]),_:1},8,["show"])}}};export{de as _,se as u};