Quellcode durchsuchen

新增物料清单详情查看库存的接口

695593266@qq.com vor 2 Wochen
Ursprung
Commit
ada344f4ec

+ 9 - 1
src/api/requirementListPlan/index.js

@@ -22,6 +22,15 @@ export async function getRequirementListPlanDetailPage(params) {
   return Promise.reject(new Error(res.data.message));
 }
 
+// 查询库存台账
+export async function getStockLedger(data) {
+  const res = await request.post('/port/jiangnan/getStock', data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
 // 获取需求计划-详情
 export async function getRequirementListPlanDetail(id) {
   const res = await request.get(`/aps/materialrequirements/getById/${id}`);
@@ -284,4 +293,3 @@ export async function getOutOrderList(params) {
   }
   return Promise.reject(new Error(res.data.message));
 }
-

+ 120 - 0
src/views/requirementListPlan/components/stockLedgerDialog.vue

@@ -0,0 +1,120 @@
+<template>
+  <ele-modal
+    width="80vw"
+    :visible.sync="visible"
+    custom-class="ele-dialog-form"
+    :before-close="cancel"
+    title="库存台账"
+    :maxable="true"
+  >
+    <ele-pro-table
+      ref="table"
+      :needPage="false"
+      :columns="columns"
+      :datasource="stockList"
+      row-key="materialCode"
+      cache-key="requirement_stock_ledger_2026_06"
+      height="520px"
+    />
+
+    <div class="btns">
+      <el-button size="small" @click="cancel">关闭</el-button>
+    </div>
+  </ele-modal>
+</template>
+
+<script>
+  export default {
+    data() {
+      return {
+        visible: false,
+        stockList: [],
+        columns: [
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            fixed: 'left'
+          },
+          {
+            prop: 'materialCode',
+            label: '物料编号',
+            minWidth: 130,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'materialName',
+            label: '物料名称',
+            minWidth: 140,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'materialSpecification',
+            label: '规格',
+            minWidth: 140,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'accountingUnit',
+            label: '单位',
+            minWidth: 90,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'sumQuantity',
+            label: '台账总量',
+            minWidth: 110,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'normalQuantity',
+            label: '可用数量',
+            minWidth: 110,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'scrapQuantity',
+            label: '报废数量',
+            minWidth: 110,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'noNormalQuantity',
+            label: '非正常库存',
+            minWidth: 120,
+            align: 'center',
+            showOverflowTooltip: true
+          }
+        ]
+      };
+    },
+
+    methods: {
+      open(list) {
+        this.stockList = Array.isArray(list) ? list : [];
+        this.visible = true;
+      },
+
+      cancel() {
+        this.visible = false;
+      }
+    }
+  };
+</script>
+
+<style scoped>
+  .btns {
+    margin-top: 20px;
+    display: flex;
+    justify-content: flex-end;
+  }
+</style>

+ 53 - 3
src/views/requirementListPlan/details.vue

@@ -158,18 +158,21 @@
     <order-list ref="orderListRef" @refresh="refreshList" />
     <borrow-list ref="borrowListRef" />
     <picking-list ref="pickingListRef" />
+    <stock-ledger-dialog ref="stockLedgerDialogRef" />
   </div>
 </template>
 
 <script>
   import {
     getRequirementListPlanDetail,
-    getRequirementListPlanDetailPage
+    getRequirementListPlanDetailPage,
+    getStockLedger
   } from '@/api/requirementListPlan';
 
   import orderList from './components/orderList.vue';
   import borrowList from './components/borrowList.vue';
   import pickingList from './components/pickingList.vue';
+  import stockLedgerDialog from './components/stockLedgerDialog.vue';
   import PageHeader from '@/components/PageHeader';
 
   const COMPONENT_ATTRIBUTE_MAP = {
@@ -193,7 +196,13 @@
   };
 
   export default {
-    components: { orderList, borrowList, pickingList, PageHeader },
+    components: {
+      orderList,
+      borrowList,
+      pickingList,
+      stockLedgerDialog,
+      PageHeader
+    },
 
     data() {
       return {
@@ -205,6 +214,7 @@
         tableHeight: 'calc(100vh - 595px)',
         detailList: [],
         selection: [],
+        searchWhere: {},
 
         componentAttributeMap: COMPONENT_ATTRIBUTE_MAP,
         attributeTypeMap: ATTRIBUTE_TYPE_MAP,
@@ -459,6 +469,7 @@
       },
 
       async datasource({ page, limit, where }) {
+        this.searchWhere = where || {};
         const res = await getRequirementListPlanDetailPage({
           ...where,
           pageNum: page,
@@ -526,7 +537,45 @@
         this.$refs.borrowListRef.open(this.form);
       },
 
-      inventoryQuery() {},
+      async inventoryQuery() {
+        const loading = this.$loading({
+          lock: true,
+          fullscreen: true,
+          text: '库存查询中...'
+        });
+
+        try {
+          const res = await getRequirementListPlanDetailPage({
+            ...this.searchWhere,
+            pageNum: 1,
+            size: -1,
+            materialRequirementsId: this.$route.query.id
+          });
+
+          const materialCodes = [
+            ...new Set(
+              (res?.list || [])
+                .map((item) => item.categoryCode)
+                .filter(
+                  (code) => code !== undefined && code !== null && code !== ''
+                )
+            )
+          ];
+
+          if (!materialCodes.length) {
+            this.$message.warning('暂无可查询的物料编码');
+            return;
+          }
+
+          const stockList = await getStockLedger(materialCodes);
+          this.$refs.stockLedgerDialogRef.open(stockList || []);
+        } catch (e) {
+          console.error(e);
+          this.$message.error('库存查询失败,请稍后重试');
+        } finally {
+          loading.close();
+        }
+      },
 
       materialReturn() {
         if (!this.selection.length) {
@@ -574,6 +623,7 @@
       },
 
       search(where) {
+        this.searchWhere = where || {};
         this.reload(where);
       },