From f728948f6b015871f2171ffd82e20298882c9d2f Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Fri, 6 Oct 2023 22:51:52 -0400 Subject: [PATCH] emits --- benchtop-fe/src/components/Sheet.vue | 16 +- benchtop-fe/src/components/UploadForm.vue | 205 ++++++++++++--------- benchtop-fe/src/components/_UploadForm.vue | 111 +++++++++++ 3 files changed, 245 insertions(+), 87 deletions(-) create mode 100644 benchtop-fe/src/components/_UploadForm.vue diff --git a/benchtop-fe/src/components/Sheet.vue b/benchtop-fe/src/components/Sheet.vue index 5c9da9d..286ddb8 100644 --- a/benchtop-fe/src/components/Sheet.vue +++ b/benchtop-fe/src/components/Sheet.vue @@ -1,7 +1,7 @@ \ No newline at end of file + +const upload_form_data = ref(); + +const uploadForm = (form) => { + upload_form_data.value = form; +} + + +const emits = defineEmits(["uploadForm"]); + diff --git a/benchtop-fe/src/components/UploadForm.vue b/benchtop-fe/src/components/UploadForm.vue index a8e94ce..d5acf60 100644 --- a/benchtop-fe/src/components/UploadForm.vue +++ b/benchtop-fe/src/components/UploadForm.vue @@ -3,109 +3,144 @@
- - - - - - + + + + + + - - - - - + + + + + + +
Report Type - -
-
    -
  • - {{ file.name }} +
Report Type + +
+ + +
    +
  • + + {{ file.name }} -
  • -
- - - Select files - + + - - - -
  - -
  + +
- \ No newline at end of file + file.kind = opt; + console.log(file); +}; + +const removeUpload = (index) => { + files.value.splice(index, 1); +}; + +const readFile = ($event) => { + const target = $event.target; + if (target && target.files) { + current_file.value = target.files[0]; + } + if (!current_file.value.name.includes(".txt")) { + return; + } + const reader = new FileReader(); + reader.onload = (res) => { + let content = res.target.result; + files.value.push({ + name: current_file.value.name, + value: content, + kind: "", + }); + }; + reader.onerror = (err) => console.log(err); + reader.readAsText(current_file.value); + doc.value.value = null; +}; + +const emit = defineEmits(); +watchEffect(() => { + emit("upload-form", { + report_type, + files, + }); +}); + diff --git a/benchtop-fe/src/components/_UploadForm.vue b/benchtop-fe/src/components/_UploadForm.vue new file mode 100644 index 0000000..a8e94ce --- /dev/null +++ b/benchtop-fe/src/components/_UploadForm.vue @@ -0,0 +1,111 @@ + + + + \ No newline at end of file