File manager - Edit - /home/autoph/public_html/projects/ahg-connect/assets/index.33be58fa.js
Back
import{D as y}from"./DealershipService.a4935403.js";import{L as F,C as E}from"./index.d8327ad1.js";import{L as O}from"./Loading.6052584f.js";import{F as I,C as M,a as V,I as L,E as D,D as T,l as q}from"./CloseButton.37069484.js";import{P as U}from"./index.4a5bff94.js";import{S as G,U as N}from"./UpdateButton.c88607b8.js";import{F as j}from"./index.dbe0636e.js";import{T as A}from"./index.9f68810f.js";import{T as Q}from"./index.1b4bf29f.js";import{c as Y,a as P,V as z}from"./object.413f31be.js";/* empty css */import{M as H}from"./Multiselect.82b9bc51.js";import{C as J}from"./CompanyService.1778ae2c.js";import{_ as B,r as o,o as a,a as c,w as d,b as p,d as r,g as K,f as i,t as W,c as X}from"./index.c8fd93d6.js";import{I as Z}from"./index.4b7607b5.js";import"./logo-white.e9971405.js";import"./_commonjsHelpers.de833af9.js";import"./index.ce033c34.js";import"./vue-cleave.min.7c593396.js";const $={components:{FormModal:I,FormGroup:j,TextInput:A,Textarea:Q,SubmitButton:G,UpdateButton:N,CloseButton:M,Loading:O,Multiselect:H},data(){return{companyOptions:[],form:{company_id:"",code:"",name:"",address:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1}}},methods:{async fetchCompanies(){await J.fetchRecords().then(e=>{e.status==200&&(this.companyOptions=e.data.data.map(t=>({value:t.id,label:t.code+" - "+t.name})))}).catch(e=>{console.log(e)})},loadRecord(e){this.resetForm(),this.state.isEdit=!0,this.form=e},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 y.create(this.form).then(e=>{e.status==201&&(this.$swal.fire({title:"Great!",text:"Record successfully saved.",icon:"success",timer:2e3}),this.state.showModal=!1,this.resetForm(),this.reload())}).catch(e=>{console.log(e),e.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:e.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})});else{const e=this.form.id;await y.update(e,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 Y().shape({code:P().required("Code field is required").min(2),name:P().required("Name 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(e){if(e instanceof z){const t={};e.inner.forEach(m=>{t[m.path]=m.message}),this.errors=t}this.state.isSaving=!1}}},Validating(e){console.log(e)},mounted(){this.fetchCompanies()}},ee={class:"lg:p-2"},te={class:"relative"},se={class:"flex gap-1 justify-end"};function oe(e,t,m,v,s,n){const f=o("Loading"),_=o("Multiselect"),h=o("FormGroup"),g=o("TextInput"),C=o("SubmitButton"),w=o("UpdateButton"),b=o("CloseButton"),x=o("FormModal");return a(),c(x,{title:s.state.isEdit?"Edit Record":"Create Record",active:s.state.showModal,onSubmit:e.confirmSubmit,onClose:n.closeModal,themeClass:s.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"lg:w-1/2"},{default:d(()=>[s.state.isEdit&&s.state.isLoading?(a(),c(f,{key:0,text:"Fetching record"})):p("",!0),r("div",ee,[r("form",{onSubmit:t[4]||(t[4]=K((...l)=>e.confirmSubmit&&e.confirmSubmit(...l),["prevent"])),class:"space-y-4"},[s.state.isEdit&&s.state.isLoading?(a(),c(f,{key:0,text:"Fetching record"})):p("",!0),s.state.isSaving?(a(),c(f,{key:1,text:"Saving record"})):p("",!0),i(h,{label:"Company",isRequired:!0},{default:d(()=>[r("div",te,[i(_,{modelValue:s.form.company_id,"onUpdate:modelValue":t[0]||(t[0]=l=>s.form.company_id=l),"close-on-select":!0,searchable:!0,id:"company_id",options:s.companyOptions},null,8,["modelValue","options"])])]),_:1}),i(h,{label:"Code",isRequired:!0},{default:d(()=>[i(g,{type:"text",placeholder:"Input code",modelValue:s.form.code,"onUpdate:modelValue":t[1]||(t[1]=l=>s.form.code=l),error:s.errors.code,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),i(h,{label:"Name",isRequired:!0},{default:d(()=>[i(g,{type:"text",placeholder:"Input name ",modelValue:s.form.name,"onUpdate:modelValue":t[2]||(t[2]=l=>s.form.name=l),error:s.errors.name,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),i(h,{label:"Address",isRequired:!0},{default:d(()=>[i(g,{type:"text",placeholder:"Input address ",modelValue:s.form.address,"onUpdate:modelValue":t[3]||(t[3]=l=>s.form.address=l),error:s.errors.address,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),r("div",se,[s.state.isEdit?(a(),c(w,{key:1,onClick:n.submitForm},null,8,["onClick"])):(a(),c(C,{key:0,onClick:n.submitForm},null,8,["onClick"])),i(b,{onClick:n.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const re=B($,[["render",oe]]),ie={components:{Layout:F,CreateButton:V,InputGroup:L,Loading:O,EditButton:D,DeleteButton:T,Pagination:U,Form:re,Card:E,Icon:Z},setup(){},data(){return{title:"Dealerships",breadcrumbs:[{text:"Home",href:"/"},{text:"Masterfile",href:"/masterfile/dealerships"},{text:"Dealerships",active:!0}],columns:[{label:"#",field:"#"},{label:"Dealer Code",field:"code"},{label:"Dealer Name",field:"name"},{label:"Company",field:"company"},{label:"Address",field:"address"},{label:"Action",field:"action"}],perPageOptions:[{value:"10",label:"10"},{value:"50",label:"50"},{value:"100",label:"100"}],items:[],totalItems:0,searchQuery:null,serverOptions:{page:1,rowsPerPage:10,sortBy:"name",sortType:"asc"},state:{isLoading:!1,isEdit:!1,isDeleting:!1}}},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(){this.state.isLoading=!0,await y.fetchRecords({keyword:this.searchQuery,page:this.serverOptions.page,per_page:this.serverOptions.rowsPerPage,sortBy:this.serverOptions.sortBy,sortType:this.serverOptions.sortType}).then(e=>{console.log("response");let t=e.data.data;console.log(t),this.items=t,this.items=t.map((m,v)=>({...m,"#":(this.serverOptions.page-1)*this.serverOptions.rowsPerPage+(v+1)})),this.totalItems=e.data.total}).finally(()=>{this.state.isLoading=!1})},handlePageChange(e){console.log(e),console.log(this.serverOptions.page),this.serverOptions.page!=e&&(this.serverOptions.page=e)},handlePerPageChange(e){this.serverOptions.page=1,this.serverOptions.rowsPerPage=e},onSortChange(e){console.log(e),e[0].type!="none"&&(this.serverOptions.sortBy=e[0].field,this.serverOptions.sortType=e[0].type)},async deleteRecord(e){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=>{console.log(t.value),t.value&&(this.state.isDeleting=!0,y.remove(e).then(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(e){this.$refs.form.resetForm(),this.$refs.form.loadRecord(e),this.$refs.form.state.showModal=!0},handlePageChange(e){console.log(e),console.log(this.serverOptions.page),this.serverOptions.page!=e&&(this.serverOptions.page=e)},handlePerPageChange(e){this.serverOptions.page=1,this.serverOptions.rowsPerPage=e}},mounted(){this.fetchRecords()}},ae={class:"rounded-t bg-[url('@/assets/images/background/car-showroom.jpg')] bg-cover bg-[center] mih-h-24 p-8"},ne={class:"bg-white bg-opacity-[0.5] rounded grid lg:grid-cols-2 p-2"},le={class:"flex gap-2 px-2"},ce={class:"h-12 w-12 flex flex-col items-center justify-center rounded-full bg-white text-2xl mb-2 drop-shadow"},de={class:"text-3xl font-sans text-primary-800 py-1 drop-shadow"},me={class:"flex justify-between"},ue={class:"flex-grow"},pe={key:0,class:"flex gap-1"},he={class:"py-4 flex justify-end"};function fe(e,t,m,v,s,n){const f=o("Icon"),_=o("InputGroup"),h=o("CreateButton"),g=o("EditButton"),C=o("DeleteButton"),w=o("Pagination"),b=o("vue-good-table"),x=o("Card"),l=o("Loading"),k=o("Form"),S=o("Layout");return a(),c(S,{breadcrumbs:s.breadcrumbs},{nocard:d(()=>[i(x,{bodyClass:"p-0"},{default:d(()=>[r("div",ae,[r("div",ne,[r("div",le,[r("div",ce,[i(f,{icon:"game-icons:city-car",class:"text-5xl text-primary-700"})]),r("div",de,W(s.title),1)]),r("div",null,[r("div",me,[r("div",ue,[i(_,{modelValue:s.searchQuery,"onUpdate:modelValue":t[0]||(t[0]=u=>s.searchQuery=u),class:"w-full focus:border-cyan-500 pt-1 pr-4",placeholder:"Search",type:"text",prependIcon:"heroicons-outline:search",merged:""},null,8,["modelValue"])]),r("div",null,[e.$ability.can("add","dealership")?(a(),c(h,{key:0,onClick:n.createRecord},null,8,["onClick"])):p("",!0)])])])])]),r("div",null,[i(b,{styleClass:"vgt-table lesspadding v-middle",columns:s.columns,rows:s.items,mode:"remote",search:!0,"sort-options":{enabled:!0},"pagination-options":{enabled:!0},onSortChange:n.onSortChange,"max-height":"600px"},{"table-row":d(u=>[u.column.field=="action"?(a(),X("div",pe,[e.$ability.can("edit","dealership")?(a(),c(g,{key:0,onClick:R=>n.editRecord(u.row)},null,8,["onClick"])):p("",!0),e.$ability.can("delete","dealership")?(a(),c(C,{key:1,onClick:R=>n.deleteRecord(u.row.id)},null,8,["onClick"])):p("",!0)])):p("",!0)]),"pagination-bottom":d(u=>[r("div",he,[i(w,{total:s.totalItems,current:s.serverOptions.page,"per-page":s.serverOptions.rowsPerPage,onPageChanged:n.handlePageChange,pageChanged:u.pageChanged,perPageChanged:s.serverOptions.rowsPerPage,enableSelect:"",perPageOptions:s.perPageOptions,onChangePerPage:n.handlePerPageChange},null,8,["total","current","per-page","onPageChanged","pageChanged","perPageChanged","perPageOptions","onChangePerPage"])])]),_:1},8,["columns","rows","onSortChange"])])]),_:1}),s.state.isLoading?(a(),c(l,{key:0,text:"Feching records"})):p("",!0),i(k,{onCloseModal:t[1]||(t[1]=u=>s.state.showModal=!1),ref:"form"},null,512)]),_:1},8,["breadcrumbs"])}const Le=B(ie,[["render",fe]]);export{Le as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings