index.vue
4.73 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<template>
<div class="square-main">
<GLDialog title="选择渠道" :visible.sync="dialogVisible" @onOk="handleSelect" @onCancel="handleCancel" mode="big">
<div class="square-tabel">
<div class="square-tabel-select">
<GLTable ref="table" :hasPage="false" :tableData="tableData" :tableTotal="tableTotal" :tableParams="tableParams" @refreshTable="handleSearch" @selectionTable="selectionTable"></GLTable>
</div>
<div class="square-tabel-selected">
<div class="selected-title">已选渠道</div>
<div class="selected-panel">
<div class="selected-item" v-for="(item, index) in selectedList" :key="index">
<div :title="item.codeName">
<span :style="{ background: colorList[index] }"></span>
{{ item.codeName }}
</div>
<img src="@/assets/img/channel/del.png" @click="delTag(item)" />
</div>
</div>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="handleCancel">取 消</el-button>
<el-button size="small" type="primary" @click="handleSelect">确 定</el-button>
</span>
</GLDialog>
</div>
</template>
<script>
import { utils } from 'glsx-common'
export default {
name: 'selectEmp',
data() {
return {
dialogVisible: false,
tableSearchForm: {},
tableParams: {
listName: 'data',
tableOption: false,
// 行数据的key
mutiSelectUniqueKey: 'id',
// 多选ref的名称
mutiSelectName: 'salelist',
tableColumns: [
{
label: '渠道名称',
prop: 'codeName'
},
{
label: '备注',
prop: 'codeRemark'
}
]
},
tableData: [],
tableTotal: 0,
selectItem: [],
selectCode: [],
selectedList: []
}
},
props: {
colorList: {
type: Array
}
},
methods: {
getFollower() {
var params = {
pageSize: 1000,
pageNum: 1
}
this.$apis.channel.listChannelCodeByPage(params).then(res => {
console.log(res)
this.tableData = res.data
this.tableTotal = res.count
this.tableData.forEach(item => {
this.selectCode.forEach((itm, index) => {
if (itm.codeState == item.codeState) {
this.$refs.table.$refs.salelistMutiTable.toggleRowSelection(item)
}
})
})
})
},
init(codeId) {
this.selectCode = JSON.parse(JSON.stringify(codeId))
this.selectedList = []
this.dialogVisible = true
this.$nextTick(() => {
this.getFollower()
})
},
handleSearch() {
this.getFollower()
},
selectionTable(val) {
this.selectedList = val
},
delTag(item) {
this.$refs.table.$refs.salelistMutiTable.toggleRowSelection(item)
},
handleCancel() {
this.dialogVisible = false
this.$refs.table.$refs.salelistMutiTable.clearSelection()
},
handleSelect: utils.debounce(function() {
if (this.selectedList.length == 0) {
this.$message.error('请选择渠道')
return
}
if (this.selectedList.length > 8) {
this.$message.error('最多选择8个渠道数据')
return
}
this.dialogVisible = false
this.$emit('selectTable', this.selectedList)
this.$refs.table.$refs.salelistMutiTable.clearSelection()
}, 300)
}
}
</script>
<style lang="scss" scoped>
.square-main {
.square-tabel {
display: flex;
&-select {
flex: 1;
}
&-selected {
width: 320px;
margin-left: 20px;
.selected-title {
background: #f4f6fc;
color: #333333;
line-height: 20px;
padding: 16px 20px;
font-weight: 600;
}
.selected-panel {
padding: 0px 20px;
.selected-item {
font-size: 14px;
font-weight: 400;
color: #333333;
line-height: 30px;
display: flex;
align-items: center;
justify-content: space-between;
div {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
span {
vertical-align: middle;
display: inline-block;
width: 12px;
height: 2px;
margin-right: 10px;
}
img {
width: 16px;
height: 16px;
cursor: pointer;
}
}
}
}
}
/deep/ {
.el-table {
height: 50vh;
overflow-y: auto;
}
.el-table::before {
left: 0;
bottom: 0;
width: 100%;
height: 0px;
}
}
}
</style>