<template>
|
<div class="in-statistic-page art-full-height">
|
<ArtSearchBar
|
v-model="searchForm"
|
:items="searchItems"
|
:showExpand="true"
|
@search="handleSearch"
|
@reset="handleReset"
|
/>
|
<ElCard class="art-table-card">
|
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData" />
|
<ArtTable
|
:loading="loading"
|
:data="data"
|
:columns="columns"
|
:pagination="pagination"
|
@pagination:size-change="handleSizeChange"
|
@pagination:current-change="handleCurrentChange"
|
/>
|
</ElCard>
|
<InStatisticDetailDrawer v-model:visible="detailDrawerVisible" :detail="detailData" />
|
</div>
|
</template>
|
|
<script setup>
|
import { computed, ref } from 'vue'
|
import { useTable } from '@/hooks/core/useTable'
|
import { fetchInStatisticPage } from '@/api/in-statistic'
|
import {
|
buildInStatisticPageQueryParams,
|
buildInStatisticSearchParams,
|
createInStatisticSearchState,
|
getInStatisticPaginationKey,
|
normalizeInStatisticRow
|
} from './inStatisticPage.helpers'
|
import { createInStatisticTableColumns } from './inStatisticTable.columns'
|
import InStatisticDetailDrawer from './modules/in-statistic-detail-drawer.vue'
|
|
defineOptions({ name: 'InStatistic' })
|
|
const searchForm = ref(createInStatisticSearchState())
|
const detailDrawerVisible = ref(false)
|
const detailData = ref({})
|
|
const searchItems = computed(() => [
|
{ label: '关键字', key: 'condition', type: 'input', props: { clearable: true, placeholder: '请输入物料名称/编码/批次' } },
|
{ label: '统计日期', key: 'dayTime', type: 'date', props: { clearable: true, type: 'date', valueFormat: 'YYYY-MM-DD' } },
|
{ label: '物料名称', key: 'maktx', type: 'input', props: { clearable: true, placeholder: '请输入物料名称' } },
|
{ label: '物料编码', key: 'matnrCode', type: 'input', props: { clearable: true, placeholder: '请输入物料编码' } },
|
{ label: '批次', key: 'batch', type: 'input', props: { clearable: true, placeholder: '请输入批次' } }
|
])
|
|
function openDetail(row) {
|
detailData.value = normalizeInStatisticRow(row)
|
detailDrawerVisible.value = true
|
}
|
|
const {
|
columns,
|
columnChecks,
|
data,
|
loading,
|
pagination,
|
getData,
|
replaceSearchParams,
|
resetSearchParams,
|
handleSizeChange,
|
handleCurrentChange,
|
refreshData
|
} = useTable({
|
core: {
|
apiFn: fetchInStatisticPage,
|
apiParams: buildInStatisticPageQueryParams(searchForm.value),
|
paginationKey: getInStatisticPaginationKey(),
|
columnsFactory: () => createInStatisticTableColumns({ handleView: openDetail })
|
},
|
transform: {
|
dataTransformer: (records) => (Array.isArray(records) ? records.map((item) => normalizeInStatisticRow(item)) : [])
|
}
|
})
|
|
function handleSearch(params) {
|
replaceSearchParams(buildInStatisticSearchParams(params))
|
getData()
|
}
|
|
function handleReset() {
|
Object.assign(searchForm.value, createInStatisticSearchState())
|
resetSearchParams()
|
}
|
</script>
|