From f98f5deaaa6c5a9cf4023e2d2dd1c445980e5a8f Mon Sep 17 00:00:00 2001
From: hanbaoshan <hanbaoshan@aiotlink.com>
Date: 星期六, 10 十月 2020 20:28:30 +0800
Subject: [PATCH] 集群管理,应用中心离线安装更新

---
 src/pages/ai/index/App.vue |  194 +++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 157 insertions(+), 37 deletions(-)

diff --git a/src/pages/ai/index/App.vue b/src/pages/ai/index/App.vue
index 9982bf5..7e79300 100644
--- a/src/pages/ai/index/App.vue
+++ b/src/pages/ai/index/App.vue
@@ -347,6 +347,52 @@
         </div>
       </div>
     </div>
+    <el-dialog
+      title="瀹夎鍖呬俊鎭�"
+      :visible.sync="installDialogVisible"
+      width="40%"
+      :close-on-click-modal="false"
+    >
+      <div class="installInfo">
+        <template v-if="installAppPackage != null">
+          <div>
+            <div>
+              <span>瀹夎鍖呭悕绉帮細</span>
+              <span>{{installAppPackage.productName}}</span>
+            </div>
+            <div>
+              <span>瀹夎鐗堟湰锛�</span>
+              <span>{{installAppPackage.version}}</span>
+            </div>
+            <div>
+              <span>鏇存柊鍐呭锛�</span>
+              <span>{{installAppPackage.installContent}}</span>
+            </div>
+          </div>
+        </template>
+        <template v-if="installSdkPackage != null">
+          <div>
+            <div>
+              <span>瀹夎鍖呭悕绉帮細</span>
+              <span>{{installSdkPackage.productName}}</span>
+            </div>
+            <div>
+              <span>瀹夎鐗堟湰锛�</span>
+              <span>{{installSdkPackage.version}}</span>
+            </div>
+            <div>
+              <span>鏇存柊鍐呭锛�</span>
+              <span>{{installSdkPackage.installContent}}</span>
+            </div>
+          </div>
+        </template>
+        <p>纭畾瀹夎锛�</p>
+      </div>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="installDialogVisible = false">鍙� 娑�</el-button>
+        <el-button type="primary" @click="offlineInstall">瀹� 瑁�</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 <script>
@@ -367,7 +413,8 @@
   findByType,
   getTagList,
   downloadSdk,
-  installSdk
+  installSdk,
+  getInstallInfo
 } from "./api";
 import { getApps, installApp, removeApp, getUnActivedSdk, actPageAlg, getUnActivedApp, actApp } from "@/api/app";
 
@@ -466,6 +513,10 @@
       sceneSdks: [],
       sceneRuleList: "",
       isInstall: false,
+      installDialogVisible: false,
+      installPackage: {},
+      installAppPackage: null,
+      installSdkPackage: null,
       installPercentage: 0,
       unActivedSDKList: [],
       unActivedAppList: [],
@@ -483,7 +534,8 @@
       // unloadLoading: false,
       // installLoading: false,
       installedApps: [],
-      storeApps: []
+      storeApps: [],
+      installFile: {}
     }
   },
   watch: {
@@ -523,10 +575,38 @@
     this.VideoManageData.init();
   },
   methods: {
+    offlineInstall () {
+      this.installDialogVisible = false;
+      this.isInstall = true;
+      //瀹夎
+      installSdk(this.installFile).then(res => {
+        debugger
+        if (res.success) {
+          this.isInstall = false;
+          this.$message({
+            type: 'success',
+            message: '瀹夎鎴愬姛,灏嗚烦杞嚦鎴戠殑绠楁硶涓煡鐪�'
+          });
+          setTimeout(() => {
+            this.findAllSdk();
+            this.getAllApps();
+            this.activeName = 'myAlgorithm';
+          }, 3000)
+        }
+
+      }).catch(e => {
+        console.log(e)
+        this.isInstall = false;
+        this.$message({
+          type: 'error',
+          message: e.data
+        });
+      })
+    },
     downloadApp (app) {
       app.installLoading = true;
       let _this = this;
-      installApp(app).then(res => {
+      installApp({ path: app.id }).then(res => {
         if (res && res.success) {
           setTimeout(() => {
             app.installLoading = false;
@@ -669,6 +749,79 @@
       this.patchFile = { ...file };
       this.fileAdded = true;
       const h = this.$createElement;
+      //涓婁紶瀹屾垚鑾峰彇瀹夎淇℃伅
+      let _this = this;
+      getInstallInfo(file).then(res => {
+        _this.installFile = file;
+        if (res.success) {
+          _this.installDialogVisible = true;
+          debugger
+          if (res.data.apps.length > 0) {
+            _this.installAppPackage = {
+              appId: res.data.apps[0].appId,
+              version: res.data.apps[0].version,
+              productName: res.data.productName,
+              installContent: res.data.apps[0].installContent
+            }
+          }
+          if (res.data.sdks.length > 0) {
+            _this.installSdkPackage = {
+              appId: res.data.sdks[0].sdkId,
+              version: res.data.sdks[0].version,
+              productName: res.data.productName,
+              installContent: res.data.sdks[0].installContent
+            }
+          }
+
+          // this.$confirm('', '绠楁硶淇℃伅', {
+          //   message: `<div class="installInfo">
+          //           <div><span>绠楁硶鍚嶇О锛�</span><span>${file.filename}</span></div>
+          //           <div><span>瀹夎鐗堟湰锛�</span><span></span></div>
+          //           <div><span>鏇存柊鍐呭锛�</span><span></span></div>
+          //           <p>纭畾瀹夎姝ょ畻娉曪紵</p>
+          //         </div>`,
+          //   confirmButtonText: '瀹夎',
+          //   cancelButtonText: '鍙栨秷',
+          //   dangerouslyUseHTMLString: true,
+          //   type: ''
+          // }).then(() => {
+          //   this.isInstall = true;
+          //   //瀹夎
+          //   installSdk(file).then(res => {
+          //     debugger
+          //     if (res.success) {
+          //       this.isInstall = false;
+          //       //this.$refs['progressBar'].style.width = 100%
+          //       //this.installPercentage = 100%
+          //       this.$message({
+          //         type: 'success',
+          //         message: '瀹夎鎴愬姛,灏嗚烦杞嚦鎴戠殑绠楁硶涓煡鐪�'
+          //       });
+          //       setTimeout(() => {
+          //         this.findAllSdk();
+          //         this.activeName = 'myAlgorithm';
+          //       }, 3000)
+          //     }
+
+          //   }).catch(e => {
+          //     console.log(e)
+          //     this.isInstall = false;
+          //     this.$message({
+          //       type: 'error',
+          //       message: e.data
+          //     });
+          //   })
+          // }).catch(() => {
+          //   console.log('鍙栨秷瀹夎');
+
+          // })
+        }
+      }).catch(e => {
+        this.$message({
+          type: 'error',
+          message: e.data
+        });
+      })
       // this.$msgbox({
       //     title: '绠楁硶淇℃伅',
       //     message: h('div', null, [
@@ -699,39 +852,7 @@
       //     });
       //   });
 
-      this.$confirm('', '绠楁硶淇℃伅', {
-        message: `<div class="installInfo">
-                    <div><span>绠楁硶鍚嶇О锛�</span><span>${file.filename}</span></div>
-                    <div><span>瀹夎鐗堟湰锛�</span><span></span></div>
-                    <div><span>鏇存柊鍐呭锛�</span><span></span></div>
-                    <p>纭畾瀹夎姝ょ畻娉曪紵</p>
-                  </div>`,
-        confirmButtonText: '瀹夎',
-        cancelButtonText: '鍙栨秷',
-        dangerouslyUseHTMLString: true,
-        type: ''
-      }).then(() => {
-        this.isInstall = true;
-        //瀹夎
-        installSdk(file).then(res => {
-          if (res.success) {
 
-            this.isInstall = false;
-            //this.$refs['progressBar'].style.width = 100%
-            //this.installPercentage = 100%
-            this.$message({
-              type: 'success',
-              message: '瀹夎鎴愬姛,灏嗚烦杞嚦鎴戠殑绠楁硶涓煡鐪�'
-            });
-            setTimeout(() => {
-              this.findAllSdk();
-              this.activeName = 'myAlgorithm';
-            }, 3000)
-          }
-        });
-      }).catch(() => {
-        console.log('鍙栨秷瀹夎')
-      })
 
     },
 
@@ -1451,10 +1572,9 @@
 .installInfo {
   text-indent: 2em;
   font-size: 14px;
-  color: #777;
+  line-height: 26px;
   p {
     text-align: center;
-    color: #666;
   }
 }
 .src-title {

--
Gitblit v1.8.0