@ebiz/designer-components 0.1.124 → 0.1.126

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 (230) hide show
  1. package/README.md +29 -29
  2. package/dist/designer-components.css +1 -1
  3. package/dist/index.mjs +35548 -33511
  4. package/dist/{pdf-C9oIcL2N.js → pdf-KomaE0u5.js} +891 -891
  5. package/package.json +1 -1
  6. package/src/App.vue +26 -26
  7. package/src/apiService/SIMPLE_DATA_SERVICE.md +284 -284
  8. package/src/apiService/mockDataService.js +115 -115
  9. package/src/apiService/simpleDataService.js +312 -312
  10. package/src/assets/base.css +86 -86
  11. package/src/assets/logo.svg +1 -1
  12. package/src/components/Button.vue +149 -149
  13. package/src/components/DataContainer.vue +40 -40
  14. package/src/components/EbizApproval.vue +366 -366
  15. package/src/components/EbizApprovalDetail.vue +169 -169
  16. package/src/components/EbizApprovalForm.vue +534 -534
  17. package/src/components/EbizApprovalV2.vue +713 -713
  18. package/src/components/EbizAutoForm.vue +596 -596
  19. package/src/components/EbizAvatar.vue +115 -115
  20. package/src/components/EbizCheckbox.vue +93 -93
  21. package/src/components/EbizCheckboxGroup.vue +69 -69
  22. package/src/components/EbizDepartmentSelector.vue +148 -148
  23. package/src/components/EbizDescriptions.vue +340 -340
  24. package/src/components/EbizDescriptionsItem.vue +47 -47
  25. package/src/components/EbizDetailBlock.vue +81 -81
  26. package/src/components/EbizDetailItem.vue +559 -559
  27. package/src/components/EbizDetailView.md +438 -438
  28. package/src/components/EbizDetailView.vue +355 -355
  29. package/src/components/EbizDialog.vue +260 -260
  30. package/src/components/EbizDictionarySelect.vue +229 -229
  31. package/src/components/EbizDiv.vue +40 -40
  32. package/src/components/EbizDivider.vue +96 -96
  33. package/src/components/EbizDormDashboard.vue +314 -314
  34. package/src/components/EbizDropdown.vue +135 -135
  35. package/src/components/EbizDropdownItem.vue +85 -85
  36. package/src/components/EbizEmployeeInfo.vue +144 -144
  37. package/src/components/EbizEmployeeSelector.vue +1160 -1160
  38. package/src/components/EbizFileList.vue +502 -502
  39. package/src/components/EbizMap.vue +541 -541
  40. package/src/components/EbizMeetingRoomSelector.vue +1149 -1149
  41. package/src/components/EbizMobileMeetingRoomSelector.vue +727 -727
  42. package/src/components/EbizOkrTree.vue +99 -99
  43. package/src/components/EbizPageHeader.vue +98 -98
  44. package/src/components/EbizPagination.vue +162 -162
  45. package/src/components/EbizParkingDashboard.vue +152 -152
  46. package/src/components/EbizPdfViewer.vue +540 -540
  47. package/src/components/EbizPopconfirm.vue +47 -47
  48. package/src/components/EbizQrCode.vue +167 -167
  49. package/src/components/EbizRadio.vue +86 -86
  50. package/src/components/EbizRadioGroup.vue +83 -83
  51. package/src/components/EbizRemoteSelect.vue +232 -232
  52. package/src/components/EbizRichTextEditor.vue +338 -338
  53. package/src/components/EbizRouteBreadcrumb.vue +46 -46
  54. package/src/components/EbizSApprovalProcess.vue +1456 -1426
  55. package/src/components/EbizSelect.vue +85 -85
  56. package/src/components/EbizSpace.vue +100 -100
  57. package/src/components/EbizStatistic.vue +149 -149
  58. package/src/components/EbizStatsCard.vue +113 -113
  59. package/src/components/EbizSwiper.vue +113 -113
  60. package/src/components/EbizSwiperItem.vue +13 -13
  61. package/src/components/EbizSwitch.vue +85 -85
  62. package/src/components/EbizTabHeader.vue +132 -132
  63. package/src/components/EbizTabPanel.vue +22 -22
  64. package/src/components/EbizTable.vue +469 -469
  65. package/src/components/EbizTableColumn.vue +116 -116
  66. package/src/components/EbizTableSort.vue +179 -179
  67. package/src/components/EbizTabs.vue +142 -142
  68. package/src/components/EbizTdesignButtonDialog.vue +332 -332
  69. package/src/components/EbizTdesignLoading.vue +107 -107
  70. package/src/components/EbizTimePicker.vue +143 -143
  71. package/src/components/EbizTitle.vue +91 -91
  72. package/src/components/EbizTree.vue +141 -141
  73. package/src/components/EbizTreeMergeTable.vue +1494 -1494
  74. package/src/components/EbizTreeSelector.vue +469 -469
  75. package/src/components/EbizVideo.vue +553 -553
  76. package/src/components/EbizVxeTable.vue +290 -290
  77. package/src/components/Form.vue +28 -28
  78. package/src/components/Home.vue +7 -7
  79. package/src/components/LaunchInterview.vue +526 -526
  80. package/src/components/MyComponent.vue +39 -39
  81. package/src/components/Table.vue +45 -45
  82. package/src/components/TdesignAlert.vue +115 -115
  83. package/src/components/TdesignButton.vue +135 -135
  84. package/src/components/TdesignCalendar/index.vue +145 -145
  85. package/src/components/TdesignCard.vue +195 -195
  86. package/src/components/TdesignCol.vue +101 -101
  87. package/src/components/TdesignCollapse.vue +142 -142
  88. package/src/components/TdesignCollapsePanel.vue +79 -79
  89. package/src/components/TdesignDatePicker.vue +124 -124
  90. package/src/components/TdesignDescriptions.vue +74 -74
  91. package/src/components/TdesignDescriptionsItem.vue +50 -50
  92. package/src/components/TdesignDialog.vue +225 -225
  93. package/src/components/TdesignForm.vue +138 -138
  94. package/src/components/TdesignFormItem.vue +105 -105
  95. package/src/components/TdesignGrid.vue +55 -55
  96. package/src/components/TdesignIcon.vue +67 -67
  97. package/src/components/TdesignImage.vue +162 -162
  98. package/src/components/TdesignImageViewer.vue +200 -200
  99. package/src/components/TdesignInput.vue +242 -242
  100. package/src/components/TdesignSelect.vue +446 -446
  101. package/src/components/TdesignTag.vue +117 -117
  102. package/src/components/TdesignTextarea.vue +142 -142
  103. package/src/components/TdesignTimeline.vue +58 -58
  104. package/src/components/TdesignTimelineItem.vue +71 -71
  105. package/src/components/TdesignUpload.vue +414 -414
  106. package/src/components/TdesignWatermark.vue +107 -107
  107. package/src/components/ebiz-form/components/cascader.vue +61 -61
  108. package/src/components/ebiz-form/components/checkbox.vue +37 -37
  109. package/src/components/ebiz-form/components/city.vue +137 -137
  110. package/src/components/ebiz-form/components/date-panel.vue +52 -52
  111. package/src/components/ebiz-form/components/date-range-panel.vue +52 -52
  112. package/src/components/ebiz-form/components/date-range.vue +56 -56
  113. package/src/components/ebiz-form/components/date.vue +52 -52
  114. package/src/components/ebiz-form/components/editor-multi-language.vue +47 -47
  115. package/src/components/ebiz-form/components/editor.vue +78 -78
  116. package/src/components/ebiz-form/components/file-multi-language.vue +52 -52
  117. package/src/components/ebiz-form/components/file.vue +149 -149
  118. package/src/components/ebiz-form/components/images-multi-language.vue +52 -52
  119. package/src/components/ebiz-form/components/images.vue +129 -129
  120. package/src/components/ebiz-form/components/img-multi-language.vue +51 -51
  121. package/src/components/ebiz-form/components/img.vue +129 -129
  122. package/src/components/ebiz-form/components/number.vue +50 -50
  123. package/src/components/ebiz-form/components/radio.vue +28 -28
  124. package/src/components/ebiz-form/components/select.vue +119 -119
  125. package/src/components/ebiz-form/components/switch.vue +23 -23
  126. package/src/components/ebiz-form/components/text-multi-language.vue +47 -47
  127. package/src/components/ebiz-form/components/text.vue +52 -52
  128. package/src/components/ebiz-form/components/textarea-multi-language.vue +48 -48
  129. package/src/components/ebiz-form/components/textarea.vue +29 -29
  130. package/src/components/ebiz-form/components/video-multi-language.vue +51 -51
  131. package/src/components/ebiz-form/components/video.vue +97 -97
  132. package/src/components/ebiz-form/index.vue +157 -157
  133. package/src/components/examples/PopconfirmExample.vue +149 -149
  134. package/src/components/icons/IconCommunity.vue +7 -7
  135. package/src/components/icons/IconDocumentation.vue +7 -7
  136. package/src/components/icons/IconEcosystem.vue +7 -7
  137. package/src/components/icons/IconSupport.vue +7 -7
  138. package/src/components/icons/IconTooling.vue +19 -19
  139. package/src/components/mItems/UserInfo.vue +349 -349
  140. package/src/components/senior/EbizApprovalList/ApprovalList.vue +127 -127
  141. package/src/components/senior/EbizSData/index.vue +280 -280
  142. package/src/components/senior/EbizSDialog/index.vue +776 -776
  143. package/src/components/senior/EbizSForm/README.md +157 -157
  144. package/src/components/senior/EbizSForm/index.vue +667 -667
  145. package/src/components/senior/EbizSForm/item.vue +1011 -1011
  146. package/src/components/senior/EbizSForm/mItems/DateTimePicker.vue +51 -51
  147. package/src/components/senior/EbizSForm/mItems/Picker.vue +63 -63
  148. package/src/index.js +327 -327
  149. package/src/main.js +55 -55
  150. package/src/router/index.js +436 -436
  151. package/src/utils/formatCode.js +24 -24
  152. package/src/utils/generateImportStatement.js +52 -52
  153. package/src/utils/hasJsx.js +25 -25
  154. package/src/utils/index.js +166 -166
  155. package/src/utils/mergeOptions.js +29 -29
  156. package/src/utils/parseRequiredBlocks.js +18 -18
  157. package/src/utils/vue-sfc-validator.js +155 -155
  158. package/src/views/Button.vue +23 -23
  159. package/src/views/CheckboxDemo.vue +104 -104
  160. package/src/views/DataContainer.vue +19 -19
  161. package/src/views/DialogDemo.vue +125 -125
  162. package/src/views/EbizApprovalDemo.vue +87 -87
  163. package/src/views/EbizApprovalFormDemo.vue +207 -207
  164. package/src/views/EbizAutoFormDemo.vue +129 -129
  165. package/src/views/EbizAvatar.vue +223 -223
  166. package/src/views/EbizDepartmentSelectorDemo.vue +169 -169
  167. package/src/views/EbizDetailBlockDemo.vue +30 -30
  168. package/src/views/EbizDetailViewDemo.vue +412 -412
  169. package/src/views/EbizDormDashboardDemo.vue +87 -87
  170. package/src/views/EbizEmployeeInfo.vue +249 -249
  171. package/src/views/EbizEmployeeSelector.vue +85 -85
  172. package/src/views/EbizFileListDemo.vue +339 -339
  173. package/src/views/EbizMap.vue +201 -201
  174. package/src/views/EbizMeetingRoomSelectorDemo.vue +293 -293
  175. package/src/views/EbizMobileMeetingRoomSelectorDemo.vue +566 -566
  176. package/src/views/EbizParkingDashboardDemo.vue +28 -28
  177. package/src/views/EbizRadioDemo.vue +151 -151
  178. package/src/views/EbizSDataDemo.vue +136 -136
  179. package/src/views/EbizSDialogDemo.vue +303 -303
  180. package/src/views/EbizSForm/index.vue +352 -352
  181. package/src/views/EbizSFormDemo.vue +420 -420
  182. package/src/views/EbizSpace.vue +185 -185
  183. package/src/views/EbizSwiper.vue +157 -157
  184. package/src/views/EbizTdesignButtonDialogExample.vue +437 -437
  185. package/src/views/Form.vue +19 -19
  186. package/src/views/GridDemo.vue +238 -238
  187. package/src/views/Home.vue +156 -156
  188. package/src/views/LaunchInterviewDemo.vue +111 -111
  189. package/src/views/Mindmap.vue +17 -17
  190. package/src/views/MyComponent.vue +19 -19
  191. package/src/views/OkrTree.vue +19 -19
  192. package/src/views/PageHeaderDemo.vue +104 -104
  193. package/src/views/PaginationDemo.vue +96 -96
  194. package/src/views/PdfViewerDemo.vue +433 -433
  195. package/src/views/PermissionBoxDemo.vue +85 -85
  196. package/src/views/PopconfirmDemo.vue +80 -80
  197. package/src/views/RemoteSelect.vue +350 -350
  198. package/src/views/StatisticDemo.vue +190 -190
  199. package/src/views/SwitchDemo.vue +79 -79
  200. package/src/views/Table.vue +19 -19
  201. package/src/views/TableDemo.vue +334 -334
  202. package/src/views/TableSortDemo.vue +143 -143
  203. package/src/views/TableView.vue +68 -68
  204. package/src/views/TabsDemo.vue +282 -282
  205. package/src/views/TagDemo.vue +101 -101
  206. package/src/views/TdesignAlert.vue +98 -98
  207. package/src/views/TdesignButton.vue +190 -190
  208. package/src/views/TdesignCalendar.vue +94 -94
  209. package/src/views/TdesignCard.vue +296 -296
  210. package/src/views/TdesignCollapse.vue +293 -293
  211. package/src/views/TdesignDatePicker.vue +187 -187
  212. package/src/views/TdesignDescriptions.vue +101 -101
  213. package/src/views/TdesignForm.vue +248 -248
  214. package/src/views/TdesignIcon.vue +203 -203
  215. package/src/views/TdesignImage.vue +215 -215
  216. package/src/views/TdesignImageViewer.vue +198 -198
  217. package/src/views/TdesignInput.vue +252 -252
  218. package/src/views/TdesignSelect.vue +473 -473
  219. package/src/views/TdesignSwiper.vue +157 -157
  220. package/src/views/TextareaDemo.vue +93 -93
  221. package/src/views/TimePickerDemo.vue +146 -146
  222. package/src/views/TimelineDemo.vue +160 -160
  223. package/src/views/Title.vue +19 -19
  224. package/src/views/TreeDemo.vue +254 -254
  225. package/src/views/TreeMergeTableDemo.vue +239 -239
  226. package/src/views/TreeSelectorDemo.vue +245 -245
  227. package/src/views/UploadDemo.vue +128 -128
  228. package/src/views/VideoDemo.vue +245 -245
  229. package/src/views/VxeTableDemo.vue +279 -279
  230. package/src/views/WatermarkDemo.vue +85 -85
