提交 | 用户 | 时间
|
0cceb6
|
1 |
import { mergeRecursive } from "@/utils/ruoyi"; |
Y |
2 |
import DictOptions from './DictOptions' |
|
3 |
|
|
4 |
/** |
|
5 |
* @classdesc 字典元数据 |
|
6 |
* @property {String} type 类型 |
|
7 |
* @property {Function} request 请求 |
|
8 |
* @property {String} label 标签字段 |
|
9 |
* @property {String} value 值字段 |
|
10 |
*/ |
|
11 |
export default class DictMeta { |
|
12 |
constructor(options) { |
|
13 |
this.type = options.type |
|
14 |
this.request = options.request |
|
15 |
this.responseConverter = options.responseConverter |
|
16 |
this.labelField = options.labelField |
|
17 |
this.valueField = options.valueField |
|
18 |
this.lazy = options.lazy === true |
|
19 |
} |
|
20 |
} |
|
21 |
|
|
22 |
|
|
23 |
/** |
|
24 |
* 解析字典元数据 |
|
25 |
* @param {Object} options |
|
26 |
* @returns {DictMeta} |
|
27 |
*/ |
|
28 |
DictMeta.parse= function(options) { |
|
29 |
let opts = null |
|
30 |
if (typeof options === 'string') { |
|
31 |
opts = DictOptions.metas[options] || {} |
|
32 |
opts.type = options |
|
33 |
} else if (typeof options === 'object') { |
|
34 |
opts = options |
|
35 |
} |
|
36 |
opts = mergeRecursive(DictOptions.metas['*'], opts) |
|
37 |
return new DictMeta(opts) |
|
38 |
} |