Commit 4b20b6d600968b4b54c4ff21cfeaae77d8c0d117
1 parent
b4baced4
1.文件资料
2.廉政风险点 3.廉洁教育
Showing
8 changed files
with
475 additions
and
1 deletions
trash-ui/src/api/other/incorruptData.js
0 → 100644
| 1 | +import request from '@/utils/request' | ||
| 2 | + | ||
| 3 | +// 查询文件资料列表 | ||
| 4 | +export function listIncorruptData(tableName) { | ||
| 5 | + return request({ | ||
| 6 | + url: '/other/incorrupt/list/'+tableName, | ||
| 7 | + method: 'get' | ||
| 8 | + }) | ||
| 9 | +} | ||
| 10 | + | ||
| 11 | +// 新增文件资料 | ||
| 12 | +export function addIncorruptData(data) { | ||
| 13 | + return request({ | ||
| 14 | + url: '/other/incorrupt', | ||
| 15 | + method: 'post', | ||
| 16 | + data: data | ||
| 17 | + }) | ||
| 18 | +} |
trash-ui/src/views/other/incorruptEducation/index.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div class="app-container"> | ||
| 3 | + <el-row :gutter="10" class="mb8"> | ||
| 4 | + <el-col :span="1.5"> | ||
| 5 | + <el-upload | ||
| 6 | + ref="upload" | ||
| 7 | + action="" | ||
| 8 | + accept=".jpg,.jpeg,.png,.gif,.jfif,.pjpeg,.pjp" | ||
| 9 | + :on-change="fileChange" | ||
| 10 | + :auto-upload="false" | ||
| 11 | + :show-file-list="false" | ||
| 12 | + multiple | ||
| 13 | + :file-list="file"> | ||
| 14 | + <el-button size="small" type="primary" icon="el-icon-upload">上传附件</el-button> | ||
| 15 | + </el-upload> | ||
| 16 | + </el-col> | ||
| 17 | + <el-col :span="1.5"> | ||
| 18 | + <el-button size="small" type="primary" @click="file=[]">删除附件</el-button> | ||
| 19 | + </el-col> | ||
| 20 | + <el-col :span="1.5"> | ||
| 21 | + <el-button size="small" type="primary" @click="submitForm">提交</el-button> | ||
| 22 | + </el-col> | ||
| 23 | + </el-row> | ||
| 24 | + <el-image v-if="file.length!=0" style="" | ||
| 25 | + :src="createUrl(file[0])" | ||
| 26 | + :preview-src-list="[createUrl(file[0])]" | ||
| 27 | + :z-index="999"> | ||
| 28 | + </el-image> | ||
| 29 | + </div> | ||
| 30 | +</template> | ||
| 31 | + | ||
| 32 | +<script> | ||
| 33 | +import {addIncorruptData, listIncorruptData} from "@/api/other/incorruptData"; | ||
| 34 | + | ||
| 35 | +export default { | ||
| 36 | + name: "incorruptEducation", | ||
| 37 | + data() { | ||
| 38 | + return { | ||
| 39 | + file: [], | ||
| 40 | + }; | ||
| 41 | + }, | ||
| 42 | + created() { | ||
| 43 | + this.getList(); | ||
| 44 | + }, | ||
| 45 | + methods: { | ||
| 46 | + /** 查询文件资料列表 */ | ||
| 47 | + getList() { | ||
| 48 | + this.loading = true; | ||
| 49 | + listIncorruptData("education").then(response => { | ||
| 50 | + this.file = [{ | ||
| 51 | + url:response[0].filePath, | ||
| 52 | + name:response[0].fileName, | ||
| 53 | + }]; | ||
| 54 | + }); | ||
| 55 | + }, | ||
| 56 | + delFile(){ | ||
| 57 | + this.file=[]; | ||
| 58 | + }, | ||
| 59 | + /** 提交按钮 */ | ||
| 60 | + submitForm() { | ||
| 61 | + | ||
| 62 | + let formData = new FormData(); | ||
| 63 | + let form = { | ||
| 64 | + files: null, | ||
| 65 | + tableName: "education", | ||
| 66 | + }; | ||
| 67 | + | ||
| 68 | + this.file.forEach(item => { | ||
| 69 | + if (item.raw != null) { | ||
| 70 | + formData.append('files', item.raw) | ||
| 71 | + } else { | ||
| 72 | + //将原有的附件拼接到form中 | ||
| 73 | + form.files = form.files !== null ? form.files + ";" + item.url : item.url; | ||
| 74 | + } | ||
| 75 | + }) | ||
| 76 | + | ||
| 77 | + for (let key in form) { | ||
| 78 | + formData.append(key, form[key] == null ? "" : form[key]) | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + addIncorruptData(formData).then(response => { | ||
| 82 | + this.msgSuccess("新增成功"); | ||
| 83 | + this.open = false; | ||
| 84 | + this.getList(); | ||
| 85 | + }); | ||
| 86 | + }, | ||
| 87 | + /** | ||
| 88 | + * 文件改变时,限制文件上传格式和大小 | ||
| 89 | + * 文件格式只能为docx/doc/pdf/png/jpeg/png/jpg | ||
| 90 | + * 大小不超过20M | ||
| 91 | + * */ | ||
| 92 | + fileChange(file, fileList) { | ||
| 93 | + let count = 0; | ||
| 94 | + if(fileList.length>1){ | ||
| 95 | + this.$message({ | ||
| 96 | + message: '只能上传一张图片!', | ||
| 97 | + type: 'warning' | ||
| 98 | + }); | ||
| 99 | + return false; | ||
| 100 | + } | ||
| 101 | + for (let i = 0; i < fileList.length; i++) { | ||
| 102 | + // console.log(fileList.length) | ||
| 103 | + // console.log(this.fileEntityList[i].name+"111"+file.name) | ||
| 104 | + if (fileList[i].name == file.name) { | ||
| 105 | + count++; | ||
| 106 | + if (count == 2) { | ||
| 107 | + this.$message({ | ||
| 108 | + message: '已存在此文件!', | ||
| 109 | + type: 'warning' | ||
| 110 | + }); | ||
| 111 | + for (let j = fileList.length; j > 0; j--) { | ||
| 112 | + //如果存在此文件,去除新选择的重复文件 | ||
| 113 | + if (fileList[j - 1].name == file.name) { | ||
| 114 | + fileList.splice(j - 1, 1); | ||
| 115 | + i--; | ||
| 116 | + return false; | ||
| 117 | + } | ||
| 118 | + } | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + let fileType = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase(); | ||
| 123 | + //格式符合后判断大小 | ||
| 124 | + if ("jpg,jpeg,png,gif,jfif,pjpeg,pjp".indexOf(fileType) != -1) { | ||
| 125 | + let max5M = file.size / 1024 / 1024 < 100; | ||
| 126 | + if (!max5M) { | ||
| 127 | + this.$message({ | ||
| 128 | + message: '上传文件大小不得超过100M!', | ||
| 129 | + type: 'warning' | ||
| 130 | + }); | ||
| 131 | + fileList = fileList.splice(fileList.length - 1, 1); | ||
| 132 | + } else { | ||
| 133 | + //符合条件后进行添加 | ||
| 134 | + this.file = fileList | ||
| 135 | + } | ||
| 136 | + } else { | ||
| 137 | + this.$message({ | ||
| 138 | + message: '上传文件只能是 jpg,jpeg,png,gif,jfif,pjpeg,pjp格式!', | ||
| 139 | + type: 'warning' | ||
| 140 | + }); | ||
| 141 | + fileList = fileList.splice(fileList.length - 1, 1); | ||
| 142 | + } | ||
| 143 | + }, | ||
| 144 | + createUrl(file) { | ||
| 145 | + if (file.raw != null) { | ||
| 146 | + return URL.createObjectURL(file.raw); | ||
| 147 | + } else { | ||
| 148 | + return process.env.VUE_APP_BASE_API + file.url; | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + }, | ||
| 152 | + } | ||
| 153 | +}; | ||
| 154 | +</script> |
trash-ui/src/views/other/incorruptGovernment/index.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div class="app-container"> | ||
| 3 | + | ||
| 4 | + | ||
| 5 | + <el-row :gutter="10" class="mb8"> | ||
| 6 | + <el-col :span="1.5"> | ||
| 7 | + <el-upload | ||
| 8 | + ref="upload" | ||
| 9 | + action="" | ||
| 10 | + accept=".jpg,.jpeg,.png,.gif,.jfif,.pjpeg,.pjp" | ||
| 11 | + :on-change="fileChange" | ||
| 12 | + :auto-upload="false" | ||
| 13 | + :show-file-list="false" | ||
| 14 | + multiple | ||
| 15 | + :file-list="file"> | ||
| 16 | + <el-button size="small" type="primary" icon="el-icon-upload">上传附件</el-button> | ||
| 17 | + </el-upload> | ||
| 18 | + </el-col> | ||
| 19 | + <el-col :span="1.5"> | ||
| 20 | + <el-button size="small" type="primary" @click="file=[]">删除附件</el-button> | ||
| 21 | + </el-col> | ||
| 22 | + <el-col :span="1.5"> | ||
| 23 | + <el-button size="small" type="primary" @click="submitForm">提交</el-button> | ||
| 24 | + </el-col> | ||
| 25 | + </el-row> | ||
| 26 | + <el-image v-if="file.length!=0" style="" | ||
| 27 | + :src="createUrl(file[0])" | ||
| 28 | + :preview-src-list="[createUrl(file[0])]" | ||
| 29 | + :z-index="999"> | ||
| 30 | + </el-image> | ||
| 31 | + </div> | ||
| 32 | +</template> | ||
| 33 | + | ||
| 34 | +<script> | ||
| 35 | +import {addIncorruptData, listIncorruptData} from "@/api/other/incorruptData"; | ||
| 36 | + | ||
| 37 | +export default { | ||
| 38 | + name: "incorruptGovernment", | ||
| 39 | + data() { | ||
| 40 | + return { | ||
| 41 | + file: [], | ||
| 42 | + }; | ||
| 43 | + }, | ||
| 44 | + created() { | ||
| 45 | + this.getList(); | ||
| 46 | + }, | ||
| 47 | + methods: { | ||
| 48 | + /** 查询文件资料列表 */ | ||
| 49 | + getList() { | ||
| 50 | + this.loading = true; | ||
| 51 | + listIncorruptData("government").then(response => { | ||
| 52 | + this.file = [{ | ||
| 53 | + url:response[0].filePath, | ||
| 54 | + name:response[0].fileName, | ||
| 55 | + }]; | ||
| 56 | + }); | ||
| 57 | + }, | ||
| 58 | + delFile(){ | ||
| 59 | + this.file=[]; | ||
| 60 | + }, | ||
| 61 | + /** 提交按钮 */ | ||
| 62 | + submitForm() { | ||
| 63 | + | ||
| 64 | + let formData = new FormData(); | ||
| 65 | + let form = { | ||
| 66 | + files: null, | ||
| 67 | + tableName: "government", | ||
| 68 | + }; | ||
| 69 | + | ||
| 70 | + this.file.forEach(item => { | ||
| 71 | + if (item.raw != null) { | ||
| 72 | + formData.append('files', item.raw) | ||
| 73 | + } else { | ||
| 74 | + //将原有的附件拼接到form中 | ||
| 75 | + form.files = form.files !== null ? form.files + ";" + item.url : item.url; | ||
| 76 | + } | ||
| 77 | + }) | ||
| 78 | + | ||
| 79 | + for (let key in form) { | ||
| 80 | + formData.append(key, form[key] == null ? "" : form[key]) | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + addIncorruptData(formData).then(response => { | ||
| 84 | + this.msgSuccess("新增成功"); | ||
| 85 | + this.open = false; | ||
| 86 | + this.getList(); | ||
| 87 | + }); | ||
| 88 | + }, | ||
| 89 | + /** | ||
| 90 | + * 文件改变时,限制文件上传格式和大小 | ||
| 91 | + * 文件格式只能为docx/doc/pdf/png/jpeg/png/jpg | ||
| 92 | + * 大小不超过20M | ||
| 93 | + * */ | ||
| 94 | + fileChange(file, fileList) { | ||
| 95 | + let count = 0; | ||
| 96 | + if(fileList.length>1){ | ||
| 97 | + this.$message({ | ||
| 98 | + message: '只能上传一张图片!', | ||
| 99 | + type: 'warning' | ||
| 100 | + }); | ||
| 101 | + return false; | ||
| 102 | + } | ||
| 103 | + for (let i = 0; i < fileList.length; i++) { | ||
| 104 | + // console.log(fileList.length) | ||
| 105 | + // console.log(this.fileEntityList[i].name+"111"+file.name) | ||
| 106 | + if (fileList[i].name == file.name) { | ||
| 107 | + count++; | ||
| 108 | + if (count == 2) { | ||
| 109 | + this.$message({ | ||
| 110 | + message: '已存在此文件!', | ||
| 111 | + type: 'warning' | ||
| 112 | + }); | ||
| 113 | + for (let j = fileList.length; j > 0; j--) { | ||
| 114 | + //如果存在此文件,去除新选择的重复文件 | ||
| 115 | + if (fileList[j - 1].name == file.name) { | ||
| 116 | + fileList.splice(j - 1, 1); | ||
| 117 | + i--; | ||
| 118 | + return false; | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + let fileType = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase(); | ||
| 125 | + //格式符合后判断大小 | ||
| 126 | + if ("jpg,jpeg,png,gif,jfif,pjpeg,pjp".indexOf(fileType) != -1) { | ||
| 127 | + let max5M = file.size / 1024 / 1024 < 100; | ||
| 128 | + if (!max5M) { | ||
| 129 | + this.$message({ | ||
| 130 | + message: '上传文件大小不得超过100M!', | ||
| 131 | + type: 'warning' | ||
| 132 | + }); | ||
| 133 | + fileList = fileList.splice(fileList.length - 1, 1); | ||
| 134 | + } else { | ||
| 135 | + //符合条件后进行添加 | ||
| 136 | + this.file = fileList | ||
| 137 | + } | ||
| 138 | + } else { | ||
| 139 | + this.$message({ | ||
| 140 | + message: '上传文件只能是 jpg,jpeg,png,gif,jfif,pjpeg,pjp格式!', | ||
| 141 | + type: 'warning' | ||
| 142 | + }); | ||
| 143 | + fileList = fileList.splice(fileList.length - 1, 1); | ||
| 144 | + } | ||
| 145 | + }, | ||
| 146 | + createUrl(file) { | ||
| 147 | + if (file.raw != null) { | ||
| 148 | + return URL.createObjectURL(file.raw); | ||
| 149 | + } else { | ||
| 150 | + return process.env.VUE_APP_BASE_API + file.url; | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + }, | ||
| 154 | + } | ||
| 155 | +}; | ||
| 156 | +</script> |
trash-workFlow/src/main/java/com/trash/office/mapper/UploadFileMapper.java
| @@ -58,4 +58,12 @@ public interface UploadFileMapper | @@ -58,4 +58,12 @@ public interface UploadFileMapper | ||
| 58 | * @return 结果 | 58 | * @return 结果 |
| 59 | */ | 59 | */ |
| 60 | int deleteUploadFileByIds(Long[] ids); | 60 | int deleteUploadFileByIds(Long[] ids); |
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * 根据表名删除文件上传 | ||
| 64 | + * | ||
| 65 | + * @param tableName 表名 | ||
| 66 | + * @return 结果 | ||
| 67 | + */ | ||
| 68 | + int deleteUploadFileByTableName(String tableName); | ||
| 61 | } | 69 | } |
trash-workFlow/src/main/java/com/trash/other/controller/IncorruptController.java
0 → 100644
| 1 | +package com.trash.other.controller; | ||
| 2 | + | ||
| 3 | +import com.trash.common.annotation.Log; | ||
| 4 | +import com.trash.common.core.controller.BaseController; | ||
| 5 | +import com.trash.common.core.domain.AjaxResult; | ||
| 6 | +import com.trash.common.enums.BusinessType; | ||
| 7 | +import com.trash.office.domain.UploadFile; | ||
| 8 | +import com.trash.other.service.IIncorruptService; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 11 | +import org.springframework.web.bind.annotation.*; | ||
| 12 | +import org.springframework.web.multipart.MultipartFile; | ||
| 13 | + | ||
| 14 | +import java.io.IOException; | ||
| 15 | +import java.util.List; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * 文件资料Controller | ||
| 19 | + * | ||
| 20 | + * @author trash | ||
| 21 | + * @date 2023-11-28 | ||
| 22 | + */ | ||
| 23 | +@RestController | ||
| 24 | +@RequestMapping("/other/incorrupt") | ||
| 25 | +public class IncorruptController extends BaseController | ||
| 26 | +{ | ||
| 27 | + @Autowired | ||
| 28 | + private IIncorruptService incorruptService; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 查询文件资料列表 | ||
| 32 | + */ | ||
| 33 | + @PreAuthorize("@ss.hasPermi('other:incorrupt:list')") | ||
| 34 | + @GetMapping("/list/{tableName}") | ||
| 35 | + public List<UploadFile> list(@PathVariable("tableName") String tableName) | ||
| 36 | + { | ||
| 37 | + return incorruptService.selectOtherDataList(tableName); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 新增文件资料 | ||
| 42 | + */ | ||
| 43 | + @PreAuthorize("@ss.hasPermi('other:incorrupt:add')") | ||
| 44 | + @Log(title = "廉政&廉洁教育", businessType = BusinessType.INSERT) | ||
| 45 | + @PostMapping | ||
| 46 | + public AjaxResult add(@RequestParam("files")MultipartFile[] files,String tableName) throws IOException { | ||
| 47 | + return toAjax(incorruptService.insertIncorrupt(files,tableName)); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | +// /** | ||
| 51 | +// * 修改文件资料 | ||
| 52 | +// */ | ||
| 53 | +// @PreAuthorize("@ss.hasPermi('other:documentData:edit')") | ||
| 54 | +// @Log(title = "文件资料", businessType = BusinessType.UPDATE) | ||
| 55 | +// @PutMapping | ||
| 56 | +// public AjaxResult edit(@RequestParam(value = "fileList") MultipartFile[] files,DocumentData documentData) throws IOException { | ||
| 57 | +// return toAjax(documentDataService.updateDocumentData(files, documentData)); | ||
| 58 | +// } | ||
| 59 | + | ||
| 60 | +} |
trash-workFlow/src/main/java/com/trash/other/service/IIncorruptService.java
0 → 100644
| 1 | +package com.trash.other.service; | ||
| 2 | + | ||
| 3 | +import com.trash.office.domain.UploadFile; | ||
| 4 | +import org.springframework.web.multipart.MultipartFile; | ||
| 5 | + | ||
| 6 | +import java.io.IOException; | ||
| 7 | +import java.util.List; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 其他专项资料Service接口 | ||
| 11 | + * | ||
| 12 | + * @author trash | ||
| 13 | + * @date 2023-05-11 | ||
| 14 | + */ | ||
| 15 | +public interface IIncorruptService | ||
| 16 | +{ | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + List<UploadFile> selectOtherDataList(String tableName); | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + int insertIncorrupt(MultipartFile[] files, String tableName) throws IOException; | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +} |
trash-workFlow/src/main/java/com/trash/other/service/impl/IncorruptServiceImpl.java
0 → 100644
| 1 | +package com.trash.other.service.impl; | ||
| 2 | + | ||
| 3 | +import com.trash.common.utils.file.FileUploadUtils; | ||
| 4 | +import com.trash.office.domain.UploadFile; | ||
| 5 | +import com.trash.office.mapper.UploadFileMapper; | ||
| 6 | +import com.trash.other.service.IIncorruptService; | ||
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | +import org.springframework.stereotype.Service; | ||
| 9 | +import org.springframework.web.multipart.MultipartFile; | ||
| 10 | + | ||
| 11 | +import java.io.IOException; | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 其他专项资料Service业务层处理 | ||
| 16 | + * | ||
| 17 | + * @author trash | ||
| 18 | + * @date 2023-05-11 | ||
| 19 | + */ | ||
| 20 | +@Service | ||
| 21 | +public class IncorruptServiceImpl implements IIncorruptService { | ||
| 22 | + @Autowired | ||
| 23 | + private UploadFileMapper uploadFileMapper; | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + @Override | ||
| 27 | + public List<UploadFile> selectOtherDataList(String tableName) { | ||
| 28 | + UploadFile uploadFile = new UploadFile(); | ||
| 29 | + uploadFile.setTableName(tableName); | ||
| 30 | + return uploadFileMapper.selectUploadFileList(uploadFile); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public int insertIncorrupt(MultipartFile[] files, String tableName) throws IOException { | ||
| 35 | + UploadFile uploadFile = new UploadFile(); | ||
| 36 | + for (MultipartFile file : files) { | ||
| 37 | + uploadFile.setTableName(tableName); | ||
| 38 | + uploadFile.setTableNumber("1"); | ||
| 39 | + uploadFile.setFileName(file.getOriginalFilename()); | ||
| 40 | + uploadFile.setFilePath(FileUploadUtils.uploadFile(file)); | ||
| 41 | + } | ||
| 42 | + uploadFileMapper.deleteUploadFileByTableName(tableName); | ||
| 43 | + return uploadFileMapper.insertUploadFile(uploadFile); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | +} |
trash-workFlow/src/main/resources/mapper/office/UploadFileMapper.xml
| @@ -71,5 +71,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -71,5 +71,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 71 | #{id} | 71 | #{id} |
| 72 | </foreach> | 72 | </foreach> |
| 73 | </delete> | 73 | </delete> |
| 74 | - | 74 | + |
| 75 | + | ||
| 76 | + <delete id="deleteUploadFileByTableName" parameterType="String"> | ||
| 77 | + delete from upload_file | ||
| 78 | + <if test="tableName != null"> | ||
| 79 | + where table_name = #{tableName} | ||
| 80 | + </if> | ||
| 81 | + </delete> | ||
| 75 | </mapper> | 82 | </mapper> |
| 76 | \ No newline at end of file | 83 | \ No newline at end of file |