layout.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. const state = {
  2. title: '统计报表',
  3. level: 0,
  4. value: ''
  5. }
  6. const mutations = {
  7. SET_TITLE: (state, title) => {
  8. state.title = title
  9. },
  10. SET_LEVEL: (state, level) => {
  11. state.level = level
  12. },
  13. SET_VALUE: (state, value) => {
  14. state.value = value
  15. }
  16. }
  17. const levels = ['统计报表', '数据详情']
  18. const actions = {
  19. init({ commit, state }, payload) {
  20. return new Promise((resolve, reject) => {
  21. commit('SET_TITLE', levels[0])
  22. commit('SET_LEVEL', 0)
  23. })
  24. },
  25. next({ commit, state }, payload) {
  26. return new Promise((resolve, reject) => {
  27. const level = state.level + 1
  28. commit('SET_TITLE', levels[level])
  29. commit('SET_LEVEL', level)
  30. resolve(level)
  31. })
  32. },
  33. pre({ commit, state }, payload) {
  34. return new Promise((resolve, reject) => {
  35. const level = state.level - 1
  36. commit('SET_TITLE', levels[level])
  37. commit('SET_LEVEL', level)
  38. resolve(level)
  39. })
  40. },
  41. gValue({ commit, state }, payload) {
  42. return new Promise((resolve, reject) => {
  43. commit('SET_VALUE', payload)
  44. resolve()
  45. })
  46. }
  47. }
  48. export default {
  49. namespaced: true,
  50. state,
  51. mutations,
  52. actions
  53. }