heyujie
2021-04-21 fed1301812fab576517b582fa01dfe51bb429f8c
src/pages/ai/index/App.vue
@@ -49,7 +49,7 @@
                              v-if="!item.isDefault || item.isUpgrade"
                            >
                              <div class="left-top">
                                <div>当前版本:{{ item.version }}</div>
                                <div>当前版本1:{{ item.version }}</div>
                                <div v-if="item.remoteVersion">
                                  最新版本:{{ item.remoteVersion }}
                                </div>
@@ -74,7 +74,7 @@
                                  type="warning"
                                  size="small"
                                  class="bot-btn"
                                  >升级</el-button
                                  >升级1</el-button
                                >
                              </div>
                            </div>
@@ -120,7 +120,9 @@
                      >
                        <div class="mask">
                           <div class="left-top">
                                <div v-if="item.installed">当前版本:{{ item.version }}</div>
                            <div v-if="item.installed">
                              当前版本:{{ item.version }}
                            </div>
                                <div v-if="item.remoteVersion">
                                  最新版本:{{ item.remoteVersion }}
                                </div>
@@ -138,9 +140,7 @@
                                  class="bot-btn"
                                  >安装</el-button
                                >
                              </div>
                        </div>
                        <div class="click-download" title="下载">
                          <span class="iconfont iconxiazai1"></span>
@@ -276,7 +276,6 @@
                            element-loading-background="rgba(0,0,0,.8)"
                          >
                            <div class="mask">
                              <el-button
                                size="small"
                                type="primary"
@@ -388,7 +387,6 @@
                                  class="bot-btn"
                                  >激活</el-button
                                >
                              </div>
                            </div>
                            <img
@@ -474,7 +472,6 @@
                                  class="bot-btn"
                                  >激活</el-button
                                >
                              </div>
                            </div>
                            <img
@@ -508,11 +505,13 @@
                  </div>
                </div>
                <!--  -->
              </el-tab-pane>
              <el-tab-pane name="update">
                <span slot="label">
                  <el-badge class="update-badge" :value="updateNum" :hidden="updateNum==0"
                  <el-badge
                    class="update-badge"
                    :value="updateNum"
                    :hidden="updateNum == 0"
                    >更新</el-badge
                  >
                </span>
@@ -760,14 +759,19 @@
    >
    <!-- <el-button-group> -->
      <div class="button-group" v-show="!backDisable||!forwardDisable">
  <el-button    size="small" @click="backwards" :disabled="backDisable"> <span>&#60;</span> </el-button>
        <el-button size="small" @click="backwards" :disabled="backDisable">
          <span>&#60;</span>
        </el-button>
  <!-- <el-button type="primary" size="small" icon="el-icon-arrow-left"></el-button> -->
  <el-button    size="small" @click="forwards" :disabled="forwardDisable">></el-button>
        <el-button size="small" @click="forwards" :disabled="forwardDisable"
          >></el-button
        >
  <!-- <el-button type="primary" size="small"><i class="el-icon-arrow-right el-icon--right"></i></el-button> -->
      </div>
<!-- </el-button-group> -->
      <div class="dialog-title" slot="title">{{isSDKDialog?"算法详情":"应用详情"}}</div>
      <div class="dialog-title" slot="title">
        {{ isSDKDialog ? "算法详情" : "应用详情" }}
      </div>
      <div class="dialog-content">
        <div class="box-top">
          <div class="top-left">
@@ -823,28 +827,74 @@
                />
              </div>
              <div class="right-desc">
                <div class="name"><el-tooltip class="" effect="dark" :content="productDetail.productName  " placement="right-start">
                <div class="name">
                  <el-tooltip
                    class=""
                    effect="dark"
                    :content="productDetail.productName"
                    placement="right-start"
                  >
                  <span>{{ productDetail.productName  }}</span>
                </el-tooltip></div>
                  </el-tooltip>
                </div>
                <div class="tags">
                  <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
                  >
                  <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&&!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>
                  <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 && !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>
              </div>
            </div>
            <div class="jihuo-input" v-if="showInputCode">
                        <el-input size="small"
              <el-input
                size="small"
                          v-model="activeCode"
                          placeholder="00000-00000-00000-00000-00000"
                          @blur="getCodeDetail"
