บันทึกข้อมูลสมัครสอบ

This commit is contained in:
Kittapath 2023-10-02 11:42:21 +07:00
parent 5fbf1bd8bd
commit bc71932976
3 changed files with 58 additions and 16 deletions

View file

@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "vite",
"build": "run-p type-check build-only",
"build": "run-p build-only",
"preview": "vite preview",
"test:unit": "vitest",
"test:e2e": "start-server-and-test preview http://localhost:4173 'cypress run --e2e'",

View file

@ -192,12 +192,13 @@ const okModalConfirm = () => {
modalError($q, 'ไม่สามารถสมัครสอบได้', 'มีข้อมูลที่ยังไม่ถูกบันทึกข้อมูล')
} else {
saveAuto.value = true
modalConfirm(
$q,
'ยืนยันการสมัครสอบ?',
'เมื่อยืนยันการสมัครสอบแล้วจะไม่สามารถแก้ไขข้อมูลได้',
saveData
)
// modalConfirm(
// $q,
// '?',
// '',
// saveData
// )
saveData()
}
}
@ -299,13 +300,13 @@ const saveData = async () => {
.then(async () => {
success($q, 'บันทึกข้อมูลส่วนตัวสำเร็จ')
if (saveAuto.value) await saveForm()
await props.fetchStep()
})
.catch((e) => {
messageError($q, e)
loaderPage(false)
})
.finally(async () => {
await props.fetchStep()
})
.finally(async () => {})
} else {
notifyError($q, 'กรุณากรอกข้อมูลให้ครบถ้วน')
}

View file

@ -232,7 +232,7 @@
</template>
<script setup lang="ts">
import { onMounted, ref, watch } from 'vue'
import { QTableProps, useQuasar } from 'quasar'
import { useQuasar } from 'quasar'
import { useCounterMixin } from '@/stores/mixin'
import { useDataStore } from '@/stores/data'
import http from '@/plugins/http'
@ -301,7 +301,7 @@ examData.career.columns.length == 0
])
: (visibleColumns.value = examData.career.columns)
const columns = ref<QTableProps['columns']>([
const columns = ref<any>([
{
name: 'position',
align: 'left',
@ -385,10 +385,51 @@ watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeExamColumns('career', count)
})
watch(startDate, async (count: Date, prevCount: Date) => {
await calDate()
})
watch(endDate, async (count: Date, prevCount: Date) => {
await calDate()
})
onMounted(async () => {
await fetchData()
})
const calDate = async () => {
let _startDate = new Date(startDate.value.toISOString().substr(0, 10))
let _endDate = new Date(endDate.value.toISOString().substr(0, 10))
if (_startDate > _endDate) {
const swap = _startDate
_startDate = _endDate
_endDate = swap
}
const startYear = _startDate.getFullYear()
const february = (startYear % 4 === 0 && startYear % 100 !== 0) || startYear % 400 === 0 ? 29 : 28
const daysInMonth = [31, february, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
let yearDiff = _endDate.getFullYear() - startYear
let monthDiff = _endDate.getMonth() - _startDate.getMonth()
if (monthDiff < 0) {
yearDiff--
monthDiff += 12
}
let dayDiff = _endDate.getDate() - _startDate.getDate()
if (dayDiff < 0) {
if (monthDiff > 0) {
monthDiff--
} else {
yearDiff--
monthDiff = 11
}
dayDiff += daysInMonth[_startDate.getMonth()]
}
rangeDate.value = `${yearDiff > 0 ? yearDiff + ' ปี ' : ''}${
monthDiff > 0 ? monthDiff + ' เดือน ' : ''
}${dayDiff > 0 ? dayDiff + ' วัน ' : ''}`
}
const fetchData = async () => {
loaderPage(true)
await http
@ -399,8 +440,8 @@ const fetchData = async () => {
data.map((r: any) => {
rows.value.push({
...r,
startDate: r.durationStart,
endDate: r.durationEnd
startDate: new Date(r.durationStart),
endDate: new Date(r.durationEnd)
})
})
})
@ -531,7 +572,7 @@ const saveData = async () => {
org: org.value,
durationStart: dateToISO(new Date(startDate.value)),
durationEnd: dateToISO(new Date(endDate.value)),
rangeDate: rangeDate.value == null ? '-' : rangeDate.value //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
rangeDate: rangeDate.value
})
.then(() => {
success($q, 'บันทึกข้อมูลสำเร็จ')
@ -558,7 +599,7 @@ const editData = async () => {
org: org.value,
durationStart: dateToISO(new Date(startDate.value)),
durationEnd: dateToISO(new Date(endDate.value)),
rangeDate: rangeDate.value == null ? '-' : rangeDate.value //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
rangeDate: rangeDate.value
})
.then(() => {
success($q, 'บันทึกข้อมูลสำเร็จ')