Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ChenSun1
vue-vben-admin
提交
c7c95dd2
V
vue-vben-admin
项目概览
ChenSun1
/
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,发现更多精彩内容 >>
提交
c7c95dd2
编写于
6月 11, 2021
作者:
V
Vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: type Descrition,Drawer,Excel,Dropdown
上级
6dbbdbac
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
129 addition
and
138 deletion
+129
-138
src/components/Description/index.ts
src/components/Description/index.ts
+4
-3
src/components/Description/src/Description.vue
src/components/Description/src/Description.vue
+35
-14
src/components/Description/src/props.ts
src/components/Description/src/props.ts
+0
-25
src/components/Description/src/typing.ts
src/components/Description/src/typing.ts
+2
-5
src/components/Description/src/useDescription.ts
src/components/Description/src/useDescription.ts
+12
-11
src/components/Drawer/index.ts
src/components/Drawer/index.ts
+4
-3
src/components/Drawer/src/BasicDrawer.vue
src/components/Drawer/src/BasicDrawer.vue
+2
-6
src/components/Drawer/src/components/DrawerHeader.vue
src/components/Drawer/src/components/DrawerHeader.vue
+1
-0
src/components/Drawer/src/props.ts
src/components/Drawer/src/props.ts
+16
-17
src/components/Drawer/src/typing.ts
src/components/Drawer/src/typing.ts
+0
-1
src/components/Drawer/src/useDrawer.ts
src/components/Drawer/src/useDrawer.ts
+22
-19
src/components/Dropdown/index.ts
src/components/Dropdown/index.ts
+4
-3
src/components/Dropdown/src/Dropdown.vue
src/components/Dropdown/src/Dropdown.vue
+13
-12
src/components/Dropdown/src/typing.ts
src/components/Dropdown/src/typing.ts
+0
-2
src/components/Excel/index.ts
src/components/Excel/index.ts
+6
-6
src/components/Excel/src/Export2Excel.ts
src/components/Excel/src/Export2Excel.ts
+2
-1
src/components/Excel/src/ExportExcelModal.vue
src/components/Excel/src/ExportExcelModal.vue
+1
-1
src/components/Excel/src/ImportExcel.vue
src/components/Excel/src/ImportExcel.vue
+1
-1
src/components/Excel/src/typing.ts
src/components/Excel/src/typing.ts
+0
-4
src/settings/localeSetting.ts
src/settings/localeSetting.ts
+1
-1
src/views/demo/excel/CustomExport.vue
src/views/demo/excel/CustomExport.vue
+3
-3
未找到文件。
src/components/Description/index.ts
浏览文件 @
c7c95dd2
import
Description
from
'
./src/Description.vue
'
;
import
{
withInstall
}
from
'
/@/utils
'
;
import
description
from
'
./src/Description.vue
'
;
export
{
Description
};
export
*
from
'
./src/types
'
;
export
*
from
'
./src/typing
'
;
export
{
useDescription
}
from
'
./src/useDescription
'
;
export
const
Description
=
withInstall
(
description
);
src/components/Description/src/Description.vue
浏览文件 @
c7c95dd2
<
script
lang=
"tsx"
>
import
type
{
Desc
Options
,
DescInstance
,
DescItem
}
from
'
./types
'
;
import
type
{
Desc
riptionProps
,
DescInstance
,
DescItem
}
from
'
./typing
'
;
import
type
{
DescriptionsProps
}
from
'
ant-design-vue/es/descriptions/index
'
;
import
type
{
CSSProperties
}
from
'
vue
'
;
import
type
{
CollapseContainerOptions
}
from
'
/@/components/Container/index
'
;
import
{
defineComponent
,
computed
,
ref
,
unref
}
from
'
vue
'
;
import
{
get
}
from
'
lodash-es
'
;
import
{
Descriptions
}
from
'
ant-design-vue
'
;
import
{
CollapseContainer
}
from
'
/@/components/Container/index
'
;
import
{
useDesign
}
from
'
/@/hooks/web/useDesign
'
;
import
{
isFunction
}
from
'
/@/utils/is
'
;
import
{
getSlot
}
from
'
/@/utils/helper/tsxHelper
'
;
import
descProps
from
'
./props
'
;
import
{
useAttrs
}
from
'
/@/hooks/core/useAttrs
'
;
const
props
=
{
useCollapse
:
{
type
:
Boolean
,
default
:
true
},
title
:
{
type
:
String
,
default
:
''
},
size
:
{
type
:
String
,
validator
:
(
v
)
=>
[
'
small
'
,
'
default
'
,
'
middle
'
,
undefined
].
includes
(
v
),
default
:
'
small
'
,
},
bordered
:
{
type
:
Boolean
,
default
:
true
},
column
:
{
type
:
[
Number
,
Object
]
as
PropType
<
number
|
Recordable
>
,
default
:
()
=>
{
return
{
xxl
:
4
,
xl
:
3
,
lg
:
3
,
md
:
3
,
sm
:
2
,
xs
:
1
};
},
},
collapseOptions
:
{
type
:
Object
as
PropType
<
CollapseContainerOptions
>
,
default
:
null
,
},
schema
:
{
type
:
Array
as
PropType
<
DescItem
[]
>
,
default
:
()
=>
[],
},
data
:
{
type
:
Object
},
};
export
default
defineComponent
({
name
:
'
Description
'
,
props
:
descProps
,
props
,
emits
:
[
'
register
'
],
setup
(
props
,
{
slots
,
emit
})
{
const
propsRef
=
ref
<
Partial
<
Desc
Option
s
>
|
null
>
(
null
);
const
propsRef
=
ref
<
Partial
<
Desc
riptionProp
s
>
|
null
>
(
null
);
const
{
prefixCls
}
=
useDesign
(
'
description
'
);
const
attrs
=
useAttrs
();
...
...
@@ -32,7 +53,7 @@
return
{
...
props
,
...(
unref
(
propsRef
)
as
Recordable
),
}
as
Desc
Option
s
;
}
as
Desc
riptionProp
s
;
});
const
getProps
=
computed
(()
=>
{
...
...
@@ -40,7 +61,7 @@
...
unref
(
getMergeProps
),
title
:
undefined
,
};
return
opt
as
Desc
Option
s
;
return
opt
as
Desc
riptionProp
s
;
});
/**
...
...
@@ -66,7 +87,7 @@
/**
* @description:设置desc
*/
function
setDescProps
(
descProps
:
Partial
<
Desc
Option
s
>
):
void
{
function
setDescProps
(
descProps
:
Partial
<
Desc
riptionProp
s
>
):
void
{
// Keep the last setDrawerProps
propsRef
.
value
=
{
...(
unref
(
propsRef
)
as
Recordable
),
...
descProps
}
as
Recordable
;
}
...
...
@@ -79,7 +100,6 @@
const
labelStyles
:
CSSProperties
=
{
...
labelStyle
,
minWidth
:
`
${
labelMinWidth
}
px `
,
};
return
<
div
style
=
{
labelStyles
}
>
{
label
}
<
/div>
;
...
...
@@ -97,7 +117,9 @@
const
getContent
=
()
=>
{
const
_data
=
unref
(
getProps
)?.
data
;
if
(
!
_data
)
return
null
;
if
(
!
_data
)
{
return
null
;
}
const
getField
=
get
(
_data
,
field
);
return
isFunction
(
render
)
?
render
(
getField
,
_data
)
:
getField
??
''
;
};
...
...
@@ -131,7 +153,6 @@
const
renderContainer
=
()
=>
{
const
content
=
props
.
useCollapse
?
renderDesc
()
:
<
div
>
{
renderDesc
()}
<
/div>
;
// Reduce the dom level
if
(
!
props
.
useCollapse
)
{
return
content
;
}
...
...
src/components/Description/src/props.ts
已删除
100644 → 0
浏览文件 @
6dbbdbac
import
type
{
PropType
}
from
'
vue
'
;
import
type
{
CollapseContainerOptions
}
from
'
/@/components/Container
'
;
import
type
{
DescItem
}
from
'
./types
'
;
import
{
propTypes
}
from
'
/@/utils/propTypes
'
;
export
default
{
useCollapse
:
propTypes
.
bool
.
def
(
true
),
title
:
propTypes
.
string
.
def
(
''
),
size
:
propTypes
.
oneOf
([
'
small
'
,
'
default
'
,
'
middle
'
,
undefined
]).
def
(
'
small
'
),
bordered
:
propTypes
.
bool
.
def
(
true
),
column
:
{
type
:
[
Number
,
Object
]
as
PropType
<
number
|
Recordable
>
,
default
:
()
=>
{
return
{
xxl
:
4
,
xl
:
3
,
lg
:
3
,
md
:
3
,
sm
:
2
,
xs
:
1
};
},
},
collapseOptions
:
{
type
:
Object
as
PropType
<
CollapseContainerOptions
>
,
default
:
null
,
},
schema
:
{
type
:
Array
as
PropType
<
Array
<
DescItem
>>
,
default
:
()
=>
[],
},
data
:
propTypes
.
object
,
};
src/components/Description/src/typ
es
.ts
→
src/components/Description/src/typ
ing
.ts
浏览文件 @
c7c95dd2
...
...
@@ -4,11 +4,8 @@ import type { DescriptionsProps } from 'ant-design-vue/es/descriptions/index';
export
interface
DescItem
{
labelMinWidth
?:
number
;
contentMinWidth
?:
number
;
labelStyle
?:
CSSProperties
;
field
:
string
;
label
:
string
|
VNode
|
JSX
.
Element
;
// Merge column
...
...
@@ -21,7 +18,7 @@ export interface DescItem {
)
=>
VNode
|
undefined
|
JSX
.
Element
|
Element
|
string
|
number
;
}
export
interface
Desc
Option
s
extends
DescriptionsProps
{
export
interface
Desc
riptionProp
s
extends
DescriptionsProps
{
// Whether to include the collapse component
useCollapse
?:
boolean
;
/**
...
...
@@ -42,7 +39,7 @@ export interface DescOptions extends DescriptionsProps {
}
export
interface
DescInstance
{
setDescProps
(
descProps
:
Partial
<
Desc
Option
s
>
):
void
;
setDescProps
(
descProps
:
Partial
<
Desc
riptionProp
s
>
):
void
;
}
export
type
Register
=
(
descInstance
:
DescInstance
)
=>
void
;
...
...
src/components/Description/src/useDescription.ts
浏览文件 @
c7c95dd2
import
type
{
DescriptionProps
,
DescInstance
,
UseDescReturnType
}
from
'
./typing
'
;
import
{
ref
,
getCurrentInstance
,
unref
}
from
'
vue
'
;
import
{
isProdMode
}
from
'
/@/utils/env
'
;
import
type
{
DescOptions
,
DescInstance
,
UseDescReturnType
}
from
'
./types
'
;
export
function
useDescription
(
props
?:
Partial
<
DescOptions
>
):
UseDescReturnType
{
export
function
useDescription
(
props
?:
Partial
<
DescriptionProps
>
):
UseDescReturnType
{
if
(
!
getCurrentInstance
())
{
throw
new
Error
(
'
Please put useDescription function in the setup function
!
'
);
throw
new
Error
(
'
useDescription() can only be used inside setup() or functional components
!
'
);
}
const
desc
Ref
=
ref
<
Nullable
<
DescInstance
>>
(
null
);
const
loaded
Ref
=
ref
(
false
);
const
desc
=
ref
<
Nullable
<
DescInstance
>>
(
null
);
const
loaded
=
ref
(
false
);
function
register
(
instance
:
DescInstance
)
{
if
(
unref
(
loadedRef
)
&&
isProdMode
())
return
;
descRef
.
value
=
instance
;
if
(
unref
(
loaded
)
&&
isProdMode
())
{
return
;
}
desc
.
value
=
instance
;
props
&&
instance
.
setDescProps
(
props
);
loaded
Ref
.
value
=
true
;
loaded
.
value
=
true
;
}
const
methods
:
DescInstance
=
{
setDescProps
:
(
descProps
:
Partial
<
Desc
Option
s
>
):
void
=>
{
unref
(
desc
Ref
)?.
setDescProps
(
descProps
);
setDescProps
:
(
descProps
:
Partial
<
Desc
riptionProp
s
>
):
void
=>
{
unref
(
desc
)?.
setDescProps
(
descProps
);
},
};
...
...
src/components/Drawer/index.ts
浏览文件 @
c7c95dd2
import
BasicDrawer
from
'
./src/BasicDrawer.vue
'
;
import
{
withInstall
}
from
'
/@/utils
'
;
import
basicDrawer
from
'
./src/BasicDrawer.vue
'
;
export
{
BasicDrawer
}
;
export
*
from
'
./src/typ
es
'
;
export
const
BasicDrawer
=
withInstall
(
basicDrawer
)
;
export
*
from
'
./src/typ
ing
'
;
export
{
useDrawer
,
useDrawerInner
}
from
'
./src/useDrawer
'
;
src/components/Drawer/src/BasicDrawer.vue
浏览文件 @
c7c95dd2
...
...
@@ -31,9 +31,8 @@
</Drawer>
</template>
<
script
lang=
"ts"
>
import
type
{
DrawerInstance
,
DrawerProps
}
from
'
./typ
es
'
;
import
type
{
DrawerInstance
,
DrawerProps
}
from
'
./typ
ing
'
;
import
type
{
CSSProperties
}
from
'
vue
'
;
import
{
defineComponent
,
ref
,
...
...
@@ -46,15 +45,12 @@
getCurrentInstance
,
}
from
'
vue
'
;
import
{
Drawer
}
from
'
ant-design-vue
'
;
import
{
useI18n
}
from
'
/@/hooks/web/useI18n
'
;
import
{
isFunction
,
isNumber
}
from
'
/@/utils/is
'
;
import
{
deepMerge
}
from
'
/@/utils
'
;
import
DrawerFooter
from
'
./components/DrawerFooter.vue
'
;
import
DrawerHeader
from
'
./components/DrawerHeader.vue
'
;
import
{
ScrollContainer
}
from
'
/@/components/Container
'
;
import
{
basicProps
}
from
'
./props
'
;
import
{
useDesign
}
from
'
/@/hooks/web/useDesign
'
;
import
{
useAttrs
}
from
'
/@/hooks/core/useAttrs
'
;
...
...
@@ -167,7 +163,7 @@
function
setDrawerProps
(
props
:
Partial
<
DrawerProps
>
):
void
{
// Keep the last setDrawerProps
propsRef
.
value
=
deepMerge
(
unref
(
propsRef
)
||
{},
props
);
propsRef
.
value
=
deepMerge
(
(
unref
(
propsRef
)
as
any
)
||
{},
props
);
if
(
Reflect
.
has
(
props
,
'
visible
'
))
{
visibleRef
.
value
=
!!
props
.
visible
;
...
...
src/components/Drawer/src/components/DrawerHeader.vue
浏览文件 @
c7c95dd2
...
...
@@ -40,6 +40,7 @@
function
handleClose
()
{
emit
(
'
close
'
);
}
return
{
prefixCls
,
handleClose
};
},
});
...
...
src/components/Drawer/src/props.ts
浏览文件 @
c7c95dd2
import
type
{
PropType
}
from
'
vue
'
;
import
{
useI18n
}
from
'
/@/hooks/web/useI18n
'
;
import
{
propTypes
}
from
'
/@/utils/propTypes
'
;
const
{
t
}
=
useI18n
();
export
const
footerProps
=
{
confirmLoading
:
propTypes
.
bool
,
confirmLoading
:
{
type
:
Boolean
}
,
/**
* @description: Show close button
*/
showCancelBtn
:
propTypes
.
bool
.
def
(
true
)
,
showCancelBtn
:
{
type
:
Boolean
,
default
:
true
}
,
cancelButtonProps
:
Object
as
PropType
<
Recordable
>
,
cancelText
:
propTypes
.
string
.
def
(
t
(
'
common.cancelText
'
))
,
cancelText
:
{
type
:
String
,
default
:
t
(
'
common.cancelText
'
)
}
,
/**
* @description: Show confirmation button
*/
showOkBtn
:
propTypes
.
bool
.
def
(
true
)
,
showOkBtn
:
{
type
:
Boolean
,
default
:
true
}
,
okButtonProps
:
Object
as
PropType
<
Recordable
>
,
okText
:
propTypes
.
string
.
def
(
t
(
'
common.okText
'
))
,
okType
:
propTypes
.
string
.
def
(
'
primary
'
)
,
showFooter
:
propTypes
.
bool
,
okText
:
{
type
:
String
,
default
:
t
(
'
common.okText
'
)
}
,
okType
:
{
type
:
String
,
default
:
'
primary
'
}
,
showFooter
:
{
type
:
Boolean
}
,
footerHeight
:
{
type
:
[
String
,
Number
]
as
PropType
<
string
|
number
>
,
default
:
60
,
},
};
export
const
basicProps
=
{
isDetail
:
propTypes
.
bool
,
title
:
propTypes
.
string
.
def
(
''
)
,
loadingText
:
propTypes
.
string
,
showDetailBack
:
propTypes
.
bool
.
def
(
true
)
,
visible
:
propTypes
.
bool
,
loading
:
propTypes
.
bool
,
maskClosable
:
propTypes
.
bool
.
def
(
true
)
,
isDetail
:
{
type
:
Boolean
}
,
title
:
{
type
:
String
,
default
:
''
}
,
loadingText
:
{
type
:
String
}
,
showDetailBack
:
{
type
:
Boolean
,
default
:
true
}
,
visible
:
{
type
:
Boolean
}
,
loading
:
{
type
:
Boolean
}
,
maskClosable
:
{
type
:
Boolean
,
default
:
true
}
,
getContainer
:
{
type
:
[
Object
,
String
]
as
PropType
<
any
>
,
},
...
...
@@ -44,7 +43,7 @@ export const basicProps = {
type
:
[
Function
,
Object
]
as
PropType
<
any
>
,
default
:
null
,
},
triggerWindowResize
:
propTypes
.
bool
,
destroyOnClose
:
propTypes
.
bool
,
triggerWindowResize
:
{
type
:
Boolean
}
,
destroyOnClose
:
{
type
:
Boolean
}
,
...
footerProps
,
};
src/components/Drawer/src/typ
es
.ts
→
src/components/Drawer/src/typ
ing
.ts
浏览文件 @
c7c95dd2
...
...
@@ -181,7 +181,6 @@ export interface DrawerProps extends DrawerFooterProps {
placement
?:
'
top
'
|
'
right
'
|
'
bottom
'
|
'
left
'
;
afterVisibleChange
?:
(
visible
?:
boolean
)
=>
void
;
keyboard
?:
boolean
;
/**
* Specify a callback that will be called when a user clicks mask, close button or Cancel button.
*/
...
...
src/components/Drawer/src/useDrawer.ts
浏览文件 @
c7c95dd2
...
...
@@ -4,7 +4,7 @@ import type {
ReturnMethods
,
DrawerProps
,
UseDrawerInnerReturnType
,
}
from
'
./typ
es
'
;
}
from
'
./typ
ing
'
;
import
{
ref
,
...
...
@@ -32,24 +32,27 @@ const visibleData = reactive<{ [key: number]: boolean }>({});
* @description: Applicable to separate drawer and call outside
*/
export
function
useDrawer
():
UseDrawerReturnType
{
const
drawerRef
=
ref
<
DrawerInstance
|
null
>
(
null
);
const
loadedRef
=
ref
<
Nullable
<
boolean
>>
(
false
);
const
uidRef
=
ref
<
string
>
(
''
);
if
(
!
getCurrentInstance
())
{
throw
new
Error
(
'
useDrawer() can only be used inside setup() or functional components!
'
);
}
const
drawer
=
ref
<
DrawerInstance
|
null
>
(
null
);
const
loaded
=
ref
<
Nullable
<
boolean
>>
(
false
);
const
uid
=
ref
<
string
>
(
''
);
function
register
(
drawerInstance
:
DrawerInstance
,
uuid
:
string
)
{
isProdMode
()
&&
tryOnUnmounted
(()
=>
{
drawer
Ref
.
value
=
null
;
loaded
Ref
.
value
=
null
;
dataTransferRef
[
unref
(
uid
Ref
)]
=
null
;
drawer
.
value
=
null
;
loaded
.
value
=
null
;
dataTransferRef
[
unref
(
uid
)]
=
null
;
});
if
(
unref
(
loaded
Ref
)
&&
isProdMode
()
&&
drawerInstance
===
unref
(
drawerRef
))
{
if
(
unref
(
loaded
)
&&
isProdMode
()
&&
drawerInstance
===
unref
(
drawer
))
{
return
;
}
uid
Ref
.
value
=
uuid
;
drawer
Ref
.
value
=
drawerInstance
;
loaded
Ref
.
value
=
true
;
uid
.
value
=
uuid
;
drawer
.
value
=
drawerInstance
;
loaded
.
value
=
true
;
drawerInstance
.
emitVisible
=
(
visible
:
boolean
,
uid
:
number
)
=>
{
visibleData
[
uid
]
=
visible
;
...
...
@@ -57,7 +60,7 @@ export function useDrawer(): UseDrawerReturnType {
}
const
getInstance
=
()
=>
{
const
instance
=
unref
(
drawer
Ref
);
const
instance
=
unref
(
drawer
);
if
(
!
instance
)
{
error
(
'
useDrawer instance is undefined!
'
);
}
...
...
@@ -70,7 +73,7 @@ export function useDrawer(): UseDrawerReturnType {
},
getVisible
:
computed
(():
boolean
=>
{
return
visibleData
[
~~
unref
(
uid
Ref
)];
return
visibleData
[
~~
unref
(
uid
)];
}),
openDrawer
:
<
T
=
any
>
(
visible
=
true
,
data
?:
T
,
openOnSet
=
true
):
void
=>
{
...
...
@@ -80,13 +83,13 @@ export function useDrawer(): UseDrawerReturnType {
if
(
!
data
)
return
;
if
(
openOnSet
)
{
dataTransferRef
[
unref
(
uid
Ref
)]
=
null
;
dataTransferRef
[
unref
(
uid
Ref
)]
=
toRaw
(
data
);
dataTransferRef
[
unref
(
uid
)]
=
null
;
dataTransferRef
[
unref
(
uid
)]
=
toRaw
(
data
);
return
;
}
const
equal
=
isEqual
(
toRaw
(
dataTransferRef
[
unref
(
uid
Ref
)]),
toRaw
(
data
));
const
equal
=
isEqual
(
toRaw
(
dataTransferRef
[
unref
(
uid
)]),
toRaw
(
data
));
if
(
!
equal
)
{
dataTransferRef
[
unref
(
uid
Ref
)]
=
toRaw
(
data
);
dataTransferRef
[
unref
(
uid
)]
=
toRaw
(
data
);
}
},
};
...
...
@@ -99,8 +102,8 @@ export const useDrawerInner = (callbackFn?: Fn): UseDrawerInnerReturnType => {
const
currentInstance
=
getCurrentInstance
();
const
uidRef
=
ref
<
string
>
(
''
);
if
(
!
currentInstance
)
{
error
(
'
useDrawerInner instance is undefined
!
'
);
if
(
!
getCurrentInstance
()
)
{
throw
new
Error
(
'
useDrawerInner() can only be used inside setup() or functional components
!
'
);
}
const
getInstance
=
()
=>
{
...
...
src/components/Dropdown/index.ts
浏览文件 @
c7c95dd2
import
Dropdown
from
'
./src/Dropdown.vue
'
;
import
{
withInstall
}
from
'
/@/utils
'
;
import
dropdown
from
'
./src/Dropdown.vue
'
;
export
*
from
'
./src/typ
es
'
;
export
{
Dropdown
}
;
export
*
from
'
./src/typ
ing
'
;
export
const
Dropdown
=
withInstall
(
dropdown
)
;
src/components/Dropdown/src/Dropdown.vue
浏览文件 @
c7c95dd2
<
template
>
<
a-d
ropdown
:trigger=
"trigger"
v-bind=
"$attrs"
>
<
D
ropdown
:trigger=
"trigger"
v-bind=
"$attrs"
>
<span>
<slot></slot>
</span>
<template
#overlay
>
<
a-m
enu
:selectedKeys=
"selectedKeys"
>
<
M
enu
:selectedKeys=
"selectedKeys"
>
<template
v-for=
"item in dropMenuList"
:key=
"`$
{item.event}`">
<
a-menu-i
tem
<
MenuI
tem
v-bind=
"getAttr(item.event)"
@
click=
"handleClickMenu(item)"
:disabled=
"item.disabled"
...
...
@@ -19,17 +19,17 @@
<Icon
:icon=
"item.icon"
v-if=
"item.icon"
/>
<span
class=
"ml-1"
>
{{
item
.
text
}}
</span>
</
template
>
</
a-menu-i
tem>
<
a-menu-d
ivider
v-if=
"item.divider"
:key=
"`d-${item.event}`"
/>
</
MenuI
tem>
<
MenuD
ivider
v-if=
"item.divider"
:key=
"`d-${item.event}`"
/>
</template>
</
a-m
enu>
</
M
enu>
</template>
</
a-d
ropdown>
</
D
ropdown>
</template>
<
script
lang=
"ts"
>
import
type
{
PropType
}
from
'
vue
'
;
import
type
{
DropMenu
}
from
'
./typ
es
'
;
import
type
{
DropMenu
}
from
'
./typ
ing
'
;
import
{
defineComponent
}
from
'
vue
'
;
import
{
Dropdown
,
Menu
,
Popconfirm
}
from
'
ant-design-vue
'
;
...
...
@@ -38,10 +38,10 @@
export
default
defineComponent
({
name
:
'
BasicDropdown
'
,
components
:
{
[
Dropdown
.
name
]:
Dropdown
,
[
Menu
.
name
]:
Menu
,
[
Menu
.
Item
.
name
]
:
Menu
.
Item
,
[
Menu
.
Divider
.
name
]
:
Menu
.
Divider
,
Dropdown
,
Menu
,
MenuItem
:
Menu
.
Item
,
MenuDivider
:
Menu
.
Divider
,
Icon
,
Popconfirm
,
},
...
...
@@ -75,6 +75,7 @@
emit
(
'
menuEvent
'
,
menu
);
item
.
onClick
?.();
}
return
{
handleClickMenu
,
getAttr
:
(
key
:
string
|
number
)
=>
({
key
}),
...
...
src/components/Dropdown/src/typ
es
.ts
→
src/components/Dropdown/src/typ
ing
.ts
浏览文件 @
c7c95dd2
...
...
@@ -7,5 +7,3 @@ export interface DropMenu {
disabled
?:
boolean
;
divider
?:
boolean
;
}
// export type Trigger = 'click' | 'hover' | 'contextMenu';
src/components/Excel/index.ts
浏览文件 @
c7c95dd2
import
{
createAsyncComponent
}
from
'
/@/utils/factory/createAsyncComponent
'
;
export
const
ImpExcel
=
createAsyncComponent
(()
=>
import
(
'
./src/ImportExcel.vue
'
));
export
const
ExpExcelModel
=
createAsyncComponent
(()
=>
import
(
'
./src/ExportExcelModel.vue
'
));
export
*
from
'
./src/types
'
;
import
{
withInstall
}
from
'
/@/utils
'
;
import
impExcel
from
'
./src/ImportExcel.vue
'
;
import
expExcelModal
from
'
./src/ExportExcelModal.vue
'
;
export
const
ImpExcel
=
withInstall
(
impExcel
);
export
const
ExpExcelModal
=
withInstall
(
expExcelModal
);
export
*
from
'
./src/typing
'
;
export
{
jsonToSheetXlsx
,
aoaToSheetXlsx
}
from
'
./src/Export2Excel
'
;
src/components/Excel/src/Export2Excel.ts
浏览文件 @
c7c95dd2
import
xlsx
from
'
xlsx
'
;
import
type
{
WorkBook
}
from
'
xlsx
'
;
import
type
{
JsonToSheet
,
AoAToSheet
}
from
'
./typ
es
'
;
import
type
{
JsonToSheet
,
AoAToSheet
}
from
'
./typ
ing
'
;
const
{
utils
,
writeFile
}
=
xlsx
;
const
DEF_FILE_NAME
=
'
excel-list.xlsx
'
;
export
function
jsonToSheetXlsx
<
T
=
any
>
({
data
,
header
,
...
...
src/components/Excel/src/ExportExcelMod
e
l.vue
→
src/components/Excel/src/ExportExcelMod
a
l.vue
浏览文件 @
c7c95dd2
...
...
@@ -14,7 +14,7 @@
</BasicModal>
</
template
>
<
script
lang=
"ts"
>
import
type
{
ExportModalResult
}
from
'
./typ
es
'
;
import
type
{
ExportModalResult
}
from
'
./typ
ing
'
;
import
{
defineComponent
}
from
'
vue
'
;
import
{
BasicModal
,
useModalInner
}
from
'
/@/components/Modal
'
;
import
{
BasicForm
,
FormSchema
,
useForm
}
from
'
/@/components/Form/index
'
;
...
...
src/components/Excel/src/ImportExcel.vue
浏览文件 @
c7c95dd2
...
...
@@ -16,7 +16,7 @@
import
{
defineComponent
,
ref
,
unref
}
from
'
vue
'
;
import
XLSX
from
'
xlsx
'
;
import
type
{
ExcelData
}
from
'
./typ
es
'
;
import
type
{
ExcelData
}
from
'
./typ
ing
'
;
export
default
defineComponent
({
name
:
'
ImportExcel
'
,
emits
:
[
'
success
'
,
'
error
'
],
...
...
src/components/Excel/src/typ
es
.ts
→
src/components/Excel/src/typ
ing
.ts
浏览文件 @
c7c95dd2
...
...
@@ -6,10 +6,6 @@ export interface ExcelData<T = any> {
meta
:
{
sheetName
:
string
};
}
// export interface ImportProps {
// beforeUpload: (file: File) => boolean;
// }
export
interface
JsonToSheet
<
T
=
any
>
{
data
:
T
[];
header
?:
T
;
...
...
src/settings/localeSetting.ts
浏览文件 @
c7c95dd2
import
type
{
DropMenu
}
from
'
/@/components/Dropdown/src/types
'
;
import
type
{
DropMenu
}
from
'
../components/Dropdown
'
;
import
type
{
LocaleSetting
,
LocaleType
}
from
'
/#/config
'
;
export
const
LOCALE
:
{
[
key
:
string
]:
LocaleType
}
=
{
...
...
src/views/demo/excel/CustomExport.vue
浏览文件 @
c7c95dd2
...
...
@@ -5,20 +5,20 @@
<a-button
@
click=
"openModal"
>
导出
</a-button>
</
template
>
</BasicTable>
<ExpExcelMod
e
l
@
register=
"register"
@
success=
"defaultHeader"
/>
<ExpExcelMod
a
l
@
register=
"register"
@
success=
"defaultHeader"
/>
</PageWrapper>
</template>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'
vue
'
;
import
{
BasicTable
}
from
'
/@/components/Table
'
;
import
{
jsonToSheetXlsx
,
ExpExcelMod
e
l
,
ExportModalResult
}
from
'
/@/components/Excel
'
;
import
{
jsonToSheetXlsx
,
ExpExcelMod
a
l
,
ExportModalResult
}
from
'
/@/components/Excel
'
;
import
{
columns
,
data
}
from
'
./data
'
;
import
{
useModal
}
from
'
/@/components/Modal
'
;
import
{
PageWrapper
}
from
'
/@/components/Page
'
;
export
default
defineComponent
({
components
:
{
BasicTable
,
ExpExcelMod
e
l
,
PageWrapper
},
components
:
{
BasicTable
,
ExpExcelMod
a
l
,
PageWrapper
},
setup
()
{
function
defaultHeader
({
filename
,
bookType
}:
ExportModalResult
)
{
// 默认Object.keys(data[0])作为header
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录