@ebiz/designer-components 0.1.90 → 0.1.91

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 (222) hide show
  1. package/README.md +29 -29
  2. package/dist/designer-components.css +1 -1
  3. package/dist/index.mjs +19156 -19199
  4. package/package.json +1 -1
  5. package/src/App.vue +26 -26
  6. package/src/apiService/SIMPLE_DATA_SERVICE.md +284 -284
  7. package/src/apiService/mockDataService.js +115 -115
  8. package/src/apiService/simpleDataService.js +299 -299
  9. package/src/assets/base.css +86 -86
  10. package/src/assets/logo.svg +1 -1
  11. package/src/components/Button.vue +149 -149
  12. package/src/components/DataContainer.vue +40 -40
  13. package/src/components/EbizApproval.vue +338 -338
  14. package/src/components/EbizApprovalForm.vue +507 -507
  15. package/src/components/EbizAutoForm.vue +596 -596
  16. package/src/components/EbizAvatar.vue +115 -115
  17. package/src/components/EbizCheckbox.vue +93 -93
  18. package/src/components/EbizCheckboxGroup.vue +69 -69
  19. package/src/components/EbizDepartmentSelector.vue +149 -149
  20. package/src/components/EbizDescriptions.vue +340 -340
  21. package/src/components/EbizDescriptionsItem.vue +47 -47
  22. package/src/components/EbizDetailBlock.vue +81 -81
  23. package/src/components/EbizDetailItem.vue +559 -559
  24. package/src/components/EbizDetailView.md +438 -438
  25. package/src/components/EbizDetailView.vue +355 -355
  26. package/src/components/EbizDialog.vue +260 -260
  27. package/src/components/EbizDictionarySelect.vue +229 -229
  28. package/src/components/EbizDiv.vue +40 -40
  29. package/src/components/EbizDivider.vue +96 -96
  30. package/src/components/EbizDropdown.vue +135 -135
  31. package/src/components/EbizDropdownItem.vue +85 -85
  32. package/src/components/EbizEmployeeInfo.vue +144 -144
  33. package/src/components/EbizEmployeeSelector.vue +1160 -1160
  34. package/src/components/EbizFileList.vue +466 -466
  35. package/src/components/EbizMap.vue +541 -541
  36. package/src/components/EbizMeetingRoomSelector.vue +664 -664
  37. package/src/components/EbizMobileMeetingRoomSelector.vue +727 -727
  38. package/src/components/EbizOkrTree.vue +99 -99
  39. package/src/components/EbizPageHeader.vue +98 -98
  40. package/src/components/EbizPagination.vue +162 -162
  41. package/src/components/EbizPdfViewer.vue +540 -540
  42. package/src/components/EbizPopconfirm.vue +47 -47
  43. package/src/components/EbizQrCode.vue +73 -73
  44. package/src/components/EbizRadio.vue +86 -86
  45. package/src/components/EbizRadioGroup.vue +83 -83
  46. package/src/components/EbizRemoteSelect.vue +232 -232
  47. package/src/components/EbizRichTextEditor.vue +275 -275
  48. package/src/components/EbizRouteBreadcrumb.vue +46 -46
  49. package/src/components/EbizSApprovalProcess.vue +1429 -1429
  50. package/src/components/EbizSelect.vue +85 -85
  51. package/src/components/EbizSpace.vue +100 -100
  52. package/src/components/EbizStatistic.vue +149 -149
  53. package/src/components/EbizStatsCard.vue +113 -113
  54. package/src/components/EbizSwiper.vue +113 -113
  55. package/src/components/EbizSwiperItem.vue +13 -13
  56. package/src/components/EbizSwitch.vue +85 -85
  57. package/src/components/EbizTabHeader.vue +132 -132
  58. package/src/components/EbizTabPanel.vue +22 -22
  59. package/src/components/EbizTable.vue +469 -469
  60. package/src/components/EbizTableColumn.vue +116 -116
  61. package/src/components/EbizTableSort.vue +179 -179
  62. package/src/components/EbizTabs.vue +142 -142
  63. package/src/components/EbizTdesignButtonDialog.vue +332 -332
  64. package/src/components/EbizTdesignLoading.vue +107 -107
  65. package/src/components/EbizTimePicker.vue +143 -143
  66. package/src/components/EbizTitle.vue +91 -91
  67. package/src/components/EbizTree.vue +141 -141
  68. package/src/components/EbizTreeMergeTable.vue +1494 -1494
  69. package/src/components/EbizTreeSelector.vue +451 -451
  70. package/src/components/EbizVideo.vue +553 -553
  71. package/src/components/EbizVxeTable.vue +290 -290
  72. package/src/components/Form.vue +28 -28
  73. package/src/components/Home.vue +7 -7
  74. package/src/components/LaunchInterview.vue +403 -403
  75. package/src/components/MyComponent.vue +39 -39
  76. package/src/components/Table.vue +45 -45
  77. package/src/components/TdesignAlert.vue +115 -115
  78. package/src/components/TdesignButton.vue +135 -135
  79. package/src/components/TdesignCalendar/index.vue +145 -145
  80. package/src/components/TdesignCard.vue +195 -195
  81. package/src/components/TdesignCol.vue +101 -101
  82. package/src/components/TdesignCollapse.vue +142 -142
  83. package/src/components/TdesignCollapsePanel.vue +79 -79
  84. package/src/components/TdesignDatePicker.vue +124 -124
  85. package/src/components/TdesignDescriptions.vue +74 -74
  86. package/src/components/TdesignDescriptionsItem.vue +50 -50
  87. package/src/components/TdesignDialog.vue +225 -225
  88. package/src/components/TdesignForm.vue +138 -138
  89. package/src/components/TdesignFormItem.vue +105 -105
  90. package/src/components/TdesignGrid.vue +55 -55
  91. package/src/components/TdesignIcon.vue +67 -67
  92. package/src/components/TdesignImage.vue +162 -162
  93. package/src/components/TdesignImageViewer.vue +200 -200
  94. package/src/components/TdesignInput.vue +242 -242
  95. package/src/components/TdesignSelect.vue +446 -446
  96. package/src/components/TdesignTag.vue +117 -117
  97. package/src/components/TdesignTextarea.vue +142 -142
  98. package/src/components/TdesignTimeline.vue +58 -58
  99. package/src/components/TdesignTimelineItem.vue +71 -71
  100. package/src/components/TdesignUpload.vue +414 -414
  101. package/src/components/TdesignWatermark.vue +107 -107
  102. package/src/components/ebiz-form/components/cascader.vue +61 -61
  103. package/src/components/ebiz-form/components/checkbox.vue +37 -37
  104. package/src/components/ebiz-form/components/city.vue +137 -137
  105. package/src/components/ebiz-form/components/date-panel.vue +52 -52
  106. package/src/components/ebiz-form/components/date-range-panel.vue +52 -52
  107. package/src/components/ebiz-form/components/date-range.vue +56 -56
  108. package/src/components/ebiz-form/components/date.vue +52 -52
  109. package/src/components/ebiz-form/components/editor-multi-language.vue +47 -47
  110. package/src/components/ebiz-form/components/editor.vue +78 -78
  111. package/src/components/ebiz-form/components/file-multi-language.vue +52 -52
  112. package/src/components/ebiz-form/components/file.vue +149 -149
  113. package/src/components/ebiz-form/components/images-multi-language.vue +52 -52
  114. package/src/components/ebiz-form/components/images.vue +129 -129
  115. package/src/components/ebiz-form/components/img-multi-language.vue +51 -51
  116. package/src/components/ebiz-form/components/img.vue +129 -129
  117. package/src/components/ebiz-form/components/number.vue +50 -50
  118. package/src/components/ebiz-form/components/radio.vue +28 -28
  119. package/src/components/ebiz-form/components/select.vue +119 -119
  120. package/src/components/ebiz-form/components/switch.vue +23 -23
  121. package/src/components/ebiz-form/components/text-multi-language.vue +47 -47
  122. package/src/components/ebiz-form/components/text.vue +52 -52
  123. package/src/components/ebiz-form/components/textarea-multi-language.vue +48 -48
  124. package/src/components/ebiz-form/components/textarea.vue +29 -29
  125. package/src/components/ebiz-form/components/video-multi-language.vue +51 -51
  126. package/src/components/ebiz-form/components/video.vue +97 -97
  127. package/src/components/ebiz-form/index.vue +157 -157
  128. package/src/components/examples/PopconfirmExample.vue +149 -149
  129. package/src/components/icons/IconCommunity.vue +7 -7
  130. package/src/components/icons/IconDocumentation.vue +7 -7
  131. package/src/components/icons/IconEcosystem.vue +7 -7
  132. package/src/components/icons/IconSupport.vue +7 -7
  133. package/src/components/icons/IconTooling.vue +19 -19
  134. package/src/components/mItems/UserInfo.vue +349 -349
  135. package/src/components/senior/EbizSData/index.vue +273 -273
  136. package/src/components/senior/EbizSDialog/index.vue +770 -770
  137. package/src/components/senior/EbizSForm/README.md +157 -157
  138. package/src/components/senior/EbizSForm/index.vue +667 -667
  139. package/src/components/senior/EbizSForm/item.vue +998 -998
  140. package/src/components/senior/EbizSForm/mItems/DateTimePicker.vue +51 -51
  141. package/src/components/senior/EbizSForm/mItems/Picker.vue +63 -63
  142. package/src/index.js +317 -317
  143. package/src/main.js +55 -55
  144. package/src/router/index.js +422 -422
  145. package/src/utils/formatCode.js +24 -24
  146. package/src/utils/generateImportStatement.js +52 -52
  147. package/src/utils/hasJsx.js +25 -25
  148. package/src/utils/index.js +166 -166
  149. package/src/utils/mergeOptions.js +29 -29
  150. package/src/utils/parseRequiredBlocks.js +18 -18
  151. package/src/utils/vue-sfc-validator.js +155 -155
  152. package/src/views/Button.vue +23 -23
  153. package/src/views/CheckboxDemo.vue +104 -104
  154. package/src/views/DataContainer.vue +19 -19
  155. package/src/views/DialogDemo.vue +125 -125
  156. package/src/views/EbizApprovalDemo.vue +87 -87
  157. package/src/views/EbizApprovalFormDemo.vue +207 -207
  158. package/src/views/EbizAutoFormDemo.vue +129 -129
  159. package/src/views/EbizAvatar.vue +223 -223
  160. package/src/views/EbizDepartmentSelectorDemo.vue +169 -169
  161. package/src/views/EbizDetailBlockDemo.vue +30 -30
  162. package/src/views/EbizDetailViewDemo.vue +412 -412
  163. package/src/views/EbizEmployeeInfo.vue +249 -249
  164. package/src/views/EbizEmployeeSelector.vue +85 -85
  165. package/src/views/EbizFileListDemo.vue +339 -339
  166. package/src/views/EbizMap.vue +201 -201
  167. package/src/views/EbizMeetingRoomSelectorDemo.vue +293 -293
  168. package/src/views/EbizMobileMeetingRoomSelectorDemo.vue +566 -566
  169. package/src/views/EbizRadioDemo.vue +151 -151
  170. package/src/views/EbizSDataDemo.vue +136 -136
  171. package/src/views/EbizSDialogDemo.vue +303 -303
  172. package/src/views/EbizSForm/index.vue +352 -352
  173. package/src/views/EbizSFormDemo.vue +420 -420
  174. package/src/views/EbizSpace.vue +185 -185
  175. package/src/views/EbizSwiper.vue +157 -157
  176. package/src/views/EbizTdesignButtonDialogExample.vue +437 -437
  177. package/src/views/Form.vue +19 -19
  178. package/src/views/GridDemo.vue +238 -238
  179. package/src/views/Home.vue +154 -154
  180. package/src/views/LaunchInterviewDemo.vue +111 -111
  181. package/src/views/Mindmap.vue +17 -17
  182. package/src/views/MyComponent.vue +19 -19
  183. package/src/views/OkrTree.vue +19 -19
  184. package/src/views/PageHeaderDemo.vue +104 -104
  185. package/src/views/PaginationDemo.vue +96 -96
  186. package/src/views/PdfViewerDemo.vue +433 -433
  187. package/src/views/PermissionBoxDemo.vue +85 -85
  188. package/src/views/PopconfirmDemo.vue +80 -80
  189. package/src/views/RemoteSelect.vue +350 -350
  190. package/src/views/StatisticDemo.vue +190 -190
  191. package/src/views/SwitchDemo.vue +79 -79
  192. package/src/views/Table.vue +19 -19
  193. package/src/views/TableDemo.vue +334 -334
  194. package/src/views/TableSortDemo.vue +143 -143
  195. package/src/views/TableView.vue +68 -68
  196. package/src/views/TabsDemo.vue +282 -282
  197. package/src/views/TagDemo.vue +101 -101
  198. package/src/views/TdesignAlert.vue +98 -98
  199. package/src/views/TdesignButton.vue +190 -190
  200. package/src/views/TdesignCalendar.vue +94 -94
  201. package/src/views/TdesignCard.vue +296 -296
  202. package/src/views/TdesignCollapse.vue +293 -293
  203. package/src/views/TdesignDatePicker.vue +187 -187
  204. package/src/views/TdesignDescriptions.vue +101 -101
  205. package/src/views/TdesignForm.vue +248 -248
  206. package/src/views/TdesignIcon.vue +203 -203
  207. package/src/views/TdesignImage.vue +215 -215
  208. package/src/views/TdesignImageViewer.vue +198 -198
  209. package/src/views/TdesignInput.vue +252 -252
  210. package/src/views/TdesignSelect.vue +473 -473
  211. package/src/views/TdesignSwiper.vue +157 -157
  212. package/src/views/TextareaDemo.vue +93 -93
  213. package/src/views/TimePickerDemo.vue +146 -146
  214. package/src/views/TimelineDemo.vue +160 -160
  215. package/src/views/Title.vue +19 -19
  216. package/src/views/TreeDemo.vue +254 -254
  217. package/src/views/TreeMergeTableDemo.vue +239 -239
  218. package/src/views/TreeSelectorDemo.vue +245 -245
  219. package/src/views/UploadDemo.vue +128 -128
  220. package/src/views/VideoDemo.vue +245 -245
  221. package/src/views/VxeTableDemo.vue +279 -279
  222. package/src/views/WatermarkDemo.vue +85 -85
