From 83b010226237a7a7eb8d77078eda14f3359a4bac Mon Sep 17 00:00:00 2001 From: hanbaoshan <hanbaoshan@aiotlink.com> Date: 星期五, 16 十月 2020 13:27:22 +0800 Subject: [PATCH] 集群节点展示更新 --- src/pages/settings/components/BasicSetting.vue | 67 ++++++++++++++++++++++++++------- 1 files changed, 53 insertions(+), 14 deletions(-) diff --git a/src/pages/settings/components/BasicSetting.vue b/src/pages/settings/components/BasicSetting.vue index f7df2dd..3c05bf4 100644 --- a/src/pages/settings/components/BasicSetting.vue +++ b/src/pages/settings/components/BasicSetting.vue @@ -8,7 +8,7 @@ type="border-card" > <!-- 鏈満淇℃伅 --> - <el-tab-pane label="鏈満淇℃伅" name="first"> + <el-tab-pane label="鏈満淇℃伅" name="sysInfo" v-if="isShow('settings:sysInfo')"> <el-menu :default-openeds="openeds" background-color="#fff" @@ -179,7 +179,7 @@ </el-tab-pane> <!-- 鏃堕棿閰嶇疆 --> - <el-tab-pane label="鏃堕棿閰嶇疆" name="second"> + <el-tab-pane label="鏃堕棿閰嶇疆" name="timeSet" v-if="isShow('settings:timeSet')"> <el-form label-width="100px"> <el-form-item label="璁惧鏃堕棿"> <!-- <el-input v-model="equipmentTime" placeholder="璇疯緭鍏�" size="small"></el-input> --> @@ -232,6 +232,7 @@ style="position: absolute; left: 330px;" :disabled="syncType === '2'" @click="testNTP" + :loading="ntpTestLoading" >娴嬭瘯</el-button> </el-form-item> @@ -268,7 +269,7 @@ </el-tab-pane> <!-- 闆嗙兢绠$悊 --> - <el-tab-pane label="闆嗙兢绠$悊" name="third"> + <el-tab-pane label="闆嗙兢绠$悊" name="cluster" v-if="isShow('settings:cluster')"> <cluster-management></cluster-management> </el-tab-pane> <!-- <el-tab-pane label="澶栭儴璁块棶" name="fourth"> @@ -310,12 +311,12 @@ </el-menu-item-group> </el-submenu> </el-menu> - </el-tab-pane> --> - <el-tab-pane label="鏉冮檺绠$悊" name="user"> - <authority-management v-if="activeName === 'user'"></authority-management> + </el-tab-pane>--> + <el-tab-pane label="鏉冮檺绠$悊" name="permission" v-if="isShow('settings:permission')"> + <authority-management v-if="activeName === 'permission'"></authority-management> </el-tab-pane> - <el-tab-pane label="骞挎挱璁剧疆" name="radio"> - <radio-set v-if="activeName === 'radio'"></radio-set> + <el-tab-pane label="骞挎挱璁剧疆" name="broadcast" v-if="isShow('settings:broadcast')"> + <radio-set v-if="activeName === 'broadcast'"></radio-set> </el-tab-pane> </el-tabs> </div> @@ -359,7 +360,18 @@ })) }) return options - } + }, + isAdmin() { + if ( + sessionStorage.getItem("userInfo") && + sessionStorage.getItem("userInfo") !== "" + ) { + let loginName = JSON.parse(sessionStorage.getItem("userInfo")).username; + return loginName === "superadmin" || loginName === "basic"; + } + + return false; + }, }, directives: { focus: { @@ -373,7 +385,7 @@ loading: true, loadingText: "", gutter: 10, - activeName: "first", + activeName: "sysInfo", timezone: "", syncType: "1", ntpServer: "", @@ -469,8 +481,23 @@ cityOptions: [], countyOptions: [] }, + webPort: 0, + ntpTestLoading: false, + buttonAuthority: sessionStorage.getItem("buttonAuthoritys") || [], }; - webPort: 0; + }, + created() { + if (this.isShow("settings:sysInfo")) { + this.activeName = "sysInfo"; + } else if (this.isShow("settings:timeSet")) { + this.activeName = "timeSet"; + } else if (this.isShow("settings:cluster")) { + this.activeName = "cluster"; + } else if (this.isShow("settings:permission")) { + this.activeName = "permission"; + } else if (this.isShow("settings:broadcast")) { + this.activeName = "broadcast"; + } }, mounted() { this.$nextTick(() => { @@ -487,6 +514,9 @@ clearInterval(this.browserTimer); }, methods: { + isShow(authority) { + return this.isAdmin || this.buttonAuthority.indexOf("," + authority + ",") > -1 + }, initSysinfo() { this.loadingText = "姝e湪鑾峰彇璁惧淇℃伅..."; getDevInfo().then(rsp => { @@ -505,7 +535,7 @@ this.sysinfo.cpuInfo = devInfo.cpu[0].modelName; this.sysinfo.disks = devInfo.disk; - this.sysinfo.mem = (devInfo.mem.total / 1024 / 1024 / 1024).toFixed(2) + "KB"; + this.sysinfo.mem = (devInfo.mem.total / 1024 / 1024 / 1024).toFixed(2) + "GB"; // this.sysinfo.arch = devInfo.host.kernelArch; this.sysinfo.uptime = this.secondsFormat(devInfo.host.uptime); } @@ -529,11 +559,13 @@ var second = s - day * 24 * 3600 - hour * 3600 - minute * 60; return day + "澶�" + hour + "鏃�" + minute + "鍒�" + second + "绉�"; }, - initClockConf() { + initClockConf(ntpTest = false) { getClockInfo().then(rsp => { if (rsp && rsp.success) { this.timezone = rsp.data.time_zone; - this.syncType = rsp.data.ntp ? "1" : "2"; + if (!ntpTest) { + this.syncType = rsp.data.ntp ? "1" : "2"; + } if (rsp.data.ntp) { this.ntpServer = rsp.data.ntp_server; this.timeInterval = rsp.data.interval; @@ -690,9 +722,12 @@ message: "璁剧疆鎴愬姛" }); } + + this.initClockConf(); }) }, testNTP() { + this.ntpTestLoading = true; testNTPserver({ server: this.ntpServer }).then(rsp => { if (rsp && rsp.success) { this.$notify({ @@ -705,11 +740,15 @@ message: "鏃堕棿鍚屾澶辫触" }); } + this.ntpTestLoading = false; + this.initClockConf(true); + }).catch(err => { this.$notify({ type: "error", message: "鏃堕棿鍚屾澶辫触,璇锋鏌ユ湇鍔″櫒ip" }); + this.ntpTestLoading = false; }) }, submitAlarm() { -- Gitblit v1.8.0