CreateServiceDialog.vue
14.4 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
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
<!-- 下载对账单 -->
<template>
<d2-dialog title="生成服务商对账单" :is-visible="accountVisible" class="accountDailog" width="688px" @closeDialog="handleClose" @confirmDialog="handleSystemBill">
<!-- <el-button v-if="isTmpl" slot="btn-start" type="primary" @click="handleSystemBill">系统对账</el-button> -->
<el-form ref="accountForm" :model="infoForm" :rules="formRules" label-width="120px" v-loading="loading">
<el-form-item label="对账商户:" prop="merchant">
<el-select v-model="infoForm.merchant" multiple :multiple-limit="multipleLimit" filterable style="width:400px">
<el-option v-for="item in baseData.merchantList" :key="item.merchantId" :label="item.merchantName" :value="item.merchantId" />
</el-select>
</el-form-item>
<el-form-item label="对账模版:" prop="templateId">
<el-select v-model="infoForm.templateId" style="width:400px" @change="handleTmplChange">
<el-option v-for="item in baseData[merchantTypeStr + 'TemplateList']" :key="item.id" :label="item.templateName" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="对账字段:" prop="fieldsJson">
<div class="tmpl-box">
<el-tooltip v-show="infoForm.fieldsTxt" effect="dark" placement="top" :content="infoForm.fieldsTxt">
<span class="fields-txt">{{infoForm.fieldsTxt}}</span>
</el-tooltip>
<div v-show="tmplSelectList.length">共{{tmplSelectList.length}}个字段</div>
<el-button v-if="infoForm.templateId" type="text" @click="handleCustTmpl" style="margin-left: 8px;">自定义</el-button>
</div>
</el-form-item>
</el-form>
</d2-dialog>
</template>
<script>
// import {
// rangePickerOptions
// } from '@/common/constants.js'
// import dayjs from 'dayjs'
import { deepClone } from '@/common/util'
// import { getMerchantPageSearch } from '@api/publicAccount'
import { getTmplList, getMetaTmpl, getBillTmplAdapter, getServiceByShopList, getShopList, createServiceBill } from '@api/accountManage'
import { mapActions, mapState } from 'vuex'
import { localTmplList } from "../constant/baseData"
export default {
name: 'CreateServiceDialog',
data() {
return {
loading: false,
multipleLimit: 1,
// 判断是否是模版模式
isTmpl: true,
localTmplList: deepClone(localTmplList),
tmplSelectList: [],
userInfo: this.$store.state.d2admin.user.info,
infoForm: {
merchantType: '7',
merchant: [],
templateId: '',
fieldsJson: '',
fieldsTxt: ''
},
// 1 - traffic; 2 - service
merchantTypeStr: 'service',
typeObj: {
'2': 'traffic',
'7': 'service'
},
formRules: {
merchant: [
{ required: true, message: '请选择对账商户', trigger: 'change' }
],
templateId: [{ required: true, message: '请选择对账模版', trigger: 'change' }],
fieldsJson: [{ required: true, message: '请选择对账字段', trigger: 'change' }],
},
selectLoading: false,
// 基本数据
baseData: {
merchantList: [],
trafficTemplateList: [],
serviceTemplateList: [],
shopMerchantList: []
},
yqCheckVisible: true
}
},
props: {
accountVisible: {
type: Boolean,
default: false
},
scene: {
type: String,
default: '7'
},
editForm: {
type: Object,
default: () => { }
}
},
watch: {
},
created() {
},
components: {},
computed: {
...mapState({
dowloadList: (state) => state.d2admin.user.dowloadList
})
},
mounted() {
// console.log(this.scene)
this.$EventBus.$on('changeFieldIds', obj => {
console.log(obj, 'obj---')
this.tmplSelectList = obj?.fieldIds || []
this.infoForm.fieldsTxt = this.getFieldsTxt()
this.getMetaTmpl()
})
this.getTmplList()
// this.judgeTmpl()
this.selectMerchant()
// if (this.scene == '2' || this.scene == '3' || this.scene == '4') {
// /** 新改逻辑:园区店选项只对精品升级/会员权益可见 */
// this.yqCheckVisible = false
// }
// this.selectMerchant()
},
methods: {
...mapActions('d2admin/user', ['actionSetDownloadList']),
selectMerchant() {
var params = {}
this.loading = true
// params.currentPage = 1
// params.pageSize = 10000
params.merchantId = this.editForm.shopMerchantId
params.scene = this.editForm.sceneType
getServiceByShopList(params).then(res => {
console.log(res, 'res---')
this.baseData.merchantList = res
this.infoForm.merchant = []
}).finally(() => {
this.loading = false
})
},
// handleChangeMerchant(e) {
// console.log(e)
// const params = {
// currentPage: 1,
// pageSize: 9999,
// partnerMerchantId: e[0],
// scene: this.scene
// }
// getShopList(params).then(res => {
// this.baseData.shopMerchantList = res.list
// })
// },
clickMerchantType(e) {
e === this.infoForm.merchantType
? (this.infoForm.merchantType = '')
: (this.infoForm.merchantType = e)
// console.log(this.infoForm.merchantType)
},
changeType(e) {
// 对账单是否有模版
// this.judgeTmpl()
this.selectMerchant()
},
/**
* 商户类型 - 商户类型value - 是否有模版
* 流量方 - 2 - 是
* 服务商 - 7 - 仅“服务商对账单”(reportType = 4)时,是有模版
* 园区店 - 6 - 否
*/
judgeTmpl() {
this.isTmpl = this.infoForm.merchantType == '2'
this.merchantTypeStr = this.typeObj[this.infoForm.merchantType]
this.infoForm.merchant = []
this.resetTmplData()
},
resetTmplData() {
this.infoForm.shopMerchantId = ''
this.infoForm.packageMerge = false
this.infoForm.templateId = ''
this.infoForm.fieldsJson = ''
this.infoForm.fieldsTxt = ''
this.infoForm.tmplType = ''
this.tmplSelectList = []
const ruleAttrList = ['packageMerge', 'templateId', 'fieldsJson']
ruleAttrList.forEach(item => {
this.formRules[item][0].required = this.isTmpl
})
this.formRules.shopMerchantId[0].required = this.isTmpl && this.infoForm.merchantType == '7'
},
getFieldsTxt() {
var fieldNames = ''
const tmplName = this.localTmplList.find(item => item.type == this.infoForm.tmplType)?.name || 'trafficTmpl'
console.log(tmplName, 'tmplName---')
var list = JSON.parse(localStorage.getItem(tmplName))
console.log(list, 'list---')
this.dealFieldsJson(list, true)
},
changeStartDate() {
if (this.infoForm.payEndDate) {
this.infoForm.payEndDate = ''
}
},
// remoteMethod(query) {
// this.selectLoading = true
// var params = {}
// params.currentPage = 1
// params.pageSize = 1000
// params.merchantName = query
// var merchantTypeList = this.infoForm.merchantType
// ? [this.infoForm.merchantType]
// : []
// params.merchantTypeList = merchantTypeList
// getMerchantPageSearch(params).then(res => {
// this.selectLoading = false
// this.baseData.merchantList = res.list
// })
// },
getTmplList() {
const params = {
pageSize: 9999,
currentPage: 1
}
// 流量方
// getTmplList({ ...params, type: 1 }).then(res => {
// this.baseData.trafficTemplateList = res.list || []
// this.baseData.trafficTemplateList.unshift({
// id: 'all',
// type: 1,
// templateName: '无',
// fieldNames: '',
// fieldIds: []
// })
// })
// 服务商
getTmplList({ ...params, type: 2 }).then(res => {
this.baseData.serviceTemplateList = res.list || []
this.baseData.serviceTemplateList.unshift({
id: 'all',
type: 2,
templateName: '无',
fieldNames: '',
fieldIds: []
})
})
},
handleTmplChange(e) {
if (!(Object.keys(this.typeObj)).includes(this.infoForm.merchantType)) {
return true
}
const item = this.baseData[this.merchantTypeStr + 'TemplateList'].find(item => item.id == e)
this.infoForm.fieldsTxt = item?.fieldNames
this.infoForm.tmplType = item?.type
this.tmplSelectList = item?.fieldIds
this.getMetaTmpl()
},
getMetaTmpl() {
const tmplName = this.localTmplList.find(item => item.type == this.infoForm.tmplType)?.name || 'trafficTmpl'
var list = JSON.parse(localStorage.getItem(tmplName))
if (list) {
this.dealFieldsJson(list)
} else {
getMetaTmpl({ type: this.infoForm.tmplType }).then(res => {
this.dealFieldsJson(res)
localStorage.setItem(tmplName, JSON.stringify(res))
})
}
},
dealFieldsJson(list, isFindTxt = false) {
// console.log(list, 'list---')
this.tmplList = []
this.moduleSubList = []
this.selectedList = []
list.forEach(item => {
const subLen = this.moduleSubList.length
this.moduleSubList.push({
rowIdx: subLen ? this.moduleSubList[subLen - 1].rowIdx + this.moduleSubList[subLen - 1].rowspan : item.items.length - 1,
rowspan: item.items.length
})
this.tmplList = this.tmplList.concat(item.items)
item.items.forEach(k => {
if (k.required == 1) {
this.selectedList.push(k)
} else if (this.tmplSelectList.includes(k.id)) {
this.selectedList.push(k)
}
})
})
this.$nextTick(() => {
isFindTxt && (this.infoForm.fieldsTxt = this.selectedList.map(item => item.fieldName).join(','))
this.infoForm.fieldsJson = JSON.stringify(this.selectedList)
})
},
handleCustTmpl() {
this.infoForm.tmplType = this.infoForm.merchantType == '2' ? '1' : '2'
this.$emit('custTmpl', {
tmplType: this.infoForm.tmplType + '',
tmplSelectList: this.tmplSelectList || []
})
},
getParams() {
var infoForm = deepClone(this.infoForm)
// console.log(infoForm)
var params = {}
var merchantList = []
var obj
infoForm.merchant.forEach(item => {
obj = {}
obj.merchantId = item
obj.merchantName = this.baseData.merchantList.find(
mer => mer.merchantId === item
).merchantName
merchantList.push(obj)
})
params.id = this.editForm.id
// params.payStartDate = infoForm.payStartDate + ' 00:00:00'
// params.payEndDate = infoForm.payEndDate + ' 23:59:59'
merchantList.forEach((item, index) => {
// const merchantName = `merchantList[${index}].merchantName`
// const merchantId = `merchantList[${index}].merchantId`
// params[merchantName] = item.merchantName
// params[merchantId] = item.merchantId
params.partnerMerchantId = item.merchantId
})
// params.merchantType = infoForm.merchantType
// if (infoForm.merchantType == '7') {
// params.reportType = infoForm.reportType
// }
// params.sceneType = this.scene
// 对账状态
// infoForm.reconciliationStatus == 'all' ? '' : (params.reconciliationStatus = infoForm.reconciliationStatus)
// infoForm.payeeType == 'all' ? '' : (params.payeeType = infoForm.payeeType)
// if (infoForm.shopMerchantId) {
// params.shopMerchantId = infoForm.shopMerchantId
// params.shopMerchantName = this.baseData.shopMerchantList.find(item => item.merchantId == infoForm.shopMerchantId)?.merchantName
// }
// if (this.isTmpl) {
// params.packageMerge = infoForm.packageMerge
params.templateId = infoForm.templateId == 'all' ? '' : infoForm.templateId
params.fieldsJson = infoForm.fieldsJson
// }
return params
},
// 系统对账 - 单个商户
handleSystemBill() {
this.$refs.accountForm.validate(valid => {
if (valid) {
// if (this.infoForm.merchant.length == 1) {
var params = this.getParams()
// params.orderCurrentPage = 1
// params.orderPageSize = 10
// console.log('params', params)
createServiceBill(params).then(res => {
console.log(res, 'res')
this.$emit('handleConfirm', { billTmplInfo: res })
})
// } else {
// this.$message.warning("仅支持单商户进行系统对账")
// }
}
})
},
handleAddConfirm() {
this.$refs.accountForm.validate(valid => {
if (valid) {
this.dowloadApi()
}
})
},
dowloadApi() {
var params = this.getParams()
params.method = 'dj.api.smartcarlife.goodsOrderProfitAllocation.exportAccountStatementForAudit.async'
console.log('params', params)
const list = [
...this.dowloadList,
{
name: '对账单',
// uuid: JSON.parse(res).data,
// ifSuccess: false
exportParam: JSON.stringify(params),
status: 'waiting',
timeid: new Date().getTime()
}
]
this.actionSetDownloadList({ list, type: 'dowloadList' })
this.handleClose()
},
handleClose() {
this.$emit('accountClose', true)
}
}
}
</script>
<style lang="scss" scoped>
.dateItem {
display: flex;
}
::v-deep .dateItem .el-form-item__content {
display: flex;
margin-left: 0 !important;
}
::v-deep .accountDailog {
/*下拉选择框-多选-内容过长-用...代替 begin */
.el-tag.el-tag--info {
background-color: #f4f4f5;
border-color: #e9e9eb;
color: #909399;
max-width: calc(100% - 50px);
/* white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;*/
}
.el-tag.el-tag--info {
width: calc(100% - 200px);
}
.el-tag.el-tag--info .el-select__tags-text {
width: calc(100% - 20px);
float: left;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
/*下拉选择框-多选-内容过长-用...代替 end */
.accountDailog .el-dialog {
min-width: 700px;
}
.accountDailog .el-select-dropdown__item {
width: 395px !important;
}
}
.tmpl-box {
display: flex;
}
.fields-txt {
width: 305px;
display: inline-block;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
margin-right: 8px;
}
</style>