123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import { fetchVehIcon, fetchUserIcon, fetchFacIcon } from "@/api/iconConfig/iconConfig";
- import { isEmpty } from 'lodash';
- const icon = {
- state: {
- vehIcon: null,
- userIcon: null,
- facIcon: null,
- },
- mutations: {
- SET_ICON: (state, {key,data}) => {
- state[key] = data
- },
- },
- actions: {
- // 获取车辆图标
- async getVehIcon({ commit, state }) {
- // console.log(this,'this')
- if (!isEmpty(state.vehIcon)) {
- return new Promise((resolve) => {
- resolve(state.vehIcon)
- })
- } else {
- let { code, data } = await fetchVehIcon({})
- if (code == 0) {
- commit('SET_ICON', {key: 'vehIcon',data},)
- }
- return new Promise((resolve) => {
- resolve(state.vehIcon)
- })
- }
- },
- // 获取人员类型图标
- async getUserIcon({ commit, state }) {
- if (!isEmpty(state.userIcon)) {
- return new Promise((resolve) => {
- resolve(state.userIcon)
- })
- } else {
- let { code, data } = await fetchUserIcon({})
- if (code == 0) {
- commit('SET_ICON', {key: 'userIcon',data},)
- }
- return new Promise((resolve) => {
- resolve(state.userIcon)
- })
- }
- },
- // 获取设施类型图标
- async getFacIcon({ commit, state }) {
- if (!isEmpty(state.facIcon)) {
- return new Promise((resolve) => {
- resolve(state.facIcon)
- })
- } else {
- let { code, data } = await fetchFacIcon({})
- if (code == 0) {
- commit('SET_ICON', {key: 'facIcon',data},)
- }
- return new Promise((resolve) => {
- resolve(state.facIcon)
- })
- }
- },
- }
- }
- export default icon
|