Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx-business
/
supply-web
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 5ee336f1
authored
Sep 09, 2020
by
cwq0219
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
表格组件
1 parent
97a07369
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
37 deletions
src/components/d2-drop-table/index.vue
src/views/consumerManage/index.vue
src/components/d2-drop-table/index.vue
View file @
5ee336f
<!-- 拖拽表格 -->
<!-- 拖拽表格 -->
<
template
>
<
template
>
<div>
<div>
<!--
<el-button
size=
"small"
type=
"primary"
@
click=
"handleSave"
>
保存
</el-button>
-->
<!--
<el-button
size=
"small"
@
click=
"handleReset"
>
恢复
</el-button>
-->
<div
class=
"table"
>
<div
class=
"table"
>
<el-table
<el-table
v-loading=
"tableLoading"
v-loading=
"tableLoading"
...
@@ -22,27 +13,28 @@
...
@@ -22,27 +13,28 @@
border
border
v-if=
"tableParams.dropCol.length"
v-if=
"tableParams.dropCol.length"
>
>
<
!--
<
el-table-column
<el-table-column
v-if=
"hasNum"
v-if=
"hasNum"
key=
"col_0"
type=
"index"
type=
"index"
:index=
"index => index+(page.page
Size - 1) * page.pageNum
+ 1"
:index=
"index => index+(page.page
Num - 1) * page.pageSize
+ 1"
label=
"序号"
label=
"序号"
width=
"80"
width=
"80"
class-name=
"noDrop"
class-name=
"noDrop"
/>
-->
/>
<el-table-column
<el-table-column
v-for=
"(item, index) in tableParams.tableColumns"
v-for=
"(item, index) in tableParams.tableColumns"
:key=
"`col_` + index"
:key=
"`col_` + index"
:prop=
"tableParams.dropCol[index].prop"
:prop=
"tableParams.dropCol[index].prop"
:label=
"tableParams.tableHead[index]"
:label=
"tableParams.tableHead[index]"
:class-name=
"
item
.className"
:class-name=
"
tableParams.dropCol[index]
.className"
>
>
<template
slot-scope=
"scope"
>
<template
slot-scope=
"scope"
>
<template
v-if=
"tableParams.dropCol[index].formatter"
>
<template
v-if=
"tableParams.dropCol[index].formatter"
>
<span
v-text=
"tableParams.dropCol[index].formatter(scope.row)"
></span>
<span
v-text=
"tableParams.dropCol[index].formatter(scope.row)"
></span>
</
template
>
</
template
>
<
template
v-else
>
<
template
v-else
>
<
p>
{{
data
[
scope
.
$index
][
tableParams
.
dropCol
[
index
].
prop
]
}}
</p
>
<
span>
{{
data
[
scope
.
$index
][
tableParams
.
dropCol
[
index
].
prop
]
}}
</span
>
</
template
>
</
template
>
</template>
</template>
</el-table-column>
</el-table-column>
...
@@ -58,7 +50,7 @@
...
@@ -58,7 +50,7 @@
<el-button
<el-button
v-for=
"(item, index) in tableParams.tableOption.option"
v-for=
"(item, index) in tableParams.tableOption.option"
:key=
"index"
:key=
"index"
type=
"text
"
size=
"mini
"
@
click=
"item.handleClick(scope.row)"
@
click=
"item.handleClick(scope.row)"
>
{{
item
.
label
}}
</el-button>
>
{{
item
.
label
}}
</el-button>
</
template
>
</
template
>
...
@@ -66,19 +58,31 @@
...
@@ -66,19 +58,31 @@
</transition>
</transition>
</el-table>
</el-table>
<div>
<div>
<el-button
<el-tooltip
class=
"refresh-btn"
effect=
"dark"
size=
"mini"
content=
"重置表头顺序"
icon=
"el-icon-refresh-left"
placement=
"right"
></el-button>
>
<el-button
class=
"refresh-btn"
type=
"text"
size=
"medium"
icon=
"el-icon-refresh-left"
@
click=
"handleReset"
></el-button>
</el-tooltip>
<el-button
<el-button
type=
"primary"
type=
"primary"
class=
"opt-btn"
class=
"opt-btn"
size=
"mini"
size=
"mini"
style=
"margin-left: 0;"
@
click=
"handleOptShow"
@
click=
"handleOptShow"
>
{{isShowOption ? '收起' : '展开'}}
</el-button>
>
{{isShowOption ? '收起' : '展开'}}
</el-button>
</div>
</div>
</div>
</div>
<!-- <pre>
{{tableParams.dropCol}}
</pre> -->
<el-pagination
<el-pagination
v-if=
"hasPage"
v-if=
"hasPage"
small
small
...
@@ -187,11 +191,6 @@ export default {
...
@@ -187,11 +191,6 @@ export default {
},
},
mounted
()
{
mounted
()
{
// if (this.hasNum) {
// this.tableParams.tableColumns.unshift({
// label: '序号'
// })
// }
document
.
body
.
ondrop
=
function
(
event
)
{
document
.
body
.
ondrop
=
function
(
event
)
{
event
.
preventDefault
()
event
.
preventDefault
()
event
.
stopPropagation
()
event
.
stopPropagation
()
...
@@ -226,26 +225,39 @@ export default {
...
@@ -226,26 +225,39 @@ export default {
// 列拖拽
// 列拖拽
columnDrop
()
{
columnDrop
()
{
const
wrapperTr
=
document
.
querySelector
(
'.el-table__header-wrapper tr'
)
const
wrapperTr
=
document
.
querySelector
(
'.el-table__header-wrapper tr'
)
// this.hasNum && (wrapperTr.shift())
console
.
log
(
wrapperTr
)
console
.
log
(
wrapperTr
)
this
.
sortable
=
Sortable
.
create
(
wrapperTr
,
{
this
.
sortable
=
Sortable
.
create
(
wrapperTr
,
{
animation
:
180
,
animation
:
180
,
delay
:
0
,
delay
:
0
,
//
filter: '.noDrop',
filter
:
'.noDrop'
,
dragClass
:
'drop-col'
,
dragClass
:
'drop-col'
,
chosenClass
:
'drop-col'
,
chosenClass
:
'drop-col'
,
onStart
:
evt
=>
{
onStart
:
evt
=>
{
this
.
isMove
=
true
this
.
isMove
=
true
clearTimeout
(
this
.
timer
)
clearTimeout
(
this
.
timer
)
},
},
// onMove: evt => {
// console.log(evt.related.classList)
// // if (evt.related.classList.includes('noDrop')) {
// // console.log('不能移动')
// // }
// },
onEnd
:
evt
=>
{
onEnd
:
evt
=>
{
// console.log(evt)
console
.
log
(
evt
)
const
oldItem
=
this
.
tableParams
.
dropCol
[
evt
.
oldIndex
]
if
(
evt
.
newIndex
===
0
)
{
this
.
tableParams
.
dropCol
.
splice
(
evt
.
oldIndex
,
1
)
this
.
handleGet
()
this
.
tableParams
.
dropCol
.
splice
(
evt
.
newIndex
,
0
,
oldItem
)
}
else
{
this
.
isMove
=
false
var
oldIndex
=
this
.
hasNum
?
(
evt
.
oldIndex
-
1
)
:
evt
.
oldIndex
this
.
timer
=
setTimeout
(()
=>
{
var
newIndex
=
this
.
hasNum
?
(
evt
.
newIndex
-
1
)
:
evt
.
newIndex
(
!
this
.
isMove
)
&&
this
.
handleSave
()
const
oldItem
=
this
.
tableParams
.
dropCol
[
oldIndex
]
},
1000
)
this
.
tableParams
.
dropCol
.
splice
(
oldIndex
,
1
)
this
.
tableParams
.
dropCol
.
splice
(
newIndex
,
0
,
oldItem
)
this
.
isMove
=
false
this
.
timer
=
setTimeout
(()
=>
{
(
!
this
.
isMove
)
&&
this
.
handleSave
()
},
1000
)
}
}
}
})
})
},
},
...
@@ -258,7 +270,7 @@ export default {
...
@@ -258,7 +270,7 @@ export default {
}).
then
(
res
=>
{
}).
then
(
res
=>
{
console
.
log
(
res
)
console
.
log
(
res
)
this
.
tableParams
.
tableHead
=
[]
this
.
tableParams
.
tableHead
=
[]
if
(
res
&&
!
isReset
)
{
if
(
res
&&
(
res
.
length
===
this
.
tableParams
.
tableColumns
.
length
)
&&
!
isReset
)
{
res
.
forEach
((
item
,
index
)
=>
{
res
.
forEach
((
item
,
index
)
=>
{
var
currItem
=
this
.
tableParams
.
tableColumns
.
find
(
i
=>
i
.
prop
===
item
)
var
currItem
=
this
.
tableParams
.
tableColumns
.
find
(
i
=>
i
.
prop
===
item
)
this
.
tableParams
.
dropCol
.
push
(
currItem
)
this
.
tableParams
.
dropCol
.
push
(
currItem
)
...
@@ -329,6 +341,8 @@ export default {
...
@@ -329,6 +341,8 @@ export default {
align-items
:
center
;
align-items
:
center
;
}
}
.refresh-btn
{
.refresh-btn
{
display
:
block
;
padding
:
0
0
;
}
}
.opt-btn
{
.opt-btn
{
width
:
20px
;
width
:
20px
;
...
...
src/views/consumerManage/index.vue
View file @
5ee336f
...
@@ -174,8 +174,8 @@ export default {
...
@@ -174,8 +174,8 @@ export default {
dropCol
:
[],
dropCol
:
[],
tableColumns
:
[{
tableColumns
:
[{
label
:
'用户名'
,
label
:
'用户名'
,
prop
:
'userName'
,
prop
:
'userName'
className
:
'noDrop'
//
className: 'noDrop'
},
{
},
{
label
:
'角色'
,
label
:
'角色'
,
prop
:
'role'
,
prop
:
'role'
,
...
...
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