From 6f23040d7580a8a842731fd0a809c9e73dcd4dc5 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@iotlink.com> Date: 星期二, 06 七月 2021 14:22:23 +0800 Subject: [PATCH] 全景跟踪.隐藏轨迹图菜单 --- src/pages/systemSettings/index/App.vue | 282 ++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 181 insertions(+), 101 deletions(-) diff --git a/src/pages/systemSettings/index/App.vue b/src/pages/systemSettings/index/App.vue index 9f3e647..785be66 100644 --- a/src/pages/systemSettings/index/App.vue +++ b/src/pages/systemSettings/index/App.vue @@ -28,12 +28,20 @@ @click="openAccount(item, index)" > <div class="touxiang"> - <img :src="item.headpic" alt="" /> + <img + v-if="item.headpic" + :src=" + item.headpic.indexOf('http') > -1 + ? item.headpic + : 'http://' + item.headpic + " + alt="" + /> </div> <span class="user-name">{{ item.username }}</span> </div> </div> - <div class="add-account" > + <div class="add-account"> <span class="icon iconfont" @click="showAddAccount"></span> </div> </div> @@ -82,7 +90,15 @@ > <div class="content-top"> <div class="touxiang-big"> - <img :src="activeAccountItem.headpic" alt="" /> + <img + v-if="activeAccountItem.headpic" + :src=" + activeAccountItem.headpic.indexOf('http') > -1 + ? activeAccountItem.headpic + : 'http://' + activeAccountItem.headpic + " + alt="" + /> </div> <div class="user-desc"> <div class="username"> @@ -109,7 +125,13 @@ ></span > </div> - <div class="user-role">{{activeAccountItem.sysRoles.length?activeAccountItem.sysRoles[0].name:""}}</div> + <div class="user-role"> + {{ + activeAccountItem.sysRoles.length + ? activeAccountItem.sysRoles[0].name + : "" + }} + </div> </div> </div> <div class="list-btn"> @@ -121,7 +143,6 @@ <div class="change-pw" v-if="inAccountDetail && isChangePw"> <div class="title">淇敼瀵嗙爜</div> - <el-form :model="passwordForm" :rules="pwRules" @@ -155,8 +176,8 @@ </el-form-item> </el-form> <div class="btns"> - <div class="cancel" @click="cancelChangePassword">鍙栨秷</div> - <div class="ok">淇濆瓨</div> + <div class="cancel" @click="cancelPassword">鍙栨秷</div> + <div class="ok" @click="SaveNewPassword('passwordForm')">淇濆瓨</div> </div> </div> @@ -201,9 +222,15 @@ <div class="upload-group"> <div class="upload-jpg" - v-for="(item, index) in jpgArr" + :class=" + selectedPic == index && url !== '' ? 'upload-jpg-mask' : '' + " + v-for="(url, index) in jpgArr" :key="index" - ></div> + @click="pickHeadDefPic(url, index)" + > + <img v-if="url !== ''" :src="url" alt="" srcset="" /> + </div> <el-upload class="upload-demo" @@ -227,6 +254,15 @@ placeholder="蹇呭~" v-model="addForm.userName" ></el-input> + </el-form-item> + <el-form-item prop="roleId"> + <div class="p-title">瑙掕壊锛�</div> + <el-select + v-model="addForm.roleId" + placeholder="璇烽�夋嫨瑙掕壊" + > + <el-option v-for="(item,i) in roleList" :key="i" :label="item.name" :value="item.id"></el-option> + </el-select> </el-form-item> <el-form-item prop="nickName"> <div class="p-title">鏄电О锛�</div> @@ -433,7 +469,7 @@ </div> <div class="btns"> - <div class="cancel" @click="cancelChangePassword">鍙栨秷</div> + <div class="cancel" @click="cancelPassword">鍙栨秷</div> <div class="ok" @click="submitClock">淇濆瓨</div> </div> </div> @@ -469,7 +505,8 @@ updatePassword, deleteUser, getUserMenus, - getSysMenus, + defHeadPics, + getRoles, } from "@/api/user"; import switchBar from "../components/switchBar"; import ipInput from "@/components/subComponents/IPInput"; @@ -488,16 +525,6 @@ generalSettings, }, data() { - var validatePass = (rule, value, callback) => { - if (value === "") { - callback(new Error("璇疯緭鍏ュ瘑鐮�")); - } else { - if (this.addForm.checkPass !== "") { - this.$refs.addForm.validateField("checkPassword"); - } - callback(); - } - }; var validatePass2 = (rule, value, callback) => { if (value === "") { callback(new Error("璇峰啀娆¤緭鍏ュ瘑鐮�")); @@ -507,30 +534,10 @@ callback(); } }; - var validatePass3 = (rule, value, callback) => { - if (value === "") { - callback(new Error("璇疯緭鍏ュ瘑鐮�")); - } else { - if (this.passwordForm.password !== "") { - this.$refs.passwordForm.validateField("pw"); - } - callback(); - } - }; - var validatePass5 = (rule, value, callback) => { - if (value === "") { - callback(new Error("璇疯緭鍏ュ瘑鐮�")); - } else { - if (this.passwordForm.newPassword !== "") { - this.$refs.passwordForm.validateField("newPw"); - } - callback(); - } - }; var validatePass4 = (rule, value, callback) => { if (value === "") { callback(new Error("璇峰啀娆¤緭鍏ュ瘑鐮�")); - } else if (value !== this.passwordForm.confirmPassword) { + } else if (value !== this.passwordForm.newPassword) { callback(new Error("涓ゆ杈撳叆瀵嗙爜涓嶄竴鑷�!")); } else { callback(); @@ -559,6 +566,7 @@ showSecInput: false, showYrsInput: false, showMonthInput: false, + selectedPic: null, showDayInput: false, cameraInfo: false, dependentScene: false, @@ -571,6 +579,7 @@ syncType: "1", equipmentTime: "", equipmentDate: "", + roleList: [], ntpTestLoading: false, settime: "", weekday: "", @@ -583,7 +592,7 @@ { name: "閫氱敤璁剧疆" }, ], accountArr: [], - jpgArr: [{}, {}, {}, {}, {}, {}, {}, {}, {}], + jpgArr: ["", "", "", "", "", "", "", "", ""], isManual: false, isNtp: true, activePage: "璐︽埛", @@ -609,6 +618,7 @@ password: "", headpic: "", confirmPassword: "", + roleId:"" }, rules: { userName: [ @@ -620,13 +630,23 @@ trigger: "blur", }, ], - password: [{ validator: validatePass, trigger: "blur" }], + password: [ + { required: true, message: "璇疯緭鍏ュ瘑鐮�", trigger: "blur" }, + { min: 6, message: "闀垮害鑷冲皯涓� 6 浣�", trigger: "blur" }, + ], confirmPassword: [{ validator: validatePass2, trigger: "blur" }], }, pwRules: { - pw: [{ validator: validatePass3, trigger: "blur" }], - newPw: [{ validator: validatePass5, trigger: "blur" }], - confirmNewPw: [{ validator: validatePass4, trigger: "blur" }], + // pw: [{ validator: validatePass3, trigger: "blur" }], + curPassword: [ + { required: true, message: "璇疯緭鍏ュ瘑鐮�", trigger: "blur" }, + { min: 6, message: "闀垮害鑷冲皯涓� 6 浣�", trigger: "blur" }, + ], + newPassword: [ + { required: true, message: "璇疯緭鍏ュ瘑鐮�", trigger: "blur" }, + { min: 6, message: "闀垮害鑷冲皯涓� 6 浣�", trigger: "blur" }, + ], + confirmPassword: [{ validator: validatePass4, trigger: "blur" }], }, }; }, @@ -636,13 +656,27 @@ }, mounted() { this.fetchUserList(); + this.fetchDefHeadPic(); }, methods: { - fetchUserList() { + fetchDefHeadPic() { + defHeadPics().then((res) => { + res.data.forEach((x, i) => { + this.jpgArr[i] = x; + }); + }); + }, + fetchUserList(showLast = false) { getUsers().then((res) => { this.accountArr = res.data; if (this.accountArr.length) { this.activeAccountItem = this.accountArr[0]; + this.activeAccountIndex = 0 + } + if (showLast) { + this.cancelAdd(); + const lastIdx = this.accountArr.length - 1; + this.openAccount(this.accountArr[lastIdx], lastIdx); } }); }, @@ -661,13 +695,15 @@ nickname: this.inputNickName, }).then((res) => { this.$message.success(res.msg); - this.fetchUserList(); + this.fetchUserList(true); }); }, openAccount(item, i) { this.activeAccountItem = item; this.activeAccountIndex = i; this.inAccountDetail = false; + this.cancelSet(); + this.fetchMenu(); }, minusOne(typ) { this.isSyncBrowser = false; @@ -726,14 +762,12 @@ }, fatherChange(item) { item.children.forEach((x) => { - x.selected = false; + x.selected = item.selected; }); }, childrenChange(item) { let isAllSelected = item.children.every((x) => x.selected == true); - let isAllNotSelected = item.children.every((x) => x.selected == false); - if (isAllSelected) item.selected = true; - if (isAllNotSelected) item.selected = false; + item.selected = isAllSelected }, getMaxDay() { const maxDay = new Date(+this.syncYrs, +this.syncMonth, 0).getDate(); @@ -790,7 +824,7 @@ }, submitClock() { if (this.syncType === "1") { - if (this.ntpServer === ""||this.ntpServer === "...") { + if (this.ntpServer === "" || this.ntpServer === "...") { this.$notify({ type: "error", message: "NTP 鏈嶅姟鍣ㄥ湴鍧�涓嶈兘涓虹┖", @@ -839,7 +873,10 @@ id: this.activeAccountItem.id, menuIds: arr, }).then((res) => { - res.data; + if (res.success) { + this.$message.success(res.msg) + this.cancelSet() + } }); }, formatTime(number, format) { @@ -870,7 +907,9 @@ let param = new FormData(); param.append("file", params.file); uploadHeadPic(param).then((res) => { - this.addForm.headpic = res.data; + let index = this.jpgArr.findIndex((x) => x == ""); + this.$set(this.jpgArr, index, res.data); + this.loadedPic= res.data }); }, initClockConf(ntpTest = false) { @@ -879,8 +918,8 @@ this.timezone = rsp.data.time_zone; if (!ntpTest) { this.syncType = rsp.data.ntp ? "1" : "2"; - this.isNtp = rsp.data.ntp - this.isManual = !rsp.data.ntp + this.isNtp = rsp.data.ntp; + this.isManual = !rsp.data.ntp; } if (rsp.data.ntp) { this.ntpServer = rsp.data.ntp_server; @@ -889,7 +928,7 @@ this.timestamp = rsp.data.local_time; if (this.clockTimer === null) { this.runClock(); - if(this.isManual)this.parseTime() + if (this.isManual) this.parseTime(); } } }); @@ -931,16 +970,42 @@ showAddAccount() { this.inAccountDetail = false; this.isAddAccount = true; + getRoles().then((res) => { + if (res.success) { + this.roleList= res.data + } + }); }, cancelAdd() { this.inAccountDetail = false; this.isAddAccount = false; + this.$refs["addForm"].resetFields(); }, - cancelChangePassword() { + cancelPassword() { this.isChangePw = false; this.inAccountDetail = false; + this.$refs["passwordForm"].resetFields(); }, - + SaveNewPassword(formName) { + this.$refs[formName].validate((valid) => { + if (valid) { + updatePassword({ + oldPwd: this.passwordForm.curPassword, + newPwd: this.passwordForm.newPassword, + }).then( + (res) => { + if(res.success) { + this.$message.success(res.msg); + this.cancelPassword() + } + }, + (err) => { + this.$message.warning("淇濆瓨澶辫触锛�" + err.msg); + } + ); + } + }); + }, saveAddAccount(formName) { this.$refs[formName].validate((valid) => { if (valid) { @@ -953,6 +1018,7 @@ addUser(data).then( (res) => { this.$message.success(res.data); + this.fetchUserList(true); }, (err) => { this.$message.warning("淇濆瓨澶辫触锛�" + err.msg); @@ -963,6 +1029,10 @@ return false; } }); + }, + pickHeadDefPic(url, i) { + this.addForm.headpic = url; + this.selectedPic = i; }, testNTP() { this.ntpTestLoading = true; @@ -993,6 +1063,7 @@ cancelSet() { this.isSetPermission = false; this.inAccountDetail = false; + this.sysMenus = []; }, showChangePassword() { this.isChangePw = true; @@ -1011,9 +1082,10 @@ cancelButtonText: "鍙栨秷", }) .then(() => { - deleteUser({ + let obj = { ids: [this.activeAccountItem.id], - }).then((res) => { + }; + deleteUser(obj).then((res) => { if (res.success) { this.fetchUserList(); this.$message({ @@ -1039,12 +1111,17 @@ openPermission() { this.inAccountDetail = true; this.isSetPermission = true; - this.fetchMenu(); + if (this.sysMenus.length==0) { + this.fetchMenu() + } }, - parseTime(){ - debugger; - [this.syncYrs, this.syncMonth, this.syncDay] = this.equipmentDate.split("-"); - [this.syncHour, this.syncMin, this.syncSec] = this.equipmentTime.split(":"); + parseTime() { + [this.syncYrs, this.syncMonth, this.syncDay] = this.equipmentDate.split( + "-" + ); + [this.syncHour, this.syncMin, this.syncSec] = this.equipmentTime.split( + ":" + ); }, changeSwitch(str) { if (str == "isNtp") { @@ -1053,28 +1130,15 @@ this.isNtp = !this[str]; } this.syncType = this.isNtp ? "1" : "2"; - if (this.isManual) this.parseTime() + if (this.isManual) this.parseTime(); }, }, computed: { - isShowAddAccount(){ - const info = JSON.parse(sessionStorage.getItem('userInfo')) - return true - } + isShowAddAccount() { + const info = JSON.parse(sessionStorage.getItem("userInfo")); + return true; + }, }, - // watch: { - // isManual(v) { - // this.isNtp = !v; - // v && (this.syncType = "2"); - // if (v) { - - // } - // }, - // isNtp(v) { - // this.isManual = !v; - // v && (this.syncType = "1"); - // }, - // }, }; </script> <style lang="scss"> @@ -1130,8 +1194,7 @@ .account-left { .add-account { color: rgba(61, 104, 225, 1); - margin-top: 50px; - + margin-top: 30px; .iconfont { cursor: pointer; font-size: 32px; @@ -1260,7 +1323,7 @@ margin: 5px 15px; height: 30px; line-height: 30px; - width: 90px; + // width: 90px; text-align: left; font-size: 15px; display: flex; @@ -1279,9 +1342,9 @@ cursor: pointer; } } - .user-role{ - margin: 5px 0 0 15px; - font-size: 14px; + .user-role { + margin: 5px 0 0 15px; + font-size: 14px; color: darkseagreen; } } } @@ -1363,37 +1426,54 @@ .add-account-page { .upload-group { height: 120px; - width: 350px; + width: 360px; margin: 0 auto; overflow: hidden; .upload-jpg { - height: 50px; - width: 50px; + height: 46px; + width: 46px; float: left; margin: 0 10px; - background-color: antiquewhite; - margin-bottom: 20px; - border-radius: 25px; + margin-bottom: 10px; + background-color: rgba(242, 242, 242, 1); + border: 3px solid transparent; + border-radius: 50%; + cursor: pointer; + img { + height: 46px; + width: 46px; + } + } + .upload-jpg-mask { + border: 3px solid blue; } .upload-jpg-up { - height: 50px; - width: 50px; + height: 52px; + width: 52px; float: left; display: flex; background-color: rgba(242, 242, 242, 1); margin: 0 10px; - margin-bottom: 20px; + margin-bottom: 10px; border-radius: 25px; justify-content: center; align-items: center; font-size: 12px; cursor: pointer; } + .loaded-Pic { + } } .fill-group { .p-title { + height: 34px; text-align: left; } + .el-form-item{ + .el-select { + width: 100%; +} + } } } } -- Gitblit v1.8.0