Files
crater/public/build/assets/EstimateCreate.890eee82.js
Mohit Panjwani 91e369ddcc new build
2021-12-01 18:02:08 +05:30

2 lines
7.0 KiB
JavaScript

var A=Object.defineProperty,J=Object.defineProperties;var K=Object.getOwnPropertyDescriptors;var q=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable;var I=(a,e,i)=>e in a?A(a,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[e]=i,V=(a,e)=>{for(var i in e||(e={}))Q.call(e,i)&&I(a,i,e[i]);if(q)for(var i of q(e))W.call(e,i)&&I(a,i,e[i]);return a},x=(a,e)=>J(a,K(e));import{r as o,o as _,c as k,b as s,y as t,w as r,g as X,i as L,u as Y,C as Z,k as w,m as g,n as y,a4 as ee,aU as te,O as ae,q as se,D as ie,t as E,s as $,x as j,A as M,z as ne,v as oe,B as re,F as le}from"./vendor.e9042f2c.js";import{j as P,c as me,l as de}from"./main.109918ee.js";import{_ as ue,a as ce,b as ge,c as pe,d as _e,e as fe}from"./ItemModal.e64b35f3.js";import{_ as ve}from"./CreateCustomFields.e1e82659.js";import{_ as ye}from"./ExchangeRateConverter.bd27e496.js";import{_ as be}from"./TaxTypeModal.1c8bef3e.js";import"./DragIcon.e15154fb.js";import"./SelectNotePopup.28113001.js";import"./NoteModal.81974d7d.js";const we={class:"md:grid-cols-12 grid-cols-1 md:gap-x-6 mt-6 mb-8 grid gap-y-5"},Ee={props:{v:{type:Object,default:null},isLoading:{type:Boolean,default:!1},isEdit:{type:Boolean,default:!1}},setup(a){const e=P();return(i,m)=>{const l=o("BaseCustomerSelectPopup"),p=o("BaseDatePicker"),d=o("BaseInputGroup"),B=o("BaseInput"),h=o("BaseInputGrid");return _(),k("div",we,[s(l,{modelValue:t(e).newEstimate.customer,"onUpdate:modelValue":m[0]||(m[0]=u=>t(e).newEstimate.customer=u),valid:a.v.customer_id,"content-loading":a.isLoading,type:"estimate",class:"col-span-5 pr-0"},null,8,["modelValue","valid","content-loading"]),s(h,{class:"col-span-7"},{default:r(()=>[s(d,{label:i.$t("reports.estimates.estimate_date"),"content-loading":a.isLoading,required:"",error:a.v.estimate_date.$error&&a.v.estimate_date.$errors[0].$message},{default:r(()=>[s(p,{modelValue:t(e).newEstimate.estimate_date,"onUpdate:modelValue":m[1]||(m[1]=u=>t(e).newEstimate.estimate_date=u),"content-loading":a.isLoading,"calendar-button":!0,"calendar-button-icon":"calendar"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading","error"]),s(d,{label:i.$t("estimates.expiry_date"),"content-loading":a.isLoading,required:"",error:a.v.expiry_date.$error&&a.v.expiry_date.$errors[0].$message},{default:r(()=>[s(p,{modelValue:t(e).newEstimate.expiry_date,"onUpdate:modelValue":m[2]||(m[2]=u=>t(e).newEstimate.expiry_date=u),"content-loading":a.isLoading,"calendar-button":!0,"calendar-button-icon":"calendar"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading","error"]),s(d,{label:i.$t("estimates.estimate_number"),"content-loading":a.isLoading,required:"",error:a.v.estimate_number.$error&&a.v.estimate_number.$errors[0].$message},{default:r(()=>[s(B,{modelValue:t(e).newEstimate.estimate_number,"onUpdate:modelValue":m[3]||(m[3]=u=>t(e).newEstimate.estimate_number=u),"content-loading":a.isLoading},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading","error"]),s(ye,{store:t(e),"store-prop":"newEstimate",v:a.v,"is-loading":a.isLoading,"is-edit":a.isEdit,"customer-currency":t(e).newEstimate.currency_id},null,8,["store","v","is-loading","is-edit","customer-currency"])]),_:1})])}}},$e=["onSubmit"],Be={class:"flex"},he={class:"block mt-10 estimate-foot lg:flex lg:justify-between lg:items-start"},Ce={class:"relative w-full lg:w-1/2"},Fe={setup(a){const e=P(),i=me(),m=de(),{t:l}=X(),p="newEstimate";let d=L(!1);const B=L(["customer","company","customerCustom","estimate","estimateCustom"]);let h=Y(),u=Z(),f=w(()=>e.isFetchingInitialSettings),F=w(()=>v.value?l("estimates.edit_estimate"):l("estimates.new_estimate")),v=w(()=>h.name==="estimates.edit");const T={estimate_date:{required:g.withMessage(l("validation.required"),y)},expiry_date:{required:g.withMessage(l("validation.required"),y)},estimate_number:{required:g.withMessage(l("validation.required"),y)},reference_number:{maxLength:g.withMessage(l("validation.price_maxlength"),ee(255))},customer_id:{required:g.withMessage(l("validation.required"),y)},exchange_rate:{required:te(function(){return g.withMessage(l("validation.required"),y),e.showExchangeRate}),decimal:g.withMessage(l("validation.valid_exchange_rate"),ae)}},b=se(T,w(()=>e.newEstimate),{$scope:p});ie(()=>e.newEstimate.customer,n=>{n&&n.currency?e.newEstimate.selectedCurrency=n.currency:e.newEstimate.selectedCurrency=i.selectedCompanyCurrency}),e.resetCurrentEstimate(),m.resetCustomFields(),b.value.$reset,e.fetchEstimateInitialSettings(v.value);async function N(){if(b.value.$touch(),b.value.$invalid)return!1;d.value=!0;let n=x(V({},e.newEstimate),{sub_total:e.getSubTotal,total:e.getTotal,tax:e.getTotalTax});const C=v.value?e.updateEstimate:e.addEstimate;try{let c=await C(n);c.data.data&&u.push(`/admin/estimates/${c.data.data.id}/view`)}catch(c){console.error(c)}d.value=!1}return(n,C)=>{const c=o("BaseBreadcrumbItem"),D=o("BaseBreadcrumb"),S=o("BaseButton"),U=o("router-link"),G=o("BaseIcon"),R=o("BasePageHeader"),z=o("BaseScrollPane"),H=o("BasePage");return _(),k(le,null,[s(ue),s(ce),s(be),s(H,{class:"relative estimate-create-page"},{default:r(()=>[E("form",{onSubmit:re(N,["prevent"])},[s(R,{title:t(F)},{actions:r(()=>[n.$route.name==="estimates.edit"?(_(),$(U,{key:0,to:`/estimates/pdf/${t(e).newEstimate.unique_hash}`,target:"_blank"},{default:r(()=>[s(S,{class:"mr-3",variant:"primary-outline",type:"button"},{default:r(()=>[E("span",Be,j(n.$t("general.view_pdf")),1)]),_:1})]),_:1},8,["to"])):M("",!0),s(S,{loading:t(d),disabled:t(d),"content-loading":t(f),variant:"primary",type:"submit"},{left:r(O=>[t(d)?M("",!0):(_(),$(G,{key:0,class:ne(O.class),name:"SaveIcon"},null,8,["class"]))]),default:r(()=>[oe(" "+j(n.$t("estimates.save_estimate")),1)]),_:1},8,["loading","disabled","content-loading"])]),default:r(()=>[s(D,null,{default:r(()=>[s(c,{title:n.$t("general.home"),to:"/admin/dashboard"},null,8,["title"]),s(c,{title:n.$tc("estimates.estimate",2),to:"/admin/estimates"},null,8,["title"]),n.$route.name==="estimates.edit"?(_(),$(c,{key:0,title:n.$t("estimates.edit_estimate"),to:"#",active:""},null,8,["title"])):(_(),$(c,{key:1,title:n.$t("estimates.new_estimate"),to:"#",active:""},null,8,["title"]))]),_:1})]),_:1},8,["title"]),s(Ee,{v:t(b),"is-loading":t(f),"is-edit":t(v)},null,8,["v","is-loading","is-edit"]),s(z,null,{default:r(()=>[s(ge,{currency:t(e).newEstimate.selectedCurrency,"is-loading":t(f),"item-validation-scope":p,store:t(e),"store-prop":"newEstimate"},null,8,["currency","is-loading","store"]),E("div",he,[E("div",Ce,[s(pe,{store:t(e),"store-prop":"newEstimate",fields:B.value,type:"Estimate"},null,8,["store","fields"]),s(ve,{type:"Estimate","is-edit":t(v),"is-loading":t(f),store:t(e),"store-prop":"newEstimate","custom-field-scope":p,class:"mb-6"},null,8,["is-edit","is-loading","store"]),s(_e,{store:t(e),"component-name":"EstimateTemplate","store-prop":"newEstimate"},null,8,["store"])]),s(fe,{currency:t(e).newEstimate.selectedCurrency,"is-loading":t(f),store:t(e),"store-prop":"newEstimate","tax-popup-type":"estimate"},null,8,["currency","is-loading","store"])])]),_:1})],40,$e)]),_:1})],64)}}};export{Fe as default};