175 lines
4.1 KiB
Java
175 lines
4.1 KiB
Java
<template>
|
|
<div style="height: 100%">
|
|
<div class="box">
|
|
<a-table
|
|
class="table"
|
|
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
|
|
:columns="columns"
|
|
:pagination="false"
|
|
:scroll="{x: 1600}"
|
|
:data-source="dataSource"
|
|
:loading="loading"
|
|
>
|
|
<span slot="operation" slot-scope="record">
|
|
<a class="text" v-for="(ol,index) in OperationList"
|
|
@click="OperationClick(ol,record)">{{ol.text}}</a>
|
|
</span>
|
|
</a-table>
|
|
</div>
|
|
<div class="page" v-if="dataSource.length > 0">
|
|
<a-pagination
|
|
:show-total="total => `共 ${total} 条`"
|
|
show-quick-jumper
|
|
show-size-changer
|
|
:page-size.sync="pageSize"
|
|
:total="total"
|
|
@change="onChange"
|
|
@showSizeChange="SizeChange"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import eventBUs from '../../common/event'
|
|
import { getAction, postAction } from '@/api/manage'
|
|
|
|
export default {
|
|
name: 'index',
|
|
props: {
|
|
//接口
|
|
url: {
|
|
type: Object,
|
|
default: {}
|
|
},
|
|
// 操作按钮
|
|
OperationList: {
|
|
type: Array,
|
|
default: []
|
|
},
|
|
flag: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
//是否显示操作;默认不显示
|
|
showAction: {
|
|
type: Boolean,
|
|
default: false
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
jsonBody: [],
|
|
checkboxList: [],
|
|
tableAll: false,
|
|
indeterminate: false,
|
|
columns: [],
|
|
selectedRowKeys: [],
|
|
dataSource: [],
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
total: 0,
|
|
searchParmes: {},
|
|
loading: false
|
|
}
|
|
},
|
|
mounted() {
|
|
eventBUs.$on('searchQuery', search => {
|
|
this.searchParmes = search
|
|
this.getTableList(search)
|
|
})
|
|
eventBUs.$on('searchReset', target => {
|
|
this.searchParmes = {}
|
|
this.getTableList()
|
|
})
|
|
this.getData()
|
|
this.getTableList()
|
|
},
|
|
methods: {
|
|
getData() {
|
|
let params = {
|
|
flag: this.flag
|
|
}
|
|
getAction(this.url.tableHeader, params).then((res) => {
|
|
if (res.success) {
|
|
var jsonHead = res.result
|
|
jsonHead.forEach(res => {
|
|
this.columns.push({
|
|
title: res.db_field_txt,
|
|
dataIndex: res.db_field_name,
|
|
align: 'center',
|
|
ellipsis: true
|
|
})
|
|
})
|
|
let width
|
|
if (this.OperationList.length > 0) {
|
|
width = this.OperationList.length * 55
|
|
}
|
|
if (this.showAction) {
|
|
this.columns.push({
|
|
title: '操作',
|
|
align: 'center',
|
|
fixed: 'right',
|
|
width: width,
|
|
scopedSlots: { customRender: 'operation' }
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
getTableList() {
|
|
let pageNo = JSON.parse(JSON.stringify(this.pageNo))
|
|
let pageSize = JSON.parse(JSON.stringify(this.pageSize))
|
|
let params = {
|
|
...this.searchParmes,
|
|
pageNo: pageNo + '',
|
|
pageSize: pageSize + ''
|
|
}
|
|
this.loading = true
|
|
postAction(this.url.tableList, params).then((res) => {
|
|
if (res.success) {
|
|
this.dataSource = res.result.records
|
|
this.total = res.result.total
|
|
this.loading = false
|
|
}
|
|
})
|
|
},
|
|
onChange(page, pageSize) {
|
|
this.pageNo = page
|
|
this.getTableList()
|
|
},
|
|
SizeChange(page, pageSize) {
|
|
this.pageSize = pageSize
|
|
this.getTableList()
|
|
},
|
|
onSelectChange() {
|
|
|
|
},
|
|
OperationClick(ol, item) {
|
|
this.$emit(ol.ClickEvent, item)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style>
|
|
.table .ant-table-column-title {
|
|
font-weight: bold;
|
|
}
|
|
</style>
|
|
<style scoped>
|
|
.box {
|
|
width: 100%;
|
|
height: calc(100% - 100px);
|
|
overflow: auto;
|
|
}
|
|
|
|
.text {
|
|
margin-right: 16px;
|
|
}
|
|
|
|
.page {
|
|
text-align: right;
|
|
margin-top: 20px;
|
|
}
|
|
</style>
|