Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Omar Elkadi
PStA WP2 OmarElkadi1
Commits
42a3ec0d
Commit
42a3ec0d
authored
Jun 06, 2021
by
Omar Elkadi
Browse files
Add message and diagnose to SickForm and Server
parent
00686ee2
Changes
3
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
42a3ec0d
.DS_Store
node_modules
server/uploads
/dist
...
...
server/src/routes/patientRoutes.ts
View file @
42a3ec0d
...
...
@@ -47,26 +47,26 @@ export class patientRoutes {
// parse JSON to Objects
var
patientStudent
=
JSON
.
parse
(
body
.
patientStudent
);
var
sickNote
=
JSON
.
parse
(
body
.
sickNoteData
);
var
sickNote
=
JSON
.
parse
(
body
.
SickNote
);
var
message
=
JSON
.
parse
(
body
.
Message
);
var
sicknessReport
=
{
patientStudent
,
sickNote
};
const
file
=
req
.
file
;
if
(
!
file
)
{
console
.
log
(
"
not file error
"
);
}
res
.
status
(
200
)
.
send
(
"
the body and the file are recived
"
+
JSON
.
stringify
(
body
));
const
path
=
"
./uploads/reports/
"
+
patientStudent
.
MatrikelNumber
+
"
.json
"
;
var
sicknessReport
=
{
patientStudent
,
sickNote
,
message
,
sickNoteFilePath
:
path
,
};
writeFile
(
path
,
JSON
.
stringify
(
sicknessReport
),
function
(
err
)
{
if
(
err
)
return
console
.
log
(
err
);
else
return
console
.
log
(
"
file generated in path:
"
+
path
);
});
res
.
status
(
200
).
send
(
"
the body and the file are recived
"
+
JSON
.
stringify
(
body
));
}
}
src/views/SickForm.vue
View file @
42a3ec0d
<
template
>
<form
class=
"container mb-
1
mt-
1
p-
1
border border-info rounded"
class=
"container mb-
3
mt-
3
p-
2
border border-info rounded"
@
submit.prevent=
"OnSubmit"
enctype=
"multipart/form-data"
>
<div
class=
"row"
>
<div
class=
"col-md-8"
>
<!--1. name-->
<div
class=
"form-row"
>
<div
class=
"form-group col-md-5"
>
<div
class=
"form-group col-md-5
col-sm-12 col-sm-12
"
>
<label
for=
"fname"
>
Vorname
</label>
<input
type=
"text"
...
...
@@ -16,7 +18,7 @@
required
/>
</div>
<div
class=
"form-group col-md-5"
>
<div
class=
"form-group col-md-5
col-sm-12
"
>
<label
for=
"lname"
>
Nachname
</label>
<input
type=
"text"
...
...
@@ -37,8 +39,9 @@
/>
</div>
</div>
<!--2. Email && phonenumber -->
<div
class=
"form-row"
>
<div
class=
"form-group col-md-6"
>
<div
class=
"form-group col-md-6
col-sm-12
"
>
<label
for=
"inputEmail4"
>
E-mail
</label>
<input
type=
"email"
...
...
@@ -48,7 +51,7 @@
required
/>
</div>
<div
class=
"form-group col-md-6"
>
<div
class=
"form-group col-md-6
col-sm-12
"
>
<label
for=
"phone"
>
Anrufnummer
</label>
<input
type=
"tel"
...
...
@@ -60,6 +63,7 @@
/>
</div>
</div>
<!--3. Adress street haus num -->
<div
class=
"form-row"
>
<div
class=
"form-group col-md-10"
>
<label
for=
"Street"
>
Straße
</label>
...
...
@@ -82,12 +86,13 @@
/>
</div>
</div>
<!-- 4. Adress city + country-->
<div
class=
"form-row"
>
<div
class=
"form-group col-md-2"
>
<label
for=
"inputZip"
>
Postleizahl
</label>
<input
type=
"text"
class=
"form-control"
id=
"inputZip"
v-model=
"patientStudent.Address.ZIPcode"
required
/>
</div>
<div
class=
"form-group col-md-6"
>
<div
class=
"form-group col-md-6
col-sm-12
"
>
<label
for=
"inputCity"
>
Stadt
</label>
<input
type=
"text"
class=
"form-control"
id=
"inputCity"
v-model=
"patientStudent.Address.City"
required
/>
</div>
...
...
@@ -100,7 +105,7 @@
</select>
</div>
</div>
<!-- 5.
Row
-->
<!-- 5.
date select and file upload
-->
<div
class=
"form-row"
>
<div
class=
"form-group col-md-4"
>
<label
for=
"date-input-start"
>
Startdatum
</label>
...
...
@@ -116,18 +121,38 @@
<input
class=
"form-control"
type=
"file"
id=
"formFile"
ref=
"file"
accept=
".pdf,.docx,image/*"
@
change=
"handleFileUpload()"
required
>
</div>
</div>
<!--
<div
class=
"form-group"
>
<div
class=
"form-check"
>
<input
class=
"form-check-input"
type=
"checkbox"
id=
"gridCheck"
/>
<label
class=
"form-check-label"
for=
"gridCheck"
>
Check me out
</label>
</div>
<div
class=
"col-md-4"
>
<div
class=
"form-row h-50 p-1"
>
<div
class=
"form-group col-md-12"
>
<label
for=
"diag"
>
Diagnose
</label>
<textarea
type=
"text-area"
class=
"form-control h-75"
id=
"diag"
v-model=
"SickNote.diagnose"
required
>
</textarea>
</div>
</div>
<div
class=
"form-row h-50 p-1"
>
<div
class=
"form-group col-md-12"
>
<label
for=
"mess"
>
Nachricht
</label>
<textarea
type=
"text-area"
class=
"form-control h-75"
id=
"mess"
v-model=
"Message"
required
>
</textarea>
</div>
</div>
-->
<button
type=
"submit"
class=
"btn btn-success"
>
Abschicken
</button>
</form>
</div>
</div>
<button
type=
"submit"
class=
"btn btn-success"
>
Abschicken
</button>
</form>
</
template
>
<
script
lang=
"ts"
>
...
...
@@ -153,9 +178,11 @@ export default {
}
},
SickNote
:
{
diagnose
:
''
,
StartDate
:
new
Date
().
getDate
(),
EndDate
:
new
Date
().
getDate
()
},
Message
:
''
,
countries
:
[
{
name
:
'
Afghanistan
'
,
code
:
'
AF
'
},
...
...
@@ -405,6 +432,7 @@ export default {
}
},
methods
:
{
// get the file in a variable and check the validation
handleFileUpload
()
{
// get the file from tag
const
file
=
this
.
$refs
.
file
.
files
[
0
]
...
...
@@ -416,7 +444,7 @@ export default {
console
.
log
(
fileExtension
)
if
(
!
allowedExtentions
.
includes
(
fileExtension
))
{
// extention validation
this
.
$refs
.
file
.
value
=
null
this
.
$refs
.
file
.
value
=
null
// delete the file from selection
Swal
.
fire
({
title
:
'
Fehler!
'
,
text
:
'
Die Datei muss jpg, jpeg, png oder pdf
'
,
...
...
@@ -445,7 +473,8 @@ export default {
// prepare and bulid the messege
// FormData is a dictionary type -> (key , value)
formData
.
append
(
'
patientStudent
'
,
JSON
.
stringify
(
this
.
patientStudent
))
formData
.
append
(
'
sickNoteData
'
,
JSON
.
stringify
(
this
.
SickNote
))
formData
.
append
(
'
SickNote
'
,
JSON
.
stringify
(
this
.
SickNote
))
formData
.
append
(
'
Message
'
,
JSON
.
stringify
(
this
.
Message
))
// add file to the message body
formData
.
append
(
'
sickNoteEvidence
'
,
this
.
EvidenceFile
)
...
...
@@ -459,7 +488,13 @@ export default {
const
data
=
res
.
data
console
.
log
(
data
)
Swal
.
fire
(
'
Danke! Das Formular wurde schon gesandet
'
)
// trigger alert the the form is accepted
Swal
.
fire
({
title
:
'
Gesandet!
'
,
text
:
'
Danke für Ihre Meldung
'
,
icon
:
'
success
'
})
// reset the form
event
.
target
.
reset
()
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment