first commit
This commit is contained in:
44
resources/js/Stores/report.js
Normal file
44
resources/js/Stores/report.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import {defineStore} from "pinia";
|
||||
import {useTimestamp} from "@vueuse/core";
|
||||
import {computed, ref} from "vue";
|
||||
|
||||
export const useReportStore = defineStore('reportStore', () => {
|
||||
const timestampNow = useTimestamp()
|
||||
|
||||
const _timestampCurrent = ref(null)
|
||||
const timestampCurrent = computed({
|
||||
get: () => {
|
||||
if (_timestampCurrent.value === null)
|
||||
return timestampNow.value
|
||||
|
||||
return _timestampCurrent.value
|
||||
},
|
||||
set: (value) => {
|
||||
_timestampCurrent.value = value
|
||||
}
|
||||
})
|
||||
|
||||
const timestampCurrentRange = ref([timestampNow.value, timestampNow.value])
|
||||
|
||||
const dataOnReport = ref(null)
|
||||
|
||||
const getDataOnReportDate = async () => {
|
||||
await axios.get(`/api/metric-forms/1/report-by-date?sent_at=${timestampCurrentRange.value}`)
|
||||
.then(res => {
|
||||
dataOnReport.value = res.data
|
||||
})
|
||||
.catch(err => {
|
||||
// Отчета на выбранную дату не найдено
|
||||
if (err.code === 404) {}
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
timestampNow,
|
||||
timestampCurrent,
|
||||
timestampCurrentRange,
|
||||
dataOnReport,
|
||||
|
||||
getDataOnReportDate
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user