From e1020ab6fe9c71d35caa420c301ce20966c16ec8 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 4 Oct 2023 09:46:36 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=95=E0=B9=88=E0=B8=ADapi=E0=B8=AA?= =?UTF-8?q?=E0=B8=A1=E0=B8=B1=E0=B8=84=E0=B8=A3=E0=B8=AA=E0=B8=AD=E0=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/01_exam/components/ExamCard.vue | 6 +- src/modules/01_exam/components/ExamForm.vue | 2 +- .../01_exam/components/Form/Career.vue | 9 +- .../01_exam/components/Form/Information.vue | 172 ++++++++++++------ src/modules/01_exam/views/ExamDetail.vue | 2 +- src/stores/mixin.ts | 43 +++++ 6 files changed, 168 insertions(+), 66 deletions(-) diff --git a/src/modules/01_exam/components/ExamCard.vue b/src/modules/01_exam/components/ExamCard.vue index da9fc9b..3b8028c 100644 --- a/src/modules/01_exam/components/ExamCard.vue +++ b/src/modules/01_exam/components/ExamCard.vue @@ -57,8 +57,8 @@ -
ผลคะแนนสอบ
-
+
ผลคะแนนสอบ
+
ประเภท
คะแนนเต็ม
คะแนนที่ได้
@@ -106,6 +106,8 @@ examResultinscore }}
+
+
ตำแหน่ง
{{ position }} diff --git a/src/modules/01_exam/components/ExamForm.vue b/src/modules/01_exam/components/ExamForm.vue index f7a76c8..2d1488e 100644 --- a/src/modules/01_exam/components/ExamForm.vue +++ b/src/modules/01_exam/components/ExamForm.vue @@ -87,7 +87,7 @@
ชื่อ :
- {{ defaultInformation.firstname }}{{ defaultInformation.firstname }} + {{ defaultInformation.prefix }}{{ defaultInformation.firstname }} {{ defaultInformation.lastname }}
diff --git a/src/modules/01_exam/components/Form/Career.vue b/src/modules/01_exam/components/Form/Career.vue index 0f61a45..696f30a 100644 --- a/src/modules/01_exam/components/Form/Career.vue +++ b/src/modules/01_exam/components/Form/Career.vue @@ -282,7 +282,7 @@ const { loaderPage } = dataStore const id = ref('') const type = ref() -const opType = ref(['ลูกจ้างประจำ','ลูกจ้างชั่วคราว','ผู้ปฏิบัติงานอื่นในกรุงเทพมหานคร']) +const opType = ref(['ลูกจ้างประจำ', 'ลูกจ้างชั่วคราว', 'ผู้ปฏิบัติงานอื่นในกรุงเทพมหานคร']) const position = ref() const group = ref() @@ -334,7 +334,6 @@ const columns = ref([ sort: (a: string, b: string) => a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' }) }, - { name: 'type', align: 'left', @@ -493,6 +492,7 @@ const clickPrevious = async () => { rowIndex.value -= 1 const row = rows.value[rowIndex.value] position.value = row.position + type.value = row.type group.value = row.group pile.value = row.pile org.value = row.org @@ -510,6 +510,7 @@ const clickNext = async () => { rowIndex.value += 1 const row = rows.value[rowIndex.value] position.value = row.position + type.value = row.type group.value = row.group pile.value = row.pile org.value = row.org @@ -600,6 +601,7 @@ const saveData = async () => { await http .post(config.API.candidateCareer(examId.value, positionId.value), { position: position.value, + type: type.value, group: group.value, pile: pile.value, org: org.value, @@ -627,6 +629,7 @@ const editData = async () => { await http .put(config.API.candidateCareer(id.value, ''), { position: position.value, + type: type.value, group: group.value, pile: pile.value, org: org.value, @@ -676,6 +679,7 @@ const selectData = (props: any) => { rawItem.value = props.row rowIndex.value = props.rowIndex position.value = props.row.position + type.value = props.row.type group.value = props.row.group pile.value = props.row.pile org.value = props.row.org @@ -694,6 +698,7 @@ const addRow = () => { modalEdit.value = false modal.value = true position.value = null + type.value = null group.value = null pile.value = null org.value = null diff --git a/src/modules/01_exam/components/Form/Information.vue b/src/modules/01_exam/components/Form/Information.vue index d4aa8fe..e2532dc 100644 --- a/src/modules/01_exam/components/Form/Information.vue +++ b/src/modules/01_exam/components/Form/Information.vue @@ -13,14 +13,33 @@ />
- + +
+ @@ -379,7 +402,7 @@ const emit = defineEmits(['update:form']) const $q = useQuasar() const mixin = useCounterMixin() -const { date2Thai, calAge, success, messageError } = mixin +const { date2Thai, calAge, success, messageError, notifyError, calAgeYear } = mixin const dataStore = useDataStore() const { loaderPage } = dataStore const districtOptions = ref([]) @@ -390,11 +413,12 @@ const edit = ref(true) const myform = ref({}) const img = ref('') const fileProfile = ref([]) +const cardid1 = ref('') +const cardid2 = ref('') const opNat = ref(['ไทย']) const idModel = ref(false) - watch(myform, async (count: any, prevCount: any) => { emit('update:form', count) }) @@ -417,6 +441,7 @@ const fetchData = async () => { .then((res) => { const data = res.data.result defaultInformation.value.prefixId = data.prefixId + selectPrefix() defaultInformation.value.lastname = data.lastName defaultInformation.value.provinceId = data.citizenProvinceId defaultInformation.value.districtId = data.citizenDistrictId @@ -446,6 +471,33 @@ const fetchData = async () => { }) } +const checkCardId = async () => { + if (cardid2.value == cardid1.value) { + idModel.value = false + defaultInformation.value.cardid = cardid2.value + } else { + notifyError($q, 'เลขบัตรไม่ตรงกัน') + } +} +const selectPrefix = async () => { + defaultInformation.value.prefix = + props.prefixOptions.filter((x) => x.id == defaultInformation.value.prefixId).length == 0 + ? '' + : props.prefixOptions.filter((x) => x.id == defaultInformation.value.prefixId)[0].name +} +const selectBirthDate = async () => { + if (defaultInformation.value.birthDate != null) { + console.log(calAgeYear(defaultInformation.value.birthDate)) + if (calAgeYear(defaultInformation.value.birthDate) < 18) { + defaultInformation.value.birthDate = null + notifyError($q, 'อายุไม่ถึง18') + } else if (calAgeYear(defaultInformation.value.birthDate) > 60) { + defaultInformation.value.birthDate = null + notifyError($q, 'อายุเกิน60') + } + } +} + const fetchImgData = async () => { loaderPage(true) await http diff --git a/src/modules/01_exam/views/ExamDetail.vue b/src/modules/01_exam/views/ExamDetail.vue index ec47849..b5ebfac 100644 --- a/src/modules/01_exam/views/ExamDetail.vue +++ b/src/modules/01_exam/views/ExamDetail.vue @@ -7,7 +7,7 @@ {{ `ครั้งที่${round}/${yearly == null ? '' : yearly + 543}` }}
- {{ position }}{{ positionLevel == null ? null : '/' + positionLevel }} + {{ position }}
diff --git a/src/stores/mixin.ts b/src/stores/mixin.ts index 1681cc6..4ed8cc6 100644 --- a/src/stores/mixin.ts +++ b/src/stores/mixin.ts @@ -61,6 +61,48 @@ export const useCounterMixin = defineStore('mixin', () => { return `${yearAge} ${year} ${monthAge} ${month} ${dateAge} ${day}` } + const calAgeYear = (srcDate: Date, birthCal: Date = new Date()) => { + const toDay = birthCal + const birth = new Date(srcDate) + + const yearNow = toDay.getFullYear() + const monthNow = toDay.getMonth() + const dateNow = toDay.getDate() + + const yearDob = birth.getFullYear() + const monthDob = birth.getMonth() + const dateDob = birth.getDate() + + const lastYear = 12 + const subtractDate: Object = moment().subtract(1, 'months').endOf('month') + + const lastMonths = new Date(subtractDate.toString()).getDate() + + let yearAge = yearNow - yearDob + let monthAge = 0 + let dateAge = 0 + + if (monthNow >= monthDob) { + monthAge = monthNow - monthDob + } else { + yearAge-- + monthAge = lastYear + monthNow - monthDob + } + + if (dateNow >= dateDob) { + dateAge = dateNow - dateDob + } else { + monthAge-- + dateAge = lastMonths + dateNow - dateDob + + if (monthAge < 0) { + monthAge = 11 + yearAge-- + } + } + return yearAge + } + function date2Thai(srcDate: Date, isFullMonth: boolean = false, isTime: boolean = false) { const date = new Date(srcDate) const isValidDate = Boolean(+date) @@ -496,6 +538,7 @@ export const useCounterMixin = defineStore('mixin', () => { return { calAge, + calAgeYear, date2Thai, dateToISO, notify,