Browse Source

会计报销 添加批量导入功能

徐滕 2 weeks atrás
parent
commit
3e7cf0aabe

+ 24 - 0
src/api/cw/reimbursementApproval/ReimbursementApprovalService.js

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

+ 1 - 1
src/views/common/reimbursement/ReimbursementComponentTest.vue

@@ -590,7 +590,7 @@
         </div>
         <div v-if="inputForm.sourceType === '3' && tenantFlag === 'cw'">
             <el-divider content-position="left"><i class="el-icon-document"></i>
-                报告报销详情1
+                报告报销详情
                 <el-button v-if="insertBtn" size="default" style="margin-left: 20px" type="primary"
                     :disabled="method === 'view' || status === 'audit' || status === 'taskFormDetail'"
                     @click="insertEvent('report_detail')" plain>

+ 30 - 0
src/views/cw/reimbursementApproval/info/InfoList.vue

@@ -109,6 +109,8 @@
 				<template #buttons>
 					<el-button v-if="hasPermission('cw:reimbursement:info:add')" type="primary" icon="el-icon-plus"
 						@click="add()">新建</el-button>
+					<el-button v-if="hasPermission('cw:reimbursement:info:import')" type="info" icon="el-icon-upload"
+						@click="openImportDialog()">导入</el-button>
 					<el-button v-if="hasPermission('cw:reimbursement:info:del')" type="danger" icon="el-icon-delete"
 						@click="del()" :disabled="$refs.infoTable && $refs.infoTable.getCheckboxRecords().length === 0"
 						plain>删除</el-button>
@@ -278,6 +280,7 @@
 				<ProjectListForm ref="projectListForm"></ProjectListForm>
 				<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>
@@ -302,6 +305,7 @@ import NewInfoUpdateForm from './NewInfoUpdateForm'
 import ProjectListForm from './ProgramForm'
 import UserSelect1 from '@/views/utils/UserTreeSelect'
 import UserSelect2 from '@/views/utils/UserTreeSelect'
+import ImportDialog from './ImportDialog'
 import dayjs from 'dayjs';
 export default {
 	data() {
@@ -385,6 +389,7 @@ export default {
 		ProjectListForm,
 		UserSelect1,
 		UserSelect2,
+		ImportDialog,
 	},
 	mounted() {
 		this.$nextTick(() => {
@@ -409,6 +414,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.reimbursementApprovalService.downloadImportError(data.errorFilePath).then(res => {
+						this.$utils.downloadExcel(res, '报销导入错误结果.xlsx')
+						this.$message.success('文件下载成功!')
+					}).catch(err => {
+						this.$message.error('下载失败')
+					})
+				} catch (err) {
+					this.$message.info('已取消下载')
+				}
+			})
+		},
 		// 判断时间
 		isNewVersion(row) {
 			let newStartDate = this.$dictUtils.getDictLabel("new_version_reimbursement_date", '1', '-')