Эх сурвалжийг харах

Merge branch 'master' of http://10.12.10.70:3000/zhangliang/simulation-front

zhangliang2 2 жил өмнө
parent
commit
93aec68f2e

+ 3 - 1
src/api/common.js

@@ -14,6 +14,7 @@ const createMultipartUpload = basePart + '/simulation/resource/common/minio/crea
 const completeMultipartUpload = basePart + '/simulation/resource/common/minio/completeMultipartUpload'; // 分片上传-文件合并地址
 
 const getMyMenuTree = '/simulation/resource/server/menu/getMyMenuTree';  //获取左侧菜单
+const getCurrentUserInfo = '/simulation/resource/server/userInfo/getCurrentUserInfo';   //获取个人信息
 
 export default {
     single,
@@ -30,7 +31,8 @@ export default {
     createMultipartUpload,
     completeMultipartUpload,
 
-    getMyMenuTree
+    getMyMenuTree,
+    getCurrentUserInfo
 }
 
 //10.15.12.74:7001/simulation/oauth/client/sign/single?code=1001&ticket=1001

+ 3 - 1
src/api/index.js

@@ -7,6 +7,7 @@ import modelLibrary from './modelLibrary.js' // 模型库
 import algorithmsLibrary from './algorithmsLibrary.js' // 算法库
 import mainPage from './mainPage.js' // 首页
 import systemManagement from "./systemManagement.js"; //系统管理
+import userInfo from "./userInfo.js";
 
 const api = {
     common,
@@ -15,7 +16,8 @@ const api = {
     modelLibrary,
     algorithmsLibrary,
     mainPage,
-    systemManagement
+    systemManagement,
+    userInfo
 }
 
 export default api;

+ 17 - 0
src/api/userInfo.js

@@ -0,0 +1,17 @@
+const basePart = '/simulation/resource/server/userInfo'
+
+const getCurrentUserInfo = basePart + '/getCurrentUserInfo'
+const getParameterByUserId = basePart + '/getParameterByUserId'
+const getClusterByUserId = basePart + '/getClusterByUserId'
+const getSceneResource = basePart + '/getSceneResource'
+const savePhone = basePart + '/savePhone'
+const savePassword = basePart + '/savePassword'
+
+export default {
+    getCurrentUserInfo,
+    getParameterByUserId,
+    getClusterByUserId,
+    getSceneResource,
+    savePhone,
+    savePassword
+}

+ 14 - 2
src/router/index.js

@@ -6,6 +6,7 @@ import algorithmsLibrary from "./algorithmsLibrary"; // 算法库
 import sceneLibrary from "./sceneLibrary"; // 场景库
 import systemManagement from "./systemManagement"; // 账户管理
 import workManagement from "./workManagement"; // 工作管理
+import personalInformation from "./personalInformation"
 
 Vue.use(VueRouter);
 
@@ -22,7 +23,8 @@ const routes = [{
     },
     component: () => import('../views/index'),
     redirect: '/mainPage',
-    children: [{
+    children: [
+      {
         path: "/mainPage",
         name: "mainPage",
         // meta: {
@@ -79,7 +81,17 @@ const routes = [{
         component: () => import("@/views/systemManagement/index"),
         redirect: '/index',
         children: systemManagement,
-      },
+      }, 
+      {
+        path: "/personalInformation",
+        name: "personalInformation",
+        meta: {
+          tabname: "个人信息"
+        },
+        component: () => import("@/views/personalInformation/personalInformation"),
+        redirect: '/index',
+        children: personalInformation,
+      }, 
     ]
     // .concat([{
     //   path: "*",

+ 9 - 0
src/router/personalInformation.js

@@ -0,0 +1,9 @@
+export default [{
+    path: "/personalInformation",
+    name: "personalInformation",
+    meta: {            
+        tabname: "个人信息",
+        menuKind: "personalInformation"
+    },        
+    component: () => import("@/views/personalInformation/personalInformation")
+}]      

+ 18 - 1
src/store/index.js

@@ -11,8 +11,25 @@ export default new Vuex.Store({
     fileHost: 'http://47.94.105.148', // 开发环境需要连开发服务器地址,上线后会用相对地址拼接fileUrl
     fileUrl: '/simulation/resource/common/minio/preview',
     themeColor: '#3397FF',
+    id: '',   //用户id
+    username: '',  //用户名称
+    roleCode: '',   //用户角色
+    useType: '',   //独占类型
+  },
+  mutations: {
+    getUserId(state, data){
+      state.id = data
+    },
+    getUsername(state, data){
+      state.username = data
+    },
+    getRoleCode(state, data){
+      state.roleCode = data
+    },
+    getUseType(state, data){
+      state.useType = data
+    }
   },
-  mutations: {},
   actions: {},
   modules: {},
 });

+ 19 - 1
src/views/index.vue

@@ -31,7 +31,7 @@ export default {
             this.$axios({
                 method: "POST",
                 url: this.$api.common.getMyMenuTree,
-                data:{}
+                data: {}
             }).then(res => {
                 if (res.code == 200 && res.info) {
                     this.menuItems = res.info
@@ -40,6 +40,22 @@ export default {
                 }
             })
         },
+        getUserInfo(){
+            this.$axios({
+                method: "POST",
+                url: this.$api.common.getCurrentUserInfo,
+                data: {}
+            }).then(res => {
+                if (res.code == 200 && res.info) {
+                    this.$store.commit("getUserId", res.info.id)
+                    this.$store.commit("getUsername", res.info.username)
+                    this.$store.commit("getRoleCode", res.info.roleCode)
+                    this.$store.commit("getUseType", res.info.useType)
+                }else{
+                    this.$message.error(res.message || '获取用户信息失败')
+                }
+            })
+        }
     },
     created() {
         let { code, ticket } = this.$route.query;
@@ -64,6 +80,7 @@ export default {
                             this.$refs.curRouter.init();
 
                         this.getMenuItems()
+                        this.getUserInfo()
                     });
                 } else {
                     this.$message.error(res.message || "网络异常");
@@ -71,6 +88,7 @@ export default {
             });
         }else{
             this.getMenuItems()
+            this.getUserInfo()
         }
     },
 };

+ 28 - 2
src/views/mainPage.vue

@@ -2,8 +2,11 @@
     <div class="mainPagePanel">
         <div class="myTabsBox">
             <el-tabs v-model="activeName" type="card" @tab-click="pageControl">
+                <!--
                 <el-tab-pane label="系统监控" name="1"></el-tab-pane>
                 <el-tab-pane label="系统概览" name="2"></el-tab-pane>
+                -->
+                <el-tab-pane v-for="(item, i) in tabsList" :label="item.label" :name="item.name" :key="i"></el-tab-pane>
             </el-tabs>
         </div>
 
@@ -222,6 +225,10 @@ export default {
         return {
             activeName: "1",
             activitedPageNumA: "1",
+            tabsList:[
+                //{label: '系统监控', name: '1'},
+                //{label: '系统监控', name: '2'},
+            ],
             pageBtnListA: [
                 {
                     type: "primary",
@@ -308,8 +315,27 @@ export default {
         };
     },
 
-    computed: {},
-
+    computed: {
+        roleCode(){
+            return this.$store.state.roleCode
+        }
+    },
+    watch:{
+        roleCode(newV){
+            if(newV == '0'|| newV == '1'){
+                this.tabsList=[
+                    {label: '系统监控', name: '1'},
+                    {label: '系统监控', name: '2'},
+                ]
+                this.activeName = '1'
+            }else{
+                this.tabsList=[
+                    {label: '系统监控', name: '2'},
+                ]
+                this.activeName = '2'
+            }
+        }
+    },
     methods: {
         pageControl(data) {
             this.activeName = data.name;

+ 38 - 3
src/views/page/breadCrumb.vue

@@ -33,7 +33,11 @@
                 </transition-group>
             </el-breadcrumb>
         </div>
-
+        
+        <div class="nameBox">
+            <div>{{$store.state.username}}</div>
+            <div class="el-icon-switch-button exit" @click="exit"></div>
+        </div>
         <div class="avatarBox">
             <img :src="imgSrc" width="100%" height="100%" />
         </div>
@@ -56,7 +60,19 @@ export default {
             imgSrc: require("@/assets/common/image/photoF.png"),
         };
     },
-    methods: {},
+    methods: {
+        exit(){
+            this.$confirm("是否确定退出系统?", "提示", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning",
+            }).then(() => {
+                localStorage.clear()
+                let loginUrl = window.location.origin + '/login'
+                window.location.href = loginUrl
+            }).catch(() => {});
+        }
+    },
     computed: {
         list() {
             // console.log(this.$route);
@@ -135,7 +151,26 @@ export default {
             margin: 0px 3px 0px 1px;
         }
     }
-
+    .nameBox {
+        position: absolute;
+        top: 4px;
+        right: 100px;
+        z-index: 669;
+        display: flex;
+        height: 40px;
+        div {
+            height: 40px;
+            line-height: 40px;
+        }
+        .exit {
+            margin-left: 10px; 
+            font-size: 30px;
+            cursor: pointer;
+        }
+        .exit:hover {
+            color: @themeColor;
+        }
+    }
     .avatarBox {
         position: absolute;
         top: 4px;

+ 4 - 1
src/views/page/pageMenu.vue

@@ -160,7 +160,10 @@
                             {{item2.name}}
                         </el-menu-item>
                     </el-submenu>
-
+                    <el-menu-item index="/personalInformation" class="indexMenu">
+                        <i class=""></i>
+                        <span>个人信息</span>
+                    </el-menu-item>
                 </el-menu>
             </div>
         </div>

+ 402 - 0
src/views/personalInformation/personalInformation.vue

@@ -0,0 +1,402 @@
+<!-- 个人信息 -->
+<template>
+    <div>
+        <div class="block">
+            <div class="titlePanel">
+                <div class="titlePanelBor">个人信息</div>
+            </div>
+            <div class="flexBox">
+                <div class="flexItem"><span class="label">用户名:</span>{{userInfo.username}}</div>
+                <div class="flexItem"><span class="label">账户类型:</span>{{roleType}}</div>
+                <div class="flexItem"><span class="label">所属父账户:</span>{{userInfo.createUserName}}</div>
+                <div class="flexItem"><span class="label">所属公司:</span>{{userInfo.company}}</div>
+                <div class="flexItem"><span class="label">联系人:</span>{{userInfo.nickname}}</div>
+                <div class="flexItem"><span class="label">联系方式:</span>{{userInfo.phone}}<span class="textButton" @click="changePhone">修改联系方式</span></div>
+                <div class="flexItem"><span class="label">密码:</span>{{"***********"}}<span class="textButton" @click="changePassword">修改密码</span></div>
+            </div>
+        </div>
+        <div class="block">
+            <div class="titlePanel">
+                <div class="titlePanelBor">配置信息</div>
+            </div>
+            <div class="flexBox">
+                <div class="flexItem"><span class="label2">可创建子账户数量:</span>{{configInfo.numCreateUser}}</div>
+                <div class="flexItem"><span class="label2">可创建场景包数量:</span>{{configInfo.numCreateScenePackage}}</div>
+                <div class="flexItem"><span class="label2">场景包最大场景数量:</span>{{configInfo.numScenePerPackage}}</div>
+                <div class="flexItem"></div>
+                <div class="flexItem"><span class="label2">仿真软件license:</span>{{clusterInfo.numSimulationLicense}}</div>
+                <div class="flexItem"><span class="label2">到期时间:</span>{{clusterInfo.dateSimulationLicense}}</div>
+                <div class="flexItem"><span class="label2">动力学软件license:</span>{{clusterInfo.numDynamicLicense}}</div>
+                <div class="flexItem"><span class="label2">到期时间:</span>{{clusterInfo.dateDynamicLicense}}</div>
+            </div>
+        </div>
+        <div class="block">
+            <div class="titlePanel">
+                <div class="titlePanelBor">场景资源</div>
+                <tableList
+                    ref="table"
+                    style="min-width: 900px;margin: auto;"
+                    :columns="columns"
+                    :getDataWay="getDataWay"
+                    index
+                >   
+                </tableList>
+            </div>
+        </div>
+
+        <el-dialog
+            title="修改联系方式"
+            :visible.sync="phoneDialogVisible"
+            width="690px"
+            :close-on-click-modal="false"
+            :close-on-press-escape="false"
+        >
+            <el-form
+                ref="phoneForm"
+                :model="phoneForm"
+                :rules="phoneRules"
+                label-width="108px"
+            >
+                <el-form-item label="联系人:" prop="nickname">
+                    <el-input
+                        v-autoTrim="{
+                            obj: phoneForm,
+                            key: 'nickname',
+                        }"
+                        v-model="phoneForm.nickname"
+                        placeholder="请输入"
+                        maxlength="20"
+                    ></el-input>
+                </el-form-item>
+                <el-form-item label="联系方式:" prop="phone">
+                    <el-input
+                        v-autoTrim="{
+                            obj: phoneForm,
+                            key: 'phone',
+                        }"
+                        v-model="phoneForm.phone"
+                        placeholder="请输入"
+                        maxlength="20"
+                    ></el-input>
+                </el-form-item>
+            </el-form>
+            <span slot="footer">
+                <el-button type="primary" @click="confirmChangePhone">确 定</el-button>
+                <el-button @click="phoneDialogVisible = false">取 消</el-button>
+            </span>
+        </el-dialog>
+
+        <el-dialog
+            title="修改密码"
+            :visible.sync="passwordDialogVisible"
+            width="690px"
+            :close-on-click-modal="false"
+            :close-on-press-escape="false"
+        >
+            <el-form
+                ref="passwordForm"
+                :model="passwordForm"
+                :rules="passwordRules"
+                label-width="108px"
+            >
+                <el-form-item label="原密码:" prop="oldPassword">
+                    <el-input
+                        type="password"
+                        v-model="passwordForm.oldPassword"
+                        placeholder="请输入"
+                        maxlength="20"
+                    ></el-input>
+                </el-form-item>
+                <el-form-item label="新密码:" prop="newPassword">
+                    <el-input
+                        type="password"
+                        v-model="passwordForm.newPassword"
+                        placeholder="请输入"
+                        maxlength="20"
+                    ></el-input>
+                </el-form-item>
+                <el-form-item label="确认密码:" prop="confirmPassword">
+                    <el-input
+                        type="password"
+                        v-model="passwordForm.confirmPassword"
+                        placeholder="请输入"
+                        maxlength="20"
+                    ></el-input>
+                </el-form-item>
+            </el-form>
+            <span slot="footer">
+                <el-button type="primary" @click="confirmChangePassword">确 定</el-button>
+                <el-button @click="passwordDialogVisible = false ">取 消</el-button>
+            </span>
+        </el-dialog>
+    </div> 
+</template>
+
+<script>
+    import tableList from "@/components/grid/TableList";
+
+    export default {
+        components: {tableList},
+        data(){
+            return {
+                userInfo: {
+                    id: "",
+                    username: "",
+                    nickname: "",
+                    password: "",
+                    phone: "",
+                    photo: "",
+                    company: "",
+                    roleCode: "",
+                    useType: "",
+                    visible: "",
+                    createTime: "",
+                    createUserName: "",
+                },
+                configInfo: {
+                    numCreateScenePackage: "",
+                    numCreateUser: "",
+                    numScenePerPackage: "",
+                },
+                clusterInfo: {
+                    numSimulationLicense: '',
+                    dateSimulationLicense: '',
+                    numDynamicLicense: '',
+                    dateDynamicLicense: ''
+                },
+                roleCodeList:[],
+                getDataWay: {
+                    dataType: "url",
+                    type: "post",
+                    data: this.$api.userInfo.getSceneResource,
+                    param: {
+                        //userId: this.$route.query.userId
+                    },
+                },
+                columns: [
+                    {
+                        label: "场景包名称",
+                        prop: "packageName",
+                    },
+                    {
+                        label: "自然驾驶仿真场景",
+                        prop: "zrCount",
+                    },
+                    {
+                        label: "交通事故仿真场景",
+                        prop: "jtCount",
+                    },
+                    {
+                        label: "标准法规仿真场景",
+                        prop: "bzCount",
+                    },
+                    {
+                        label: "泛化场景",
+                        prop: "fhCount"
+                    },
+                    {
+                        label: "合计",
+                        prop: "totalCount"
+                    }
+                ],
+                phoneDialogVisible: false,
+                passwordDialogVisible: false,
+                phoneForm: {
+                    nickname: '',
+                    phone: ''
+                },
+                phoneRules: {
+                    nickname: [
+                         { required: true, message: "请输入", trigger: "blur" },
+                    ],
+                    phone: [
+                         { required: true, message: "请输入", trigger: "blur" },
+                         {
+                            validator: (rule, value, callback) => {
+                                if(this.$validatePhone(value)){
+                                    callback()
+                                }else{
+                                    callback(new Error('格式错误'))
+                                }
+                            },
+                            trigger: "blur"
+                        }
+                    ]
+                },
+                passwordForm: {
+                    oldPassword: '',
+                    newPassword: '',
+                    confirmPassword: '',
+                },
+                passwordRules: {
+                    oldPassword: [{ required: true, message: "请输入", trigger: "blur" },],
+                    newPassword: [{ required: true, message: "请输入", trigger: "blur" },],
+                    confirmPassword: [{ required: true, message: "请输入", trigger: "blur" },]
+                }
+            }
+        },
+        async mounted(){
+            await this.$dicsListsInit({
+                roleCodeList: "roleCode"
+            });
+            this.getUserInfo()
+            this.getParameter()
+            this.getCluster()
+        },
+        computed: {
+            roleType(){
+                let label = ''
+                this.roleCodeList.map(item => {
+                    if(item.code == this.userInfo.roleCode){
+                        label = item.caption
+                    }
+                })
+                return label
+            }
+        },
+        methods: {
+            getUserInfo(){
+                this.$axios({
+                    method: "POST",
+                    url: this.$api.userInfo.getCurrentUserInfo,
+                    data: {}
+                }).then(res => {
+                    if (res.code == 200 && res.info) {
+                        this.userInfo = res.info
+                    }else{
+                        this.$message.error(res.message || '获取用户信息失败')
+                    }
+                })
+            },
+            getParameter(){
+                this.$axios({
+                    method: "POST",
+                    url: this.$api.userInfo.getParameterByUserId,
+                    data: {}
+                }).then(res => {
+                    if (res.code == 200) {
+                        if(res.info){
+                            this.configInfo = res.info
+                        }
+                    }else{
+                        this.$message.error(res.message || '获取配置信息失败')
+                    }
+                })
+            },
+            getCluster(){
+                this.$axios({
+                    method: "POST",
+                    url: this.$api.userInfo.getClusterByUserId,
+                    data: {}
+                }).then(res => {
+                    if (res.code == 200) {
+                        if(res.info){
+                            this.clusterInfo = res,info
+                        }
+                    }else{
+                        this.$message.error(res.message || '获取配置信息失败')
+                    }
+                })
+            },
+            changePhone(){
+                this.phoneForm = {
+                    nickname: this.userInfo.nickname,
+                    phone: this.userInfo.phone
+                }
+                this.phoneDialogVisible = true
+            },
+            changePassword(){
+                this.passwordForm = {
+                    oldPassword: '',
+                    newPassword: '',
+                    confirmPassword: ''
+                }
+                this.passwordDialogVisible = true
+            },
+            confirmChangePhone(){
+                this.$refs.phoneForm.validate(valid => {
+                    if(valid){
+                        this.$axios({
+                            method: 'POST',
+                            url: this.$api.userInfo.savePhone,
+                            data: {
+                                id: this.userInfo.id,
+                                nickname: this.phoneForm.nickname,
+                                phone: this.phoneForm.phone
+                            }
+                        }).then(res => {
+                            if (res.code == 200) {
+                                this.$message.success('修改联系方式成功')
+                                this.getUserInfo()
+                                this.phoneDialogVisible = false
+                            }else{
+                                this.$message.error(res.message || '修改联系方式失败')
+                            }
+                        })
+                    }
+                })
+                
+            },
+            confirmChangePassword(){
+                if(this.passwordForm.newPassword !== this.passwordForm.confirmPassword){
+                    this.$message.warning('新密码与确认密码必须保持一致')
+                    return
+                }
+                if(this.passwordForm.newPassword == this.passwordForm.oldPassword){
+                    this.$message.warning('新密码不能与旧密码相同')
+                    return
+                }
+                this.$refs.passwordForm.validate(valid => {
+                    if(valid){
+                        this.$axios({
+                            method: 'POST',
+                            url: this.$api.userInfo.savePassword,
+                            data: {
+                                id: this.userInfo.id,
+                                password: this.passwordForm.oldPassword,
+                                newPassword: this.passwordForm.newPassword
+                            }
+                        }).then(res => {
+                            if (res.code == 200) {
+                                this.$message.success('修改密码成功')
+                                this.getUserInfo()
+                                this.passwordDialogVisible = false
+                            }else{
+                                this.$message.error(res.message || '修改密码失败')
+                            }
+                        })
+                    }
+                })
+            }
+        }
+    }
+</script>
+
+<style scoped lang="less"> 
+.block{
+    width: 88%;
+    margin: 24px auto 0;
+}
+.titlePanel {
+    padding: 22px 0;
+}
+.flexItem{
+    width: 40%;
+    margin-bottom: 10px;
+    .label{
+        display: inline-block;
+        width: 120px;
+        text-align: right;
+    }
+    .label2{
+        display: inline-block;
+        width: 140px;
+        text-align: right;
+    }
+}
+.textButton{
+    padding-left: 5px;
+    color: @themeColor;
+    cursor: pointer;
+}
+</style>