zhangzengfei
2022-07-20 4a800a8fc83c6bd1f86a8e847b079a51a7532c09
src/pages/ai/index/App.vue
@@ -26,7 +26,8 @@
                <span class="icon iconfont all-scene">&#xe703;</span>
                <el-input
                  placeholder="搜索"
                  v-model="input3"
                  v-model="inputText"
                  @change="searchAll"
                  class="input-with-select"
                >
                  <i class="el-icon-search" slot="prepend"></i>
@@ -66,7 +67,7 @@
                  class="quick-item"
                  v-for="(item, index) in recomandUpdateList"
                  :key="index"
                  @click="checkDetail(item, 'inactive')"
                  @click="checkDetail(item, 'inactive', item.sdk_name)"
                >
                  <div class="icon-img">
                    <span class="icon iconfont" v-if="item.isUpgrade"
@@ -84,11 +85,18 @@
                    <img v-else :src="item.icon" alt />
                  </div>
                  <div class="desc">
                    <div class="desc-1">{{ item.sdk_name || item.name }}</div>
                    <el-tooltip
                      :content="item.sdk_name || item.name"
                      effect="light"
                    >
                      <div class="desc-1">{{ item.sdk_name || item.name }}</div>
                    </el-tooltip>
                    <div class="desc-2">版本 {{ item.version }}</div>
                  </div>
                  <div class="right-icon">
                    <span class="icon iconfont">&#xe71a;</span>
                    <el-tooltip effect="dark" content="下载" placement="bottom">
                      <span class="icon iconfont">&#xe71a;</span>
                    </el-tooltip>
                  </div>
                </div>
              </div>
@@ -141,7 +149,10 @@
                  class="front-page-item"
                  v-for="(item, index) in tempList"
                  :key="index"
                  @click="checkDetail(item)"
                  @click="checkDetail(item, null, item.sdk_name)"
                  :class="{
                    disabled: activeName == '应用中心' && !item.canUpOrIns,
                  }"
                >
                  <div class="icon-img">
                    <span class="icon iconfont" v-if="item.isUpgrade"
@@ -159,7 +170,12 @@
                    <img v-else :src="item.icon" alt />
                  </div>
                  <div class="desc">
                    <div class="desc-1">{{ item.sdk_name || item.name }}</div>
                    <el-tooltip
                      :content="item.sdk_name || item.name"
                      effect="light"
                    >
                      <div class="desc-1">{{ item.sdk_name || item.name }}</div>
                    </el-tooltip>
                    <div class="desc-2">版本 {{ item.version }}</div>
                  </div>
                  <div class="right-btn">
@@ -168,8 +184,8 @@
                      type="primary"
                      class="other-btn"
                      round
                      @click="checkDetail(item)"
                      v-if="activeName == '应用中心'&&item.price>0"
                      @click="checkDetail(item, null, item.sdk_name)"
                      v-if="activeName == '应用中心' && item.price > 0"
                      >激活</el-button
                    >
                    <el-button
@@ -178,7 +194,7 @@
                      class="update-btn"
                      round
                      @click.stop="actived(item)"
                      v-if="activeName == '应用中心'&&item.price==0"
                      v-if="activeName == '应用中心' && item.price == 0"
                      >安装</el-button
                    >
                    <el-button
@@ -280,7 +296,7 @@
                  class="front-page-item item-dimmed"
                  v-for="(item, index) in tempDarkList"
                  :key="index"
                  @click="checkDetail(item, 'activeNotInstall')"
                  @click="checkDetail(item, 'activeNotInstall', item.sdk_name)"
                >
                  <div class="icon-img">
                    <img
@@ -295,7 +311,12 @@
                    <img v-else :src="item.icon" alt />
                  </div>
                  <div class="desc">
                    <div class="desc-1">{{ item.sdk_name || item.name }}</div>
                    <el-tooltip
                      :content="item.sdk_name || item.name"
                      effect="light"
                    >
                      <div class="desc-1">{{ item.sdk_name || item.name }}</div>
                    </el-tooltip>
                    <div class="desc-2">版本 {{ item.version }}</div>
                  </div>
                  <div class="right-btn">
@@ -343,7 +364,9 @@
                  class="upload-demo"
                  single
                  tip
                  :sourceType="3"
                  :isDrag="true"
                  :attrs="{ accept: '.zip,.tar,.gz,.tar.gz' }"
                  tipWords="点击上传"
                  uploadPlaceholder="算法软件"
                  url="/data/api-v/sdk/upload"
@@ -357,6 +380,8 @@
          <detailPage
            :detailProductID="detailProductID"
            :detailType="detailType"
            :detailPrice="detailPrice"
            :isSdk="isSdk"
            v-if="inDetail"
            @flushSdk="getAllSdk"
            @flushApp="getAllApps"
@@ -469,6 +494,7 @@
      showUpload: false,
      detailType: "",
      detailProductID: "",
      detailPrice: "",
      buttonAuthority: sessionStorage.getItem("buttonAuthoritys") || [],
      activeName: "应用中心",
      patchUpdateStatus: "",
@@ -490,7 +516,7 @@
      isSDKDialog: true,
      actType: "",
      actId: "",
      input3: "",
      inputText: "",
      tempList: [],
      select: "",
      activedSdkOrApp: {
@@ -543,14 +569,15 @@
    this.autoRefresh = false;
  },
  methods: {
    searchAll() {
      this.getAllApps();
      this.getAllSdk();
      this.getUnActivedList(1);
      this.getUnActivedAppList();
    },
    goback() {
      this.inDetail = false;
    },
    // isShow(authority) {
    //   return (
    //     this.isAdmin || this.buttonAuthority.indexOf("," + authority + ",") > -1
    //   );
    // },
    batchUpdate(s) {
      if (s == "both") {
        this.batchUpdateSDK();
@@ -584,7 +611,6 @@
          this.tempList = this.installedList;
          this.tempDarkList = this.notInstalledList;
          break;
        case "更新":
          this.showQuickPath = false;
          this.tempList = this.hasNewVersionSdk;
@@ -620,69 +646,23 @@
        this.tempDarkList = [];
      }
    },
    // closeDial() {
    //   this.productDetailVisible = false;
    //   this.productDetail = {};
    //   this.otherProducts = [];
    // },
    checkDetail(item, typ) {
    checkDetail(item, typ, sdkName) {
      /* if (!item.canUpOrIns && typ == "Appcenter") {
        return false;
      } */
      this.isSdk = Boolean(sdkName);
      this.inDetail = true;
      this.detailProductID = item.id;
      this.detailPrice = item.price;
      if (typ) {
        this.detailType = typ;
      } else {
        this.detailType = this.activeName == "应用中心" ? "inactive" : "active";
      }
    },
    // checkInWindow(item) {
    //   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,
    //     ];
    //     for (let i = 0; i < allNeedToNew.length; i++) {
    //       const item = allNeedToNew[i];
    //       if (item.id == _this.productDetail.productBaseId) {
    //         flag = true;
    //       }
    //     }
    //     this.needToUpgradeInWin = flag;
    //     _this.productDetail.isUpgrade = flag;
    //     _this.otherProducts = res.data.randoms;
    //   });
    // },
    checkIsDefOrNot(id) {
      if (id.length > 10) {
        this.isDefaultApp = false;
      } else {
        this.isDefaultApp = true;
      }
      this.isDefaultApp = id.length <= 10;
    },
    // backwards() {
    //   if (this.backStack.length == 0) {
    //     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;
    //   if (this.backStack.length == 0) {
    //     this.backDisable = true;
    //   }
    // },
    forwards() {
      if (this.forwardStack.length == 0) {
        this.forwardDisable = true;
@@ -716,7 +696,7 @@
        })
        .catch((e) => {
          this.isInstall = false;
          this.$message.error(e.data);
          this.$message.error(e.msg);
        });
    },
    downloadApp(app, action) {
@@ -740,7 +720,7 @@
          }
        })
        .catch((e) => {
          _this.$notify.warning(e.data);
          _this.$notify.warning(e.msg);
          clearInterval(timer);
          app.upgradeLoading = false;
        });
@@ -751,7 +731,7 @@
      let iArry = [];
      let sArry = [];
      let nArry = [];
      let rsp = await getApps();
      let rsp = await getApps({ appName: this.inputText });
      if (rsp && rsp.success) {
        // 遍历app的过程重置
        this.appUpgreading = false;
@@ -804,18 +784,6 @@
        })
        .catch((e) => {});
    },
    // toActivatePage(item) {
    //   this.checkDetail(item, "inactive");
    //   this.actType = this.activeTab;
    //   this.actId = item.id;
    //   this.actStep = 0;
    //   this.activeCode = "";
    //   this.activedSdkOrApp = this.newActInfo();
    // },
    // cancelActivate() {
    //   this.showInputCode = false;
    //   this.activeCode = "";
    // },
    newActInfo() {
      return {
        activateCode: "",
@@ -827,7 +795,7 @@
      };
    },
    getUnActivedList(v) {
      getUnActivedSdk().then((res) => {
      getUnActivedSdk({ sdkName: this.inputText }).then((res) => {
        if (res.code == 200) {
          this.unActivedSDKList = res.data;
          const len = this.unActivedSDKList.length;
@@ -850,14 +818,18 @@
      });
    },
    getUnActivedAppList() {
      getUnActivedApp().then((res) => {
      getUnActivedApp({ appName: this.inputText }).then((res) => {
        if (res.code == 200) {
          this.unActivedAppList = res.data;
          this.pickTab()
          this.pickTab();
        }
      });
    },
    actived(item) {
      if (!item.canUpOrIns) {
        return false;
      }
      let _this = this;
      if (this.activeTab == "sdk") {
        actPageAlg(item.id, "")
@@ -873,9 +845,7 @@
              _this.$notify.error(res.data.failMsg.failMsg);
            }
          })
          .catch((e) => {
            console.log(e);
          });
          .catch((e) => {});
      } else if (this.activeTab == "app") {
        //激活应用
        actApp(item.id, "")
@@ -891,15 +861,9 @@
              _this.$notify.error(res.data.failMsg.failMsg);
            }
          })
          .catch((e) => {
            console.log(e);
          });
          .catch((e) => {});
      }
    },
    // checkMyAlgorith() {
    //   this.showActivateSuccess = false;
    //   this.activeName = "已激活";
    // },
    onFileUpload(file) {
      this.patchFile = { ...file };
      this.fileAdded = true;
@@ -935,12 +899,6 @@
          this.$message.error(e.msg);
        });
    },
    // openApp() {
    //   window.parent.postMessage(
    //     { msg: "toOpenApp?" + this.productDetail.productBaseId },
    //     "*"
    //   );
    // },
    onFileAdded(f) {
      this.patchUpdateStatus = "";
    },
@@ -948,7 +906,7 @@
      let installedList = [];
      let unInstalledList = [];
      let hasNewVersionList = [];
      let res = await findAllSdk();
      let res = await findAllSdk({ sdkName: this.inputText });
      if (res && res.success) {
        this.sdkUpgreading = false;
@@ -975,26 +933,8 @@
      this.notInstalledList = unInstalledList;
      this.toUpdateArr1 = this.installedList.slice(0, 10);
      this.hasNewVersionSdk = hasNewVersionList;
      this.pickTab()
      this.pickTab();
    },
    // unloadSDKinWin() {
    //   let appToUnload;
    //   let sdkToUnload;
    //   if (this.productDetail.productTypeName == "应用") {
    //     appToUnload = this.installedApps.find((item) => {
    //       return item.id == this.productDetail.productBaseId;
    //     });
    //     this.unloadApp(appToUnload);
    //   } else {
    //     sdkToUnload = this.installedList.find((item) => {
    //       return item.id == this.productDetail.productBaseId;
    //     });
    //     this.unloadSdk(sdkToUnload);
    //   }
    // },
    // unLoadSdkOrApp(item) {
    //   this.activeTab == "sdk" ? this.unloadSdk(item) : this.unloadApp(item);
    // },
    unloadSdk(sdk) {
      let _this = this;
      this.$confirm("确定要卸载该算法吗?", "提示")
@@ -1016,7 +956,6 @@
        })
        .catch((e) => {});
    },
    donwloadSDK(item) {
      let timer = null;
      item.upgradeLoading = true;
@@ -1029,7 +968,7 @@
          clearInterval(timer);
          item.upgradeLoading = false;
          this.downloadItem = "";
          window.parent.postMessage({ msg: "AppUpdate" }, "*");
        })
        .catch((err) => {
@@ -1041,19 +980,18 @@
      this.sdkUpgreading = true;
    },
    autoRefreshAppAndSdkState() {
      // 关闭后退出
      this.getAllApps();
      this.getAllSdk();
      if (!this.autoRefresh) {
        return;
      }
      if (this.appUpgreading) {
        this.getAllApps();
      }
      if (this.sdkUpgreading) {
        this.getAllSdk();
      }
      let _this = this;
      setTimeout(() => {
        _this.autoRefreshAppAndSdkState();
        if (this.appUpgreading) {
          this.getAllApps();
        }
        if (this.sdkUpgreading) {
          this.getAllSdk();
        }
      }, 1000);
    },
  },
@@ -1062,6 +1000,7 @@
<style lang="scss">
.s-task-manage {
  width: 100% !important;
  min-width: 754px !important;
  height: 100%;
  box-sizing: border-box;
  text-align: left;
@@ -1418,6 +1357,10 @@
            height: 76px;
            border-radius: 4px;
            /*  &.disabled {
              cursor: default;
            } */
            .icon-img {
              width: 58px;
              height: 58px;
@@ -1461,8 +1404,8 @@
              text-align: center;
              position: relative;
              .check-btn {
                background-color:#FFFFFF !important;
                border-color: #BDBDBD !important;
                background-color: #ffffff !important;
                border-color: #bdbdbd !important;
                color: #333333;
              }
              .update-btn {
@@ -1501,6 +1444,7 @@
                text-align: end;
                position: absolute;
                right: 0;
                width: 120px;
                margin-top: 2px;
              }
              .rocket-icon {
@@ -1633,5 +1577,14 @@
    }
  }
}
@media screen and (max-width: 800px) {
  .quick-path .left-items .quick-item:last-child {
    display: none !important;
  }
  .quick-path .left-items .quick-item:nth-child(2) {
    border: none !important;
  }
}
</style>