WIP
This commit is contained in:
parent
a7264fe1fc
commit
f7030d1213
|
@ -32,7 +32,7 @@ const statusIcons = {
|
|||
}
|
||||
};
|
||||
const formInitialData = reactive({
|
||||
schema: 'catalog',
|
||||
collectionFk: 'catalog',
|
||||
updateMatching: true
|
||||
});
|
||||
const imageCollections = ref([]);
|
||||
|
@ -51,6 +51,10 @@ const getImageCollections = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
const buildUploadUrl = (id, collection) => {
|
||||
return `images/upload?id=${encodeURIComponent(id)}&collection=${encodeURIComponent(collection)}`;
|
||||
};
|
||||
|
||||
const onSubmit = async data => {
|
||||
if (!addedFiles.value.length) {
|
||||
notify(t('noFilesToUpload'), 'warning');
|
||||
|
@ -59,20 +63,37 @@ const onSubmit = async data => {
|
|||
const filteredFiles = addedFiles.value.filter(
|
||||
file => file.uploadStatus === 'pending'
|
||||
);
|
||||
const promises = filteredFiles.map((file, index) => {
|
||||
const promises = filteredFiles.map(async (file, index) => {
|
||||
const fileIndex = filteredFiles[index].index;
|
||||
addedFiles.value[fileIndex].uploadStatus = 'uploading';
|
||||
|
||||
// const formData = new FormData();
|
||||
// formData.append('file', file.file);
|
||||
|
||||
// const entityId = imageCollections.value.find(
|
||||
// collection => collection.name === data.collectionFk
|
||||
// ).model;
|
||||
|
||||
// const url = buildUploadUrl(entityId, data.collectionFk);
|
||||
// console.log('url', url);
|
||||
// return api({
|
||||
// method: 'post',
|
||||
// url: url,
|
||||
// data: formData,
|
||||
// headers: {
|
||||
// 'Content-Type': 'multipart/form-data'
|
||||
// }
|
||||
// });
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('updateMatching', data.updateMatching);
|
||||
formData.append('image', file.file);
|
||||
formData.append('name', file.name);
|
||||
formData.append('schema', data.schema);
|
||||
formData.append('srv', 'json:image/upload');
|
||||
return api({
|
||||
method: 'post',
|
||||
url: location.origin,
|
||||
data: formData,
|
||||
const now = Date.vnNew();
|
||||
const timestamp = now.getTime();
|
||||
console.log('file', file);
|
||||
const fileName = `${file.file?.name}_${timestamp}`;
|
||||
formData.append('blob', file.file, fileName);
|
||||
|
||||
await axios.post('Images/upload', formData, {
|
||||
params: newPhoto,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
|
@ -102,6 +123,7 @@ const onSubmit = async data => {
|
|||
};
|
||||
|
||||
const onFilesAdded = files => {
|
||||
console.log('files', files);
|
||||
const initialFilesLength = addedFiles.value.length;
|
||||
files.forEach((file, index) => {
|
||||
const [name] = file.name.split('.');
|
||||
|
@ -146,7 +168,7 @@ onMounted(async () => getImageCollections());
|
|||
>
|
||||
<template #form="{ data }">
|
||||
<VnSelect
|
||||
v-model="data.schema"
|
||||
v-model="data.collectionFk"
|
||||
:label="t('collection')"
|
||||
option-label="desc"
|
||||
option-value="name"
|
||||
|
|
Loading…
Reference in New Issue