Transaction.js 587 Bytes
Newer Older
1 2
import Utils from "~/utils";

潘际乾 committed
3 4 5 6 7 8 9 10 11 12 13
const state = {
  operateFuns: {},
};

const mutations = {
  /**
   *
   * @param {Object} state
   * @param {Object} funs
   * @returns
   */
wangguangchao committed
14
  ADD_OPERATE_FUN(state, { id, funs }) {
潘际乾 committed
15 16 17 18 19
    state.operateFuns[id] = funs;
  },
};

const actions = {
潘际乾 committed
20
  setOperateFuns({ commit }, funs) {
wangguangchao committed
21 22
    return new Promise(resolve => {
      // const id = Symbol("transaction-id");
23
      const id = Utils.generateUUID();
wangguangchao committed
24 25 26
      commit('ADD_OPERATE_FUN', { id, funs })
      resolve(id)
    });
潘际乾 committed
27 28 29 30 31 32 33 34 35
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};