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 8c024d46
authored
Apr 02, 2022
by
luyt
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add;新增table more button组件
1 parent
caf24c68
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
158 additions
and
19 deletions
src/packages/GlTableButton/src/index.vue
src/packages/index.js
src/packages/GlTableButton/src/index.vue
View file @
8c024d4
<
script
>
<
script
>
export
default
{
export
default
{
name
:
'GLTableButton'
,
name
:
'GLTableButton'
,
props
:{},
props
:
{
data
()
{
buttonList
:
{
type
:
Array
,
default
:
()
=>
[]
},
buttonItem
:
{
type
:
Object
,
default
:
()
=>
({})
}
},
data
()
{
return
{
return
{
};
// buttonList: [
// {
// type: 'el-button',
// name: '编辑',
// condition: row => {
// console.log('row: ', row)
// return false
// },
// attrs: {
// type: 'text'
// },
// listeners: {
// click: this.conditionFn
// }
// }
// ]
}
},
},
created
(){},
mounted
()
{},
mounted
(){},
render
()
{
methods
:
{},
/**
components
:
{},
* 组件处理函数
computed
:
{},
* @param {*} component 单个组件的配置项
}
* @param {*} hasSelect 是否是有更多操作项,默认false
*/
const
handleVNode
=
(
component
,
hasSelect
=
false
)
=>
{
let
comp
=
''
if
(
component
.
type
===
'el-button'
)
{
//el-button
if
(
hasSelect
)
{
return
(
comp
=
(
<
el
-
dropdown
-
item
>
<
el
-
button
{...{
attrs
:
component
.
attrs
}}
onClick
=
{()
=>
{
component
.
listeners
.
click
(
this
.
buttonItem
,
component
)
}}
domPropsInnerHTML
=
{
component
.
name
?
component
.
name
(
this
.
buttonItem
)
:
''
}
>
// {component.name}
<
/el-button
>
<
/el-dropdown-item
>
))
}
comp
=
(
<
el
-
button
{...{
attrs
:
component
.
attrs
}}
onClick
=
{()
=>
{
component
.
listeners
.
click
(
this
.
buttonItem
,
component
)
}}
domPropsInnerHTML
=
{
component
.
name
?
component
.
name
(
this
.
buttonItem
)
:
''
}
>
// {component.name}
<
/el-button
>
)
}
else
if
(
component
.
type
===
'GLButton'
)
{
if
(
hasSelect
)
{
comp
=
(
<
el
-
dropdown
-
item
>
<
GLButton
{...{
attrs
:
component
.
attrs
}}
onClick
=
{()
=>
{
component
.
listeners
.
click
(
this
.
buttonItem
,
component
)
}}
domPropsInnerHTML
=
{
component
.
name
?
component
.
name
(
this
.
buttonItem
)
:
''
}
>
// {component.name}
<
/GLButton
>
<
/el-dropdown-item
>
)
}
comp
=
(
<
GLButton
{...{
attrs
:
component
.
attrs
}}
onClick
=
{()
=>
{
component
.
listeners
.
click
(
this
.
buttonItem
,
component
)
}}
domPropsInnerHTML
=
{
component
.
name
?
component
.
name
(
this
.
buttonItem
)
:
''
}
>
// {component.name}
<
/GLButton
>
)
}
return
comp
}
let
ButtonsComponent
=
''
if
(
this
.
buttonList
.
length
===
0
)
return
// //1.筛选过滤条件
const
componentList
=
this
.
buttonList
.
map
(
item
=>
{
const
status
=
item
.
condition
(
this
.
buttonItem
)
if
(
status
)
{
return
item
}
})
.
filter
(
item
=>
item
)
if
(
componentList
.
length
===
0
)
return
// // 2.渲染组件
// 判断长度
const
len
=
componentList
.
length
let
preButtonsComp
let
selectComp
let
renderComp
if
(
len
>
3
)
{
//有更多的情况
let
preButtons
=
componentList
.
slice
(
0
,
2
)
let
postButtons
=
componentList
.
slice
(
2
)
preButtonsComp
=
preButtons
.
map
(
item
=>
handleVNode
(
item
))
selectComp
=
(
<
el
-
dropdown
class
=
"gl-dropdown"
>
<
span
class
=
"el-dropdown-link"
>
更多
<
i
class
=
"el-icon-arrow-down el-icon--right"
><
/i
>
<
/span
>
<
el
-
dropdown
-
menu
slot
=
"dropdown"
>
{
postButtons
.
map
(
item
=>
handleVNode
(
item
,
true
))}
<
/el-dropdown-menu
>
<
/el-dropdown
>
)
}
else
{
//少于3个情况
preButtonsComp
=
componentList
.
map
(
item
=>
handleVNode
(
item
))
}
//确定最终渲染组件
if
(
selectComp
)
{
renderComp
=
[...
preButtonsComp
,
selectComp
]
}
else
{
renderComp
=
preButtonsComp
}
ButtonsComponent
=
<
div
class
=
"gl-table-button"
>
{
renderComp
.
map
(
item
=>
item
)}
<
/div
>
return
ButtonsComponent
}
}
</
script
>
</
script
>
<
style
lang=
'scss'
>
</
style
>
\ No newline at end of file
\ No newline at end of file
<
style
lang=
"scss"
>
.gl-table-button
{
//
todo
放到组件库后,这行注释掉
$
color-primary
:
var
(
--primaryColor
,
#5850ff
);
.gl-dropdown
{
margin-left
:
10px
;
color
:
$
color-primary
;
}
}
</
style
>
src/packages/index.js
View file @
8c024d4
/***
/***
* 打包的组件的出口
* 打包的组件的出口
*/
*/
// 导入颜色选择器组件
// 导入颜色选择器组件
// import '@/plugins/element.js'
// import '@/plugins/element.js'
import
{
Table
,
TableColumn
,
Popover
,
Button
,
ButtonGroup
,
Loading
,
Input
,
Form
,
FormItem
,
Pagination
,
Tooltip
,
Icon
,
Select
,
Option
,
DatePicker
}
from
'@/plugins/element.js'
import
{
Table
,
TableColumn
,
Popover
,
Button
,
ButtonGroup
,
Loading
,
Input
,
Form
,
FormItem
,
Pagination
,
Tooltip
,
Icon
,
Select
,
Option
,
DatePicker
,
Dropdown
,
DropdownItem
,
DropdownMenu
}
from
'@/plugins/element.js'
import
'@/theme/theme.scss'
import
'@/theme/theme.scss'
// 一次性注册所有的过滤器 本地测试
// 一次性注册所有的过滤器 本地测试
...
@@ -21,13 +20,13 @@ import GLFooter from './Footer'
...
@@ -21,13 +20,13 @@ import GLFooter from './Footer'
import
GLSearch
from
'./GlSearch'
import
GLSearch
from
'./GlSearch'
import
GLSearchItem
from
'./GlSearchItem'
import
GLSearchItem
from
'./GlSearchItem'
import
GLCombiForm
from
'./GlCombiForm'
import
GLCombiForm
from
'./GlCombiForm'
import
GLTableButton
from
'./GlTableButton'
//el原始组件
//el原始组件
const
ElComponent
=
[
Table
,
TableColumn
,
Popover
,
Button
,
ButtonGroup
,
Loading
,
Input
,
Form
,
FormItem
,
Pagination
,
Tooltip
,
Icon
,
Select
,
Option
,
DatePicker
]
const
ElComponent
=
[
Table
,
TableColumn
,
Popover
,
Button
,
ButtonGroup
,
Loading
,
Input
,
Form
,
FormItem
,
Pagination
,
Tooltip
,
Icon
,
Select
,
Option
,
DatePicker
,
Dropdown
,
DropdownItem
,
DropdownMenu
]
// 存储组件列表
// 存储组件列表
const
components
=
[
TestComp
,
GLExternal
,
GLButton
,
GLDialog
,
GLTable
,
GLFooter
,
GLSearch
,
GLSearchItem
,
GLCombiForm
].
concat
(
ElComponent
)
const
components
=
[
TestComp
,
GLExternal
,
GLButton
,
GLDialog
,
GLTable
,
GLFooter
,
GLSearch
,
GLSearchItem
,
GLCombiForm
,
GLTableButton
].
concat
(
ElComponent
)
// console.log('components: ', components);
// console.log('components: ', components);
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
...
@@ -58,5 +57,6 @@ export default {
...
@@ -58,5 +57,6 @@ export default {
GLFooter
,
GLFooter
,
GLSearch
,
GLSearch
,
GLSearchItem
,
GLSearchItem
,
GLCombiForm
GLCombiForm
,
GLTableButton
}
}
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