@zl-ui-kit/components 0.18.0 → 0.18.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.
Files changed (2) hide show
  1. package/README.md +114 -7
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -875,6 +875,36 @@ const { data } = useDataRequest(getChartDataApi, { dataKey: 'data' })
875
875
 
876
876
  内部用 `usePageableRequest` 驱动分页与查询;`columns` 为 `TableColumn[]`,`queryItems` 为 `SearchItem[]`。
877
877
 
878
+ `queryItems` 与 `ZlForm` 的 `items` 是同一套 schema:基础查询项直接 `component` + `props` 配置(不用写模板),
879
+ 选项类控件用 EP 的 `options`,字段不是 `label`/`value` 时用 `props` 别名重映射,联动项用 `slot:true` + `#<model>` 接管:
880
+
881
+ ```ts
882
+ const queryItems: SearchItem[] = [
883
+ {
884
+ model: 'keyword',
885
+ label: '名称',
886
+ component: 'el-input',
887
+ props: { placeholder: '请输入名称', clearable: true },
888
+ },
889
+ {
890
+ model: 'type',
891
+ label: '类型',
892
+ component: 'el-select',
893
+ props: {
894
+ options: [
895
+ { id: 'db', name: '数据库' },
896
+ { id: 'api', name: 'API' },
897
+ ],
898
+ props: { value: 'id', label: 'name' },
899
+ clearable: true,
900
+ style: 'width: 100%',
901
+ },
902
+ // 条件标签文案 / 查询入参可用 SearchItem 的 toLabel / toParams 转换
903
+ toLabel: (v) => (v === 'db' ? '数据库' : 'API'),
904
+ },
905
+ ]
906
+ ```
907
+
878
908
  #### ② `ZlCardPage` —— 直接传 service
879
909
 
880
910
  ```vue
@@ -886,6 +916,7 @@ const { data } = useDataRequest(getChartDataApi, { dataKey: 'data' })
886
916
  ```
887
917
 
888
918
  内部组合 `usePageableRequest + ZlSearch + ZlPagination + ZlEmpty`。
919
+ 搜索栏直接由 `queryItems: SearchItem[]` 驱动,写法与上面的 `ZlSearchTable` 完全一致(`component` + `props` 配置,选项类用 EP 的 `options`)。
889
920
 
890
921
  **条件查询 / 页签切换怎么重查**:把变化源放进 `request.options.refreshDeps`(ref / getter 数组),
891
922
  依赖变化会自动重查**并回到第 1 页**——卡片页的请求是 `manual` 的(首屏由 `ZlSearch` 触发),
