fix: quotation attachment
This commit is contained in:
parent
7ae74cdd5d
commit
f5626f9f2e
2 changed files with 12 additions and 5 deletions
|
|
@ -160,11 +160,10 @@ export const useQuotationPayment = defineStore('quotation-payment', () => {
|
|||
}
|
||||
|
||||
function createPaymentFileManager(
|
||||
api: AxiosInstance,
|
||||
quotationId: string,
|
||||
opts?: { onUploadProgress: (e: AxiosProgressEvent) => void },
|
||||
) {
|
||||
return manageAttachment(api, `/quotation/${quotationId}/payment`, opts);
|
||||
return manageAttachment(api, `quotation/${quotationId}/payment`, opts);
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -288,15 +288,18 @@ export function manageAttachment(
|
|||
parentId: string;
|
||||
name: string;
|
||||
file: File;
|
||||
onUploadProgress?: (e: AxiosProgressEvent) => void;
|
||||
}) => {
|
||||
const res = await api.put(
|
||||
`/${base}/${opts.parentId}/attachment/${opts.name}`,
|
||||
opts.file,
|
||||
{
|
||||
headers: { 'Content-Type': opts.file.type },
|
||||
onUploadProgress: option?.onUploadProgress
|
||||
? option.onUploadProgress
|
||||
: (e) => console.log(e),
|
||||
onUploadProgress: opts.onUploadProgress
|
||||
? opts.onUploadProgress
|
||||
: option?.onUploadProgress
|
||||
? option.onUploadProgress
|
||||
: (e) => console.log(e),
|
||||
},
|
||||
);
|
||||
if (res.status < 400) return true;
|
||||
|
|
@ -470,4 +473,9 @@ export function convertFileSize(size: number): string {
|
|||
return sizeNumber.toFixed(2) + ' ' + units[i];
|
||||
}
|
||||
|
||||
export async function getAttachmentHead(api: AxiosInstance, url: string) {
|
||||
const res = await api.head<string>(`${url}`);
|
||||
if (res) return res.headers;
|
||||
}
|
||||
|
||||
export default useUtilsStore;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue