ZN
昨天 dbb8a7488164f41302c88c55c9add26d32cc69f3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<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>