Parcourir la source

add situation list and getJson method

xyh il y a 2 ans
Parent
commit
ab056e15ac
1 fichiers modifiés avec 151 ajouts et 1 suppressions
  1. 151 1
      src/views/situation/index.vue

+ 151 - 1
src/views/situation/index.vue

@@ -102,6 +102,22 @@
             <i class="el-icon-discount"></i>
           </el-modeltooltip>
           </span>
+        </el-tab-pane>      
+          <el-tab-pane name="fouth">
+          <span slot="label">
+          <el-modeltooltip class="item" effect="dark" content="测想定" placement="left">
+            <i class="el-icon-house"></i>
+          </el-modeltooltip>
+          </span>
+          <el-table :data="situation">
+            <el-table-column label="名称" prop="xdname"></el-table-column>
+            <el-table-column label="操作">
+              <template slot-scope="scope">
+              <el-button type="primary" @click="getJson(scope.row)">导入</el-button>
+              <el-button type="primary" @click="saveJson(scope.row)">保存</el-button>
+            </template>
+            </el-table-column>
+          </el-table>
         </el-tab-pane>
       </el-tabs>
       <div class="buttons">
@@ -119,6 +135,8 @@
 <script>
 import screenfull from 'screenfull';
 import fireController from '../../api/fireController';
+import { getToken } from '@/utils';
+import axios from 'axios';
 export default ({
   computed: {
 
@@ -147,12 +165,144 @@ export default ({
   
     }
   },
+  created() {
+    this.getData();
+  },
   mounted() {
     this.cesiumInit();
-    this.getData();
+  
   },
 
   methods: {
+  async saveJson(row) {
+    await axios.post('http://localhost:8084/admin/online/onlineOperation/updateDatasource/main',{
+      params : {
+      datasourceId: "1656243335922192384",
+      masterData:row,
+      slaveData:{}
+    }
+    }).then(res=>{
+      console.log('update successfully ' );
+    })
+    },
+   async getJson(row){
+      let redunit = []
+      let blueunit = []
+      let satellite = []
+      let center = []
+      let fileInfoStr = row.blueunit;
+            let fileInfoArr = JSON.parse(fileInfoStr);
+            for (let i = 0; i < fileInfoArr.length; i++) {
+              await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/main', {
+                params: {
+                  datasourceId: '1656243335922192384',
+                  fieldName: 'blueunit',
+                  asImage: false,
+                  dataId: row.id,
+                  filename: fileInfoArr[i].filename,
+                  Authorization: getToken(),
+                  MenuId: '1656244747347431424'
+                }
+              })
+                .then(response => {
+                // 处理成功的响应
+                  blueunit.push(response.data);
+                })
+                .catch(error => {
+                // 处理错误
+                  console.error(error);
+                });
+            }
+            fileInfoStr = row.redunit;
+            fileInfoArr = JSON.parse(fileInfoStr);
+    
+            for (let i = 0; i < fileInfoArr.length; i++) {
+              await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/main', {
+                params: {
+                  datasourceId: '1656243335922192384',
+                  fieldName: 'redunit',
+                  asImage: false,
+                  dataId: row.id,
+                  filename: fileInfoArr[i].filename,
+                  Authorization: getToken(),
+                  MenuId: '1656244747347431424'
+                }
+              })
+                .then(response => {
+                // 处理成功的响应
+                  redunit.push(response.data);
+                  
+                })
+                .catch(error => {
+                // 处理错误
+                  console.error(error);
+                });
+            }
+            fileInfoStr = row.center;
+            fileInfoArr = JSON.parse(fileInfoStr);
+    
+            for (let i = 0; i < fileInfoArr.length; i++) {
+              await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/main', {
+                params: {
+                  datasourceId: '1656243335922192384',
+                  fieldName: 'center',
+                  asImage: false,
+                  dataId: row.id,
+                  filename: fileInfoArr[i].filename,
+                  Authorization: getToken(),
+                  MenuId: '1656244747347431424'
+                }
+              })
+                .then(response => {
+                // 处理成功的响应
+                  center.push(response.data);
+                })
+                .catch(error => {
+                // 处理错误
+                  console.error(error);
+                });
+            }
+            fileInfoStr = row.satellite;
+            fileInfoArr = JSON.parse(fileInfoStr);
+    
+            for (let i = 0; i < fileInfoArr.length; i++) {
+              await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/main', {
+                params: {
+                  datasourceId: '1656243335922192384',
+                  fieldName: 'satellite',
+                  asImage: false,
+                  dataId: row.id,
+                  filename: fileInfoArr[i].filename,
+                  Authorization: getToken(),
+                  MenuId: '1656244747347431424'
+                }
+              })
+                .then(response => {
+                // 处理成功的响应
+                  satellite.push(response.data);
+                })
+                .catch(error => {
+                // 处理错误
+                  console.error(error);
+                });
+            }
+            const jsonData = {
+              id: row.id,
+              xdname: row.xdname,
+              type: row.type,
+              creator: row.creator,
+              createtime: row.createtime,
+              bluecnt: row.bluecnt,
+              target: row.target,
+              starttime: row.starttime,
+              steptime: row.steptime,
+              blueunit: blueunit,
+              redunit: redunit,
+              satellite: satellite,
+              center: center
+            };
+            console.log('jsonData :>> ', jsonData);
+    },
     //获取所有数据
     getData(){
       this.getCenter();