outputValueDialog.vue
16.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
468
<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-file-import-dialog :is-visible="fileVisible"
title="上传文件"
@closeDialog="handleImport"
@confirmDialog="handleConfirmImport"
@downloadTemplate="downLoadTemplate" />
</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,
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)
})
},
handleImport() {
this.fileVisible = !this.fileVisible
},
handleConfirmImport({ fileName, fileData }) {
merchantOutputValueTargetImport({ file: fileData }).then((result) => {
if (result) {
const list = [...this.updateList, {
name: fileName,
ifSuccess: false,
uuid: result,
type: 'upload'
}]
this.actionSetDownloadList({ list, type: 'updateList' })
this.notice.okTips('上传成功')
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;
}
</style>