File tree Expand file tree Collapse file tree 3 files changed +66
-1
lines changed
src/packages/table/editable-table Expand file tree Collapse file tree 3 files changed +66
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { defineComponent , ref , unref } from 'vue'
2
+ import { Popover } from 'ant-design-vue'
3
+ import { pick } from 'lodash-es'
4
+ import classNames from '@/utils/classNames/bind'
5
+ import styles from './style/index.module.scss'
6
+
7
+ const cx = classNames . bind ( styles )
8
+
9
+ export default defineComponent ( {
10
+ inheritAttrs : false ,
11
+ props : {
12
+ ...Popover . props ,
13
+ trigger : {
14
+ type : String ,
15
+ default : 'click'
16
+ } ,
17
+ placement : {
18
+ type : String ,
19
+ default : 'topLeft'
20
+ } ,
21
+ errors : {
22
+ type : Array ,
23
+ default : ( ) => ( [ ] )
24
+ }
25
+ } ,
26
+ setup ( props , { slots } ) {
27
+ const sOpen = ref ( false )
28
+
29
+ function onOpenChange ( value ) {
30
+ if ( value !== unref ( sOpen ) ) {
31
+ sOpen . value = value
32
+ }
33
+ }
34
+
35
+ return ( ) => {
36
+ const { errors } = props
37
+
38
+ const popoverProps = {
39
+ ...pick ( props , Object . keys ( Popover . props ) ) ,
40
+ open : errors . length !== 0 ? unref ( sOpen ) : false ,
41
+ onOpenChange : onOpenChange
42
+ }
43
+
44
+ const popoverSlots = {
45
+ content : ( ) => (
46
+ < div class = { cx ( 'with-help' ) } >
47
+ { errors }
48
+ </ div >
49
+ )
50
+ }
51
+ return (
52
+ < Popover { ...popoverProps } v-slots = { popoverSlots } >
53
+ < div onClick = { ( ) => false } >
54
+ { slots . default && slots . default ( ) }
55
+ </ div >
56
+ </ Popover >
57
+ )
58
+ }
59
+ }
60
+ } )
Original file line number Diff line number Diff line change 1
1
import { defineComponent , reactive , watch } from 'vue'
2
2
import { Field , Form } from '@/packages/form'
3
3
import Table from '../table'
4
+ import InlineError from './components/inline-error'
4
5
import { omit , pick } from 'lodash-es'
5
6
6
7
const editable = {
@@ -56,7 +57,11 @@ export default defineComponent({
56
57
fieldProps : { ...fieldProps , style : { width : '100%' } } ,
57
58
formItemProps : needFormItemProps
58
59
}
59
- return < Field { ...needFieldProps } />
60
+ return (
61
+ < InlineError errors = { [ '此项为必填项' ] } >
62
+ < Field { ...needFieldProps } />
63
+ </ InlineError >
64
+ )
60
65
}
61
66
62
67
return ( ) => {
You can’t perform that action at this time.
0 commit comments