fantasy-ngzorro 2.1.0 → 2.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.
Files changed (107) hide show
  1. package/README.md +765 -804
  2. package/bundles/fantasy-ngzorro.umd.js +1780 -623
  3. package/bundles/fantasy-ngzorro.umd.js.map +1 -1
  4. package/bundles/fantasy-ngzorro.umd.min.js +2 -2
  5. package/bundles/fantasy-ngzorro.umd.min.js.map +1 -1
  6. package/esm2015/fantasy-ngzorro.js +26 -24
  7. package/esm2015/hd-button/hd-button.component.js +6 -11
  8. package/esm2015/hd-button/hd-button.module.js +3 -7
  9. package/esm2015/hd-button-group/hd-button-group.component.js +1 -1
  10. package/esm2015/hd-button-group/hd-button-group.module.js +3 -3
  11. package/esm2015/hd-component.module.js +3 -1
  12. package/esm2015/hd-current-table/hd-current-table.component.js +1 -1
  13. package/esm2015/hd-detail-form/hd-detail-form.component.js +14 -4
  14. package/esm2015/hd-detail-form/hd-detail-form.module.js +3 -5
  15. package/esm2015/hd-detail-lines/hd-detail-lines.component.js +173 -30
  16. package/esm2015/hd-detail-lines/hd-detail-lines.module.js +18 -8
  17. package/esm2015/hd-detail-lines-page/hd-detail-lines-page.component.js +357 -0
  18. package/esm2015/hd-detail-lines-page/hd-detail-lines-page.module.js +20 -0
  19. package/esm2015/hd-detail-tip/hd-detail-tip.component.js +18 -8
  20. package/esm2015/hd-detail-tip/hd-detail-tip.module.js +3 -3
  21. package/esm2015/hd-filter/hd-filter.component.js +76 -15
  22. package/esm2015/hd-filter/hd-filter.module.js +3 -19
  23. package/esm2015/hd-filter/hd-filter.service.js +5 -1
  24. package/esm2015/hd-form/hd-form.component.js +76 -3
  25. package/esm2015/hd-form/hd-form.module.js +3 -23
  26. package/esm2015/hd-form/hd-form.service.js +19 -3
  27. package/esm2015/hd-form-lines/hd-form-lines.component.js +267 -135
  28. package/esm2015/hd-form-lines/hd-form-lines.module.js +3 -21
  29. package/esm2015/hd-form-lines/hd-form-lines.service.js +9 -1
  30. package/esm2015/hd-log/hd-log.component.js +2 -2
  31. package/esm2015/hd-log/hd-log.module.js +3 -1
  32. package/esm2015/hd-popconfirm/hd-popconfirm.component.js +2 -2
  33. package/esm2015/hd-popconfirm/hd-popconfirm.module.js +3 -3
  34. package/esm2015/hd-space/hd-space.module.js +3 -3
  35. package/esm2015/hd-status/hd-status.component.js +17 -8
  36. package/esm2015/hd-status/hd-status.module.js +4 -2
  37. package/esm2015/hd-status/hd-status.service.js +7 -6
  38. package/esm2015/hd-table/hd-table.component.js +246 -115
  39. package/esm2015/hd-table/hd-table.service.js +8 -1
  40. package/esm2015/hd-tip/hd-tip.component.js +3 -3
  41. package/esm2015/hd-tip/hd-tip.module.js +3 -3
  42. package/esm2015/index.js +2 -2
  43. package/esm2015/model/common-type.js +35 -1
  44. package/esm2015/public-api.js +2 -2
  45. package/esm5/fantasy-ngzorro.js +26 -24
  46. package/esm5/hd-button/hd-button.component.js +15 -19
  47. package/esm5/hd-button/hd-button.module.js +3 -7
  48. package/esm5/hd-button-group/hd-button-group.component.js +1 -1
  49. package/esm5/hd-button-group/hd-button-group.module.js +3 -3
  50. package/esm5/hd-component.module.js +3 -1
  51. package/esm5/hd-current-table/hd-current-table.component.js +1 -1
  52. package/esm5/hd-detail-form/hd-detail-form.component.js +14 -4
  53. package/esm5/hd-detail-form/hd-detail-form.module.js +3 -5
  54. package/esm5/hd-detail-lines/hd-detail-lines.component.js +211 -25
  55. package/esm5/hd-detail-lines/hd-detail-lines.module.js +18 -8
  56. package/esm5/hd-detail-lines-page/hd-detail-lines-page.component.js +423 -0
  57. package/esm5/hd-detail-lines-page/hd-detail-lines-page.module.js +24 -0
  58. package/esm5/hd-detail-tip/hd-detail-tip.component.js +18 -8
  59. package/esm5/hd-detail-tip/hd-detail-tip.module.js +3 -3
  60. package/esm5/hd-filter/hd-filter.component.js +91 -16
  61. package/esm5/hd-filter/hd-filter.module.js +3 -19
  62. package/esm5/hd-filter/hd-filter.service.js +5 -1
  63. package/esm5/hd-form/hd-form.component.js +87 -3
  64. package/esm5/hd-form/hd-form.module.js +3 -23
  65. package/esm5/hd-form/hd-form.service.js +19 -3
  66. package/esm5/hd-form-lines/hd-form-lines.component.js +286 -129
  67. package/esm5/hd-form-lines/hd-form-lines.module.js +3 -21
  68. package/esm5/hd-form-lines/hd-form-lines.service.js +9 -1
  69. package/esm5/hd-log/hd-log.component.js +2 -2
  70. package/esm5/hd-log/hd-log.module.js +3 -1
  71. package/esm5/hd-popconfirm/hd-popconfirm.component.js +2 -2
  72. package/esm5/hd-popconfirm/hd-popconfirm.module.js +3 -3
  73. package/esm5/hd-space/hd-space.module.js +3 -3
  74. package/esm5/hd-status/hd-status.component.js +16 -7
  75. package/esm5/hd-status/hd-status.module.js +4 -2
  76. package/esm5/hd-status/hd-status.service.js +7 -6
  77. package/esm5/hd-table/hd-table.component.js +252 -102
  78. package/esm5/hd-table/hd-table.service.js +6 -1
  79. package/esm5/hd-tip/hd-tip.component.js +3 -3
  80. package/esm5/hd-tip/hd-tip.module.js +3 -3
  81. package/esm5/index.js +2 -2
  82. package/esm5/model/common-type.js +39 -1
  83. package/esm5/public-api.js +2 -2
  84. package/fantasy-ngzorro.d.ts +24 -22
  85. package/fantasy-ngzorro.metadata.json +1 -1
  86. package/fesm2015/fantasy-ngzorro.js +1621 -661
  87. package/fesm2015/fantasy-ngzorro.js.map +1 -1
  88. package/fesm5/fantasy-ngzorro.js +1758 -617
  89. package/fesm5/fantasy-ngzorro.js.map +1 -1
  90. package/hd-button/hd-button.component.d.ts +3 -2
  91. package/hd-detail-form/hd-detail-form.component.d.ts +9 -0
  92. package/hd-detail-lines/hd-detail-lines.component.d.ts +19 -6
  93. package/hd-detail-lines-page/hd-detail-lines-page.component.d.ts +56 -0
  94. package/hd-detail-lines-page/hd-detail-lines-page.module.d.ts +2 -0
  95. package/hd-detail-tip/hd-detail-tip.component.d.ts +1 -1
  96. package/hd-filter/hd-filter.component.d.ts +4 -0
  97. package/hd-filter/hd-filter.service.d.ts +2 -0
  98. package/hd-form/hd-form.component.d.ts +4 -0
  99. package/hd-form/hd-form.service.d.ts +10 -3
  100. package/hd-form-lines/hd-form-lines.component.d.ts +18 -7
  101. package/hd-form-lines/hd-form-lines.service.d.ts +2 -0
  102. package/hd-status/hd-status.component.d.ts +1 -1
  103. package/hd-status/hd-status.service.d.ts +1 -1
  104. package/hd-table/hd-table.component.d.ts +16 -7
  105. package/hd-table/hd-table.service.d.ts +3 -1
  106. package/model/common-type.d.ts +14 -0
  107. package/package.json +2 -1
package/README.md CHANGED
@@ -2,382 +2,453 @@
2
2
 
3
3
  # Fantasy-Ngzorro
4
4
 