@@ -895,7 +945,9 @@
        </div>
        <div class="box-bottom">
          <div class="bot-left">
            <div class="part-title">{{isSDKDialog?"应用场景":"功能特点"}}</div>
            <div class="part-title">
              {{ isSDKDialog ? "应用场景" : "功能特点" }}
            </div>
            <div class="list-zone">
              <div
                class="list-item"
@@ -906,11 +958,7 @@
                  {{ item.title === "" ? "暂无数据" : item.title }}
                </el-tag>
                <div class="desc">
                  {{
                    item.desc === ""
                      ? "暂无数据"
                      : item.desc
                  }}
                  {{ item.desc === "" ? "暂无数据" : item.desc }}
                </div>
              </div>
            </div>
@@ -941,14 +989,25 @@
                  />
                <div class="icon-name">
                  <el-tooltip class="" effect="dark" :content="item.name === '' ? '暂无数据':item.name" placement="top-start">
                  <span>{{ item.name === "" ? "暂无数据" : item.name }}</span>
                    <el-tooltip
                      class=""
                      effect="dark"
                      :content="item.name === '' ? '暂无数据' : item.name"
                      placement="top-start"
                    >
                      <span>{{
                        item.name === "" ? "暂无数据" : item.name
                      }}</span>
                </el-tooltip>
                  </div>
                </div>
                <div class="look-button">
                  <el-button type="primary" size="mini" @click="checkInWindow(item)">查看</el-button>
                  <el-button
                    type="primary"
                    size="mini"
                    @click="checkInWindow(item)"
                    >查看</el-button
                  >
                </div>
              </div>
            </div>
@@ -987,9 +1046,7 @@
          </li>
        </ul>
        <div class="text-right">
          <el-button type="primary" @click="checkMyAlgorith"
            >确定</el-button
          >
          <el-button type="primary" @click="checkMyAlgorith">确定</el-button>
          <p class="tip">提示:请在“已激活”中查看并安装算法</p>
        </div>
      </div>
