<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" :detail="detailData" />
|
</div>
|
</template>
|
|
<script setup>
|
import { computed, ref } from 'vue'
|
import { useTable } from '@/hooks/core/useTable'
|
import { 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 searchForm = ref(createInStatisticItemSearchState())
|
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: 'locCode', type: 'input', props: { clearable: true, placeholder: '请输入库位' } },
|
{ label: '物料编码', key: 'matnrCode', type: 'input', props: { clearable: true, placeholder: '请输入物料编码' } },
|
{ label: '物料名称', key: 'maktx', type: 'input', props: { clearable: true, placeholder: '请输入物料名称' } },
|
{ label: '批次', key: 'batch', type: 'input', props: { clearable: true, placeholder: '请输入批次' } }
|
])
|
|
function openDetail(row) {
|
detailData.value = normalizeInStatisticItemRow(row)
|
detailDrawerVisible.value = true
|
}
|
|
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>
|