From c3ec4842626d72020557a9553b11570cf78f70ce Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期三, 08 四月 2026 14:52:32 +0800
Subject: [PATCH] feat(库存管理): 重构库存管理模块并新增原材料库存页
---
src/views/inventoryManagement/stockManagement/index.vue | 40 ++++-
src/views/inventoryManagement/stockManagement/Qualified.vue | 7
src/views/inventoryManagement/stockManagement/rawMaterialRecord.vue | 213 +++++++++++++++++++++++++++++++++++
src/views/inventoryManagement/stockManagement/Unqualified.vue | 86 +++++++++-----
4 files changed, 303 insertions(+), 43 deletions(-)
diff --git a/src/views/inventoryManagement/stockManagement/Qualified.vue b/src/views/inventoryManagement/stockManagement/Qualified.vue
index 8b15db1..16ef53d 100644
--- a/src/views/inventoryManagement/stockManagement/Qualified.vue
+++ b/src/views/inventoryManagement/stockManagement/Qualified.vue
@@ -23,7 +23,9 @@
:row-class-name="tableRowClassName" height="calc(100vh - 18.5em)">
<el-table-column align="center" type="selection" width="55" />
<el-table-column align="center" label="搴忓彿" type="index" width="60" />
- <el-table-column label="浜у搧澶х被" prop="productName" show-overflow-tooltip />
+ <el-table-column label="浠撳簱缂栫爜" prop="warehouseCode" show-overflow-tooltip />
+ <el-table-column label="浠撳簱" prop="warehouseName" show-overflow-tooltip />
+ <el-table-column label="瀛樿揣缂栫爜" prop="productCode" show-overflow-tooltip />
<el-table-column label="瑙勬牸鍨嬪彿" prop="model" show-overflow-tooltip />
<el-table-column label="鍗曚綅" prop="unit" show-overflow-tooltip />
<el-table-column label="搴撳瓨鏁伴噺" prop="qualitity" show-overflow-tooltip />
@@ -99,6 +101,7 @@
const data = reactive({
searchForm: {
productName: '',
+ rootName:'鎴愬搧'
}
})
const { searchForm } = toRefs(data)
@@ -186,7 +189,7 @@
type: 'warning',
}
).then(() => {
- proxy.download("/stockInventory/exportStockInventory", {}, '鍚堟牸搴撳瓨淇℃伅.xlsx')
+ proxy.download("/stockInventory/exportStockInventory", {}, '鎴愬搧搴撳瓨淇℃伅.xlsx')
}).catch(() => {
proxy.$modal.msg("宸插彇娑�")
})
diff --git a/src/views/inventoryManagement/stockManagement/Unqualified.vue b/src/views/inventoryManagement/stockManagement/Unqualified.vue
index 9b5652d..565b410 100644
--- a/src/views/inventoryManagement/stockManagement/Unqualified.vue
+++ b/src/views/inventoryManagement/stockManagement/Unqualified.vue
@@ -10,21 +10,27 @@
<el-button type="primary" @click="handleQuery" style="margin-left: 10px">鎼滅储</el-button>
</div>
<div>
- <el-button type="primary" @click="isShowNewModal = true">鏂板搴撳瓨</el-button>
+ <el-button type="primary" @click="isShowNewModal = true">鏂板搴撳瓨</el-button>
+ <el-button type="info" plain icon="Upload" @click="isShowImportModal = true">
+ 瀵煎叆搴撳瓨
+ </el-button>
<el-button @click="handleOut">瀵煎嚭</el-button>
</div>
</div>
<div class="table_list">
<el-table :data="tableData" border v-loading="tableLoading" @selection-change="handleSelectionChange"
- :expand-row-keys="expandedRowKeys" :row-key="row => row.id" style="width: 100%"
- :row-class-name="tableRowClassName" height="calc(100vh - 18.5em)">
+ :expand-row-keys="expandedRowKeys" :row-key="row => row.id" style="width: 100%"
+ :row-class-name="tableRowClassName" height="calc(100vh - 18.5em)">
<el-table-column align="center" type="selection" width="55" />
<el-table-column align="center" label="搴忓彿" type="index" width="60" />
- <el-table-column label="浜у搧澶х被" prop="productName" show-overflow-tooltip />
+ <el-table-column label="浠撳簱缂栫爜" prop="warehouseCode" show-overflow-tooltip />
+ <el-table-column label="浠撳簱" prop="warehouseName" show-overflow-tooltip />
+ <el-table-column label="瀛樿揣缂栫爜" prop="productCode" show-overflow-tooltip />
<el-table-column label="瑙勬牸鍨嬪彿" prop="model" show-overflow-tooltip />
<el-table-column label="鍗曚綅" prop="unit" show-overflow-tooltip />
<el-table-column label="搴撳瓨鏁伴噺" prop="qualitity" show-overflow-tooltip />
<el-table-column label="鍐荤粨鏁伴噺" prop="lockedQuantity" show-overflow-tooltip />
+ <el-table-column label="搴撳瓨棰勮鏁伴噺" prop="warnNum" show-overflow-tooltip />
<el-table-column label="澶囨敞" prop="remark" show-overflow-tooltip />
<el-table-column label="鏈�杩戞洿鏂版椂闂�" prop="updateTime" show-overflow-tooltip />
<el-table-column fixed="right" label="鎿嶄綔" min-width="60" align="center">
@@ -36,24 +42,29 @@
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" layout="total, sizes, prev, pager, next, jumper"
- :page="page.current" :limit="page.size" @pagination="paginationChange" />
+ :page="page.current" :limit="page.size" @pagination="paginationChange" />
</div>
<new-stock-inventory v-if="isShowNewModal"
- v-model:visible="isShowNewModal"
- type="unqualified"
- @completed="handleQuery" />
+ v-model:visible="isShowNewModal"
+ type="qualified"
+ @completed="handleQuery" />
<subtract-stock-inventory v-if="isShowSubtractModal"
- v-model:visible="isShowSubtractModal"
- :record="record"
- type="unqualified"
- @completed="handleQuery" />
+ v-model:visible="isShowSubtractModal"
+ :record="record"
+ type="qualified"
+ @completed="handleQuery" />
+ <!-- 瀵煎叆搴撳瓨-->
+ <import-stock-inventory v-if="isShowImportModal"
+ v-model:visible="isShowImportModal"
+ type="qualified"
+ @uploadSuccess="handleQuery" />
<!-- 鍐荤粨/瑙e喕搴撳瓨-->
<frozen-and-thaw-stock-inventory v-if="isShowFrozenAndThawModal"
v-model:visible="isShowFrozenAndThawModal"
:record="record"
:operation-type="operationType"
- type="unqualified"
+ type="qualified"
@completed="handleQuery" />
</div>
</template>
@@ -61,12 +72,12 @@
<script setup>
import pagination from '@/components/PIMTable/Pagination.vue'
import { ref, reactive, toRefs, onMounted, getCurrentInstance } from 'vue'
-import { ElMessageBox } from "element-plus";
-import { getStockUninventoryListPage } from "@/api/inventoryManagement/stockUninventory.js";
+import {ElMessage, ElMessageBox} from "element-plus";
+import { getStockInventoryListPage } from "@/api/inventoryManagement/stockInventory.js";
const NewStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/New.vue"));
const SubtractStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/Subtract.vue"));
+const ImportStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/Import.vue"));
const FrozenAndThawStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/FrozenAndThaw.vue"));
-
const { proxy } = getCurrentInstance()
const tableData = ref([])
const selectedRows = ref([])
@@ -81,13 +92,17 @@
const isShowNewModal = ref(false)
// 鏄惁鏄剧ず棰嗙敤寮规
const isShowSubtractModal = ref(false)
+
// 鏄惁鏄剧ず鍐荤粨/瑙e喕寮规
const isShowFrozenAndThawModal = ref(false)
// 鎿嶄綔绫诲瀷
const operationType = ref('frozen')
+// 鏄惁鏄剧ず瀵煎叆寮规
+const isShowImportModal = ref(false)
const data = reactive({
searchForm: {
productName: '',
+ rootName:'杈呮潗'
}
})
const { searchForm } = toRefs(data)
@@ -105,7 +120,7 @@
}
const getList = () => {
tableLoading.value = true
- getStockUninventoryListPage({ ...searchForm.value, ...page }).then(res => {
+ getStockInventoryListPage({ ...searchForm.value, ...page }).then(res => {
tableLoading.value = false
tableData.value = res.data.records
total.value = res.data.total
@@ -115,6 +130,17 @@
tableLoading.value = false
})
}
+
+const handleFileSuccess = (response) => {
+ const { code, msg } = response;
+ if (code == 200) {
+ ElMessage({ message: "瀵煎叆鎴愬姛", type: "success" });
+ upload.open = false;
+ emits("uploadSuccess");
+ } else {
+ ElMessage({ message: msg, type: "error" });
+ }
+};
// 鐐瑰嚮棰嗙敤
const showSubtractModal = (row) => {
@@ -146,25 +172,25 @@
// 琛ㄦ牸琛岀被鍚�
const tableRowClassName = ({ row }) => {
- // const stock = Number(row?.unLockedQuantity ?? 0);
- // const warn = Number(row?.warnNum ?? 0);
- // if (!Number.isFinite(stock) || !Number.isFinite(warn)) {
- // return '';
- // }
- // return stock < warn ? 'row-low-stock' : '';
+ const stock = Number(row?.unLockedQuantity ?? 0);
+ const warn = Number(row?.warnNum ?? 0);
+ if (!Number.isFinite(stock) || !Number.isFinite(warn)) {
+ return '';
+ }
+ return stock < warn ? 'row-low-stock' : '';
};
// 瀵煎嚭
const handleOut = () => {
ElMessageBox.confirm(
- '鏄惁纭瀵煎嚭锛�',
- '瀵煎嚭', {
- confirmButtonText: '纭',
- cancelButtonText: '鍙栨秷',
- type: 'warning',
- }
+ '鏄惁纭瀵煎嚭锛�',
+ '瀵煎嚭', {
+ confirmButtonText: '纭',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning',
+ }
).then(() => {
- proxy.download("/stockUninventory/exportStockUninventory", {}, '涓嶅悎鏍煎簱瀛樹俊鎭�.xlsx')
+ proxy.download("/stockInventory/exportStockInventory", {}, '杈呮潗搴撳瓨淇℃伅.xlsx')
}).catch(() => {
proxy.$modal.msg("宸插彇娑�")
})
diff --git a/src/views/inventoryManagement/stockManagement/index.vue b/src/views/inventoryManagement/stockManagement/index.vue
index 347de38..2323fa5 100644
--- a/src/views/inventoryManagement/stockManagement/index.vue
+++ b/src/views/inventoryManagement/stockManagement/index.vue
@@ -1,33 +1,51 @@
<template>
<div class="app-container">
<el-tabs v-model="activeTab" @tab-change="handleTabChange">
- <el-tab-pane v-for="tab in tabs"
- :label="tab.label"
- :name="tab.name"
- :key="tab.name">
- <component :is="tab.name === 'qualified' ? QualifiedRecord : UnqualifiedRecord" />
+ <el-tab-pane
+ v-for="tab in tabs"
+ :label="tab.label"
+ :name="tab.name"
+ :key="tab.name"
+ >
+ <component
+ :is="tab.component"
+ v-if="activeTab === tab.name"
+ :stock-type="tab.name"
+ />
</el-tab-pane>
</el-tabs>
</div>
</template>
<script setup>
+// 1. 瀵煎叆 shallowRef
+import { ref, shallowRef } from 'vue'
import QualifiedRecord from "@/views/inventoryManagement/stockManagement/Qualified.vue";
import UnqualifiedRecord from "@/views/inventoryManagement/stockManagement/Unqualified.vue";
+import rawMaterialRecord from "@/views/inventoryManagement/stockManagement/rawMaterialRecord.vue"
const activeTab = ref('qualified')
-const tabs = ref([
+
+// 2. 鍏抽敭锛歵abs 鐢� shallowRef 鍖呰9
+const tabs = shallowRef([
{
- label: '鍚堟牸搴撳瓨',
- name: 'qualified'
+ label: '鎴愬搧搴撳瓨',
+ name: 'qualified',
+ component: QualifiedRecord
},
{
- label: '涓嶅悎鏍煎簱瀛�',
- name: 'unqualified'
+ label: '杈呮潗搴撳瓨',
+ name: 'assistant',
+ component: UnqualifiedRecord
+ },
+ {
+ label: '鍘熸潗鏂欏簱瀛�',
+ name: 'rawMaterial',
+ component: rawMaterialRecord
}
])
const handleTabChange = (tabName) => {
activeTab.value = tabName;
}
-</script>
+</script>
\ No newline at end of file
diff --git a/src/views/inventoryManagement/stockManagement/rawMaterialRecord.vue b/src/views/inventoryManagement/stockManagement/rawMaterialRecord.vue
new file mode 100644
index 0000000..78feab1
--- /dev/null
+++ b/src/views/inventoryManagement/stockManagement/rawMaterialRecord.vue
@@ -0,0 +1,213 @@
+<template>
+ <div class="app-container">
+ <div class="search_form">
+ <div>
+ <span class="search_title ml10">浜у搧澶х被锛�</span>
+ <el-input v-model="searchForm.productName"
+ style="width: 240px"
+ placeholder="璇疯緭鍏�"
+ clearable/>
+ <el-button type="primary" @click="handleQuery" style="margin-left: 10px">鎼滅储</el-button>
+ </div>
+ <div>
+ <el-button type="primary" @click="isShowNewModal = true">鏂板搴撳瓨</el-button>
+ <el-button type="info" plain icon="Upload" @click="isShowImportModal = true">
+ 瀵煎叆搴撳瓨
+ </el-button>
+ <el-button @click="handleOut">瀵煎嚭</el-button>
+ </div>
+ </div>
+ <div class="table_list">
+ <el-table :data="tableData" border v-loading="tableLoading" @selection-change="handleSelectionChange"
+ :expand-row-keys="expandedRowKeys" :row-key="row => row.id" style="width: 100%"
+ :row-class-name="tableRowClassName" height="calc(100vh - 18.5em)">
+ <el-table-column align="center" type="selection" width="55" />
+ <el-table-column align="center" label="搴忓彿" type="index" width="60" />
+ <el-table-column label="浠撳簱缂栫爜" prop="warehouseCode" show-overflow-tooltip />
+ <el-table-column label="浠撳簱" prop="warehouseName" show-overflow-tooltip />
+ <el-table-column label="瀛樿揣缂栫爜" prop="productCode" show-overflow-tooltip />
+ <el-table-column label="瑙勬牸鍨嬪彿" prop="model" show-overflow-tooltip />
+ <el-table-column label="鍗曚綅" prop="unit" show-overflow-tooltip />
+ <el-table-column label="搴撳瓨鏁伴噺" prop="qualitity" show-overflow-tooltip />
+ <el-table-column label="鍐荤粨鏁伴噺" prop="lockedQuantity" show-overflow-tooltip />
+ <el-table-column label="搴撳瓨棰勮鏁伴噺" prop="warnNum" show-overflow-tooltip />
+ <el-table-column label="澶囨敞" prop="remark" show-overflow-tooltip />
+ <el-table-column label="鏈�杩戞洿鏂版椂闂�" prop="updateTime" show-overflow-tooltip />
+ <el-table-column fixed="right" label="鎿嶄綔" min-width="60" align="center">
+ <template #default="scope">
+ <el-button link type="primary" size="small" @click="showSubtractModal(scope.row)" :disabled="scope.row.unLockedQuantity === 0">棰嗙敤</el-button>
+ <el-button link type="primary" size="small" v-if="scope.row.unLockedQuantity > 0" @click="showFrozenModal(scope.row)">鍐荤粨</el-button>
+ <el-button link type="primary" size="small" v-if="scope.row.lockedQuantity > 0" @click="showThawModal(scope.row)">瑙e喕</el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ <pagination v-show="total > 0" :total="total" layout="total, sizes, prev, pager, next, jumper"
+ :page="page.current" :limit="page.size" @pagination="paginationChange" />
+ </div>
+ <new-stock-inventory v-if="isShowNewModal"
+ v-model:visible="isShowNewModal"
+ type="qualified"
+ @completed="handleQuery" />
+
+ <subtract-stock-inventory v-if="isShowSubtractModal"
+ v-model:visible="isShowSubtractModal"
+ :record="record"
+ type="qualified"
+ @completed="handleQuery" />
+ <!-- 瀵煎叆搴撳瓨-->
+ <import-stock-inventory v-if="isShowImportModal"
+ v-model:visible="isShowImportModal"
+ type="qualified"
+ @uploadSuccess="handleQuery" />
+ <!-- 鍐荤粨/瑙e喕搴撳瓨-->
+ <frozen-and-thaw-stock-inventory v-if="isShowFrozenAndThawModal"
+ v-model:visible="isShowFrozenAndThawModal"
+ :record="record"
+ :operation-type="operationType"
+ type="qualified"
+ @completed="handleQuery" />
+ </div>
+</template>
+
+<script setup>
+import pagination from '@/components/PIMTable/Pagination.vue'
+import { ref, reactive, toRefs, onMounted, getCurrentInstance } from 'vue'
+import {ElMessage, ElMessageBox} from "element-plus";
+import { getStockInventoryListPage } from "@/api/inventoryManagement/stockInventory.js";
+const NewStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/New.vue"));
+const SubtractStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/Subtract.vue"));
+const ImportStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/Import.vue"));
+const FrozenAndThawStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/FrozenAndThaw.vue"));
+const { proxy } = getCurrentInstance()
+const tableData = ref([])
+const selectedRows = ref([])
+const record = ref({})
+const tableLoading = ref(false)
+const page = reactive({
+ current: 1,
+ size: 100,
+})
+const total = ref(0)
+// 鏄惁鏄剧ず鏂板寮规
+const isShowNewModal = ref(false)
+// 鏄惁鏄剧ず棰嗙敤寮规
+const isShowSubtractModal = ref(false)
+
+// 鏄惁鏄剧ず鍐荤粨/瑙e喕寮规
+const isShowFrozenAndThawModal = ref(false)
+// 鎿嶄綔绫诲瀷
+const operationType = ref('frozen')
+// 鏄惁鏄剧ず瀵煎叆寮规
+const isShowImportModal = ref(false)
+const data = reactive({
+ searchForm: {
+ productName: '',
+ rootName:'鍘熸潗鏂�'
+ }
+})
+const { searchForm } = toRefs(data)
+
+// 鏌ヨ鍒楄〃
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+ page.current = 1
+ getList()
+}
+const paginationChange = (obj) => {
+ page.current = obj.page;
+ page.size = obj.limit;
+ getList()
+}
+const getList = () => {
+ tableLoading.value = true
+ getStockInventoryListPage({ ...searchForm.value, ...page }).then(res => {
+ tableLoading.value = false
+ tableData.value = res.data.records
+ total.value = res.data.total
+ // 鏁版嵁鍔犺浇瀹屾垚鍚庢鏌ュ簱瀛�
+ // checkStockAndCreatePurchase();
+ }).catch(() => {
+ tableLoading.value = false
+ })
+}
+
+const handleFileSuccess = (response) => {
+ const { code, msg } = response;
+ if (code == 200) {
+ ElMessage({ message: "瀵煎叆鎴愬姛", type: "success" });
+ upload.open = false;
+ emits("uploadSuccess");
+ } else {
+ ElMessage({ message: msg, type: "error" });
+ }
+};
+
+// 鐐瑰嚮棰嗙敤
+const showSubtractModal = (row) => {
+ record.value = row
+ isShowSubtractModal.value = true
+}
+
+// 鐐瑰嚮鍐荤粨
+const showFrozenModal = (row) => {
+ record.value = row
+ isShowFrozenAndThawModal.value = true
+ operationType.value = 'frozen'
+}
+
+// 鐐瑰嚮瑙e喕
+const showThawModal = (row) => {
+ record.value = row
+ isShowFrozenAndThawModal.value = true
+ operationType.value = 'thaw'
+}
+
+// 琛ㄦ牸閫夋嫨鏁版嵁
+const handleSelectionChange = (selection) => {
+ // 杩囨护鎺夊瓙鏁版嵁
+ selectedRows.value = selection.filter(item => item.id);
+ console.log('selection', selectedRows.value)
+}
+const expandedRowKeys = ref([])
+
+// 琛ㄦ牸琛岀被鍚�
+const tableRowClassName = ({ row }) => {
+ const stock = Number(row?.unLockedQuantity ?? 0);
+ const warn = Number(row?.warnNum ?? 0);
+ if (!Number.isFinite(stock) || !Number.isFinite(warn)) {
+ return '';
+ }
+ return stock < warn ? 'row-low-stock' : '';
+};
+
+// 瀵煎嚭
+const handleOut = () => {
+ ElMessageBox.confirm(
+ '鏄惁纭瀵煎嚭锛�',
+ '瀵煎嚭', {
+ confirmButtonText: '纭',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning',
+ }
+ ).then(() => {
+ proxy.download("/stockInventory/exportStockInventory", {}, '鍘熸潗鏂欏簱瀛樹俊鎭�.xlsx')
+ }).catch(() => {
+ proxy.$modal.msg("宸插彇娑�")
+ })
+}
+
+onMounted(() => {
+ getList()
+})
+</script>
+
+<style scoped lang="scss">
+:deep(.row-low-stock td) {
+ background-color: #fde2e2;
+ color: #c45656;
+}
+
+:deep(.row-low-stock:hover > td) {
+ background-color: #fcd4d4;
+}
+</style>
--
Gitblit v1.9.3