@ebiz/designer-components 0.1.78 → 0.1.79

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