戴艳蓉 hace 3 años
padre
commit
da6343dde0
Se han modificado 1 ficheros con 69 adiciones y 39 borrados
  1. 69 39
      src/views/purchase/orderRecord/components/proofreading.vue

+ 69 - 39
src/views/purchase/orderRecord/components/proofreading.vue

@@ -23,7 +23,7 @@
         <el-row :gutter="10">
         <el-row :gutter="10">
           <el-col :span="24">
           <el-col :span="24">
             <el-row :gutter="20">
             <el-row :gutter="20">
-              <el-col :span="24">
+              <el-col :span="24" style="padding: 0 20px 0 0">
                 <el-table
                 <el-table
                   :size="'mini'"
                   :size="'mini'"
                   :data="examForm.item_list"
                   :data="examForm.item_list"
@@ -56,7 +56,7 @@
                       ></el-input>
                       ></el-input>
                     </template>
                     </template>
                   </el-table-column>
                   </el-table-column>
-                  <el-table-column prop="unit" width="100" label="单位">
+                  <el-table-column prop="unit" width="70" label="单位">
                     <template slot-scope="scope">
                     <template slot-scope="scope">
                       <el-input
                       <el-input
                         :size="'mini'"
                         :size="'mini'"
@@ -83,7 +83,7 @@
                       ></el-input>
                       ></el-input>
                     </template>
                     </template>
                   </el-table-column>
                   </el-table-column>
-                  <el-table-column prop="tax_rate" width="100" label="税率">
+                  <el-table-column prop="tax_rate" width="80" label="税率">
                     <template slot-scope="scope">
                     <template slot-scope="scope">
                       <el-input
                       <el-input
                         :size="'mini'"
                         :size="'mini'"
@@ -103,13 +103,14 @@
                   </el-table-column>
                   </el-table-column>
                   <el-table-column fixed="right" width="50">
                   <el-table-column fixed="right" width="50">
                     <template slot="header" slot-scope="scope">
                     <template slot="header" slot-scope="scope">
-                      <el-button size="mini" @click="addGoods">新建</el-button>
+                      <el-link type="primary" @click="addGoods">新建</el-link>
+                      <!-- <el-button size="mini" @click="addGoods">新建</el-button> -->
                     </template>
                     </template>
                     <template slot-scope="scope">
                     <template slot-scope="scope">
                       <el-tooltip effect="dark" content="删除" placement="top">
                       <el-tooltip effect="dark" content="删除" placement="top">
                         <i
                         <i
                           class="el-icon-delete tb-icon"
                           class="el-icon-delete tb-icon"
-                          @click="deleteRow(scope.$index, examForm.item_list)"
+                          @click="deleteRow(scope.$index)"
                         ></i>
                         ></i>
                       </el-tooltip>
                       </el-tooltip>
                     </template>
                     </template>
@@ -295,25 +296,32 @@ export default {
       this.examForm.item_list.forEach((v1, i1) => {
       this.examForm.item_list.forEach((v1, i1) => {
         this.$set(this.examForm.item_list, i1, v1);
         this.$set(this.examForm.item_list, i1, v1);
       });
       });
-      this.$set(rows, index, rows[index]);
     },
     },
-    deleteRow(index, rows) {
-      rows.splice(index, 1);
-      this.$set(rows, index, rows[index]);
+    deleteRow(index) {
+      this.examForm.item_list.splice(index, 1);
+      // this.$set(this.examForm.item_list, index, this.examForm.item_list[index]);
     },
     },
