Commit 57bd0f29 by Sweet Zhang

Merge branch 'swhotfix' into test

parents 34a3d7db d312c36f
import request from '@/utils/request'
// 修改上传图片方法,添加正确的请求配置
export function uploadImage(data) {
console.log('data', data)
......@@ -168,9 +167,9 @@ export function uploadMaterialList(data) {
})
}
// 删除上传文件
export function delUploadFile(fileBizId) {
export function delUploadFile(fileBizId,projectBizId) {
return request({
url: `/oss/api/ossFile/del?fileBizId=${fileBizId}`,
url: `/oss/api/ossFile/del?fileBizId=${fileBizId}&projectBizId=${projectBizId}`,
method: 'delete'
})
}
......
......@@ -132,6 +132,7 @@ const props = defineProps({
tenantBizId: { type: String, required: true,default: '' },
projectBizId: { type: String, required: true, default: '' },
objectBizId: { type: String, required: true, default: '' },
projectType: { type: String, default: '' },
objectType: { type: String, default: '' },
objectTableName: { type: String, default: '' },
objectName: { type: String, default: '' },
......@@ -303,7 +304,7 @@ const initOssClient = async () => {
const data = res.data || res;
const rawData = data.data || data;
const { region, accessKeyId, accessKeySecret, stsToken, bucket, endpoint } = rawData;
const { region, accessKeyId, accessKeySecret, stsToken, bucket, endpoint,filePrefix } = rawData;
if (!accessKeyId || !bucket) throw new Error('STS 凭证信息不完整');
......@@ -319,6 +320,7 @@ const initOssClient = async () => {
endpoint: ossEndpoint,
secure: true,
timeout: 60000,
filePrefix
});
return ossClient.value;
} catch (error) {
......@@ -335,8 +337,8 @@ const uploadSingleFile = async (item) => {
console.error('Invalid file object for upload:', file);
throw new Error('文件对象无效,必须是 File 或 Blob 类型');
}
const objectName = `uploads/${props.projectBizId}/${Date.now()}_${item.uid}_${file.name}`;
console.log(ossClient.value)
const objectName = `${ossClient.value.options.filePrefix}${props.projectBizId}${Date.now()}_${item.uid}_${file.name}`;
item.status = 'uploading';
item.startTime = Date.now();
......@@ -360,8 +362,6 @@ const uploadSingleFile = async (item) => {
item.status = 'success';
item.progress = 100;
item.speed = '-';
// const endpoint = client.options.endpoint.replace(/^https?:\/\//, '');
const endpoint = client.options.endpoint.host;
item.url = `https://${client.options.bucket}.${endpoint}/${objectName}`;
......@@ -400,6 +400,7 @@ const startUpload = async () => {
tenantBizId: props.tenantBizId,
projectBizId: props.projectBizId,
objectBizId: props.objectBizId,
projectType:props.projectType,
objectType: props.objectType,
objectTableName: props.objectTableName,
objectName: props.objectName,
......
......@@ -85,6 +85,7 @@
<div class="fileUploadBox">
<el-upload
:action="uploadImgUrl"
:data="{'projectBizId':userStore.projectInfo.projectBizId}"
:headers="headers"
multiple
:limit="limit"
......@@ -138,6 +139,8 @@ import CardOne from '@/components/formCard/cardOne'
import { getToken } from '@/utils/auth'
import { addFile, getAppointmentFile, delFile, editAppointmentFile } from '@/api/sign/appointment'
import useDictStore from '@/store/modules/dict'
import useUserStore from '@/store/modules/user'
const userStore = useUserStore()
import {
uploadMaterialList,
delUploadFile,
......@@ -395,7 +398,7 @@ const uploadSuccess = (res, file, fileList) => {
// 删除已上传的文件(仅从列表移除,不调用后端删除)
const removeUploadedFile = (file, index) => {
try {
delUploadFile(file.fileBizId).then(response => {
delUploadFile(file.fileBizId,userStore.projectInfo.projectBizId).then(response => {
uploadedFiles.value.splice(index, 1)
})
} catch (error) {
......
......@@ -199,6 +199,7 @@
:project-biz-id="userStore.projectInfo.projectBizId"
:object-biz-id="props.policyBizId"
:object-type="'DOCUMENT'"
:project-type="'pc'"
:upload-concurrency="3"
ref="uploaderRef"
/>
......@@ -1117,7 +1118,7 @@ const handleCancel = () => {
const deleteFile = (row)=>{
console.log(row)
const fileBizId = row.fileBizId || '';
delUploadFile(fileBizId).then(res=>{
delUploadFile(fileBizId,userStore.projectInfo.projectBizId).then(res=>{
console.log(res)
if(res.code===200){
getAttachmentListDetail(props.policyBizId)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment