Skip to content

Commit 4c88ccc

Browse files
YunaiVgitee-org
authored andcommitted
!761 接口选择器新增事件配置功能
Merge pull request !761 from 宿命的风/master
2 parents 5fe16b4 + 32a224c commit 4c88ccc

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

src/components/FormCreate/src/components/useApiSelect.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,24 @@ export const useApiSelect = (option: ApiSelectProps) => {
6969
if (isEmpty(props.url)) {
7070
return
7171
}
72+
7273
switch (props.method) {
7374
case 'GET':
7475
let url: string = props.url
7576
if (props.remote) {
76-
url = `${url}?${props.remoteField}=${queryParam.value}`
77+
if(queryParam.value!=undefined)
78+
{
79+
if(checkUrl(url))
80+
{
81+
url = `${url}&${props.remoteField}=${queryParam.value}`
82+
}else
83+
{
84+
url = `${url}?${props.remoteField}=${queryParam.value}`
85+
}
86+
}else
87+
{
88+
url = `${url}`
89+
}
7790
}
7891
parseOptions(await request.get({ url: url }))
7992
break
@@ -87,6 +100,11 @@ export const useApiSelect = (option: ApiSelectProps) => {
87100
}
88101
}
89102

103+
function checkUrl(url)
104+
{
105+
return url.includes('?')
106+
}
107+
90108
function parseOptions(data: any) {
91109
// 情况一:如果有自定义解析函数优先使用自定义解析
92110
if (!isEmpty(props.parseFunc)) {

src/components/FormCreate/src/config/useSelectRule.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const useSelectRule = (option: SelectRuleOption) => {
1717
icon: option.icon,
1818
label,
1919
name,
20+
event: option.event,
2021
rule() {
2122
return {
2223
type: name,

src/components/FormCreate/src/type/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ export interface SelectRuleOption {
4646
label: string // label 名称
4747
name: string // 组件名称
4848
icon: string // 组件图标
49-
props?: any[] // 组件规则
49+
props?: any[], // 组件规则
50+
event?: any[] // 事件配置
5051
}

src/components/FormCreate/src/useFormCreateDesigner.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ export const useFormCreateDesigner = async (designer: Ref) => {
6363
name: 'ApiSelect',
6464
label: '接口选择器',
6565
icon: 'icon-server',
66-
props: [...apiSelectRule]
66+
props: [...apiSelectRule],
67+
event:['click','change','visibleChange','clear','blur','focus']
6768
})
6869

6970
/**

0 commit comments

Comments
 (0)