confirm.ts 554 B

123456789101112131415161718192021222324252627
  1. import { defineStore } from "pinia";
  2. export const useConfirmStore = props => {
  3. const { modalUuid } = props;
  4. return defineStore(`confirm-${modalUuid}`, {
  5. state: () => ({
  6. message: "",
  7. onCompleted: null,
  8. action: null,
  9. params: null
  10. }),
  11. actions: {
  12. init({ message, onCompleted, action, params }) {
  13. this.message = message;
  14. this.onCompleted = onCompleted;
  15. this.action = action;
  16. this.params = params;
  17. },
  18. confirm() {
  19. this.onCompleted({
  20. action: this.action,
  21. params: this.params
  22. });
  23. }
  24. }
  25. })();
  26. };