<template>
|
<view class="qualified-record-container">
|
<view class="search-section">
|
<view class="search-bar">
|
<view class="search-input">
|
<up-input
|
class="search-text"
|
placeholder="请输入产品大类"
|
v-model="searchForm.productName"
|
@confirm="handleQuery"
|
clearable
|
/>
|
</view>
|
<view class="filter-button" @click="handleQuery">
|
<up-icon name="search" size="24" color="#999"></up-icon>
|
</view>
|
</view>
|
</view>
|
|
<scroll-view scroll-y class="ledger-list" v-if="tableData.length > 0" @scrolltolower="loadMore">
|
<view v-for="item in tableData" :key="item.id" class="ledger-item" :class="{ 'low-stock': isLowStock(item) }">
|
<view class="item-header">
|
<view class="item-left">
|
<view class="document-icon">
|
<up-icon name="file-text" size="16" color="#ffffff"></up-icon>
|
</view>
|
<text class="item-id">{{ item.productName }}</text>
|
</view>
|
<view class="item-right">
|
<text class="item-tag tag-type">合格库存</text>
|
</view>
|
</view>
|
|
<up-divider></up-divider>
|
|
<view class="item-details">
|
<view class="detail-row">
|
<text class="detail-label">规格型号</text>
|
<text class="detail-value">{{ item.model }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">库存数量</text>
|
<text class="detail-value">{{ item.qualitity }} {{ item.unit }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">锁定/冻结</text>
|
<text class="detail-value">{{ item.lockedQuantity }} {{ item.unit }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">可用库存</text>
|
<text class="detail-value" style="color: #2979ff; font-weight: bold;">{{ item.unLockedQuantity }} {{ item.unit }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">库存预警</text>
|
<text class="detail-value">{{ item.warnNum }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">更新时间</text>
|
<text class="detail-value">{{ item.updateTime }}</text>
|
</view>
|
</view>
|
</view>
|
<up-loadmore :status="loadStatus" />
|
</scroll-view>
|
<view v-else-if="!loading" class="no-data">
|
<up-empty mode="data" text="暂无库存数据"></up-empty>
|
</view>
|
</view>
|
</template>
|
|
<script setup>
|
import { ref, reactive, onMounted } from 'vue';
|
import { getStockInventoryListPage } from "@/api/inventoryManagement/stockInventory.js";
|
|
const tableData = ref([]);
|
const loading = ref(false);
|
const loadStatus = ref('loadmore');
|
const page = reactive({ current: 1, size: 10 });
|
const total = ref(0);
|
const searchForm = reactive({ productName: '' });
|
|
const handleQuery = () => {
|
page.current = 1;
|
tableData.value = [];
|
getList();
|
};
|
|
const getList = () => {
|
if (loading.value) return;
|
loading.value = true;
|
loadStatus.value = 'loading';
|
getStockInventoryListPage({ ...searchForm, ...page, type: 'qualified' }).then(res => {
|
loading.value = false;
|
const records = res.data.records || [];
|
tableData.value = page.current === 1 ? records : [...tableData.value, ...records];
|
total.value = res.data.total;
|
loadStatus.value = tableData.value.length >= total.value ? 'nomore' : 'loadmore';
|
}).catch(() => {
|
loading.value = false;
|
loadStatus.value = 'loadmore';
|
});
|
};
|
|
const loadMore = () => {
|
if (loadStatus.value === 'nomore' || loading.value) return;
|
page.current++;
|
getList();
|
};
|
|
const isLowStock = (row) => {
|
const stock = Number(row?.unLockedQuantity ?? 0);
|
const warn = Number(row?.warnNum ?? 0);
|
return Number.isFinite(stock) && Number.isFinite(warn) && stock < warn;
|
};
|
|
onMounted(() => {
|
getList();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
@import '@/styles/sales-common.scss';
|
|
.qualified-record-container {
|
height: 100%;
|
display: flex;
|
flex-direction: column;
|
}
|
|
.tag-type {
|
background-color: #e3f2fd;
|
color: #2196f3;
|
padding: 2px 8px;
|
border-radius: 4px;
|
font-size: 12px;
|
}
|
|
.ledger-list {
|
flex: 1;
|
overflow-y: auto;
|
}
|
|
.low-stock {
|
background-color: #fde2e2;
|
color: #c45656;
|
}
|
|
.no-data {
|
padding-top: 100px;
|
}
|
</style>
|