diff --git a/src/components/CustomDialog.vue b/src/components/CustomDialog.vue new file mode 100644 index 0000000..fcedbed --- /dev/null +++ b/src/components/CustomDialog.vue @@ -0,0 +1,91 @@ + + + + + + + + + {{ title }} + + {{ message }} + + + + + + + + + + + + + + + + diff --git a/src/components/FormTime.vue b/src/components/FormTime.vue index 7bbde35..4f92687 100644 --- a/src/components/FormTime.vue +++ b/src/components/FormTime.vue @@ -1,16 +1,24 @@ @@ -61,7 +72,7 @@ function onCkickSave() { - + + { - + diff --git a/src/main.ts b/src/main.ts index c37899f..6c599a5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,7 +4,9 @@ import "./registerServiceWorker"; import router from "./router"; import { createPinia } from "pinia"; -import { Quasar } from "quasar"; +import { Quasar, Dialog, Notify, Loading } from "quasar"; +import '@quasar/extras/material-icons/material-icons.css'; +import './styles/quasar.sass'; import quasarUserOptions from "./quasar-user-options"; import VueDatePicker from "@vuepic/vue-datepicker"; import "@vuepic/vue-datepicker/dist/main.css"; @@ -14,6 +16,13 @@ const pinia = createPinia(); app.use(router); app.use(Quasar, quasarUserOptions); +app.use(Quasar, { + plugins: { + Notify, + Dialog, + Loading, + }, +}); app.use(pinia); app.component("VueDatePicker", VueDatePicker); diff --git a/src/quasar-user-options.ts b/src/quasar-user-options.ts index f19fe69..5cc6de3 100644 --- a/src/quasar-user-options.ts +++ b/src/quasar-user-options.ts @@ -1,9 +1,10 @@ -import './styles/quasar.sass' +import "./styles/quasar.sass"; // import "quasar/dist/quasar.css"; import "@quasar/extras/material-icons/material-icons.css"; +import { Dialog, Notify } from "quasar"; // To be used on app.use(Quasar, { ... }) export default { config: {}, - plugins: {}, + plugins: { Dialog, Notify }, }; diff --git a/src/stores/mixin.ts b/src/stores/mixin.ts index 8715432..2e8096d 100644 --- a/src/stores/mixin.ts +++ b/src/stores/mixin.ts @@ -1,4 +1,7 @@ import { defineStore } from "pinia"; +import CustomComponent from "@/components/CustomDialog.vue"; +import { useQuasar } from "quasar"; +const $q = useQuasar(); export const useCounterMixin = defineStore("mixin", () => { function date2Thai(srcDate: Date, isFullMonth = false, isTime = false) { @@ -80,9 +83,40 @@ export const useCounterMixin = defineStore("mixin", () => { return date2Thai(dateObject); } } + type OkCallback = () => void; + type CancelCallback = () => void; + const dialogConfirm = ( + q: any, + ok?: OkCallback, + title?: string, // ถ้ามี cancel action ใส่เป็น null + desc?: string, // ถ้ามี cancel action ใส่เป็น null + cancel?: CancelCallback + ) => { + q.dialog({ + component: CustomComponent, + componentProps: { + title: title && title != null ? title : "ยืนยันการบันทึก", + message: + desc && desc != null + ? desc + : "ต้องการยืนยันการบันทึกข้อมูลนี้ใช่หรือไม่?", + icon: "info", + color: "public", + textOk: "ตกลง", + onlycancel: false, + }, + }) + .onOk(() => { + if (ok) ok(); + }) + .onCancel(() => { + if (cancel) cancel(); + }); + }; return { date2Thai, covertDateObject, + dialogConfirm, }; }); diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index cf6e063..e2fcea4 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -1,6 +1,7 @@