childTable.vue
3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<template>
<div v-if="isShow" class="childTable manage-content">
<el-table :data="tableData" :max-height="tableHeight" v-loading='isLoading' style="width: 100%" header-row-class-name="manage-tab-head">
<el-table-column prop="tabOrder" align="center" :label="$t('table.order')" width="100"></el-table-column>
<el-table-column prop="name" align="center" label="业态名称"></el-table-column>
<el-table-column prop="intro" align="center" label="简介"></el-table-column>
<el-table-column :label="$t('table.operate')" align="center" width="180">
<template slot-scope="scope">
<el-button @click="editRow(scope.row)" type="text" size="small" class="tab-btn">{{$t('button.edit')}}
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination class="manage-pagination" background :current-page="currentPage" :page-sizes="[10, 20, 50, 100]"
:page-size="pageSize" @size-change="sizeChange" @current-change="currentChange"
layout="sizes, prev, pager, next, slot" :total="total">
<span class="slot-ele-total">{{$t('table.pageHead')}} {{ total }} {{$t('table.pageTail')}}</span>
</el-pagination>
<add-dialog ref="addRef"></add-dialog>
</div>
</template>
<script>
import addDialog from "./add";
export default {
components: {
"add-dialog": addDialog
},
data() {
return {
tableData: [],
total: 0,
pageSize: 10,
currentPage: 1,
isShow:false,
isLoading:''
};
},
computed: {
tableHeight() {
const windowInnerHeight = window.innerHeight;
return windowInnerHeight - windowInnerHeight * 0.24;
}
},
methods: {
dialogInit(parmas) {
this.getTableData(parmas.id)
},
getTableData( pid) {
this.isLoading = true
this.tableData = [];
this.isShow = true
let tabelParams = {
pageNum: this.currentPage,
pageSize: this.pageSize,
pid: pid ? pid : '-1',
};
this.$api.management.getFormatList(tabelParams)
.then(data => {
setTimeout(()=>{
this.isLoading = false
},100)
const result = data.data;
result.data.list.forEach((item, index) => {
item.tabOrder = (this.currentPage - 1) * this.pageSize + index + 1
})
this.tableData = result.data.list;
this.total = result.data.total
})
},
// 切换每页
sizeChange(val) {
this.pageSize = val;
this.currentPage = 1
this.getTableData()
},
// 切换分页
currentChange(val) {
this.currentPage = val;
this.getTableData()
},
//点击编辑弹框
editRow(row) {
let str = JSON.parse(JSON.stringify(row));
this.$refs.addRef.dialogInit('edit', str,'child');
},
}
};
</script>
<style scoped>
.childTable{
margin-top: 81px;
}
.manage-pagination{
position: absolute;
right: 15px;
margin-top: 15px
}
</style>