cz 1 жил өмнө
parent
commit
fc9ecf2c54

+ 61 - 103
src/views/purchaseSales/stockManage/monthlyReport/index.vue

@@ -29,95 +29,15 @@
 </template>
 
 <script setup>
+import { ElMessage, ElMessageBox } from "element-plus";
 import { computed, nextTick, ref, toRef } from "vue";
 import byTable from "@/components/byTable/index";
+import { getToken } from "@/utils/auth";
+const actionUrl = import.meta.env.VITE_APP_BASE_API;
 
 const { proxy } = getCurrentInstance();
 const route = useRoute();
-const opTypeList = ref([
-  {
-    label: "入库",
-    value: "1",
-  },
-  {
-    label: "出库",
-    value: "2",
-  },
-]);
-const typeList = ref([
-  {
-    label: "手动入库",
-    value: "1",
-  },
-  {
-    label: "手动出库",
-    value: "2",
-  },
-  {
-    label: "调仓入库",
-    value: "3",
-  },
-  {
-    label: "待入库入库",
-    value: "4",
-  },
-  {
-    label: "待出库出库",
-    value: "5",
-  },
-  {
-    label: "组合入库",
-    value: "6",
-  },
-  {
-    label: "组合出库",
-    value: "7",
-  },
-  {
-    label: "组合拆分入库",
-    value: "8",
-  },
-  {
-    label: "组合拆分出库",
-    value: "9",
-  },
-  {
-    label: "京东销售出库",
-    value: "10",
-  },
-  {
-    label: "调仓出库",
-    value: "11",
-  },
-  {
-    label: "销售订单出库",
-    value: "12",
-  },
-  {
-    label: "退货出库",
-    value: "13",
-  },
-  {
-    label: "到货入库",
-    value: "14",
-  },
-  {
-    label: "京东退货入库",
-    value: "15",
-  },
-  {
-    label: "采购到货",
-    value: "18",
-  },
-  {
-    label: "到货质检",
-    value: "19",
-  },
-  {
-    label: "生产任务出库",
-    value: "20",
-  },
-]);
+
 const warehouseList = ref([]);
 const productUnit = ref([]);
 const currencyType = ref([]);
@@ -128,26 +48,37 @@ const sourceList = ref({
     pageNum: 1,
     pageSize: 10,
     keyword: "",
-    opType: "",
-    productId: "",
+    year: "",
+    month: "",
+    warehouseId: "",
   },
 });
 const loading = ref(false);
+const yearData = ref([]);
+
+const monthData = ref([]);
+for (let i = 1; i < 13; i++) {
+  const obj = {
+    label: i + " 月",
+    value: i + " ",
+  };
+  monthData.value.push(obj);
+}
 const selectConfig = computed(() => {
   return [
     {
       label: "年份",
-      prop: "opType",
-      data: opTypeList.value,
+      prop: "year",
+      data: yearData.value,
     },
     {
       label: "月份",
-      prop: "type",
-      data: typeList.value,
+      prop: "month",
+      data: monthData.value,
     },
     {
       label: "仓库名称",
-      prop: "type",
+      prop: "warehouseId",
       data: warehouseList.value,
     },
   ];
@@ -157,15 +88,13 @@ const config = computed(() => {
     {
       attrs: {
         label: "仓库名称",
-        prop: "opType",
-        width: 80,
+        prop: "warehouseName",
       },
     },
     {
       attrs: {
         label: "物品编码",
-        prop: "type",
-        width: 130,
+        prop: "productCode",
       },
     },
 
@@ -194,44 +123,50 @@ const config = computed(() => {
     {
       attrs: {
         label: "期初数量",
-        prop: "quantity",
+        prop: "initialQuantity",
         width: 120,
       },
     },
     {
       attrs: {
         label: "入库数量",
-        prop: "quantity",
+        prop: "receiptQuantity",
         width: 120,
       },
     },
     {
       attrs: {
         label: "出库数量",
-        prop: "quantity",
+        prop: "outboundQuantity",
         width: 120,
       },
     },
     {
       attrs: {
         label: "结存数量",
-        prop: "quantity",
+        prop: "balanceQuantity",
         width: 120,
       },
     },
     {
       attrs: {
         label: "结存单价",
-        prop: "quantity",
+        prop: "balanceUnitPrice",
         width: 120,
       },
+      render(money) {
+        return proxy.moneyFormat(money, 2);
+      },
     },
     {
       attrs: {
         label: "结存金额",
-        prop: "quantity",
+        prop: "balanceAmount",
         width: 120,
       },
+      render(money) {
+        return proxy.moneyFormat(money, 2);
+      },
     },
   ];
 });
@@ -257,7 +192,7 @@ const getList = async (req) => {
   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   loading.value = true;
   proxy
-    .post("/stockJournalDetails/page", sourceList.value.pagination)
+    .post("/monthlyInventoryReport/page", sourceList.value.pagination)
     .then((res) => {
       sourceList.value.data = res.rows;
       sourceList.value.pagination.total = res.total;
@@ -269,7 +204,30 @@ const getList = async (req) => {
 getDict();
 getList();
 const deriveExcel = () => {
-  console.log("deriveExcel");
+  ElMessage({
+    message: "请稍后",
+    type: "success",
+  });
+  let xhr = new XMLHttpRequest();
+  //域名是华为云的
+  xhr.open("POST", `${actionUrl}/monthlyInventoryReport/exportExcel`, true);
+  xhr.responseType = "blob";
+  xhr.setRequestHeader("Authorization", `Bearer ${getToken()}`);
+  xhr.setRequestHeader("Content-Type", "application/json");
+  xhr.send(JSON.stringify(sourceList.value.pagination));
+  xhr.onreadystatechange = function () {
+    if (xhr.readyState === 4 && xhr.status === 200) {
+      let url = window.URL.createObjectURL(xhr.response);
+      const a = document.createElement("a");
+      a.href = url;
+      a.download = "月度库存报表.xlsx"; // 下载后文件名
+      a.style.display = "none";
+      document.body.appendChild(a);
+      a.click(); // 点击下载
+      window.URL.revokeObjectURL(a.href);
+      document.body.removeChild(a); // 下载完成移除元素
+    }
+  };
 };
 </script>