From 364adbc9a93a396b74e154f910c2a0a72bfb1a0f Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期六, 29 十一月 2025 22:10:41 +0800
Subject: [PATCH] feat: 更新车辆里程统计
---
ruoyi-ui/src/views/task/general/detail.vue | 170 +++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 143 insertions(+), 27 deletions(-)
diff --git a/ruoyi-ui/src/views/task/general/detail.vue b/ruoyi-ui/src/views/task/general/detail.vue
index 0450def..3685884 100644
--- a/ruoyi-ui/src/views/task/general/detail.vue
+++ b/ruoyi-ui/src/views/task/general/detail.vue
@@ -203,11 +203,38 @@
</div>
<el-table :data="taskDetail.attachments" v-loading="attachmentLoading">
- <el-table-column label="鏂囦欢鍚�" align="center" prop="fileName" />
- <el-table-column label="鏂囦欢绫诲瀷" align="center" prop="fileType" />
- <el-table-column label="鏂囦欢澶у皬" align="center" prop="fileSize">
+ <el-table-column label="缂╃暐鍥�" align="center" width="120">
<template slot-scope="scope">
- <span>{{ formatFileSize(scope.row.fileSize) }}</span>
+ <el-image
+ v-if="isImage(scope.row.fileType)"
+ :src="scope.row.fileUrl"
+ :preview-src-list="[scope.row.fileUrl]"
+ fit="cover"
+ style="width: 80px; height: 80px; border-radius: 4px; cursor: pointer;"
+ >
+ <div slot="error" class="image-slot">
+ <i class="el-icon-picture-outline" style="font-size: 40px; color: #C0C4CC;"></i>
+ </div>
+ </el-image>
+ <div v-else style="text-align: center;">
+ <i class="el-icon-document" style="font-size: 40px; color: #909399;"></i>
+ </div>
+ </template>
+ </el-table-column>
+ <el-table-column label="涓氬姟鍒嗙被" align="center" prop="attachmentCategory" width="150">
+ <template slot-scope="scope">
+ <dict-tag :options="dict.type.sys_attachment_category" :value="scope.row.attachmentCategory"/>
+ </template>
+ </el-table-column>
+ <el-table-column label="鍚屾鐘舵��" align="center" width="120">
+ <template slot-scope="scope">
+ <el-tag v-if="scope.row.syncedToImageData === 0" type="info" size="small">
+ <i class="el-icon-warning"></i> 鏈悓姝�
+ </el-tag>
+ <el-tag v-else-if="scope.row.syncedToImageData === 1" type="success" size="small">
+ <i class="el-icon-success"></i> 宸插悓姝�
+ </el-tag>
+ <span v-else style="color: #C0C4CC;">--</span>
</template>
</el-table-column>
<el-table-column label="涓婁紶鏃堕棿" align="center" prop="uploadTime" width="180">
@@ -388,21 +415,42 @@
</el-dialog>
<!-- 涓婁紶闄勪欢瀵硅瘽妗� -->
- <el-dialog title="涓婁紶闄勪欢" :visible.sync="uploadOpen" width="500px" append-to-body>
- <el-upload
- class="upload-demo"
- drag
- :action="uploadUrl"
- :headers="uploadHeaders"
- :data="uploadData"
- :on-success="handleUploadSuccess"
- :on-error="handleUploadError"
- :before-upload="beforeUpload"
- multiple>
- <i class="el-icon-upload"></i>
- <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
- <div class="el-upload__tip" slot="tip">鍙兘涓婁紶jpg/png/pdf/doc/docx鏂囦欢锛屼笖涓嶈秴杩�10MB</div>
- </el-upload>
+ <el-dialog title="涓婁紶闄勪欢" :visible.sync="uploadOpen" width="500px" append-to-body @close="cancelUpload">
+ <el-form ref="uploadForm" :model="uploadForm" :rules="uploadRules" label-width="100px">
+ <el-form-item label="涓氬姟鍒嗙被" prop="category">
+ <el-select v-model="uploadForm.category" placeholder="璇烽�夋嫨涓氬姟鍒嗙被" clearable style="width: 100%;">
+ <el-option
+ v-for="dict in dict.type.sys_attachment_category"
+ :key="dict.value"
+ :label="dict.label"
+ :value="dict.value"
+ />
+ </el-select>
+ </el-form-item>
+ <el-form-item label="闄勪欢" prop="files">
+ <el-upload
+ ref="upload"
+ class="upload-demo"
+ :action="uploadUrl"
+ :headers="uploadHeaders"
+ :data="uploadData"
+ :on-success="handleUploadSuccess"
+ :on-error="handleUploadError"
+ :before-upload="beforeUpload"
+ :file-list="fileList"
+ :auto-upload="false"
+ multiple
+ drag>
+ <i class="el-icon-upload"></i>
+ <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
+ <div class="el-upload__tip" slot="tip">鍙兘涓婁紶jpg/png/pdf/doc/docx鏂囦欢锛屼笖涓嶈秴杩�100MB</div>
+ </el-upload>
+ </el-form-item>
+ </el-form>
+ <div slot="footer" class="dialog-footer">
+ <el-button type="primary" @click="submitUpload">纭� 瀹�</el-button>
+ <el-button @click="cancelUpload">鍙� 娑�</el-button>
+ </div>
</el-dialog>
</div>
</template>
@@ -414,7 +462,7 @@
export default {
name: "TaskDetail",
- dicts: ['sys_task_type', 'sys_task_status', 'sys_vehicle_type', 'sys_task_vehicle_status', 'sys_user_sex', 'hospital_department'],
+ dicts: ['sys_task_type', 'sys_task_status', 'sys_vehicle_type', 'sys_task_vehicle_status', 'sys_user_sex', 'hospital_department', 'sys_attachment_category'],
data() {
return {
// 浠诲姟璇︽儏
@@ -433,6 +481,12 @@
vehicleAssignOpen: false,
// 鏄惁鏄剧ず涓婁紶瀵硅瘽妗�
uploadOpen: false,
+ // 涓婁紶琛ㄥ崟
+ uploadForm: {
+ category: null
+ },
+ // 鏂囦欢鍒楄〃
+ fileList: [],
// 缂栬緫琛ㄥ崟
editForm: {},
// 鍒嗛厤琛ㄥ崟
@@ -449,7 +503,7 @@
vehicleLoading: false,
attachmentLoading: false,
// 涓婁紶鐩稿叧
- uploadUrl: process.env.VUE_APP_BASE_API + "/task/attachment/upload/" + this.$route.params.taskId,
+ uploadUrl: process.env.VUE_APP_BASE_API + "/task/attachment/upload/" + (new URLSearchParams(window.location.search).get('taskId') || ''),
uploadHeaders: {
Authorization: "Bearer " + getToken()
},
@@ -480,12 +534,19 @@
vehicleIds: [
{ required: true, message: "杞﹁締涓嶈兘涓虹┖", trigger: "change" }
]
+ },
+ uploadRules: {
+ category: [
+ { required: true, message: "涓氬姟鍒嗙被涓嶈兘涓虹┖", trigger: "change" }
+ ]
}
};
},
created() {
this.getTaskDetail();
this.getUserList();
+ // 鍒濆鍖栦笂浼燯RL
+ this.uploadUrl = process.env.VUE_APP_BASE_API + "/task/attachment/upload/" + this.$route.params.taskId;
},
methods: {
/** 鑾峰彇浠诲姟璇︽儏 */
@@ -554,6 +615,10 @@
},
/** 涓婁紶闄勪欢 */
handleUpload() {
+ this.uploadForm = {
+ category: null
+ };
+ this.fileList = [];
this.uploadOpen = true;
},
/** 鍙栨秷杞﹁締鍒嗛厤 */
@@ -648,22 +713,67 @@
},
/** 涓婁紶鍓嶆鏌� */
beforeUpload(file) {
+ // 妫�鏌ユ槸鍚﹂�夋嫨浜嗕笟鍔″垎绫�
+ if (!this.uploadForm.category) {
+ this.$message.error('璇峰厛閫夋嫨涓氬姟鍒嗙被!');
+ return false;
+ }
+
+ // 鏇存柊uploadData锛岀‘淇濇瘡娆′笂浼犻兘甯︽湁category鍙傛暟
+ this.uploadData = {
+ category: this.uploadForm.category
+ };
+
const isValidType = ['image/jpeg', 'image/png', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'].includes(file.type);
- const isLt10M = file.size / 1024 / 1024 < 10;
+ const isLt10M = file.size / 1024 / 1024 < 100;
if (!isValidType) {
this.$message.error('鍙兘涓婁紶 JPG/PNG/PDF/DOC/DOCX 鏍煎紡鐨勬枃浠�!');
+ return false;
}
if (!isLt10M) {
- this.$message.error('涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃 10MB!');
+ this.$message.error('涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃 100MB!');
+ return false;
}
- return isValidType && isLt10M;
+ return true;
+ },
+ /** 鎻愪氦涓婁紶 */
+ submitUpload() {
+ this.$refs["uploadForm"].validate(valid => {
+ if (valid) {
+ // 妫�鏌ユ槸鍚﹂�夋嫨浜嗘枃浠�
+ const fileList = this.$refs.upload.uploadFiles;
+ if (!fileList || fileList.length === 0) {
+ this.$message.warning('璇烽�夋嫨瑕佷笂浼犵殑鏂囦欢');
+ return;
+ }
+
+ // 瑙﹀彂涓婁紶
+ this.$refs.upload.submit();
+ }
+ });
+ },
+ /** 鍙栨秷涓婁紶 */
+ cancelUpload() {
+ this.uploadOpen = false;
+ this.uploadForm = {
+ category: null
+ };
+ this.fileList = [];
+ if (this.$refs.upload) {
+ this.$refs.upload.clearFiles();
+ }
},
/** 涓婁紶鎴愬姛 */
handleUploadSuccess(response, file, fileList) {
- this.$modal.msgSuccess("涓婁紶鎴愬姛");
- this.uploadOpen = false;
- this.getTaskDetail();
+ // 妫�鏌ユ槸鍚︽墍鏈夋枃浠堕兘涓婁紶瀹屾垚
+ const allDone = fileList.every(f => f.status === 'success' || f.status === 'fail');
+
+ if (allDone) {
+ this.$modal.msgSuccess("涓婁紶鎴愬姛");
+ this.cancelUpload();
+ this.getTaskDetail();
+ }
},
/** 涓婁紶澶辫触 */
handleUploadError(err, file, fileList) {
@@ -687,6 +797,12 @@
return typeItem ? typeItem.label : vehicleType;
}
return vehicleType;
+ },
+ /** 鍒ゆ柇鏄惁涓哄浘鐗囩被鍨� */
+ isImage(fileType) {
+ if (!fileType) return false;
+ const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
+ return imageTypes.includes(fileType.toLowerCase());
}
}
};
--
Gitblit v1.9.1