@@ -1,503 +1,503 @@
1
- <template>
2
- <div class="ebiz-file-list" :class="{ 'mini-mode': size === 'mini' }">
3
- <div v-if="computedFiles.length === 0" class="empty-state">
4
- <div>-</div>
5
- </div>
6
- <div v-else class="file-list-container" :class="{ 'mini-container': size === 'mini' }">
7
- <div v-for="(file, index) in computedFiles" :key="index" class="file-item"
8
- :class="{ 'mini-item': size === 'mini' }" @click="handleFileClick(file)">
9
- <!-- 图片文件直接显示缩略图 -->
10
- <div v-if="isImage(file.extension)" class="file-icon">
11
- <t-image :src="file.url" :alt="file.name" fit="cover" loading="lazy"
12
- :style="{ width: actualImageSize, height: actualImageSize, borderRadius: '4px' }" error="" />
13
- </div>
14
-
15
- <!-- 非图片文件显示图标 -->
16
- <div v-else class="file-icon">
17
- <t-icon :name="getFileIcon(file.extension)" :size="actualImageSize"
18
- :style="{ color: getFileColor(file.extension) }" />
19
- </div>
20
-
21
- <div v-if="size !== 'mini'" class="file-info">
22
- <div class="file-name" :title="file.name">{{ file.name }}</div>
23
- <div class="file-meta">
24
- <span v-if="showFileType" class="file-type">{{ file.extension?.toUpperCase() || '未知' }}</span>
25
- <span v-if="showFileSize && file.size" class="file-size">{{ formatFileSize(file.size) }}</span>
26
- </div>
27
- </div>
28
-
29
- <!-- 操作按钮 -->
30
- <div v-if="showActions && size !== 'mini'" class="file-actions">
31
- <t-button size="small" variant="text" @click.stop="handleDownload(file)"
32
- :title="isImage(file.extension) ? '查看' : '下载'">
33
- <t-icon :name="isImage(file.extension) ? 'view-list' : 'download'" />
34
- </t-button>
35
- <t-button v-if="allowDelete" size="small" variant="text" theme="danger"
36
- @click.stop="handleDelete(file, index)" title="删除">
37
- <t-icon name="delete" />
38
- </t-button>
39
- </div>
40
- </div>
41
- </div>
42
-
43
- <!-- 图片预览弹窗 -->
44
- <t-image-viewer v-model:visible="previewVisible" :images="previewImages" :index="previewIndex" :close-on-esc="true"
45
- @close="previewVisible = false" />
46
- </div>
47
- </template>
48
-
49
- <script>
50
- export default {
51
- name: "EbizFileList"
52
- }
53
- </script>
54
-
55
- <script setup>
56
- import { defineProps, defineEmits, computed, ref } from 'vue';
57
- import { Image as TImage, ImageViewer as TImageViewer, Icon as TIcon, Button as TButton } from 'tdesign-vue-next';
58
-
59
- const props = defineProps({
60
- // 文件列表数据,支持数组或字符串(逗号分隔)
61
- files: {
62
- type: [Array, String],
63
- default: () => []
64
- },
65
- // 尺寸大小,支持default和mini
66
- size: {
67
- type: String,
68
- default: 'default'
69
- },
70
- // 图片尺寸
71
- imageSize: {
72
- type: String,
73
- default: '50px'
74
- },
75
- // 是否显示文件大小
76
- showFileSize: {
77
- type: Boolean,
78
- default: true
79
- },
80
- // 是否显示文件类型
81
- showFileType: {
82
- type: Boolean,
83
- default: true
84
- },
85
- // 是否显示操作按钮
86
- showActions: {
87
- type: Boolean,
88
- default: true
89
- },
90
- // 是否允许删除
91
- allowDelete: {
92
- type: Boolean,
93
- default: false
94
- },
95
- // 文件基础URL(用于相对路径)
96
- baseUrl: {
97
- type: String,
98
- default: ''
99
- }
100
- });
101
-
102
- const emit = defineEmits(['file-click', 'file-download', 'file-delete', 'file-preview']);
103
-
104
- // 预览相关状态
105
- const previewVisible = ref(false);
106
- const previewImages = ref([]);
107
- const previewIndex = ref(0);
108
-
109
- // 获取完整URL
110
- const getFullUrl = (url) => {
111
- if (!url) return '';
112
- if (url.startsWith('http') || url.startsWith('data:')) return url;
113
- return props.baseUrl + url;
114
- };
115
-
116
- // 获取文件扩展名
117
- const getFileExtension = (filename) => {
118
- if (!filename) return '';
119
- // 移除查询参数和锚点
120
- const cleanFilename = filename.split('?')[0].split('#')[0];
121
- const parts = cleanFilename.split('.');
122
- return parts.length > 1 ? parts.pop().toLowerCase() : '';
123
- };
124
-
125
- // 提取文件名
126
- const extractFileName = (url) => {
127
- if (!url) return '未知文件';
128
-
129
- // 移除查询参数和锚点
130
- const cleanUrl = url.split('?')[0].split('#')[0];
131
- const parts = cleanUrl.split('/');
132
- let fileName = parts[parts.length - 1] || '未知文件';
133
-
134
- // 如果文件名为空或只是扩展名,生成一个默认名称
135
- if (!fileName || fileName.startsWith('.')) {
136
- const extension = getFileExtension(fileName || url);
137
- fileName = extension ? `文件.${extension}` : '未知文件';
138
- }
139
-
140
- return fileName;
141
- };
142
-
143
- // 解析文件信息
144
- const parseFileInfo = (url) => {
145
- const fullUrl = getFullUrl(url);
146
- const fileName = extractFileName(url);
147
- const extension = getFileExtension(fileName);
148
-
149
- return {
150
- name: fileName,
151
- url: fullUrl,
152
- extension,
153
- size: null
154
- };
155
- };
156
-
157
- // 计算文件列表
158
- const computedFiles = computed(() => {
159
- let fileList = [];
160
-
161
- if (typeof props.files === 'string') {
162
- if (!props.files.trim()) {
163
- return [];
164
- }
165
-
166
- // 判断是否为JSON字符串
167
- const trimmedFiles = props.files.trim();
168
- if (trimmedFiles.startsWith('[') && trimmedFiles.endsWith(']')) {
169
- try {
170
- // 尝试解析JSON字符串
171
- const parsedArray = JSON.parse(trimmedFiles);
172
- if (Array.isArray(parsedArray)) {
173
- // 解析成功,处理数组中的每个元素
174
- fileList = parsedArray.map(item => {
175
- if (typeof item === 'string') {
176
- // 数组中的字符串元素,作为URL处理
177
- return parseFileInfo(item);
178
- } else if (item && typeof item === 'object') {
179
- // 对象格式的文件信息
180
- const url = item.url || item.src || item.path || '';
181
- return {
182
- name: item.name || extractFileName(url),
183
- url: getFullUrl(url),
184
- size: item.size || null,
185
- extension: item.extension || getFileExtension(url || item.name || ''),
186
- ...item
187
- };
188
- } else {
189
- // 其他情况,返回默认对象
190
- return {
191
- name: '未知文件',
192
- url: '',
193
- extension: '',
194
- size: null
195
- };
196
- }
197
- });
198
- } else {
199
- // 解析出来不是数组,按普通字符串处理
200
- fileList = [parseFileInfo(trimmedFiles)];
201
- }
202
- } catch (e) {
203
- // JSON解析失败,按普通字符串处理
204
- fileList = [parseFileInfo(trimmedFiles)];
205
- }
206
- } else if (props.files.includes(',')) {
207
- // 逗号分隔的多个URL
208
- const urls = props.files.split(',').map(url => url.trim()).filter(url => url);
209
- fileList = urls.map(url => parseFileInfo(url));
210
- } else {
211
- // 单个URL
212
- fileList = [parseFileInfo(props.files.trim())];
213
- }
214
- } else if (Array.isArray(props.files)) {
215
- // 数组格式
216
- fileList = props.files.map(file => {
217
- if (typeof file === 'string') {
218
- // 数组中的字符串元素,直接作为URL处理
219
- return parseFileInfo(file);
220
- } else if (file && typeof file === 'object') {
221
- // 对象格式的文件信息
222
- const url = file.url || file.src || file.path || '';
223
- return {
224
- name: file.name || extractFileName(url),
225
- url: getFullUrl(url),
226
- size: file.size || null,
227
- extension: file.extension || getFileExtension(url || file.name || ''),
228
- ...file
229
- };
230
- } else {
231
- // 其他情况,返回默认对象
232
- return {
233
- name: '未知文件',
234
- url: '',
235
- extension: '',
236
- size: null
237
- };
238
- }
239
- }).filter(file => file.url); // 过滤掉没有URL的文件
240
- }
241
-
242
- return fileList;
243
- });
244
-
245
- // 判断是否为图片
246
- const isImage = (extension) => {
247
- const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'];
248
- return imageExtensions.includes(extension?.toLowerCase());
249
- };
250
-
251
- // 获取文件图标
252
- const getFileIcon = (extension) => {
253
- const iconMap = {
254
- // 文档类
255
- 'pdf': 'file-pdf',
256
- 'doc': 'file-word',
257
- 'docx': 'file-word',
258
- 'xls': 'file-excel',
259
- 'xlsx': 'file-excel',
260
- 'ppt': 'file-powerpoint',
261
- 'pptx': 'file-powerpoint',
262
- 'txt': 'file-text',
263
- 'rtf': 'file-text',
264
- // 代码类
265
- 'js': 'file-code',
266
- 'ts': 'file-code',
267
- 'html': 'file-code',
268
- 'css': 'file-code',
269
- 'json': 'file-code',
270
- 'xml': 'file-code',
271
- // 压缩类
272
- 'zip': 'file-zip',
273
- 'rar': 'file-zip',
274
- '7z': 'file-zip',
275
- 'tar': 'file-zip',
276
- 'gz': 'file-zip',
277
- // 音视频类
278
- 'mp3': 'file-music',
279
- 'wav': 'file-music',
280
- 'mp4': 'file-video',
281
- 'avi': 'file-video',
282
- 'mov': 'file-video',
283
- 'wmv': 'file-video'
284
- };
285
-
286
- return iconMap[extension?.toLowerCase()] || 'file';
287
- };
288
-
289
- // 获取文件颜色
290
- const getFileColor = (extension) => {
291
- const colorMap = {
292
- 'pdf': '#FF4757',
293
- 'doc': '#2E5BFF',
294
- 'docx': '#2E5BFF',
295
- 'xls': '#00A854',
296
- 'xlsx': '#00A854',
297
- 'ppt': '#FF8C42',
298
- 'pptx': '#FF8C42',
299
- 'txt': '#666666',
300
- 'zip': '#9C27B0',
301
- 'rar': '#9C27B0',
302
- 'mp3': '#FF9800',
303
- 'mp4': '#795548'
304
- };
305
-
306
- return colorMap[extension?.toLowerCase()] || '#666666';
307
- };
308
-
309
- // 计算实际使用的图片尺寸
310
- const actualImageSize = computed(() => {
311
- return props.size === 'mini' ? '20px' : props.imageSize;
312
- });
313
-
314
- // 格式化文件大小
315
- const formatFileSize = (bytes) => {
316
- if (!bytes) return '';
317
- const units = ['B', 'KB', 'MB', 'GB'];
318
- let size = bytes;
319
- let unitIndex = 0;
320
-
321
- while (size >= 1024 && unitIndex < units.length - 1) {
322
- size /= 1024;
323
- unitIndex++;
324
- }
325
-
326
- return `${size.toFixed(1)} ${units[unitIndex]}`;
327
- };
328
-
329
- // 是否可在线预览
330
- const canPreviewOnline = (extension) => {
331
- const onlinePreviewExtensions = ['pdf', 'txt', 'html', 'xml', 'json'];
332
- return onlinePreviewExtensions.includes(extension?.toLowerCase());
333
- };
334
-
335
- // 文件下载
336
- const handleDownload = (file) => {
337
- const link = document.createElement('a');
338
- link.href = file.url;
339
- link.download = file.name;
340
- link.target = '_blank';
341
- document.body.appendChild(link);
342
- link.click();
343
- document.body.removeChild(link);
344
-
345
- emit('file-download', file);
346
- };
347
-
348
- // 图片预览
349
- const handlePreview = (file) => {
350
- const imageFiles = computedFiles.value.filter(f => isImage(f.extension));
351
- previewImages.value = imageFiles.map(f => f.url);
352
- previewIndex.value = imageFiles.findIndex(f => f.url === file.url);
353
- previewVisible.value = true;
354
-
355
- emit('file-preview', file);
356
- };
357
-
358
- // 文件点击处理
359
- const handleFileClick = (file) => {
360
- emit('file-click', file);
361
-
362
- if (isImage(file.extension)) {
363
- // 图片文件,显示预览
364
- handlePreview(file);
365
- } else if (canPreviewOnline(file.extension)) {
366
- // 可在线预览的文件
367
- window.open(file.url, '_blank');
368
- } else {
369
- // 其他文件,触发下载
370
- handleDownload(file);
371
- }
372
- };
373
-
374
- // 文件删除
375
- const handleDelete = (file, index) => {
376
- emit('file-delete', file, index);
377
- };
378
-
379
- // 图片加载错误处理
380
- const handleImageError = () => {
381
- // 图片加载失败时的处理
382
- };
383
- </script>
384
-
385
- <style lang="less" scoped>
386
- .ebiz-file-list {
387
- width: 100%;
388
-
389
- &.mini-mode {
390
- .file-list-container {
391
- display: flex;
392
- flex-direction: row;
393
- flex-wrap: wrap;
394
- gap: 4px;
395
- }
396
- }
397
-
398
- .empty-state {
399
- display: flex;
400
- flex-direction: column;
401
- padding: 10px;
402
- color: #999;
403
-
404
- p {
405
- margin: 8px 0 0 0;
406
- font-size: 12px;
407
- }
408
- }
409
-
410
- .file-list-container {
411
- display: flex;
412
- flex-direction: column;
413
- gap: 8px;
414
-
415
- &.mini-container {
416
- flex-direction: row;
417
- flex-wrap: wrap;
418
- }
419
- }
420
-
421
- .file-item {
422
- display: flex;
423
- align-items: center;
424
- padding: 8px 12px;
425
- border: 1px solid #e6e6e6;
426
- border-radius: 6px;
427
- cursor: pointer;
428
- transition: all 0.3s;
429
- background: #fff;
430
-
431
- &.mini-item {
432
- padding: 0;
433
- border: none;
434
- background: transparent;
435
- box-shadow: none;
436
- margin-right: 8px;
437
- margin-bottom: 8px;
438
-
439
- &:hover {
440
- border-color: transparent;
441
- box-shadow: none;
442
- }
443
- }
444
-
445
- &:hover {
446
- border-color: #0052d9;
447
- box-shadow: 0 2px 8px rgba(0, 82, 217, 0.15);
448
-
449
- .file-actions {
450
- opacity: 1;
451
- }
452
- }
453
- }
454
-
455
- .file-icon {
456
- margin-right: 12px;
457
- flex-shrink: 0;
458
- display: flex;
459
- align-items: center;
460
- justify-content: center;
461
- width: v-bind(actualImageSize);
462
- height: v-bind(actualImageSize);
463
-
464
- .mini-item & {
465
- margin-right: 0;
466
- }
467
- }
468
-
469
- .file-info {
470
- flex: 1;
471
- min-width: 0;
472
-
473
- .file-name {
474
- font-size: 14px;
475
- font-weight: 500;
476
- color: #333;
477
- margin-bottom: 3px;
478
- overflow: hidden;
479
- text-overflow: ellipsis;
480
- white-space: nowrap;
481
- }
482
-
483
- .file-meta {
484
- display: flex;
485
- gap: 8px;
486
-
487
- .file-size,
488
- .file-type {
489
- font-size: 12px;
490
- color: #999;
491
- }
492
- }
493
- }
494
-
495
- .file-actions {
496
- display: flex;
497
- gap: 4px;
498
- opacity: 0;
499
- transition: opacity 0.3s;
500
- flex-shrink: 0;
501
- }
502
- }
1
+ <template>
2
+ <div class="ebiz-file-list" :class="{ 'mini-mode': size === 'mini' }">
3
+ <div v-if="computedFiles.length === 0" class="empty-state">
4
+ <div>-</div>
5
+ </div>
6
+ <div v-else class="file-list-container" :class="{ 'mini-container': size === 'mini' }">
7
+ <div v-for="(file, index) in computedFiles" :key="index" class="file-item"
8
+ :class="{ 'mini-item': size === 'mini' }" @click="handleFileClick(file)">
9
+ <!-- 图片文件直接显示缩略图 -->
10
+ <div v-if="isImage(file.extension)" class="file-icon">
11
+ <t-image :src="file.url" :alt="file.name" fit="cover" loading="lazy"
12
+ :style="{ width: actualImageSize, height: actualImageSize, borderRadius: '4px' }" error="" />
13
+ </div>
14
+
15
+ <!-- 非图片文件显示图标 -->
16
+ <div v-else class="file-icon">
17
+ <t-icon :name="getFileIcon(file.extension)" :size="actualImageSize"
18
+ :style="{ color: getFileColor(file.extension) }" />
19
+ </div>
20
+
21
+ <div v-if="size !== 'mini'" class="file-info">
22
+ <div class="file-name" :title="file.name">{{ file.name }}</div>
23
+ <div class="file-meta">
24
+ <span v-if="showFileType" class="file-type">{{ file.extension?.toUpperCase() || '未知' }}</span>
25
+ <span v-if="showFileSize && file.size" class="file-size">{{ formatFileSize(file.size) }}</span>
26
+ </div>
27
+ </div>
28
+
29
+ <!-- 操作按钮 -->
30
+ <div v-if="showActions && size !== 'mini'" class="file-actions">
31
+ <t-button size="small" variant="text" @click.stop="handleDownload(file)"
32
+ :title="isImage(file.extension) ? '查看' : '下载'">
33
+ <t-icon :name="isImage(file.extension) ? 'view-list' : 'download'" />
34
+ </t-button>
35
+ <t-button v-if="allowDelete" size="small" variant="text" theme="danger"
36
+ @click.stop="handleDelete(file, index)" title="删除">
37
+ <t-icon name="delete" />
38
+ </t-button>
39
+ </div>
40
+ </div>
41
+ </div>
42
+
43
+ <!-- 图片预览弹窗 -->
44
+ <t-image-viewer v-model:visible="previewVisible" :images="previewImages" :index="previewIndex" :close-on-esc="true"
45
+ @close="previewVisible = false" />
46
+ </div>
47
+ </template>
48
+
49
+ <script>
50
+ export default {
51
+ name: "EbizFileList"
52
+ }
53
+ </script>
54
+
55
+ <script setup>
56
+ import { defineProps, defineEmits, computed, ref } from 'vue';
57
+ import { Image as TImage, ImageViewer as TImageViewer, Icon as TIcon, Button as TButton } from 'tdesign-vue-next';
58
+
59
+ const props = defineProps({
60
+ // 文件列表数据,支持数组或字符串(逗号分隔)
61
+ files: {
62
+ type: [Array, String],
63
+ default: () => []
64
+ },
65
+ // 尺寸大小,支持default和mini
66
+ size: {
67
+ type: String,
68
+ default: 'default'
69
+ },
70
+ // 图片尺寸
71
+ imageSize: {
72
+ type: String,
73
+ default: '50px'
74
+ },
75
+ // 是否显示文件大小
76
+ showFileSize: {
77
+ type: Boolean,
78
+ default: true
79
+ },
80
+ // 是否显示文件类型
81
+ showFileType: {
82
+ type: Boolean,
83
+ default: true
84
+ },
85
+ // 是否显示操作按钮
86
+ showActions: {
87
+ type: Boolean,
88
+ default: true
89
+ },
90
+ // 是否允许删除
91
+ allowDelete: {
92
+ type: Boolean,
93
+ default: false
94
+ },
95
+ // 文件基础URL(用于相对路径)
96
+ baseUrl: {
97
+ type: String,
98
+ default: ''
99
+ }
100
+ });
101
+
102
+ const emit = defineEmits(['file-click', 'file-download', 'file-delete', 'file-preview']);
103
+
104
+ // 预览相关状态
105
+ const previewVisible = ref(false);
106
+ const previewImages = ref([]);
107
+ const previewIndex = ref(0);
108
+
109
+ // 获取完整URL
110
+ const getFullUrl = (url) => {
111
+ if (!url) return '';
112
+ if (url.startsWith('http') || url.startsWith('data:')) return url;
113
+ return props.baseUrl + url;
114
+ };
115
+
116
+ // 获取文件扩展名
117
+ const getFileExtension = (filename) => {
118
+ if (!filename) return '';
119
+ // 移除查询参数和锚点
120
+ const cleanFilename = filename.split('?')[0].split('#')[0];
121
+ const parts = cleanFilename.split('.');
122
+ return parts.length > 1 ? parts.pop().toLowerCase() : '';
123
+ };
124
+
125
+ // 提取文件名
126
+ const extractFileName = (url) => {
127
+ if (!url) return '未知文件';
128
+
129
+ // 移除查询参数和锚点
130
+ const cleanUrl = url.split('?')[0].split('#')[0];
131
+ const parts = cleanUrl.split('/');
132
+ let fileName = parts[parts.length - 1] || '未知文件';
133
+
134
+ // 如果文件名为空或只是扩展名,生成一个默认名称
135
+ if (!fileName || fileName.startsWith('.')) {
136
+ const extension = getFileExtension(fileName || url);
137
+ fileName = extension ? `文件.${extension}` : '未知文件';
138
+ }
139
+
140
+ return fileName;
141
+ };
142
+
143
+ // 解析文件信息
144
+ const parseFileInfo = (url) => {
145
+ const fullUrl = getFullUrl(url);
146
+ const fileName = extractFileName(url);
147
+ const extension = getFileExtension(fileName);
148
+
149
+ return {
150
+ name: fileName,
151
+ url: fullUrl,
152
+ extension,
153
+ size: null
154
+ };
155
+ };
156
+
157
+ // 计算文件列表
158
+ const computedFiles = computed(() => {
159
+ let fileList = [];
160
+
161
+ if (typeof props.files === 'string') {
162
+ if (!props.files.trim()) {
163
+ return [];
164
+ }
165
+
166
+ // 判断是否为JSON字符串
167
+ const trimmedFiles = props.files.trim();
168
+ if (trimmedFiles.startsWith('[') && trimmedFiles.endsWith(']')) {
169
+ try {
170
+ // 尝试解析JSON字符串
171
+ const parsedArray = JSON.parse(trimmedFiles);
172
+ if (Array.isArray(parsedArray)) {
173
+ // 解析成功,处理数组中的每个元素
174
+ fileList = parsedArray.map(item => {
175
+ if (typeof item === 'string') {
176
+ // 数组中的字符串元素,作为URL处理
177
+ return parseFileInfo(item);
178
+ } else if (item && typeof item === 'object') {
179
+ // 对象格式的文件信息
180
+ const url = item.url || item.src || item.path || '';
181
+ return {
182
+ name: item.name || extractFileName(url),
183
+ url: getFullUrl(url),
184
+ size: item.size || null,
185
+ extension: item.extension || getFileExtension(url || item.name || ''),
186
+ ...item
187
+ };
188
+ } else {
189
+ // 其他情况,返回默认对象
190
+ return {
191
+ name: '未知文件',
192
+ url: '',
193
+ extension: '',
194
+ size: null
195
+ };
196
+ }
197
+ });
198
+ } else {
199
+ // 解析出来不是数组,按普通字符串处理
200
+ fileList = [parseFileInfo(trimmedFiles)];
201
+ }
202
+ } catch (e) {
203
+ // JSON解析失败,按普通字符串处理
204
+ fileList = [parseFileInfo(trimmedFiles)];
205
+ }
206
+ } else if (props.files.includes(',')) {
207
+ // 逗号分隔的多个URL
208
+ const urls = props.files.split(',').map(url => url.trim()).filter(url => url);
209
+ fileList = urls.map(url => parseFileInfo(url));
210
+ } else {
211
+ // 单个URL
212
+ fileList = [parseFileInfo(props.files.trim())];
213
+ }
214
+ } else if (Array.isArray(props.files)) {
215
+ // 数组格式
216
+ fileList = props.files.map(file => {
217
+ if (typeof file === 'string') {
218
+ // 数组中的字符串元素,直接作为URL处理
219
+ return parseFileInfo(file);
220
+ } else if (file && typeof file === 'object') {
221
+ // 对象格式的文件信息
222
+ const url = file.url || file.src || file.path || '';
223
+ return {
224
+ name: file.name || extractFileName(url),
225
+ url: getFullUrl(url),
226
+ size: file.size || null,
227
+ extension: file.extension || getFileExtension(url || file.name || ''),
228
+ ...file
229
+ };
230
+ } else {
231
+ // 其他情况,返回默认对象
232
+ return {
233
+ name: '未知文件',
234
+ url: '',
235
+ extension: '',
236
+ size: null
237
+ };
238
+ }
239
+ }).filter(file => file.url); // 过滤掉没有URL的文件
240
+ }
241
+
242
+ return fileList;
243
+ });
244
+
245
+ // 判断是否为图片
246
+ const isImage = (extension) => {
247
+ const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'];
248
+ return imageExtensions.includes(extension?.toLowerCase());
249
+ };
250
+
251
+ // 获取文件图标
252
+ const getFileIcon = (extension) => {
253
+ const iconMap = {
254
+ // 文档类
255
+ 'pdf': 'file-pdf',
256
+ 'doc': 'file-word',
257
+ 'docx': 'file-word',
258
+ 'xls': 'file-excel',
259
+ 'xlsx': 'file-excel',
260
+ 'ppt': 'file-powerpoint',
261
+ 'pptx': 'file-powerpoint',
262
+ 'txt': 'file-text',
263
+ 'rtf': 'file-text',
264
+ // 代码类
265
+ 'js': 'file-code',
266
+ 'ts': 'file-code',
267
+ 'html': 'file-code',
268
+ 'css': 'file-code',
269
+ 'json': 'file-code',
270
+ 'xml': 'file-code',
271
+ // 压缩类
272
+ 'zip': 'file-zip',
273
+ 'rar': 'file-zip',
274
+ '7z': 'file-zip',
275
+ 'tar': 'file-zip',
276
+ 'gz': 'file-zip',
277
+ // 音视频类
278
+ 'mp3': 'file-music',
279
+ 'wav': 'file-music',
280
+ 'mp4': 'file-video',
281
+ 'avi': 'file-video',
282
+ 'mov': 'file-video',
283
+ 'wmv': 'file-video'
284
+ };
285
+
286
+ return iconMap[extension?.toLowerCase()] || 'file';
287
+ };
288
+
289
+ // 获取文件颜色
290
+ const getFileColor = (extension) => {
291
+ const colorMap = {
292
+ 'pdf': '#FF4757',
293
+ 'doc': '#2E5BFF',
294
+ 'docx': '#2E5BFF',
295
+ 'xls': '#00A854',
296
+ 'xlsx': '#00A854',
297
+ 'ppt': '#FF8C42',
298
+ 'pptx': '#FF8C42',
299
+ 'txt': '#666666',
300
+ 'zip': '#9C27B0',
301
+ 'rar': '#9C27B0',
302
+ 'mp3': '#FF9800',
303
+ 'mp4': '#795548'
304
+ };
305
+
306
+ return colorMap[extension?.toLowerCase()] || '#666666';
307
+ };
308
+
309
+ // 计算实际使用的图片尺寸
310
+ const actualImageSize = computed(() => {
311
+ return props.size === 'mini' ? '20px' : props.imageSize;
312
+ });
313
+
314
+ // 格式化文件大小
315
+ const formatFileSize = (bytes) => {
316
+ if (!bytes) return '';
317
+ const units = ['B', 'KB', 'MB', 'GB'];
318
+ let size = bytes;
319
+ let unitIndex = 0;
320
+
321
+ while (size >= 1024 && unitIndex < units.length - 1) {
322
+ size /= 1024;
323
+ unitIndex++;
324
+ }
325
+
326
+ return `${size.toFixed(1)} ${units[unitIndex]}`;
327
+ };
328
+
329
+ // 是否可在线预览
330
+ const canPreviewOnline = (extension) => {
331
+ const onlinePreviewExtensions = ['pdf', 'txt', 'html', 'xml', 'json'];
332
+ return onlinePreviewExtensions.includes(extension?.toLowerCase());
333
+ };
334
+
335
+ // 文件下载
336
+ const handleDownload = (file) => {
337
+ const link = document.createElement('a');
338
+ link.href = file.url;
339
+ link.download = file.name;
340
+ link.target = '_blank';
341
+ document.body.appendChild(link);
342
+ link.click();
343
+ document.body.removeChild(link);
344
+
345
+ emit('file-download', file);
346
+ };
347
+
348
+ // 图片预览
349
+ const handlePreview = (file) => {
350
+ const imageFiles = computedFiles.value.filter(f => isImage(f.extension));
351
+ previewImages.value = imageFiles.map(f => f.url);
352
+ previewIndex.value = imageFiles.findIndex(f => f.url === file.url);
353
+ previewVisible.value = true;
354
+
355
+ emit('file-preview', file);
356
+ };
357
+
358
+ // 文件点击处理
359
+ const handleFileClick = (file) => {
360
+ emit('file-click', file);
361
+
362
+ if (isImage(file.extension)) {
363
+ // 图片文件,显示预览
364
+ handlePreview(file);
365
+ } else if (canPreviewOnline(file.extension)) {
366
+ // 可在线预览的文件
367
+ window.open(file.url, '_blank');
368
+ } else {
369
+ // 其他文件,触发下载
370
+ handleDownload(file);
371
+ }
372
+ };
373
+
374
+ // 文件删除
375
+ const handleDelete = (file, index) => {
376
+ emit('file-delete', file, index);
377
+ };
378
+
379
+ // 图片加载错误处理
380
+ const handleImageError = () => {
381
+ // 图片加载失败时的处理
382
+ };
383
+ </script>
384
+
385
+ <style lang="less" scoped>
386
+ .ebiz-file-list {
387
+ width: 100%;
388
+
389
+ &.mini-mode {
390
+ .file-list-container {
391
+ display: flex;
392
+ flex-direction: row;
393
+ flex-wrap: wrap;
394
+ gap: 4px;
395
+ }
396
+ }
397
+
398
+ .empty-state {
399
+ display: flex;
400
+ flex-direction: column;
401
+ padding: 10px;
402
+ color: #999;
403
+
404
+ p {
405
+ margin: 8px 0 0 0;
406
+ font-size: 12px;
407
+ }
408
+ }
409
+
410
+ .file-list-container {
411
+ display: flex;
412
+ flex-direction: column;
413
+ gap: 8px;
414
+
415
+ &.mini-container {
416
+ flex-direction: row;
417
+ flex-wrap: wrap;
418
+ }
419
+ }
420
+
421
+ .file-item {
422
+ display: flex;
423
+ align-items: center;
424
+ padding: 8px 12px;
425
+ border: 1px solid #e6e6e6;
426
+ border-radius: 6px;
427
+ cursor: pointer;
428
+ transition: all 0.3s;
429
+ background: #fff;
430
+
431
+ &.mini-item {
432
+ padding: 0;
433
+ border: none;
434
+ background: transparent;
435
+ box-shadow: none;
436
+ margin-right: 8px;
437
+ margin-bottom: 8px;
438
+
439
+ &:hover {
440
+ border-color: transparent;
441
+ box-shadow: none;
442
+ }
443
+ }
444
+
445
+ &:hover {
446
+ border-color: #0052d9;
447
+ box-shadow: 0 2px 8px rgba(0, 82, 217, 0.15);
448
+
449
+ .file-actions {
450
+ opacity: 1;
451
+ }
452
+ }
453
+ }
454
+
455
+ .file-icon {
456
+ margin-right: 12px;
457
+ flex-shrink: 0;
458
+ display: flex;
459
+ align-items: center;
460
+ justify-content: center;
461
+ width: v-bind(actualImageSize);
462
+ height: v-bind(actualImageSize);
463
+
464
+ .mini-item & {
465
+ margin-right: 0;
466
+ }
467
+ }
468
+
469
+ .file-info {
470
+ flex: 1;
471
+ min-width: 0;
472
+
473
+ .file-name {
474
+ font-size: 14px;
475
+ font-weight: 500;
476
+ color: #333;
477
+ margin-bottom: 3px;
478
+ overflow: hidden;
479
+ text-overflow: ellipsis;
480
+ white-space: nowrap;
481
+ }
482
+
483
+ .file-meta {
484
+ display: flex;
485
+ gap: 8px;
486
+
487
+ .file-size,
488
+ .file-type {
489
+ font-size: 12px;
490
+ color: #999;
491
+ }
492
+ }
493
+ }
494
+
495
+ .file-actions {
496
+ display: flex;
497
+ gap: 4px;
498
+ opacity: 0;
499
+ transition: opacity 0.3s;
500
+ flex-shrink: 0;
501
+ }
502
+ }
503
503
  </style>