vue3-element-dict 2.1.2 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -377,6 +377,22 @@ getGlobalConfigApi().then(data => {
377
377
 
378
378
  ## 更新日志
379
379
 
380
+ ### 3.0.1
381
+
382
+ 1. 【修复】修复动态表单组件隐藏的表单变成显示后会校验错误的问题
383
+
384
+ ### 3.0.0
385
+
386
+ 1. 【新增】新增`ElInputDict`、`ElDynamicComponentsDict`、`ElDescriptionsDict`、`ElButtonsDict`组件
387
+
388
+ 2. 【优化】原`disableObj`字段配置改为`disabledObj`, 原先`disableObj`对象中的`disableValue`改为`disabledValues`
389
+
390
+ 3. 【优化】新增`mask`全局配置,用于替换字典包内置的脱敏方法
391
+
392
+ 4. 【优化】字典包配置项新增`mask`、`formatDate`、`validator`、`dynamicComponentsConfig`四个配置项用于新增或覆盖自定义脱敏方法、日期格式化方法、表单校验方法、动态组件配置。
393
+
394
+ 5. 【修复】调整几处细微的逻辑和样式细节
395
+
380
396
  ### 2.1.2
381
397
 
382
398
  1. 【优化】usuallyGetDictTypes配置了localDictCodes重复的字典类型时,给出警告,并且过滤掉本地存在的字典类型。
package/lib/style.css ADDED
@@ -0,0 +1 @@
1
+ .el-buttons-dict[data-v-bcf5096d]{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;width:100%}.dict-dynamic-components.container-class[data-v-ccd77baf]{width:100%;box-sizing:border-box;display:flex;align-items:flex-start;flex-wrap:wrap;container-type:inline-size;container-name:dynamic-components}@container dynamic-components (min-width: 768px){.dict-dynamic-components[data-v-ccd77baf]>.comp-item.form:not(.full):not(.half):not(.three):not(.four){width:50%!important}}@container dynamic-components (min-width: 1024px){.dict-dynamic-components[data-v-ccd77baf]>.comp-item.form:not(.full):not(.half):not(.three):not(.four){width:33.33333%!important}}@container dynamic-components (min-width: 1400px){.dict-dynamic-components[data-v-ccd77baf]>.comp-item.form:not(.full):not(.half):not(.three):not(.four){width:25%!important}}.dict-dynamic-components[data-v-ccd77baf]>.comp-item{width:100%!important}.dict-dynamic-components[data-v-ccd77baf]>.comp-item.full{width:100%!important}.dict-dynamic-components[data-v-ccd77baf]>.comp-item.half{width:50%!important}.dict-dynamic-components[data-v-ccd77baf]>.comp-item.three{width:33.33333%!important}.dict-dynamic-components[data-v-ccd77baf]>.comp-item.four{width:25%!important}
package/lib/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,350 @@
1
+ /**
2
+ * 字典配置相关开始
3
+ */
4
+ export type TreeSetting = {
5
+ idField: string, //唯一标识字段名
6
+ parentIdField: string, //父节点唯一标识字段名
7
+ childrenField: string, //子节点标识字段名
8
+ firstId: string|number, // 根节点值
9
+ labelField: string, //label字段名
10
+ labelArrField: string, //给对象新增的中文数组字段名
11
+ idArrField: string, //给对象新增的id数组字段名
12
+ levelField: string, //给对象新增的层级字段名
13
+ level: number, // 给根目录配置的层级
14
+ leafField: string //叶子节点标识字段名
15
+ }
16
+
17
+ export interface IFilterDataFun {
18
+ (list: {[key: string]: any}[]): {key: string}[]
19
+ }
20
+ export interface IDisabledDataFun extends IFilterDataFun {}
21
+
22
+ export type DictConfig = {
23
+ getDictCodeApi: any; // 获取字典的接口
24
+ version: string; // 当前字典最新版本号
25
+ localDictCodes: { [key: string]: object[] }; // 本地字典数据
26
+ versionKey: string; // 版本号缓存键名
27
+ dictDataKey: string; // 字典数据缓存键名
28
+ query: string; // 请求字典的参数名
29
+ format: {
30
+ // 格式化字典数据的 值和名 字段
31
+ value: string;
32
+ label: string;
33
+ disabled: string;
34
+ type: string;
35
+ color: string;
36
+ };
37
+ formatterDictList: (
38
+ data: { dictData: object; version: string },
39
+ query?: string
40
+ ) => object; //格式化字典数据
41
+ formatterDictVersion: (data: {
42
+ dictData: object;
43
+ version: string;
44
+ }) => string; // 格式化返回的最新字典版本号
45
+ filterDataFun: IFilterDataFun; // 字典数据过滤方法
46
+ disabledDataFun: IDisabledDataFun; // 字典数据禁用方法
47
+ formatterRequest: (query: string, dictType: string) => object; // 格式化请求体
48
+ storage: any; // localstorage sessionstorage
49
+
50
+ isGetAll?: boolean; // 是否请求全部
51
+ usuallyGetDictTypes?: string; // 经常获取的字典数据
52
+ usuallyGetDictTypesByApi?: boolean; // 是否每次都通过接口获取数据
53
+ treeSetting: TreeSetting;
54
+ }
55
+
56
+ // 可选的字典配置
57
+ export type OptionalDictConfig = {
58
+ getDictCodeApi: any; // 获取字典的接口
59
+ version: string; // 当前字典最新版本号
60
+ localDictCodes?: { [key: string]: object[] }; // 本地字典数据
61
+ versionKey?: string; // 版本号缓存键名
62
+ dictDataKey?: string; // 字典数据缓存键名
63
+ query?: string; // 请求字典的参数名
64
+ format?: {
65
+ // 格式化字典数据的 值和名 字段
66
+ value: string;
67
+ label: string;
68
+ disabled: string;
69
+ type: string;
70
+ color: string;
71
+ };
72
+ formatterDictList?: (
73
+ data: { dictCodeList: object; version: string },
74
+ query?: string
75
+ ) => object; //格式化字典数据
76
+ formatterDictVersion?: (data: {
77
+ dictCodeList: object;
78
+ version: string;
79
+ }) => string; // 格式化返回的最新字典版本号
80
+ filterDataFun?: (list: object[]) => object[]; // 字典数据过滤方法
81
+ disabledDataFun?: (list: object[]) => object[]; // 字典数据禁用方法
82
+
83
+ formatterRequest?: (query: string, dictType: string) => object; // 格式化请求体
84
+ storage?: any; // localstorage sessionstorage
85
+ isGetAll?: boolean; // 是否请求全部
86
+ usuallyGetDictTypes?: string; // 经常获取的字典数据
87
+ usuallyGetDictTypesByApi?: boolean; // 是否每次都通过接口获取数据
88
+ treeSetting?: FewTreeSetting;
89
+ }
90
+
91
+
92
+ // 可选的树形配置
93
+ export type OptionalTreeSetting = {
94
+ idField?: "id", //唯一标识字段名
95
+ parentIdField?: "parentId", //父节点唯一标识字段名
96
+ childrenField?: "children", //子节点标识字段名
97
+ firstId?: "0", // 根节点值
98
+ labelField?: "label", //label字段名
99
+ labelArrField?: "labelArr", //给对象新增的中文数组字段名
100
+ idArrField?: "idArr", //给对象新增的id数组字段名
101
+ levelField?: "level", //给对象新增的层级字段名
102
+ level?: 0, // 给根目录配置的层级
103
+ leafField?: "leaf" //叶子节点标识字段名
104
+ }
105
+
106
+ // 通过code获取树形数据配置
107
+ export type GetTreeItemByCodeOptions = {
108
+ idField: string,
109
+ parentIdField: string
110
+ }
111
+
112
+ export type GetTreeItemByLabelOptions = {
113
+ idField: string,
114
+ labelField: string, //唯一标识字段名
115
+ parentIdField: string //父节点唯一标识字段名
116
+ }
117
+
118
+ /**
119
+ * 字典配置相关结束
120
+ */
121
+
122
+ /**
123
+ * 脱敏相关开始
124
+ */
125
+ export type OptionalMaskOptions = {
126
+ start?: number; // 从前往后保留的位数,默认为 1
127
+ end?: number; // 从后往前保留的位数,默认为 0
128
+ middle?: number; // 中间展示几个symbol
129
+ symbol?: string; // 替换的字符,默认为 *
130
+ }
131
+
132
+ export type MaskOptions = {
133
+ start: number; // 从前往后保留的位数,默认为 1
134
+ end: number; // 从后往前保留的位数,默认为 0
135
+ symbol: string; // 替换的字符,默认为 *
136
+ middle?: number; // 中间展示几个symbol
137
+ }
138
+
139
+ export type MaskType = "name" | "mobile" |"address" | "idCard" | "none" | ""
140
+
141
+ // 必填的脱敏配置
142
+ export type DesensitizationOptions = MaskOptions & {
143
+ defaultVal: string,
144
+ maskType: MaskType,
145
+ middle?: number;
146
+ }
147
+
148
+ // 可选的脱敏方法配置
149
+ export type OptionalDesensitizationOptions = OptionalMaskOptions & {
150
+ middle?: number,
151
+ defaultVal?: string,
152
+ maskType?: MaskType
153
+ }
154
+ /**
155
+ * 脱敏相关结束
156
+ */
157
+
158
+ /**
159
+ * 日期格式化 开始
160
+ */
161
+ export type DefaultForamt = {
162
+ date: string,
163
+ month: string,
164
+ datetime: string,
165
+ time: string,
166
+ year: string
167
+ }
168
+
169
+ export type FormatType = "date" | "month" | "datetime" | "time" | "year"
170
+
171
+ /**
172
+ * 日期格式化 结束
173
+ */
174
+
175
+ // 获取字典配置接口
176
+ export interface IGetDictConfig {
177
+ (): DictConfig
178
+ }
179
+
180
+ // 通过key获取对应字典配置接口
181
+ export interface IGetDictConfigByKey {
182
+ (string): any
183
+ }
184
+
185
+ // 判断是否是日期接口
186
+ export interface IIsDate {
187
+ (string): boolean
188
+ }
189
+
190
+ // 格式化日期接口
191
+ export interface IFormatDate {
192
+ (date: Date|string|number, format: string, defaultVal?:string): string
193
+ }
194
+
195
+
196
+ // 通过code获取字典数据接口
197
+ export interface IGetLabelByCode {
198
+ (val: string | number, type: string, defaultVal?: string | number): Promise<string | number>
199
+ }
200
+
201
+ export interface IGetLabelByCodeFilter {
202
+ (val: string | number, type: string, defaultVal?: string | number): string | number | undefined
203
+ }
204
+
205
+ export type Format = { label: string | number; value: string | number }
206
+
207
+ export type GetLabelByCodesOptions = {
208
+ defaultVal?: string | number,
209
+ formatFun?: (arr: object[], format: Format) => string|number,
210
+ spacer?: string
211
+ }
212
+
213
+ // 通过多个code获取多个label
214
+ export interface IGetLabelByCodes {
215
+ (vals: string | (string | number)[], type: string, options?: GetLabelByCodesOptions): Promise<string|number>
216
+ }
217
+
218
+ export interface IGetLabelByCodesFilter {
219
+ (vals: string | (string | number)[], type: string, options?: GetLabelByCodesOptions): string | number | undefined
220
+ }
221
+
222
+
223
+ export interface IGetCodeByLabel {
224
+ (val: string | number, type: string, defaultVal?: string | number): Promise<string | number>
225
+ }
226
+
227
+ export interface IGetCodeByLabelFilter {
228
+ (val: string | number, type: string, defaultVal?: string | number): string | number | undefined
229
+ }
230
+
231
+
232
+ export type GetCodeByLabelsOptions = GetLabelByCodesOptions
233
+ export interface IGetCodeByLabels {
234
+ (vals: string | (string | number)[], type: string, options?: GetCodeByLabelsOptions): Promise<string|number>
235
+ }
236
+
237
+ export interface IGetCodeByLabelsFilter {
238
+ (vals: string | (string | number)[], type: string, options?: GetCodeByLabelsOptions): string|number|undefined
239
+ }
240
+
241
+ export interface IGetDictObjByDictTypes {
242
+ (dictTypes: string | string[]): Promise<object>
243
+ }
244
+
245
+ export interface IListToTree {
246
+ (data: object[], config?: OptionalTreeSetting, parentObj?:{ [key: string]: any }): object[]
247
+ }
248
+
249
+ export interface IGetTreeItemByCode {
250
+ (id: string | number, arr: {[key: string]: any}[], options: GetTreeItemByCodeOptions): object[]
251
+ }
252
+
253
+ export interface IGetTreeItemByLabel {
254
+ (label: string | number, arr: {[key: string]: any}[], options: GetTreeItemByLabelOptions): object[]
255
+ }
256
+
257
+ export interface IMask {
258
+ (str: string, paramsOptions: OptionalMaskOptions): string
259
+ }
260
+
261
+ export interface IMaskName {
262
+ (name: string, symbol:string): string
263
+ }
264
+
265
+ export interface IMaskIdCard {
266
+ (idcard: string, symbol: string): string
267
+ }
268
+
269
+ export interface IMaskPhone {
270
+ (phone: string | number, symbol: string): string
271
+ }
272
+
273
+ export interface IMaskAddress {
274
+ (address: string, symbol: string): string
275
+ }
276
+
277
+ export type MaskTypeObj = {
278
+ mobile: IMaskPhone
279
+ name: IMaskName
280
+ address: IMaskAddress
281
+ idCard: IMaskIdCard
282
+ }
283
+
284
+ export interface IDesensitization {
285
+ (str: string, options: OptionalDesensitizationOptions): string
286
+ }
287
+
288
+ export interface IFormatFun {
289
+ (arr: any, treeSetting: TreeSetting): string|number
290
+ }
291
+ export type GetTreeLabelByCodeOptions = {
292
+ defaultVal?: string | number,
293
+ formatFun?: IFormatFun,
294
+ treeSetting?: OptionalTreeSetting
295
+ }
296
+ export interface IGetTreeLabelByCode {
297
+ (val: string, type: string, options?:GetTreeLabelByCodeOptions): Promise<string|number>
298
+ }
299
+
300
+ export interface IGetTreeLabelByCodeFilter {
301
+ (val: string, type: string, options?:GetTreeLabelByCodeOptions): string | number | undefined
302
+ }
303
+
304
+ export interface IFormatFunIn {
305
+ (arr: any, treeSetting: TreeSetting): string
306
+ }
307
+
308
+ export interface IFormatFunOut {
309
+ (arr: any, treeSetting: TreeSetting): string
310
+ }
311
+
312
+ export type GetTreeLabelByCodesOptions = {
313
+ defaultVal?: string | number,
314
+ formatFunIn?: IFormatFunIn,
315
+ treeSetting?: OptionalTreeSetting,
316
+ formatFunOut?: IFormatFunOut,
317
+ spacer?: string
318
+ }
319
+
320
+ export interface IGetTreeLabelByCodes {
321
+ (vals: string[] | string, type: string, options?: GetTreeLabelByCodesOptions): Promise<string|number>
322
+ }
323
+
324
+ export interface IGetTreeLabelByCodesFilter {
325
+ (vals: string[] | string, type: string, options?: GetTreeLabelByCodesOptions): string | number | undefined
326
+ }
327
+
328
+ export type GetTreeCodeByLabelOptions = GetTreeLabelByCodeOptions
329
+ export interface IGetTreeCodeByLabel {
330
+ ( val: string, type: string, options?: GetTreeCodeByLabelOptions): Promise<string | number>
331
+ }
332
+
333
+ export interface IGetTreeCodeByLabelFilter {
334
+ ( val: string, type: string, options?: GetTreeCodeByLabelOptions): string | number | undefined
335
+ }
336
+
337
+ export type GetTreeCodeByLabelsOptions = GetTreeLabelByCodesOptions
338
+ export interface IGetTreeCodeByLabels {
339
+ ( vals: string[] | string, type: string, options?: GetTreeCodeByLabelsOptions): Promise<string|number>
340
+ }
341
+
342
+ export interface IGetTreeCodeByLabelsFilter {
343
+ ( vals: string[] | string, type: string, options?: GetTreeCodeByLabelsOptions): string | number | undefined
344
+ }
345
+
346
+
347
+
348
+ export interface IGetItemByCode {
349
+ (val: string | number, type: string, defaultVal?: string | number): Promise<object | string | number>
350
+ }