File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.e82283c3.js
Back
import{a as g,_ as M,r,o as c,c as p,w as l,j as f,d as m,k as V,e as s,t as B,h as I,b as O}from"./index.3a0d1437.js";import{P as S}from"./PayrollItemsService.0097dd66.js";import{w as L,L as T}from"./index.09b28a7f.js";import{B as U}from"./index.95db1698.js";import{C as N}from"./CreateButton.83988a87.js";import{D as A}from"./DeleteButton.3eb26d6c.js";import{E as G}from"./EditButton.f8156944.js";/* empty css */import{I as q}from"./index.163ce270.js";import"./jspdf.es.min.a68db437.js";/* empty css *//* empty css */import"./vue-cleave.min.da4c1c61.js";import{c as Y,a as k,V as Q}from"./array.057dff5d.js";import{L as F}from"./Loading.2fa16091.js";import"./vue-quill.snow.08c5baab.js";/* empty css */import{I as j}from"./index.fd1302f6.js";import{F as z}from"./index.5338216a.js";import{F as H}from"./index.4888d65f.js";import{T as $}from"./index.474be899.js";import{T as J}from"./index.53519759.js";import{C as K}from"./CloseButton.f9c39bb8.js";import{S as W}from"./SubmitButton.53a3866c.js";import{U as X}from"./UpdateButton.161928d8.js";import{M as Z}from"./Multiselect.4d70245a.js";import{l as ee}from"./lodash.7ba26c92.js";import{P as te}from"./index.ceaa4080.js";import{h as oe}from"./meeting-office.7e6e2274.js";import{C as se}from"./index.5a868516.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.eb053693.js";import"./EmployeeService.0d36c049.js";import"./es.string.replace.6e729815.js";import"./Loading.vue_vue_type_style_index_0_scoped_cbded5a2_lang.717f943d.js";import"./index.57af9821.js";import"./index.ae1bb6da.js";const y="https://staging-ahg-hr-api.autohub.ph/api/v1/deduction-type",R={fetchRecords(e={}){return g.get(`${y}`,{params:e})},fetchRecord(e){return g.get(`${y}/${e}`)},async create(e){return g.post(`${y}`,e)},async update(e,t){return g.put(`${y}/${e}`,t)},async remove(e){return g.delete(`${y}/${e}`)}},re={components:{FormModal:H,FormGroup:z,TextInput:J,TextArea:$,SubmitButton:W,UpdateButton:X,CloseButton:K,Loading:F,Multiselect:Z},data(){return{typeOptions:[{value:1,label:"Addition"},{value:2,label:"Deduction"}],taxableOptions:[{value:1,label:"Yes"},{value:0,label:"No"}],form:{code:"",name:"",type:"",taxable:"",description:"",add_less:"2",tag:"deduction"},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1}}},methods:{loadRecord(e){this.resetForm(),this.state.isEdit=!0,this.form=e},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={code:"",name:"",type:"",taxable:"",description:"",add_less:"2",tag:"deduction"}},reload(){this.$emit("reload")},async saveRecord(){if(this.state.isSaving=!0,!this.state.isEdit)this.state.isSaving=!1,await S.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=>{this.$swal.fire({title:"Ooops! something is wrong.",text:e.response.data.message,icon:"error",timer:2e3})});else{const e=this.form.id;await S.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({name:k().required("Name field is required"),taxable:k().required("Taxable 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 Q){const t={};e.inner.forEach(d=>{t[d.path]=d.message}),this.errors=t}this.state.isSaving=!1}}},mounted(){}},ae={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},ie={class:"grid grid-cols-2 gap-4"},ne={class:"flex gap-1 justify-end"};function le(e,t,d,v,o,n){const b=r("Loading"),h=r("TextInput"),u=r("FormGroup"),_=r("Multiselect"),x=r("SubmitButton"),w=r("UpdateButton"),C=r("CloseButton"),P=r("FormModal");return c(),p(P,{title:o.state.isEdit?"Edit Record":"Create Record",active:o.state.showModal,onSubmit:e.confirmSubmit,onClose:n.closeModal,themeClass:o.state.isEdit?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-3/4"},{default:l(()=>[o.state.isEdit&&o.state.isLoading?(c(),p(b,{key:0,text:"Fetching record"})):f("",!0),m("div",ae,[m("form",{onSubmit:t[5]||(t[5]=V((...a)=>e.confirmSubmit&&e.confirmSubmit(...a),["prevent"])),class:"space-y-4"},[o.state.isSaving?(c(),p(b,{key:0,text:"Saving record"})):f("",!0),s(u,{label:"Code"},{default:l(()=>[s(h,{type:"text",placeholder:"Input code",modelValue:o.form.code,"onUpdate:modelValue":t[0]||(t[0]=a=>o.form.code=a),error:o.errors.code,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),s(u,{label:"Name",isRequired:!0},{default:l(()=>[s(h,{type:"text",placeholder:"Input name ",modelValue:o.form.name,"onUpdate:modelValue":t[1]||(t[1]=a=>o.form.name=a),error:o.errors.name,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),m("div",ie,[s(u,{label:"Add/Less"},{default:l(()=>[s(_,{modelValue:o.form.add_less,"onUpdate:modelValue":t[2]||(t[2]=a=>o.form.add_less=a),"close-on-select":!0,searchable:!0,id:"type",options:o.typeOptions,disabled:""},null,8,["modelValue","options"])]),_:1}),s(u,{label:"Taxable",isRequired:!0},{default:l(()=>[s(_,{modelValue:o.form.taxable,"onUpdate:modelValue":t[3]||(t[3]=a=>o.form.taxable=a),"close-on-select":!0,searchable:!0,id:"taxable",options:o.taxableOptions},null,8,["modelValue","options"])]),_:1})]),s(u,{label:"Decsription"},{default:l(()=>[s(h,{type:"text",placeholder:"Input description ",modelValue:o.form.description,"onUpdate:modelValue":t[4]||(t[4]=a=>o.form.description=a),error:o.errors.description,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),m("div",ne,[o.state.isEdit?(c(),p(w,{key:1,onClick:n.submitForm},null,8,["onClick"])):(c(),p(x,{key:0,onClick:n.submitForm},null,8,["onClick"])),s(C,{onClick:n.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const ce=M(re,[["render",le]]);const de={mixins:[L],setup(){},components:{Layout:T,CreateButton:N,Loading:F,InputGroup:j,EditButton:G,DeleteButton:A,Button:U,Form:ce,Pagination:te,Card:se,Icon:q},data(){return{headerImage:oe,title:"Deduction Type",breadcrumbs:[{text:"Home",href:"/"},{text:"Payroll",href:"/payroll/deduction-type"},{text:"Deduction Type",active:!0}],columns:[{label:"#",field:"#"},{label:"Code",field:"code"},{label:"Name",field:"name"},{label:"Description",field:"description"},{label:"Type",field:"type"},{label:"Taxable",field:"taxable"},{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:ee.debounce(function(){this.fetchRecords()},800)},computed:{perPage:function(){return this.serverOptions.rowsPerPage}},methods:{async fetchRecords(){this.state.isLoading=!0,this.state.isMounted=!1,await S.fetchRecords({keyword:this.searchQuery,page:this.serverOptions.page,per_page:this.serverOptions.rowsPerPage,sortBy:this.serverOptions.sortBy,sortType:this.serverOptions.sortType,add_less:2,tag:"deduction"}).then(e=>{let t=e.data.data;console.log("response data",t),this.items=t.map((d,v)=>({...d,"#":(this.serverOptions.page-1)*this.serverOptions.rowsPerPage+(v+1)})),console.log("processed items",this.items),this.totalItems=e.data.total}).catch(e=>{console.error("Error fetching records:",e)}).finally(()=>{this.state.isLoading=!1,this.state.isMounted=!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},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,R.remove(e).then(d=>{console.log(d),d.status==201&&(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},async submitForm(){if(console.log("Submit Form"),this.state.isLoading=!0,this.state.isSubmitted=!0,!this.v$.$invalid)try{this.state.isEdit==!0?(await R.update(this.categoryData.category_code,this.categoryData),Swal.fire("Success!","Data successfully updated.","success")):(await R.create(this.categoryData),Swal.fire("Success!","Data succesfully created.","success")),this.state.showModal=!1,this.state.isLoading=!1,this.resetData(),this.fetchRecords()}catch(e){this.error=e||"",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()}},me={class:"my-5"},ue={class:"md:flex pb-6 items-center"},pe={class:"flex-1 md:mb-0 mb-3"},he={key:0,class:"flex gap-1"},fe={key:1,class:"flex gap-1"},ge={key:2,class:"flex gap-1"},ye={class:"py-4 flex justify-end"};function be(e,t,d,v,o,n){const b=r("InputGroup"),h=r("Button"),u=r("EditButton"),_=r("DeleteButton"),x=r("Pagination"),w=r("vue-good-table"),C=r("Card"),P=r("Loading"),a=r("Form"),D=r("Layout");return c(),p(D,{breadcrumbs:o.breadcrumbs},{default:l(()=>[m("div",me,[s(C,{noborder:""},{default:l(()=>[m("div",ue,[m("h6",pe,B(o.title),1),m("div",{class:I(["md:flex md:space-x-3 items-center flex-none rtl:space-x-reverse my-3 float-right",e.window.width<768?"space-x-rb":""])},[s(b,{modelValue:o.searchQuery,"onUpdate:modelValue":t[0]||(t[0]=i=>o.searchQuery=i),placeholder:"Search",type:"text",prependIcon:"heroicons-outline:search",merged:""},null,8,["modelValue"]),s(h,{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(h,{icon:"heroicons-outline:plus-sm",text:"Add Record",btnClass:" btn-dark font-normal btn-sm ",iconClass:"text-lg",onClick:t[1]||(t[1]=i=>n.createRecord())})],2)]),s(w,{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:n.onSortChange,"max-height":"600px"},{"table-row":l(i=>[i.column.field=="type"?(c(),O("div",he,B(i.row.type?"Addition":"Deduction"),1)):f("",!0),i.column.field=="taxable"?(c(),O("div",fe,B(i.row.taxable?"Yes":"No"),1)):f("",!0),i.column.field=="action"?(c(),O("div",ge,[s(u,{onClick:E=>n.editRecord(i.row)},null,8,["onClick"]),s(_,{onClick:E=>n.deleteRecord(i.row.id)},null,8,["onClick"])])):f("",!0)]),"pagination-bottom":l(i=>[m("div",ye,[s(x,{total:o.totalItems,current:o.serverOptions.page,"per-page":o.serverOptions.rowsPerPage,onPageChanged:n.handlePageChange,pageChanged:i.pageChanged,perPageChanged:o.serverOptions.rowsPerPage,enableSelect:"",perPageOptions:o.perPageOptions,onChangePerPage:n.handlePerPageChange},null,8,["total","current","per-page","onPageChanged","pageChanged","perPageChanged","perPageOptions","onChangePerPage"])])]),_:1},8,["columns","rows","onSortChange"])]),_:1}),o.state.isLoading?(c(),p(P,{key:0,text:"Fetching records"})):f("",!0),s(a,{onCloseModal:t[2]||(t[2]=i=>o.state.showModal=!1),ref:"form",onReload:n.fetchRecords},null,8,["onReload"])])]),_:1},8,["breadcrumbs"])}const st=M(de,[["render",be],["__scopeId","data-v-e1103459"]]);export{st as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.15 |
proxy
|
phpinfo
|
Settings