Поиск, работа над query в js

This commit is contained in:
brusnitsyn
2025-12-01 17:38:11 +09:00
parent c9a392f84f
commit 063ddafdfb
8 changed files with 160 additions and 6 deletions

View File

@@ -0,0 +1,16 @@
<script setup>
import { NModal } from 'naive-ui'
const open = defineModel('open')
</script>
<template>
<NModal v-model:show="open">
<template #header>
</template>
</NModal>
</template>
<style scoped>
</style>

View File

@@ -1,12 +1,18 @@
<script setup>
import {NDataTable, NEllipsis} from "naive-ui"
import {h, ref} from "vue"
import {h, reactive, ref} from "vue"
import {useMedicalHistory} from "../../../Composables/useMedicalHistory.js";
const { navigate } = useMedicalHistory('/')
const props = defineProps({
data: {
type: Array,
default: []
},
meta: {
type: Object,
default: {}
},
maxHeight: {
type: String,
default: null
@@ -67,10 +73,28 @@ const columns = ref([
render: (row) => h(NEllipsis, null, { default: () => row.status || '-' })
}
])
const paginationReactive = reactive({
page: props.meta.current_page,
pageCount: props.meta.last_page,
pageSize: props.meta.per_page,
itemCount: props.meta.total,
pageSizes: [15, 50, 100],
showSizePicker: true,
prefix({ itemCount }) {
return `Всего карт ${itemCount}.`
},
onUpdatePage(page) {
navigate(undefined, page)
},
onUpdatePageSize(pageSize) {
navigate(undefined, 1, pageSize)
}
})
</script>
<template>
<NDataTable remote striped :columns="columns" :max-height="maxHeight" size="small" :min-height="minHeight" :data="data" />
<NDataTable remote striped :columns="columns" :pagination="paginationReactive" :max-height="maxHeight" size="small" :min-height="minHeight" :data="data" />
</template>
<style scoped>

View File

@@ -2,6 +2,8 @@
import AppLayout from "../../Layouts/AppLayout.vue"
import TableCards from './DataTable/Index.vue'
import { NInput, NFlex, NDivider, NDatePicker } from 'naive-ui'
import {useMedicalHistory} from "../../Composables/useMedicalHistory.js";
import {useDebounceFn} from "@vueuse/core";
const props = defineProps({
cards: {
@@ -9,18 +11,28 @@ const props = defineProps({
default: []
}
})
const { navigate } = useMedicalHistory('/')
const search = (value) => {
navigate(value)
}
const debounceSearch = useDebounceFn((searchValue) => {
search(searchValue)
}, 500)
</script>
<template>
<AppLayout>
<template #header>
<NFlex class="py-4" align="center" :wrap="false">
<NInput placeholder="Поиск по ФИО, № карты" />
<NInput placeholder="Поиск по ФИО, № карты" @update:value="val => debounceSearch(val)"/>
<NDivider vertical />
<NDatePicker type="daterange" clearable start-placeholder="Дата выписки с" end-placeholder="по" />
<NDatePicker type="daterange" clearable format="dd.MM.yyyy" start-placeholder="Дата выписки с" end-placeholder="по" />
</NFlex>
</template>
<TableCards :data="cards.data" min-height="calc(100vh - 136px)" max-height="calc(100vh - 136px)" />
<TableCards :data="cards.data" :meta="cards.meta" min-height="calc(100vh - 179px)" max-height="calc(100vh - 196px)" />
</AppLayout>
</template>