Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
fa64fc8a
Commit
fa64fc8a
authored
Jun 24, 2021
by
Vben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(api-select): ensure that the onchange function parameters are correct
parent
a2a75a09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
+24
-6
ApiSelect.vue
src/components/Form/src/components/ApiSelect.vue
+8
-2
useFormItem.ts
src/hooks/component/useFormItem.ts
+16
-4
No files found.
src/components/Form/src/components/ApiSelect.vue
View file @
fa64fc8a
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
<Select
<Select
@
dropdownVisibleChange=
"handleFetch"
@
dropdownVisibleChange=
"handleFetch"
v-bind=
"attrs"
v-bind=
"attrs"
@
change=
"handleChange"
:options=
"getOptions"
:options=
"getOptions"
v-model:value=
"state"
v-model:value=
"state"
>
>
...
@@ -67,11 +68,12 @@
...
@@ -67,11 +68,12 @@
const
options
=
ref
<
OptionsItem
[]
>
([]);
const
options
=
ref
<
OptionsItem
[]
>
([]);
const
loading
=
ref
(
false
);
const
loading
=
ref
(
false
);
const
isFirstLoad
=
ref
(
true
);
const
isFirstLoad
=
ref
(
true
);
const
emitData
=
ref
<
any
[]
>
([]);
const
attrs
=
useAttrs
();
const
attrs
=
useAttrs
();
const
{
t
}
=
useI18n
();
const
{
t
}
=
useI18n
();
// Embedded in the form, just use the hook binding to perform form verification
// Embedded in the form, just use the hook binding to perform form verification
const
[
state
]
=
useRuleFormItem
(
props
);
const
[
state
]
=
useRuleFormItem
(
props
,
'
value
'
,
'
change
'
,
emitData
);
const
getOptions
=
computed
(()
=>
{
const
getOptions
=
computed
(()
=>
{
const
{
labelField
,
valueField
,
numberToString
}
=
props
;
const
{
labelField
,
valueField
,
numberToString
}
=
props
;
...
@@ -135,7 +137,11 @@
...
@@ -135,7 +137,11 @@
emit
(
'
options-change
'
,
unref
(
options
));
emit
(
'
options-change
'
,
unref
(
options
));
}
}
return
{
state
,
attrs
,
getOptions
,
loading
,
t
,
handleFetch
};
function
handleChange
(
_
,
...
args
)
{
emitData
.
value
=
args
;
}
return
{
state
,
attrs
,
getOptions
,
loading
,
t
,
handleFetch
,
handleChange
};
},
},
});
});
</
script
>
</
script
>
src/hooks/component/useFormItem.ts
View file @
fa64fc8a
import
type
{
UnwrapRef
}
from
'
vue
'
;
import
type
{
UnwrapRef
,
Ref
}
from
'
vue
'
;
import
{
reactive
,
readonly
,
computed
,
getCurrentInstance
,
watchEffect
}
from
'
vue
'
;
import
{
reactive
,
readonly
,
computed
,
getCurrentInstance
,
watchEffect
,
unref
,
nextTick
,
toRaw
,
}
from
'
vue
'
;
import
{
isEqual
}
from
'
lodash-es
'
;
import
{
isEqual
}
from
'
lodash-es
'
;
export
function
useRuleFormItem
<
T
extends
Recordable
>
(
export
function
useRuleFormItem
<
T
extends
Recordable
>
(
props
:
T
,
props
:
T
,
key
:
keyof
T
=
'
value
'
,
key
:
keyof
T
=
'
value
'
,
changeEvent
=
'
change
'
changeEvent
=
'
change
'
,
emitData
?:
Ref
<
any
[]
>
)
{
)
{
const
instance
=
getCurrentInstance
();
const
instance
=
getCurrentInstance
();
const
emit
=
instance
?.
emit
;
const
emit
=
instance
?.
emit
;
...
@@ -33,7 +43,9 @@ export function useRuleFormItem<T extends Recordable>(
...
@@ -33,7 +43,9 @@ export function useRuleFormItem<T extends Recordable>(
if
(
isEqual
(
value
,
defaultState
.
value
))
return
;
if
(
isEqual
(
value
,
defaultState
.
value
))
return
;
innerState
.
value
=
value
as
T
[
keyof
T
];
innerState
.
value
=
value
as
T
[
keyof
T
];
emit
?.(
changeEvent
,
value
);
nextTick
(()
=>
{
emit
?.(
changeEvent
,
value
,
...(
toRaw
(
unref
(
emitData
))
||
[]));
});
},
},
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment