index.vue
12.7 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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
<template>
<div class="equity-wrap">
<el-button fn="开通配置" class="addGood" type="primary" icon="el-icon-plus" @click="jump('add')">开通配置</el-button>
<!-- <el-button fn="开通配置" class="addGood" type="primary" icon="el-icon-plus" @click="jump('add')">开通配置</el-button> -->
<div class="equity-wrap contain merchant-select">
<GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchForm" :searchSelectObj="searchSelectObj" :formData="searchFormData" @handleOk="selConfig" @handleRest="selConfig('reset')"></GLCombiForm>
<div class="row-btns">
<!-- <el-button size="small" @click="toggleAll">全选</el-button> -->
<!-- <el-checkbox v-model="checkbox" @change="toggleAll" style="margin-left:20px">全选</el-checkbox> -->
<div style="float: right" class="primary_plain_btn">
<el-button size="small" plain @click="batchOpenSale()">批量开通驻店零售</el-button>
<el-button size="small" plain @click="batchOperation(1)">批量开通</el-button>
<el-button size="small" @click="batchOperation(2)">批量关闭</el-button>
<el-button size="small" @click="exportTable">导出</el-button>
</div>
</div>
<GLTable v-if="flag" ref="table" :searchForm="searchForm" :tableParams="tableParams" :pageConf="pageConf" :getListApi="getConfigList" :beforeSearchFn="check">
<span slot="operate" slot-scope="scope">
<el-button fn="修改配置" type="text" @click="jump(scope.scope.merchantId)">修改配置</el-button>
<!-- <el-button fn="修改配置" type="text" @click="jump(scope.scope.merchantId)">修改配置</el-button> -->
</span>
<span slot="openFlag" slot-scope="scope">
<el-switch :value="scope.scope.openFlag == 1" active-color="#2A58AD" inactive-color="#eee" @change="changStatus(scope.scope.openFlag, scope.scope.id)"></el-switch>
</span>
</GLTable>
</div>
</div>
</template>
<script type="text/ecmascript-6">
function date_format(date) {
var date2 = new Date(date)
var YY = date2.getFullYear() + '-'
var MM = (date2.getMonth() + 1 < 10 ? '0' + (date2.getMonth() + 1) : date2.getMonth() + 1) + '-'
var DD = date2.getDate() < 10 ? '0' + date2.getDate() : date2.getDate()
var hh = (date2.getHours() < 10 ? '0' + date2.getHours() : date2.getHours()) + ':'
var mm = (date2.getMinutes() < 10 ? '0' + date2.getMinutes() : date2.getMinutes()) + ':'
var ss = date2.getSeconds() < 10 ? '0' + date2.getSeconds() : date2.getSeconds()
return YY + MM + DD + ' ' + hh + mm + ss
}
import utils from '../../util/util'
// import { searchMixin } from '@/mixins'
export default {
name: '',
// mixins: [searchMixin],
data() {
return {
showTableOperate: false,
showGh: true,
checkbox: false,
date_format,
openFlag: '',
getConfigList: this.$apis.openconfig.getConfigList,
select: '1',
selectInput: '',
size: 'small',
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
flag: true,
searchForm: {
openFlag: ''
},
searchSelectObj: {
idOrName: {
attr: 'merchantName',
value: ''
}
},
searchFormData: [
{
type: 'selectInput',
selectName: 'idOrName',
isClear: true,
inputWidth: '325px',
selectWidth: '110px',
selectOption: [
{
label: '商户名称',
name: 'merchantName'
},
{
label: '商户号',
name: 'merchantId'
}
],
handleSelectChange: value => {
this.searchSelectObj.idOrName.value = ''
}
},
{
label: '开通状态',
name: 'openFlag',
type: 'select',
optionList: [
{
label: '全部',
value: ''
},
{
label: '未开通',
value: '0'
},
{
label: '已开通',
value: '1'
}
],
optionId: 'value',
optionLabel: 'label'
}
],
openFlagList: [
{
label: '全部',
value: ''
},
{
label: '未开通',
value: '0'
},
{
label: '已开通',
value: '1'
}
],
statusList: [
{
label: '上架',
value: '1'
},
{
label: '下架',
value: '2'
},
{
label: '待上架',
value: '0'
}
],
tableParams: {
listName: 'list',
mutiSelectName: 'configIndex',
mutiSelectUniqueKey: 'id',
tableOption: false,
tableColumns: [
{
label: '商户名称',
prop: 'merchantName'
},
{
label: '商户号',
prop: 'merchantId'
},
{
label: '销售模式',
prop: 'saleMode',
formatter: cell => {
return cell.saleMode == 1 ? '批发销售' : '驻店零售'
}
},
{
label: '状态',
prop: 'openFlag',
formatter: cell => {
return cell.openFlag == 0 ? '未开通' : '已开通'
}
},
{
prop: 'createdDate',
label: '开通时间',
formatter: cellValue => {
return this.date_format(cellValue.createdDate)
},
width: 170
},
{
label: '操作人',
prop: 'updatedBy'
},
{
label: '操作',
addHtml: 'operate'
},
{
label: '开通开关',
addHtml: 'openFlag',
width: 100,
formatter: cellValue => {
if (cellValue.openFlag == '1') {
return true
} else {
return false
}
}
}
]
},
goodsBrandList: [],
selectStatus: false
}
},
mounted() {},
created() {
this.diffHost()
},
methods: {
// 区分滴加和广汇
diffHost() {
let href = window.location.host
// 从域名判断是不是广汇的
let gxurl1 = 'http://scrm.cgacar.com'
let gxurl2 = 'https://scrm.cgacar.com'
if (href == gxurl1 || href == gxurl2) {
this.showGh = true
} else {
this.showGh = false
}
},
check() {
return new Promise((resolve, reject) => {
var reg = /^[+]{0,1}(\d+)$/g
if (this.selectInput) {
if (this.select == 2) {
if (!reg.test(this.selectInput)) {
this.$message.error('请输入正整数')
reject()
}
}
}
resolve()
})
},
jump(e) {
if (e == 'add') {
this.$router.push({ path: '/config/addConfig', query: { $title: encodeURI('开通配置') } })
} else {
let query = { $title: encodeURI('修改配置') }
query.merchantId = e
console.log(query, 'query')
this.$router.push({ path: '/config/addConfig', query })
}
},
toggleAll() {
let { configIndexMutiTable } = this.$refs.table.$refs
let { data } = configIndexMutiTable
this.selectStatus = !this.selectStatus
data.map(row => {
configIndexMutiTable.toggleRowSelection(row, this.selectStatus)
})
},
selConfig(e) {
this.searchForm = {
openFlag: this.searchForm.openFlag
}
if (e == 'reset') {
this.searchForm = {
openFlag: ''
}
this.searchSelectObj = {
idOrName: {
attr: 'merchantName',
value: ''
}
}
}
this.searchForm[this.searchSelectObj.idOrName.attr] = this.searchSelectObj.idOrName.value
this.$refs.table.refreshTable()
},
batchOpenSale() {
const data = this.$refs.table?.mutiSelectArr?.[this.tableParams.mutiSelectName] || []
if (!data?.length) return this.$message.error('请选择需要开通的商户')
this.$confirm('确定批量开通驻店零售吗', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
const ids = data.map(item => item.id)
this.$apis.openconfig.batchOpenSaleModeApi({ ids, saleMode: 2 }).then(res => {
if (res) {
this.$message.success('操作成功')
this.$refs.table.refreshTable()
}
})
}
}
})
},
// ['开通', '关闭'] //
batchOperation(status) {
let { configIndexMutiTable } = this.$refs.table.$refs
let { selection } = configIndexMutiTable
if (!selection.length) return
let ids = []
try {
selection.map(e => {
if (status == 1) {
if (e.openFlag == 1) throw '仅能开通未开通的配置'
} else if (status == 2) {
if (e.openFlag != 1) throw '仅能关闭开通的配置'
}
ids.push(e.id)
})
} catch (error) {
this.$message.error(error)
return
}
let content = {
1: '是否批量开通',
2: '是否批量关闭'
}
this.$confirm(content[status], '提示', {
confirmButtonText: '是',
cancelButtonText: '否',
type: 'warning'
})
.then(() => {
let target = 'openConfigs'
if (status != 1) {
target = 'closeConfigs'
}
let params = { ids }
console.log(this.$apis.openconfig)
this.$apis.openconfig[target](params).then(({ code, message }) => {
if (code == 0) {
this.$message({
message: '操作成功!',
type: 'success'
})
this.$refs.table.refreshTable()
} else {
this.$message.error(message)
}
})
})
.catch(() => {})
},
exportTable() {
let params = {
merchantId: this.searchForm.merchantId,
merchantName: this.searchForm.merchantName,
pageSize: this.$refs.table.page.pageSize,
pageNum: this.$refs.table.page.pageNum
}
if (this.select == 1) {
this.searchForm.merchantName = this.selectInput
this.searchForm.merchantId = ''
} else {
this.searchForm.merchantId = this.selectInput
this.searchForm.merchantName = ''
}
if (this.openFlag < 2) {
params.openFlag = this.openFlag
}
this.$apis.openconfig.exportConfig(params).then(res => {
// window.open(res)
let tempaa = utils.getExplorer()
if (tempaa == 'QQ') {
window.open(res)
} else {
let iframe = document.createElement('iframe')
iframe.style.display = 'none'
iframe.src = res
document.body.appendChild(iframe)
}
})
},
changStatus(openFlag, id) {
let ids = []
ids.push(id)
let target = 'openConfigs'
if (openFlag == 1) {
target = 'closeConfigs'
}
let params = { ids }
this.$apis.openconfig[target](params).then(({ code, message }) => {
if (code == 0) {
this.$message({
message: '操作成功!',
type: 'success'
})
this.$refs.table.refreshTable()
} else {
this.$message.error(message)
}
})
}
}
}
</script>
<style lang="scss" scoped>
.equity-wrap {
}
.addGood {
margin-bottom: 10px;
padding: 8px 16px;
// margin-bottom: 20px;
}
.merchant-select {
margin-bottom: 10px !important;
}
/deep/ .equity-wrap {
.el-button + .el-button {
margin-left: 8px;
}
.el-form--inline .el-form-item {
margin-bottom: 0;
}
.open-status {
.el-input__inner {
width: 215px;
color: #999;
}
.el-form-item__label {
color: #333333;
display: inline;
padding-right: 15px;
}
}
.el-input-group--prepend .el-select .el-input__inner,
.el-input-group__append {
width: 120px;
color: #333333;
}
.el-input-group--prepend .el-input__inner,
.el-input-group__append:last-child {
width: 166px;
color: #999;
}
.row-btns .el-checkbox__label {
color: #333;
padding-left: 8px;
}
.el-pagination {
margin-top: 20px;
}
}
.row-btns {
height: 32px;
line-height: 32px;
margin-bottom: 10px;
}
.fr-mr0 {
float: right;
margin-right: 0px !important;
}
/deep/ .el-input-group__prepend {
background-color: #fff;
}
</style>