Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
一臭打代码的 aka 潘先生です
vue-vben-admin
提交
49827866
V
vue-vben-admin
项目概览
一臭打代码的 aka 潘先生です
/
vue-vben-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-vben-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
49827866
编写于
11月 28, 2020
作者:
V
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(form): fix updateSchema error #100
上级
81baf1d5
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
114 addition
and
91 deletion
+114
-91
src/components/Form/index.ts
src/components/Form/index.ts
+4
-1
src/components/Form/src/BasicForm.vue
src/components/Form/src/BasicForm.vue
+16
-4
src/components/Form/src/FormAction.tsx
src/components/Form/src/FormAction.tsx
+54
-57
src/components/Form/src/props.ts
src/components/Form/src/props.ts
+1
-1
src/router/menus/index.ts
src/router/menus/index.ts
+4
-1
src/router/menus/modules/dashboard.ts
src/router/menus/modules/dashboard.ts
+29
-20
src/router/routes/modules/dashboard.ts
src/router/routes/modules/dashboard.ts
+3
-2
src/utils/index.ts
src/utils/index.ts
+2
-4
vite.config.ts
vite.config.ts
+1
-1
未找到文件。
src/components/Form/index.ts
浏览文件 @
49827866
export
{
default
as
BasicForm
}
from
'
./src/BasicForm.vue
'
;
import
BasicFormLib
from
'
./src/BasicForm.vue
'
;
import
{
withInstall
}
from
'
../util
'
;
export
*
from
'
./src/types/form
'
;
export
*
from
'
./src/types/formItem
'
;
export
{
useComponentRegister
}
from
'
./src/hooks/useComponentRegister
'
;
export
{
useForm
}
from
'
./src/hooks/useForm
'
;
export
const
BasicForm
=
withInstall
(
BasicFormLib
);
src/components/Form/src/BasicForm.vue
浏览文件 @
49827866
...
...
@@ -16,6 +16,7 @@
</
template
>
</FormItem>
</template>
<FormAction
v-bind=
"{ ...getActionPropsRef, ...advanceState }"
@
toggle-advanced=
"handleToggleAdvanced"
...
...
@@ -30,7 +31,17 @@
import
type
{
Ref
,
WatchStopHandle
}
from
'
vue
'
;
import
type
{
ValidateFields
}
from
'
ant-design-vue/lib/form/interface
'
;
import
{
defineComponent
,
reactive
,
ref
,
computed
,
unref
,
toRef
,
onMounted
,
watch
}
from
'
vue
'
;
import
{
defineComponent
,
reactive
,
ref
,
computed
,
unref
,
toRef
,
onMounted
,
watch
,
toRefs
,
}
from
'
vue
'
;
import
{
Form
,
Row
}
from
'
ant-design-vue
'
;
import
FormItem
from
'
./FormItem
'
;
import
{
basicProps
}
from
'
./props
'
;
...
...
@@ -103,6 +114,7 @@
const
schemas
:
FormSchema
[]
=
unref
(
schemaRef
)
||
(
unref
(
getProps
).
schemas
as
any
);
for
(
const
schema
of
schemas
)
{
const
{
defaultValue
,
component
}
=
schema
;
// handle date type
if
(
defaultValue
&&
dateItemType
.
includes
(
component
))
{
if
(
!
Array
.
isArray
(
defaultValue
))
{
schema
.
defaultValue
=
moment
(
defaultValue
);
...
...
@@ -127,10 +139,10 @@
formModel
,
defaultValueRef
,
});
const
{
transformDateFunc
,
fieldMapToTime
}
=
toRefs
(
props
);
const
{
handleFormValues
,
initDefault
}
=
useFormValues
({
transformDateFuncRef
:
t
oRef
(
props
,
'
transformDateFunc
'
)
as
Ref
<
Fn
<
any
>>
,
fieldMapToTimeRef
:
toRef
(
props
,
'
fieldMapToTime
'
)
,
transformDateFuncRef
:
t
ransformDateFunc
as
Ref
<
Fn
<
any
>>
,
fieldMapToTimeRef
:
fieldMapToTime
,
defaultValueRef
,
getSchema
,
formModel
,
...
...
src/components/Form/src/FormAction.tsx
浏览文件 @
49827866
...
...
@@ -7,28 +7,17 @@ import { BasicArrow } from '/@/components/Basic/index';
import
{
getSlot
}
from
'
/@/utils/helper/tsxHelper
'
;
import
{
useI18n
}
from
'
/@/hooks/web/useI18n
'
;
import
{
propTypes
}
from
'
/@/utils/propTypes
'
;
const
{
t
}
=
useI18n
(
'
component.form
'
);
export
default
defineComponent
({
name
:
'
BasicFormAction
'
,
props
:
{
show
:
{
type
:
Boolean
,
default
:
true
,
},
showResetButton
:
{
type
:
Boolean
,
default
:
true
,
},
showSubmitButton
:
{
type
:
Boolean
,
default
:
true
,
},
showAdvancedButton
:
{
type
:
Boolean
,
default
:
true
,
},
show
:
propTypes
.
bool
.
def
(
true
),
showResetButton
:
propTypes
.
bool
.
def
(
true
),
showSubmitButton
:
propTypes
.
bool
.
def
(
true
),
showAdvancedButton
:
propTypes
.
bool
.
def
(
true
),
resetButtonOptions
:
{
type
:
Object
as
PropType
<
any
>
,
default
:
{},
...
...
@@ -41,18 +30,9 @@ export default defineComponent({
type
:
Object
as
PropType
<
any
>
,
default
:
{},
},
actionSpan
:
{
type
:
Number
,
default
:
6
,
},
isAdvanced
:
{
type
:
Boolean
,
default
:
false
,
},
hideAdvanceBtn
:
{
type
:
Boolean
,
default
:
false
,
},
actionSpan
:
propTypes
.
number
.
def
(
6
),
isAdvanced
:
propTypes
.
bool
,
hideAdvanceBtn
:
propTypes
.
bool
,
},
emits
:
[
'
toggle-advanced
'
],
setup
(
props
,
{
slots
,
emit
})
{
...
...
@@ -87,27 +67,13 @@ export default defineComponent({
emit
(
'
toggle-advanced
'
);
}
return
()
=>
{
if
(
!
props
.
show
)
{
return
;
}
const
{
showAdvancedButton
,
hideAdvanceBtn
,
isAdvanced
,
showResetButton
,
showSubmitButton
,
}
=
props
;
function
renderAdvanceButton
()
{
const
{
showAdvancedButton
,
hideAdvanceBtn
,
isAdvanced
}
=
props
;
if
(
!
showAdvancedButton
||
!!
hideAdvanceBtn
)
{
return
null
;
}
return
(
<
Col
{
...
unref
(
actionColOpt
)
}
style
=
{
{
textAlign
:
'
right
'
}
}
>
{
()
=>
(
<
Form
.
Item
>
{
()
=>
(
<>
{
getSlot
(
slots
,
'
advanceBefore
'
)
}
{
showAdvancedButton
&&
!
hideAdvanceBtn
&&
(
<
Button
type
=
"default"
class
=
"mr-2"
onClick
=
{
toggleAdvanced
}
>
{
()
=>
(
<>
...
...
@@ -116,21 +82,52 @@ export default defineComponent({
</>
)
}
</
Button
>
)
}
);
}
{
getSlot
(
slots
,
'
resetBefore
'
)
}
{
showResetButton
&&
(
function
renderResetButton
()
{
const
{
showResetButton
}
=
props
;
if
(
!
showResetButton
)
{
return
null
;
}
return
(
<
Button
type
=
"default"
class
=
"mr-2"
{
...
unref
(
getResetBtnOptionsRef
)
}
>
{
()
=>
unref
(
getResetBtnOptionsRef
).
text
}
</
Button
>
)
}
);
}
{
getSlot
(
slots
,
'
submitBefore
'
)
}
{
showSubmitButton
&&
(
function
renderSubmitButton
()
{
const
{
showSubmitButton
}
=
props
;
if
(
!
showSubmitButton
)
{
return
null
;
}
return
(
<
Button
type
=
"primary"
{
...
unref
(
getSubmitBtnOptionsRef
)
}
>
{
()
=>
unref
(
getSubmitBtnOptionsRef
).
text
}
</
Button
>
)
}
);
}
return
()
=>
{
if
(
!
props
.
show
)
{
return
null
;
}
return
(
<
Col
{
...
unref
(
actionColOpt
)
}
style
=
{
{
textAlign
:
'
right
'
}
}
>
{
()
=>
(
<
Form
.
Item
>
{
()
=>
(
<>
{
getSlot
(
slots
,
'
advanceBefore
'
)
}
{
renderAdvanceButton
()
}
{
getSlot
(
slots
,
'
resetBefore
'
)
}
{
renderResetButton
()
}
{
getSlot
(
slots
,
'
submitBefore
'
)
}
{
renderSubmitButton
()
}
{
getSlot
(
slots
,
'
submitAfter
'
)
}
</>
...
...
src/components/Form/src/props.ts
浏览文件 @
49827866
...
...
@@ -5,7 +5,7 @@ import { TableActionType } from '/@/components/Table';
export
const
basicProps
=
{
model
:
{
type
:
Object
as
PropType
<
any
>
,
type
:
Object
as
PropType
<
Record
<
string
,
any
>
>
,
default
:
{},
},
// 标签宽度 固定宽度
...
...
src/router/menus/index.ts
浏览文件 @
49827866
...
...
@@ -13,7 +13,9 @@ import modules from 'globby!/@/router/menus/modules/**/*.@(ts)';
const
menuModules
:
MenuModule
[]
=
[];
Object
.
keys
(
modules
).
forEach
((
key
)
=>
{
menuModules
.
push
(
modules
[
key
]);
const
moduleItem
=
modules
[
key
];
const
menuModule
=
Array
.
isArray
(
moduleItem
)
?
[...
moduleItem
]
:
[
moduleItem
];
menuModules
.
push
(...
menuModule
);
});
// ===========================
...
...
@@ -25,6 +27,7 @@ const staticMenus: Menu[] = [];
menuModules
.
sort
((
a
,
b
)
=>
{
return
(
a
.
orderNo
||
0
)
-
(
b
.
orderNo
||
0
);
});
for
(
const
menu
of
menuModules
)
{
staticMenus
.
push
(
transformMenuModule
(
menu
));
}
...
...
src/router/menus/modules/dashboard.ts
浏览文件 @
49827866
import
type
{
MenuModule
}
from
'
/@/router/types.d
'
;
const
menu
:
MenuModule
=
{
const
menu
:
MenuModule
[]
=
[
{
orderNo
:
0
,
menu
:
{
path
:
'
/dashboard/welcome
'
,
name
:
'
routes.dashboard.welcome
'
,
},
},
{
orderNo
:
10
,
menu
:
{
name
:
'
routes.dashboard.dashboard
'
,
...
...
@@ -14,11 +22,12 @@ const menu: MenuModule = {
path
:
'
/analysis
'
,
name
:
'
routes.dashboard.analysis
'
,
},
{
path
:
'
/welcome
'
,
name
:
'
routes.dashboard.welcome
'
,
},
//
{
//
path: '/welcome',
//
name: 'routes.dashboard.welcome',
//
},
],
},
};
},
];
export
default
menu
;
src/router/routes/modules/dashboard.ts
浏览文件 @
49827866
...
...
@@ -7,7 +7,7 @@ const dashboard: AppRouteModule = {
path
:
'
/dashboard
'
,
name
:
'
Dashboard
'
,
component
:
PAGE_LAYOUT_COMPONENT
,
redirect
:
'
/dashboard/w
orkbench
'
,
redirect
:
'
/dashboard/w
elcome
'
,
meta
:
{
icon
:
'
ant-design:home-outlined
'
,
title
:
'
routes.dashboard.dashboard
'
,
...
...
@@ -21,6 +21,8 @@ const dashboard: AppRouteModule = {
component
:
()
=>
import
(
'
/@/views/dashboard/welcome/index.vue
'
),
meta
:
{
title
:
'
routes.dashboard.welcome
'
,
affix
:
true
,
icon
:
'
ant-design:home-outlined
'
,
},
},
{
...
...
@@ -29,7 +31,6 @@ const dashboard: AppRouteModule = {
component
:
()
=>
import
(
'
/@/views/dashboard/workbench/index.vue
'
),
meta
:
{
title
:
'
routes.dashboard.workbench
'
,
affix
:
true
,
},
},
{
...
...
src/utils/index.ts
浏览文件 @
49827866
export
const
timestamp
=
()
=>
+
Date
.
now
();
import
{
isObject
}
from
'
/@/utils/is
'
;
export
const
clamp
=
(
n
:
number
,
min
:
number
,
max
:
number
)
=>
Math
.
min
(
max
,
Math
.
max
(
min
,
n
));
export
const
noop
=
()
=>
{};
export
const
now
=
()
=>
Date
.
now
();
...
...
@@ -40,10 +41,7 @@ export function setObjToUrlParams(baseUrl: string, obj: any): string {
export
function
deepMerge
<
T
=
any
>
(
src
:
any
,
target
:
any
):
T
{
let
key
:
string
;
for
(
key
in
target
)
{
src
[
key
]
=
src
[
key
]
&&
src
[
key
].
toString
()
===
'
[object Object]
'
?
deepMerge
(
src
[
key
],
target
[
key
])
:
(
src
[
key
]
=
target
[
key
]);
src
[
key
]
=
isObject
(
src
[
key
])
?
deepMerge
(
src
[
key
],
target
[
key
])
:
(
src
[
key
]
=
target
[
key
]);
}
return
src
;
}
...
...
vite.config.ts
浏览文件 @
49827866
...
...
@@ -89,7 +89,7 @@ const viteConfig: UserConfig = {
* Transpile target for esbuild.
* @default 'es2020'
*/
esbuildTarget
:
'
es20
20
'
,
esbuildTarget
:
'
es20
19
'
,
/**
* Whether to log asset info to console
* @default false
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录