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,933 @@
1
+ <template>
2
+ <jh-card
3
+ :class="['jh-descriptions', { 'jh-descriptions--editable': editable }]"
4
+ :bordered="bordered"
5
+ :title="title"
6
+ :tooltip="tooltip"
7
+ :loading="loading"
8
+ :size="size"
9
+ >
10
+ <!-- 标题插槽 -->
11
+ <template v-if="$slots.title" #title>
12
+ <slot name="title"></slot>
13
+ </template>
14
+
15
+ <!-- 额外内容 -->
16
+ <template v-if="$slots.extra || showEditButton" #extra>
17
+ <slot name="extra">
18
+ <v-btn
19
+ v-if="showEditButton && editable"
20
+ text
21
+ small
22
+ color="primary"
23
+ @click="toggleEdit"
24
+ >
25
+ <v-icon small left>{{ isEditing ? 'mdi-close' : 'mdi-pencil' }}</v-icon>
26
+ {{ isEditing ? cancelText : editText }}
27
+ </v-btn>
28
+ <v-btn
29
+ v-if="isEditing"
30
+ text
31
+ small
32
+ color="success"
33
+ class="ml-2"
34
+ :loading="saving"
35
+ @click="handleSave"
36
+ >
37
+ <v-icon small left>mdi-check</v-icon>
38
+ {{ saveText }}
39
+ </v-btn>
40
+ </slot>
41
+ </template>
42
+
43
+ <!-- 描述列表内容 -->
44
+ <div :class="descriptionsClasses">
45
+ <v-row v-if="layout === 'horizontal'" :dense="size === 'small'">
46
+ <template v-for="(item, index) in visibleColumns">
47
+ <v-col
48
+ :key="`label-${index}`"
49
+ :cols="getLabelCols(item)"
50
+ :class="['jh-descriptions-item-label', { 'jh-descriptions-item-label--colon': colon }]"
51
+ >
52
+ <span class="jh-descriptions-item-label-text">{{ item.label || item.title }}</span>
53
+ <v-tooltip v-if="item.tooltip" bottom>
54
+ <template v-slot:activator="{ on, attrs }">
55
+ <v-icon x-small class="ml-1" v-bind="attrs" v-on="on">mdi-help-circle-outline</v-icon>
56
+ </template>
57
+ <span>{{ item.tooltip }}</span>
58
+ </v-tooltip>
59
+ </v-col>
60
+ <v-col
61
+ :key="`content-${index}`"
62
+ :cols="getContentCols(item)"
63
+ class="jh-descriptions-item-content"
64
+ >
65
+ <!-- 编辑模式 -->
66
+ <template v-if="isEditing && item.editable !== false">
67
+ <component
68
+ :is="getFieldComponent(item)"
69
+ v-model="formData[item.dataIndex || item.key]"
70
+ v-bind="getFieldProps(item)"
71
+ :disabled="item.disabled"
72
+ :readonly="item.readonly"
73
+ dense
74
+ outlined
75
+ hide-details="auto"
76
+ @change="handleFieldChange(item, $event)"
77
+ />
78
+ </template>
79
+
80
+ <!-- 显示模式 -->
81
+ <template v-else>
82
+ <div class="jh-descriptions-item-value">
83
+ <!-- 自定义插槽 -->
84
+ <slot
85
+ v-if="$slots[`item-${item.dataIndex || item.key}`]"
86
+ :name="`item-${item.dataIndex || item.key}`"
87
+ :value="getValue(item)"
88
+ :record="dataSource"
89
+ :item="item"
90
+ ></slot>
91
+
92
+ <!-- 自定义 render -->
93
+ <template v-else-if="item.render">
94
+ <span v-html="renderValue(item)"></span>
95
+ </template>
96
+
97
+ <!-- 默认渲染 -->
98
+ <template v-else>
99
+ {{ formatValue(item) }}
100
+ </template>
101
+
102
+ <!-- 复制按钮 -->
103
+ <v-btn
104
+ v-if="item.copyable && getValue(item)"
105
+ icon
106
+ x-small
107
+ class="ml-2"
108
+ @click="copyToClipboard(getValue(item), item)"
109
+ >
110
+ <v-icon x-small>mdi-content-copy</v-icon>
111
+ </v-btn>
112
+ </div>
113
+ </template>
114
+ </v-col>
115
+ </template>
116
+ </v-row>
117
+
118
+ <!-- 垂直布局 -->
119
+ <v-row v-else-if="layout === 'vertical' || layout === 'simple'" :dense="size === 'small'">
120
+ <v-col
121
+ v-for="(item, index) in visibleColumns"
122
+ :key="index"
123
+ :cols="getItemCols(item)"
124
+ class="jh-descriptions-item-vertical"
125
+ >
126
+ <div :class="['jh-descriptions-item-label', { 'jh-descriptions-item-label--colon': colon }]">
127
+ <span class="jh-descriptions-item-label-text">{{ item.label || item.title }}</span>
128
+ <v-tooltip v-if="item.tooltip" bottom>
129
+ <template v-slot:activator="{ on, attrs }">
130
+ <v-icon x-small class="ml-1" v-bind="attrs" v-on="on">mdi-help-circle-outline</v-icon>
131
+ </template>
132
+ <span>{{ item.tooltip }}</span>
133
+ </v-tooltip>
134
+ </div>
135
+ <div class="jh-descriptions-item-content">
136
+ <!-- 编辑模式 -->
137
+ <template v-if="isEditing && item.editable !== false">
138
+ <component
139
+ :is="getFieldComponent(item)"
140
+ v-model="formData[item.dataIndex || item.key]"
141
+ v-bind="getFieldProps(item)"
142
+ :disabled="item.disabled"
143
+ :readonly="item.readonly"
144
+ dense
145
+ outlined
146
+ hide-details="auto"
147
+ @change="handleFieldChange(item, $event)"
148
+ />
149
+ </template>
150
+
151
+ <!-- 显示模式 -->
152
+ <template v-else>
153
+ <div class="jh-descriptions-item-value">
154
+ <!-- 自定义插槽 -->
155
+ <slot
156
+ v-if="$slots[`item-${item.dataIndex || item.key}`]"
157
+ :name="`item-${item.dataIndex || item.key}`"
158
+ :value="getValue(item)"
159
+ :record="dataSource"
160
+ :item="item"
161
+ ></slot>
162
+
163
+ <!-- 自定义 render -->
164
+ <template v-else-if="item.render">
165
+ <span v-html="renderValue(item)"></span>
166
+ </template>
167
+
168
+ <!-- 默认渲染 -->
169
+ <template v-else>
170
+ {{ formatValue(item) }}
171
+ </template>
172
+
173
+ <!-- 复制按钮 -->
174
+ <v-btn
175
+ v-if="item.copyable && getValue(item)"
176
+ icon
177
+ x-small
178
+ class="ml-2"
179
+ @click="copyToClipboard(getValue(item), item)"
180
+ >
181
+ <v-icon x-small>mdi-content-copy</v-icon>
182
+ </v-btn>
183
+ </div>
184
+ </template>
185
+ </div>
186
+ </v-col>
187
+ </v-row>
188
+
189
+ <!-- 行内布局 -->
190
+ <div
191
+ v-else
192
+ class="jh-descriptions-inline"
193
+ :class="{
194
+ 'jh-descriptions-inline--small': size === 'small',
195
+ 'jh-descriptions-inline--bordered': bordered,
196
+ }"
197
+ >
198
+ <div
199
+ v-for="(item, index) in visibleColumns"
200
+ :key="index"
201
+ class="jh-descriptions-inline-item"
202
+ :style="getInlineItemStyle(item)"
203
+ >
204
+ <div :class="['jh-descriptions-inline-label', { 'jh-descriptions-item-label--colon': colon }]">
205
+ <span class="jh-descriptions-item-label-text">{{ item.label || item.title }}</span>
206
+ <v-tooltip v-if="item.tooltip" bottom>
207
+ <template v-slot:activator="{ on, attrs }">
208
+ <v-icon x-small class="ml-1" v-bind="attrs" v-on="on">mdi-help-circle-outline</v-icon>
209
+ </template>
210
+ <span>{{ item.tooltip }}</span>
211
+ </v-tooltip>
212
+ </div>
213
+ <div class="jh-descriptions-inline-value">
214
+ <!-- 编辑模式 -->
215
+ <template v-if="isEditing && item.editable !== false">
216
+ <component
217
+ :is="getFieldComponent(item)"
218
+ v-model="formData[item.dataIndex || item.key]"
219
+ v-bind="getFieldProps(item)"
220
+ :disabled="item.disabled"
221
+ :readonly="item.readonly"
222
+ dense
223
+ outlined
224
+ hide-details="auto"
225
+ @change="handleFieldChange(item, $event)"
226
+ />
227
+ </template>
228
+
229
+ <!-- 显示模式 -->
230
+ <template v-else>
231
+ <div class="jh-descriptions-item-value">
232
+ <!-- 自定义插槽 -->
233
+ <slot
234
+ v-if="$slots[`item-${item.dataIndex || item.key}`]"
235
+ :name="`item-${item.dataIndex || item.key}`"
236
+ :value="getValue(item)"
237
+ :record="dataSource"
238
+ :item="item"
239
+ ></slot>
240
+
241
+ <!-- 自定义 render -->
242
+ <template v-else-if="item.render">
243
+ <span v-html="renderValue(item)"></span>
244
+ </template>
245
+
246
+ <!-- 默认渲染 -->
247
+ <template v-else>
248
+ {{ formatValue(item) }}
249
+ </template>
250
+
251
+ <!-- 复制按钮 -->
252
+ <v-btn
253
+ v-if="item.copyable && getValue(item)"
254
+ icon
255
+ x-small
256
+ class="ml-2"
257
+ @click="copyToClipboard(getValue(item), item)"
258
+ >
259
+ <v-icon x-small>mdi-content-copy</v-icon>
260
+ </v-btn>
261
+ </div>
262
+ </template>
263
+ </div>
264
+ </div>
265
+ </div>
266
+ </div>
267
+ </jh-card>
268
+ </template>
269
+
270
+ <script>
271
+ import JhCard from '../JhCard/JhCard.vue';
272
+
273
+ export default {
274
+ name: 'JhDescriptions',
275
+
276
+ components: {
277
+ JhCard,
278
+ },
279
+
280
+ props: {
281
+ // 标题
282
+ title: {
283
+ type: String,
284
+ default: '',
285
+ },
286
+
287
+ // 提示信息
288
+ tooltip: {
289
+ type: String,
290
+ default: '',
291
+ },
292
+
293
+ // 列配置
294
+ columns: {
295
+ type: Array,
296
+ required: true,
297
+ default: () => [],
298
+ },
299
+
300
+ // 数据源
301
+ dataSource: {
302
+ type: Object,
303
+ default: () => ({}),
304
+ },
305
+
306
+ // 请求数据的方法
307
+ request: {
308
+ type: Function,
309
+ default: null,
310
+ },
311
+
312
+ // 请求参数
313
+ params: {
314
+ type: Object,
315
+ default: () => ({}),
316
+ },
317
+
318
+ // 列数
319
+ column: {
320
+ type: [Number, Object],
321
+ default: 3,
322
+ },
323
+
324
+ // 布局方式 horizontal | vertical | inline | simple
325
+ layout: {
326
+ type: String,
327
+ default: 'horizontal',
328
+ validator: (value) => ['horizontal', 'vertical', 'inline', 'simple'].includes(value),
329
+ },
330
+
331
+ // 是否显示边框
332
+ bordered: {
333
+ type: Boolean,
334
+ default: true,
335
+ },
336
+
337
+ // 尺寸 small | default
338
+ size: {
339
+ type: String,
340
+ default: 'default',
341
+ validator: (value) => ['small', 'default'].includes(value),
342
+ },
343
+
344
+ // 是否显示冒号
345
+ colon: {
346
+ type: Boolean,
347
+ default: true,
348
+ },
349
+
350
+ // 标签宽度比例(仅水平布局)
351
+ labelWidth: {
352
+ type: [Number, String],
353
+ default: 'auto',
354
+ },
355
+
356
+ // 是否可编辑
357
+ editable: {
358
+ type: [Boolean, Object],
359
+ default: false,
360
+ },
361
+
362
+ // 编辑按钮文本
363
+ editText: {
364
+ type: String,
365
+ default: '编辑',
366
+ },
367
+
368
+ // 取消按钮文本
369
+ cancelText: {
370
+ type: String,
371
+ default: '取消',
372
+ },
373
+
374
+ // 保存按钮文本
375
+ saveText: {
376
+ type: String,
377
+ default: '保存',
378
+ },
379
+
380
+ // 空值占位符
381
+ emptyText: {
382
+ type: String,
383
+ default: '-',
384
+ },
385
+
386
+ // 加载状态
387
+ loading: {
388
+ type: Boolean,
389
+ default: false,
390
+ },
391
+
392
+ // 响应式配置
393
+ responsive: {
394
+ type: Boolean,
395
+ default: true,
396
+ },
397
+ },
398
+
399
+ data() {
400
+ return {
401
+ internalData: {},
402
+ formData: {},
403
+ isEditing: false,
404
+ saving: false,
405
+ internalLoading: false,
406
+ };
407
+ },
408
+
409
+ computed: {
410
+ // 是否显示编辑按钮
411
+ showEditButton() {
412
+ if (typeof this.editable === 'boolean') {
413
+ return this.editable;
414
+ }
415
+ return this.editable && this.editable.showEditButton !== false;
416
+ },
417
+
418
+ // 可见的列
419
+ visibleColumns() {
420
+ return this.columns.filter(col => {
421
+ if (col.hideInDescriptions) return false;
422
+ if (typeof col.visible === 'function') {
423
+ return col.visible(this.dataSource);
424
+ }
425
+ return col.visible !== false;
426
+ });
427
+ },
428
+
429
+ // 描述列表样式类
430
+ descriptionsClasses() {
431
+ return [
432
+ 'jh-descriptions-content',
433
+ `jh-descriptions-content--${this.layout}`,
434
+ {
435
+ 'jh-descriptions-content--bordered': this.bordered,
436
+ 'jh-descriptions-content--small': this.size === 'small',
437
+ },
438
+ ];
439
+ },
440
+
441
+ // 实际数据源
442
+ actualDataSource() {
443
+ return Object.keys(this.internalData).length > 0 ? this.internalData : this.dataSource;
444
+ },
445
+ },
446
+
447
+ watch: {
448
+ dataSource: {
449
+ handler(val) {
450
+ this.internalData = { ...val };
451
+ this.formData = { ...val };
452
+ },
453
+ deep: true,
454
+ immediate: true,
455
+ },
456
+
457
+ params: {
458
+ handler() {
459
+ if (this.request) {
460
+ this.fetchData();
461
+ }
462
+ },
463
+ deep: true,
464
+ },
465
+ },
466
+
467
+ mounted() {
468
+ if (this.request) {
469
+ this.fetchData();
470
+ }
471
+ },
472
+
473
+ methods: {
474
+ // 获取标签列宽
475
+ getLabelCols(item) {
476
+ if (this.labelWidth === 'auto') {
477
+ return item.labelCol || 6;
478
+ }
479
+ if (typeof this.labelWidth === 'number') {
480
+ return this.labelWidth;
481
+ }
482
+ return 6;
483
+ },
484
+
485
+ // 获取内容列宽
486
+ getContentCols(item) {
487
+ const labelCols = this.getLabelCols(item);
488
+ const span = item.span || 1;
489
+ const totalCols = 12 / this.getColumnCount();
490
+ return totalCols * span - labelCols;
491
+ },
492
+
493
+ // 获取项目列宽(垂直布局)
494
+ getItemCols(item) {
495
+ const span = item.span || 1;
496
+ return 12 / this.getColumnCount() * span;
497
+ },
498
+
499
+ // 行内布局宽度
500
+ getInlineItemStyle(item) {
501
+ const span = item.span || 1;
502
+ const columns = this.getColumnCount() || 1;
503
+ const percent = Math.min(100, (span / columns) * 100);
504
+ return {
505
+ flexBasis: `${percent}%`,
506
+ maxWidth: `${percent}%`,
507
+ };
508
+ },
509
+
510
+ // 获取列数
511
+ getColumnCount() {
512
+ if (typeof this.column === 'number') {
513
+ return this.column;
514
+ }
515
+ // 响应式配置
516
+ const breakpoint = this.getBreakpoint();
517
+ return this.column[breakpoint] || this.column.default || 3;
518
+ },
519
+
520
+ // 获取当前断点
521
+ getBreakpoint() {
522
+ const width = window.innerWidth;
523
+ if (width < 576) return 'xs';
524
+ if (width < 768) return 'sm';
525
+ if (width < 992) return 'md';
526
+ if (width < 1200) return 'lg';
527
+ if (width < 1920) return 'xl';
528
+ return 'xxl';
529
+ },
530
+
531
+ // 获取值
532
+ getValue(item) {
533
+ const key = item.dataIndex || item.key;
534
+ return this.actualDataSource[key];
535
+ },
536
+
537
+ // 格式化值
538
+ formatValue(item) {
539
+ const value = this.getValue(item);
540
+
541
+ if (value === null || value === undefined || value === '') {
542
+ return this.emptyText;
543
+ }
544
+
545
+ // 根据 valueType 格式化
546
+ const valueType = item.valueType || 'text';
547
+
548
+ switch (valueType) {
549
+ case 'money':
550
+ return this.formatMoney(value);
551
+ case 'percent':
552
+ return `${value}%`;
553
+ case 'date':
554
+ return this.formatDate(value, 'YYYY-MM-DD');
555
+ case 'dateTime':
556
+ return this.formatDate(value, 'YYYY-MM-DD HH:mm:ss');
557
+ case 'time':
558
+ return this.formatDate(value, 'HH:mm:ss');
559
+ case 'option':
560
+ return this.formatOption(value, item);
561
+ case 'tag':
562
+ return value;
563
+ case 'progress':
564
+ return `${value}%`;
565
+ case 'digit':
566
+ return this.formatDigit(value);
567
+ default:
568
+ return value;
569
+ }
570
+ },
571
+
572
+ // 渲染值(自定义 render)
573
+ renderValue(item) {
574
+ const value = this.getValue(item);
575
+ return item.render(value, this.actualDataSource, item);
576
+ },
577
+
578
+ // 格式化金额
579
+ formatMoney(value) {
580
+ if (!value && value !== 0) return this.emptyText;
581
+ return `¥ ${Number(value).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
582
+ },
583
+
584
+ // 格式化日期
585
+ formatDate(value, format) {
586
+ if (!value) return this.emptyText;
587
+ // 简单的日期格式化,实际项目中建议使用 dayjs 或 moment
588
+ const date = new Date(value);
589
+ if (isNaN(date.getTime())) return value;
590
+
591
+ const year = date.getFullYear();
592
+ const month = String(date.getMonth() + 1).padStart(2, '0');
593
+ const day = String(date.getDate()).padStart(2, '0');
594
+ const hours = String(date.getHours()).padStart(2, '0');
595
+ const minutes = String(date.getMinutes()).padStart(2, '0');
596
+ const seconds = String(date.getSeconds()).padStart(2, '0');
597
+
598
+ return format
599
+ .replace('YYYY', year)
600
+ .replace('MM', month)
601
+ .replace('DD', day)
602
+ .replace('HH', hours)
603
+ .replace('mm', minutes)
604
+ .replace('ss', seconds);
605
+ },
606
+
607
+ // 格式化选项
608
+ formatOption(value, item) {
609
+ if (!item.valueEnum) return value;
610
+ const option = item.valueEnum[value];
611
+ if (!option) return value;
612
+ return typeof option === 'object' ? option.text : option;
613
+ },
614
+
615
+ // 格式化数字
616
+ formatDigit(value) {
617
+ if (!value && value !== 0) return this.emptyText;
618
+ return Number(value).toLocaleString('zh-CN');
619
+ },
620
+
621
+ // 获取字段组件
622
+ getFieldComponent(item) {
623
+ const valueType = item.valueType || 'text';
624
+
625
+ const componentMap = {
626
+ text: 'v-text-field',
627
+ textarea: 'v-textarea',
628
+ digit: 'v-text-field',
629
+ money: 'v-text-field',
630
+ date: 'v-text-field',
631
+ dateTime: 'v-text-field',
632
+ time: 'v-text-field',
633
+ select: 'v-select',
634
+ radio: 'v-radio-group',
635
+ checkbox: 'v-checkbox',
636
+ switch: 'v-switch',
637
+ };
638
+
639
+ return item.fieldComponent || componentMap[valueType] || 'v-text-field';
640
+ },
641
+
642
+ // 获取字段属性
643
+ getFieldProps(item) {
644
+ const valueType = item.valueType || 'text';
645
+ const props = { ...item.fieldProps };
646
+
647
+ // 根据 valueType 设置默认属性
648
+ if (valueType === 'digit' || valueType === 'money') {
649
+ props.type = 'number';
650
+ }
651
+
652
+ if (valueType === 'date') {
653
+ props.type = 'date';
654
+ }
655
+
656
+ if (valueType === 'dateTime') {
657
+ props.type = 'datetime-local';
658
+ }
659
+
660
+ if (valueType === 'time') {
661
+ props.type = 'time';
662
+ }
663
+
664
+ if (valueType === 'select' && item.valueEnum) {
665
+ props.items = Object.entries(item.valueEnum).map(([value, label]) => ({
666
+ value,
667
+ text: typeof label === 'object' ? label.text : label,
668
+ }));
669
+ }
670
+
671
+ return props;
672
+ },
673
+
674
+ // 切换编辑状态
675
+ toggleEdit() {
676
+ if (this.isEditing) {
677
+ // 取消编辑,恢复数据
678
+ this.formData = { ...this.actualDataSource };
679
+ this.isEditing = false;
680
+ this.$emit('cancel');
681
+ } else {
682
+ // 开始编辑
683
+ this.formData = { ...this.actualDataSource };
684
+ this.isEditing = true;
685
+ this.$emit('edit-start');
686
+ }
687
+ },
688
+
689
+ // 处理字段变化
690
+ handleFieldChange(item, value) {
691
+ this.$emit('field-change', {
692
+ field: item.dataIndex || item.key,
693
+ value,
694
+ item,
695
+ });
696
+ },
697
+
698
+ // 保存
699
+ async handleSave() {
700
+ this.saving = true;
701
+
702
+ try {
703
+ // 触发保存事件
704
+ const result = await this.$emit('save', this.formData);
705
+
706
+ // 如果配置了 onSave 回调
707
+ if (this.editable && typeof this.editable.onSave === 'function') {
708
+ await this.editable.onSave(this.formData);
709
+ }
710
+
711
+ // 更新内部数据
712
+ this.internalData = { ...this.formData };
713
+ this.isEditing = false;
714
+
715
+ this.$emit('save-success', this.formData);
716
+ } catch (error) {
717
+ this.$emit('save-error', error);
718
+ console.error('Save error:', error);
719
+ } finally {
720
+ this.saving = false;
721
+ }
722
+ },
723
+
724
+ // 复制到剪贴板
725
+ async copyToClipboard(text, item) {
726
+ try {
727
+ await navigator.clipboard.writeText(String(text));
728
+ this.$emit('copy', { text, item });
729
+
730
+ // 可以在这里显示提示消息
731
+ if (window.$toast) {
732
+ window.$toast.success('复制成功');
733
+ }
734
+ } catch (error) {
735
+ console.error('Copy failed:', error);
736
+ if (window.$toast) {
737
+ window.$toast.error('复制失败');
738
+ }
739
+ }
740
+ },
741
+
742
+ // 获取数据
743
+ async fetchData() {
744
+ if (!this.request) return;
745
+
746
+ this.internalLoading = true;
747
+ this.$emit('update:loading', true);
748
+
749
+ try {
750
+ const data = await this.request(this.params);
751
+ this.internalData = data || {};
752
+ this.formData = { ...this.internalData };
753
+ this.$emit('request-success', data);
754
+ } catch (error) {
755
+ this.$emit('request-error', error);
756
+ console.error('Request error:', error);
757
+ } finally {
758
+ this.internalLoading = false;
759
+ this.$emit('update:loading', false);
760
+ }
761
+ },
762
+
763
+ // 刷新数据
764
+ reload() {
765
+ if (this.request) {
766
+ this.fetchData();
767
+ }
768
+ },
769
+ },
770
+ };
771
+ </script>
772
+
773
+ <style scoped>
774
+ /* 描述列表容器 */
775
+ .jh-descriptions {
776
+ width: 100%;
777
+ }
778
+
779
+ .jh-descriptions-content {
780
+ width: 100%;
781
+ }
782
+
783
+ /* 水平布局 */
784
+ .jh-descriptions-content--horizontal .jh-descriptions-item-label {
785
+ padding: 12px 16px;
786
+ background: #fafafa;
787
+ font-weight: 500;
788
+ color: rgba(0, 0, 0, 0.85);
789
+ text-align: right;
790
+ border-bottom: 1px solid #f0f0f0;
791
+ }
792
+
793
+ .jh-descriptions-content--horizontal .jh-descriptions-item-content {
794
+ padding: 12px 16px;
795
+ color: rgba(0, 0, 0, 0.65);
796
+ border-bottom: 1px solid #f0f0f0;
797
+ }
798
+
799
+ /* 垂直布局 */
800
+ .jh-descriptions-content--vertical .jh-descriptions-item-vertical {
801
+ padding: 0;
802
+ }
803
+
804
+ .jh-descriptions-content--vertical .jh-descriptions-item-label {
805
+ padding: 8px 0;
806
+ font-weight: 500;
807
+ color: rgba(0, 0, 0, 0.85);
808
+ border-bottom: 1px solid #f0f0f0;
809
+ }
810
+
811
+ .jh-descriptions-content--vertical .jh-descriptions-item-content {
812
+ padding: 12px 0;
813
+ color: rgba(0, 0, 0, 0.65);
814
+ min-height: 40px;
815
+ }
816
+
817
+ /* 简洁布局 */
818
+ .jh-descriptions-content--simple .jh-descriptions-item-vertical {
819
+ border: none;
820
+ padding: 0;
821
+ }
822
+
823
+ .jh-descriptions-content--simple .jh-descriptions-item-label {
824
+ padding: 4px 0;
825
+ border: none;
826
+ font-weight: 500;
827
+ color: rgba(0, 0, 0, 0.6);
828
+ }
829
+
830
+ .jh-descriptions-content--simple .jh-descriptions-item-content {
831
+ padding: 4px 0 12px;
832
+ border-bottom: 1px solid #f5f5f5;
833
+ }
834
+
835
+ .jh-descriptions-content--simple .jh-descriptions-item-content:last-child {
836
+ border-bottom: none;
837
+ }
838
+
839
+ /* 行内布局 */
840
+ .jh-descriptions-inline {
841
+ display: flex;
842
+ flex-wrap: wrap;
843
+ width: 100%;
844
+ }
845
+
846
+ .jh-descriptions-inline--bordered {
847
+ border-top: 1px solid #f0f0f0;
848
+ border-left: 1px solid #f0f0f0;
849
+ }
850
+
851
+ .jh-descriptions-inline-item {
852
+ display: flex;
853
+ flex-direction: row;
854
+ align-items: flex-start;
855
+ padding: 12px 16px;
856
+ box-sizing: border-box;
857
+ min-width: 200px;
858
+ }
859
+
860
+ .jh-descriptions-inline--bordered .jh-descriptions-inline-item {
861
+ border-right: 1px solid #f0f0f0;
862
+ border-bottom: 1px solid #f0f0f0;
863
+ }
864
+
865
+ .jh-descriptions-inline-label {
866
+ font-weight: 500;
867
+ color: rgba(0, 0, 0, 0.65);
868
+ margin-right: 12px;
869
+ min-width: 80px;
870
+ }
871
+
872
+ .jh-descriptions-inline-value {
873
+ flex: 1;
874
+ min-width: 0;
875
+ color: rgba(0, 0, 0, 0.65);
876
+ }
877
+
878
+ .jh-descriptions-inline--small .jh-descriptions-inline-item {
879
+ padding: 8px 12px;
880
+ }
881
+
882
+ /* 标签冒号 */
883
+ .jh-descriptions-item-label--colon .jh-descriptions-item-label-text::after {
884
+ content: ':';
885
+ margin: 0 8px 0 2px;
886
+ }
887
+
888
+ /* 值容器 */
889
+ .jh-descriptions-item-value {
890
+ display: flex;
891
+ align-items: center;
892
+ word-break: break-word;
893
+ }
894
+
895
+ /* 小尺寸 */
896
+ .jh-descriptions-content--small .jh-descriptions-item-label,
897
+ .jh-descriptions-content--small .jh-descriptions-item-content {
898
+ padding: 8px 12px;
899
+ }
900
+
901
+ .jh-descriptions-content--small.jh-descriptions-content--vertical .jh-descriptions-item-label {
902
+ padding: 6px 0;
903
+ }
904
+
905
+ .jh-descriptions-content--small.jh-descriptions-content--vertical .jh-descriptions-item-content {
906
+ padding: 8px 0;
907
+ }
908
+
909
+ /* 边框样式 */
910
+ .jh-descriptions-content--bordered.jh-descriptions-content--horizontal .jh-descriptions-item-label,
911
+ .jh-descriptions-content--bordered.jh-descriptions-content--horizontal .jh-descriptions-item-content {
912
+ border-right: 1px solid #f0f0f0;
913
+ }
914
+
915
+ .jh-descriptions-content--bordered.jh-descriptions-content--vertical .jh-descriptions-item-vertical {
916
+ border: 1px solid #f0f0f0;
917
+ border-radius: 4px;
918
+ padding: 12px;
919
+ margin-bottom: 8px;
920
+ }
921
+
922
+ /* 编辑模式 */
923
+ .jh-descriptions--editable .jh-descriptions-item-content {
924
+ min-height: 48px;
925
+ }
926
+
927
+ /* 响应式 */
928
+ @media (max-width: 768px) {
929
+ .jh-descriptions-content--horizontal .jh-descriptions-item-label {
930
+ text-align: left;
931
+ }
932
+ }
933
+ </style>