File manager - Edit - /home/autoph/.trash/assets/index-fda7ddc7.js
Back
import{S as h}from"./SupplierService-82329129.js";import{L as I}from"./index-c954d15a.js";import{C as O,E as R,D as k}from"./DeleteButton-835f7446.js";import{L as P}from"./Loading-cfed3691.js";import{I as M}from"./index-7aeaebc7.js";import{F as E}from"./index-9334fed0.js";import{S as F,U as L}from"./UpdateButton-9d990a49.js";import{C as T}from"./CloseButton-d2eebd1f.js";import{F as D,l as q}from"./lodash-9a5070a4.js";import{T as U}from"./index-0998fa6f.js";import{T as N}from"./index-afa55389.js";import{c as G,a as y,V as A}from"./array-2d279bb5.js";import{M as Q}from"./Multiselect-698d81dd.js";import{_ as V,r as n,o as c,c as u,g as a,b as f,f as b,w as Y,e as s,d as j}from"./index-3ade5c76.js";import{P as z}from"./index-aae042c5.js";import"./index-83fa9446.js";import"./vue-cleave.min-157d9b32.js";import"./_commonjsHelpers-de833af9.js";import"./xhebrhsj-b8cee719.js";import"./es.string.replace-2e300990.js";import"./index-ba97739a.js";const H={components:{FormModal:E,FormGroup:D,TextInput:U,Textarea:N,SubmitButton:F,UpdateButton:L,CloseButton:T,Loading:P,Multiselect:Q},data(){return{companyOptions:[],form:{code:"",name:"",phone_no:"",fax_no:"",contact_person:"",contact_person_email:"",contact_person_mobile:"",tin:"",terms:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1}}},methods:{async fetchCompanies(){await h.fetchRecords().then(o=>{o.status==200&&(this.companyOptions=o.data.data.map(t=>({value:t.id,label:t.code+" - "+t.name})))}).catch(o=>{console.log(o)})},loadRecord(o){this.resetForm(),this.state.isEdit=!0,this.form=o},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={company_id:"",code:"",name:""}},reload(){this.$emit("reload")},async saveRecord(){if(this.state.isSaving=!0,!this.state.isEdit)this.state.isSaving=!1,await h.create(this.form).then(o=>{o.status==201&&(this.$swal.fire({title:"Great!",text:"Record successfully saved.",icon:"success",timer:2e3}),this.state.showModal=!1,this.resetForm(),this.reload())}).catch(o=>{this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})});else{const o=this.form.id;await h.update(o,this.form).then(t=>{t.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(t=>{console.log(t),t.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:t.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})}).finally(()=>{this.state.isSaving=!1,this.reload()})}},async submitForm(){try{await G().shape({code:y().required("Code field is required").min(2),name:y().required("Name field is required"),address:y().required("Address field is required"),contact_person:y().required("Contact Person field is required"),contact_person_mobile:y().required("Contact Person mobile field is required")}).validate(this.form,{abortEarly:!1}),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(t=>{t.value&&this.saveRecord()})}catch(o){if(o instanceof A){const t={};o.inner.forEach(m=>{t[m.path]=m.message}),this.errors=t}this.state.isSaving=!1}}},Validating(o){console.log(o)},mounted(){}},J={class:"lg:p-2"},K={class:"flex gap-1 justify-end"};function W(o,t,m,_,e,d){const g=n("Loading"),i=n("TextInput"),l=n("FormGroup"),C=n("SubmitButton"),w=n("UpdateButton"),v=n("CloseButton"),x=n("FormModal");return c(),u(x,{title:e.state.isEdit?"Edit Record":"Create Record",active:e.state.showModal,onSubmit:o.confirmSubmit,onClose:d.closeModal,themeClass:e.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"lg:w-1/2"},{default:a(()=>[e.state.isEdit&&e.state.isLoading?(c(),u(g,{key:0,text:"Fetching record"})):f("",!0),b("div",J,[b("form",{onSubmit:t[10]||(t[10]=Y((...r)=>o.confirmSubmit&&o.confirmSubmit(...r),["prevent"])),class:"space-y-4"},[e.state.isEdit&&e.state.isLoading?(c(),u(g,{key:0,text:"Fetching record"})):f("",!0),e.state.isSaving?(c(),u(g,{key:1,text:"Saving record"})):f("",!0),s(l,{label:"Code",isRequired:!0},{default:a(()=>[s(i,{type:"text",placeholder:"Input code",modelValue:e.form.code,"onUpdate:modelValue":t[0]||(t[0]=r=>e.form.code=r),error:e.errors.code,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),s(l,{label:"Name",isRequired:!0},{default:a(()=>[s(i,{type:"text",placeholder:"Input name ",modelValue:e.form.name,"onUpdate:modelValue":t[1]||(t[1]=r=>e.form.name=r),error:e.errors.name,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),s(l,{label:"Address",isRequired:!0},{default:a(()=>[s(i,{type:"text",placeholder:"Input address ",modelValue:e.form.address,"onUpdate:modelValue":t[2]||(t[2]=r=>e.form.address=r),error:e.errors.address,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),s(l,{label:"Phone_no"},{default:a(()=>[s(i,{type:"text",placeholder:"Input phone number ",modelValue:e.form.phone_no,"onUpdate:modelValue":t[3]||(t[3]=r=>e.form.phone_no=r),error:e.errors.phone_no,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),s(l,{label:"fax no."},{default:a(()=>[s(i,{type:"text",placeholder:"Input fax number ",modelValue:e.form.fax_no,"onUpdate:modelValue":t[4]||(t[4]=r=>e.form.fax_no=r),error:e.errors.fax_no,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),s(l,{label:"Contact Person",isRequired:!0},{default:a(()=>[s(i,{type:"text",placeholder:"Input Contact Person ",modelValue:e.form.contact_person,"onUpdate:modelValue":t[5]||(t[5]=r=>e.form.contact_person=r),error:e.errors.contact_person,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),s(l,{label:"Contact Person Email"},{default:a(()=>[s(i,{type:"email",placeholder:"Input Email",modelValue:e.form.contact_person_email,"onUpdate:modelValue":t[6]||(t[6]=r=>e.form.contact_person_email=r),error:e.errors.contact_person_email,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),s(l,{label:"Contact Person mobile",isRequired:!0},{default:a(()=>[s(i,{type:"number",placeholder:"Input mobile",modelValue:e.form.contact_person_mobile,"onUpdate:modelValue":t[7]||(t[7]=r=>e.form.contact_person_mobile=r),error:e.errors.contact_person_mobile,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),s(l,{label:"TIN"},{default:a(()=>[s(i,{type:"text",placeholder:"Input TIN",modelValue:e.form.tin,"onUpdate:modelValue":t[8]||(t[8]=r=>e.form.tin=r),error:e.errors.tin,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),s(l,{label:"Terms"},{default:a(()=>[s(i,{type:"text",placeholder:"Input Terms",modelValue:e.form.terms,"onUpdate:modelValue":t[9]||(t[9]=r=>e.form.terms=r),error:e.errors.terms,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),b("div",K,[e.state.isEdit?(c(),u(w,{key:1,onClick:d.submitForm},null,8,["onClick"])):(c(),u(C,{key:0,onClick:d.submitForm},null,8,["onClick"])),s(v,{onClick:d.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const X=V(H,[["render",W]]),Z={setup(){},components:{Layout:I,CreateButton:O,Loading:P,InputGroup:M,EditButton:R,DeleteButton:k,Form:X,Pagination:z},data(){return{title:"Supplier/Vendor",breadcrumbs:[{text:"Home",href:"/"},{text:"Supplier/Vendor",active:!0}],columns:[{label:"#",field:"#"},{label:"Code",field:"code"},{label:"Name",field:"name"},{label:"Address",field:"address"},{label:"Phone no.",field:"phone_no"},{label:"Fax no.",field:"fox_no"},{label:"Contact Person",field:"contact_person"},{label:"Email",field:"contact_person_email"},{label:"Mobile",field:"contact_person_mobile"},{label:"TIN",field:"tin"},{label:"Terms",field:"terms"},{label:"Business permit",field:"business_permit"},{label:"SEC/DTI permit",field:"sec_dti_permit"},{label:"Action",field:"action"}],perPageOptions:[{value:"10",label:"10"},{value:"50",label:"50"},{value:"100",label:"100"}],state:{isLoading:!1,isMounted:!1,showModal:!1,isDeleting:!1},items:[],totalItems:0,error:[],searchQuery:"",serverOptions:{page:1,rowsPerPage:10,sortBy:"name",sortType:"asc",sortBy:"code",sortType:"asc"}}},watch:{serverOptions:{handler(){console.log(`perPage: ${this.serverOptions.rowsPerPage}`),this.fetchRecords()},deep:!0},searchQuery:q.debounce(function(){this.fetchRecords()},800)},computed:{perPage:function(){return this.serverOptions.rowsPerPage}},methods:{async fetchRecords(){console.log("fetching.."),this.state.isLoading=!0,this.state.isMounted=!1,await h.fetchRecords({keyword:this.searchQuery,page:this.serverOptions.page,per_page:this.serverOptions.rowsPerPage,sortBy:this.serverOptions.sortBy,sortType:this.serverOptions.sortType}).then(o=>{console.log(o);let t=o.data.data;this.items=t,this.items=t.map((m,_)=>({...m,"#":(this.serverOptions.page-1)*this.serverOptions.rowsPerPage+(_+1)})),this.totalItems=o.data.total}).finally(()=>{this.state.isLoading=!1,this.state.isMounted=!0})},handlePageChange(o){console.log(o),console.log(this.serverOptions.page),this.serverOptions.page!=o&&(this.serverOptions.page=o)},handlePerPageChange(o){this.serverOptions.page=1,this.serverOptions.rowsPerPage=o},onSortChange(o){console.log(o),o[0].type!="none"&&(this.serverOptions.sortBy=o[0].field,this.serverOptions.sortType=o[0].type)},async deleteRecord(o){this.$swal.fire({title:"Are you sure?",text:"You want to delete this record?",icon:"warning",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes, delete it!",background:this.$store.themeSettingsStore.isDark?"#1e293b":"#fff"}).then(t=>{t.value&&(this.state.isDeleting=!0,h.remove(o).then(m=>{console.log(m),m.status==200&&(this.$swal.fire({title:"Yaaay!",text:"Record has been deleted successfully.",type:"success",icon:"success",timer:2e3}),this.fetchRecords())}))}).catch(t=>{t.response&&t.response.status==401&&this.$swal.fire({title:"Ooops! something is wrong.",text:"Error deleting record. Please contact system administrator",type:"error",icon:"error",timer:2e3})}).finally(()=>{this.state.isDeleting=!1})},createRecord(){this.$refs.form.resetForm(),this.$refs.form.state.showModal=!0},editRecord(o){this.$refs.form.resetForm(),this.$refs.form.loadRecord(o),this.$refs.form.state.showModal=!0},async submitForm(){if(console.log("Submit Form"),this.state.isLoading=!0,this.state.isSubmitted=!0,!this.v$.$invalid)try{this.state.isEdit==!0?(await h.update(this.categoryData.category_code,this.categoryData),Swal.fire("Success!","Data successfully updated.","success")):(await h.create(this.categoryData),Swal.fire("Success!","Data succesfully created.","success")),this.state.showModal=!1,this.state.isLoading=!1,this.resetData(),this.fetchRecords()}catch(o){this.error=o||"",this.state.isResetError=!0,this.state.isLoading=!1}},closeModal(){this.state.showModal=!1,this.resetData(),this.fetchRecords()},resetData(){this.state={isLoading:!1,isMounted:!1,isResetError:!1,isSubmitted:!1,showModal:!1},this.categoryData={category_code:"",category_desc:""},this.error=[]}},mounted(){this.fetchRecords()}},$={key:0,class:"flex gap-1"},ee={class:"py-4 flex justify-end"};function te(o,t,m,_,e,d){const g=n("InputGroup"),i=n("CreateButton"),l=n("EditButton"),C=n("DeleteButton"),w=n("Pagination"),v=n("vue-good-table"),x=n("Loading"),r=n("Form"),S=n("Layout");return c(),u(S,{header:e.title,headerIcon:"mdi:file-cabinet",breadcrumbs:e.breadcrumbs},{search:a(()=>[s(g,{modelValue:e.searchQuery,"onUpdate:modelValue":t[0]||(t[0]=p=>e.searchQuery=p),class:"w-full focus:border-cyan-500 pt-1 pr-4",placeholder:"Search",type:"text",prependIcon:"heroicons-outline:search",merged:""},null,8,["modelValue"])]),action:a(()=>[o.$ability.can("add","company")?(c(),u(i,{key:0,onClick:d.createRecord},null,8,["onClick"])):f("",!0)]),default:a(()=>[b("div",null,[s(v,{styleClass:"vgt-table lesspadding v-middle",columns:e.columns,rows:e.items,mode:"remote",search:!0,"sort-options":{enabled:!0},"pagination-options":{enabled:!0},onSortChange:d.onSortChange,"max-height":"600px"},{"table-row":a(p=>[p.column.field=="action"?(c(),j("div",$,[o.$ability.can("edit","suppliers")?(c(),u(l,{key:0,onClick:B=>d.editRecord(p.row)},null,8,["onClick"])):f("",!0),o.$ability.can("delete","suppliers")?(c(),u(C,{key:1,onClick:B=>d.deleteRecord(p.row.id)},null,8,["onClick"])):f("",!0)])):f("",!0)]),"pagination-bottom":a(p=>[b("div",ee,[s(w,{total:e.totalItems,current:e.serverOptions.page,"per-page":e.serverOptions.rowsPerPage,onPageChanged:d.handlePageChange,pageChanged:p.pageChanged,perPageChanged:e.serverOptions.rowsPerPage,enableSelect:"",perPageOptions:e.perPageOptions,onChangePerPage:d.handlePerPageChange},null,8,["total","current","per-page","onPageChanged","pageChanged","perPageChanged","perPageOptions","onChangePerPage"])])]),_:1},8,["columns","rows","onSortChange"]),e.state.isLoading?(c(),u(x,{key:0,text:"Fetching records"})):f("",!0),s(r,{onCloseModal:t[1]||(t[1]=p=>e.state.showModal=!1),ref:"form"},null,512)])]),_:1},8,["header","breadcrumbs"])}const xe=V(Z,[["render",te]]);export{xe as default};
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings