• vuex


     1 import { getIndustryList } from '@/api/basic'
     2 
     3 const industry = {
     4   state: {
     5     list: []
     6   },
     7 
     8   mutations: {
     9     SET_INDUSTRY_LIST: (state, list) => {
    10       const parentList = list
    11         .filter(item => item.parentIndustryId === '0')
    12         .map(item => { return { label: item.industryNameZhCn, value: item.industryId } })
    13       state.list = parentList.map(parentItem => {
    14         const children = list
    15           .filter(item => item.parentIndustryId === parentItem.value)
    16           .map(item => { return { label: item.industryNameZhCn, value: item.industryId } })
    17         return { ...parentItem, children }
    18       })
    19     }
    20   },
    21 
    22   actions: {
    23     GetIndustryList({commit}) {
    24       getIndustryList().then(response => {
    25         commit('SET_INDUSTRY_LIST', response.data)
    26       })
    27     }
    28   }
    29 }
    30 
    31 export default industry
     1 import { getLocationByCountryId, getCountryList, getCurrencyList, getTimezoneList } from '@/api/basic'
     2 import { CHINA_COUNTRY_ID } from '@/constants/location'
     3 
     4 const location = {
     5   state: {
     6     provincesOfChina: [],
     7     citiesOfChina: [],
     8     districtsOfChina: [],
     9     chinaZoneTree: [],
    10     countries: [],
    11     timeZone: [],  // 时区基础数据7.0接口未找到
    12     currencyList: []
    13   },
    14 
    15   mutations: {
    16     SET_CHINA_PROVINCES(state, provinces) {
    17       state.provincesOfChina = provinces
    18     },
    19     SET_CHINA_CITIES(state, cities) {
    20       state.citiesOfChina = cities
    21     },
    22     SET_CHINA_DISTRICTS(state, districts) {
    23       state.districtsOfChina = districts
    24     },
    25     SET_CHINA_ZONE_TREE(state, data) {
    26       const tree = data.provinces.map(province => {
    27         const cities = data.citys
    28           .filter(city => city.provinceId === province.provinceId)
    29           .map(city => { return { label: city.cityName, value: city.cityId } })
    30         return { label: province.provinceName, value: province.provinceId, children: cities }
    31       })
    32       state.chinaZoneTree = tree
    33     },
    34     SET_COUNTRIES(state, countries) {
    35       state.countries = countries
    36     },
    37     SET_TIMEZONE(state, data) {
    38       state.timeZone = data
    39     },
    40     SET_CURRENCY(state, data) {
    41       state.currencyList = data
    42     }
    43   },
    44 
    45   actions: {
    46     GetProvincesOfChina({ commit }) {
    47       console.log('获取基础地址数据')
    48       getLocationByCountryId(CHINA_COUNTRY_ID).then(response => {
    49         commit('SET_CHINA_PROVINCES', response.data.provinces)
    50         commit('SET_CHINA_CITIES', response.data.citys) // API 存在拼写错误,city复数cities
    51         commit('SET_CHINA_DISTRICTS', response.data.districts)
    52         commit('SET_CHINA_ZONE_TREE', response.data)
    53       })
    54     },
    55     GetCountries({ commit }) {
    56       getCountryList().then(response => {
    57         commit('SET_COUNTRIES', response.data)
    58       })
    59     },
    60     GetTimeZone({ commit }) {
    61       getTimezoneList().then(response => {
    62         commit('SET_TIMEZONE', response.data)
    63       })
    64     },
    65     GetCurrencyList({ commit }) {
    66       getCurrencyList().then(response => {
    67         commit('SET_CURRENCY', response.data)
    68       })
    69     }
    70   }
    71 }
    72 
    73 export default location
  • 相关阅读:
    浅谈MVC架构模式
    用JSP实现学生查询
    读cookie中文字符乱码问题
    span 换行与不换行
    SAP HANA中的Synonym使用及demo 沧海
    SAP HANA HDB序列的使用方法及技巧(SAP HANA HDB SEQUENCE ) 沧海
    SAP HANA中创建与时间相关的数据及Time Attribute View(Fiscal) 沧海
    SAP HANA中创建与时间相关的数据及Time Attribute View(Gregorian) 沧海
    SAP HANA如何在存储过程中使用自定义的table type 沧海
    SAP HANA SQL执行计划(SAP HANA SQL explain plan)(SQL 优化分析) 沧海
  • 原文地址:https://www.cnblogs.com/lujunan/p/10304831.html
Copyright © 2020-2023  润新知