Browse Source

报告作废导出

sangwenwei 1 year atrás
parent
commit
1b289dd8be

+ 10 - 0
src/api/cw/reportCancellApply/ReportCancellApplyService.js

@@ -51,4 +51,14 @@ export default class ReportCancellApplyService {
       params: {no: no}
     })
   }
+	exportExcel (params) {
+		return request({
+			url: prefix + '/cwProjectReportCancell/export',
+			method: 'get',
+			params: params,
+			responseType: 'blob'
+		})
+	}
+
+
 }

+ 46 - 6
src/views/cw/reportCancellApply/ReportCancellApplyList.vue

@@ -52,7 +52,7 @@
       </el-form-item>
     </el-form>
     <div class="jp-table top" style="">
-      <vxe-toolbar :refresh="{query: refreshList}" custom>
+      <vxe-toolbar :refresh="{query: refreshList}" ref="toolbarRef" export custom>
         <template #buttons>
           <el-button v-if="hasPermission('cw_work_client:info:add')" type="primary" icon="el-icon-plus" @click="start()">新建</el-button>
         </template>
@@ -69,7 +69,6 @@
       </vxe-toolbar>
       <div style="height: calc(100% - 90px)">
         <vxe-table
-          :key="tableKey"
           border="inner"
           auto-resize
           resizable
@@ -79,6 +78,15 @@
           show-header-overflow
           show-overflow
           highlight-hover-row
+		  :print-config="{}"
+		  :export-config="{
+                    remote: true,
+                    filename: `报告作废信息${moment(new Date()).format('YYYY-MM-DD')}`,
+                    sheetName: '报告作废信息',
+                    exportMethod: exportMethod,
+                    types: ['xlsx'],
+                    modes: ['current', 'selected', 'all']
+                  }"
           :menu-config="{}"
           @sort-change="sortChangeHandle"
           :sort-config="{remote:true}"
@@ -167,7 +175,8 @@
           createBy: '',
           contractDates: [],
           projectMasterName: '', // 项目经理1
-          projectMaster2Name: '' // 项目经理2
+          projectMaster2Name: '', // 项目经理2
+
         },
         dataList: [],
         tablePage: {
@@ -176,7 +185,6 @@
           pageSize: 10,
           orders: []
         },
-        tableKey: '',
         loading: false,
         processDefinitionAuditId: '',
         procDefAuditKey: '',
@@ -204,6 +212,12 @@
       }
     },
     mounted () {
+		this.$nextTick(() => {
+			//将表格和工具栏进行关联
+			const $table = this.$refs.clientTable;
+			const $toolbar = this.$refs.toolbarRef;
+			$table.connect($toolbar);
+		})
       this.refreshList()
     },
     activated () {
@@ -261,7 +275,6 @@
         }).then((data) => {
           this.dataList = data.records
           this.tablePage.total = data.total
-          this.tableKey = Math.random()
           this.loading = false
         })
         this.checkIsAdmin()
@@ -464,7 +477,34 @@
           }
         }
         return false
-      }
+      },
+		// 自定义服务端导出
+		exportMethod ({ options }) {
+			// 传给服务端的参数
+			const params = {
+				'current': this.tablePage.currentPage,
+				'size': this.tablePage.pageSize,
+				'orders': this.tablePage.orders,
+				...this.searchForm,
+				filename: options.filename,
+				sheetName: options.sheetName,
+				isHeader: options.isHeader,
+				original: options.original,
+				mode: options.mode,
+				selectIds: options.mode === 'selected' ? options.map(item => item.id) : [],
+				exportFields: options.columns.map(column => column.property)
+			}
+			console.log(111)
+			return this.reportCancellApplyService.exportExcel(params).then((res) => {
+				console.log(res)
+				// 将二进制流文件写入excel表,以下为重要步骤
+				this.$utils.downloadExcel(res, options.filename)
+			}).catch(function (err) {
+				if (err.response) {
+					// console.log(err.response)
+				}
+			})
+		},
     }
   }
 </script>