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 5bccbaea
authored
Nov 17, 2022
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
commit
1 parent
f238fd7a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
30 deletions
src/App.vue
src/packages/GLTabs/src/index.vue
src/packages/Table/src/index.vue
src/packages/Table/src/sub-el-table-column.vue
src/utils/index.js
src/App.vue
View file @
5bccbae
...
@@ -292,14 +292,12 @@ export default {
...
@@ -292,14 +292,12 @@ export default {
{
{
label
:
'状态'
,
label
:
'状态'
,
prop
:
'status'
,
prop
:
'status'
,
type
:
'status'
,
enum
:
[
enum
:
[
{
label
:
'成功'
,
value
:
1
},
{
label
:
'成功'
,
value
:
1
},
{
label
:
'进行中'
,
value
:
1
},
{
label
:
'进行中'
,
value
:
1
,
color
:
'#fdb757'
},
{
label
:
'失败'
,
value
:
3
}
{
label
:
'失败'
,
value
:
3
,
color
:
'#999'
}
],
],
searchProps
:
{
label
:
'label'
,
value
:
'value'
},
searchProps
:
{
label
:
'label'
,
value
:
'value'
},
colors
:
[
'#2cca74'
,
'#fdb757'
,
'#999'
]
},
},
{
{
label
:
'房间号'
,
label
:
'房间号'
,
...
...
src/packages/GLTabs/src/index.vue
View file @
5bccbae
...
@@ -24,10 +24,14 @@ export default {
...
@@ -24,10 +24,14 @@ export default {
type
:
Array
,
type
:
Array
,
default
:
()
=>
[{}]
default
:
()
=>
[{}]
},
},
// type:默认不传;
// type:card卡片式;
// type:btn按钮式
type
:
{
type
:
{
type
:
String
,
type
:
String
,
default
:
''
default
:
''
},
},
//标签是否可关闭
edit
:
{
edit
:
{
type
:
Boolean
,
type
:
Boolean
,
default
:
false
default
:
false
...
...
src/packages/Table/src/index.vue
View file @
5bccbae
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
</span>
</span>
</
template
>
</
template
>
<
template
v-else-if=
"item.enum"
>
<
template
v-else-if=
"item.enum"
>
<span
v-if=
"item.colors"
class=
"task_icon"
:style=
"
{ background: filterEnum(scope.row[item.prop], item.enum, item.searchProps,item.color
s).color }">
</span>
<span
class=
"task_icon"
v-if=
" filterEnum(scope.row[item.prop], item.enum, item.searchProps).color"
:style=
"
{ background: filterEnum(scope.row[item.prop], item.enum, item.searchProp
s).color }">
</span>
<span>
{{
item
.
enum
&&
filterEnum
(
scope
.
row
[
item
.
prop
],
item
.
enum
,
item
.
searchProps
).
label
}}
</span>
<span>
{{
item
.
enum
&&
filterEnum
(
scope
.
row
[
item
.
prop
],
item
.
enum
,
item
.
searchProps
).
label
}}
</span>
</
template
>
</
template
>
<
template
v-else-if=
"getListApi"
>
<
template
v-else-if=
"getListApi"
>
...
@@ -325,8 +325,8 @@ export default {
...
@@ -325,8 +325,8 @@ export default {
},
},
methods
:
{
methods
:
{
filterEnum
(
callValue
,
enumData
,
searchProps
,
colors
)
{
filterEnum
(
callValue
,
enumData
,
searchProps
)
{
return
filterEnum
(
callValue
,
enumData
,
searchProps
,
colors
)
return
filterEnum
(
callValue
,
enumData
,
searchProps
)
},
},
findShowHeadCol
()
{
findShowHeadCol
()
{
// findShowHeadCol事件
// findShowHeadCol事件
...
@@ -700,21 +700,5 @@ export default {
...
@@ -700,21 +700,5 @@ export default {
display
:
inline-block
;
display
:
inline-block
;
vertical-align
:
middle
;
vertical-align
:
middle
;
margin-right
:
8px
;
margin-right
:
8px
;
background
:
#2cca74
;
}
.green-icon
{
&::after
{
background
:
#2cca74
;
}
}
.yellow-icon
{
&::after
{
background
:
#fdb757
;
}
}
.gray-icon
{
&::after
{
background
:
#999
;
}
}
}
</
style
>
</
style
>
src/packages/Table/src/sub-el-table-column.vue
View file @
5bccbae
...
@@ -14,7 +14,10 @@
...
@@ -14,7 +14,10 @@
{{
item
.
formatter
(
scope
.
row
)
|
tableCellFormat
}}
{{
item
.
formatter
(
scope
.
row
)
|
tableCellFormat
}}
</span>
</span>
</
template
>
</
template
>
<
template
v-else-if=
"item.enum"
>
<span
class=
"task_icon"
v-if=
"filterEnum(scope.row[item.prop], item.enum, item.searchProps).color"
:style=
"
{ background: filterEnum(scope.row[item.prop], item.enum, item.searchProps).color }">
</span>
<span>
{{
item
.
enum
&&
filterEnum
(
scope
.
row
[
item
.
prop
],
item
.
enum
,
item
.
searchProps
).
label
}}
</span>
</
template
>
<
template
v-else-if=
"getListApi"
>
<
template
v-else-if=
"getListApi"
>
<el-popover
v-if=
"scope.row[item.prop] && scope.row[item.prop].length >= Math.ceil((item.width - 36) / 14) * 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 - 36) / 14) * 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 : '' }">
...
@@ -48,14 +51,13 @@
...
@@ -48,14 +51,13 @@
<!-- 递归 -->
<!-- 递归 -->
<sub-el-table-column
v-if=
"item.children"
:data=
"item.children"
:tableData=
"tableData"
:getListApi=
"getListApi"
></sub-el-table-column>
<sub-el-table-column
v-if=
"item.children"
:data=
"item.children"
:tableData=
"tableData"
:getListApi=
"getListApi"
></sub-el-table-column>
</el-table-column>
</el-table-column>
</div>
</div>
</template>
</template>
<
script
>
<
script
>
// import GlSubTableColumn from '../../GlSubTableColumn'
// import GlSubTableColumn from '../../GlSubTableColumn'
import
{
filterEnum
}
from
'../../../utils/index'
export
default
{
export
default
{
name
:
'sub-el-table-column'
,
name
:
'sub-el-table-column'
,
props
:
{
props
:
{
...
@@ -82,6 +84,11 @@ export default {
...
@@ -82,6 +84,11 @@ export default {
return
arr
return
arr
}
}
},
},
methods
:
{
filterEnum
(
callValue
,
enumData
,
searchProps
)
{
return
filterEnum
(
callValue
,
enumData
,
searchProps
)
}
}
// components: {
// components: {
// GlSubTableColumn
// GlSubTableColumn
// }
// }
...
...
src/utils/index.js
View file @
5bccbae
...
@@ -8,17 +8,23 @@ export const objectType = value => {
...
@@ -8,17 +8,23 @@ export const objectType = value => {
return
res
return
res
}
}
/**
* @description 根据枚举列表查询当需要的数据(如果指定了 label 和 value 的 key值,会自动识别格式化)
* @param {String} callValue 当前单元格值
* @param {Array} enumData 枚举列表
* @param {Array} colors 颜色列表
* @return string
* */
export
function
filterEnum
(
callValue
,
enumData
,
searchProps
,
colors
)
{
export
function
filterEnum
(
callValue
,
enumData
,
searchProps
,
colors
)
{
const
value
=
searchProps
.
value
?
searchProps
.
value
:
'value'
const
value
=
searchProps
.
value
?
searchProps
.
value
:
'value'
const
label
=
searchProps
.
label
?
searchProps
.
label
:
'label'
const
label
=
searchProps
.
label
?
searchProps
.
label
:
'label'
let
filterData
=
{}
let
filterData
=
{}
let
index
=
-
1
let
storage
=
{}
let
storage
=
{}
if
(
Array
.
isArray
(
enumData
))
filterData
=
enumData
.
find
(
item
=>
item
[
value
]
===
callValue
)
if
(
Array
.
isArray
(
enumData
))
filterData
=
enumData
.
find
(
item
=>
item
[
value
]
===
callValue
)
if
(
Array
.
isArray
(
colors
))
index
=
enumData
.
findIndex
(
item
=>
item
[
value
]
===
callValue
)
storage
=
{
storage
=
{
label
:
filterData
?
filterData
[
label
]
:
'--'
,
label
:
filterData
?
filterData
[
label
]
:
'--'
,
color
:
index
!=-
1
&&
colors
[
index
]
color
:
filterData
?
filterData
.
color
:
''
}
}
return
storage
return
storage
}
}
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