123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- <template>
- <div style="height: 100%">
- <div v-show="isLogin" class="left-menu">
- <div style="background-color: #0053cb;width: 60px;height: 60px;display: inline-block">
- <span class="c-icon collapse-btn" @click="toggleSideBar">
- <i-ant-design-unordered-list-outlined/>
- </span>
- </div>
- <div class="title">
- <el-avatar class="title-logo" shape="square" :size="32" :src="logo"></el-avatar>
- <span class="title-content">智慧运营管理中心</span>
- </div>
- <el-select class="select-btn" v-model="value">
- <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
- </el-option>
- </el-select>
- </div>
- <div v-show="isLogin" class="right-menu">
- <div class="header-btn">
- <span class="c-icon" style="margin: 10px 4px;padding: 6px 10px 0">
- <i-ant-design-desktop-outlined/>
- </span>
- <span class="c-icon" style="margin: 10px 4px;padding: 6px 10px 0">
- <i-ant-design-mobile-outlined/>
- </span>
- <span class="c-icon" style="margin: 10px 4px;padding: 6px 10px 0">
- <i-ant-design-question-circle-outlined/>
- </span>
- <el-avatar :size="30"
- style="vertical-align: top;margin: 15px 0 0 15px;background-color: #fde3cf;color: #f56a00">
- <span style="font-size: 20px;display: inline-block;margin-top: 3px">
- <i-ant-design-user-outlined/>
- </span>
- </el-avatar>
- <el-dropdown class="userinfo" @command="handleCommand">
- <span class="el-dropdown-link">
- <span style="vertical-align: middle;font-size: 20px;margin-right: 4px">
- <i-ant-design-user-outlined/>
- </span>
- {{ $store.state.user.userInfo.user_name }}
- </span>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item command="updPwd">修改密码</el-dropdown-item>
- <el-dropdown-item command="logout">退出登录</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </div>
- <el-dialog v-if="showUpdPwd" width="500px" :visible="true" title="修改密码">
- <el-form ref="updPwdForm" :model="updPwdForm" :rules="updPwdFormRules" label-position="right" label-width="90px">
- <el-form-item label="原密码:" prop="oldPwd">
- <el-input v-model="updPwdForm.oldPwd" type="password" show-password/>
- </el-form-item>
- <el-form-item label="新密码:" prop="password">
- <el-input v-model="updPwdForm.password" type="password" show-password/>
- </el-form-item>
- <el-form-item label="确认密码:" prop="confirmPwd">
- <el-input v-model="updPwdForm.confirmPwd" type="password" show-password/>
- </el-form-item>
- </el-form>
- <template #footer>
- <div style="width: 100%;text-align: center">
- <el-button style="width: 80px;height: 30px;padding: 0" @click="showUpdPwd=false">取消</el-button>
- <el-button type="primary" style="width: 80px;height: 30px;padding: 0" @click="updPwd">确定</el-button>
- </div>
- </template>
- </el-dialog>
- </div>
- </template>
- <script>
- import hamburger from '@/components/Hamburger/index'
- import logo from '@/assets/background/logo.png'
- import {updPwd} from "@/api/user/user";
- export default {
- components: {hamburger},
- props: {
- leftVisible: Boolean,
- //isLogin: Boolean,
- },
- data() {
- let validatePass = (rule, value, callback) => {
- if (value === '') {
- callback(new Error('请输入密码'));
- } else {
- if (this.updPwdForm.confirmPwd !== '') {
- this.$refs.updPwdForm.validateField('confirmPwd');
- }
- callback();
- }
- };
- let validatePass2 = (rule, value, callback) => {
- if (value === '') {
- callback(new Error('请再次输入密码'));
- } else if (value !== this.updPwdForm.password) {
- callback(new Error('两次输入密码不一致!'));
- } else {
- callback();
- }
- };
- return {
- logo,
- showUpdPwd: false,
- value: '1',
- options: [
- {
- label: '主语国际3号楼',
- value: '1'
- }
- ],
- updPwdForm: {
- oldPwd: '',
- password: '',
- confirmPwd: '',
- },
- updPwdFormRules: {
- oldPwd: [
- { required: true, message: '请输入旧密码', trigger: 'change' }
- ],
- password: [
- { validator: validatePass, required: true, trigger: 'change' }
- ],
- confirmPwd: [
- { validator: validatePass2, required: true, trigger: 'change' }
- ],
- },
- isLogin: true,
- opened: false,
- name: "test",
- circleUrl: "https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png",
- isCollapse: false,
- tips: {
- labtap: require('@/assets/tips/diannao@3x.png'),
- phone: require('@/assets/tips/shouji-4@3x.png'),
- help: require('@/assets/tips/help@3x.png'),
- notification: require('@/assets/tips/tongzhi@3x.png')
- }
- }
- },
- mounted() {
- this.$emit('collapseControl', this.isCollapse);
- },
- methods: {
- toggleSideBar() {
- this.isCollapse = !this.isCollapse;
- this.$emit('collapseControl', this.isCollapse);
- },
- handleCommand(command) {
- if (command == 'logout') {
- this.logout()
- } else if (command == 'updPwd') {
- this.showUpdPwd = true;
- this.updPwdForm = {
- oldPwd: '',
- password: '',
- confirmPwd: '',
- }
- }
- },
- updPwd() {
- this.$refs.updPwdForm.validate(valid=>{
- if (valid) {
- let user = this.$store.state.user.userInfo
- updPwd(user.id, user.user_name, this.updPwdForm.password).then(res=>{
- let data = res.data;
- if (data.code==0) {
- this.$message.success('修改成功');
- } else {
- this.$message.error(data.message);
- }
- })
- }
- })
- },
- logout() {
- this.$store.state.token = '';
- localStorage.removeItem('Authorization');
- localStorage.removeItem('UserInfo');
- localStorage.clear();
- this.$router.push('/login')
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .left-menu {
- //float: left;
- display: inline-block;
- cursor: default;
- text-align: left;
- height: 100%;
- line-height: 35px;
- width: 50%;
- color: white;
- .collapse-btn {
- margin: 7px;
- cursor: pointer;
- &:hover {
- background: #0043a3;
- }
- }
- .title {
- display: inline-block;
- vertical-align: top;
- line-height: 60px;
- color: white;
- margin-left: 15px;
- .title-logo {
- vertical-align: top;
- margin-top: 15px;
- margin-right: 18px;
- background-color: transparent;
- }
- .title-content {
- font-size: 22px;
- letter-spacing: 8px;
- }
- }
- .select-btn {
- width: 180px;
- color: white;
- font-size: 16px;
- text-align: center;
- margin-left: 15px;
- margin-top: 15px;
- display: inline-block;
- vertical-align: top;
- /deep/ .el-input__inner {
- background-color: #0062c4;
- height: 32px !important;
- padding-left: 20px;
- color: white;
- border: none;
- border-radius: 20px;
- }
- }
- }
- .right-menu {
- display: inline-block;
- vertical-align: top;
- width: 50%;
- text-align: right;
- .header-btn {
- }
- .userinfo {
- cursor: default;
- color: white;
- vertical-align: top;
- line-height: 20px;
- margin-top: 15px;
- margin-right: 20px;
- font-size: 18px;
- padding: 6px 15px;
- margin-left: 5px;
- border-radius: 20px;
- &:hover {
- background: #3c9cd3;
- }
- }
- }
- </style>
|