Sfoglia il codice sorgente

工作台批量审批-所有报销相关流程

huangguoce 2 giorni fa
parent
commit
c9f3e80a25

+ 17 - 0
src/api/flowable/taskService.js

@@ -85,6 +85,23 @@ export default {
 		});
 	},
 
+	// 批量审批
+	batchAudit: function (data) {
+		return request({
+			url: prefix + "/flowable/task/batch-audit-jobs",
+			method: "post",
+			data: data,
+		});
+	},
+
+	// 批量审批任务状态查询
+	getBatchAuditJob: function (jobId) {
+		return request({
+			url: prefix + "/flowable/task/batch-audit-jobs/" + jobId,
+			method: "get",
+		});
+	},
+
 	backNodes: function (taskId) {
 		return request({
 			url: prefix + "/flowable/task/backNodes",

+ 123 - 0
src/views/flowable/task/TodoBatch.vue

@@ -0,0 +1,123 @@
+<template>
+	<div>
+		<el-dialog :title="title" :close-on-click-modal="false" dialogDrag width="400px" append-to-body
+			align-center="true" height="auto" v-loading="loading" @close="close" @keyup.enter.native="getWorkClient"
+			v-model="visibleChoose">
+			<el-icon style="color: #E6A23C;size:20px">
+				<Warning />
+			</el-icon>{{ confirmText }}
+			<template #footer>
+				<div class="dialog-footer">
+					<el-button v-loading="loading" size="primary" @click="todo('1')" v-noMoreClick>同意
+					</el-button>
+					<!-- <el-button v-loading="loading" type="paimary" @click="todo('0')" v-noMoreClick>驳回
+					</el-button> -->
+				</div>
+			</template>
+		</el-dialog>
+		<TaskForm ref="taskForm"></TaskForm>
+	</div>
+</template>
+
+<script>
+import taskService from "@/api/flowable/taskService";
+
+export default {
+	data() {
+		return {
+			title: '',
+			visibleChoose: false,
+			loading: false,
+			dataList: [],
+			allReimbursements: false,
+			batchAuditTimer: null
+		}
+	},
+	beforeUnmount() {
+		if (this.batchAuditTimer) {
+			clearTimeout(this.batchAuditTimer)
+		}
+	},
+	methods: {
+		init(info) {
+			this.title = '批量审核'
+			this.visibleChoose = true
+			this.dataList = info || []
+			this.allReimbursements = false
+			this.loading = false
+		},
+		initAll() {
+			this.title = '一键处理'
+			this.visibleChoose = true
+			this.dataList = []
+			this.allReimbursements = true
+			this.loading = false
+		},
+		async todo(type) {
+			if (!this.allReimbursements && !this.dataList.length) {
+				this.$message.warning('请选择需要审核的数据')
+				return
+			}
+
+			this.loading = true
+			try {
+				const params = {
+					agree: type === '1'
+				}
+				if (this.allReimbursements) {
+					params.allReimbursements = true
+				} else {
+					params.taskIds = this.dataList.map(item => item.task.id)
+				}
+				const data = await taskService.batchAudit(params)
+				this.$message.success('批量审核已提交,正在处理中')
+				this.close()
+				if (data && data.jobId) {
+					this.pollBatchAudit(data.jobId)
+				}
+			} finally {
+				this.loading = false
+			}
+		},
+		pollBatchAudit(jobId) {
+			if (this.batchAuditTimer) {
+				clearTimeout(this.batchAuditTimer)
+			}
+			this.batchAuditTimer = setTimeout(async () => {
+				try {
+					const progress = await taskService.getBatchAuditJob(jobId)
+					if (progress.status !== 'COMPLETED') {
+						this.pollBatchAudit(jobId)
+						return
+					}
+					// this.$message({
+					// 	type: progress.failed > 0 ? 'warning' : 'success',
+					// 	message: `批量审核完成:成功${progress.success}条,失败${progress.failed}条`
+					// })
+					this.$emit('refreshDataList')
+				} catch (e) {
+					this.pollBatchAudit(jobId)
+				}
+			}, 2000)
+		},
+		close() {
+			this.visibleChoose = false
+		}
+	},
+	computed: {
+		confirmText() {
+			return this.allReimbursements ? '是否处理全部报销审核' : '是否处理被选中的报销审核'
+		}
+	}
+}
+</script>
+<style scoped>
+/deep/ .el-dialog__body {
+	padding-top: 0;
+}
+
+/deep/ .el-form-item--mini.el-form-item,
+.el-form-item--small.el-form-item {
+	margin-bottom: 0px;
+}
+</style>

+ 31 - 1
src/views/flowable/task/TodoList.vue

@@ -27,6 +27,10 @@
 		<div class="jp-table">
 			<vxe-toolbar ref="todoToolbar" :refresh="{ query: refreshList }" export print custom>
 				<template #buttons>
+					<el-button v-if="hasPermission('approval:info:reimbursementApproval')" type="primary"
+						@click="allReimbursementApproval()">一键审核报销</el-button>
+					<el-button v-if="hasPermission('approval:info:reimbursementApproval')" type="primary"
+						@click="oneClickApproval()">批量审核报销</el-button>
 					<el-button v-if="hasPermission('approval:info:edit')" type="primary" icon="el-icon-plus"
 						@click="approval()"
 						:disabled="$refs.todoTable && $refs.todoTable.getCheckboxRecords().length === 0">批量审核</el-button>
@@ -99,6 +103,7 @@
 		<user-select2 ref="userSelect2" @doSubmit="selectUser">
 		</user-select2>
 		<TodoDia ref="todoDia" @refreshDataList="refreshList"></TodoDia>
+		<TodoBatch ref="todoBatch" @refreshDataList="refreshList"></TodoBatch>
 	</div>
 </template>
 
@@ -109,6 +114,7 @@ import UserSelect from "@/components/userSelect/UserSelectDialog";
 import taskService from "@/api/flowable/taskService";
 import UserSelect2 from '@/views/utils/UserTreeSelect';
 import TodoDia from "./TodoDia";
+import TodoBatch from "./TodoBatch";
 export default {
 	data() {
 		return {
@@ -151,7 +157,8 @@ export default {
 	components: {
 		UserSelect,
 		UserSelect2,
-		TodoDia
+		TodoDia,
+		TodoBatch
 		// FlowChart
 	},
 	watch: {
@@ -467,6 +474,29 @@ export default {
 			let info = this.$refs.todoTable.getCheckboxRecords()
 			this.$refs.todoDia.init(info)
 		},
+		oneClickApproval() {
+			let info = this.$refs.todoTable.getCheckboxRecords()
+			if (info.some(item => !this.isBatchReimbursementProcess(item.processDefinitionName))) {
+				this.$message.warning('勾选数据中包含非报销流程,请重新选择')
+				return
+			}
+			this.$refs.todoBatch.init(info)
+		},
+		isBatchReimbursementProcess(processName) {
+			const processNames = [
+				'咨询-所长报销-电子发票', '咨询-所长报销', '咨询-总经办报销', '咨询-报销审批-电子发票', '咨询-报销审批',
+				'项目-总经办报销', '中审-总经办报销', '评估-总经办报销', '会计-总经办报销',
+				'项目-报销审批-电子发票', '项目-报销审批', '评估-所长报销-电子发票', '评估-所长报销',
+				'中审-所长报销-电子发票', '中审-所长报销', '会计-所长报销', '会计-所长报销-电子发票',
+				'中审-报销审批-电子发票', '评估-报销审批-电子发票', '会计-报销审批-电子发票',
+				'中审-报销审批', '评估-报销审批', '会计-报销审批',
+				'苏州-业务操作报销', '中审-苏州分公司(智永祥)-报销'
+			]
+			return processNames.includes(processName)
+		},
+		allReimbursementApproval() {
+			this.$refs.todoBatch.initAll()
+		},
 		// // 审核方法
 		todoCcpm(row) {
 			console.log('row', row)