File manager - Edit - /home/autoph/.trash/assets/index-83cf2983.js
Back
import{E as h}from"./ExpenseCategoryService-6db2858a.js";import{T as k,s as E,L as R}from"./index-09409e71.js";import{B as F}from"./index-a5aa51c8.js";import{_ as S,r,o as a,c,g as m,b as u,f as i,w as D,e as l,I as P,d as B}from"./index-9809eabd.js";import{C as L,E as T,D as I}from"./DeleteButton-a35f309f.js";/* empty css */import{P as V}from"./index-a6ca9342.js";import{I as G}from"./index-5ecfb783.js";import{L as O}from"./Loading-8db5248e.js";import{F as N}from"./index-6ec21a5a.js";import{F as U,l as A}from"./lodash-55491229.js";import"./index-0a3abe15.js";import{T as q}from"./index-eb93d4d3.js";import{C as j}from"./CloseButton-50a00ab5.js";import{S as Q,U as Y}from"./UpdateButton-a4d97754.js";import{c as $,a as z,V as H}from"./array-2d279bb5.js";import{S as J}from"./StatusProcessService-805c6ef2.js";import{S as K}from"./index-8ab8f8c8.js";import"./vue-cleave.min-6fce3276.js";import"./_commonjsHelpers-de833af9.js";import"./xhebrhsj-21ad2b9f.js";import"./es.string.replace-2e300990.js";const W={components:{FormModal:N,FormGroup:U,TextInput:k,TextArea:q,SubmitButton:Q,UpdateButton:Y,CloseButton:j,Loading:O,Multiselect:E},data(){return{form:{name:null,description:null},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1},processOptions:[]}},methods:{async fetchStatusProcess(){await J.fetchRecords().then(e=>{console.log(e),e.status==200&&(this.processOptions=e.data.data.map(t=>({value:t.id,label:`${t.name} (${t.description})`})))}).catch(e=>{console.log(e)})},loadRecord(e){this.resetForm(),this.state.isEdit=!0,this.form=e},resetForm(){this.state.isEdit=!1,this.form={name:null,description:null},this.errors={}},async submitForm(){try{await $().shape({name:z().nullable().required("Name 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 H){const t={};e.inner.forEach(d=>{t[d.path]=d.message}),this.errors=t}this.state.isSaving=!1}},async saveRecord(){if(this.state.isSaving=!0,!this.state.isEdit)await h.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.reload()):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})}).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})}).finally(()=>{this.state.isSaving=!1});else{const e=this.form.id;await h.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})}).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()})}},closeModal(){this.state.showModal=!1},reload(){this.$emit("reload")}},mounted(){this.state.isEdit=!1,this.fetchStatusProcess()}},X={class:"lg:p-2"},Z={class:"flex gap-1 justify-end"};function ee(e,t,d,g,s,n){const p=r("Loading"),_=r("TextInput"),f=r("FormGroup"),w=r("TextArea"),y=r("Multiselect"),v=r("SubmitButton"),b=r("UpdateButton"),x=r("CloseButton"),C=r("FormModal");return a(),c(C,{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:m(()=>[s.state.isEdit&&s.state.isLoading?(a(),c(p,{key:0,text:"Fetching record"})):u("",!0),s.state.isSaving?(a(),c(p,{key:1,text:"Saving record"})):u("",!0),i("div",X,[i("form",{onSubmit:t[3]||(t[3]=D((...o)=>e.confirmSubmit&&e.confirmSubmit(...o),["prevent"])),class:"space-y-4"},[l(f,{label:"Name",isRequired:!0},{default:m(()=>[l(_,{type:"text",placeholder:"Input name ",modelValue:s.form.name,"onUpdate:modelValue":t[0]||(t[0]=o=>s.form.name=o),error:s.errors.name,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),l(f,{label:"Description"},{default:m(()=>[l(w,{placeholder:"Input description",modelValue:s.form.description,"onUpdate:modelValue":t[1]||(t[1]=o=>s.form.description=o)},null,8,["modelValue"])]),_:1}),l(f,{label:"Status Process"},{default:m(()=>[l(y,{modelValue:s.form.status_process_id,"onUpdate:modelValue":t[2]||(t[2]=o=>s.form.status_process_id=o),id:"status_process_id","close-on-select":!0,searchable:!0,options:s.processOptions},null,8,["modelValue","options"])]),_:1}),i("div",Z,[s.state.isEdit?(a(),c(b,{key:1,onClick:n.submitForm},null,8,["onClick"])):(a(),c(v,{key:0,onClick:n.submitForm},null,8,["onClick"])),l(x,{onClick:n.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const te=S(W,[["render",ee]]);const se={components:{Layout:R,Loading:O,Pagination:V,InputGroup:G,CreateButton:L,EditButton:T,DeleteButton:I,Form:te,SubMenu:K,Button:F},data(){return{title:"Expense Categories",breadcrumbs:[{text:"Home",href:"/"},{text:"Masterfile",href:"/settings/expense-categories"},{text:"Expense Categories",active:!0}],state:{isEdit:!1,isLoading:!1,isMounted:!1,isResetError:!1,isSubmitted:!1,showModal:!1,isDeleting:!1},items:[],error:[],totalItems:0,columns:[{label:"#",field:"#",tdClass:"text-center w-[20px]",sortable:!1},{label:"Name",field:"name"},{label:"Description",field:"description"},{label:"Status Process",field:"process"},{label:"Action",field:"action",tdClass:"self-center w-[100px]",sortable:!1}],perPageOptions:[{value:"10",label:"10"},{value:"50",label:"50"},{value:"100",label:"100"}],searchQuery:"",serverOptions:{page:1,rowsPerPage:10,sortBy:"name",sortType:"asc"}}},watch:{serverOptions:{handler(){console.log(`perPage: ${this.serverOptions.rowsPerPage}`),this.fetchRecords()},deep:!0},searchQuery:A.debounce(function(){this.fetchRecords()},800)},computed:{perPage:function(){return this.serverOptions.rowsPerPage}},methods:{async fetchRecords(){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(e=>{console.log(e);let t=e.data.data;this.items=t.map((d,g)=>({...d,"#":(this.serverOptions.page-1)*this.serverOptions.rowsPerPage+(g+1)})),this.totalItems=e.data.total??0}).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)},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},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,h.remove(e).then(d=>{d.status==200&&(this.$swal.fire({title:"Great!",text:"Record has been deleted successfully.",type:"success",icon:"success",timer:2e3}),this.fetchRecords())}).catch(d=>{console.log(d),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}))})}},mounted(){this.fetchRecords()}},oe={class:"flex flex-col lg:flex-row"},re={class:"lg:w-48 w-full pr-4 py-8"},ie={class:"w-full flex-grow-1"},ae={class:"bg-[url('@/assets/images/background/computer.jpg')] bg-cover bg-[center] rounded-t p-6"},ne={class:"bg-white bg-opacity-[0.7] p-4 rounded-md flex"},le={class:"text-2xl"},ce={key:0,class:"flex gap-1"},de={class:"flex gap-2"},ue={class:"text-primary-800 font-semibold"},me={key:1,class:"flex gap-1"},pe={class:"py-4 px-3 flex justify-end"};function fe(e,t,d,g,s,n){const p=r("Loading"),_=r("SubMenu"),f=r("Button"),w=r("EditButton"),y=r("DeleteButton"),v=r("Pagination"),b=r("vue-good-table"),x=r("Form"),C=r("Layout");return a(),c(C,{breadcrumbs:s.breadcrumbs},{nocard:m(()=>[s.state.isLoading?(a(),c(p,{key:0,searching:!0,text:"Fetching records"})):u("",!0),s.state.isDeleting?(a(),c(p,{key:1,text:"Deleting record"})):u("",!0),i("div",oe,[i("div",re,[l(_,{activeModule:s.title},null,8,["activeModule"])]),i("div",ie,[i("div",ae,[i("div",ne,[i("div",le,P(s.title),1)])]),l(b,{columns:s.columns,styleClass:"vgt-table lesspadding v-middle",mode:"remote",rows:s.items,search:!0,"sort-options":{enabled:!0},"pagination-options":{enabled:!0},onSortChange:n.onSortChange,"max-height":"600px"},{"table-row":m(o=>[o.column.field=="process"?(a(),B("div",ce,[o.row.process?(a(),c(f,{key:0,class:"bg-transparent text-slate-800",title:o.row.process.description},{default:m(()=>[i("div",de,[i("span",ue,"ID: "+P(o.row.process.id),1),i("span",null,P(o.row.process.name),1)])]),_:2},1032,["title"])):u("",!0)])):u("",!0),o.column.field=="action"?(a(),B("div",me,[e.$ability.can("edit","expenseCategory")?(a(),c(w,{key:0,onClick:M=>n.editRecord(o.row)},null,8,["onClick"])):u("",!0),e.$ability.can("delete","expenseCategory")?(a(),c(y,{key:1,onClick:M=>n.deleteRecord(o.row.id)},null,8,["onClick"])):u("",!0)])):u("",!0)]),"pagination-bottom":m(o=>[i("div",pe,[l(v,{total:s.totalItems,current:s.serverOptions.page,"per-page":s.serverOptions.rowsPerPage,onPageChanged:n.handlePageChange,pageChanged:o.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"])])]),l(x,{editData:e.editData,onCloseModal:t[0]||(t[0]=o=>s.state.showModal=!1),ref:"form",onReload:t[1]||(t[1]=o=>n.fetchRecords())},null,8,["editData"])]),_:1},8,["breadcrumbs"])}const Ve=S(se,[["render",fe],["__scopeId","data-v-5396257f"]]);export{Ve as default};
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings