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 8ea8efb9
authored
Sep 11, 2020
by
cwq0219
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
表格组件-优化
1 parent
277b4b19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
127 additions
and
65 deletions
src/components/d2-drop-table/index.vue
src/views/consumerManage/index.vue
src/views/orderManage/assignOrder.vue
src/components/d2-drop-table/index.vue
View file @
8ea8efb
<!-- 拖拽表格 -->
<
template
>
<div>
<div
ref=
"tableCom"
>
<div
class=
"table"
>
<el-table
:ref=
"tableParams.tableId + 'MutiTable' || 'mutiTable'"
v-loading=
"tableLoading"
:id=
"tableParams.tableId"
:data=
"getListApi ? data : tableData"
stripe
style=
"width: 98.5%"
size=
"small"
row-key=
"id
"
:row-key=
"tableParams.uniqueKey || 'id'
"
border
v-if=
"tableParams.dropCol.length"
>
<el-table-column
v-if=
"tableParams.isMuti"
type=
"selection"
width=
"55"
fixed=
"left"
:reserve-selection=
"true"
>
</el-table-column>
<el-table-column
v-if=
"hasNum"
key=
"col_0"
type=
"index"
...
...
@@ -28,6 +37,7 @@
:prop=
"tableParams.dropCol[index].prop"
:label=
"tableParams.tableHead[index]"
:class-name=
"tableParams.dropCol[index].className"
:width=
"tableParams.dropCol[index].width"
>
<template
slot-scope=
"scope"
>
<template
v-if=
"tableParams.dropCol[index].formatter"
>
...
...
@@ -47,12 +57,18 @@
fixed=
"right"
>
<
template
slot-scope=
"scope"
>
<
el-butto
n
<
spa
n
v-for=
"(item, index) in tableParams.tableOption.option"
:key=
"index"
size=
"mini"
@
click=
"item.handleClick(scope.row)"
>
{{
item
.
label
}}
</el-button>
>
<el-button
v-show=
"item.showConf ? (scope.row[item.showConf.attr] == item.showConf.showVal) : true"
:type=
"item.type || 'primary'"
size=
"mini"
plain
@
click=
"item.handleClick(scope.row)"
>
{{
item
.
label
}}
</el-button>
</span>
</
template
>
</el-table-column>
</transition>
...
...
@@ -80,22 +96,21 @@
>
{{isShowOption ? '收起' : '展开'}}
</el-button>
</div>
</div>
<!-- <pre>
{{tableParams.dropCol}}
</pre> -->
<el-pagination
v-if=
"hasPage"
small
background
@
size-change=
"handleSizeChange"
@
current-change=
"handleCurrentChange"
:current-page=
"page.pageNum"
:page-sizes=
"[10,20,30,40]"
:page-size=
"page.pageSize"
:total=
"getListApi ? total : tableTotal"
layout=
"sizes,total,->,prev,pager,next,jumper"
>
</el-pagination>
<div
ref=
"page"
>
<el-pagination
v-if=
"hasPage"
small
background
@
size-change=
"handleSizeChange"
@
current-change=
"handleCurrentChange"
:current-page=
"page.pageNum"
:page-sizes=
"[10,20,30,40]"
:page-size=
"page.pageSize"
:total=
"getListApi ? total : tableTotal"
layout=
"sizes,total,->,prev,pager,next,jumper"
>
</el-pagination>
</div>
</div>
</template>
...
...
@@ -118,7 +133,9 @@ export default {
pageNum
:
1
,
pageSize
:
10
},
total
:
10
total
:
10
,
// 多选数组
mutiSelectArr
:
{}
}
},
...
...
@@ -142,6 +159,13 @@ export default {
type
:
Function
,
default
:
null
},
// 接口请求前,参数处理
dealParams
:
{
type
:
Function
,
default
:
()
=>
{
return
new
Promise
(
resolve
=>
{
resolve
()
})
}
},
// 分页,默认有
hasPage
:
{
type
:
Boolean
,
...
...
@@ -160,11 +184,21 @@ export default {
type
:
String
,
default
:
''
},
// 唯一标识(表格返回的参数的唯一标识)
// uniqueKey: {
// type: String,
// default: ''
// },
// 搜索按钮id;new Date().getTime() + parseInt(Math.random() * 1000)
// btnId: {
// type: String,
// default: ''
// },
// 是否多选;默认没有
isMuti
:
{
type
:
Boolean
,
default
:
false
},
// 后端返回列表参数名
listName
:
{
type
:
String
,
...
...
@@ -190,7 +224,14 @@ export default {
}
},
watch
:
{
'$store.state.d2admin.tsearch.active'
(
val
)
{
this
.
getHeight
()
}
},
mounted
()
{
this
.
getHeight
()
document
.
body
.
ondrop
=
function
(
event
)
{
event
.
preventDefault
()
event
.
stopPropagation
()
...
...
@@ -202,9 +243,34 @@ export default {
},
methods
:
{
// addClass({ row, rowIndex }) {
// return 'col_' + rowIndex
// },
// 表格高度
getHeight
()
{
setTimeout
(()
=>
{
// var parentHeight = document.querySelector('.table').parentElement.parentElement.clientHeight
var
parentHeight
=
this
.
$refs
.
tableCom
.
parentElement
.
clientHeight
var
pageHeight
=
this
.
hasPage
?
this
.
$refs
.
page
.
clientHeight
:
0
document
.
querySelector
(
'.table'
).
style
.
height
=
parentHeight
-
pageHeight
-
50
+
'px'
this
.
loading
=
false
},
400
)
},
// 排序
sortChange
({
column
,
prop
,
order
})
{
this
.
sortColum
=
order
?
prop
:
''
this
.
sort
=
order
this
.
refreshTable
()
},
// 多选
handleSelect
(
val
)
{
this
.
mutiSelectArr
[
this
.
tableParams
.
tableId
]
=
val
},
// 清空多选
clearMutiSelect
()
{
this
.
mutiSelectArr
[
this
.
tableParams
.
tableId
]
=
[]
this
.
$refs
[
this
.
tableParams
.
tableId
+
'MutiTable'
].
clearSelection
()
},
handleReset
()
{
this
.
handleGet
(
true
)
...
...
@@ -224,8 +290,6 @@ export default {
// 列拖拽
columnDrop
()
{
const
wrapperTr
=
document
.
querySelector
(
'.el-table__header-wrapper tr'
)
// this.hasNum && (wrapperTr.shift())
// console.log(wrapperTr)
this
.
sortable
=
Sortable
.
create
(
wrapperTr
,
{
animation
:
180
,
delay
:
0
,
...
...
@@ -260,7 +324,7 @@ export default {
tableName
:
'database'
,
path
:
'tableCol.'
+
this
.
tableParams
.
tableId
}).
then
(
res
=>
{
console
.
log
(
res
)
//
console.log(res)
this
.
tableParams
.
tableHead
=
[]
if
(
res
&&
(
res
.
length
===
this
.
tableParams
.
tableColumns
.
length
)
&&
!
isReset
)
{
res
.
forEach
((
item
,
index
)
=>
{
...
...
@@ -283,27 +347,28 @@ export default {
},
refreshTable
(
clearMuti
=
true
)
{
// 清空多选
//
clearMuti && this.clearMutiSelect()
this
.
tableParams
.
dropCol
.
length
&&
this
.
tableParams
.
isMuti
&&
clearMuti
&&
this
.
clearMutiSelect
()
this
.
loading
=
true
var
params
=
{
...
this
.
page
,
...
this
.
searchForm
}
console
.
log
(
params
)
// if (this.sort) {
// params.sortColum = this.sortColum
// params.sort = this.sort === 'descending' ? 1 : 0
// }
this
.
getListApi
(
params
).
then
(
res
=>
{
console
.
log
(
res
)
var
data
=
res
.
data
console
.
log
(
data
)
// this.pagination = data.pagination ? data.pagination : this.page
this
.
data
=
data
[
this
.
tableParams
.
listName
]
this
.
total
=
data
.
total
this
.
loading
=
false
}).
catch
(()
=>
{
this
.
loading
=
false
this
.
dealParams
().
then
(
res
=>
{
var
params
=
res
||
this
.
searchForm
params
=
{
...
params
,
...
this
.
page
}
// console.log(params)
if
(
this
.
sort
)
{
params
.
sortColum
=
this
.
sortColum
params
.
sort
=
this
.
sort
===
'descending'
?
1
:
0
}
this
.
getListApi
(
params
).
then
(
res
=>
{
// console.log(res)
var
data
=
res
.
data
this
.
data
=
data
[
this
.
tableParams
.
listName
]
this
.
total
=
data
.
total
this
.
loading
=
false
}).
catch
(()
=>
{
this
.
loading
=
false
})
})
},
...
...
@@ -330,7 +395,10 @@ export default {
<
style
>
.table
{
display
:
flex
;
align-items
:
center
;
/* align-items: center; */
}
.el-table
{
overflow-y
:
scroll
;
}
.refresh-btn
{
display
:
block
;
...
...
@@ -342,12 +410,6 @@ export default {
white-space
:
initial
;
padding
:
7px
10px
7px
3px
;
}
/* .el-table--small td {
padding: 2px 0;
}
.el-table .cell {
line-height: 14px;
} */
.drop-col
{
color
:
CornflowerBlue
;
}
...
...
src/views/consumerManage/index.vue
View file @
8ea8efb
...
...
@@ -155,7 +155,7 @@ export default {
{
required
:
true
,
message
:
'请输入密码'
,
trigger
:
'blur'
}
]
},
// 表格
参数
// 表格
配置
tableParams
:
{
btnId
:
new
Date
().
getTime
()
+
parseInt
(
Math
.
random
()
*
1000
),
tableId
:
'consumer'
,
...
...
@@ -179,14 +179,14 @@ export default {
},
{
label
:
'角色'
,
prop
:
'role'
,
formatter
:
(
item
)
=>
{
return
this
.
roleShow
[
item
.
role
]
formatter
:
(
row
)
=>
{
return
this
.
roleShow
[
row
.
role
]
}
},
{
label
:
'工厂/仓库名'
,
prop
:
'imsi'
,
formatter
:
(
item
)
=>
{
return
item
.
wareHouseInfo
?
item
.
wareHouseInfo
.
name
:
''
formatter
:
(
row
)
=>
{
return
row
.
wareHouseInfo
?
row
.
wareHouseInfo
.
name
:
''
}
},
{
label
:
'创建人'
,
...
...
@@ -194,14 +194,14 @@ export default {
},
{
label
:
'创建时间'
,
prop
:
'createdDate'
,
formatter
:
(
item
)
=>
{
return
this
.
DATEFORMATE
(
item
.
createdDate
,
'YYYY-MM-DD HH:mm:ss'
)
formatter
:
(
row
)
=>
{
return
this
.
DATEFORMATE
(
row
.
createdDate
,
'YYYY-MM-DD HH:mm:ss'
)
}
},
{
label
:
'更新时间'
,
prop
:
'updatedDate'
,
formatter
:
(
item
)
=>
{
return
this
.
DATEFORMATE
(
item
.
updatedDate
,
'YYYY-MM-DD HH:mm:ss'
)
formatter
:
(
row
)
=>
{
return
this
.
DATEFORMATE
(
row
.
updatedDate
,
'YYYY-MM-DD HH:mm:ss'
)
}
}]
},
...
...
src/views/orderManage/assignOrder.vue
View file @
8ea8efb
This diff is collapsed.
Click to expand it.
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