gxd-vue-library
Version:
依赖与element Ui插件库,聚福宝福利PC端插件库
57 lines (52 loc) • 1.3 kB
JavaScript
;
/**
* @description 常量列表
* @type {Object}
*/
const constantObject = {
STATUS: [
{"label": "启用", "value": 'Y'},
{"label": "禁用", "value": 'N'},
],
IS: [
{"label": "是", "value": 'Y'},
{"label": "否", "value": 'N'},
]
}
/**
* @description 通过值获取选项卡名称
* @param key {String} 常量键值key
* @param value {*} 选项卡值
*/
export function getConstantValueForName(key, value){
let temp = null;
if(!constantObject[key]) return temp;
constantObject[key].map(item=>{
if(item.value === value) temp = item.name;
});
return temp;
}
/**
* @description 通过键值key获取选项列表
* @param key {String} 常量键值key
*/
export function getConstantKeyForList(key) {
let temp = [];
if (!constantObject[key]) return temp;
return constantObject[key];
}
/**
* @description 通过值获取自定义选项卡名称
* @param setting {Object} 自定义选项卡集合
* @param key {String} 常量键值key
* @param value {*} 选项卡值
*/
export function getCustomConstantValueForName(setting, key, value) {
let temp = null;
if (!setting[key]) return temp;
setting[key].map(item => {
if (item.value === value) temp = item.label;
});
console.log(setting, value, temp)
return temp;
}