<template>
|
<div class="in-statistic-item-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>
|
|
<InStatisticItemDetailDrawer
|
v-model:visible="detailDrawerVisible"
|
:loading="detailLoading"
|
:detail="detailData"
|
/>
|
</div>
|
</template>
|
|
<script setup>
|
import { computed, ref } from 'vue'
|
import { useI18n } from 'vue-i18n'
|
import { useTable } from '@/hooks/core/useTable'
|
import { fetchGetInStatisticItemDetail, fetchInStatisticItemPage } from '@/api/in-statistic-item'
|
import {
|
buildInStatisticItemPageQueryParams,
|
buildInStatisticItemSearchParams,
|
createInStatisticItemSearchState,
|
getInStatisticItemPaginationKey,
|
normalizeInStatisticItemRow
|
} from './inStatisticItemPage.helpers'
|
import { createInStatisticItemTableColumns } from './inStatisticItemTable.columns'
|
import InStatisticItemDetailDrawer from './modules/in-statistic-item-detail-drawer.vue'
|
|
defineOptions({ name: 'InStatisticItem' })
|
const { t } = useI18n()
|
|
const searchForm = ref(createInStatisticItemSearchState())
|
const detailDrawerVisible = ref(false)
|
const detailLoading = ref(false)
|
const detailData = ref({})
|
|
const searchItems = computed(() => [
|
{
|
label: t('pages.manager.inStatisticItem.search.condition'),
|
key: 'condition',
|
type: 'input',
|
props: {
|
clearable: true,
|
placeholder: t('pages.manager.inStatisticItem.search.conditionPlaceholder')
|
}
|
},
|
{
|
label: t('pages.manager.inStatisticItem.search.dayTime'),
|
key: 'dayTime',
|
type: 'date',
|
props: {
|
clearable: true,
|
type: 'date',
|
valueFormat: 'YYYY-MM-DD'
|
}
|
},
|
{
|
label: t('pages.manager.inStatisticItem.search.maktx'),
|
key: 'maktx',
|
type: 'input',
|
props: {
|
clearable: true,
|
placeholder: t('pages.manager.inStatisticItem.search.maktxPlaceholder')
|
}
|
},
|
{
|
label: t('pages.manager.inStatisticItem.search.matnrCode'),
|
key: 'matnrCode',
|
type: 'input',
|
props: {
|
clearable: true,
|
placeholder: t('pages.manager.inStatisticItem.search.matnrCodePlaceholder')
|
}
|
},
|
{
|
label: t('pages.manager.inStatisticItem.search.batch'),
|
key: 'batch',
|
type: 'input',
|
props: {
|
clearable: true,
|
placeholder: t('pages.manager.inStatisticItem.search.batchPlaceholder')
|
}
|
}
|
])
|
|
async function openDetail(row) {
|
const normalizedRow = normalizeInStatisticItemRow(row)
|
detailDrawerVisible.value = true
|
detailLoading.value = true
|
detailData.value = normalizedRow
|
|
try {
|
if (row?.id === void 0 || row?.id === null || row?.id === '') {
|
return
|
}
|
const response = await fetchGetInStatisticItemDetail(row.id)
|
const detail = response?.data?.data ?? response?.data ?? response ?? {}
|
detailData.value = normalizeInStatisticItemRow(detail)
|
} finally {
|
detailLoading.value = false
|
}
|
}
|
|
const {
|
columns,
|
columnChecks,
|
data,
|
loading,
|
pagination,
|
getData,
|
replaceSearchParams,
|
resetSearchParams,
|
handleSizeChange,
|
handleCurrentChange,
|
refreshData
|
} = useTable({
|
core: {
|
apiFn: fetchInStatisticItemPage,
|
apiParams: buildInStatisticItemPageQueryParams(searchForm.value),
|
paginationKey: getInStatisticItemPaginationKey(),
|
columnsFactory: () =>
|
createInStatisticItemTableColumns({
|
handleView: openDetail
|
})
|
},
|
transform: {
|
dataTransformer: (records) =>
|
Array.isArray(records) ? records.map((item) => normalizeInStatisticItemRow(item)) : []
|
}
|
})
|
|
function handleSearch(params) {
|
replaceSearchParams(buildInStatisticItemSearchParams(params))
|
getData()
|
}
|
|
function handleReset() {
|
Object.assign(searchForm.value, createInStatisticItemSearchState())
|
resetSearchParams()
|
}
|
</script>
|