parent
138fee1560
commit
88e110b6b0
@ -0,0 +1,4 @@
|
||||
export const dict_types = ["sys_user_sex",
|
||||
"sys_show_hide", "sys_normal_disable", "sys_job_status", "sys_job_group", "sys_yes_no", "sys_notice_type", "sys_notice_status",
|
||||
"sys_oper_type", "sys_common_status", "wms_item_type", "wms_carrier_level", "wms_supplier_level", "wms_receipt_type", "wms_receipt_status",
|
||||
"wms_shipment_type", "wms_shipment_status", "wms_movement_type", "wms_movement_status"];
|
||||
@ -0,0 +1,37 @@
|
||||
import {allByTypes} from "@/api/system/dict/data";
|
||||
import {dict_types} from "@/config/business";
|
||||
|
||||
const dict = {
|
||||
state: {
|
||||
dictMap: {}
|
||||
},
|
||||
|
||||
mutations: {
|
||||
SET_DICT_MAP: (state, map) => {
|
||||
state.dictMap = map
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
loadDictionaries({ commit, state }, force = false) {
|
||||
if (!force && Object.keys(state.dictMap).length > 0) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return allByTypes(dict_types).then(res => {
|
||||
const rows = res.data
|
||||
rows.sort((a, b) => a.dictSort - b.dictSort);
|
||||
const map = {}
|
||||
rows.forEach(it => {
|
||||
let list = map[it.dictType];
|
||||
if (!list) {
|
||||
list = [];
|
||||
map[it.dictType] = list;
|
||||
}
|
||||
list.push({...it, label: it.dictLabel, value: it.dictValue.match(/^\d+$/) ? +it.dictValue : it.dictValue })
|
||||
})
|
||||
commit('SET_DICT_MAP', map)
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default dict
|
||||
Loading…
Reference in new issue