| | |
| | | const pic = JSON.parse(sessionStorage.getItem('pic')); |
| | | if (pic) { |
| | | result = pic; |
| | | console.log('缓存') |
| | | // console.log('缓存') |
| | | } else { |
| | | console.log('请求'); |
| | | // console.log('请求'); |
| | | await this.$axios({ |
| | | method: 'get', |
| | | url: 'sccg/system/portal/logo/search', |
| | |
| | | }; |
| | | </script> |
| | | <style> |
| | | |
| | | .el-select-dropdown__item{ |
| | | height: 100%; |
| | | } |
| | | .el-select-dropdown,.popper-class{ |
| | | background-color: #17324c; |
| | | } |
| | | .el-select-dropdown__item.hover, .el-select-dropdown__item:hover{ |
| | | background-color: #17324c; |
| | | } |
| | | .el-tree{ |
| | | background-color: #17324c; |
| | | } |
| | | .el-tree-node__content:hover, .el-upload-list__item:hover{ |
| | | background-color: #09152f; |
| | | color: #4b9bb7; |
| | | } |
| | | .el-tree-node:focus>.el-tree-node__content{ |
| | | background-color: #09152f; |
| | | } |
| | | </style> |
| | |
| | | import ElementUI from 'element-ui'; |
| | | import "element-ui/lib/theme-chalk/index.css"; |
| | | // 引入icons |
| | | import './assets/icons' |
| | | import './assets/icons' |
| | | // 引入全局样式 |
| | | import '@/styles/index.scss' |
| | | import '@/styles/index.scss' |
| | | import api from "./utils/request" |
| | | Vue.prototype.$axios=api |
| | | console.log(process.env.VUE_APP_BASE_API); |
| | | Vue.prototype.$axios = api |
| | | router.beforeEach((to, from, next) => { |
| | | if (to.meta.needLogin) { |
| | | const token = sessionStorage.getItem('token'); |
| | | const tokenHead = sessionStorage.getItem('tokenHead'); |
| | | if (token && tokenHead) { |
| | | next(); |
| | | } else { |
| | | router.push("/login"); |
| | | } |
| | | } else { |
| | | next(); |
| | | } |
| | | }) |
| | | // console.log(process.env.VUE_APP_BASE_API); |
| | | Vue.use(ElementUI); |
| | | new Vue({ |
| | | router, |
| | |
| | | path: '/home', |
| | | name: 'home', |
| | | component: () => import('@/views/layout'), |
| | | meta:{ |
| | | needLogin:true, |
| | | }, |
| | | children: [ |
| | | { |
| | | path: 'system', |
| | |
| | | // 拦截器 |
| | | // 请求 |
| | | api.interceptors.request.use((config)=>{ |
| | | const token = localStorage.getItem('token'); |
| | | const tokenHead = localStorage.getItem('tokenHead'); |
| | | const token = sessionStorage.getItem('token'); |
| | | const tokenHead = sessionStorage.getItem('tokenHead'); |
| | | if(token && tokenHead){ |
| | | config.headers.Authorization = tokenHead+token; |
| | | } |
| | |
| | | }, |
| | | methods:{ |
| | | loginout(){ |
| | | sessionStorage.removeItem('token'); |
| | | sessionStorage.removeItem('tokenHead'); |
| | | this.$router.push({path:"/login"}) |
| | | } |
| | | } |
| | |
| | | if (response.code === 200) { |
| | | // 保存token |
| | | console.log(response); |
| | | localStorage.setItem('token',response.data.token); |
| | | sessionStorage.setItem('token',response.data.token); |
| | | // 保存token |
| | | localStorage.setItem('tokenHead',response.data.tokenHead) |
| | | sessionStorage.setItem('tokenHead',response.data.tokenHead) |
| | | // 跳转到首页 |
| | | that.$router.push("/home"); |
| | | }else{ |
| | |
| | | <div class="addUser"> |
| | | <el-button class="addBtn" type="primary" @click="dialogCreate = true">新建角色</el-button> |
| | | <el-dialog :visible.sync="dialogCreate" title="新增角色" width="45%" v-if="dialogCreate"> |
| | | <createUser :refresh="getUserList" /> |
| | | <createUser :refresh="context==='' ? getUserList : search" /> |
| | | </el-dialog> |
| | | </div> |
| | | </div> |
| | |
| | | <!-- 查看修改页面 --> |
| | | <el-dialog :visible.sync="dialogUpdate" width="45%" :title="updateFlag ? '权限设置' :'查看角色信息'" |
| | | v-if="dialogUpdate"> |
| | | <updateUser :updateFlag="updateFlag" :userInfo=userInfo :getUserList=getUserList |
| | | @changeDialog="changeDialog" /> |
| | | <updateUser :updateFlag="updateFlag" :userInfo=userInfo |
| | | :getUserList=" context ? getUserList : getUserList" @changeDialog="changeDialog" /> |
| | | </el-dialog> |
| | | <!-- 分页 --> |
| | | <div class="pagination"> |
| | |
| | | if (res.code === 200) { |
| | | console.log(res); |
| | | res.data.list.forEach(item => { |
| | | item.createTime = helper(item.createTime); |
| | | // item.createTime = helper(item.createTime); |
| | | item.status == 1 ? item.status = true : item.status = false; |
| | | }) |
| | | that.tableData = res.data.list |
| | | that.tableData = res.data.list; |
| | | this.totalNum = res.data.list.length; |
| | | } |
| | | }) |
| | | } else { |
| | | this.$axios({ |
| | | method: 'get', |
| | | url: 'sccg/role/list?keyword='+context + '&pageNum=' + currentPage + '&pageSize=' + pageSize, |
| | | url: 'sccg/role/list?keyword=' + context + '&pageNum=' + currentPage + '&pageSize=' + pageSize, |
| | | }).then(res => { |
| | | if (res.code === 200) { |
| | | console.log(2, res); |
| | | res.data.list.forEach(item => { |
| | | item.createTime = helper(item.createTime); |
| | | item.status == 1 ? item.status = true : item.status = false; |
| | | }) |
| | | that.tableData = res.data.list |
| | | this.totalNum = res.data.length; |
| | | this.totalNum = res.data.list.length; |
| | | } |
| | | }) |
| | | // this.$axios.get('sccg/role/list?'+context).then(res => { |
| | | // if (res.code === 200) { |
| | | // console.log(2,res); |
| | | // res.data.list.forEach(item => { |
| | | // item.createTime = helper(item.createTime); |
| | | // item.status == 1 ? item.status = true : item.status = false; |
| | | // }) |
| | | // that.tableData = res.data.list |
| | | // } |
| | | // }) |
| | | } |
| | | }, |
| | | // 设置表格斑马纹 |
| | |
| | | </el-form-item> |
| | | <!-- 角色类型 --> |
| | | <el-form-item class="optionItems" label="角色类型:" prop="sort"> |
| | | <el-input v-model="role.sort" placeholder="请选择角色类型" :disabled="!updateFlag"></el-input> |
| | | <!-- <el-input v-model="role.sort" placeholder="请选择角色类型" :disabled="!updateFlag"></el-input> --> |
| | | <el-select v-model="role.sort" placeholder="请选择角色类型"> |
| | | <!-- v-for="item in roleList" :key="item.id" :label="item.departName" |
| | | :value="item.id" --> |
| | | <el-option :value="treeId" :label="treeLabel"> |
| | | <el-tree :data="roleList" :props="defaultProps" @node-click="handleNodeClick"></el-tree> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <!-- 角色描述 --> |
| | | <el-form-item class="optionItem" label="角色描述:" prop="description"> |
| | |
| | | { required: false, trigger: "blur", validator: validateTruename }, |
| | | ], |
| | | }, |
| | | roleList: [], |
| | | defaultProps: { |
| | | children: 'children', |
| | | label: 'title' |
| | | }, |
| | | treeLabel:'', |
| | | treeId:23 |
| | | } |
| | | }, |
| | | created() { |
| | | const that = this; |
| | | this.userInfo.status ? this.userInfo.status = 1 : this.userInfo.status = 0; |
| | | this.role = JSON.parse(JSON.stringify(that.userInfo)); |
| | | console.log(this.role); |
| | | this.getMenuList(); |
| | | }, |
| | | methods: { |
| | | handleUser() { |
| | | this.$refs.user.validate((valid) => { |
| | | console.log(valid); |
| | | if (valid) { |
| | | const { role } = this; |
| | | console.log(role); |
| | | this.$axios.post('/sccg/role/update/' + role.id, { |
| | | id: role.id, |
| | | status: role.status, |
| | | description: role.description, |
| | | name: role.name, |
| | | sort:role.sort |
| | | sort: 0 |
| | | }).then(res => { |
| | | this.$emit('changeDialog', { dialogUpdate: false }); |
| | | this.getUserList(); |
| | |
| | | return false; |
| | | } |
| | | }) |
| | | }, |
| | | // 获取系统菜单 |
| | | getMenuList() { |
| | | this.$axios({ |
| | | method: 'get', |
| | | url: 'sccg/menu/treeList', |
| | | }) |
| | | .then(res => { |
| | | this.roleList = res.data; |
| | | console.log(res); |
| | | }) |
| | | }, |
| | | // 点击树节点 |
| | | handleNodeClick({title,id}) { |
| | | // console.log(obj); |
| | | this.role.sort = title; |
| | | this.treeLabel = title; |
| | | this.treeId = id; |
| | | |
| | | } |
| | | }, |
| | | props: ['userInfo', 'updateFlag', 'getUserList', 'changeDialog'] |
| | |
| | | border: 1px solid #17324c; |
| | | } |
| | | } |
| | | |
| | | </style> |
| | |
| | | <div class="mainContent"> |
| | | <el-form ref="user" label-width="140px" autoComplete="on" :model="user" :rules="createUserRules" |
| | | label-position="right"> |
| | | <!-- 用户名称 --> |
| | | <!-- 用户名称 |
| | | <el-form-item class="optionItem" label="用户名称:" prop="nickName"> |
| | | <el-input v-model="user.nickName" placeholder="填写用户名称"></el-input> |
| | | </el-form-item> |
| | | </el-form-item> --> |
| | | <!-- 用户密码 --> |
| | | <el-form-item class="optionItems" label="用户密码:" prop="password"> |
| | | <el-input v-model="user.password" type="password" placeholder="请输入用户密码"></el-input> |
| | |
| | | <div class="optionBtn"> |
| | | <el-button type="primary" class="btn submit" @click.native.prevent="handleUser">提交 |
| | | </el-button> |
| | | <el-button class="btn reset">重置</el-button> |
| | | <el-button class="btn reset" @click.native.prevent="resetForm">重置</el-button> |
| | | </div> |
| | | </el-form-item> |
| | | </el-form> |
| | |
| | | <script> |
| | | export default { |
| | | data() { |
| | | const validateNickname = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("用户名称不能为空")); |
| | | }else{ |
| | | callback(); |
| | | } |
| | | }; |
| | | // const validateNickname = (rule, value, callback) => { |
| | | // if (!value) { |
| | | // callback(new Error("用户名称不能为空")); |
| | | // }else{ |
| | | // callback(); |
| | | // } |
| | | // }; |
| | | const validatePass = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("用户密码不能为空")); |
| | |
| | | // }; |
| | | return { |
| | | user: { |
| | | nickName: '', |
| | | // nickName: '', |
| | | password: '', |
| | | username: '', |
| | | gender: 1, |
| | |
| | | ip: '', |
| | | }, |
| | | createUserRules: { |
| | | nickName: [ |
| | | { required: true, trigger: "blur", validator: validateNickname }, |
| | | ], |
| | | // nickName: [ |
| | | // { required: true, trigger: "blur", validator: validateNickname }, |
| | | // ], |
| | | password: [ |
| | | { required: true, trigger: "blur", validator: validatePass }, |
| | | ], |
| | |
| | | }) |
| | | }, |
| | | methods: { |
| | | // 提交注册 |
| | | handleUser() { |
| | | this.$refs['user'].validate((valid) => { |
| | | console.log(valid); |
| | |
| | | }).then(res => { |
| | | if (res.code === 200) { |
| | | console.log(1); |
| | | this.$message({ |
| | | type:'success', |
| | | message:res.code, |
| | | }) |
| | | this.$emit('sendDialog', { flag: false }); |
| | | }else if(res.code === 500 && res.message === "操作失败"){ |
| | | this.$message({ |
| | | type:'warning', |
| | | message:'该用户已注册' |
| | | }) |
| | | } |
| | | }) |
| | | }else{ |
| | |
| | | .then(res => { |
| | | this.roleList = res.data; |
| | | }) |
| | | }, |
| | | // 重置表单 |
| | | resetForm(){ |
| | | this.$refs['user'].resetFields(); |
| | | } |
| | | }, |
| | | props: ['sendDialog'] |
| | |
| | | <div class="addUser"> |
| | | <!-- :before-close="handleClose" --> |
| | | <el-button class="addBtn" type="primary" @click="dialogCreate = true">添加用户</el-button> |
| | | <el-dialog :visible.sync="dialogCreate" title="新增账户" width="45%" v-if="dialogCreate"> |
| | | <el-dialog :visible.sync="dialogCreate" title="新增账户" width="45%" v-if="dialogCreate" |
| | | :before-close="handleClose"> |
| | | <createUser @sendDialog="sendDialog" /> |
| | | </el-dialog> |
| | | </div> |
| | |
| | | sendDialog(flag) { |
| | | console.log(flag); |
| | | this.dialogCreate = flag.flag; |
| | | this.$emit('setDialog', { flag:true }) |
| | | this.$emit('setDialog', { flag: true }) |
| | | }, |
| | | handleClose(done) { |
| | | this.$confirm('确认关闭?') |
| | | .then(_ => { |
| | | this.dialogCreate = false; |
| | | done(); |
| | | }) |
| | | .catch(_ => { }); |
| | | } |
| | | }, |
| | | props: ['setDialog', 'getSearch', 'flag'], |
| | |
| | | padding: 12px 30px; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | </style> |
| | |
| | | <el-table-column prop="jobTitle" label="所属职务" min-width="8"> |
| | | </el-table-column> |
| | | <el-table-column prop="createTime" label="创建时间" min-width="10"> |
| | | <template slot-scope="scope"> |
| | | <span>{{changeTime(scope.row)}}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="status" label="启用" min-width="5"> |
| | | <template slot-scope="scope"> |
| | |
| | | this.getUserList(); |
| | | }, |
| | | methods: { |
| | | changeTime({createTime}){ |
| | | return helper(createTime); |
| | | }, |
| | | selectAll() { |
| | | this.$refs.multipleTable.toggleAllSelection(); |
| | | |
| | |
| | | </el-form-item> --> |
| | | <!-- 所属部门 --> |
| | | <el-form-item class="optionItem" label="所属部门:" prop="departmentId"> |
| | | <el-select v-model="user.departmentId" placeholder="请选择所属部门" :disabled="!flag.depart"> |
| | | <el-option v-for="item in departList" :key="item.name" :label="item.departName" |
| | | <el-select v-model="user.departmentId" placeholder="请选择所属部门" :disabled="!flag.depart" @change="changeDepart"> |
| | | <el-option v-for="item in departList" :key="item.id" :label="item.departName" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | |
| | | }) |
| | | }, |
| | | methods: { |
| | | changeDepart(data){ |
| | | console.log(data); |
| | | this.departList.forEach(item=>{ |
| | | if(item.id===data){ |
| | | this.user.departName = item.departName; |
| | | } |
| | | }) |
| | | }, |
| | | // 修改用户信息 |
| | | handleUser() { |
| | | this.$refs.user.validate((valid) => { |
| | | if (valid) { |
| | | const { user } = this; |
| | | console.log(user); |
| | | // for(let key in user){ |
| | | // if(user[key]===null){ |
| | | // user[key] = ''; |
| | | // } |
| | | // } |
| | | // user.status = String(user.status); |
| | | // user.isDy = String(user.isDy); |
| | | // user.userType = String(user.userType); |
| | | // this.$axios({ |
| | | // method: 'post', |
| | | // url: 'sccg/admin/update/' + user.id, |
| | | // data: user |
| | | // }) |
| | | // .then(res => { |
| | | // console.log(res); |
| | | // this.getUserList(); |
| | | // this.$emit('closeDialog', { flag: false }); |
| | | // }) |
| | | this.$axios({ |
| | | method: 'post', |
| | | url: 'sccg/admin/update/' + user.id, |
| | | data: user |
| | | }) |
| | | .then(res => { |
| | | this.$message({ |
| | | type:res.code===200 ? 'success' : 'warning', |
| | | message:res.message, |
| | | }) |
| | | this.getUserList(); |
| | | this.$emit('closeDialog', { flag: false }); |
| | | }) |
| | | } else { |
| | | return false; |
| | | } |
| | |
| | | keyword: '', |
| | | } |
| | | }, |
| | | created(){ |
| | | |
| | | }, |
| | | methods: { |
| | | // 获取搜索返回结果 |
| | | getSearch({ text }) { |
| | |
| | | resetFresh({ flag }) { |
| | | this.isFresh = flag; |
| | | console.log(this.isFresh); |
| | | } |
| | | }, |
| | | } |
| | | } |
| | | </script> |