Selaa lähdekoodia

导出授权文件修改

zhangjie 2 vuotta sitten
vanhempi
commit
b873da1f1e

+ 7 - 0
src/components/VersionSelect.vue

@@ -44,6 +44,10 @@ export default {
       type: Boolean,
       default: false,
     },
+    filterHandle: {
+      type: Function,
+      default: null,
+    },
   },
   data() {
     return {
@@ -81,6 +85,9 @@ export default {
         pageSize: 100,
       });
       this.optionList = res.records;
+      if (this.filterHandle) {
+        this.optionList = this.filterHandle(this.optionList);
+      }
 
       if (!this.selectDefault) return;
 

+ 12 - 48
src/modules/admin/app-deploy/AppDeployBindDevice.vue

@@ -71,6 +71,7 @@
       ref="AppDeployDeviceInfoView"
       :device-id="curDeviceId"
     />
+    <AppDeployExportLicense ref="AppDeployExportLicense" :data="curRow" />
     <!-- AppDeployDeviceUpload -->
     <AppDeployDeviceUpload
       v-if="checkPrivilege('DEPLOY_DEVICE_EDIT', instance.id)"
@@ -82,18 +83,18 @@
 </template>
 
 <script>
-import { downloadBlob } from "@/plugins/utils";
-import {
-  appDeployDeviceList,
-  appDeployDeviceDelete,
-  appDeployLicenseDownload,
-} from "../api";
+import { appDeployDeviceList, appDeployDeviceDelete } from "../api";
 import AppDeployDeviceInfoView from "./AppDeployDeviceInfoView.vue";
 import AppDeployDeviceUpload from "./AppDeployDeviceUpload.vue";
+import AppDeployExportLicense from "./AppDeployExportLicense.vue";
 
 export default {
   name: "app-device-manage",
-  components: { AppDeployDeviceInfoView, AppDeployDeviceUpload },
+  components: {
+    AppDeployDeviceInfoView,
+    AppDeployDeviceUpload,
+    AppDeployExportLicense,
+  },
   props: {
     instance: {
       type: Object,
@@ -108,6 +109,7 @@ export default {
       dataList: [],
       curDeviceId: null,
       loading: false,
+      curRow: {},
     };
   },
   methods: {
@@ -131,47 +133,9 @@ export default {
     toUpload() {
       this.$refs.AppDeployDeviceUpload.open();
     },
-    async toExport(row = {}) {
-      if (this.loading) return;
-
-      this.$prompt("", "导出设置", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        // inputPattern: /^\d{1,}\.\d{1,}\.\d{1,}$/,
-        // inputErrorMessage: "版本号格式不对",
-        inputPlaceholder: "版本号,非必填",
-        inputValidator(val) {
-          if (!val) return true;
-          if (!/^\d{1,}\.\d{1,}\.\d{1,}$/.test(val)) {
-            return "版本号格式不对";
-          }
-          return true;
-        },
-      })
-        .then(({ value }) => {
-          this.exportLicense({ ...row, version: value });
-        })
-        .catch(() => {});
-    },
-    async exportLicense(row) {
-      this.loading = true;
-      const res = await downloadBlob(() => {
-        const params = {
-          id: this.instance.id,
-        };
-        if (row) params.deviceId = row.deviceId;
-        if (row.version) params.version = row.version;
-
-        return appDeployLicenseDownload(params);
-      }).catch(() => {});
-
-      this.loading = false;
-
-      if (res) {
-        this.$message.success("文件下载成功!");
-      } else {
-        this.$message.error("文件下载失败,请重新尝试!");
-      }
+    toExport(row = {}) {
+      this.curRow = { ...row, appId: this.instance.appId };
+      this.$refs.AppDeployExportLicense.open();
     },
     async toDelete(row) {
       const result = await this.$confirm("确定要删除当前设备吗?", "操作警告", {

+ 95 - 0
src/modules/admin/app-deploy/AppDeployExportLicense.vue

@@ -0,0 +1,95 @@
+<template>
+  <el-dialog
+    class="modify-org"
+    :visible.sync="modalIsShow"
+    :title="title"
+    top="10vh"
+    width="400px"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    @opened="visibleChange"
+  >
+    <el-form>
+      <el-form-item>
+        <version-select
+          v-model="versionId"
+          class="width-full"
+          :app-id="data.appId"
+          placeholder="版本号,非必填"
+          :filter-handle="filterHandle"
+        ></version-select>
+      </el-form-item>
+    </el-form>
+    <div slot="footer">
+      <el-button type="danger" @click="cancel" plain>取消</el-button>
+      <el-button type="primary" :disabled="loading" @click="submit"
+        >确认</el-button
+      >
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+import { appDeployLicenseDownload } from "../api";
+import { downloadBlob } from "@/plugins/utils";
+
+export default {
+  name: "app-deploy-export-license",
+  props: {
+    data: {
+      type: Object,
+      default() {
+        return {};
+      },
+    },
+  },
+  data() {
+    return {
+      modalIsShow: false,
+      loading: false,
+      versionId: "",
+    };
+  },
+  computed: {
+    title() {
+      return this.data.deviceId ? "导出授权文件" : "导出通用授权文件";
+    },
+  },
+  methods: {
+    visibleChange() {
+      this.versionId = null;
+    },
+    cancel() {
+      this.modalIsShow = false;
+    },
+    open() {
+      this.modalIsShow = true;
+    },
+    filterHandle(optionList) {
+      return optionList.filter((item) => !item.archived);
+    },
+    async submit() {
+      this.loading = true;
+      const res = await downloadBlob(() => {
+        const params = {
+          id: this.data.deployId,
+        };
+        if (this.data.deviceId) params.deviceId = this.data.deviceId;
+        if (this.versionId) params.versionId = this.versionId;
+
+        return appDeployLicenseDownload(params);
+      }).catch(() => {});
+
+      this.loading = false;
+
+      if (res) {
+        this.$message.success("文件下载成功!");
+      } else {
+        this.$message.error("文件下载失败,请重新尝试!");
+      }
+      this.cancel();
+    },
+  },
+};
+</script>