littlegreen 2 years ago
parent
commit
fe2446f8a5
2 changed files with 29 additions and 26 deletions
  1. 7 0
      lab-ui/src/api/asset/asset.js
  2. 22 26
      lab-ui/src/views/index.vue

+ 7 - 0
lab-ui/src/api/asset/asset.js

@@ -42,3 +42,10 @@ export function delAsset(id) {
     method: 'delete'
   })
 }
+//统计数据
+export function countAssets(){
+  return request({
+    url:'/asset/asset/count',
+    method: 'get'
+  })
+}

+ 22 - 26
lab-ui/src/views/index.vue

@@ -4,25 +4,25 @@
         <el-col :span="6">
           <div class="grid-content bg-fff">
             <div class="gird-header assets-all">记录设备</div>
-            <div class="gird-num">9999</div>
+            <div class="gird-num">{{countAssetData.allAsset}}</div>
           </div>
         </el-col>
         <el-col :span="6">
           <div class="grid-content bg-fff">
             <div class="gird-header assets-borrow">借出设备</div>
-            <div class="gird-num">9999</div>
+            <div class="gird-num">{{ countAssetData.borrowAsset }}</div>
           </div>
         </el-col>
         <el-col :span="6">
           <div class="grid-content bg-fff">
             <div class="gird-header assets-fault">故障设备</div>
-            <div class="gird-num">9999</div>
+            <div class="gird-num">{{ countAssetData.faultAsset }}</div>
           </div>
         </el-col>
         <el-col :span="6">
           <div class="grid-content bg-fff">
             <div class="gird-header assets-scrap">报废设备</div>
-            <div class="gird-num">9999</div>
+            <div class="gird-num">{{ countAssetData.scrapAsset }}</div>
           </div>
         </el-col>
       </el-row>
@@ -98,6 +98,7 @@
 
 <script>
 import { countNumber,listBorrow } from "@/api/asset/borrow";
+import { countAssets } from "@/api/asset/asset";
 export default {
   data() {
     return {
@@ -110,33 +111,20 @@ export default {
       countData: [
         {countNum: '', typeName: ''}
       ],
-      tableData: [{
-            date: '2016-05-02',
-            name: '王小虎',
-            address: '上海市普陀区金沙江路 1518 弄'
-          }, {
-            date: '2016-05-04',
-            name: '王小虎',
-            address: '上海市普陀区金沙江路 1517 弄'
-          }, {
-            date: '2016-05-01',
-            name: '王小虎',
-            address: '上海市普陀区金沙江路 1519 弄'
-          }, {
-            date: '2016-05-03',
-            name: '王小虎',
-            address: '上海市普陀区金沙江路 1516 弄'
-          },{
-            date: '2016-02-03',
-            name: '王小虎',
-            address: '上海市普陀区金沙江路 1516 弄'
-          }]
+      tableData: [],
+      countAssetData:{
+        allAsset:0,
+        borrowAsset:0,
+        faultAsset:0,
+        scrapAsset:0
+      }
     };
   },
   mounted() {
     // this.startInterval();
     this.getEchartPicture();
-    this.getNewBorrowList()
+    this.getNewBorrowList();
+    this.getCountAsset();
   },
   methods: {
     //开启定时器
@@ -254,6 +242,14 @@ export default {
         }
         
       })
+    },
+    getCountAsset(){
+      countAssets().then(res=>{
+        console.log(res)
+        if(res.data){
+          this.countAssetData = res.data
+        }
+      })
     }
   },
 };