File manager - Edit - /home/autoph/.trash/assets/canvassForm-4b1c34cb.js
Back
import{F as B}from"./index-5bb1d040.js";import{F as I,l as U}from"./lodash-23ed7bc0.js";import"./index-3a1efcbb.js";import{a as f,_ as O,r as c,o as d,c as h,g as i,b as g,f as s,w as R,I as _,e as l,h as x,d as C}from"./index-697396ab.js";import{T as k}from"./index-5318c6a2.js";import{T as q}from"./index-be88ec72.js";import{S as E,U as P}from"./UpdateButton-8be5cbfa.js";import{C as j}from"./CloseButton-337f4ade.js";import{c as D,d as A,V as L}from"./array-2d279bb5.js";import{L as N}from"./Loading-c9f0e534.js";import{C as V}from"./CanvassService-662f9bc2.js";import{M as G}from"./Multiselect-4012cf07.js";import{B as Q}from"./index-603d5a77.js";import{S as W}from"./SupplierService-9f63630f.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:B,FormGroup:I,TextInput:k,TextArea:q,SubmitButton:E,UpdateButton:P,CloseButton:j,Loading:N,Multiselect:G,Button:Q,load:U},data(){return{SupplierOptions:[],PaymentTermsOptions:[],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,errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1,showModal:!1}}},computed:{optionSuppliers:function(){let t=[];return this.form.supplier_id&&(t=this.SupplierOptions.filter(e=>e.supplier_id==this.form.supplier_id).map(e=>({label:e.name,value:e.id}))),t}},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 W.fetchRecords().then(t=>{t.status==200&&(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("loading data into form..."),console.log(t),this.form=e},closeModal(){this.state.showModal=!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(){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 V.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.showModal=!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 V.update(e,t).then(a=>{a.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully updated.",icon:"success",timer:2e3}),this.state.showModal=!1):(this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.state.showModal=!1)}).catch(a=>{console.log(a),a.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:a.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,this.reload()}),this.state.isSaving=!1}},async submitForm(){try{await D().shape({supplier_id:A().required("supplier field 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 L){const e={};t.inner.forEach(a=>{e[a.path]=a.message}),this.errors=e}this.state.isSaving=!1}},HandelOnchangeuser(){this.form.supplier_id=""},handleMainImageUpload(t,e,a){const u=t.target.files[0];this.form[e]=u;const o=new FileReader;o.onload=()=>{console.log(u.type),u.type.startsWith("image/")?this.form[a]=o.result:u.type==="application/pdf"?this.form[a]=this.pdf_file_view:(u.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"||u.tyoe==="application/vnd.ms-excel")&&(this.form[a]=this.excel_file_view)},o.readAsDataURL(u)},closeModalCanvass(){this.state.showModal=!1,this.state.showModal=!0,this.resetForm()},createCanvas(){this.state.showModal=!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("quantity "+t),console.log("unit "+e),console.log("total cost :"),console.log(this.form.total_cost)}},Validating(t){console.log(t)},mounted(){this.fetchSuppliers(),this.fetchPaymentTerms()}},K={class:"p-2"},X={class:"w-full border"},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:"text-center"},te={class:"text-center"},oe={class:"text-center"},se={class:"text-center"},re={class:"text-center"},le={class:"grid grid-cols-2 gap-4"},ie={class:"col-span-1"},ae={class:"relative mb-2"},ne={class:"w-full flex justify-between"},me=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),ce={class:"text-left h-[50px] w-[50px] rounded-md bg-slate-100 p-2"},ue=["src"],de={class:"col-span-1"},pe={class:"relative mb-2"},fe={class:"w-full flex justify-between"},he=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),_e={class:"h-[200px] w-[250px] rounded-md bg-slate-100 p-2 mx-auto"},ye=["src"],ge={class:"flex gap-1 justify-end mt-4"};function be(t,e,a,u,o,m){const b=c("Loading"),v=c("Multiselect"),n=c("FormGroup"),p=c("TextInput"),w=c("Button"),S=c("TextArea"),T=c("SubmitButton"),F=c("UpdateButton"),M=c("FormModal");return d(),h(M,{title:o.state.isEdit?"Edit Record":"Create Record",active:o.state.showModal,onSubmit:t.confirmSubmit,onClose:e[16]||(e[16]=r=>m.closeModal()),themeClass:o.state.isEdit?"bg-success-700":"bg-primary-800",sizeClass:"lg:w-1/2"},{default:i(()=>[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",null,[s("td",ee,_(o.form.reference_no),1),s("td",te,_(o.form.asset_item_name),1),s("td",oe,_(o.form.description),1),s("td",se,_(o.form.uom),1),s("td",re,_(o.form.quantity),1)])])])]),s("div",le,[s("div",ie,[l(n,{label:"Supplier/Vendor",isRequired:!0},{default:i(()=>[l(v,{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=>m.HandelOnchangeuser())},null,8,["modelValue","options"])]),_:1}),l(n,{label:"Quantity"},{default:i(()=>[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(n,{label:"Unit Cost"},{default:i(()=>[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=>m.calculateTotalCost()),classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),l(n,{label:"Total Cost"},{default:i(()=>[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(n,{label:"Terms of Payment"},{default:i(()=>[l(v,{modelValue:o.form.terms,"onUpdate:modelValue":e[6]||(e[6]=r=>o.form.terms=r),id:"terms",name:"terms","close-on-select":!0,searchable:!0,options:o.PaymentTermsOptions},null,8,["modelValue","options"])]),_:1}),l(n,{label:"Delivery lead time"},{default:i(()=>[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(n,{label:"Attachment"},{default:i(()=>[s("div",ae,[s("div",ne,[s("input",{type:"file",id:"file_attachment",name:"file_attachment",onChange:e[8]||(e[8]=r=>m.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),me,l(w,{onClick:e[9]||(e[9]=r=>m.Clearfile_attachment("file_attachment","file_attachment_preview")),btnClass:"bg-red-500 mx-1 text-gray-100 min-h-3 pt-2"},{default:i(()=>[x(" Clear ")]),_:1})])]),s("div",ce,[o.form.file_attachment_preview?(d(),C("img",{key:0,src:o.form.file_attachment_preview,class:"object-contain w-full h-full rounded-lg"},null,8,ue)):g("",!0)])]),_:1})]),s("div",de,[l(n,{label:"Warranty"},{default:i(()=>[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(n,{label:"Notation"},{default:i(()=>[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(n,{label:"Description"},{default:i(()=>[l(S,{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 input-control block w-full pt-3",rows:"5"},null,8,["modelValue","error"])]),_:1}),l(n,{label:"Item Photo"},{default:i(()=>[s("div",pe,[s("div",fe,[s("input",{type:"file",id:"item_photo",name:"item_photo",onChange:e[13]||(e[13]=r=>m.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),he,l(w,{onClick:e[14]||(e[14]=r=>m.Clearfile_attachment("item_photo","item_photo_preview")),btnClass:"bg-red-500 mx-1 text-gray-100 min-h-3 pt-2"},{default:i(()=>[x(" Clear ")]),_:1})])]),s("div",_e,[o.form.item_photo_preview?(d(),C("img",{key:0,src:o.form.item_photo_preview,class:"object-contain w-full h-full rounded-lg"},null,8,ye)):g("",!0)])]),_:1})])]),s("div",ge,[o.state.isEdit?(d(),h(F,{key:1,onClick:m.submitForm},null,8,["onClick"])):(d(),h(T,{key:0,onClick:m.submitForm},null,8,["onClick"]))])],32)])]),_:1},8,["title","active","onSubmit","themeClass"])}const Ee=O(J,[["render",be]]);export{Ee as C};
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings