This commit is contained in:
liufumingren 2026-04-30 19:42:10 +08:00
commit e6ec226c9f
2 changed files with 56 additions and 17 deletions

View File

@ -28,6 +28,19 @@ export function getReceivingDetail(data: any): Promise<any> {
})
}
export function queryReceivingLogs(data: any): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'storage.receiving.queryReceivingLogs',
v,
timestamp: new Date().getTime()
},
data
})
}
// 未使用
// export function getReceivingProduct(data: any): Promise<any> {
// return request({

View File

@ -4,10 +4,11 @@
<el-button
type="primary"
size="small"
icon="Refresh"
@click="fetchStockInfo"
:icon="Refresh"
@click="fetchReceivingLogs"
title="刷新"
:loading="loading"
:disabled="!props.id"
class="toolbar-btn"
>
刷新
@ -85,15 +86,15 @@
</template>
<script setup lang="ts">
import { ref, reactive, watch, onMounted } from 'vue'
import { ref, reactive, watch } from 'vue'
import { useResizeObserver } from '@vueuse/core'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ElMessage } from 'element-plus'
import { Refresh } from '@element-plus/icons-vue'
import * as stockApi from '@/api/stock/stock'
import * as receivingApi from '@/api/storage_receiving/receiving'
import RequestData from '@/components/RequestData/index.vue'
const props = defineProps<{
id?: number
id?: number | string
}>()
const loading = ref(false)
@ -119,17 +120,13 @@ useResizeObserver(tableHostRef, (entries) => {
watch(() => props.id, (newVal) => {
if (newVal) {
fetchStockInfo()
pagination.page = 1
fetchReceivingLogs()
} else {
tableData.value = []
pagination.total = 0
}
})
onMounted(() => {
if (props.id) {
fetchStockInfo()
}
requestAnimationFrame(() => {
const el = tableHostRef.value
if (el) {
@ -137,26 +134,55 @@ onMounted(() => {
if (h >= 100) tableHeight.value = Math.floor(h)
}
})
})
}, { immediate: true })
async function handlePageChange(page: number) {
pagination.page = page
await fetchStockInfo()
await fetchReceivingLogs()
}
async function handlePageSizeChange(pageSize: number) {
pagination.pageSize = pageSize
pagination.page = 1
await fetchStockInfo()
await fetchReceivingLogs()
}
async function fetchStockInfo() {
async function fetchReceivingLogs() {
if (!props.id) return
loading.value = true
try {
const res: any = await receivingApi.queryReceivingLogs({
receiving_id: props.id,
pagination: {
page: pagination.page,
pageSize: pagination.pageSize
}
})
if (res && (res.code === 200 || res.code === 0 || res.code === 1)) {
const data = res.data || {}
tableData.value = Array.isArray(data.list) ? data.list : []
pagination.page = data.pagination?.page ?? pagination.page
pagination.pageSize = data.pagination?.pageSize ?? pagination.pageSize
pagination.total = data.pagination?.total ?? 0
} else {
tableData.value = []
pagination.total = 0
ElMessage.error(res?.message || '获取收货单操作日志失败')
}
} catch (error: any) {
console.error('获取收货单操作日志失败', error)
tableData.value = []
pagination.total = 0
ElMessage.error(error?.message || '获取收货单操作日志失败')
} finally {
loading.value = false
}
}
function viewData(row: any) {
requestId.value = row.external_log_id
requestId.value = Number(row.external_log_id) || 0
requestType.value = row.external_log_type
showRequestData.value = true
}