Commit c653a596 by 胡悦

Merge branch 'v0.0.1' of 192.168.3.233:glsx-business/supply-web into v0.0.1

2 parents dbc96f16 0c05d68c
<!-- 拖拽表格 --> <!-- 拖拽表格 -->
<template> <template>
<div> <div ref="tableCom">
<div class="table"> <div class="table">
<el-table <el-table
:ref="tableParams.tableId + 'MutiTable' || 'mutiTable'"
v-loading="tableLoading" v-loading="tableLoading"
:id="tableParams.tableId" :id="tableParams.tableId"
:data="getListApi ? data : tableData" :data="getListApi ? data : tableData"
stripe stripe
style="width: 98.5%" style="width: 98.5%"
size="small" size="small"
row-key="id" :row-key="tableParams.uniqueKey || 'id'"
border border
v-if="tableParams.dropCol.length" v-if="tableParams.dropCol.length"
> >
<el-table-column <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" v-if="hasNum"
key="col_0" key="col_0"
type="index" type="index"
...@@ -28,6 +37,7 @@ ...@@ -28,6 +37,7 @@
:prop="tableParams.dropCol[index].prop" :prop="tableParams.dropCol[index].prop"
:label="tableParams.tableHead[index]" :label="tableParams.tableHead[index]"
:class-name="tableParams.dropCol[index].className" :class-name="tableParams.dropCol[index].className"
:width="tableParams.dropCol[index].width"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<template v-if="tableParams.dropCol[index].formatter"> <template v-if="tableParams.dropCol[index].formatter">
...@@ -47,12 +57,18 @@ ...@@ -47,12 +57,18 @@
fixed="right" fixed="right"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <span
v-for="(item, index) in tableParams.tableOption.option" v-for="(item, index) in tableParams.tableOption.option"
:key="index" :key="index"
>
<el-button
v-show="item.showConf ? (scope.row[item.showConf.attr] == item.showConf.showVal) : true"
:type="item.type || 'primary'"
size="mini" size="mini"
plain
@click="item.handleClick(scope.row)" @click="item.handleClick(scope.row)"
>{{item.label}}</el-button> >{{item.label}}</el-button>
</span>
</template> </template>
</el-table-column> </el-table-column>
</transition> </transition>
...@@ -80,9 +96,7 @@ ...@@ -80,9 +96,7 @@
>{{isShowOption ? '收起' : '展开'}}</el-button> >{{isShowOption ? '收起' : '展开'}}</el-button>
</div> </div>
</div> </div>
<!-- <pre> <div ref="page">
{{tableParams.dropCol}}
</pre> -->
<el-pagination <el-pagination
v-if="hasPage" v-if="hasPage"
small small
...@@ -97,6 +111,7 @@ ...@@ -97,6 +111,7 @@
> >
</el-pagination> </el-pagination>
</div> </div>
</div>
</template> </template>
<script> <script>
...@@ -118,7 +133,9 @@ export default { ...@@ -118,7 +133,9 @@ export default {
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: 10
}, },
total: 10 total: 10,
// 多选数组
mutiSelectArr: {}
} }
}, },
...@@ -142,6 +159,13 @@ export default { ...@@ -142,6 +159,13 @@ export default {
type: Function, type: Function,
default: null default: null
}, },
// 接口请求前,参数处理
dealParams: {
type: Function,
default: () => {
return new Promise(resolve => { resolve() })
}
},
// 分页,默认有 // 分页,默认有
hasPage: { hasPage: {
type: Boolean, type: Boolean,
...@@ -160,11 +184,21 @@ export default { ...@@ -160,11 +184,21 @@ export default {
type: String, type: String,
default: '' default: ''
}, },
// 唯一标识(表格返回的参数的唯一标识)
// uniqueKey: {
// type: String,
// default: ''
// },
// 搜索按钮id;new Date().getTime() + parseInt(Math.random() * 1000) // 搜索按钮id;new Date().getTime() + parseInt(Math.random() * 1000)
// btnId: { // btnId: {
// type: String, // type: String,
// default: '' // default: ''
// }, // },
// 是否多选;默认没有
isMuti: {
type: Boolean,
default: false
},
// 后端返回列表参数名 // 后端返回列表参数名
listName: { listName: {
type: String, type: String,
...@@ -190,7 +224,14 @@ export default { ...@@ -190,7 +224,14 @@ export default {
} }
}, },
watch: {
'$store.state.d2admin.tsearch.active'(val) {
this.getHeight()
}
},
mounted() { mounted() {
this.getHeight()
document.body.ondrop = function(event) { document.body.ondrop = function(event) {
event.preventDefault() event.preventDefault()
event.stopPropagation() event.stopPropagation()
...@@ -202,9 +243,34 @@ export default { ...@@ -202,9 +243,34 @@ export default {
}, },
methods: { 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() { handleReset() {
this.handleGet(true) this.handleGet(true)
...@@ -224,8 +290,6 @@ export default { ...@@ -224,8 +290,6 @@ 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)
this.sortable = Sortable.create(wrapperTr, { this.sortable = Sortable.create(wrapperTr, {
animation: 180, animation: 180,
delay: 0, delay: 0,
...@@ -260,7 +324,7 @@ export default { ...@@ -260,7 +324,7 @@ export default {
tableName: 'database', tableName: 'database',
path: 'tableCol.' + this.tableParams.tableId path: 'tableCol.' + this.tableParams.tableId
}).then(res => { }).then(res => {
console.log(res) // console.log(res)
this.tableParams.tableHead = [] this.tableParams.tableHead = []
if (res && (res.length === this.tableParams.tableColumns.length) && !isReset) { if (res && (res.length === this.tableParams.tableColumns.length) && !isReset) {
res.forEach((item, index) => { res.forEach((item, index) => {
...@@ -283,28 +347,29 @@ export default { ...@@ -283,28 +347,29 @@ export default {
}, },
refreshTable(clearMuti = true) { refreshTable(clearMuti = true) {
// 清空多选 // 清空多选
// clearMuti && this.clearMutiSelect() this.tableParams.dropCol.length && this.tableParams.isMuti && clearMuti && this.clearMutiSelect()
this.loading = true this.loading = true
var params = { this.dealParams().then(res => {
...this.page, var params = res || this.searchForm
...this.searchForm params = {
...params,
...this.page
}
// console.log(params)
if (this.sort) {
params.sortColum = this.sortColum
params.sort = this.sort === 'descending' ? 1 : 0
} }
console.log(params)
// if (this.sort) {
// params.sortColum = this.sortColum
// params.sort = this.sort === 'descending' ? 1 : 0
// }
this.getListApi(params).then(res => { this.getListApi(params).then(res => {
console.log(res) // console.log(res)
var data = res.data var data = res.data
console.log(data)
// this.pagination = data.pagination ? data.pagination : this.page
this.data = data[this.tableParams.listName] this.data = data[this.tableParams.listName]
this.total = data.total this.total = data.total
this.loading = false this.loading = false
}).catch(() => { }).catch(() => {
this.loading = false this.loading = false
}) })
})
}, },
// 发布事件,以期查询条件改变后,页面图表需要刷新 // 发布事件,以期查询条件改变后,页面图表需要刷新
...@@ -330,7 +395,10 @@ export default { ...@@ -330,7 +395,10 @@ export default {
<style> <style>
.table { .table {
display: flex; display: flex;
align-items: center; /* align-items: center; */
}
.el-table {
overflow-y: scroll;
} }
.refresh-btn { .refresh-btn {
display: block; display: block;
...@@ -342,12 +410,6 @@ export default { ...@@ -342,12 +410,6 @@ export default {
white-space: initial; white-space: initial;
padding: 7px 10px 7px 3px; padding: 7px 10px 7px 3px;
} }
/* .el-table--small td {
padding: 2px 0;
}
.el-table .cell {
line-height: 14px;
} */
.drop-col { .drop-col {
color: CornflowerBlue; color: CornflowerBlue;
} }
......
...@@ -157,7 +157,7 @@ export default { ...@@ -157,7 +157,7 @@ export default {
{ required: true, message: '请输入密码', trigger: 'blur' } { required: true, message: '请输入密码', trigger: 'blur' }
] ]
}, },
// 表格参数 // 表格配置
tableParams: { tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000), btnId: new Date().getTime() + parseInt(Math.random() * 1000),
tableId: 'consumer', tableId: 'consumer',
...@@ -181,14 +181,14 @@ export default { ...@@ -181,14 +181,14 @@ export default {
}, { }, {
label: '角色', label: '角色',
prop: 'role', prop: 'role',
formatter: (item) => { formatter: (row) => {
return this.roleShow[item.role] return this.roleShow[row.role]
} }
}, { }, {
label: '工厂/仓库名', label: '工厂/仓库名',
prop: 'imsi', prop: 'imsi',
formatter: (item) => { formatter: (row) => {
return item.wareHouseInfo ? item.wareHouseInfo.name : '' return row.wareHouseInfo ? row.wareHouseInfo.name : ''
} }
}, { }, {
label: '创建人', label: '创建人',
...@@ -196,14 +196,14 @@ export default { ...@@ -196,14 +196,14 @@ export default {
}, { }, {
label: '创建时间', label: '创建时间',
prop: 'createdDate', prop: 'createdDate',
formatter: (item) => { formatter: (row) => {
return this.DATEFORMATE(item.createdDate, 'YYYY-MM-DD HH:mm:ss') return this.DATEFORMATE(row.createdDate, 'YYYY-MM-DD HH:mm:ss')
} }
}, { }, {
label: '更新时间', label: '更新时间',
prop: 'updatedDate', prop: 'updatedDate',
formatter: (item) => { formatter: (row) => {
return this.DATEFORMATE(item.updatedDate, 'YYYY-MM-DD HH:mm:ss') return this.DATEFORMATE(row.updatedDate, 'YYYY-MM-DD HH:mm:ss')
} }
}] }]
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!