@yqg/simple 1.0.1-beta.1.1 → 1.0.1-beta.1.2
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 +202 -4
- package/dist/constant/fields.d.ts +1 -1
- package/dist/index-66c4e9f4.js.map +1 -1
- package/dist/index-87a0d73b.js.map +1 -1
- package/package.json +16 -1
- package/src/constant/fields.ts +1 -1
package/README.md
CHANGED
|
@@ -278,12 +278,210 @@ class Storage {
|
|
|
278
278
|
|
|
279
279
|
## 常量
|
|
280
280
|
|
|
281
|
+
组件库提供了丰富的常量定义,包括表单字段定义、表格配置等。
|
|
282
|
+
|
|
283
|
+
### 引入方式
|
|
284
|
+
|
|
285
|
+
#### 从主入口引入
|
|
286
|
+
|
|
281
287
|
```javascript
|
|
282
|
-
import
|
|
288
|
+
import { constant } from '@yqg/simple'
|
|
283
289
|
|
|
284
|
-
//
|
|
285
|
-
|
|
286
|
-
|
|
290
|
+
// 使用
|
|
291
|
+
const dateDef = constant.dateTimeDef
|
|
292
|
+
const requiredField = constant.required({ field: 'name', label: '姓名' })
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
#### 按需引入(推荐)
|
|
296
|
+
|
|
297
|
+
```javascript
|
|
298
|
+
// 引入 fields.ts(包含 common-fields 的所有导出)
|
|
299
|
+
import {
|
|
300
|
+
extendsDefValue,
|
|
301
|
+
dateTimeDayStartDef,
|
|
302
|
+
dateTimeDayEndDef,
|
|
303
|
+
// 以下来自 common-fields
|
|
304
|
+
dateTimeDef,
|
|
305
|
+
required,
|
|
306
|
+
merge,
|
|
307
|
+
id,
|
|
308
|
+
timeCreate,
|
|
309
|
+
timeUpdate,
|
|
310
|
+
remark
|
|
311
|
+
} from '@yqg/simple/constant/fields'
|
|
312
|
+
|
|
313
|
+
// 引入 common-fields
|
|
314
|
+
import {
|
|
315
|
+
dateTimeDef,
|
|
316
|
+
required,
|
|
317
|
+
merge,
|
|
318
|
+
primaryStaticProps,
|
|
319
|
+
successStaticProps,
|
|
320
|
+
warningStaticProps,
|
|
321
|
+
fixedLeft,
|
|
322
|
+
fixedRight,
|
|
323
|
+
staticComp,
|
|
324
|
+
blockItem,
|
|
325
|
+
hiddenItem,
|
|
326
|
+
id,
|
|
327
|
+
time,
|
|
328
|
+
timeCreate,
|
|
329
|
+
timeUpdate,
|
|
330
|
+
remark
|
|
331
|
+
} from '@yqg/simple/constant/common-fields'
|
|
332
|
+
|
|
333
|
+
// 引入表格常量
|
|
334
|
+
import { defaultPagination } from '@yqg/simple/constant/table'
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### 常用常量 API
|
|
338
|
+
|
|
339
|
+
#### fields 相关 (`constant/fields`)
|
|
340
|
+
|
|
341
|
+
**字段定义辅助函数:**
|
|
342
|
+
|
|
343
|
+
- `extendsDefValue(options)` - 扩展 DefValue 组件
|
|
344
|
+
```javascript
|
|
345
|
+
const customDef = extendsDefValue({
|
|
346
|
+
props: { showTime: true },
|
|
347
|
+
filter: 'dateTime'
|
|
348
|
+
})
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
- `dateTimeDayStartDef` - 日期时间定义(默认 00:00:00)
|
|
352
|
+
```javascript
|
|
353
|
+
// 用于搜索开始时间
|
|
354
|
+
const startTimeDef = {
|
|
355
|
+
...dateTimeDayStartDef,
|
|
356
|
+
field: 'startTime',
|
|
357
|
+
label: '开始时间'
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
- `dateTimeDayEndDef` - 日期时间定义(默认 23:59:59)
|
|
362
|
+
```javascript
|
|
363
|
+
// 用于搜索结束时间
|
|
364
|
+
const endTimeDef = {
|
|
365
|
+
...dateTimeDayEndDef,
|
|
366
|
+
field: 'endTime',
|
|
367
|
+
label: '结束时间'
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
#### common-fields 相关 (`constant/common-fields`)
|
|
372
|
+
|
|
373
|
+
**辅助函数:**
|
|
374
|
+
|
|
375
|
+
- `merge<T>(...args)` - 合并字段定义
|
|
376
|
+
```javascript
|
|
377
|
+
const customField = merge(dateTimeDef, { required: true, label: '创建时间' })
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
- `required(def)` - 标记字段为必填
|
|
381
|
+
```javascript
|
|
382
|
+
const nameField = required({ field: 'name', label: '姓名' })
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
- `fixedLeft(def, width?)` - 固定列到左侧
|
|
386
|
+
```javascript
|
|
387
|
+
const idColumn = fixedLeft(id, 100)
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
- `fixedRight(def, width?)` - 固定列到右侧
|
|
391
|
+
```javascript
|
|
392
|
+
const opColumn = fixedRight(op, 150)
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
- `staticComp(def)` - 将字段转为静态组件(只读)
|
|
396
|
+
```javascript
|
|
397
|
+
const readOnlyName = staticComp({ field: 'name', label: '姓名' })
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
**样式定义:**
|
|
401
|
+
|
|
402
|
+
- `primaryStaticProps` - 主色文本样式
|
|
403
|
+
- `successStaticProps` - 成功色文本样式
|
|
404
|
+
- `warningStaticProps` - 警告色文本样式
|
|
405
|
+
- `sizeLongProps` - 长宽度输入框样式
|
|
406
|
+
|
|
407
|
+
**布局定义:**
|
|
408
|
+
|
|
409
|
+
- `blockItem` - 块级表单项
|
|
410
|
+
- `hiddenItem` - 隐藏表单项
|
|
411
|
+
- `rangeItem` - 范围表单项
|
|
412
|
+
|
|
413
|
+
**常用字段定义:**
|
|
414
|
+
|
|
415
|
+
- `dateTimeDef` - 日期时间字段
|
|
416
|
+
```javascript
|
|
417
|
+
{ type: 'date', props: { showTime: true }, filter: 'dateTime' }
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
- `id` - ID 字段
|
|
421
|
+
```javascript
|
|
422
|
+
{ field: 'id', label: 'ID' }
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
- `time` - 时间字段
|
|
426
|
+
- `timeCreate` - 创建时间字段
|
|
427
|
+
- `timeUpdate` - 更新时间字段
|
|
428
|
+
- `timeCreated` - 创建时间字段(别名)
|
|
429
|
+
- `timeUpdated` - 更新时间字段(别名)
|
|
430
|
+
- `remark` - 备注字段(文本域)
|
|
431
|
+
- `op` - 操作列字段
|
|
432
|
+
|
|
433
|
+
**七牛上传字段:**
|
|
434
|
+
|
|
435
|
+
- `qiniuFileDef` - 七牛文件上传字段
|
|
436
|
+
- `qiniuImageDef` - 七牛图片上传字段
|
|
437
|
+
|
|
438
|
+
### 使用示例
|
|
439
|
+
|
|
440
|
+
```javascript
|
|
441
|
+
import {
|
|
442
|
+
merge,
|
|
443
|
+
required,
|
|
444
|
+
dateTimeDayStartDef,
|
|
445
|
+
dateTimeDayEndDef,
|
|
446
|
+
id,
|
|
447
|
+
timeCreate,
|
|
448
|
+
timeUpdate,
|
|
449
|
+
remark,
|
|
450
|
+
fixedLeft,
|
|
451
|
+
fixedRight
|
|
452
|
+
} from '@yqg/simple/constant/fields'
|
|
453
|
+
|
|
454
|
+
export default {
|
|
455
|
+
data() {
|
|
456
|
+
return {
|
|
457
|
+
// 表单字段定义
|
|
458
|
+
formFields: [
|
|
459
|
+
required(merge(id, { label: '用户ID' })),
|
|
460
|
+
required({ field: 'name', label: '姓名' }),
|
|
461
|
+
{
|
|
462
|
+
...dateTimeDayStartDef,
|
|
463
|
+
field: 'startTime',
|
|
464
|
+
label: '开始时间'
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
...dateTimeDayEndDef,
|
|
468
|
+
field: 'endTime',
|
|
469
|
+
label: '结束时间'
|
|
470
|
+
},
|
|
471
|
+
remark
|
|
472
|
+
],
|
|
473
|
+
|
|
474
|
+
// 表格列定义
|
|
475
|
+
tableColumns: [
|
|
476
|
+
fixedLeft(id, 80),
|
|
477
|
+
{ field: 'name', label: '姓名' },
|
|
478
|
+
timeCreate,
|
|
479
|
+
timeUpdate,
|
|
480
|
+
fixedRight({ field: 'op', label: '操作' }, 120)
|
|
481
|
+
]
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
287
485
|
```
|
|
288
486
|
|
|
289
487
|
## 文档
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Def } from '@yqg/type';
|
|
2
|
-
import type { CommonObject } from './common-fields
|
|
2
|
+
import type { CommonObject } from './common-fields';
|
|
3
3
|
export * from './common-fields';
|
|
4
4
|
export declare const extendsDefValue: (options: CommonObject) => CommonObject;
|
|
5
5
|
export declare const dateTimeDayStartDef: Def;
|