소스 검색

批量下载附件

huangguoce 3 주 전
부모
커밋
c42c8398d0

+ 9 - 0
src/api/human/enrollment/EnrollmentRegistrationService.js

@@ -221,6 +221,15 @@ export default {
 			responseType: "blob",
 		});
 	},
+	downloadAttachmentById(data) {
+		return request({
+			url: prefix + "/enrollmentRegistration/downloadAttachmentById",
+			method: "post",
+			data: data,
+			responseType: "blob",
+		});
+	},
+
 	downloadDepartFile(handoverId) {
 		return request({
 			url: prefix + "/enrollmentRegistration/downloadDepartFile",

+ 51 - 22
src/views/human/enrollment/registration/EnrollmentRegistrationList.vue

@@ -75,31 +75,26 @@
 								<el-input v-model="searchForm.mobilePhone" placeholder="请输入联系电话" clearable></el-input>
 							</el-form-item>
 							<el-form-item label="政治面貌" prop="politicalOutlook" :rules="[]">
-								<el-select v-model="searchForm.politicalOutlook" placeholder="请选择政治面貌" style="width:100%;" clearable>
-									<el-option v-for="item in $dictUtils.getDictList('political_outlook')" :key="item.value"
-											   :label="item.label" :value="item.value">
+								<el-select v-model="searchForm.politicalOutlook" placeholder="请选择政治面貌"
+									style="width:100%;" clearable>
+									<el-option v-for="item in $dictUtils.getDictList('political_outlook')"
+										:key="item.value" :label="item.label" :value="item.value">
 									</el-option>
 								</el-select>
 							</el-form-item>
 							<el-form-item label="账号状态" prop="loginFlag" :rules="[]">
-								<el-select v-model="searchForm.loginFlag" placeholder="请选择账号状态" style="width:100%;" clearable>
+								<el-select v-model="searchForm.loginFlag" placeholder="请选择账号状态" style="width:100%;"
+									clearable>
 									<el-option v-for="item in $dictUtils.getDictList('login_flag')" :key="item.value"
-											   :label="item.label" :value="item.value">
+										:label="item.label" :value="item.value">
 									</el-option>
 								</el-select>
 							</el-form-item>
 
 							<el-form-item label="入所日期" prop="createDates">
-								<el-date-picker
-									style = "width: 300px"
-									placement="bottom-start"
-									format="YYYY-MM-DD"
-									value-format="YYYY-MM-DD"
-									v-model="searchForm.createDates"
-									type="daterange"
-									range-separator="至"
-									start-placeholder="开始日期"
-									end-placeholder="结束日期">
+								<el-date-picker style="width: 300px" placement="bottom-start" format="YYYY-MM-DD"
+									value-format="YYYY-MM-DD" v-model="searchForm.createDates" type="daterange"
+									range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
 								</el-date-picker>
 							</el-form-item>
 
@@ -115,6 +110,10 @@
 						<vxe-toolbar :refresh="{ query: resetSearch }" ref="toolbarRef" import export custom>
 							<template #buttons>
 								<el-button type="primary" icon="el-icon-plus" @click="start()">新建</el-button>
+								<!-- <el-button type="primary" icon="el-icon-plus" @click="selectAllEvent()">全选</el-button> -->
+								<el-button type="primary" icon="el-icon-plus"
+									@click="downloadAttachments()">批量下载附件</el-button>
+
 							</template>
 							<template #tools>
 								<vxe-button type="text" :title="searchVisible ? '收起检索' : '展开检索'
@@ -139,7 +138,9 @@
 									types: ['xlsx'],
 									modes: ['current', 'selected', 'all']
 								}" :menu-config="{}" @sort-change="sortChangeHandle" :sort-config="{ remote: true }" :data="dataList"
-								:checkbox-config="{}">
+								:checkbox-config="{}" @checkbox-all="selectAllChangeEvent"
+								@checkbox-change="selectChangeEvent">
+								<vxe-column type="checkbox" width="60"></vxe-column>
 								<vxe-column type="seq" width="60" title="序号"></vxe-column>
 								<vxe-column min-width="160" align="center" title="姓名" field="name">
 									<template #default="scope">
@@ -164,8 +165,7 @@
 									field="departmentName"></vxe-column>
 								<vxe-column min-width="160" align="center" title="联系电话"
 									field="mobilePhone"></vxe-column>
-								<vxe-column min-width="160" align="center" title="进所日期"
-									field="entryDate"></vxe-column>
+								<vxe-column min-width="160" align="center" title="进所日期" field="entryDate"></vxe-column>
 								<!--								<vxe-column min-width="160" fixed="right" align="center" title="是否已加入钉钉" field="ddType">
 									<template #default="scope">
 										<el-button v-if="scope.row.ddType === '1'" @click="detail(scope.row)"
@@ -242,14 +242,15 @@
 			</el-container>
 		</pane>
 	</splitpanes>
-	<!--  <div class="page">-->
 
 	<EnrollmentRegistrationEditForm ref="enrollmentRegistrationEditForm" @refreshDataList="refreshList">
 	</EnrollmentRegistrationEditForm>
 
 	<!-- 修改密码 -->
 	<EditPassword ref="userPwForm" @refreshDataList="refreshList"></EditPassword>
-	<!--  </div>-->
+	<!-- 批量下载附件 -->
+	<DownloadAttachment ref="downloadAttachment" @refreshDataList="refreshList" />
+
 </template>
 
 <script>
@@ -264,6 +265,7 @@ import taskService from '@/api/flowable/TaskService'
 import pick from "lodash.pick";
 import officeService from "@/api/sys/officeService";
 import EditPassword from "./EditPassword.vue"
+import DownloadAttachment from "./components/DownloadAttachment.vue";
 export default {
 	data() {
 		return {
@@ -296,6 +298,7 @@ export default {
 			searchVisible: true,
 			officeTreeData: [],
 			filterText: "",
+			selectChangeList: []
 		}
 	},
 	created() {
@@ -305,7 +308,8 @@ export default {
 		EnrollmentRegistrationEditForm,
 		Splitpanes,
 		Pane,
-		EditPassword
+		EditPassword,
+		DownloadAttachment
 	},
 	watch: {
 		filterText(val) {
@@ -636,6 +640,31 @@ export default {
 				})
 			})
 		},
+		downloadAttachments() {
+			if (!this.selectChangeList || !this.selectChangeList.length) {
+				this.$message.warning("未选择任何用户,无法下载附件")
+				return
+			}
+			let ids = this.selectChangeList.map(item => {
+				return item.id
+			})
+			this.$refs.downloadAttachment.visible = true
+			this.$refs.downloadAttachment.ids = ids.join(',');
+		},
+		selectAllChangeEvent({ checked }) {
+			const $table = this.$refs.clientTable
+			if ($table) {
+				const records = $table.getCheckboxRecords()
+				this.selectChangeList = [...records]
+			}
+		},
+		selectChangeEvent({ checked }) {
+			const $table = this.$refs.clientTable
+			if ($table) {
+				const records = $table.getCheckboxRecords()
+				this.selectChangeList = [...records]
+			}
+		},
 	}
 }
-</script>
+</script>

+ 112 - 0
src/views/human/enrollment/registration/components/DownloadAttachment.vue

@@ -0,0 +1,112 @@
+<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
+	<div>
+		<el-dialog title="批量下载附件" :close-on-click-modal="false" draggable width="600px" height="500px" @close="close"
+			append-to-body v-model="visible" center align-center>
+			<el-form :model="inputForm" ref="inputForm" v-loading="loading" :rules="rules" label-width="100px"
+				@submit.native.prevent>
+				<el-form-item label="下载附件" prop="attachmentType">
+					<el-select size="default" v-model="inputForm.attachmentType" placeholder="请选择下载附件类型"
+						style="width: 100%;">
+						<el-option v-for="item in $dictUtils.getDictList('attachment_type')" :key="item.value"
+							:label="item.label" :value="item.value">
+						</el-option>
+					</el-select> </el-form-item>
+			</el-form>
+			<template #footer>
+				<span class="dialog-footer">
+					<el-button @click="close()" icon="el-icon-circle-close">关闭</el-button>
+					<el-button type="primary" icon="el-icon-circle-check" @click="doSubmit()">确定</el-button>
+				</span>
+			</template>
+		</el-dialog>
+	</div>
+</template>
+
+<script>
+import enrollmentRegistrationService from '@/api/human/enrollment/EnrollmentRegistrationService'
+export default {
+	data() {
+		return {
+			disabled: false,
+			title: '',
+			method: '',
+			visible: false,
+			loading: false,
+			ids: "",
+			inputForm: {
+				attachmentType: ""
+			},
+			keyWatch: '',
+			rules: {
+				attachmentType: [
+					{ required: true, message: '请选择下载附件类型', trigger: 'blur' }
+				],
+
+			}
+		}
+	},
+	computed: {
+		name() {
+			return this.$store.state.user.name
+		},
+		userId() {
+			return this.$store.state.user.id
+		}
+	},
+	watch: {
+		'loading': {
+			handler(newVal) {
+				this.$emit('changeLoading', newVal)
+			}
+		}
+	},
+	methods: {
+		// 表单提交
+		doSubmit() {
+			this.$refs['inputForm'].validate((valid) => {
+				if (valid) {
+					this.loading = true
+					enrollmentRegistrationService.downloadAttachmentById({
+						ids: this.ids,
+						attachmentType: this.inputForm.attachmentType
+					}).then(res => {
+						if (res.type == "application/json") {
+							const reader = new FileReader()
+							reader.readAsText(res, 'utf-8')
+							reader.onload = () => {
+								const result = JSON.parse(reader.result)
+								this.$message.error(result.msg)
+								this.close()
+								this.loading = false
+							}
+							return
+						}
+						let fileName = this.$dictUtils.getDictLabel("attachment_type", this.inputForm.attachmentType,
+							'用户信息')
+						this.$utils.downloadWord(res, fileName + '.zip')
+						this.$message.success("操作成功")
+						this.close()
+						this.loading = false
+					}).catch(err => {
+						this.loading = false
+					})
+				}
+			})
+		},
+		close() {
+			this.$refs.inputForm.resetFields()
+			this.ids = ""
+			this.visible = false
+		},
+	}
+}
+</script>
+
+
+<style lang="less">
+.fileUpload {
+	.el-form-item__content {
+		width: 100%;
+	}
+}
+</style>