acc_batch.html
18 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
<!--验收列表 - 药品信息 列表页 - wwb-->
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="import" href="batch_list_tpl.html" id="list_tpl" />
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link href="../../css/mui.min.css" rel="stylesheet" />
<link href="../../css/themes.css" rel="stylesheet" />
<link href="../../css/index_view.css" rel="stylesheet" />
</head>
<body>
<div class="mui-content">
<header class="mui-bar mui-bar-nav themes_bg_color">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left">
<label class="mui-pull-right theme_back_font">返回</label>
</a>
<h1 class="mui-title themes_title">药品信息</h1>
</header>
<div class="home-card-wrapper" style="padding: 8px;margin-top: 0;margin-bottom: 8px;">
<div class="home-card-title">待验收</div>
</div>
<div id="slider" class="mui-slider themes_tab mui-fullscreen" style="margin-top: 45px;padding-bottom: 59px;">
<div class="mui-slider-group">
<div id="item1mobile" class="mui-slider-item mui-control-content">
<div id="scroll1" class="mui-scroll-wrapper">
<div class="mui-scroll" id="mui-table-view-tab1">
<ul class="mui-table-view">
<li class="mui-table-view-cell mui-tab1" style="padding: 0;">
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="fix_bottom-wraper">
<div class="fix-bottom-content">
<div class="mui-checkbox mui-left">
<label>全选</label>
<input name="checkboxAll" value="1" id="checkall" type="checkbox" style="top: -5px;z-index: 10;">
</div>
<span style="margin-left: 8px;">已选中 <label class="total"> 0 </label> 项</span>
</div>
<a href="javascript:;" class="btn acceptance fix-bottom-extra">验 收</a>
</div>
</div>
<script src="../../js/mui.min.js"></script>
<script src="../../js/jquery.min.js"></script>
<script src="../../js/mui.pullToRefresh.js"></script>
<script src="../../js/mui.pullToRefresh.material.js"></script>
<script src="../../js/template-web.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/utils.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/common.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/request.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
(function($, $JQ) {
$.init({
beforeback: function() {
var list = plus.webview.currentWebview().opener();
mui.fire(list, 'pagefresh', { selectTabs: '1', query: params.query || {} });
return true;
}
})
var page = 1,
totalPage = undefined,
pageSize = 15,
isMore = true;
var checkType = undefined,
status = undefined, // 验收单类型 // 验收状态 1 待验收 2 已验收
params = undefined,
distributeCode = undefined,
isShowTemprature = undefined,
barcode = undefined,
isPsList = undefined,
selectedRows = [],
acceptList = [],// 数据
selecteIndex = [];
var _url = '/a/exam/detail', // 分页接口
checkUrl = '/a/checkacceptdetail/checkList';
/* 渲染模板 */
var utils = new Utils();
utils.appendModule('#list_tpl');
var deceleration = mui.os.ios?0.003:0.0009;
$('.mui-scroll-wrapper').scroll({
bounce: true,
indicators: true, //是否显示滚动条
deceleration:deceleration
});
function template(data, insertType,render) {
utils.innerTplHtml('batch_list_tpl_view', '.mui-tab1', data, insertType);
if(render){
var checkList = document.querySelectorAll('.checkone');
mui.each(selecteIndex, function(index, item) {
checkList[item].checked = true;
});
}
}
/* 下拉刷新 */
function pulldownRefresh() {
// 重置 勾选项
document.querySelector('.total').innerText = 0;
document.querySelector('#checkall').checked = false;
selecteIndex = [];
var self = this;
page = 1;
var postData = {
distributeCode: distributeCode,
status: status,
pageNo: page,
pageSize: pageSize
};
if(barcode){
_url = '/a/exam/padDetail'
postData = {
barcode: barcode,
status: status,
pageNo: page,
pageSize: pageSize
};
}else{
_url = '/a/exam/detail'
}
mui.ajaxRequest(_url, {
type: 'POST',
data: postData,
success: function(data) {
if(data.code == 200){
var resData = data.data;
resData.page = page;
resData.pageSize = pageSize;
acceptList = resData.list;
resData.acceptance = true;
resData.checkType = checkType;
resData.barcode = barcode;
resData.isPsList = isPsList;
totalPage = data.totalPage;
console.log( resData.list.length === 0 || (resData.list.length <= resData.pageSize && resData.pageNo === resData.totalPage))
if(resData.list.length === 0 || (resData.list.length <= resData.pageSize && resData.pageNo === resData.totalPage)){
isMore = false;
self.endPullDownToRefresh(true);
document.querySelectorAll('.mui-pull-loading')[0].innerHTML = '没有更多数据';
} else {
isMore = true;
self.endPullDownToRefresh(false);
self.refresh(true);
}
return template(resData, false)
}else{
self.endPullDownToRefresh(true);
document.querySelectorAll('.mui-pull-loading')[0].innerHTML = '没有更多数据';
//mui.alert(data.msg,'提示','确定',function (e) {},'div');
}
},
error: function(xhr, type, errorThrown) {
console.log(xhr.responseText)
}
});
}
/*
* 上拉加载更多
* */
function pullupRefresh() {
document.querySelector('#checkall').checked = false;
var self = this;
console.log(isMore, 'isMore');
if (isMore) {
page++;
var paramData = {
distributeCode: distributeCode,
status: status,
pageNo: page,
pageSize: pageSize
}
if(barcode){
_url = '/a/exam/padDetail'
paramData = {
barcode: barcode,
status: status,
pageNo: page,
pageSize: pageSize
};
}else{
_url = '/a/exam/detail'
}
mui.ajaxRequest(_url, {
type: 'POST',
data: paramData,
success: function(data) {
if(data.code == 200){
var resData = data.data;
resData.page = page;
resData.pageSize = pageSize;
mui.each(resData.list,function(index,item){
acceptList.push(item)
});
resData.acceptance = true;
resData.checkType = checkType;
resData.barcode = barcode;
resData.isPsList = isPsList;
if (resData.pageNo === resData.totalPage) {
isMore = false;
self.endPullUpToRefresh(true);
} else {
isMore = true;
self.endPullUpToRefresh(false);
self.refresh(true);
}
return template(resData, true,'rerender')
}else{
//mui.alert(data.msg,'提示','确定',function (e) {},'div');
isMore = false;
self.endPullUpToRefresh(true);
}
},
error: function(xhr, type, errorThrown) {
console.log(xhr.responseText)
}
});
} else {
document.querySelectorAll('.mui-pull-loading')[0].innerHTML = '没有更多数据';
self.endPullUpToRefresh(true);
}
}
// 模板加载
$.plusReady(function() {
window.addEventListener('pagefresh',function(event){
mui('.mui-scroll-wrapper').scroll().scrollTo(0,0,100);
mui(".mui-scroll").pullToRefresh().pullDownLoading();
});
var self = plus.webview.currentWebview();
params = JSON.parse(self.params); //获得参数
distributeCode = params.distributeCode;
status = params.status;
checkType = params.checkType;
isShowTemprature = params.isShowTemprature;
barcode = params.barcode;
isPsList = params.isPsList;
console.log(checkType,'checkType')
console.log(params);
//循环初始化所有下拉刷新,上拉加载。
$.each(document.querySelectorAll('.mui-scroll'), function(index, pullRefreshEl) {
$(pullRefreshEl).pullToRefresh({
down: {
style: 'circle',
contentdown: "下拉可以刷新",
contentover: "释放立即刷新",
contentrefresh: "正在刷新...",
callback: pulldownRefresh
},
up: {
contentrefresh: "正在加载...", //可选,正在加载状态时,上拉加载控件上显示的标题内容
contentnomore: '没有更多数据',
callback: pullupRefresh
}
});
});
// 第一个tab 默认加载一次数据
mui(".mui-scroll").pullToRefresh().pullDownLoading();
// 全选 及反选
$('.fix_bottom-wraper').on('click', '#checkall', function() {
selecteIndex = [];
var checkList = document.querySelectorAll('.checkone');
if (document.querySelector('#checkall').checked) {
// 全选
mui.each(checkList, function(index, item) {
item.checked = true;
selecteIndex.push(index);
});
document.querySelector('.total').innerText = checkList.length;
} else {
// 取消全选
mui.each(checkList, function(index, item) {
item.checked = false
});
document.querySelector('.total').innerText = 0;
selectedRows = [];
selecteIndex = []
}
console.log(selecteIndex)
});
// 复选框选中
$('#slider').on('change', '.checkone', function(e, index) {
selectedRows = [];
selecteIndex = [];
console.log(JSON.stringify(e), this.dataset)
var checkList = document.querySelectorAll('.checkone')
var checkAll = document.querySelector('#checkall');
var checkLen = checkList.length;
var len = 0;
mui.each(checkList,function(index,item){
if(item.checked){
len++;
selecteIndex.push(Number(this.dataset.index));
}
});
checkAll.checked = len === checkLen ? true : false;
document.querySelector('.total').innerText = len;
console.log(selecteIndex)
})
// 绑定事件 --确认验收
$('.fix_bottom-wraper').on('tap', '.acceptance', function() {
document.activeElement.blur(); // 隐藏软键盘
console.log(document.querySelector('.total').innerText)
if (Number(document.querySelector('.total').innerText) === 0) {
return mui.alert('请至少选中一项', '警告', ['确认'], function() {}, 'div')
}
var cards = document.querySelectorAll('.am-card');
let detailList = [],
submitData = {};
if (params.isPsList || params.barcode) {
let selectedCards = [],
cardFactNum = [];
mui.each(selecteIndex, function(index, item) {
selectedCards.push(cards[item]);
if (cards[index].dataset.isusual === '0') {
// 正常单据
cardFactNum.push(cards[item].querySelector('.realReceiveQuantiry'));
} else {
// 异常单据
cardFactNum.push(cards[item].querySelector('.errorQuantiry'))
}
});
var flag = true;
mui.each(cardFactNum, function(index, item) {
if (item.tagName === 'INPUT') {
if (!item.value) {
flag = false;
}
}
})
if (!flag) {
return mui.alert('实到数量不能为空', '警告', ['确定'], function() {}, 'div');
};
mui.each(selectedCards, function(index, item) {
var postData = {};
postData.id = item.dataset.id;
postData.isUsual = item.dataset.isusual;
postData.drugCode = item.dataset.drugcode;
postData.distributeCode = item.dataset.distributecode;
postData.rowNo = item.dataset.rowno;
if (item.dataset.isusual === '0') {
var realReceiveQuantiry = item.querySelector('.realReceiveQuantiry').value;
var realProductTime = item.querySelector('.realProductTime').value;
var productBatchNo = item.querySelector('.productBatchNo').value;
var realValidEndDate = item.querySelector('.realValidEndDate').value;
if (isShowTemprature === 1) {
var realAcceptanceTemperature = item.querySelector('.realAcceptanceTemperature').value;
postData.realAcceptanceTemperature = realAcceptanceTemperature
}
postData.realReceiveQuantiry = realReceiveQuantiry;
postData.realProductTime = realProductTime;
postData.productBatchNo = productBatchNo;
postData.realValidEndDate = realValidEndDate;
} else {
var errorQuantiry = item.querySelector('.errorQuantiry').innerText;
var errRealProductTime = item.querySelector('.errRealProductTime').innerText;
var errVailEndDate = item.querySelector('.errVailEndDate').innerText;
postData.realReceiveQuantiry = errorQuantiry;
postData.realProductTime = errRealProductTime;
postData.productBatchNo = item.dataset.productbatchno;
postData.realValidEndDate = errVailEndDate;
}
detailList.push(postData);
});
} else {
mui.each(selecteIndex, function(index, item) {
let postData = {};
postData.realReceiveQuantiry = acceptList[item].realNum;//应海洪的要求改的
postData.realProductTime = acceptList[item].realProductTime;
postData.productBatchNo = acceptList[item].productBatchNo;
postData.realValidEndDate = acceptList[item].realValidEndDate;
postData.id = acceptList[item].id;
postData.isUsual = acceptList[item].isUsual;
if (isShowTemprature === 1) {
postData.realAcceptanceTemperature = acceptList[item].realAcceptanceTemperature;
}
postData.drugCode = acceptList[item].drugCode;
postData.distributeCode = acceptList[item].distributeCode;
postData.rowNo = acceptList[item].rowNo;
detailList.push(postData);
});
}
submitData.detailList = detailList;
submitData.distributeCode = distributeCode;
if(barcode){
submitData.barcode = barcode;
}
console.log(submitData)
var btnArray = ['否', '是'];
mui.confirm('确认批量验收选中的药品?', '确认', btnArray, function(e) {
if (e.index == 1) {
mui.ajaxRequest(checkUrl, {
type: 'POST',
data: submitData,
showWaiting: true,
contentType: "application/json",
success: function(data) {
if (data.code === 200) {
var text = "验收成功!";
if(data.data[0]){
text = data.data[0];
}
mui.alert(text,'提示','确定',function (e) {
$JQ('.total').text(0);
document.querySelector('#checkall').checked=false;
setTimeout(function(){
mui('.mui-scroll-wrapper').scroll().scrollTo(0,0);
mui(".mui-scroll").pullToRefresh().pullDownLoading();
},300)
},'div');
}else{
mui.alert(data.mag,'提示','确定',function (e) {},'div');
}
},
error: function(xhr, type, errorThrown) {
console.log(xhr.responseText)
}
})
}
}, 'div')
});
//绑定输入实到数量验证
var countModal = false;
$JQ('#slider').on('keyup','.realReceiveQuantiry',function(){
var _this = this,$this = $JQ(this);
var index = this.dataset.index;
var value = Number(this.value?this.value:0);
var _this_node = document.querySelectorAll('.am-card')[index];
var realDeliveryQuantiry = _this_node.dataset.realdeliveryquantiry?_this_node.dataset.realdeliveryquantiry:0;
var realReceiveQuantiry = _this_node.dataset.realnum?_this_node.dataset.realnum:0;
var compareNum = realDeliveryQuantiry;
var text = "实到数量不能大于数量"+compareNum+",且不能小于0!";
if(barcode){
compareNum = realReceiveQuantiry;
text = "实到数量不能大于条码数量"+compareNum+",且不能小于0!";
}
if(!countModal){
if(value<0 || value>compareNum){
countModal = true;
mui.alert(text,'提示','确定',function (e) {
countModal = false;
_this.value = compareNum;
},'div')
}
}
});
//生产日期与有效日期验证
$JQ('#slider').on('change','.realProductTime,.realValidEndDate',function(){
var _this = this,$this = $JQ(this);
var index = this.dataset.index,cls = this.className;
var _this_node = document.querySelectorAll('.am-card')[index];
var realProductTime = _this_node.dataset.realproducttime?_this_node.dataset.realproducttime:"0";
var realValidEndDate = _this_node.dataset.realvalidenddate?_this_node.dataset.realvalidenddate:"0";
var value = this.value?this.value:"0";
var _realProductTime = "",_realValidEndDate = "";
if(realProductTime.indexOf("-") != -1){
_realProductTime = Number(realProductTime.replace(/-/g,""));
}
if(realValidEndDate.indexOf("-") != -1){
_realValidEndDate = Number(realValidEndDate.replace(/-/g,""));
}
if(value.indexOf("-") != -1){
value = Number(value.replace(/-/g,""));
}
if(cls.indexOf("realProductTime")!=-1){//生产日期
var text1 = "生产日期不能大于有效日期!";
if(value > _realValidEndDate){
mui.alert(text1,'提示','确定',function (e) {
_this.value = realProductTime;
},'div')
}
}else if(cls.indexOf("realValidEndDate")!=-1){//有效期至
var text2 = "有效日期不能小于生产日期!";
if(value < _realProductTime){
mui.alert(text2,'提示','确定',function (e) {
_this.value = realValidEndDate;
},'div')
}
}
});
});
})(mui, jQuery);
</script>
</body>
</html>