1
1
<script lang="tsx">
2
2
import { PropType , defineComponent , ref , computed , unref , watch , onMounted } from ' vue'
3
- import { ElForm , ElFormItem , ElRow , ElCol } from ' element-plus'
3
+ import { ElForm , ElFormItem , ElRow , ElCol , ElTooltip } from ' element-plus'
4
4
import { componentMap } from ' ./componentMap'
5
5
import { propTypes } from ' @/utils/propTypes'
6
6
import { getSlot } from ' @/utils/tsxHelper'
@@ -19,6 +19,7 @@ import { useDesign } from '@/hooks/web/useDesign'
19
19
import { findIndex } from ' @/utils'
20
20
import { set } from ' lodash-es'
21
21
import { FormProps } from ' ./types'
22
+ import { Icon } from ' @/components/Icon'
22
23
23
24
const { getPrefixCls } = useDesign ()
24
25
@@ -181,10 +182,35 @@ export default defineComponent({
181
182
) {
182
183
slotsMap .default = () => renderOptions (item )
183
184
}
185
+
186
+ const formItemSlots: Recordable = setFormItemSlots (slots , item .field )
187
+ // 如果有 labelMessage,自动使用插槽渲染
188
+ if (item ?.labelMessage ) {
189
+ formItemSlots .label = () => {
190
+ return (
191
+ <>
192
+ <span >{ item .label } </span >
193
+ <ElTooltip placement = " right" raw-content >
194
+ { {
195
+ content : () => <span v-html = { item .labelMessage } ></span >,
196
+ default : () => (
197
+ <Icon
198
+ icon = " ep:warning"
199
+ size = { 16 }
200
+ color = " var(--el-color-primary)"
201
+ class = " ml-2px relative top-1px"
202
+ ></Icon >
203
+ )
204
+ }}
205
+ </ElTooltip >
206
+ </>
207
+ )
208
+ }
209
+ }
184
210
return (
185
211
<ElFormItem { ... (item .formItemProps || {})} prop = { item .field } label = { item .label || ' ' } >
186
212
{ {
187
- ... setFormItemSlots ( slots , item . field ) ,
213
+ ... formItemSlots ,
188
214
default : () => {
189
215
const Com = componentMap [item .component as string ] as ReturnType <
190
216
typeof defineComponent
0 commit comments