up
This commit is contained in:
@@ -22,7 +22,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="projectName" column="project_name" />
|
<result property="projectName" column="project_name" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectBizDocVo">
|
<!-- 轻量字段:用于列表,排除大字段 doc_content -->
|
||||||
|
<sql id="selectBizDocListVo">
|
||||||
|
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
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 详情字段:下载/单条查询专用,含 doc_content -->
|
||||||
|
<sql id="selectBizDocDetailVo">
|
||||||
select
|
select
|
||||||
d.doc_id,
|
d.doc_id,
|
||||||
d.project_id,
|
d.project_id,
|
||||||
@@ -44,7 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectBizDocList" parameterType="BizDoc" resultMap="BizDocResult">
|
<select id="selectBizDocList" parameterType="BizDoc" resultMap="BizDocResult">
|
||||||
<include refid="selectBizDocVo"/>
|
<include refid="selectBizDocListVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="docId != null and docId != ''"> and doc_id = #{docId}</if>
|
<if test="docId != null and docId != ''"> and doc_id = #{docId}</if>
|
||||||
<if test="projectId != null and projectId != ''"> and d.project_id = #{projectId}</if>
|
<if test="projectId != null and projectId != ''"> and d.project_id = #{projectId}</if>
|
||||||
@@ -96,7 +118,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectBizDocByDocId" parameterType="Long" resultMap="BizDocResult">
|
<select id="selectBizDocByDocId" parameterType="Long" resultMap="BizDocResult">
|
||||||
<include refid="selectBizDocVo"/>
|
<include refid="selectBizDocDetailVo"/>
|
||||||
where doc_id = #{docId}
|
where doc_id = #{docId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@@ -125,7 +125,11 @@
|
|||||||
:data="upload.data"
|
:data="upload.data"
|
||||||
:on-progress="handleFileUploadProgress"
|
:on-progress="handleFileUploadProgress"
|
||||||
:on-success="handleFileSuccess"
|
:on-success="handleFileSuccess"
|
||||||
|
:on-error="handleFileError"
|
||||||
|
:on-exceed="handleFileExceed"
|
||||||
:auto-upload="false"
|
:auto-upload="false"
|
||||||
|
:with-credentials="false"
|
||||||
|
:http-request="customHttpRequest"
|
||||||
drag
|
drag
|
||||||
>
|
>
|
||||||
<i class="el-icon-upload"></i>
|
<i class="el-icon-upload"></i>
|
||||||
@@ -465,6 +469,51 @@ export default {
|
|||||||
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
|
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
|
||||||
this.getList();
|
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() {
|
submitFileForm() {
|
||||||
// 将选择的元数据同步到上传表单字段
|
// 将选择的元数据同步到上传表单字段
|
||||||
|
Reference in New Issue
Block a user