jianghu-ui 1.0.6 → 1.0.8

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 (49) hide show
  1. package/dist/jianghu-ui.css +195 -132
  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/JhDrawer/JhDrawer.vue +7 -1
  6. package/src/components/JhDrawerForm/JhDrawerForm.stories.js +161 -0
  7. package/src/components/JhDrawerForm/JhDrawerForm.vue +1 -1
  8. package/src/components/JhForm/JhForm.stories.js +114 -95
  9. package/src/components/JhForm/JhForm.vue +896 -205
  10. package/src/components/JhFormFields/JhFormFields.vue +42 -16
  11. package/src/components/JhModal/JhModal.stories.js +6 -6
  12. package/src/components/JhModal/JhModal.vue +1 -1
  13. package/src/components/JhModalForm/JhModalForm.vue +1 -1
  14. package/src/components/JhTable/JhTable.stories.js +134 -167
  15. package/src/components/JhTable/JhTable.vue +83 -23
  16. package/src/style/globalCSSVuetifyV4.css +1 -2
  17. package/src/components/JhAddressSelect/JhAddressSelect.md +0 -267
  18. package/src/components/JhCard/JhCard.md +0 -246
  19. package/src/components/JhCheckCard/JhCheckCard.md +0 -245
  20. package/src/components/JhConfirmDialog/JhConfirmDialog.md +0 -70
  21. package/src/components/JhDateRangePicker/JhDateRangePicker.md +0 -56
  22. package/src/components/JhDescriptions/JhDescriptions.md +0 -724
  23. package/src/components/JhDraggable/JhDraggable.md +0 -66
  24. package/src/components/JhDrawer/JhDrawer.md +0 -68
  25. package/src/components/JhDrawerForm/JhDrawerForm.md +0 -69
  26. package/src/components/JhEditableTable/JhEditableTable.md +0 -507
  27. package/src/components/JhFileInput/JhFileInput.md +0 -56
  28. package/src/components/JhForm/JhForm.md +0 -676
  29. package/src/components/JhFormFields/JhFormFields.md +0 -647
  30. package/src/components/JhFormList/JhFormList.md +0 -303
  31. package/src/components/JhJsonEditor/JhJsonEditor.md +0 -54
  32. package/src/components/JhLayout/JhLayout.md +0 -580
  33. package/src/components/JhList/JhList.md +0 -441
  34. package/src/components/JhMarkdownEditor/JhMarkdownEditor.md +0 -56
  35. package/src/components/JhMask/JhMask.md +0 -62
  36. package/src/components/JhMenu/JhMenu.md +0 -85
  37. package/src/components/JhModal/JhModal.md +0 -68
  38. package/src/components/JhModalForm/JhModalForm.md +0 -69
  39. package/src/components/JhPageContainer/JhPageContainer.md +0 -409
  40. package/src/components/JhQueryFilter/JhQueryFilter.md +0 -77
  41. package/src/components/JhScene/JhScene.md +0 -64
  42. package/src/components/JhStatisticCard/JhStatisticCard.md +0 -363
  43. package/src/components/JhStepsForm/JhStepsForm.md +0 -666
  44. package/src/components/JhTable/JhTable.md +0 -730
  45. package/src/components/JhTableAttachment/JhTableAttachment.md +0 -70
  46. package/src/components/JhToast/JhToast.md +0 -67
  47. package/src/components/JhTreeSelect/JhTreeSelect.md +0 -82
  48. package/src/components/JhWaterMark/JhWaterMark.md +0 -190
  49. package/src/components/README.md +0 -52
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jianghu-ui",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "JianghuJS UI Component Library with Storybook, Vue 2, and Vuetify 2",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -115,7 +115,7 @@ export default {
115
115
  };
116
116
 
117
117
  // 基础用法
