store.js 1.11 KB
Newer Older
xioln's avatar
xioln committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
/* store module */
import config from '@/api/config'
import { actionInit } from '@/utils/store.js'
import axios from 'axios'
export default {
  namespaced: true, // namespaced must be true in module app.
  state: {
    name: process.env.VUE_APP_NAME
  },
  mutations: {},
  actions: actionInit(config, {
    getpvoList({ commit }, params) {
      return new Promise((resolve, reject) => {
        axios.all([config.getPOByName(params), config.getVOByName(params)])
          .then(axios.spread(function(res1, res2) {
            const optionsList = []
            res1.items.forEach(element => {
              optionsList.push({
                label: element.field,
                value: element.field,
                ...element
              })
            })
            res2.items.forEach(element => {
              optionsList.push({
                label: element.field,
                value: element.field,
                voLabel: true,
                ...element
              })
            })
            resolve(optionsList)
          }))
          .catch(e => {
            reject(e)
          })
      })
    }
  })
}