Bläddra i källkod

报告批量登记和批量发起报告号申请流程

huangguoce 1 månad sedan
förälder
incheckning
2c8a0e86ba

+ 22 - 0
src/api/cw/reportManagement/ProjectReportService.js

@@ -312,4 +312,26 @@ export default {
 			responseType: "blob",
 		});
 	},
+	// 批量导入报告模板-下载
+	downloadReportTemplate: function () {
+		return request({
+			url: prefix + "/cwProjectReport/download/template",
+			method: "get",
+			responseType: "blob",
+		});
+	},
+	importReport: function (data) {
+		return request({
+			url: prefix + "/cwProjectReport/importReport",
+			method: "post",
+			data: data,
+		});
+	},
+	batchStartReportNumber: function (data) {
+		return request({
+			url: prefix + "/cwProjectReport/batchStartReportNumber",
+			method: "post",
+			data: data,
+		});
+	},
 };

+ 153 - 0
src/views/cw/reportManagement/ReportListImport.vue

@@ -0,0 +1,153 @@
+<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
+	<div>
+		<el-dialog :title="title" :close-on-click-modal="false" draggable width="1000px" height="500px" @close="close"
+			append-to-body v-model="visible">
+			<el-form :model="inputForm" ref="inputForm" :class="method === 'view' ? 'readonly' : ''"
+				:disabled="status === 'audit' || status === 'taskFormDetail'" label-width="135px"
+				@submit.native.prevent>
+				<el-row :gutter="0">
+				</el-row>
+				<el-row :gutter="0">
+					<el-col :span="24">
+						<el-form-item label="附件上传:">
+							<el-upload ref="upload" :on-remove="handleRemove" action="" :limit="1" :auto-upload="false"
+								:on-change="beforeUploadDetail" :show-file-list="true">
+								<el-button type="primary">点击上传Excel文件</el-button>
+							</el-upload>
+						</el-form-item>
+					</el-col>
+				</el-row>
+
+			</el-form>
+
+
+			<template #footer>
+				<span class="dialog-footer">
+					<el-button type="warning" @click="downloadTpl()" plain>下载模板</el-button>
+					<el-button @click="close()" icon="el-icon-circle-close">关闭</el-button>
+					<el-button v-if="method !== 'view'" type="primary" icon="el-icon-circle-check"
+						@click="doSubmit()">确定</el-button>
+				</span>
+			</template>
+		</el-dialog>
+	</div>
+</template>
+
+<script>
+import projectReportService from '@/api/cw/reportManagement/ProjectReportService'
+import { ElMessageBox } from 'element-plus'
+export default {
+	data() {
+		return {
+			visible: false,
+			title: '',
+			inputForm: {
+				file: []
+			}
+		}
+	},
+	created() {
+	},
+	components: {
+	},
+	methods: {
+		handleRemove() {
+			this.inputForm.file.pop()
+			console.log(this.inputForm.file);
+		},
+		init() {
+			this.visible = true
+			this.title = '项目导入'
+			this.inputForm = {
+				file: []
+			}
+			this.$forceUpdate()
+		},
+
+		beforeUploadDetail(file) {
+			this.inputForm.file.push(file)
+		},
+
+		// 下载模板
+		downloadTpl() {
+			const loading = this.$loading({
+				lock: true,
+				text: '模板下载中,请稍后',
+				spinner: 'el-icon-loading',
+				background: 'rgba(255, 255, 255, 0.3)'
+			});
+			projectReportService.downloadReportTemplate().then((res) => {
+				// 将二进制流文件写入excel表,以下为重要步骤
+				this.$utils.downloadExcel(res, '报告批量导入模板' + ".xlsx")
+				loading.close();
+			}).catch(function (err) {
+				loading.close();
+				if (err.response) {
+					console.log(err.response)
+				}
+			})
+		},
+		doSubmit() {
+			if (this.inputForm.file.length == 0) {
+				this.$message.warning('未上传文件,无法提交导入')
+				return
+			}
+			const loading = this.$loading({
+				lock: true,
+				text: '导入中,请稍后',
+				spinner: 'el-icon-loading',
+				background: 'rgba(255, 255, 255, 0.3)'
+			});
+			const formBody = new FormData()
+			formBody.append('file', this.inputForm.file[0].raw)
+			projectReportService.importReport(formBody).then((data) => {
+				if (data) {
+					loading.close();
+					this.close()
+					if (data.length > 0) {
+						let message = '操作完成</br>';
+						data.forEach((item) => {
+							message += item + '</br>';
+						});
+						ElMessageBox.alert(message, '提示', {
+							dangerouslyUseHTMLString: true,
+							confirmButtonText: '确定',
+							callback: (action) => {
+								this.$emit("refreshDataList");
+							},
+						})
+					} else {
+						this.$message.success('操作成功')
+						this.$emit("refreshDataList");
+					}
+				} else {
+					loading.close();
+				}
+			}).catch(err => {
+				loading.close();
+			})
+		},
+		close() {
+			this.visible = false
+			this.$refs.inputForm.resetFields()
+			this.$refs.upload.clearFiles();
+			this.inputForm = {
+				file: []
+			}
+		}
+
+	}
+}
+</script>
+
+<style scoped>
+/deep/ .el-input-number .el-input__inner {
+	text-align: left;
+}
+
+.el-row {
+	display: flex;
+	align-items: center;
+	/* 垂直居中 */
+}
+</style>

+ 56 - 1
src/views/cw/reportManagement/ReportManagementList.vue

@@ -147,6 +147,11 @@
 						plain>已盖章文件下载</el-button>
 					<el-button v-if="hasPermission('cw_report_number:replace')" type="primary"
 						@click="importReplaceNumber()" plain>报告号替换</el-button>
+					<el-button type="primary" v-if="hasPermission('cwProjectReport:import')" @click="exportReport()"
+						plain>批量登记报告</el-button>
+					<el-button type="primary" v-if="hasPermission('cwProjectReport:start')"
+						@click="batchStartReportNumber()" plain
+						:disabled="$refs.clientTable && $refs.clientTable.getCheckboxRecords().length === 0">批量报告号申请</el-button>
 				</template>
 				<template #tools>
 					<vxe-button text type="primary" :title="searchVisible ? '收起检索' : '展开检索'" icon="vxe-icon-search"
@@ -468,6 +473,7 @@
 		<user-select2 ref="userSelect2" @doSubmit="selectUser2"></user-select2>
 		<user-select3 ref="userSelect3" @doSubmit="selectUser3"></user-select3>
 		<NumberReplace ref="numberReplace" @refreshList="refreshList"></NumberReplace>
+		<ReportListImport ref="reportListImport" @refreshDataList="refreshList"></ReportListImport>
 	</div>
 </template>
 
@@ -492,6 +498,8 @@ import UserSelect1 from '@/views/utils/UserTreeSelectBySignatureScribe'
 import UserSelect2 from '@/views/utils/UserTreeSelectBySignatureScribe'
 import UserSelect3 from '@/views/utils/UserTreeSelect'
 import NumberReplace from "./NumberReplace";
+import ReportListImport from "./ReportListImport.vue";
+import { ElMessageBox } from 'element-plus'
 export default {
 	data() {
 		return {
@@ -574,7 +582,8 @@ export default {
 		UserSelect2,
 		UserSelect1,
 		UserSelect3,
-		NumberReplace
+		NumberReplace,
+		ReportListImport
 	},
 	computed: {
 		userName() {
@@ -2179,6 +2188,52 @@ export default {
 		//报告号替换
 		importReplaceNumber() {
 			this.$refs.numberReplace.init()
+		},
+		// 批量导入报告
+		exportReport() {
+			this.$refs.reportListImport.init()
+		},
+		// 批量启动报告号申请流程
+		batchStartReportNumber() {
+			let selectedRows = this.$refs.clientTable.getCheckboxRecords()
+			// 校验是否存在下节点审核人和是否存在已发起流程的数据
+			for (const row of selectedRows) {
+				if ((row.applyStatus != '0' && row.applyStatus != '1')) {
+					this.$message.error('所选数据中存在已发起报告号申请流程的数据,请重新选择')
+					return
+				}
+				if (!row.reviewBy) {
+					this.$message.error('报告名称为:' + row.reportName + '的数据未选择下一节点审核人')
+					return
+				}
+				if (!row.takeNumberType) {
+					this.$message.error('报告名称为:' + row.reportName + '的数据未选择取号类型')
+					return
+				}
+
+			}
+			ElMessageBox.confirm(
+				'确定发起选中数据的报告号申请吗?',
+				'提示',
+				{
+					confirmButtonText: '确定',
+					cancelButtonText: '取消',
+					type: 'warning',
+				}
+			)
+				.then(() => {
+					this.loading = true
+					projectReportService.batchStartReportNumber(selectedRows).then(() => {
+						this.$message.success('操作成功')
+						this.refreshList()
+					}).catch(() => {
+						this.$message.error('操作失败,请重试')
+						this.refreshList()
+					})
+				})
+				.catch(() => {
+
+				})
 		}
 	}
 }