Pārlūkot izejas kodu

中审报销 添加批量导入功能

徐滕 2 nedēļas atpakaļ
vecāks
revīzija
e2cc4996ac

+ 24 - 0
src/api/zs/reimbursement/ReimbursementService.js

@@ -182,4 +182,28 @@ export default class ReimbursementService {
 			},
 		});
 	}
+	// ==================== 导入功能 ====================
+	importTemplate() {
+		return request({
+			url: prefix + "/zsReimbursement/info/importTemplate",
+			method: "get",
+			responseType: "blob",
+		});
+	}
+	importFile(data) {
+		return request({
+			url: prefix + "/zsReimbursement/info/importFile",
+			method: "post",
+			data: data,
+			headers: { "Content-Type": "multipart/form-data" },
+		});
+	}
+	downloadImportError(filePath) {
+		return request({
+			url: prefix + "/zsReimbursement/info/downloadImportError",
+			method: "get",
+			params: { filePath: filePath },
+			responseType: "blob",
+		});
+	}
 }

+ 30 - 0
src/views/zs/reimbursement/info/InfoList.vue

@@ -111,6 +111,8 @@
 				<template #buttons>
 					<el-button v-if="hasPermission('zsReimbursement:info:add')" type="primary" icon="el-icon-plus"
 						@click="add()">新建</el-button>
+					<el-button v-if="hasPermission('zsReimbursement:info:import')" type="info" icon="el-icon-upload"
+						@click="openImportDialog()">导入</el-button>
 					<el-button v-if="hasPermission('zsReimbursement:info:del')" type="danger" icon="el-icon-delete"
 						@click="del()" :disabled="$refs.infoTable && $refs.infoTable.getCheckboxRecords().length === 0"
 						plain>删除</el-button>
@@ -277,6 +279,7 @@
 				<ContractNameForm ref="contractNameForm"></ContractNameForm>
 				<user-select1 ref="userSelect1" @doSubmit="selectUser1"></user-select1>
 				<user-select2 ref="userSelect2" @doSubmit="selectUser2"></user-select2>
+				<ImportDialog ref="importDialog" @refreshDataList="refreshList" @import-error="handleImportError"></ImportDialog>
 			</div>
 		</div>
 	</div>
@@ -305,6 +308,7 @@ import NewInfoUpdateForm from "./NewInfoUpdateForm";
 
 import UserSelect1 from '@/views/utils/UserTreeSelect'
 import UserSelect2 from '@/views/utils/UserTreeSelect'
+import ImportDialog from './ImportDialog'
 import dayjs from 'dayjs';
 export default {
 	data() {
@@ -395,6 +399,7 @@ export default {
 		NewInfoUpdateForm,
 		UserSelect1,
 		UserSelect2,
+		ImportDialog,
 	},
 	mounted() {
 		this.$nextTick(() => {
@@ -420,6 +425,31 @@ export default {
 		}
 	},
 	methods: {
+		// 打开导入弹窗
+		openImportDialog() {
+			this.$refs.importDialog.init()
+		},
+		// 导入错误处理:提示下载错误文件
+		handleImportError(data) {
+			this.$nextTick(async () => {
+				try {
+					await this.$confirm('导入数据存在问题,是否下载错误详情文件?', '提示', {
+						confirmButtonText: '是',
+						cancelButtonText: '否',
+						type: 'warning',
+						distinguishCancelAndClose: true
+					});
+					this.reimbursementService.downloadImportError(data.errorFilePath).then(res => {
+						this.$utils.downloadExcel(res, '中审报销导入错误结果.xlsx')
+						this.$message.success('文件下载成功!')
+					}).catch(err => {
+						this.$message.error('下载失败')
+					})
+				} catch (err) {
+					// 用户取消
+				}
+			})
+		},
 		// 判断时间
 		isNewVersion(row) {
 			let newStartDate = this.$dictUtils.getDictLabel("new_version_reimbursement_date", '1', '-')