Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
fa64fc8a
提交
fa64fc8a
authored
6月 24, 2021
作者:
Vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(api-select): ensure that the onchange function parameters are correct
上级
a2a75a09
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
6 行删除
+24
-6
ApiSelect.vue
src/components/Form/src/components/ApiSelect.vue
+8
-2
useFormItem.ts
src/hooks/component/useFormItem.ts
+16
-4
没有找到文件。
src/components/Form/src/components/ApiSelect.vue
浏览文件 @
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
浏览文件 @
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
))
||
[]));
});
},
},
});
});
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论