Sfoglia il codice sorgente

提交加校验行标红

黄梓星 1 anno fa
parent
commit
ee93f9de18
1 ha cambiato i file con 31 aggiunte e 2 eliminazioni
  1. 31 2
      src/views/purchase/PurchaseDemandList/add.vue

+ 31 - 2
src/views/purchase/PurchaseDemandList/add.vue

@@ -191,7 +191,7 @@
           <ux-table-column resizable type="checkbox" fixed="left"/>
           <ux-table-column resizable title="序号" type="index" align="center" width="50px"/>
           <ux-table-column resizable title="行号" align="center" field="rowNo" width="50px">
-            <template v-slot:edit="scope">
+            <template v-slot="scope">
               {{ scope.row.rowNo = scope.rowIndex + 1 + "0" }}
             </template>
           </ux-table-column>
@@ -974,6 +974,9 @@ export default {
                       this.back()
                     }
                   }).catch(err => {
+                    let errorList = JSON.parse(err.message).rowList
+                    console.log(errorList)
+                    this.gainRed(errorList)
                     this.$modal.closeLoading();
                   })
                 } else if (this.sonPageStu == 'edit') {
@@ -991,6 +994,9 @@ export default {
                       this.back()
                     }
                   }).catch(err => {
+                    let errorList = JSON.parse(err.message).rowList
+                    console.log(errorList)
+                    this.gainRed(errorList)
                     this.$modal.closeLoading();
                   })
                 }
@@ -1040,6 +1046,27 @@ export default {
         this.$modal.notifyWarning("明细信息不能为空!");
       }
     },
+    // 后端校验标红方法
+    gainRed(errList) {
+        // 将子表下标加入进入标识字段
+        this.basicForm.puDemandItemList.forEach((item,index) => {
+          item.rightIndex = index
+        })
+        console.log('所有列表', this.basicForm.puDemandItemList)
+        // 将校验未通过的项与整个表格数据进行过滤对比,得出校验通过的数据
+        let rightList = this.basicForm.puDemandItemList.filter((item, index) => {
+          return errList.find(item2 => {
+            return item2.rowIndex !== item.rightIndex
+          })
+        })
+        console.log('xxx',rightList)
+        rightList.forEach(items => {
+          this.$refs.table.$el.querySelector(`.elx-body--row:nth-of-type(${items.rightIndex+1})`).style.background = ''
+        })
+        errList.forEach(item => {
+          this.$refs.table.$el.querySelector(`.elx-body--row:nth-of-type(${item/10})`).style.background = '#f34b4bb8'
+        })
+    },
     submit() {
       this.$modal.loading("提交中...");
       submitDemand(this.basicForm).then(res => {
@@ -1049,7 +1076,9 @@ export default {
           this.back()
         }
       }).catch(err => {
-        console.log(err)
+        let errorList = JSON.parse(err.message).rowList
+        console.log(errorList)
+        this.gainRed(errorList)
         this.$modal.closeLoading();
       })
     },