@@ -1015,7 +1072,7 @@
  actApp,
} from "@/api/app";
import bus from '@/plugin/bus'
import bus from "@/plugin/bus";
import FileUploader from "@/components/subComponents/FileUpload/index";
export default {
  name: "algorithmManage",
@@ -1118,7 +1175,7 @@
      showInputCode:false,
      needToUpgradeInWin:false,
      errMsg:"",
      showInstallNotActive:false
      showInstallNotActive: false,
    };
  },
  directives: {
@@ -1135,7 +1192,6 @@
    this.getUnActivedList();
    this.getUnActivedAppList();
  },
  beforeDestroy() {
    this.autoRefresh = false;
@@ -1158,114 +1214,113 @@
      }
    },
    closeDial(){
      this.productDetailVisible = false
      this.productDetail = {}
      this.otherProducts = []
      this.productDetailVisible = false;
      this.productDetail = {};
      this.otherProducts = [];
    },
    checkDetail(item,type) {
      if (type =='inactive') {
        this.isActive =false
         this.showInstallNotActive = false
        this.showInputCode = false
      }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
      if (type == "inactive") {
        this.isActive = false;
        this.showInstallNotActive = false;
        this.showInputCode = false;
      } 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
      this.resetStack()
      this.checkIsDefOrNot(item.id);
      this.needToUpgradeInWin = item.isUpgrade ? true : false;
      this.resetStack();
      if (item.sdk_type===undefined) {
       this.isSDKDialog=false
        this.isSDKDialog = false;
      }else{
       this.isSDKDialog=true
        this.isSDKDialog = true;
      }
      this.productDetailVisible = true;
      let _this = this;
      getAppDetail({ id: item.id }).then((res) => {
        _this.productDetail = res.data.detail;
        _this.productDetail.isUpgrade = item.isUpgrade
        _this.productDetail.iconBlob = item.iconBlob
        _this.productDetail.isUpgrade = item.isUpgrade;
        _this.productDetail.iconBlob = item.iconBlob;
        _this.otherProducts = res.data.randoms;
      });
    },
    resetStack(){
      this.forwardStack = []
       this.backStack = []
       this.backDisable = true
       this.forwardDisable = true
      this.forwardStack = [];
      this.backStack = [];
      this.backDisable = true;
      this.forwardDisable = true;
    },
    checkInWindow(item){
      this.backStack.push([this.productDetail, this.otherProducts])
      this.backDisable = false
      this.checkIsDefOrNot(item.id)
      this.backStack.push([this.productDetail, this.otherProducts]);
      this.backDisable = false;
      this.checkIsDefOrNot(item.id);
      let _this = this;
      getAppDetail({ id: item.id }).then((res) => {
        _this.productDetail = res.data.detail;
        _this.productDetail.iconBlob = item.iconBlob
        this.actId = _this.productDetail.productBaseId
        let flag=false
       const allNeedToNew = [...this.hasNewVersionSdk,...this.hasNewVersionApp]
        _this.productDetail.iconBlob = item.iconBlob;
        this.actId = _this.productDetail.productBaseId;
        let flag = false;
        const allNeedToNew = [
          ...this.hasNewVersionSdk,
          ...this.hasNewVersionApp,
        ];
        for (let i = 0; i < allNeedToNew.length; i++) {
          const item = allNeedToNew[i];
          if (item.id == _this.productDetail.productBaseId) {
            flag=true
            flag = true;
          }
        }
        this.needToUpgradeInWin = flag
          _this.productDetail.isUpgrade = flag
        this.needToUpgradeInWin = flag;
        _this.productDetail.isUpgrade = flag;
        _this.otherProducts = res.data.randoms;
      });
    },
    checkIsDefOrNot(id){
      if (id.length>10) {
        this.isDefaultApp=false
        this.isDefaultApp = false;
      }else {
        this.isDefaultApp=true
        this.isDefaultApp = true;
      }
    },
    backwards(){
      if (this.backStack.length ==0) {
        this.backDisable = true
      return
        this.backDisable = true;
        return;
      }
   this.forwardStack.push([this.productDetail,this.otherProducts])
   let item = this.backStack.pop()
   this.productDetail =  item[0]
   this.checkIsDefOrNot(this.productDetail.productBaseId)
   this.otherProducts = item[1]
  this.forwardDisable=false
      this.forwardStack.push([this.productDetail, this.otherProducts]);
      let item = this.backStack.pop();
      this.productDetail = item[0];
      this.checkIsDefOrNot(this.productDetail.productBaseId);
      this.otherProducts = item[1];
      this.forwardDisable = false;
 if (this.backStack.length ==0) {
        this.backDisable = true
        this.backDisable = true;
      }
    },
    forwards(){
      if(this.forwardStack.length==0){
        this.forwardDisable=true
        return
        this.forwardDisable = true;
        return;
      }
        this.backStack.push([this.productDetail,this.otherProducts])
        this.backDisable=false
        let item = this.forwardStack.pop()
      this.backStack.push([this.productDetail, this.otherProducts]);
      this.backDisable = false;
      let item = this.forwardStack.pop();
        this.productDetail = item[0]
        this.otherProducts = item[1]
      this.productDetail = item[0];
      this.otherProducts = item[1];
      if (this.forwardStack.length==0) {
        this.forwardDisable=true
        this.forwardDisable = true;
      }
    },
    //离线安装
    offlineInstall() {
@@ -1332,7 +1387,6 @@
              );
            }, 3000);
          }else {
          }
        })
        .catch((e) => {
@@ -1384,7 +1438,7 @@
      let _this = this;
      this.$confirm("确定要卸载该应用吗?", "提示")
        .then(() => {
      _this.productDetailVisible = false
          _this.productDetailVisible = false;
          app.unloadLoading = true;
          removeApp({ appId: app.id })
@@ -1416,7 +1470,7 @@
    },
    actSdkOrApp(item, type = "sdk") {
      this.checkDetail(item, 'inactive')
      this.checkDetail(item, "inactive");
      this.actType = type;
      this.actId = item.id;
      this.actStep = 0;
@@ -1425,8 +1479,8 @@
    },
    cancelActivate(){
      this.showInputCode= false
      this.activeCode = ""
      this.showInputCode = false;
      this.activeCode = "";
    },
    newActInfo() {
      return {
@@ -1459,16 +1513,16 @@
          type: "error",
          message: "激活码不能为空",
        });
        return
        return;
      }
      if (this.actType == "sdk") {
        //激活算法
        actPageAlg(this.actId, this.activeCode)
          .then((res) => {
            if (res.data.isSuccess) {
              this.productDetailVisible = false
              this.productDetailVisible = false;
              _this.activedSdkOrApp = res.data.successMsg;
              this.showActivateSuccess=true
              this.showActivateSuccess = true;
              _this.actStep++;
              _this.getUnActivedList();
              _this.getAllSdk();
@@ -1487,9 +1541,9 @@
        actApp(this.actId, this.activeCode)
          .then((res) => {
            if (res.data.isSuccess) {
              this.productDetailVisible = false
              this.productDetailVisible = false;
              _this.activedSdkOrApp = res.data.successMsg;
              this.showActivateSuccess=true
              this.showActivateSuccess = true;
              _this.actStep++;
              _this.getUnActivedAppList();
              _this.getAllApps();
@@ -1548,10 +1602,13 @@
        });
    },
    openApp(){
      let message = 'toOpenApp?' + this.productDetail.productBaseId;
      window.parent.postMessage({
        msg: message
      }, "*")
      let message = "toOpenApp?" + this.productDetail.productBaseId;
      window.parent.postMessage(
        {
          msg: message,
        },
        "*"
      );
    },
    onFileAdded(f) {
@@ -1579,7 +1636,7 @@
          //算法软件 已安装其中包含待升级 未安装
          item.installed ? installedList.push(obj) : unInstalledList.push(obj);
          item.isUpgrade ? hasNewVersionList.push(obj): null
          item.isUpgrade ? hasNewVersionList.push(obj) : null;
        });
      }
      this.installedList = installedList;
@@ -1587,19 +1644,18 @@
      this.hasNewVersionSdk = hasNewVersionList;
    },
    unloadSDKinWin(){
      let appToUnload
      let sdkToUnload
      let appToUnload;
      let sdkToUnload;
      if (this.productDetail.productTypeName=="应用") {
        appToUnload= this.installedApps.find((item)=>{
          return item.id == this.productDetail.productBaseId
        })
        this.unLoad(appToUnload)
          return item.id == this.productDetail.productBaseId;
        });
        this.unLoad(appToUnload);
      }else{
          sdkToUnload= this.installedList.find((item)=>{
          return item.id == this.productDetail.productBaseId
        })
        this.unLoadSdk(sdkToUnload)
          return item.id == this.productDetail.productBaseId;
        });
        this.unLoadSdk(sdkToUnload);
      }
    },
    //卸载算法
