relateStoreDialog.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!-- 关联门店弹窗 -->
<template>
<d2-dialog
title="关联门店"
:isVisible.sync="relateStoreVisible"
width="70%"
btnOkLabel="关联"
@closeDialog="handleRelateStoreClose"
class="relateStore"
>
<el-row>
<el-col :span="12">
<el-table
ref="seletingTable"
:data="selectingData"
height="500px"
class="table"
border
@select="handleChange"
@select-all="handleAll"
>
<el-table-column
type="selection"
width="55"
align="center"
></el-table-column>
<el-table-column
prop="confValue"
label="门店名称"
></el-table-column>
</el-table>
<el-pagination
small
background
@current-change="handleCurrentChange"
:current-page.sync="currentPage"
:page-size="10"
layout="total, prev, pager, next"
:total="total"
></el-pagination>
</el-col>
<el-col :span="12">
<el-table
:data="selectedData"
class="table"
border
height="500px"
>
<el-table-column
prop="confValue"
label="门店名称"
></el-table-column>
</el-table>
</el-col>
</el-row>
</d2-dialog>
</template>
<script>
export default {
name: 'relateStoreDialog',
data() {
return {
selectedData: [],
selectingData: [{
confId: 1,
confValue: '广州上策贸易有限公司'
}, {
confId: 2,
confValue: '广州上策贸易有限公司2'
}, {
confId: 3,
confValue: '广州上策贸易有限公司3'
}, {
confId: 4,
confValue: '广州上策贸易有限公司4'
}],
// 分页
total: 100,
currentPage: 1
}
},
props: {
relateStoreVisible: {
type: Boolean,
default: false
}
},
mounted() { },
methods: {
handleChange(selection, row) {
var addOrDelete = !!selection.find(item => item.confId === row.confId)
addOrDelete
? this.selectedData.push(row)
: (this.selectedData = this.selectedData.filter(item => item.confId !== row.confId))
},
handleAll(selection) {
this.selectingData.forEach(item => {
var isExit = this.selectedData.findIndex(subItem => subItem.confId === item.confId)
if (selection.length && (isExit === -1)) {
this.selectedData.push(item)
} else if (!selection.length && (isExit !== -1)) {
this.selectedData.splice(isExit, 1)
}
})
},
handleCurrentChange(val) {
this.currentPage = val
console.log(this.currentPage)
// 调接口
},
handleRelateStoreClose() {
this.$emit('handleRelateStoreClose')
}
}
}
</script>
<style>
.relateStore .table {
margin: 0 auto 20px !important;
width: 98%;
}
.relateStore .el-table .cell {
line-height: 20px !important;
}
.relateStore .el-table .cell {
padding: 0 8px !important;
}
</style>