เพิ่ม dialog confirm
This commit is contained in:
parent
fe8d157c64
commit
8453e20234
7 changed files with 166 additions and 10 deletions
|
|
@ -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,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue