zhangzengfei
2021-04-07 5058e8d5fc8220a4fa31d160935c1aafd6074fb3
src/pages/ai/index/App.vue
@@ -26,47 +26,6 @@
                >
                  <p class="src-title">算法软件</p>
                  <div class="flex-list">
                    <!-- <div class="wrap-box" v-for="item in ungradeList" :key="'upgrade'+item.id">
                      <div class="list-choose-item-left">
                        <div class="list-complete-item-handle">
                          <div
                            class="svg-wrap"
                            :class="{willUpGrade:item.isUpgrade}"
                            v-loading="item.upgradeLoading"
                            :element-loading-text="item.progressMsg"
                            element-loading-background="rgba(0,0,0,.8)"
                          >
                            <i class="iconfont iconupdate" v-if="item.isUpgrade"></i>
                            <div class="mask">
                              <div class="info-onmask">
                                <div>当前版本:{{item.version}}</div>
                                <div>最新版本:{{item.remoteVersion}}</div>
                              </div>
                              <div class="mask-btn">
                                <el-button
                                  type="warning"
                                  class="bot-btn"
                                  size="small"
                                  @click="donwload(item)"
                                >升级</el-button>
                              </div>
                            </div>
                            <img
                              v-if="item.iconBlob"
                              class="baseImg"
                              :src="item.iconBlob.indexOf(',')>0? item.iconBlob:`data:image/png;base64,${item.iconBlob}`"
                              alt
                            />
                            <img v-else class="baseImg" :src="item.icon" alt />
                          </div>
                          <div class="alg-name">
                            <div style="padding:0px 10px 0px 10px;">
                              <span>{{ item.sdk_name }}</span>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>-->
                    <div
                      class="wrap-box"
                      v-for="item in installedList"
@@ -111,7 +70,7 @@
                                >
                                <el-button
                                  v-if="item.isUpgrade"
                                  @click="donwload(item)"
                                  @click="donwload(item,0)"
                                  type="warning"
                                  size="small"
                                  class="bot-btn"
@@ -168,13 +127,13 @@
                              </div>
                              <div
                                class="info-onmask"
                                @click="checkDetail(item, 'inactive')"
                                @click="checkDetail(item, 'activeNotInstall')"
                              >
                                查看详情
                              </div>
                              <div class="mask-btn">
                                <el-button
                                 @click="donwload(item)"
                                 @click="donwload(item,1)"
                                  type="primary"
                                  class="bot-btn"
                                  >安装</el-button
@@ -548,78 +507,12 @@
                    </div>
                  </div>
                </div>
                <el-drawer
                  title="下载"
                  :visible.sync="actDrawerShow"
                  :direction="direction"
                >
                  <div class="drawer-content">
                    <div class="current-step">
                      <el-steps
                        align-center
                        :active="actStep"
                        finish-status="success"
                      >
                        <el-step title="添加激活码"></el-step>
                        <el-step title="激活成功"></el-step>
                      </el-steps>
                    </div>
                    <div v-if="actStep == 0">
                      <div class="act-code">
                        <p>使用激活码将新的算法添加到您的账户</p>
                        <el-input
                          v-model="activeCode"
                          placeholder="00000-00000-00000-00000-00000"
                          @blur="getCodeDetail"
                        ></el-input>
                      </div>
                      <div class="text-right">
                        <el-button type="primary" @click="actived"
                          >激活</el-button
                        >
                      </div>
                    </div>
                    <div v-else-if="actStep == 1">
                      <ul class="desc">
                        <li>
                          <label>激活码:</label>
                          <span>{{ activedSdkOrApp.activateCode }}</span>
                        </li>
                        <li>
                          <label>产品名称:</label>
                          <span>{{ activedSdkOrApp.productName }}</span>
                        </li>
                        <li>
                          <label>配置详情:</label>
                          <span>{{ activedSdkOrApp.setting }}</span>
                        </li>
                        <li>
                          <label>服务到期日:</label>
                          <span>{{ activedSdkOrApp.expireTime }}</span>
                        </li>
                        <li>
                          <label>许可证:</label>
                          <span>{{ activedSdkOrApp.licence }}</span>
                        </li>
                        <!-- <li>
                          <label>设备ID:</label>
                          <span>3342-235f-ret55-fdsg</span>
                        </li>-->
                      </ul>
                      <div class="text-right">
                        <el-button type="primary" @click="checkMyAlgorith"
                          >确定</el-button
                        >
                        <p class="tip">提示:请在“已激活”中查看并安装算法</p>
                      </div>
                    </div>
                  </div>
                </el-drawer>
                <!--  -->
              </el-tab-pane>
              <el-tab-pane name="update">
                <span slot="label">
                  <el-badge class="update-badge" :value="updateNum"
                  <el-badge class="update-badge" :value="updateNum" :hidden="updateNum==0"
                    >更新</el-badge
                  >
                </span>
@@ -681,7 +574,7 @@
                                >
                                <el-button
                                  v-if="item.isUpgrade"
                                  @click="donwload(item)"
                                  @click="donwload(item,0)"
                                  type="warning"
                                  size="small"
                                  class="bot-btn"
@@ -935,21 +828,16 @@
                  <span>{{ productDetail.productName  }}</span>
                </el-tooltip></div>
                <div class="tags">
                  <!-- <span
                  class="tag"
                  v-for="(id, index) in curCheckTarget.productLabelId"
                  :key="index+'i'"
                >{{showNameById(id)}}</span> -->
                  <el-tag type="info" size="small" color="#fff" v-if="!isSDKDialog">应用</el-tag>
                  <el-tag type="info" size="small" color="#fff" v-if="isSDKDialog">算法</el-tag>
                  <!-- <el-tag type="info"  size="small" color="#fff" v-if="!isSDKDialog">软件</el-tag> -->
                </div>
                <div class="btns">
                  <el-button size="small" type="warning"  v-if="needToUpgradeInWin||productDetail.isUpgrade" @click="upgradeSDKinWin" >{{
                    isUpgrading ? "升级中.." : "升级"
                  }}</el-button>
                  <el-button size="small" type="primary" v-if="isActive&&!isDefaultApp" @click="unloadSDKinWin">卸载</el-button>
                  <el-button size="small" type="primary" v-if="!isActive" @click="showInputCode=!showInputCode">激活</el-button>
                  <el-button size="small" type="primary" v-if="!isActive&&!showInstallNotActive" @click="showInputCode=!showInputCode">激活</el-button>
                  <el-button size="small" type="primary" v-if="!isActive&&showInstallNotActive" @click="downloadSdkInSide">{{isUpgrading?"安装中..":"安装"}}</el-button>
                  <el-button size="small" type="success" v-if="!isSDKDialog&&isActive" @click="openApp">打开</el-button>
                </div>
               
@@ -1068,7 +956,6 @@
        </div>
      </div>
    </el-dialog>
  <!--  -->
    <el-dialog 
    :visible.sync="showActivateSuccess"
    title="激活成功!"
@@ -1185,7 +1072,6 @@
      downloadItem: "",
      downloading: false,
      direction: "rtl",
      actDrawerShow: false,
      actStep: 0,
      showActivateSuccess:false,
      activeCode: "",
@@ -1232,6 +1118,7 @@
      showInputCode:false,
      needToUpgradeInWin:false,
      errMsg:"",
      showInstallNotActive:false
    };
  },
  directives: {
@@ -1262,7 +1149,7 @@
    batchUpdate(type) {
      if (type == "sdk") {
        this.hasNewVersionSdk.forEach((sdk) => {
          this.donwload(sdk);
          this.donwload(sdk,0);
        });
      } else {
        this.hasNewVersionApp.forEach((app) => {
@@ -1278,10 +1165,16 @@
    checkDetail(item,type) {
      if (type =='inactive') {
        this.isActive =false
         this.showInstallNotActive = false
        this.showInputCode = false
      }else{
      }else if (type =='active'){
        this.showInputCode = false
         this.showInstallNotActive = false
         this.isActive =true
      }else if (type =='activeNotInstall'){
        this.showInputCode = false
         this.isActive =false
         this.showInstallNotActive = true
      }
      this.checkIsDefOrNot(item.id)
        this.needToUpgradeInWin = item.isUpgrade?true:false
@@ -1374,7 +1267,6 @@
      }
      
    },
    //离线安装
    offlineInstall() {
      this.installDialogVisible = false;
@@ -1420,6 +1312,11 @@
      installApp({ path: app.id })
        .then((res) => {
          if (res && res.success) {
            _this.$notify({
               title: "成功",
               message: "安装应用成功",
               type: "success",
             });
            setTimeout(() => {
              if (action == "upgrade") {
                app.upgradeLoading = false;
@@ -1501,6 +1398,11 @@
                  },
                  "*"
                );
                _this.$notify({
                  title: "成功",
                  message: "卸载应用成功",
                  type: "success",
                });
              }
            })
            .catch((e) => {
@@ -1512,18 +1414,11 @@
          console.log(e);
        });
    },
    // actSdk (id) {
    //   this.actSdkId = id;
    //   this.actDrawerShow = true;
    //   this.actStep = 0;
    //   this.activeCode = '';
    //   this.activedSdkOrApp = this.newActInfo()
    // },
    actSdkOrApp(item, type = "sdk") {
      this.checkDetail(item, 'inactive')
      this.actType = type;
      this.actId = item.id;
      // this.actDrawerShow = true;
      this.actStep = 0;
      this.activeCode = "";
      this.activedSdkOrApp = this.newActInfo();
@@ -1531,6 +1426,7 @@
    cancelActivate(){
      this.showInputCode= false
      this.activeCode = ""
    },
    newActInfo() {
      return {
@@ -1558,51 +1454,56 @@
    },
    actived() {
      let _this = this;
      if (this.activeCode.trim()=="") {
        this.$notify({
          type: "error",
          message: "激活码不能为空",
        });
        return
      }
      if (this.actType == "sdk") {
        //激活算法
        actPageAlg(this.actId, this.activeCode)
          .then((res) => {
            if (res.data.isSuccess) {
              this.productDetailVisible = false
              _this.activedSdkOrApp = res.data.successMsg;
              this.showActivateSuccess=true
      // if (this.actType == "sdk") {
      //   //激活算法
      //   actPageAlg(this.actId, this.activeCode)
      //     .then((res) => {
      //       if (res.data.isSuccess) {
      //         this.productDetailVisible = false
      //         _this.activedSdkOrApp = res.data.successMsg;
      //         this.showActivateSuccess=true
      //         _this.actStep++;
      //         _this.getUnActivedList();
      //         _this.getAllSdk();
      //       } else {
      //         _this.$notify({
      //           type: "error",
      //           message: res.data.failMsg.failMsg,
      //         });
      //       }
      //     })
      //     .catch((e) => {
      //       console.log(e);
      //     });
      // } else if (this.actType == "app") {
      //   //激活应用
      //   actApp(this.actId, this.activeCode)
      //     .then((res) => {
      //       if (res.data.isSuccess) {
      //         this.productDetailVisible = false
      //         _this.activedSdkOrApp = res.data.successMsg;
      //         this.showActivateSuccess=true
      //         _this.actStep++;
      //         _this.getUnActivedAppList();
      //         _this.getAllApps();
      //       } else {
      //         _this.$notify({
      //           type: "error",
      //           message: res.data.failMsg.failMsg,
      //         });
      //       }
      //     })
      //     .catch((e) => {
      //       console.log(e);
      //     });
      // }
              _this.actStep++;
              _this.getUnActivedList();
              _this.getAllSdk();
            } else {
              _this.$notify({
                type: "error",
                message: res.data.failMsg.failMsg,
              });
            }
          })
          .catch((e) => {
            console.log(e);
          });
      } else if (this.actType == "app") {
        //激活应用
        actApp(this.actId, this.activeCode)
          .then((res) => {
            if (res.data.isSuccess) {
              this.productDetailVisible = false
              _this.activedSdkOrApp = res.data.successMsg;
              this.showActivateSuccess=true
              _this.actStep++;
              _this.getUnActivedAppList();
              _this.getAllApps();
            } else {
              _this.$notify({
                type: "error",
                message: res.data.failMsg.failMsg,
              });
            }
          })
          .catch((e) => {
            console.log(e);
          });
      }
    },
    getCodeDetail() {},
    checkMyAlgorith() {
@@ -1712,6 +1613,11 @@
            .then((res) => {
              if (res && res.success) {
                sdk.unloadLoading = false;
                this.$notify({
                title: "成功",
                message: "卸载完成",
                type: "success",
              });
                _this.getAllSdk();
                window.parent.postMessage(
                  {
@@ -1763,14 +1669,14 @@
      this.appUpgreading = true;
      }else{
        downloadSdk({path:this.productDetail.productBaseId}).then((res)=>{
          this.needToUpgradeInWin=false
        this.productDetail.isUpgrade = false
        this.isUpgrading = !this.isUpgrading;
        this.$notify({
          title: "成功",
          message: "升级完成",
          type: "success",
        });
        this.needToUpgradeInWin=false
        this.productDetail.isUpgrade = false
        this.isUpgrading = !this.isUpgrading;
      }).catch((err)=>{
        this.$notify({
          title: "升级失败",
@@ -1785,21 +1691,43 @@
      
    },
    donwload(item) {
    downloadSdkInSide(){
      this.downloadItem = this.productDetail.productBaseId;
      this.isUpgrading = true
      downloadSdk({ path: this.productDetail.productBaseId })
        .then((rsp) => {
          this.productDetailVisible = false
          this.downloadItem = "";
          this.$notify({
            type: "success",
            message: "算法已安装"
          });
      this.isUpgrading=false
        })
        .catch((err) => {
          this.$notify({
            type: "warning",
            message: err.data,
          });
          this.downloadItem = "";
      this.isUpgrading=false
        });
      // 开启自动刷新
      this.sdkUpgreading = true;
    },
    donwload(item,typ) {
      item.upgradeLoading = true;
      //this.downloading = true;
      this.downloadItem = item.id;
      downloadSdk({ path: item.id })
        .then((rsp) => {
          // this.$notify({
          //   type: "success",
          //   message: "算法已安装"
          // });
          item.upgradeLoading = false;
          //this.downloading = false;
          this.downloadItem = "";
          this.$notify({
            type: "success",
            message: typ==1? "算法安装成功":"算法升级成功"
          });
        })
        .catch((err) => {
          this.$notify({
@@ -1998,8 +1926,9 @@
             margin-bottom: 10px;
              .el-input{
                float: left;
                width: 64%;
                 margin-bottom: 8px;
                width: 63%;
                margin-bottom: 8px;
                margin-right: 10px;
              }
              el-button{
                float: left;
@@ -2022,9 +1951,9 @@
            }
            .text {
                 height: 156px;
    overflow: auto;
    padding: 0 15px 0px 15px;
                height: 156px;
              overflow: auto;
              padding: 0 15px 0px 15px;
              .single-desc {
@@ -2069,6 +1998,8 @@
                background-color: rgba(242, 242, 242, 1.3);
                      margin: 5px 12px 0 12px;
                    font-size: 12px;
                        line-height: 18px;
              }
               margin-bottom: 12px;
            }