diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1d08b4d..ec0b6fc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -66,21 +66,21 @@ jobs: docker-compose pull docker-compose up -d echo "${{ steps.gen_ver.outputs.image_ver }}"> success - - uses: snow-actions/line-notify@v1.1.0 - if: success() - with: - access_token: ${{ env.TOKEN_LINE }} - message: | - -Success✅✅✅ - Image: ${{env.IMAGE_NAME}} - Version: ${{ github.event.inputs.IMAGE_VER }} - By: ${{secrets.DOCKER_USER}} - - uses: snow-actions/line-notify@v1.1.0 - if: failure() - with: - access_token: ${{ env.TOKEN_LINE }} - message: | - -Failure❌❌❌ - Image: ${{env.IMAGE_NAME}} - Version: ${{ github.event.inputs.IMAGE_VER }} - By: ${{secrets.DOCKER_USER}} + # - uses: snow-actions/line-notify@v1.1.0 + # if: success() + # with: + # access_token: ${{ env.TOKEN_LINE }} + # message: | + # -Success✅✅✅ + # Image: ${{env.IMAGE_NAME}} + # Version: ${{ github.event.inputs.IMAGE_VER }} + # By: ${{secrets.DOCKER_USER}} + # - uses: snow-actions/line-notify@v1.1.0 + # if: failure() + # with: + # access_token: ${{ env.TOKEN_LINE }} + # message: | + # -Failure❌❌❌ + # Image: ${{env.IMAGE_NAME}} + # Version: ${{ github.event.inputs.IMAGE_VER }} + # By: ${{secrets.DOCKER_USER}} diff --git a/src/api/exam/api.metadata.ts b/src/api/exam/api.metadata.ts index b8d6209..77ccfed 100644 --- a/src/api/exam/api.metadata.ts +++ b/src/api/exam/api.metadata.ts @@ -1,18 +1,10 @@ import env from '../index' -const prefix = `${env.API_URI}/metadata/prefix/` -const religion = `${env.API_URI}/metadata/religion/` -const relationship = `${env.API_URI}/metadata/relationship/` -const educationLevel = `${env.API_URI}/metadata/education-level/` -const province = `${env.API_URI}/metadata/province/` +const person = `${env.API_URI}/metadata/main/` const district = `${env.API_URI}/metadata/district/` const subDistrict = `${env.API_URI}/metadata/sub-district/` export default { - prefix, - religion, - relationship, - educationLevel, - province, + person: `${person}person`, listDistrict: (id: string) => `${district}${id}`, listSubDistrict: (id: string) => `${subDistrict}${id}` } diff --git a/src/api/index.ts b/src/api/index.ts index 79932ae..2a454bc 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -3,16 +3,11 @@ import { ref } from 'vue' const env = ref(process.env.NODE_ENV || 'development') export const apiUrlConfig = import.meta.env.VITE_API_URI_CONFIG -console.log(apiUrlConfig) -// if (process.env.VUE_APP_TEST) { -// env = "test"; -// } const config = ref({ development: { // API_URI: 'https://localhost:7007/api/v1', API_URI: apiUrlConfig, - // API_METADATA_URI: 'https://bma-ehr.frappet.synology.me/api/v1/metadata', MEET_URI: 'meet.frappet.com' }, test: { @@ -22,19 +17,16 @@ const config = ref({ production: { // API_URI: "https://localhost:5010", API_URI: apiUrlConfig, - // API_METADATA_URI: 'https://bma-ehr.frappet.synology.me/api/v1/metadata', MEET_URI: 'meet.frappet.com' } }) const API_URI = ref(config.value[env.value].API_URI) -// const API_METADATA_URI = ref(config.value[env.value].API_METADATA_URI) const MEET_URI = ref(config.value[env.value].MEET_URI) export default { env: env.value, config: config.value, API_URI: API_URI.value, - // API_METADATA_URI: API_METADATA_URI.value, MEET_URI: MEET_URI.value } diff --git a/src/components/CustomDialog.vue b/src/components/CustomDialog.vue new file mode 100644 index 0000000..953a124 --- /dev/null +++ b/src/components/CustomDialog.vue @@ -0,0 +1,62 @@ + + + diff --git a/src/components/DialogFooter.vue b/src/components/DialogFooter.vue index 4bda154..525353e 100644 --- a/src/components/DialogFooter.vue +++ b/src/components/DialogFooter.vue @@ -32,18 +32,6 @@ แก้ไขข้อมูล
- diff --git a/src/components/NotifyConfirm.vue b/src/components/NotifyConfirm.vue deleted file mode 100644 index a5e953b..0000000 --- a/src/components/NotifyConfirm.vue +++ /dev/null @@ -1,86 +0,0 @@ - - - diff --git a/src/components/NotifyDelete.vue b/src/components/NotifyDelete.vue deleted file mode 100644 index a5e953b..0000000 --- a/src/components/NotifyDelete.vue +++ /dev/null @@ -1,86 +0,0 @@ - - - diff --git a/src/components/NotifyError.vue b/src/components/NotifyError.vue deleted file mode 100644 index 64f3069..0000000 --- a/src/components/NotifyError.vue +++ /dev/null @@ -1,79 +0,0 @@ - - - diff --git a/src/components/Table.vue b/src/components/Table.vue index 7c740b6..52e85d0 100644 --- a/src/components/Table.vue +++ b/src/components/Table.vue @@ -12,12 +12,6 @@ :editOnly="false" :editData="editData" /> - -
@@ -90,15 +84,6 @@ import { ref, useAttrs, watch } from 'vue' import HeaderTop from '@/components/top.vue' import type { Pagination } from '@/modules/01_exam/interface/index/Main' -const attrs = ref(useAttrs()) -const table = ref(null) -const filterRef = ref(null) -const editBtn = ref(true) -const initialPagination = ref({ - // descending: false, - rowsPerPage: 0 -}) - const props = defineProps({ inputfilter: String, name: String, @@ -135,13 +120,18 @@ const props = defineProps({ const emit = defineEmits(['update:inputfilter', 'update:inputvisible', 'update:editvisible']) +const attrs = ref(useAttrs()) +const table = ref(null) +const filterRef = ref(null) +const editBtn = ref(true) +const initialPagination = ref({ + rowsPerPage: 0 +}) + watch(props, (count: any, prevCount: any) => { editBtn.value = props.editvisible }) -const updateEdit = (value: Boolean) => { - emit('update:editvisible', value) -} const updateInput = (value: string | number | null) => { emit('update:inputfilter', value) } @@ -154,27 +144,14 @@ const paginationLabel = (start: string, end: string, total: string) => { } const clickAdd = () => { - // props.validate(); props.add() } const clickEdit = () => { - // props.validate(); props.edit() } const clickCancel = () => { - // props.validate(); - props.cancel() -} - -const edit = async () => { - updateEdit(!props.editvisible) - props.edit() -} - -const cancel = async () => { - updateEdit(!props.editvisible) props.cancel() } @@ -183,10 +160,6 @@ const resetFilter = () => { emit('update:inputfilter', '') filterRef.value.focus() } - -const add = () => { - props.add() -} diff --git a/src/components/TheWelcome.vue b/src/components/TheWelcome.vue deleted file mode 100644 index a70765c..0000000 --- a/src/components/TheWelcome.vue +++ /dev/null @@ -1,86 +0,0 @@ - - - diff --git a/src/components/WelcomeItem.vue b/src/components/WelcomeItem.vue deleted file mode 100644 index ba0def3..0000000 --- a/src/components/WelcomeItem.vue +++ /dev/null @@ -1,86 +0,0 @@ - - - diff --git a/src/components/top.vue b/src/components/top.vue index d1a538a..62b20a7 100644 --- a/src/components/top.vue +++ b/src/components/top.vue @@ -8,18 +8,6 @@
- บันทึกข้อมูล -
- เพิ่มข้อมูล -
@@ -122,43 +76,11 @@ const props = defineProps({ save: { type: Function, default: () => console.log('not function') - }, - deleted: { - type: Function, - default: () => console.log('not function') - }, - cancel: { - type: Function, - default: () => console.log('not function') - }, - editBtn: { - type: Function, - default: () => console.log('not function') - }, - changeBtn: { - type: Function, - default: () => console.log('not function') } }) const emit = defineEmits(['update:edit']) -const updateEdit = (value: any) => { - emit('update:edit', value) -} - -const ClickEdit = () => { - updateEdit(!props.edit) - props.editBtn() - props.changeBtn() -} - -const ClickCancel = () => { - updateEdit(!props.edit) - props.cancel() - props.changeBtn() -} - const save = () => { props.save() } diff --git a/src/interface/main/index.ts b/src/interface/main/index.ts index 3c39ec2..59a5a9e 100644 --- a/src/interface/main/index.ts +++ b/src/interface/main/index.ts @@ -21,52 +21,4 @@ interface optionType { color: string } -const menuList = readonly([ - { - key: 1, - icon: 'mdi-home-variant-outline', - activeIcon: 'mdi-home-variant', - label: 'หน้าแรก', - path: 'dashboard' - }, - { - key: 2, - icon: 'o_person', - activeIcon: 'person', - label: 'รายการสอบทั้งหมด', - path: 'exam' - } -]) - -const options = readonly([ - { - icon: 'mdi-account-cog', - label: 'ผู้ดูแลระบบ', - value: 'op1', - color: 'primary' - }, - { - icon: 'mdi-account-group', - label: 'เจ้าหน้าที่', - value: 'op2', - color: 'blue' - }, - { - icon: 'mdi-account-circle', - label: 'บุคคล', - value: 'op3', - color: 'indigo' - } -]) - -const notiList = readonly([ - { - id: 1, - sender: 'ท', - body: 'ขอแก้ไขข้อมูลรายการสอบทั้งหมด', - timereceive: '13/12/2565' - } -]) - -export { menuList, options, notiList } export type { menuType, notiType, optionType } diff --git a/src/main.ts b/src/main.ts index 27e8ef4..1c6ac0e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -36,14 +36,6 @@ app.use( // quasarUserOptions ) -app.component( - 'data-table', - defineAsyncComponent(() => import('./components/TableView.vue')) -) -app.component( - 'notifyError', - defineAsyncComponent(() => import('./components/NotifyError.vue')) -) app.component( 'datepicker', defineAsyncComponent(() => import('@vuepic/vue-datepicker')) diff --git a/src/modules/01_exam/components/Conference.vue b/src/modules/01_exam/components/Consendform.vue similarity index 90% rename from src/modules/01_exam/components/Conference.vue rename to src/modules/01_exam/components/Consendform.vue index 0731b51..a5cdd88 100644 --- a/src/modules/01_exam/components/Conference.vue +++ b/src/modules/01_exam/components/Consendform.vue @@ -48,12 +48,12 @@ จะใช้วิธีการที่ชอบด้วยกฏหมายและเป็นธรรมในการเก็บรวบรวมข้อมูลส่วนบุคคลอย่างจำกัดเพียงเท่าที่จำเป็นภายใต้วัตถุประสงค์การทำงานของกรุงเทพมหานครฯ เพื่อใช้เป็นข้อมูลประกอบการพิจารณาคัดเลือกตามตำแหน่งที่ผู้ให้ข้อมูลประสงค์จะสมัครรับการคัดเลือกโดยกรุงเทพมหานครฯ จะเก็บรวบรวมข้อมูลส่วนบุคคลของท่าน ดังนี้ -
    -
  • ชื่อ-นามสกุล เพื่อติดต่อกับทางกรุงเทพมหานครฯ
  • -
  • อีเมล์ เพื่อใช้ในการติดต่อกับกรุงเทพมหานครฯ
  • -
  • เบอร์โทร เพื่อใช้สมัครงานกับทางกรุงเทพมหานครฯ
  • -
  • ที่อยู่ เพื่อใช้สมัครงานกับทางกรุงเทพมหานครฯ
  • -
  • ประวัติการทำงาน, ประวัติการศึกษา, ประวัติการฝึกอบรม ตามข้อมูลข้างต้น
  • +
      +
    • ชื่อ-นามสกุล เพื่อติดต่อกับทางกรุงเทพมหานครฯ
    • +
    • อีเมล์ เพื่อใช้ในการติดต่อกับกรุงเทพมหานครฯ
    • +
    • เบอร์โทร เพื่อใช้สมัครงานกับทางกรุงเทพมหานครฯ
    • +
    • ที่อยู่ เพื่อใช้สมัครงานกับทางกรุงเทพมหานครฯ
    • +
    • ประวัติการทำงาน, ประวัติการศึกษา, ประวัติการฝึกอบรม ตามข้อมูลข้างต้น
            ท้้งนี้ข้อมูลส่วนบุคคลดังกล่าวเป็นข้อมูลที่จำเป็นสำหรับการทำงานของกรุงเทพมหานครฯ หากไม่มีข้อมูลดังกล่าว อาจส่งผลต่อกระบวนการพิจารณาคุณสมบัติของผู้สมัคร @@ -80,7 +80,13 @@ - + @@ -88,10 +94,6 @@ import { ref } from 'vue' import keycloak from '@/plugins/keycloak' const props = defineProps({ - close: { - type: Function, - default: () => console.log('not function') - }, ok: { type: Function, default: () => console.log('not function') diff --git a/src/modules/01_exam/components/ExamCard.vue b/src/modules/01_exam/components/ExamCard.vue index cc473c5..a67eed4 100644 --- a/src/modules/01_exam/components/ExamCard.vue +++ b/src/modules/01_exam/components/ExamCard.vue @@ -20,17 +20,11 @@
    เลขประจำตัวสอบ :
    {{ examNumber }}
-
เลขที่นั่งสอบ :
{{ examSeat }}
-
ผลการสอบ
ประเภท
@@ -81,14 +75,6 @@
- @@ -114,15 +100,19 @@ import { onMounted, ref } from 'vue' import { useRoute } from 'vue-router' import { useCounterMixin } from '@/stores/mixin' +import { useDataStore } from '@/stores/data' import http from '@/plugins/http' import config from '@/app.config' +import { useQuasar } from 'quasar' +const $q = useQuasar() const route = useRoute() const mixin = useCounterMixin() //เรียกฟังก์ชันกลาง -const { dateThaiRange, modalDelete, modalConfirm, dateToISO, success, date2Thai } = mixin +const { date2Thai, messageError } = mixin +const dataStore = useDataStore() +const { loaderPage } = dataStore const examId = ref(route.params.id.toString()) const positionId = ref(route.params.positionId.toString()) -const loader = ref(false) const fullName = ref('') const examNumber = ref('') const citizenId = ref('') @@ -143,7 +133,7 @@ onMounted(async () => { }) const fetchStatus = async () => { - loader.value = true + loaderPage(true) await http .get(config.API.candidateCard(examId.value, positionId.value)) .then((res) => { @@ -180,25 +170,16 @@ const fetchStatus = async () => { score_expired.value = new Date(data.announcementDate) number.value = data.number }) - .catch(() => { - // acceptTermOfUse.value = false + .catch((e) => { + messageError($q, e) }) .finally(() => { - loader.value = false + loaderPage(false) }) } const download = () => { window.print() - // var printContent = document.getElementById('print') - // var WinPrint = window.open() - // if (WinPrint != null && printContent != null) { - // WinPrint.document.write(printContent.innerHTML) - // // WinPrint.document.close() - // // WinPrint.focus() - // // WinPrint.print() - // // WinPrint.close() - // } } diff --git a/src/modules/01_exam/components/ExamCrad.vue b/src/modules/01_exam/components/ExamCrad.vue index dde74f8..7e262ec 100644 --- a/src/modules/01_exam/components/ExamCrad.vue +++ b/src/modules/01_exam/components/ExamCrad.vue @@ -20,8 +20,8 @@ diff --git a/src/modules/01_exam/components/ExamFinished.vue b/src/modules/01_exam/components/ExamFinished.vue index 917158f..5d9ea40 100644 --- a/src/modules/01_exam/components/ExamFinished.vue +++ b/src/modules/01_exam/components/ExamFinished.vue @@ -88,6 +88,9 @@ import { onMounted, ref } from 'vue' import http from '@/plugins/http' import config from '@/app.config' import { useRoute } from 'vue-router' +import { useCounterMixin } from '@/stores/mixin' +import { useDataStore } from '@/stores/data' +import { useQuasar } from 'quasar' import ExamCard from '@/modules/01_exam/components/ExamCard.vue' const props = defineProps({ @@ -101,10 +104,14 @@ const props = defineProps({ } }) +const $q = useQuasar() const route = useRoute() +const dataStore = useDataStore() +const { loaderPage } = dataStore +const mixin = useCounterMixin() +const { messageError } = mixin const examId = ref(route.params.id.toString()) const positionId = ref(route.params.positionId.toString()) -const loader = ref(false) const fullName = ref('') const examNumber = ref('') const citizenId = ref('') @@ -117,7 +124,6 @@ const scoreSumFull = ref(null) const scoreSum = ref(null) const examResultinscore = ref('') const avatar = ref('') - const dialog = ref(false) const rating = ref(5) const text = ref('') @@ -127,7 +133,7 @@ onMounted(async () => { }) const fetchStatus = async () => { - loader.value = true + loaderPage(true) await http .get(config.API.candidateCard(examId.value, positionId.value)) .then((res) => { @@ -153,27 +159,27 @@ const fetchStatus = async () => { avatar.value = data.avatar if (data.reviewPoint == null) dialog.value = true }) - .catch(() => { - // acceptTermOfUse.value = false + .catch((e) => { + messageError($q, e) }) .finally(() => { - loader.value = false + loaderPage(false) }) } const sendRating = async () => { - loader.value = true + loaderPage(true) await http .put(config.API.candidateReview(examId.value, positionId.value), { reviewPoint: rating.value, //คะแนน review: text.value //ข้อความ }) .then((res) => {}) - .catch(() => { - // acceptTermOfUse.value = false + .catch((e) => { + messageError($q, e) }) .finally(() => { - loader.value = false + loaderPage(false) dialog.value = false }) } @@ -188,10 +194,6 @@ const getClass = (val: string) => { size: A4; margin: 0; } -/* #print { - display: none; - visibility: none; -} */ @media print { @page { diff --git a/src/modules/01_exam/components/ExamForm.vue b/src/modules/01_exam/components/ExamForm.vue index 99dd1ac..7fa4879 100644 --- a/src/modules/01_exam/components/ExamForm.vue +++ b/src/modules/01_exam/components/ExamForm.vue @@ -44,9 +44,9 @@ import { onMounted, ref } from 'vue' import { useQuasar } from 'quasar' import { useCounterMixin } from '@/stores/mixin' +import { useDataStore } from '@/stores/data' import http from '@/plugins/http' import config from '@/app.config' -import Profile from '@/modules/01_exam/components/Form/Profile.vue' import { useRoute } from 'vue-router' import { defaultInformation, @@ -54,6 +54,7 @@ import { defaultAddress, defaultFamily } from '@/modules/01_exam/interface/index/Main' +import Profile from '@/modules/01_exam/components/Form/Profile.vue' const props = defineProps({ fetchStep: { @@ -68,8 +69,9 @@ const props = defineProps({ const $q = useQuasar() const mixin = useCounterMixin() //เรียกฟังก์ชันกลาง -const { modalConfirm, modalError, success, dateToISO } = mixin -const loader = ref(false) +const { modalConfirm, modalError, success, dateToISO, messageError } = mixin +const dataStore = useDataStore() +const { loaderPage } = dataStore const statusEdit = ref(false) const acceptTermOfUse = ref(false) const route = useRoute() @@ -82,9 +84,6 @@ const formOccupation = ref({}) const saveAuto = ref(false) onMounted(async () => { - // if (props.status !== 'register') { - // acceptTermOfUse.value = true - // } await fetchStatus() }) @@ -103,31 +102,30 @@ const okModalConfirm = () => { } const fetchStatus = async () => { - loader.value = true + loaderPage(true) await http .get(config.API.candidateCard(examId.value, positionId.value)) .then((res) => { acceptTermOfUse.value = true }) - .catch(() => { + .catch((e) => { acceptTermOfUse.value = false }) .finally(() => { - loader.value = false + loaderPage(false) }) } const saveForm = async () => { - loader.value = true + loaderPage(true) await http .get(config.API.candidateRegister(examId.value, positionId.value)) - .then(() => { - // success($q, 'สมัครสอบสำเร็จสำเร็จ') + .then(() => {}) + .catch((e) => { + messageError($q, e) }) - .catch(() => {}) .finally(async () => { await props.fetchStep() - loader.value = false }) } @@ -156,7 +154,7 @@ const saveData = async () => { type.value = defaultOccupation.value.employee if (defaultOccupation.value.status == 'other') type.value = defaultOccupation.value.other - loader.value = true + loaderPage(true) await http .post(config.API.candidateId(examId.value, positionId.value), { prefixId: defaultInformation.value.prefixId, @@ -227,14 +225,10 @@ const saveData = async () => { success($q, 'บันทึกข้อมูลส่วนตัวสำเร็จ') if (saveAuto.value) await saveForm() }) - .catch(() => { - // modalError.value = true - // modalErrorTittle.value = 'ไม่สามารถบันทึกข้อมูลร่างได้' - // modalErrorDetail.value = e.response.data.message - // statusCode.value = e.response.data.status + .catch((e) => { + messageError($q, e) }) .finally(async () => { - loader.value = false await props.fetchStep() }) } diff --git a/src/modules/01_exam/components/ExamPayment.vue b/src/modules/01_exam/components/ExamPayment.vue index a079495..3a59519 100644 --- a/src/modules/01_exam/components/ExamPayment.vue +++ b/src/modules/01_exam/components/ExamPayment.vue @@ -83,21 +83,6 @@ accept="image/*" @change="uploadImage" /> - @@ -169,7 +154,6 @@
@@ -230,11 +199,11 @@ /> - diff --git a/src/modules/01_exam/components/Form/Address.vue b/src/modules/01_exam/components/Form/Address.vue index 2ae8370..6886d77 100644 --- a/src/modules/01_exam/components/Form/Address.vue +++ b/src/modules/01_exam/components/Form/Address.vue @@ -8,7 +8,6 @@ :editOnly="false" :editData="false" /> -
@@ -25,7 +24,6 @@ :rules="[(val) => !!val || `${'กรุณากรอก ที่อยู่ตามทะเบียนบ้าน'}`]" :label="`${'ที่อยู่ตามทะเบียนบ้าน'}`" /> -
(route.params.id.toString()) const positionId = ref(route.params.positionId.toString()) const edit = ref(true) const myform = ref({}) -const loader = ref(false) const districtOptions = ref([]) const districtCOptions = ref([]) const subdistrictOptions = ref([]) const subdistrictCOptions = ref([]) -const emit = defineEmits(['update:form']) - watch(myform, async (count: any, prevCount: any) => { emit('update:form', count) }) @@ -269,31 +273,35 @@ onMounted(async () => { }) const fetchData = async () => { - // loader.value = true; + loaderPage(true) await http .get(config.API.candidateAddress(examId.value, positionId.value)) .then((res) => { const data = res.data.result - defaultAddress.value.address = data.registAddress - defaultAddress.value.addressC = data.currentAddress - defaultAddress.value.provinceId = data.registProvinceId - defaultAddress.value.provinceIdC = data.currentProvinceId - defaultAddress.value.districtId = data.registDistrictId - defaultAddress.value.districtIdC = data.currentDistrictId - defaultAddress.value.subdistrictId = data.registSubDistrictId - defaultAddress.value.subdistrictIdC = data.currentSubDistrictId - defaultAddress.value.code = data.registZipCode - defaultAddress.value.codeC = data.currentZipCode - defaultAddress.value.same = - data.registSame == true ? '1' : data.registSame == false ? '0' : null + if (data != null) { + defaultAddress.value.address = data.registAddress + defaultAddress.value.addressC = data.currentAddress + defaultAddress.value.provinceId = data.registProvinceId + defaultAddress.value.provinceIdC = data.currentProvinceId + defaultAddress.value.districtId = data.registDistrictId + defaultAddress.value.districtIdC = data.currentDistrictId + defaultAddress.value.subdistrictId = data.registSubDistrictId + defaultAddress.value.subdistrictIdC = data.currentSubDistrictId + defaultAddress.value.code = data.registZipCode + defaultAddress.value.codeC = data.currentZipCode + defaultAddress.value.same = + data.registSame == true ? '1' : data.registSame == false ? '0' : null + } + }) + .catch((e) => { + messageError($q, e) }) - .catch(() => {}) .finally(() => { - // loader.value = false; + loaderPage(false) }) } -const selectProvince = (e: string, name: string) => { +const selectProvince = async (e: string, name: string) => { if (name == '1') { defaultAddress.value.districtId = '' defaultAddress.value.subdistrictId = '' @@ -304,10 +312,10 @@ const selectProvince = (e: string, name: string) => { defaultAddress.value.codeC = null } myform.value.resetValidation() - fetchDistrict(e, name) + await fetchDistrict(e, name) } -const selectDistrict = (e: string, name: string) => { +const selectDistrict = async (e: string, name: string) => { if (name == '1') { defaultAddress.value.subdistrictId = '' defaultAddress.value.code = null @@ -316,7 +324,7 @@ const selectDistrict = (e: string, name: string) => { defaultAddress.value.codeC = null } myform.value.resetValidation() - fetchSubDistrict(e, name) + await fetchSubDistrict(e, name) } const selectSubDistrict = (e: string, name: string) => { @@ -332,7 +340,7 @@ const selectSubDistrict = (e: string, name: string) => { } const fetchDistrict = async (id: string, position: string) => { - loader.value = true + loaderPage(true) await http .get(config.API.listDistrict(id)) .then((res) => { @@ -347,14 +355,16 @@ const fetchDistrict = async (id: string, position: string) => { districtCOptions.value = option } }) - .catch(() => {}) + .catch((e) => { + messageError($q, e) + }) .finally(() => { - loader.value = false + loaderPage(false) }) } const fetchSubDistrict = async (id: string, position: string) => { - loader.value = true + loaderPage(true) await http .get(config.API.listSubDistrict(id)) .then((res) => { @@ -373,9 +383,11 @@ const fetchSubDistrict = async (id: string, position: string) => { subdistrictCOptions.value = option } }) - .catch(() => {}) + .catch((e) => { + messageError($q, e) + }) .finally(() => { - loader.value = false + loaderPage(false) }) } diff --git a/src/modules/01_exam/components/Form/Career.vue b/src/modules/01_exam/components/Form/Career.vue index 38329a7..88829e0 100644 --- a/src/modules/01_exam/components/Form/Career.vue +++ b/src/modules/01_exam/components/Form/Career.vue @@ -11,7 +11,6 @@ v-model:editvisible="edit" :add="clickAdd" :edit="clickEdit" - :cancel="clickCancel" :addData="false" :editData="status == 'register' || status == 'rejectRegister'" name="ประวัติการทำงาน/ฝึกงาน" @@ -51,7 +50,6 @@ - @@ -165,7 +163,6 @@ (false) +const dataStore = useDataStore() +const { loaderPage } = dataStore const id = ref('') const location = ref() const position = ref() @@ -297,7 +296,7 @@ onMounted(async () => { }) const fetchData = async () => { - loader.value = true + loaderPage(true) await http .get(config.API.candidateCareer(examId.value, positionId.value)) .then((res) => { @@ -311,16 +310,18 @@ const fetchData = async () => { }) }) }) - .catch(() => {}) + .catch((e) => { + // messageError($q, e) + }) .finally(() => { - loader.value = false + loaderPage(false) }) } /** * กดดูข้อมูลก่อนหน้า */ -const clickPrevious = () => { +const clickPrevious = async () => { rowIndex.value -= 1 const row = rows.value[rowIndex.value] location.value = row.location @@ -329,13 +330,13 @@ const clickPrevious = () => { duration.value = row.duration reason.value = row.reason id.value = row.id - checkRowPage() + await checkRowPage() } /** * กดดูข้อมูลต่อไป */ -const clickNext = () => { +const clickNext = async () => { rowIndex.value += 1 const row = rows.value[rowIndex.value] location.value = row.location @@ -344,7 +345,7 @@ const clickNext = () => { duration.value = row.duration reason.value = row.reason id.value = row.id - checkRowPage() + await checkRowPage() } /** @@ -366,7 +367,6 @@ const checkRowPage = () => { * กดปุ่มแก้ไขใน dialog */ const clickEdit = () => { - // edit.value = true next.value = false previous.value = false } @@ -374,8 +374,8 @@ const clickEdit = () => { /** * กดปุ่มเพิ่มด้านบน table */ -const clickAdd = () => { - addRow() +const clickAdd = async () => { + await addRow() } const checkDelete = (row: RequestItemsObject) => { @@ -388,26 +388,20 @@ const checkDelete = (row: RequestItemsObject) => { */ const clickDeleteRow = async () => { if (rawItem.value != null) { - loader.value = true + loaderPage(true) await http .delete(config.API.candidateCareer(rawItem.value.id, '')) .then(() => { success($q, 'ลบข้อมูลสำเร็จ') }) - .catch(() => { - // modalError.value = true - // modalErrorTittle.value = 'ไม่สามารถบันทึกข้อมูลร่างได้' - // modalErrorDetail.value = e.response.data.message - // statusCode.value = e.response.data.status + .catch((e) => { + messageError($q, e) }) .finally(async () => { - loader.value = false await fetchData() - // edit.value = false }) } else { await fetchData() - // edit.value = false } } @@ -417,15 +411,11 @@ const clickDeleteRow = async () => { const clickSave = async () => { myForm.value.validate().then(async (result: boolean) => { if (result) { - // if (store.consend == true) { if (modalEdit.value) { await editData() } else { await saveData() } - // } else { - // modalConsend.value = true - // } } }) } @@ -434,7 +424,7 @@ const clickSave = async () => { * บันทึกเพิ่มข้อมูล */ const saveData = async () => { - loader.value = true + loaderPage(true) await http .post(config.API.candidateCareer(examId.value, positionId.value), { name: location.value, @@ -447,15 +437,10 @@ const saveData = async () => { .then(() => { success($q, 'บันทึกข้อมูลสำเร็จ') }) - .catch(() => { - // modalError.value = true - // modalErrorTittle.value = 'ไม่สามารถบันทึกข้อมูลร่างได้' - // modalErrorDetail.value = e.response.data.message - // statusCode.value = e.response.data.status + .catch((e) => { + messageError($q, e) }) .finally(async () => { - loader.value = false - // edit.value = false modal.value = false await fetchData() }) @@ -465,7 +450,7 @@ const saveData = async () => { * บันทึกแก้ไขข้อมูล */ const editData = async () => { - loader.value = true + loaderPage(true) await http .put(config.API.candidateCareer(id.value, ''), { name: location.value, @@ -478,15 +463,10 @@ const editData = async () => { .then(() => { success($q, 'บันทึกข้อมูลสำเร็จ') }) - .catch(() => { - // modalError.value = true - // modalErrorTittle.value = 'ไม่สามารถบันทึกข้อมูลร่างได้' - // modalErrorDetail.value = e.response.data.message - // statusCode.value = e.response.data.status + .catch((e) => { + messageError($q, e) }) .finally(async () => { - loader.value = false - // edit.value = false modal.value = false await fetchData() }) @@ -527,12 +507,8 @@ const selectData = (props: DataProps) => { duration.value = props.row.duration reason.value = props.row.reason id.value = props.row.id - // if (edit.value == true) { next.value = false previous.value = false - // } else { - // checkRowPage() - // } } /** @@ -548,13 +524,6 @@ const addRow = () => { reason.value = '' } -/** - * ฟังก์ชันปุ่มยกเลิกการแก้ไขข้อมูล - */ -const clickCancel = async () => { - // edit.value = false -} - /** * เช็คว่ามีการแก้ไขข้อมูล */ diff --git a/src/modules/01_exam/components/Form/Document.vue b/src/modules/01_exam/components/Form/Document.vue index c0f2235..39b9b4e 100644 --- a/src/modules/01_exam/components/Form/Document.vue +++ b/src/modules/01_exam/components/Form/Document.vue @@ -81,18 +81,6 @@ เลือกไฟล์ - - ยกเลิกการอัปโหลด @@ -142,12 +130,15 @@ diff --git a/src/modules/01_exam/router.ts b/src/modules/01_exam/router.ts index 7599d2e..5e8a774 100644 --- a/src/modules/01_exam/router.ts +++ b/src/modules/01_exam/router.ts @@ -1,16 +1,6 @@ -const Main = () => import('@/modules/01_exam/views/ExamMain.vue') const Detail = () => import('@/modules/01_exam/views/ExamDetail.vue') export default [ - // { - // path: '/exam', - // name: 'exam', - // component: Main, - // meta: { - // Auth: true - // // Key: [7] - // } - // }, { path: '/exam/:id/:positionId', name: 'examDetail', diff --git a/src/modules/01_exam/views/ExamDetail.vue b/src/modules/01_exam/views/ExamDetail.vue index ef2390e..46640a7 100644 --- a/src/modules/01_exam/views/ExamDetail.vue +++ b/src/modules/01_exam/views/ExamDetail.vue @@ -61,7 +61,7 @@ - + @@ -70,6 +70,7 @@ import { onMounted, ref } from 'vue' import { useRoute } from 'vue-router' import { useCounterMixin } from '@/stores/mixin' +import { useDataStore } from '@/stores/data' import { useQuasar } from 'quasar' import { useExamDataStore } from '@/modules/01_exam/store' import http from '@/plugins/http' @@ -77,12 +78,14 @@ import config from '@/app.config' import ExamForm from '@/modules/01_exam/components/ExamForm.vue' import ExamPayment from '@/modules/01_exam/components/ExamPayment.vue' import ExamFinished from '@/modules/01_exam/components/ExamFinished.vue' -import Conference from '@/modules/01_exam/components/Conference.vue' +import Consendform from '@/modules/01_exam/components/Consendform.vue' const $q = useQuasar() -const store = useExamDataStore() +const storeExam = useExamDataStore() const mixin = useCounterMixin() -const { modalError } = mixin +const { modalError, messageError } = mixin +const dataStore = useDataStore() +const { loaderPage } = dataStore const step = ref(1) const stepRaw = ref(1) const tittle = ref('') @@ -90,7 +93,6 @@ const position = ref('') const route = useRoute() const examId = ref(route.params.id.toString()) const positionId = ref(route.params.positionId.toString()) -const loader = ref(false) const status = ref('register') const modalConsend = ref(false) const stepPayment = ref(true) @@ -99,19 +101,17 @@ const round = ref(null) const yearly = ref(null) onMounted(async () => { - // stepRaw.value = 3 - // step.value = 3 await fetchPeriodExam() await candidateCheck() }) const candidateCheck = async () => { - loader.value = true + loaderPage(true) await http .get(config.API.candidateCheckCreate(examId.value, positionId.value)) .then(async (res) => { const data = res.data.result - store.consend = data.consend + storeExam.consend = data.consend const positionExam = data.positionExam stepPayment.value = data.payment if ( @@ -128,7 +128,7 @@ const candidateCheck = async () => { closeWindow ) } else { - if (store.consend == true) { + if (storeExam.consend == true) { await fetchStep() } else { modalConsend.value = true @@ -137,20 +137,20 @@ const candidateCheck = async () => { } } }) - .catch(() => {}) + .catch((e) => { + messageError($q, e) + }) .finally(() => { - loader.value = false + loaderPage(false) }) } const closeWindow = async () => { // window.close() - // window.closed = true - // console.log(window) } const fetchStep = async () => { - loader.value = true + loaderPage(true) await http .get(config.API.candidateStatus(examId.value, positionId.value)) .then((res) => { @@ -194,15 +194,17 @@ const fetchStep = async () => { step.value = 4 } }) - .catch(() => {}) + .catch((e) => { + messageError($q, e) + }) .finally(() => { - loader.value = false - store.changeStatus(status.value) + loaderPage(false) + storeExam.changeStatus(status.value) }) } const fetchPeriodExam = async () => { - loader.value = true + loaderPage(true) await http .get(config.API.periodExamPosition(examId.value, positionId.value)) .then((res) => { @@ -212,9 +214,11 @@ const fetchPeriodExam = async () => { yearly.value = data.year position.value = data.posiiton == null ? '' : 'ตำแหน่ง: ' + data.posiiton.positionName }) - .catch(() => {}) + .catch((e) => { + messageError($q, e) + }) .finally(() => { - loader.value = false + loaderPage(false) }) } @@ -224,8 +228,6 @@ const consenClose = () => { const consendOk = () => { modalConsend.value = false - // store.consend = true - // saveData() } diff --git a/src/modules/02_meta/interface/index/main.ts b/src/modules/02_meta/interface/index/main.ts deleted file mode 100644 index 254d833..0000000 --- a/src/modules/02_meta/interface/index/main.ts +++ /dev/null @@ -1,10 +0,0 @@ -interface Pagination { - rowsPerPage: number -} - -interface DataOption { - id: string - name: string -} - -export type { Pagination, DataOption } diff --git a/src/modules/02_meta/interface/request/Main.ts b/src/modules/02_meta/interface/request/Main.ts deleted file mode 100644 index 1d8f36d..0000000 --- a/src/modules/02_meta/interface/request/Main.ts +++ /dev/null @@ -1,28 +0,0 @@ -interface DataProps { - row: RequestItemsObject - rowIndex: number -} - -//ข้อมูล -interface RequestItemsObject { - id: string - name: string - certiNumber: string - start: Date - end: Date -} - -//columns -interface Columns { - [index: number]: { - name: String - align: String - label: String - sortable: Boolean - field: String - headerStyle: String - style: String - } -} - -export type { RequestItemsObject, Columns, DataProps } diff --git a/src/modules/02_meta/interface/response/Main.ts b/src/modules/02_meta/interface/response/Main.ts deleted file mode 100644 index 9a1f525..0000000 --- a/src/modules/02_meta/interface/response/Main.ts +++ /dev/null @@ -1,11 +0,0 @@ -//ข้อมูล -interface ResponseObject { - id: string - date: Date - status: string - level: string - refNo: string - refDate: Date -} - -export type { ResponseObject } diff --git a/src/modules/02_meta/router.ts b/src/modules/02_meta/router.ts deleted file mode 100644 index 4b1724a..0000000 --- a/src/modules/02_meta/router.ts +++ /dev/null @@ -1,13 +0,0 @@ -const Meta = () => import('@/modules/02_meta/views/Meta02View.vue') - -export default [ - { - path: '/meta02', - name: 'meta02', - component: Meta, - meta: { - Auth: true - // Key: [7] - } - } -] diff --git a/src/modules/02_meta/store.ts b/src/modules/02_meta/store.ts deleted file mode 100644 index b0e868c..0000000 --- a/src/modules/02_meta/store.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { ref, computed } from 'vue' -import { defineStore } from 'pinia' - -export const useMetaStore = defineStore('meta', () => { - const meta = ref('') - - return { - meta - } -}) diff --git a/src/modules/02_meta/views/Meta02View.vue b/src/modules/02_meta/views/Meta02View.vue deleted file mode 100644 index 7f8e8e8..0000000 --- a/src/modules/02_meta/views/Meta02View.vue +++ /dev/null @@ -1,15 +0,0 @@ - - - diff --git a/src/plugins/axios.ts b/src/plugins/axios.ts index 79bba4e..a04ba81 100644 --- a/src/plugins/axios.ts +++ b/src/plugins/axios.ts @@ -1,25 +1,21 @@ -import axios from "axios" -import config from "process" -// import { dotnetPath } from "../path/axiosPath"; -// import { getToken } from "@baloise/vue-keycloak"; -import keycloak from "../plugins/keycloak" +import axios from 'axios' +import keycloak from '../plugins/keycloak' const axiosInstance = axios.create({ - withCredentials: false, + withCredentials: false }) -// axiosInstance.defaults.baseURL = dotnetPath; axiosInstance.interceptors.request.use( - async (config) => { - const token = await keycloak.token - config.headers = { - Authorization: `Bearer ${token}`, - } - return config - }, - (error) => { - Promise.reject(error) + async (config) => { + const token = await keycloak.token + config.headers = { + Authorization: `Bearer ${token}` } + return config + }, + (error) => { + Promise.reject(error) + } ) export default axiosInstance diff --git a/src/plugins/http.ts b/src/plugins/http.ts index 494c9aa..5381dfe 100644 --- a/src/plugins/http.ts +++ b/src/plugins/http.ts @@ -1,45 +1,42 @@ -import Axios, { type AxiosRequestConfig, type AxiosResponse } from "axios"; -import keycloak from "./keycloak"; +import Axios, { type AxiosRequestConfig, type AxiosResponse } from 'axios' +import keycloak from './keycloak' const http = Axios.create({ timeout: 1000000000, // เพิ่มค่า timeout headers: { - "X-Requested-With": "XMLHttpRequest", - }, -}); + 'X-Requested-With': 'XMLHttpRequest' + } +}) http.interceptors.request.use( async function (config: AxiosRequestConfig) { - await keycloak.updateToken(1); - config.headers = config.headers ?? {}; - const token = keycloak.token; - // const token = localStorage.getItem("access_token") - // const token = - // "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICIxU2VKV2dVRFVlNXZwNS13Q1ZHaG9lT2l4bDJTTkdKemthLU5ZN211NXZJIn0.eyJleHAiOjE2NzI0MTI1NDksImlhdCI6MTY3MjM3NjU0OSwiYXV0aF90aW1lIjoxNjcyMzc2NTQ5LCJqdGkiOiI1MTVhY2IwNC1jODQ3LTQzM2YtYjUxOC03ODUzMzJhY2ZjNWYiLCJpc3MiOiJodHRwczovL2tleWNsb2FrLmZyYXBwZXQuc3lub2xvZ3kubWUvYXV0aC9yZWFsbXMvYm1hLWVociIsImF1ZCI6ImFjY291bnQiLCJzdWIiOiJlZmM5YjRlMC1mZGU2LTQ1NDQtYmU1OS1lMTA0MjEwMjUzZjAiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJibWEtZWhyIiwibm9uY2UiOiI3NjMyMGI3ZS0xZTMxLTQ5ODYtYWIzOC1iOTUyYjFlODY3OGYiLCJzZXNzaW9uX3N0YXRlIjoiMDZlNTBkZjktNzAyNi00ZGIwLTkxMjgtMWY3Y2FiYTRkNDEyIiwiYWNyIjoiMSIsImFsbG93ZWQtb3JpZ2lucyI6WyJodHRwczovL2xvY2FsaG9zdDo3MDA2Il0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJkZWZhdWx0LXJvbGVzLWJtYS1laHIiLCJvZmZsaW5lX2FjY2VzcyIsImFkbWluIiwidW1hX2F1dGhvcml6YXRpb24iXX0sInJlc291cmNlX2FjY2VzcyI6eyJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6Im9wZW5pZCBlbWFpbCBwcm9maWxlIiwic2lkIjoiMDZlNTBkZjktNzAyNi00ZGIwLTkxMjgtMWY3Y2FiYTRkNDEyIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsInJvbGUiOlsiZGVmYXVsdC1yb2xlcy1ibWEtZWhyIiwib2ZmbGluZV9hY2Nlc3MiLCJhZG1pbiIsInVtYV9hdXRob3JpemF0aW9uIl0sIm5hbWUiOiJTeXN0ZW0gQWRtaW5pc3RyYXRvciIsInByZWZlcnJlZF91c2VybmFtZSI6ImFkbWluIiwiZ2l2ZW5fbmFtZSI6IlN5c3RlbSIsImZhbWlseV9uYW1lIjoiQWRtaW5pc3RyYXRvciIsImVtYWlsIjoiYWRtaW5AbG9jYWxob3N0In0.xmfJ3pzI-jLYsaiFXyjTW7gfAEpvUmMVsp9BsB1CfRCVOKiGBbuZhnQY8W-1SWVAx1NjJ55L-zMHPK6hk1dRPLbEse3DlIBZw04W9j8m-Wz3eqdHf_UCjmrXb8qAwkeq0Iaxq9mVfJJeQWeKhFBi-Ff8ek4hCXTYDICXS8ny_BaC5WkyrefHQ2xBqQjwRyoxsg4IoVMjXYNb8L9A-4BNlRfs928SqgFYCRlF5h6zw_rC0XoLrGTmqeacBdpey-r3j2g_lTqWy8mQg2T9s65IDqW3kFPOsr0SVO88sjlFbN9Et0L57RmiqORk_RwzbWg-_Yb6dOuolXsnjBOhOoTzkA"; - if (token) config.headers.Authorization = `Bearer ${token}`; - return config; + await keycloak.updateToken(1) + config.headers = config.headers ?? {} + const token = keycloak.token + if (token) config.headers.Authorization = `Bearer ${token}` + return config }, function (error: any) { - return Promise.reject(error); + return Promise.reject(error) } -); +) http.interceptors.response.use( function (response: AxiosResponse) { - return response; + return response }, function (error: any) { if (typeof error !== undefined) { // eslint-disable-next-line no-prototype-builtins - if (error.hasOwnProperty("response")) { + if (error.hasOwnProperty('response')) { if (error.response.status === 401 || error.response.status === 403) { // Store.commit("SET_ERROR_MESSAGE", error.response.data.message); // Store.commit("REMOVE_ACCESS_TOKEN") } } } - return Promise.reject(error); + return Promise.reject(error) } -); +) -export default http; +export default http diff --git a/src/plugins/keycloak.ts b/src/plugins/keycloak.ts index bea4f25..01a3203 100644 --- a/src/plugins/keycloak.ts +++ b/src/plugins/keycloak.ts @@ -2,18 +2,13 @@ * front connect to keycloak */ import Keycloak from 'keycloak-js' -// import config from "../app.config"; -// import http from "../shared/http"; -// import router from "../router"; +//option keycloak ที่จะ connect const initOptions = { - // url: "https://keycloak.frappet.synology.me/auth/", realm: 'bma-ehr', clientId: 'bma-ehr-vue3', url: 'https://identity.frappet.com/' - // realm: 'bma-ehr-exam', - // clientId: 'bma-ehr-exam-vue3' -} //option keycloak ที่จะ connect +} const keycloak = Keycloak(initOptions) diff --git a/src/router/index.ts b/src/router/index.ts index f7cf0f1..374915f 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,7 +1,5 @@ import { createRouter, createWebHistory } from 'vue-router' -import HomeView from '../views/HomeView.vue' import Exam from '@/modules/01_exam/router' -import Meta02 from '@/modules/02_meta/router' import keycloak from '@/plugins/keycloak' @@ -13,57 +11,16 @@ const router = createRouter({ routes: [ { path: '/exam/:id', - // name: 'home', component: MainLayout, - children: [ - // { - // path: '/', - // name: 'dashboard', - // component: HomeView, - // meta: { - // Auth: true, - // Key: [7] - // } - // }, - ...Exam - // ...Meta02 - ] + children: [...Exam] }, - /** - * 404 Not Found - * ref: https://router.vuejs.org/guide/essentials/dynamic-matching.html#catch-all-404-not-found-route - */ - // { - // // path: "/:catchAll(.*)*", // TODO: ใช้ pathMatch แทนตามในเอกสารแนะนำ คงไว้เผื่อจำเป็น - // path: "/:pathMatch(.*)*", - // component: Error404NotFound, - // }, { - // path: "/:catchAll(.*)*", // TODO: ใช้ pathMatch แทนตามในเอกสารแนะนำ คงไว้เผื่อจำเป็น path: '/:pathMatch(.*)*', component: Error404NotFound } ] }) -// const router = createRouter({ -// history: createWebHistory(import.meta.env.BASE_URL), -// routes: [ -// { -// path: '/', -// name: 'home', -// component: HomeView -// }, -// { -// path: '/about', -// name: 'about', -// // route level code-splitting -// // this generates a separate chunk (About.[hash].js) for this route -// // which is lazy-loaded when the route is visited. -// component: () => import('../views/AboutView.vue') -// } -// ] -// }) router.beforeEach((to, from, next) => { if (to.meta.Auth) { if (!keycloak.authenticated) { @@ -72,13 +29,11 @@ router.beforeEach((to, from, next) => { locale: 'th' }) } else { - // keycloak.updateToken(60); next() } } else { next() } - // next() }) export default router diff --git a/src/stores/data.ts b/src/stores/data.ts new file mode 100644 index 0000000..fbfbadf --- /dev/null +++ b/src/stores/data.ts @@ -0,0 +1,19 @@ +import { ref } from 'vue' +import { defineStore } from 'pinia' + +export const useDataStore = defineStore('data', () => { + // ref() คือการประกาศ state เหมือน vuex + const loader = ref(false) + + /** + * active tab หน้า รายละเอียดทะเบียนประวัติ + * @param val boolean false = close , true = open + */ + const loaderPage = (val: boolean) => { + loader.value = val + } + return { + loader, + loaderPage + } +}) diff --git a/src/stores/mixin.ts b/src/stores/mixin.ts index dbbd8c4..932021f 100644 --- a/src/stores/mixin.ts +++ b/src/stores/mixin.ts @@ -2,6 +2,7 @@ import { ref, computed } from 'vue' import { defineStore } from 'pinia' import moment from 'moment' import type { DataDateMonthObject } from '@/modules/01_exam/interface/index/Main' +import CustomComponent from '@/components/CustomDialog.vue' export const useCounterMixin = defineStore('mixin', () => { /** @@ -230,6 +231,74 @@ export const useCounterMixin = defineStore('mixin', () => { } } + const messageError = (q: any, e: any = '') => { + if (e.response !== undefined) { + if (e.response.data.status !== undefined) { + q.dialog({ + component: CustomComponent, + componentProps: { + title: `พบข้อผิดพลาด`, + message: `${e.response.data.message}`, + icon: 'warning', + color: 'red', + onlycancel: true + } + }) + } else { + q.dialog({ + component: CustomComponent, + componentProps: { + title: `พบข้อผิดพลาด`, + message: `ข้อมูลผิดพลาดทำให้เกิดการไม่ตอบสนองต่อการเรียกใช้งานดูเว็บไซต์`, + icon: 'warning', + color: 'red', + onlycancel: true + } + }) + } + } else { + q.dialog({ + component: CustomComponent, + componentProps: { + title: `พบข้อผิดพลาด`, + message: `ข้อมูลผิดพลาดทำให้เกิดการไม่ตอบสนองต่อการเรียกใช้งานดูเว็บไซต์`, + icon: 'warning', + color: 'red', + onlycancel: true + } + }) + } + } + + const dialogMessage = ( + // ไม่เอาใส่ undefined + q: any, + title: string, + message: string, + icon: string, + textOk: string, + color: string, + ok?: Function, + cancel?: Function + ) => { + q.dialog({ + component: CustomComponent, + componentProps: { + title: title, + message: message, + icon: icon, + color: color, + textOk: textOk + } + }) + .onOk(() => { + if (ok != undefined) ok() + }) + .onCancel(() => { + if (cancel != undefined) cancel() + }) + } + function modalDelete(q: any, title: string, message: string, ok: Function, cancel?: Function) { q.dialog({ title: `${title}`, @@ -442,6 +511,7 @@ export const useCounterMixin = defineStore('mixin', () => { modalDelete, modalConfirm, modalError, - statusCandidate + statusCandidate, + messageError } }) diff --git a/src/views/AboutView.vue b/src/views/AboutView.vue deleted file mode 100644 index 756ad2a..0000000 --- a/src/views/AboutView.vue +++ /dev/null @@ -1,15 +0,0 @@ - - - diff --git a/src/views/Error404NotFound.vue b/src/views/Error404NotFound.vue index e06a8c1..8ec0b8f 100644 --- a/src/views/Error404NotFound.vue +++ b/src/views/Error404NotFound.vue @@ -11,7 +11,6 @@ export default defineComponent({
ไม่พบหน้าที่ต้องการ
(404 Not Found)
-
diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue deleted file mode 100644 index d5c0217..0000000 --- a/src/views/HomeView.vue +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/src/views/MainLayout.vue b/src/views/MainLayout.vue index 95587cb..60eeac1 100644 --- a/src/views/MainLayout.vue +++ b/src/views/MainLayout.vue @@ -1,11 +1,11 @@