indexOfGh.vue
12.1 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
<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">
<el-form :inline="true" style="width: 100%" :model="searchForm" label-width="85px" label-position="right">
<el-row>
<el-form-item size="small" label="">
<el-input placeholder="请输入内容" v-model="selectInput" class="input-with-select">
<el-select v-model="select" slot="prepend" placeholder="请选择">
<el-option label="商户名称" value="1"></el-option>
<el-option label="商户号" value="2"></el-option>
</el-select>
</el-input>
</el-form-item>
<el-form-item class="open-status" size="small" label="开通状态" style="margin-left: -10px">
<el-select size="small" v-model="openFlag">
<el-option v-for="item in openFlagList" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item size="small" class="fr-mr0">
<el-button size="small" @click="selConfig('reset')">重置</el-button>
<el-button size="small" type="primary" @click="selConfig">查询</el-button>
<el-button size="small" @click="exportTable">导出</el-button>
</el-form-item>
</el-row>
</el-form>
<div class="row-btns" style="margin-top: 20px">
<!-- <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">
<el-button size="small" @click="batchOperation(1)">批量开通</el-button>
<el-button size="small" @click="batchOperation(2)">批量关闭</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: {
merchantId: '',
merchantName: ''
},
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: 'openFlag',
formatter: cell => {
return cell.openFlag == 0 ? '未开通' : '已开通'
}
},
{
prop: 'createdDate',
label: '开通时间',
formatter: cellValue => {
return this.date_format(cellValue.createdDate)
}
},
{
label: '操作人',
prop: 'updatedBy'
},
{
label: '操作',
minWidth: '200',
addHtml: 'operate'
},
{
label: '开通开关',
addHtml: 'openFlag',
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/addConfigOfGh', query: { $title: encodeURI('开通配置') } })
} else {
let query = { $title: encodeURI('修改配置') }
query.merchantId = e
console.log(query, 'query')
this.$router.push({ path: '/config/addConfigOfGh', 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) {
if (this.select == 1) {
this.searchForm.merchantName = this.selectInput
this.searchForm.merchantId = ''
} else {
this.searchForm.merchantId = this.selectInput
this.searchForm.merchantName = ''
}
if (e == 'reset') {
this.openFlag = '全部'
this.searchForm = {}
this.selectInput = ''
this.$refs.table.refreshTable()
} else {
if (this.openFlag < 2) {
this.searchForm.openFlag = this.openFlag
this.$refs.table.refreshTable()
} else {
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',
center: true
})
.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 {
padding-right: 20px;
}
.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: 20px;
}
.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;
}
.el-form-item__content .el-button--small:first-child,
.row-btns > div .el-button--small:first-child {
border-color: #2a58ad;
color: #2a58ad;
}
.el-form-item__content .el-button--small:last-child,
.row-btns > div .el-button--small:last-child {
border-color: #999;
color: #666666;
}
.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>