Просмотр исходного кода

手写信息采集表增加导出功能

cgp 1 день назад
Родитель
Сommit
30308b994b

+ 10 - 0
src/api/company/handwriteCollection.js

@@ -67,3 +67,13 @@ export function ocrImage(data) {
     data: data
   })
 }
+
+// 导出手写信息采集表
+export function exportCollection(data) {
+  return request({
+    url: '/handwrite/collection/export',
+    method: 'post',
+    data: data,
+    responseType: 'blob' //返回二进制流
+  });
+}

+ 35 - 1
src/views/company/handwriteCollection/index.vue

@@ -38,6 +38,9 @@
       <el-col :span="1.5">
         <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete">删除</el-button>
       </el-col>
+      <el-col :span="1.5">
+        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
     </el-row>
 
@@ -99,7 +102,7 @@
 </template>
 
 <script>
-import { listCollection, getCollection,delCollection,} from "@/api/company/handwriteCollection";
+import { listCollection, getCollection,delCollection,exportCollection } from "@/api/company/handwriteCollection";
 import ImageUpload from "@/components/ImageUpload";
 
 export default {
@@ -255,6 +258,37 @@ export default {
       const minute = date.getMinutes().toString().padStart(2, '0');
       const second = date.getSeconds().toString().padStart(2, '0');
       return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
+    },
+    // 导出手写信息采集表
+    handleExport() {
+      const params = { ...this.queryParams };
+      if (this.dateRange && this.dateRange.length === 2) {
+        params.startDate = this.dateRange[0];
+        params.endDate = this.dateRange[1];
+      }
+      delete params.pageNum;
+      delete params.pageSize;
+
+      this.$confirm('是否确认导出当前查询条件下的所有数据?', '导出确认', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        exportCollection(params).then(response => {
+          const blob = new Blob([response], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
+          const url = window.URL.createObjectURL(blob);
+          const link = document.createElement('a');
+          link.href = url;
+          link.download = `手写信息采集表_${new Date().getTime()}.xlsx`;
+          document.body.appendChild(link);
+          link.click();
+          document.body.removeChild(link);
+          window.URL.revokeObjectURL(url);
+          this.$message.success('导出成功');
+        }).catch(() => {
+          this.$message.error('导出失败');
+        });
+      }).catch(() => {});
     }
   }
 };