distribution-inventory.vue
25.5 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
<template>
<div class="container resource close-left-menu">
<div class="pop-banner clearfix">
<div class="operate-btns">
<a @click="saveDistribStock" class="fbtn fb-save ml-10 mr-10">保存分配</a>
<a @click="confirm" class="fbtn fb-submit ml-10 mr-10">确认分配</a>
<!-- <a @click="exportsuppliergoodsPO" class="fbtn fb-del ml-10 mr-10">取消分配</a> -->
</div>
<h3 class="current-module">分配库存</h3>
</div>
<div class="supplylist clearfix supply-select">
<div class="supplylist-root pt0 w480">
<!-- <div class="w480 h-40">
<form class="search-bar w370 fl" active="###">
<div class="search-btn fr cur-poin" @click="getDate()">
</div>
<input type="text" placeholder="商品编号、名称、助记码" v-model="search.goodsinfo">
</form>
</div> -->
<table class="itable itable-thead-13px">
<thead>
<tr>
<th class="w50 pt15 pb15">序号</th>
<th class="w40 pt15 pb15">商品名称</th>
<th class="w130 pt15 pb15">规格</th>
<th class="w50 pt15 pb15">单位</th>
<th class="w70 pt15 pb15">最小单位</th>
<th class="w50 pt15 pb15">申领数</th>
<th class="w70 pt15 pb15">库存数</th>
</tr>
</thead>
<tbody>
<tr v-for="mFMedGoods in getApplyDetailList">
<td class="pt7">
<div class="control radio-control">
<input type="radio" id="radio1{{$index+1}}" name="radio1" v-model="checkHospitalGood" value="{{mFMedGoods.guid}}{{mFMedGoods.rowno}}" style="opacity: 0;" v-on:click="getSupDoods(mFMedGoods.guid,mFMedGoods.rowno,mFMedGoods.goodsname,mFMedGoods.depotname,mFMedGoods.applyqty,mFMedGoods.goodsguid,mFMedGoods.depotguid,mFMedGoods.meddeptname)">
<label class="radio mr-0" for="radio1{{$index+1}}"> {{ $index + 1 }}</label>
</div>
</td>
<td class="t-left">{{ mFMedGoods.goodsname}}</td>
<td>{{ mFMedGoods.goodsspec }}</td>
<td>{{ mFMedGoods.unit }}</td>
<td>{{ mFMedGoods.unit }}</td>
<td>{{ mFMedGoods.applyqty }}</td>
<td>{{ mFMedGoods.stocknumber }}</td>
</tr>
</tbody>
</table>
<!-- <div class="pagination" style="margin: 20px 0">
<pagination @page-change="getDate()" :class="['m-20-0']" :page-no.sync="search.page" :total-pages.sync="search.totalPages"></pagination>
</div> -->
</div>
<div class="supplylist-table ml-500">
<div class="fheader no-bottom pd0 h-60">
<p class="fl">商品:<lable class="text-color-red">{{goodsname}}</lable></p><br>
<p class="fl">申领科室:<lable class="text-color-red">{{meddeptname}}</lable></p>
<p class="fl ml-10">待分配申领数量:<lable class="text-color-red">{{sums}}</lable></p>
</div>
<table class="itable itable-thead-13px">
<thead>
<tr>
<th class="w50">序号</th>
<th class="w50">批次号</th>
<th class="w50">批号</th>
<th class="w50">单位</th>
<th class="w50">可分配数</th>
<th class="w50">分配数</th>
<th class="w70">有效期</th>
</tr>
</thead>
<tbody>
<tr v-for="geInfo in getDistribStockInfo">
<td>
<!-- <div class="checkbox-control">
<input type="checkbox" :id="geInfo.guid" @click="selectAll(geInfo,$index,geInfo.guid,geInfo.assignedqty)"
v-model="geInfo.checkboxid"
:value="geInfo.guid">
<label class="checkbox" :for="geInfo.guid">{{ $index + 1 }} </label>
</div> -->
<div class="checkbox-control"> <!-- :checked="mFMedGoods.csupplierguid" -->
<input type="checkbox" :id="geInfo.guid + geInfo.batchguid"
v-model="chSupListListener"
:value="geInfo.guid + geInfo.batchguid" :checked="geInfo.checkboxid">
<label class="checkbox" :for="geInfo.guid + geInfo.batchguid">{{ $index + 1 }}</label>
</div>
</td>
<td class="t-left">{{ geInfo.stockbatch}}</td>
<td>{{ geInfo.lot }}</td>
<td>{{ geInfo.unit }}</td>
<td>{{ geInfo.number }}</td>
<td><input type="text" v-model='geInfo.assignedqty' style="border-radius: 8px;" @change="medCheckInfo(geInfo.guid,geInfo.number,geInfo.assignedqty, $index, 7,geInfo.batchguid)"></td>
<td>
<span class="text-color-yellow" v-if="sh[$index]">{{ geInfo.expiredate | getYMD}}</span>
<span v-else>{{ geInfo.expiredate | getYMD}}</span>
</td>
</tr>
</tbody>
</table>
<div class="pagination hide" style="margin: 20px 0">
<pagination @page-change="getSupDoods()" :class="['m-20-0']" :page-no.sync="search1.page" :total-pages.sync="search1.totalPages"></pagination>
</div>
</div>
</div>
<!--新加提示信息 start -->
<div class="roll-bg" v-show='requestS'>
<div class="w60" style="margin:0 auto;">
<img src="/images/roll.gif">
</div>
<div class="container resource t-center text-color-red">
正在处理中,请勿关闭!
</div>
</div>
<!--新加提示信息 end-->
</template>
<script>
module.exports = {
data: function() {
return {
requestS:false,
search: {
goodsinfo: '',
pageSize: 1500,
page: 1,
totalPages: 0,
total: 0,
pageNo:0
},
search1: {
pageSize: 1500,
page: 1,
totalPages: 0,
total: 0,
pageNo:0
},
getApplyDetailList: '',
checkHospitalGood: '',
getDistribStockInfo:[],
goodsname:'',
depotname:'',
meddeptname:'',
sums:0,
applyqty:'',
goodsguid:'',
flag:'',
guid:'',
rowno:'',
disList:[],
disInfo:{
guid:'',
depotGuid:'',
depotName:'',
details:[]
},
chGoodsList:[],
chSupListListener:[],
sh:[]
};
},
watch:{
// 实时监听复选框勾选变化
'chSupListListener': function (val) {
console.log(val);
var self = this;
if(self.sums > 0){
self.flag = '';
}else{
self.flag = '';
}
for(var j=0; j<self.getDistribStockInfo.length; j++){
if(JSON.stringify(val).indexOf(self.getDistribStockInfo[j].guid+self.getDistribStockInfo[j].batchguid) !=-1 && JSON.stringify(self.chGoodsList).indexOf(self.getDistribStockInfo[j].guid+self.getDistribStockInfo[j].batchguid) ==-1){
var itme = {
/*rowno:self.getDistribStockInfo[j].rowno,
goodsguid:self.getDistribStockInfo[j].goodsguid,
goodsname:self.getDistribStockInfo[j].goodsname,*/
disNumber:self.getDistribStockInfo[j].assignedqty,
lot:self.getDistribStockInfo[j].lot,
guid:self.getDistribStockInfo[j].guid,
flag:self.flag,
batchguid:self.getDistribStockInfo[j].batchguid,
expiredate:self.getDistribStockInfo[j].expiredate,
sssssss:self.getDistribStockInfo[j].guid + self.getDistribStockInfo[j].batchguid
}
var rowno = self.getDistribStockInfo[j].rowno || self.rowno;
itme.rowno = rowno;
var goodsRow = self.getApplyDetailList.filter(function(item,index){
return item.rowno == rowno;
})
if(goodsRow && goodsRow[0]){
itme.goodsguid = goodsRow[0].goodsguid;
itme.goodsname = goodsRow[0].goodsname;
}
self.chGoodsList.push(itme);
}
}
if(self.chSupListListener.length==0){
self.chGoodsList=[];
}else{
for(var i=0;i<self.chGoodsList.length;i++){
if(JSON.stringify(self.chSupListListener).indexOf(self.chGoodsList[i].guid+self.chGoodsList[i].batchguid)==-1 && JSON.stringify(self.chSupListListener).indexOf(self.chGoodsList[i].sssssss)==-1) {
self.chGoodsList.splice(i,1);
}
}
}
console.log(self.chGoodsList);
}
},
methods: {
//左侧商品列表
getDate: function() {
var self = this;
Ajax.post('/procurment/getApplyDetailLists',{'page':self.search.page,'pageSize':self.search.pageSize,'totalPages':self.search.totalPages,'goodsinfo':self.search.goodsinfo,'guid':self.$route.params.guid})
.then(function(response) {
var data = response.data.data;
if(response.data.errorCode == 0) {
self.$set('getApplyDetailList', data.list);
self.search.pageNo = data.pageNo;
self.search.totalPages = data.totalPages;
self.search.total = data.total;
var len = self.getApplyDetailList.length;
if(self.getApplyDetailList && len>0){
for (var i = len-1; i >= 1; i--) {//反着顺序来
var item = self.getApplyDetailList[i];
self.getSupDoods(item.guid,item.rowno,item.goodsname,item.depotname,item.applyqty,item.goodsguid,item.depotguid,item.meddeptname);
}
setTimeout(function () {
var item0 = self.getApplyDetailList[0];
self.getSupDoods(item0.guid,item0.rowno,item0.goodsname,item0.depotname,item0.applyqty,item0.goodsguid,item0.depotguid,item0.meddeptname);
},100)
}
} else {
self.MessageBox({
title: '警告',
message: response.data.message,
type: 'alert'
}, function(action) {});
}
})
},
//右侧商品列表
getSupDoods: function(guid, rowno,goodsname,depotname,applyqty,goodsguid,depotguid,meddeptname) {
var self = this;
self.sums = applyqty;
self.goodsname = goodsname;
self.depotname = depotname;
self.meddeptname = meddeptname;
self.depotguid = depotguid;
self.applyqty = applyqty;
self.goodsguid = goodsguid;
self.guid = guid;
self.rowno = rowno;
self.checkHospitalGood = guid + rowno;
Ajax.post('/procurment/getDistribStockInfo', {
'page': self.search1.page,
'pageSize': self.search1.pageSize,
'totalPages': self.search1.totalPages,
'guid': guid,
'rowno': rowno
}).then(function(response) {
var data = response.data.data;
if(response.data.errorCode == 0) {
self.$set("getDistribStockInfo", data.list);
self.search1.pageNo = data.pageNo;
self.search1.totalPages = data.totalPages;
self.search1.total = data.total;
var sum = 0;
for (var i = 0; i < self.getDistribStockInfo.length; i++) {
for (var j = 0; j < self.chGoodsList.length; j++) {
if(self.chGoodsList[j].guid == self.getDistribStockInfo[i].guid && self.chGoodsList[j].batchguid == self.getDistribStockInfo[i].batchguid){
self.getDistribStockInfo[i].assignedqty = self.chGoodsList[j].disNumber;
// self.$set('getDistribStockInfo['+i+'].checkboxid',true);
}
}
if(self.getDistribStockInfo[i].assignedqty !=null && JSON.stringify(self.chSupListListener).indexOf(self.getDistribStockInfo[i].guid+self.getDistribStockInfo[i].batchguid) ==-1){
var item = self.getDistribStockInfo[i];
self.chSupListListener.push(item.guid + item.batchguid);
sum += Number(item.assignedqty);
}
}
self.sums = self.applyqty - sum;
self.sh = [];
for(var a=0;a<data.list.length;a++){
self.sh.push(false);
var date1 = new Date();
var date2 = new Date(date1);
date2.setMonth(date1.getMonth()+6);
var times = date2.getFullYear()+"-"+(date2.getMonth()+1)+"-"+date2.getDate();
var mxListss = data.list[a];
//有效期
var mxLists = mxListss.expiredate;
if( mxLists != null && mxLists != ''){
var da1 = mxLists.replace(/\-/gi,"/");
}
if( times != null && times != ''){
var da2 = times.replace(/\-/gi,"/");
}
var time1 = new Date(da1).getTime();
var time2 = new Date(da2).getTime();
if(time1 <= time2){
self.sh.splice(a,1,true);
}
}
} else {
self.MessageBox({
title: '警告',
message: response.data.message,
type: 'alert'
}, function(action) {});
}
})
},
//保存分配
saveDistribStock: function() {
var self = this;
console.log(self.chGoodsList);
if(self.chGoodsList.length == 0){
self.MessageBox({
title: '提示信息',
message: '请为商品勾选分配数!',
type: 'alert'
}, function(action) {});
return;
}
for (var i = 0; i < self.chGoodsList.length; i++) {
if(self.chGoodsList[i].disNumber == '' || self.chGoodsList[i].disNumber == null){
self.MessageBox({
title: '提示信息',
message: '请为【'+self.chGoodsList[i].goodsname+'】填写分配数!',
type: 'alert'
}, function(action) {});
return;
}
var str = self.chGoodsList[i].disNumber.toString();
if(str != null && str != ''){
self.chGoodsList[i].disNumber = str.replace(/(^\s*)|(\s*$)/g, "");
}
}
self.disInfo.guid = self.guid;
self.disInfo.depotGuid = self.depotguid;
self.disInfo.depotName = self.depotname;
self.disInfo.details = self.chGoodsList;
for (var j = 0; j < self.getApplyDetailList.length; j++) {
if(JSON.stringify(self.chGoodsList).indexOf(self.getApplyDetailList[j].goodsguid) ==-1){
self.MessageBox({
title: '提示信息',
message: '请为【'+self.getApplyDetailList[j].goodsname+'】勾选分配数!',
type: 'alert'
}, function(action) {});
return;
}
}
self.requestS = true;
Ajax.post('/procurment/saveDistribStock', {
'disInfo': self.disInfo,
})
.then(function(response) {
var data = response.data.data;
self.requestS = false;
if(response.data.errorCode == 0) {
self.MessageBox({
title: '提示信息',
message: response.data.message,
type: 'alert'
}, function(action) {
self.chGoodsList = [];
window.location.reload();
});
} else {
self.MessageBox({
title: '警告',
message: response.data.message,
type: 'alert'
}, function(action) {});
}
})
},
//提交保存
confirm: function() {
var self = this;
for (var i = 0; i < self.chGoodsList.length; i++) {
if(self.chGoodsList[i].disNumber == '' || self.chGoodsList[i].disNumber == null){
self.MessageBox({
title: '提示信息',
message: '请为【'+self.chGoodsList[i].goodsname+'】填写分配数!',
type: 'alert'
}, function(action) {});
return;
}
var str = self.chGoodsList[i].disNumber.toString();
if(str != null && str != ''){
self.chGoodsList[i].disNumber = str.replace(/(^\s*)|(\s*$)/g, "");
}
}
self.disInfo.guid = self.guid;
self.disInfo.depotGuid = self.depotguid;
self.disInfo.depotName = self.depotname;
self.disInfo.details = self.chGoodsList;
if(self.disInfo.details.length == 0){
self.MessageBox({
title: '提示信息',
message: '请为商品勾选分配数!',
type: 'alert'
}, function(action) {});
return;
}
for (var j = 0; j < self.getApplyDetailList.length; j++) {
if(JSON.stringify(self.chGoodsList).indexOf(self.getApplyDetailList[j].goodsguid) ==-1){
self.MessageBox({
title: '提示信息',
message: '请为【'+self.getApplyDetailList[j].goodsname+'】勾选分配数!',
type: 'alert'
}, function(action) {});
return;
}
}
self.requestS = true;
Ajax.post('/procurment/saveDistribStock', {
'disInfo': self.disInfo,
})
.then(function(response) {
var data = response.data.data;
self.requestS = false;
if(response.data.errorCode == 0) {
self.confirmDistribStock();
self.chGoodsList = [];
self.chSupListListener = [];
} else {
self.MessageBox({
title: '警告',
message: response.data.message,
type: 'alert'
}, function(action) {});
}
})
},
//确认分配
confirmDistribStock: function() {
var self = this;
Ajax.post('/procurment/confirmDistribStock', {
'guid': self.guid,
})
.then(function(response) {
var data = response.data.data;
if(response.data.errorCode == 0) {
self.chGoodsList = [];
self.MessageBox({
title: '提示信息',
message: response.data.message,
type: 'alert'
}, function(action) {
//跳转
self.$router.go({
path: '/requisition'
});
});
} else {
self.MessageBox({
title: '警告',
message: response.data.message,
type: 'alert'
}, function(action) {});
}
})
},
// 验证系数
medCheckInfo: function(guid,po1,po, index, code,batchguid) {
var self = this;
var sum = 0;
for (var j = 0; j < self.chGoodsList.length; j++) {
if(self.chGoodsList[j].guid ==guid && self.chGoodsList[j].batchguid ==batchguid){
self.chGoodsList[j].disNumber = po;
}
if(self.chGoodsList[j].disNumber != null){
sum += Number(self.chGoodsList[j].disNumber)
}
}
var sum1 = 0;
for (var d = 0; d < self.getDistribStockInfo.length; d++) {
if(self.getDistribStockInfo[d].assignedqty != null){
sum1 += Number(self.getDistribStockInfo[d].assignedqty)
}
}
if(po <= 0 || po > po1 || sum1 > self.applyqty || isNaN(po)) { // || sum > self.applyqty
self.MessageBox({
title: '警告',
message: "请输入大于0小于可分配数、申领数的正整数!",
type: 'alert'
}, function(action) {
if(action == 'confirm') {
if(code == 7) {
self.$set('getDistribStockInfo[' + index + '].assignedqty', '');
self.sums = 0;
} else {
self.$set('getDistribStockInfo[' + index + '].assignedqty', '');
self.sums = 0;
}
}
});
}
console.log(self.chGoodsList);
self.sums = self.applyqty - sum1;
},
},
route: {
activate: function() {
this.getDate();
this.chGoodsList = [];
this.chSupListListener = [];
this.checkHospitalGood='';
}
}
};
</script>