Commit b4baced4de7c8da2939a63576c971ffcd54225df
1 parent
28de91f0
建筑垃圾-基础数据
Showing
11 changed files
with
1081 additions
and
41 deletions
trash-ui/src/api/other/documentData.js
0 → 100644
| 1 | +import request from '@/utils/request' | ||
| 2 | + | ||
| 3 | +// 查询文件资料列表 | ||
| 4 | +export function listDocumentData(query) { | ||
| 5 | + return request({ | ||
| 6 | + url: '/other/documentData/list', | ||
| 7 | + method: 'get', | ||
| 8 | + params: query | ||
| 9 | + }) | ||
| 10 | +} | ||
| 11 | + | ||
| 12 | +// 查询文件资料详细 | ||
| 13 | +export function getDocumentData(id) { | ||
| 14 | + return request({ | ||
| 15 | + url: '/other/documentData/' + id, | ||
| 16 | + method: 'get' | ||
| 17 | + }) | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +// 新增文件资料 | ||
| 21 | +export function addDocumentData(data) { | ||
| 22 | + return request({ | ||
| 23 | + url: '/other/documentData', | ||
| 24 | + method: 'post', | ||
| 25 | + data: data | ||
| 26 | + }) | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +// 修改文件资料 | ||
| 30 | +export function updateDocumentData(data) { | ||
| 31 | + return request({ | ||
| 32 | + url: '/other/documentData', | ||
| 33 | + method: 'put', | ||
| 34 | + data: data | ||
| 35 | + }) | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +// 删除文件资料 | ||
| 39 | +export function delDocumentData(id) { | ||
| 40 | + return request({ | ||
| 41 | + url: '/other/documentData/' + id, | ||
| 42 | + method: 'delete' | ||
| 43 | + }) | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +// 导出文件资料 | ||
| 47 | +export function exportDocumentData(query) { | ||
| 48 | + return request({ | ||
| 49 | + url: '/other/documentData/export', | ||
| 50 | + method: 'get', | ||
| 51 | + params: query | ||
| 52 | + }) | ||
| 53 | +} | ||
| 0 | \ No newline at end of file | 54 | \ No newline at end of file |
trash-ui/src/views/other/documentData/index.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div class="app-container"> | ||
| 3 | + <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | + <el-form-item label="标题" prop="title"> | ||
| 5 | + <el-input | ||
| 6 | + v-model="queryParams.title" | ||
| 7 | + placeholder="请输入标题" | ||
| 8 | + clearable | ||
| 9 | + size="small" | ||
| 10 | + @keyup.enter.native="handleQuery" | ||
| 11 | + /> | ||
| 12 | + </el-form-item> | ||
| 13 | + <el-form-item> | ||
| 14 | + <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 15 | + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 16 | + </el-form-item> | ||
| 17 | + </el-form> | ||
| 18 | + | ||
| 19 | + <el-row :gutter="10" class="mb8"> | ||
| 20 | + <el-col :span="1.5"> | ||
| 21 | + <el-button | ||
| 22 | + type="primary" | ||
| 23 | + icon="el-icon-plus" | ||
| 24 | + size="mini" | ||
| 25 | + @click="handleAdd" | ||
| 26 | + v-hasPermi="['other:documentData:add']" | ||
| 27 | + >新增 | ||
| 28 | + </el-button> | ||
| 29 | + </el-col> | ||
| 30 | + <el-col :span="1.5"> | ||
| 31 | + <el-button | ||
| 32 | + type="success" | ||
| 33 | + icon="el-icon-edit" | ||
| 34 | + size="mini" | ||
| 35 | + :disabled="single" | ||
| 36 | + @click="handleUpdate" | ||
| 37 | + v-hasPermi="['other:documentData:edit']" | ||
| 38 | + >修改 | ||
| 39 | + </el-button> | ||
| 40 | + </el-col> | ||
| 41 | + <el-col :span="1.5"> | ||
| 42 | + <el-button | ||
| 43 | + type="danger" | ||
| 44 | + icon="el-icon-delete" | ||
| 45 | + size="mini" | ||
| 46 | + :disabled="multiple" | ||
| 47 | + @click="handleDelete" | ||
| 48 | + v-hasPermi="['other:documentData:remove']" | ||
| 49 | + >删除 | ||
| 50 | + </el-button> | ||
| 51 | + </el-col> | ||
| 52 | + <el-col :span="1.5"> | ||
| 53 | + <el-button | ||
| 54 | + type="warning" | ||
| 55 | + icon="el-icon-download" | ||
| 56 | + size="mini" | ||
| 57 | + @click="handleExport" | ||
| 58 | + v-hasPermi="['other:documentData:export']" | ||
| 59 | + >导出 | ||
| 60 | + </el-button> | ||
| 61 | + </el-col> | ||
| 62 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 63 | + </el-row> | ||
| 64 | + | ||
| 65 | + <el-table v-loading="loading" :data="documentDataList" @selection-change="handleSelectionChange"> | ||
| 66 | + <el-table-column type="selection" width="55" align="center"/> | ||
| 67 | + <el-table-column label="附件" align="center" prop="id"/> | ||
| 68 | + <el-table-column label="标题" align="center" prop="title"/> | ||
| 69 | + <el-table-column label="时间" align="center" prop="createTime"> | ||
| 70 | + <template slot-scope="scope"> | ||
| 71 | + <span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d} {h}:{i}:{s}") }}</span> | ||
| 72 | + </template> | ||
| 73 | + </el-table-column> | ||
| 74 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 75 | + <template slot-scope="scope"> | ||
| 76 | + <el-button | ||
| 77 | + size="mini" | ||
| 78 | + type="text" | ||
| 79 | + icon="el-icon-edit" | ||
| 80 | + @click="handleUpdate(scope.row)" | ||
| 81 | + v-hasPermi="['other:documentData:edit']" | ||
| 82 | + >修改 | ||
| 83 | + </el-button> | ||
| 84 | + <el-button | ||
| 85 | + size="mini" | ||
| 86 | + type="text" | ||
| 87 | + icon="el-icon-delete" | ||
| 88 | + @click="handleDelete(scope.row)" | ||
| 89 | + v-hasPermi="['other:documentData:remove']" | ||
| 90 | + >删除 | ||
| 91 | + </el-button> | ||
| 92 | + </template> | ||
| 93 | + </el-table-column> | ||
| 94 | + </el-table> | ||
| 95 | + | ||
| 96 | + <pagination | ||
| 97 | + v-show="total>0" | ||
| 98 | + :total="total" | ||
| 99 | + :page.sync="queryParams.pageNum" | ||
| 100 | + :limit.sync="queryParams.pageSize" | ||
| 101 | + @pagination="getList" | ||
| 102 | + /> | ||
| 103 | + | ||
| 104 | + <!-- 添加或修改文件资料对话框 --> | ||
| 105 | + <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body> | ||
| 106 | + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||
| 107 | + <el-form-item label="标题" prop="title"> | ||
| 108 | + <el-input v-model="form.title" placeholder="请输入标题"/> | ||
| 109 | + </el-form-item> | ||
| 110 | + <el-form-item label="内容" prop="content"> | ||
| 111 | + <editor v-model="form.content" :min-height="368"/> | ||
| 112 | + </el-form-item> | ||
| 113 | + <el-row> | ||
| 114 | + <el-col :span="12"> | ||
| 115 | + <el-form-item label="录入时间"> | ||
| 116 | + <el-input v-model="form.createTime" disabled="disabled"/> | ||
| 117 | + </el-form-item> | ||
| 118 | + </el-col> | ||
| 119 | + <el-col :span="12"> | ||
| 120 | + <el-form-item label="录入人"> | ||
| 121 | + <el-input v-model="form.createBy" disabled="disabled"/> | ||
| 122 | + </el-form-item> | ||
| 123 | + </el-col> | ||
| 124 | + </el-row> | ||
| 125 | + <el-form-item label="附件预览"> | ||
| 126 | + <el-image v-for="item in fileEntityList" | ||
| 127 | + v-if="!/\.(pjp|pdf|doc|docx|xls|xlsx)$/.test(item.name)" | ||
| 128 | + style="width: 150px; height: 100px; margin: 5px;" | ||
| 129 | + :src="createUrl(item)" | ||
| 130 | + :preview-src-list="[createUrl(item)]" | ||
| 131 | + :z-index="999"> | ||
| 132 | + </el-image> | ||
| 133 | + </el-form-item> | ||
| 134 | + <el-form-item prop="fileEntityList" label="附件"> | ||
| 135 | + <el-upload | ||
| 136 | + ref="upload" | ||
| 137 | + action="" | ||
| 138 | + accept=".jpg,.jpeg,.png,.gif,.jfif,.pjpeg,.pjp,.pdf,.doc,.docx,.xls,.xlsx" | ||
| 139 | + :on-change="fileChange" | ||
| 140 | + :auto-upload="false" | ||
| 141 | + :show-file-list="false" | ||
| 142 | + multiple | ||
| 143 | + :file-list="fileEntityList"> | ||
| 144 | + <el-button size="small" type="primary" icon="el-icon-upload">上传附件</el-button> | ||
| 145 | + </el-upload> | ||
| 146 | + </el-form-item> | ||
| 147 | + <el-table :data="fileEntityList"> | ||
| 148 | + <el-table-column property="name" label="附件名称" header-align="center" align="center"></el-table-column> | ||
| 149 | + <el-table-column label="操作" class-name="small-padding fixed-width" header-align="center" align="center"> | ||
| 150 | + <template slot-scope="scope"> | ||
| 151 | + <el-button | ||
| 152 | + size="small" type="success" | ||
| 153 | + icon="el-icon-download" | ||
| 154 | + @click="tempDownload(scope.row)" | ||
| 155 | + v-hasPermi="['other:documentData:edit']" | ||
| 156 | + round>下载 | ||
| 157 | + </el-button> | ||
| 158 | + <el-button | ||
| 159 | + size="small" type="danger" | ||
| 160 | + icon="el-icon-delete" | ||
| 161 | + @click="handleDeleteFile(scope.$index)" | ||
| 162 | + v-hasPermi="['other:documentData:remove']" | ||
| 163 | + round>删除 | ||
| 164 | + </el-button> | ||
| 165 | + </template> | ||
| 166 | + </el-table-column> | ||
| 167 | + </el-table> | ||
| 168 | + </el-form> | ||
| 169 | + <div slot="footer" class="dialog-footer"> | ||
| 170 | + <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 171 | + <el-button @click="cancel">取 消</el-button> | ||
| 172 | + </div> | ||
| 173 | + </el-dialog> | ||
| 174 | + </div> | ||
| 175 | +</template> | ||
| 176 | + | ||
| 177 | +<script> | ||
| 178 | +import { | ||
| 179 | + addDocumentData, | ||
| 180 | + delDocumentData, | ||
| 181 | + exportDocumentData, | ||
| 182 | + getDocumentData, | ||
| 183 | + listDocumentData, | ||
| 184 | + updateDocumentData | ||
| 185 | +} from "@/api/other/documentData"; | ||
| 186 | +import Editor from '@/components/ZcEditor'; | ||
| 187 | +import {parseTime} from "../../../utils/trash"; | ||
| 188 | + | ||
| 189 | +export default { | ||
| 190 | + name: "DocumentData", | ||
| 191 | + components: {Editor}, | ||
| 192 | + data() { | ||
| 193 | + return { | ||
| 194 | + // 遮罩层 | ||
| 195 | + loading: true, | ||
| 196 | + // 选中数组 | ||
| 197 | + ids: [], | ||
| 198 | + // 非单个禁用 | ||
| 199 | + single: true, | ||
| 200 | + // 非多个禁用 | ||
| 201 | + multiple: true, | ||
| 202 | + // 显示搜索条件 | ||
| 203 | + showSearch: true, | ||
| 204 | + // 总条数 | ||
| 205 | + total: 0, | ||
| 206 | + // 文件资料表格数据 | ||
| 207 | + documentDataList: [], | ||
| 208 | + // 弹出层标题 | ||
| 209 | + title: "", | ||
| 210 | + // 是否显示弹出层 | ||
| 211 | + open: false, | ||
| 212 | + // 查询参数 | ||
| 213 | + queryParams: { | ||
| 214 | + pageNum: 1, | ||
| 215 | + pageSize: 10, | ||
| 216 | + title: null, | ||
| 217 | + content: null, | ||
| 218 | + files: null, | ||
| 219 | + }, | ||
| 220 | + // 表单参数 | ||
| 221 | + form: {}, | ||
| 222 | + // 表单校验 | ||
| 223 | + rules: { | ||
| 224 | + title: [ | ||
| 225 | + {required: true, message: "请输入标题", trigger: "blur"}, | ||
| 226 | + {min: 1, max: 100, message: "长度在 1 到 100 个字符", trigger: "blur"} | ||
| 227 | + ], | ||
| 228 | + content: [ | ||
| 229 | + {required: true, message: "请输入内容", trigger: "blur"}, | ||
| 230 | + {min: 1, max: 10000, message: "长度在 1 到 10000 个字符", trigger: "blur"} | ||
| 231 | + ], | ||
| 232 | + files: [ | ||
| 233 | + {required: true, message: "请上传附件", trigger: "blur"} | ||
| 234 | + ] | ||
| 235 | + }, | ||
| 236 | + fileEntityList: [], | ||
| 237 | + }; | ||
| 238 | + }, | ||
| 239 | + created() { | ||
| 240 | + this.getList(); | ||
| 241 | + }, | ||
| 242 | + methods: { | ||
| 243 | + /** 查询文件资料列表 */ | ||
| 244 | + getList() { | ||
| 245 | + this.loading = true; | ||
| 246 | + listDocumentData(this.queryParams).then(response => { | ||
| 247 | + this.documentDataList = response.rows; | ||
| 248 | + this.total = response.total; | ||
| 249 | + this.loading = false; | ||
| 250 | + }); | ||
| 251 | + }, | ||
| 252 | + // 取消按钮 | ||
| 253 | + cancel() { | ||
| 254 | + this.open = false; | ||
| 255 | + this.reset(); | ||
| 256 | + }, | ||
| 257 | + // 表单重置 | ||
| 258 | + reset() { | ||
| 259 | + this.form = { | ||
| 260 | + id: null, | ||
| 261 | + title: null, | ||
| 262 | + content: null, | ||
| 263 | + files: null, | ||
| 264 | + createTime: null, | ||
| 265 | + createBy: null, | ||
| 266 | + updateTime: null, | ||
| 267 | + updateBy: null | ||
| 268 | + }; | ||
| 269 | + this.fileEntityList = []; | ||
| 270 | + this.resetForm("form"); | ||
| 271 | + }, | ||
| 272 | + /** 搜索按钮操作 */ | ||
| 273 | + handleQuery() { | ||
| 274 | + this.queryParams.pageNum = 1; | ||
| 275 | + this.getList(); | ||
| 276 | + }, | ||
| 277 | + /** 重置按钮操作 */ | ||
| 278 | + resetQuery() { | ||
| 279 | + this.resetForm("queryForm"); | ||
| 280 | + this.handleQuery(); | ||
| 281 | + }, | ||
| 282 | + // 多选框选中数据 | ||
| 283 | + handleSelectionChange(selection) { | ||
| 284 | + this.ids = selection.map(item => item.id) | ||
| 285 | + this.single = selection.length !== 1 | ||
| 286 | + this.multiple = !selection.length | ||
| 287 | + }, | ||
| 288 | + /** 新增按钮操作 */ | ||
| 289 | + handleAdd() { | ||
| 290 | + this.reset(); | ||
| 291 | + //yyyy-MM-dd HH:mm:ss | ||
| 292 | + this.form.createTime = parseTime(new Date(), "{y}-{m}-{d} {h}:{i}:{s}"); | ||
| 293 | + this.form.createBy = this.$store.getters.name; | ||
| 294 | + this.open = true; | ||
| 295 | + this.title = "添加文件资料"; | ||
| 296 | + }, | ||
| 297 | + /** 修改按钮操作 */ | ||
| 298 | + handleUpdate(row) { | ||
| 299 | + this.reset(); | ||
| 300 | + const id = row.id || this.ids | ||
| 301 | + getDocumentData(id).then(response => { | ||
| 302 | + this.form = response.data; | ||
| 303 | + //将附件转换为前端可视化数组 | ||
| 304 | + if (this.form.files != null && this.form.files !== "") { | ||
| 305 | + let fileList = this.form.files.split(";"); | ||
| 306 | + fileList.map(item => { | ||
| 307 | + let name = item.substring(item.lastIndexOf("/") + 1); | ||
| 308 | + this.fileEntityList.push({name: name, url: item}) | ||
| 309 | + }) | ||
| 310 | + } | ||
| 311 | + this.open = true; | ||
| 312 | + this.title = "修改文件资料"; | ||
| 313 | + }); | ||
| 314 | + }, | ||
| 315 | + /** 提交按钮 */ | ||
| 316 | + submitForm() { | ||
| 317 | + this.$refs["form"].validate(valid => { | ||
| 318 | + if (valid) { | ||
| 319 | + let formData = new FormData(); | ||
| 320 | + let form = this.form; | ||
| 321 | + //去掉params属性 | ||
| 322 | + delete form.params; | ||
| 323 | + //先清空原有的附件 | ||
| 324 | + form.files = null; | ||
| 325 | + | ||
| 326 | + | ||
| 327 | + this.fileEntityList.forEach(item => { | ||
| 328 | + if (item.raw != null) { | ||
| 329 | + formData.append('fileList', item.raw) | ||
| 330 | + } else { | ||
| 331 | + //将原有的附件拼接到form中 | ||
| 332 | + form.files = form.files !== null ? form.files + ";" + item.url : item.url; | ||
| 333 | + } | ||
| 334 | + }) | ||
| 335 | + | ||
| 336 | + for (let key in form) { | ||
| 337 | + formData.append(key, form[key] == null ? "" : form[key]) | ||
| 338 | + } | ||
| 339 | + | ||
| 340 | + if (this.form.id != null) { | ||
| 341 | + updateDocumentData(formData).then(response => { | ||
| 342 | + this.msgSuccess("修改成功"); | ||
| 343 | + this.open = false; | ||
| 344 | + this.getList(); | ||
| 345 | + }); | ||
| 346 | + } else { | ||
| 347 | + addDocumentData(formData).then(response => { | ||
| 348 | + this.msgSuccess("新增成功"); | ||
| 349 | + this.open = false; | ||
| 350 | + this.getList(); | ||
| 351 | + }); | ||
| 352 | + } | ||
| 353 | + } | ||
| 354 | + }); | ||
| 355 | + }, | ||
| 356 | + /** 删除按钮操作 */ | ||
| 357 | + handleDelete(row) { | ||
| 358 | + const ids = row.id || this.ids; | ||
| 359 | + this.$confirm('是否确认删除文件资料编号为"' + ids + '"的数据项?', "警告", { | ||
| 360 | + confirmButtonText: "确定", | ||
| 361 | + cancelButtonText: "取消", | ||
| 362 | + type: "warning" | ||
| 363 | + }).then(function () { | ||
| 364 | + return delDocumentData(ids); | ||
| 365 | + }).then(() => { | ||
| 366 | + this.getList(); | ||
| 367 | + this.msgSuccess("删除成功"); | ||
| 368 | + }) | ||
| 369 | + }, | ||
| 370 | + /** 导出按钮操作 */ | ||
| 371 | + handleExport() { | ||
| 372 | + const queryParams = this.queryParams; | ||
| 373 | + this.$confirm('是否确认导出所有文件资料数据项?', "警告", { | ||
| 374 | + confirmButtonText: "确定", | ||
| 375 | + cancelButtonText: "取消", | ||
| 376 | + type: "warning" | ||
| 377 | + }).then(function () { | ||
| 378 | + return exportDocumentData(queryParams); | ||
| 379 | + }).then(response => { | ||
| 380 | + this.download(response.msg); | ||
| 381 | + }) | ||
| 382 | + }, | ||
| 383 | + /** | ||
| 384 | + * 文件改变时,限制文件上传格式和大小 | ||
| 385 | + * 文件格式只能为docx/doc/pdf/png/jpeg/png/jpg | ||
| 386 | + * 大小不超过20M | ||
| 387 | + * */ | ||
| 388 | + fileChange(file, fileList) { | ||
| 389 | + let count = 0; | ||
| 390 | + for (let i = 0; i < fileList.length; i++) { | ||
| 391 | + // console.log(fileList.length) | ||
| 392 | + // console.log(this.fileEntityList[i].name+"111"+file.name) | ||
| 393 | + if (fileList[i].name == file.name) { | ||
| 394 | + count++; | ||
| 395 | + if (count == 2) { | ||
| 396 | + this.$message({ | ||
| 397 | + message: '已存在此文件!', | ||
| 398 | + type: 'warning' | ||
| 399 | + }); | ||
| 400 | + for (let j = fileList.length; j > 0; j--) { | ||
| 401 | + //如果存在此文件,去除新选择的重复文件 | ||
| 402 | + if (fileList[j - 1].name == file.name) { | ||
| 403 | + fileList.splice(j - 1, 1); | ||
| 404 | + i--; | ||
| 405 | + return false; | ||
| 406 | + } | ||
| 407 | + } | ||
| 408 | + } | ||
| 409 | + } | ||
| 410 | + } | ||
| 411 | + let fileType = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase(); | ||
| 412 | + //格式符合后判断大小 | ||
| 413 | + if ("jpg,jpeg,png,gif,jfif,pjpeg,pjp,pdf,doc,docx,xls,xlsx".indexOf(fileType) != -1) { | ||
| 414 | + let max5M = file.size / 1024 / 1024 < 100; | ||
| 415 | + if (!max5M) { | ||
| 416 | + this.$message({ | ||
| 417 | + message: '上传文件大小不得超过100M!', | ||
| 418 | + type: 'warning' | ||
| 419 | + }); | ||
| 420 | + fileList = fileList.splice(fileList.length - 1, 1); | ||
| 421 | + } else { | ||
| 422 | + //符合条件后进行添加 | ||
| 423 | + this.fileEntityList = fileList | ||
| 424 | + } | ||
| 425 | + } else { | ||
| 426 | + this.$message({ | ||
| 427 | + message: '上传文件只能是 jpg,jpeg,png,gif,jfif,pjpeg,pjp,pdf,doc,docx,xls,xlsx格式!', | ||
| 428 | + type: 'warning' | ||
| 429 | + }); | ||
| 430 | + fileList = fileList.splice(fileList.length - 1, 1); | ||
| 431 | + } | ||
| 432 | + }, | ||
| 433 | + // 删除文件 | ||
| 434 | + handleDeleteFile(index) { | ||
| 435 | + this.fileEntityList.splice(index, 1); | ||
| 436 | + }, | ||
| 437 | + /** 文件下载 */ | ||
| 438 | + tempDownload(row) { | ||
| 439 | + let name = row.name; | ||
| 440 | + let url = ""; | ||
| 441 | + if (row.raw != null) { | ||
| 442 | + url = URL.createObjectURL(row.raw); | ||
| 443 | + } else { | ||
| 444 | + url = process.env.VUE_APP_BASE_API + row.url; | ||
| 445 | + } | ||
| 446 | + const a = document.createElement('a') | ||
| 447 | + a.setAttribute('download', name) | ||
| 448 | + a.setAttribute('target', '_blank') | ||
| 449 | + a.setAttribute('href', url); | ||
| 450 | + a.click() | ||
| 451 | + }, | ||
| 452 | + createUrl(file) { | ||
| 453 | + if (file.raw != null) { | ||
| 454 | + return URL.createObjectURL(file.raw); | ||
| 455 | + } else { | ||
| 456 | + return process.env.VUE_APP_BASE_API + file.url; | ||
| 457 | + } | ||
| 458 | + | ||
| 459 | + }, | ||
| 460 | + } | ||
| 461 | +}; | ||
| 462 | +</script> |
trash-ui/src/views/unit/driver/info.vue
| @@ -18,23 +18,9 @@ | @@ -18,23 +18,9 @@ | ||
| 18 | </el-form-item> | 18 | </el-form-item> |
| 19 | </el-col> | 19 | </el-col> |
| 20 | <el-col :span="7"> | 20 | <el-col :span="7"> |
| 21 | - <el-row> | ||
| 22 | - <el-col :span="8"> | ||
| 23 | - <el-form-item label="安全教育培训日期" prop="safetyTrainingDate"> | ||
| 24 | - <el-date-picker clearable size="small" style="width: 100%" | ||
| 25 | - v-model="form.safetyTrainingDate" | ||
| 26 | - type="date" | ||
| 27 | - value-format="yyyy-MM-dd" | ||
| 28 | - placeholder="选择日期"> | ||
| 29 | - </el-date-picker> | ||
| 30 | - </el-form-item> | ||
| 31 | - </el-col> | ||
| 32 | - <el-col :span="16"> | ||
| 33 | - <el-form-item label="安全教育培训内容"> | ||
| 34 | - <el-input v-model="form.safetyTrainingContent" placeholder="请输入内容"/> | ||
| 35 | - </el-form-item> | ||
| 36 | - </el-col> | ||
| 37 | - </el-row> | 21 | + <el-form-item label="手机号码" prop="phoneNo"> |
| 22 | + <el-input v-model="form.phoneNo" placeholder="请输入手机号码" :maxlength="11" show-word-limit/> | ||
| 23 | + </el-form-item> | ||
| 38 | </el-col> | 24 | </el-col> |
| 39 | </el-row> | 25 | </el-row> |
| 40 | <el-row :gutter="30"> | 26 | <el-row :gutter="30"> |
| @@ -93,6 +79,23 @@ | @@ -93,6 +79,23 @@ | ||
| 93 | 79 | ||
| 94 | </el-col> | 80 | </el-col> |
| 95 | <el-col :span="7"> | 81 | <el-col :span="7"> |
| 82 | + <el-row> | ||
| 83 | + <el-col :span="8"> | ||
| 84 | + <el-form-item label="安全教育培训日期" prop="safetyTrainingDate"> | ||
| 85 | + <el-date-picker clearable size="small" style="width: 100%" | ||
| 86 | + v-model="form.safetyTrainingDate" | ||
| 87 | + type="date" | ||
| 88 | + value-format="yyyy-MM-dd" | ||
| 89 | + placeholder="选择日期"> | ||
| 90 | + </el-date-picker> | ||
| 91 | + </el-form-item> | ||
| 92 | + </el-col> | ||
| 93 | + <el-col :span="16"> | ||
| 94 | + <el-form-item label="安全教育培训内容"> | ||
| 95 | + <el-input v-model="form.safetyTrainingContent" placeholder="请输入内容"/> | ||
| 96 | + </el-form-item> | ||
| 97 | + </el-col> | ||
| 98 | + </el-row> | ||
| 96 | </el-col> | 99 | </el-col> |
| 97 | </el-row> | 100 | </el-row> |
| 98 | 101 | ||
| @@ -364,6 +367,14 @@ export default { | @@ -364,6 +367,14 @@ export default { | ||
| 364 | safetyTrainingContent: [ | 367 | safetyTrainingContent: [ |
| 365 | {required: true, message: "请输入安全教育培训内容", trigger: "blur"} | 368 | {required: true, message: "请输入安全教育培训内容", trigger: "blur"} |
| 366 | ], | 369 | ], |
| 370 | + phoneNo: [ | ||
| 371 | + {required: true, message: "请输入手机号码", trigger: "blur"}, | ||
| 372 | + { | ||
| 373 | + pattern: /^1(3|4|5|7|8|9)\d{9}$/, | ||
| 374 | + message: '手机号格式错误', | ||
| 375 | + trigger: 'change' | ||
| 376 | + } | ||
| 377 | + ], | ||
| 367 | }, | 378 | }, |
| 368 | areas:[], | 379 | areas:[], |
| 369 | drivingLicence:[], | 380 | drivingLicence:[], |
trash-unit/src/main/java/com/trash/driver/domain/Driver.java
| @@ -85,6 +85,16 @@ public class Driver extends BaseEntity | @@ -85,6 +85,16 @@ public class Driver extends BaseEntity | ||
| 85 | @Excel(name = "一寸免冠照片2") | 85 | @Excel(name = "一寸免冠照片2") |
| 86 | private String photographTwo; | 86 | private String photographTwo; |
| 87 | 87 | ||
| 88 | + private String phoneNo; | ||
| 89 | + | ||
| 90 | + public String getPhoneNo() { | ||
| 91 | + return phoneNo; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + public void setPhoneNo(String phoneNo) { | ||
| 95 | + this.phoneNo = phoneNo; | ||
| 96 | + } | ||
| 97 | + | ||
| 88 | public void setId(Long id) | 98 | public void setId(Long id) |
| 89 | { | 99 | { |
| 90 | this.id = id; | 100 | this.id = id; |
trash-unit/src/main/resources/mapper/unit/DriverMapper.xml
| @@ -26,38 +26,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -26,38 +26,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 26 | <result property="updateBy" column="update_by"/> | 26 | <result property="updateBy" column="update_by"/> |
| 27 | <result property="photographOne" column="photograph_one"/> | 27 | <result property="photographOne" column="photograph_one"/> |
| 28 | <result property="photographTwo" column="photograph_two"/> | 28 | <result property="photographTwo" column="photograph_two"/> |
| 29 | + <result property="phoneNo" column="phoneNo"/> | ||
| 29 | </resultMap> | 30 | </resultMap> |
| 30 | - <resultMap type="DriverVo" id="DriverVoResult"> | ||
| 31 | - <result property="id" column="id"/> | ||
| 32 | - <result property="name" column="name"/> | ||
| 33 | - <result property="identityCard" column="identity_card"/> | ||
| 34 | - <result property="companyId" column="company_id"/> | ||
| 35 | - <result property="professionalQualificationBeginDate" column="professional_qualification_begin_date"/> | ||
| 36 | - <result property="professionalQualificationEndDate" column="professional_qualification_end_date"/> | ||
| 37 | - <result property="drivingLicenceBeginDate" column="driving_licence_begin_date"/> | ||
| 38 | - <result property="drivingLicenceEndDate" column="driving_licence_end_date"/> | ||
| 39 | - <result property="safetyTrainingDate" column="safety_training_date"/> | ||
| 40 | - <result property="safetyTrainingContent" column="safety_training_content"/> | ||
| 41 | - <result property="remark" column="remark"/> | ||
| 42 | - <result property="drivingLicence" column="driving_licence"/> | ||
| 43 | - <result property="professionalQualification" column="professional_qualification"/> | ||
| 44 | - <result property="safetyTraining" column="safety_training"/> | ||
| 45 | - <result property="status" column="status"/> | ||
| 46 | - <result property="createTime" column="create_time"/> | ||
| 47 | - <result property="createBy" column="create_by"/> | ||
| 48 | - <result property="updateTime" column="update_time"/> | ||
| 49 | - <result property="updateBy" column="update_by"/> | ||
| 50 | - <result property="photographOne" column="photograph_one"/> | ||
| 51 | - <result property="photographTwo" column="photograph_two"/> | 31 | + <resultMap type="DriverVo" id="DriverVoResult" extends="DriverResult"> |
| 52 | <result property="companyName" column="companyName"/> | 32 | <result property="companyName" column="companyName"/> |
| 53 | </resultMap> | 33 | </resultMap> |
| 54 | 34 | ||
| 55 | <sql id="selectDriverVo"> | 35 | <sql id="selectDriverVo"> |
| 56 | - select id, name, identity_card, company_id, professional_qualification_begin_date, professional_qualification_end_date, driving_licence_begin_date, driving_licence_end_date, safety_training_date, safety_training_content, remark, driving_licence, professional_qualification, safety_training, status, create_time, create_by, update_time, update_by, photograph_one, photograph_two from driver | 36 | + select id, name, identity_card, company_id, professional_qualification_begin_date, professional_qualification_end_date, driving_licence_begin_date, driving_licence_end_date, safety_training_date, safety_training_content, remark, driving_licence, professional_qualification, safety_training, status, create_time, create_by, update_time, update_by, photograph_one, photograph_two,phoneNo from driver |
| 57 | </sql> | 37 | </sql> |
| 58 | 38 | ||
| 59 | <sql id="selectDriverCompanyVo"> | 39 | <sql id="selectDriverCompanyVo"> |
| 60 | - select d.id, d.name,c.name companyName, identity_card, company_id, professional_qualification_begin_date, professional_qualification_end_date, driving_licence_begin_date, driving_licence_end_date, safety_training_date, safety_training_content, d.remark, driving_licence, professional_qualification, safety_training, d.status, d.create_time, d.create_by, d.update_time, d.update_by, photograph_one, photograph_two from driver d | 40 | + select d.id, d.name,c.name companyName, identity_card, company_id, professional_qualification_begin_date, professional_qualification_end_date, driving_licence_begin_date, driving_licence_end_date, safety_training_date, safety_training_content, d.remark, driving_licence, professional_qualification, safety_training, d.status, d.create_time, d.create_by, d.update_time, d.update_by, photograph_one, photograph_two,phoneNo from driver d |
| 61 | left join transportation_enterprise c on d.company_id = c.id | 41 | left join transportation_enterprise c on d.company_id = c.id |
| 62 | </sql> | 42 | </sql> |
| 63 | 43 | ||
| @@ -80,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -80,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 80 | <if test="status != null "> and status = #{status}</if> | 60 | <if test="status != null "> and status = #{status}</if> |
| 81 | <if test="photographOne != null and photographOne != ''"> and photograph_one = #{photographOne}</if> | 61 | <if test="photographOne != null and photographOne != ''"> and photograph_one = #{photographOne}</if> |
| 82 | <if test="photographTwo != null and photographTwo != ''"> and photograph_two = #{photographTwo}</if> | 62 | <if test="photographTwo != null and photographTwo != ''"> and photograph_two = #{photographTwo}</if> |
| 63 | + <if test="phoneNo != null and phoneNo != ''"> and phoneNo = #{phoneNo}</if> | ||
| 83 | </where> | 64 | </where> |
| 84 | </select> | 65 | </select> |
| 85 | 66 | ||
| @@ -115,6 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -115,6 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 115 | <if test="updateBy != null">update_by,</if> | 96 | <if test="updateBy != null">update_by,</if> |
| 116 | <if test="photographOne != null">photograph_one,</if> | 97 | <if test="photographOne != null">photograph_one,</if> |
| 117 | <if test="photographTwo != null">photograph_two,</if> | 98 | <if test="photographTwo != null">photograph_two,</if> |
| 99 | + <if test="phoneNo != null">phoneNo,</if> | ||
| 118 | </trim> | 100 | </trim> |
| 119 | <trim prefix="values (" suffix=")" suffixOverrides=","> | 101 | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| 120 | <if test="name != null">#{name},</if> | 102 | <if test="name != null">#{name},</if> |
| @@ -137,6 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -137,6 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 137 | <if test="updateBy != null">#{updateBy},</if> | 119 | <if test="updateBy != null">#{updateBy},</if> |
| 138 | <if test="photographOne != null">#{photographOne},</if> | 120 | <if test="photographOne != null">#{photographOne},</if> |
| 139 | <if test="photographTwo != null">#{photographTwo},</if> | 121 | <if test="photographTwo != null">#{photographTwo},</if> |
| 122 | + <if test="phoneNo != null">#{phoneNo},</if> | ||
| 140 | </trim> | 123 | </trim> |
| 141 | </insert> | 124 | </insert> |
| 142 | 125 | ||
| @@ -163,6 +146,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -163,6 +146,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 163 | <if test="updateBy != null">update_by = #{updateBy},</if> | 146 | <if test="updateBy != null">update_by = #{updateBy},</if> |
| 164 | <if test="photographOne != null">photograph_one = #{photographOne},</if> | 147 | <if test="photographOne != null">photograph_one = #{photographOne},</if> |
| 165 | <if test="photographTwo != null">photograph_two = #{photographTwo},</if> | 148 | <if test="photographTwo != null">photograph_two = #{photographTwo},</if> |
| 149 | + <if test="phoneNo != null">phoneNo = #{phoneNo},</if> | ||
| 166 | </trim> | 150 | </trim> |
| 167 | where id = #{id} | 151 | where id = #{id} |
| 168 | </update> | 152 | </update> |
trash-workFlow/src/main/java/com/trash/other/controller/DocumentDataController.java
0 → 100644
| 1 | +package com.trash.other.controller; | ||
| 2 | + | ||
| 3 | +import java.io.IOException; | ||
| 4 | +import java.util.List; | ||
| 5 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | +import org.springframework.web.bind.annotation.*; | ||
| 8 | +import com.trash.common.annotation.Log; | ||
| 9 | +import com.trash.common.core.controller.BaseController; | ||
| 10 | +import com.trash.common.core.domain.AjaxResult; | ||
| 11 | +import com.trash.common.enums.BusinessType; | ||
| 12 | +import com.trash.other.domain.DocumentData; | ||
| 13 | +import com.trash.other.service.IDocumentDataService; | ||
| 14 | +import com.trash.common.utils.poi.ExcelUtil; | ||
| 15 | +import com.trash.common.core.page.TableDataInfo; | ||
| 16 | +import org.springframework.web.multipart.MultipartFile; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * 文件资料Controller | ||
| 20 | + * | ||
| 21 | + * @author trash | ||
| 22 | + * @date 2023-11-28 | ||
| 23 | + */ | ||
| 24 | +@RestController | ||
| 25 | +@RequestMapping("/other/documentData") | ||
| 26 | +public class DocumentDataController extends BaseController | ||
| 27 | +{ | ||
| 28 | + @Autowired | ||
| 29 | + private IDocumentDataService documentDataService; | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 查询文件资料列表 | ||
| 33 | + */ | ||
| 34 | + @PreAuthorize("@ss.hasPermi('other:documentData:list')") | ||
| 35 | + @GetMapping("/list") | ||
| 36 | + public TableDataInfo list(DocumentData documentData) | ||
| 37 | + { | ||
| 38 | + startPage(); | ||
| 39 | + List<DocumentData> list = documentDataService.selectDocumentDataList(documentData); | ||
| 40 | + return getDataTable(list); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 导出文件资料列表 | ||
| 45 | + */ | ||
| 46 | + @PreAuthorize("@ss.hasPermi('other:documentData:export')") | ||
| 47 | + @Log(title = "文件资料", businessType = BusinessType.EXPORT) | ||
| 48 | + @GetMapping("/export") | ||
| 49 | + public AjaxResult export(DocumentData documentData) | ||
| 50 | + { | ||
| 51 | + List<DocumentData> list = documentDataService.selectDocumentDataList(documentData); | ||
| 52 | + ExcelUtil<DocumentData> util = new ExcelUtil<DocumentData>(DocumentData.class); | ||
| 53 | + return util.exportExcel(list, "documentData"); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 获取文件资料详细信息 | ||
| 58 | + */ | ||
| 59 | + @PreAuthorize("@ss.hasPermi('other:documentData:query')") | ||
| 60 | + @GetMapping(value = "/{id}") | ||
| 61 | + public AjaxResult getInfo(@PathVariable("id") Long id) | ||
| 62 | + { | ||
| 63 | + return AjaxResult.success(documentDataService.selectDocumentDataById(id)); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * 新增文件资料 | ||
| 68 | + */ | ||
| 69 | + @PreAuthorize("@ss.hasPermi('other:documentData:add')") | ||
| 70 | + @Log(title = "文件资料", businessType = BusinessType.INSERT) | ||
| 71 | + @PostMapping | ||
| 72 | + public AjaxResult add(@RequestParam(value = "fileList") MultipartFile[] files, DocumentData documentData) throws IOException { | ||
| 73 | + return toAjax(documentDataService.insertDocumentData(files, documentData)); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * 修改文件资料 | ||
| 78 | + */ | ||
| 79 | + @PreAuthorize("@ss.hasPermi('other:documentData:edit')") | ||
| 80 | + @Log(title = "文件资料", businessType = BusinessType.UPDATE) | ||
| 81 | + @PutMapping | ||
| 82 | + public AjaxResult edit(@RequestParam(value = "fileList") MultipartFile[] files,DocumentData documentData) throws IOException { | ||
| 83 | + return toAjax(documentDataService.updateDocumentData(files, documentData)); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * 删除文件资料 | ||
| 88 | + */ | ||
| 89 | + @PreAuthorize("@ss.hasPermi('other:documentData:remove')") | ||
| 90 | + @Log(title = "文件资料", businessType = BusinessType.DELETE) | ||
| 91 | + @DeleteMapping("/{ids}") | ||
| 92 | + public AjaxResult remove(@PathVariable Long[] ids) | ||
| 93 | + { | ||
| 94 | + return toAjax(documentDataService.deleteDocumentDataByIds(ids)); | ||
| 95 | + } | ||
| 96 | +} |
trash-workFlow/src/main/java/com/trash/other/domain/DocumentData.java
0 → 100644
| 1 | +package com.trash.other.domain; | ||
| 2 | + | ||
| 3 | +import org.apache.commons.lang3.builder.ToStringBuilder; | ||
| 4 | +import org.apache.commons.lang3.builder.ToStringStyle; | ||
| 5 | +import com.trash.common.annotation.Excel; | ||
| 6 | +import com.trash.common.core.domain.BaseEntity; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 文件资料对象 document_data | ||
| 10 | + * | ||
| 11 | + * @author trash | ||
| 12 | + * @date 2023-11-28 | ||
| 13 | + */ | ||
| 14 | +public class DocumentData extends BaseEntity | ||
| 15 | +{ | ||
| 16 | + private static final long serialVersionUID = 1L; | ||
| 17 | + | ||
| 18 | + /** $column.columnComment */ | ||
| 19 | + private Long id; | ||
| 20 | + | ||
| 21 | + /** 标题 */ | ||
| 22 | + @Excel(name = "标题") | ||
| 23 | + private String title; | ||
| 24 | + | ||
| 25 | + /** 内容 */ | ||
| 26 | + @Excel(name = "内容") | ||
| 27 | + private String content; | ||
| 28 | + | ||
| 29 | + /** 附件 */ | ||
| 30 | + @Excel(name = "附件") | ||
| 31 | + private String files; | ||
| 32 | + | ||
| 33 | + public void setId(Long id) | ||
| 34 | + { | ||
| 35 | + this.id = id; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public Long getId() | ||
| 39 | + { | ||
| 40 | + return id; | ||
| 41 | + } | ||
| 42 | + public void setTitle(String title) | ||
| 43 | + { | ||
| 44 | + this.title = title; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public String getTitle() | ||
| 48 | + { | ||
| 49 | + return title; | ||
| 50 | + } | ||
| 51 | + public void setContent(String content) | ||
| 52 | + { | ||
| 53 | + this.content = content; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public String getContent() | ||
| 57 | + { | ||
| 58 | + return content; | ||
| 59 | + } | ||
| 60 | + public void setFiles(String files) | ||
| 61 | + { | ||
| 62 | + this.files = files; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public String getFiles() | ||
| 66 | + { | ||
| 67 | + return files; | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public String toString() { | ||
| 72 | + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | ||
| 73 | + .append("id", getId()) | ||
| 74 | + .append("title", getTitle()) | ||
| 75 | + .append("content", getContent()) | ||
| 76 | + .append("files", getFiles()) | ||
| 77 | + .append("createTime", getCreateTime()) | ||
| 78 | + .append("createBy", getCreateBy()) | ||
| 79 | + .append("updateTime", getUpdateTime()) | ||
| 80 | + .append("updateBy", getUpdateBy()) | ||
| 81 | + .toString(); | ||
| 82 | + } | ||
| 83 | +} |
trash-workFlow/src/main/java/com/trash/other/mapper/DocumentDataMapper.java
0 → 100644
| 1 | +package com.trash.other.mapper; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | +import com.trash.other.domain.DocumentData; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 文件资料Mapper接口 | ||
| 8 | + * | ||
| 9 | + * @author trash | ||
| 10 | + * @date 2023-11-28 | ||
| 11 | + */ | ||
| 12 | +public interface DocumentDataMapper | ||
| 13 | +{ | ||
| 14 | + /** | ||
| 15 | + * 查询文件资料 | ||
| 16 | + * | ||
| 17 | + * @param id 文件资料ID | ||
| 18 | + * @return 文件资料 | ||
| 19 | + */ | ||
| 20 | + DocumentData selectDocumentDataById(Long id); | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 查询文件资料列表 | ||
| 24 | + * | ||
| 25 | + * @param documentData 文件资料 | ||
| 26 | + * @return 文件资料集合 | ||
| 27 | + */ | ||
| 28 | + List<DocumentData> selectDocumentDataList(DocumentData documentData); | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 新增文件资料 | ||
| 32 | + * | ||
| 33 | + * @param documentData 文件资料 | ||
| 34 | + * @return 结果 | ||
| 35 | + */ | ||
| 36 | + int insertDocumentData(DocumentData documentData); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 修改文件资料 | ||
| 40 | + * | ||
| 41 | + * @param documentData 文件资料 | ||
| 42 | + * @return 结果 | ||
| 43 | + */ | ||
| 44 | + int updateDocumentData(DocumentData documentData); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 删除文件资料 | ||
| 48 | + * | ||
| 49 | + * @param id 文件资料ID | ||
| 50 | + * @return 结果 | ||
| 51 | + */ | ||
| 52 | + int deleteDocumentDataById(Long id); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 批量删除文件资料 | ||
| 56 | + * | ||
| 57 | + * @param ids 需要删除的数据ID | ||
| 58 | + * @return 结果 | ||
| 59 | + */ | ||
| 60 | + int deleteDocumentDataByIds(Long[] ids); | ||
| 61 | +} |
trash-workFlow/src/main/java/com/trash/other/service/IDocumentDataService.java
0 → 100644
| 1 | +package com.trash.other.service; | ||
| 2 | + | ||
| 3 | +import java.io.IOException; | ||
| 4 | +import java.util.List; | ||
| 5 | +import com.trash.other.domain.DocumentData; | ||
| 6 | +import org.springframework.web.multipart.MultipartFile; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 文件资料Service接口 | ||
| 10 | + * | ||
| 11 | + * @author trash | ||
| 12 | + * @date 2023-11-28 | ||
| 13 | + */ | ||
| 14 | +public interface IDocumentDataService | ||
| 15 | +{ | ||
| 16 | + /** | ||
| 17 | + * 查询文件资料 | ||
| 18 | + * | ||
| 19 | + * @param id 文件资料ID | ||
| 20 | + * @return 文件资料 | ||
| 21 | + */ | ||
| 22 | + DocumentData selectDocumentDataById(Long id); | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 查询文件资料列表 | ||
| 26 | + * | ||
| 27 | + * @param documentData 文件资料 | ||
| 28 | + * @return 文件资料集合 | ||
| 29 | + */ | ||
| 30 | + List<DocumentData> selectDocumentDataList(DocumentData documentData); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 新增文件资料 | ||
| 34 | + * | ||
| 35 | + * @param files | ||
| 36 | + * @param documentData 文件资料 | ||
| 37 | + * @return 结果 | ||
| 38 | + */ | ||
| 39 | + int insertDocumentData(MultipartFile[] files, DocumentData documentData) throws IOException; | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 修改文件资料 | ||
| 43 | + * | ||
| 44 | + * @param files | ||
| 45 | + * @param documentData 文件资料 | ||
| 46 | + * @return 结果 | ||
| 47 | + */ | ||
| 48 | + int updateDocumentData(MultipartFile[] files,DocumentData documentData) throws IOException; | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 批量删除文件资料 | ||
| 52 | + * | ||
| 53 | + * @param ids 需要删除的文件资料ID | ||
| 54 | + * @return 结果 | ||
| 55 | + */ | ||
| 56 | + int deleteDocumentDataByIds(Long[] ids); | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * 删除文件资料信息 | ||
| 60 | + * | ||
| 61 | + * @param id 文件资料ID | ||
| 62 | + * @return 结果 | ||
| 63 | + */ | ||
| 64 | + int deleteDocumentDataById(Long id); | ||
| 65 | +} |
trash-workFlow/src/main/java/com/trash/other/service/impl/DocumentDataServiceImpl.java
0 → 100644
| 1 | +package com.trash.other.service.impl; | ||
| 2 | + | ||
| 3 | +import java.io.IOException; | ||
| 4 | +import java.util.List; | ||
| 5 | + | ||
| 6 | +import com.trash.common.config.trashConfig; | ||
| 7 | +import com.trash.common.utils.DateUtils; | ||
| 8 | +import com.trash.common.utils.SecurityUtils; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.stereotype.Service; | ||
| 11 | +import com.trash.other.mapper.DocumentDataMapper; | ||
| 12 | +import com.trash.other.domain.DocumentData; | ||
| 13 | +import com.trash.other.service.IDocumentDataService; | ||
| 14 | +import org.springframework.web.multipart.MultipartFile; | ||
| 15 | + | ||
| 16 | +import static com.trash.common.utils.file.FileUploadUtils.upload; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * 文件资料Service业务层处理 | ||
| 20 | + * | ||
| 21 | + * @author trash | ||
| 22 | + * @date 2023-11-28 | ||
| 23 | + */ | ||
| 24 | +@Service | ||
| 25 | +public class DocumentDataServiceImpl implements IDocumentDataService | ||
| 26 | +{ | ||
| 27 | + @Autowired | ||
| 28 | + private DocumentDataMapper documentDataMapper; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 查询文件资料 | ||
| 32 | + * | ||
| 33 | + * @param id 文件资料ID | ||
| 34 | + * @return 文件资料 | ||
| 35 | + */ | ||
| 36 | + @Override | ||
| 37 | + public DocumentData selectDocumentDataById(Long id) | ||
| 38 | + { | ||
| 39 | + return documentDataMapper.selectDocumentDataById(id); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * 查询文件资料列表 | ||
| 44 | + * | ||
| 45 | + * @param documentData 文件资料 | ||
| 46 | + * @return 文件资料 | ||
| 47 | + */ | ||
| 48 | + @Override | ||
| 49 | + public List<DocumentData> selectDocumentDataList(DocumentData documentData) | ||
| 50 | + { | ||
| 51 | + return documentDataMapper.selectDocumentDataList(documentData); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 新增文件资料 | ||
| 56 | + * | ||
| 57 | + * @param files | ||
| 58 | + * @param documentData 文件资料 | ||
| 59 | + * @return 结果 | ||
| 60 | + */ | ||
| 61 | + @Override | ||
| 62 | + public int insertDocumentData(MultipartFile[] files, DocumentData documentData) throws IOException { | ||
| 63 | + for (MultipartFile file:files){ | ||
| 64 | + documentData.setFiles(documentData.getFiles()!=null?documentData.getFiles()+";"+uploadFile(file):uploadFile(file)); | ||
| 65 | + } | ||
| 66 | + documentData.setFiles(removeSemicolon(documentData.getFiles())); | ||
| 67 | + return documentDataMapper.insertDocumentData(documentData); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * 修改文件资料 | ||
| 72 | + * | ||
| 73 | + * @param files | ||
| 74 | + * @param documentData 文件资料 | ||
| 75 | + * @return 结果 | ||
| 76 | + */ | ||
| 77 | + @Override | ||
| 78 | + public int updateDocumentData(MultipartFile[] files, DocumentData documentData) throws IOException { | ||
| 79 | + documentData.setUpdateTime(DateUtils.getNowDate()); | ||
| 80 | + documentData.setUpdateBy(SecurityUtils.getUsername()); | ||
| 81 | + for (MultipartFile file:files){ | ||
| 82 | + documentData.setFiles(documentData.getFiles()!=null?documentData.getFiles()+";"+uploadFile(file):uploadFile(file)); | ||
| 83 | + } | ||
| 84 | + documentData.setFiles(removeSemicolon(documentData.getFiles())); | ||
| 85 | + return documentDataMapper.updateDocumentData(documentData); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * 批量删除文件资料 | ||
| 90 | + * | ||
| 91 | + * @param ids 需要删除的文件资料ID | ||
| 92 | + * @return 结果 | ||
| 93 | + */ | ||
| 94 | + @Override | ||
| 95 | + public int deleteDocumentDataByIds(Long[] ids) | ||
| 96 | + { | ||
| 97 | + return documentDataMapper.deleteDocumentDataByIds(ids); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + /** | ||
| 101 | + * 删除文件资料信息 | ||
| 102 | + * | ||
| 103 | + * @param id 文件资料ID | ||
| 104 | + * @return 结果 | ||
| 105 | + */ | ||
| 106 | + @Override | ||
| 107 | + public int deleteDocumentDataById(Long id) | ||
| 108 | + { | ||
| 109 | + return documentDataMapper.deleteDocumentDataById(id); | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + /** | ||
| 113 | + * 文件上传 | ||
| 114 | + * | ||
| 115 | + * @param file | ||
| 116 | + * @author 2c | ||
| 117 | + */ | ||
| 118 | + public static String uploadFile(MultipartFile file) throws IOException { | ||
| 119 | + // 上传文件路径 | ||
| 120 | + String filePath = trashConfig.getUploadPath(); | ||
| 121 | + // 上传并返回新文件名称 | ||
| 122 | + String newFileName = upload(filePath, file); | ||
| 123 | + return newFileName; | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + //去掉第一个分号,如果有的话 | ||
| 127 | + public String removeSemicolon(String str){ | ||
| 128 | + if (str.startsWith(";")) | ||
| 129 | + str = str.substring(1); | ||
| 130 | + return str; | ||
| 131 | + } | ||
| 132 | +} |
trash-workFlow/src/main/resources/mapper/other/DocumentDataMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
| 2 | +<!DOCTYPE mapper | ||
| 3 | +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 4 | +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 5 | +<mapper namespace="com.trash.other.mapper.DocumentDataMapper"> | ||
| 6 | + | ||
| 7 | + <resultMap type="DocumentData" id="DocumentDataResult"> | ||
| 8 | + <result property="id" column="id" /> | ||
| 9 | + <result property="title" column="title" /> | ||
| 10 | + <result property="content" column="content" /> | ||
| 11 | + <result property="files" column="files" /> | ||
| 12 | + <result property="createTime" column="create_time" /> | ||
| 13 | + <result property="createBy" column="create_by" /> | ||
| 14 | + <result property="updateTime" column="update_time" /> | ||
| 15 | + <result property="updateBy" column="update_by" /> | ||
| 16 | + </resultMap> | ||
| 17 | + | ||
| 18 | + <sql id="selectDocumentDataVo"> | ||
| 19 | + select id, title, content, files, create_time, create_by, update_time, update_by from document_data | ||
| 20 | + </sql> | ||
| 21 | + | ||
| 22 | + <select id="selectDocumentDataList" parameterType="DocumentData" resultMap="DocumentDataResult"> | ||
| 23 | + <include refid="selectDocumentDataVo"/> | ||
| 24 | + <where> | ||
| 25 | + <if test="title != null and title != ''"> and title like concat('%',#{title},'%')</if> | ||
| 26 | + <if test="content != null and content != ''"> and content = #{content}</if> | ||
| 27 | + <if test="files != null and files != ''"> and files = #{files}</if> | ||
| 28 | + </where> | ||
| 29 | + </select> | ||
| 30 | + | ||
| 31 | + <select id="selectDocumentDataById" parameterType="Long" resultMap="DocumentDataResult"> | ||
| 32 | + <include refid="selectDocumentDataVo"/> | ||
| 33 | + where id = #{id} | ||
| 34 | + </select> | ||
| 35 | + | ||
| 36 | + <insert id="insertDocumentData" parameterType="DocumentData" useGeneratedKeys="true" keyProperty="id"> | ||
| 37 | + insert into document_data | ||
| 38 | + <trim prefix="(" suffix=")" suffixOverrides=","> | ||
| 39 | + <if test="title != null">title,</if> | ||
| 40 | + <if test="content != null">content,</if> | ||
| 41 | + <if test="files != null">files,</if> | ||
| 42 | + <if test="createTime != null">create_time,</if> | ||
| 43 | + <if test="createBy != null">create_by,</if> | ||
| 44 | + <if test="updateTime != null">update_time,</if> | ||
| 45 | + <if test="updateBy != null">update_by,</if> | ||
| 46 | + </trim> | ||
| 47 | + <trim prefix="values (" suffix=")" suffixOverrides=","> | ||
| 48 | + <if test="title != null">#{title},</if> | ||
| 49 | + <if test="content != null">#{content},</if> | ||
| 50 | + <if test="files != null">#{files},</if> | ||
| 51 | + <if test="createTime != null">#{createTime},</if> | ||
| 52 | + <if test="createBy != null">#{createBy},</if> | ||
| 53 | + <if test="updateTime != null">#{updateTime},</if> | ||
| 54 | + <if test="updateBy != null">#{updateBy},</if> | ||
| 55 | + </trim> | ||
| 56 | + </insert> | ||
| 57 | + | ||
| 58 | + <update id="updateDocumentData" parameterType="DocumentData"> | ||
| 59 | + update document_data | ||
| 60 | + <trim prefix="SET" suffixOverrides=","> | ||
| 61 | + <if test="title != null">title = #{title},</if> | ||
| 62 | + <if test="content != null">content = #{content},</if> | ||
| 63 | + <if test="files != null">files = #{files},</if> | ||
| 64 | + <if test="createTime != null">create_time = #{createTime},</if> | ||
| 65 | + <if test="createBy != null">create_by = #{createBy},</if> | ||
| 66 | + <if test="updateTime != null">update_time = #{updateTime},</if> | ||
| 67 | + <if test="updateBy != null">update_by = #{updateBy},</if> | ||
| 68 | + </trim> | ||
| 69 | + where id = #{id} | ||
| 70 | + </update> | ||
| 71 | + | ||
| 72 | + <delete id="deleteDocumentDataById" parameterType="Long"> | ||
| 73 | + delete from document_data where id = #{id} | ||
| 74 | + </delete> | ||
| 75 | + | ||
| 76 | + <delete id="deleteDocumentDataByIds" parameterType="String"> | ||
| 77 | + delete from document_data where id in | ||
| 78 | + <foreach item="id" collection="array" open="(" separator="," close=")"> | ||
| 79 | + #{id} | ||
| 80 | + </foreach> | ||
| 81 | + </delete> | ||
| 82 | + | ||
| 83 | +</mapper> | ||
| 0 | \ No newline at end of file | 84 | \ No newline at end of file |