merchantChoose.vue
12 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
<!-- 关联门店弹窗 -->
<template>
<div class="tableBox">
<span>
<!-- <el-tag>{{showData[sourcePage].title}}</el-tag> -->
<p class="edit-title"
style="textAlign:center">
{{ showData[sourcePage].title }}
<el-button type="text"
style="paddingLeft:20px"
v-if="sourcePage == 'serviceStore'"
@click="resetCheck">重新选择</el-button>
</p>
</span>
<div class="checkSpan">
<p v-for="item in selectedDataShow">已选:<span
style="paddingRight:20px">{{ item.merchantName }}</span><span>{{
item.merchantId }}</span>
</p>
</div>
<div style="padding: 10px 50px;">
<el-input v-model="merchantIdName"
placeholder="搜索门店内容"
maxlength="20"
style="width:300px;paddingRight:20px" />
<el-button size="small"
type="primary"
@click="searchList">
查询
</el-button>
</div>
<el-table :ref="seletingTable"
:data="selectingData"
height="464px"
class="table"
border
@select="selectFn"
@select-all="handleAll"
:header-cell-class-name="cellClass">
<!-- :selectable="selectable" -->
<el-table-column type="selection"
width="55"
align="center" />
<el-table-column prop="merchantName"
align="center">
<template slot-scope="scope">
<span
style="paddingRight:20px">{{ scope.row.merchantName }}</span><span>{{ scope.row.merchantNo }}</span>
</template>
</el-table-column>
</el-table>
<el-pagination v-if="sourcePage == '4sStore'"
small
background
@current-change="handleCurrentChange"
:current-page.sync="currentPage"
:page-size="pageSize"
layout="total, prev, pager, next"
:total="total" />
</div>
</template>
<script>
import { deepClone } from '@/common/util'
export default {
name: 'MerchantChoose',
data() {
return {
showData: {
'4sStore': {
title: '4S店列表',
selectMethod: 'Single'
},
yqStore: {
title: '园区店列表',
selectMethod: 'Single'
},
serviceStore: {
title: '服务商列表',
selectMethod: 'Multiple'
}
},
seletingTable: this.sourcePage + 'SeletingTable',
merchantIdName: '',
selectedData: [],
selectedDataShow: [],
selectingData: [],
needTip: ['editProduct'],
// 分页
total: 0,
currentPage: 1,
pageSize: 20,
baseData: {
RefStoreList: []
}
// selectioned: '',//单选中的值
}
},
props: {
relateStoreVisible: {
type: Boolean,
default: false
},
// 页面来源
sourcePage: {
type: String,
default: ''
},
storeApi: {
type: Function,
default: () => { }
},
selectedRecord: {
type: Array,
default: () => []
},
storeSearchForm: {
type: Object,
default: () => { }
}
},
watch: {
selectedRecord(val) {
// console.log('selectedRecord_1', val);
this.selectedData = []
this.selectedDataShow = []
this.$refs[this.seletingTable].clearSelection()
if (val.length > 0) {
this.selectedDataShow = deepClone(val)
this.selectingData.forEach(d => {
this.selectedRecord.forEach(item => {
if (d.merchantNo == item.merchantId) {
d.ruleFlag = item.ruleFlag
this.selectedData.push(d)
this.$refs[this.seletingTable].toggleRowSelection(d, true)
}
})
})
}
// console.log('this.selectedData_1', this.selectedData)
this.$emit('chooseData', this.selectedData)
},
selectingData(val) {
// console.log('watch selectingData', val);
// console.log('watch selectingData this.selectedData', this.selectedData);
if (val.length > 0 && this.selectedData.length > 0) {
val.forEach(d => {
this.selectedData.forEach(item => {
if (d.merchantNo == item.merchantNo) {
d.ruleFlag = item.ruleFlag
this.$nextTick(_ => {
this.$refs[this.seletingTable].toggleRowSelection(d, true)
})
}
})
})
}
}
},
mounted() {
this.getSelectingList()
},
methods: {
cellClass(row) {
// if (this.showData[this.sourcePage].selectMethod == 'Single') { // 单选时隐藏全选按钮
if (row.columnIndex === 0) {
return 'disabledCheck'
}
// }
},
selectFn(selection, row) {
if (this.showData[this.sourcePage].selectMethod == 'Single') {
this.dialogCheck(selection, row)
} else {
this.handleChange(selection, row)
}
},
dialogCheck: function (selection, row) {
this.$refs[this.seletingTable].clearSelection()
this.selectedData = []
this.selectedDataShow = []
if (row) {
this.$refs[this.seletingTable].toggleRowSelection(row, true)
this.selectedDataShow.push({ merchantName: row.merchantName, merchantId: row.merchantNo })
this.selectedData.push(row)
}
this.$emit('chooseData', this.selectedData)
},
// selectable(row, index) {
// if (row.isDisable) {
// return false
// }
// return true
// },
getSelectingList() {
// console.log('this.selectedRecord_2', this.selectedRecord);
// console.log('this.selectedData_2', this.selectedData);
const params = {
currentPage: this.currentPage,
pageSize: this.pageSize,
merchantIdName: this.merchantIdName
}
if (this.sourcePage != '4sStore') { // 只有4s点列表需要分页
params.currentPage = 1
params.pageSize = 100000
}
this.storeApi(params).then(res => {
this.selectingData = res.list
this.total = res.total
// if (this.selectingData.length > 0) {
// this.$refs[this.seletingTable].clearSelection()
// this.selectingData.forEach(d => {
// this.selectedData.forEach(item => {
// if (d.merchantNo == item.merchantNo) {
// console.log('d.merchantNo', d.merchantNo);
// console.log('item.merchantNo', item.merchantNo);
// this.$nextTick(_ => {
// this.$refs[this.seletingTable].toggleRowSelection(d, true)
// })
// }
// })
// })
// }
})
},
searchList() {
this.getSelectingList()
},
handleChange(selection, row) {
// console.log('handleChange');
// console.log('selection', selection);
// console.log('row', row);
// console.log('JSON.stringify(selection).indexOf(JSON.stringify(row)) == -1', JSON.stringify(selection).indexOf(JSON.stringify(row)) == -1);
if (this.sourcePage == 'serviceStore') { // 服务商
if (JSON.stringify(selection).indexOf(JSON.stringify(row)) == -1) { // 判断是否取消选中
// 如果是取消,则判断是否存在财务规则
const showIndex = this.selectedDataShow.findIndex(item => (item.merchantId == row.merchantNo))
const dataIndex = this.selectedData.findIndex(item => (item.merchantNo == row.merchantNo))
let showHtml = ''
switch (row.ruleFlag) {
case 1:
showHtml = '该商户配置有财务规则,取消关联会重置财务配置;被修改的关联关系保存后,系统自动重置对应4s在对应场景的财务规则'
break
case 2:
showHtml = '该商户配置有对账规则,取消关联会重置对账配置;被修改的关联关系保存后,系统自动重置对应4s在对应场景的对账规则'
break
case 3:
showHtml = '该商户配置有财务规则和对账规则,取消关联会重置财务配置和对账配置;被修改的关联关系保存后,系统自动重置对应4s在对应场景的财务规则和对账规则'
break
default:
showHtml = ''
}
if (row.ruleFlag == 1 || row.ruleFlag == 2 || row.ruleFlag == 3) {
this.$confirm(showHtml, '提示', {
confirmButtonText: '确定',
showCancelButton: true,
type: 'warning'
}).then(() => {
this.selectedDataShow.splice(showIndex, 1)
this.selectedData.splice(dataIndex, 1)
}).catch(err => {
this.$refs[this.seletingTable].toggleRowSelection(row, true)
})
} else {
this.selectedDataShow.splice(showIndex, 1)
this.selectedData.splice(dataIndex, 1)
}
} else {
// 新增则添加
this.selectedDataShow.push({ merchantName: row.merchantName, merchantId: row.merchantNo })
this.selectedData.push(row)
}
}
if (this.selectedRecord.length == 0) {
this.$emit('chooseData', this.selectedData)
}
},
handleAll(selection) {
this.selectedData = selection
this.selectedDataShow = selection
this.$emit('chooseData', selection)
},
handleCurrentChange(val) {
this.currentPage = val
this.getSelectingList()
},
handleRelateStoreConfirm() {
this.$emit('handleRelateStoreConfirm', this.selectedData)
},
handleRelateStoreClose() {
this.$emit('handleRelateStoreClose')
},
resetCheck() {
const allCheck = this.$refs[this.seletingTable].selection
const flag = allCheck.some((item) => {
return item.ruleFlag == 1 || item.ruleFlag == 2 || item.ruleFlag == 3
})
if (flag) {
this.$confirm('选择的商户中配置有财务规则或对账规则,取消关联会重置财务配置或对账配置', '提示', {
confirmButtonText: '确定',
showCancelButton: true,
type: 'warning'
}).then(() => {
this.$refs[this.seletingTable].clearSelection()
this.selectedData = []
this.selectedDataShow = []
this.$emit('chooseData', this.selectedData)
}).catch(err => {
console.log(err)
})
} else {
this.$refs[this.seletingTable].clearSelection()
this.selectedData = []
this.selectedDataShow = []
this.$emit('chooseData', this.selectedData)
}
},
clearSelect() {
const checkItem = this.$refs[this.seletingTable].selection
if (checkItem && checkItem.length > 0) {
this.$refs[this.seletingTable].clearSelection()
}
this.selectedData = []
this.selectedDataShow = []
}
}
}
</script>
<style lang="scss" scoped>
.relateStore .table {
margin: 0 auto 20px !important;
width: 98%;
}
.relateStore .tableCon {
display: flex;
.tableBox {
flex: 1;
}
}
.service-store .relateStore .el-table .cell,
.d2-form .relateStore .el-table .cell {
line-height: 26px !important;
}
.service-store .relateStore .el-table--medium td,
.d2-form .relateStore .el-table--medium td {
padding: 6px 8px !important;
}
.relateStore .red {
color: red;
}
.relateStore .tip-icon {
position: absolute;
display: inline-block;
height: 10px;
width: 10px;
line-height: 10px;
color: #ffffff;
background-color: red;
border: 1px solid red;
border-radius: 50%;
cursor: pointer;
font-size: 6px;
margin-left: 2px;
}
//去掉表头多选框
// ::v-deep .el-table__header-wrapper .el-checkbox {
// display: none;
// }
// 深度选择器 去掉全选按钮
::v-deep .el-table .disabledCheck .cell .el-checkbox__inner {
display: none;
}
::v-deep .el-table .disabledCheck .cell::before {
content: "";
text-align: center;
line-height: 37px;
}
.checkSpan {
max-height: 120px;
overflow: scroll;
}
</style>