芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/www/invoicer.pulsehost.co.uk/public/build/assets/EstimateCreate-DFLtrJ9W.js
import{as as L,r as l,o as c,c as M,a,l as t,w as o,av as H,E as A,ae as J,v as K,f as C,L as O,e as W,k as v,g as _,h as w,ai as Q,ag as X,W as Z,j as ee,z as te,m as E,K as x,b,t as q,J as ae,p as se,q as ie,N as ne,P as oe}from"./main-WS8l16KQ.js";import{_ as le,a as re,b as me,c as de,d as ue,e as ce,f as pe}from"./SalesTax-LST-awog.js";import{_ as ge}from"./CreateCustomFields-KP2lJheQ.js";import{_ as _e}from"./ExchangeRateConverter-oor-rXm9.js";import{_ as fe}from"./TaxTypeModal-BIJxDmkL.js";import"./DragIcon-Bhk7q250.js";import"./SelectNotePopup-C-3WYDWX.js";import"./NoteModal-CwF9gy7n.js";import"./payment-DKm7vv1R.js";import"./dynamic-import-helper-BheWnx7M.js";import"./exchange-rate-MCtDo2g9.js";const ve={class:"md:grid-cols-12 grid-cols-1 md:gap-x-6 mt-6 mb-8 grid gap-y-5"},Ee={__name:"EstimateCreateBasicFields",props:{v:{type:Object,default:null},isLoading:{type:Boolean,default:!1},isEdit:{type:Boolean,default:!1}},setup(i){const e=L();return(f,r)=>{const B=l("BaseCustomerSelectPopup"),m=l("BaseDatePicker"),u=l("BaseInputGroup"),$=l("BaseInput"),h=l("BaseInputGrid");return c(),M("div",ve,[a(B,{modelValue:t(e).newEstimate.customer,"onUpdate:modelValue":r[0]||(r[0]=d=>t(e).newEstimate.customer=d),valid:i.v.customer_id,"content-loading":i.isLoading,type:"estimate",class:"col-span-5 pr-0"},null,8,["modelValue","valid","content-loading"]),a(h,{class:"col-span-7"},{default:o(()=>[a(u,{label:f.$t("reports.estimates.estimate_date"),"content-loading":i.isLoading,required:"",error:i.v.estimate_date.$error&&i.v.estimate_date.$errors[0].$message},{default:o(()=>[a(m,{modelValue:t(e).newEstimate.estimate_date,"onUpdate:modelValue":r[1]||(r[1]=d=>t(e).newEstimate.estimate_date=d),"content-loading":i.isLoading,"calendar-button":!0,"calendar-button-icon":"calendar"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading","error"]),a(u,{label:f.$t("estimates.expiry_date"),"content-loading":i.isLoading},{default:o(()=>[a(m,{modelValue:t(e).newEstimate.expiry_date,"onUpdate:modelValue":r[2]||(r[2]=d=>t(e).newEstimate.expiry_date=d),"content-loading":i.isLoading,"calendar-button":!0,"calendar-button-icon":"calendar"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading"]),a(u,{label:f.$t("estimates.estimate_number"),"content-loading":i.isLoading,required:"",error:i.v.estimate_number.$error&&i.v.estimate_number.$errors[0].$message},{default:o(()=>[a($,{modelValue:t(e).newEstimate.estimate_number,"onUpdate:modelValue":r[3]||(r[3]=d=>t(e).newEstimate.estimate_number=d),"content-loading":i.isLoading},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading","error"]),a(_e,{store:t(e),"store-prop":"newEstimate",v:i.v,"is-loading":i.isLoading,"is-edit":i.isEdit,"customer-currency":t(e).newEstimate.currency_id},null,8,["store","v","is-loading","is-edit","customer-currency"])]),_:1})])}}},ye={class:"flex"},we={class:"block mt-10 estimate-foot lg:flex lg:justify-between lg:items-start"},be={class:"relative w-full lg:w-1/2"},k="newEstimate",Me={__name:"EstimateCreate",setup(i){const e=L(),f=H(),r=A(),B=J(),{t:m}=K.useI18n();let u=C(!1);const $=C(!1),h=C(["customer","company","customerCustom","estimate","estimateCustom"]);let d=O(),P=W(),p=v(()=>e.isFetchingInitialSettings),T=v(()=>g.value?m("estimates.edit_estimate"):m("estimates.new_estimate")),g=v(()=>d.name==="estimates.edit");const F=v(()=>r.selectedCompanySettings.sales_tax_us_enabled==="YES"&&f.salesTaxUSEnabled),N={estimate_date:{required:_.withMessage(m("validation.required"),w)},estimate_number:{required:_.withMessage(m("validation.required"),w)},reference_number:{maxLength:_.withMessage(m("validation.price_maxlength"),Q(255))},customer_id:{required:_.withMessage(m("validation.required"),w)},exchange_rate:{required:X(function(){return _.withMessage(m("validation.required"),w),e.showExchangeRate}),decimal:_.withMessage(m("validation.valid_exchange_rate"),Z)}},y=ee(N,v(()=>e.newEstimate),{$scope:k});te(()=>e.newEstimate.customer,s=>{s&&s.currency?e.newEstimate.selectedCurrency=s.currency:e.newEstimate.selectedCurrency=r.selectedCompanyCurrency}),e.resetCurrentEstimate(),B.resetCustomFields(),y.value.$reset,e.fetchEstimateInitialSettings(g.value);async function D(){if(y.value.$touch(),y.value.$invalid)return!1;u.value=!0;let s=oe.cloneDeep({...e.newEstimate,sub_total:e.getSubTotal,total:e.getTotal,tax:e.getTotalTax});s.discount_per_item==="YES"?s.items.forEach((n,S)=>{n.discount_type==="fixed"&&(s.items[S].discount=Math.round(n.discount*100))}):s.discount_type==="fixed"&&(s.discount=Math.round(s.discount*100)),!e.newEstimate.tax_per_item==="YES"&&s.taxes.length&&(s.tax_type_ids=s.taxes.map(n=>n.tax_type_id));const I=g.value?e.updateEstimate:e.addEstimate;try{let n=await I(s);n.data.data&&P.push(`/admin/estimates/${n.data.data.id}/view`)}catch(n){console.error(n)}u.value=!1}return(s,I)=>{const n=l("BaseBreadcrumbItem"),S=l("BaseBreadcrumb"),V=l("BaseButton"),U=l("router-link"),j=l("BaseIcon"),G=l("BasePageHeader"),R=l("BaseScrollPane"),Y=l("BasePage");return c(),M(ne,null,[a(le),a(re),a(fe),F.value&&(!t(p)||t(d).query.customer)?(c(),E(me,{key:0,store:t(e),"store-prop":"newEstimate","is-edit":t(g),customer:t(e).newEstimate.customer},null,8,["store","is-edit","customer"])):x("",!0),a(Y,{class:"relative estimate-create-page"},{default:o(()=>[b("form",{onSubmit:ie(D,["prevent"])},[a(G,{title:t(T)},{actions:o(()=>[s.$route.name==="estimates.edit"?(c(),E(U,{key:0,to:`/estimates/pdf/${t(e).newEstimate.unique_hash}`,target:"_blank"},{default:o(()=>[a(V,{class:"mr-3",variant:"primary-outline",type:"button"},{default:o(()=>[b("span",ye,q(s.$t("general.view_pdf")),1)]),_:1})]),_:1},8,["to"])):x("",!0),a(V,{loading:t(u),disabled:t(u),"content-loading":t(p),variant:"primary",type:"submit"},{left:o(z=>[t(u)?x("",!0):(c(),E(j,{key:0,class:ae(z.class),name:"SaveIcon"},null,8,["class"]))]),default:o(()=>[se(" "+q(s.$t("estimates.save_estimate")),1)]),_:1},8,["loading","disabled","content-loading"])]),default:o(()=>[a(S,null,{default:o(()=>[a(n,{title:s.$t("general.home"),to:"/admin/dashboard"},null,8,["title"]),a(n,{title:s.$t("estimates.estimate",2),to:"/admin/estimates"},null,8,["title"]),s.$route.name==="estimates.edit"?(c(),E(n,{key:0,title:s.$t("estimates.edit_estimate"),to:"#",active:""},null,8,["title"])):(c(),E(n,{key:1,title:s.$t("estimates.new_estimate"),to:"#",active:""},null,8,["title"]))]),_:1})]),_:1},8,["title"]),a(Ee,{v:t(y),"is-loading":t(p),"is-edit":t(g)},null,8,["v","is-loading","is-edit"]),a(R,null,{default:o(()=>[a(de,{currency:t(e).newEstimate.selectedCurrency,"is-loading":t(p),"item-validation-scope":k,store:t(e),"store-prop":"newEstimate"},null,8,["currency","is-loading","store"]),b("div",we,[b("div",be,[a(ue,{store:t(e),"store-prop":"newEstimate",fields:h.value,type:"Estimate"},null,8,["store","fields"]),a(ge,{type:"Estimate","is-edit":t(g),"is-loading":t(p),store:t(e),"store-prop":"newEstimate","custom-field-scope":k,class:"mb-6"},null,8,["is-edit","is-loading","store"]),a(ce,{store:t(e),"component-name":"EstimateTemplate","store-prop":"newEstimate","is-mark-as-default":$.value},null,8,["store","is-mark-as-default"])]),a(pe,{currency:t(e).newEstimate.selectedCurrency,"is-loading":t(p),store:t(e),"store-prop":"newEstimate","tax-popup-type":"estimate"},null,8,["currency","is-loading","store"])])]),_:1})],32)]),_:1})],64)}}};export{Me as default};