add_repair_frm.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<title>填写故障_frm</title>
<link rel="stylesheet" type="text/css" href="../../css/api.css"/>
<link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
<link rel="stylesheet" type="text/css" href="../../css/style.css"/>
<style>
html,
body{
background: #F4F6F9;
}
</style>
</head>
<body>
<div class="repair-info-panel">
<div class="repair-info-inside-panel">
<!-- <div class="aui-row aui-row-flex padding-top-21">
<div class="aui-col aui-col-span-12 aui-row-flex-start">
<span class="repair-measure-obj">设备类型</span>
</div>
<div class="aui-col aui-col-span-12 aui-row-flex-end" tapmode onclick="chooseDeviceType();">
<span class="repair-measure-obj" style="color:rgba(174,184,206,1);margin-right:0.5rem;" id="device_type_inputed">请选择</span>
<i class="repair-down-sign"></i>
</div>
</div>
<div class="repair-panel-line margin-top-21"></div> -->
<div class="aui-row aui-row-flex padding-top-21">
<div class="aui-col aui-col-span-12 aui-row-flex-start">
<span class="repair-measure-obj">设备型号</span>
</div>
<div class="aui-col aui-col-span-12 aui-row-flex-end" tapmode onclick="chooseDeviceModel();">
<span class="repair-measure-obj" style="color:rgba(174,184,206,1);margin-right:0.5rem;" id="device_model_inputed">请选择</span>
<i class="repair-down-sign"></i>
</div>
</div>
<div class="repair-panel-line margin-top-21"></div>
<div class="aui-row aui-row-flex padding-top-21">
<div class="aui-col aui-col-span-12 aui-row-flex-start">
<span class="repair-measure-obj">设备编号</span>
</div>
<div class="aui-col aui-col-span-12 aui-row-flex-end" tapmode onclick="chooseImei();">
<span class="repair-measure-obj" style="color:rgba(174,184,206,1);margin-right:0.5rem;" id="device_imei_inputed">请选择</span>
<i class="repair-down-sign"></i>
</div>
</div>
<div class="repair-panel-line margin-top-21"></div>
<div class="aui-row aui-row-flex padding-top-21">
<div class="aui-col aui-col-span-12 aui-row-flex-start">
<span class="repair-measure-obj">故障分类</span>
</div>
<div class="aui-col aui-col-span-12 aui-row-flex-end" tapmode onclick="chooseType();">
<span class="repair-measure-obj" style="color:rgba(174,184,206,1);margin-right:0.5rem;" id="device_type_inputed">请选择</span>
<i class="repair-down-sign"></i>
</div>
</div>
<div class="repair-panel-line margin-top-21"></div>
<div class="aui-row aui-row-flex padding-top-21">
<div class="aui-col aui-col-span-12 aui-row-flex-start">
<span class="repair-measure-obj">设备所在地址</span>
</div>
<div class="aui-col aui-col-span-12 aui-row-flex-end" tapmode onclick="choosePosition();">
<span class="repair-measure-obj" style="color:rgba(174,184,206,1);margin-right:0.5rem;" id="device_address_inputed">请选择</span>
<i class="repair-down-sign"></i>
</div>
</div>
<div class="repair-panel-line margin-top-21"></div>
<div class="aui-row aui-row-flex padding-top-21">
<div class="aui-col aui-col-span-7 aui-row-flex-start">
<span class="repair-measure-obj">完善详细地址</span>
</div>
<div class="aui-col aui-col-span-17 aui-row-flex-end">
<input id="detail_address" class="aui-input" placeholder="请输入详细地址" type="text" maxlength="15" style="height:1.26rem;text-align:right;font-weight:500;color:rgba(91,127,248,1);font-size:14px;" >
</div>
</div>
<div class="repair-panel-line margin-top-21"></div>
<div class="aui-row aui-row-flex padding-top-21">
<div class="aui-col aui-col-span-6 aui-row-flex-start">
<span class="repair-measure-obj">联系电话</span>
</div>
<div class="aui-col aui-col-span-18 aui-row-flex-end">
<input id="connect_tel" class="aui-input" placeholder="我们将与您联系" type="tel" maxlength="15" style="height:1.26rem;text-align:right;font-weight:500;color:rgba(91,127,248,1);font-size:14px;" >
</div>
</div>
<div class="repair-panel-line margin-top-21"></div>
<div class="aui-row aui-row-flex padding-top-21" style="height:98px;">
<div class="aui-col aui-col-span-6 aui-row-flex-start">
<span class="repair-measure-obj" style="margin-top:1.3rem;">问题描述</span>
</div>
<div class="aui-col aui-col-span-18 aui-row-flex-end" style="margin-top:1.1rem;">
<textarea rows="4" maxlength="50" id="detail_qa" placeholder="为了方便于分析定位问题,请详细描述故障信息" style="height:auto;font-weight:500;color:rgba(91,127,248,1);font-size:14px;"></textarea>
</div>
</div>
<div style="height:21px;"></div>
</div>
</div>
<div class="confirm-btn" tapmode onclick="handleAddRepair();">提交</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/addr.js"></script>
<script type="text/javascript" src="../../script/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../script/ctrl.js"></script>
<script type="text/javascript">
var imeis = [];
var UIActionSelector;
var token;
var types = [];
var userId;
var province,city;
var productInfos
apiready = function(){
api.parseTapmode();
token = api.getPrefs({sync: true,key: 'userToken'});
userId = api.getPrefs({sync: true,key: 'userID'});
// var deviceList = $api.getStorage('devices');
UIActionSelector = api.require('UIActionSelector');
getIssueType();
if (api.pageParam.isAdd) {
api.toast({msg: '提交成功,我们将会尽快为您处理!'});
}
api.addEventListener({
name: 'changeRepairType'
}, function(ret, err){
if( ret ){
$api.html($api.byId('device_type_inputed'), ret.value.curSelect);
}
});
};
function choosePosition() {
UIActionSelector.open({
datas: subjson,
layout: {
row: 5,
col: 2,
height: 30,
size: 12,
sizeActive: 14,
rowSpacing: 5,
colSpacing: 10,
maskBg: 'rgba(0,0,0,0.2)',
bg: '#fff',
color: '#888',
colorActive: '#f00',
colorSelected: '#f00'
},
animation: true,
cancel: {
text: '取消',
size: 12,
w: 90,
h: 35,
bg: '#5B7FF8',
bgActive: '#ccc',
color: '#FFFFFF',
colorActive: '#fff'
},
ok: {
text: '确定',
size: 12,
w: 90,
h: 35,
bg: '#5B7FF8',
bgActive: '#ccc',
color: '#FFFFFF',
colorActive: '#fff'
},
title: {
text: '设备地址',
size: 14,
h: 44,
bg: '#eee',
color: '#000000'
},
fixedOn: api.frameName
}, function(ret, err) {
if (ret && ret['eventType'] == "ok") {
province = ret['level1'];
city = ret['level2'];
$api.html($api.byId('device_address_inputed'), ret['level1'] + ' ' + ret['level2']);
province = ret['level1'];
city = ret['level2'];
}
});
}
async function chooseImei() {
var imeis_ = [];
var listParams = {
user_id: userId,
params: {},
type: "",
imei: "",
limit: 10000,
page: 1
}
let deviceType = $api.html($api.byId('device_model_inputed'));
if (deviceType == "请选择") {
api.toast({msg: '请先选择产品型号!',duration: 2000,location: 'bottom'});
return;
}else {
for (let i = 0; i < productInfos.data.List.length; i++) {
const e = productInfos.data.List[i];
if (e.remark == deviceType) {
listParams.type = e.id
}
}
}
var user_perference = await get_product_perference(userId)
let userPreferenceList = user_perference.data
for (let i = 0; i < userPreferenceList.length; i++) {
const productPref = JSON.parse(userPreferenceList[i]);
const prefList = []
productPref.data_index.forEach(d => {
prefList.push('"'+d+'"')
});
eval('listParams.params["' + productPref.name +'"]=[' + prefList + ']')
}
let deviceListRes = await get_bind_list_data(listParams)
let deviceList = deviceListRes.data.list.rows
let deviceList_ = []
for (let i = 0; i < deviceList.length; i++) {
const l = deviceList[i];
deviceList_.push(deviceList[i].imei)
}
api.actionSheet({
title: '请选择设备编号',
cancelTitle: '取消',
buttons: deviceList_
}, function(ret, err){
if( ret ){
if (ret.buttonIndex != deviceList_.length+1) {
$api.html($api.byId('device_imei_inputed'), deviceList_[ret.buttonIndex-1]);
}
}
});
}
async function chooseDeviceModel() {
productInfos = await get_product_type_list()
let deviceType_ = [];
for (let i = 0; i < productInfos.data.List.length; i++) {
deviceType_.push(productInfos.data.List[i].remark)
}
api.actionSheet({
title: '请选择设备型号',
cancelTitle: '取消',
buttons: deviceType_
}, function(ret, err){
if( ret ){
if (ret.buttonIndex != productInfos.data.List.length+1) {
$api.html($api.byId('device_model_inputed'), productInfos.data.List[ret.buttonIndex-1].remark);
}
}
});
}
function getIssueType() {
$.ajax({
url: HOST + '/iot_api/v2/app/get_issue_type',
type: 'GET',
dataType: 'json',
headers: {
'Content-Type': 'application/json;charset=utf-8',
'token': token
},
success: function(ret) {
if (ret.code == 0) {
types = ret.data;
}
},
error: function() {
api.toast({msg: ERR_MSG,duration: 2000,location: 'bottom'});
}
});
}
function chooseType() {
api.openFrame({
name: 'repair_tools',
url: './repair_tools.html',
rect: {
x: 0,
y: api.pageParam.h,
w: api.winWidth,
h: api.winHeight-api.pageParam.h
},
pageParam: {
typeList: types
},
bounces: false,
animation: {
type:"fade", //动画类型(详见动画类型常量)
subType:"from_bottom", //动画子类型(详见动画子类型常量)
duration:300 //动画过渡时间,默认300毫秒
}
});
}
function handleAddRepair() {
var imeiCode = $api.html($api.byId('device_imei_inputed'));
if (!imeiCode || imeiCode == '请输入设备编号') {
api.toast({msg: '请输入设备编号'});
return;
}
var deviceType = $api.html($api.byId('device_type_inputed'));
if (!deviceType || deviceType == '请选择') {
api.toast({msg: '请选择故障类型'});
return;
}
var deviceAddress = $api.html($api.byId('device_address_inputed'));
if (!deviceAddress || deviceAddress == '请选择') {
api.toast({msg: '请选择设备地址'});
return;
}
var detailAddress = $api.val($api.byId('detail_address'));
if (!detailAddress || detailAddress == '') {
api.toast({msg: '请填写设备详细地址'});
return;
}
var connectTel = $api.val($api.byId('connect_tel'));
if (!connectTel || connectTel == '') {
api.toast({msg: '请填写您的手机号'});
return;
}
if (!checkPhone(connectTel)) {
api.toast({msg: '手机格式有误!'});
return;
}
var detailQa = $api.val($api.byId('detail_qa'));
if (!detailQa || detailQa == '') {
api.toast({msg: '请填写故障详细描述'});
return;
}
//开始提交
$.ajax({
url: HOST + '/iot_api/v2/app/create_issue',
type: 'POST',
dataType: 'json',
headers:{
'Content-Type':'application/json;charset=utf-8',
'token': token
},
data: JSON.stringify({
imei: imeiCode,
user_id: userId,
phone: connectTel,
type: deviceType,
province: province,
city: city,
content: detailQa,
address: detailAddress
}),
success: function(ret) {
if (ret.code == 0) {
api.sendEvent({
name: 'reloadAddRepairFrame',
});
}
},
error: function() {
api.toast({msg: ERR_MSG,duration: 2000,location: 'bottom'});
}
});
}
</script>
</html>