Browse Source

用户管理

zhangkunling 3 years ago
parent
commit
65f6663b18

+ 19 - 3
src/assets/styles/common.css

@@ -224,14 +224,16 @@ textarea.ivu-input {
 }
 /* 滚动条 webkit内核 start  .ivu-cascader-menu 级联下拉列表里的滚动条 .ivu-select-dropdown 单个下拉列表里的滚动条 .common-modal-tabs .ivu-tabs-tabpane详情对话框里的滚动条*/
 .common-scroll::-webkit-scrollbar,
-.ivu-select-dropdown::-webkit-scrollbar {
+.ivu-select-dropdown::-webkit-scrollbar,
+.ivu-cascader-menu::-webkit-scrollbar{
   height: 8px;
   width: 8px;
   opacity: 0.6;
 }
 
 .common-scroll::-webkit-scrollbar-track,
-.ivu-select-dropdown::-webkit-scrollbar-track {
+.ivu-select-dropdown::-webkit-scrollbar-track,
+.ivu-cascader-menu::-webkit-scrollbar-track{
   background-color: rgba(39, 76, 136, 0.4);
   -webkit-border-radius: 2em;
   -moz-border-radius: 2em;
@@ -239,7 +241,8 @@ textarea.ivu-input {
 }
 
 .common-scroll::-webkit-scrollbar-thumb,
-.ivu-select-dropdown::-webkit-scrollbar-thumb {
+.ivu-select-dropdown::-webkit-scrollbar-thumb,
+.ivu-cascader-menu::-webkit-scrollbar-thumb {
   opacity: 0.3;
   background-color: rgba(8, 26, 64, 0.8);
   -webkit-border-radius: 2em;
@@ -542,4 +545,17 @@ textarea.ivu-input {
 /* Message 全局提示 设置层级*/
 .ivu-message {
  z-index: 999999 !important;
+}
+/* Cascader 级联选择样式*/
+.common-cascader .ivu-cascader-menu-item{
+ color: #fff;
+}
+.common-cascader .ivu-cascader-menu {
+  border-right: 1px solid #143455;
+}
+.common-cascader .ivu-cascader-menu-item:hover  {
+  background: #3565BC;
+}
+.common-cascader .ivu-cascader-menu .ivu-cascader-menu-item-active {
+  background: #3565BC;
 }

+ 15 - 1
src/login/Login.vue

@@ -73,7 +73,6 @@ export default {
     };
   },
   mounted() {
-    // console.log(moment().format('dddd'))
   },
   methods: {
      handleLogin(name) {
@@ -83,6 +82,21 @@ export default {
           const mdTime = moment().format("YYYY-MM-DD");
           const tomdpsw ="userName:" + userName + "-userPwd:" + password + "-time:" + mdTime;
           const formtmdpsw = md5(tomdpsw);
+          // let params = {
+          //   feature: formtmdpsw,
+          //   userName: userName,
+          //   vCode: 111111
+          // }
+          // this.$store.dispatch('userLogin', params).then(() => {
+          //   utils.storage("sw_user", {
+          //     user: userName,
+          //     menus: this.$store.state.user.userInfo.menus,
+          //     userId: this.$store.state.user.userInfo.userId
+          //   });
+          //   this.$Message.info('登录成功');
+          //   this.$router.push("/mainPage");
+          //   sessionStorage.setItem("id", 0);
+          // })
           let that = this;
           this.$post('metroapi/login', { userName, feature: formtmdpsw, vCode }).then(res => {
               if (res.httpCode == 1) {

+ 9 - 12
src/store/index.js

@@ -1,15 +1,12 @@
 import Vue from 'vue'
-import Vuex from 'vuex'
-
+import Vuex from "vuex"
+import user from "./modules/user"
 Vue.use(Vuex)
 
-export default new Vuex.Store({
-  state: {
-  },
-  mutations: {
-  },
-  actions: {
-  },
-  modules: {
-  }
-})
+const store = new Vuex.Store({
+    modules:{ 
+     user,
+    },
+ }
+)
+export default store

+ 62 - 0
src/store/modules/user.js

@@ -0,0 +1,62 @@
+// vuex两种写法
+// import axios from 'axios'
+// export default {
+//   state: {
+//     userInfo: JSON.parse(sessionStorage.getItem('userInfo')),
+//   },
+//   mutations: {
+//     userSign(state, userInfo) {
+//       state.userInfo = userInfo
+//       sessionStorage.setItem('userInfo', JSON.stringify(userInfo))
+//     },
+//   },
+//   actions: {
+//     userLogin ({commit}, params) {
+//       return axios.post('/metroapi/login', params).then(res => {
+//         const { httpCode, msg, data } = res.data
+//         if (httpCode !== 1) {
+//           throw new Error(msg)
+//         }
+//         commit('userSign', data)
+//       })
+//     },
+//   },
+//   getters: {
+//     getMenuList: state => state.userInfo.menus
+//   }
+// }
+import axios from 'axios'
+const state =  { // state状态树 保留变量数据 (其他页面调用state里的值是 this.$store.state.user.userInfo)
+  userInfo: JSON.parse(sessionStorage.getItem('userInfo'))
+}
+const mutations = { //更改 Vuex 的 store 中的状态的唯一方法是提交 mutation
+  userSign (state, userInfo) {
+    console.log(userInfo)
+    state.userInfo = userInfo
+    sessionStorage.setItem('userInfo', JSON.stringify(userInfo))
+  },
+}
+
+const actions = { // Action 类似于 mutation. Action 提交的是 mutation,而不是直接变更状态。 Action 可以包含任意异步操作
+  userLogin ({commit}, params) {
+    return axios.post('/metroapi/login', params).then(res => {
+      const { httpCode, msg, data } = res.data
+      if (httpCode !== 1) {
+        throw new Error(msg)
+      }
+      console.log(data)
+      commit('userSign', data)
+    })
+  },
+}
+const getters = {
+  getMenuList: state => state.userInfo.menus //store 中的 state 中派生出一些状态
+}
+
+export default {
+  // namespaced: true,
+  state,
+  mutations,
+  actions,
+  getters
+}

+ 37 - 1
src/views/homecomponents/Head.vue

@@ -46,6 +46,11 @@
 </template>
 <script>
 import utils from '../../libs/utils';
+//...mapState({...}) 将多个对象合并为一个 并且将vuex中的this.$store.user.userInfo 映射到this.userInfo (this -> vue)上面来
+// mapMutations 其实跟mapState 的作用是类似的,将组件中的 methods 映射为 store.commit 调用 如@click="sign"
+// mapActions, action的一个辅助函数,将组件的 methods 映射为 store.dispatch 调用 this.userLogin()
+// mapGetter 仅仅是将 store 中的 getter 映射到局部计算属性 userInfo
+// import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'
 export default {
   name: "Head",
   components:{
@@ -60,6 +65,14 @@ export default {
       menuNameArr: []
     };
   },
+//   computed: {
+//     ...mapState({
+//     userInfo: 'userInfo'
+//     }),
+//     ...mapGetters({
+//     getMenuList: 'getMenuList' // getToDo 不是字符串,对应的是getter里面的一个方法名字 然后将这个方法名字重新取一个别名 todosALise
+//     })
+//  },
   watch: {
       '$route' (to, from) {
         let menuNameArr = []
@@ -84,16 +97,39 @@ export default {
         if (to.path == '/mainPage') {
            this.activeId = 0
         }
-      }
+      },
+      // getMenuList: { //全局切换菜单
+      //   handler(newVal, oldVal) {
+      //     this.menus = newVal
+      //   },
+      //   deep: true
+      // }
     },
+  created () {
+    // this.$store.state.user.userInfo 直接获取vuex state里的userInfo值
+    // 我理解的是两种方法都是调用stroe/user组件里的userLogin方法
+    // this.$store.dispatch('userLogin',{}) // 直接通过store的方法 触发action, 改变 userInfo 的值 (重新调用actions里的userLogin方法
+    // this.userLogin() // 通过mapActions 触发mutation 从而commit ,改变state的值
+
+    // let params = {userId: 75,menus: []}
+    // this.$store.commit('userSign',params); 重新调用mutations的userSign方法
+  },
   mounted() {
+    // this.menus = this.getMenuList // vuex里保存菜单的写法 获取菜单
     this.menus = utils.storage('sw_user').menus
     this.roleName = this.getCookie('role_name')
     const ID = sessionStorage.getItem('id')
     this.activeId = parseInt(ID)
     this.$emit('listenMenuId', parseInt(ID));
   },
+  
   methods: {
+//     ...mapMutations({
+//     sign: 'userSign' // userSign 是mutation 里的方法,sign是重新定义的一个别名方法,本组件直接调用这个方法
+//     }),
+//    ...mapActions({
+//     userLogin: 'userLogin' // 第一个userLogin是定义的一个函数别名称,挂载在到this(vue)实例上,后面一个userLogin 才是actions里面函数方法名称
+//     }),
     // 获取cookie里某个参数的值
     getCookie(name) {
       let cookieValue = null;

+ 13 - 5
src/views/homecomponents/SystemSettings/Organization.vue

@@ -60,11 +60,6 @@ export default {
   },
   mounted() {
   },
-   // 离开当前路由之前的钩子函数 
-  beforeRouteLeave(to, form, next) {
-    sessionStorage.removeItem('currentTabs')
-    next()
-  },
   methods: {
      // 获取树形数据
     getMetroLevel (text,currentOrgId,editText) {
@@ -357,4 +352,17 @@ export default {
   height: 100%;
   padding: 10px 0;
 }
+/* 对话框里的input里的placeholder样式修改 */
+/deep/ .ivu-input::-webkit-input-placeholder , /deep/ .ivu-input-number-input::-webkit-input-placeholder{
+  color: #718EBD;
+}
+/deep/ .ivu-input::-moz-placeholder, /deep/ .ivu-input-number-input::-webkit-input-placeholder{   /* Mozilla Firefox 19+ */
+  color: #718EBD;
+}
+/deep/ .ivu-input::-moz-placeholde, /deep/ .ivu-input-number-input::-webkit-input-placeholderr{    /* Mozilla Firefox 4 to 18 */
+ color: #718EBD;
+}
+/deep/ .ivu-input::-ms-input-placeholder, /deep/ .ivu-input-number-input::-webkit-input-placeholder{  /* Internet Explorer 10-11 */
+  color: #718EBD;
+}
 </style>

+ 29 - 53
src/views/homecomponents/SystemSettings/OrganizationIndex.vue

@@ -45,7 +45,7 @@
         </div>
       </FormItem>
       <FormItem label="当前组织用户数" prop="equipmentStatus" style="width:48%">
-        <span class="form-item-bot-left">{{currentOrganList.curOrgUserCount || 0}}</span>
+        <span class="form-item-bot-left" @click="pageJump(currentOrganList)">{{currentOrganList.curOrgUserCount || 0}}</span>
       </FormItem>
       <FormItem label="次级组织总数" prop="equipmentStatus" style="width:48%">
         <span class="form-item-bot-right">{{currentOrganList.childOrgCount || 0}}个</span>
@@ -70,8 +70,8 @@
           <FormItem label="">
             <DatePicker type="datetimerange" :value="dateRange" format="yyyy-MM-dd HH:mm:ss" placeholder="更新时间范围" class="common-date-picker date-picker-main" :clearable="false" :editable="false" @on-change="changePicker"></DatePicker>
           </FormItem>
-          <FormItem label="" prop="equipmentName">
-            <Input placeholder="输入负责人关键字查询" clearable search v-model="tableParams.equipmentName" />
+          <FormItem label="" prop="keywords">
+            <Input placeholder="输入负责人关键字查询" clearable search v-model="tableParams.keywords" />
           </FormItem>
           <FormItem label="" >
             <Button type="primary" class="common-btn-search" @click="searchClick">
@@ -127,9 +127,6 @@
               </div>
           </Poptip>
 				</FormItem> -->
-        <!-- <FormItem label="组织名称:" prop="orgTest">
-          <Cascader :data="data3" :render-format="format" change-on-select v-model="formOption.orgTest"></Cascader>
-        </FormItem> -->
 				<FormItem label="序号:" prop="orgOrder">
           <InputNumber :max="99" :min="1" v-model="formOption.orgOrder" placeholder="请输入1~99,序号越小显示越靠前"></InputNumber>
         </FormItem>
@@ -202,12 +199,6 @@ export default {
             message: '请输入组织名称',
             trigger: 'blur'
         }],
-        // orgTest: [{
-        //     type: 'array',
-        //     required: true,
-        //     message: '请选择组织名称',
-        //     trigger: 'change'
-        // }],
       },
       formOption: {},
       isSaveNumber: false,
@@ -354,32 +345,6 @@ export default {
       disabledLevel: 0,
       // visiblePoptip: false,
       currentTreeId: null,
-      // data3: [
-      //             {
-      //               value: 'zhejiang',
-      //               label: '浙江',
-      //               children: [{
-      //                   value: 'hangzhou',
-      //                   label: '杭州',
-      //                   children: [{
-      //                       value: 'xihu',
-      //                       label: '西湖',
-      //                       code: 310000
-      //                   }]
-      //               }]
-      //           }, {
-      //               value: 'jiangsu',
-      //               label: '江苏',
-      //               children: [{
-      //                   value: 'nanjing',
-      //                   label: '南京',
-      //                   children: [{
-      //                       value: 'zhonghuamen',
-      //                       label: '中华门',
-      //                       code: 210000
-      //                   }]
-      //               }]
-      //           }]
     };
   },
   watch: {
@@ -391,13 +356,19 @@ export default {
         } else {
           this.childDisabled = false
         }
-      }, 
-      // immediate: true,
+      }
    },
   },
   mounted() {
   },
   methods: {
+    pageJump (currentOrgObj) {
+      // let menuNameArr = []
+      // menuNameArr = ['系统设置','用户管理']
+      // sessionStorage.setItem('routname', '/MainPage/UserManagement')
+      // sessionStorage.setItem('menuNameArr',JSON.stringify(menuNameArr))
+      // this.$router.push({ name: 'UserManagement', params: { orgId:currentOrgObj.orgId }})
+    },
     // getTestTree(arr) {
     //   return arr.map((v,index) => {
     //     v.value = v.id
@@ -407,14 +378,6 @@ export default {
     //     return v;
     //   });
     // },
-    //  format (labels, selectedData) {
-    //     const index = labels.length - 1;
-    //     return labels[index];
-    //   },
-    // handleCheckChange (val) {
-    //   this.formOption.orgName = val[0].title;
-    //   this.visiblePoptip = false;
-    // },
     editIconNumber (title) {
       this.numberTitle = title
       if (title == 'edit') {
@@ -535,8 +498,8 @@ export default {
     getTableData (nodeId) {
       this.tableParams.parentOrgId = nodeId ? nodeId : this.currentTreeId
       let params = JSON.parse(JSON.stringify(this.tableParams))
-      params.orgUserNum = params.orgUserNum == '-1' ? '':params.orgUserNum
-      params.isEnabled = params.isEnabled == '-1'?'':params.isEnabled
+      params.orgUserNum = params.orgUserNum == '-1' ? '' : params.orgUserNum
+      params.isEnabled = params.isEnabled == '-1'?'': params.isEnabled
       this.loading = true
       this.$get('metroapi/org/querySysOrgPage', params).then(res=>{
         this.loading = false
@@ -607,9 +570,9 @@ export default {
     //   })
     // },
     modalChange (modalStatus) {
-     if (!modalStatus) {
-      this.$refs.formOption.resetFields();
-     }
+      if (!modalStatus) {
+        this.$refs.formOption.resetFields();
+      }
     },
     modalOk (formName) {
       let params = JSON.parse(JSON.stringify(this.formOption))
@@ -873,4 +836,17 @@ export default {
   background-color: #a3a3a3;
   border-color: #a3a3a3;
 }
+/* 对话框里的input里的placeholder样式修改 */
+/deep/ .ivu-input::-webkit-input-placeholder , /deep/ .ivu-input-number-input::-webkit-input-placeholder{
+  color: #718EBD;
+}
+/deep/ .ivu-input::-moz-placeholder, /deep/ .ivu-input-number-input::-webkit-input-placeholder{   /* Mozilla Firefox 19+ */
+  color: #718EBD;
+}
+/deep/ .ivu-input::-moz-placeholde, /deep/ .ivu-input-number-input::-webkit-input-placeholderr{    /* Mozilla Firefox 4 to 18 */
+ color: #718EBD;
+}
+/deep/ .ivu-input::-ms-input-placeholder, /deep/ .ivu-input-number-input::-webkit-input-placeholder{  /* Internet Explorer 10-11 */
+  color: #718EBD;
+}
 </style>

+ 8 - 30
src/views/homecomponents/SystemSettings/RolePermissions.vue

@@ -1,6 +1,7 @@
 <template>
   <div class="content-main-manage">
-    <div class="content-main">
+     <!-- <i class="iconfont icon-quanxian" style="cursor:not-allowed;color:#fb9c2c;fontSize:18px;marginRight:6px" v-if="row.roleId == 1"></i> -->
+    <!-- <div class="content-main">
      <div class="content-body-wrap">
         <div class="search-list">
         <div class="search-left">
@@ -37,8 +38,7 @@
             </template>
             <template slot-scope="{ row }" slot="action">
               <Tooltip content="配置权限" placement="top">
-                  <!-- <i class="iconfont icon-quanxian" style="cursor:not-allowed;color:#fb9c2c;fontSize:18px;marginRight:6px" v-if="row.roleId == 1"></i> -->
-                  <i class="iconfont icon-quanxian" style="cursor:pointer;color:#fb9c2c;fontSize:18px;marginRight:6px" @click="detailClick(row)"></i>
+                  <i class="iconfont icon-quanxian" style="cursor:pointer;color:#fb9c2c;fontSize:18px;marginRight:6px" @click="permissionConfig(row)"></i>
               </Tooltip>
               <Tooltip content="编辑" placement="top">
                   <i class="iconfont icon-bianji" style="cursor:pointer;color:#64ACFE;fontSize:20px;marginRight:6px" @click="editClick(row)"></i>
@@ -123,7 +123,7 @@
            </div>
         </Modal>
      </div>
-    </div>
+    </div> -->
   </div>
 </template>
 <script>
@@ -136,7 +136,6 @@ export default {
   data() {
     return {
       loading: true,
-      modalLoading: true,
       tableParams: {
         keywords: '',
         isEnable: '',
@@ -245,7 +244,6 @@ export default {
           trigger: 'blur'
         }],
       },
-      chooseMenu: [],
       permissionMenu: [],
       homeChecked: true,
       homeDisabled: true
@@ -255,16 +253,6 @@ export default {
     this.getTableData()
   },
   methods: {
-    // 跳转到综合查询页面
-    go (val) {
-      if (val.name == '已标注告警') {
-        let menuNameArr = []
-        menuNameArr = ['设备分析','告警分析','综合查询']
-        sessionStorage.setItem('routname', '/MainPage/ComprehensiveQuery')
-        sessionStorage.setItem('menuNameArr',JSON.stringify(menuNameArr))
-        this.$router.push({ name: 'ComprehensiveQuery', params: { alertRankId:this.rowObj.id }})
-      }
-    },
     changePicker (date) {
       this.tableParams.beginDate = date[0]
       this.tableParams.endDate = date[1]
@@ -325,10 +313,9 @@ export default {
       this.title = '新增角色'
       this.showModal = true
     },
-    detailClick (row) {
+    permissionConfig (row) {
       this.rowObj = row
-      this.getMenus()  
-      // this.permissStatus = true
+      this.getMenus()
     },
     getMenus () {
       this.$get('metroapi/role/queryMenus', {roleId:this.rowObj.roleId}).then(res=>{
@@ -428,26 +415,17 @@ export default {
         }
       })
     },
-    commonPermissOk () {
-     console.log(this.$refs.treeMenu.getCheckedAndIndeterminateNodes())
+    commonPermissOk () { 
      let node = this.$refs.treeMenu.getCheckedAndIndeterminateNodes()
      let idArr = node.map(item => item.id);
      this.$put('metroapi/role/menus', {roleId: this.rowObj.roleId,menuIds: idArr}).then(res=>{
         if (res.httpCode == 1 ){
-          this.showModal = false
+          this.permissStatus = false
           this.$Message.info(res.msg)
         } else {
           this.$Message.info(res.msg)
         }
       })
-     console.log(idArr)
-    //  let id = node.filter (item => {
-    //   return item.children ==0
-    //  }).map( item => {
-    //    console.log(item)
-    //   return item.id
-    //  }).join()
-    //   console.log(id)
     },
     commonPermissCancel () {
       this.permissStatus = false

+ 94 - 148
src/views/homecomponents/SystemSettings/UserManagement.vue

@@ -11,7 +11,7 @@
                 </div>
                 <div class="station-tree-center">
                   <div class="station-tree-left common-scroll" v-show="showTree">
-                    <tree-list :defaultData="stationData" :currentStaData="currentStaData" :clickAllNode="true" v-if="stationData && stationData.length>0" @treeChange="treeChange" ref="tree"></tree-list>
+                    <tree-list :defaultData="stationData" :currentStaData="currentStaData" :clickAllNode="true" v-if="stationData && stationData.length>0" @treeChange="treeChange" ref="treeManage"></tree-list>
                   </div>
                   <div class="station-tree-left-notree" v-show="!showTree">
                     站点输入错误!
@@ -22,7 +22,7 @@
           </i-col>
           <i-col span="20" style="height:100%">
             <div class="right-main">
-              <user-management-index></user-management-index>
+              <user-management-index ref="user" :stationData="stationData" :currentOrgId="currentOrgId"></user-management-index>
             </div>
           </i-col>
         </Row>
@@ -43,76 +43,70 @@ export default {
       currentStaData: [], // 当前搜索框搜索的站台数组对象,传给子组件,用来判断单选站台名当前选中状态
       showTree: true,// 是否显示树形组件
 		  stationData: [],
+      currentOrgId: '',
     };
   },
   mounted() {
-    // this.getCurrentTab (sessionStorage.getItem('currentTabs'))
     this.getMetroLevel()
   },
-   // 离开当前路由之前的钩子函数 
-  beforeRouteLeave(to, form, next) {
-    sessionStorage.removeItem('currentTabs')
-    next()
-  },
   methods: {
      // 获取树形数据
-    getMetroLevel (text,currentOrgId,editText) {
+    getMetroLevel () {
       this.$get('metroapi/org/sysOrgTree').then(res => {
 				if (res.httpCode == 1) {
           this.stationData = res.data
-          if (text == 'update') {
-            this.stationData = this.getChangeTree(this.stationData,currentOrgId,editText)
+          if (this.$route.params.orgId) {
+            let pageJumpOrgId = this.$route.params.orgId
+            this.stationData = this.getJumpTree(this.stationData,pageJumpOrgId) //从组织机构跳转过来携带参数orgId
           } else {
-            this.stationData = this.getTree(this.stationData)
+            this.stationData = this.getTree(this.stationData) //直接到当前页面无参数默认选中树形根节点
           }
 				}
 		  })
     },
-    getTree(arr) {
-      return arr.map((v,index) => {
+    getJumpTree (arr,pageJumpOrgId) {
+     return arr.map((v,index) => {
+        v.value = v.nodeId
+        v.label = v.title
+        v.children = v.children ? v.children : []
+        v.expand = false
+        v.selected = false
         if (index==0) {
           v.expand = true
-        } else {
-          v.expand = false
-        }
-        if (v.level== 1) {
-          v.disabled = true
         }
-        if (index==0 && v.level== 2) {
-          this.levelNum = v.level
+        if (v.id == pageJumpOrgId) {
           v.selected = true
-          v.disabled = true
           this.currentStation = v.title
           this.currentOrgId = v.nodeId
-          this.$refs.treeManage.getOrgData(v.nodeId)
-        }
-        if (v.children) v.children = this.getTree(v.children);
+          this.$refs.user.getTableData('',v.nodeId)
+        } 
+        if (v.children) v.children = this.getJumpTree(v.children,pageJumpOrgId);
         return v;
       });
     },
-    getChangeTree(arr,currentOrgId,editText) {
+    getTree(arr,textState) {
       return arr.map((v,index) => {
-        if (v.level== 1) {
-          v.disabled = true
+        v.value = v.nodeId
+        v.label = v.title
+        v.children = v.children ? v.children : []
+        v.expand = false
+        v.selected = false
+        if (index==0) {
+          v.expand = true
         }
-        if (v.nodeId == currentOrgId) {
-          this.levelNum = v.level
+        if(v.level== 1 && textState != 'del'){
           v.selected = true
-          v.disabled = true
           this.currentStation = v.title
           this.currentOrgId = v.nodeId
-          this.$refs.treeManage.getOrgData(v.nodeId,editText)
+          this.$refs.user.getTableData('',v.nodeId)
         }
-        if (v.children) v.children = this.getChangeTree(v.children,currentOrgId,editText);
+        if (v.children) v.children = this.getTree(v.children,textState);
         return v;
       });
     },
     iconChange: _.throttle(function() {
       this.currentStaData = []
       this.treeName = []
-      this.$nextTick(()=> {
-       this.getCurrentTab(this.currentTabs,this.currentStation)
-      })
       if(this.currentStation != ''){
         this.showTree = false
         document.querySelector(".common-scroll").scrollTo(0, 0); // 滚动条回到顶部
@@ -122,126 +116,78 @@ export default {
         this.stationData = this.getTree(this.stationData)
         return 
       }
-      this.getSelectedItem()
+      let currentNodeId = this.filterNodeId(this.stationData,this.currentStation)
+      if (currentNodeId) {
+        this.stationData = this.getParentIdList(this.stationData,currentNodeId)
+      }
 		}, 500),
     clearChange () {
-      this.getSelectedItem()
-      this.getCurrentTab(this.currentTabs,this.currentStation)
+      this.getTree(this.stationData,'del')
+      this.$refs.user.getTableData('',0)
     },
-    getSelectedItem  () {
-      this.stationData.forEach((item, index,itemArr) => {
-        item.expand = false;
-        item.disabled = false; 
-        item.selected = false;
-        if (item.title == this.currentStation) {
-            item.selected = true;
-            item.disabled = true; // disabled 是否禁止选中 
-            item.expand = true;
-            this.currentStaData.push(item)
-            this.showTree = true
-        }
-        if (this.currentStation == '' && index == 0) {
-          item.expand = true
-        }
-        if (item.children) {
-          item.children.forEach((val, i,valArr) => {
-          val.expand = false; //expand 是否展开直子节点 
-          val.disabled = false; // disabled 是否禁止选中
-          val.selected = false;
-          if (val.title == this.currentStation) {
-            val.selected = true;
-            val.disabled = true; // disabled 是否禁止选中 
-            val.expand = true;
-            item.expand = true;
-            this.currentStaData.push(val)
-            this.showTree = true
+    // 根据搜索框的值查到当前nodeId
+    filterNodeId(list,val){
+      let _this=this
+      for (let i = 0; i < list.length; i++) {
+        let a=list[i]
+        if(a.title=== val){
+          return a.nodeId
+        }else{
+          if(a.children && a.children.length>0){
+            let res=_this.filterNodeId(a.children,val)
+            if(res){
+              return res
+            }
           }
-          if (this.currentStation == '' && i==0) {
-            val.expand = true
-          }
-          if (val.children) {
-            val.children.forEach ((lastVal,lastIndex) => {
-              lastVal.selected = false; //expand 是否展开直子节点 
-              lastVal.disabled = false; 
-              lastVal.expand = false;
-              if (lastVal.title == this.currentStation) {
-                lastVal.selected = true;
-                lastVal.disabled = true; // disabled 是否禁止选中 
-                lastVal.expand = true;
-                val.expand = true
-                item.expand = true
-                this.currentStaData.push(lastVal)
-                this.showTree = true
-              } 
-            })
-          } 
-        });
-        }    
-      });
+        }
+      }
     },
-    treeChange(val,arr,level) {
-      this.currentStation = val
-      this.getCurrentTab(this.currentTabs,this.currentStation,arr,level)
-		},
-    // tabsClick (name) {
-    //   this.stationData = this.getElseTree(this.stationData) // 切换tab页时,清除tree选中情况
-    //   this.currentStation = ''
-    //   sessionStorage.setItem("currentTabs",name)
-    //   this.getCurrentTab (name)
-    //   if (document.querySelector(".station-tree-left")) {
-    //     document.querySelector(".station-tree-left").scrollTo(0, 0) 
-    //   }
-    // },
-    // getCurrentTab (currentTabs,currentStation,arr,level) {
-    //   this.currentTabs = currentTabs || '告警信息-无法判定等级'
-    //   if (currentTabs == '告警信息-无法判定等级' || !currentTabs) {
-    //      this.$nextTick(()=> {
-    //       this.$refs.unableDeter.tableParams.pageNum = 1
-    //       this.$refs.unableDeter.getTableData(currentStation,arr,level)
-    //     })
-    //   } else if(currentTabs == '告警信息-待确认'){       
-    //     this.$nextTick(()=> {
-    //       this.$refs.toConfirmed.tableParams.pageNum = 1
-    //       this.$refs.toConfirmed.getTableData(currentStation,arr,level)
-    //     })
-    //   } else if(currentTabs == '告警信息-已确认'){
-    //     this.$nextTick(()=> {
-    //       this.$refs.confirmed.tableParams.pageNum = 1
-    //       this.$refs.confirmed.getTableData(currentStation,arr,level)
-    //     })
-    //   } else if(currentTabs == '告警信息-已清除'){
-    //     this.$nextTick(()=> {
-    //       this.$refs.cleared.tableParams.pageNum = 1
-    //       this.$refs.cleared.getTableData(currentStation,arr,level)
-    //     })
-    //   } else if(currentTabs == '告警信息-已过滤'){
-    //     this.$nextTick(()=> {
-    //       this.$refs.filtered.tableParams.pageNum = 1
-    //       this.$refs.filtered.getTableData(currentStation,arr,level)
-    //     })
-    //   } else {
-    //      this.$nextTick(()=> {
-    //        this.$refs.comprehensive.tableParams.pageNum = 1
-    //       this.$refs.comprehensive.getTableData(currentStation,arr,level)
-    //     })
-    //   }
-    // },
-    // 递归函数 每层数组的第一个对象里的属性expand 全展开(true)
-    getElseTree(arr) {
-      return arr.map((v,index) => {
-        if (v.title==this.currentStation) {
-          v.selected = false
-          v.disabled = false
+    // 递归循环 根据当前id找到它的所有父节点
+    getParentIdList(list, id) {
+        if (!list || !id) {
+            return ''
         }
-        if (index == 0) {
-          v.expand = true
-        } else {
-          v.expand = false
+        let arr = [];
+        let findParent = (data, currentdId, nodeId) => {
+            for (var i = 0, length = data.length; i < length; i++) {
+                let node = data[i];
+                node.expand = false
+                node.selected = false
+                node.disabled = false
+                if (node.level== 1) {
+                  node.disabled = true
+                }
+                if (node.nodeId === currentdId) {
+                    node.expand = true
+                    if (node.title == this.currentStation) {
+                      node.expand = true   
+                      this.currentOrgId = node.nodeId
+                      node.selected = true
+                      node.disabled = true
+                      this.showTree = true
+                      this.$refs.user.getTableData('',node.id)        
+                    }
+                    if (!node.nodeId) {
+                        break
+                    }
+                    findParent(list, nodeId);
+                    // break
+                } else {
+                    if (node.children) {
+                      findParent(node.children, currentdId, node.nodeId);
+                    }
+                    continue
+                }
+            }
+            return list;
         }
-        if (v.children) v.children = this.getElseTree(v.children);
-        return v;
-      });
+        return findParent(list, id);
     },
+    treeChange(val,arr,level,currentNodeId) {
+      this.currentStation = val
+      this.currentOrgId = currentNodeId
+      this.$refs.user.getTableData('',currentNodeId)
+		},
   }
 };
 </script>

+ 243 - 341
src/views/homecomponents/SystemSettings/UserManagementIndex.vue

@@ -3,14 +3,14 @@
     <div class="search-list">
       <div class="search-left">
         <Form class="common-form common-form-list" ref="tableParams" :model="tableParams" inline>
-          <FormItem label="" prop="lineId">
-            <Select v-model="tableParams.lineId" placeholder="线路" @on-select="changeLine" label-in-value>
-              <Option v-for="item in lineTypeData" :value="item.id" :key="item.id">{{ item.lineName }}</Option>
+          <FormItem label="" prop="orgType">
+            <Select v-model="tableParams.orgType" placeholder="" label-in-value>
+              <Option v-for="item in orgTypeData" :value="item.value" :key="item.value">{{ item.label }}</Option>
             </Select>
           </FormItem>
           <FormItem label="" prop="roleId">
             <Select v-model="tableParams.roleId" placeholder="角色名称">
-              <Option v-for="item in roleData" :value="item.id" :key="item.id">{{ item.stationName }}</Option>
+              <Option v-for="item in roleData" :value="item.value" :key="item.value">{{ item.label }}</Option>
             </Select>
           </FormItem>
           <FormItem label="" prop="isEnabled">
@@ -18,19 +18,14 @@
               <Option v-for="item in enabledData" :value="item.value" :key="item.value">{{ item.label }}</Option>
             </Select>
           </FormItem>
-          <FormItem label="" prop="userCode">
-            <Input placeholder="输入用户号" clearable search v-model="tableParams.userCode" />
-          </FormItem>
           <FormItem label="" prop="userName">
-            <Input placeholder="输入姓名关键词" clearable search v-model="tableParams.userName" />
+            <Input placeholder="输入用户号" clearable search v-model="tableParams.userName" />
+          </FormItem>
+          <FormItem label="" prop="realName">
+            <Input placeholder="输入姓名关键词" clearable search v-model="tableParams.realName" />
           </FormItem>
-          <!-- <FormItem label="" prop="equipmentType">
-             <Select v-model="tableParams.equipmentType" placeholder="用户类型">
-              <Option v-for="item in equipTypeData" :value="(item.id)" :key="item.id">{{ item.name }}</Option>
-            </Select>
-          </FormItem> -->
           <FormItem label="">
-            <DatePicker type="daterange" :value="dateRange" :clearable="false" :editable="false" class="common-date-picker date-picker-main" placement="bottom-start" placeholder="启用日期范围" @on-change="changePicker"></DatePicker>
+            <DatePicker type="datetimerange" :value="dateRange" format="yyyy-MM-dd HH:mm:ss" placeholder="更新时间范围" class="common-date-picker date-picker-main" :clearable="false" :editable="false" @on-change="changePicker"></DatePicker>
           </FormItem>
           <FormItem label="" >
             <Button type="primary" class="common-btn-search" @click="searchClick">
@@ -51,15 +46,9 @@
         <template slot="loading">
             <Loading-animation></Loading-animation>
         </template>
-        <!-- <template slot-scope="{ row }" slot="lineName">
-          <span>{{!row.lineName ? '/' : row.lineName}}</span>
-        </template>
-        <template slot-scope="{ row }" slot="stationName">
-          <span>{{!row.stationName ? '/' : row.stationName}}</span>
-        </template> -->
          <template slot-scope="{ row }" slot="action">
            <Tooltip content="重置密码" placement="top">
-              <i class="iconfont icon-mima" style="cursor:pointer;color:#858aea;fontSize:16px;marginRight:6px;vertical-align: middle;" @click="detailClick(row)"></i>
+              <i class="iconfont icon-mima" style="cursor:pointer;color:#858aea;fontSize:16px;marginRight:6px;vertical-align: middle;" @click="resetPwd(row)"></i>
            </Tooltip>
            <Tooltip content="详情" placement="top">
               <i class="iconfont icon-xiangqingmingxi" style="cursor:pointer;color:#B8B532;fontSize:20px;marginRight:6px;vertical-align: middle;" @click="detailClick(row)"></i>
@@ -89,50 +78,32 @@
       @on-visible-change="modalChange"
       :mask-closable="false"
       class-name="common-modal">
-      <Form class="common-form" ref="formOption" :model="formOption" :rules="ruleValidate" :label-width="120" inline>
-				<FormItem label="归属线路:" prop="lineId" style="width:48%">
-          <Select v-model="formOption.lineId" placeholder="线路" @on-change="selectModalLine" label-in-value>
-              <Option v-for="item in lineTypeData" :value="String(item.id)" :key="item.id">{{ item.lineName }}</Option>
-          </Select>
+      <Form class="common-form common-form-modal" ref="formOption" :model="formOption" :rules="ruleValidate" :label-width="120">
+				<FormItem label="用户号:" prop="userName">
+          <Input v-model.trim="formOption.userName" placeholder="请输入用户号" /> 
+          <div class="common-form-item-text">可使用工号、学号等唯一不重复身份识别号</div> 
 				</FormItem>
-				<FormItem label="归属站点:" prop="stationId" style="width:48%">
-           <Select v-model="formOption.stationId" placeholder="站点" @on-change="selectModalStation" label-in-value>
-            <Option v-for="item in stationTypeData" :value="String(item.id)" :key="item.id">{{ item.stationName }}</Option>
-          </Select>
-        </FormItem>
-        <FormItem label="归属应用:" prop="appId" style="width:48%">
-           <Select v-model="formOption.appId" placeholder="归属应用" @on-change="selectModalApp">
-             <Option v-for="item in equipAppModalData" :value="item.id" :key="item.id">{{ item.appName }}</Option>
-          </Select>
-        </FormItem>
-        <FormItem label="用户类型:" prop="equipmentType" style="width:48%">
-          <Select v-model="formOption.equipmentType" placeholder="用户类型">
-             <Option v-for="item in equipTypeModalData" :value="item.equipmentTypeId" :key="item.equipmentTypeId">{{ item.equipmentName }}</Option>
-          </Select>
-        </FormItem>
-        <FormItem label="用户ID:" style="width:100%">
-          <span v-show="title=='新增用户'">系统自动生成,唯一不重复</span>
-          <span v-show="title=='编辑用户'">{{formOption.equipmentId}}</span>
-        </FormItem>
-        <FormItem label="用户名称:" prop="equipmentName" style="width:100%">
-          <Input v-model.trim="formOption.equipmentName" type="textarea" :rows="3" maxlength="100" show-word-limit />  
-        </FormItem>
-        <FormItem label="用户状态:" prop="equipmentStatus" style="width:48%">
-          <Select v-model="formOption.equipmentStatus" placeholder="用户状态">
-            <Option v-for="item in equipStateModalData" :value="item.id" :key="item.id">{{ item.value }}</Option>
-          </Select>
+        <FormItem label="用户名:" prop="realName">
+          <Input v-model.trim="formOption.realName" maxlength="10" show-word-limit /> 
+				</FormItem>
+				<FormItem label="组织机构:" prop="orgIdArr">
+          <Cascader :data="stationData[0].children" :render-format="format" :clearable="false" change-on-select v-model="formOption.orgIdArr" placeholder="选择组织机构" class="common-cascader" v-if="stationData && stationData.length>0"></Cascader>
         </FormItem>
-        <FormItem label="启用日期:" prop="useDate" style="width:48%">
-          <DatePicker type="date" :value="formOption.useDate" :editable="false" class="common-date-picker" placement="bottom-start" placeholder="启用日期" style="width: 100%" @on-change="changeMoldaPicker"></DatePicker>
+        <FormItem label="角色名称:" prop="roleId">
+           <Select v-model="formOption.roleId" placeholder="角色名称">
+              <Option v-for="item in roleModalData" :value="item.value" :key="item.value">{{ item.label }}</Option>
+            </Select>
         </FormItem>
-         <FormItem label="用户型号:" prop="equipmentVersion" style="width:100%">
-          <Input v-model="formOption.equipmentVersion" maxlength="20" show-word-limit />  
+        <FormItem label="手机号码:" prop="mobilePhone">
+         <Input v-model.trim="formOption.mobilePhone" placeholder="手机号格式校验" />
         </FormItem>
-         <FormItem label="供应商:" prop="supplier" style="width:100%">
-          <Input v-model="formOption.supplier" maxlength="20" show-word-limit />  
+        <FormItem label="邮箱:" prop="userMail">
+          <Input v-model.trim="formOption.userMail" placeholder="邮箱格式校验"/>  
         </FormItem>
-         <FormItem label="说明:" prop="remark" style="width:100%">
-          <Input v-model="formOption.remark" type="textarea" :rows="6" maxlength="200" show-word-limit /> 
+         <FormItem label="启用状态:" prop="isEnable" v-if="title == '新增用户'">
+          <i-switch true-color="#57C44F" v-model="formOption.isEnable" disabled></i-switch>
+          <span style="color: #718EBD;margin-left:6px">关</span>
+          <span style="color: #718EBD;margin-left:12px">(所有新增状态均为关闭,需在列表打开)</span>
         </FormItem>
 			</Form>
       <div slot="footer">
@@ -159,71 +130,70 @@
      <Modal
       v-model="detailStatus"
       title="用户详情"
-      width="45"
+      width="30"
       ref="modalGrag"
       draggable
       reset-drag-position
       footer-hide
       :mask-closable="false"
       class-name="common-modal">
-      <div v-for="(item,index) in detailLabel" :key="index">
-        <div class="common-modal-top">
-        <span class="common-modal-top-text">{{item.name}}</span>
-        </div>
-        <div class="common-modal-content">
-          <div class="modal-content-item" v-for="(val,i) in item.value" :key="i" :class="{'item-especial': val.name == '说明'||  val.name == '最后通讯时间' && item.value.length%2!=0,'item-especial-bot':(i==item.value.length-1 || i==item.value.length-2) && item.value.length%2==0}">
-            <div class="modal-content-item-name">
-            {{val.name}}
-            </div>
-            <div class="modal-content-item-value"> 
-              <Tooltip placement="top-start" transfer max-width="350" v-if="val.name == '归属线路' || val.name == '归属站点' || val.value || val.value===0">
-                <span v-if="val.name == '归属线路' || val.name == '归属站点'">{{!val.value ? '/' : val.value}}</span>
-                <span v-else>{{val.value}}</span>
-                <div slot="content">
-                  <span v-if="val.name == '归属线路' || val.name == '归属站点'">{{!val.value ? '/' : val.value}}</span>
-                  <span v-else>{{val.value}}</span>
-                </div>
-              </Tooltip>
-              <span v-else>{{val.value}}</span>
-            </div>
-          </div>
-        </div>
-      </div>
+      <!-- <Form class="common-form common-form-modal" :model="detailData" :label-width="120">
+				<FormItem label="用户号:"> 
+          <div class="common-form-detail-text">{{detailData.userName}}</div> 
+				</FormItem>
+        <FormItem label="用户名:">
+         <div class="common-form-detail-text">{{detailData.realName}}</div> 
+				</FormItem>
+				<FormItem label="组织机构:">
+          <div class="common-form-detail-text">{{detailData.orgName}}</div> 
+        </FormItem>
+        <FormItem label="角色名称:">
+          <div class="common-form-detail-text">{{detailData.roleName}}</div> 
+        </FormItem>
+        <FormItem label="手机号码:">
+         <div class="common-form-detail-text">{{detailData.mobilePhone}}</div> 
+        </FormItem>
+        <FormItem label="邮箱:">
+          <div class="common-form-detail-text">{{detailData.userMail}}</div> 
+        </FormItem>
+        <FormItem label="启用状态:">
+          <div class="common-form-detail-text">{{detailData.isEnable == 1 ? '开启' : '关闭'}}</div>
+        </FormItem>
+        <FormItem label="更新时间:">
+          <div class="common-form-detail-text">{{detailData.updateTime}}</div> 
+        </FormItem>
+        <FormItem label="最后登录时间:">
+          <div class="common-form-detail-text">{{detailData.lastLoginTime}}</div> 
+        </FormItem>
+			</Form> -->
     </Modal>
   </div>
 </template>
 <script>
-const defaultFrom = {lineId: '',stationId: '',appId:'',equipmentName: '',equipmentType:'',equipmentStatus: '',equipmentVersion: '',supplier: '',remark: ''}
+const defaultFrom = {userName: '',realName: '',orgId: '',orgIdArr: [],roleId: '',mobilePhone: '',userMail: '',isEnable:0}
 export default {
   name: "UserManagementIndex",
-  components:{
+  props: {
+    stationData: {
+      type: Array,
+      default: () => {
+        return [];
+      }
+    },
+    currentOrgId: [String,Number]
   },
   data() {
     return {
-      applicationParams: {
-        level: '',
-        lineId: '',
-        stationId: '',
-        equipmentCheck: '',
-        instrumentCheck: '',
-        pageNum: 1,
-        pageSize: 9999
-      },
-      appParams: {
-        applicationId: '',
-        equipmentTypeId: '',
-        keywords: '',
-        pageNum: 1,
-        pageSize: 9999
-      },
       loading: true,
       dateRange: [],
       tableParams: {
-        lineId: '',
+        keywords: '',
+        orgType: 'all',
+        orgId: '',
         roleId: '',
         isEnabled: '',
-        userCode:'',
-        userName: '',
+        userName:'',
+        realName: '',
         beginUpdateTime: '',
         endUpdateTime: '',
         pageNum: 1,
@@ -247,7 +217,18 @@ export default {
           label: '关闭'
         },
       ],
+      orgTypeData: [
+        {
+          value: 'all',
+          label: '当前及下级节点所有用户'
+        },
+        {
+          value: 'cur',
+          label: '仅当前节点用户'
+        },
+      ],
       roleData: [],
+      roleModalData: [],
       stationTypeData: [],
       equipStateData: [],
       equipStateModalData: [],
@@ -255,24 +236,21 @@ export default {
       equipTypeModalData: [],
       equipAppModalData: [],
       columns: [
-         {
+          {
             title: '序号',
             type: 'index',
-            align: 'center'
+            align: 'center',
+            ellipsis: true,
+            tooltip: true
           },
-        //  {
-        //     type: 'selection',
-        //     width: 60,
-        //     align: 'center'
-        //   },
           {
-            title: '用户ID',
-            key: 'userId',
+            title: '用户号',
+            key: 'userName',
             align: 'center'
           },
           {
             title: '用户名',
-            key: 'userName',
+            key: 'realName',
             align: 'center',
             ellipsis: true,
             tooltip: true
@@ -300,38 +278,37 @@ export default {
           },
           {
             title: '启用状态',
-            key: 'isEnabled',
+            key: 'isEnable',
             align: 'center',
             width: 120,
             render: (h, params) => {
               return h('div', [                             
                 h('i-switch', {
-                  props: { value: params.row.isEnabled,'true-color': '#57C44F', trueValue:1,falseValue: 0
+                  props: { value: params.row.isEnable,'true-color': '#57C44F', trueValue:1,falseValue: 0
                   },
                   nativeOn:{
                       "mousedown":(event)=>{ // 监听组件原生事件mousedown,此事件在click之前触发
                         this.rowObj =  params.row
-                        this.isClickOrg = false
-                        if (params.row.isEnabled == 1) {
-                          this.commonTitle = '确认关闭'
-                          this.activeColor = '#E92E2E'
-                          this.activeClass = 'icon-guanbi'
-                          this.modalTitle = '关闭后线路下所有站点将同时关闭,线路及站点统计数据不可见。'
-                          this.modalStatus = true         
-                        } else {
-                          this.commonTitle = '确认启用'
-                          this.activeColor = '#57C44F'
-                          this.activeClass = 'icon-qiyong'
-                          this.modalTitle = '启用后此线路统计数据将在各管理模块及前端显示页面生效。'
-                          this.modalStatus = true
-                        }
+                        // if (params.row.isEnable == 1) {
+                        //   this.commonTitle = '确认关闭'
+                        //   this.activeColor = '#E92E2E'
+                        //   this.activeClass = 'icon-guanbi'
+                        //   this.modalTitle = '关闭后,用户无法登录。关闭不影响用户已经产生的操作记录。'
+                        //   this.modalStatus = true         
+                        // } else {
+                        //   this.commonTitle = '确认启用'
+                        //   this.activeColor = '#57C44F'
+                        //   this.activeClass = 'icon-qiyong'
+                        //   this.modalTitle = '启用后,用户即可正常登录使用。'
+                        //   this.modalStatus = true
+                        // }
                       },
                     }
                 }),
               ])
             }
         },
-          {
+        {
           title: '操作',
           align: 'center',
           slot: 'action',
@@ -346,60 +323,57 @@ export default {
       activeColor: '#E92E2E',
       activeClass: '',
       modalTitle: '',
-      formOption: {lineId: '',stationId: '',appId:'',equipmentName: '',equipmentType:'',equipmentStatus: '',useDate:'',equipmentVersion: '',supplier: '',remark: ''},
+      formOption: {userName: '',realName: '',orgId: '',orgIdArr: [],roleId: '',mobilePhone: '',userMail: '',isEnable:0},
       ruleValidate: {
-        lineId: [{
-          required: true,
-          message: '请选择所属线路',
-          trigger: 'change'
-        }],
-        stationId: [{
-          required: true,
-          message: '请选择所属站点',
-          trigger: 'change'
-        }],
-        appId: [{
+        userName: [{
           required: true,
-          type: 'number',
-          message: '请选择归属应用',
-          trigger: 'change'
-        }],
-        equipmentName: [{
-          required: true,
-          message: '请输入用户名称',
-          trigger: 'change'
+          message: '请输入用户ID',
+          trigger: 'blur'
         }],
-        appName: [{
+        realName: [{
           required: true,
-          message: '请输入用户名',
+          message: '请输入用户名',
           trigger: 'blur'
         }],
-        equipmentType: [{
+        orgIdArr: [{
           required: true,
-          type: 'number',
-          message: '请选择用户类型',
+          type: 'array',
+          message: '请选择组织机构',
           trigger: 'change'
         }],
-        equipmentStatus: [{
+        roleId: [{
           required: true,
           type: 'number',
-          message: '请选择用户状态',
+          message: '请选择角色名称',
           trigger: 'change'
-        }]
+        }], 
+        mobilePhone: [
+             { required: true, message: "请输入手机号码", trigger: "blur" },
+             { pattern: /^1[3456789]\d{9}$/, message: "手机号码格式不正确", trigger: "blur" } ///^[1][345789]\d{9}$/
+        ],
+        userMail: [
+            { type: 'email', message: '请输入正确格式的邮箱', trigger: 'blur'}
+        ]
       }, 
-      detailLabel: [],
+      detailData: {},
+      curOrgId: '',
     };
   },
+  watch: {
+    currentOrgId: {
+     handler(newValue, oldValue) {
+      this.curOrgId = newValue
+    }
+   },
+  },
   mounted() {
     this.getType()
-    this.getAppApplicate()
-    this.getTableData()
   },
   methods: {
-    go (){
-      // this.$router.push({path:'//ApplicationManage'})
-      // this.$router.push({path:'/MainPage/ApplicationManage/2'})
-      this.$router.push({ name: 'ApplicationManage', params: { type:2 }}) // -> /home/123
+    format (labels, selectedData) {
+      const index = labels.length - 1;
+      this.formOption.orgId = selectedData.length >0 ? selectedData[selectedData.length-1].nodeId : ''
+      return labels[index];
     },
     changePicker (date) {
       this.tableParams.beginUpdateTime = date[0]
@@ -437,71 +411,29 @@ export default {
       //获取角色名称
       this.$get('metroapi/role/box').then(res=>{
         if (res.httpCode == 1 ){
+          this.roleModalData = JSON.parse(JSON.stringify(res.data))
           this.roleData = res.data
-          this.roleData.unshift({ id: '-1', value: '角色名称' })
+          this.roleData.unshift({ value: '-1', label: '角色名称' })
         } else {
           this.roleData = []
         }
       })
     },
-    // 获取归属应用
-    getAppApplicate () {
-     this.$get('metroapi/application/info/list', this.applicationParams).then(res=>{
-        if (res.httpCode == 1 ){
-          this.equipAppModalData = res.data.data
+    // 获取表格数据
+    getTableData (keywords,orgId) {
+      if (typeof(orgId) == 'number' && orgId>0) {
+       this.tableParams.orgId = orgId
+      } else {
+        if (!orgId) {
+          this.tableParams.orgId = ''
         } else {
-          this.equipAppModalData = []
+          this.tableParams.orgId = this.curOrgId
         }
-      })
-    },
-    changeLine (val) {
-      // 获取站点类型
-      this.tableParams.stationId = ''
-      this.tableParams.lineId = val.value
-      if (this.tableParams.lineId) {
-        this.getStationData(val.value)
       }
-    },
-    // 获取所属站点
-    getStationData (lineId) {
-      if(lineId == '-1') {
-        this.stationTypeData = [{ id: '-1', stationName: '站点' }]
-      } else {
-        this.$get('metroapi/lineStation/queryStationByLineId', {lineId:lineId}).then(res=>{
-          if (res.httpCode == 1 ){
-            this.stationTypeData = res.data
-            this.stationTypeData.unshift({ id: '-1', stationName: '站点' })
-          }
-        })
-      }
-    },
-    // 获取表格数据
-    getTableData (keywords,arr,level) {
-      //  if (level) {
-      //   this.tableParams.keywords = ''
-      //   if (level == 2) {
-      //     this.tableParams.applicationId = arr[arr.length-1]
-      //     this.tableParams.equipmentType = ''
-      //   } else if (level == 3) {
-      //     this.tableParams.applicationId = arr[arr.length-2]
-      //     this.tableParams.equipmentType = arr[arr.length-1]
-      //   } else {
-      //     this.tableParams.applicationId = ''
-      //     this.tableParams.equipmentType = ''
-      //   }
-      // } else {
-      //   this.tableParams.applicationId = ''
-      //   this.tableParams.equipmentType = ''
-      //   if (keywords == '合肥轨道交通' || keywords == '' || !keywords) {
-      //     this.tableParams.keywords = ''
-      //   } else {
-      //     this.tableParams.keywords = keywords
-      //   }
-      // }
+      this.tableParams.keywords = keywords ? keywords : ''
       let params = JSON.parse(JSON.stringify(this.tableParams))
-      // params.lineId = params.lineId == '-1' || !params.lineId ? '':params.lineId
-      // params.stationId = params.stationId == '-1' || !params.stationId ?'':params.stationId
-      // params.equipmentStatus = params.equipmentStatus == '-1' || !params.equipmentStatus ?'':params.equipmentStatus
+      params.roleId = params.roleId == '-1' ? '' : params.roleId
+      params.isEnabled = params.isEnabled == '-1' ? '' : params.isEnabled
       this.loading = true
       this.$get('metroapi/user/querySysUserPage', params).then(res=>{
         this.loading = false
@@ -523,24 +455,6 @@ export default {
           }
         })
     },
-    selectModalLine (val) {
-      this.formOption.stationId = ''
-      if (val) {
-        this.getStationData(val.value)
-      }
-    },
-    selectModalStation (val) {
-      if (val) {
-       this.formOption.stationId =val.value
-      }
-    },
-    selectModalApp (val) {
-      this.appParams.applicationId = val
-      this.formOption.equipmentType = ''
-      if (val) {
-        this.getAddEquipType(this.appParams)
-      }
-    },
     // 获取新增用户类型 
     getAddEquipType (params) {
       this.$get('metroapi/application/equipmentTypeInfo', params).then(res=>{
@@ -554,13 +468,11 @@ export default {
     searchClick () {
       this.tableParams.pageNum = 1
       this.getTableData()
-      // this.$router.push({ path: '/MainPage/ApplicationManage',  query: {deptName: "2"}})
     },
     resetClick (name) {
      this.dateRange = []
      this.tableParams.beginUpdateTime = ''
      this.tableParams.endUpdateTime = ''
-     this.stationTypeData = [{ id: '-1', stationName: '站点' }]
      this.$refs[name].resetFields()
      this.tableParams.pageNum = 1
      this.getTableData()
@@ -576,9 +488,9 @@ export default {
     detailClick (row) {
       this.rowObj = row
       this.detailStatus = true
-      this.$get('metroapi/equipment/equipmentDetail', {equipmentId:row.id}).then(res=>{
+      this.$get('metroapi/user/userView', {userId:row.userId}).then(res=>{
         if (res.httpCode == 1 ){
-          this.detailLabel = res.data
+          this.detailData = res.data
         } else {
           this.$Message.info(res.msg)
         }
@@ -587,11 +499,7 @@ export default {
     editClick (row) {
       this.rowObj = row
       this.formOption = JSON.parse(JSON.stringify(row));
-      this.formOption.lineId = this.formOption.lineId ? String(this.formOption.lineId) : '-1'
-      this.formOption.stationId = this.formOption.stationId ? String(this.formOption.stationId) : '-1'
-      this.getStationData(this.formOption.lineId)
-      this.appParams.applicationId = this.formOption.appId
-      this.getAddEquipType(this.appParams)
+      this.formOption.orgIdArr = [row.orgId]
       this.title = '编辑用户'
       this.showModal = true
     },
@@ -600,25 +508,29 @@ export default {
       this.commonTitle = '确认删除'
       this.activeColor = '#E92E2E'
       this.activeClass = ''
-      this.modalTitle = '删除不影响已产生的操作和记录。'
+      this.modalTitle = '删除不影响用户已经产生的操作记录。'
+      this.modalStatus = true
+    },
+    resetPwd (row) {
+      this.rowObj = row
+      this.commonTitle = '密码重置'
+      this.activeColor = '#858aea'
+      this.activeClass = ''
+      this.modalTitle = '用户密码将被重置为123456。'
       this.modalStatus = true
     },
     modalChange (modalStatus) {
      if (!modalStatus) {
       this.$refs.formOption.resetFields();
-      this.stationTypeData = [{ id: '-1', stationName: '站点' }]
-      this.equipTypeModalData = []
      }
     },
     modalOk (formName) {
       let params = JSON.parse(JSON.stringify(this.formOption)) //把对象中的数据给了某个变量,改变一个对象的值,另一个对象也变化的解决方法
-      params.lineId = params.lineId == '-1' ? '':params.lineId
-      params.stationId = params.stationId == '-1' ? '':params.stationId
       if (this.title == '新增用户') {
         this.$refs[formName].validate((valid) => {
           if (valid) {
-            this.$post('metroapi/equipment/addEquipment', params).then(res=>{
-              if ( res.httpCode == 1 ){
+            this.$post('metroapi/user/addSysUser', params).then(res=>{
+              if (res.httpCode == 1 ){
                 this.showModal = false
                 this.$Message.info(res.msg)
                 this.getTableData()
@@ -633,7 +545,7 @@ export default {
       } else {
         this.$refs[formName].validate((valid) => {
           if (valid) {
-            this.$post('metroapi/equipment/editEquipment', params).then(res=>{
+            this.$post('metroapi/user/updateUser', params).then(res=>{
               if (res.httpCode == 1 ){
                 this.showModal = false
                 this.$Message.info(res.msg)
@@ -652,17 +564,68 @@ export default {
       this.showModal = false
     },
     commonOk () {
-      let params = {
-        id: this.rowObj.id
+      if (this.commonTitle == '确认启用') {
+        let params = {
+          userId: this.rowObj.userId,
+          enabled: 1,
+          type: 0
+        }
+        this.getSwitchStatus(params)
+      } else if (this.commonTitle == '确认关闭') {
+        let params = {
+          userId: this.rowObj.userId,
+          enabled:0,
+          type: 0
+        }
+        this.getSwitchStatus(params)
+      } else if(this.commonTitle == '确认删除'){
+        let params = {
+          userId: this.rowObj.userId,
+          type: 2
+        }
+        this.delData(params)
+      } else {
+        let params = {
+          userId: this.rowObj.userId
+        }
+        console.log(typeof(this.rowObj.userId))
+        this.resetPwdData(params)
       }
-      this.delData(params)
     },
     commonCancel () {
       this.modalStatus = false
     },
+    // 启用 关闭/接口
+    getSwitchStatus (params) {
+      this.$get('metroapi/user/operation',params).then(res=>{
+        if (res.httpCode == 1 ){
+          if (params.enabled == 0) {
+            this.rowObj.isEnable = 0
+          } else {
+            this.rowObj.isEnable = 1
+          }
+          this.modalStatus = false
+        } else {
+          this.rowObj.isEnable = 0
+          this.$Message.info(res.msg)
+        }
+      })
+    },
     // 删除接口
     delData (params) {
-      this.$get('metroapi/equipment/delEquipment',params).then(res=>{
+      this.$get('metroapi/user/operation',params).then(res=>{
+        if (res.httpCode == 1 ){
+          this.modalStatus = false
+          this.$Message.info(res.msg)
+          this.getTableData()
+        } else {
+          this.$Message.info(res.msg)
+        }
+      })
+    },
+    // 重置密码
+    resetPwdData (params) {
+      this.$put('metroapi/user/intial',params).then(res=>{
         if (res.httpCode == 1 ){
           this.modalStatus = false
           this.$Message.info(res.msg)
@@ -688,18 +651,18 @@ export default {
   display: flex;
   align-items: center;
    .ivu-select {
-     width: 150px;
+     width: 165px;
      height: 32px;
    }
    .ivu-select-single .ivu-select-selection {
      height: 100%;
    }
    >>> .ivu-input {
-     width: 165px;
+     width: 155px;
      height: 32px;
    }
    >>> .ivu-date-picker-editor .ivu-input {
-     width: 210px;
+     width: 315px;
    }
    >>> .ivu-input-prefix, >>> .ivu-input-suffix {
      height: 32px;
@@ -722,6 +685,10 @@ export default {
   display: flex;
   flex-wrap: wrap;
 }
+.common-form-modal {
+  display: flex;
+  flex-direction: column;
+}
 >>> .common-form-list .ivu-form-item {
   margin-bottom: 10px;
 }
@@ -779,90 +746,25 @@ export default {
     color #409EFF;
   }
 }
->>> .modal-tabs-item {
-  margin-top: 10px;
-}
->>> .common-modal-top-text {
-  font-size: 14px;
-  font-weight: bold;
-  color: #29A0FF;
-  line-height: 42px;
-  border-left: 3px solid #1590F1;
-  padding-left: 12px;
-}
->>> .common-modal-content {
-  display: flex;
-  width: 100%;
-  justify-content: space-between;
-  flex-wrap: wrap;
-  margin-bottom: 15px;
-  border-right: 1px solid #21437B;
+.common-form-item-text {
+  font-size: 11px;
+  color: #85A3D4;
 }
->>> .modal-content-item {
-  width: 50%;
-  display: flex;
-}
->>> .item-especial {
-  width: 100%;
-}
->>> .modal-content-item-name {
-  width: 50%;
-  height: 45px;
-  line-height: 45px;
-  background: #13305F;
-  border-top: 1px solid #21437B;
-  border-left: 1px solid #21437B;
-  font-size: 14px;
-  color: #F5F5F5;
-  padding-left: 20px;
-}
->>> .modal-content-item-value {
-  width: 50%;
-  height: 45px;
-  line-height: 45px;
-  background: #06214D;
-  border-top: 1px solid #21437B;
-  border-left: 1px solid #21437B;
-  font-size: 14px;
-  color: #F5F5F5;
-  padding-left: 20px;
-}
->>> .item-especial .modal-content-item-name{
-  width: 25%;
-  height: 45px;
-  line-height: 45px;
-  border-bottom: 1px solid #21437B;
-}
->>> .item-especial .modal-content-item-value{
-  width: 75%;
-  height: 45px;
-  line-height: 45px;
-  border-bottom: 1px solid #21437B;
-}
->>> .item-especial-bot .modal-content-item-name {
-  border-bottom: 1px solid #21437B;
-}
->>> .item-especial-bot .modal-content-item-value {
-  border-bottom: 1px solid #21437B;
+.common-form-detail-text {
+  color: #fff;
+  font-size: 14PX;
 }
-/deep/ .ivu-input::-webkit-input-placeholder{
+/* 对话框里的input里的placeholder样式修改 */
+/deep/ .ivu-input::-webkit-input-placeholder , /deep/ .ivu-input-number-input::-webkit-input-placeholder{
   color: #718EBD;
 }
-/deep/ .ivu-input::-moz-placeholder{   /* Mozilla Firefox 19+ */
+/deep/ .ivu-input::-moz-placeholder, /deep/ .ivu-input-number-input::-webkit-input-placeholder{   /* Mozilla Firefox 19+ */
   color: #718EBD;
 }
-/deep/ .ivu-input::-moz-placeholder{    /* Mozilla Firefox 4 to 18 */
-  color: #718EBD;
+/deep/ .ivu-input::-moz-placeholde, /deep/ .ivu-input-number-input::-webkit-input-placeholderr{    /* Mozilla Firefox 4 to 18 */
+ color: #718EBD;
 }
-/deep/ .ivu-input::-ms-input-placeholder{  /* Internet Explorer 10-11 */
+/deep/ .ivu-input::-ms-input-placeholder, /deep/ .ivu-input-number-input::-webkit-input-placeholder{  /* Internet Explorer 10-11 */
   color: #718EBD;
 }
->>> .modal-content-item-value .ivu-tooltip {
-  width: 100%;
-}
->>> .modal-content-item-value .ivu-tooltip-rel {
-  overflow: hidden;
-  text-overflow:ellipsis; 
-  white-space: nowrap;
-}
 </style>

+ 1 - 1
vue.config.js

@@ -7,7 +7,7 @@ module.exports = {
       open: false,//配置自动启动浏览器 
       proxy: { // 设置代理
       '/metroapi': {
-        target: 'http://192.168.20.58:8088',// http://192.168.20.58:8086 http://192.168.20.188:8088
+        target: 'http://192.168.20.188:8088',// http://192.168.20.58:8086 http://192.168.20.188:8088
         changeOrigin: true, //允许跨域
         pathRewrite: {
             '^/metroapi': ''