Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
DolphinScheduler
提交
9fff2afe
DolphinScheduler
项目概览
apache
/
DolphinScheduler
上一次同步 1 年多
通知
707
Star
9572
Fork
3514
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9fff2afe
编写于
2月 06, 2022
作者:
A
Amy0104
提交者:
GitHub
2月 06, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Feature][UI Next] Add switch,select and input-number to form (#8287)
上级
41efe305
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
158 addition
and
79 deletion
+158
-79
dolphinscheduler-ui-next/src/components/form/fields/custom-parameters.ts
...r-ui-next/src/components/form/fields/custom-parameters.ts
+7
-8
dolphinscheduler-ui-next/src/components/form/fields/get-field.ts
...scheduler-ui-next/src/components/form/fields/get-field.ts
+10
-31
dolphinscheduler-ui-next/src/components/form/fields/index.ts
dolphinscheduler-ui-next/src/components/form/fields/index.ts
+3
-0
dolphinscheduler-ui-next/src/components/form/fields/input-number.ts
...eduler-ui-next/src/components/form/fields/input-number.ts
+33
-0
dolphinscheduler-ui-next/src/components/form/fields/input.ts
dolphinscheduler-ui-next/src/components/form/fields/input.ts
+3
-3
dolphinscheduler-ui-next/src/components/form/fields/monaco-editor.ts
...duler-ui-next/src/components/form/fields/monaco-editor.ts
+6
-3
dolphinscheduler-ui-next/src/components/form/fields/radio.ts
dolphinscheduler-ui-next/src/components/form/fields/radio.ts
+3
-3
dolphinscheduler-ui-next/src/components/form/fields/select.ts
...hinscheduler-ui-next/src/components/form/fields/select.ts
+33
-0
dolphinscheduler-ui-next/src/components/form/fields/switch.ts
...hinscheduler-ui-next/src/components/form/fields/switch.ts
+32
-0
dolphinscheduler-ui-next/src/components/form/get-elements-by-json.ts
...duler-ui-next/src/components/form/get-elements-by-json.ts
+10
-9
dolphinscheduler-ui-next/src/components/form/index.tsx
dolphinscheduler-ui-next/src/components/form/index.tsx
+9
-10
dolphinscheduler-ui-next/src/components/form/types.ts
dolphinscheduler-ui-next/src/components/form/types.ts
+9
-12
未找到文件。
dolphinscheduler-ui-next/src/components/form/fields/custom-parameters.ts
浏览文件 @
9fff2afe
...
...
@@ -20,14 +20,14 @@ import { NFormItem, NSpace, NButton, NIcon } from 'naive-ui'
import
{
PlusCircleOutlined
,
DeleteOutlined
}
from
'
@vicons/antd
'
import
getField
from
'
./get-field
'
import
{
formatValidate
}
from
'
../utils
'
import
type
{
I
FieldParams
,
I
JsonItem
,
FormItemRule
}
from
'
../types
'
import
type
{
IJsonItem
,
FormItemRule
}
from
'
../types
'
interface
ICustomParameters
extends
Omit
<
IFieldParams
,
'
rules
'
>
{
rules
?:
{
[
key
:
string
]:
FormItemRule
}[]
}
export
function
renderCustomParameters
(
params
:
ICustomParameters
)
{
const
{
field
s
,
field
,
children
=
[],
rules
=
[]
}
=
params
export
function
renderCustomParameters
(
item
:
IJsonItem
,
fields
:
{
[
field
:
string
]:
any
},
rules
:
{
[
key
:
string
]:
FormItemRule
}[]
)
{
const
{
field
,
children
=
[]
}
=
item
let
defaultValue
:
{
[
field
:
string
]:
any
}
=
{}
let
ruleItem
:
{
[
key
:
string
]:
FormItemRule
}
=
{}
children
.
forEach
((
child
)
=>
{
...
...
@@ -77,7 +77,6 @@ export function renderCustomParameters(params: ICustomParameters) {
onClick
:
()
=>
{
rules
.
push
(
ruleItem
)
fields
[
field
].
push
({
...
defaultValue
})
console
.
log
(
rules
)
}
},
()
=>
h
(
NIcon
,
{
size
:
24
},
()
=>
h
(
PlusCircleOutlined
))
...
...
dolphinscheduler-ui-next/src/components/form/fields/get-field.ts
浏览文件 @
9fff2afe
...
...
@@ -15,7 +15,8 @@
* limitations under the License.
*/
import
*
as
Field
from
'
./index
'
import
type
{
FormRules
}
from
'
naive-ui
'
import
{
camelCase
,
upperFirst
}
from
'
lodash
'
import
type
{
FormRules
,
FormItemRule
}
from
'
naive-ui
'
import
type
{
IJsonItem
}
from
'
../types
'
const
getField
=
(
...
...
@@ -23,39 +24,17 @@ const getField = (
fields
:
{
[
field
:
string
]:
any
},
rules
?:
FormRules
)
=>
{
const
{
type
,
props
=
{},
field
,
options
,
children
}
=
item
const
{
type
=
'
input
'
}
=
item
const
renderTypeName
=
`render
${
upperFirst
(
camelCase
(
type
))}
`
// TODO Support other widgets later
if
(
type
===
'
radio
'
)
{
return
Field
.
renderRadio
({
field
,
fields
,
props
,
options
})
}
if
(
type
===
'
editor
'
)
{
return
Field
.
renderEditor
({
field
,
fields
,
props
})
}
if
(
type
===
'
custom-parameters
'
)
{
const
params
=
{
field
,
fields
,
children
,
props
,
rules
:
[]
}
if
(
rules
)
{
params
.
rules
=
rules
[
field
]
=
[]
}
return
Field
.
renderCustomParameters
(
params
)
let
fieldRules
:
{
[
key
:
string
]:
FormItemRule
}[]
=
[]
if
(
rules
&&
!
rules
[
item
.
field
])
fieldRules
=
rules
[
item
.
field
]
=
[]
// @ts-ignore
return
Field
[
renderTypeName
](
item
,
fields
,
fieldRules
)
}
return
Field
.
renderInput
({
field
,
fields
,
props
}
)
// @ts-ignore
return
Field
[
renderTypeName
](
item
,
fields
)
}
export
default
getField
dolphinscheduler-ui-next/src/components/form/fields/index.ts
浏览文件 @
9fff2afe
...
...
@@ -19,3 +19,6 @@ export { renderInput } from './input'
export
{
renderRadio
}
from
'
./radio
'
export
{
renderEditor
}
from
'
./monaco-editor
'
export
{
renderCustomParameters
}
from
'
./custom-parameters
'
export
{
renderSwitch
}
from
'
./switch
'
export
{
renderInputNumber
}
from
'
./input-number
'
export
{
renderSelect
}
from
'
./select
'
dolphinscheduler-ui-next/src/components/form/fields/input-number.ts
0 → 100644
浏览文件 @
9fff2afe
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
h
}
from
'
vue
'
import
{
NInputNumber
}
from
'
naive-ui
'
import
type
{
IJsonItem
}
from
'
../types
'
export
function
renderInputNumber
(
item
:
IJsonItem
,
fields
:
{
[
field
:
string
]:
any
}
)
{
const
{
props
,
field
}
=
item
return
h
(
NInputNumber
,
{
...
props
,
value
:
fields
[
field
],
onUpdateValue
:
(
value
)
=>
void
(
fields
[
field
]
=
value
)
})
}
dolphinscheduler-ui-next/src/components/form/fields/input.ts
浏览文件 @
9fff2afe
...
...
@@ -17,10 +17,10 @@
import
{
h
}
from
'
vue
'
import
{
NInput
}
from
'
naive-ui
'
import
type
{
I
FieldParams
}
from
'
../types
'
import
type
{
I
JsonItem
}
from
'
../types
'
export
function
renderInput
(
params
:
IFieldParams
)
{
const
{
props
,
field
s
,
field
}
=
params
export
function
renderInput
(
item
:
IJsonItem
,
fields
:
{
[
field
:
string
]:
any
}
)
{
const
{
props
,
field
}
=
item
return
h
(
NInput
,
{
...
props
,
value
:
fields
[
field
],
...
...
dolphinscheduler-ui-next/src/components/form/fields/monaco-editor.ts
浏览文件 @
9fff2afe
...
...
@@ -17,10 +17,13 @@
import
{
h
}
from
'
vue
'
import
Editor
from
'
@/components/monaco-editor
'
import
type
{
I
FieldParams
}
from
'
../types
'
import
type
{
I
JsonItem
}
from
'
../types
'
export
function
renderEditor
(
params
:
IFieldParams
)
{
const
{
props
,
fields
,
field
}
=
params
export
function
renderEditor
(
item
:
IJsonItem
,
fields
:
{
[
field
:
string
]:
any
}
)
{
const
{
props
,
field
}
=
item
return
h
(
Editor
,
{
...
props
,
value
:
fields
[
field
],
...
...
dolphinscheduler-ui-next/src/components/form/fields/radio.ts
浏览文件 @
9fff2afe
...
...
@@ -17,10 +17,10 @@
import
{
h
}
from
'
vue
'
import
{
NRadio
,
NRadioGroup
,
NSpace
}
from
'
naive-ui
'
import
type
{
I
FieldParams
,
IOption
}
from
'
../types
'
import
type
{
I
JsonItem
,
IOption
}
from
'
../types
'
export
function
renderRadio
(
params
:
IFieldParams
)
{
const
{
props
,
field
s
,
field
,
options
}
=
params
export
function
renderRadio
(
item
:
IJsonItem
,
fields
:
{
[
field
:
string
]:
any
}
)
{
const
{
props
,
field
,
options
}
=
item
if
(
!
options
||
options
.
length
===
0
)
{
return
h
(
NRadio
,
{
...
props
,
...
...
dolphinscheduler-ui-next/src/components/form/fields/select.ts
0 → 100644
浏览文件 @
9fff2afe
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
h
}
from
'
vue
'
import
{
NSelect
}
from
'
naive-ui
'
import
type
{
IJsonItem
}
from
'
../types
'
export
function
renderSelect
(
item
:
IJsonItem
,
fields
:
{
[
field
:
string
]:
any
}
)
{
const
{
props
,
field
,
options
=
[]
}
=
item
return
h
(
NSelect
,
{
...
props
,
value
:
fields
[
field
],
onUpdateValue
:
(
value
)
=>
void
(
fields
[
field
]
=
value
),
options
})
}
dolphinscheduler-ui-next/src/components/form/fields/switch.ts
0 → 100644
浏览文件 @
9fff2afe
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
h
}
from
'
vue
'
import
{
NSwitch
}
from
'
naive-ui
'
import
type
{
IJsonItem
}
from
'
../types
'
export
function
renderSwitch
(
item
:
IJsonItem
,
fields
:
{
[
field
:
string
]:
any
}
)
{
const
{
props
,
field
}
=
item
return
h
(
NSwitch
,
{
...
props
,
value
:
fields
[
field
],
onUpdateValue
:
(
value
:
string
)
=>
void
(
fields
[
field
]
=
value
)
})
}
dolphinscheduler-ui-next/src/components/form/get-elements-by-json.ts
浏览文件 @
9fff2afe
...
...
@@ -17,6 +17,7 @@
import
{
formatValidate
}
from
'
./utils
'
import
getField
from
'
./fields/get-field
'
import
{
omit
}
from
'
lodash
'
import
type
{
FormRules
}
from
'
naive-ui
'
import
type
{
IJsonItem
}
from
'
./types
'
...
...
@@ -27,20 +28,20 @@ export default function getElementByJson(
const
rules
:
FormRules
=
{}
const
initialValues
:
{
[
field
:
string
]:
any
}
=
{}
const
elements
=
[]
for
(
let
item
of
json
)
{
if
(
item
.
value
)
{
fields
[
item
.
field
]
=
item
.
value
initialValues
[
item
.
field
]
=
item
.
value
const
{
name
,
value
,
field
,
children
,
validate
,
...
rest
}
=
item
if
(
value
)
{
fields
[
field
]
=
value
initialValues
[
field
]
=
value
}
if
(
item
.
validate
)
rules
[
item
.
field
]
=
formatValidate
(
item
.
validate
)
if
(
validate
)
rules
[
field
]
=
formatValidate
(
validate
)
elements
.
push
({
label
:
item
.
name
,
path
:
!
item
.
children
?
item
.
field
:
''
,
showLabel
:
!!
item
.
name
,
showLabel
:
!!
name
,
...
omit
(
rest
,
[
'
type
'
,
'
props
'
,
'
options
'
]),
label
:
name
,
path
:
!
children
?
field
:
''
,
widget
:
()
=>
getField
(
item
,
fields
,
rules
)
})
}
return
{
rules
,
elements
,
initialValues
}
}
dolphinscheduler-ui-next/src/components/form/index.tsx
浏览文件 @
9fff2afe
...
...
@@ -47,20 +47,19 @@ const Form = defineComponent({
},
render
(
props
:
{
meta
:
IMeta
;
layout
?:
GridProps
;
loading
?:
boolean
})
{
const
{
loading
,
layout
,
meta
}
=
props
const
{
elements
,
...
restFormProps
}
=
meta
const
{
elements
=
[]
,
...
restFormProps
}
=
meta
return
(
<
NSpin
show
=
{
loading
}
>
<
NForm
{
...
restFormProps
}
ref
=
'formRef'
>
<
NGrid
{
...
layout
}
>
{
elements
&&
elements
.
map
((
element
)
=>
{
const
{
span
=
24
,
path
,
widget
,
...
formItemProps
}
=
element
return
(
<
NFormItemGi
{
...
formItemProps
}
span
=
{
span
}
path
=
{
path
}
>
{
h
(
widget
)
}
</
NFormItemGi
>
)
})
}
{
elements
.
map
((
element
)
=>
{
const
{
span
=
24
,
path
,
widget
,
...
formItemProps
}
=
element
return
(
<
NFormItemGi
{
...
formItemProps
}
span
=
{
span
}
path
=
{
path
}
>
{
h
(
widget
)
}
</
NFormItemGi
>
)
})
}
</
NGrid
>
</
NForm
>
</
NSpin
>
...
...
dolphinscheduler-ui-next/src/components/form/types.ts
浏览文件 @
9fff2afe
...
...
@@ -24,7 +24,14 @@ import type {
SelectOption
}
from
'
naive-ui
'
type
IType
=
'
input
'
|
'
radio
'
|
'
editor
'
|
'
custom-parameters
'
type
IType
=
|
'
input
'
|
'
radio
'
|
'
editor
'
|
'
custom-parameters
'
|
'
switch
'
|
'
input-number
'
|
'
select
'
type
IOption
=
SelectOption
...
...
@@ -37,15 +44,6 @@ interface IMeta extends Omit<FormProps, 'model'> {
model
:
object
}
interface
IFieldParams
{
field
:
string
props
:
object
fields
:
{
[
field
:
string
]:
any
}
options
?:
IOption
[]
rules
?:
FormRules
|
{
[
key
:
string
]:
FormRules
}
children
?:
IJsonItem
[]
}
interface
IJsonItem
{
field
:
string
name
?:
string
...
...
@@ -66,6 +64,5 @@ export {
FormItemRule
,
FormRules
,
IFormItem
,
GridProps
,
IFieldParams
GridProps
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录