File manager - Edit - /home/autoph/.trash/assets/canvassForm-2aa28a4f.js
Back
import{F as M}from"./index-ce1b03cd.js";import{F as U,l as k}from"./lodash-2486ead9.js";import"./index-629fd9e2.js";import{a as f,_ as q,r as u,o as d,c as h,g as a,b as g,f as s,w as R,I as _,e as l,h as C,d as S}from"./index-e5373ec2.js";import{T as O}from"./index-479e0467.js";import{T as E}from"./index-66dfb15c.js";import{S as L,U as P}from"./UpdateButton-cd065730.js";import{C as j}from"./CloseButton-82833f99.js";import{c as D,d as v,V as A}from"./array-6d4b6a20.js";import{L as N}from"./Loading-a86a6dc0.js";import{C as T}from"./CanvassService-568ed15c.js";import{M as W}from"./Multiselect-32cb99a2.js";import{B as G}from"./index-63f57c33.js";import{S as Q}from"./SupplierService-b174b6b0.js";import{f as H}from"./file-type-pdf-a9709057.js";import{f as z}from"./file-type-excel-3a83eaab.js";const y="https://ahg-prf-api.autohub.ph/api/v1/po-terms",Y={fetchRecords(t={}){return f.get(`${y}`,{params:t})},fetchRecord(t){return f.get(`${y}/${t}`)},async create(t){return f.post(`${y}`,t)},async update(t,e){return f.put(`${y}/${t}`,e)},async remove(t){return f.delete(`${y}/${t}`)}},J={components:{FormModal:M,FormGroup:U,TextInput:O,TextArea:E,SubmitButton:L,UpdateButton:P,CloseButton:j,Loading:N,Multiselect:W,Button:G,load:k},data(){return{SupplierOptions:[],PaymentTermsOptions:[],SupplierWithTermsList:[],form:{prf_id:null,item_id:null,supplier_id:"",description:"",quantity:0,unit_cost:0,total_cost:0,terms:"",warranty:"",notation:"",delieveryTime:"",item_photo:null,item_photo_preview:null,file_attachment:null,file_attachment_preview:null},pdf_file_view:H,excel_file_view:z,assetItem:null,state:{isEdit:!1,isSaving:!1,isLoading:!1,showModal:!1,showModalFromCanvass:!1},errors:{supplier_id:null,unit_cost:null,total_cost:null,terms:null}}},computed:{},methods:{async fetchExpenseCategories(){await ExpenseCategory.fetchRecords().then(t=>{t.status==200&&(this.categoryOptions=t.data.data.map(e=>({value:e.id,label:e.name})))}).catch(t=>{console.log(t)})},async fetchItemClassifications(){await ItemClassification.fetchRecords().then(t=>{t.status==200&&(this.classifications=t.data.data)}).catch(t=>{console.log(t)})},async fetchSuppliers(){await Q.fetchRecords().then(t=>{console.log("reponse suppliers data",t.data.data),t.status==200&&(this.SupplierWithTermsList=t.data.data.filter(e=>e.vendor_term).map(e=>{var i,n;return{supplier_id:e.id,term_id:(i=e.vendor_term)==null?void 0:i.id,term_desc:(n=e.vendor_term)==null?void 0:n.code}}),console.log("supplier wit terms",this.SupplierWithTermsList),this.SupplierOptions=t.data.data.map(e=>({value:e.id,label:e.name})))}).catch(t=>{console.log(t)})},async fetchPaymentTerms(){await Y.fetchRecords().then(t=>{t.status==200&&(this.PaymentTermsOptions=t.data.map(e=>({value:e.id,label:e.code+" - "+e.description})))}).catch(t=>{console.log(t)})},loadRecord(t){let e=Object.assign({},t);this.resetForm(),console.log(t),this.form=e},closeModalCanvass(){this.state.showModalFromCanvass=!1,this.state.isSaving=!1},resetForm(){this.form={supplier_id:"",unit_cost:"",total_cost:"",quantity:"",terms:"",notation:"",delieveryTime:"",warranty:"",description:"",file_attachment:null,item_photo:null,prf_id:"",item_id:""}},reload(){this.$emit("reload")},async saveRecord(){console.log("saving record...");let t=new FormData;if(Object.keys(this.form).forEach(e=>{t.append(e,this.form[e])}),this.state.isSaving=!0,!this.state.isEdit)this.state.isSaving=!0,await T.create(t).then(e=>{console.log("saving...."),e.status==201&&(this.$swal.fire({title:"Great!",text:"Record successfully saved.",type:"success",icon:"success",timer:1500}),this.state.isSaving=!1,this.state.showModalFromCanvass=!1,this.resetForm(),this.reload())}).catch(e=>{this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})});else{const e=this.form.id;await T.update(e,t).then(i=>{i.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully updated.",icon:"success",timer:2e3}),this.state.showModalFromCanvass=!1):(this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.state.showModalFromCanvass=!1)}).catch(i=>{console.log(i),i.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:i.response.data.message,type:"error",icon:"error"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})}).finally(()=>{}),this.state.isSaving=!1}},async submitForm(){console.log("saving...");try{await D().shape({supplier_id:v().required("supplier field is required."),unit_cost:v().required("unit cost is required."),total_cost:v().required("Total cost is required.")}).validate(this.form,{abortEarly:!1}),console.log("submitting..."),console.log(this.form),this.$swal.fire({title:"Are you sure you want to save this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(e=>{e.value&&this.saveRecord()})}catch(t){if(t instanceof A){const e={};t.inner.forEach(i=>{e[i.path]=i.message}),this.errors=e}this.state.isSaving=!1}},HandelOnchangeSupplier(t){this.form.supplier_id=t;const e=this.SupplierWithTermsList.find(i=>i.supplier_id===t);this.form.terms=null,e&&(this.form.terms=e.term_id)},handleMainImageUpload(t,e,i){const n=t.target.files[0];this.form[e]=n;const o=new FileReader;o.onload=()=>{console.log(n.type),n.type.startsWith("image/")?this.form[i]=o.result:n.type==="application/pdf"?this.form[i]=this.pdf_file_view:(n.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"||n.tyoe==="application/vnd.ms-excel")&&(this.form[i]=this.excel_file_view)},o.readAsDataURL(n)},createCanvas(){this.state.showModalFromCanvass=!0},Clearfile_attachment(t,e){this.form[t]=null,this.form[e]=null},calculateTotalCost(){const t=parseFloat(this.form.quantity)||0,e=parseFloat(this.form.unit_cost)||0;this.form.total_cost=t*e,console.log(this.form.total_cost)}},Validating(t){console.log(t)},mounted(){this.fetchSuppliers(),this.fetchPaymentTerms()}},K={class:"p-2"},X={class:"w-full px-5"},Z={class:"table-auto w-full"},$=s("thead",null,[s("tr",null,[s("th",{class:"text-center border border-slate-200 ..."}," PRF# "),s("th",{class:"text-center border border-slate-200 ..."}," Item "),s("th",{class:"text-center border border-slate-200 ..."}," Description "),s("th",{class:"text-center border border-slate-200 ..."}," Uom "),s("th",{class:"text-center border border-slate-200 ..."}," Qty ")])],-1),ee={class:"bg-pink-500 text-gray-100"},te={class:"text-center"},oe={class:"text-center"},se={class:"text-center"},re={class:"text-center"},le={class:"text-center"},ie={class:"grid grid-cols-2 gap-4 p-5"},ae={class:"col-span-1"},ne={class:"relative mb-2"},me={class:"w-full flex justify-between"},ce=s("div",{class:"bg-white rounded border border-gray-300 p-0 flex flex-grow items-center justify-between"},[s("span",{class:"mr-2 pl-2 text-sm text-slate-500"},"Choose a file..."),s("button",{type:"button",class:"px-4 py-2 bg-slate-200 text-slate-500 rounded hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 pointer-events-auto"}," Browse ")],-1),ue={class:"text-left h-[50px] w-[50px] rounded-md bg-slate-100 p-2"},de=["src"],pe={class:"col-span-1"},fe={class:"relative mb-2"},he={class:"w-full flex justify-between"},_e=s("div",{class:"bg-white rounded border border-gray-300 p-0 flex flex-grow items-center justify-between"},[s("span",{class:"mr-2 pl-2 text-sm text-slate-500"},"Choose a file..."),s("button",{type:"button",class:"px-4 py-2 bg-slate-200 text-slate-500 rounded hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 pointer-events-auto"}," Browse ")],-1),ye={class:"h-[200px] w-[250px] rounded-md bg-slate-100 p-2 mx-auto"},ge=["src"],ve={class:"flex gap-1 justify-end mt-4"};function be(t,e,i,n,o,c){const b=u("Loading"),w=u("Multiselect"),m=u("FormGroup"),p=u("TextInput"),x=u("Button"),V=u("TextArea"),F=u("SubmitButton"),B=u("UpdateButton"),I=u("FormModal");return d(),h(I,{title:o.state.isEdit?"Edit Record":"Create Record",active:o.state.showModalFromCanvass,onSubmit:t.confirmSubmit,onClose:e[16]||(e[16]=r=>c.closeModalCanvass()),themeClass:o.state.isEdit?"bg-success-700":"bg-primary-800",sizeClass:"lg:w-3/4"},{default:a(()=>[o.state.isLoading?(d(),h(b,{key:0,text:"Fetching resources"})):g("",!0),o.state.isSaving?(d(),h(b,{key:1,text:"Saving record"})):g("",!0),s("div",K,[s("form",{onSubmit:e[15]||(e[15]=R((...r)=>t.confirmSubmit&&t.confirmSubmit(...r),["prevent"])),enctype:"multipart/form-data",class:"space-y-4"},[s("div",X,[s("table",Z,[$,s("tbody",null,[s("tr",ee,[s("td",te,_(o.form.reference_no),1),s("td",oe,_(o.form.asset_item_name),1),s("td",se,_(o.form.description),1),s("td",re,_(o.form.uom),1),s("td",le,_(o.form.quantity),1)])])])]),s("div",ie,[s("div",ae,[l(m,{label:"Supplier/Vendor",isRequired:!0},{default:a(()=>[l(w,{modelValue:o.form.supplier_id,"onUpdate:modelValue":e[0]||(e[0]=r=>o.form.supplier_id=r),id:"supplier_id",name:"supplier_id","close-on-select":!0,searchable:!0,options:o.SupplierOptions,onChange:e[1]||(e[1]=r=>c.HandelOnchangeSupplier(r))},null,8,["modelValue","options"])]),_:1}),l(m,{label:"Quantity"},{default:a(()=>[l(p,{type:"number",modelValue:o.form.quantity,"onUpdate:modelValue":e[2]||(e[2]=r=>o.form.quantity=r),id:"unit_cost",name:"unit_cost",placeholder:"quantity",error:o.errors.quantity,classInput:"h-[48px]",ref:"inputQty",readonly:""},null,8,["modelValue","error"])]),_:1}),l(m,{label:"Unit Cost"},{default:a(()=>[l(p,{type:"number",modelValue:o.form.unit_cost,"onUpdate:modelValue":e[3]||(e[3]=r=>o.form.unit_cost=r),id:"unit_cost",name:"unit_cost",placeholder:"Add unit cost",error:o.errors.unit_cost,onInput:e[4]||(e[4]=r=>c.calculateTotalCost()),classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),l(m,{label:"Total Cost"},{default:a(()=>[l(p,{type:"number",modelValue:o.form.total_cost,"onUpdate:modelValue":e[5]||(e[5]=r=>o.form.total_cost=r),id:"total_cost",name:"total_cost",placeholder:"Total cost",error:o.errors.total_cost,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),l(m,{label:"Terms of Payment"},{default:a(()=>[l(w,{modelValue:o.form.terms,"onUpdate:modelValue":e[6]||(e[6]=r=>o.form.terms=r),id:"terms",name:"terms",error:o.errors.terms,"close-on-select":!0,searchable:!0,options:o.PaymentTermsOptions},null,8,["modelValue","error","options"])]),_:1}),l(m,{label:"Delivery lead time"},{default:a(()=>[l(p,{type:"text",modelValue:o.form.delieveryTime,"onUpdate:modelValue":e[7]||(e[7]=r=>o.form.delieveryTime=r),id:"deliveryTime",name:"deliveryTime",placeholder:"Devery lead time",error:o.errors.delieveryTime,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),l(m,{label:"Attachment"},{default:a(()=>[s("div",ne,[s("div",me,[s("input",{type:"file",id:"file_attachment",name:"file_attachment",onChange:e[8]||(e[8]=r=>c.handleMainImageUpload(r,"file_attachment","file_attachment_preview")),class:"absolute inset-0 opacity-0 w-full h-full cursor-pointer pointer-events-auto",multiple:""},null,32),ce,l(x,{onClick:e[9]||(e[9]=r=>c.Clearfile_attachment("file_attachment","file_attachment_preview")),btnClass:"bg-red-500 mx-1 text-gray-100 min-h-3 pt-2"},{default:a(()=>[C(" Clear ")]),_:1})])]),s("div",ue,[o.form.file_attachment_preview?(d(),S("img",{key:0,src:o.form.file_attachment_preview,class:"object-contain w-full h-full rounded-lg"},null,8,de)):g("",!0)])]),_:1})]),s("div",pe,[l(m,{label:"Warranty"},{default:a(()=>[l(p,{type:"text",modelValue:o.form.warranty,"onUpdate:modelValue":e[10]||(e[10]=r=>o.form.warranty=r),id:"warranty",name:"warranty",placeholder:"Input Warranty",error:o.errors.warranty,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),l(m,{label:"Notation"},{default:a(()=>[l(p,{type:"text",modelValue:o.form.notation,"onUpdate:modelValue":e[11]||(e[11]=r=>o.form.notation=r),id:"notation",name:"notation",placeholder:"Notation",error:o.errors.notation,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),l(m,{label:"Description"},{default:a(()=>[l(V,{placeholder:"Input item description",modelValue:o.form.description,"onUpdate:modelValue":e[12]||(e[12]=r=>o.form.description=r),id:"description",error:o.errors.description,class:"classinput block w-full pt-3",rows:"5"},null,8,["modelValue","error"])]),_:1}),l(m,{label:"Item Photo"},{default:a(()=>[s("div",fe,[s("div",he,[s("input",{type:"file",id:"item_photo",name:"item_photo",onChange:e[13]||(e[13]=r=>c.handleMainImageUpload(r,"item_photo","item_photo_preview")),class:"absolute inset-0 opacity-0 w-full h-full cursor-pointer pointer-events-auto",multiple:""},null,32),_e,l(x,{onClick:e[14]||(e[14]=r=>c.Clearfile_attachment("item_photo","item_photo_preview")),btnClass:"bg-red-500 mx-1 text-gray-100 min-h-3 pt-2"},{default:a(()=>[C(" Clear ")]),_:1})])]),s("div",ye,[o.form.item_photo_preview?(d(),S("img",{key:0,src:o.form.item_photo_preview,class:"object-contain w-full h-full rounded-lg"},null,8,ge)):g("",!0)])]),_:1})])]),s("div",ve,[o.state.isEdit?(d(),h(B,{key:1,onClick:c.submitForm},null,8,["onClick"])):(d(),h(F,{key:0,onClick:c.submitForm},null,8,["onClick"]))])],32)])]),_:1},8,["title","active","onSubmit","themeClass"])}const Le=q(J,[["render",be]]);export{Le as C};
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings