Browse Source

页面逻辑修改

谢杰标 2 years ago
parent
commit
6868bd18aa
2 changed files with 21 additions and 18 deletions
  1. 13 1
      src/utils/index.js
  2. 8 17
      src/views/financed/arap/index.vue

+ 13 - 1
src/utils/index.js

@@ -1,5 +1,5 @@
 import { parseTime } from "./ruoyi";
-
+import * as baseUrls from "@/utils/request.js";
 /**
  * 表格时间格式化
  */
@@ -392,6 +392,18 @@ export function camelCase(str) {
 export function isNumberStr(str) {
   return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str);
 }
+
+export function exportFn(str, name) {
+  let url = process.env.VUE_APP_BASE_API + "common/download?fileName=" + str;
+  let link = document.createElement("a");
+  let fileName = name + ".xlsx";
+  document.body.appendChild(link);
+  link.href = url;
+  link.dowmload = fileName;
+  link.click();
+  link.remove();
+}
+
 // 保留x位小数
 export function checkNum(val, int = 2) {
   if (int === 0) {

+ 8 - 17
src/views/financed/arap/index.vue

@@ -90,7 +90,7 @@ import tableList from "@/components/tableList";
 import pagination from "@/components/pagination";
 import dislogTip from "./dislogTip.vue";
 import dislogOrderDetails from "../components/dislogOrderDetails.vue";
-import * as baseUrls from "@/utils/request.js";
+import { exportFn } from "@/utils/index.js";
 import { orderList, orderExport } from "@/api/financed/index";
 export default {
   name: "cost",
@@ -294,17 +294,10 @@ export default {
       console.log(data);
     },
     batchExport() {
-      orderExport(this.backData()).then((res) => {
+      const fn = [orderExport, orderExport, orderExport][this.type - 1];
+      fn(this.backData()).then((res) => {
         if (res.msg) {
-          let url = baseUrls.baseURL + "common/download?fileName=" + res.msg;
-          let link = document.createElement("a");
-          let fileName = "导出应收应付数据" + ".xlsx";
-          document.body.appendChild(link);
-          link.href = url;
-          link.dowmload = fileName;
-          link.click();
-          link.remove();
-          this.$message.success("导出成功");
+          exportFn(res.msg, "导出应收应付数据");
         } else {
           this.$message.error("导出失败");
         }
@@ -323,12 +316,12 @@ export default {
       this.init();
     },
     handelClick(row) {
-      console.log(row);
       this.activeOrderInfo = row;
       this.dialogVisible = true;
     },
-    orderList(data) {
-      orderList(data)
+    getDataList(data) {
+      const fn = [orderList, orderList, orderList][this.type - 1];
+      fn(data)
         .then((res) => {
           this.tableData = res.rows;
           this.total = res.total;
@@ -346,9 +339,7 @@ export default {
           pageNum: 1,
         };
       }
-      [this.orderList, this.orderList, this.orderList][this.type](
-        this.backData()
-      );
+      this.getDataList(this.backData());
     },
     backData() {
       let data = this.formData;