ปรับ ui สรรหาสอบคัดเลือก
This commit is contained in:
parent
e3aa1d8221
commit
5fbf1bd8bd
11 changed files with 836 additions and 1200 deletions
|
|
@ -1,302 +1,243 @@
|
|||
<!-- tab ประวัติการศึกษา -->
|
||||
<!-- card วุฒิที่ใช้สมัครสอบ -->
|
||||
<template>
|
||||
<q-form ref="myForm">
|
||||
<Table
|
||||
:rows="rows"
|
||||
:columns="columns"
|
||||
:filter="filter"
|
||||
:visible-columns="visibleColumns"
|
||||
v-model:inputfilter="filter"
|
||||
v-model:inputvisible="visibleColumns"
|
||||
v-model:editvisible="edit"
|
||||
:add="clickAdd"
|
||||
:edit="clickEdit"
|
||||
:addData="false"
|
||||
:editData="status == 'register' || status == 'rejectRegister'"
|
||||
name="ประวัติการศีกษา"
|
||||
icon="mdi-school"
|
||||
>
|
||||
<template #columns="props">
|
||||
<q-tr :props="props">
|
||||
<q-td
|
||||
v-for="col in props.cols"
|
||||
:key="col.name"
|
||||
:props="props"
|
||||
@click="selectData(props)"
|
||||
class="cursor-pointer"
|
||||
<HeaderTop
|
||||
v-model:edit="edit"
|
||||
header="วุฒิที่ใช้สมัครสอบ"
|
||||
icon="mdi-briefcase"
|
||||
:addData="true"
|
||||
:editOnly="false"
|
||||
:editData="false"
|
||||
/>
|
||||
<q-form ref="myform">
|
||||
<div class="row col-12 items-center q-col-gutter-x-sm q-col-gutter-y-xs">
|
||||
<div class="col-12 row">
|
||||
<div class="col-3">
|
||||
<q-select
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
emit-value
|
||||
map-options
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
:options="educationLevelOptions"
|
||||
v-model="defaultEducation.educationLevelExamId"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือก วุฒิที่ใช้สมัครสอบ'}`]"
|
||||
:label="`${'วุฒิที่ใช้สมัครสอบ'}`"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<q-input
|
||||
class="q-pl-sm"
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
autogrow
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
v-model="defaultEducation.educationName"
|
||||
:rules="[(val) => !!val || `${'กรุณากรอก ชื่อปริญญา'}`]"
|
||||
:label="`${'ชื่อปริญญา'}`"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<q-input
|
||||
class="q-pl-sm"
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
autogrow
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
v-model="defaultEducation.educationMajor"
|
||||
:rules="[(val) => !!val || `${'กรุณากรอก สาขาวิชา/วิชาเอก'}`]"
|
||||
:label="`${'สาขาวิชา/วิชาเอก'}`"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 row">
|
||||
<div class="col-3">
|
||||
<q-input
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
autogrow
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
v-model="defaultEducation.educationLocation"
|
||||
:rules="[(val) => !!val || `${'กรุณากรอก ชื่อสถานศึกษา'}`]"
|
||||
:label="`${'ชื่อสถานศึกษา'}`"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<q-select
|
||||
class="q-pl-sm"
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
emit-value
|
||||
map-options
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
:options="educationTypeOptions"
|
||||
v-model="defaultEducation.educationType"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือก ประเภทสถานศึกษา'}`]"
|
||||
:label="`${'ประเภทสถานศึกษา'}`"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<datepicker
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
v-model="defaultEducation.educationEndDate"
|
||||
:locale="'th'"
|
||||
autoApply
|
||||
:enableTimePicker="false"
|
||||
week-start="0"
|
||||
:max-date="new Date()"
|
||||
:disabled="!(status == 'register' || status == 'rejectRegister')"
|
||||
>
|
||||
<div v-if="col.name == 'duration'" class="">
|
||||
{{ dateThaiRange(col.value) }}
|
||||
</div>
|
||||
<div v-else class="">
|
||||
{{ col.value }}
|
||||
</div>
|
||||
</q-td>
|
||||
<q-td auto-width v-if="edit === true">
|
||||
<q-btn
|
||||
color="red"
|
||||
flat
|
||||
dense
|
||||
round
|
||||
size="14px"
|
||||
icon="mdi-trash-can-outline"
|
||||
@click="checkDelete(props.row)"
|
||||
/>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</Table>
|
||||
</q-form>
|
||||
<q-dialog v-model="modal" persistent>
|
||||
<q-card style="width: 600px">
|
||||
<q-form ref="myForm">
|
||||
<DialogHeader tittle="ประวัติการศึกษา" :close="checkClose" />
|
||||
<q-separator />
|
||||
<q-card-section class="q-p-sm">
|
||||
<div class="row col-12 items-center q-col-gutter-x-xs q-col-gutter-y-xs">
|
||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||
<q-select
|
||||
:class="getClass(edit)"
|
||||
:outlined="edit"
|
||||
dense
|
||||
lazy-rules
|
||||
:readonly="!edit"
|
||||
:borderless="!edit"
|
||||
v-model="educationLevelId"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกวุฒิที่ได้รับ'}`]"
|
||||
:label="`${'วุฒิที่ได้รับ'}`"
|
||||
@update:modelValue="clickEditRow"
|
||||
emit-value
|
||||
map-options
|
||||
option-label="name"
|
||||
:options="educationLevelOptions"
|
||||
option-value="id"
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||
<template #year="{ year }">
|
||||
{{ year + 543 }}
|
||||
</template>
|
||||
<template #year-overlay-value="{ value }">
|
||||
{{ parseInt(value + 543) }}
|
||||
</template>
|
||||
<template #trigger>
|
||||
<q-input
|
||||
:class="getClass(edit)"
|
||||
:outlined="edit"
|
||||
class="q-pl-sm"
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
:readonly="!edit"
|
||||
:borderless="!edit"
|
||||
v-model="major"
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกสาขาวิชา/วิชาเอก'}`]"
|
||||
:label="`${'สาขาวิชา/วิชาเอก'}`"
|
||||
@update:modelValue="clickEditRow"
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
:model-value="date2Thai(defaultEducation.educationEndDate)"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกวันที่สำเร็จการศึกษา'}`]"
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||
<q-input
|
||||
type="number"
|
||||
:class="getClass(edit)"
|
||||
:outlined="edit"
|
||||
dense
|
||||
lazy-rules
|
||||
:readonly="!edit"
|
||||
:borderless="!edit"
|
||||
v-model="scores"
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกคะแนนเฉลี่ยตลอดหลักสูตร'}`]"
|
||||
:label="`${'คะแนนเฉลี่ยตลอดหลักสูตร'}`"
|
||||
@update:modelValue="clickEditRow"
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||
<q-input
|
||||
:class="getClass(edit)"
|
||||
:outlined="edit"
|
||||
dense
|
||||
lazy-rules
|
||||
:readonly="!edit"
|
||||
:borderless="!edit"
|
||||
v-model="name"
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกชื่อสถานศึกษา'}`]"
|
||||
:label="`${'ชื่อสถานศึกษา'}`"
|
||||
@update:modelValue="clickEditRow"
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||
<datepicker
|
||||
menu-class-name="modalfix"
|
||||
:readonly="!edit"
|
||||
v-model="duration"
|
||||
:locale="'th'"
|
||||
autoApply
|
||||
range
|
||||
:enableTimePicker="false"
|
||||
week-start="0"
|
||||
:label="`${'วันที่สำเร็จการศึกษา'}`"
|
||||
>
|
||||
<template #year="{ year }">
|
||||
{{ year + 543 }}
|
||||
</template>
|
||||
<template #year-overlay-value="{ value }">
|
||||
{{ parseInt(value + 543) }}
|
||||
</template>
|
||||
<template #trigger>
|
||||
<q-input
|
||||
:class="getClass(edit)"
|
||||
class="datepicker"
|
||||
:outlined="edit"
|
||||
dense
|
||||
lazy-rules
|
||||
:borderless="!edit"
|
||||
:model-value="dateThaiRange(duration)"
|
||||
hide-bottom-space
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
name="event"
|
||||
class="cursor-pointer"
|
||||
:style="
|
||||
status == 'register' || status == 'rejectRegister'
|
||||
? 'color: var(--q-primary)'
|
||||
: 'color: var(--q-grey)'
|
||||
"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
name="mdi-calendar-outline"
|
||||
class="cursor-pointer"
|
||||
style="color: var(--q-primary)"
|
||||
>
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</q-icon>
|
||||
</template>
|
||||
</datepicker>
|
||||
</div>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-separator />
|
||||
<DialogFooter
|
||||
:edit="clickEdit"
|
||||
:save="clickSave"
|
||||
:validate="validateData"
|
||||
:clickNext="clickNext"
|
||||
:clickPrevious="clickPrevious"
|
||||
:editData="status == 'register' || status == 'rejectRegister'"
|
||||
v-model:editvisible="edit"
|
||||
v-model:next="next"
|
||||
v-model:previous="previous"
|
||||
v-model:modalEdit="modalEdit"
|
||||
/>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</q-input>
|
||||
</template>
|
||||
</datepicker>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<q-input
|
||||
class="q-pl-sm"
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
type="number"
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
v-model="defaultEducation.educationScores"
|
||||
:rules="[(val) => !!val || `${'กรุณากรอก คะแนนเฉลี่ยสะสม'}`]"
|
||||
:label="`${'คะแนนเฉลี่ยสะสม'}`"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 row">
|
||||
<div class="col-3">
|
||||
<q-select
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
emit-value
|
||||
map-options
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
:options="educationLevelOptions"
|
||||
v-model="defaultEducation.educationLevelHighId"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือก วุฒิการศึกษาสูงสุด'}`]"
|
||||
:label="`${'วุฒิการศึกษาสูงสุด'}`"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</q-form>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch } from 'vue'
|
||||
import type { PropType } from 'vue'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { useCounterMixin } from '@/stores/mixin'
|
||||
import { useDataStore } from '@/stores/data'
|
||||
import { ref, onMounted, watch, PropType } from 'vue'
|
||||
import http from '@/plugins/http'
|
||||
import config from '@/app.config'
|
||||
import { useExamDataStore } from '@/modules/01_exam/store'
|
||||
import type { DataOption, Education } from '@/modules/01_exam/interface/index/Main'
|
||||
import { defaultEducation, changeData } from '@/modules/01_exam/interface/index/Main'
|
||||
import HeaderTop from '@/components/top.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import type {
|
||||
RequestItemsObject,
|
||||
Columns,
|
||||
DataProps
|
||||
} from '@/modules/01_exam/interface/request/Education'
|
||||
import type { DataOption } from '@/modules/01_exam/interface/index/Main'
|
||||
import type { ResponseObject } from '@/modules/01_exam/interface/response/Education'
|
||||
import Table from '@/components/Table.vue'
|
||||
import DialogHeader from '@/components/DialogHeader.vue'
|
||||
import DialogFooter from '@/components/DialogFooter.vue'
|
||||
|
||||
import { useCounterMixin } from '@/stores/mixin'
|
||||
import { useDataStore } from '@/stores/data'
|
||||
import { useQuasar } from 'quasar'
|
||||
|
||||
const props = defineProps({
|
||||
educationLevelOptions: {
|
||||
type: Array as PropType<DataOption[]>,
|
||||
required: true
|
||||
},
|
||||
status: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
form: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
educationLevelOptions: {
|
||||
type: Array as PropType<DataOption[]>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const $q = useQuasar()
|
||||
const mixin = useCounterMixin() //เรียกฟังก์ชันกลาง
|
||||
const { dateThaiRange, modalDelete, modalConfirm, dateToISO, success, messageError } = mixin
|
||||
const store = useExamDataStore()
|
||||
const { examData, changeExamColumns } = store
|
||||
const dataStore = useDataStore()
|
||||
const { loaderPage } = dataStore
|
||||
const id = ref<string>('')
|
||||
const educationLevel = ref<string>()
|
||||
const educationLevelId = ref<string>()
|
||||
const major = ref<string>()
|
||||
const scores = ref<number | null>()
|
||||
const name = ref<string>()
|
||||
const duration = ref<[Date, Date]>([new Date(), new Date()])
|
||||
const myForm = ref<any>() //form data input
|
||||
const edit = ref<boolean>(true) //เช็คการกดปุ่มแก้ไขใน dialog
|
||||
const modal = ref<boolean>(false) //modal add detail
|
||||
const modalEdit = ref<boolean>(false) //modal ที่แสดงใช้สำหรับแก้ไขหรือไม่
|
||||
const rawItem = ref<RequestItemsObject>() //ข้อมูลเดิมที่เลือกใน row นั้น
|
||||
const rowIndex = ref<number>(0) //indexข้อมูลเดิมที่เลือกใน row นั้น
|
||||
const previous = ref<boolean>() //แสดงปุ่มดูข้อมูลก่อนหน้า
|
||||
const next = ref<boolean>() //แสดงปุ่มดูข้อมูลต่อไป
|
||||
const editRow = ref<boolean>(false) //เช็คมีการแก้ไขข้อมูล
|
||||
const checkValidate = ref<boolean>(false) //validate data ผ่านหรือไม่
|
||||
const rows = ref<RequestItemsObject[]>([])
|
||||
const edit = ref<boolean>(true)
|
||||
const myform = ref<any>({})
|
||||
const route = useRoute()
|
||||
const examId = ref<string>(route.params.id.toString())
|
||||
const positionId = ref<string>(route.params.positionId.toString())
|
||||
const filter = ref<string>('') //search data table
|
||||
|
||||
const visibleColumns = ref<String[]>([])
|
||||
|
||||
examData.education.columns.length == 0
|
||||
? (visibleColumns.value = ['educationLevel', 'major', 'scores', 'name', 'duration'])
|
||||
: (visibleColumns.value = examData.education.columns)
|
||||
|
||||
const columns = ref<Columns>([
|
||||
const educationTypeOptions = ref<any>([
|
||||
{
|
||||
name: 'educationLevel',
|
||||
align: 'left',
|
||||
label: 'วุฒิที่ได้รับ',
|
||||
sortable: true,
|
||||
field: 'educationLevel',
|
||||
headerStyle: 'font-size: 14px',
|
||||
style: 'font-size: 14px'
|
||||
name: 'รัฐบาล',
|
||||
id: 'รัฐบาล'
|
||||
},
|
||||
{
|
||||
name: 'major',
|
||||
align: 'left',
|
||||
label: 'สาขาวิชา/วิชาเอก',
|
||||
sortable: true,
|
||||
field: 'major',
|
||||
headerStyle: 'font-size: 14px',
|
||||
style: 'font-size: 14px'
|
||||
},
|
||||
{
|
||||
name: 'scores',
|
||||
align: 'left',
|
||||
label: 'คะแนนเฉลี่ยตลอดหลักสูตร',
|
||||
sortable: true,
|
||||
field: 'scores',
|
||||
headerStyle: 'font-size: 14px',
|
||||
style: 'font-size: 14px'
|
||||
},
|
||||
{
|
||||
name: 'name',
|
||||
align: 'left',
|
||||
label: 'ชื่อสถานศึกษา',
|
||||
sortable: true,
|
||||
field: 'name',
|
||||
headerStyle: 'font-size: 14px',
|
||||
style: 'font-size: 14px'
|
||||
},
|
||||
{
|
||||
name: 'duration',
|
||||
align: 'left',
|
||||
label: 'ระยะเวลา',
|
||||
sortable: true,
|
||||
field: 'duration',
|
||||
headerStyle: 'font-size: 14px',
|
||||
style: 'font-size: 14px'
|
||||
name: 'เอกชน',
|
||||
id: 'เอกชน'
|
||||
}
|
||||
])
|
||||
|
||||
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
|
||||
await changeExamColumns('education', count)
|
||||
const mixin = useCounterMixin()
|
||||
const { messageError, date2Thai } = mixin
|
||||
const dataStore = useDataStore()
|
||||
const { loaderPage } = dataStore
|
||||
|
||||
const emit = defineEmits(['update:form'])
|
||||
|
||||
watch(myform, async (count: any, prevCount: any) => {
|
||||
emit('update:form', count)
|
||||
})
|
||||
|
||||
watch(defaultEducation, async (count: Education, prevCount: Education) => {
|
||||
await changeData('education', count)
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
|
|
@ -309,15 +250,14 @@ const fetchData = async () => {
|
|||
.get(config.API.candidateEducation(examId.value, positionId.value))
|
||||
.then((res) => {
|
||||
const data = res.data.result
|
||||
rows.value = []
|
||||
data.map((r: ResponseObject) => {
|
||||
rows.value.push({
|
||||
...r,
|
||||
educationLevelId: r.educationLevelId,
|
||||
educationLevel: r.educationLevelName,
|
||||
duration: [r.durationStart, r.durationEnd]
|
||||
})
|
||||
})
|
||||
defaultEducation.value.educationLevelExamId = data.educationLevelExamId
|
||||
defaultEducation.value.educationName = data.educationName
|
||||
defaultEducation.value.educationMajor = data.educationMajor
|
||||
defaultEducation.value.educationLocation = data.educationLocation
|
||||
defaultEducation.value.educationType = data.educationType
|
||||
defaultEducation.value.educationEndDate = new Date(data.educationEndDate)
|
||||
defaultEducation.value.educationScores = data.educationScores
|
||||
defaultEducation.value.educationLevelHighId = data.educationLevelHighId
|
||||
})
|
||||
.catch((e) => {
|
||||
// messageError($q, e)
|
||||
|
|
@ -327,239 +267,6 @@ const fetchData = async () => {
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* กดดูข้อมูลก่อนหน้า
|
||||
*/
|
||||
const clickPrevious = async () => {
|
||||
rowIndex.value -= 1
|
||||
const row = rows.value[rowIndex.value]
|
||||
educationLevel.value = row.educationLevel
|
||||
educationLevelId.value = row.educationLevelId
|
||||
major.value = row.major
|
||||
scores.value = row.scores
|
||||
name.value = row.name
|
||||
duration.value = row.duration
|
||||
id.value = row.id
|
||||
await checkRowPage()
|
||||
}
|
||||
|
||||
/**
|
||||
* กดดูข้อมูลต่อไป
|
||||
*/
|
||||
const clickNext = async () => {
|
||||
rowIndex.value += 1
|
||||
const row = rows.value[rowIndex.value]
|
||||
educationLevel.value = row.educationLevel
|
||||
educationLevelId.value = row.educationLevelId
|
||||
major.value = row.major
|
||||
scores.value = row.scores
|
||||
name.value = row.name
|
||||
duration.value = row.duration
|
||||
id.value = row.id
|
||||
await checkRowPage()
|
||||
}
|
||||
|
||||
/**
|
||||
* เช็คปุ่มดูข้อมูล ย้อน กับ ต่อไป ว่าต้องแสดงไหม
|
||||
*/
|
||||
const checkRowPage = () => {
|
||||
editRow.value = false
|
||||
next.value = true
|
||||
previous.value = true
|
||||
if (rowIndex.value + 1 >= rows.value.length) {
|
||||
next.value = false
|
||||
}
|
||||
if (rowIndex.value - 1 < 0) {
|
||||
previous.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* กดปุ่มแก้ไขใน dialog
|
||||
*/
|
||||
const clickEdit = () => {
|
||||
next.value = false
|
||||
previous.value = false
|
||||
}
|
||||
|
||||
/**
|
||||
* กดปุ่มเพิ่มด้านบน table
|
||||
*/
|
||||
const clickAdd = async () => {
|
||||
await addRow()
|
||||
}
|
||||
|
||||
const checkDelete = (row: RequestItemsObject) => {
|
||||
rawItem.value = row
|
||||
modalDelete($q, 'ยืนยันการลบข้อมูล', 'หากต้องการลบกดให้กดตกลง', clickDeleteRow)
|
||||
}
|
||||
|
||||
/**
|
||||
* ลบข้อมูลใน table
|
||||
*/
|
||||
const clickDeleteRow = async () => {
|
||||
if (rawItem.value != null) {
|
||||
loaderPage(true)
|
||||
await http
|
||||
.delete(config.API.candidateEducation(rawItem.value.id, ''))
|
||||
.then(() => {
|
||||
success($q, 'ลบข้อมูลสำเร็จ')
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e)
|
||||
})
|
||||
.finally(async () => {
|
||||
await fetchData()
|
||||
})
|
||||
} else {
|
||||
await fetchData()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* กดบันทึกใน dialog
|
||||
*/
|
||||
const clickSave = async () => {
|
||||
myForm.value.validate().then(async (result: boolean) => {
|
||||
if (result) {
|
||||
if (modalEdit.value) {
|
||||
await editData()
|
||||
} else {
|
||||
await saveData()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* บันทึกเพิ่มข้อมูล
|
||||
*/
|
||||
const saveData = async () => {
|
||||
loaderPage(true)
|
||||
await http
|
||||
.post(config.API.candidateEducation(examId.value, positionId.value), {
|
||||
educationLevelId: educationLevelId.value,
|
||||
major: major.value,
|
||||
scores: scores.value,
|
||||
name: name.value,
|
||||
durationStart: dateToISO(new Date(duration.value[0])),
|
||||
durationEnd: dateToISO(new Date(duration.value[1]))
|
||||
})
|
||||
.then(() => {
|
||||
success($q, 'บันทึกข้อมูลสำเร็จ')
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e)
|
||||
})
|
||||
.finally(async () => {
|
||||
modal.value = false
|
||||
await fetchData()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* บันทึกแก้ไขข้อมูล
|
||||
*/
|
||||
const editData = async () => {
|
||||
loaderPage(true)
|
||||
await http
|
||||
.put(config.API.candidateEducation(id.value, ''), {
|
||||
educationLevelId: educationLevelId.value,
|
||||
major: major.value,
|
||||
scores: scores.value,
|
||||
name: name.value,
|
||||
durationStart: dateToISO(new Date(duration.value[0])),
|
||||
durationEnd: dateToISO(new Date(duration.value[1]))
|
||||
})
|
||||
.then(() => {
|
||||
success($q, 'บันทึกข้อมูลสำเร็จ')
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e)
|
||||
})
|
||||
.finally(async () => {
|
||||
modal.value = false
|
||||
await fetchData()
|
||||
})
|
||||
}
|
||||
|
||||
const checkClose = async () => {
|
||||
if (editRow.value == true) {
|
||||
modalConfirm($q, 'ข้อมูลมีการแก้ไข', 'ยืนยันการดำเนินต่อใช่หรือไม่', clickClose)
|
||||
} else {
|
||||
await clickClose()
|
||||
}
|
||||
await fetchData()
|
||||
}
|
||||
|
||||
/**
|
||||
* กดปิด dialog
|
||||
*/
|
||||
const clickClose = async () => {
|
||||
modal.value = false
|
||||
editRow.value = false
|
||||
next.value = false
|
||||
previous.value = false
|
||||
}
|
||||
|
||||
/**
|
||||
* กดเลือกข้อมูลที่จะแก้ไข
|
||||
* @param props ค่า props ใน row ที่เลือก
|
||||
*/
|
||||
const selectData = (props: DataProps) => {
|
||||
modalEdit.value = true
|
||||
modal.value = true
|
||||
editRow.value = false
|
||||
rawItem.value = props.row
|
||||
rowIndex.value = props.rowIndex
|
||||
educationLevel.value = props.row.educationLevel
|
||||
educationLevelId.value = props.row.educationLevelId
|
||||
major.value = props.row.major
|
||||
scores.value = props.row.scores
|
||||
name.value = props.row.name
|
||||
duration.value = props.row.duration
|
||||
id.value = props.row.id
|
||||
next.value = false
|
||||
previous.value = false
|
||||
}
|
||||
|
||||
/**
|
||||
* กดปุ่มเพิ่มบน table
|
||||
*/
|
||||
const addRow = () => {
|
||||
modalEdit.value = false
|
||||
modal.value = true
|
||||
educationLevel.value = ''
|
||||
educationLevelId.value = ''
|
||||
major.value = ''
|
||||
scores.value = null
|
||||
name.value = ''
|
||||
duration.value = [new Date(), new Date()]
|
||||
}
|
||||
|
||||
/**
|
||||
* เช็คว่ามีการแก้ไขข้อมูล
|
||||
*/
|
||||
const clickEditRow = () => {
|
||||
editRow.value = true
|
||||
}
|
||||
|
||||
/**
|
||||
* validate input ใน dialog
|
||||
*/
|
||||
const validateData = async () => {
|
||||
checkValidate.value = true
|
||||
await myForm.value.validate().then((result: boolean) => {
|
||||
if (result == false) {
|
||||
checkValidate.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* class จัดรูปแบบแสดงระหว่างข้อมูลที่แก้ไขหรือแสดงเฉยๆ
|
||||
* @param val ข้อมูล input สำหรับแก้ไขหรือไม่
|
||||
*/
|
||||
const getClass = (val: boolean) => {
|
||||
return {
|
||||
'full-width inputgreen cursor-pointer': val,
|
||||
|
|
@ -567,8 +274,3 @@ const getClass = (val: boolean) => {
|
|||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.modalfix {
|
||||
position: fixed !important;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue