档案管理
This commit is contained in:
parent
595eacd152
commit
ce3607ec08
|
|
@ -39,11 +39,14 @@ export function addFileManageLeftApi(data) {
|
|||
}
|
||||
|
||||
// 新增档案表格数据
|
||||
export function addArchiveRightApi(data) {
|
||||
export function addFileManageRightApi(data) {
|
||||
return request({
|
||||
url: '/smartArchives/fileManage/addRight',
|
||||
url: '/smartArchives/fileManage/addFileManageRight',
|
||||
method: 'post',
|
||||
data:data
|
||||
data:data,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -52,16 +55,19 @@ export function updateFileManageLeftApi(data) {
|
|||
return request({
|
||||
url: '/smartArchives/fileManage/updateFileManageLeft',
|
||||
method: 'post',
|
||||
data:data,
|
||||
data:data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改档案目录
|
||||
export function editArchiveRightApi(data) {
|
||||
export function updateFileManageRightApi(data) {
|
||||
return request({
|
||||
url: '/smartArchives/fileManage/editRight',
|
||||
url: '/smartArchives/fileManage/updateFileManageRight',
|
||||
method: 'post',
|
||||
data:data,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,14 @@ const service = axios.create({
|
|||
timeout: 30000,
|
||||
})
|
||||
|
||||
// 判断是否为二进制数据(File/Blob)
|
||||
function isBinaryData(value) {
|
||||
return (
|
||||
(typeof File !== 'undefined' && value instanceof File) ||
|
||||
(typeof Blob !== 'undefined' && value instanceof Blob)
|
||||
)
|
||||
}
|
||||
|
||||
// request 拦截器
|
||||
service.interceptors.request.use(
|
||||
(config) => {
|
||||
|
|
@ -139,9 +147,40 @@ service.interceptors.request.use(
|
|||
|
||||
// POST/PUT 请求处理
|
||||
if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) {
|
||||
let data = typeof config.data === 'object' ? JSON.stringify(config.data) : config.data
|
||||
let contentType = config.headers['Content-Type']
|
||||
|
||||
// 处理 multipart/form-data: 仅加密非二进制字段(如 params),忽略文件本身
|
||||
const isFormData = (typeof FormData !== 'undefined') && (config.data instanceof FormData)
|
||||
if (isFormData) {
|
||||
if (systemConfig.requestConfig.encryptRequest && encryptRequest) {
|
||||
const newForm = new FormData()
|
||||
// 遍历原始 FormData,二进制原样,文本字段进行加密
|
||||
for (const [key, value] of config.data.entries()) {
|
||||
if (isBinaryData(value)) {
|
||||
newForm.append(key, value)
|
||||
} else if (typeof value === 'string') {
|
||||
const payload = value + '|' + hashWithSM3AndSalt(value)
|
||||
newForm.append(key, encryptWithSM4(payload))
|
||||
} else {
|
||||
// 其他类型(如对象)先转字符串再加密
|
||||
try {
|
||||
const stringified = JSON.stringify(value)
|
||||
const payload = stringified + '|' + hashWithSM3AndSalt(stringified)
|
||||
newForm.append(key, encryptWithSM4(payload))
|
||||
} catch (e) {
|
||||
// 兜底:直接追加原值
|
||||
newForm.append(key, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
config.data = newForm
|
||||
}
|
||||
// 对于 FormData,跳过重复提交体积计算(不可可靠 stringify)
|
||||
return config
|
||||
}
|
||||
|
||||
// 非 multipart/form-data 的 JSON 等请求
|
||||
let data = typeof config.data === 'object' ? JSON.stringify(config.data) : config.data
|
||||
if (contentType && contentType.includes('application/json') && typeof data !== 'undefined') {
|
||||
// 加密数据
|
||||
if (systemConfig.requestConfig.encryptRequest && encryptRequest) {
|
||||
|
|
@ -149,10 +188,10 @@ service.interceptors.request.use(
|
|||
}
|
||||
}
|
||||
|
||||
// 检查请求数据大小
|
||||
// 检查请求数据大小(仅针对可 stringify 的场景)
|
||||
const requestSize = JSON.stringify({
|
||||
url: config.url,
|
||||
data: data,
|
||||
data: typeof data === 'string' ? data : '[non-string-data]',
|
||||
time: Date.now(),
|
||||
}).length
|
||||
const limitSize = 1000 * 1024 * 1024
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ export default {
|
|||
},
|
||||
/** 删除操作 */
|
||||
handleDelete(row) {
|
||||
this.$modal.confirm(`是否确认删除文件分类标记名称为"${row.classifyName}"的数据项?`).then(() => {
|
||||
this.$modal.confirm(`是否确认删除文件分类标记名称为"${row.classifyMarkName}"的数据项?`).then(() => {
|
||||
// 显示加载遮罩
|
||||
this.$modal.loading("正在删除,请稍候...");
|
||||
delArchivalCatalogueAPI({ id: row.id }).then(res => {
|
||||
|
|
|
|||
|
|
@ -37,23 +37,23 @@
|
|||
:value="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="附件上传" v-if="!detailStatus">
|
||||
<el-form-item label="附件上传" v-if="!detailStatus" prop="fileList">
|
||||
<el-upload
|
||||
ref="upload"
|
||||
:action="uploadUrl"
|
||||
:headers="uploadHeaders"
|
||||
:data="uploadData"
|
||||
action="#"
|
||||
:file-list="fileList"
|
||||
:before-upload="beforeUpload"
|
||||
:on-success="handleUploadSuccess"
|
||||
:on-error="handleUploadError"
|
||||
:on-remove="handleRemove"
|
||||
:on-change="handleFileChange"
|
||||
:before-upload="beforeUpload"
|
||||
:auto-upload="false"
|
||||
:limit="1"
|
||||
accept=".pdf,.jpg,.jpeg,.png,.gif,.bmp">
|
||||
<el-button size="small" type="primary" icon="el-icon-upload">选择文件</el-button>
|
||||
accept=".pdf,.jpg,.jpeg,.png"
|
||||
:http-request="customUpload">
|
||||
<el-button size="small" type="primary" icon="el-icon-upload" :disabled="fileList.length > 0">选择文件</el-button>
|
||||
<div slot="tip" class="el-upload__tip">
|
||||
只能上传PDF和图片文件,且不超过10MB
|
||||
<span>
|
||||
只能上传PDF和图片文件,且不超过{{maxFileTips}}
|
||||
</span>
|
||||
</div>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
|
|
@ -69,11 +69,10 @@
|
|||
<script>
|
||||
import _ from 'lodash'
|
||||
import {
|
||||
addArchiveRightApi,
|
||||
editArchiveRightApi,
|
||||
} from '@/api/archivesManagement/index.js'
|
||||
addFileManageRightApi,
|
||||
updateFileManageRightApi,
|
||||
} from '@/api/archivesManagement/fileManager/fileManager.js'
|
||||
import { getClassifyMarkSelApi } from '@/api/select.js'
|
||||
import { getToken } from '@/utils/auth'
|
||||
export default {
|
||||
name: "FileAddTableData",
|
||||
props: ["width", "dataForm", "title", "disabled", "isAdd", "rowData", "projectId"],
|
||||
|
|
@ -98,16 +97,21 @@ export default {
|
|||
detailStatus: false,
|
||||
// 文件上传相关
|
||||
fileList: [],
|
||||
uploadUrl: process.env.VUE_APP_BASE_API + '/smartArchives/file/upload',
|
||||
uploadHeaders: {
|
||||
'Authorization': 'Bearer ' + getToken()
|
||||
},
|
||||
uploadData: {},
|
||||
maxFileSize: 10 * 1024 * 1024, // 默认10MB
|
||||
maxFileTips: '10MB',
|
||||
rules: {
|
||||
contentName: [
|
||||
{ required: true, message: '文件题名不能为空', trigger: 'blur' }
|
||||
],
|
||||
fileList: [
|
||||
{ validator: (rule, value, callback) => {
|
||||
if (!Array.isArray(this.fileList) || this.fileList.length === 0) {
|
||||
callback(new Error('请上传附件文件'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}, trigger: 'change' }
|
||||
],
|
||||
term: [
|
||||
{ required: true, message: '案卷期限不能为空', trigger: 'blur' }
|
||||
],
|
||||
|
|
@ -127,30 +131,48 @@ export default {
|
|||
};
|
||||
},
|
||||
created() {
|
||||
this.initUploadLimit();
|
||||
this.initFormData();
|
||||
},
|
||||
mounted() {
|
||||
// 在mounted生命周期中再次尝试获取字典数据
|
||||
this.$nextTick(() => {
|
||||
this.updateFileSizeLimit();
|
||||
});
|
||||
},
|
||||
watch: {
|
||||
// 监听字典数据变化
|
||||
'dict.type.file_size_limit': {
|
||||
handler(newVal) {
|
||||
if (newVal && Array.isArray(newVal) && newVal.length > 0) {
|
||||
this.updateFileSizeLimit();
|
||||
}
|
||||
},
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async initUploadLimit(){
|
||||
// 加载文件上传限制
|
||||
await this.$nextTick();
|
||||
this.updateFileSizeLimit();
|
||||
},
|
||||
// 更新文件大小限制
|
||||
updateFileSizeLimit() {
|
||||
if (this.dict && this.dict.type && this.dict.type.file_size_limit) {
|
||||
const fileSizeLimit = this.dict.type.file_size_limit;
|
||||
if (Array.isArray(fileSizeLimit) && fileSizeLimit.length > 0) {
|
||||
const firstValue = fileSizeLimit[0].value;
|
||||
// 更新最大文件大小限制
|
||||
if (firstValue && !isNaN(firstValue)) {
|
||||
this.maxFileSize = parseInt(firstValue);
|
||||
this.maxFileSize = parseInt(firstValue) * 1024 * 1024;
|
||||
this.maxFileTips = firstValue + 'MB';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
},
|
||||
/** 初始化表单数据 */
|
||||
async initFormData() {
|
||||
// 等待字典数据加载完成
|
||||
await this.$nextTick();
|
||||
const fileSizeLimit = this.dict.type.file_size_limit;
|
||||
const firstFileSizeLimit = fileSizeLimit && Array.isArray(fileSizeLimit) && fileSizeLimit.length > 0 ? fileSizeLimit[0].value : null;
|
||||
const res = await getClassifyMarkSelApi();
|
||||
this.classifyMarkList = res.data;
|
||||
this.belongName = this.rowData.belongName;
|
||||
|
|
@ -166,7 +188,7 @@ export default {
|
|||
markCode: this.rowData.markCode || null,
|
||||
classifyMark: this.rowData.classifyMark || null,
|
||||
parentId: this.rowData.parentId || null,
|
||||
level: 4
|
||||
level: 5
|
||||
};
|
||||
} else {
|
||||
// 新增模式:重置表单
|
||||
|
|
@ -178,7 +200,7 @@ export default {
|
|||
markCode: null,
|
||||
classifyMark: null,
|
||||
parentId: this.rowData.id || null,
|
||||
level: 4
|
||||
level: 5
|
||||
};
|
||||
}
|
||||
},
|
||||
|
|
@ -208,10 +230,12 @@ export default {
|
|||
markCode: null,
|
||||
classifyMark: null,
|
||||
parentId: null,
|
||||
level: 4
|
||||
level: 5
|
||||
};
|
||||
this.fileList = [];
|
||||
this.$refs.upload && this.$refs.upload.clearFiles();
|
||||
this.$nextTick(() => {
|
||||
this.$refs.upload && this.$refs.upload.clearFiles();
|
||||
});
|
||||
this.resetForm("ruleForm");
|
||||
},
|
||||
handleReuslt(res) {
|
||||
|
|
@ -220,7 +244,7 @@ export default {
|
|||
this.$emit('handleQuery');
|
||||
this.handleClose();
|
||||
},
|
||||
// 上传前验证
|
||||
// 上传前对文件进行验证
|
||||
beforeUpload(file) {
|
||||
const isValidType = this.checkFileType(file)
|
||||
const isValidSize = this.checkFileSize(file)
|
||||
|
|
@ -240,13 +264,6 @@ export default {
|
|||
return false
|
||||
}
|
||||
|
||||
// 设置上传数据
|
||||
this.uploadData = {
|
||||
projectId: this.projectId,
|
||||
categoryId: this.form.parentId || 0,
|
||||
description: this.form.contentName || ''
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
// 检查文件类型
|
||||
|
|
@ -283,6 +300,21 @@ export default {
|
|||
handleRemove(file, fileList) {
|
||||
this.fileList = fileList
|
||||
},
|
||||
// 文件状态改变
|
||||
handleFileChange(file, fileList) {
|
||||
this.fileList = fileList
|
||||
// 主动触发校验
|
||||
if (this.$refs.ruleForm) {
|
||||
this.$refs.ruleForm.validateField('fileList')
|
||||
}
|
||||
console.log('文件列表更新:', fileList.length, '个文件')
|
||||
},
|
||||
// 自定义上传方法
|
||||
customUpload(options) {
|
||||
// 这里可以处理文件上传,但由于您已经移除了上传功能,这里只是占位
|
||||
console.log('自定义上传:', options)
|
||||
return Promise.resolve()
|
||||
},
|
||||
// 上传文件
|
||||
uploadFiles() {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
@ -326,11 +358,7 @@ export default {
|
|||
if (valid) {
|
||||
// 如果有文件需要上传,先上传文件
|
||||
if (this.fileList.length > 0) {
|
||||
this.uploadFiles().then(() => {
|
||||
this.submitFormData();
|
||||
}).catch(error => {
|
||||
this.$message.error('文件上传失败,请重试');
|
||||
});
|
||||
this.submitFormData();
|
||||
} else {
|
||||
this.submitFormData();
|
||||
}
|
||||
|
|
@ -346,10 +374,17 @@ export default {
|
|||
background: 'rgba(0,0,0,0.5)',
|
||||
target: this.$el.querySelector('.el-dialog') || document.body
|
||||
})
|
||||
let formData = new FormData();
|
||||
let params = _.cloneDeep(this.form);
|
||||
|
||||
if(this.fileList.length > 0){
|
||||
this.fileList.map(file => {
|
||||
formData.append('file', file.raw);
|
||||
})
|
||||
}
|
||||
if (this.isAdd === 'add') {
|
||||
addArchiveRightApi(params).then(res => {
|
||||
formData.append('params', JSON.stringify(params));
|
||||
console.log(params);
|
||||
addFileManageRightApi(formData).then(res => {
|
||||
this.loading.close();
|
||||
if (res.code === 200) {
|
||||
this.handleReuslt(res);
|
||||
|
|
@ -361,7 +396,7 @@ export default {
|
|||
// this.$modal.msgError('提交失败,请重试');
|
||||
});
|
||||
} else {
|
||||
editArchiveRightApi(params).then(res => {
|
||||
updateFileManageRightApi(formData).then(res => {
|
||||
this.loading.close();
|
||||
if (res.code === 200) {
|
||||
this.handleReuslt(res);
|
||||
|
|
|
|||
Loading…
Reference in New Issue