refactor: 显示设置调整位置,提供hasLicense函数处理v-pack失效的问题

This commit is contained in:
Captain.B 2020-11-30 18:16:53 +08:00
parent 5491eac52e
commit 1ba7a8365b
4 changed files with 28 additions and 15 deletions

View File

@ -34,7 +34,6 @@ export default {
},
...requireContext.keys().map(key => requireContext(key).system),
...requireContext.keys().map(key => requireContext(key).license),
...requireContext.keys().map(key => requireContext(key).display),
{
path: 'organizationpmnmember',
component: () => import('@/business/components/settings/organization/OrganizationMember'),

View File

@ -11,6 +11,9 @@
<el-tab-pane :label="$t('system_parameter_setting.ldap_setting')" name="ldap">
<ldap-setting/>
</el-tab-pane>
<el-tab-pane v-if="hasLicense()" :label="$t('display.title')" name="display">
<ms-display/>
</el-tab-pane>
</el-tabs>
</el-card>
</template>
@ -19,10 +22,13 @@
import EmailSetting from "./EmailSetting";
import LdapSetting from "./LdapSetting";
import BaseSetting from "./BaseSetting";
import MsDisplay from "@/business/components/xpack/display/Display";
import {hasLicense} from '@/common/js/utils';
export default {
name: "SystemParameterSetting",
components: {
MsDisplay,
BaseSetting,
EmailSetting, LdapSetting
},
@ -30,6 +36,9 @@ export default {
return {
activeName: 'base'
}
},
methods: {
hasLicense,
}
}
</script>

View File

@ -1,6 +1,6 @@
import router from './components/common/router/router'
import {LicenseKey, TokenKey} from '@/common/js/constants';
import {hasRolePermissions, hasRoles} from "@/common/js/utils";
import {TokenKey} from '@/common/js/constants';
import {hasLicense, hasRolePermissions, hasRoles} from "@/common/js/utils";
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
const whiteList = ['/login']; // no redirect whitelist
@ -26,9 +26,9 @@ export const xpack = {
};
function checkLicense(el, binding, type) {
let v = localStorage.getItem(LicenseKey);
let v = hasLicense()
if (v !== 'valid') {
if (v) {
el.parentNode && el.parentNode.removeChild(el)
}
}

View File

@ -1,12 +1,12 @@
import {
LicenseKey,
REFRESH_SESSION_USER_URL,
ROLE_ORG_ADMIN,
ROLE_ADMIN,
ROLE_ORG_ADMIN,
ROLE_TEST_MANAGER,
ROLE_TEST_USER,
ROLE_TEST_VIEWER,
TokenKey,
LicenseKey
TokenKey
} from "./constants";
import axios from "axios";
import {jsPDF} from "jspdf";
@ -45,6 +45,11 @@ export function hasRolePermission(role) {
return false
}
export function hasLicense() {
let v = localStorage.getItem(LicenseKey);
return v === 'valid';
}
//是否含有对应组织或工作空间的角色
export function hasRolePermissions(...roles) {
for (let role of roles) {
@ -238,7 +243,7 @@ export function exportPdf(name, canvasList) {
// html页面生成的canvas在pdf中图片的宽高
let imgWidth = a4Width;
let imgHeight = a4Width/contentWidth * contentHeight;
let imgHeight = a4Width / contentWidth * contentHeight;
let pageData = canvas.toDataURL('image/jpeg', 1.0);
@ -251,7 +256,7 @@ export function exportPdf(name, canvasList) {
if (leftHeight > blankHeight) {
//页面偏移
let position = 0;
while(leftHeight > 0) {
while (leftHeight > 0) {
// 本次添加占用的高度
let occupation = a4Height - currentHeight;
pdf.addImage(pageData, 'JPEG', 0, position + currentHeight, imgWidth, imgHeight);
@ -259,7 +264,7 @@ export function exportPdf(name, canvasList) {
leftHeight -= occupation;
position -= occupation;
//避免添加空白页
if(leftHeight > 0) {
if (leftHeight > 0) {
pdf.addPage();
currentHeight = 0;
}
@ -277,15 +282,15 @@ export function exportPdf(name, canvasList) {
export function windowPrint(id, zoom) {
//根据div标签ID拿到div中的局部内容
let bdhtml=window.document.body.innerHTML;
let bdhtml = window.document.body.innerHTML;
let el = document.getElementById(id);
var jubuData = el.innerHTML;
document.getElementsByTagName('body')[0].style.zoom=zoom;
document.getElementsByTagName('body')[0].style.zoom = zoom;
//把获取的 局部div内容赋给body标签, 相当于重置了 body里的内容
window.document.body.innerHTML= jubuData;
window.document.body.innerHTML = jubuData;
//调用打印功能
window.print();
window.document.body.innerHTML=bdhtml;//重新给页面内容赋值;
window.document.body.innerHTML = bdhtml;//重新给页面内容赋值;
return false;
}