@@ -1607,7 +1663,7 @@
      let _this = this;
      this.$confirm("确定要卸载该算法吗?", "提示")
        .then(() => {
      _this.productDetailVisible = false
          _this.productDetailVisible = false;
          sdk.unloadLoading = true;
          removeSdk({ sdkId: sdk.id })
            .then((res) => {
@@ -1637,7 +1693,6 @@
        });
    },
    upgradeSDKinWin(){
      this.isUpgrading = !this.isUpgrading;
      let _this = this;
@@ -1650,10 +1705,9 @@
          message: "升级完成",
          type: "success",
        });
        this.needToUpgradeInWin=false
        this.productDetail.isUpgrade = false
              this.needToUpgradeInWin = false;
              this.productDetail.isUpgrade = false;
        this.isUpgrading = !this.isUpgrading;
          }
        })
        .catch((e) => {
@@ -1668,41 +1722,40 @@
      // 开启自动刷新
      this.appUpgreading = true;
      }else{
        downloadSdk({path:this.productDetail.productBaseId}).then((res)=>{
          this.needToUpgradeInWin=false
        this.productDetail.isUpgrade = false
        downloadSdk({ path: this.productDetail.productBaseId })
          .then((res) => {
            this.needToUpgradeInWin = false;
            this.productDetail.isUpgrade = false;
        this.isUpgrading = !this.isUpgrading;
        this.$notify({
          title: "成功",
          message: "升级完成",
          type: "success",
        });
      }).catch((err)=>{
          })
          .catch((err) => {
        this.$notify({
          title: "升级失败",
          message: err.data,
          type: "warning",
        });
        this.isUpgrading = !this.isUpgrading;
      })
          });
      this.sdkUpgreading = true;
      }
    },
    downloadSdkInSide(){
      this.downloadItem = this.productDetail.productBaseId;
      this.isUpgrading = true
      this.isUpgrading = true;
      downloadSdk({ path: this.productDetail.productBaseId })
        .then((rsp) => {
          this.productDetailVisible = false
          this.productDetailVisible = false;
          this.downloadItem = "";
          this.$notify({
            type: "success",
            message: "算法已安装"
            message: "算法已安装",
          });
      this.isUpgrading=false
          this.isUpgrading = false;
        })
        .catch((err) => {
          this.$notify({
@@ -1710,12 +1763,13 @@
            message: err.data,
          });
          this.downloadItem = "";
      this.isUpgrading=false
          this.isUpgrading = false;
        });
      // 开启自动刷新
      this.sdkUpgreading = true;
    },
    donwload(item,typ) {
      item.upgradeLoading = true;
      this.downloadItem = item.id;
@@ -1726,7 +1780,7 @@
          this.downloadItem = "";
          this.$notify({
            type: "success",
            message: typ==1? "算法安装成功":"算法升级成功"
            message: typ == 1 ? "算法安装成功" : "算法升级成功",
          });
        })
        .catch((err) => {
@@ -1803,7 +1857,6 @@
  .product-detail-dialog {
    .dialog-title{
          font-size: 13px;
    }
    .el-dialog {
      width: 50%;
@@ -1837,7 +1890,6 @@
                left: 10px;
      .el-button--small {
        padding: 5px 12px;
    }
        button{
          font-size: 18px;
@@ -1860,7 +1912,6 @@
        text-align: center;
        margin-top: 3px;
           video {
            margin: 0px auto;
                 margin-top: 23px;
@@ -1884,7 +1935,6 @@
          overflow: hidden;
          .summary {
                height: 120px;
                margin: 5px 5px 0 5px;
@@ -1919,7 +1969,6 @@
                }
              }
            }
          }
           .jihuo-input{
             margin-left: 10px;
@@ -1948,19 +1997,15 @@
              width: fit-content;
                 height: 26px;
            margin-bottom: 8px;
            }
            .text {
                height: 156px;
              overflow: auto;
              padding: 0 15px 0px 15px;
              .single-desc {
                   margin-bottom: 10px;
                        font-size: 13px;
              }
            }
          }
@@ -1987,7 +2032,6 @@
               margin-bottom: 10px;
              height: 33px;
          }
          .list-zone {
            overflow: auto;
@@ -1999,7 +2043,6 @@
                      margin: 5px 12px 0 12px;
                    font-size: 12px;
                        line-height: 18px;
              }
               margin-bottom: 12px;
            }
@@ -2022,7 +2065,6 @@
            width: fit-content;
            margin-bottom: 5px;
                height: 33px;
          }
          .item-zone {
            overflow: auto;
@@ -2060,7 +2102,6 @@
            white-space: nowrap;
            overflow: hidden;
              font-size: 13px;
                }
              }
              .look-button {
@@ -2228,7 +2269,6 @@
            max-width: 200px;
            .mask {
              width: 100%;
            
              .el-button + .el-button {
                margin-left: 0 !important;
@@ -2754,7 +2794,6 @@
}
.active-Dial{
  .el-dialog{
    min-width: 400px;
  }
@@ -2788,6 +2827,5 @@
        }
}
}
</style>