This commit is contained in:
parent
6d70187cb9
commit
c578538fe0
10 changed files with 195 additions and 107 deletions
|
|
@ -66,7 +66,7 @@
|
|||
<input
|
||||
id="upload-pdf"
|
||||
type="file"
|
||||
@change="addPdf($event)"
|
||||
@change="addPdf($event, page.uri, true)"
|
||||
accept="application/pdf"
|
||||
ref="pdfInput"
|
||||
hidden
|
||||
|
|
@ -96,45 +96,13 @@
|
|||
import { ref } from "vue";
|
||||
import { usePageStore } from "../../../stores/page";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useBriefStore } from "../../../stores/brief";
|
||||
|
||||
const emit = defineEmits("update:step");
|
||||
|
||||
const { page } = storeToRefs(usePageStore());
|
||||
const { addPdf } = useBriefStore();
|
||||
const pdfInput = ref(null);
|
||||
|
||||
async function addPdf(event) {
|
||||
const file = event.target.files[0];
|
||||
|
||||
if (file) {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
"/upload-pdf.json?pageUri=" + page.value.uri,
|
||||
{
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}
|
||||
);
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
console.log("File uploaded successfully.");
|
||||
page.value = result;
|
||||
location.href =
|
||||
location.origin + "/" + page.value.parent + "?dialog=client-brief";
|
||||
} else {
|
||||
console.error("Error uploading file:", result.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Request failed:", error);
|
||||
}
|
||||
} else {
|
||||
console.error("No file selected.");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue