Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
npm
/
glsx-components
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 860de73e
authored
Jan 14, 2022
by
luyt
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add:省略宽度自定义
1 parent
178e12b2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
18 deletions
src/App.vue
src/filters/index.js
src/packages/Table/src/index.vue
src/packages/Table/src/sub-el-table-column.vue
src/App.vue
View file @
860de73
...
@@ -101,7 +101,8 @@ export default {
...
@@ -101,7 +101,8 @@ export default {
{
{
label
:
'直播间名称'
,
label
:
'直播间名称'
,
prop
:
'name'
,
prop
:
'name'
,
line
:
1
line
:
2
,
width
:
350
// children:[
// children:[
// {
// {
// label: '直播间名称1',
// label: '直播间名称1',
...
@@ -185,7 +186,7 @@ export default {
...
@@ -185,7 +186,7 @@ export default {
name2
:
'123'
name2
:
'123'
},
},
{
{
name
:
'王小虎王小虎王小虎王王小虎王小虎王小虎王'
,
name
:
'王小虎王小虎王小虎王王小虎王小虎王小虎王
王小虎王小虎王小虎王王小虎王小虎王小虎王小虎王小虎王王小虎王小虎王小虎王
'
,
liveStatus3
:
'132'
,
liveStatus3
:
'132'
,
liveStatus4
:
'789'
,
liveStatus4
:
'789'
,
name1
:
'123'
,
name1
:
'123'
,
...
...
src/filters/index.js
View file @
860de73
const
lineEllipsis
=
(
value
,
line
=
1
)
=>
{
const
lineEllipsis
=
(
value
,
columnWidth
,
line
=
1
)
=>
{
if
(
!
value
)
return
''
if
(
!
value
)
return
''
// 假设一行的宽是字的个数10
// 假设一行的宽是字的个数10
160px的宽度 一个汉字16px
const
strleng
=
10
*
line
-
2
const
strleng
=
Math
.
ceil
(
columnWidth
/
16
)
*
line
-
2
if
(
value
.
length
>
strleng
)
{
if
(
value
.
length
>
strleng
)
{
return
value
.
substring
(
0
,
strleng
)
+
'...'
return
value
.
substring
(
0
,
strleng
)
+
'...'
}
}
...
...
src/packages/Table/src/index.vue
View file @
860de73
...
@@ -13,9 +13,9 @@
...
@@ -13,9 +13,9 @@
<
template
slot-scope=
"scope"
>
<
template
slot-scope=
"scope"
>
<slot
v-if=
"item.addHtml"
:name=
"item.addHtml"
:scope=
"scope.row"
:prop=
"item.prop"
:width=
"item.width"
></slot>
<slot
v-if=
"item.addHtml"
:name=
"item.addHtml"
:scope=
"scope.row"
:prop=
"item.prop"
:width=
"item.width"
></slot>
<template
v-else-if=
"item.formatter"
>
<template
v-else-if=
"item.formatter"
>
<el-popover
v-if=
"scope.row[item.prop] && scope.row[item.prop].length >=
10
* item.line"
placement=
"top"
popper-class=
"base-popper"
trigger=
"hover"
:content=
"item.formatter(scope.row)"
>
<el-popover
v-if=
"scope.row[item.prop] && scope.row[item.prop].length >=
Math.ceil(item.width / 16)
* item.line"
placement=
"top"
popper-class=
"base-popper"
trigger=
"hover"
:content=
"item.formatter(scope.row)"
>
<span
slot=
"reference"
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
<span
slot=
"reference"
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{
item
.
formatter
(
scope
.
row
)
|
lineEllipsis
(
item
.
line
)
}}
{{
item
.
formatter
(
scope
.
row
)
|
lineEllipsis
(
item
.
width
,
item
.
line
)
}}
</span>
</span>
</el-popover>
</el-popover>
<span
v-else
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
<span
v-else
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
...
@@ -23,9 +23,9 @@
...
@@ -23,9 +23,9 @@
</span>
</span>
</
template
>
</
template
>
<
template
v-else-if=
"getListApi"
>
<
template
v-else-if=
"getListApi"
>
<el-popover
v-if=
"scope.row[item.prop] && scope.row[item.prop].length >=
10
* item.line"
placement=
"top"
popper-class=
"base-popper"
trigger=
"hover"
:content=
"scope.row[item.prop]"
>
<el-popover
v-if=
"scope.row[item.prop] && scope.row[item.prop].length >=
Math.ceil(item.width / 16)
* item.line"
placement=
"top"
popper-class=
"base-popper"
trigger=
"hover"
:content=
"scope.row[item.prop]"
>
<span
slot=
"reference"
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
<span
slot=
"reference"
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{
scope
.
row
[
item
.
prop
]
|
lineEllipsis
(
item
.
line
)
}}
{{
scope
.
row
[
item
.
prop
]
|
lineEllipsis
(
item
.
width
,
item
.
line
)
}}
</span>
</span>
</el-popover>
</el-popover>
<span
v-else
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
<span
v-else
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
...
@@ -35,9 +35,9 @@
...
@@ -35,9 +35,9 @@
<
template
v-else
>
<
template
v-else
>
<!-- 大于10或 20个字节长度 宽度160px -->
<!-- 大于10或 20个字节长度 宽度160px -->
<el-popover
v-if=
"tableData[scope.$index][item.prop] && tableData[scope.$index][item.prop].length >=
10
* item.line"
placement=
"top"
popper-class=
"base-popper"
trigger=
"hover"
:content=
"tableData[scope.$index][item.prop]"
>
<el-popover
v-if=
"tableData[scope.$index][item.prop] && tableData[scope.$index][item.prop].length >=
Math.ceil(item.width / 16)
* item.line"
placement=
"top"
popper-class=
"base-popper"
trigger=
"hover"
:content=
"tableData[scope.$index][item.prop]"
>
<span
slot=
"reference"
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
<span
slot=
"reference"
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{
tableData
[
scope
.
$index
][
item
.
prop
]
|
lineEllipsis
(
item
.
line
)
}}
{{
tableData
[
scope
.
$index
][
item
.
prop
]
|
lineEllipsis
(
item
.
width
,
item
.
line
)
}}
</span>
</span>
</el-popover>
</el-popover>
<span
v-else
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="tableData[scope.$index][item.prop]">
</span>
<span
v-else
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="tableData[scope.$index][item.prop]">
</span>
...
...
src/packages/Table/src/sub-el-table-column.vue
View file @
860de73
...
@@ -4,18 +4,18 @@
...
@@ -4,18 +4,18 @@
<template
slot-scope=
"scope"
>
<template
slot-scope=
"scope"
>
<slot
v-if=
"item.addHtml"
:name=
"item.addHtml"
:scope=
"scope.row"
:prop=
"item.prop"
:width=
"item.width"
></slot>
<slot
v-if=
"item.addHtml"
:name=
"item.addHtml"
:scope=
"scope.row"
:prop=
"item.prop"
:width=
"item.width"
></slot>
<template
v-else-if=
"item.formatter"
>
<template
v-else-if=
"item.formatter"
>
<el-popover
v-if=
"scope.row[item.prop] && scope.row[item.prop].length >=
10
* item.line"
placement=
"top"
popper-class=
"base-popper"
trigger=
"hover"
:content=
"item.formatter(scope.row)"
>
<el-popover
v-if=
"scope.row[item.prop] && scope.row[item.prop].length >=
Math.ceil(item.width / 16)
* item.line"
placement=
"top"
popper-class=
"base-popper"
trigger=
"hover"
:content=
"item.formatter(scope.row)"
>
<span
slot=
"reference"
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
<span
slot=
"reference"
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{
item
.
formatter
(
scope
.
row
)
|
lineEllipsis
(
item
.
line
)
}}
{{
item
.
formatter
(
scope
.
row
)
|
lineEllipsis
(
item
.
width
,
item
.
line
)
}}
</span>
</span>
</el-popover>
</el-popover>
<span
v-else
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="item.formatter(scope.row)">
</span>
<span
v-else
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="item.formatter(scope.row)">
</span>
</
template
>
</
template
>
<
template
v-else-if=
"getListApi"
>
<
template
v-else-if=
"getListApi"
>
<el-popover
v-if=
"scope.row[item.prop] && scope.row[item.prop].length >=
10
* item.line"
placement=
"top"
popper-class=
"base-popper"
trigger=
"hover"
:content=
"scope.row[item.prop]"
>
<el-popover
v-if=
"scope.row[item.prop] && scope.row[item.prop].length >=
Math.ceil(item.width / 16)
* item.line"
placement=
"top"
popper-class=
"base-popper"
trigger=
"hover"
:content=
"scope.row[item.prop]"
>
<span
slot=
"reference"
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
<span
slot=
"reference"
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{
scope
.
row
[
item
.
prop
]
|
lineEllipsis
(
item
.
line
)
}}
{{
scope
.
row
[
item
.
prop
]
|
lineEllipsis
(
item
.
width
,
item
.
line
)
}}
</span>
</span>
</el-popover>
</el-popover>
<span
v-else
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="scope.row[item.prop]">
</span>
<span
v-else
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="scope.row[item.prop]">
</span>
...
@@ -24,14 +24,14 @@
...
@@ -24,14 +24,14 @@
<
template
v-else
>
<
template
v-else
>
<!-- 大于10或 20个字节长度 -->
<!-- 大于10或 20个字节长度 -->
<el-popover
v-if=
"tableData[scope.$index][item.prop] && tableData[scope.$index][item.prop].length >=
10
* item.line"
placement=
"top"
width=
"200"
trigger=
"hover"
:content=
"tableData[scope.$index][item.prop]"
>
<el-popover
v-if=
"tableData[scope.$index][item.prop] && tableData[scope.$index][item.prop].length >=
Math.ceil(item.width / 16)
* item.line"
placement=
"top"
width=
"200"
trigger=
"hover"
:content=
"tableData[scope.$index][item.prop]"
>
<span
slot=
"reference"
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
<span
slot=
"reference"
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{
tableData
[
scope
.
$index
][
item
.
prop
]
|
lineEllipsis
(
item
.
line
)
}}
{{
tableData
[
scope
.
$index
][
item
.
prop
]
|
lineEllipsis
(
item
.
width
,
item
.
line
)
}}
</span>
</span>
</el-popover>
</el-popover>
<!--
<span
v-else
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="tableData[scope.$index][item.prop]">
</span>
-->
<!--
<span
v-else
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="tableData[scope.$index][item.prop]">
</span>
-->
<span
v-else
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
<span
v-else
class=
"line-ellipsis"
:style=
"
{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{
tableData
[
scope
.
$index
][
item
.
prop
]
}}
{{
tableData
[
scope
.
$index
][
item
.
prop
]
}}
</span>
</span>
</
template
>
</
template
>
<
template
v-if=
"item.addSymbol"
>
<
template
v-if=
"item.addSymbol"
>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment