เพิ่ม modal sickform
This commit is contained in:
parent
d69ca225a4
commit
809216c6d8
1 changed files with 190 additions and 200 deletions
|
|
@ -1,20 +1,54 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from "vue";
|
import { ref, reactive, watch } from "vue"
|
||||||
|
import type { FormData } from "../../interface/request/SickForm"
|
||||||
const edit = ref<boolean>(true);
|
import { useCounterMixin } from "@/stores/mixin"
|
||||||
const halfDay = ref<string>("day");
|
|
||||||
|
|
||||||
|
const mixin = useCounterMixin()
|
||||||
|
const { date2Thai } = mixin
|
||||||
|
const edit = ref<boolean>(true)
|
||||||
|
const halfDay = ref<string>("day")
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: {
|
data: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
// ข้อมูลทั้งก้อน form
|
||||||
|
const formData = reactive<FormData>({
|
||||||
|
leaveNo: "",
|
||||||
|
startLeaveDate: null,
|
||||||
|
endLeaveDate: null,
|
||||||
|
contractTel: "",
|
||||||
|
leaveTotal: "",
|
||||||
|
leaveContactTel: "",
|
||||||
|
leaveContactLocation: "",
|
||||||
|
leaveDetail: "",
|
||||||
|
file: null,
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(props.data, async () => {
|
||||||
|
// console.log("data==>", props.data)
|
||||||
|
formData.leaveNo = props.data.leaveNo
|
||||||
|
formData.startLeaveDate = props.data.startLeaveDate
|
||||||
|
formData.endLeaveDate = props.data.endLeaveDate
|
||||||
|
formData.contractTel = props.data.contractTel
|
||||||
|
formData.leaveTotal = props.data.leaveTotal
|
||||||
|
formData.leaveContactTel = props.data.leaveContactTel
|
||||||
|
formData.leaveDetail = props.data.leaveDetail
|
||||||
|
formData.file = props.data.file
|
||||||
|
})
|
||||||
|
const fileDocDataUpload = ref<File[]>([])
|
||||||
|
|
||||||
|
const fileUploadDoc = async (files: any) => {
|
||||||
|
files.forEach((file: any) => {
|
||||||
|
fileDocDataUpload.value.push(file)
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<!-- ลาป่วย ลาคลอดบุตร และลากิจส่วนตัว
|
<!-- ลาป่วย ลาคลอดบุตร และลากิจส่วนตัว
|
||||||
<ul>
|
<ul>
|
||||||
<li>เขียนที่</li>
|
<li>เขียนที่</li>
|
||||||
<li>ลาตั้งแต่วันที่</li>
|
<li>ลาตั้งแต่วันที่</li>
|
||||||
|
|
@ -32,202 +66,158 @@ const props = defineProps({
|
||||||
(อาจดึงมาจากที่อยู่ปัจจุบันโดยอัตโนมัติ แต่ให้ผู้ใช้งานแก้ไขได้)
|
(อาจดึงมาจากที่อยู่ปัจจุบันโดยอัตโนมัติ แต่ให้ผู้ใช้งานแก้ไขได้)
|
||||||
</p> -->
|
</p> -->
|
||||||
|
|
||||||
|
<div class="col-12 row q-col-gutter-md q-pa-md">
|
||||||
|
<div class="col-xs-12 col-sm-12">
|
||||||
|
<q-card bordered class="q-pa-md bg-grey-1">
|
||||||
|
<div class="col-12 row q-pa-sm q-col-gutter-sm">
|
||||||
|
<q-input class="col-12 col-sm-12" dense outlined v-model="formData.leaveNo" label="เขียนที่" :readonly="!edit" :rules="[val => !!val || `${'เขียนที่'}`]" />
|
||||||
|
|
||||||
<q-card bordered class="q-pa-md bg-grey-1">
|
<div class="col-md-4 col-sm-12">
|
||||||
<div class="col-12 row q-pa-sm q-col-gutter-sm">
|
<q-radio v-model="halfDay" val="day" label="ลาทั้งวัน" />
|
||||||
<q-input
|
<q-radio v-model="halfDay" val="half_day_morning" label="ลาครึ่งวันเช้า" />
|
||||||
class="col-12 col-sm-12"
|
<q-radio v-model="halfDay" val="half_day_afternoon" label="ลาครึ่งวันบ่าย" />
|
||||||
dense
|
</div>
|
||||||
outlined
|
|
||||||
v-model="Writeat"
|
|
||||||
label="เขียนที่"
|
|
||||||
:readonly="!edit"
|
|
||||||
:rules="[(val) => !!val || `${'เขียนที่'}`]"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div class="col-md-4 col-sm-12">
|
<datepicker
|
||||||
<q-radio v-model="halfDay" val="day" label="ลาทั้งวัน" />
|
class="col-md-3 col-sm-12"
|
||||||
<q-radio
|
menu-class-name="modalfix"
|
||||||
v-model="halfDay"
|
v-model="formData.startLeaveDate"
|
||||||
val="half_day_morning"
|
:locale="'th'"
|
||||||
label="ลาครึ่งวันเช้า"
|
autoApply
|
||||||
/>
|
borderless
|
||||||
<q-radio
|
:enableTimePicker="false"
|
||||||
v-model="halfDay"
|
week-start="0"
|
||||||
val="half_day_afternoon"
|
:readonly="!edit"
|
||||||
label="ลาครึ่งวันบ่าย"
|
>
|
||||||
/>
|
<template #year="{ year }">
|
||||||
</div>
|
{{ year + 543 }}
|
||||||
|
</template>
|
||||||
|
<template #year-overlay-value="{ value }">
|
||||||
|
{{ parseInt(value + 543) }}
|
||||||
|
</template>
|
||||||
|
<template #trigger>
|
||||||
|
<q-input
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
hide-bottom-space
|
||||||
|
:readonly="!edit"
|
||||||
|
class="full-width datepicker"
|
||||||
|
:model-value="formData.startLeaveDate != null ? date2Thai(formData.startLeaveDate) : null"
|
||||||
|
:label="`${'ลาตั้งแต่วันที่'}`"
|
||||||
|
:rules="[val => !!val || `${'กรุณาเลือกลาตั้งแต่วันที่'}`]"
|
||||||
|
>
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<q-icon name="event" class="cursor-pointer" style="color: var(--q-primary)"> </q-icon>
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
</template>
|
||||||
|
</datepicker>
|
||||||
|
|
||||||
<datepicker
|
<datepicker
|
||||||
class="col-md-3 col-sm-12"
|
class="col-md-3 col-sm-12"
|
||||||
menu-class-name="modalfix"
|
menu-class-name="modalfix"
|
||||||
v-model="dateLeaveStart"
|
v-model="formData.endLeaveDate"
|
||||||
:locale="'th'"
|
:locale="'th'"
|
||||||
autoApply
|
autoApply
|
||||||
borderless
|
borderless
|
||||||
:enableTimePicker="false"
|
:enableTimePicker="false"
|
||||||
week-start="0"
|
week-start="0"
|
||||||
:readonly="!edit"
|
:readonly="!edit"
|
||||||
>
|
>
|
||||||
<template #year="{ year }">
|
<template #year="{ year }">
|
||||||
{{ year + 543 }}
|
{{ year + 543 }}
|
||||||
</template>
|
</template>
|
||||||
<template #year-overlay-value="{ value }">
|
<template #year-overlay-value="{ value }">
|
||||||
{{ parseInt(value + 543) }}
|
{{ parseInt(value + 543) }}
|
||||||
</template>
|
</template>
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<q-input
|
<q-input
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:readonly="!edit"
|
:readonly="!edit"
|
||||||
class="full-width datepicker"
|
class="full-width datepicker"
|
||||||
:model-value="
|
:model-value="formData.endLeaveDate != null ? date2Thai(formData.endLeaveDate) : null"
|
||||||
dateLeaveStart != null ? date2Thai(dateLeaveStart) : null
|
:label="`${'ลาถึงวันที่'}`"
|
||||||
"
|
:rules="[val => !!val || `${'กรุณาเลือกลาถึงวันที่'}`]"
|
||||||
:label="`${'ลาตั้งแต่วันที่'}`"
|
>
|
||||||
:rules="[(val) => !!val || `${'กรุณาเลือกลาตั้งแต่วันที่'}`]"
|
<template v-slot:prepend>
|
||||||
>
|
<q-icon name="event" class="cursor-pointer" style="color: var(--q-primary)"> </q-icon>
|
||||||
<template v-slot:prepend>
|
</template>
|
||||||
<q-icon
|
</q-input>
|
||||||
name="event"
|
</template>
|
||||||
class="cursor-pointer"
|
</datepicker>
|
||||||
style="color: var(--q-primary)"
|
<q-input
|
||||||
>
|
class="col-md-2 col-sm-12"
|
||||||
</q-icon>
|
dense
|
||||||
</template>
|
outlined
|
||||||
</q-input>
|
type="number"
|
||||||
</template>
|
v-model="formData.leaveTotal"
|
||||||
</datepicker>
|
label="จำนวนวันที่ลา"
|
||||||
|
readonly
|
||||||
|
:rules="[val => !!val || `${'กรุณากรอกจำนวนวัน'}`]"
|
||||||
|
/>
|
||||||
|
|
||||||
<datepicker
|
<q-input
|
||||||
class="col-md-3 col-sm-12"
|
class="col-3"
|
||||||
menu-class-name="modalfix"
|
dense
|
||||||
v-model="dateLeaveEnd"
|
outlined
|
||||||
:locale="'th'"
|
v-model="formData.leaveContactTel"
|
||||||
autoApply
|
mask="(###)-###-####"
|
||||||
borderless
|
unmasked-value
|
||||||
:enableTimePicker="false"
|
label="หมายเลขโทรศัพท์ที่ติดต่อได้"
|
||||||
week-start="0"
|
:readonly="!edit"
|
||||||
:readonly="!edit"
|
:rules="[val => !!val || `${'กรุณากรอกหมายเลขโทรศัพท์ที่ติดต่อได้'}`]"
|
||||||
>
|
/>
|
||||||
<template #year="{ year }">
|
|
||||||
{{ year + 543 }}
|
|
||||||
</template>
|
|
||||||
<template #year-overlay-value="{ value }">
|
|
||||||
{{ parseInt(value + 543) }}
|
|
||||||
</template>
|
|
||||||
<template #trigger>
|
|
||||||
<q-input
|
|
||||||
outlined
|
|
||||||
dense
|
|
||||||
hide-bottom-space
|
|
||||||
:readonly="!edit"
|
|
||||||
class="full-width datepicker"
|
|
||||||
:model-value="
|
|
||||||
dateLeaveEnd != null ? date2Thai(dateLeaveEnd) : null
|
|
||||||
"
|
|
||||||
:label="`${'ลาถึงวันที่'}`"
|
|
||||||
:rules="[(val) => !!val || `${'กรุณาเลือกลาถึงวันที่'}`]"
|
|
||||||
>
|
|
||||||
<template v-slot:prepend>
|
|
||||||
<q-icon
|
|
||||||
name="event"
|
|
||||||
class="cursor-pointer"
|
|
||||||
style="color: var(--q-primary)"
|
|
||||||
>
|
|
||||||
</q-icon>
|
|
||||||
</template>
|
|
||||||
</q-input>
|
|
||||||
</template>
|
|
||||||
</datepicker>
|
|
||||||
<q-input
|
|
||||||
class="col-md-2 col-sm-12"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
type="number"
|
|
||||||
v-model="dateTotal"
|
|
||||||
label="จำนวนวันที่ลา"
|
|
||||||
readonly
|
|
||||||
:rules="[(val) => !!val || `${'กรุณากรอกจำนวนวัน'}`]"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
class="col-3"
|
class="col-md-9 col-sm-12"
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
v-model="tel"
|
v-model="formData.leaveContactLocation"
|
||||||
mask="(###)-###-####"
|
label="ที่อยู่ที่ติดต่อได้ระหว่างลา"
|
||||||
unmasked-value
|
:readonly="!edit"
|
||||||
label="หมายเลขโทรศัพท์ที่ติดต่อได้"
|
:rules="[val => !!val || `${'กรุณากรอกที่อยู่ที่ติดต่อได้ระหว่างลา'}`]"
|
||||||
:readonly="!edit"
|
/>
|
||||||
:rules="[
|
|
||||||
(val) => !!val || `${'กรุณากรอกหมายเลขโทรศัพท์ที่ติดต่อได้'}`,
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
class="col-md-9 col-sm-12"
|
type="textarea"
|
||||||
dense
|
class="col-md-12 col-sm-12"
|
||||||
outlined
|
dense
|
||||||
v-model="locationAbsence"
|
outlined
|
||||||
label="ที่อยู่ที่ติดต่อได้ระหว่างลา"
|
v-model="formData.leaveDetail"
|
||||||
:readonly="!edit"
|
label="รายละเอียด"
|
||||||
:rules="[
|
:readonly="!edit"
|
||||||
(val) => !!val || `${'กรุณากรอกที่อยู่ที่ติดต่อได้ระหว่างลา'}`,
|
:rules="[val => !!val || `${'กรุณากรอกรายละเอียด'}`]"
|
||||||
]"
|
/>
|
||||||
/>
|
|
||||||
|
|
||||||
<q-input
|
<q-file v-model="formData.file" @added="fileUploadDoc" dense label="เอกสารประกอบ" outlined use-chips multiple class="q-pl-sm col-6">
|
||||||
type="textarea"
|
<template v-slot:prepend>
|
||||||
class="col-md-12 col-sm-12"
|
<q-icon name="attach_file" color="primary" />
|
||||||
dense
|
</template>
|
||||||
outlined
|
</q-file>
|
||||||
v-model="detail"
|
|
||||||
label="รายละเอียด"
|
|
||||||
:readonly="!edit"
|
|
||||||
:rules="[(val) => !!val || `${'กรุณากรอกรายละเอียด'}`]"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<q-file
|
<div class="col-12 row" v-if="!edit">
|
||||||
v-model="files"
|
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
|
||||||
dense
|
<div class="q-pl-sm text-weight-bold text-dark">เอกสารเพิ่มเติม</div>
|
||||||
label="เอกสารประกอบ"
|
</div>
|
||||||
outlined
|
<q-card bordered flat class="full-width">
|
||||||
use-chips
|
<q-list separator>
|
||||||
multiple
|
<q-item v-for="file in formData.file" :key="file.key" class="q-my-xs">
|
||||||
class="q-pl-sm col-6"
|
<q-item-section>
|
||||||
>
|
<q-item-label class="full-width ellipsis">
|
||||||
<template v-slot:prepend>
|
{{ file.fileName }}
|
||||||
<q-icon name="attach_file" color="primary" />
|
</q-item-label>
|
||||||
</template>
|
|
||||||
</q-file>
|
|
||||||
|
|
||||||
<div class="col-12 row" v-if="!edit">
|
|
||||||
<div
|
|
||||||
class="bg-grey-1 q-pa-sm col-12 row items-center text-primary"
|
|
||||||
>
|
|
||||||
<div class="q-pl-sm text-weight-bold text-dark">
|
|
||||||
เอกสารเพิ่มเติม
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<q-card bordered flat class="full-width">
|
|
||||||
<q-list separator>
|
|
||||||
<q-item v-for="file in files" :key="file.key" class="q-my-xs">
|
|
||||||
<q-item-section>
|
|
||||||
<q-item-label class="full-width ellipsis">
|
|
||||||
{{ file.fileName }}
|
|
||||||
</q-item-label>
|
|
||||||
|
|
||||||
<q-item-label caption> </q-item-label>
|
|
||||||
</q-item-section>
|
|
||||||
</q-item>
|
|
||||||
</q-list>
|
|
||||||
</q-card>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</q-card>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
<q-item-label caption> </q-item-label>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue