浏览代码

授权配置

zhangjie 3 年之前
父节点
当前提交
4aa531da23
共有 4 个文件被更改,包括 116 次插入0 次删除
  1. 6 0
      src/constants/adminNavs.js
  2. 17 0
      src/modules/admin/api.js
  3. 6 0
      src/modules/admin/router.js
  4. 87 0
      src/modules/admin/views/AuthSet.vue

+ 6 - 0
src/constants/adminNavs.js

@@ -22,6 +22,12 @@ const navs = [
     parentId: "1",
     name: "权限管理",
     url: "PrivilegeManage"
+  },
+  {
+    id: "5",
+    parentId: "1",
+    name: "授权配置",
+    url: "AuthSet"
   }
 ];
 

+ 17 - 0
src/modules/admin/api.js

@@ -27,3 +27,20 @@ export const updateMenu = datas => {
 export const deleteMenu = id => {
   return $post("/api/admin/sys/privilege/remove", { id });
 };
+
+// auth-set
+export const authSelect = () => {
+  return $post("/api/admin/auth/select", {});
+};
+export const offlineActivation = datas => {
+  return $post("/api/admin/auth/offline/activation", datas);
+};
+export const exportDeviceInfo = () => {
+  return $post(
+    "/api/admin/auth/export/device/info",
+    {},
+    {
+      responseType: "blob"
+    }
+  );
+};

+ 6 - 0
src/modules/admin/router.js

@@ -1,6 +1,7 @@
 import AdminUserManage from "./views/AdminUserManage.vue";
 import PrivilegeManage from "./views/PrivilegeManage.vue";
 import SystemRoleManage from "./views/SystemRoleManage.vue";
+import AuthSet from "./views/AuthSet.vue";
 import Admin from "./views/Admin.vue";
 
 export default {
@@ -22,6 +23,11 @@ export default {
       path: "system-role-manage",
       name: "SystemRoleManage",
       component: SystemRoleManage
+    },
+    {
+      path: "auth-set",
+      name: "AuthSet",
+      component: AuthSet
     }
   ]
 };

+ 87 - 0
src/modules/admin/views/AuthSet.vue

@@ -0,0 +1,87 @@
+<template>
+  <div class="auth-set">
+    <div class="part-box part-box-pad">
+      <el-form ref="modalFormComp" :model="modalForm" label-width="120px">
+        <el-form-item prop="loginName" label="当前信息:">
+          {{ modalForm.expireTime === null ? "未授权" : "已授权" }}
+        </el-form-item>
+        <el-form-item label="过期时间:">
+          <span v-if="modalForm.expireTime === -1">不过期</span>
+          <span v-else-if="modalForm.expireTime">
+            {{ modalForm.expireTime | timestampFilter }}</span
+          >
+          <span v-else>--</span>
+        </el-form-item>
+        <el-form-item prop="mobileNumber" label="导出:">
+          <el-button type="primary" :loading="downloading" @click="toExport">
+            硬件信息
+          </el-button>
+        </el-form-item>
+        <el-form-item prop="code" label="导入授权文件:">
+          <upload-button
+            btn-content="选择文件"
+            btn-type="primary"
+            :upload-url="uploadUrl"
+            :format="['lic']"
+            accept=".lic"
+            style="margin:0;"
+            @valid-error="validError"
+            @upload-success="uploadSuccess"
+          >
+          </upload-button>
+        </el-form-item>
+      </el-form>
+    </div>
+  </div>
+</template>
+
+<script>
+import { downloadByApi } from "@/plugins/download";
+import { exportDeviceInfo, authSelect } from "../api";
+import UploadButton from "@/components/UploadButton";
+
+export default {
+  name: "auth-set",
+  components: { UploadButton },
+  data() {
+    return {
+      modalForm: {
+        expireTime: "",
+        authFile: null
+      },
+      downloading: false,
+      // import
+      uploadUrl: "/api/admin/auth/offline/activation"
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    async search() {
+      const res = await authSelect();
+      this.modalForm.expireTime = res;
+    },
+    async toExport() {
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return exportDeviceInfo();
+      }).catch(e => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
+    },
+    validError(errorData) {
+      this.$message.error(errorData.message);
+    },
+    uploadSuccess() {
+      this.search();
+    }
+  }
+};
+</script>