Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
夏日掠影
vue-vben-admin
提交
19d8e01e
V
vue-vben-admin
项目概览
夏日掠影
/
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,发现更多精彩内容 >>
提交
19d8e01e
编写于
6月 06, 2021
作者:
无
无木
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(table-img): support simple show mode and more props
改进TableImg组件,支持简单显示模式以及更多可配置的属性。
上级
50f94bfe
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
82 addition
and
18 deletion
+82
-18
src/components/Table/src/components/TableImg.vue
src/components/Table/src/components/TableImg.vue
+42
-13
src/views/demo/table/CustomerCell.vue
src/views/demo/table/CustomerCell.vue
+40
-5
未找到文件。
src/components/Table/src/components/TableImg.vue
浏览文件 @
19d8e01e
<
template
>
<div
:class=
"prefixCls"
class=
"flex
mx-auto items-center
"
class=
"flex
items-center mx-auto
"
v-if=
"imgList && imgList.length"
:style=
"getWrapStyle"
>
<PreviewGroup>
<template
v-for=
"img in imgList"
:key=
"img"
>
<Image
:width=
"size"
:src=
"img"
/>
<Badge
:count=
"!showBadge || imgList.length == 1 ? 0 : imgList.length"
v-if=
"simpleShow"
>
<div
class=
"img-div"
>
<PreviewGroup>
<template
v-for=
"(img, index) in imgList"
:key=
"img"
>
<Image
:width=
"size"
:style=
"
{
display: index === 0 ? '' : 'none !important',
}"
:src="srcPrefix + img"
/>
</
template
>
</PreviewGroup>
</div>
</Badge>
<PreviewGroup
v-else
>
<
template
v-for=
"(img, index) in imgList"
:key=
"img"
>
<Image
:width=
"size"
:style=
"
{ 'margin-left': index === 0 ? 0 : margin }"
:src="srcPrefix + img"
/>
</
template
>
</PreviewGroup>
</div>
...
...
@@ -17,24 +36,30 @@
import
{
defineComponent
,
computed
}
from
'
vue
'
;
import
{
useDesign
}
from
'
/@/hooks/web/useDesign
'
;
import
{
Image
}
from
'
ant-design-vue
'
;
import
{
Image
,
Badge
}
from
'
ant-design-vue
'
;
import
{
propTypes
}
from
'
/@/utils/propTypes
'
;
export
default
defineComponent
({
name
:
'
TableImage
'
,
components
:
{
Image
,
PreviewGroup
:
Image
.
PreviewGroup
},
components
:
{
Image
,
PreviewGroup
:
Image
.
PreviewGroup
,
Badge
},
props
:
{
imgList
:
propTypes
.
arrayOf
(
propTypes
.
string
),
size
:
propTypes
.
number
.
def
(
40
),
// 是否简单显示(只显示第一张图片)
simpleShow
:
propTypes
.
bool
,
// 简单模式下是否显示图片数量的badge
showBadge
:
propTypes
.
bool
.
def
(
true
),
// 图片间距
margin
:
propTypes
.
number
.
def
(
4
),
// src前缀,将会附加在imgList中每一项之前
srcPrefix
:
propTypes
.
string
.
def
(
''
),
},
setup
(
props
)
{
const
getWrapStyle
=
computed
(
():
CSSProperties
=>
{
const
{
size
}
=
props
;
const
s
=
`
${
size
}
px`
;
return
{
height
:
s
,
width
:
s
};
}
);
const
getWrapStyle
=
computed
(():
CSSProperties
=>
{
const
{
size
}
=
props
;
const
s
=
`
${
size
}
px`
;
return
{
height
:
s
,
width
:
s
};
});
const
{
prefixCls
}
=
useDesign
(
'
basic-table-img
'
);
return
{
prefixCls
,
getWrapStyle
};
...
...
@@ -53,5 +78,9 @@
border-radius: 2px;
}
}
.img-div {
display: inline-grid;
}
}
</
style
>
src/views/demo/table/CustomerCell.vue
浏览文件 @
19d8e01e
...
...
@@ -7,9 +7,31 @@
{{
record
.
no
}}
</Tag>
</
template
>
<
template
#avatar=
"{ record }"
>
<Avatar
:size=
"60"
:src=
"'http://api.btstu.cn/sjtx/api.php?lx=c1&format=images&id=' + record.id"
/>
</
template
>
<
template
#img
>
<TableImg
:imgList=
"['https://picsum.photos/id/66/346/216', 'https://picsum.photos/id/67/346/216']"
:size=
"60"
:simpleShow=
"true"
:imgList=
"[
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png?1622962250222',
'https://picsum.photos/id/66/346/216',
'https://picsum.photos/id/67/346/216',
]"
/>
</
template
>
<
template
#imgs
>
<TableImg
:size=
"60"
:imgList=
"[
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png?1622962250222',
'https://picsum.photos/id/66/346/216',
'https://picsum.photos/id/67/346/216',
]"
/>
</
template
>
...
...
@@ -24,7 +46,7 @@
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'
vue
'
;
import
{
BasicTable
,
useTable
,
BasicColumn
,
TableImg
}
from
'
/@/components/Table
'
;
import
{
Tag
}
from
'
ant-design-vue
'
;
import
{
Tag
,
Avatar
}
from
'
ant-design-vue
'
;
import
{
demoListApi
}
from
'
/@/api/demo/table
'
;
const
columns
:
BasicColumn
[]
=
[
{
...
...
@@ -32,6 +54,12 @@
dataIndex
:
'
id
'
,
slots
:
{
customRender
:
'
id
'
},
},
{
title
:
'
头像
'
,
dataIndex
:
'
avatar
'
,
width
:
100
,
slots
:
{
customRender
:
'
avatar
'
},
},
{
title
:
'
分类
'
,
dataIndex
:
'
category
'
,
...
...
@@ -46,11 +74,18 @@
width
:
120
,
},
{
title
:
'
头像
'
,
title
:
'
图片列表1
'
,
dataIndex
:
'
img
'
,
width
:
120
,
helpMessage
:
[
'
这是简单模式的图片列表
'
,
'
只会显示一张在表格中
'
,
'
但点击可预览多张图片
'
],
width
:
140
,
slots
:
{
customRender
:
'
img
'
},
},
{
title
:
'
照片列表2
'
,
dataIndex
:
'
imgs
'
,
width
:
160
,
slots
:
{
customRender
:
'
imgs
'
},
},
{
title
:
'
地址
'
,
dataIndex
:
'
address
'
,
...
...
@@ -70,7 +105,7 @@
},
];
export
default
defineComponent
({
components
:
{
BasicTable
,
TableImg
,
Tag
},
components
:
{
BasicTable
,
TableImg
,
Tag
,
Avatar
},
setup
()
{
const
[
registerTable
]
=
useTable
({
title
:
'
自定义列内容
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录