From a1e14096b98fc9c84b5614b1dac41a9c65b4d723 Mon Sep 17 00:00:00 2001
From: Quella <2892744389@qq.com>
Date: Fri, 12 Sep 2025 10:38:17 +0800
Subject: [PATCH] up
---
.../resources/mapper/project/BizDocMapper.xml | 28 +++++++++--
ruoyi-ui/src/views/project/doc/index.vue | 49 +++++++++++++++++++
2 files changed, 74 insertions(+), 3 deletions(-)
diff --git a/ruoyi-admin/src/main/resources/mapper/project/BizDocMapper.xml b/ruoyi-admin/src/main/resources/mapper/project/BizDocMapper.xml
index ace4ecf..fb1ad6b 100644
--- a/ruoyi-admin/src/main/resources/mapper/project/BizDocMapper.xml
+++ b/ruoyi-admin/src/main/resources/mapper/project/BizDocMapper.xml
@@ -22,7 +22,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-
+
+
+ select
+ d.doc_id,
+ d.project_id,
+ d.module_id,
+ d.kind_type,
+ d.file_name as doc_name,
+ d.file_url as doc_path,
+ null as doc_size,
+ null as doc_type,
+ d.del_flag,
+ d.upload_by as create_by,
+ d.upload_time as create_time,
+ null as update_by,
+ null as update_time,
+ p.project_name as project_name
+ from biz_doc d
+ left join biz_project p on p.project_id = d.project_id
+
+
+
+
select
d.doc_id,
d.project_id,
@@ -44,7 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
diff --git a/ruoyi-ui/src/views/project/doc/index.vue b/ruoyi-ui/src/views/project/doc/index.vue
index d009634..2852965 100644
--- a/ruoyi-ui/src/views/project/doc/index.vue
+++ b/ruoyi-ui/src/views/project/doc/index.vue
@@ -125,7 +125,11 @@
:data="upload.data"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
+ :on-error="handleFileError"
+ :on-exceed="handleFileExceed"
:auto-upload="false"
+ :with-credentials="false"
+ :http-request="customHttpRequest"
drag
>
@@ -465,6 +469,51 @@ export default {
this.$alert("" + response.msg + "
", "导入结果", { dangerouslyUseHTMLString: true });
this.getList();
},
+ // 文件上传失败处理(网络/后端错误)
+ handleFileError(err, file, fileList) {
+ this.upload.isUploading = false;
+ this.$message.error('上传失败:' + (err && (err.msg || err.message) || '网络错误'));
+ },
+ // 文件数超出限制
+ handleFileExceed(files, fileList) {
+ this.$message.warning('一次最多上传 1 个文件');
+ },
+ // 自定义上传请求:支持大文件进度与中断恢复(预留)
+ async customHttpRequest(options) {
+ const { file, onProgress, onSuccess, onError } = options
+ // 直接透传给默认 xhr,但保留钩子可用于分片
+ try {
+ const form = new FormData()
+ form.append('file', file)
+ Object.keys(this.upload.data || {}).forEach(k => form.append(k, this.upload.data[k]))
+ const xhr = new XMLHttpRequest()
+ xhr.open('POST', this.upload.url, true)
+ const headers = this.upload.headers || {}
+ Object.keys(headers).forEach(k => xhr.setRequestHeader(k, headers[k]))
+ xhr.upload.onprogress = function (evt) {
+ if (evt.lengthComputable && typeof onProgress === 'function') {
+ onProgress({ percent: Math.round((evt.loaded / evt.total) * 100) })
+ }
+ }
+ xhr.onreadystatechange = () => {
+ if (xhr.readyState === 4) {
+ if (xhr.status >= 200 && xhr.status < 300) {
+ try {
+ const res = JSON.parse(xhr.responseText || '{}')
+ onSuccess && onSuccess(res)
+ } catch (e) {
+ onSuccess && onSuccess({ msg: '上传成功' })
+ }
+ } else {
+ onError && onError(new Error('HTTP ' + xhr.status))
+ }
+ }
+ }
+ xhr.send(form)
+ } catch (e) {
+ onError && onError(e)
+ }
+ },
// 提交上传文件
submitFileForm() {
// 将选择的元数据同步到上传表单字段