File manager - Edit - /home/autoph/.trash/assets/index-cbdce920.js
Back
import{S as w}from"./StatusProcessService-10432b96.js";import{T as D,s as U,L as T}from"./index-1f4d61fc.js";import{L}from"./Loading-233c0ed2.js";import{F as N,l as q}from"./lodash-5487abc8.js";import"./index-78a110b6.js";import"./index-72121a78.js";import{a as y,_ as I,r as n,o as l,c as d,g as u,f as r,b as m,w as A,e as i,d as _,G as B,I as M,J as V,K as $,L as j}from"./index-78c69a5e.js";import{C as G,E as Q,D as Y}from"./DeleteButton-d9ef8ff9.js";/* empty css */import{I as z}from"./index-18beb27d.js";import{P as H}from"./index-101ba171.js";import{F as J}from"./index-7a5287b5.js";import{T as K}from"./index-364a367e.js";import{C as X}from"./CloseButton-94a3337b.js";import{S as W,U as Z}from"./UpdateButton-2bf97d46.js";import{c as ee,a as te,V as se}from"./array-2d279bb5.js";import{P as oe}from"./PrfstatusService-2343c5ab.js";import{E as re}from"./ExpenseCategoryService-f6141034.js";import{R as ae}from"./RoleGroupService-64cc4569.js";import"./vue-cleave.min-1313a293.js";import"./_commonjsHelpers-de833af9.js";import"./xhebrhsj-70e4cd0e.js";import"./es.string.replace-2e300990.js";const v="https://ahg-prf-api.autohub.ph/api/v1/settings/sub-processes",ie={fetchRecords(e={}){return y.get(`${v}`,{params:e})},fetchRecord(e){return y.get(`${v}/${e}`)},async create(e){return y.post(`${v}`,e)},async update(e,t){return y.put(`${v}/${e}`,t)},async remove(e){return y.delete(`${v}/${e}`)}};const ne={components:{FormModal:J,FormGroup:N,TextInput:D,TextArea:K,CreateButton:G,SubmitButton:W,UpdateButton:Z,CloseButton:X,Loading:L,Multiselect:U},data(){return{statusOptions:[],categoryOptions:[],roleGroupOptions:[],subProcessOptions:[],form:{name:"",description:"",expense_category_id:null,statuses:[],details:[]},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1,isLoadingExpenseInput:!1,isFetchingCategories:!1,isFetchingStatuses:!1,isFetchingSubprocess:!1,isFetchingRoleGroups:!1,isLoadRecord:!1}}},computed:{selectedStatus:function(){return this.statusOptions.filter(e=>this.form.statuses.includes(e.value)).map(e=>({...e}))}},methods:{async fetchExpenseCategories(){this.state.isFetchingCategories||(this.state.isFetchingCategories=!0,this.state.isLoadingExpenseInput=!0,this.state.isLoading=!0,await re.fetchRecords().then(e=>{if(e.status===200){const t=e.data.data;console.log("responseData",t),Array.isArray(t)?(this.categoryOptions=t.map(o=>({label:o.name,value:o.id})),console.log("Category Options:",this.categoryOptions)):console.error("Unexpected response structure:",e.data)}}).catch(e=>{console.log(e)}).finally(()=>{this.state.isFetchingCategories=!1,this.state.isLoadingExpenseInput=!1,this.state.isLoading=!1}))},async fetchStatuses(){this.state.isFetchingStatuses||(this.state.isFetchingStatuses=!0,await oe.fetchRecords().then(e=>{e.status==200&&(this.statusOptions=e.data.data.map(t=>({label:t.name,value:t.id,description:t.description})))}).catch(e=>{console.log(e)}).finally(()=>{this.state.isFetchingStatuses=!1}))},async fetchRoleGroups(){this.state.isFetchingRoleGroups||(this.state.isFetchingRoleGroups=!0,await ae.fetchRecords().then(e=>{e.status==200&&(this.roleGroupOptions=e.data.data.map(t=>({label:t.name,value:t.id})))}).catch(e=>{console.log(e)}).finally(()=>{this.state.isFetchingRoleGroups=!1}))},async fetchSubProcess(){this.isFetchingSubprocess||(this.state.isFetchingSubprocess=!0,await ie.fetchRecords().then(e=>{e.status==200&&(this.subProcessOptions=e.data.data.map(t=>({label:t.name,value:t.id})))}).catch(e=>{console.log(e)}).finally(()=>{this.state.isFetchingSubprocess=!1}))},selectExpenseCategories(e,t){},selectStatus(e,t){let o=Object.assign({},t);this.form.details.push({status_id:e,sequence:this.form.details?this.form.details.length:0,name:o.label,description:o.description,next_statuses:[{action:null,sub_process_id:null,next_status:null}]})},removeStatus(e){let t=this.form.details.findIndex(o=>o.status_id==e);console.log("remove status "+e+" "+t),t!==-1&&this.form.details.splice(t,1)},loadRecord(e){console.log("data"),console.log(e),this.resetForm(),this.state.isEdit=!0,this.form=Object.assign({},e),this.form.statuses=e.details.flatMap(t=>t.id),this.form.details=e.details.map(t=>({status_id:t.id,name:t.name,description:t.description,next_statuses:t.next_statuses})),this.form.details.forEach((t,o)=>{t.next_statuses.length==0&&this.addNextStatus(o)}),console.log("CATEGORIES"),console.log(e.categories),this.form.expense_category_id=e.categories.flatMap(t=>Number(t.expense_category_id))},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={name:null,description:null,statuses:[],details:[]}},reload(){this.$emit("reload")},async saveRecord(){this.state.isSaving=!0;let e=Object.assign({},this.form);if(e.details=e.details.map(t=>{let{name:o,description:x,...s}=t;return s}),!this.state.isEdit)this.state.isSaving=!1,await w.create(e).then(t=>{t.status==201&&(this.$swal.fire({title:"Great!",text:"Record successfully saved.",type:"success",icon:"success",timer:2e3}),this.state.showModal=!1,this.resetForm(),this.reload())}).catch(t=>{console.log(t),this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})});else{const t=this.form.id;await w.update(t,e).then(o=>{o.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(o=>{console.log(o),o.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:o.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 ee().shape({name:te().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 se){const t={};e.inner.forEach(o=>{t[o.path]=o.message}),this.errors=t}this.state.isSaving=!1}},compare(e,t){return e.sequence<t.sequence?-1:e.sequence>t.sequence?1:0},reArrangeDetails(){this.form.details=this.form.details.sort(this.compare),this.form.details=this.form.details.map((e,t)=>({...e,sequence:t}))},addNextStatus(e){console.log("adding next status "+e),console.log("this.form.details",this.form.details),this.form.details[e].next_statuses||(this.form.details[e].next_statuses=[]),this.form.details[e].next_statuses.push({action:null,sub_process_id:null,next_status:null}),console.log("selected status : ",this.selectedStatus)},removeNextStatus(e,t){this.form.details[e].next_statuses.splice(t,1)}},Validating(e){console.log(e)},mounted(){}},le=e=>($("data-v-80c718d2"),e=e(),j(),e),ce={class:"p-2"},ue={class:"grid lg:grid-cols-2 gap-8"},de={key:0,class:"text-error"},pe={class:"mt-4"},me=le(()=>r("h5",null,"Process",-1)),he={class:"overflow-x-auto"},fe={class:"p-2 border-r border-slate-200"},ge={class:"col-span-3 space-y-2 p-2"},_e={class:"flex-grow grid grid-cols-3 gap-3"},be=["onClick"],ye=["onClick"],ve={class:"flex gap-1 justify-end"};function xe(e,t,o,x,s,c){const b=n("Loading"),C=n("TextInput"),p=n("FormGroup"),P=n("TextArea"),f=n("Multiselect"),O=n("SubmitButton"),R=n("UpdateButton"),F=n("CloseButton"),E=n("FormModal");return l(),d(E,{title:s.state.isEdit?"Edit Record":"Create Record",active:s.state.showModal,onSubmit:e.confirmSubmit,onClose:c.closeModal,themeClass:s.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full"},{default:u(()=>[r("div",ce,[s.state.isLoading?(l(),d(b,{key:0,text:"Loading record"})):m("",!0),r("form",{onSubmit:t[4]||(t[4]=A((...a)=>e.confirmSubmit&&e.confirmSubmit(...a),["prevent"])),class:"space-y-4"},[s.state.isEdit&&s.state.isLoading?(l(),d(b,{key:0,text:"Fetching record"})):m("",!0),s.state.isSaving?(l(),d(b,{key:1,text:"Saving record"})):m("",!0),r("div",null,[r("div",ue,[i(p,{label:"Name",isRequired:!0},{default:u(()=>[i(C,{type:"text",placeholder:"Input name ",modelValue:s.form.name,"onUpdate:modelValue":t[0]||(t[0]=a=>s.form.name=a),classInput:"h-[48px]"},null,8,["modelValue"]),s.errors.name?(l(),_("span",de)):m("",!0)]),_:1}),i(p,{label:"Description",isRequired:!0},{default:u(()=>[i(P,{placeholder:"Input description",modelValue:s.form.description,"onUpdate:modelValue":t[1]||(t[1]=a=>s.form.description=a),error:s.errors.description,classInput:"h-[64px]"},null,8,["modelValue","error"])]),_:1})]),r("div",null,[i(p,{label:"Expense Categories",isRequired:!0},{default:u(()=>[i(f,{modelValue:s.form.expense_category_id,"onUpdate:modelValue":t[2]||(t[2]=a=>s.form.expense_category_id=a),mode:"tags","close-on-select":!1,searchable:!0,disabled:s.state.isFetchingCategories||!s.categoryOptions.length,options:s.categoryOptions,loading:s.state.isLoadingExpenseInput},null,8,["modelValue","disabled","options","loading"])]),_:1})]),r("div",null,[i(p,{label:"Status",isRequired:!0},{default:u(()=>[i(f,{modelValue:s.form.statuses,"onUpdate:modelValue":t[3]||(t[3]=a=>s.form.statuses=a),mode:"tags","close-on-select":!1,searchable:!0,options:s.statusOptions,onSelect:c.selectStatus,onDeselect:c.removeStatus},null,8,["modelValue","options","onSelect","onDeselect"])]),_:1})])]),r("div",pe,[me,r("div",he,[(l(!0),_(V,null,B(s.form.details,(a,S)=>(l(),_("div",{class:"grid grid-cols-4 border border-slate-300",key:a.id},[r("div",fe,M(a.name),1),r("div",ge,[(l(!0),_(V,null,B(a.next_statuses,(h,k)=>(l(),_("div",{key:k,class:"flex gap-3"},[r("div",_e,[i(p,{label:"Action",labelClass:"text-xs text-slate-300 p-0 mb-0"},{default:u(()=>[i(C,{modelValue:h.action,"onUpdate:modelValue":g=>h.action=g},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024),i(p,{label:"Sub Process",labelClass:"text-xs text-slate-300 p-0 mb-0"},{default:u(()=>[i(f,{modelValue:h.sub_process_id,"onUpdate:modelValue":g=>h.sub_process_id=g,"close-on-select":!0,searchable:!0,options:s.subProcessOptions},null,8,["modelValue","onUpdate:modelValue","options"])]),_:2},1024),i(p,{label:"Next Status",labelClass:"text-xs text-slate-300 p-0 mb-0"},{default:u(()=>[i(f,{modelValue:h.next_status,"onUpdate:modelValue":g=>h.next_status=g,"close-on-select":!0,searchable:!0,options:c.selectedStatus},null,8,["modelValue","onUpdate:modelValue","options"])]),_:2},1024)]),r("div",null,[r("button",{class:"p-1 text-pink-500 font-semibold",onClick:g=>c.removeNextStatus(S,k)}," X ",8,be)])]))),128)),r("div",null,[r("button",{class:"btn py-1 px-2 text-primary-500",onClick:h=>c.addNextStatus(S)}," Add Row ",8,ye)])])]))),128))])]),r("div",ve,[s.state.isEdit?(l(),d(R,{key:1,onClick:c.submitForm},null,8,["onClick"])):(l(),d(O,{key:0,onClick:c.submitForm},null,8,["onClick"])),i(F,{onClick:c.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const Ce=I(ne,[["render",xe],["__scopeId","data-v-80c718d2"]]),Se={components:{Layout:T,CreateButton:G,InputGroup:z,Loading:L,EditButton:Q,DeleteButton:Y,Pagination:H,Form:Ce},setup(){},data(){return{title:"Status Process",breadcrumbs:[{text:"Home",href:"/"},{text:"Settings",href:"/settings/status-process"},{text:"Status Process",active:!0}],columns:[{label:"#",field:"#"},{label:"Name",field:"name"},{label:"Description",field:"description"},{label:"Expense Categories",field:"expense_category_names"},{label:"Action",field:"action_buttons"}],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,isEditRecord:!1}}},watch:{serverOptions:{handler(){console.log(`perPage: ${this.serverOptions.rowsPerPage}`),this.fetchRecords()},deep:!0},searchQuery:q.debounce(function(){this.fetchRecords()},800)},methods:{async fetchRecords(){this.state.isLoading=!0,this.state.isEditRecord=!1,await w.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((o,x)=>({...o,"#":(this.serverOptions.page-1)*this.serverOptions.rowsPerPage+(x+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,w.remove(e).then(o=>{o.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.fetchExpenseCategories(),this.$refs.form.fetchStatuses(),this.$refs.form.fetchRoleGroups(),this.$refs.form.fetchSubProcess(),this.$refs.form.state.showModal=!0},editRecord(e){console.log("edit"),!this.state.isEditRecord&&(this.state.isEditRecord=!0,this.$refs.form.resetForm(),this.$refs.form.fetchExpenseCategories(),this.$refs.form.fetchStatuses(),this.$refs.form.fetchRoleGroups(),this.$refs.form.fetchSubProcess(),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()}},we={class:"p-2 bg-gradient-to-r from-blue-500 to-purple-600 shadow-lg"},Pe={class:"bg-white bg-opacity-[0.8] p-2 rounded-md md:flex items-center"},Oe={class:"text-xl font-semibold text-gray-800 flex-1 md:mb-0 mb-4"},Re={class:"md:flex md:space-x-3 items-center flex-none rtl:space-x-reverse float-right"},Fe={key:0,class:"flex gap-1"},Ee={class:"py-4 flex justify-end"};function ke(e,t,o,x,s,c){const b=n("Loading"),C=n("InputGroup"),p=n("EditButton"),P=n("DeleteButton"),f=n("Pagination"),O=n("vue-good-table"),R=n("Form"),F=n("Card"),E=n("Layout");return l(),d(E,{breadcrumbs:s.breadcrumbs},{nocard:u(()=>[r("div",null,[s.state.isLoading?(l(),d(b,{key:0,text:"Fetching records"})):m("",!0),i(F,{noborder:""},{default:u(()=>[r("div",we,[r("div",Pe,[r("h6",Oe,M(s.title),1),r("div",Re,[i(C,{modelValue:s.searchQuery,"onUpdate:modelValue":t[0]||(t[0]=a=>s.searchQuery=a),placeholder:"Search",type:"text",prependIcon:"heroicons-outline:search",class:"",merged:""},null,8,["modelValue"])])])]),r("div",null,[i(O,{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:e.onShortChange,"max-height":"600px"},{"table-row":u(a=>[a.column.field=="action_buttons"?(l(),_("div",Fe,[e.$ability.can("edit","prfStatus")?(l(),d(p,{key:0,onClick:S=>c.editRecord(a.row)},null,8,["onClick"])):m("",!0),e.$ability.can("delete","prfStatus")?(l(),d(P,{key:1,onClick:S=>c.deleteRecord(a.row.id)},null,8,["onClick"])):m("",!0)])):m("",!0)]),"pagination-bottom":u(a=>[r("div",Ee,[i(f,{total:s.totalItems,current:s.serverOptions.page,"per-page":s.serverOptions.rowsPerPage,onPageChanged:c.handlePageChange,pageChanged:a.pageChanged,perPageChanged:s.serverOptions.rowsPerPage,enableSelect:"",perPageOptions:s.perPageOptions,onChangePerPage:c.handlePerPageChange},null,8,["total","current","per-page","onPageChanged","pageChanged","perPageChanged","perPageOptions","onChangePerPage"])])]),_:1},8,["columns","rows","onSortChange"])]),i(R,{onCloseModal:t[1]||(t[1]=a=>s.state.showModal=!1),ref:"form",onReload:t[2]||(t[2]=a=>c.fetchRecords())},null,512)]),_:1})])]),_:1},8,["breadcrumbs"])}const et=I(Se,[["render",ke]]);export{et as default};
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings