|
@@ -3,7 +3,7 @@
|
3
|
3
|
<div class="position">
|
4
|
4
|
<bread-crumb :crumbs="crumbs"></bread-crumb>
|
5
|
5
|
</div>
|
6
|
|
-<div class="app-container ">
|
|
6
|
+<div class="app-container" v-loading="loading">
|
7
|
7
|
<div style="justify-content: space-between;margin: 0px 0 12px 0;display: flex;align-items: center;">
|
8
|
8
|
<div>
|
9
|
9
|
<span style="color:red">*</span><span>供应商:</span>
|
|
@@ -44,11 +44,13 @@
|
44
|
44
|
value-format="yyyy-MM-dd"
|
45
|
45
|
@change="endTimeChange"
|
46
|
46
|
></el-date-picker>
|
47
|
|
- <span>单据编码:</span>
|
|
47
|
+ <span>单据编码:{{number}}</span>
|
48
|
48
|
|
49
|
49
|
</div>
|
50
|
50
|
<div>
|
51
|
51
|
<el-button size="small" type="primary" @click="savePurchaseOrder" v-show="showTwo">保存</el-button>
|
|
52
|
+ <el-button size="small" type="primary" @click="updatePurchaseOrder" v-show="showOne">打印</el-button>
|
|
53
|
+ <el-button size="small" type="primary" @click="updatePurchaseOrder" v-show="showOne">审核</el-button>
|
52
|
54
|
<el-button size="small" type="primary" @click="updatePurchaseOrder" v-show="showOne">修改</el-button>
|
53
|
55
|
</div>
|
54
|
56
|
</div>
|
|
@@ -71,7 +73,7 @@
|
71
|
73
|
<span>商品<span style="color: red">*</span></span>
|
72
|
74
|
</template>
|
73
|
75
|
<template slot-scope="scope">
|
74
|
|
- <el-form-item required prop="name">
|
|
76
|
+ <el-form-item :prop="'tableList.' + scope.$index + '.name'" :rules='tableRules.name'>
|
75
|
77
|
<el-select v-model="scope.row.name" style="width:160px;" filterable placeholder="请选择" @change="changeName" @input="changeGoodName(scope.$index)">
|
76
|
78
|
<el-option
|
77
|
79
|
v-for="(item,index) in tabList"
|
|
@@ -106,8 +108,8 @@
|
106
|
108
|
<span>数量<span style="color: red">*</span></span>
|
107
|
109
|
</template>
|
108
|
110
|
<template slot-scope="scope">
|
109
|
|
- <el-form-item :rules="tableRules.supply_count" required prop="supply_count">
|
110
|
|
- <el-input v-model="scope.row.supply_count" style="width:80px"></el-input>
|
|
111
|
+ <el-form-item :prop="'tableList.' + scope.$index + '.supply_count'" :rules='tableRules.supply_count'>
|
|
112
|
+ <el-input v-model="scope.row.supply_count" style="width:80px"></el-input>
|
111
|
113
|
</el-form-item>
|
112
|
114
|
</template>
|
113
|
115
|
</el-table-column>
|
|
@@ -166,6 +168,9 @@
|
166
|
168
|
</el-table-column>
|
167
|
169
|
</el-table>
|
168
|
170
|
</el-form>
|
|
171
|
+ <div style="margin-top:10px">
|
|
172
|
+ 合计:{{getAllPrice()}} 元
|
|
173
|
+ </div>
|
169
|
174
|
<div style="margin-top:10px">
|
170
|
175
|
<span>优惠率:<el-input style="width:100px" v-model="rate_of_concession"></el-input>%</span>
|
171
|
176
|
|
|
@@ -178,8 +183,8 @@
|
178
|
183
|
|
179
|
184
|
<script>
|
180
|
185
|
import BreadCrumb from "@/xt_pages/components/bread-crumb";
|
181
|
|
-
|
182
|
|
-import {getInitOrder,savePurchaseOrder} from "@/api/supply"
|
|
186
|
+import {uParseTime } from '@/utils/tools'
|
|
187
|
+import {getInitOrder,savePurchaseOrder,updatePurchaseOrder} from "@/api/supply"
|
183
|
188
|
export default {
|
184
|
189
|
name: "addPurchaseOrder",
|
185
|
190
|
created() {
|
|
@@ -241,8 +246,14 @@ return {
|
241
|
246
|
tableRules: {
|
242
|
247
|
name: [{ required: true, message: '商品不能为空', trigger: 'blur' }],
|
243
|
248
|
supply_count: [{ required: true, message: '数量不能为空', trigger: 'blur' }],
|
244
|
|
- },
|
245
|
|
-};
|
|
249
|
+ },
|
|
250
|
+ warehousing_id:0,
|
|
251
|
+ number:"",
|
|
252
|
+ loading:false,
|
|
253
|
+ drugList:[],
|
|
254
|
+ goodList:[],
|
|
255
|
+ id:0,
|
|
256
|
+ };
|
246
|
257
|
},
|
247
|
258
|
methods:{
|
248
|
259
|
|
|
@@ -283,7 +294,7 @@ getInitOrder(){
|
283
|
294
|
|
284
|
295
|
this.tabList.push(drugList[i])
|
285
|
296
|
}
|
286
|
|
-
|
|
297
|
+ this.drugList = drugList
|
287
|
298
|
var goodList = response.data.data.goodList
|
288
|
299
|
for(let i=0;i<goodList.length;i++){
|
289
|
300
|
for(let j=0;j<this.manufactuerList.length;j++){
|
|
@@ -311,14 +322,15 @@ getInitOrder(){
|
311
|
322
|
|
312
|
323
|
this.tabList.push(goodList[i])
|
313
|
324
|
}
|
314
|
|
- }
|
|
325
|
+ this.goodList = goodList
|
|
326
|
+ }
|
315
|
327
|
})
|
316
|
328
|
},
|
317
|
329
|
changeGoodName(val){
|
318
|
330
|
this.currentIndex = val
|
319
|
331
|
},
|
320
|
332
|
changeName(val){
|
321
|
|
-
|
|
333
|
+ //var obj = {"id":0,"name":"合计","supply_name":"","supply_type":"","supply_specification_name":"","supply_total":"","supply_count":"","supply_price":"","supply_total_price":"","supply_manufacturer":"","supply_license_number":"","supply_remake":"","is_total":2}
|
322
|
334
|
for(let i=0;i<this.recordInfo.tableList.length;i++){
|
323
|
335
|
if(this.currentIndex == i){
|
324
|
336
|
this.recordInfo.tableList[i].id = val.id
|
|
@@ -339,8 +351,10 @@ changeName(val){
|
339
|
351
|
this.recordInfo.tableList[i].supply_manufacturer = val.supply_manufacturer
|
340
|
352
|
this.recordInfo.tableList[i].supply_license_number = val.supply_license_number
|
341
|
353
|
this.recordInfo.tableList[i].supply_remake = val.supply_remake
|
|
354
|
+ this.recordInfo.tableList[i].is_total = val.is_total
|
342
|
355
|
}
|
343
|
356
|
}
|
|
357
|
+
|
344
|
358
|
|
345
|
359
|
},
|
346
|
360
|
handleEdit(){
|
|
@@ -358,6 +372,7 @@ handleEdit(){
|
358
|
372
|
tempObj['supply_license_number'] = ''
|
359
|
373
|
tempObj['supply_remake'] = ''
|
360
|
374
|
tempObj['type'] = 0
|
|
375
|
+ tempObj['is_total'] = 1
|
361
|
376
|
this.recordInfo.tableList.push(tempObj)
|
362
|
377
|
},
|
363
|
378
|
handleDelete: function(index, row) {
|
|
@@ -371,21 +386,17 @@ handleDelete: function(index, row) {
|
371
|
386
|
|
372
|
387
|
|
373
|
388
|
savePurchaseOrder(){
|
374
|
|
- // console.log("tablelsit323232",this.recordInfo.tableList)
|
375
|
|
- console.log("hhh232323",this.$refs)
|
|
389
|
+ this.loading = true
|
|
390
|
+ if(this.supplier_name == 0 || this.supplier_name == ""){
|
|
391
|
+ this.$message.error("供应商不能为空!")
|
|
392
|
+ return false
|
|
393
|
+ }
|
376
|
394
|
this.$refs["tableForm"].validate((valid)=>{
|
377
|
395
|
if(valid){
|
378
|
|
- var params = {
|
379
|
|
- supplier_name:this.supplier_name,
|
380
|
|
- start_time:this.start_time,
|
381
|
|
- end_time:this.end_time,
|
382
|
|
- rate_of_concession:this.rate_of_concession,
|
383
|
|
- discount_amount:this.discount_amount,
|
384
|
|
- }
|
385
|
|
- console.log("partam2332232332",params)
|
386
|
|
- console.log("tablelsit323232",this.recordInfo.tableList)
|
387
|
396
|
for(let i=0;i<this.recordInfo.tableList.length;i++){
|
388
|
397
|
this.recordInfo.tableList[i].supply_count = parseInt(this.recordInfo.tableList[i].supply_count)
|
|
398
|
+ this.recordInfo.tableList[i].supply_license_number = this.recordInfo.tableList[i].supply_license_number.toString()
|
|
399
|
+ this.recordInfo.tableList[i].supply_total_price = (this.recordInfo.tableList[i].supply_count * this.recordInfo.tableList[i].supply_price).toString()
|
389
|
400
|
for(let j=0;j<this.manufactuerList.length;j++){
|
390
|
401
|
if(this.recordInfo.tableList[i].supply_manufacturer == this.manufactuerList[j].manufacturer_name){
|
391
|
402
|
this.recordInfo.tableList[i].manufacturer_id = this.manufactuerList[j].id
|
|
@@ -393,11 +404,48 @@ savePurchaseOrder(){
|
393
|
404
|
|
394
|
405
|
}
|
395
|
406
|
}
|
396
|
|
- return
|
397
|
|
- savePurchaseOrder(this.recordInfo.tableList,this.supplier_name,this.start_time,this.end_time,this.rate_of_concession,this.discount_amount).then(response=>{
|
|
407
|
+ var start = this.getTimes(this.start_time)
|
|
408
|
+ var end = this.getTimes(this.end_time)
|
|
409
|
+ const params = {
|
|
410
|
+ 'stockIn': this.recordInfo.tableList
|
|
411
|
+ }
|
|
412
|
+
|
|
413
|
+ savePurchaseOrder(params,this.supplier_name,start,end,this.rate_of_concession,this.discount_amount).then(response=>{
|
398
|
414
|
if(response.data.state == 1){
|
399
|
415
|
var order = response.data.data.order
|
|
416
|
+ this.loading = false
|
400
|
417
|
this.$message.success("保存成功!")
|
|
418
|
+ var warehouseInfo = response.data.data.warehouseInfo
|
|
419
|
+ this.number = warehouseInfo.number
|
|
420
|
+ this.id = warehouseInfo.id
|
|
421
|
+ this.recordInfo.tableList = []
|
|
422
|
+ var orderInfo = response.data.data.orderInfo
|
|
423
|
+ for(let i=0;i<orderInfo.length;i++){
|
|
424
|
+ orderInfo[i].supply_count = orderInfo[i].count
|
|
425
|
+ orderInfo[i].supply_price = orderInfo[i].price
|
|
426
|
+ orderInfo[i].supply_remake = orderInfo[i].remark
|
|
427
|
+ }
|
|
428
|
+ console.log("orderINFO23323232",orderInfo)
|
|
429
|
+ this.recordInfo.tableList = orderInfo
|
|
430
|
+ // for(let i=0;i<orderInfo.length;i++){
|
|
431
|
+ // orderInfo[i].name = ""
|
|
432
|
+ // orderInfo[i].supply_name = ""
|
|
433
|
+ // orderInfo[i].supply_specification_name = ""
|
|
434
|
+ // if(orderInfo[i].is_source == 1){
|
|
435
|
+ // for(let j=0;j<this.drugList.length;j++){
|
|
436
|
+ // if(orderInfo[i].project_id == this.drugList[j].id){
|
|
437
|
+ // orderInfo[i].name = this.drugList[j].drug_name
|
|
438
|
+ // }
|
|
439
|
+ // }
|
|
440
|
+ // }
|
|
441
|
+ // if(orderInfo[i].is_source == 2){
|
|
442
|
+ // for(let y=0;y<this.goodList.length;y++){
|
|
443
|
+ // if(orderInfo[i].project_id = this.goodList[y].id){
|
|
444
|
+ // orderInfo[i].name = this.goodList[y].good_name
|
|
445
|
+ // }
|
|
446
|
+ // }
|
|
447
|
+ // }
|
|
448
|
+ // }
|
401
|
449
|
this.showTwo = false
|
402
|
450
|
this.showOne = true
|
403
|
451
|
}
|
|
@@ -408,6 +456,7 @@ savePurchaseOrder(){
|
408
|
456
|
|
409
|
457
|
},
|
410
|
458
|
|
|
459
|
+
|
411
|
460
|
changeTypeName(){
|
412
|
461
|
|
413
|
462
|
},
|
|
@@ -463,8 +512,46 @@ calculate: function(val) {
|
463
|
512
|
}
|
464
|
513
|
return Math.round(parseFloat(val) * 100) / 100;
|
465
|
514
|
},
|
|
515
|
+getTimes(time) {
|
|
516
|
+ if (time === '') {
|
|
517
|
+ return ''
|
|
518
|
+ }
|
|
519
|
+ return uParseTime(time, '{y}-{m}-{d}')
|
|
520
|
+},
|
466
|
521
|
updatePurchaseOrder(){
|
467
|
|
-
|
|
522
|
+ this.$refs.validate((valid)=>{
|
|
523
|
+ if(valid){
|
|
524
|
+ for(let i=0;i<this.recordInfo.tableList.length;i++){
|
|
525
|
+ this.recordInfo.tableList[i].supply_count = parseInt(this.recordInfo.tableList[i].supply_count)
|
|
526
|
+ this.recordInfo.tableList[i].supply_license_number = this.recordInfo.tableList[i].supply_license_number.toString()
|
|
527
|
+ this.recordInfo.tableList[i].supply_total_price = (this.recordInfo.tableList[i].supply_count * this.recordInfo.tableList[i].supply_price).toString()
|
|
528
|
+ for(let j=0;j<this.manufactuerList.length;j++){
|
|
529
|
+ if(this.recordInfo.tableList[i].supply_manufacturer == this.manufactuerList[j].manufacturer_name){
|
|
530
|
+ this.recordInfo.tableList[i].manufacturer_id = this.manufactuerList[j].id
|
|
531
|
+ }
|
|
532
|
+ }
|
|
533
|
+ }
|
|
534
|
+ var start = this.getTimes(this.start_time)
|
|
535
|
+ var end = this.getTimes(this.end_time)
|
|
536
|
+ const params = {
|
|
537
|
+ 'stockIn': this.recordInfo.tableList
|
|
538
|
+ }
|
|
539
|
+ updatePurchaseOrder(params,this.supplier_name,start,end,this.rate_of_concession,this.discount_amount,this.id,this.number).then(response=>{
|
|
540
|
+ if(response.data.state == 1){
|
|
541
|
+ var warehousingInfo = response.data.data.warehousingInfo
|
|
542
|
+ this.$message.success("修改成功!")
|
|
543
|
+ }
|
|
544
|
+ })
|
|
545
|
+ }
|
|
546
|
+ })
|
|
547
|
+ },
|
|
548
|
+ getAllPrice(){
|
|
549
|
+ console.log("表哥2332323223323223",this.recordInfo.tableList)
|
|
550
|
+ var total_price = 0
|
|
551
|
+ for(let i=0;i<this.recordInfo.tableList.length;i++){
|
|
552
|
+ total_price += (this.recordInfo.tableList[i].supply_price * this.recordInfo.tableList[i].supply_count)
|
|
553
|
+ }
|
|
554
|
+ return total_price.toFixed(2)
|
468
|
555
|
}
|
469
|
556
|
},
|
470
|
557
|
created(){
|
|
@@ -482,6 +569,7 @@ created(){
|
482
|
569
|
tempObj['supply_license_number'] = ''
|
483
|
570
|
tempObj['supply_remake'] = ''
|
484
|
571
|
tempObj['type'] = 0
|
|
572
|
+ tempObj['is_total'] = 1
|
485
|
573
|
this.recordInfo.tableList.push(tempObj)
|
486
|
574
|
this.getInitOrder()
|
487
|
575
|
}
|