Роли, переделывание отчета, изменение на главной странице
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {defineStore} from "pinia";
|
||||
import {useTimestamp} from "@vueuse/core";
|
||||
import {computed, ref} from "vue";
|
||||
import {router} from "@inertiajs/vue3";
|
||||
|
||||
export const useReportStore = defineStore('reportStore', () => {
|
||||
const timestampNow = useTimestamp()
|
||||
@@ -22,6 +23,82 @@ export const useReportStore = defineStore('reportStore', () => {
|
||||
|
||||
const dataOnReport = ref(null)
|
||||
|
||||
const reportInfo = ref(null)
|
||||
|
||||
const patientColumns = [
|
||||
{
|
||||
title: '№',
|
||||
width: '80',
|
||||
key: 'num'
|
||||
},
|
||||
{
|
||||
title: 'ФИО',
|
||||
width: '320',
|
||||
key: 'fullname'
|
||||
},
|
||||
{
|
||||
title: 'Возраст',
|
||||
key: 'age'
|
||||
},
|
||||
{
|
||||
title: 'Дата рождения',
|
||||
key: 'birth_date'
|
||||
},
|
||||
{
|
||||
title: 'Диагноз',
|
||||
key: 'ds'
|
||||
}
|
||||
]
|
||||
|
||||
const patientsData = ref({
|
||||
plan: [],
|
||||
emergency: [],
|
||||
observation: [],
|
||||
deceased: []
|
||||
})
|
||||
|
||||
const reportForm = ref({})
|
||||
|
||||
const getColumnsByKey = (keys) => {
|
||||
const result = []
|
||||
for (const key of keys) {
|
||||
const column = patientColumns.find(item => item.key === key)
|
||||
result.push(column)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
const sendReportForm = (assignForm) => {
|
||||
const form = {
|
||||
metrics: reportForm.value,
|
||||
observationPatients: patientsData.value['observation'],
|
||||
...assignForm
|
||||
}
|
||||
|
||||
axios.post('/api/report', form)
|
||||
.then(r => {
|
||||
window.$message.success('Отчет сохранен')
|
||||
resetReportForm()
|
||||
router.visit('/')
|
||||
})
|
||||
}
|
||||
|
||||
const resetReportForm = () => {
|
||||
reportForm.value = {}
|
||||
patientsData.value.observation = []
|
||||
}
|
||||
|
||||
const $reset = () => {
|
||||
|
||||
}
|
||||
|
||||
const getReportInfo = async () => {
|
||||
await axios.get('/api/report').then((res) => {
|
||||
reportInfo.value = res.data
|
||||
})
|
||||
}
|
||||
|
||||
const getDataOnReportDate = async () => {
|
||||
await axios.get(`/api/metric-forms/1/report-by-date?sent_at=${timestampCurrentRange.value}`)
|
||||
.then(res => {
|
||||
@@ -38,7 +115,15 @@ export const useReportStore = defineStore('reportStore', () => {
|
||||
timestampCurrent,
|
||||
timestampCurrentRange,
|
||||
dataOnReport,
|
||||
patientColumns,
|
||||
patientsData,
|
||||
reportInfo,
|
||||
reportForm,
|
||||
|
||||
getDataOnReportDate
|
||||
getColumnsByKey,
|
||||
getDataOnReportDate,
|
||||
getReportInfo,
|
||||
sendReportForm,
|
||||
resetReportForm,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user