jianghu-ui 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +376 -0
  2. package/dist/jianghu-ui.css +2318 -0
  3. package/dist/jianghu-ui.js +2 -0
  4. package/dist/jianghu-ui.js.LICENSE.txt +1 -0
  5. package/package.json +56 -0
  6. package/src/Design.stories.mdx +195 -0
  7. package/src/Introduction.stories.mdx +148 -0
  8. package/src/components/JhAddressSelect/JhAddressSelect.md +250 -0
  9. package/src/components/JhAddressSelect/JhAddressSelect.stories.js +282 -0
  10. package/src/components/JhAddressSelect/JhAddressSelect.vue +261 -0
  11. package/src/components/JhCard/JhCard.md +246 -0
  12. package/src/components/JhCard/JhCard.stories.js +688 -0
  13. package/src/components/JhCard/JhCard.vue +604 -0
  14. package/src/components/JhCheckCard/JhCheckCard.md +245 -0
  15. package/src/components/JhCheckCard/JhCheckCard.stories.js +750 -0
  16. package/src/components/JhCheckCard/JhCheckCard.vue +476 -0
  17. package/src/components/JhConfirmDialog/JhConfirmDialog.md +70 -0
  18. package/src/components/JhConfirmDialog/JhConfirmDialog.stories.js +550 -0
  19. package/src/components/JhConfirmDialog/JhConfirmDialog.vue +181 -0
  20. package/src/components/JhDateRangePicker/JhDateRangePicker.md +56 -0
  21. package/src/components/JhDateRangePicker/JhDateRangePicker.stories.js +320 -0
  22. package/src/components/JhDateRangePicker/JhDateRangePicker.vue +307 -0
  23. package/src/components/JhDescriptions/JhDescriptions.md +724 -0
  24. package/src/components/JhDescriptions/JhDescriptions.stories.js +858 -0
  25. package/src/components/JhDescriptions/JhDescriptions.vue +933 -0
  26. package/src/components/JhDraggable/JhDraggable.md +66 -0
  27. package/src/components/JhDraggable/JhDraggable.stories.js +161 -0
  28. package/src/components/JhDraggable/JhDraggable.vue +254 -0
  29. package/src/components/JhDrawer/JhDrawer.md +68 -0
  30. package/src/components/JhDrawer/JhDrawer.stories.js +478 -0
  31. package/src/components/JhDrawer/JhDrawer.vue +281 -0
  32. package/src/components/JhDrawerForm/JhDrawerForm.md +69 -0
  33. package/src/components/JhDrawerForm/JhDrawerForm.stories.js +492 -0
  34. package/src/components/JhDrawerForm/JhDrawerForm.vue +297 -0
  35. package/src/components/JhEditableTable/JhEditableTable.md +507 -0
  36. package/src/components/JhEditableTable/JhEditableTable.stories.js +615 -0
  37. package/src/components/JhEditableTable/JhEditableTable.vue +685 -0
  38. package/src/components/JhFileInput/JhFileInput.md +56 -0
  39. package/src/components/JhFileInput/JhFileInput.stories.js +103 -0
  40. package/src/components/JhFileInput/JhFileInput.vue +253 -0
  41. package/src/components/JhForm/JhForm.md +676 -0
  42. package/src/components/JhForm/JhForm.stories.js +1375 -0
  43. package/src/components/JhForm/JhForm.vue +657 -0
  44. package/src/components/JhFormField/JhFormField.stories.js +217 -0
  45. package/src/components/JhFormField/JhFormField.vue +439 -0
  46. package/src/components/JhFormFields/JhFormFields.md +647 -0
  47. package/src/components/JhFormFields/JhFormFields.stories.js +922 -0
  48. package/src/components/JhFormFields/JhFormFields.vue +998 -0
  49. package/src/components/JhFormList/JhFormList.md +303 -0
  50. package/src/components/JhFormList/JhFormList.stories.js +661 -0
  51. package/src/components/JhFormList/JhFormList.vue +1127 -0
  52. package/src/components/JhJsonEditor/JhJsonEditor.md +54 -0
  53. package/src/components/JhJsonEditor/JhJsonEditor.stories.js +157 -0
  54. package/src/components/JhJsonEditor/JhJsonEditor.vue +178 -0
  55. package/src/components/JhLayout/JhLayout.md +580 -0
  56. package/src/components/JhLayout/JhLayout.stories.js +414 -0
  57. package/src/components/JhLayout/JhLayout.vue +387 -0
  58. package/src/components/JhList/JhList.md +441 -0
  59. package/src/components/JhList/JhList.stories.js +524 -0
  60. package/src/components/JhList/JhList.vue +571 -0
  61. package/src/components/JhMarkdownEditor/JhMarkdownEditor.md +56 -0
  62. package/src/components/JhMarkdownEditor/JhMarkdownEditor.stories.js +191 -0
  63. package/src/components/JhMarkdownEditor/JhMarkdownEditor.vue +188 -0
  64. package/src/components/JhMask/JhMask.md +62 -0
  65. package/src/components/JhMask/JhMask.stories.js +270 -0
  66. package/src/components/JhMask/JhMask.vue +123 -0
  67. package/src/components/JhMenu/JhMenu.md +85 -0
  68. package/src/components/JhMenu/JhMenu.stories.js +384 -0
  69. package/src/components/JhMenu/JhMenu.vue +545 -0
  70. package/src/components/JhModal/JhModal.md +68 -0
  71. package/src/components/JhModal/JhModal.stories.js +562 -0
  72. package/src/components/JhModal/JhModal.vue +235 -0
  73. package/src/components/JhModalForm/JhModalForm.md +69 -0
  74. package/src/components/JhModalForm/JhModalForm.stories.js +592 -0
  75. package/src/components/JhModalForm/JhModalForm.vue +298 -0
  76. package/src/components/JhPageContainer/JhPageContainer.md +409 -0
  77. package/src/components/JhPageContainer/JhPageContainer.stories.js +209 -0
  78. package/src/components/JhPageContainer/JhPageContainer.vue +72 -0
  79. package/src/components/JhQueryFilter/JhQueryFilter.md +77 -0
  80. package/src/components/JhQueryFilter/JhQueryFilter.stories.js +684 -0
  81. package/src/components/JhQueryFilter/JhQueryFilter.vue +429 -0
  82. package/src/components/JhScene/JhScene.md +64 -0
  83. package/src/components/JhScene/JhScene.stories.js +317 -0
  84. package/src/components/JhScene/JhScene.vue +376 -0
  85. package/src/components/JhStatisticCard/JhStatisticCard.md +363 -0
  86. package/src/components/JhStatisticCard/JhStatisticCard.stories.js +847 -0
  87. package/src/components/JhStatisticCard/JhStatisticCard.vue +459 -0
  88. package/src/components/JhStepsForm/JhStepsForm.md +666 -0
  89. package/src/components/JhStepsForm/JhStepsForm.stories.js +1224 -0
  90. package/src/components/JhStepsForm/JhStepsForm.vue +749 -0
  91. package/src/components/JhTable/JhTable.md +730 -0
  92. package/src/components/JhTable/JhTable.stories.js +1444 -0
  93. package/src/components/JhTable/JhTable.vue +2298 -0
  94. package/src/components/JhTableAttachment/JhTableAttachment.md +70 -0
  95. package/src/components/JhTableAttachment/JhTableAttachment.stories.js +198 -0
  96. package/src/components/JhTableAttachment/JhTableAttachment.vue +264 -0
  97. package/src/components/JhToast/JhToast.md +67 -0
  98. package/src/components/JhToast/JhToast.stories.js +386 -0
  99. package/src/components/JhToast/JhToast.vue +239 -0
  100. package/src/components/JhTreeSelect/JhTreeSelect.md +82 -0
  101. package/src/components/JhTreeSelect/JhTreeSelect.stories.js +391 -0
  102. package/src/components/JhTreeSelect/JhTreeSelect.vue +727 -0
  103. package/src/components/JhWaterMark/JhWaterMark.md +190 -0
  104. package/src/components/JhWaterMark/JhWaterMark.stories.js +675 -0
  105. package/src/components/JhWaterMark/JhWaterMark.vue +351 -0
  106. package/src/components/README.md +52 -0
  107. package/src/index.js +135 -0
  108. package/src/style/globalCSSJHV4.css +348 -0
  109. package/src/style/globalCSSVuetifyV4.css +637 -0
  110. package/src/style/storybook.css +4 -0
  111. package/src/tailwind.css +3 -0
  112. package/src/utils/vuetify.js +31 -0
@@ -0,0 +1,615 @@
1
+ import JhEditableTable from './JhEditableTable.vue';
2
+
3
+ export default {
4
+ title: '数据展示/JhEditableTable - 可编辑表格',
5
+ component: JhEditableTable,
6
+ tags: ['autodocs'],
7
+ argTypes: {
8
+ value: {
9
+ control: 'object',
10
+ description: '表格数据(v-model)',
11
+ table: {
12
+ type: { summary: 'Array' },
13
+ category: 'Props',
14
+ },
15
+ },
16
+ columns: {
17
+ control: 'object',
18
+ description: '列配置数组',
19
+ table: {
20
+ type: { summary: 'Array<Column>' },
21
+ category: 'Props',
22
+ },
23
+ },
24
+ editable: {
25
+ control: 'boolean',
26
+ description: '是否可编辑',
27
+ table: {
28
+ type: { summary: 'boolean' },
29
+ defaultValue: { summary: 'true' },
30
+ category: 'Props',
31
+ },
32
+ },
33
+ deletable: {
34
+ control: 'boolean',
35
+ description: '是否可删除',
36
+ table: {
37
+ type: { summary: 'boolean' },
38
+ defaultValue: { summary: 'true' },
39
+ category: 'Props',
40
+ },
41
+ },
42
+ recordCreator: {
43
+ control: 'boolean',
44
+ description: '是否显示新增按钮',
45
+ table: {
46
+ type: { summary: 'boolean' },
47
+ defaultValue: { summary: 'true' },
48
+ category: 'Props',
49
+ },
50
+ },
51
+ dense: {
52
+ control: 'boolean',
53
+ description: '紧凑模式',
54
+ table: {
55
+ type: { summary: 'boolean' },
56
+ category: 'Props',
57
+ },
58
+ },
59
+ onSave: {
60
+ action: 'save',
61
+ description: '保存行时触发',
62
+ table: {
63
+ category: 'Events',
64
+ },
65
+ },
66
+ onDelete: {
67
+ action: 'delete',
68
+ description: '删除行时触发',
69
+ table: {
70
+ category: 'Events',
71
+ },
72
+ },
73
+ onChange: {
74
+ action: 'change',
75
+ description: '数据变化时触发',
76
+ table: {
77
+ category: 'Events',
78
+ },
79
+ },
80
+ },
81
+ parameters: {
82
+ docs: {
83
+ description: {
84
+ component: `
85
+
86
+ 可编辑表格组件,支持行内编辑、新增、删除等操作,参考 Ant Design Pro 的 EditableProTable 设计。
87
+
88
+ ## 核心特性
89
+
90
+ - ✅ **行编辑模式**:点击编辑按钮整行进入编辑状态
91
+ - ✅ **新增/删除行**:支持动态添加和删除数据行
92
+ - ✅ **内联验证**:编辑时实时验证字段规则
93
+ - ✅ **操作列**:编辑、保存、取消、删除按钮
94
+ - ✅ **多种字段类型**:text、number、select、date、switch、enum
95
+ - ✅ **数据绑定**:v-model 双向绑定
96
+ - ✅ **自定义渲染**:支持通过 slot 自定义单元格和操作列
97
+
98
+ ## 使用场景
99
+
100
+ - 配置管理界面
101
+ - 表单数据批量录入
102
+ - 动态列表编辑
103
+ - 权限配置表格
104
+ - 商品/订单管理
105
+
106
+ ## Column 配置说明
107
+
108
+ \`\`\`javascript
109
+ {
110
+ key: 'name', // 字段名(必填)
111
+ label: '姓名', // 列标题(必填)
112
+ type: 'text', // 字段类型:text | number | select | date | switch | enum
113
+ editable: true, // 是否可编辑(默认 true)
114
+ rules: [], // 验证规则数组
115
+ options: [], // select 类型的选项
116
+ enum: {}, // enum 类型的映射 { value: { text, color } }
117
+ placeholder: '', // 占位符
118
+ width: 150, // 列宽度
119
+ sortable: false, // 是否可排序
120
+ }
121
+ \`\`\`
122
+ `,
123
+ },
124
+ },
125
+ },
126
+ };
127
+
128
+ // Story 1: 基础示例
129
+ export const 基础示例 = {
130
+ render: (args) => ({
131
+ components: { JhEditableTable },
132
+ data() {
133
+ return {
134
+ tableData: [
135
+ { id: 1, name: '张三', age: 28, email: 'zhangsan@example.com', city: '北京' },
136
+ { id: 2, name: '李四', age: 32, email: 'lisi@example.com', city: '上海' },
137
+ { id: 3, name: '王五', age: 25, email: 'wangwu@example.com', city: '广州' },
138
+ ],
139
+ columns: [
140
+ {
141
+ key: 'name',
142
+ label: '姓名',
143
+ type: 'text',
144
+ rules: [(v) => !!v || '姓名不能为空'],
145
+ },
146
+ {
147
+ key: 'age',
148
+ label: '年龄',
149
+ type: 'number',
150
+ rules: [(v) => (v > 0 && v < 150) || '请输入有效年龄'],
151
+ },
152
+ {
153
+ key: 'email',
154
+ label: '邮箱',
155
+ type: 'text',
156
+ rules: [
157
+ (v) => !!v || '邮箱不能为空',
158
+ (v) => /.+@.+\..+/.test(v) || '请输入有效邮箱',
159
+ ],
160
+ },
161
+ {
162
+ key: 'city',
163
+ label: '城市',
164
+ type: 'select',
165
+ options: ['北京', '上海', '广州', '深圳', '杭州'],
166
+ },
167
+ ],
168
+ };
169
+ },
170
+ template: `
171
+ <div class="pa-4">
172
+ <h3 class="mb-4">基础可编辑表格</h3>
173
+ <JhEditableTable
174
+ v-model="tableData"
175
+ :columns="columns"
176
+ />
177
+ <div class="mt-4">
178
+ <h4>当前数据:</h4>
179
+ <pre>{{ tableData }}</pre>
180
+ </div>
181
+ </div>
182
+ `,
183
+ }),
184
+ parameters: {
185
+ docs: {
186
+ description: {
187
+ story: '展示基本的可编辑表格功能,支持文本、数字、邮箱、下拉选择等字段类型。',
188
+ },
189
+ },
190
+ },
191
+ };
192
+
193
+ // Story 2: 多种字段类型
194
+ export const 多种字段类型 = {
195
+ render: () => ({
196
+ components: { JhEditableTable },
197
+ data() {
198
+ return {
199
+ tableData: [
200
+ {
201
+ id: 1,
202
+ name: '产品A',
203
+ price: 99.99,
204
+ category: 'electronics',
205
+ status: 'active',
206
+ inStock: true,
207
+ releaseDate: '2024-01-15',
208
+ },
209
+ {
210
+ id: 2,
211
+ name: '产品B',
212
+ price: 199.99,
213
+ category: 'clothing',
214
+ status: 'inactive',
215
+ inStock: false,
216
+ releaseDate: '2024-02-20',
217
+ },
218
+ ],
219
+ columns: [
220
+ {
221
+ key: 'name',
222
+ label: '产品名称',
223
+ type: 'text',
224
+ rules: [(v) => !!v || '必填'],
225
+ },
226
+ {
227
+ key: 'price',
228
+ label: '价格',
229
+ type: 'number',
230
+ rules: [(v) => v > 0 || '价格必须大于0'],
231
+ },
232
+ {
233
+ key: 'category',
234
+ label: '分类',
235
+ type: 'select',
236
+ options: [
237
+ { text: '电子产品', value: 'electronics' },
238
+ { text: '服装', value: 'clothing' },
239
+ { text: '食品', value: 'food' },
240
+ { text: '图书', value: 'books' },
241
+ ],
242
+ },
243
+ {
244
+ key: 'status',
245
+ label: '状态',
246
+ type: 'enum',
247
+ editable: true,
248
+ enum: {
249
+ active: { text: '启用', color: 'success' },
250
+ inactive: { text: '禁用', color: 'default' },
251
+ pending: { text: '待审核', color: 'warning' },
252
+ },
253
+ },
254
+ {
255
+ key: 'inStock',
256
+ label: '库存',
257
+ type: 'switch',
258
+ },
259
+ {
260
+ key: 'releaseDate',
261
+ label: '上架日期',
262
+ type: 'date',
263
+ },
264
+ ],
265
+ };
266
+ },
267
+ template: `
268
+ <div class="pa-4">
269
+ <h3 class="mb-4">多种字段类型示例</h3>
270
+ <JhEditableTable
271
+ v-model="tableData"
272
+ :columns="columns"
273
+ />
274
+ </div>
275
+ `,
276
+ }),
277
+ parameters: {
278
+ docs: {
279
+ description: {
280
+ story: '展示支持的多种字段类型:文本、数字、下拉选择、枚举、开关、日期等。',
281
+ },
282
+ },
283
+ },
284
+ };
285
+
286
+ // Story 3: 自定义新增按钮
287
+ export const 自定义新增按钮 = {
288
+ render: () => ({
289
+ components: { JhEditableTable },
290
+ data() {
291
+ return {
292
+ tableData: [
293
+ { id: 1, username: 'admin', role: 'admin', active: true },
294
+ { id: 2, username: 'user1', role: 'user', active: true },
295
+ ],
296
+ columns: [
297
+ {
298
+ key: 'username',
299
+ label: '用户名',
300
+ type: 'text',
301
+ rules: [(v) => !!v || '必填'],
302
+ },
303
+ {
304
+ key: 'role',
305
+ label: '角色',
306
+ type: 'select',
307
+ options: [
308
+ { text: '管理员', value: 'admin' },
309
+ { text: '普通用户', value: 'user' },
310
+ { text: '访客', value: 'guest' },
311
+ ],
312
+ },
313
+ {
314
+ key: 'active',
315
+ label: '激活状态',
316
+ type: 'switch',
317
+ },
318
+ ],
319
+ recordCreatorProps: {
320
+ creatorButtonText: '新增用户',
321
+ record: {
322
+ username: '',
323
+ role: 'user',
324
+ active: true,
325
+ },
326
+ },
327
+ };
328
+ },
329
+ template: `
330
+ <div class="pa-4">
331
+ <h3 class="mb-4">自定义新增按钮</h3>
332
+ <JhEditableTable
333
+ v-model="tableData"
334
+ :columns="columns"
335
+ :record-creator-props="recordCreatorProps"
336
+ />
337
+ </div>
338
+ `,
339
+ }),
340
+ parameters: {
341
+ docs: {
342
+ description: {
343
+ story: '通过 recordCreatorProps 自定义新增按钮文字和新行的默认数据。',
344
+ },
345
+ },
346
+ },
347
+ };
348
+
349
+ // Story 4: 只读模式
350
+ export const 只读模式 = {
351
+ render: () => ({
352
+ components: { JhEditableTable },
353
+ data() {
354
+ return {
355
+ tableData: [
356
+ { id: 1, name: '项目A', status: 'completed', progress: 100 },
357
+ { id: 2, name: '项目B', status: 'in_progress', progress: 60 },
358
+ { id: 3, name: '项目C', status: 'pending', progress: 0 },
359
+ ],
360
+ columns: [
361
+ { key: 'name', label: '项目名称', type: 'text' },
362
+ {
363
+ key: 'status',
364
+ label: '状态',
365
+ type: 'enum',
366
+ enum: {
367
+ completed: { text: '已完成', color: 'success' },
368
+ in_progress: { text: '进行中', color: 'primary' },
369
+ pending: { text: '待开始', color: 'grey' },
370
+ },
371
+ },
372
+ { key: 'progress', label: '进度', type: 'number' },
373
+ ],
374
+ };
375
+ },
376
+ template: `
377
+ <div class="pa-4">
378
+ <h3 class="mb-4">只读模式</h3>
379
+ <JhEditableTable
380
+ v-model="tableData"
381
+ :columns="columns"
382
+ :editable="false"
383
+ :deletable="false"
384
+ :record-creator="false"
385
+ />
386
+ </div>
387
+ `,
388
+ }),
389
+ parameters: {
390
+ docs: {
391
+ description: {
392
+ story: '设置 editable、deletable、recordCreator 为 false,表格变为只读展示模式。',
393
+ },
394
+ },
395
+ },
396
+ };
397
+
398
+ // Story 5: 紧凑模式
399
+ export const 紧凑模式 = {
400
+ render: () => ({
401
+ components: { JhEditableTable },
402
+ data() {
403
+ return {
404
+ tableData: [
405
+ { id: 1, code: 'P001', name: '产品1', qty: 100, price: 50 },
406
+ { id: 2, code: 'P002', name: '产品2', qty: 200, price: 80 },
407
+ { id: 3, code: 'P003', name: '产品3', qty: 150, price: 120 },
408
+ { id: 4, code: 'P004', name: '产品4', qty: 80, price: 200 },
409
+ ],
410
+ columns: [
411
+ { key: 'code', label: '编码', type: 'text' },
412
+ { key: 'name', label: '名称', type: 'text' },
413
+ { key: 'qty', label: '数量', type: 'number' },
414
+ { key: 'price', label: '单价', type: 'number' },
415
+ ],
416
+ };
417
+ },
418
+ template: `
419
+ <div class="pa-4">
420
+ <h3 class="mb-4">紧凑模式</h3>
421
+ <JhEditableTable
422
+ v-model="tableData"
423
+ :columns="columns"
424
+ dense
425
+ />
426
+ </div>
427
+ `,
428
+ }),
429
+ parameters: {
430
+ docs: {
431
+ description: {
432
+ story: '使用 dense 属性启用紧凑模式,适合展示更多数据。',
433
+ },
434
+ },
435
+ },
436
+ };
437
+
438
+ // Story 6: 自定义单元格渲染
439
+ export const 自定义单元格渲染 = {
440
+ render: () => ({
441
+ components: { JhEditableTable },
442
+ data() {
443
+ return {
444
+ tableData: [
445
+ { id: 1, name: '张三', score: 85, grade: 'B' },
446
+ { id: 2, name: '李四', score: 92, grade: 'A' },
447
+ { id: 3, name: '王五', score: 78, grade: 'C' },
448
+ ],
449
+ columns: [
450
+ { key: 'name', label: '姓名', type: 'text' },
451
+ { key: 'score', label: '分数', type: 'number' },
452
+ { key: 'grade', label: '等级', type: 'text', editable: false },
453
+ ],
454
+ };
455
+ },
456
+ methods: {
457
+ getScoreColor(score) {
458
+ if (score >= 90) return 'success';
459
+ if (score >= 80) return 'primary';
460
+ if (score >= 70) return 'warning';
461
+ return 'error';
462
+ },
463
+ },
464
+ template: `
465
+ <div class="pa-4">
466
+ <h3 class="mb-4">自定义单元格渲染</h3>
467
+ <JhEditableTable
468
+ v-model="tableData"
469
+ :columns="columns"
470
+ >
471
+ <!-- 自定义分数单元格 -->
472
+ <template #cell.score="{ value }">
473
+ <v-chip :color="getScoreColor(value)" small dark>
474
+ {{ value }} 分
475
+ </v-chip>
476
+ </template>
477
+
478
+ <!-- 自定义操作列 -->
479
+ <template #actions="{ item }">
480
+ <v-btn icon small color="info" @click="() => alert('查看详情: ' + item.name)">
481
+ <v-icon small>mdi-eye</v-icon>
482
+ </v-btn>
483
+ </template>
484
+ </JhEditableTable>
485
+ </div>
486
+ `,
487
+ }),
488
+ parameters: {
489
+ docs: {
490
+ description: {
491
+ story: '使用 slot 自定义单元格渲染和操作列,实现更丰富的展示效果。',
492
+ },
493
+ },
494
+ },
495
+ };
496
+
497
+ // Story 7: 完整功能演示
498
+ export const 完整功能演示 = {
499
+ render: () => ({
500
+ components: { JhEditableTable },
501
+ data() {
502
+ return {
503
+ tableData: [
504
+ {
505
+ id: 1,
506
+ name: '任务A',
507
+ assignee: '张三',
508
+ priority: 'high',
509
+ status: 'in_progress',
510
+ dueDate: '2024-12-31',
511
+ completed: false,
512
+ },
513
+ {
514
+ id: 2,
515
+ name: '任务B',
516
+ assignee: '李四',
517
+ priority: 'medium',
518
+ status: 'pending',
519
+ dueDate: '2024-11-30',
520
+ completed: false,
521
+ },
522
+ ],
523
+ columns: [
524
+ {
525
+ key: 'name',
526
+ label: '任务名称',
527
+ type: 'text',
528
+ rules: [(v) => !!v || '任务名称不能为空'],
529
+ },
530
+ {
531
+ key: 'assignee',
532
+ label: '负责人',
533
+ type: 'select',
534
+ options: ['张三', '李四', '王五', '赵六'],
535
+ },
536
+ {
537
+ key: 'priority',
538
+ label: '优先级',
539
+ type: 'select',
540
+ options: [
541
+ { text: '高', value: 'high' },
542
+ { text: '中', value: 'medium' },
543
+ { text: '低', value: 'low' },
544
+ ],
545
+ },
546
+ {
547
+ key: 'status',
548
+ label: '状态',
549
+ type: 'enum',
550
+ enum: {
551
+ pending: { text: '待开始', color: 'grey' },
552
+ in_progress: { text: '进行中', color: 'primary' },
553
+ completed: { text: '已完成', color: 'success' },
554
+ },
555
+ },
556
+ {
557
+ key: 'dueDate',
558
+ label: '截止日期',
559
+ type: 'date',
560
+ },
561
+ {
562
+ key: 'completed',
563
+ label: '完成',
564
+ type: 'switch',
565
+ },
566
+ ],
567
+ };
568
+ },
569
+ template: `
570
+ <div class="pa-4">
571
+ <h3 class="mb-4">完整功能演示 - 任务管理</h3>
572
+
573
+ <v-alert type="info" dense outlined class="mb-4">
574
+ <div><strong>功能说明:</strong></div>
575
+ <ul class="mt-2 mb-0">
576
+ <li>点击编辑按钮可编辑整行数据</li>
577
+ <li>编辑时会显示保存和取消按钮</li>
578
+ <li>支持字段验证,验证失败无法保存</li>
579
+ <li>点击添加按钮可新增任务</li>
580
+ <li>新增的行会自动进入编辑状态</li>
581
+ <li>所有操作都会触发相应事件</li>
582
+ </ul>
583
+ </v-alert>
584
+
585
+ <JhEditableTable
586
+ v-model="tableData"
587
+ :columns="columns"
588
+ :record-creator-props="{
589
+ creatorButtonText: '新增任务',
590
+ record: {
591
+ name: '',
592
+ assignee: '张三',
593
+ priority: 'medium',
594
+ status: 'pending',
595
+ dueDate: new Date().toISOString().substr(0, 10),
596
+ completed: false,
597
+ }
598
+ }"
599
+ />
600
+
601
+ <div class="mt-4 pa-3 grey lighten-4 rounded">
602
+ <h4>当前表格数据({{ tableData.length }} 条):</h4>
603
+ <pre class="mt-2">{{ JSON.stringify(tableData, null, 2) }}</pre>
604
+ </div>
605
+ </div>
606
+ `,
607
+ }),
608
+ parameters: {
609
+ docs: {
610
+ description: {
611
+ story: '完整功能演示,包含所有字段类型、验证、新增、编辑、删除等操作,适用于任务管理等场景。',
612
+ },
613
+ },
614
+ },
615
+ };