From e83b458dad9bf8fcd98e889cf3cf234481014183 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期三, 21 十月 2026 01:24:11 +0800
Subject: [PATCH] feat: 添加产品规格筛选功能,优化查询表单默认值和布局
---
src/views/procurementManagement/procurementReport/index.vue | 93 +++++++++++++++++++++++++++++-----------------
1 files changed, 58 insertions(+), 35 deletions(-)
diff --git a/src/views/procurementManagement/procurementReport/index.vue b/src/views/procurementManagement/procurementReport/index.vue
index 37ca1f8..e491a08 100644
--- a/src/views/procurementManagement/procurementReport/index.vue
+++ b/src/views/procurementManagement/procurementReport/index.vue
@@ -25,6 +25,22 @@
style="width: 200px"
/>
</el-form-item>
+ <el-form-item label="浜у搧瑙勬牸锛�">
+ <el-select
+ v-model="searchForm.specificationModel"
+ placeholder="璇烽�夋嫨浜у搧瑙勬牸"
+ clearable
+ filterable
+ style="width: 200px"
+ >
+ <el-option
+ v-for="m in modelOptions"
+ :key="m.value"
+ :label="m.label"
+ :value="m.value"
+ />
+ </el-select>
+ </el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch" :loading="loading">
鏌ヨ
@@ -92,11 +108,15 @@
// 鎼滅储琛ㄥ崟
const searchForm = reactive({
dateRange: [],
- productCategory: ''
+ productCategory: '',
+ specificationModel: ''
})
// 浜у搧绫诲埆鏍戦�夐」
const productOptions = ref([])
+
+// 浜у搧瑙勬牸閫夐」锛堟寜鎶ヨ〃瀹為檯鍑虹幇鐨勮鏍煎姩鎬佺敓鎴愶級
+const modelOptions = ref([])
// 缁熻鏁版嵁
const businessSummaryStats = ref({
@@ -234,53 +254,55 @@
try {
loading.value = true
const params = {}
-
+
// 鏃堕棿鑼冨洿
if (searchForm.dateRange && searchForm.dateRange.length === 2) {
params.entryDateStart = searchForm.dateRange[0]
params.entryDateEnd = searchForm.dateRange[1]
}
-
- // 浜у搧绫诲埆
+
+ // 浜у搧澶х被
if (searchForm.productCategory) {
const categoryName = findNodeLabelById(productOptions.value, searchForm.productCategory)
if (categoryName) {
params.productCategory = categoryName
}
}
-
- // 鍒嗛〉鍙傛暟
- params.current = page.current
- params.size = page.size
+
+ // 鎶ヨ〃鎸夈�屼骇鍝佸ぇ绫�+瑙勬牸+渚涘簲鍟嗐�嶈仛鍚堬紝鏁版嵁閲忓皬锛屼竴娆″彇鍥炲悗鎸夎鏍兼湰鍦拌繃婊�
+ params.current = 1
+ params.size = 1000
const res = await procurementBusinessSummaryListPage(params)
- if (res && res.data) {
- // 鍏煎鍚庣鍙兘鐩存帴杩斿洖鏁扮粍/鎴栬繑鍥炲垎椤靛璞�
- businessSummaryData.value = Array.isArray(res.data) ? res.data : (res.data.records || [])
+ const payload = res && res.data !== undefined ? res.data : res
+ let rows = Array.isArray(payload) ? payload : ((payload && payload.records) || [])
- if (!Array.isArray(res.data)) {
- page.total = Number(res.data.total ?? 0)
- page.current = Number(res.data.current ?? page.current)
- page.size = Number(res.data.size ?? page.size)
- }
-
- // 璁$畻缁熻鏁版嵁
- if (businessSummaryData.value.length > 0) {
- businessSummaryStats.value.totalAmount = businessSummaryData.value.reduce((sum, item) => {
- return sum + (parseFloat(item.purchaseAmount) || 0)
- }, 0)
- businessSummaryStats.value.returnAmount = businessSummaryData.value.reduce((sum, item) => {
- return sum + (parseFloat(item.returnAmount) || 0)
- }, 0)
- businessSummaryStats.value.productTypes = businessSummaryData.value.length
- } else {
- businessSummaryStats.value = {
- totalAmount: 0,
- returnAmount: 0,
- productTypes: 0
- }
- }
+ // 瑙勬牸涓嬫媺閫夐」闅忓綋鍓嶆煡璇㈢粨鏋滃姩鎬佺敓鎴�
+ const specSet = []
+ rows.forEach((item) => {
+ const sp = item.specificationModel
+ if (sp && specSet.indexOf(sp) === -1) specSet.push(sp)
+ })
+ modelOptions.value = specSet.sort().map((sp) => ({ label: sp, value: sp }))
+
+ // 浜у搧瑙勬牸杩囨护
+ if (searchForm.specificationModel) {
+ rows = rows.filter((item) => item.specificationModel === searchForm.specificationModel)
}
+
+ page.total = rows.length
+ if (page.current < 1) page.current = 1
+ const startIdx = (page.current - 1) * page.size
+ businessSummaryData.value = rows.slice(startIdx, startIdx + page.size)
+
+ // 缁熻鎸夊叏閲忚繃婊ょ粨鏋滃彛寰�
+ businessSummaryStats.value.totalAmount = rows.reduce((sum, item) => {
+ return sum + (parseFloat(item.purchaseAmount) || 0)
+ }, 0)
+ businessSummaryStats.value.returnAmount = rows.reduce((sum, item) => {
+ return sum + (parseFloat(item.returnAmount) || 0)
+ }, 0)
+ businessSummaryStats.value.productTypes = rows.length
} catch (error) {
console.error('鏌ヨ澶辫触:', error)
} finally {
@@ -298,7 +320,8 @@
const resetSearch = () => {
Object.assign(searchForm, {
dateRange: [],
- productCategory: ''
+ productCategory: '',
+ specificationModel: ''
})
page.current = 1
handleSearch()
@@ -326,7 +349,7 @@
onMounted(() => {
- // 鍒濆鍖栦骇鍝佺被鍒爲
+ // 鍒濆鍖栦骇鍝佺被鍒爲銆佷骇鍝佽鏍�
getProductOptions()
// 璁剧疆榛樿鏃堕棿鑼冨洿涓烘渶杩�30澶�
--
Gitblit v1.9.3