Jelajahi Sumber

事业发展部批量导入

002390 1 tahun lalu
induk
melakukan
d0e8a56071

+ 1 - 0
src/views/purchase/purchase-order/add/column.js

@@ -475,6 +475,7 @@ const PurchaseTabColumns =[
         // precision:2,
         require: true,
         disabled:true,
+        width: 180,
        },
       { 
         key: "money", 

+ 65 - 38
src/views/purchase/purchase-order/add/index.vue

@@ -613,7 +613,10 @@ export default {
   
           if (code == 200) {
   
-            this.params = data;
+            this.params = {
+              ...this.params,
+              ...data
+            };
   
           }
   
@@ -631,16 +634,22 @@ export default {
 
         formData.append('file',fileList[0].raw);
 
-        this.$modal.loading("正在上传文件,请稍候...");
-
+        
         let tabList = {
           puOrderItemList: [...this.params.puOrderItemList],
           puOrderExecuteList: [...this.params.puOrderExecuteList],
         }
 
-        console.log(tabList,'tabList-------------------------');
+        const blob = new Blob([JSON.stringify(tabList)], {
+            type: 'application/json'
+        })
+
+        formData.append('tabList',blob);
+        
+        
+        this.$modal.loading("正在上传文件,请稍候...");
 
-        let {code,data} = await orderApi.orderImport(formData,tabList);
+        let {code,data} = await orderApi.orderImport(formData);
 
         if(code == 200) {
           // this.tabLoading = true;
@@ -714,21 +723,32 @@ export default {
     //   let role =  roles.find(item => item === "syfz-purchaseorder") || "procurementManager";
     //   return role;
     // },
-    getSummaries(param){
-        const { columns, data } = param;
-				const sums = [];
-        let { tabColumns, tabName } = this;
+    getSummaries({ columns, data }){
+      // const  = param;
+      const sums = [];
+      let { tabColumns, tabName } = this;
+      console.log(columns,'columns-----------------------');
 
-				columns.forEach((column, index) => {
+      columns.forEach((column, index) => {
 
 				if (index === 0) {
 				   sums[index] = '合计';
 				   return;
 				}
 
+        // console.log(column,'column---------------------------');
+
 				const values = data.map(item => Number(item[column.property]));
        
-        let sumColumn = tabColumns.find(tab => tab.key === tabName).tableColumns.filter(({key,isSummary}) => isSummary && key === column.property);
+        let sumColumn = tabColumns.find(tab => tab.key === tabName).tableColumns.filter(({key,isSummary}) => {
+
+          // console.log(key,'key',isSummary,'isSummary',column.property);
+          // console.log(isSummary && key === column.property);
+          if(isSummary && key === column.property){
+
+            return {key,isSummary}
+          }
+        });
         
         if (sumColumn.length) {
           sums[index] = values.reduce((prev, curr) => {
@@ -741,12 +761,8 @@ export default {
           }, 0);
           sums[index];
           }
-				});
-				return sums;
-
-        // return 0
-
-      
+			});
+			return sums;
     }
 
   },
@@ -754,6 +770,12 @@ export default {
     console.log("ADD CREATED", this.params);
   },
   mounted() {},
+  updated() {
+    this.$nextTick(()=>{
+     this.$refs.puOrderExecuteList && this.$refs.puOrderExecuteList[0].doLayout();
+     this.$refs.puOrderItemList && this.$refs.puOrderItemList[0].doLayout();
+    })
+  },
   destroyed() {},
 };
 </script>
@@ -956,34 +978,38 @@ export default {
             <template slot-scope="{ headerCellFixedStyle, cellFixedStyle }">
 
               <el-table 
-              :row-key="column.key === 'puOrderItemList' ? 'rowNo' :'rowno'" 
-              :data="tableData" 
-              style="width: 100%"
-              border
-              :headerCellStyle="headerCellFixedStyle"
-              :cellStyle="cellFixedStyle"
-              max-height="500px"
-              show-summary
-              :summary-method="getSummaries"
-            >
-              <template slot="empty">
-                <el-empty description="暂无数据"></el-empty>
-              </template>
-
-              
+                border
+                :ref="column.key"
+                :row-key="column.key === 'puOrderItemList' ? 'rowNo' :'rowno'" 
+                :data="tableData" 
+                style="width: 100%"
+                :headerCellStyle="headerCellFixedStyle"
+                :cellStyle="cellFixedStyle"
+                :height="tabHeight"
+              >
+                <!-- 
+                  :height="tabHeight"
+                   max-height="500px"
+                show-summary
+                :summary-method="getSummaries"
+                -->
+                <template slot="empty">
+                  <el-empty description="暂无数据"></el-empty>
+                </template>
 
                 <el-table-column
                   v-for="(cColumn, cIndex) in column.tableColumns"
                   :key="cIndex"
                   :label="cColumn.title"
                   :width="cColumn.width || 80"
+                  :prop="cColumn.key"
                 >
-                <template slot="header" slot-scope="scope">
-                  <span v-if="cColumn.require" style="color: #ff4949">*</span>
-                  <span>
-                    {{ cColumn.title }}
-                  </span>
-                </template>
+                  <template slot="header" slot-scope="scope">
+                    <span v-if="cColumn.require" style="color: #ff4949">*</span>
+                    <span>
+                      {{ cColumn.title }}
+                    </span>
+                  </template>
   
                   <template slot-scope="scope">
                     <el-form-item 
@@ -1120,3 +1146,4 @@ export default {
   </el-drawer>
 </template>
 
+

+ 22 - 3
src/views/purchase/purchase-order/edit/index.vue

@@ -651,6 +651,17 @@ export default {
 
         formData.append('file',fileList[0].raw);
 
+        let tabList = {
+          puOrderItemList: [...this.params.puOrderItemList],
+          puOrderExecuteList: [...this.params.puOrderExecuteList],
+        }
+
+        const blob = new Blob([JSON.stringify(tabList)], {
+            type: 'application/json'
+        })
+
+        formData.append('tabList',blob);
+
         this.$modal.loading("正在上传文件,请稍候...");
 
         let {code,data} = await orderApi.orderImport(formData);
@@ -758,6 +769,12 @@ export default {
   },
   created() {},
   mounted() { },
+  updated() {
+    this.$nextTick(()=>{
+     this.$refs.puOrderExecuteList && this.$refs.puOrderExecuteList[0].doLayout();
+     this.$refs.puOrderItemList && this.$refs.puOrderItemList[0].doLayout();
+    })
+  },
   destroyed() { },
 };
 </script>
@@ -927,14 +944,16 @@ export default {
               <!-- row-key绑定列唯一值,height一定要设置否则会滚动条滚动位置不对且数据滚动全部加载完后会出现白板-->
                 <el-table 
                   border
+                  :ref="column.key"
                   :data="tableData" 
                   style="width: 100%"
                   :headerCellStyle="headerCellFixedStyle"
                   :cellStyle="cellFixedStyle"
-                  max-height="500px"
-                  show-summary
-                  :summary-method="getSummaries"
+                  :height="tabHeight"
                 >
+                <!-- max-height="500px"
+                  show-summary
+                  :summary-method="getSummaries" -->
                   <el-table-column label="序号">
                     <template slot-scope="scope">
                       {{ scope.$index + 1 }}