jianghu-ui 1.0.6 → 1.0.7

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 (47) hide show
  1. package/dist/jianghu-ui.css +181 -110
  2. package/dist/jianghu-ui.js +1 -1
  3. package/package.json +1 -1
  4. package/src/components/JhDrawer/JhDrawer.stories.js +6 -6
  5. package/src/components/JhDrawerForm/JhDrawerForm.vue +1 -1
  6. package/src/components/JhForm/JhForm.stories.js +114 -95
  7. package/src/components/JhForm/JhForm.vue +148 -21
  8. package/src/components/JhFormFields/JhFormFields.vue +33 -14
  9. package/src/components/JhModal/JhModal.stories.js +6 -6
  10. package/src/components/JhModal/JhModal.vue +1 -1
  11. package/src/components/JhModalForm/JhModalForm.vue +1 -1
  12. package/src/components/JhTable/JhTable.stories.js +134 -167
  13. package/src/components/JhTable/JhTable.vue +83 -23
  14. package/src/style/globalCSSVuetifyV4.css +1 -2
  15. package/src/components/JhAddressSelect/JhAddressSelect.md +0 -267
  16. package/src/components/JhCard/JhCard.md +0 -246
  17. package/src/components/JhCheckCard/JhCheckCard.md +0 -245
  18. package/src/components/JhConfirmDialog/JhConfirmDialog.md +0 -70
  19. package/src/components/JhDateRangePicker/JhDateRangePicker.md +0 -56
  20. package/src/components/JhDescriptions/JhDescriptions.md +0 -724
  21. package/src/components/JhDraggable/JhDraggable.md +0 -66
  22. package/src/components/JhDrawer/JhDrawer.md +0 -68
  23. package/src/components/JhDrawerForm/JhDrawerForm.md +0 -69
  24. package/src/components/JhEditableTable/JhEditableTable.md +0 -507
  25. package/src/components/JhFileInput/JhFileInput.md +0 -56
  26. package/src/components/JhForm/JhForm.md +0 -676
  27. package/src/components/JhFormFields/JhFormFields.md +0 -647
  28. package/src/components/JhFormList/JhFormList.md +0 -303
  29. package/src/components/JhJsonEditor/JhJsonEditor.md +0 -54
  30. package/src/components/JhLayout/JhLayout.md +0 -580
  31. package/src/components/JhList/JhList.md +0 -441
  32. package/src/components/JhMarkdownEditor/JhMarkdownEditor.md +0 -56
  33. package/src/components/JhMask/JhMask.md +0 -62
  34. package/src/components/JhMenu/JhMenu.md +0 -85
  35. package/src/components/JhModal/JhModal.md +0 -68
  36. package/src/components/JhModalForm/JhModalForm.md +0 -69
  37. package/src/components/JhPageContainer/JhPageContainer.md +0 -409
  38. package/src/components/JhQueryFilter/JhQueryFilter.md +0 -77
  39. package/src/components/JhScene/JhScene.md +0 -64
  40. package/src/components/JhStatisticCard/JhStatisticCard.md +0 -363
  41. package/src/components/JhStepsForm/JhStepsForm.md +0 -666
  42. package/src/components/JhTable/JhTable.md +0 -730
  43. package/src/components/JhTableAttachment/JhTableAttachment.md +0 -70
  44. package/src/components/JhToast/JhToast.md +0 -67
  45. package/src/components/JhTreeSelect/JhTreeSelect.md +0 -82
  46. package/src/components/JhWaterMark/JhWaterMark.md +0 -190
  47. package/src/components/README.md +0 -52
@@ -1,666 +0,0 @@
1
- # JhStepsForm - 分步表单
2
-
3
- 基于 Ant Design ProComponents StepsForm 设计的分步表单组件,用于将复杂表单拆分为多个步骤,提升用户体验。
4
-
5
- ## 特性
6
-
7
- - 📝 **多步骤表单** - 将复杂表单拆分为多个步骤,降低用户填写负担
8
- - 🎯 **步骤导航** - 支持步骤点击跳转、上一步/下一步操作
9
- - ✅ **表单验证** - 每个步骤支持独立验证,确保数据准确性
10
- - 🎨 **灵活布局** - 支持水平/垂直布局,适应不同场景
11
- - 🔧 **高度可定制** - 支持自定义步骤内容、按钮、样式等
12
- - 📦 **表单实例管理** - 提供 formMapRef 访问所有步骤表单实例
13
- - 🎭 **插槽支持** - 支持自定义步骤内容和提交按钮渲染
14
-
15
- ## 基础用法
16
-
17
- ```vue
18
- <template>
19
- <jh-steps-form
20
- :steps="steps"
21
- @finish="handleFinish"
22
- >
23
- <template #step-confirm="{ formData }">
24
- <div>确认信息...</div>
25
- </template>
26
- </jh-steps-form>
27
- </template>
28
-
29
- <script>
30
- export default {
31
- data() {
32
- return {
33
- steps: [
34
- {
35
- title: '基本信息',
36
- subTitle: '填写基本信息',
37
- fields: [
38
- {
39
- name: 'username',
40
- label: '用户名',
41
- type: 'text',
42
- required: true,
43
- },
44
- {
45
- name: 'email',
46
- label: '邮箱',
47
- type: 'email',
48
- required: true,
49
- },
50
- ],
51
- },
52
- {
53
- title: '详细信息',
54
- fields: [
55
- {
56
- name: 'address',
57
- label: '地址',
58
- type: 'text',
59
- },
60
- ],
61
- },
62
- {
63
- title: '确认信息',
64
- slot: 'step-confirm',
65
- },
66
- ],
67
- };
68
- },
69
- methods: {
70
- handleFinish(data) {
71
- console.log('提交数据:', data);
72
- },
73
- },
74
- };
75
- </script>
76
- ```
77
-
78
- ## API
79
-
80
- ### Props
81
-
82
- | 参数 | 说明 | 类型 | 默认值 |
83
- |------|------|------|--------|
84
- | steps | 步骤配置数组 | `Array<StepConfig>` | `[]` |
85
- | initialStep | 初始步骤索引 (从0开始) | `number` | `0` |
86
- | value / v-model | 当前激活步骤 (支持 v-model) | `number` | `null` |
87
- | current | 当前步骤 (支持 .sync) | `number` | `null` |
88
- | editable | 是否可编辑已完成的步骤 | `boolean` | `false` |
89
- | vertical | 是否垂直布局 | `boolean` | `false` |
90
- | altLabels | 是否替代标签模式 | `boolean` | `false` |
91
- | outlined | 输入框样式 | `boolean` | `true` |
92
- | dense | 紧凑模式 | `boolean` | `false` |
93
- | submitting | 提交中状态 | `boolean` | `false` |
94
- | previousButtonText | 上一步按钮文本 | `string` | `'上一步'` |
95
- | nextButtonText | 下一步按钮文本 | `string` | `'下一步'` |
96
- | finishButtonText | 完成按钮文本 | `string` | `'完成'` |
97
- | validateStep | 步骤验证函数 | `Function` | `null` |
98
- | transformBeforeFinish | 数据转换函数(最终提交前) | `Function` | `null` |
99
- | onCurrentChange | 步骤变化回调 | `Function` | `null` |
100
- | onFormChange | 表单字段变化回调 | `Function` | `null` |
101
- | stepsProps | 传递给 v-stepper 的额外属性 | `object` | `{}` |
102
- | formProps | 传递给所有步骤表单的公共属性 | `object` | `{}` |
103
- | stepFormRender | 自定义步骤表单渲染 | `Function` | `null` |
104
- | submitter | 提交按钮配置 | `object \| boolean` | `null` |
105
- | containerStyle | 容器样式 | `object \| string` | `null` |
106
-
107
- ### StepConfig
108
-
109
- 步骤配置对象:
110
-
111
- ```typescript
112
- interface StepConfig {
113
- title: string; // 步骤标题
114
- subTitle?: string; // 步骤副标题
115
- slot?: string; // 自定义插槽名称
116
- fields?: Array<Field>; // 表单字段配置 (使用 JhForm)
117
- }
118
- ```
119
-
120
- ### Submitter 配置
121
-
122
- ```typescript
123
- interface Submitter {
124
- render?: false | Function; // false 隐藏按钮,Function 自定义渲染
125
- showPrevious?: boolean; // 是否显示上一步按钮
126
- previousText?: string; // 上一步按钮文本
127
- previousButtonProps?: object; // 上一步按钮属性
128
- nextText?: string; // 下一步按钮文本
129
- nextButtonProps?: object; // 下一步按钮属性
130
- submitText?: string; // 提交按钮文本
131
- submitButtonProps?: object; // 提交按钮属性
132
- }
133
- ```
134
-
135
- ### Events
136
-
137
- | 事件名 | 说明 | 回调参数 |
138
- |--------|------|----------|
139
- | finish | 完成所有步骤时触发 | `(formData: object)` |
140
- | change | 表单数据变化时触发 | `(formData: object)` |
141
- | step-change | 步骤变化时触发 | `({ current: number, step: StepConfig })` |
142
- | input | v-model 更新事件 | `(stepIndex: number)` |
143
- | update:current | .sync 更新事件 | `(stepIndex: number)` |
144
-
145
- ### Slots
146
-
147
- | 插槽名 | 说明 | 参数 |
148
- |--------|------|------|
149
- | [step.slot] | 自定义步骤内容 | `{ step, index, formData }` |
150
- | submitter | 自定义提交按钮 | `{ step, index, onPrevious, onNext, onFinish, submitting, validating }` |
151
- | default | 默认步骤内容 | `{ step, index, formData }` |
152
-
153
- ### Methods
154
-
155
- | 方法名 | 说明 | 参数 | 返回值 |
156
- |--------|------|------|--------|
157
- | goToStep | 跳转到指定步骤 | `(stepIndex: number)` | - |
158
- | reset | 重置表单 | - | - |
159
- | getFormData | 获取所有表单数据 | - | `object` |
160
- | setFormData | 设置表单数据 | `(data: object)` | - |
161
- | getFormMapRef | 获取表单实例映射 | - | `object` |
162
- | getStepFormRef | 获取指定步骤的表单实例 | `(stepIndex: number)` | `FormInstance \| null` |
163
- | validateAll | 验证所有步骤 | - | `Promise<boolean>` |
164
-
165
- ## 使用示例
166
-
167
- ### 基础分步表单
168
-
169
- ```vue
170
- <jh-steps-form
171
- :steps="steps"
172
- @finish="handleFinish"
173
- />
174
- ```
175
-
176
- ### 可编辑步骤
177
-
178
- 允许用户点击已完成的步骤返回修改:
179
-
180
- ```vue
181
- <jh-steps-form
182
- :steps="steps"
183
- editable
184
- @finish="handleFinish"
185
- />
186
- ```
187
-
188
- ### 垂直布局
189
-
190
- 适用于侧边栏或窄屏场景:
191
-
192
- ```vue
193
- <jh-steps-form
194
- :steps="steps"
195
- vertical
196
- @finish="handleFinish"
197
- />
198
- ```
199
-
200
- ### 自定义步骤内容
201
-
202
- 使用插槽自定义某个步骤的内容:
203
-
204
- ```vue
205
- <jh-steps-form :steps="steps" @finish="handleFinish">
206
- <template #step-custom="{ formData }">
207
- <v-card>
208
- <v-card-title>自定义内容</v-card-title>
209
- <v-card-text>
210
- <!-- 自定义内容 -->
211
- </v-card-text>
212
- </v-card>
213
- </template>
214
- </jh-steps-form>
215
- ```
216
-
217
- ### 自定义验证
218
-
219
- ```vue
220
- <jh-steps-form
221
- :steps="steps"
222
- :validate-step="validateStep"
223
- @finish="handleFinish"
224
- />
225
-
226
- <script>
227
- export default {
228
- methods: {
229
- async validateStep({ step, stepIndex, formData }) {
230
- // 自定义验证逻辑
231
- if (stepIndex === 0) {
232
- const username = formData.step0?.username;
233
- if (username === 'admin') {
234
- this.$message.error('用户名已存在');
235
- return false;
236
- }
237
- }
238
- return true;
239
- },
240
- },
241
- };
242
- </script>
243
- ```
244
-
245
- ### 数据转换
246
-
247
- 在提交前转换数据格式:
248
-
249
- ```vue
250
- <jh-steps-form
251
- :steps="steps"
252
- :transform-before-finish="transformData"
253
- @finish="handleFinish"
254
- />
255
-
256
- <script>
257
- export default {
258
- methods: {
259
- transformData(formData) {
260
- // 合并所有步骤数据
261
- return {
262
- ...formData.step0,
263
- ...formData.step1,
264
- ...formData.step2,
265
- };
266
- },
267
- },
268
- };
269
- </script>
270
- ```
271
-
272
- ### 自定义按钮
273
-
274
- ```vue
275
- <jh-steps-form
276
- :steps="steps"
277
- :submitter="{
278
- previousText: 'Back',
279
- nextText: 'Continue',
280
- submitText: 'Submit',
281
- previousButtonProps: { color: 'secondary' },
282
- nextButtonProps: { color: 'primary', large: true },
283
- }"
284
- @finish="handleFinish"
285
- />
286
- ```
287
-
288
- ### 隐藏按钮
289
-
290
- ```vue
291
- <jh-steps-form
292
- :steps="steps"
293
- :submitter="{ render: false }"
294
- @finish="handleFinish"
295
- />
296
- ```
297
-
298
- ### 使用 v-model 控制当前步骤
299
-
300
- ```vue
301
- <template>
302
- <div>
303
- <v-btn @click="currentStep = 0">跳转到第一步</v-btn>
304
- <jh-steps-form
305
- v-model="currentStep"
306
- :steps="steps"
307
- @finish="handleFinish"
308
- />
309
- </div>
310
- </template>
311
-
312
- <script>
313
- export default {
314
- data() {
315
- return {
316
- currentStep: 0,
317
- };
318
- },
319
- };
320
- </script>
321
- ```
322
-
323
- ### 访问表单实例
324
-
325
- ```vue
326
- <template>
327
- <div>
328
- <jh-steps-form
329
- ref="stepsForm"
330
- :steps="steps"
331
- @finish="handleFinish"
332
- />
333
- <v-btn @click="validateAllSteps">验证所有步骤</v-btn>
334
- </div>
335
- </template>
336
-
337
- <script>
338
- export default {
339
- methods: {
340
- async validateAllSteps() {
341
- const isValid = await this.$refs.stepsForm.validateAll();
342
- console.log('所有步骤验证结果:', isValid);
343
-
344
- // 获取表单实例映射
345
- const formMapRef = this.$refs.stepsForm.getFormMapRef();
346
- console.log('表单实例:', formMapRef);
347
-
348
- // 获取指定步骤的表单实例
349
- const step0Form = this.$refs.stepsForm.getStepFormRef(0);
350
- if (step0Form) {
351
- step0Form.validate();
352
- }
353
- },
354
- },
355
- };
356
- </script>
357
- ```
358
-
359
- ### 监听步骤变化
360
-
361
- ```vue
362
- <jh-steps-form
363
- :steps="steps"
364
- :on-current-change="handleStepChange"
365
- @finish="handleFinish"
366
- />
367
-
368
- <script>
369
- export default {
370
- methods: {
371
- handleStepChange(stepIndex) {
372
- console.log('当前步骤:', stepIndex);
373
- // 可以在这里做一些操作,比如埋点统计
374
- },
375
- },
376
- };
377
- </script>
378
- ```
379
-
380
- ### 监听表单字段变化
381
-
382
- ```vue
383
- <jh-steps-form
384
- :steps="steps"
385
- :on-form-change="handleFormChange"
386
- @finish="handleFinish"
387
- />
388
-
389
- <script>
390
- export default {
391
- methods: {
392
- handleFormChange({ stepIndex, values, allValues }) {
393
- console.log('步骤索引:', stepIndex);
394
- console.log('当前步骤值:', values);
395
- console.log('所有值:', allValues);
396
- },
397
- },
398
- };
399
- </script>
400
- ```
401
-
402
- ### 传递公共表单属性
403
-
404
- ```vue
405
- <jh-steps-form
406
- :steps="steps"
407
- :form-props="{
408
- outlined: true,
409
- dense: true,
410
- hideDetails: 'auto',
411
- }"
412
- @finish="handleFinish"
413
- />
414
- ```
415
-
416
- ### 自定义容器样式
417
-
418
- ```vue
419
- <jh-steps-form
420
- :steps="steps"
421
- :container-style="{
422
- maxWidth: '800px',
423
- margin: '0 auto',
424
- padding: '24px',
425
- }"
426
- @finish="handleFinish"
427
- />
428
- ```
429
-
430
- ## 完整示例:员工入职流程
431
-
432
- ```vue
433
- <template>
434
- <v-container>
435
- <jh-steps-form
436
- ref="employeeForm"
437
- v-model="currentStep"
438
- :steps="steps"
439
- editable
440
- :submitting="submitting"
441
- :validate-step="validateStep"
442
- :transform-before-finish="transformData"
443
- :on-current-change="handleStepChange"
444
- @finish="handleFinish"
445
- >
446
- <template #step-confirm="{ formData }">
447
- <v-card outlined>
448
- <v-card-title>请确认以下信息</v-card-title>
449
- <v-card-text>
450
- <v-simple-table>
451
- <tbody>
452
- <tr v-for="(value, key) in flattenData(formData)" :key="key">
453
- <td class="font-weight-bold">{{ key }}</td>
454
- <td>{{ value }}</td>
455
- </tr>
456
- </tbody>
457
- </v-simple-table>
458
- </v-card-text>
459
- </v-card>
460
- </template>
461
- </jh-steps-form>
462
- </v-container>
463
- </template>
464
-
465
- <script>
466
- export default {
467
- data() {
468
- return {
469
- currentStep: 0,
470
- submitting: false,
471
- steps: [
472
- {
473
- title: '基本信息',
474
- subTitle: '填写员工基本信息',
475
- fields: [
476
- {
477
- name: 'name',
478
- label: '姓名',
479
- type: 'text',
480
- required: true,
481
- cols: 12,
482
- md: 6,
483
- },
484
- {
485
- name: 'email',
486
- label: '邮箱',
487
- type: 'email',
488
- required: true,
489
- cols: 12,
490
- md: 6,
491
- },
492
- {
493
- name: 'phone',
494
- label: '手机号',
495
- type: 'tel',
496
- required: true,
497
- cols: 12,
498
- md: 6,
499
- },
500
- ],
501
- },
502
- {
503
- title: '岗位信息',
504
- subTitle: '设置员工岗位',
505
- fields: [
506
- {
507
- name: 'department',
508
- label: '部门',
509
- type: 'select',
510
- options: [
511
- { text: '技术部', value: 'tech' },
512
- { text: '产品部', value: 'product' },
513
- { text: '市场部', value: 'marketing' },
514
- ],
515
- required: true,
516
- cols: 12,
517
- md: 6,
518
- },
519
- {
520
- name: 'position',
521
- label: '职位',
522
- type: 'text',
523
- required: true,
524
- cols: 12,
525
- md: 6,
526
- },
527
- ],
528
- },
529
- {
530
- title: '确认信息',
531
- subTitle: '请确认填写的信息',
532
- slot: 'step-confirm',
533
- },
534
- ],
535
- };
536
- },
537
- methods: {
538
- async validateStep({ step, stepIndex, formData }) {
539
- // 自定义验证逻辑
540
- if (stepIndex === 0) {
541
- const email = formData.step0?.email;
542
- if (email && !email.includes('@company.com')) {
543
- this.$message.warning('请使用公司邮箱');
544
- return false;
545
- }
546
- }
547
- return true;
548
- },
549
-
550
- transformData(formData) {
551
- // 合并所有步骤数据
552
- return {
553
- ...formData.step0,
554
- ...formData.step1,
555
- };
556
- },
557
-
558
- handleStepChange(stepIndex) {
559
- console.log('切换到步骤:', stepIndex);
560
- // 埋点统计
561
- },
562
-
563
- async handleFinish(data) {
564
- this.submitting = true;
565
- try {
566
- // 提交数据到服务器
567
- await this.$api.createEmployee(data);
568
- this.$message.success('员工入职信息提交成功');
569
- this.$refs.employeeForm.reset();
570
- } catch (error) {
571
- this.$message.error('提交失败: ' + error.message);
572
- } finally {
573
- this.submitting = false;
574
- }
575
- },
576
-
577
- flattenData(formData) {
578
- const result = {};
579
- Object.values(formData).forEach(stepData => {
580
- Object.assign(result, stepData);
581
- });
582
- return result;
583
- },
584
- },
585
- };
586
- </script>
587
- ```
588
-
589
- ## 最佳实践
590
-
591
- ### 1. 步骤数量
592
-
593
- - 建议 3-5 个步骤,不宜过多
594
- - 每个步骤的字段数量控制在 5-10 个
595
-
596
- ### 2. 步骤命名
597
-
598
- - 使用清晰简洁的步骤标题
599
- - 提供副标题说明步骤目的
600
-
601
- ### 3. 表单验证
602
-
603
- - 每个步骤都应该有必要的验证
604
- - 使用 `validateStep` 进行自定义验证
605
- - 在下一步前验证当前步骤
606
-
607
- ### 4. 数据管理
608
-
609
- - 使用 `formData` 存储所有步骤数据
610
- - 使用 `transformBeforeFinish` 转换数据格式
611
- - 在最后一步展示确认信息
612
-
613
- ### 5. 用户体验
614
-
615
- - 开启 `editable` 允许用户返回修改
616
- - 提供清晰的步骤指示
617
- - 在提交时显示 loading 状态
618
-
619
- ## 注意事项
620
-
621
- 1. **步骤索引从 0 开始**
622
- 2. **表单数据按 `step${index}` 格式存储**
623
- 3. **使用 `slot` 时需要在步骤配置中指定 `slot` 属性**
624
- 4. **`validateStep` 返回 `false` 会阻止进入下一步**
625
- 5. **`submitter.render = false` 会完全隐藏按钮区域**
626
-
627
- ## 与 Ant Design ProComponents 的对应关系
628
-
629
- | ProComponents | JhStepsForm | 说明 |
630
- |---------------|-------------|------|
631
- | StepsForm | JhStepsForm | 主组件 |
632
- | StepForm | steps[].fields | 步骤配置 |
633
- | current | value / current | 当前步骤 |
634
- | onCurrentChange | onCurrentChange | 步骤变化回调 |
635
- | formMapRef | getFormMapRef() | 表单实例映射 |
636
- | stepsProps | stepsProps | Steps 属性 |
637
- | formProps | formProps | 表单公共属性 |
638
- | submitter | submitter | 提交按钮配置 |
639
- | onFinish | @finish | 完成事件 |
640
-
641
- ## 更新日志
642
-
643
- ### v1.1.0 (2024-11-09)
644
-
645
- **新增功能**
646
- - ✨ 新增 `formMapRef` 表单实例管理
647
- - ✨ 新增 `onCurrentChange` 步骤变化回调
648
- - ✨ 新增 `onFormChange` 表单字段变化回调
649
- - ✨ 新增 `stepsProps` 传递给 v-stepper 的属性
650
- - ✨ 新增 `formProps` 传递给所有表单的公共属性
651
- - ✨ 新增 `submitter` 提交按钮配置
652
- - ✨ 新增 `containerStyle` 容器样式配置
653
- - ✨ 新增 `current` prop 支持 .sync 修饰符
654
- - ✨ 新增 `getFormMapRef()` 方法
655
- - ✨ 新增 `getStepFormRef(index)` 方法
656
- - ✨ 新增 `validateAll()` 方法
657
-
658
- **优化改进**
659
- - 🎨 优化步骤切换逻辑,支持 v-model 和 .sync
660
- - 🎨 优化表单实例管理,自动维护 formMapRef
661
- - 🎨 优化按钮配置,支持更灵活的自定义
662
- - 📝 完善文档和示例
663
-
664
- ### v1.0.0
665
-
666
- - 🎉 初始版本发布