mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 04:01:10 -04:00
v5.0.0 update
This commit is contained in:
74
resources/scripts/stores/modal.js
Normal file
74
resources/scripts/stores/modal.js
Normal file
@ -0,0 +1,74 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useModalStore = (useWindow = false) => {
|
||||
const defineStoreFunc = useWindow ? window.pinia.defineStore : defineStore
|
||||
const { global } = window.i18n
|
||||
|
||||
return defineStoreFunc({
|
||||
id: 'modal',
|
||||
|
||||
state: () => ({
|
||||
active: false,
|
||||
content: '',
|
||||
title: '',
|
||||
componentName: '',
|
||||
id: '',
|
||||
size: 'md',
|
||||
data: null,
|
||||
refreshData: null,
|
||||
variant: '',
|
||||
}),
|
||||
|
||||
getters: {
|
||||
isEdit() {
|
||||
return (this.id ? true : false)
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
openModal(payload) {
|
||||
this.componentName = payload.componentName
|
||||
this.active = true
|
||||
|
||||
if (payload.id) {
|
||||
this.id = payload.id
|
||||
}
|
||||
|
||||
this.title = payload.title
|
||||
|
||||
if (payload.data) {
|
||||
this.data = payload.data
|
||||
}
|
||||
|
||||
if (payload.refreshData) {
|
||||
this.refreshData = payload.refreshData
|
||||
}
|
||||
|
||||
if (payload.variant) {
|
||||
this.variant = payload.variant
|
||||
}
|
||||
|
||||
if (payload.size) {
|
||||
this.size = payload.size
|
||||
}
|
||||
},
|
||||
|
||||
resetModalData() {
|
||||
this.content = ''
|
||||
this.title = ''
|
||||
this.componentName = ''
|
||||
this.id = ''
|
||||
this.data = null
|
||||
this.refreshData = null
|
||||
},
|
||||
|
||||
closeModal() {
|
||||
this.active = false
|
||||
|
||||
setTimeout(() => {
|
||||
this.resetModalData()
|
||||
}, 300)
|
||||
}
|
||||
}
|
||||
})()
|
||||
}
|
||||
Reference in New Issue
Block a user