@@ -1,999 +1,999 @@
1
- <template>
2
- <t-form-item :class="['ebiz-s-form-item', className]" :for="forAttr" :help="help" :label="label" :name="name"
3
- :style="customStyle" :rules="rules" :label-width="labelWidth" :label-align="labelAlign" :status="status"
4
- @validate="handleValidate" style="margin-bottom: 10px;">
5
-
6
- <slot name="default">
7
- <!-- 员工选择 -->
8
- <template v-if="type === 'employee'">
9
- <ebiz-employee-selector v-model="computedModelValue" :placeholder="placeholder || '请选择员工'"
10
- :disabled="disabled" :clearable="clearable" :single="single" :defaultTab="defaultTab"
11
- :maxCount="maxCount" @change="handleChange" />
12
- </template>
13
-
14
- <!-- 部门选择 -->
15
- <template v-if="type === 'dept'">
16
- <ebiz-department-selector v-model="computedModelValue" :placeholder="placeholder || '请选择部门'"
17
- :disabled="disabled" :clearable="clearable" :filterable="filterable" :apiUrl="apiUrl"
18
- :companyId="companyId" :multiple="multiple" @change="handleChange" />
19
- </template>
20
-
21
- <!-- 输入框 -->
22
- <template v-if="type === 'input'">
23
- <t-input v-model="computedModelValue" :placeholder="placeholder || '请输入'" :disabled="disabled"
24
- :readonly="readonly" :clearable="clearable" :max-length="maxLength" :max-character="maxCharacter"
25
- :show-limit-number="showLimitNumber" @change="handleChange" />
26
- </template>
27
-
28
- <!-- 数字输入框 -->
29
- <template v-else-if="type === 'number'">
30
- <t-input-number v-model="computedModelValue" :placeholder="placeholder || '请输入'" :disabled="disabled"
31
- :readonly="readonly" :max="max" :min="min" :step="step" :format="format" @change="handleChange" />
32
- </template>
33
-
34
- <!-- 文本域 -->
35
- <template v-else-if="type === 'textarea'">
36
- <t-textarea v-model="computedModelValue" :placeholder="placeholder || '请输入'" :disabled="disabled"
37
- :readonly="readonly" :autosize="autosize" :maxlength="maxLength" :max-character="maxCharacter"
38
- :show-limit-number="showLimitNumber" @change="handleChange" />
39
- </template>
40
-
41
- <!-- 选择器 -->
42
- <template v-else-if="type === 'select'">
43
- <template v-if="isRemote">
44
- <ebiz-remote-select v-model="computedModelValue" :queryParams="queryParams"
45
- :placeholder="placeholder || '请选择'" :disabled="disabled" :clearable="clearable"
46
- :filterable="true" :multiple="multiple" :loading="loading" :apiConfig="remoteApiConfig"
47
- @change="handleChange" />
48
- </template>
49
- <template v-else>
50
- <t-select v-model="computedModelValue" :options="options" :placeholder="placeholder || '请选择'"
51
- :disabled="disabled" :clearable="clearable" :filterable="filterable" :multiple="multiple"
52
- :loading="loading" @change="handleChange" />
53
- </template>
54
- </template>
55
-
56
- <!-- 日期选择器 -->
57
- <template v-else-if="type === 'datetime'">
58
- <t-date-picker v-model="computedModelValue" :placeholder="placeholder || '请选择日期时间'" :disabled="disabled"
59
- :clearable="clearable" enable-time-picker format="YYYY-MM-DD HH:mm:ss" @change="handleChange" />
60
- </template>
61
-
62
-
63
- <!-- 日期选择器 -->
64
- <template v-else-if="type === 'date'">
65
- <t-date-picker v-model="computedModelValue" :placeholder="placeholder || '请选择日期'" :disabled="disabled"
66
- :clearable="clearable" :format="dateFormat || 'YYYY-MM-DD'" :mode="dateMode || 'date'"
67
- @change="handleChange" />
68
- </template>
69
-
70
- <!-- 时间选择器 -->
71
- <template v-else-if="type === 'time'">
72
- <t-time-picker v-model="computedModelValue" :placeholder="placeholder || '请选择时间'" :disabled="disabled"
73
- :clearable="clearable" :format="timeFormat || 'HH:mm:ss'" @change="handleChange" />
74
- </template>
75
-
76
- <!-- 单选框组 -->
77
- <template v-else-if="type === 'radio'">
78
- <t-radio-group v-model="computedModelValue" :disabled="disabled" :options="options"
79
- @change="handleChange" />
80
- </template>
81
-
82
- <!-- 复选框组 -->
83
- <template v-else-if="type === 'checkbox'">
84
- <t-checkbox-group v-model="computedModelValue" :disabled="disabled" :options="options" :max="max"
85
- @change="handleChange" />
86
- </template>
87
-
88
- <!-- 开关 -->
89
- <template v-else-if="type === 'switch'">
90
- <t-switch v-model="computedModelValue" :disabled="disabled" @change="handleChange" />
91
- </template>
92
-
93
- <!-- 滑块 -->
94
- <template v-else-if="type === 'slider'">
95
- <t-slider v-model="computedModelValue" :disabled="disabled" :max="max" :min="min" :step="step"
96
- :range="range" :marks="marks" @change="handleChange" />
97
- </template>
98
-
99
- <!-- 上传 -->
100
- <template v-else-if="type === 'upload'">
101
- <ebiz-upload v-model="computedModelValue" :disabled="disabled" :accept="accept" :multiple="multiple"
102
- :max="max" :theme="uploadTheme || 'file'" @change="handleChange" />
103
- </template>
104
-
105
- <!-- 视频上传 -->
106
- <template v-else-if="type === 'video-upload'">
107
- <div>
108
- <ebiz-upload v-if="!computedModelValue" v-model="computedModelValue" :disabled="disabled"
109
- :accept="accept || 'video/*'" :multiple="false" :max="1" :theme="'file'" :action="action"
110
- :headers="headers" :withCredentials="withCredentials" :beforeUpload="beforeUpload"
111
- :formatResponse="formatResponse" :placeholder="placeholder || '请上传视频'" :sizeLimit="sizeLimit"
112
- :tips="tips || '只能上传一个视频文件'" @change="handleChange" />
113
- <div v-else style="display: flex; position: relative;">
114
- <video :src="computedModelValue" controls autoplay muted width="400"></video>
115
- <div style="position: absolute; top: 5px; right: 5px;">
116
- <t-button theme="danger" @click="clearVideoUpload" size="small" :disabled="disabled">
117
- <template #icon>
118
- <t-icon name="delete"></t-icon>
119
- </template>
120
- </t-button>
121
- </div>
122
- </div>
123
- </div>
124
- </template>
125
-
126
- <!-- 级联选择器 -->
127
- <template v-else-if="type === 'cascader'">
128
- <t-cascader v-model="computedModelValue" :disabled="disabled" :options="options"
129
- :placeholder="placeholder || '请选择'" :clearable="clearable" :filterable="filterable"
130
- :multiple="multiple" @change="handleChange" />
131
- </template>
132
-
133
- <!-- 树形选择器 -->
134
- <template v-else-if="type === 'tree-select'">
135
- <t-tree-select v-model="computedModelValue" :disabled="disabled" :data="treeData || options"
136
- :placeholder="placeholder || '请选择'" :clearable="clearable" :filterable="filterable"
137
- :multiple="multiple" @change="handleChange" />
138
- </template>
139
-
140
- <!-- 颜色选择器 -->
141
- <template v-else-if="type === 'color-picker'">
142
- <t-color-picker v-model="computedModelValue" :disabled="disabled" :clearable="clearable"
143
- @change="handleChange" />
144
- </template>
145
-
146
- <!-- 富文本编辑器 -->
147
- <template v-else-if="type === 'rich-text'">
148
- <ebiz-rich-text-editor v-model="computedModelValue" :placeholder="placeholder || '请输入内容'"
149
- :disabled="disabled" :readonly="readonly" :height="editorHeight"
150
- :toolbar-config="editorToolbarConfig" :editor-config="editorConfig" :image-path="editorImagePath"
151
- :video-path="editorVideoPath" :max-length="maxLength" @change="handleChange" />
152
- </template>
153
-
154
- <!-- 子表格 -->
155
- <template v-else-if="type === 'table'">
156
- <div class="ebiz-form-table">
157
- <t-space direction="vertical" style="width: 100%;">
158
- <!-- 添加按钮 -->
159
- <div>
160
- <t-button theme="primary" variant="outline" @click="addTableRow" :disabled="disabled">
161
- <template #icon>
162
- <svg width="16" height="16" viewBox="0 0 16 16" fill="none">
163
- <path d="M8 1V15M1 8H15" stroke="currentColor" stroke-width="1.5"
164
- stroke-linecap="round" />
165
- </svg>
166
- </template>
167
- {{ addButtonText }}
168
- </t-button>
169
- </div>
170
-
171
- <!-- 表格 -->
172
- <t-table :data="computedModelValue" :columns="computedTableColumns"
173
- row-key="__id" size="small" bordered :empty="'暂无数据'">
174
- <!-- 序号列 -->
175
- <template #index="{ rowIndex }">
176
- {{ rowIndex + 1 }}
177
- </template>
178
-
179
- <!-- 动态渲染每个数据列 -->
180
- <template v-for="col in tableColumns" :key="col.key" #[col.key]="{ row, rowIndex }">
181
- <!-- 输入框 -->
182
- <t-input v-if="!col.type || col.type === 'input'" v-model="row[col.key]"
183
- :disabled="disabled" :placeholder="col.placeholder || `请输入${col.name}`"
184
- :clearable="col.clearable !== false" :maxlength="col.maxlength"
185
- @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
186
-
187
- <!-- 数字输入框 -->
188
- <t-input-number v-else-if="col.type === 'number'" v-model="row[col.key]"
189
- :disabled="disabled" :placeholder="col.placeholder || `请输入${col.name}`"
190
- :min="col.min" :max="col.max" :step="col.step || 1"
191
- :decimal-places="col.decimalPlaces"
192
- @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
193
-
194
- <!-- 选择器 -->
195
- <t-select v-else-if="col.type === 'select' && col.isRemote !== true" v-model="row[col.key]" :disabled="disabled"
196
- :placeholder="col.placeholder || `请选择${col.name}`" :options="col.options || []"
197
- :clearable="col.clearable !== false" :filterable="col.filterable"
198
- :multiple="col.multiple"
199
- @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
200
-
201
- <!-- 远程搜索 -->
202
- <ebiz-remote-select v-else-if="col.type === 'select' && col.isRemote === true" v-model="row[col.key]" :queryParams="col.queryParams"
203
- :placeholder="col.placeholder || `请选择${col.name}`" :disabled="disabled" :clearable="col.clearable !== false"
204
- :filterable="true" :multiple="col.multiple" :apiConfig="col.remoteApiConfig"
205
- @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
206
-
207
- <!-- 日期选择器 -->
208
- <t-date-picker v-else-if="col.type === 'date'" v-model="row[col.key]"
209
- :disabled="disabled" :placeholder="col.placeholder || `请选择${col.name}`"
210
- :format="col.format || 'YYYY-MM-DD'" :clearable="col.clearable !== false"
211
- @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
212
-
213
- <!-- 日期时间选择器 -->
214
- <t-date-picker v-else-if="col.type === 'datetime'" v-model="row[col.key]"
215
- :disabled="disabled" :placeholder="col.placeholder || `请选择${col.name}`"
216
- :format="col.format || 'YYYY-MM-DD HH:mm:ss'" enable-time-picker
217
- :clearable="col.clearable !== false"
218
- @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
219
-
220
- <!-- 开关 -->
221
- <t-switch v-else-if="col.type === 'switch'" v-model="row[col.key]" :disabled="disabled"
222
- @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
223
-
224
- <!-- 文本域 -->
225
- <t-textarea v-else-if="col.type === 'textarea'" v-model="row[col.key]"
226
- :disabled="disabled" :placeholder="col.placeholder || `请输入${col.name}`"
227
- :autosize="col.autosize || { minRows: 2, maxRows: 4 }" :maxlength="col.maxlength"
228
- @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
229
-
230
- <!-- 单选框组 -->
231
- <t-radio-group v-else-if="col.type === 'radio'" v-model="row[col.key]"
232
- :disabled="disabled" :options="col.options || []"
233
- @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
234
-
235
- <!-- 复选框组 -->
236
- <t-checkbox-group v-else-if="col.type === 'checkbox'" v-model="row[col.key]"
237
- :disabled="disabled" :options="col.options || []" :max="col.max"
238
- @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
239
-
240
- <ebiz-employee-selector v-else-if="col.type === 'employee'" v-model="row[col.key]"
241
- :placeholder="col.placeholder || '请选择员工'" :disabled="disabled"
242
- :clearable="col.clearable !== false" :single="col.single" :defaultTab="col.defaultTab"
243
- :maxCount="col.maxCount" @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
244
-
245
- <!-- 默认文本显示 -->
246
- <span v-else>{{ row[col.key] || '' }}</span>
247
- </template>
248
-
249
- <!-- 操作列 -->
250
- <template v-if="showTableActions" #actions="{ rowIndex }">
251
- <t-button theme="danger" variant="text" size="small" :disabled="disabled"
252
- @click="removeTableRow(rowIndex)">
253
- 删除
254
- </t-button>
255
- </template>
256
- </t-table>
257
- </t-space>
258
- </div>
259
- </template>
260
-
261
- <!-- 字典选择器 -->
262
- <template v-else-if="type === 'dictionarySelect'">
263
- <ebiz-dictionary-select v-model="computedModelValue" :dictionary-key="dictionaryKey" :queryParams="queryParams"
264
- :placeholder="placeholder || '请选择'" :disabled="disabled" :clearable="clearable"
265
- :filterable="true" :multiple="multiple" :loading="loading"
266
- @change="handleChange" />
267
- </template>
268
-
269
- <!-- 默认插槽,用于自定义控件 -->
270
- <template v-else>
271
- </template>
272
- </slot>
273
-
274
- </t-form-item>
275
- </template>
276
-
277
- <script>
278
- /**
279
- * @displayName PC端表单项
280
- * @description PC端表单项组件,基于TDesign FormItem封装,支持多种控件类型,包括子表格功能
281
- * @category 表单组件
282
- * @name EbizSFormItem
283
- */
284
- export default {
285
- name: "EbizSFormItem"
286
- }
287
- </script>
288
-
289
- <script setup>
290
- import { defineProps, defineEmits, computed, watch, onMounted } from 'vue';
291
- import {
292
- FormItem as TFormItem,
293
- Input as TInput,
294
- InputNumber as TInputNumber,
295
- Textarea as TTextarea,
296
- Select as TSelect,
297
- DatePicker as TDatePicker,
298
- TimePicker as TTimePicker,
299
- RadioGroup as TRadioGroup,
300
- CheckboxGroup as TCheckboxGroup,
301
- Switch as TSwitch,
302
- Slider as TSlider,
303
- Cascader as TCascader,
304
- TreeSelect as TTreeSelect,
305
- ColorPicker as TColorPicker,
306
- Table as TTable,
307
- Button as TButton,
308
- Space as TSpace
309
- } from 'tdesign-vue-next';
310
- import EbizRemoteSelect from '../../EbizRemoteSelect.vue';
311
- import EbizEmployeeSelector from '../../EbizEmployeeSelector.vue';
312
- import EbizDepartmentSelector from '../../EbizDepartmentSelector.vue';
313
- import { EbizUpload } from '../../../index.js'
314
- import EbizRichTextEditor from '../../EbizRichTextEditor.vue';
315
- import EbizDictionarySelect from '../../EbizDictionarySelect.vue';
316
-
317
- const props = defineProps({
318
- /**
319
- * 组件类型
320
- * @options input|number|textarea|select|date|datetime|time|radio|checkbox|switch|slider|upload|video-upload|cascader|tree-select|color-picker|employee|dept|table
321
- */
322
- type: {
323
- type: String,
324
- default: undefined,
325
- validator: (val) => [
326
- 'input', 'number', 'textarea', 'select', 'date', 'datetime', 'time', 'radio',
327
- 'checkbox', 'switch', 'slider', 'upload', 'video-upload', 'cascader', 'tree-select',
328
- 'color-picker', 'employee', 'dept', 'table', 'rich-text'
329
- ].includes(val)
330
- },
331
-
332
- queryParams: {
333
- type: Object,
334
- default: () => ({})
335
- },
336
- /**
337
- * 绑定的值
338
- */
339
- modelValue: {
340
- type: [String, Number, Boolean, Array, Object],
341
- default: undefined
342
- },
343
- /**
344
- * 表单项标签
345
- */
346
- label: {
347
- type: String,
348
- default: ''
349
- },
350
- /**
351
- * 表单项字段名,唯一标识
352
- */
353
- name: {
354
- type: String,
355
- default: ''
356
- },
357
- /**
358
- * html元素原生属性for
359
- */
360
- forAttr: {
361
- type: String,
362
- default: undefined
363
- },
364
- /**
365
- * 表单项帮助文本
366
- */
367
- help: {
368
- type: [String, Function],
369
- default: ''
370
- },
371
- /**
372
- * 是否禁用
373
- */
374
- disabled: {
375
- type: Boolean,
376
- default: false
377
- },
378
- /**
379
- * 是否只读
380
- */
381
- readonly: {
382
- type: Boolean,
383
- default: false
384
- },
385
- /**
386
- * 表单项规则
387
- */
388
- rules: {
389
- type: [Array, Object],
390
- default: undefined
391
- },
392
- /**
393
- * 自定义样式
394
- */
395
- customStyle: {
396
- type: [String, Object],
397
- default: ''
398
- },
399
- /**
400
- * 自定义类名
401
- */
402
- className: {
403
- type: String,
404
- default: ''
405
- },
406
- /**
407
- * 表单项标签宽度
408
- */
409
- labelWidth: {
410
- type: [String, Number],
411
- default: undefined
412
- },
413
- /**
414
- * 表单项标签对齐方式
415
- * @options left|right|top
416
- */
417
- labelAlign: {
418
- type: String,
419
- default: undefined,
420
- validator: (val) => ['left', 'right', 'top'].includes(val)
421
- },
422
- /**
423
- * 表单项状态
424
- * @options default|success|warning|error
425
- */
426
- status: {
427
- type: String,
428
- default: undefined,
429
- validator: (val) => ['default', 'success', 'warning', 'error'].includes(val)
430
- },
431
- /**
432
- * 占位文本
433
- */
434
- placeholder: {
435
- type: String,
436
- default: ''
437
- },
438
- /**
439
- * 是否可清空
440
- */
441
- clearable: {
442
- type: Boolean,
443
- default: true
444
- },
445
- /**
446
- * 最大长度
447
- */
448
- maxLength: {
449
- type: Number,
450
- default: undefined
451
- },
452
- /**
453
- * 最大字符数
454
- */
455
- maxCharacter: {
456
- type: Number,
457
- default: undefined
458
- },
459
- /**
460
- * 是否显示字数限制
461
- */
462
- showLimitNumber: {
463
- type: Boolean,
464
- default: false
465
- },
466
- /**
467
- * 选项数据,用于select, radio, checkbox等
468
- */
469
- options: {
470
- type: Array,
471
- default: () => []
472
- },
473
- /**
474
- * 树形数据,用于tree-select
475
- */
476
- treeData: {
477
- type: Array,
478
- default: undefined
479
- },
480
- /**
481
- * 是否支持过滤
482
- */
483
- filterable: {
484
- type: Boolean,
485
- default: true
486
- },
487
- /**
488
- * 是否支持多选
489
- */
490
- multiple: {
491
- type: Boolean,
492
- default: false
493
- },
494
- /**
495
- * 加载状态
496
- */
497
- loading: {
498
- type: Boolean,
499
- default: false
500
- },
501
- /**
502
- * 日期格式
503
- */
504
- dateFormat: {
505
- type: String,
506
- default: 'YYYY-MM-DD'
507
- },
508
- /**
509
- * 日期选择器模式
510
- * @options date|week|month|quarter|year
511
- */
512
- dateMode: {
513
- type: String,
514
- default: 'date',
515
- validator: (val) => ['date', 'week', 'month', 'quarter', 'year'].includes(val)
516
- },
517
- /**
518
- * 时间格式
519
- */
520
- timeFormat: {
521
- type: String,
522
- default: 'HH:mm:ss'
523
- },
524
- /**
525
- * 最大值
526
- */
527
- max: {
528
- type: Number,
529
- default: undefined
530
- },
531
- /**
532
- * 最小值
533
- */
534
- min: {
535
- type: Number,
536
- default: undefined
537
- },
538
- /**
539
- * 步长
540
- */
541
- step: {
542
- type: Number,
543
- default: 1
544
- },
545
- /**
546
- * 格式化函数
547
- */
548
- format: {
549
- type: Function,
550
- default: undefined
551
- },
552
- /**
553
- * 文本域自适应高度
554
- */
555
- autosize: {
556
- type: [Boolean, Object],
557
- default: false
558
- },
559
- /**
560
- * 滑块是否为范围选择
561
- */
562
- range: {
563
- type: Boolean,
564
- default: false
565
- },
566
- /**
567
- * 滑块刻度标记
568
- */
569
- marks: {
570
- type: Object,
571
- default: () => ({})
572
- },
573
- /**
574
- * 上传接受的文件类型
575
- */
576
- accept: {
577
- type: String,
578
- default: ''
579
- },
580
- /**
581
- * 上传接口地址
582
- */
583
- action: {
584
- type: String,
585
- default: ''
586
- },
587
- /**
588
- * 上传请求头
589
- */
590
- headers: {
591
- type: Object,
592
- default: () => ({})
593
- },
594
- /**
595
- * 上传是否携带cookie
596
- */
597
- withCredentials: {
598
- type: Boolean,
599
- default: false
600
- },
601
- /**
602
- * 上传前的钩子函数
603
- */
604
- beforeUpload: {
605
- type: Function,
606
- default: undefined
607
- },
608
- /**
609
- * 上传响应格式化函数
610
- */
611
- formatResponse: {
612
- type: Function,
613
- default: undefined
614
- },
615
- /**
616
- * 上传组件主题
617
- * @options file|image|image-flow
618
- */
619
- uploadTheme: {
620
- type: String,
621
- default: 'file',
622
- validator: (val) => ['file', 'image', 'image-flow'].includes(val)
623
- },
624
- /**
625
- * 是否开启远程搜索
626
- */
627
- isRemote: {
628
- type: Boolean,
629
- default: false
630
- },
631
- /**
632
- * 远程搜索配置
633
- */
634
- remoteApiConfig: {
635
- type: Object,
636
- default: () => ({
637
- url: '',
638
- method: 'GET',
639
- params: {},
640
- data: {},
641
- headers: {},
642
- transformResponse: null
643
- })
644
- },
645
- /**
646
- * 员工选择器是否单选
647
- */
648
- single: {
649
- type: Boolean,
650
- default: true
651
- },
652
- /**
653
- * 员工选择器默认标签页
654
- * @options organization|recent
655
- */
656
- defaultTab: {
657
- type: String,
658
- default: 'organization',
659
- validator: (val) => ['organization', 'recent'].includes(val)
660
- },
661
- /**
662
- * 员工选择器最大选择数量
663
- */
664
- maxCount: {
665
- type: Number,
666
- default: undefined
667
- },
668
- /**
669
- * 部门选择器API地址
670
- */
671
- apiUrl: {
672
- type: String,
673
- default: '/api/departments'
674
- },
675
- /**
676
- * 部门选择器所属公司ID
677
- */
678
- companyId: {
679
- type: [String, Number],
680
- default: undefined
681
- },
682
- /**
683
- * 子表格列配置,用于table类型
684
- * 示例:[
685
- * {name:'名称', key:'name', type:'input', width:150},
686
- * {name:'类型', key:'type', type:'select', options:[{label:'选项1', value:'1'}]},
687
- * {name:'数量', key:'num', type:'number', min:0, max:999}
688
- * ]
689
- */
690
- tableColumns: {
691
- type: Array,
692
- default: () => []
693
- },
694
- /**
695
- * 子表格是否显示操作列
696
- */
697
- showTableActions: {
698
- type: Boolean,
699
- default: true
700
- },
701
- /**
702
- * 子表格新增按钮文本
703
- */
704
- addButtonText: {
705
- type: String,
706
- default: '添加数据'
707
- },
708
- /**
709
- * 富文本编辑器高度
710
- */
711
- editorHeight: {
712
- type: [String, Number],
713
- default: 300
714
- },
715
- /**
716
- * 富文本编辑器工具栏配置
717
- */
718
- editorToolbarConfig: {
719
- type: Object,
720
- default: () => ({})
721
- },
722
- /**
723
- * 富文本编辑器配置
724
- */
725
- editorConfig: {
726
- type: Object,
727
- default: () => ({})
728
- },
729
- /**
730
- * 富文本图片上传路径
731
- */
732
- editorImagePath: {
733
- type: String,
734
- default: 'editor'
735
- },
736
- /**
737
- * 富文本视频上传路径
738
- */
739
- editorVideoPath: {
740
- type: String,
741
- default: 'video'
742
- },
743
- /**
744
- * 字典类型
745
- */
746
- dictionaryKey: {
747
- type: String,
748
- default: ''
749
- }
750
- });
751
-
752
- const emit = defineEmits([
753
- 'update:modelValue',
754
- 'change',
755
- 'validate'
756
- ]);
757
-
758
- // 计算属性处理v-model双向绑定
759
- const computedModelValue = computed({
760
- get: () => props.modelValue,
761
- set: (val) => {
762
- emit('update:modelValue', val);
763
- }
764
- });
765
-
766
- // 表格列配置计算属性
767
- const computedTableColumns = computed(() => {
768
- if (props.type !== 'table' || !props.tableColumns?.length) return [];
769
-
770
- const columns = [];
771
-
772
- // 添加序号列
773
- columns.push({
774
- colKey: 'index',
775
- title: '序号',
776
- width: 80,
777
- align: 'center'
778
- });
779
-
780
- // 添加用户配置的列
781
- const userColumns = props.tableColumns.map(col => ({
782
- colKey: col.key,
783
- title: col.name,
784
- width: col.width || undefined,
785
- align: col.align || 'left'
786
- }));
787
-
788
- columns.push(...userColumns);
789
-
790
- // 添加操作列
791
- if (props.showTableActions) {
792
- columns.push({
793
- colKey: 'actions',
794
- title: '操作',
795
- width: 80,
796
- align: 'center'
797
- });
798
- }
799
-
800
- return columns;
801
- });
802
-
803
- /**
804
- * 值变更事件
805
- * @param {*} val 新值
806
- */
807
- const handleChange = (val) => {
808
- emit('change', val);
809
- };
810
-
811
- /**
812
- * 验证事件
813
- * @param {Object} validateResult 验证结果
814
- */
815
- const handleValidate = (validateResult) => {
816
- emit('validate', validateResult);
817
- };
818
-
819
- /**
820
- * 清除视频上传
821
- */
822
- const clearVideoUpload = () => {
823
- computedModelValue.value = null;
824
- emit('change', null);
825
- };
826
-
827
- /**
828
- * 添加表格行
829
- */
830
- const addTableRow = () => {
831
- const currentData = computedModelValue.value || [];
832
- const newRow = {};
833
-
834
- // 根据表格列配置初始化新行数据
835
- props.tableColumns.forEach(col => {
836
- // 根据列类型设置默认值
837
- switch (col.type) {
838
- case 'number':
839
- newRow[col.key] = col.defaultValue || 0;
840
- break;
841
- case 'switch':
842
- newRow[col.key] = col.defaultValue || false;
843
- break;
844
- case 'checkbox':
845
- newRow[col.key] = col.defaultValue || [];
846
- break;
847
- case 'select':
848
- if (col.multiple) {
849
- newRow[col.key] = col.defaultValue || [];
850
- } else {
851
- newRow[col.key] = col.defaultValue || '';
852
- }
853
- break;
854
- default:
855
- newRow[col.key] = col.defaultValue || '';
856
- break;
857
- }
858
- });
859
-
860
- const newData = [...currentData, newRow];
861
- // 只更新computedModelValue,让watch自动处理change事件
862
- computedModelValue.value = JSON.parse(JSON.stringify(newData));
863
- };
864
-
865
- /**
866
- * 删除表格行
867
- * @param {number} rowIndex 行索引
868
- */
869
- const removeTableRow = (rowIndex) => {
870
- if (props.type !== 'table') return;
871
-
872
- const currentData = [...(computedModelValue.value || [])];
873
- currentData.splice(rowIndex, 1);
874
-
875
- // 只更新computedModelValue,让watch自动处理change事件
876
- computedModelValue.value = currentData;
877
- };
878
-
879
- /**
880
- * 更新表格单元格数据
881
- * @param {number} rowIndex 行索引
882
- * @param {string} colKey 列键名
883
- * @param {*} value 新值
884
- */
885
- const updateTableCell = (rowIndex, colKey, value) => {
886
- if (props.type !== 'table') return;
887
-
888
- const currentData = [...(computedModelValue.value || [])];
889
- if (currentData[rowIndex]) {
890
- currentData[rowIndex] = {
891
- ...currentData[rowIndex],
892
- [colKey]: value
893
- };
894
-
895
- // 只更新computedModelValue,让watch自动处理change事件
896
- computedModelValue.value = currentData;
897
- }
898
- };
899
-
900
- // 监听modelValue变化,触发change事件(仅在table类型时)
901
- watch(
902
- () => props.modelValue,
903
- (newVal, oldVal) => {
904
- if (props.type === 'table' && newVal !== oldVal) {
905
- // 只在数据真正变化时触发change事件
906
- const cleanData = Array.isArray(newVal) ? newVal : [];
907
- handleChange(cleanData);
908
- }
909
- },
910
- { deep: true }
911
- );
912
-
913
- // 组件挂载时初始化文件列表
914
- onMounted(() => {
915
- });
916
- </script>
917
-
918
- <style scoped>
919
- .custom-control {
920
- width: 100%;
921
- }
922
-
923
- .ebiz-form-table {
924
- width: 100%;
925
- }
926
-
927
- .ebiz-form-table :deep(.t-table) {
928
- border: 1px solid var(--td-border-level-1-color);
929
- border-radius: var(--td-radius-default);
930
- }
931
-
932
- .ebiz-form-table :deep(.t-table td) {
933
- padding: 8px 12px;
934
- }
935
-
936
- .ebiz-form-table :deep(.t-table th) {
937
- background-color: var(--td-bg-color-secondarycontainer);
938
- font-weight: 500;
939
- }
940
-
941
- .ebiz-form-table :deep(.t-input) {
942
- border: none;
943
- box-shadow: none;
944
- }
945
-
946
- .ebiz-form-table :deep(.t-input:focus-within) {
947
- border: 1px solid var(--td-brand-color);
948
- box-shadow: 0 0 0 2px var(--td-brand-color-focus);
949
- }
950
-
951
- .ebiz-form-table :deep(.t-input-number) {
952
- border: none;
953
- box-shadow: none;
954
- }
955
-
956
- .ebiz-form-table :deep(.t-input-number:focus-within) {
957
- border: 1px solid var(--td-brand-color);
958
- box-shadow: 0 0 0 2px var(--td-brand-color-focus);
959
- }
960
-
961
- .ebiz-form-table :deep(.t-select) {
962
- border: none;
963
- box-shadow: none;
964
- }
965
-
966
- .ebiz-form-table :deep(.t-select:focus-within) {
967
- border: 1px solid var(--td-brand-color);
968
- box-shadow: 0 0 0 2px var(--td-brand-color-focus);
969
- }
970
-
971
- .ebiz-form-table :deep(.t-date-picker) {
972
- border: none;
973
- box-shadow: none;
974
- }
975
-
976
- .ebiz-form-table :deep(.t-date-picker:focus-within) {
977
- border: 1px solid var(--td-brand-color);
978
- box-shadow: 0 0 0 2px var(--td-brand-color-focus);
979
- }
980
-
981
- .ebiz-form-table :deep(.t-textarea) {
982
- border: none;
983
- box-shadow: none;
984
- }
985
-
986
- .ebiz-form-table :deep(.t-textarea:focus-within) {
987
- border: 1px solid var(--td-brand-color);
988
- box-shadow: 0 0 0 2px var(--td-brand-color-focus);
989
- }
990
-
991
- .ebiz-form-table :deep(.t-switch) {
992
- justify-content: center;
993
- }
994
-
995
- .ebiz-form-table :deep(.t-radio-group),
996
- .ebiz-form-table :deep(.t-checkbox-group) {
997
- justify-content: center;
998
- }
1
+ <template>
2
+ <t-form-item :class="['ebiz-s-form-item', className]" :for="forAttr" :help="help" :label="label" :name="name"
3
+ :style="customStyle" :rules="rules" :label-width="labelWidth" :label-align="labelAlign" :status="status"
4
+ @validate="handleValidate" style="margin-bottom: 10px;">
5
+
6
+ <slot name="default">
7
+ <!-- 员工选择 -->
8
+ <template v-if="type === 'employee'">
9
+ <ebiz-employee-selector v-model="computedModelValue" :placeholder="placeholder || '请选择员工'"
10
+ :disabled="disabled" :clearable="clearable" :single="single" :defaultTab="defaultTab"
11
+ :maxCount="maxCount" @change="handleChange" />
12
+ </template>
13
+
14
+ <!-- 部门选择 -->
15
+ <template v-if="type === 'dept'">
16
+ <ebiz-department-selector v-model="computedModelValue" :placeholder="placeholder || '请选择部门'"
17
+ :disabled="disabled" :clearable="clearable" :filterable="filterable" :apiUrl="apiUrl"
18
+ :companyId="companyId" :multiple="multiple" @change="handleChange" />
19
+ </template>
20
+
21
+ <!-- 输入框 -->
22
+ <template v-if="type === 'input'">
23
+ <t-input v-model="computedModelValue" :placeholder="placeholder || '请输入'" :disabled="disabled"
24
+ :readonly="readonly" :clearable="clearable" :max-length="maxLength" :max-character="maxCharacter"
25
+ :show-limit-number="showLimitNumber" @change="handleChange" />
26
+ </template>
27
+
28
+ <!-- 数字输入框 -->
29
+ <template v-else-if="type === 'number'">
30
+ <t-input-number v-model="computedModelValue" :placeholder="placeholder || '请输入'" :disabled="disabled"
31
+ :readonly="readonly" :max="max" :min="min" :step="step" :format="format" @change="handleChange" />
32
+ </template>
33
+
34
+ <!-- 文本域 -->
35
+ <template v-else-if="type === 'textarea'">
36
+ <t-textarea v-model="computedModelValue" :placeholder="placeholder || '请输入'" :disabled="disabled"
37
+ :readonly="readonly" :autosize="autosize" :maxlength="maxLength" :max-character="maxCharacter"
38
+ :show-limit-number="showLimitNumber" @change="handleChange" />
39
+ </template>
40
+
41
+ <!-- 选择器 -->
42
+ <template v-else-if="type === 'select'">
43
+ <template v-if="isRemote">
44
+ <ebiz-remote-select v-model="computedModelValue" :queryParams="queryParams"
45
+ :placeholder="placeholder || '请选择'" :disabled="disabled" :clearable="clearable"
46
+ :filterable="true" :multiple="multiple" :loading="loading" :apiConfig="remoteApiConfig"
47
+ @change="handleChange" />
48
+ </template>
49
+ <template v-else>
50
+ <t-select v-model="computedModelValue" :options="options" :placeholder="placeholder || '请选择'"
51
+ :disabled="disabled" :clearable="clearable" :filterable="filterable" :multiple="multiple"
52
+ :loading="loading" @change="handleChange" />
53
+ </template>
54
+ </template>
55
+
56
+ <!-- 日期选择器 -->
57
+ <template v-else-if="type === 'datetime'">
58
+ <t-date-picker v-model="computedModelValue" :placeholder="placeholder || '请选择日期时间'" :disabled="disabled"
59
+ :clearable="clearable" enable-time-picker format="YYYY-MM-DD HH:mm:ss" @change="handleChange" />
60
+ </template>
61
+
62
+
63
+ <!-- 日期选择器 -->
64
+ <template v-else-if="type === 'date'">
65
+ <t-date-picker v-model="computedModelValue" :placeholder="placeholder || '请选择日期'" :disabled="disabled"
66
+ :clearable="clearable" :format="dateFormat || 'YYYY-MM-DD'" :mode="dateMode || 'date'"
67
+ @change="handleChange" />
68
+ </template>
69
+
70
+ <!-- 时间选择器 -->
71
+ <template v-else-if="type === 'time'">
72
+ <t-time-picker v-model="computedModelValue" :placeholder="placeholder || '请选择时间'" :disabled="disabled"
73
+ :clearable="clearable" :format="timeFormat || 'HH:mm:ss'" @change="handleChange" />
74
+ </template>
75
+
76
+ <!-- 单选框组 -->
77
+ <template v-else-if="type === 'radio'">
78
+ <t-radio-group v-model="computedModelValue" :disabled="disabled" :options="options"
79
+ @change="handleChange" />
80
+ </template>
81
+
82
+ <!-- 复选框组 -->
83
+ <template v-else-if="type === 'checkbox'">
84
+ <t-checkbox-group v-model="computedModelValue" :disabled="disabled" :options="options" :max="max"
85
+ @change="handleChange" />
86
+ </template>
87
+
88
+ <!-- 开关 -->
89
+ <template v-else-if="type === 'switch'">
90
+ <t-switch v-model="computedModelValue" :disabled="disabled" @change="handleChange" />
91
+ </template>
92
+
93
+ <!-- 滑块 -->
94
+ <template v-else-if="type === 'slider'">
95
+ <t-slider v-model="computedModelValue" :disabled="disabled" :max="max" :min="min" :step="step"
96
+ :range="range" :marks="marks" @change="handleChange" />
97
+ </template>
98
+
99
+ <!-- 上传 -->
100
+ <template v-else-if="type === 'upload'">
101
+ <ebiz-upload v-model="computedModelValue" :disabled="disabled" :accept="accept" :multiple="multiple"
102
+ :max="max" :theme="uploadTheme || 'file'" @change="handleChange" />
103
+ </template>
104
+
105
+ <!-- 视频上传 -->
106
+ <template v-else-if="type === 'video-upload'">
107
+ <div>
108
+ <ebiz-upload v-if="!computedModelValue" v-model="computedModelValue" :disabled="disabled"
109
+ :accept="accept || 'video/*'" :multiple="false" :max="1" :theme="'file'" :action="action"
110
+ :headers="headers" :withCredentials="withCredentials" :beforeUpload="beforeUpload"
111
+ :formatResponse="formatResponse" :placeholder="placeholder || '请上传视频'" :sizeLimit="sizeLimit"
112
+ :tips="tips || '只能上传一个视频文件'" @change="handleChange" />
113
+ <div v-else style="display: flex; position: relative;">
114
+ <video :src="computedModelValue" controls autoplay muted width="400"></video>
115
+ <div style="position: absolute; top: 5px; right: 5px;">
116
+ <t-button theme="danger" @click="clearVideoUpload" size="small" :disabled="disabled">
117
+ <template #icon>
118
+ <t-icon name="delete"></t-icon>
119
+ </template>
120
+ </t-button>
121
+ </div>
122
+ </div>
123
+ </div>
124
+ </template>
125
+
126
+ <!-- 级联选择器 -->
127
+ <template v-else-if="type === 'cascader'">
128
+ <t-cascader v-model="computedModelValue" :disabled="disabled" :options="options"
129
+ :placeholder="placeholder || '请选择'" :clearable="clearable" :filterable="filterable"
130
+ :multiple="multiple" @change="handleChange" />
131
+ </template>
132
+
133
+ <!-- 树形选择器 -->
134
+ <template v-else-if="type === 'tree-select'">
135
+ <t-tree-select v-model="computedModelValue" :disabled="disabled" :data="treeData || options"
136
+ :placeholder="placeholder || '请选择'" :clearable="clearable" :filterable="filterable"
137
+ :multiple="multiple" @change="handleChange" />
138
+ </template>
139
+
140
+ <!-- 颜色选择器 -->
141
+ <template v-else-if="type === 'color-picker'">
142
+ <t-color-picker v-model="computedModelValue" :disabled="disabled" :clearable="clearable"
143
+ @change="handleChange" />
144
+ </template>
145
+
146
+ <!-- 富文本编辑器 -->
147
+ <template v-else-if="type === 'rich-text'">
148
+ <ebiz-rich-text-editor v-model="computedModelValue" :placeholder="placeholder || '请输入内容'"
149
+ :disabled="disabled" :readonly="readonly" :height="editorHeight"
150
+ :toolbar-config="editorToolbarConfig" :editor-config="editorConfig" :image-path="editorImagePath"
151
+ :video-path="editorVideoPath" :max-length="maxLength" @change="handleChange" />
152
+ </template>
153
+
154
+ <!-- 子表格 -->
155
+ <template v-else-if="type === 'table'">
156
+ <div class="ebiz-form-table">
157
+ <t-space direction="vertical" style="width: 100%;">
158
+ <!-- 添加按钮 -->
159
+ <div>
160
+ <t-button theme="primary" variant="outline" @click="addTableRow" :disabled="disabled">
161
+ <template #icon>
162
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none">
163
+ <path d="M8 1V15M1 8H15" stroke="currentColor" stroke-width="1.5"
164
+ stroke-linecap="round" />
165
+ </svg>
166
+ </template>
167
+ {{ addButtonText }}
168
+ </t-button>
169
+ </div>
170
+
171
+ <!-- 表格 -->
172
+ <t-table :data="computedModelValue" :columns="computedTableColumns"
173
+ row-key="__id" size="small" bordered :empty="'暂无数据'">
174
+ <!-- 序号列 -->
175
+ <template #index="{ rowIndex }">
176
+ {{ rowIndex + 1 }}
177
+ </template>
178
+
179
+ <!-- 动态渲染每个数据列 -->
180
+ <template v-for="col in tableColumns" :key="col.key" #[col.key]="{ row, rowIndex }">
181
+ <!-- 输入框 -->
182
+ <t-input v-if="!col.type || col.type === 'input'" v-model="row[col.key]"
183
+ :disabled="disabled" :placeholder="col.placeholder || `请输入${col.name}`"
184
+ :clearable="col.clearable !== false" :maxlength="col.maxlength"
185
+ @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
186
+
187
+ <!-- 数字输入框 -->
188
+ <t-input-number v-else-if="col.type === 'number'" v-model="row[col.key]"
189
+ :disabled="disabled" :placeholder="col.placeholder || `请输入${col.name}`"
190
+ :min="col.min" :max="col.max" :step="col.step || 1"
191
+ :decimal-places="col.decimalPlaces"
192
+ @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
193
+
194
+ <!-- 选择器 -->
195
+ <t-select v-else-if="col.type === 'select' && col.isRemote !== true" v-model="row[col.key]" :disabled="disabled"
196
+ :placeholder="col.placeholder || `请选择${col.name}`" :options="col.options || []"
197
+ :clearable="col.clearable !== false" :filterable="col.filterable"
198
+ :multiple="col.multiple"
199
+ @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
200
+
201
+ <!-- 远程搜索 -->
202
+ <ebiz-remote-select v-else-if="col.type === 'select' && col.isRemote === true" v-model="row[col.key]" :queryParams="col.queryParams"
203
+ :placeholder="col.placeholder || `请选择${col.name}`" :disabled="disabled" :clearable="col.clearable !== false"
204
+ :filterable="true" :multiple="col.multiple" :apiConfig="col.remoteApiConfig"
205
+ @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
206
+
207
+ <!-- 日期选择器 -->
208
+ <t-date-picker v-else-if="col.type === 'date'" v-model="row[col.key]"
209
+ :disabled="disabled" :placeholder="col.placeholder || `请选择${col.name}`"
210
+ :format="col.format || 'YYYY-MM-DD'" :clearable="col.clearable !== false"
211
+ @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
212
+
213
+ <!-- 日期时间选择器 -->
214
+ <t-date-picker v-else-if="col.type === 'datetime'" v-model="row[col.key]"
215
+ :disabled="disabled" :placeholder="col.placeholder || `请选择${col.name}`"
216
+ :format="col.format || 'YYYY-MM-DD HH:mm:ss'" enable-time-picker
217
+ :clearable="col.clearable !== false"
218
+ @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
219
+
220
+ <!-- 开关 -->
221
+ <t-switch v-else-if="col.type === 'switch'" v-model="row[col.key]" :disabled="disabled"
222
+ @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
223
+
224
+ <!-- 文本域 -->
225
+ <t-textarea v-else-if="col.type === 'textarea'" v-model="row[col.key]"
226
+ :disabled="disabled" :placeholder="col.placeholder || `请输入${col.name}`"
227
+ :autosize="col.autosize || { minRows: 2, maxRows: 4 }" :maxlength="col.maxlength"
228
+ @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
229
+
230
+ <!-- 单选框组 -->
231
+ <t-radio-group v-else-if="col.type === 'radio'" v-model="row[col.key]"
232
+ :disabled="disabled" :options="col.options || []"
233
+ @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
234
+
235
+ <!-- 复选框组 -->
236
+ <t-checkbox-group v-else-if="col.type === 'checkbox'" v-model="row[col.key]"
237
+ :disabled="disabled" :options="col.options || []" :max="col.max"
238
+ @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
239
+
240
+ <ebiz-employee-selector v-else-if="col.type === 'employee'" v-model="row[col.key]"
241
+ :placeholder="col.placeholder || '请选择员工'" :disabled="disabled"
242
+ :clearable="col.clearable !== false" :single="col.single" :defaultTab="col.defaultTab"
243
+ :maxCount="col.maxCount" @update:model-value="(value) => updateTableCell(rowIndex, col.key, value)" />
244
+
245
+ <!-- 默认文本显示 -->
246
+ <span v-else>{{ row[col.key] || '' }}</span>
247
+ </template>
248
+
249
+ <!-- 操作列 -->
250
+ <template v-if="showTableActions" #actions="{ rowIndex }">
251
+ <t-button theme="danger" variant="text" size="small" :disabled="disabled"
252
+ @click="removeTableRow(rowIndex)">
253
+ 删除
254
+ </t-button>
255
+ </template>
256
+ </t-table>
257
+ </t-space>
258
+ </div>
259
+ </template>
260
+
261
+ <!-- 字典选择器 -->
262
+ <template v-else-if="type === 'dictionarySelect'">
263
+ <ebiz-dictionary-select v-model="computedModelValue" :dictionary-key="dictionaryKey" :queryParams="queryParams"
264
+ :placeholder="placeholder || '请选择'" :disabled="disabled" :clearable="clearable"
265
+ :filterable="true" :multiple="multiple" :loading="loading"
266
+ @change="handleChange" />
267
+ </template>
268
+
269
+ <!-- 默认插槽,用于自定义控件 -->
270
+ <template v-else>
271
+ </template>
272
+ </slot>
273
+
274
+ </t-form-item>
275
+ </template>
276
+
277
+ <script>
278
+ /**
279
+ * @displayName PC端表单项
280
+ * @description PC端表单项组件,基于TDesign FormItem封装,支持多种控件类型,包括子表格功能
281
+ * @category 表单组件
282
+ * @name EbizSFormItem
283
+ */
284
+ export default {
285
+ name: "EbizSFormItem"
286
+ }
287
+ </script>
288
+
289
+ <script setup>
290
+ import { defineProps, defineEmits, computed, watch, onMounted } from 'vue';
291
+ import {
292
+ FormItem as TFormItem,
293
+ Input as TInput,
294
+ InputNumber as TInputNumber,
295
+ Textarea as TTextarea,
296
+ Select as TSelect,
297
+ DatePicker as TDatePicker,
298
+ TimePicker as TTimePicker,
299
+ RadioGroup as TRadioGroup,
300
+ CheckboxGroup as TCheckboxGroup,
301
+ Switch as TSwitch,
302
+ Slider as TSlider,
303
+ Cascader as TCascader,
304
+ TreeSelect as TTreeSelect,
305
+ ColorPicker as TColorPicker,
306
+ Table as TTable,
307
+ Button as TButton,
308
+ Space as TSpace
309
+ } from 'tdesign-vue-next';
310
+ import EbizRemoteSelect from '../../EbizRemoteSelect.vue';
311
+ import EbizEmployeeSelector from '../../EbizEmployeeSelector.vue';
312
+ import EbizDepartmentSelector from '../../EbizDepartmentSelector.vue';
313
+ import { EbizUpload } from '../../../index.js'
314
+ import EbizRichTextEditor from '../../EbizRichTextEditor.vue';
315
+ import EbizDictionarySelect from '../../EbizDictionarySelect.vue';
316
+
317
+ const props = defineProps({
318
+ /**
319
+ * 组件类型
320
+ * @options input|number|textarea|select|date|datetime|time|radio|checkbox|switch|slider|upload|video-upload|cascader|tree-select|color-picker|employee|dept|table
321
+ */
322
+ type: {
323
+ type: String,
324
+ default: undefined,
325
+ validator: (val) => [
326
+ 'input', 'number', 'textarea', 'select', 'date', 'datetime', 'time', 'radio',
327
+ 'checkbox', 'switch', 'slider', 'upload', 'video-upload', 'cascader', 'tree-select',
328
+ 'color-picker', 'employee', 'dept', 'table', 'rich-text'
329
+ ].includes(val)
330
+ },
331
+
332
+ queryParams: {
333
+ type: Object,
334
+ default: () => ({})
335
+ },
336
+ /**
337
+ * 绑定的值
338
+ */
339
+ modelValue: {
340
+ type: [String, Number, Boolean, Array, Object],
341
+ default: undefined
342
+ },
343
+ /**
344
+ * 表单项标签
345
+ */
346
+ label: {
347
+ type: String,
348
+ default: ''
349
+ },
350
+ /**
351
+ * 表单项字段名,唯一标识
352
+ */
353
+ name: {
354
+ type: String,
355
+ default: ''
356
+ },
357
+ /**
358
+ * html元素原生属性for
359
+ */
360
+ forAttr: {
361
+ type: String,
362
+ default: undefined
363
+ },
364
+ /**
365
+ * 表单项帮助文本
366
+ */
367
+ help: {
368
+ type: [String, Function],
369
+ default: ''
370
+ },
371
+ /**
372
+ * 是否禁用
373
+ */
374
+ disabled: {
375
+ type: Boolean,
376
+ default: false
377
+ },
378
+ /**
379
+ * 是否只读
380
+ */
381
+ readonly: {
382
+ type: Boolean,
383
+ default: false
384
+ },
385
+ /**
386
+ * 表单项规则
387
+ */
388
+ rules: {
389
+ type: [Array, Object],
390
+ default: undefined
391
+ },
392
+ /**
393
+ * 自定义样式
394
+ */
395
+ customStyle: {
396
+ type: [String, Object],
397
+ default: ''
398
+ },
399
+ /**
400
+ * 自定义类名
401
+ */
402
+ className: {
403
+ type: String,
404
+ default: ''
405
+ },
406
+ /**
407
+ * 表单项标签宽度
408
+ */
409
+ labelWidth: {
410
+ type: [String, Number],
411
+ default: undefined
412
+ },
413
+ /**
414
+ * 表单项标签对齐方式
415
+ * @options left|right|top
416
+ */
417
+ labelAlign: {
418
+ type: String,
419
+ default: undefined,
420
+ validator: (val) => ['left', 'right', 'top'].includes(val)
421
+ },
422
+ /**
423
+ * 表单项状态
424
+ * @options default|success|warning|error
425
+ */
426
+ status: {
427
+ type: String,
428
+ default: undefined,
429
+ validator: (val) => ['default', 'success', 'warning', 'error'].includes(val)
430
+ },
431
+ /**
432
+ * 占位文本
433
+ */
434
+ placeholder: {
435
+ type: String,
436
+ default: ''
437
+ },
438
+ /**
439
+ * 是否可清空
440
+ */
441
+ clearable: {
442
+ type: Boolean,
443
+ default: true
444
+ },
445
+ /**
446
+ * 最大长度
447
+ */
448
+ maxLength: {
449
+ type: Number,
450
+ default: undefined
451
+ },
452
+ /**
453
+ * 最大字符数
454
+ */
455
+ maxCharacter: {
456
+ type: Number,
457
+ default: undefined
458
+ },
459
+ /**
460
+ * 是否显示字数限制
461
+ */
462
+ showLimitNumber: {
463
+ type: Boolean,
464
+ default: false
465
+ },
466
+ /**
467
+ * 选项数据,用于select, radio, checkbox等
468
+ */
469
+ options: {
470
+ type: Array,
471
+ default: () => []
472
+ },
473
+ /**
474
+ * 树形数据,用于tree-select
475
+ */
476
+ treeData: {
477
+ type: Array,
478
+ default: undefined
479
+ },
480
+ /**
481
+ * 是否支持过滤
482
+ */
483
+ filterable: {
484
+ type: Boolean,
485
+ default: true
486
+ },
487
+ /**
488
+ * 是否支持多选
489
+ */
490
+ multiple: {
491
+ type: Boolean,
492
+ default: false
493
+ },
494
+ /**
495
+ * 加载状态
496
+ */
497
+ loading: {
498
+ type: Boolean,
499
+ default: false
500
+ },
501
+ /**
502
+ * 日期格式
503
+ */
504
+ dateFormat: {
505
+ type: String,
506
+ default: 'YYYY-MM-DD'
507
+ },
508
+ /**
509
+ * 日期选择器模式
510
+ * @options date|week|month|quarter|year
511
+ */
512
+ dateMode: {
513
+ type: String,
514
+ default: 'date',
515
+ validator: (val) => ['date', 'week', 'month', 'quarter', 'year'].includes(val)
516
+ },
517
+ /**
518
+ * 时间格式
519
+ */
520
+ timeFormat: {
521
+ type: String,
522
+ default: 'HH:mm:ss'
523
+ },
524
+ /**
525
+ * 最大值
526
+ */
527
+ max: {
528
+ type: Number,
529
+ default: undefined
530
+ },
531
+ /**
532
+ * 最小值
533
+ */
534
+ min: {
535
+ type: Number,
536
+ default: undefined
537
+ },
538
+ /**
539
+ * 步长
540
+ */
541
+ step: {
542
+ type: Number,
543
+ default: 1
544
+ },
545
+ /**
546
+ * 格式化函数
547
+ */
548
+ format: {
549
+ type: Function,
550
+ default: undefined
551
+ },
552
+ /**
553
+ * 文本域自适应高度
554
+ */
555
+ autosize: {
556
+ type: [Boolean, Object],
557
+ default: false
558
+ },
559
+ /**
560
+ * 滑块是否为范围选择
561
+ */
562
+ range: {
563
+ type: Boolean,
564
+ default: false
565
+ },
566
+ /**
567
+ * 滑块刻度标记
568
+ */
569
+ marks: {
570
+ type: Object,
571
+ default: () => ({})
572
+ },
573
+ /**
574
+ * 上传接受的文件类型
575
+ */
576
+ accept: {
577
+ type: String,
578
+ default: ''
579
+ },
580
+ /**
581
+ * 上传接口地址
582
+ */
583
+ action: {
584
+ type: String,
585
+ default: ''
586
+ },
587
+ /**
588
+ * 上传请求头
589
+ */
590
+ headers: {
591
+ type: Object,
592
+ default: () => ({})
593
+ },
594
+ /**
595
+ * 上传是否携带cookie
596
+ */
597
+ withCredentials: {
598
+ type: Boolean,
599
+ default: false
600
+ },
601
+ /**
602
+ * 上传前的钩子函数
603
+ */
604
+ beforeUpload: {
605
+ type: Function,
606
+ default: undefined
607
+ },
608
+ /**
609
+ * 上传响应格式化函数
610
+ */
611
+ formatResponse: {
612
+ type: Function,
613
+ default: undefined
614
+ },
615
+ /**
616
+ * 上传组件主题
617
+ * @options file|image|image-flow
618
+ */
619
+ uploadTheme: {
620
+ type: String,
621
+ default: 'file',
622
+ validator: (val) => ['file', 'image', 'image-flow'].includes(val)
623
+ },
624
+ /**
625
+ * 是否开启远程搜索
626
+ */
627
+ isRemote: {
628
+ type: Boolean,
629
+ default: false
630
+ },
631
+ /**
632
+ * 远程搜索配置
633
+ */
634
+ remoteApiConfig: {
635
+ type: Object,
636
+ default: () => ({
637
+ url: '',
638
+ method: 'GET',
639
+ params: {},
640
+ data: {},
641
+ headers: {},
642
+ transformResponse: null
643
+ })
644
+ },
645
+ /**
646
+ * 员工选择器是否单选
647
+ */
648
+ single: {
649
+ type: Boolean,
650
+ default: true
651
+ },
652
+ /**
653
+ * 员工选择器默认标签页
654
+ * @options organization|recent
655
+ */
656
+ defaultTab: {
657
+ type: String,
658
+ default: 'organization',
659
+ validator: (val) => ['organization', 'recent'].includes(val)
660
+ },
661
+ /**
662
+ * 员工选择器最大选择数量
663
+ */
664
+ maxCount: {
665
+ type: Number,
666
+ default: undefined
667
+ },
668
+ /**
669
+ * 部门选择器API地址
670
+ */
671
+ apiUrl: {
672
+ type: String,
673
+ default: '/api/departments'
674
+ },
675
+ /**
676
+ * 部门选择器所属公司ID
677
+ */
678
+ companyId: {
679
+ type: [String, Number],
680
+ default: undefined
681
+ },
682
+ /**
683
+ * 子表格列配置,用于table类型
684
+ * 示例:[
685
+ * {name:'名称', key:'name', type:'input', width:150},
686
+ * {name:'类型', key:'type', type:'select', options:[{label:'选项1', value:'1'}]},
687
+ * {name:'数量', key:'num', type:'number', min:0, max:999}
688
+ * ]
689
+ */
690
+ tableColumns: {
691
+ type: Array,
692
+ default: () => []
693
+ },
694
+ /**
695
+ * 子表格是否显示操作列
696
+ */
697
+ showTableActions: {
698
+ type: Boolean,
699
+ default: true
700
+ },
701
+ /**
702
+ * 子表格新增按钮文本
703
+ */
704
+ addButtonText: {
705
+ type: String,
706
+ default: '添加数据'
707
+ },
708
+ /**
709
+ * 富文本编辑器高度
710
+ */
711
+ editorHeight: {
712
+ type: [String, Number],
713
+ default: 300
714
+ },
715
+ /**
716
+ * 富文本编辑器工具栏配置
717
+ */
718
+ editorToolbarConfig: {
719
+ type: Object,
720
+ default: () => ({})
721
+ },
722
+ /**
723
+ * 富文本编辑器配置
724
+ */
725
+ editorConfig: {
726
+ type: Object,
727
+ default: () => ({})
728
+ },
729
+ /**
730
+ * 富文本图片上传路径
731
+ */
732
+ editorImagePath: {
733
+ type: String,
734
+ default: 'editor'
735
+ },
736
+ /**
737
+ * 富文本视频上传路径
738
+ */
739
+ editorVideoPath: {
740
+ type: String,
741
+ default: 'video'
742
+ },
743
+ /**
744
+ * 字典类型
745
+ */
746
+ dictionaryKey: {
747
+ type: String,
748
+ default: ''
749
+ }
750
+ });
751
+
752
+ const emit = defineEmits([
753
+ 'update:modelValue',
754
+ 'change',
755
+ 'validate'
756
+ ]);
757
+
758
+ // 计算属性处理v-model双向绑定
759
+ const computedModelValue = computed({
760
+ get: () => props.modelValue,
761
+ set: (val) => {
762
+ emit('update:modelValue', val);
763
+ }
764
+ });
765
+
766
+ // 表格列配置计算属性
767
+ const computedTableColumns = computed(() => {
768
+ if (props.type !== 'table' || !props.tableColumns?.length) return [];
769
+
770
+ const columns = [];
771
+
772
+ // 添加序号列
773
+ columns.push({
774
+ colKey: 'index',
775
+ title: '序号',
776
+ width: 80,
777
+ align: 'center'
778
+ });
779
+
780
+ // 添加用户配置的列
781
+ const userColumns = props.tableColumns.map(col => ({
782
+ colKey: col.key,
783
+ title: col.name,
784
+ width: col.width || undefined,
785
+ align: col.align || 'left'
786
+ }));
787
+
788
+ columns.push(...userColumns);
789
+
790
+ // 添加操作列
791
+ if (props.showTableActions) {
792
+ columns.push({
793
+ colKey: 'actions',
794
+ title: '操作',
795
+ width: 80,
796
+ align: 'center'
797
+ });
798
+ }
799
+
800
+ return columns;
801
+ });
802
+
803
+ /**
804
+ * 值变更事件
805
+ * @param {*} val 新值
806
+ */
807
+ const handleChange = (val) => {
808
+ emit('change', val);
809
+ };
810
+
811
+ /**
812
+ * 验证事件
813
+ * @param {Object} validateResult 验证结果
814
+ */
815
+ const handleValidate = (validateResult) => {
816
+ emit('validate', validateResult);
817
+ };
818
+
819
+ /**
820
+ * 清除视频上传
821
+ */
822
+ const clearVideoUpload = () => {
823
+ computedModelValue.value = null;
824
+ emit('change', null);
825
+ };
826
+
827
+ /**
828
+ * 添加表格行
829
+ */
830
+ const addTableRow = () => {
831
+ const currentData = computedModelValue.value || [];
832
+ const newRow = {};
833
+
834
+ // 根据表格列配置初始化新行数据
835
+ props.tableColumns.forEach(col => {
836
+ // 根据列类型设置默认值
837
+ switch (col.type) {
838
+ case 'number':
839
+ newRow[col.key] = col.defaultValue || 0;
840
+ break;
841
+ case 'switch':
842
+ newRow[col.key] = col.defaultValue || false;
843
+ break;
844
+ case 'checkbox':
845
+ newRow[col.key] = col.defaultValue || [];
846
+ break;
847
+ case 'select':
848
+ if (col.multiple) {
849
+ newRow[col.key] = col.defaultValue || [];
850
+ } else {
851
+ newRow[col.key] = col.defaultValue || '';
852
+ }
853
+ break;
854
+ default:
855
+ newRow[col.key] = col.defaultValue || '';
856
+ break;
857
+ }
858
+ });
859
+
860
+ const newData = [...currentData, newRow];
861
+ // 只更新computedModelValue,让watch自动处理change事件
862
+ computedModelValue.value = JSON.parse(JSON.stringify(newData));
863
+ };
864
+
865
+ /**
866
+ * 删除表格行
867
+ * @param {number} rowIndex 行索引
868
+ */
869
+ const removeTableRow = (rowIndex) => {
870
+ if (props.type !== 'table') return;
871
+
872
+ const currentData = [...(computedModelValue.value || [])];
873
+ currentData.splice(rowIndex, 1);
874
+
875
+ // 只更新computedModelValue,让watch自动处理change事件
876
+ computedModelValue.value = currentData;
877
+ };
878
+
879
+ /**
880
+ * 更新表格单元格数据
881
+ * @param {number} rowIndex 行索引
882
+ * @param {string} colKey 列键名
883
+ * @param {*} value 新值
884
+ */
885
+ const updateTableCell = (rowIndex, colKey, value) => {
886
+ if (props.type !== 'table') return;
887
+
888
+ const currentData = [...(computedModelValue.value || [])];
889
+ if (currentData[rowIndex]) {
890
+ currentData[rowIndex] = {
891
+ ...currentData[rowIndex],
892
+ [colKey]: value
893
+ };
894
+
895
+ // 只更新computedModelValue,让watch自动处理change事件
896
+ computedModelValue.value = currentData;
897
+ }
898
+ };
899
+
900
+ // 监听modelValue变化,触发change事件(仅在table类型时)
901
+ watch(
902
+ () => props.modelValue,
903
+ (newVal, oldVal) => {
904
+ if (props.type === 'table' && newVal !== oldVal) {
905
+ // 只在数据真正变化时触发change事件
906
+ const cleanData = Array.isArray(newVal) ? newVal : [];
907
+ handleChange(cleanData);
908
+ }
909
+ },
910
+ { deep: true }
911
+ );
912
+
913
+ // 组件挂载时初始化文件列表
914
+ onMounted(() => {
915
+ });
916
+ </script>
917
+
918
+ <style scoped>
919
+ .custom-control {
920
+ width: 100%;
921
+ }
922
+
923
+ .ebiz-form-table {
924
+ width: 100%;
925
+ }
926
+
927
+ .ebiz-form-table :deep(.t-table) {
928
+ border: 1px solid var(--td-border-level-1-color);
929
+ border-radius: var(--td-radius-default);
930
+ }
931
+
932
+ .ebiz-form-table :deep(.t-table td) {
933
+ padding: 8px 12px;
934
+ }
935
+
936
+ .ebiz-form-table :deep(.t-table th) {
937
+ background-color: var(--td-bg-color-secondarycontainer);
938
+ font-weight: 500;
939
+ }
940
+
941
+ .ebiz-form-table :deep(.t-input) {
942
+ border: none;
943
+ box-shadow: none;
944
+ }
945
+
946
+ .ebiz-form-table :deep(.t-input:focus-within) {
947
+ border: 1px solid var(--td-brand-color);
948
+ box-shadow: 0 0 0 2px var(--td-brand-color-focus);
949
+ }
950
+
951
+ .ebiz-form-table :deep(.t-input-number) {
952
+ border: none;
953
+ box-shadow: none;
954
+ }
955
+
956
+ .ebiz-form-table :deep(.t-input-number:focus-within) {
957
+ border: 1px solid var(--td-brand-color);
958
+ box-shadow: 0 0 0 2px var(--td-brand-color-focus);
959
+ }
960
+
961
+ .ebiz-form-table :deep(.t-select) {
962
+ border: none;
963
+ box-shadow: none;
964
+ }
965
+
966
+ .ebiz-form-table :deep(.t-select:focus-within) {
967
+ border: 1px solid var(--td-brand-color);
968
+ box-shadow: 0 0 0 2px var(--td-brand-color-focus);
969
+ }
970
+
971
+ .ebiz-form-table :deep(.t-date-picker) {
972
+ border: none;
973
+ box-shadow: none;
974
+ }
975
+
976
+ .ebiz-form-table :deep(.t-date-picker:focus-within) {
977
+ border: 1px solid var(--td-brand-color);
978
+ box-shadow: 0 0 0 2px var(--td-brand-color-focus);
979
+ }
980
+
981
+ .ebiz-form-table :deep(.t-textarea) {
982
+ border: none;
983
+ box-shadow: none;
984
+ }
985
+
986
+ .ebiz-form-table :deep(.t-textarea:focus-within) {
987
+ border: 1px solid var(--td-brand-color);
988
+ box-shadow: 0 0 0 2px var(--td-brand-color-focus);
989
+ }
990
+
991
+ .ebiz-form-table :deep(.t-switch) {
992
+ justify-content: center;
993
+ }
994
+
995
+ .ebiz-form-table :deep(.t-radio-group),
996
+ .ebiz-form-table :deep(.t-checkbox-group) {
997
+ justify-content: center;
998
+ }
999
999
  </style>