Explorar el Código

供应商修改

huangyw hace 3 años
padre
commit
8556394c56
Se han modificado 1 ficheros con 46 adiciones y 51 borrados
  1. 46 51
      src/xt_pages/supply/components/addSupply.vue

+ 46 - 51
src/xt_pages/supply/components/addSupply.vue Ver fichero

@@ -26,11 +26,21 @@
26 26
           <el-col span="6">
27 27
             <el-form-item label="供应商类别" prop="supplierType">
28 28
               <!-- <el-input v-model="supplier.type"></el-input> -->
29
-              <el-autocomplete
29
+              <!-- <el-autocomplete
30 30
                 v-model="supplier.supplierType"
31 31
                 :fetch-suggestions="querySearchAsync"
32 32
                 @select="handleSelect"
33
-              ></el-autocomplete>
33
+              ></el-autocomplete> -->
34
+
35
+              <el-select v-model="supplier.supplierType">
36
+                <el-option
37
+                  v-for="item in supplierType"
38
+                  :key="item.value"
39
+                  :label="item.label"
40
+                  :value="item.value"
41
+                >
42
+                </el-option>
43
+              </el-select>
34 44
             </el-form-item>
35 45
           </el-col>
36 46
           <el-col span="6">
@@ -91,7 +101,7 @@
91 101
                         {
92 102
                           required: 'true',
93 103
                           message: '请输入主要联系人',
94
-                          trigger: ['blur', 'change'],
104
+                          trigger: ['blur'],
95 105
                         },
96 106
                       ]
97 107
                     : null
@@ -227,6 +237,7 @@ export default {
227 237
       supplier_ids: "",
228 238
       title: "",
229 239
       Template,
240
+      supplierType: [],
230 241
       signAndWeighBoxPatients: "sign-and-weigh-box-patients",
231 242
       list: ["001", "002"],
232 243
       // 表单验证规则
@@ -297,8 +308,10 @@ export default {
297 308
         this.initSupplierData();
298 309
         this.show_type = 1;
299 310
         this.title = "新增供应商";
311
+        this.getsupplytype();
300 312
         this.dialogVisible = true;
301 313
       } else if (type == 2) {
314
+        this.getsupplytype();
302 315
         // console.log(data,'oop')
303 316
         this.show_type = 2;
304 317
         this.supplier_ids = data.ID;
@@ -306,6 +319,7 @@ export default {
306 319
         this.supplier.supplierCode = data.SupplierCode;
307 320
         this.supplier.supplierName = data.SupplierName;
308 321
         this.supplier.supplierType = data.SupplierType;
322
+
309 323
         this.supplier.vatRate = data.VatRate;
310 324
         this.supplier.number = data.Number;
311 325
         this.supplier.bank = data.Bank;
@@ -363,35 +377,18 @@ export default {
363 377
       });
364 378
     },
365 379
 
366
-    querySearchAsync(queryString, cb) {
367
-      clearTimeout(this.timeout);
368
-      var results = [];
369
-      if (queryString == "") {
370
-        cb(results);
371
-      } else {
372
-        // 获取供应商类别接口
373
-        getsupplytype()
374
-          .then((res) => {
375
-            if (res.status == 200) {
376
-              var result = res.data.data.list;
377
-              //远程搜索需要的数组
378
-              for (let i = 0; i < result.length; i++) {
379
-                const element = result[i];
380
-                results.push({
381
-                  value: element.name,
382
-                  name: element.value,
383
-                });
384
-              }
385
-              cb(results);
386
-            } else {
387
-              results = [];
388
-              cb(results);
389
-            }
390
-          })
391
-          .catch((err) => {
392
-            console.log(err);
393
-          });
394
-      }
380
+    getsupplytype() {
381
+      // 获取供应商类别接口
382
+      getsupplytype()
383
+        .then((res) => {
384
+          if (res.status == 200) {
385
+            this.supplierType = res.data.data.list;
386
+            console.log(this.supplierType, "this.supplierType");
387
+          }
388
+        })
389
+        .catch((err) => {
390
+          console.log(err);
391
+        });
395 392
     },
396 393
 
397 394
     handleSelect(item) {
@@ -429,11 +426,11 @@ export default {
429 426
                 };
430 427
                 savesupply(params).then((res) => {
431 428
                   if (res.data.state == 1) {
432
-                    this.$message.success("修改成功");
429
+                    this.$message.success("新增成功");
433 430
                     this.closePop();
434 431
                     this.$emit("init");
435 432
                   } else {
436
-                    this.$message.error("修改失败");
433
+                    this.$message.error("新增失败");
437 434
                     setTimeout(() => {
438 435
                       this.closePop();
439 436
                     }, 2000);
@@ -466,7 +463,7 @@ export default {
466 463
                 let params = {
467 464
                   suppliercode: this.supplier.supplierCode || "",
468 465
                   suppliername: this.supplier.supplierName || "",
469
-                  id: this.supplier.id|| 0,
466
+                  id: this.supplier.id || 0,
470 467
                   suppliertype: this.supplier.supplierType || "",
471 468
                   vatrate: this.supplier.vatRate || 0,
472 469
                   number: this.supplier.number || "",
@@ -511,23 +508,18 @@ export default {
511 508
           if (this.recordInfo.contacts.length == 0) {
512 509
             this.recordInfo.contacts = [{}];
513 510
             this.recordInfo.contacts[0].is_first = data.value;
514
-          } else if (this.recordInfo.contacts.length == 1) {
515
-            let val = res.data.data.contact[0];
516
-            this.recordInfo.contacts[0].is_first = data.value;
517
-            this.recordInfo.contacts[0] = {
518
-              id: val.id,
519
-              name: val.name,
520
-              address: val.address,
521
-              phone: val.phone,
522
-            };
523
-            this.$forceUpdate();
524
-          } else {
525
-            this.recordInfo.contacts.forEach((o) => {
526
-              if (o.isfirst == 0) {
527
-              } else if (o.isfirst == 1) {
528
-              }
529
-            });
530 511
           }
512
+          // else if (this.recordInfo.contacts.length == 1) {
513
+          //     let val = res.data.data.contact[0];
514
+          //     this.recordInfo.contacts[0].is_first = data.value;
515
+          //     this.recordInfo.contacts[0] = {
516
+          //       id: parseFloat(val.id),
517
+          //       name: val.name,
518
+          //       address: val.address,
519
+          //       phone: val.phone,
520
+          //     };
521
+          //     this.$forceUpdate();
522
+          //   }
531 523
         }
532 524
       });
533 525
     },
@@ -639,6 +631,9 @@ export default {
639 631
     .el-autocomplete {
640 632
       width: 75% !important;
641 633
     }
634
+    .el-select.el-select--medium {
635
+      width: 70% !important;
636
+    }
642 637
   }
643 638
 }
644 639