outputValueDialog.vue
22.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
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
<template>
<div>
<d2-dialog :title="'编辑单店信息'" :is-visible="outputVisible" :width="'1190px'" @closeDialog="handleClose"
@confirmDialog="handleConfirm">
<slot>
<div class="searchWrap">
<el-col :span="9">
<el-date-picker v-model="search.targetDate" :clearable="false" type="month" format="yyyy 年 MM 月"
@change="handleSearch" value-format="yyyy-MM" :picker-options="pickerOptions" placeholder="选择月" />
</el-col>
<el-col :span="9">
<el-input v-model="search.keyword" clearable placeholder="输入门店名称搜索" />
</el-col>
<el-col :span="6" class="btnContainer">
<el-button type="primary" size="small" @click="handleSearch" class="searchBtn">
搜索
</el-button>
<el-button size="small" style="margin-right: 10px;" @click="handleReset">
重置
</el-button>
<!-- <el-button size="small" @click="() => fileVisible = true">
导入
</el-button> -->
<auth-button category="Button" size="small" :show-btn-ids="['90708']" />
</el-col>
</div>
<div class="yqdTableContainer">
<el-table :data="tableData" stripe max-height="450" :header-cell-style="rowClass" style="width: 100%">
<el-table-column label="序号" type="index" width="50" />
<el-table-column prop="merchantName" label="门店列表" width="200" />
<el-table-column prop="merchantId" label="商户号" width="120" />
<el-table-column prop="businessType" label="业务性质" width="120">
<template slot-scope="scope">
<span>{{ scope.row.businessType ? businessNatureShow[scope.row.businessType] : '' }}</span>
</template>
</el-table-column>
<!-- <el-table-column prop="outputValue" label="场景在营" width="220">
<template slot-scope="scope">
<el-select v-model="scope.row['businessScene']" class="select" multiple collapse-tags placeholder="请选择">
<el-option v-for="item in sceneCodeList" :key="item.confId" :label="item.confValue"
:value="item.confId">
</el-option>
</el-select>
</template>
</el-table-column> -->
<el-table-column prop="outputValue" label="配置场景导出" width="220">
<template slot-scope="scope">
<el-select v-model="scope.row['deployScene']" class="select" multiple collapse-tags placeholder="请选择">
<el-option v-for="item in sceneCodeList" :key="item.confId" :label="item.confValue"
:value="item.confId">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column prop="outputValue" label="区域督导" width="150">
<template slot-scope="scope">
<el-select clearable filterable value-key="userId" v-model="scope.row['areaSupervision']" class="select"
collapse-tags placeholder="请选择">
<el-option v-for="item in supervisionOptionsList" :key="item.userId" :label="item.userName"
:value="item">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column prop="outputValue" label="驻店负责人" width="150">
<template slot-scope="scope">
<el-select clearable filterable value-key="userId" v-model="scope.row['residentManager']" class="select"
@focus="getSelectList(scope.row, scope.$index,)" collapse-tags placeholder="请选择">
<el-option v-for="item in scope.row['residentManagerOptionsList']" :key="item.userId"
:label="item.userName" :value="item">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column prop="outputValue" label="产值目标" width="150">
<template slot-scope="scope">
<!-- <div>slot-scope="scope"</div> &&item.isEdit-->
<span v-if="!scope.row['isEdit']">{{ scope.row['outputValue'] }}</span>
<!-- @input="input($event,item)" -->
<el-input v-else style="width: 140px" @input="handleInput($event, scope)"
v-model="scope.row['outputValue']" placeholder="" />
</template>
</el-table-column>
</el-table>
<el-pagination v-if="hasPage" background @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-page="page.currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="page.pageSize"
:total="tableTotal" :layout="layout" />
<div class="tips">
产值目标填写后不支持修改,请谨慎输入。
<!-- 填写后不支持修改,请谨慎输入。 -->
</div>
</div>
</slot>
</d2-dialog>
<!-- 导入门店设置 -->
<d2-dialog :title="'上传文件'" :is-visible="fileVisible" @closeDialog="handleImport"
@confirmDialog="handleConfirmImport" width="600px">
<slot>
<div>
<el-form :model="fileForm" :rules="fileRules" ref="fileRuleForm" label-width="120px">
<el-form-item label="导入文件:" prop="fileName">
<el-col :span="16">
<el-input readonly v-model="fileForm.fileName" />
</el-col>
<el-col :span="4" class="m-l-md">
<el-button class="import-btn">
导入文件
<input type="file" id="fileUpload" class="import-input"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
@change="importFile($event)" />
<!-- href="https://img01.glsx.com.cn/weapp/resource/saas/scrm/xlsx/对账单模版.xlsx" -->
<el-link type="primary" class="import-template" @click="downLoadTemplate" icon="el-icon-link">
模版下载
</el-link>
</el-button>
</el-col>
</el-form-item>
</el-form>
<span v-show="showNum">
<div class="upload-statistics">
<div class="quantity">
<div class="success">{{ importNum.successCount }}</div>
<div>有效数据</div>
</div>
<div class="line"></div>
<div class="quantity">
<div class="err">{{ importNum.failCount }}</div>
<div>异常数据</div>
</div>
</div>
<div class="abnormal">
<p>数据异常的可能原因:</p>
<p class="color-33">
1. 订单编号不匹配
</p>
</div>
</span>
</div>
</slot>
</d2-dialog>
</div>
</template>
<script>
import { limitPrice } from '@/common/format'
import { sceneCodeList, businessNatureShow } from '@/common/constants'
import { downLoadFile } from '@/common/util'
// import moment from 'moment'
// import orderManage from "@api/orderManage"
import dayjs from 'dayjs'
import { merchantOutputValueTargetExport, merchantOutputValueTargetImport, getMerchantOutputValueTarget, setMerchantOutputValueTarget, findMerchantStaffList } from '@api/index'
import { mapActions, mapState, mapMutations } from 'vuex'
export default {
props: {
isShow: {
// 弹窗是否展示
type: Boolean,
default: true
}
},
data() {
return {
fileVisible: false,
showNum: false,
importNum: {
succNum: 0,
failNum: 0
},
fileForm: {},
fileRules: {
fileName: [{ required: true, message: "请上传文件", trigger: "change" }]
},
pickerOptions: {
disabledDate: (time) => {
const maxMonth = dayjs().subtract(-1, 'months').endOf('month')
const minMonth = dayjs().subtract(5, 'months').startOf('month')
// console.log(minMonth.valueOf())
// console.log(time.getTime())
// time.getTime() > minMonth.valueOf() ||
return time.getTime() > maxMonth.valueOf() || time.getTime() < minMonth.valueOf()
}
},
nowMonth: dayjs().subtract(0, 'months').startOf('month').format('YYYY-MM'),
nextMonth: dayjs().subtract(-1, 'months').startOf('month').format('YYYY-MM'),
search: {
keyword: '',
targetDate: ''
},
tableData: [],
sceneCodeList,
supervisionOptionsList: [],
tableTotal: 10,
// 页码
page: {
pageSize: 10,
currentPage: 1
},
hasPage: true,
// 分页组件配置
layout: 'sizes,total,->,prev,pager,next,jumper',
// outputVisible: true
businessNatureShow: businessNatureShow
}
},
computed: {
outputVisible: {
get() {
return this.isShow
},
set(val) {
this.$emit('update:isShow', false)
}
},
...mapState({
dowloadList: (state) => state.d2admin.user.dowloadList,
updateList: (state) => state.d2admin.user.updateList,
updateRefesh: (state) => state.d2admin.user.updateRefesh
})
},
mounted() {
// console.log(this.nowMonth)
this.search.targetDate = this.nowMonth
this.getList()
this.getOptionsList()
// console.log(moment().subtract(-1, 'months').endOf('month').format('YYYY-MM-DD'))
// console.log(moment().subtract(5, 'months').startOf('month').format('YYYY-MM-DD'))
},
watch: {
updateRefesh(val) {
if (val == true) {
this.getList()
this.setUpdateRefesh('false')
}
},
},
methods: {
...mapActions({
get: 'd2admin/base/get',
close: 'd2admin/page/close'
}),
...mapMutations('d2admin/user', ['setUpdateRefesh']),
...mapActions('d2admin/user', ['actionSetDownloadList']),
getSelectList(item, index) {
console.log(item, index, 'item')
if (item.remote) return false
const { merchantId } = item
findMerchantStaffList({ merchantId }).then((result) => {
console.log('residentManagerOptionsList', result)
// 督导
// this.tableData
const optionsList = result.map((item) => {
return {
userType: 2,
userId: item.uuid,
userName: item.staffName,
userNum: item.staffPhone
}
})
this.$set(this.tableData[index], 'residentManagerOptionsList', optionsList)
this.$set(this.tableData[index], 'remote', true)
console.log(this.tableData[index])
// this.supervisionOptionsList = result.map((item) => {
// return {
// userType: 1,
// userId: item.uuid,
// userName: item.staffName,
// userNum: item.staffPhone
// }
// })
})
},
// 导入
handleOutputImport() {
this.fileVisible = true
},
getOptionsList() {
findMerchantStaffList({ merchantId: -1 }).then((result) => {
console.log('findMerchantStaffList', result)
// 督导
// if (merchantId == -1) {
this.supervisionOptionsList = result.map((item) => {
return {
userType: 1,
userId: item.uuid,
userName: item.staffName,
userNum: item.staffPhone
}
})
// }
})
},
downLoadTemplate() {
merchantOutputValueTargetExport({ targetDate: this.search.targetDate }).then((result) => {
console.log(result, 'result')
// const { data } = result
result && downLoadFile(result)
})
},
// 上传文件,转码为base64
importFile(e) {
const size = e.target.files[0].size / 1024 / 1024
console.log(e)
if (size < 9) {
this.$set(this.fileForm, "fileName", e.target.files[0].name)
// // 转码base64
const reader = new FileReader()
reader.readAsDataURL(e.target.files[0])
reader.onload = (event) => {
const imgFile = event.target.result
const arrBase64 = imgFile.split(",")
this.fileInfo =
e.target.files[0].name.split(".")[1] + "@" + arrBase64[1]
// orderManage.pictureUpload({ file: this.fileInfo }).then((res) => {
// if (res) {
// this.fileForm.fileUrl = res
// }
// // const refName = "file" + row.id
// // const refName = "file"
// e.target.value = ""
// // this.$refs[refName].value = ""
// })
document.getElementById("fileUpload").value = ""
}
} else {
this.notice.errorTips("上传文件不可超过9M")
}
},
handleImport() {
this.fileVisible = !this.fileVisible
this.$refs.fileRuleForm && this.$refs.fileRuleForm.resetFields()
},
handleConfirmImport() {
this.$refs.fileRuleForm.validate((valid) => {
if (valid) {
// var params = {
// fileUrl: this.fileForm.fileUrl
// }
merchantOutputValueTargetImport({ file: this.fileInfo }).then((result) => {
if (result) {
// 异步处理文件上传 把id传入处理轮询
const list = [...this.updateList, {
name: this.fileForm.fileName,
ifSuccess: false,
uuid: result,
type: 'upload'
}]
this.actionSetDownloadList({ list, type: 'updateList' })
this.notice.okTips('上传成功')
this.handleImport()
}
// console.log(result, 'result')
// const { url, dataList } = result
// console.log(url, 'url')
// if (url) {
// // this.$message.error('上传失败')
// this.$message.error('上传失败')
// downLoadFile(url)
// }
// if (dataList) {
// this.$message.success('上传成功')
// this.fileVisible = false
// this.hasPage = false
// // const listFilter = result.list
// this.tableData = dataList.map((item) => {
// item.dataMonth = this.search.targetDate
// item.isEdit = true
// item.areaSupervision = item.areaSupervision || {}
// item.residentManager = item.residentManager || {}
// item.area = item.area || ''
// // item.residentManagerOptionsList = item.residentManager?{}
// if (item.residentManager) {
// item.residentManagerOptionsList = [{
// userId: item.residentManager.userId,
// userName: item.residentManager.userName,
// userNum: item.residentManager.userNum,
// userType: item.residentManager.userType
// }]
// } else {
// item.residentManagerOptionsList = []
// }
// return item
// })
// // this.tableTotal = result.total
// }
})
// .catch((err) => {
// })
// orderManage.orderEndExportApi(params).then((res) => {
// if (res) {
// this.showNum = true
// this.importNum = {
// successCount: res.successCount,
// failCount: res.failCount
// }
// this.$message.success('上传成功')
// // this.handleImport()
// }
// })
}
})
},
// 每页条数
handleSizeChange(value) {
this.page.pageSize = value
this.getListApi ? this.refreshTable(false) : this.$emit('refreshTable', this.page)
},
// 页码
handleCurrentChange(value) {
this.page.currentPage = value
// this.getListApi ? this.refreshTable(false) : this.$emit('refreshTable', this.page)
this.getList()
},
handleReset() {
this.search.targetDate = this.nowMonth
this.search.keyword = ''
this.getList()
},
handleSearch() {
this.hasPage = true
this.page.currentPage = 1
this.getList()
},
getList() {
const params = {
...this.search,
...this.page
}
getMerchantOutputValueTarget(params).then((result) => {
console.log(result, 'result')
const monthCheck = [this.nowMonth, this.nextMonth].includes(this.search.targetDate)
// console.log(monthCheck)
// 处理值能否编辑的问题
const listFilter = result.list
// 要单月或者下月并且值为0才可以编辑
this.tableData = listFilter.map((item) => {
item.dataMonth = this.search.targetDate
item.isEdit = monthCheck && !item.outputValue
item.areaSupervision = item.areaSupervision || {}
item.residentManager = item.residentManager || {}
// item.residentManagerOptionsList = item.residentManager?{}
if (item.residentManager) {
item.residentManagerOptionsList = [{
userId: item.residentManager.userId,
userName: item.residentManager.userName,
userNum: item.residentManager.userNum,
userType: item.residentManager.userType
}]
} else {
item.residentManagerOptionsList = []
}
return item
})
this.tableTotal = result.total
// console.log(this.tableData)
}).catch((err) => {
console.log(err)
})
},
handleInput(newValue, item) {
// console.log(newValue, item)
// let limitNum = limitPrice
// console.log(limitPrice(newValue, item.row.outputValue, 6))
newValue = newValue.replace(/[^\d.]/g, '') // 清除“数字”和“.”以外的字符
// console.log(newValue)
this.tableData[item.$index].outputValue = limitPrice(newValue, item.row.outputValue, 6, 2, 1, 999999)
// console.log(this.tableData[item.$index]['name'])
},
// 设置表头的颜色
rowClass({ row, rowIndex }) {
// console.log(rowIndex) // 表头行标号为0
return 'background:#F4F6FC'
},
async handleConfirm() {
let filterList = this.tableData.filter((item) => {
// 删除无需字段 避免后台类型报错
// delete item.createdDate
// delete item.updatedDate
// delete item.createdBy
// delete item.updatedBy
// delete item.deletedFlag
// delete item.targetDate
// const list = ['deployScene', 'businessScene', 'areaSupervision', 'residentManager']
// || item.deployScene || item.businessScene || item.areaSupervision || item.residentManager
const testFlag = (item.isEdit && item.outputValue)
const testFlag2 = ['deployScene', 'businessScene'].some(ele => item[ele])
const testFlag3 = ['areaSupervision', 'residentManager'].some(ele => item[ele] && item[ele].userId)
return testFlag || testFlag2 || testFlag3
})
filterList = filterList.map((item) => {
return {
merchantName: item.merchantName,
merchantId: item.merchantId,
outputValue: item.outputValue,
deployScene: item.deployScene,
businessScene: item.businessScene,
dataMonth: item.dataMonth,
areaSupervision: item.areaSupervision || {},
residentManager: item.residentManager || {},
area: item.area
}
})
console.log(filterList, 'filterList')
if (filterList.length) {
// console.log('请求修改')
// const result =
// await setMerchantOutputValueTarget({ list: filterList })
await setMerchantOutputValueTarget({ dataString: JSON.stringify(filterList) })
// console.log(result)
}
// else {
// console.log('没有能修改的')
// }
this.$notify({
type: 'success',
title: '保存成功'
})
// this.$notify.successTips('保存成功')
this.handleClose()
},
handleClose() {
this.outputVisible = false
}
}
}
</script>
<style lang="scss" scoped>
::v-deep.searchWrap {
height: 30px;
margin-bottom: 10px;
.el-input__inner {
height: 30px;
}
.el-input__icon {
line-height: 30px;
}
.btnContainer {
text-align: right;
padding-right: 10px;
}
// .searchBtn {
// font-size: 12px;
// padding: 8px 10px;
// }
}
::v-deep.yqdTableContainer {
.el-table .cell {
padding: 0 10px;
}
// padding-right: 3px;
.el-table__body-wrapper {
.el-table__row td:nth-child(1) {
border-left: 1px solid #ebeef5;
}
.el-table__row td:nth-last-child(1) {
border-right: 1px solid #ebeef5;
}
}
.select {
.el-tag {
width: auto;
}
}
}
.tips {
margin-top: 10px;
font-size: 12px;
text-align: right;
color: #f46967;
}
.list-tips {
background: #e4e3ff;
border-radius: 4px;
border: none;
display: flex;
align-items: center;
font-size: 14px;
color: rgba(0, 0, 0, 0.65);
padding: 10px 16px;
height: 20px;
line-height: 20px;
}
.m-t-94 {
margin-top: 94px;
}
.upload-wrap {
display: flex;
}
.import-btn {
position: relative;
}
.import-input {
opacity: 0;
position: absolute;
right: 0;
top: 0;
width: 98px;
height: 36px;
cursor: pointer;
font-size: 0;
}
.import-template {
position: absolute;
height: 20px;
top: 50px;
left: 0;
}
.m-l-md {
margin-left: 20px;
}
.upload-statistics {
display: flex;
align-items: center;
justify-content: space-between;
margin: 30px 70px;
.quantity {
font-size: 14px;
color: #333333;
text-align: center;
.success {
font-size: 26px;
color: #2cca74;
text-align: center;
margin-bottom: 4px;
}
.err {
font-size: 26px;
color: #eb4e4e;
text-align: center;
margin-bottom: 4px;
}
}
.line {
width: 1px;
height: 56px;
background: #e8e8ea;
}
}
</style>