File manager - Edit - /home/autoph/.trash/assets/index-fc76aa29.js
Back
import{L as F}from"./index-77d1df54.js";import{L}from"./Loading-cf989e31.js";import{F as V,l as M}from"./lodash-8d7fbae2.js";import{C as q,E as A,D as U}from"./DeleteButton-d97e7094.js";import{I}from"./index-e8bb200d.js";import{P as T}from"./index-7e82e20c.js";import{F as G}from"./index-a9f8494f.js";import{S as N,U as Q}from"./UpdateButton-4a93f10c.js";import{C as Y}from"./CloseButton-7091266e.js";import{T as j}from"./index-72a8b0b2.js";import{T as H}from"./index-3d1d64ac.js";import{c as z,a as w,V as J}from"./array-2d279bb5.js";import{E as x}from"./ExecomOfficerSetupService-a4680f92.js";import{M as K}from"./Multiselect-76dc7c6f.js";import{E as W}from"./EmployeeService-8783dbbc.js";import{C as X}from"./CompanyService-5aecf25f.js";import{D as Z}from"./DealershipService-e43193b5.js";import{a as b,_ as S,r as a,o as i,c as m,g as u,b as n,f as l,w as $,e as s,d as p,I as y}from"./index-3ad01394.js";import{A as ee}from"./ApprovalMatrixService-393348bb.js";import"./index-ce1a8b93.js";import"./vue-cleave.min-5b24c519.js";import"./_commonjsHelpers-de833af9.js";import"./xhebrhsj-6516ec76.js";import"./es.string.replace-2e300990.js";import"./index-749eb373.js";const C="https://ahg-prf-api.autohub.ph/api/v1/divisions",te={fetchRecords(e={}){return b.get(`${C}`,{params:e})},fetchRecord(e){return b.get(`${C}/${e}`)},async create(e){return b.post(`${C}`,e)},async update(e,t){return b.put(`${C}/${e}`,t)},async remove(e){return b.delete(`${C}/${e}`)}},oe={components:{FormModal:G,FormGroup:V,TextInput:j,Textarea:H,SubmitButton:N,UpdateButton:Q,CloseButton:Y,Loading:L,Multiselect:K},data(){return{AuthorityOptions:[],CompanyOptions:[],DealershipOptions:[],DivisionOptions:[],UserOptions:[],form:{employee_id:"",approval_matrix_id:"",company_id:null,dealership_id:null,division_id:null},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1},loading:{employeeLoading:!1,authorityLoading:!1,companyLoading:!1}}},computed:{optionDealership:function(){let e=[];return this.form.company_id&&(e=this.DealershipOptions.filter(t=>t.company_id==this.form.company_id).map(t=>({label:t.name,value:t.id}))),e}},methods:{async fetchUsers(){this.loading.employeeLoading=!0,await W.fetchRecords().then(e=>{e.status==200&&(this.UserOptions=e.data.data.map(t=>({value:t.employee_id,label:t.firstname+" "+t.lastname})),this.loading.employeeLoading=!1)}).catch(e=>{console.log(e)})},async fetchAuthority(){this.loading.authorityLoading=!0,await ee.fetchRecords().then(e=>{e.status==200&&(this.AuthorityOptions=e.data.data.map(t=>({value:t.id,label:t.description})),this.loading.authorityLoading=!1)}).catch(e=>{console.log(e)})},async fetchCompany(){this.loading.companyLoading=!0,await X.fetchRecords().then(e=>{e.status==200&&(this.CompanyOptions=e.data.data.map(t=>({value:t.id,label:t.code+" - "+t.name})),this.loading.companyLoading=!1)}).catch(e=>{console.log(e)})},async fetchDealer(){this.loading.companyLoading=!0,await Z.fetchRecords().then(e=>{e.status==200&&(this.DealershipOptions=e.data.data.map(t=>({value:t.id,label:t.code+" - "+t.name})),this.loading.companyLoading=!1)}).catch(e=>{console.log(e)})},async fetchDivision(){this.loading.companyLoading=!0,await te.fetchRecords().then(e=>{e.status==200&&(this.DivisionOptions=e.data.data.map(t=>({value:t.id,label:t.name})),this.loading.companyLoading=!1)}).catch(e=>{console.log(e)})},loadRecord(e){this.state.isEdit=!0,this.resetForm(),console.log("loading data into form..."),this.form=e},closeModal(){this.state.showModal=!1},resetForm(){this.form={employee_id:null,approval_matrix_id:null,company_id:null}},reload(){this.$emit("reload")},async saveRecord(){if(this.state.isSaving=!0,!this.state.isEdit)this.state.isSaving=!1,await x.create(this.form).then(e=>{e.status==201&&(this.$swal.fire({title:"Great!",text:"Record successfully saved.",type:"success",icon:"success",timer:1500}),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 x.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,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()})}},async submitForm(){try{await z().shape({employee_id:w().nullable().required("Employee field is required"),approval_matrix_id:w().nullable().required("Authority field is required"),company_id:w().nullable().required("Company is required"),dealership_id:w().nullable().required("Dealer 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():this.state.showModal=!1})}catch(e){if(e instanceof J){const t={};e.inner.forEach(h=>{t[h.path]=h.message}),this.errors=t}this.state.isSaving=!1}}},mounted(){this.fetchUsers(),this.fetchAuthority(),this.fetchCompany(),this.fetchDealer(),this.fetchDivision()}},se={class:"p-2"},ie={class:"relative"},re={key:0,class:"text-[#ec4899]"},ae={class:"relative"},ne={key:0,class:"text-[#ec4899]"},le={class:"relative"},ce={key:0,class:"text-[#ec4899]"},de={class:"relative"},me={key:0,class:"text-[#ec4899]"},ue={class:"relative"},pe={class:"flex gap-1 justify-end pt-4"};function he(e,t,h,O,o,d){const v=a("Loading"),f=a("Multiselect"),g=a("FormGroup"),_=a("SubmitButton"),P=a("UpdateButton"),k=a("CloseButton"),B=a("FormModal");return i(),m(B,{title:o.state.isEdit?"Edit Record":"Create Record",active:o.state.showModal,onSubmit:e.confirmSubmit,onClose:d.closeModal,themeClass:o.state.isEdit?"bg-success-700":"bg-primary-800",sizeClass:"w-2/4"},{default:u(()=>[o.state.isEdit&&o.state.isLoading?(i(),m(v,{key:0,text:"Fetching record"})):n("",!0),l("div",se,[l("form",{onSubmit:t[5]||(t[5]=$((...c)=>e.confirmSubmit&&e.confirmSubmit(...c),["prevent"])),class:"space-y-4"},[o.state.isEdit&&o.state.isLoading?(i(),m(v,{key:0,text:"Fetching record"})):n("",!0),o.state.isSaving?(i(),m(v,{key:1,text:"Saving record"})):n("",!0),s(g,{label:"Employee",isRequired:!0},{default:u(()=>[l("div",ie,[s(f,{modelValue:o.form.employee_id,"onUpdate:modelValue":t[0]||(t[0]=c=>o.form.employee_id=c),"close-on-select":!0,searchable:!0,id:"employee_id",options:o.UserOptions,loading:e.employeeLoading},null,8,["modelValue","options","loading"])]),o.errors.employee_id?(i(),p("div",re,"Employee is required")):n("",!0)]),_:1}),s(g,{label:"Authority",isRequired:!0},{default:u(()=>[l("div",ae,[s(f,{modelValue:o.form.approval_matrix_id,"onUpdate:modelValue":t[1]||(t[1]=c=>o.form.approval_matrix_id=c),"close-on-select":!0,searchable:!0,id:"approval_matrix_id",options:o.AuthorityOptions,loading:e.authorityLoading},null,8,["modelValue","options","loading"])]),o.errors.approval_matrix_id?(i(),p("div",ne,"Authority is required")):n("",!0)]),_:1}),s(g,{label:"Company",isRequired:!0,class:""},{default:u(()=>[l("div",le,[s(f,{modelValue:o.form.company_id,"onUpdate:modelValue":t[2]||(t[2]=c=>o.form.company_id=c),"close-on-select":!0,searchable:!0,id:"company_id",options:o.CompanyOptions,loading:e.companyLoading},null,8,["modelValue","options","loading"])]),o.errors.company_id?(i(),p("div",ce,"Company is required")):n("",!0)]),_:1}),s(g,{label:"Dealership",isRequired:!0,class:""},{default:u(()=>[l("div",de,[s(f,{modelValue:o.form.dealership_id,"onUpdate:modelValue":t[3]||(t[3]=c=>o.form.dealership_id=c),"close-on-select":!0,searchable:!0,id:"dealership_id",options:o.DealershipOptions,loading:e.companyLoading},null,8,["modelValue","options","loading"])]),o.errors.dealership_id?(i(),p("div",me,"Dealer is required")):n("",!0)]),_:1}),s(g,{label:"Division",class:""},{default:u(()=>[l("div",ue,[s(f,{modelValue:o.form.division_id,"onUpdate:modelValue":t[4]||(t[4]=c=>o.form.division_id=c),"close-on-select":!0,searchable:!0,id:"division_id",options:o.DivisionOptions,loading:e.companyLoading},null,8,["modelValue","options","loading"])])]),_:1}),l("div",pe,[o.state.isEdit?(i(),m(P,{key:1,onClick:d.submitForm},null,8,["onClick"])):(i(),m(_,{key:0,onClick:d.submitForm},null,8,["onClick"])),s(k,{onClick:d.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const fe=S(oe,[["render",he]]),ge={components:{Layout:F,CreateButton:q,InputGroup:I,Loading:L,EditButton:A,DeleteButton:U,Pagination:T,Form:fe},data(){return{title:"Execom Officer Setup",breadcrumbs:[{text:"Home",href:"/"},{text:"Settings",href:"/settings/execom-officer-setup"},{text:"Execom Officer Setup",active:!0}],columns:[{label:"#",field:"#"},{label:"Name",field:"fullname"},{label:"Authority",field:"authority"},{label:"Company",field:"company"},{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:"employee_id",sortType:"asc"},state:{isLoading:!1,isEdit:!1,isDeleting:!1}}},watch:{serverOptions:{handler(){console.log(`perPage: ${this.serverOptions.rowsPerPage}`),this.fetchRecords()},deep:!0},searchQuery:M.debounce(function(){this.fetchRecords()},800)},methods:{async fetchRecords(){this.state.isLoading=!0,await x.fetchRecords({keyword:this.searchQuery,page:this.serverOptions.page,per_page:this.serverOptions.rowsPerPage,sortBy:this.serverOptions.sortBy,sortType:this.serverOptions.sortType}).then(e=>{let t=e.data.data;console.log("DATA",t),this.items=t,this.items=t.map((h,O)=>({...h,"#":(this.serverOptions.page-1)*this.serverOptions.rowsPerPage+(O+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=>{t.value&&(this.state.isDeleting=!0,x.remove(e).then(h=>{h.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.state.showModal=!0,this.$refs.form.resetForm()},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},formatCurrency(e){return new Intl.NumberFormat("fil-PH",{style:"currency",currency:"PHP"}).format(e)}},mounted(){this.fetchRecords()}},ye={class:"p-6 bg-[url('@/assets/images/background/shopping.jpg')] bg-cover bg-[center]"},ve={class:"bg-white bg-opacity-[0.8] p-4 rounded-md md:flex items-center"},_e={class:"flex-1 md:mb-0 mb-3"},be={class:"md:flex md:space-x-3 items-center flex-none rtl:space-x-reverse float-right"},Ce={key:0},we={key:0},xe={key:1},Oe={key:2},Pe={key:3,class:"flex gap-1"},ke={class:"py-4 flex justify-end"};function Be(e,t,h,O,o,d){const v=a("InputGroup"),f=a("Button"),g=a("CreateButton"),_=a("Loading"),P=a("EditButton"),k=a("DeleteButton"),B=a("Pagination"),c=a("vue-good-table"),R=a("Form"),D=a("Layout");return i(),m(D,{header:o.title,headerIcon:"mdi:file-cabinet",breadcrumbs:o.breadcrumbs},{default:u(()=>[l("div",ye,[l("div",ve,[l("h6",_e,y(o.title),1),l("div",be,[s(v,{modelValue:o.searchQuery,"onUpdate:modelValue":t[0]||(t[0]=r=>o.searchQuery=r),placeholder:"Search",type:"text",prependIcon:"heroicons-outline:search",class:"btn-outline-secondary",merged:""},null,8,["modelValue"]),s(f,{icon:"heroicons-outline:filter",text:"Filter",btnClass:" btn-outline-secondary text-slate-600 dark:border-slate-700 dark:text-slate-300 font-normal btn-sm ",iconClass:"text-lg"}),s(g,{onClick:d.createRecord},null,8,["onClick"])])])]),l("div",null,[o.state.isLoading?(i(),m(_,{key:0,searching:!0,text:"Fetching records"})):n("",!0),o.state.isDeleting?(i(),m(_,{key:1,text:"Deleting record"})):n("",!0),s(c,{styleClass:"vgt-table lesspadding v-middle",columns:o.columns,rows:o.items,mode:"remote",search:!0,"sort-options":{enabled:!0},"pagination-options":{enabled:!0},onSortChange:e.onShortChange,"max-height":"600px"},{"table-row":u(r=>[r.column.field=="fullname"?(i(),p("div",Ce,[r.row.employee?(i(),p("span",we,y(r.row.employee.firstname)+" "+y(r.row.employee.middlename||"")+" "+y(r.row.employee.lastname),1)):n("",!0)])):n("",!0),r.column.field=="authority"?(i(),p("div",xe,y(r.row.authority.description),1)):n("",!0),r.column.field=="company"?(i(),p("div",Oe,y(r.row.company.name),1)):n("",!0),r.column.field=="action"?(i(),p("div",Pe,[s(P,{onClick:E=>d.editRecord(r.row)},null,8,["onClick"]),s(k,{onClick:E=>d.deleteRecord(r.row.id)},null,8,["onClick"])])):n("",!0)]),"pagination-bottom":u(r=>[l("div",ke,[s(B,{total:o.totalItems,current:o.serverOptions.page,"per-page":o.serverOptions.rowsPerPage,onPageChanged:d.handlePageChange,pageChanged:r.pageChanged,perPageChanged:o.serverOptions.rowsPerPage,enableSelect:"",perPageOptions:o.perPageOptions,onChangePerPage:d.handlePerPageChange},null,8,["total","current","per-page","onPageChanged","pageChanged","perPageChanged","perPageOptions","onChangePerPage"])])]),_:1},8,["columns","rows","onSortChange"])]),o.state.isLoading?(i(),m(_,{key:0,text:"Feching records"})):n("",!0),s(R,{onCloseModal:t[1]||(t[1]=r=>o.state.showModal=!1),ref:"form",onReload:t[2]||(t[2]=r=>d.fetchRecords())},null,512)]),_:1},8,["header","breadcrumbs"])}const $e=S(ge,[["render",Be]]);export{$e as default};
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings