Browse Source

供应商

huangyw 3 years ago
parent
commit
f97af6e16b
2 changed files with 36 additions and 2 deletions
  1. 35 1
      src/xt_pages/supply/components/addSupply.vue
  2. 1 1
      src/xt_pages/supply/supplyQuery.vue

+ 35 - 1
src/xt_pages/supply/components/addSupply.vue View File

@@ -377,6 +377,18 @@ export default {
377 377
           if (valid) {
378 378
             this.$refs[formName].validate((valid) => {
379 379
               if (valid) {
380
+                this.recordInfo.contacts.forEach((el) => {
381
+                  console.log(el, "op");
382
+                  if (!el.phone) {
383
+                    el.phone = "";
384
+                  }
385
+                  if (!el.address) {
386
+                    el.address = "";
387
+                  }
388
+                  if (!el.id) {
389
+                    el.id = 0;
390
+                  }
391
+                });
380 392
                 let params = {
381 393
                   suppliercode: this.supplier.supplierCode || "",
382 394
                   suppliername: this.supplier.supplierName || "",
@@ -387,11 +399,16 @@ export default {
387 399
                   bankaccount: this.supplier.bankAccount || "",
388 400
                   contacts: [...this.recordInfo.contacts],
389 401
                 };
402
+                console.log(
403
+                  this.recordInfo.contacts,
404
+                  "this.recordInfo.contacts"
405
+                );
390 406
                 savesupply(params).then((res) => {
391 407
                   console.log(res, "op");
392 408
                   if (res.data.state == 1) {
393 409
                     this.$message.success("修改成功");
394 410
                     this.closePop();
411
+                    this.$emit("init");
395 412
                   } else {
396 413
                     this.$message.error("修改失败");
397 414
                     setTimeout(() => {
@@ -412,6 +429,18 @@ export default {
412 429
           if (valid) {
413 430
             this.$refs[formName].validate((valid) => {
414 431
               if (valid) {
432
+                this.recordInfo.contacts.forEach((el) => {
433
+                  console.log(el, "op");
434
+                  if (!el.phone) {
435
+                    el.phone = "";
436
+                  }
437
+                  if (!el.address) {
438
+                    el.address = "";
439
+                  }
440
+                  if (!el.id) {
441
+                    el.id = 0;
442
+                  }
443
+                });
415 444
                 let params = {
416 445
                   suppliercode: this.supplier.supplierCode || "",
417 446
                   suppliername: this.supplier.supplierName || "",
@@ -423,12 +452,17 @@ export default {
423 452
                   bankaccount: this.supplier.bankAccount || "",
424 453
                   contacts: [...this.recordInfo.contacts],
425 454
                 };
455
+                console.log(
456
+                  this.recordInfo.contacts,
457
+                  "this.recordInfo.contacts"
458
+                );
426 459
                 console.log(params, "params");
427 460
                 updatesupply(params).then((res) => {
428 461
                   console.log(res, "op");
429 462
                   if (res.data.state == 1) {
430 463
                     this.$message.success("修改成功");
431 464
                     this.closePop();
465
+                    this.$emit("init");
432 466
                   } else {
433 467
                     this.$message.error("修改失败");
434 468
                     setTimeout(() => {
@@ -457,7 +491,7 @@ export default {
457 491
       getsupplyandcontactone({ id: val }).then((res) => {
458 492
         if (res.data.code == 0) {
459 493
           this.recordInfo.contacts = res.data.data.contact;
460
-          console.log(this.recordInfo.contacts,'supply')
494
+          console.log(this.recordInfo.contacts, "supply");
461 495
           if (this.recordInfo.contacts.length == 0) {
462 496
             this.recordInfo.contacts = [{}];
463 497
             this.recordInfo.contacts[0].is_first = data.value;

+ 1 - 1
src/xt_pages/supply/supplyQuery.vue View File

@@ -49,7 +49,7 @@
49 49
           <el-button size="small" type="primary" @click="toAdd(1)"
50 50
             >新增</el-button
51 51
           >
52
-          <addSupply ref="addSupply"></addSupply>
52
+          <addSupply ref="addSupply" @init="initData"></addSupply>
53 53
         </div>
54 54
       </div>
55 55