index.vue 4.18 KB
<template>
  <div class="app-container authorize">
    <el-card class="box-card" style="width: 30vw">
      <div slot="header" class="clearfix">
        <span>{{ $t("systemPermission.authorizationInformation") }}</span>
      </div>
      <el-descriptions :column="1" border>
        <el-descriptions-item
          label-class-name="descriptions-label"
          :label="$t('systemPermission.authorize.companySoftware')"
          >{{ customName }}
        </el-descriptions-item>
        <el-descriptions-item
          label-class-name="descriptions-label"
          :label="$t('systemPermission.authorize.authorizedVersion')"
          >{{ customRole }}
        </el-descriptions-item>
        <el-descriptions-item
          label-class-name="descriptions-label"
          :label="$t('systemPermission.authorize.expirationDate')"
          >{{ expireTime }}
        </el-descriptions-item>
        <el-descriptions-item
          label-class-name="descriptions-label"
          :label="$t('systemPermission.authorize.permit')"
          ><el-tag :type="isValid ? 'success' : 'danger'">{{
            isValid ? $t("systemPermission.authorize.effective") : $t("systemPermission.authorize.invalid")
          }}</el-tag>
        </el-descriptions-item>
        <el-descriptions-item label-class-name="descriptions-label" label=""
          ><el-button type="primary" size="mini" @click="btnOpenAuthorize"
            >{{ $t("systemPermission.authorize.updateAuthorization") }}</el-button
          >
        </el-descriptions-item>
      </el-descriptions>
    </el-card>
    <el-card
      v-show="isShow"
      class="box-card"
      style="width: 30vw; margin-top: 10px"
    >
      <div slot="header" class="clearfix">
        <span>{{ $t("systemPermission.authorize.importAuthorization") }}</span>
      </div>
      <el-descriptions :column="1" border>
        <el-descriptions-item
          label-class-name="descriptions-label"
          :label="$t('systemPermission.authorize.enterAuthorization')"
          ><el-input type="textarea" v-model="authorize"></el-input>
        </el-descriptions-item>
        <el-descriptions-item label-class-name="descriptions-label" label=""
          ><el-button type="primary" size="mini" @click="btnUpdAuthorize"
            >{{ $t("systemPermission.authorize.update") }}</el-button
          ><el-button type="primary" size="mini" plain @click="btnCancel"
            >{{ $t("systemPermission.authorize.cancel") }}</el-button
          >
        </el-descriptions-item>
      </el-descriptions>
    </el-card>
  </div>
</template>

<script>
import { getLicense, importLicense } from "@/api/user";
import { formatTime, showMsg } from "@/utils/index.js";
export default {
  data() {
    return {
      customName: "",
      customRole: "",
      expireTime: "",
      isValid: false,
      authorize: "",
      isShow: false,
    };
  },
  mounted() {
    this.loadLicense();
  },
  methods: {
    loadLicense() {
      getLicense().then((response) => {
        this.customName = response.data.customName;
        this.customRole = response.data.customRole;
        this.expireTime = formatTime(
          new Date(response.data.expireTime),
          "{y}-{m}-{d} {h}:{i}:{s}"
        );
        this.isValid = response.code === "Success";
      });
    },
    btnOpenAuthorize() {
      this.isShow = true;
    },
    btnUpdAuthorize() {
      if (this.authorize.trim() == "") {
        showMsg(this.$t("systemPermission.msg.authEmpty"), false);
        return;
      }
      importLicense(this.authorize).then((response) => {
        if (response.code === "Success") {
          showMsg(this.$t("systemPermission.msg.authSuccess"));
          this.authorize = "";
          this.isShow = false;
        } else {
          showMsg(this.$t("systemPermission.msg.authFailed"));
        }
      });
    },
    btnCancel() {
      this.authorize = "";
      this.isShow = false;
    },
  },
};
</script>
<style scoped>
.grid-content {
  padding-top: 40px;
  color: #333333;
}
.el-col {
  line-height: 36px;
}
.el-tag {
  font-size: 14px;
}
</style>
<style>
.authorize {
  .descriptions-label {
    text-align: right !important;
    /* color:black !important; */
  }
  .el-textarea__inner {
    min-height: 200px !important;
  }
}
</style>