@@ -1395,23 +1426,99 @@ function cardActions(data: any) {
1395
1426
 
1396
1427
  ### ZlForm —— schema 驱动
1397
1428
 
1429
+ 基础表单项**不用写模板**:`component` 直接写 EP 组件名(`el-input` / `el-select` / `el-radio-group` …)或组件对象,
1430
+ `props` 原样透传给该控件,并自动包装 `update:modelValue` 回写 `model`(不必自己接 `v-model`)。
1431
+
1398
1432
  ```ts
1433
+ const form = reactive<Record<string, any>>({})
1434
+ const contractOptions = ref([{ id: 'c1', name: '合约 A' }])
1435
+ const envOptions = ref([
1436
+ { label: '生产', value: 'prod' },
1437
+ { label: '测试', value: 'test' },
1438
+ ])
1439
+
1399
1440
  const items: FormItem[] = [
1400
- { model: 'name', label: '名称', component: 'el-input', props: { placeholder: '请输入' }, rules: [{ required: true }] },
1401
- { model: 'type', label: '类型', component: 'el-select', props: { options: [...] } },
1441
+ // 选项类:用 EP 的 options;数据字段不是 label/value 时用 props 别名重映射(props 里嵌 props)
1442
+ {
1443
+ model: 'contractId',
1444
+ label: '合约名称',
1445
+ component: 'el-select',
1446
+ props: {
1447
+ options: contractOptions.value,
1448
+ props: { value: 'id', label: 'name' },
1449
+ clearable: true,
1450
+ filterable: true,
1451
+ style: 'width: 100%',
1452
+ },
1453
+ // rules 属于 el-form-item → 放 formItemProps,不要平铺在 item 上
1454
+ formItemProps: { rules: [{ required: true, message: '请选择合约名称', trigger: 'change' }] },
1455
+ },
1456
+ // 动态禁用:在生成 schema 时算进 options(computed 随依赖变化重算整表)
1457
+ {
1458
+ model: 'env',
1459
+ label: '计算环境',
1460
+ component: 'el-radio-group',
1461
+ props: { options: envOptions.value.map((i) => ({ ...i, disabled: i.disabled })) },
1462
+ },
1463
+ // 输入类:placeholder / maxlength / 多行(type/rows/showWordLimit)全走 props
1464
+ {
1465
+ model: 'name',
1466
+ label: '任务名称',
1467
+ component: 'el-input',
1468
+ props: { placeholder: '请输入', maxlength: 30 },
1469
+ },
1402
1470
  { model: 'enable', label: '启用', component: 'ZlSwitch' },
1471
+ // 联动 / 复合控件(多选表格、树选择)不硬塞 props,用 slot:true + #<model> 插槽整块接管
1472
+ { model: 'productIds', label: '数据产品', slot: true },
1403
1473
  ]
1404
1474
  ```
1405
1475
 
1406
1476
  ```vue
1407
- <ZlForm :model="form" :items="items" label-width="auto" />
1477
+ <ZlForm :model="form" :items="items" label-width="auto">
1478
+ <template #productIds="{ model }">…</template>
1479
+ </ZlForm>
1408
1480
  ```
1409
1481
 
1410
- `FormItem` 关键字段:`model`(必填) / `label` / `component`(组件名或组件) / `props`(自动包装 `update:modelValue` 回写) / `slots` / `rules` / `defaultValue` / `visible`(布尔或函数) / `tooltip`(label 后帮助图标 + tooltip)。
1482
+ `FormItem` 关键字段:`model`(必填) / `label` / `component`(组件名或组件) / `props`(控件入参,自动包装 `update:modelValue` 回写) /
1483
+ `slots`(控件插槽) / `formItemProps`(`el-form-item` 属性,如 `rules`) / `defaultValue` / `visible`(布尔或函数) / `tooltip`(label 后帮助图标) / `slot`(启用 `#<model>` 插槽)。
1484
+
1485
+ > `rules` 必须写在 `formItemProps` 里:item 上除上述字段外的键会被当作**控件 props** 透传给控件,写错不会报错、但校验不生效。
1411
1486
 
1412
1487
  ### ZlSearch —— 查询条
1413
1488
 
1414
- 见 6.3 ④。`items: SearchItem[]`,`SearchItem` 继承 `FormItem` 并扩展 `toLabel`(值→条件标签) 与 `toParams`(值→查询参数合并)。
1489
+ `items: SearchItem[]`,与 `ZlForm` 的 `items` **同一套 schema**:基础查询项直接 `component` + `props` 配置(不用写模板),
1490
+ 选项类用 EP 的 `options`(字段不是 `label`/`value` 时用 `props` 别名重映射),联动 / 复合项用 `slot:true` + `#<model>` 插槽接管。
1491
+ `SearchItem` 在 `FormItem` 之上扩展了 `toLabel`(值→条件标签文案) 与 `toParams`(值→查询参数合并)。
1492
+
1493
+ ```ts
1494
+ const items: SearchItem[] = [
1495
+ {
1496
+ model: 'keyword',
1497
+ label: '名称',
1498
+ component: 'el-input',
1499
+ props: { placeholder: '请输入名称', clearable: true },
1500
+ },
1501
+ {
1502
+ model: 'type',
1503
+ label: '类型',
1504
+ component: 'el-select',
1505
+ props: {
1506
+ options: [
1507
+ { id: 'db', name: '数据库' },
1508
+ { id: 'api', name: 'API' },
1509
+ ],
1510
+ props: { value: 'id', label: 'name' },
1511
+ clearable: true,
1512
+ style: 'width: 100%',
1513
+ },
1514
+ toLabel: (v) => (v === 'db' ? '数据库' : 'API'),
1515
+ },
1516
+ ]
1517
+ ```
1518
+
1519
+ ```vue
1520
+ <ZlSearch :items="items" @search="onSearch" />
1521
+ ```
1415
1522
 
1416
1523
  **自适应溢出**(`useSearchFormOverflow`,移植自源组件逻辑,非按项数猜):
1417
1524
 
@@ -4142,11 +4249,11 @@ import { ZlCardPage } from '@zl-ui-kit/components'
4142
4249
  </script>
4143
4250
 
4144
4251
  <template>
4145
- <ZlCardPage :request="mockPageRequest" card-min-width="200px" />
4252
+ <ZlCardPage :request="mockPageRequest" card-min-width="200px" :query-items="queryItems" />
4146
4253
  </template>
4147
4254
  ```
4148
4255
 
4149
- > 示例中的 `request` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
4256
+ > 示例中的 `request`、`queryItems` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
4150
4257
 
4151
4258
  **插槽用法**
4152
4259
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zl-ui-kit/components",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "type": "module",
5
5
  "description": "ZL UI 业务组件库(Element Plus 体系,Zl 前缀)——首批:Icon/AutoTooltip/Tag/CornerTag/Text/Title/Copy/Empty/Pagination/DictTag",
6
6
  "license": "MIT",
@@ -39,9 +39,9 @@
39
39
  "file-type": "^20.4.1",
40
40
  "dt-sql-parser": "^4.3.1",
41
41
  "sql-formatter": "^15.4.2",
42
- "@zl-ui-kit/composables": "0.18.0",
43
- "@zl-ui-kit/utils": "0.18.0",
44
- "@zl-ui-kit/icons": "0.18.0"
42
+ "@zl-ui-kit/composables": "0.18.1",
43
+ "@zl-ui-kit/icons": "0.18.1",
44
+ "@zl-ui-kit/utils": "0.18.1"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@vueuse/core": "^12.3.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
@@ -98,10 +98,10 @@
98
98
  "@vue-office/pdf": "^2.0.10",
99
99
  "@vue-office/pptx": "1.0.1",
100
100
  "echarts": "^5.6.0",
101
- "@zl-ui-kit/theme": "0.18.0",
102
- "@jichuang/eslint-config": "1.0.0",
103
101
  "@jichuang/tsconfig": "1.0.0",
104
- "@jichuang/vite-config": "1.0.0"
102
+ "@jichuang/eslint-config": "1.0.0",
103
+ "@jichuang/vite-config": "1.0.0",
104
+ "@zl-ui-kit/theme": "0.18.1"
105
105
  },
106
106
  "repository": {
107
107
  "type": "git",