118
- export const Basic = {
118
+ export const 基础用法 = {
119
119
  render: (args) => ({
120
120
  components: { JhDrawer },
121
121
  data() {
@@ -188,7 +188,7 @@ export const Basic = {
188
188
  };
189
189
 
190
190
  // 左侧抽屉
191
- export const LeftDrawer = {
191
+ export const 左侧抽屉 = {
192
192
  render: (args) => ({
193
193
  components: { JhDrawer },
194
194
  data() {
@@ -230,7 +230,7 @@ export const LeftDrawer = {
230
230
  };
231
231
 
232
232
  // 底部抽屉
233
- export const BottomDrawer = {
233
+ export const 底部抽屉 = {
234
234
  render: (args) => ({
235
235
  components: { JhDrawer },
236
236
  data() {
@@ -282,7 +282,7 @@ export const BottomDrawer = {
282
282
  };
283
283
 
284
284
  // 自定义操作按钮
285
- export const CustomActions = {
285
+ export const 自定义操作按钮 = {
286
286
  render: (args) => ({
287
287
  components: { JhDrawer },
288
288
  data() {
@@ -369,7 +369,7 @@ export const CustomActions = {
369
369
  };
370
370
 
371
371
  // 无按钮抽屉
372
- export const NoButtons = {
372
+ export const 无按钮抽屉 = {
373
373
  render: (args) => ({
374
374
  components: { JhDrawer },
375
375
  data() {
@@ -416,7 +416,7 @@ export const NoButtons = {
416
416
  };
417
417
 
418
418
  // 宽度配置
419
- export const WidthConfig = {
419
+ export const 宽度配置 = {
420
420
  render: (args) => ({
421
421
  components: { JhDrawer },
422
422
  data() {
@@ -49,7 +49,7 @@
49
49
  <v-divider class="jh-divider"></v-divider>
50
50
 
51
51
  <!-- 抽屉内容 -->
52
- <div class="pa-4">
52
+ <div :class="drawerContentClass">
53
53
  <!-- 完全自定义内容插槽 -->
54
54
  <slot></slot>
55
55
  </div>
@@ -131,6 +131,12 @@ export default {
131
131
  type: String,
132
132
  default: '取消'
133
133
  },
134
+
135
+ // 抽屉内容class
136
+ drawerContentClass: {
137
+ type: String,
138
+ default: 'pa-4',
139
+ },
134
140
  },
135
141
 
136
142
  data() {
@@ -490,3 +490,164 @@ export const 自定义验证 = {
490
490
  },
491
491
  }),
492
492
  };
493
+
494
+ // 初始化表单数据
495
+ export const 初始化表单数据 = {
496
+ render: () => ({
497
+ components: { JhDrawerForm },
498
+ data() {
499
+ return {
500
+ visible: false,
501
+ fields: [
502
+ {
503
+ key: 'username',
504
+ label: '用户名',
505
+ type: 'text',
506
+ rules: 'require',
507
+ placeholder: '请输入用户名',
508
+ cols: 12,
509
+ },
510
+ {
511
+ key: 'email',
512
+ label: '邮箱',
513
+ type: 'text',
514
+ rules: 'require|email',
515
+ placeholder: '请输入邮箱',
516
+ cols: 12,
517
+ },
518
+ {
519
+ key: 'phone',
520
+ label: '手机号',
521
+ type: 'text',
522
+ rules: 'phone',
523
+ placeholder: '请输入手机号',
524
+ cols: 12,
525
+ },
526
+ {
527
+ key: 'role',
528
+ label: '角色',
529
+ type: 'select',
530
+ rules: 'require',
531
+ options: [
532
+ { text: '管理员', value: 'admin' },
533
+ { text: '普通用户', value: 'user' },
534
+ { text: '访客', value: 'guest' },
535
+ ],
536
+ cols: 12,
537
+ },
538
+ ],
539
+ initialData: {
540
+ username: '默认用户名',
541
+ email: 'default@example.com',
542
+ phone: '13800138000',
543
+ role: 'user',
544
+ },
545
+ };
546
+ },
547
+ template: `
548
+ <div>
549
+ <v-btn color="primary" @click="visible = true">
550
+ 打开表单(带初始数据)
551
+ </v-btn>
552
+ <jh-drawer-form
553
+ v-model="visible"
554
+ title="用户信息"
555
+ :fields="fields"
556
+ :initial-data="initialData"
557
+ @confirm="handleConfirm"
558
+ />
559
+ </div>
560
+ `,
561
+ methods: {
562
+ handleConfirm(data) {
563
+ console.log('表单数据:', data);
564
+ alert('提交成功!\n' + JSON.stringify(data, null, 2));
565
+ this.visible = false;
566
+ },
567
+ },
568
+ }),
569
+ };
570
+
571
+ // 异步填充数据
572
+ export const 异步填充数据 = {
573
+ render: () => ({
574
+ components: { JhDrawerForm },
575
+ data() {
576
+ return {
577
+ visible: false,
578
+ fields: [
579
+ {
580
+ key: 'userId',
581
+ label: '用户ID',
582
+ type: 'text',
583
+ rules: 'require',
584
+ placeholder: '请输入用户ID',
585
+ cols: 12,
586
+ },
587
+ {
588
+ key: 'username',
589
+ label: '用户名',
590
+ type: 'text',
591
+ rules: 'require',
592
+ placeholder: '请输入用户名',
593
+ cols: 12,
594
+ },
595
+ {
596
+ key: 'email',
597
+ label: '邮箱',
598
+ type: 'text',
599
+ rules: 'require|email',
600
+ placeholder: '请输入邮箱',
601
+ cols: 12,
602
+ },
603
+ {
604
+ key: 'phone',
605
+ label: '手机号',
606
+ type: 'text',
607
+ rules: 'phone',
608
+ placeholder: '请输入手机号',
609
+ cols: 12,
610
+ },
611
+ ],
612
+ };
613
+ },
614
+ template: `
615
+ <div>
616
+ <v-btn color="primary" @click="openDrawer">
617
+ 打开表单(异步填充数据)
618
+ </v-btn>
619
+ <jh-drawer-form
620
+ ref="drawerForm"
621
+ v-model="visible"
622
+ title="用户信息"
623
+ :fields="fields"
624
+ @confirm="handleConfirm"
625
+ />
626
+ </div>
627
+ `,
628
+ methods: {
629
+ // 打开抽屉并异步填充数据
630
+ openDrawer() {
631
+ this.visible = true;
632
+
633
+ // 模拟异步请求获取数据
634
+ setTimeout(() => {
635
+ // 等待抽屉完全打开后设置数据
636
+ this.$nextTick(() => {
637
+ this.$refs.drawerForm.setFieldsValue({
638
+ userId: '1001',
639
+ username: '异步获取的用户名',
640
+ email: 'async@example.com',
641
+ phone: '13900139000',
642
+ });
643
+ });
644
+ }, 1000); // 模拟1秒的网络延迟
645
+ },
646
+ handleConfirm(data) {
647
+ console.log('表单数据:', data);
648
+ alert('提交成功!\n' + JSON.stringify(data, null, 2));
649
+ this.visible = false;
650
+ },
651
+ },
652
+ }),
653
+ };
@@ -9,7 +9,7 @@
9
9
  class="elevation-24"
10
10
  >
11
11
  <!-- 抽屉标题 -->
12
- <v-row class="jh-drawer-header px-4 bg-white" no-gutters align="center">
12
+ <v-row class="jh-drawer-header px-4 bg-white sticky top-0 z-10" no-gutters align="center">
13
13
  <span class="text-h7 font-weight-bold py-4">{{ title }}</span>
14
14
  <v-spacer></v-spacer>
15
15
 
@@ -301,8 +301,8 @@ export const Grid栅格布局 = {
301
301
  template: `
302
302
  <JhForm v-bind="args">
303
303
  <template #actions="{ validate, resetForm }">
304
- <v-btn class="mr-2" text @click="resetForm">重置</v-btn>
305
- <v-btn color="primary" @click="validate">提交</v-btn>
304
+ <v-btn class="mr-2 mt-4" text @click="resetForm">重置</v-btn>
305
+ <v-btn color="primary mt-4" @click="validate">提交</v-btn>
306
306
  </template>
307
307
  </JhForm>
308
308
  `,
@@ -656,8 +656,8 @@ export const 行内布局 = {
656
656
  <div>
657
657
  <JhForm v-bind="args">
658
658
  <template #actions="{ validate, resetForm }">
659
- <v-btn color="primary" class="ml-2" @click="validate">查询</v-btn>
660
- <v-btn text class="ml-2" @click="resetForm">重置</v-btn>
659
+ <v-btn color="primary" class="ml-2 mt-4" @click="validate">查询</v-btn>
660
+ <v-btn text class="ml-2 mt-4" @click="resetForm">重置</v-btn>
661
661
  </template>
662
662
  </JhForm>
663
663
  </div>
@@ -1059,97 +1059,6 @@ export const 数据转换 = {
1059
1059
  }),
1060
1060
  };
1061
1061
 
1062
- // onFinish 回调示例
1063
- export const 提交回调 = {
1064
- args: {
1065
- fields: [
1066
- {
1067
- key: 'title',
1068
- label: '标题',
1069
- type: 'text',
1070
- placeholder: '请输入标题',
1071
- required: true,
1072
- },
1073
- {
1074
- key: 'content',
1075
- label: '内容',
1076
- type: 'textarea',
1077
- placeholder: '请输入内容',
1078
- required: true,
1079
- rows: 4,
1080
- cols: { md: 12 },
1081
- },
1082
- ],
1083
- initialData: {
1084
- title: '',
1085
- content: '',
1086
- },
1087
- },
1088
- render: (args) => ({
1089
- components: { JhForm },
1090
- data() {
1091
- return {
1092
- args: {
1093
- ...args,
1094
- onFinish: this.handleFinish,
1095
- onFinishFailed: this.handleFinishFailed,
1096
- },
1097
- loading: false,
1098
- };
1099
- },
1100
- template: `
1101
- <div>
1102
- <JhForm v-bind="args">
1103
- <template #actions="{ validate, resetForm }">
1104
- <v-row class="mt-4">
1105
- <v-col cols="12" class="text-right">
1106
- <v-btn class="mr-2" @click="resetForm" :disabled="loading">重置</v-btn>
1107
- <v-btn
1108
- color="success"
1109
- @click="validate"
1110
- :loading="loading"
1111
- >
1112
- 提交
1113
- </v-btn>
1114
- </v-col>
1115
- </v-row>
1116
- </template>
1117
- </JhForm>
1118
- <v-alert v-if="submitResult" :type="submitResult.type" class="mt-4">
1119
- {{ submitResult.message }}
1120
- </v-alert>
1121
- </div>
1122
- `,
1123
- data() {
1124
- return {
1125
- submitResult: null,
1126
- };
1127
- },
1128
- methods: {
1129
- async handleFinish(values) {
1130
- this.loading = true;
1131
- this.submitResult = null;
1132
-
1133
- // 模拟 API 调用
1134
- await new Promise(resolve => setTimeout(resolve, 1500));
1135
-
1136
- console.log('提交成功:', values);
1137
- this.submitResult = {
1138
- type: 'success',
1139
- message: '提交成功! 数据: ' + JSON.stringify(values),
1140
- };
1141
- this.loading = false;
1142
- },
1143
- handleFinishFailed(values) {
1144
- console.log('验证失败:', values);
1145
- this.submitResult = {
1146
- type: 'error',
1147
- message: '表单验证失败,请检查必填项',
1148
- };
1149
- },
1150
- },
1151
- }),
1152
- };
1153
1062
 
1154
1063
  // 只读模式示例
1155
1064
  export const 只读模式 = {
@@ -1227,6 +1136,116 @@ export const 只读模式 = {
1227
1136
  },
1228
1137
  };
1229
1138
 
1139
+ // 增强版提交功能示例
1140
+ export const 增强版提交功能 = {
1141
+ args: {
1142
+ fields: [
1143
+ {
1144
+ key: 'name',
1145
+ label: '姓名',
1146
+ type: 'text',
1147
+ placeholder: '请输入姓名',
1148
+ required: true,
1149
+ cols: { md: 6 },
1150
+ },
1151
+ {
1152
+ key: 'email',
1153
+ label: '邮箱',
1154
+ type: 'text',
1155
+ placeholder: '请输入邮箱',
1156
+ rules: 'email',
1157
+ required: true,
1158
+ cols: { md: 6 },
1159
+ },
1160
+ {
1161
+ key: 'phone',
1162
+ label: '手机号',
1163
+ type: 'text',
1164
+ placeholder: '请输入手机号',
1165
+ rules: 'phone',
1166
+ required: true,
1167
+ cols: { md: 12 },
1168
+ },
1169
+ ],
1170
+ },
1171
+ render: (args) => ({
1172
+ components: { JhForm },
1173
+ data() {
1174
+ return {
1175
+ args,
1176
+ submitResult: null,
1177
+ };
1178
+ },
1179
+ template: `
1180
+ <div>
1181
+ <JhForm v-bind="args" ref="form" @submit-error="handleSubmitError">
1182
+ <template #actions="{ validate, resetForm }">
1183
+ <v-row class="mt-4">
1184
+ <v-col cols="12" class="text-right">
1185
+ <v-btn class="mr-2" @click="resetForm">重置</v-btn>
1186
+ <v-btn
1187
+ color="success"
1188
+ @click="handleSubmit"
1189
+ :loading="$refs.form?.submitLoading"
1190
+ >
1191
+ 提交(增强版)
1192
+ </v-btn>
1193
+ </v-col>
1194
+ </v-row>
1195
+ </template>
1196
+ </JhForm>
1197
+ <v-alert
1198
+ v-if="submitResult"
1199
+ :type="submitResult.type"
1200
+ class="mt-4"
1201
+ >
1202
+ {{ submitResult.message }}
1203
+ </v-alert>
1204
+ <v-alert
1205
+ v-if="$refs.form?.submitError"
1206
+ type="error"
1207
+ class="mt-4"
1208
+ >
1209
+ 提交错误: {{ $refs.form.submitError }}
1210
+ </v-alert>
1211
+ <div class="mt-4">
1212
+ <v-btn text @click="showFormState">查看表单状态</v-btn>
1213
+ </div>
1214
+ </div>
1215
+ `,
1216
+ methods: {
1217
+ async handleSubmit() {
1218
+ this.submitResult = null;
1219
+
1220
+ const result = await this.$refs.form.submit({
1221
+ showLoading: true,
1222
+ resetError: true
1223
+ });
1224
+
1225
+ if (result) {
1226
+ this.submitResult = {
1227
+ type: 'success',
1228
+ message: '提交成功!',
1229
+ };
1230
+ } else {
1231
+ this.submitResult = {
1232
+ type: 'error',
1233
+ message: '提交失败,请检查表单',
1234
+ };
1235
+ }
1236
+ },
1237
+ handleSubmitError(error) {
1238
+ console.error('提交错误:', error);
1239
+ },
1240
+ showFormState() {
1241
+ const state = this.$refs.form.getFormState();
1242
+ console.log('表单状态:', state);
1243
+ alert('表单状态已打印到控制台,请查看');
1244
+ },
1245
+ },
1246
+ }),
1247
+ };
1248
+
1230
1249
  // 使用 JhFormFields 组合表单
1231
1250
  export const 使用JhFormFields组合 = () => ({
1232
1251
  components: { JhFormFields },