customerDeviceCtrl.js
10.9 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
(function (angular) {
function customerDeviceCtrl($scope, customerService, DTColumnBuilder, DTOptionsBuilder, $http, $state, $uibModal, Utils) {
$scope.fieldName = 'merchantId';
$scope.fieldName2 = 'createdBy';
$scope.dtColumns = [
DTColumnBuilder.newColumn('imei').withOption('width', 60).withTitle('IMEI/SN号'),
DTColumnBuilder.newColumn('deviceTypeId').withOption('width', 60).withTitle('设备类型').renderWith(function (data, type, full, oSettings) {
return {
1: 'OBD',
2: '云导航',
3: '电子狗',
5: 'TBOX(2G)',
6: '记录仪',
7: 'BBOX',
8: 'GPS',
9: '车载wifi',
12134: '后视镜',
12501: '智能蓝牙耳机车充'
} [data] || '--'
}),
DTColumnBuilder.newColumn('merchantName').withOption('width', 60).withTitle('商户名称'),
DTColumnBuilder.newColumn('merchantId').withOption('width', 60).withTitle('商户号'),
DTColumnBuilder.newColumn('isAuth').withOption('width', 50).withTitle('实名认证').renderWith(function (data, type, full, oSettings) {
if (data === 1 || data == "1") {
return "已实名"
} else {
return "未实名"
}
}),
DTColumnBuilder.newColumn('source').withOption('width', 80).withTitle('来源').renderWith(function (data, type, full, oSettings) {
if (data === 1 || data == "1") {
return "手机端录入"
} else if (data === 2 || data == "2") {
return "PC后台导入"
} else if (data === 3 || data == "3") {
return "PC后台添加"
} else if (data === 4 || data == "4") {
return "系统预录"
} else {
return "--"
}
}),
DTColumnBuilder.newColumn('phone').withOption('width', 100).withTitle('客户电话'),
DTColumnBuilder.newColumn('name').withOption('width', 60).withTitle('客户姓名'),
DTColumnBuilder.newColumn('gender').withOption('width', 60).withTitle('性别').renderWith(function (data, type, full, oSettings) {
if(data === 1 || data == '1'){
return "男"
} else if(data === 2 || data == '2'){
return "女"
} else {
return "- -"
}
}),
DTColumnBuilder.newColumn('plateNum').withOption('width', 60).withTitle('车牌号'),
DTColumnBuilder.newColumn('standNo').withOption('width', 100).withTitle('车架号'),
DTColumnBuilder.newColumn(null).withOption('width', 60).withTitle('车型').renderWith(data => {
let str = data.vehicleBrand ? `<div>${data.vehicleBrand}<br/></div>` : '<div>- -</div>'
return str
}),
DTColumnBuilder.newColumn('installMileage').withOption('width', 100).withTitle('设备安装时车辆里程'),
DTColumnBuilder.newColumn('nextMaintainMileage').withOption('width', 80).withTitle('下次保养里程'),
DTColumnBuilder.newColumn('nextMaintainTime').withOption('width', 100).withTitle('下次保养时间').renderWith(function (data, type, full, oSettings) {
if (data) {
return data.split(" ")[0];
}
return "";
}),
DTColumnBuilder.newColumn('lastMaintainMileage').withOption('width', 80).withTitle('上次保养里程'),
DTColumnBuilder.newColumn('lastMaintainTime').withOption('width', 100).withTitle('上次保养时间').renderWith(function (data, type, full, oSettings) {
if (data) {
return data.split(" ")[0];
}
return "";
}),
DTColumnBuilder.newColumn('iccid').withOption('width', 110).withTitle('ICCID').renderWith(function (data, type, full, oSettings) {
if (data) {
return data;
}
return "";
}),
DTColumnBuilder.newColumn('dispatchOrderCode').withOption('width',100).withTitle('订单号'),
DTColumnBuilder.newColumn('createdDate').withOption('width', 90).withTitle('操作时间'),
DTColumnBuilder.newColumn('employeeName').withOption('width', 80).withTitle('录入员工'),
DTColumnBuilder.newColumn('createdBy').withOption('width', 80).withTitle('操作人登录账号'),
DTColumnBuilder.newColumn('isChange').withOption('width', 80).withTitle('是否更换设备').renderWith(function (data, type, full, oSettings) {
if(data === 1 || data == '1'){
return "保修更换-免费"
} else if(data == 2 || data == '2'){
return "维修更换"
} else if(data == 3 || data == '3'){
return "购买"
} else {
return "- -"
}
}),
DTColumnBuilder.newColumn(null).withTitle('操作').withOption('width', 100).renderWith((data, type, full, oSettings) => {
let {
id,
vehicleBrand,
vehicleBrandId,
vehicleChildsBrandName,
vehicleChildsBrandId,
vehicleSeriesName,
vehicleSeriesId,
vehicleTypeId,
vehicleTypeName,
imei,
phone,
name,
gender,
plateNum,
standNo,
isAuth,
isChange
} = data
let _data = JSON.stringify({
id,
vehicleBrand,
vehicleBrandId,
vehicleChildsBrandName,
vehicleChildsBrandId,
vehicleSeriesName,
vehicleSeriesId,
vehicleTypeId,
vehicleTypeName,
imei,
phone,
name,
gender,
plateNum,
standNo,
isAuth,
isChange
})
let str = `<a class="btn-link" style="padding:0 5px;" ng-click='change(${_data})' >修改用户信息</a>`
return str
})
];
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withOption('id', 'id')
.withFixedColumns({
leftColumns: 1,
rightColumns: 1
})
.withOption('lengthMenu', [10, 20, 40, 60, 100])
.withOption('num', true);
$scope.dtInstance = {
serverData: customerService.listCustomerDevicePage
};
$scope.change = data => {
$uibModal.open({
templateUrl: 'biz/customer/view/updateDeviceModel.html',
controller: 'updateDeviceModelCtrl',
size: 'xs',
resolve: {
parentData: function () {
return data
}
}
}).result.then(function (data) {
$scope.select()
})
}
//查询条件
$scope.filter = {
time: moment(),
factoryMerchantId:''
};
$scope.drOptions = {
opens: 'right',
eventHandlers: {
'apply.daterangepicker': function (ev, picker) {
$scope.filter.time.startDate = picker.startDate;
$scope.filter.time.endDate = picker.endDate;
},
'cancel.daterangepicker': function (ev, picker) {
$scope.filter.time = {}
$scope.filter.time.startDate = null;
$scope.filter.time.endDate = null;
$scope.$apply()
}
}
};
$scope.getParam = function () {
var param = {};
if ($scope.imei) {
param.imei = $scope.imei;
}
var factoryMerchantId = $scope.factoryMerchantId;
var provinceMerchantId = $scope.provinceMerchantId;
var cityMerchantId = $scope.cityMerchantId;
var shopMerchantId = $scope.shopMerchantId;
if(factoryMerchantId) {
param.factoryMerchantId = $scope.factoryMerchantId;
}
if(provinceMerchantId) {
param.provinceMerchantId = $scope.provinceMerchantId;
}
if(cityMerchantId) {
param.cityMerchantId = $scope.cityMerchantId;
}
if(shopMerchantId) {
param.shopMerchantId = $scope.shopMerchantId;
}
if ($scope.isBind) {
param.isBind = $scope.isBind
}
if ($scope.fieldName && $scope.fieldValue) {
if ($scope.fieldName == 'merchantId') {
var m = -1;
if (/^[1-9]\d*$/.test($scope.fieldValue)) {
m = parseInt($scope.fieldValue) || -1;
if (m > 2147483647) {
m = -1;
}
}
param[$scope.fieldName] = m;
} else {
param[$scope.fieldName] = $scope.fieldValue;
}
}
if ($scope.fieldName2 && $scope.fieldValue2) {
param[$scope.fieldName2] = $scope.fieldValue2;
}
if ($scope.deviceTypeId) {
param.deviceTypeId = $scope.deviceTypeId;
}
if ($scope.createdBy) {
param.createdBy = $scope.createdBy;
}
if ($scope.filter.time) {
if ($scope.filter.time.startDate) {
param.startDate = $scope.filter.time.startDate.format('YYYY-MM-DD') + " 00:00:00";
}
if ($scope.filter.time.endDate) {
param.endDate = $scope.filter.time.endDate.format('YYYY-MM-DD') + " 23:59:59";
}
if ($scope.isAuth) {
param.isAuth= $scope.isAuth
}
if ($scope.source) {
param.source = $scope.source;
}
}
var obj = {
condition: param
};
return obj;
}
$scope.select = function () {
var param = $scope.getParam();
$scope.dtInstance.query(param);
}
$scope.importExcel = function () {
$uibModal.open({
templateUrl: 'biz/customer/view/customerImportModal.html',
controller: 'customerImportModalCtrl',
size: 'md',
scope: $scope,
resolve: {
importConfig: function () {
return {
pageTitle: '设备录入', //弹框标题
ajaxUrl: 'customer/customerDevice/import', //导入服务地址
downloadType: '13', //下载导入模板类型
importTemplate: '设备录入-模版', //下载导入模板文件名
errorDown: '设备录入报错下载.xlsx'
};
}
}
}).result.then(function () {
//关闭弹框后执行方法
}, function () {
$scope.select();
});
};
// 添加设备
$scope.handleAdd = function () {
$uibModal.open({
templateUrl: 'biz/customer/view/addDeviceModel.html',
controller: 'addDeviceModelCtrl',
size: 'md',
resolve: function() {
return {}
}
}).result.then(function(isRefresh) {
if(isRefresh) {
$scope.select()
}
}, function () {})
};
// 添加设备
$scope.handleUpdate = function () {
$uibModal.open({
templateUrl: 'biz/customer/view/updateDeviceModel.html',
controller: 'updateDeviceModelCtrl',
size: 'md',
resolve: function() {
return {}
}
}).result.then(function(isRefresh) {
if(isRefresh) {
$scope.select()
}
}, function () {})
};
$scope.exportExcel = function () {
var options = $scope.getParam().condition;
Utils.exportExcel2('customer/customerDevice/export', options, '设备录入');
};
}
angular.module('customer').controller('customerDeviceCtrl', customerDeviceCtrl);
})(angular);