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