Browse Source

库存快照页面

lxf 1 year ago
parent
commit
5cb7b63fdd

+ 2 - 4
src/views/group/order/management/add.vue

@@ -318,11 +318,9 @@ import byForm from "@/components/byForm/index";
 import { ElMessage } from "element-plus";
 import Editor from "@/components/Editor/index.vue";
 import { useRouter, useRoute } from "vue-router";
-import useTagsViewStore from "@/store/modules/tagsView.js";
 import SelectProduct from "@/views/group/product/management/index";
 import SelectBOM from "@/views/group/BOM/management/index";
-import useUserStore from "@/store/modules/tagsView";
-import { get } from "@vueuse/core";
+import useTagsViewStore from "@/store/modules/tagsView";
 
 const { proxy } = getCurrentInstance();
 const router = useRouter();
@@ -545,7 +543,7 @@ const clickCancel = () => {
 };
 onMounted(() => {
   if (route.query && (route.query.id || route.query.detailId)) {
-    useUserStore().visitedViews = useUserStore().visitedViews.map((item) => {
+    useTagsViewStore().visitedViews = useTagsViewStore().visitedViews.map((item) => {
       if (item.query && item.query.random === route.query.random) {
         return {
           ...item,

+ 60 - 28
src/views/production/warehouse/inventory/index.vue

@@ -50,8 +50,11 @@
 
 <script setup>
 import byTable from "@/components/byTable/index";
+import { useRoute } from "vue-router";
+import useTagsViewStore from "@/store/modules/tagsView";
 
 const { proxy } = getCurrentInstance();
+const route = useRoute();
 const departmentList = ref([]);
 const warehouseList = ref([
   {
@@ -196,27 +199,31 @@ const getDemandData = () => {
       { id: "0", name: "胜德体育" },
     ];
     departmentList.value = list.concat(res.rows);
-    proxy.post("/inventory/getQuantityByDepartment", {}).then((res) => {
-      for (let i = 0; i < departmentList.value.length; i++) {
-        let list = res.filter((item) => item.departmentId === departmentList.value[i].id);
-        if (list && list.length > 0) {
-          departmentList.value[i].quantity = list[0].inventoryQuantity;
+    if (!(route.query && route.query.backupDateStr)) {
+      proxy.post("/inventory/getQuantityByDepartment", {}).then((res) => {
+        for (let i = 0; i < departmentList.value.length; i++) {
+          let list = res.filter((item) => item.departmentId === departmentList.value[i].id);
+          if (list && list.length > 0) {
+            departmentList.value[i].quantity = list[0].inventoryQuantity;
+          }
         }
-      }
-    });
+      });
+    }
   });
   proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
     warehouseList.value[0].children = res.rows;
-    proxy.post("/inventory/getQuantityByWarehouse", { departmentId: sourceList.value.pagination.departmentId }).then((res) => {
-      if (warehouseList.value[0].children && warehouseList.value[0].children.length > 0) {
-        for (let i = 0; i < warehouseList.value[0].children.length; i++) {
-          let list = res.filter((item) => item.warehouseId === warehouseList.value[0].children[i].id);
-          if (list && list.length > 0) {
-            warehouseList.value[0].children[i].quantity = list[0].inventoryQuantity;
+    if (!(route.query && route.query.backupDateStr)) {
+      proxy.post("/inventory/getQuantityByWarehouse", { departmentId: sourceList.value.pagination.departmentId }).then((res) => {
+        if (warehouseList.value[0].children && warehouseList.value[0].children.length > 0) {
+          for (let i = 0; i < warehouseList.value[0].children.length; i++) {
+            let list = res.filter((item) => item.warehouseId === warehouseList.value[0].children[i].id);
+            if (list && list.length > 0) {
+              warehouseList.value[0].children[i].quantity = list[0].inventoryQuantity;
+            }
           }
         }
-      }
-    });
+      });
+    }
   });
 };
 getDemandData();
@@ -229,8 +236,12 @@ const getList = async (req, status) => {
   } else {
     sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   }
+  let path = "/inventory/page";
+  if (route.query && route.query.backupDateStr) {
+    path = "/inventoryBackup/detailPage";
+  }
   loading.value = true;
-  proxy.post("/inventory/page", sourceList.value.pagination).then((res) => {
+  proxy.post(path, sourceList.value.pagination).then((res) => {
     sourceList.value.data = res.rows;
     sourceList.value.pagination.total = res.total;
     setTimeout(() => {
@@ -238,7 +249,6 @@ const getList = async (req, status) => {
     }, 200);
   });
 };
-getList();
 const clickReset = () => {
   proxy.$refs.treeCategory.setCurrentKey(null);
   getList("", true);
@@ -253,20 +263,22 @@ const getTotal = (item) => {
   }
   return proxy.moneyFormat(total, 2);
 };
-const changeDepartment = (val) => {
+const changeDepartment = () => {
   proxy.$refs.treeCategory.setCurrentKey(null);
-  proxy.post("/inventory/getQuantityByWarehouse", { departmentId: sourceList.value.pagination.departmentId }).then((res) => {
-    if (warehouseList.value[0].children && warehouseList.value[0].children.length > 0) {
-      for (let i = 0; i < warehouseList.value[0].children.length; i++) {
-        let list = res.filter((item) => item.warehouseId === warehouseList.value[0].children[i].id);
-        if (list && list.length > 0) {
-          warehouseList.value[0].children[i].quantity = list[0].inventoryQuantity;
-        } else {
-          warehouseList.value[0].children[i].quantity = null;
+  if (!(route.query && route.query.backupDateStr)) {
+    proxy.post("/inventory/getQuantityByWarehouse", { departmentId: sourceList.value.pagination.departmentId }).then((res) => {
+      if (warehouseList.value[0].children && warehouseList.value[0].children.length > 0) {
+        for (let i = 0; i < warehouseList.value[0].children.length; i++) {
+          let list = res.filter((item) => item.warehouseId === warehouseList.value[0].children[i].id);
+          if (list && list.length > 0) {
+            warehouseList.value[0].children[i].quantity = list[0].inventoryQuantity;
+          } else {
+            warehouseList.value[0].children[i].quantity = null;
+          }
         }
       }
-    }
-  });
+    });
+  }
   getList({ departmentId: sourceList.value.pagination.departmentId });
 };
 const showName = (item) => {
@@ -283,6 +295,26 @@ const renderContent = (h, data) => {
     return h("span", h("span", null, data.node.label));
   }
 };
+onMounted(() => {
+  if (route.query && route.query.backupDateStr) {
+    useTagsViewStore().visitedViews = useTagsViewStore().visitedViews.map((item) => {
+      if (item.query && item.query.backupDateStr === route.query.backupDateStr) {
+        return {
+          ...item,
+          name: "库存快照: " + route.query.backupDateStr,
+          title: "库存快照: " + route.query.backupDateStr,
+        };
+      } else {
+        return {
+          ...item,
+        };
+      }
+    });
+    getList({ backupDate: route.query.backupDateStr });
+  } else {
+    getList();
+  }
+});
 </script>
 
 <style lang="scss" scoped>

+ 102 - 0
src/views/production/warehouse/record/index.vue

@@ -0,0 +1,102 @@
+<template>
+  <div>
+    <el-card class="box-card">
+      <byTable
+        :source="sourceList.data"
+        :pagination="sourceList.pagination"
+        :config="config"
+        :loading="loading"
+        :searchConfig="searchConfig"
+        highlight-current-row
+        @get-list="getList"
+        @clickReset="clickReset">
+        <template #backupDateStr="{ item }">
+          <div>
+            <a style="color: #409eff; cursor: pointer; word-break: break-all" @click="clickDate(item)">{{ item.backupDateStr }}</a>
+          </div>
+        </template>
+      </byTable>
+    </el-card>
+  </div>
+</template>
+
+<script setup>
+import byTable from "@/components/byTable/index";
+import { ElMessage, ElMessageBox } from "element-plus";
+
+const { proxy } = getCurrentInstance();
+const sourceList = ref({
+  data: [],
+  pagination: {
+    total: 0,
+    pageNum: 1,
+    pageSize: 10,
+    beginTime: "",
+    endTime: "",
+  },
+});
+const loading = ref(false);
+const searchConfig = computed(() => {
+  return [
+    {
+      type: "date",
+      propList: ["beginTime", "endTime"],
+      label: "日期",
+    },
+  ];
+});
+const config = computed(() => {
+  return [
+    {
+      attrs: {
+        label: "日期",
+        slot: "backupDateStr",
+        width: 220,
+        align: "center",
+      },
+    },
+    {
+      attrs: {
+        label: "快照时间",
+        prop: "backupDate",
+      },
+    },
+  ];
+});
+const getList = async (req, status) => {
+  if (status) {
+    sourceList.value.pagination = {
+      pageNum: sourceList.value.pagination.pageNum,
+      pageSize: sourceList.value.pagination.pageSize,
+    };
+  } else {
+    sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  }
+  loading.value = true;
+  proxy.post("/inventoryBackup/page", sourceList.value.pagination).then((res) => {
+    sourceList.value.data = res.rows;
+    sourceList.value.pagination.total = res.total;
+    setTimeout(() => {
+      loading.value = false;
+    }, 200);
+  });
+};
+getList();
+const clickReset = () => {
+  getList("", true);
+};
+const clickDate = (row) => {
+  proxy.$router.replace({
+    path: "/production/warehouse/warehouse-inventory",
+    query: {
+      backupDateStr: row.backupDateStr,
+    },
+  });
+};
+</script>
+
+<style lang="scss" scoped>
+::v-deep(.el-input-number .el-input__inner) {
+  text-align: left;
+}
+</style>