瀏覽代碼

Merge branch 'purchaseDev' of http://172.16.100.139/new-business/drp-web into purchaseDev

002390 1 年之前
父節點
當前提交
8cad0c1276
共有 3 個文件被更改,包括 59 次插入3 次删除
  1. 10 0
      src/api/business/purchase/apply.js
  2. 31 2
      src/views/purchase/PurchaseDemandList/add.vue
  3. 18 1
      src/views/purchase/apply/index.vue

+ 10 - 0
src/api/business/purchase/apply.js

@@ -38,3 +38,13 @@ export function REMOVE(data) {
     method: "delete",
   });
 }
+
+// 模板下载
+export function mbDownload(data) {
+  return request({
+    url: `/pu/demand/download`,
+    method: 'post',
+    data: data,
+    responseType: 'blob'
+  })
+}

+ 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();
       })
     },

+ 18 - 1
src/views/purchase/apply/index.vue

@@ -1,7 +1,7 @@
 <script>
 import { dicts } from "./dicts";
 import useColumns from "./columns";
-import { LIST } from "@/api/business/purchase/apply";
+import { LIST, mbDownload } from "@/api/business/purchase/apply";
 
 export default {
   name: "PuchaseApply",
@@ -79,6 +79,19 @@ export default {
       const { open } = this.$refs.SeeButton;
       await open([prop]);
     },
+    // 下载模板
+    downLoadMb() {
+      this.$modal.loading("正在下载模板,请稍后...");
+      mbDownload().then(res => {
+
+      }).catch(err => {
+        this.$modal.closeLoading();
+      })
+    },
+    // 导入数据
+    importMb() {
+      
+    },
   },
 };
 </script>
@@ -145,6 +158,10 @@ export default {
           @success="useQuery(params, page)"
         ></subm-button>
       </el-button-group>
+      <el-button-group>
+        <el-button size="mini" @click="downLoadMb">模 板</el-button>
+        <el-button size="mini" @click="importMb">导 入</el-button>
+      </el-button-group>
     </el-row>
     <el-super-table
       v-model="tableData"