add convert data/time to api in mixin
This commit is contained in:
parent
6744d4d243
commit
b589f98bf1
1 changed files with 18 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ import "moment/dist/locale/th";
|
|||
import moment from "moment";
|
||||
import CustomComponent from "@/components/CustomDialog.vue";
|
||||
import { Loading, QSpinnerCube } from "quasar";
|
||||
import { format, utcToZonedTime } from "date-fns-tz";
|
||||
|
||||
moment.locale("th");
|
||||
|
||||
|
|
@ -1078,6 +1079,20 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
});
|
||||
}
|
||||
|
||||
// กรณีมีเฉพาะ date
|
||||
function convertDateToAPI(date: Date | null) {
|
||||
return date
|
||||
? format(utcToZonedTime(date, "Asia/Bangkok"), "yyyy-MM-dd")
|
||||
: null;
|
||||
}
|
||||
|
||||
// กรณี datetime
|
||||
function convertDatetimeToAPI(date: Date | null) {
|
||||
return date
|
||||
? format(utcToZonedTime(date, "Asia/Bangkok"), "yyyy-MM-dd HH:mm:ss")
|
||||
: null;
|
||||
}
|
||||
|
||||
return {
|
||||
calAge,
|
||||
date2Thai,
|
||||
|
|
@ -1121,5 +1136,8 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
findPosMasterNoOld,
|
||||
|
||||
onSearchDataTable,
|
||||
|
||||
convertDateToAPI,
|
||||
convertDatetimeToAPI,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue