123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <template>
- <el-dialog
- class="page-dialog"
- :visible.sync="modalIsShow"
- width="800px"
- top="10px"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- append-to-body
- title="授权测试"
- @open="visibleChange"
- >
- <el-tabs v-model="tabType" type="card" v-loading="loading">
- <el-tab-pane label="授权文件解密查看" name="tab1">
- <div class="tab1-wrap">
- <el-form>
- <el-form-item>
- <div style="display: flex; align-items: flex-start">
- <span style="color: #f56c6c; font-size: 14px; margin-right: 4px"
- >*</span
- >
- <UploadButton
- theme="success"
- btnContent="选择文件"
- @file-change="getFile"
- showFileList
- :autoUpload="false"
- style="margin-right: 10px"
- />
- </div>
- </el-form-item>
- <el-form-item>
- <version-select
- v-model="version"
- placeholder="版本号,非必填"
- ></version-select>
- <el-button
- type="primary"
- style="margin-left: 10px"
- :disabled="!file"
- @click="see"
- >解密查看</el-button
- >
- </el-form-item>
- </el-form>
- <json-viewer
- v-if="info"
- :value="info"
- :expand-depth="9"
- ></json-viewer>
- </div>
- </el-tab-pane>
- <el-tab-pane label="授权信息加密下载" name="tab2">
- <vue-json-editor
- v-model="resultInfo"
- :showBtns="false"
- :mode="'code'"
- @json-change="onJsonChange"
- @json-save="onJsonSave"
- @has-error="onError"
- :format="['lic']"
- />
- <br />
- <div style="text-align: right">
- <el-button type="primary" :disabled="!hasJsonFlag" @click="createFile"
- >确定</el-button
- >
- </div>
- </el-tab-pane>
- </el-tabs>
- </el-dialog>
- </template>
- <script>
- import {
- orgQuery,
- appDeployOrgList,
- appDeployOrgUpdate,
- authorizeFileDownload,
- appDeployDeviceView,
- } from "../api";
- import vueJsonEditor from "vue-json-editor";
- import { downloadBlob } from "@/plugins/utils";
- import UploadButton from "@/components/UploadButton";
- export default {
- name: "authorize-file-test",
- components: { vueJsonEditor, UploadButton },
- data() {
- return {
- modalIsShow: false,
- tabType: "tab1",
- info: "",
- resultInfo: {},
- hasJsonFlag: true,
- loading: false,
- version: "",
- file: null,
- };
- },
- methods: {
- getFile(obj) {
- this.file = obj.file;
- },
- see() {
- this.loading = true;
- appDeployDeviceView({
- file: this.file,
- version: this.version,
- })
- .then((res) => {
- console.log("rrr", res);
- this.info = res || "";
- })
- .finally(() => {
- this.loading = false;
- });
- },
- onJsonChange(value) {
- // 实时保存
- this.onJsonSave(value);
- },
- onJsonSave(value) {
- this.resultInfo = value;
- this.hasJsonFlag = true;
- },
- onError(value) {
- this.hasJsonFlag = false;
- },
- // 检查json
- async createFile() {
- this.loading = true;
- const res = await downloadBlob(() => {
- return authorizeFileDownload(this.resultInfo || {});
- }).catch(() => {});
- this.loading = false;
- if (res) {
- this.$message.success("文件下载成功!");
- } else {
- this.$message.error("文件下载失败,请重新尝试!");
- }
- },
- visibleChange() {
- this.tabType = "tab1";
- this.resultInfo = {};
- this.hasJsonFlag = true;
- this.loading = false;
- this.version = "";
- this.file = null;
- },
- cancel() {
- this.modalIsShow = false;
- },
- open() {
- this.modalIsShow = true;
- },
- },
- };
- </script>
- <style scoped lang="scss">
- .tab1-wrap {
- min-height: 300px;
- }
- .tab1-form {
- display: flex;
- align-items: center;
- }
- </style>
- <style lang="scss">
- .jsoneditor-vue {
- height: calc(100vh - 280px);
- .jsoneditor-outer {
- margin: 0;
- padding: 0;
- }
- }
- .jsoneditor-mode-code {
- .jsoneditor-menu {
- display: none;
- // opacity: 0;
- }
- }
- </style>
|