+
     async getData() {
     async getData() {
-      console.log(this.companyNo);
+      // console.log(this.companyNo);
       const res = await asyncRequest.companydetail({
       const res = await asyncRequest.companydetail({
         companyNo: this.companyNo,
         companyNo: this.companyNo,
         sid: this.id,
         sid: this.id,
       });
       });
       if (res && res.code === 0) {
       if (res && res.code === 0) {
-        const data = res.data || [];
+        const {
+          company_address,
+          mobile,
+          bank_name,
+          bankNo,
+          company_license,
+          company_name,
+        } = res.data || {};
         this.oldresList = [];
         this.oldresList = [];
-        this.oldItem.buyer_address = data.company_address + data.mobile;
-        this.oldItem.buyer_bank = data.bank_name + data.bankNo;
-        this.oldItem.buyer_id = data.company_license;
-        this.oldItem.buyer_name = data.company_name;
+        this.oldItem.buyer_address = company_address + mobile;
+        this.oldItem.buyer_bank = bank_name + bankNo;
+        this.oldItem.buyer_id = company_license;
+        this.oldItem.buyer_name = company_name;
       } else if (res && res.code >= 100 && res.code <= 104) {
       } else if (res && res.code >= 100 && res.code <= 104) {
         await this.logout();
         await this.logout();
       } else {
       } else {
@@ -331,20 +339,22 @@ export default {
         res.data.invoice.length > 0
         res.data.invoice.length > 0
       ) {
       ) {
         // console.log("整合数据!");
         // console.log("整合数据!");
-        const data = res.data || [];
-        this.oldItem.seller_address = data.old.seller_address;
-        this.oldItem.seller_bank = data.old.seller_bank;
-        this.oldItem.seller_id = data.old.seller_id;
-        this.oldItem.seller_name = data.old.seller_name;
-        this.newItem.buyer_address = data.buyer.buyer_address;
-        this.newItem.buyer_bank = data.buyer.buyer_bank;
-        this.newItem.buyer_id = data.buyer.buyer_id;
-        this.newItem.buyer_name = data.buyer.buyer_name;
-        this.newItem.seller_address = data.seller.seller_address;
-        this.newItem.seller_bank = data.seller.seller_bank;
-        this.newItem.seller_id = data.seller.seller_id;
-        this.newItem.seller_name = data.seller.seller_name;
-        data.invoice.forEach((v1) => {
+        const { old, buyer, seller, invoice } = res.data || {};
+        this.oldItem.seller_address = old.seller_address;
+        this.oldItem.seller_bank = old.seller_bank;
+        this.oldItem.seller_id = old.seller_id;
+        this.oldItem.seller_name = old.seller_name;
+
+        this.newItem.buyer_address = buyer.buyer_address;
+        this.newItem.buyer_bank = buyer.buyer_bank;
+        this.newItem.buyer_id = buyer.buyer_id;
+        this.newItem.buyer_name = buyer.buyer_name;
+
+        this.newItem.seller_address = seller.seller_address;
+        this.newItem.seller_bank = seller.seller_bank;
+        this.newItem.seller_id = seller.seller_id;
+        this.newItem.seller_name = seller.seller_name;
+        invoice.forEach((v1) => {
           let x = {
           let x = {
             bstatus: v1.bstatus,
             bstatus: v1.bstatus,
             id: v1.id,
             id: v1.id,
@@ -375,7 +385,7 @@ export default {
 
 
         this.length = this.oldresList.length;
         this.length = this.oldresList.length;
         this.activeImg = 0;
         this.activeImg = 0;
-        console.log("整合完数据!");
+        // console.log("整合完数据!");
         await this.carouselChange(0);
         await this.carouselChange(0);
       } else if (res && res.code >= 100 && res.code <= 104) {
       } else if (res && res.code >= 100 && res.code <= 104) {
         await this.logout();
         await this.logout();
@@ -427,28 +437,47 @@ export default {
       }
       }
       this.loading = false;
       this.loading = false;
     },
     },
+    reskeyhas(v) {
+      let keyhas = true;
+      for (let key in v) {
+        keyhas = keyhas && v[key] === "";
+      }
+      return keyhas;
+    },
     async submitForm() {
     async submitForm() {
       await this.$refs.examForm.validate(async (valid) => {
       await this.$refs.examForm.validate(async (valid) => {
         if (valid) {
         if (valid) {
           this.loading = true;
           this.loading = true;
           const obj = JSON.parse(JSON.stringify(this.examForm));
           const obj = JSON.parse(JSON.stringify(this.examForm));
-          console.log(obj);
-          // const listOk = await this.ValidationList(obj.item_list);
-          // if (!listOk) {
-          //   this.$message.error("商品明细数据不能出现空值!");
-          //   return;
-          // }
+          let isok = true;
+          let list = JSON.parse(
+            JSON.stringify(this.oldresList[this.activeImg].goods)
+          );
+          if(list.length===0){
+             this.$message.warning("商品明细不能为空!");
+            this.loading = false;
+            return;
+          }
+          list.forEach((v1) => {
+            if (this.reskeyhas(v1)) {
+              isok = false;
+            }
+          });
+          if (!isok) {
+            this.$message.warning("商品明细不能出现整行都为空!");
+            this.loading = false;
+            return;
+          }
           const modal = await this.detectionField(obj, this.activeImg);
           const modal = await this.detectionField(obj, this.activeImg);
-          console.log(modal);
-
           let res = await asyncRequest.invoicesave(modal);
           let res = await asyncRequest.invoicesave(modal);
           if (res && res.code === 0) {
           if (res && res.code === 0) {
             if (this.activeImg + 1 == this.length) {
             if (this.activeImg + 1 == this.length) {
+              console.log('aaaaaaa');
               await this.invoicecheck();
               await this.invoicecheck();
               // let model1 = {
               // let model1 = {
               //   sid: this.id,
               //   sid: this.id,
               //   payNo: this.payNo,
               //   payNo: this.payNo,
-              //   status: "6",
+              //   status: "6", 
               // };
               // };
               // let res = {};
               // let res = {};
               // res = await asyncRequest.again(model1);
               // res = await asyncRequest.again(model1);
@@ -463,6 +492,7 @@ export default {
               //   this.$message.warning(res.message);
               //   this.$message.warning(res.message);
               // }
               // }
             } else {
             } else {
+              console.log('bbbbbb');
               await this.carouselChange(++this.activeImg);
               await this.carouselChange(++this.activeImg);
             }
             }
           }
           }