maintainRemind.js
18.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
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
;
(function (angular) {
function maintainRemind($scope, $rootScope, aiNicheService, DTOptionsBuilder, DTColumnBuilder, $location, $compile, Utils, $uibModal, $filter, toaster, localStorageService) {
// 跳转 活动列表 保养线索 流失线索 拦截
$scope.activityFlag = false
$scope.jumpLink = function (name, target) {
checkPermission(name, $scope.menuList, target)
if ($scope[target]) {
// 跳往一件营销
$scope.jumpActivity()
} else {
toaster.pop({
type: 'error',
body: '您暂未开通该服务,请联系客服处理',
showCloseButton: true,
timeout: 3000
})
}
}
function checkPermission(pageTitle, data, name) {
angular.forEach(data, function (e) {
if (e.children) {
checkPermission(pageTitle, e.children, name)
} else {
if (e.pageTitle == pageTitle) {
$scope[name] = true
}
}
})
}
// 图表
$scope.chartActive = 1
$scope.chartCbk = function (chartActive) {
$scope.chartActive = chartActive
if (chartActive == 1) {
if (chart7) chart7.destroy()
} else if (chartActive == 2) {
if (chart6) chart6.destroy()
}
}
var chart6
var chart7
$scope.data6 = []
$scope.data7 = []
$scope.bgColor = [{}, {}, {}, {}, {}, {}]
var rankColor = ['#01C292', '#3090FF', '#00B0FF', '#12DCAA', '#FFAB00', '#FFD600']
$scope.$watch('chartActive', function () {
if ($scope.chartActive == 1) {
// 到店线索,忠诚客户分析
aiNicheService.getCountTotalClassify(function (res) {
var total = '- -'
if (res.returnCode == '0') {
$scope.data6 = res.data
total = res.data[0].total
} else {
$scope.data6 = [{
number: 0,
total: '- -',
name: 0
}]
}
var chart6 = new G2.Chart({
container: 'mileageTotal',
forceFit: true,
height: 200,
padding: [30],
options: {
legends: false
}
})
// var total = res.data.length == 0 ? 0 : res.data[0].total
drawChart($scope.data6, chart6, '总人数', total)
})
} else if ($scope.chartActive == 2) {
aiNicheService.getMileageClassify(function (res) {
var total = '- -'
if (res.returnCode == '0') {
$scope.data7 = res.data
total = res.data[0].total
} else {
$scope.data7 = [{
number: 0,
total: '- -',
name: 0
}]
}
var chart7 = new G2.Chart({
container: 'lastMileage',
forceFit: true,
height: 200,
padding: [30],
options: {
legends: false
}
})
// var total = res.data.length == 0 ? 0 : res.data[0].total
drawChart($scope.data7, chart7, '总人数', total)
})
}
})
var sliceNumber = 0.005
// 自定义 other 的图形,增加两条线
G2.Shape.registerShape('interval', 'sliceShape', {
draw: function draw(cfg, container) {
var points = cfg.points
var path = []
path.push(['M', points[0].x, points[0].y])
path.push(['L', points[1].x, points[1].y - sliceNumber])
path.push(['L', points[2].x, points[2].y - sliceNumber])
path.push(['L', points[3].x, points[3].y])
path.push('Z')
path = this.parsePath(path)
return container.addShape('path', {
attrs: {
fill: cfg.color,
path: path
}
})
}
})
function drawChart(data, chart, totalName, total) {
var bgColor = ['#01C292', '#3090FF', '#00B0FF', '#12DCAA', '#FFAB00', '#FFD600']
angular.forEach(data, function (item, index) {
$scope.bgColor[index]['background-color'] = rankColor[index]
})
if (total == 0 || total == '- -') {
var info = [{
number: 1,
name: 1
}]
chart.source(info)
bgColor = ['#CFD3D5']
chart.tooltip(false)
} else {
chart.source(data)
chart.tooltip({
showTitle: false
})
}
chart.coord('theta', {
innerRadius: 0.75
})
chart.guide().html({
position: ['50%', '50%'],
html: `<div class="g2-guide-html"><div class="value">${total}</div><div class="title">${totalName}</div></div>`
})
chart.intervalStack().position('number').color('name', bgColor).shape('sliceShape')
chart.render()
}
$scope.form = {
duplicate: 1
}
// 推送
$scope.pushType = 'yesterday'
$scope.pushTypeFlag = false
$scope.formPush = function (pushType) {
this.pushType = pushType
if (pushType == 'yesterday') {
$scope.pushTypeFlag = false
$scope.$broadcast('reset')
$scope.monthSelectsDate = null
} else {
$scope.pushTypeFlag = true
}
$scope.tableSearch()
}
// 定义表数据显示格式
var resultShow = (function () {
return function (e, dt, node, config) {
var results = null
if (node.status == 1) {
results = '-'
} else {
if (node.followResult == '5') {
results = '预约到店'
} else if (node.followResult == '6') {
results = '回店时间待定'
} else if (node.followResult == '14') {
results = '拒访,需跟进'
} else if (node.followResult == '7') {
results = '无人接听或通话中,需跟进'
} else if (node.followResult == '15') {
results = '流失竞店'
} else if (node.followResult == '16') {
results = '车辆故障'
} else if (node.followResult == '17') {
results = '外地用车'
} else if (node.followResult == '8') {
results = '其他原因'
} else if (node.followResult == '18') {
results = '拒访,无需跟进'
} else if (node.followResult == '19') {
results = '已经回店'
} else if (node.followResult == '20') {
results = '联系方式有误'
} else if (node.followResult == '21') {
results = '车辆已售'
} else if (node.followResult == '27') {
results = '他店保养'
}
}
return results
}
})()
var statusShow = (function () {
return function (e, dt, node, config) {
var results = null
if (node.status == '1') {
results = '未回访'
} else if (node.status == '2') {
results = '已回访'
} else {
results = '--'
}
return results
}
})()
var ruleShow = (function () {
return function (e, dt, node, config) {
var results = null
if (node.remindType == '1') {
results = '首保'
} else if (node.remindType == '2') {
results = '定保'
} else {
results = '--'
}
return results
}
})()
var timeShow = (function () {
return function (e, dt, node, config) {
var results = null
if (node.remindRule == '1') {
results = '里程提醒'
} else if (node.remindRule == '2') {
results = '时间提醒'
} else {
results = '--'
}
return results
}
})()
var formatTime = (function () {
return function (e, dt, node, config) {
var results = null
if (node.inTime == null) {
results = '-'
} else {
results = $filter('date')(new Date(node.inTime), 'yyyy-MM-dd')
}
return results
}
})()
var formatFollowTime = (function () {
return function (e, dt, node, config) {
var results = null
if (node.followTime == null || node.status == '1') {
results = '-'
} else {
results = $filter('date')(new Date(node.followTime), 'yyyy-MM-dd')
}
return results
}
})()
var formatRegistTime = (function () {
return function (e, dt, node, config) {
var results = null
if (node.registTime == null) {
results = '-'
} else {
results = $filter('date')(new Date(node.registTime), 'yyyy-MM-dd')
}
return results
}
})()
var formatDistance = (function () {
return function (e, dt, node, config) {
var results = null
if (node.distance == null) {
results = '-'
} else {
results = node.distance
}
return results
}
})()
var remarksShow = (function () {
return function (e, dt, node, config) {
var results = null
if (node.status == '1') {
results = '-'
} else {
results = node.followRemarks
}
return results
}
})()
$scope.dtColumns = [
DTColumnBuilder.newColumn('svrtimeStr').withOption('width', 80).withTitle('保养提醒时间'),
DTColumnBuilder.newColumn('standNo').withOption('width', 135).withTitle('车架号'),
DTColumnBuilder.newColumn('remindType').withOption('width', 80).withTitle('保养提醒类型').renderWith(ruleShow),
DTColumnBuilder.newColumn('remindRule').withOption('width', 80).withTitle('保养提醒规则').renderWith(timeShow),
DTColumnBuilder.newColumn('maintainSource').withOption('width', 120).withTitle('来源').renderWith(function (e, dt, node, config) {
if (node.maintainSource == 1) {
return "设备录入</br>本次保养里程:</br>" + (node.thisMaintainMileage ? node.thisMaintainMileage + '</br>' : '') + "本次保养时间:</br> " +
(node.thisMaintainTime ? node.thisMaintainTime.split(" ")[0] : '');
} else if (node.maintainSource == 0) {
return "系统默认";
} else if (node.maintainSource == 2) {
return "自定义";
}
return "";
}),
DTColumnBuilder.newColumn('registTime').withOption('width', 80).withTitle('车辆注册时间').renderWith(formatRegistTime),
DTColumnBuilder.newColumn('totalMileage').withOption('width', 100).withTitle('当前里程(KM)'),
DTColumnBuilder.newColumn('diffBackshopMileage').withOption('width', 100).withTitle('未保养里程(KM)<br><font color="#00956e">[跟进记录]</font>'),
DTColumnBuilder.newColumn('diffBackshopTime').withOption('width', 100).withTitle('未保养天数(天)<br><font color="#00956e">[跟进记录]</font>'),
DTColumnBuilder.newColumn('name').withOption('width', 60).withTitle('客户姓名'),
DTColumnBuilder.newColumn('mobile').withOption('width', 85).withTitle('手机号'),
DTColumnBuilder.newColumn('diffMileage').withOption('width', 150).withTitle('距上次到店间隔里程(KM)<br><font color="#00956e">[电子围栏]</font>'),
DTColumnBuilder.newColumn('diffTime').withOption('width', 140).withTitle('距上次到店间隔时间(天)<br><font color="#00956e">[电子围栏]</font>'),
DTColumnBuilder.newColumn('distance').withOption('width', 120).withTitle('常驻地到店距离(KM)'),
DTColumnBuilder.newColumn('inTime').withOption('width', 80).withTitle('上次到店时间<br><font color="#00956e">[电子围栏]</font>').renderWith(formatTime),
DTColumnBuilder.newColumn('prevMileage').withOption('width', 120).withTitle('上次到店时里程(KM)<br><font color="#00956e">[电子围栏]</font>'),
DTColumnBuilder.newColumn('numbers').withOption('width', 60).withTitle('到店次数'),
DTColumnBuilder.newColumn('merchantName').withOption('width', 120).withTitle('店面'),
DTColumnBuilder.newColumn(null).withTitle(function () {
return '操作'
}).withOption('width', 140).withClass('text-center').renderWith(function (data, type, full, oSettings) {
var str = '<div class="form-inline">' +
'<div class="form-group"><a class="btn btn-link" ng-click="details(' + data.id + ')">详情</a></div>' +
'<div class="form-group"><a class="btn btn-link" ng-click="followRecord(\'' + data.standNo + "'," + data.id + ',\'' + data.sn + '\')">跟进记录</a></div>'
str += '</div>'
return str
})
]
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withOption('id', 'id')
.withFixedColumns({
leftColumns: 4,
rightColumns: 1
})
.withOption('num', true)
.withOption('completeCb', function () {
// 使table头部自定义内容能够绑定到当前scope
setTimeout(function () {
$compile(angular.element('.dt-head-ctrl').contents())($scope)
}, 0)
})
$scope.dtInstance = {
serverData: function (param) {
var day1 = new Date()
day1.setDate(day1.getDate() - 1)
var s1 = moment(day1).format('YYYY-MM-DD')
var paramCopy = {}
if ($scope.form.duplicate == '1') {
paramCopy.isNew = $scope.form.duplicate
}
if ($scope.pushType == 'yesterday') {
angular.extend(paramCopy, {
sTime: s1 + ' 00:00:00',
eTime: s1 + ' 23:59:59'
})
}
angular.extend(param, paramCopy)
return aiNicheService.getMaintainRemindListInfo(param)
}
}
$scope.monthSelects = []
aiNicheService.maintainQueryMonthList(function (response) {
$scope.monthSelects = response.data
if ($scope.monthSelects == null) {
$scope.monthSelects = []
}
$scope.monthSelects.unshift({
name: '全部'
})
})
// 商机总览
// function getBusinessOverview() {
// aiNicheService.getBusinessOverview(function (response) {
// $scope.businessOverviewInfo = response.data[0]
// $scope.businessOverviewInfos = response.data[1]
// })
// }
// getBusinessOverview()
// table搜索
$scope.tableSearch = function () {
var params = getParams()
$scope.dtInstance.query(params)
}
$scope.gotoCreateActivity = function () {
$location.path('/marketing/coupon/createActivityAdd/')
}
if (!angular.equals({}, $scope.createTime)) {
$scope.createTime = {
startDate: null,
endDate: null
}
}
function getParams() {
var obj = {}
if ($scope.selectCondition && $scope.conditionText) {
obj.searchKey = $scope.selectCondition
obj.searchValue = $scope.conditionText
}
if ($scope.status) {
obj.status = $scope.status
}
if ($scope.followResult) {
obj.followResult = $scope.followResult
}
if ($scope.remindType) {
obj.remindType = $scope.remindType
}
if ($scope.remindRule) {
obj.remindRule = $scope.remindRule
}
// if($scope.warnTimes1){
obj.warnTimesStart = $scope.warnTimes1
// }
// if($scope.warnTimes2){
obj.warnTimesEnd = $scope.warnTimes2
// }
if ($scope.distance == 1) {
obj.minDistance = 0
obj.maxDistance = 5
}
if ($scope.distance == 2) {
obj.minDistance = 5
obj.maxDistance = 10
}
if ($scope.distance == 3) {
obj.minDistance = 10
obj.maxDistance = 20
}
if ($scope.distance == 4) {
obj.minDistance = 20
obj.maxDistance = 300
}
if ($scope.pushType == 'history' && $scope.createTime.startDate && $scope.createTime.endDate) {
obj.sTime = $scope.createTime.startDate.format('YYYY-MM-DD HH:mm:ss')
obj.eTime = $scope.createTime.endDate.format('YYYY-MM-DD HH:mm:ss')
}
if ($scope.monthSelectsDate) {
obj.monthSelectsDate = $scope.monthSelectsDate.id
}
return obj
}
$scope.exportExcel = function () {
if ($scope.isExporting) return
var day1 = new Date()
day1.setDate(day1.getDate() - 1)
var s1 = moment(day1).format('YYYY-MM-DD')
var params = getParams()
var paramCopy = {}
if ($scope.form.duplicate == '1') {
paramCopy.isNew = $scope.form.duplicate
}
if ($scope.pushType == 'yesterday') {
angular.extend(paramCopy, {
sTime: s1 + ' 00:00:00',
eTime: s1 + ' 23:59:59'
})
}
angular.extend(params, paramCopy)
$scope.isExporting = true
var maintainTitle = '里程保养商机'
Utils.exportExcel3('maintain/exportMaintain', params, maintainTitle, 'GET', function () {
$scope.isExporting = false
})
/*
var options={
url:"maintain/exportMaintain"
}
Utils.exportExcel(options, params, function(){
$scope.$apply(function(){
$scope.isExporting = false
})
})
*/
}
// 详情
$scope.details = function (id) {
var modalInstance = $uibModal
.open({
templateUrl: 'biz/AIniche/view/maintainDetails.html',
controller: 'DetailsInfoDefine',
size: 'lg',
resolve: {
param: function () {
return {
id: id
}
}
}
})
// 弹窗返回值
modalInstance.result
.then(function (data) {
if (data) {
$scope.dtInstance.query(data)
}
})
}
// 跟进记录
$scope.followRecord = function (standNo, id, sn) {
var modalInstance = $uibModal
.open({
templateUrl: 'biz/AIniche/view/followRecord.html',
controller: 'FollowRecordInfoDefine',
size: 'lg',
resolve: {
param: function () {
return {
standNo: standNo,
id: id,
sn: sn
}
}
}
})
// 弹窗返回值
modalInstance.result
.then(function (data) {
if (data) {
// $scope.dtInstance.query(data)
$scope.tableSearch()
}
})
}
}
angular.module('AIniche').controller('maintainRemind', maintainRemind)
})(angular)