5
- ## 更新记录
6
-
7
- | 更新人 | 更新时间 | 更新内容 |
8
- | ------ | --------- | ------------------------------------------------------------ |
9
- | MC | 2023-2-10 | 1、Readme文件目录结构创建 <br/>2、新增按钮、按钮组、通用表格、筛选器、状态、详情头、详情单头、详情明细相关文档。 |
10
- | MC | 2023-2-13 | 1、新增表单、明细表单、间隔、小标题相关文档<br/>2、所有组件字段增加必填选项。 |
11
- | | | |
5
+ 基于 **Angular 8** + **ng-zorro-antd 8.5.x** 的业务组件库,封装按钮、表格、表单、详情页等常用 UI 模式。
6
+
7
+ ## 组件一览
8
+
9
+ | 序号 | 选择器 | 说明 |
10
+ | ---- | ------ | ---- |
11
+ | 1 | `hd-button` | 按钮 |
12
+ | 2 | `hd-button-group` | 按钮组(左右布局) |
13
+ | 3 | `hd-space` | 间隔占位 |
14
+ | 4 | `hd-tip` | 小标题 |
15
+ | 5 | `hd-status` | 状态标签 |
16
+ | 6 | `hd-popconfirm` | 气泡确认框 |
17
+ | 7 | `hd-filter` | 筛选器 |
18
+ | 8 | `hd-current-table` | 通用表格(自定义列模板) |
19
+ | 9 | `hd-table` | 增强表格(列配置、排序、列缓存) |
20
+ | 10 | `hd-form` | 表单 |
21
+ | 11 | `hd-form-lines` | 明细表单(可编辑表格) |
22
+ | 12 | `hd-detail-tip` | 详情头 |
23
+ | 13 | `hd-detail-form` | 详情单头 |
24
+ | 14 | `hd-detail-lines` | 详情明细(前端分页 / 搜索) |
25
+ | 15 | `hd-detail-lines-page` | 详情明细(服务端分页) |
26
+ | 16 | `hd-log` | 操作日志 |
27
+
28
+ > 配置类型(SelectOption、FormItem、HdTableColumn 等)见 [附录:公共配置类型](#附录公共配置类型)。
12
29
 
30
+ ## 更新记录
13
31
 
32
+ | 更新人 | 更新时间 | 更新内容 |
33
+ | ------ | -------- | -------- |
34
+ | MC | 2023-2-10 | Readme 创建;按钮、按钮组、通用表格、筛选器、状态、详情头、详情单头、详情明细文档 |
35
+ | MC | 2023-2-13 | 表单、明细表单、间隔、小标题文档;组件字段增加必填说明 |
36
+ | — | 2026-5-20 | 补充 hd-table、hd-detail-lines-page 等组件;完善公共子类型(SelectOption、FormItem 等)文档 |
37
+ | — | 2026-6-23 | hd-table 状态列支持 `stateField` 自定义取值字段、`isState` 按列名取值;hd-form Input 支持 `prefix` / `prefixIcon`;hd-detail-lines-page 支持 `isCrossPageSelect` 跨页勾选开关 |
38
+ | — | 2026-7-6 | hd-form 支持 `FormListType.Checkbox`(单个复选框 / 复选框组)及 `CheckboxOption` 配置 |
14
39
 
15
40
  ## 前言
16
41
 
17
- > 1、文档中的插槽概念借用vue中的插槽,在angular里面体现出来就是模板 #template
18
- >
19
- > 2、事件传递建议使用bind(this)绑定自定义的函数去实现方法, 而不是箭头函数。示例:onChangeEvent: this.formInputChange.bind(this)
20
- >
21
- > 3、运行本地服务之后,访问demo路由即可查看具体交互
22
-
42
+ > 1. 文档中的「插槽」对应 Angular 的模板 `#template`(`ng-template` + `@ContentChild`)。
43
+ > 2. 事件回调建议使用 `bind(this)`,示例:`onChangeEvent: this.formInputChange.bind(this)`。
44
+ > 3. 本地运行 `npm start`,访问 `http://localhost:13000` 查看 Demo 交互。
45
+ > 4. 业务模块引入:`import { FantasyNgzorroModule } from 'fantasy-ngzorro'`。
23
46
 
47
+ ### 公共导出
24
48
 
25
- ## 1、按钮(hd-button)
49
+ | 模块 | 说明 |
50
+ | ---- | ---- |
51
+ | `ColWidth` | 列宽常量 |
52
+ | `Page<T>` | 分页数据结构 |
53
+ | `Utils` | 精度计算工具 |
54
+ | `HdTableColumn` / `FormLine` / `Filter` 等 | 各组件配置类型,详见 [附录:公共配置类型](#附录公共配置类型) |
26
55
 
27
- ### 效果图
56
+ ---
28
57
 
29
- ![hd-button](../../../../../海鼎/code/fantasy-ngzorro-project/projects/fantasy-ngzorro/readme/img/hd-button.png)
58
+ ## 1、按钮(hd-button
30
59
 
31
60
  ### 示例
32
61
 
33
62
  ```html
34
- <hd-button type="primary">查询</hd-button>
63
+ <hd-button type="primary" (clickAction)="search()">查询</hd-button>
64
+ <hd-button type="default" [loading]="loading" (clickAction)="save()">保存</hd-button>
35
65
  ```
36
66
 
37
- ### 说明
67
+ ### 参数
38
68
 
39
- | 参数 | 类型 | 默认值 | 说明 |
40
- | -------- | ------ | ------- | ------------------------------------------------------------ |
41
- | loading | boolen | false | 加载中 |
42
- | type | string | default | primary \| dashed \| danger \| default \| link \| submit \| reset \| add (其中add类型会默认增加加号) |
43
- | disabled | boolen | False | 按钮是否禁用 |
69
+ | 参数 | 类型 | 默认值 | 说明 |
70
+ | ---- | ---- | ------ | ---- |
71
+ | type | string | default | primary \| dashed \| danger \| default \| link \| reset \| add |
72
+ | size | string | normal | 按钮尺寸 |
73
+ | loading | boolean | false | 加载中(与 loading 配合时必须用 clickAction) |
74
+ | disabled | boolean | false | 是否禁用 |
75
+ | clickAction | EventEmitter | — | 点击事件 |
44
76
 
45
77
  ### 注意点
46
78
 
47
- - 为防止回车触发表单提交事件,禁止使用submit类型的按钮,请使用普通按钮+click事件触发表单提交!
48
-
49
-
50
-
51
- ## 2、按钮组(hd-button-group)
79
+ - **禁止**使用 `type="submit"`,请用普通按钮 + `clickAction` 触发表单提交。
80
+ - 设置了 `loading` 的按钮必须用 `(clickAction)`,不能用 `(click)`。
52
81
 
53
- ### 效果图
82
+ ---
54
83
 
55
- ![hd-button-group](../../../../../海鼎/code/fantasy-ngzorro-project/projects/fantasy-ngzorro/readme/img/hd-button-group.png)
84
+ ## 2、按钮组(hd-button-group
56
85
 
57
86
  ### 示例
58
87
 
59
88
  ```html
60
89
  <hd-button-group>
61
90
  <ng-template #buttonGroupLeft>
62
- <hd-button type="add">add</hd-button>
63
- <hd-button type="default">default</hd-button>
64
- <hd-button type="default">default</hd-button>
65
- <hd-button type="default">default</hd-button>
91
+ <hd-button type="add">新增</hd-button>
66
92
  </ng-template>
67
93
  <ng-template #buttonGroupRight>
68
- <hd-button type="default">default</hd-button>
94
+ <hd-button type="default">导出</hd-button>
69
95
  </ng-template>
70
96
  </hd-button-group>
71
97
  ```
72
98
 
73
- ### 说明
99
+ ### 插槽
74
100
 
75
- | 参数 | 类型 | 说明 |
76
- | ---------------- | ------------------------------- | -------------- |
77
- | buttonGroupLeft | @ContentChild TemplateRef<void> | 按钮组左侧插槽 |
78
- | buttonGroupRight | @ContentChild TemplateRef<void> | 按钮组右侧插槽 |
101
+ | 插槽 | 说明 |
102
+ | ---- | ---- |
103
+ | buttonGroupLeft | 左侧按钮区 |
104
+ | buttonGroupRight | 右侧按钮区 |
79
105
 
80
- ### 注意点
106
+ 按钮间距自动 12px。
107
+
108
+ ---
81
109
 
82
- - hd-button-group中的按钮会自动增加间距12px
110
+ ## 3、间隔(hd-space)
83
111
 
112
+ ### 示例
84
113
 
114
+ ```html
115
+ <hd-space background="#fff" type="row" size="12"></hd-space>
116
+ ```
85
117
 
86
- ## 3、通用表格(hd-current-table)
118
+ | 参数 | 类型 | 默认值 | 说明 |
119
+ | ---- | ---- | ------ | ---- |
120
+ | background | string | inherit | 背景色 |
121
+ | type | string | row | row \| column |
122
+ | size | number | — | 高度或宽度(px) |
87
123
 
88
- ### 效果图
124
+ ---
89
125
 
90
- ![hd-current-table](../../../../../海鼎/code/fantasy-ngzorro-project/projects/fantasy-ngzorro/readme/img/hd-current-table.png)
126
+ ## 4、小标题(hd-tip)
91
127
 
92
128
  ### 示例
93
129
 
94
130
  ```html
95
- <hd-current-table #hdCurrentTable [(tablePageIndex)]="pageIndex" [(tablePageSize)]="pageSize" [scroll]="{x: '600px'}" [tableData]="page" (tableSearchEvent)="search($event)" showSelected selectField="billNumber" (selectEvent)="selectResult($event)">
96
- <ng-template #tableTotal>
97
- <nz-alert nzType="info" [nzMessage]="nzAlertTotal" nzShowIcon></nz-alert>
98
- <ng-template #nzAlertTotal>
99
- <span>已选择{{ tableSelectList.length }}项服务</span>&nbsp;&nbsp;
100
- <span>调用总计:36.4万</span>&nbsp;&nbsp;
101
- <span class="common-btn-group">
102
- <a (click)="hdCurrentTable.resetStatus()">清空</a>
103
- </span>
104
- </ng-template>
105
- </ng-template>
131
+ <hd-tip title="基本信息" [fontSize]="14"></hd-tip>
132
+ <hd-tip title="新增" [showIcon]="false" [fontSize]="16"></hd-tip>
133
+ ```
134
+
135
+ | 参数 | 类型 | 默认值 | 说明 |
136
+ | ---- | ---- | ------ | ---- |
137
+ | title | string | — | 标题文案 |
138
+ | showIcon | boolean | true | 是否显示左侧竖线 |
139
+ | fontSize | number | — | 字体大小 |
140
+
141
+ ---
142
+
143
+ ## 5、状态(hd-status)
144
+
145
+ ### 示例
146
+
147
+ ```html
148
+ <hd-status status="initial">未审核</hd-status>
149
+ <hd-status status="audited">已审核</hd-status>
150
+ <hd-status status="received">已收货</hd-status>
151
+ ```
152
+
153
+ | 参数 | 类型 | 说明 |
154
+ | ---- | ---- | ---- |
155
+ | status | string | 状态值,匹配 `hd-status.service.ts` 中 `statusToColor` 配置 |
156
+
157
+ 匹配时不区分大小写。新增状态请在 `statusToColor` 中配置颜色。
158
+
159
+ ---
160
+
161
+ ## 6、气泡确认(hd-popconfirm)
162
+
163
+ ### 示例
164
+
165
+ ```html
166
+ <hd-popconfirm message="确认删除该记录吗?" (confirmOption)="onConfirm()" (cancelOption)="onCancel()">
167
+ </hd-popconfirm>
168
+ ```
169
+
170
+ | 参数 | 类型 | 说明 |
171
+ | ---- | ---- | ---- |
172
+ | message | string | 提示文案 |
173
+ | confirmOption | EventEmitter | 点击确认 |
174
+ | cancelOption | EventEmitter | 点击取消 |
175
+
176
+ ---
177
+
178
+ ## 7、筛选器(hd-filter)
179
+
180
+ ### 示例
181
+
182
+ ```html
183
+ <hd-filter [filterList]="filterList" (searchEvent)="filterChange($event)" (resetEvent)="resetFilterChange($event)">
184
+ </hd-filter>
185
+ ```
186
+
187
+ | 参数 | 类型 | 说明 |
188
+ | ---- | ---- | ---- |
189
+ | filterList | Array\<Filter\> | 筛选项配置 |
190
+ | searchEvent | EventEmitter | 查询,带回筛选数据 |
191
+ | resetEvent | EventEmitter | 重置 |
192
+
193
+ #### Filter 配置
194
+
195
+ 筛选项使用 [Filter](#filter筛选项) 类型,下拉/数字/级联等子配置见 [SelectOption](#selectoption下拉选项配置)、[InputNumber](#inputnumber数字输入配置)、[CascaderOption](#cascaderoption级联选择配置)。
196
+
197
+ ---
198
+
199
+ ## 8、通用表格(hd-current-table)(已废弃、禁用)
200
+
201
+ 适用于**完全自定义**表头、表体模板的列表页。
202
+
203
+ ### 示例
204
+
205
+ ```html
206
+ <hd-current-table #hdCurrentTable [(tablePageIndex)]="pageIndex" [(tablePageSize)]="pageSize"
207
+ [scroll]="{x: '600px'}" [tableData]="page" [tableLoading]="loading"
208
+ (tableSearchEvent)="search($event)" showSelected selectField="billNumber"
209
+ (selectEvent)="selectResult($event)">
210
+ <ng-template #tableTotal>...</ng-template>
106
211
  <ng-template #tableHead>
107
- <th nzLeft="40px" style="width: 100px">配送单号</th>
108
- <th>收货日期</th>
212
+ <th>配送单号</th>
109
213
  <th>状态</th>
110
- <th nzRight="0px">操作</th>
111
214
  </ng-template>
112
215
  <ng-template #tableBody let-data>
113
- <!-- 父页面自己的样式,不允许用行内样式,全都定义class写到css文件中,颜色、字号等属性用通用文件中的变量,不允许直接写颜色值 -->
114
- <td nzLeft="40px" style="width: 100px" class="common-billNumber"><a>{{ data.billNumber || '&lt;空&gt;' }}</a></td>
115
- <td>{{ data.distDate || '&lt;空&gt;' }}</td>
116
- <td>
117
- <hd-status [status]="'initial'">未审核</hd-status>
118
- </td>
119
- <td nzRight="0px" style="width: 200px">
120
- <span class="common-btn-group">
121
- <a>复制</a>
122
- <a>修改详情</a>
123
- <a>修改日期</a>
124
- <a class="common-danger-btn">删除</a>
125
- </span>
126
- </td>
216
+ <td>{{ data.billNumber }}</td>
217
+ <td><hd-status [status]="data.state">{{ data.stateText }}</hd-status></td>
127
218
  </ng-template>
128
219
  </hd-current-table>
129
220
  ```
130
221
 
131
- ```tsx
132
- // 通用表格的相关变量
133
- page: Page<any> = new Page<any>();
222
+ ```typescript
223
+ page: Page<any> = new Page();
134
224
  pageIndex = 1;
135
225
  pageSize = 10;
136
- loading: boolean = false;
137
- tableSelectList: Array<any> = [];
138
-
139
- // 表格的查询事件
140
- search(reset: boolean = false): void {
141
- if (reset) {
142
- this.pageIndex = 1;
143
- }
226
+ loading = false;
144
227
 
228
+ search(reset = false) {
229
+ if (reset) { this.pageIndex = 1; }
145
230
  this.queryFilter.pageNumber = this.pageIndex - 1;
146
231
  this.queryFilter.pageSize = this.pageSize;
147
-
148
232
  this.loading = true;
149
- this.hdDemoService.queryDemo(this.queryFilter).subscribe(
150
- result => {
151
- this.loading = false;
152
- this.page = result;
153
- }, error => {
154
- this.loading = false;
155
- }
233
+ this.service.query(this.queryFilter).subscribe(
234
+ result => { this.loading = false; this.page = result; },
235
+ () => { this.loading = false; }
156
236
  );
157
237
  }
158
-
159
- /**
160
- * 表格的选择事件
161
- * @param selectList 勾选的所有的数据集合
162
- */
163
- selectResult(selectList?: any) {
164
- // 拿到勾选的所有的数据
165
- // console.log('selectList', selectList);
166
- this.tableSelectList = selectList;
167
- }
168
238
  ```
169
239
 
170
- ### 说明
171
-
172
- | 参数 | 类型 | 默认值 | 说明 |
173
- | ------------------------ | ------------------------------ | --------------- | ------------------------------------------------------------ |
174
- | *tableData | Page<any> | | 表格源数据 |
175
- | scroll | { [*key*: string]: string } | { x: '1150px' } | 滚动参数 |
176
- | *tablePageIndex | number | | 当前页码(双向绑定) |
177
- | *tablePageSize | number | | 每页展示的数据量(双向绑定) |
178
- | *tableSearchEvent | EventEmitter<reset: boolen> | | 表格更换tablePageIndex、tablePageSize触发函数,emit重置标识 |
179
- | showSelected | boolean | false | 是否开启勾选功能 |
180
- | selectEvent | EventEmitter<array> | | 勾选状态改变触发函数,emit已勾选数组 |
181
- | selectField | string | billNumber | 与showSelected配合使用,勾选判断逻辑的关键词(传入源数据中的主键字段) |
182
- | tableHead | @ContentChild TemplateRef<any> | | 表格头插槽 |
183
- | tableBody | @ContentChild TemplateRef<any> | | 表格数据主体插槽 |
184
- | tableTotal | @ContentChild TemplateRef<any> | | 表格顶部合计插槽 |
185
- | showTableTotal(弃用) | boolean | False | 是否显示底部合计区域 |
186
- | tableTotalOption(弃用) | Array<TableTotalOption> | | 底部合计区域的合计字段选项集合 |
240
+ | 参数 | 类型 | 默认值 | 说明 |
241
+ | ---- | ---- | ------ | ---- |
242
+ | tableData | Page\<any\> | | 分页数据 |
243
+ | tablePageIndex | number | 1 | 当前页(双向绑定) |
244
+ | tablePageSize | number | 10 | 每页条数(双向绑定) |
245
+ | tableLoading | boolean | false | 加载状态 |
246
+ | tableSearchEvent | EventEmitter || 翻页 / 改 pageSize 触发,参数 reset 表示是否重置到第一页 |
247
+ | scroll | object | { x: '1150px' } | 横向滚动 |
248
+ | showSelected | boolean | false | 是否显示勾选列 |
249
+ | selectField | string | billNumber | 勾选主键字段 |
250
+ | selectEvent | EventEmitter || 勾选变化 |
251
+ | tableHead / tableBody / tableTotal | TemplateRef | | 表头 / 表体 / 顶部合计插槽 |
187
252
 
188
- ### 注意点
253
+ ---
254
+
255
+ ## 9、增强表格(hd-table)
256
+
257
+ 在通用表格基础上支持**列配置渲染**、**排序**、**列宽/顺序/pageSize 本地缓存**、**设置列**等能力。列表页**优先推荐使用**。
258
+
259
+ ### 示例
260
+
261
+ ```html
262
+ <hd-table #hdTable [(tablePageIndex)]="pageIndex" [(tablePageSize)]="pageSize"
263
+ [tableCols]="tableCols" [tableData]="page" [tableLoading]="loading"
264
+ (tableSearchEvent)="search($event)" showSelected showOperateColWarpButton
265
+ selectField="billNumber" (selectEvent)="selectResult($event)"
266
+ uuid="74907b48-1b17-4e51-9fa9-81fd0ac94051"
267
+ (sortEvent)="sortEvent($event)" (tablePageSizeChangeEvent)="search(true)">
268
+ <ng-template #tableLeftButton>
269
+ <hd-button type="default" (clickAction)="search()">刷新</hd-button>
270
+ </ng-template>
271
+ <ng-template #tableRightButton>
272
+ <hd-button type="default">导出</hd-button>
273
+ </ng-template>
274
+ <ng-template #tableTotal>...</ng-template>
275
+ </hd-table>
276
+ ```
277
+
278
+ ```typescript
279
+ tableCols: HdTableColumn[] = [{
280
+ title: '配送单号',
281
+ name: 'billNumber',
282
+ fixed: 'left',
283
+ click: (line) => { /* 点击行 */ }
284
+ }, {
285
+ title: '状态',
286
+ name: 'state',
287
+ width: ColWidth.enumColWidth,
288
+ // stateField: 'orderStatus', // 可选,自定义状态取值字段,默认取 data.state
289
+ render: (line) => line.state === 'received' ? '已收货' : '未收货'
290
+ }, {
291
+ title: '订单状态',
292
+ name: 'orderStatus',
293
+ isState: true, // 按 hd-status 渲染,取值字段为 name(orderStatus)
294
+ width: ColWidth.enumColWidth,
295
+ render: (line) => line.orderStatusText
296
+ }, {
297
+ title: '操作',
298
+ name: 'operate',
299
+ width: ColWidth.operateColWidth,
300
+ btnList: [{ name: '删除', showConfirm: true, click: (line) => this.remove(line) }]
301
+ // showConfirm 也可传函数,按行属性决定是否二次确认
302
+ // btnList: [{ name: '删除', showConfirm: (line) => line.state !== 'draft', click: (line) => this.remove(line) }]
303
+ }];
304
+ ```
189
305
 
190
- - 如果发现tableSearchEvent绑定的函数当tablePageSize改变时会触发两次,请不要惊慌,这是ngzorro8.5.x版本的bug,不会影响使用体验,只会额外调用一次接口,浪费些性能。
306
+ | 参数 | 类型 | 默认值 | 说明 |
307
+ | ---- | ---- | ------ | ---- |
308
+ | tableCols | HdTableColumn[] | [] | 列配置 |
309
+ | tableData | Page\<any\> | — | 分页数据 |
310
+ | tablePageIndex / tablePageSize | number | — | 分页(双向绑定) |
311
+ | tableLoading | boolean | false | 加载状态 |
312
+ | tableSearchEvent | EventEmitter | — | 翻页查询 |
313
+ | sortEvent | EventEmitter | — | 排序 |
314
+ | selectEvent | EventEmitter | — | 勾选变化 |
315
+ | showSelected | boolean | false | 勾选列 |
316
+ | showOperateColWarpButton | boolean | false | 展开/缩略显示换行列 |
317
+ | showTableTotal | boolean | false | 底部合计行 |
318
+ | tableTotalOption | HdTableTotalOption[] | — | 合计配置 |
319
+ | isFirstEntrySearch | boolean | — | 首次进入是否自动查询 |
320
+ | isCrossPageSelect | boolean | — | 跨页勾选 |
321
+ | uuid | string | — | 列缓存唯一标识(必填,用于 IndexedDB 缓存) |
322
+ | tableLeftButton / tableRightButton / tableTotal | TemplateRef | — | 工具栏插槽 |
191
323
 
324
+ #### HdTableColumn 配置
192
325
 
326
+ 列定义见 [HdTableColumn](#hdtablecolumn表格列)、[OperateBtn](#operatebtn操作列按钮)、[HdTableTotalOption](#hdtabletotaloptionhd-table-底部合计)。
193
327
 
194
- ## 4、筛选器(hd-filter)
328
+ `name` 为 `state` 或 `isState` 为 `true` 时,列内容使用 `hd-status` 渲染。取值规则:`isState` 时取 `data[name]`;否则可通过 `stateField` 指定字段,未配置时默认取 `state`。
195
329
 
196
- ### 效果图
330
+ ---
197
331
 
198
- ![hd-filter](../../../../../海鼎/code/fantasy-ngzorro-project/projects/fantasy-ngzorro/readme/img/hd-filter.png)
332
+ ## 10、表单(hd-form)
199
333
 
200
334
  ### 示例
201
335
 
202
- ```js
203
- <hd-filter [filterList]="filterList" (searchEvent)="search(true, $event)"></hd-filter>
336
+ ```html
337
+ <hd-form [formList]="formInput" (changeEvent)="formChangeEvent($event)"></hd-form>
204
338
  ```
205
339
 
206
- ```tsx
207
- filterList: Array<Filter> = [];
208
- filterListTemplate: Array<Filter> = [{
209
- type: FilterListType.Input,
340
+ ```typescript
341
+ formInput: FormItem[] = [{
342
+ type: FormListType.Input,
210
343
  label: '配送单号',
211
- name: 'billNumberEq',
212
- value: '',
213
- onChangeEvent: (item) => {
214
- console.log('item', item);
215
- }
344
+ name: 'billNumber',
345
+ require: true,
346
+ width: 2,
347
+ onChangeEvent: this.formInputChange.bind(this)
216
348
  }, {
217
- type: FilterListType.Select,
218
- label: '单项选择器测试测',
219
- name: 'selectValue',
220
- value: true,
221
- selectOption: {
222
- value: 'value',
223
- label: 'label',
224
- selectList: [{
225
- value: true,
226
- label: '是是是是是是是是是是是是是是是是是是是是是是'
227
- }, {
228
- value: false,
229
- label: '否'
230
- }]
231
- },
232
- onChangeEvent: (item) => {
233
- console.log('item', item);
234
- }
349
+ type: FormListType.Select,
350
+ label: '是否启用',
351
+ name: 'enabled',
352
+ width: 1,
353
+ selectOption: { value: 'value', label: 'label', selectList: [...] }
235
354
  }, {
236
- type: FilterListType.MultipleSelect,
237
- label: '多项选择器选择',
238
- name: 'multipleSelectValue',
239
- value: null,
240
- onChangeEvent: (item) => {
241
- console.log('onChangeEvent', item);
242
- },
243
- onSearchEvent: (item) => {
244
- console.log('onSearchEvent', item);
245
- },
246
- selectOption: {
247
- value: 'value',
248
- label: 'label',
249
- selectList: [{
250
- value: '01',
251
- label: '第一个第一个第一个第一个第一个'
252
- }, {
253
- value: '02',
254
- label: '第二个'
255
- }, {
256
- value: '03',
257
- label: '第三个'
258
- }, {
259
- value: '04',
260
- label: '第四个'
261
- }]
262
- }
355
+ type: FormListType.Input,
356
+ label: '金额',
357
+ name: 'amount',
358
+ prefix: '¥' // 前缀文字,对应 nz-input-group nzPrefix
263
359
  }, {
264
- type: FilterListType.Select,
265
- label: '测试label',
266
- name: 'selectValue1',
267
- value: null,
268
- selectOption: {
269
- value: 'productCode',
270
- label: 'productName',
271
- showLabelAndValue: true,
272
- selectList: []
273
- },
274
- onSearchEvent: (item, selectOption) => {
275
- console.log('onSearchEvent', item);
276
- console.log('selectOption', selectOption);
277
- // 在这里去调接口查数据 定时器模拟调接口
278
- setTimeout(() => {
279
- selectOption.selectList = [{
280
- productCode: '123213213',
281
- productName: '测试商品1'
282
- }, {
283
- productCode: 'qwertyuiop',
284
- productName: '测试商品2'
285
- }]
286
- }, 1000);
287
- }
360
+ type: FormListType.Input,
361
+ label: '手机号',
362
+ name: 'mobile',
363
+ prefixIcon: 'phone' // 前缀图标,对应 nz-icon nzType
364
+ }, {
365
+ type: FormListType.InputNumber,
366
+ label: '数量',
367
+ name: 'qty',
368
+ inputNumber: { min: 0, max: 9999, step: 1, precision: 2 }
288
369
  }, {
289
- type: FilterListType.Date,
290
- label: '单个日期选择',
291
- name: 'dateValue',
292
- value: '2020-1-2'
370
+ type: FormListType.Checkbox,
371
+ label: '是否启用',
372
+ name: 'enabled',
373
+ value: false // 单个复选框,值为 boolean
293
374
  }, {
294
- type: FilterListType.DateRange,
295
- label: '日期范围选择',
296
- name: 'dateRangeValue',
297
- value: ['2020-1-2', '2020-1-2']
375
+ type: FormListType.Checkbox,
376
+ label: '权限',
377
+ name: 'permissions',
378
+ value: ['read'],
379
+ checkboxOption: {
380
+ label: 'name',
381
+ value: 'code',
382
+ optionList: [
383
+ { code: 'read', name: '查看' },
384
+ { code: 'edit', name: '编辑' }
385
+ ]
386
+ }
298
387
  }];
299
388
 
300
- // 查询、重置按钮触发函数
301
- filterChange(filter?: any) {
302
- console.log('filter',filter);
303
- if (filter) {
304
- this.queryFilter = filter;
305
- // 因为更改了filter 需要清空所有的勾选 触发组件的重置事件
306
- this.hdCurrentTable.resetStatus();
307
- this.search(true);
308
- }
389
+ formChangeEvent(validateForm: FormGroup) {
390
+ this.validateHdForm = validateForm;
309
391
  }
310
392
  ```
311
393
 
312
- ### 说明
313
-
314
- | 参数 | 类型 | 默认值 | 说明 |
315
- | ----------- | -------------- | ------ | -------------------------------------- |
316
- | filterList | Array<Filter> | | 所有的筛选器空间数据 |
317
- | searchEvent | EventEmitter<> | | 查询、重置按钮触发函数,带回筛选器数据 |
318
-
319
- #### Filter
320
-
321
- | 参数 | 类型 | 默认值 | 说明 |
322
- | ------------- | ----------------------------------------------------------- | ------ | ------------------------------------------------------------ |
323
- | *type | FilterListType | | 控件类型 Input \| Select \| Date \| DateRange \| MultipleSelect |
324
- | *label | string | | 控件前文案 |
325
- | *name | string | | 字段名称 |
326
- | placeholder | string | | 输入框提示文案 |
327
- | value | string \| boolen \| number \| Array<string \| Date> \| null | null | 初始值 |
328
- | selectOption | SelectOption | | select选择器选项配置 |
329
- | onSearchEvent | EventEmitter<> | | select选择器搜索事件 可用于更新备选集合 |
330
- | onChangeEvent | EventEmitter<> | | 控件的值改变事件 可用于控件间联动 |
394
+ | 参数 | 类型 | 说明 |
395
+ | ---- | ---- | ---- |
396
+ | formList | FormItem[] | 表单项配置 |
397
+ | changeEvent | EventEmitter | 表单值变化,返回 FormGroup |
331
398
 
332
- #### SelectOption
399
+ #### FormItem 配置
333
400
 
334
- | 参数 | 类型 | 默认值 | 说明 |
335
- | -------------------------- | ---------- | ------ | ------------------------------------------------------ |
336
- | *label | string | | label字段,取selectList数组中的某个字段作为选择器label |
337
- | *value | string | | Value字段,取selectList数组中的某个字段作为选择器value |
338
- | *selectList | Array<any> | | 选项列表 |
339
- | showLabelAndValue | boolean | false | 选项同时展示label和value,格式:[value]label |
340
- | hdDropdownMatchSelectWidth | boolean | false | 选择框长度是否和控件长度保持一致,默认不保持 |
401
+ 表单项使用 [FormItem](#formitem表单项) 类型,下拉/数字等子配置见 [SelectOption](#selectoption下拉选项配置)、[InputNumber](#inputnumber数字输入配置)、[RadioOption](#radiooption单选配置)、[CheckboxOption](#checkboxoption复选框配置)。
341
402
 
342
- ### 注意点
343
-
344
- - 事件函数如果内部语句过多,请使用bind(this)方法,示例:onChangeEvent: this.formInputChange.bind(this)
403
+ ---
345
404
 
346
- ## 5、状态(hd-status)
405
+ ## 11、明细表单(hd-form-lines)
347
406
 
348
- ### 效果图
349
-
350
- ![hd-button](../../../../../海鼎/code/fantasy-ngzorro-project/projects/fantasy-ngzorro/readme/img/hd-status.png)
407
+ 可编辑的明细行表格,支持键盘导航、行内搜索、合计等。
351
408
 
352
409
  ### 示例
353
410
 
354
411
  ```html
355
- <hd-status status="initial">未审核</hd-status>
356
- <hd-status status="audited">已审核</hd-status>
357
- <hd-status status="picking">拣货中</hd-status>
358
- <hd-status status="partshipped">部分收货</hd-status>
359
- <hd-status status="received">已收货</hd-status>
360
- <hd-status status="deleted">已删除</hd-status>
361
- <hd-status status="shipped">已配送</hd-status>
412
+ <hd-form-lines #hdFormLines showSearch showKeyboardOperateTip
413
+ [formLines]="formLines" [formLinesData]="formLinesData"
414
+ [operateButtons]="['add', 'delete']" [allowEmpty]="false"
415
+ (changeEvent)="formLinesChangeEvent($event)">
416
+ </hd-form-lines>
362
417
  ```
363
418
 
364
- ### 说明
419
+ | 参数 | 类型 | 默认值 | 说明 |
420
+ | ---- | ---- | ------ | ---- |
421
+ | formLines | FormLine[] | — | 列定义 |
422
+ | formLinesData | any[] | — | 行数据 |
423
+ | operateButtons | string[] | ['add','delete'] | 操作按钮 |
424
+ | showDeleteConfirm | boolean | false | 删除前确认 |
425
+ | showSearch | boolean | false | 行内搜索 |
426
+ | showKeyboardOperateTip | boolean | false | 键盘操作提示 |
427
+ | showLineNumber | boolean | true | 序号列 |
428
+ | allowEmpty | boolean | true | 是否允许空表 |
429
+ | showTotal | boolean | false | 合计行 |
430
+ | totalOption / columnsNumber | — | — | 合计配置 |
431
+ | scroll | object | { x: '1px' } | 横向滚动 |
432
+ | changeEvent | EventEmitter | — | 表单变化 |
433
+ | deleteLastLineEvent | EventEmitter | — | 删除最后一行 |
365
434
 
366
- | 参数 | 类型 | 说明 |
367
- | ------ | ------ | ------ |
368
- | status | string | 状态值 |
435
+ #### FormLine 配置
369
436
 
370
- ### 注意点
437
+ 明细列使用 [FormLine](#formline明细表单项) 类型,含 [ColorOption](#coloroption)、[ExplainOption](#explainoption) 及表格型 [SelectOption](#selectoption下拉选项配置)。
371
438
 
372
- - state需要在hd-status.service.ts中的statusToColor添加值,选择对应的颜色
439
+ ---
373
440
 
441
+ 开启 `showKeyboardOperateTip` 后支持 `[↑][↓][←][→]`、`Enter` 在单元格间跳转;InputNumber 上下键用于跳转,不触发 step 增减。
374
442
 
443
+ #### 暴露方法
375
444
 
376
- ## 6、详情头(hd-detail-tip)
445
+ ```typescript
446
+ this.hdFormLines.getValid(); // 获取整表校验状态
447
+ ```
377
448
 
378
- ### 效果图
449
+ ---
379
450
 
380
- ![hd-button](../../../../../海鼎/code/fantasy-ngzorro-project/projects/fantasy-ngzorro/readme/img/hd-detail-tip.png)
451
+ ## 12、详情头(hd-detail-tip
381
452
 
382
453
  ### 示例
383
454
 
@@ -385,590 +456,480 @@ filterChange(filter?: any) {
385
456
  <hd-detail-tip state="shipped" stateText="配送中" billNumber="202111030001"></hd-detail-tip>
386
457
  ```
387
458
 
388
- ### 说明
389
-
390
- | 参数 | 类型 | 说明 |
391
- | ---------- | ------ | -------- |
392
- | state | string | 状态值 |
393
- | stateText | string | 状态文案 |
394
- | billNumber | string | 单号 |
395
-
396
- ### 注意点
397
-
398
- - state需要在hd-status.service.ts中的statusToColor添加值,选择对应的颜色
399
-
459
+ | 参数 | 类型 | 说明 |
460
+ | ---- | ---- | ---- |
461
+ | state | string | 状态值 |
462
+ | stateText | string | 状态文案 |
463
+ | billNumber | string | 单号 |
464
+ | tip | string | 前缀文案,默认「详情」 |
400
465
 
466
+ ---
401
467
 
402
- ## 7、详情单头(hd-detail-form)
403
-
404
- ### 效果图
405
-
406
- ![hd-button](../../../../../海鼎/code/fantasy-ngzorro-project/projects/fantasy-ngzorro/readme/img/hd-detail-form.png)
468
+ ## 13、详情单头(hd-detail-form
407
469
 
408
470
  ### 示例
409
471
 
410
472
  ```html
411
473
  <hd-detail-form [formCols]="formCols"></hd-detail-form>
474
+ <!-- 固定两列:<hd-detail-form [formCols]="formCols" [nzColumn]="2"></hd-detail-form> -->
412
475
  ```
413
476
 
414
- ```tsx
415
- // 详情页面单头组件数据
416
- formCols: Array<HdOption> = [
417
- {
418
- label: '收货单号收货单号收货单号',
419
- value: '202111030001'
420
- },
421
- {
422
- label: '收货单号',
423
- value: '202111030001'
424
- },
425
- {
426
- label: '收货单号',
427
- value: '202111030001'
428
- },
429
- {
430
- label: '收货单号',
431
- value: ''
432
- },
433
- {
434
- label: '收货单号',
435
- value: '202111030001'
436
- },
437
- {
438
- label: '备注',
439
- value: '字数很多字数很多字数很多字数很多202111030001字数很多字数很多字数很多字数很多202111030001字数很多字数很多字数很多字数很多202111030001'
440
- },
477
+ ```typescript
478
+ formCols: HdOption[] = [
479
+ { label: '收货单号', value: '202111030001' },
480
+ { label: '备注', value: '...' }
441
481
  ];
442
482
  ```
443
483
 
444
- ### 说明
484
+ | 参数 | 类型 | 默认值 | 说明 |
485
+ | ---- | ---- | ------ | ---- |
486
+ | formCols | HdOption[] | — | 展示字段,见 [HdOption](#hdoption键值展示项) |
487
+ | nzColumn | number \| object | `{ xxl: 4, xl: 3, lg: 3, md: 3, sm: 2, xs: 1 }` | 列数;传数字为固定列数,传对象为响应式列数 |
488
+
489
+ ---
445
490
 
446
- | 参数 | 类型 | 说明 |
447
- | -------- | -------------------- | ------------ |
448
- | formCols | Array<{label,value}> | 展示的列数组 |
491
+ ## 14、详情明细(hd-detail-lines)
449
492
 
493
+ 详情页只读/轻编辑明细表格,支持**前端分页**和**行内搜索**。
450
494
 
495
+ ### 示例
451
496
 
452
- ## 8、详情明细(hd-detail-lines)
497
+ ```html
498
+ <!-- 带搜索 + 前端分页 -->
499
+ <hd-detail-lines showSearch [lines]="lines" [scroll]="{x: '1150px'}">
500
+ <ng-template #detailLineHead>...</ng-template>
501
+ <ng-template #detailLineBody let-data let-index="index">...</ng-template>
502
+ </hd-detail-lines>
453
503
 
454
- ### 效果图
504
+ <!-- 勾选 + 合计 + 前端分页 -->
505
+ <hd-detail-lines [lines]="lines" showSelected selectField="uuid"
506
+ hdFrontPagination showTotal columnsNumber="4" [totalOption]="detailLinesTotalOption"
507
+ (selectEvent)="selectResultLines($event)">
508
+ ...
509
+ </hd-detail-lines>
510
+ ```
455
511
 
456
- ![hd-button](../../../../../海鼎/code/fantasy-ngzorro-project/projects/fantasy-ngzorro/readme/img/hd-detail-lines.png)
512
+ | 参数 | 类型 | 默认值 | 说明 |
513
+ | ---- | ---- | ------ | ---- |
514
+ | lines | any[] | — | 明细数据 |
515
+ | scroll | object | { x: '1px' } | 横向滚动 |
516
+ | showSearch | boolean | false | 行内搜索 |
517
+ | searchFields | string[] | [] | 搜索字段,空则搜全部字段 |
518
+ | hdFrontPagination | boolean | false | 前端分页 |
519
+ | showSelected | boolean | false | 勾选 |
520
+ | selectField | string | billNumber | 勾选主键 |
521
+ | selectedField | string | — | 初始勾选标记字段 |
522
+ | selectEvent | EventEmitter | — | 勾选变化 |
523
+ | allowDrop | boolean | false | 拖拽排序 |
524
+ | showTotal | boolean | false | 合计行 |
525
+ | columnsNumber | number | — | 总列数(含合计) |
526
+ | totalOption | TotalOption[] | — | 合计配置,见 [TotalOption](#totaloption明细合计行) |
527
+ | detailLineHead / detailLineBody | TemplateRef | — | 表头 / 表体插槽 |
528
+
529
+ ---
530
+
531
+ ## 15、详情明细-服务端分页(hd-detail-lines-page)
532
+
533
+ 与 `hd-detail-lines` 模板用法相同,但**不做内部分页和搜索**,分页由父组件控制(对齐 `hd-table`)。
457
534
 
458
535
  ### 示例
459
536
 
460
537
  ```html
461
- <hd-detail-lines [scroll]="{x: '1150px'}" selectField="uuid" (selectEvent)="selectResultLines($event)"
462
- [lines]="lines" showSelected columnsNumber="4" showTotal [totalOption]="detailLinesTotalOption">
538
+ <hd-detail-lines-page [scroll]="{x: '1150px'}"
539
+ [lines]="detailLinesPageData.content"
540
+ [tableData]="detailLinesPageData"
541
+ [tableLoading]="detailLinesPageLoading"
542
+ [tablePageIndex]="detailLinesPageIndex"
543
+ [tablePageSize]="detailLinesPageSize"
544
+ (tablePageIndexChange)="onDetailLinesPageIndexChange($event)"
545
+ (tablePageSizeChange)="onDetailLinesPageSizeChange($event)">
463
546
  <ng-template #detailLineHead>
464
547
  <th style="width: 40px">序号</th>
465
548
  <th style="width: 150px">商品编码</th>
466
549
  <th>商品名称</th>
467
- <th style="width: 80px" nzRight="0">操作</th>
468
550
  </ng-template>
469
- <ng-template #detailLineBody let-data>
470
- <td style="width: 40px">{{ data.lineNumber || '&lt;空&gt;' }}</td>
471
- <td style="width: 150px">
472
- <span *ngIf="!modifyFlag;else modifyTmp">{{ data.productCode || '&lt;空&gt;' }}</span>
473
- <ng-template #modifyTmp>
474
- <input nz-input placeholder="请输入商品编码" [(ngModel)]="data.productCode" />
475
- </ng-template>
476
- </td>
477
- <td>{{ data.productName || '&lt;空&gt;' }}</td>
478
- <td style="width: 80px" nzRight="0">
479
- <span class="common-btn-group">
480
- <a>详情</a>
481
- <a class="common-danger-btn">删除</a>
482
- </span>
483
- </td>
551
+ <ng-template #detailLineBody let-data let-index="index">
552
+ <td>{{ index + 1 }}</td>
553
+ <td>{{ data.productCode }}</td>
554
+ <td>{{ data.productName }}</td>
484
555
  </ng-template>
485
- </hd-detail-lines>
556
+ </hd-detail-lines-page>
486
557
  ```
487
558
 
488
- ```tsx
489
- detailLinesTotalOption = [{
490
- insertIndex: 1,
491
- insertValue: 100
492
- },{
493
- insertIndex: 2,
494
- insertValue: 200,
495
- align: 'right'
496
- }]
497
-
498
- /**
499
- * 明细的选择事件
500
- * @param selectList 勾选的所有的数据集合
501
- */
502
- selectResultLines(selectList?: any) {
503
- // 拿到勾选的所有的数据
504
- // console.log('selectResultLines', selectList);
559
+ ```typescript
560
+ detailLinesPageData: Page<any> = new Page();
561
+ detailLinesPageIndex = 1;
562
+ detailLinesPageSize = 5;
563
+ detailLinesPageLoading = false;
564
+
565
+ loadDetailLinesPage(reset = false) {
566
+ if (reset) { this.detailLinesPageIndex = 1; }
567
+ this.detailLinesPageLoading = true;
568
+ this.service.queryLines({
569
+ pageNumber: this.detailLinesPageIndex - 1,
570
+ pageSize: this.detailLinesPageSize
571
+ }).subscribe(result => {
572
+ this.detailLinesPageData = result;
573
+ this.detailLinesPageLoading = false;
574
+ });
505
575
  }
506
- ```
507
576
 
508
- ### 说明
577
+ onDetailLinesPageIndexChange(pageIndex: number) {
578
+ this.detailLinesPageIndex = pageIndex;
579
+ this.loadDetailLinesPage();
580
+ }
509
581
 
510
- | 参数 | 类型 | 默认值 | 说明 |
511
- | -------------- | ------------------------------ | ---------- | ------------------------------------------------------------ |
512
- | *lines | Array<any> | | 接口返回的源数据 |
513
- | showTotal | boolean | false | 是否显示合计 |
514
- | columnsNumber | number \| string | | 列数(detailLineHead中所有的列数) |
515
- | totalOption | Array<TotalOption> | | 合计列选项 |
516
- | showSelected | boolean | false | 是否开启勾选功能 |
517
- | selectEvent | EventEmitter<array> | | 勾选状态改变触发函数,emit已勾选数组 |
518
- | selectField | string | billNumber | 与showSelected配合使用,勾选判断逻辑的关键词(传入源数据中的主键字段) |
519
- | detailLineHead | @ContentChild TemplateRef<any> | | 表格头插槽 |
520
- | detailLineBody | @ContentChild TemplateRef<any> | | 表格数据主体插槽 |
582
+ onDetailLinesPageSizeChange(pageSize: number) {
583
+ this.detailLinesPageSize = pageSize;
584
+ this.loadDetailLinesPage(true);
585
+ }
586
+ ```
521
587
 
522
- #### TotalOption
588
+ | 参数 | 类型 | 默认值 | 说明 |
589
+ | ---- | ---- | ------ | ---- |
590
+ | lines | any[] | [] | 当前页数据(也可用 tableData.content) |
591
+ | tableData | Page\<any\> | — | 分页对象,提供 totalElements |
592
+ | tablePageIndex / tablePageSize | number | 1 / 10 | 分页 |
593
+ | tableLoading | boolean | false | 加载状态 |
594
+ | tablePageIndexChange | EventEmitter | — | 页码变化 |
595
+ | tablePageSizeChange | EventEmitter | — | 每页条数变化(组件内会重置到第 1 页) |
596
+ | pageChange | EventEmitter | — | 任意分页变化 |
597
+ | showSelected / allowDrop / showTotal 等 | — | — | 同 hd-detail-lines |
598
+ | isCrossPageSelect | boolean | — | 跨页勾选 |
523
599
 
524
- | 参数 | 类型 | 说明 |
525
- | ----------- | ------ | ----------------------------------- |
526
- | insertIndex | number | 插入下标 |
527
- | insertValue | any | 插入值 |
528
- | align | string | 列对齐方式 left \| right \| center |
600
+ 模板中 `index` 为**全局序号**:`(pageIndex - 1) * pageSize + 行号`。
529
601
 
602
+ ### 与 hd-detail-lines 选型
530
603
 
604
+ | 场景 | 推荐组件 |
605
+ | ---- | -------- |
606
+ | 数据量小、前端筛选/分页 | hd-detail-lines |
607
+ | 接口分页、数据量大 | hd-detail-lines-page |
531
608
 
532
- ## 9、表单(hd-form)
609
+ ---
533
610
 
534
- ### 效果图
611
+ ## 16、操作日志(hd-log)
535
612
 
536
- ![hd-button](../../../../../海鼎/code/fantasy-ngzorro-project/projects/fantasy-ngzorro/readme/img/hd-form.png)
613
+ 基于 `hd-detail-lines` 封装的日志展示,内置列:时间、操作人、事件、描述。
537
614
 
538
615
  ### 示例
539
616
 
540
617
  ```html
541
- <hd-form [formList]="formInput" (changeEvent)="formChangeEvent($event)"></hd-form>
618
+ <hd-log [logs]="logs"></hd-log>
542
619
  ```
543
620
 
544
- ```tsx
545
- validateHdForm: FormGroup;
546
- formInput: Array<FormItem> = [{
547
- type: FormListType.Input,
548
- label: '配送单号',
549
- name: 'billNumberEq',
550
- require: true,
551
- width: 2,
552
- value: '',
553
- maxLength: 10,
554
- color: 'blue',
555
- // 事件传递的建议写法, 建议使用bind(this), 而不是箭头函数
556
- onChangeEvent: this.formInputChange.bind(this)
557
- }, {
558
- type: FormListType.ViewDom,
559
- label: '学校',
560
- name: 'school',
561
- width: 2,
562
- value: '[T8888]测试用中学'
563
- }, {
564
- type: FormListType.Select,
565
- label: '单项选择器选择',
566
- name: 'selectValue',
567
- value: 'qwer',
568
- require: true,
569
- defaultLabel: '组件外默认的选项',
570
- width: 2,
571
- onChangeEvent: (item) => {
572
- console.log('onChangeEvent', item);
573
- console.log('测试this', this);
574
- this.validateHdForm.get('qwer').setValue(true);
575
- },
576
- onSearchEvent: (item) => {
577
- console.log('onSearchEvent', item);
578
- },
579
- selectOption: {
580
- value: 'value',
581
- label: 'label',
582
- showLabelAndValue: true, // 使用此配置,最后展示为[value]label
583
- selectList: [{
584
- value: true,
585
- label: '是'
586
- }, {
587
- value: false,
588
- label: '否'
589
- }]
590
- }
591
- }, {
592
- type: FormListType.MultipleSelect,
593
- label: '多项选择器选择',
594
- name: 'multipleSelectValue',
595
- value: ['05', '06'],
596
- require: true,
597
- defaultLabel: ['第五个', '第六个'],
598
- width: 2,
599
- onChangeEvent: (item) => {
600
- console.log('onChangeEvent', item);
601
- },
602
- onSearchEvent: (item) => {
603
- console.log('onSearchEvent', item);
604
- },
605
- selectOption: {
606
- value: 'value',
607
- label: 'label',
608
- selectList: [{
609
- value: '01',
610
- label: '第一个'
611
- }, {
612
- value: '02',
613
- label: '第二个'
614
- }, {
615
- value: '03',
616
- label: '第三个'
617
- }, {
618
- value: '04',
619
- label: '第四个'
620
- }]
621
- }
622
- }, {
623
- type: FormListType.Date,
624
- label: '单个日期选择选择',
625
- name: 'dateValue',
626
- width: 1,
627
- value: '2020-1-2'
628
- }, {
629
- type: FormListType.DateRange,
630
- label: '日期范围选择',
631
- require: true,
632
- width: 1,
633
- name: 'dateRangeValue',
634
- value: ['2020-1-2', '2020-1-2']
635
- }, {
636
- type: FormListType.InputNumber,
637
- label: '数字输入',
638
- require: true,
639
- width: 1,
640
- name: 'inputNumberValue',
641
- value: null,
642
- disabled: false,
643
- color: 'red'
644
- }, {
645
- type: FormListType.TextArea,
646
- label: '备注',
647
- require: true,
648
- name: 'remark',
649
- width: 4,
650
- value: '这是个备注'
651
- }];
652
-
653
-
654
- /**
655
- * form组件值改变函数
656
- * @param validateForm form组件返回的表单对象
657
- */
658
- formChangeEvent(validateForm: any) {
659
- this.validateHdForm = validateForm;
660
- // console.log('form组件返回',this.validateHdForm.getRawValue());
621
+ | 参数 | 类型 | 说明 |
622
+ | ---- | ---- | ---- |
623
+ | logs | any[] | 日志列表,字段:`createInfo.operateTime`、`createInfo.operatorName`、`event`、`describe` |
624
+
625
+ 也可作为 Modal 内容组件使用(`entryComponents: HdLogComponent`)。
626
+
627
+ ---
628
+
629
+ ## 附录:公共配置类型
630
+
631
+ 以下类型在 `hd-filter`、`hd-form`、`hd-form-lines`、`hd-table` 等组件中复用。
632
+
633
+ ### SelectOption(下拉选项配置)
634
+
635
+ 用于 `Filter.selectOption`、`FormItem.selectOption`、`FormLine.selectOption`。
636
+
637
+ | 参数 | 类型 | 默认值 | 说明 |
638
+ | ---- | ---- | ------ | ---- |
639
+ | label | string | — | selectList 中作为显示文案的字段名 |
640
+ | value | string | — | selectList 中作为绑定值的字段名 |
641
+ | selectList | any[] | — | 静态选项列表 |
642
+ | selectListName | string | — | 选项来自行数据某字段时使用(配合 hide 字段) |
643
+ | showLabelAndValue | boolean | false | 选项展示为 `[value]label` |
644
+ | hdDropdownMatchSelectWidth | boolean | false | 下拉宽度是否与控件一致 |
645
+ | hdServerSearch | boolean | false | 是否远程搜索 |
646
+ | hdShowSearch | boolean | true | 是否可搜索 |
647
+ | hdAllowClear | boolean | true | 是否允许清空 |
648
+ | hdShowItemCode | boolean | false | 已选展示是否带 `[value]` 前缀 |
649
+ | tableColumns | SelectOptionTableColumn[] | — | 表格型下拉列配置(商品选择器等) |
650
+
651
+ ```typescript
652
+ selectOption: {
653
+ value: 'productCode',
654
+ label: 'productName',
655
+ showLabelAndValue: true,
656
+ hdServerSearch: true,
657
+ selectList: [],
658
+ tableColumns: [
659
+ { width: ColWidth.codeNameColWidth, label: '商品', name: 'product',
660
+ render: (line) => `[${line.productCode}] ${line.productName}` },
661
+ { width: ColWidth.enumColWidth, label: '规格', name: 'specification' }
662
+ ]
661
663
  }
662
664
  ```
663
665
 
664
- ### 说明
665
-
666
- | 参数 | 类型 | 默认值 | 说明 |
667
- | --------------- | --------------- | ------ | -------------------------------- |
668
- | formInput | Array<FormItem> | | 表单控件数组 |
669
- | formChangeEvent | EventEmitter<> | | 表单值改变事件,返回当前表单内容 |
670
-
671
- #### TotalOption
672
-
673
- | 参数 | 类型 | 说明 |
674
- | ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
675
- | *type | FormListType | 控件类型 Input \| Select \| Date \| DateRange \| MultipleSelect \| TextArea \| InputNumber \| ViewDom(单纯的显示控件) |
676
- | *label | string | 文本 |
677
- | *name | string | 字段名 |
678
- | require | boolen | 是否必填 |
679
- | placeholder | string | 输入框提示文案 |
680
- | width | number | 占据的列数。默认1 |
681
- | value | string \| boolen \| number \| Array<Date> \| Array<string> \| null | 值 |
682
- | disabled | boolen | 是否禁用 |
683
- | color | string | 控件文本颜色 |
684
- | hide | boolean | 是否为隐藏字段,仅用于填充表单的字段,不显示在页面上 |
685
- | maxLength | number | input控件的输入长度 |
686
- | selectOption | SelectOption | 控件为Select时,选项列表 |
687
- | inputNumber | InputNumber | number组件的选项,min、max、step |
688
- | onChangeEvent | Function | 控件的值改变事件 可用于控件间联动 |
689
- | onSearchEvent | Function | select选择器搜索事件 可用于更新备选集合 |
690
- | defaultLabel | string \| Array<string> | select选择器不初始化的时候可以使用defaultLabel搭配value,设置默认值 |
691
-
692
- #### InputNumber
693
-
694
- | 参数 | 类型 | 默认值 | 说明 |
695
- | ---- | ------ | -------- | ------ |
696
- | min | number | 0 | 最小值 |
697
- | max | number | 99999999 | 最大值 |
698
- | step | number | 1 | 步阶 |
699
-
700
- #### SelectOption
701
-
702
- | 参数 | 类型 | 默认值 | 说明 |
703
- | -------------------------- | ---------- | ------ | ------------------------------------------------------ |
704
- | *label | string | | label字段,取selectList数组中的某个字段作为选择器label |
705
- | *value | string | | Value字段,取selectList数组中的某个字段作为选择器value |
706
- | *selectList | Array<any> | | 选项列表 |
707
- | showLabelAndValue | boolean | false | 选项同时展示label和value,格式:[value]label |
708
- | hdDropdownMatchSelectWidth | boolean | false | 选择框长度是否和控件长度保持一致,默认不保持 |
709
-
710
- ## 10、明细表单(hd-form-lines)
711
-
712
- ### 效果图
713
-
714
- ![hd-button](../../../../../海鼎/code/fantasy-ngzorro-project/projects/fantasy-ngzorro/readme/img/hd-form-lines.png)
715
-
716
- ### 示例
717
-
718
- ```html
719
- <hd-form-lines [formLines]="formLines" [operateButtons]="['delete']" showDeleteConfirm [formLinesData]="formLinesData" (changeEvent)="formLinesChangeEvent($event)"></hd-form-lines>
720
- ```
721
-
722
- ```tsx
723
- validateHdFormLines: FormGroup;
724
- formLines: Array<FormLine> = [{
725
- type: FormLineType.Select,
726
- label: '商品',
727
- name: 'productCode',
728
- require: true,
729
- onChangeEvent: (item, line: FormGroup) => {
730
- // 列之间的交互赋值等等
731
- console.log('item', item);
732
- console.log('测试this', line);
733
- if (item) {
734
- line.get('productSpec').setValue(12);
735
- line.get('money').setValue(22);
736
- }
737
- },
738
- onSearchEvent: (item) => {
739
- console.log('onSearchEvent', item);
740
- // 在这里去调接口查数据
741
- this.formLines[0].selectOption.selectList = [{
742
- productCode: '03',
743
- productName: '第三个'
744
- }, {
745
- productCode: '04',
746
- productName: '第四个'
747
- }]
748
- console.log('formLines', this.formLines);
749
- },
750
- selectOption: {
751
- value: 'productCode',
752
- label: 'productName',
753
- showLabelAndValue: true,
754
- selectList: [{
755
- productCode: '01',
756
- productName: '第一个'
757
- }, {
758
- productCode: '02',
759
- productName: '第二个'
760
- }]
761
- }
762
- },{
763
- type: FormLineType.MultipleSelect,
764
- label: '多项选择器选择',
765
- name: 'multipleSelectValue',
766
- require: true,
767
- onChangeEvent: (item) => {
768
- console.log('onChangeEvent', item);
769
- },
770
- onSearchEvent: (item) => {
771
- console.log('onSearchEvent', item);
772
- },
773
- selectOption: {
774
- value: 'multipleSelectValue',
775
- label: 'multipleSelectValueLabel',
776
- selectList: [{
777
- multipleSelectValue: '01',
778
- multipleSelectValueLabel: '第一个'
779
- }, {
780
- multipleSelectValue: '02',
781
- multipleSelectValueLabel: '第二个'
782
- }, {
783
- multipleSelectValue: '03',
784
- multipleSelectValueLabel: '第三个'
785
- }, {
786
- multipleSelectValue: '04',
787
- multipleSelectValueLabel: '第四个'
788
- }]
789
- }
790
- }, {
791
- type: FormLineType.Input,
792
- label: '测试输入框',
793
- name: 'testInput',
794
- maxLength: 10,
795
- explainOption: {
796
- show: true,
797
- name: 'explain',
798
- color: 'red'
799
- },
800
- onChangeEvent: (item, line: FormGroup) => {
801
- // 这里利用隐藏属性 根据line里面的相关字段 去判断是否需要展示出来
802
- if(line.get('hideQuantity').value === 100 && item){
803
- line.get('explain').setValue('这是一个测试文案qaq');
804
- }else{
805
- line.get('explain').setValue('');
806
- }
807
- },
808
- }, {
809
- type: FormLineType.InputNumber,
810
- label: '测试输入框1',
811
- name: 'testInput1',
812
- maxLength: 10,
813
- colorOption: {
814
- name: 'inputColor',
815
- color: 'red'
816
- },
817
- onChangeEvent: (item, line: FormGroup) => {
818
- // 这里利用隐藏属性 根据line里面的相关字段 去判断是否需要展示出来
819
- if(line.get('testInput1').value >= 50 && item){
820
- line.get('inputColor').setValue('red');
821
- }else{
822
- line.get('inputColor').setValue(null);
823
- }
824
- },
825
- }, {
826
- type: FormLineType.ViewDom,
827
- label: '规格',
828
- name: 'productSpec'
829
- }, {
830
- type: FormLineType.ViewDom,
831
- label: '金额',
832
- name: 'money',
833
- preserveNumber: 1
834
- }, {
835
- type: FormLineType.ViewDom,
836
- label: '价格',
837
- align: 'right',
838
- name: 'price',
839
- preserveNumber: 2
840
- }, {
841
- type: FormLineType.ViewDom,
842
- label: '数量',
843
- name: 'quantity'
844
- }, {
845
- type: FormLineType.ViewDom,
846
- label: '隐藏数量',
847
- hide: true,
848
- name: 'hideQuantity'
849
- }, {
850
- type: FormLineType.ViewDom,
851
- label: '隐藏的说明',
852
- hide: true,
853
- name: 'explain'
854
- }, {
855
- type: FormLineType.ViewDom,
856
- label: '隐藏的颜色,用于表示',
857
- hide: true,
858
- name: 'inputColor'
859
- }];
666
+ ### SelectOptionTableColumn(表格型下拉列)
667
+
668
+ | 参数 | 类型 | 说明 |
669
+ | ---- | ---- | ---- |
670
+ | width | number | 列宽(px),参考 `ColWidth` |
671
+ | label | string | 表头文案 |
672
+ | name | string | selectList item 字段名 |
673
+ | render | (line) => string | 自定义渲染,优先级高于 name |
674
+ | icons | SelectOptionTableColumnIcon[] | 图标列(如推荐、协采标签) |
675
+
676
+ ### SelectOptionTableColumnIcon(表格型下拉图标列)
677
+
678
+ | 参数 | 类型 | 说明 |
679
+ | ---- | ---- | ---- |
680
+ | iconName | string | `hd-select-close`(禁用)、`hd-select-purchase`(协)、`hd-recommend-star`、`hd-img-star` |
681
+ | fieldName | string | selectList item 中控制显示的布尔字段 |
682
+
683
+ ### InputNumber(数字输入配置)
684
+
685
+ 用于 `Filter.inputNumber`、`FormItem.inputNumber`、`FormLine.inputNumber`。
686
+
687
+ | 参数 | 类型 | 默认值 | 说明 |
688
+ | ---- | ---- | ------ | ---- |
689
+ | min | number | 0 | 最小值 |
690
+ | max | number | 99999999 | 最大值 |
691
+ | step | number | 1 | 步进值 |
692
+ | precision | number | 4 | 小数精度 |
693
+ | nzFormatter | Function | — | 展示格式化 |
694
+ | nzParser | Function | — | 输入解析 |
695
+
696
+ ### CascaderOption(级联选择配置)
697
+
698
+ | 参数 | 类型 | 说明 |
699
+ | ---- | ---- | ---- |
700
+ | options | any[] | 级联数据源(ng-zorro cascader 格式) |
701
+
702
+ ### RadioOption(单选配置)
703
+
704
+ 用于 `FormItem.radioOption`(`FormListType.Radio`)。
705
+
706
+ | 参数 | 类型 | 默认值 | 说明 |
707
+ | ---- | ---- | ------ | ---- |
708
+ | label | string || optionList 中作为显示文案的字段名 |
709
+ | value | string | | optionList 中作为绑定值的字段名 |
710
+ | optionList | any[] | | 选项列表 |
711
+ | showLabelAndValue | boolean | false | 选项展示为 `[value]label` |
712
+
713
+ ### CheckboxOption(复选框配置)
714
+
715
+ 用于 `FormItem.checkboxOption`(`FormListType.Checkbox` 多选组)。未配置 `checkboxOption` 时渲染单个复选框,值为 `boolean`,默认 `false`;配置后为复选框组,值为选中项 `value` 组成的数组,默认 `[]`。
716
+
717
+ | 参数 | 类型 | 默认值 | 说明 |
718
+ | ---- | ---- | ------ | ---- |
719
+ | label | string | — | optionList 中作为显示文案的字段名 |
720
+ | value | string | — | optionList 中作为绑定值的字段名 |
721
+ | optionList | any[] | — | 选项列表 |
722
+ | showLabelAndValue | boolean | false | 选项展示为 `[value]label` |
723
+
724
+ ### HdOption(键值展示项)
725
+
726
+ 用于 `hd-detail-form` `formCols`。
727
+
728
+ | 参数 | 类型 | 说明 |
729
+ | ---- | ---- | ---- |
730
+ | label | string | 标签 |
731
+ | value | any | 值 |
732
+ | color | string | 文字颜色 |
733
+ | hide | boolean | 是否隐藏 |
734
+ | clickText | string | 可点击文案 |
735
+ | click | (value) => void | 点击回调 |
736
+
737
+ ### Filter(筛选项)
738
+
739
+ | 参数 | 类型 | 默认值 | 说明 |
740
+ | ---- | ---- | ------ | ---- |
741
+ | type | FilterListType | — | 控件类型 |
742
+ | label | string | — | 标签 |
743
+ | name | string | — | 字段名(提交给后端的 key) |
744
+ | value | any | null | 初始值 |
745
+ | placeholder | string | — | 占位符 |
746
+ | require | boolean | false | 是否必填 |
747
+ | show | boolean | — | 是否显示 |
748
+ | selectOption | SelectOption | — | Select / MultipleSelect 配置 |
749
+ | inputNumber | InputNumber | — | InputNumber 配置 |
750
+ | cascaderOption | CascaderOption | — | Cascader 配置 |
751
+ | showTime | boolean | false | Date 是否含时间 |
752
+ | hdDisabledDate | Function | — | 不可选日期 `(date) => boolean` |
753
+ | onChangeEvent | Function | — | 值变化 |
754
+ | onSearchEvent | Function | — | 下拉搜索 |
755
+ | onBlurEvent | Function | — | 失焦 |
756
+ | onChangeEventDebounceTime | number | — | change 防抖(ms) |
757
+ | onSearchEventEventDebounceTime | number | — | search 防抖(ms) |
758
+
759
+ #### FilterListType 枚举
760
+
761
+ `Input` \| `Select` \| `MultipleSelect` \| `Date` \| `DateRange` \| `Cascader` \| `Month` \| `InputNumber`
762
+
763
+ ### FormItem(表单项)
764
+
765
+ | 参数 | 类型 | 默认值 | 说明 |
766
+ | ---- | ---- | ------ | ---- |
767
+ | type | FormListType | — | 控件类型 |
768
+ | label / name | string | — | 标签 / 字段名 |
769
+ | require | boolean | false | 是否必填 |
770
+ | width | number | 1 | 占据列数(总宽 4 列) |
771
+ | hide | boolean | false | 隐藏字段 |
772
+ | value | any | null | 初始值 |
773
+ | placeholder | string | — | 占位符 |
774
+ | disabled | boolean | — | 是否禁用 |
775
+ | color / labelColor | string | — | 控件 / 标签颜色 |
776
+ | maxLength | number | — | Input 最大长度 |
777
+ | prefix | string | — | Input 前缀文字(`nzPrefix`) |
778
+ | prefixIcon | string | — | Input 前缀图标(`nz-icon` 的 `nzType`) |
779
+ | textAreaRows | number | — | TextArea 行数 |
780
+ | explain | string | — | label 下方说明 |
781
+ | showTime | boolean | false | Date 含时间 |
782
+ | format | string | — | 时间格式化 |
783
+ | selectOption | SelectOption | — | 下拉配置 |
784
+ | radioOption | RadioOption | — | 单选配置 |
785
+ | checkboxOption | CheckboxOption | — | 复选框组配置;不传则为单个复选框 |
786
+ | inputNumber | InputNumber | — | 数字框配置 |
787
+ | cascaderOption | CascaderOption | — | 级联配置 |
788
+ | defaultLabel | string \| string[] | — | Select 默认展示文案 |
789
+ | hdDisabledDate | Function | — | 不可选日期 |
790
+ | validatorKeys | ValidatorKey[] | — | 校验键 |
791
+ | validator | ValidatorFn | — | 自定义校验 |
792
+ | onChangeEvent / onSearchEvent | Function | — | 值变化 / 下拉搜索 |
793
+ | onChangeEventDebounceTime | number | — | change 防抖(ms) |
794
+ | onSearchEventEventDebounceTime | number | — | search 防抖(ms) |
795
+
796
+ #### FormListType 枚举
797
+
798
+ `Input` \| `Select` \| `MultipleSelect` \| `Date` \| `DateRange` \| `TextArea` \| `InputNumber` \| `ViewDom` \| `Switch` \| `Time` \| `Cascader` \| `Radio` \| `Checkbox`
799
+
800
+ #### ValidatorKey
801
+
802
+ | 参数 | 类型 | 说明 |
803
+ | ---- | ---- | ---- |
804
+ | key | string | 校验规则 key |
805
+ | label | string | 校验失败提示 |
806
+
807
+ ### FormLine(明细表单项)
808
+
809
+ 在 FormItem 基础上用于行内编辑,额外字段:
810
+
811
+ | 参数 | 类型 | 默认值 | 说明 |
812
+ | ---- | ---- | ------ | ---- |
813
+ | type | FormLineType | — | 控件类型 |
814
+ | align | string | — | 列对齐 |
815
+ | hideViewDomValue | boolean | false | ViewDom 隐藏 value |
816
+ | isSelect | boolean | — | 聚焦后全选内容 |
817
+ | preserveNumber | number | — | ViewDom 小数位 |
818
+ | disabled | boolean | — | 是否禁用 |
819
+ | style | object | — | 列样式 |
820
+ | canSearch | boolean | false | hide 字段参与搜索 |
821
+ | explainOption / explainOptionRight | ExplainOption | — | 说明文字 |
822
+ | colorOption | ColorOption | — | 动态颜色 |
823
+ | selectOption | SelectOption | — | 含 tableColumns 表格下拉 |
824
+ | onChangeEventDebounceTime | number | — | change 防抖(ms) |
825
+
826
+ #### FormLineType 枚举
827
+
828
+ `Input` \| `Select` \| `Date` \| `DateRange` \| `TextArea` \| `InputNumber` \| `MultipleSelect` \| `ViewDom` \| `Switch` \| `Time`
829
+
830
+ #### ColorOption / ExplainOption
831
+
832
+ | ColorOption | ExplainOption |
833
+ | ----------- | ------------- |
834
+ | name:hide 字段名存颜色 | show:是否显示 |
835
+ | color:默认颜色 | name:hide 字段名存文案 |
836
+ | | color:文字颜色 |
837
+
838
+ #### FormLine 事件签名
839
+
840
+ ```typescript
841
+ onChangeEvent: (value, line: FormGroup) => void
842
+ onSearchEvent: (keyword, line?: FormGroup) => void
860
843
  ```
861
844
 
862
- ### 说明
863
-
864
- | 参数 | 类型 | 默认值 | 说明 |
865
- | ----------------- | --------------- | ---------------- | ------------------------------------------------------------ |
866
- | formInput | Array<FormItem> | | 表单控件数组 |
867
- | operateButtons | Array<string> | ['add','delete'] | 操作按钮组,默认有添加和删除,如传入['delete']则不显示新增按钮 |
868
- | showDeleteConfirm | boolen | false | 删除按钮是否显示确认提示框 |
869
- | formChangeEvent | EventEmitter<> | | 表单值改变事件,返回当前表单内容 |
870
-
871
- #### TotalOption
872
-
873
- | 参数 | 类型 | 说明 |
874
- | -------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
875
- | *type | FormListType | 控件类型 Input \| Select \| Date \| DateRange \| MultipleSelect \| TextArea \| InputNumber \| ViewDom(单纯的显示控件) |
876
- | *label | string | 文本 |
877
- | *name | string | 字段名 |
878
- | placeholder | string | 输入框提示文案 |
879
- | require | boolen | 是否必填 |
880
- | width | number | 占据的列数。默认1 |
881
- | value | string \| boolen \| number \| Array<Date> \| Array<string> \| null | 值 |
882
- | align | string | 列对齐方式,'left' \| 'right' \| 'center' |
883
- | isSelect | boolean | 输入框等是否允许点击之后全选内容,默认不允许 |
884
- | colorOption | ColorOption | 颜色选项 |
885
- | explainOption | ExplainOption | 说明字段 |
886
- | hide | boolean | 是否为隐藏字段,仅用于填充表单的字段,不显示在页面上 |
887
- | maxLength | number | input控件的输入长度 |
888
- | selectOption | SelectOption | 控件为Select时,选项列表 |
889
- | inputNumber | InputNumber | number组件的选项,min、max、step |
890
- | onChangeEvent | Function | 控件的值改变事件 可用于控件间联动 |
891
- | onSearchEvent | Function | select选择器搜索事件 可用于更新备选集合 |
892
- | defaultLabel | any | select选择器不初始化的时候可以使用defaultLabel搭配value,设置默认值 |
893
- | preserveNumber | number | 需要保留小数的列的位数 |
894
-
895
- #### ColorOption
896
-
897
- | 参数 | 类型 | 说明 |
898
- | ----- | ------ | ---- |
899
- | *name | string | 字段 |
900
- | color | string | 颜色 |
901
-
902
- #### ExplainOption
903
-
904
- | 参数 | 类型 | 说明 |
905
- | ----- | ------ | -------- |
906
- | *name | string | 字段 |
907
- | *show | string | 是否显示 |
908
- | color | string | 颜色 |
909
-
910
- #### InputNumber
911
-
912
- | 参数 | 类型 | 默认值 | 说明 |
913
- | ---- | ------ | -------- | ------ |
914
- | min | number | 0 | 最小值 |
915
- | max | number | 99999999 | 最大值 |
916
- | step | number | 1 | 步阶 |
917
-
918
- #### SelectOption
919
-
920
- | 参数 | 类型 | 默认值 | 说明 |
921
- | -------------------------- | ---------- | ------ | ------------------------------------------------------------ |
922
- | *label | string | | label字段,取selectList数组中的某个字段作为选择器label |
923
- | *value | string | | Value字段,取selectList数组中的某个字段作为选择器value |
924
- | selectList | Array<any> | | 选项列表 |
925
- | selectListName | String | | 选项列表为数据object的某个字段的时候,增加hide viewdom,selectListName设置为该hide viewdom的name |
926
- | showLabelAndValue | boolean | false | 选项同时展示label和value,格式:[value]label |
927
- | hdDropdownMatchSelectWidth | boolean | false | 选择框长度是否和控件长度保持一致,默认不保持 |
928
-
929
- ## 11、间隔(hd-space)
930
-
931
- ### 效果图(组件间的空白区域)
932
-
933
- ![hd-button](../../../../../海鼎/code/fantasy-ngzorro-project/projects/fantasy-ngzorro/readme/img/hd-space.png)
934
-
935
- ### 示例
936
-
937
- ```html
938
- <hd-space background="#fff" type="row" size="12"></hd-space>
845
+ ### HdTableColumn(表格列)
846
+
847
+ | 参数 | 类型 | 默认值 | 说明 |
848
+ | ---- | ---- | ------ | ---- |
849
+ | title / name | string || 列标题 / 字段名 |
850
+ | width / minWidth | number | | 列宽 / 最小列宽 |
851
+ | align | string | left | 对齐方式 |
852
+ | color | string || 文字颜色 |
853
+ | fixed / fixedWidth | — | — | 固定列 |
854
+ | isShow | boolean | true | 设置列可见性 |
855
+ | canSort / canWarp | boolean | false | 排序 / 换行 |
856
+ | isState | boolean | false | 是否按状态列渲染,取值字段为 `name` |
857
+ | stateField | string | | 状态列取值字段(`name` 为 `state` 且未设置 `isState` 时生效,默认 `state`) |
858
+ | render / click | Function | | 渲染 / 点击 |
859
+ | btnList | OperateBtn[] | | 操作按钮 |
860
+
861
+ #### OperateBtn(操作列按钮)
862
+
863
+ | 参数 | 类型 | 默认值 | 说明 |
864
+ | ---- | ---- | ------ | ---- |
865
+ | name | string | | 按钮文案 |
866
+ | showConfirm | boolean \| (line) => boolean | false | 是否 popconfirm 确认;传函数时按行数据判断 |
867
+ | isRepeat | boolean | false | 与其他按钮互斥显示 |
868
+ | click | (line) => void | | 点击回调 |
869
+ | permission | (line) => boolean | | 是否显示 |
870
+
871
+ #### HdTableTotalOption(hd-table 底部合计)
872
+
873
+ | 参数 | 类型 | 说明 |
874
+ | ---- | ---- | ---- |
875
+ | columnNumber | number | 总列数 |
876
+ | insertIndex | number | 插入列下标 |
877
+ | insertName | string | 合计字段名 |
878
+
879
+ #### TotalOption(明细合计行)
880
+
881
+ 用于 `hd-detail-lines`、`hd-detail-lines-page`、`hd-form-lines`。
882
+
883
+ | 参数 | 类型 | 说明 |
884
+ | ---- | ---- | ---- |
885
+ | insertIndex | number | 插入列下标(从 1 开始) |
886
+ | insertValue | any | 合计值 |
887
+ | align | string | 对齐方式 |
888
+ | showDecimal | boolean | 始终显示小数 |
889
+ | isHide | boolean | 隐藏该合计列 |
890
+
891
+ #### TableTotalOption(hd-current-table 合计,已弃用)
892
+
893
+ | 参数 | 类型 | 说明 |
894
+ | ---- | ---- | ---- |
895
+ | columnNumber | number | 总列数 |
896
+ | insertIndex | number | 插入列下标 |
897
+ | insertName | string | 合计字段名 |
898
+
899
+ ---
900
+
901
+ ## 附录:ColWidth 列宽常量
902
+
903
+ ```typescript
904
+ import { ColWidth } from 'fantasy-ngzorro';
905
+
906
+ ColWidth.tableImageColWidth // 25 表格单图标
907
+ ColWidth.tableTwoImageColWidth // 40 表格双图标(Select 表格下拉)
908
+ ColWidth.billNumberColWidth // 150 单号
909
+ ColWidth.nameColWidth // 150 名称
910
+ ColWidth.codeColWidth // 100 代码
911
+ ColWidth.codeNameColWidth // 200 [code]name
912
+ ColWidth.enumColWidth // 100 枚举
913
+ ColWidth.dateColWidth // 100 日期
914
+ ColWidth.dateTimeColWidth // 150 日期时间
915
+ ColWidth.dateRangeWidth // 200 日期范围
916
+ ColWidth.operateColWidth // 150 操作列
917
+ ColWidth.numberColWidth // 100 数字
918
+ ColWidth.remarkColWidth // 250 备注
919
+ ColWidth.fixColWidth // 150 通用固定宽
920
+ ColWidth.maxColWidth // 350 超长省略展开
939
921
  ```
940
922
 
941
- ### 说明
942
-
943
- | 参数 | 类型 | 默认值 | 说明 |
944
- | ---------- | --------- | --------- | ----------------------- |
945
- | background | string | 'inherit' | 加载中 |
946
- | type | SpaceType | | 类型,'row' \| 'column' |
947
- | size | number | | 高度 \| 宽度 |
948
-
949
- ## 12、小标题(hd-tip)
950
-
951
- ### 效果图
952
-
953
- ![hd-button](../../../../../海鼎/code/fantasy-ngzorro-project/projects/fantasy-ngzorro/readme/img/hd-tip.png)
954
-
955
- ### 示例
956
-
957
- ```html
958
- <hd-tip title="基本信息" [fontSize]="14"></hd-tip>
959
- <hd-tip title="新增" [showIcon]="false" [fontSize]="16"></hd-tip>
923
+ ## 附录:Page 分页结构
924
+
925
+ ```typescript
926
+ class Page<T> {
927
+ totalPages: number;
928
+ totalElements: number;
929
+ pageNumber: number; // 0 开始
930
+ pageSize: number;
931
+ hasContent: boolean;
932
+ hasNext: boolean;
933
+ content: T[];
934
+ }
960
935
  ```
961
-
962
- ### 说明
963
-
964
- | 参数 | 类型 | 默认值 | 说明 |
965
- | -------- | ------ | ------ | ---------------------- |
966
- | showIcon | boolen | true | 是否显示前面的竖线icon |
967
- | fontSize | number | | 字体大小 |
968
- | title | string | False | 标题文案 |
969
-
970
- ## TODO
971
-
972
- - [x] 文档示例
973
- - [x] 更新记录
974
- - [x]