|
|
- import {
- getConfigList,
- getPetTypeList,
- getIncreaseServiceList
- } from '@/api/config/config.js'
-
- const system = {
- state: {
- configList: {},
- petTypeOptions: [],
- increaseServiceOptions: [],
- },
- mutations: {
- setConfigList(state, list) {
- const obj = {}
-
- list.forEach(n => {
- obj[n.paramCode] = n;
- })
-
- state.configList = obj;
- },
- setPetTypeOptions(state, list) {
- state.petTypeOptions = list
- },
- setIncreaseServiceOptions(state, list) {
- state.increaseServiceOptions = list
- },
- },
- actions: {
- async fetchConfigList({
- commit,
- state
- }) {
- try {
- const data = await getConfigList()
-
- commit('setConfigList', data)
- } catch (err) {
-
- }
- },
- async fetchPetTypeOptions({
- commit,
- state
- }) {
- if (state.petTypeOptions.length) {
- return
- }
-
- try {
- const data = await getPetTypeList()
- commit('setPetTypeOptions', data)
- } catch (err) {
-
- }
- },
- async fetchIncreaseServiceOptions({
- commit,
- state
- }) {
- if (state.increaseServiceOptions.length) {
- return
- }
-
- try {
- const data = await getIncreaseServiceList()
- commit('setIncreaseServiceOptions', data)
- } catch (err) {
-
- }
- },
- }
- }
-
- export default system
|