123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import {defineStore} from "pinia";
- export const useDialogStore = defineStore('dialog', {
- state: () => ({
- dialogShows: <any>[],
- confirmParam: <any>{
- show: false,
- title: '提示',
- content: '',
- onSubmit: () => {},
- onCancel: () => {},
- }
- }),
- getters: {
- },
- actions: {
- add(key) {
- const oldDom: any = document.body.getElementsByClassName(this.dialogShows[0])?.[0]
- if (oldDom) {
- oldDom.style.display = 'none'
- }
- this.dialogShows.unshift(key)
- },
- del(key) {
- this.dialogShows = this.dialogShows.filter(v => v !== key)
- const newDom: any = document.body.getElementsByClassName(this.dialogShows[0])?.[0]
- if (newDom) {
- newDom.style.display = 'unset'
- }
- },
- confirm({title = '提示', content, onSubmit, onCancel = () => {}}) {
- this.confirmParam = {
- show: true,
- title: title,
- content,
- onSubmit: onSubmit,
- onCancel: onCancel
- }
- }
- },
- })
|