Browse Source

项目预算总表接口联调

ljb 10 months ago
parent
commit
cecb513640

+ 11 - 0
src/api/projectManage/projectList.js

@@ -50,3 +50,14 @@ export const update = (row) => {
     data: row
   })
 }
+
+// 获取项目预算总表
+export const getAllBudget = (params) => {
+  return request({
+    url: '/api/kd-scientific/xm/yszb',
+    method: 'get',
+    params: {
+      ...params,
+    }
+  })
+}

+ 49 - 1
src/views/project-manage/components/all-budget-table.vue

@@ -66,6 +66,8 @@
 <script>
 import moment from 'moment';
 import projectSelect from "@/components/project-select";
+import { getAllBudget } from "@/api/projectManage/projectList";
+import Decimal from "decimal.js";
 
 export default {
   props: {
@@ -78,7 +80,7 @@ export default {
     return {
       currProjectId: "",
       tableData: [{
-        kmmc: '一、人员人工费用'
+        kmmc: '一、人员人工费用',
       }, {
         kmmc: '二、直接投入费用'
       }, {
@@ -108,12 +110,58 @@ export default {
       return `年 月 日至 年 月 日`;
     },
   },
+  watch: {
+    currProjectId(newVal) {
+      if (!!newVal) {
+        this.getAllBudgetData(newVal);
+      }
+    }
+  },
   mounted() {
     this.currProjectId = this.projectId || '';
   },
   methods: {
     handleProjectChange(data) {
       this.selProject = data;
+    },
+    getAllBudgetData(id) {
+      getAllBudget({ xmId: id }).then(({ data }) => {
+        if (data.success) {
+          const { xmysze } = data.data;
+          let ysze = xmysze === -1 ? 1 : xmysze;
+          this.tableData = this.tableData.map((item, index) => {
+            let readKey = '';
+            if (index == 0) {
+              readKey = 'ryrgfy';
+            } else if (index == 1) {
+              readKey = 'zjtrfy';
+            } else if (index == 2) {
+              readKey = 'zjfyycqdtfy';
+            } else if (index == 3) {
+              readKey = 'wxzctxfy';
+            } else if (index == 4) {
+              readKey = 'sjfy';
+            } else if (index == 5) {
+              readKey = 'zbtsysyfy';
+            } else if (index == 6) {
+              readKey = 'wtwbyjkffy';
+            } else if (index == 7) {
+              readKey = 'qtfy';
+            }
+
+            item.sales = data.data[readKey] === -1 ? 0 : data.data[readKey];
+            let ratio = 0;
+            if (item.sales) {
+              ratio = new Decimal(item.sales).div(new Decimal(ysze)).toNumber();
+            }
+            item.ratio = ratio;
+
+            return item;
+          });
+
+          console.log(this.tableData)
+        }
+      });
     }
   }
 };