Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
815250ed
提交
815250ed
authored
11月 18, 2020
作者:
jq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: update upload component
上级
c8ef82b2
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
183 行增加
和
34 行删除
+183
-34
FileList.less
src/components/Upload/src/FileList.less
+34
-0
FileList.tsx
src/components/Upload/src/FileList.tsx
+57
-0
UploadModal.vue
src/components/Upload/src/UploadModal.vue
+38
-23
UploadPreviewModal.vue
src/components/Upload/src/UploadPreviewModal.vue
+7
-10
data.tsx
src/components/Upload/src/data.tsx
+1
-1
props.ts
src/components/Upload/src/props.ts
+16
-0
types.ts
src/components/Upload/src/types.ts
+30
-0
没有找到文件。
src/components/Upload/src/FileList.less
0 → 100644
浏览文件 @
815250ed
@import (reference) '../../../design/index.less';
.file-table {
width: 100%;
border-collapse: collapse;
// border: 1px solid @border-color-light;
.center {
text-align: center;
}
.left {
text-align: left;
}
.right {
text-align: right;
}
&-th,
&-td {
padding: 12px 8px;
}
thead {
background-color: @background-color-dark;
}
table,
td,
th {
border: 1px solid @border-color-light;
}
}
src/components/Upload/src/FileList.tsx
0 → 100644
浏览文件 @
815250ed
import
{
defineComponent
}
from
'vue'
;
import
{
fileListProps
}
from
'./props'
;
import
{
isFunction
}
from
'/@/utils/is'
;
import
'./FileList.less'
;
export
default
defineComponent
({
name
:
'FileList'
,
props
:
fileListProps
,
setup
(
props
)
{
return
()
=>
{
const
{
columns
,
actionColumn
,
dataSource
}
=
props
;
return
(
<
table
class=
"file-table"
>
<
colgroup
>
{
[...
columns
,
actionColumn
].
map
((
item
)
=>
{
const
{
width
=
0
}
=
item
;
return
width
?
(
<
col
style=
{
'width:'
+
width
+
'px;min-width:'
+
width
+
'px;'
}
/>
)
:
(
<
col
/>
);
})
}
</
colgroup
>
<
thead
>
<
tr
class=
"file-table-tr"
>
{
[...
columns
,
actionColumn
].
map
((
item
)
=>
{
const
{
title
=
''
,
align
=
'center'
}
=
item
;
return
<
th
class=
{
[
'file-table-th'
,
align
]
}
>
{
title
}
</
th
>;
})
}
</
tr
>
</
thead
>
<
tbody
>
{
dataSource
.
map
((
record
=
{})
=>
{
return
(
<
tr
class=
"file-table-tr"
>
{
[...
columns
,
actionColumn
].
map
((
item
)
=>
{
const
{
dataIndex
=
''
,
customRender
,
align
=
'center'
}
=
item
;
if
(
customRender
&&
isFunction
(
customRender
))
{
return
(
<
td
class=
{
[
'file-table-td'
,
align
]
}
>
{
customRender
({
text
:
record
[
dataIndex
],
record
})
}
</
td
>
);
}
else
{
return
<
td
class=
{
[
'file-table-td'
,
align
]
}
>
{
record
[
dataIndex
]
}
</
td
>;
}
})
}
</
tr
>
);
})
}
</
tbody
>
</
table
>
);
};
},
});
src/components/Upload/src/UploadModal.vue
浏览文件 @
815250ed
...
@@ -23,24 +23,25 @@
...
@@ -23,24 +23,25 @@
{{
getUploadBtnText
}}
{{
getUploadBtnText
}}
</a-button>
</a-button>
</
template
>
</
template
>
<div
class=
"upload-modal-toolbar"
>
<BasicTable
@
register=
"registerTable"
:dataSource=
"fileListRef"
>
<Alert
:message=
"getHelpText"
type=
"info"
banner
class=
"upload-modal-toolbar__text"
></Alert>
<
template
#
toolbar
>
<Upload
<Upload
:accept=
"getStringAccept"
:multiple=
"multiple"
:before-upload=
"beforeUpload"
>
:accept=
"getStringAccept"
<a-button
type=
"primary"
>
选择文件
</a-button>
:multiple=
"multiple"
</Upload>
:before-upload=
"beforeUpload"
</
template
>
class=
"upload-modal-toolbar__btn"
<
template
#
tableTitle
>
>
<Alert
:message=
"getHelpText"
type=
"info"
banner
></Alert>
<a-button
type=
"primary"
>
选择文件
</a-button>
</
template
>
</Upload>
</BasicTable>
</div>
<FileList
:dataSource=
"fileListRef"
:columns=
"columns"
:actionColumn=
"actionColumn"
/>
</BasicModal>
</BasicModal>
</template>
</template>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
{
defineComponent
,
reactive
,
ref
,
toRefs
,
unref
,
computed
}
from
'vue'
;
import
{
defineComponent
,
reactive
,
ref
,
toRefs
,
unref
,
computed
}
from
'vue'
;
import
{
Upload
,
Alert
}
from
'ant-design-vue'
;
import
{
Upload
,
Alert
}
from
'ant-design-vue'
;
import
{
BasicModal
,
useModalInner
}
from
'/@/components/Modal'
;
import
{
BasicModal
,
useModalInner
}
from
'/@/components/Modal'
;
import
{
BasicTable
,
useTable
}
from
'/@/components/Table'
;
//
import { BasicTable, useTable } from '/@/components/Table';
// hooks
// hooks
import
{
useUploadType
}
from
'./useUpload'
;
import
{
useUploadType
}
from
'./useUpload'
;
import
{
useMessage
}
from
'/@/hooks/web/useMessage'
;
import
{
useMessage
}
from
'/@/hooks/web/useMessage'
;
...
@@ -55,9 +56,9 @@
...
@@ -55,9 +56,9 @@
import
{
uploadApi
}
from
'/@/api/sys/upload'
;
import
{
uploadApi
}
from
'/@/api/sys/upload'
;
import
{
isFunction
}
from
'/@/utils/is'
;
import
{
isFunction
}
from
'/@/utils/is'
;
import
{
warn
}
from
'/@/utils/log'
;
import
{
warn
}
from
'/@/utils/log'
;
import
FileList
from
'./FileList'
;
export
default
defineComponent
({
export
default
defineComponent
({
components
:
{
BasicModal
,
Upload
,
BasicTable
,
Aler
t
},
components
:
{
BasicModal
,
Upload
,
Alert
,
FileLis
t
},
props
:
basicProps
,
props
:
basicProps
,
setup
(
props
,
{
emit
})
{
setup
(
props
,
{
emit
})
{
// 是否正在上传
// 是否正在上传
...
@@ -257,23 +258,25 @@
...
@@ -257,23 +258,25 @@
}
}
}
}
const
[
registerTable
]
=
useTable
({
// const [registerTable] = useTable({
// columns: createTableColumns(),
// actionColumn: createActionColumn(handleRemove, handlePreview),
// pagination: false,
// inset: true,
// scroll: {
// y: 3000,
// },
// });
return
{
columns
:
createTableColumns
(),
columns
:
createTableColumns
(),
actionColumn
:
createActionColumn
(
handleRemove
,
handlePreview
),
actionColumn
:
createActionColumn
(
handleRemove
,
handlePreview
),
pagination
:
false
,
inset
:
true
,
scroll
:
{
y
:
3000
,
},
});
return
{
register
,
register
,
closeModal
,
closeModal
,
getHelpText
,
getHelpText
,
getStringAccept
,
getStringAccept
,
getOkButtonProps
,
getOkButtonProps
,
beforeUpload
,
beforeUpload
,
registerTable
,
//
registerTable,
fileListRef
,
fileListRef
,
state
,
state
,
isUploadingRef
,
isUploadingRef
,
...
@@ -295,5 +298,17 @@
...
@@ -295,5 +298,17 @@
.ant-table-wrapper
.ant-spin-nested-loading
{
.ant-table-wrapper
.ant-spin-nested-loading
{
padding
:
0
;
padding
:
0
;
}
}
&
-toolbar
{
display
:
flex
;
align-items
:
center
;
margin-bottom
:
8px
;
&__btn
{
margin-left
:
8px
;
text-align
:
right
;
flex
:
1
;
}
}
}
}
</
style
>
</
style
>
src/components/Upload/src/UploadPreviewModal.vue
浏览文件 @
815250ed
...
@@ -7,13 +7,15 @@
...
@@ -7,13 +7,15 @@
@
register=
"register"
@
register=
"register"
:showOkBtn=
"false"
:showOkBtn=
"false"
>
>
<
BasicTable
@
register=
"registerTable"
:dataSource=
"fileListRef
"
/>
<
FileList
:dataSource=
"fileListRef"
:columns=
"columns"
:actionColumn=
"actionColumn
"
/>
</BasicModal>
</BasicModal>
</
template
>
</
template
>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
{
defineComponent
,
watch
,
ref
,
unref
}
from
'vue'
;
import
{
defineComponent
,
watch
,
ref
,
unref
}
from
'vue'
;
import
{
BasicTable
,
useTable
}
from
'/@/components/Table'
;
// import { BasicTable, useTable } from '/@/components/Table';
import
FileList
from
'./FileList'
;
import
{
BasicModal
,
useModalInner
}
from
'/@/components/Modal'
;
import
{
BasicModal
,
useModalInner
}
from
'/@/components/Modal'
;
import
{
previewProps
}
from
'./props'
;
import
{
previewProps
}
from
'./props'
;
import
{
PreviewFileItem
}
from
'./types'
;
import
{
PreviewFileItem
}
from
'./types'
;
...
@@ -22,7 +24,7 @@
...
@@ -22,7 +24,7 @@
import
{
createPreviewColumns
,
createPreviewActionColumn
}
from
'./data'
;
import
{
createPreviewColumns
,
createPreviewActionColumn
}
from
'./data'
;
export
default
defineComponent
({
export
default
defineComponent
({
components
:
{
BasicModal
,
BasicTable
},
components
:
{
BasicModal
,
FileList
},
props
:
previewProps
,
props
:
previewProps
,
setup
(
props
,
{
emit
})
{
setup
(
props
,
{
emit
})
{
const
[
register
,
{
closeModal
}]
=
useModalInner
();
const
[
register
,
{
closeModal
}]
=
useModalInner
();
...
@@ -71,17 +73,12 @@
...
@@ -71,17 +73,12 @@
downloadByUrl
({
url
});
downloadByUrl
({
url
});
}
}
const
[
registerTable
]
=
useTable
({
columns
:
createPreviewColumns
(),
pagination
:
false
,
actionColumn
:
createPreviewActionColumn
({
handleRemove
,
handlePreview
,
handleDownload
}),
});
return
{
return
{
register
,
register
,
closeModal
,
closeModal
,
fileListRef
,
fileListRef
,
registerTable
,
columns
:
createPreviewColumns
(),
actionColumn
:
createPreviewActionColumn
({
handleRemove
,
handlePreview
,
handleDownload
}),
};
};
},
},
});
});
...
...
src/components/Upload/src/data.tsx
浏览文件 @
815250ed
...
@@ -12,7 +12,7 @@ export function createTableColumns(): BasicColumn[] {
...
@@ -12,7 +12,7 @@ export function createTableColumns(): BasicColumn[] {
width
:
100
,
width
:
100
,
customRender
:
({
record
})
=>
{
customRender
:
({
record
})
=>
{
const
{
thumbUrl
,
type
}
=
(
record
as
FileItem
)
||
{};
const
{
thumbUrl
,
type
}
=
(
record
as
FileItem
)
||
{};
return
<
span
>
{
thumbUrl
?
<
img
style=
{
{
maxWidth
:
'
60px
'
}
}
src=
{
thumbUrl
}
/>
:
type
}
</
span
>;
return
<
span
>
{
thumbUrl
?
<
img
style=
{
{
maxWidth
:
'
100%
'
}
}
src=
{
thumbUrl
}
/>
:
type
}
</
span
>;
},
},
},
},
{
{
...
...
src/components/Upload/src/props.ts
浏览文件 @
815250ed
import
type
{
PropType
}
from
'vue'
;
import
type
{
PropType
}
from
'vue'
;
import
{
FileBasicColumn
}
from
'./types'
;
export
const
basicProps
=
{
export
const
basicProps
=
{
helpText
:
{
helpText
:
{
...
@@ -57,3 +58,18 @@ export const previewProps = {
...
@@ -57,3 +58,18 @@ export const previewProps = {
default
:
()
=>
[],
default
:
()
=>
[],
},
},
};
};
export
const
fileListProps
=
{
columns
:
{
type
:
[
Array
]
as
PropType
<
FileBasicColumn
[]
>
,
default
:
null
,
},
actionColumn
:
{
type
:
Object
as
PropType
<
FileBasicColumn
>
,
default
:
null
,
},
dataSource
:
{
type
:
Array
as
PropType
<
any
[]
>
,
default
:
null
,
},
};
src/components/Upload/src/types.ts
浏览文件 @
815250ed
...
@@ -23,3 +23,33 @@ export interface PreviewFileItem {
...
@@ -23,3 +23,33 @@ export interface PreviewFileItem {
name
:
string
;
name
:
string
;
type
:
string
;
type
:
string
;
}
}
export
interface
FileBasicColumn
{
/**
* Renderer of the table cell. The return value should be a VNode, or an object for colSpan/rowSpan config
* @type Function | ScopedSlot
*/
customRender
?:
Function
;
/**
* Title of this column
* @type any (string | slot)
*/
title
:
string
;
/**
* Width of this column
* @type string | number
*/
width
?:
number
;
/**
* Display field of the data record, could be set like a.b.c
* @type string
*/
dataIndex
:
string
;
/**
* specify how content is aligned
* @default 'left'
* @type string
*/
align
?:
'left'
|
'right'
|
'center'
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论