From fa7044f3ccc9a91bc2bc117d1a06f650d86554f2 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@iotlink.com> Date: 星期二, 15 六月 2021 16:07:16 +0800 Subject: [PATCH] 优化联动规则加载场景列表的操作 --- src/pages/settings/components/BasicSetting.vue | 177 +++++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 117 insertions(+), 60 deletions(-) diff --git a/src/pages/settings/components/BasicSetting.vue b/src/pages/settings/components/BasicSetting.vue index 34573a2..604374d 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" @@ -79,20 +79,24 @@ <el-menu-item-group class="item-group desc-info"> <el-row :gutter="gutter"> <el-col :span="12" class="flex-box"> - <div class="xiangqin-label">ID</div> + <div class="xiangqin-label">璁惧ID</div> <div class="xiangqing-info">{{sysinfo.server_id}}</div> </el-col> - <el-col :span="12" class="flex-box"> + <!-- <el-col :span="12" class="flex-box"> <div class="xiangqin-label">璁惧缂栧彿</div> <div class="xiangqing-info">{{sysinfo.deviceNum}}</div> - </el-col> + </el-col>--> <el-col :span="12" class="flex-box"> <div class="xiangqin-label">璁惧鍨嬪彿</div> - <div class="xiangqing-info">{{sysinfo.deviceType}}</div> + <div class="xiangqing-info">{{sysinfo.deviceModel}}</div> </el-col> <el-col :span="12" class="flex-box"> - <div class="xiangqin-label">璁惧搴忓垪鍙�</div> - <div class="xiangqing-info">{{sysinfo.deviceSerialNum}}</div> + <div class="xiangqin-label">璁惧绫诲瀷</div> + <div class="xiangqing-info">{{sysinfo.deviceDesc}}</div> + </el-col> + <el-col :span="12" class="flex-box"> + <div class="xiangqin-label">閫氶亾涓暟</div> + <div class="xiangqing-info">{{sysinfo.channelCount}}</div> </el-col> <el-col :span="12" class="flex-box"> <div class="xiangqin-label">涓绘帶鐗堟湰</div> @@ -103,12 +107,20 @@ <div class="xiangqing-info">{{sysinfo.webVersion}}</div> </el-col> <el-col :span="12" class="flex-box"> - <div class="xiangqin-label">閫氶亾涓暟</div> - <div class="xiangqing-info">{{sysinfo.channelCount}}</div> + <div class="xiangqin-label">纭洏淇℃伅</div> + <div class="xiangqing-info">{{sysinfo.disks}}</div> </el-col> <el-col :span="12" class="flex-box"> - <div class="xiangqin-label">纭洏涓暟</div> - <div class="xiangqing-info">{{sysinfo.diskCount}}</div> + <div class="xiangqin-label">CPU</div> + <div class="xiangqing-info">{{sysinfo.cpuInfo}}</div> + </el-col> + <el-col :span="12" class="flex-box"> + <div class="xiangqin-label">鍐呭瓨</div> + <div class="xiangqing-info">{{sysinfo.mem}}</div> + </el-col> + <el-col :span="12" class="flex-box"> + <div class="xiangqin-label">杩愯鏃堕棿</div> + <div class="xiangqing-info">{{sysinfo.uptime}}</div> </el-col> </el-row> </el-menu-item-group> @@ -159,32 +171,14 @@ </el-menu-item-group> </el-submenu> <!-- 瀵瑰鏈嶅姟IP 鏀瑰悕涓哄閮ㄧ綉缁�(鏂皌ab)--> - </el-menu> </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> --> {{ equipmentTime }} - </el-form-item> - - <el-form-item label="鏃跺尯" prop="timezone"> - <el-select - v-model="timezone" - placeholder="璇烽�夋嫨" - style="width: 360px; height: 32px" - size="small" - > - <el-option - v-for="item in timeZoneOption" - :key="item.value" - :label="item.label" - :value="item.value" - ></el-option> - </el-select> </el-form-item> <div style="text-align: left;padding: 10px 0px"> <div class="time-type">NTP鏍℃椂</div> @@ -216,6 +210,7 @@ style="position: absolute; left: 330px;" :disabled="syncType === '2'" @click="testNTP" + :loading="ntpTestLoading" >娴嬭瘯</el-button> </el-form-item> @@ -233,7 +228,6 @@ placeholder="閫夋嫨鏃ユ湡鏃堕棿" size="small" value-format="yyyy-MM-dd HH:mm:ss" - :readonly="settimeRadio" :disabled="syncType === '1'" ></el-date-picker> <el-checkbox @@ -253,10 +247,10 @@ </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"> + <!-- <el-tab-pane label="澶栭儴璁块棶" name="fourth"> <el-menu :default-openeds="openeds" background-color="#fff" @@ -294,14 +288,13 @@ </el-form> </el-menu-item-group> </el-submenu> - </el-menu> + </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="user"> - <authority-management v-if="activeName === 'user'"></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> @@ -327,6 +320,7 @@ import ClusterManagement from "./ClusterManagement"; import AuthorityManagement from "./AuthorityManagement"; import RadioSet from "./RadioSet"; +import config from '../../../../package.json' export default { name: "BasicSettings", @@ -337,15 +331,26 @@ RadioSet }, computed: { - timeZoneOption() { - let options = [] - TimeZones.forEach(zone => { - options = options.concat(zone.utc.map(v => { - return { value: v, label: v } - })) - }) - return options - } + // timeZoneOption() { + // let options = [] + // TimeZones.forEach(zone => { + // options = options.concat(zone.utc.map(v => { + // return { value: v, label: v } + // })) + // }) + // 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: { @@ -359,7 +364,7 @@ loading: true, loadingText: "", gutter: 10, - activeName: "first", + activeName: "sysInfo", timezone: "", syncType: "1", ntpServer: "", @@ -455,8 +460,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(() => { @@ -464,6 +484,7 @@ // this.initAlarmConf(); this.initResourceConfig(); this.initClockConf(); + //this.markStartTime(); }); }, beforeDestroy() { @@ -471,6 +492,9 @@ clearInterval(this.browserTimer); }, methods: { + isShow(authority) { + return this.isAdmin || this.buttonAuthority.indexOf("," + authority + ",") > -1 + }, initSysinfo() { this.loadingText = "姝e湪鑾峰彇璁惧淇℃伅..."; getDevInfo().then(rsp => { @@ -484,11 +508,23 @@ this.alarmConf.min_video_len = rsp.data.min_video_len; this.alarmConf.max_video_len = rsp.data.max_video_len; + if (this.sysinfo.deviceInfo) { + let devInfo = this.sysinfo.deviceInfo; + + this.sysinfo.cpuInfo = devInfo.cpu[0].modelName; + this.sysinfo.disks = "( " + devInfo.disk + ") "; + 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); + } + if (!this.sysinfo.server_port) { this.sysinfo.server_port = 7003; } this.webPort = this.sysinfo.server_port; + + this.sysinfo.webVersion = 'V' + config.version; } this.loading = false; @@ -496,11 +532,20 @@ this.loading = false; }); }, - initClockConf() { + secondsFormat(s) { + var day = Math.floor(s / (24 * 3600)); // Math.floor()鍚戜笅鍙栨暣 + var hour = Math.floor((s - day * 24 * 3600) / 3600); + var minute = Math.floor((s - day * 24 * 3600 - hour * 3600) / 60); + var second = s - day * 24 * 3600 - hour * 3600 - minute * 60; + return day + "澶�" + hour + "鏃�" + minute + "鍒�" + second + "绉�"; + }, + 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; @@ -514,7 +559,6 @@ }, runClock() { this.equipmentTime = this.formatTime(++this.timestamp, 'Y-M-D h:m:s'); - // console.log(this.equipmentTime) this.clockTimer = setTimeout(() => { this.runClock(); }, 1000) @@ -546,6 +590,10 @@ }, 1000) } }, + markStartTime() { + let timestamp = new Date().getTime() / 1000; + this.settime = this.formatTime(timestamp, 'Y-M-D h:m:s') + }, submitSysinfo() { this.$refs["sysinfo"].validate(valid => { if (valid) { @@ -557,7 +605,7 @@ if (this.sysinfo.ip !== this.originNetConfig.ip) { let newUri = location.protocol + "//" + this.sysinfo.ip + ":" + this.sysinfo.server_port; var changeIPTimer = setTimeout(() => { - this.$alert('<strong>鎮ㄥ凡淇敼浜嗘湇鍔″櫒ip, 璇烽噸鏂扮櫥褰�</strong><a href="' + newUri + '"> ' + newUri + '<a/>', '鎻愮ず', { + this.$alert('<strong>鎮ㄥ凡淇敼浜嗘湇鍔″櫒ip, 璇烽噸鏂扮櫥褰�</strong><a target="_parent" href="' + newUri + '"> ' + newUri + '<a/>', '鎻愮ず', { dangerouslyUseHTMLString: true }); }, 10000) @@ -603,7 +651,7 @@ if (this.sysinfo.server_port !== this.webPort) { let newUri = location.protocol + "//" + this.sysinfo.ip + ":" + this.sysinfo.server_port; var changeIPTimer = setTimeout(() => { - this.$alert('<strong>鎮ㄥ凡淇敼浜嗘湇鍔″櫒绔彛, 璇烽噸鏂扮櫥褰�</strong><a href="' + newUri + '"> ' + newUri + '<a/>', '鎻愮ず', { + this.$alert('<strong>鎮ㄥ凡淇敼浜嗘湇鍔″櫒绔彛, 璇烽噸鏂扮櫥褰�</strong><a target="_parent" href="' + newUri + '"> ' + newUri + '<a/>', '鎻愮ず', { dangerouslyUseHTMLString: true }); }, 5000) @@ -614,6 +662,9 @@ return false; } }); + }, + checkTimeZone(val) { + }, submitClock() { if (this.syncType === '1') { @@ -649,9 +700,11 @@ message: "璁剧疆鎴愬姛" }); } + this.initClockConf(); }) }, testNTP() { + this.ntpTestLoading = true; testNTPserver({ server: this.ntpServer }).then(rsp => { if (rsp && rsp.success) { this.$notify({ @@ -664,11 +717,15 @@ message: "鏃堕棿鍚屾澶辫触" }); } + this.ntpTestLoading = false; + this.initClockConf(true); + }).catch(err => { this.$notify({ type: "error", message: "鏃堕棿鍚屾澶辫触,璇锋鏌ユ湇鍔″櫒ip" }); + this.ntpTestLoading = false; }) }, submitAlarm() { @@ -783,8 +840,8 @@ // margin-left: -80px; .el-form-item { text-align: left; - &.is-required:not(.is-no-asterisk)>.el-form-item__label:before{ - margin-left:-8px; + &.is-required:not(.is-no-asterisk) > .el-form-item__label:before { + margin-left: -8px; } .el-button { float: right; @@ -933,12 +990,12 @@ width: 300px; } } -.desc-info{ +.desc-info { margin-bottom: 14px; - .flex-box{ + .flex-box { height: 40px; line-height: 40px; - .xiangqin-label{ + .xiangqin-label { width: 80px; } } -- Gitblit v1.8.0