Explorar o código

Merge remote-tracking branch 'origin/master'

不吃鱼 %!s(int64=2) %!d(string=hai) anos
pai
achega
8430c2c425

+ 1 - 1
chuanyi-admin/src/router/index.js

@@ -87,7 +87,7 @@ export const constantRoutes = [
         path: 'role/:userId(\\d+)',
         component: () => import('@/views/system/role/user-auth'),
         name: 'AuthRole',
-        meta: { title: '分配角色', activeMenu: '/system/role' }
+        meta: { title: '分配用户', activeMenu: '/system/role' }
       }
     ]
   },

+ 5 - 2
chuanyi-admin/src/views/system/role/user-auth.vue

@@ -60,10 +60,10 @@
         <el-button
           type="warning"
           plain
-          icon="el-icon-close"
+          icon="el-icon-back"
           size="mini"
           @click="handleClose"
-        >关闭</el-button>
+        >返回</el-button>
       </el-col>
     </el-row>
 
@@ -209,6 +209,9 @@ export default {
       getUserListById(this.queryParams).then(res => {
         if (res.code === 200) {
           const data = res.data
+          data.userList.forEach(item => {
+            item.lastLoginTime ? item.lastLoginTime : item.lastLoginTime = '暂未登录'
+          })
           this.userList = data.userList
           this.total = data.count
           this.loading = false

+ 2 - 2
chuanyi-admin/src/views/system/role/user-menu.vue

@@ -28,10 +28,10 @@
         <el-button
           type="warning"
           plain
-          icon="el-icon-close"
+          icon="el-icon-back"
           size="mini"
           @click="handleClose"
-        >关闭</el-button>
+        >返回</el-button>
       </el-col>
     </el-row>
 

+ 3 - 0
chuanyi-admin/src/views/system/role/user-select.vue

@@ -123,6 +123,9 @@ export default {
       getUserList(this.queryParams).then(res => {
         if (res.code === 200) {
           const data = res.data
+          data.userList.forEach(item => {
+            item.lastLoginTime ? item.lastLoginTime : item.lastLoginTime = '暂未登录'
+          })
           this.userList = data.userList
           this.total = data.count
         }

+ 30 - 0
chuanyi_client2/src/api/datasource.js

@@ -105,6 +105,36 @@ export function getAllItemGroup() {
 }
 
 /**
+ * 获取组配置详细信息
+ * @param id
+ * @returns {AxiosPromise}
+ */
+export function getItemGroupById(id) {
+    return request({
+        url: '/itemGroup/getItemGroupById/' + id,
+        headers: {
+            isToken: true
+        },
+        method: 'get'
+    })
+}
+
+/**
+ * 删除组配置
+ * @param id
+ * @returns {AxiosPromise}
+ */
+export function delItemGroupById(id) {
+    return request({
+        url: '/itemGroup/delItemGroupById/' + id,
+        headers: {
+            isToken: true
+        },
+        method: 'post'
+    })
+}
+
+/**
  * 保存组配置
  * @param data
  * @returns {AxiosPromise}

+ 1 - 0
chuanyi_client2/src/assets/icons/svg/file-bg.svg

@@ -0,0 +1 @@
+<svg t="1669706574535" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="101055" width="16" height="16"><path d="M750.933333 512c0-20.48 13.653333-34.133333 34.133334-34.133333s34.133333 13.653333 34.133333 34.133333v273.066667c0 58.026667-44.373333 102.4-102.4 102.4H307.2c-58.026667 0-102.4-44.373333-102.4-102.4V238.933333c0-58.026667 44.373333-102.4 102.4-102.4h290.133333c20.48 0 40.96 10.24 51.2 23.893334l160.426667 191.146666c13.653333 13.653333 10.24 37.546667-3.413333 47.786667-13.653333 13.653333-37.546667 10.24-47.786667-3.413333L597.333333 204.8H307.2c-20.48 0-34.133333 13.653333-34.133333 34.133333v546.133334c0 20.48 13.653333 34.133333 34.133333 34.133333h409.6c20.48 0 34.133333-13.653333 34.133333-34.133333v-273.066667z" fill="#2D3545" p-id="101056"></path><path d="M580.266667 204.8c-20.48 0-34.133333-13.653333-34.133334-34.133333s13.653333-34.133333 34.133334-34.133334c37.546667 0 68.266667 30.72 68.266666 68.266667v136.533333h136.533334c20.48 0 34.133333 13.653333 34.133333 34.133334s-13.653333 34.133333-34.133333 34.133333h-136.533334c-37.546667 0-68.266667-30.72-68.266666-68.266667V204.8z" fill="#2D3545" p-id="101057"></path><path d="M375.466667 375.466667c-20.48 0-34.133333-13.653333-34.133334-34.133334s13.653333-34.133333 34.133334-34.133333h102.4c20.48 0 34.133333 13.653333 34.133333 34.133333s-13.653333 34.133333-34.133333 34.133334h-102.4zM375.466667 546.133333c-20.48 0-34.133333-13.653333-34.133334-34.133333s13.653333-34.133333 34.133334-34.133333h273.066666c20.48 0 34.133333 13.653333 34.133334 34.133333s-13.653333 34.133333-34.133334 34.133333h-273.066666zM375.466667 716.8c-20.48 0-34.133333-13.653333-34.133334-34.133333s13.653333-34.133333 34.133334-34.133334h273.066666c20.48 0 34.133333 13.653333 34.133334 34.133334s-13.653333 34.133333-34.133334 34.133333h-273.066666z" fill="#005CFF" p-id="101058"></path></svg>

+ 1 - 0
chuanyi_client2/src/assets/icons/svg/group.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1669705442653" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="45439" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><path d="M531.500522 483.194435L193.446957 301.234087l23.596521-44.432696 314.457044 169.405218 314.501565-169.405218 23.552 44.432696-338.053565 181.960348z m0 0" fill="#2B3B95" p-id="45440"></path><path d="M531.500522 884.736l-351.365565-189.261913V264.102957l351.365565-189.217392 351.365565 189.217392v431.37113l-351.365565 189.261913z m-301.100522-219.091478l301.100522 162.103652 301.189565-162.103652V293.977043l-301.189565-162.148173-301.100522 162.148173v371.667479z m0 0" fill="#2B3B95" p-id="45441"></path><path d="M506.434783 454.834087h50.176v401.586087h-50.176zM583.323826 496.150261l228.307478-126.130087v276.836174l-228.307478 117.225739z" fill="#2B3B95" p-id="45442"></path></svg>

+ 1 - 0
chuanyi_client2/src/assets/icons/svg/groups.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1669704681048" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9575" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><path d="M912.027826 661.993739l-352.300522 211.389218a70.077217 70.077217 0 0 1-35.216695 8.770782c-12.733217 0-25.510957-2.938435-35.261218-8.770782l-352.300521-211.389218c-19.456-11.664696-19.456-30.630957 0-42.25113l59.748173-35.84 271.84974 163.127652c15.62713 9.305043 35.439304 14.425043 55.963826 14.425043 20.48 0 40.292174-5.12 55.919304-14.425043l271.849739-163.127652 59.748174 35.84c19.456 11.664696 19.456 30.586435 0 42.25113z" fill="#2B3B94" p-id="9576"></path><path d="M912.027826 501.092174l-352.300522 211.433739a70.077217 70.077217 0 0 1-35.216695 8.770783c-12.733217 0-25.510957-2.938435-35.261218-8.770783l-352.300521-211.433739c-19.456-11.664696-19.456-30.630957 0-42.251131L196.697043 422.956522l271.84974 163.127652c15.62713 9.394087 35.439304 14.514087 55.963826 14.514087 20.48 0 40.292174-5.12 55.919304-14.514087L852.324174 422.956522l59.748174 35.884521c19.411478 11.664696 19.411478 30.630957-0.044522 42.251131z" fill="#2B3B94" p-id="9577"></path><path d="M912.027826 340.23513l-352.300522 211.43374a70.077217 70.077217 0 0 1-35.216695 8.770782c-12.733217 0-25.510957-2.938435-35.261218-8.770782L136.94887 340.23513c-19.456-11.620174-19.456-30.630957 0-42.25113l352.300521-211.433739c9.750261-5.832348 22.528-8.726261 35.261218-8.726261 12.688696 0 25.466435 2.893913 35.216695 8.726261l352.300522 211.433739c19.456 11.664696 19.456 30.630957 0 42.25113z" fill="#2B3B94" p-id="9578"></path></svg>

+ 156 - 56
chuanyi_client2/src/components/HeaderMain/index.vue

@@ -7,7 +7,7 @@
       </div>
       <div>
         <el-tree node-key="id"
-                 class="filter-tree group-tree"></el-tree>
+                 class="cy-group-tree"></el-tree>
       </div>
     </el-tab-pane>
     <el-tab-pane>
@@ -16,15 +16,24 @@
         <div class="nav-title">数据组配置</div>
       </div>
       <div>
-        <el-tree class="filter-tree group-tree"
-                 :data="groupDataList"
-                 :indent="0"
+<!--        :data="groupDataList"-->
+        <el-tree class="cy-group-tree"
+                 ref="groupTree"
+                 :indent="10"
                  node-key="id"
+                 :load="loadGroupNode"
+                 :props="groupProps"
+                 lazy
                  @node-contextmenu="rightNodeEvent"
                  @node-click="handleNodeClick"
-                 :highlight-current="false"
-                 :expand-on-click-node="false"
-                 :default-expand-all="true"></el-tree>
+                 :expand-on-click-node="false">
+              <span class="custom-tree-node" slot-scope="{ node, data }">
+                <svg-icon v-if="data.itemName" icon-class="file-bg"/>
+                <svg-icon v-else-if="data.id == -1" icon-class="groups"/>
+                <svg-icon v-else icon-class="group"/>
+                <span :title='data.groupName || data.itemName' style="margin-left: 2px;">{{ data.groupName || data.itemName }}</span>
+              </span>
+        </el-tree>
       </div>
     </el-tab-pane>
 
@@ -35,6 +44,14 @@
       <li @click="createGroupEvent">添加组</li>
     </ul>
 
+    <!-- 数据组列表右键操作 -->
+    <ul v-show="visibleGroupChildMenu"
+        :style="{ left: menuLeft + 'px', top: menuTop + 'px' }"
+        class="contextmenu contextmenu-black">
+      <li @click="updateGroup">修改</li>
+      <li @click="delGroup">删除</li>
+    </ul>
+
     <!-- 添加组配置弹出层 -->
     <el-dialog
         :title="groupDialogTitle"
@@ -204,9 +221,11 @@
 
 <script>
 import {
+  delDataSourceById,
+  delItemGroupById,
   getAllDataSource,
   getAllItemGroup,
-  getDataSourceItemTree,
+  getDataSourceItemTree, getItemGroupById,
   saveOrUpdateDataSource,
   saveOrUpdateItemGroup
 } from "@/api/datasource";
@@ -224,15 +243,21 @@ export default {
       labelPosition: 'top',
       // 组配置右键布局显示状态
       visibleGroupMenu: false,
+      visibleGroupChildMenu: false,
       // 右键布局显示位置
       menuLeft: 0,
       // 右键布局显示位置
       menuTop: 0,
       groupDataList: [{
-        id: 0,
-        label: '数据组列表',
+        id: -1,
+        groupName: '数据组列表',
         children: []
       }],
+      chooseGroupData: null,
+      chooseGroupParentNode: null,
+      groupProps: {
+        isLeaf: 'leaf'
+      },
       // 读取模式
       readModeList: [],
       // 数据源
@@ -275,11 +300,17 @@ export default {
         document.body.removeEventListener('click', this.closeMenu)
       }
     },
+    visibleGroupChildMenu(value) {
+      if (value) {
+        document.body.addEventListener('click', this.closeMenu)
+      } else {
+        document.body.removeEventListener('click', this.closeMenu)
+      }
+    }
   },
   computed: {
   },
   created() {
-    this.getGroupList()
   },
   methods: {
     /** 数据项搜索过滤 */
@@ -291,16 +322,48 @@ export default {
     handleNodeClick(data, node, target) {
       this.closeMenu()
     },
+    /** 懒加载查询组配置文件 */
+    loadGroupNode(node, resolve) {
+      if (node.level === 0) {
+        return resolve(this.groupDataList)
+      }
+      if (node.data.id == -1) {
+        getAllItemGroup().then(res => {
+          resolve(res.data)
+        }).catch((e) => {
+          resolve([])
+        })
+      } else {
+        getItemGroupById(node.data.id).then(res => {
+          if (!res.data) {
+            resolve([])
+            return
+          }
+          let arr = res.data.itemList
+          for (let i in arr) {
+            arr[i].leaf = true
+          }
+          resolve(arr)
+        }).catch((e) => {
+          resolve([])
+        })
+      }
+    },
     /** 数据组配置右键菜单事件 */
     rightNodeEvent(event, data, node, target) {
       this.closeMenu()
       // 判断是否最后一级菜单
-      if ((!data.children || data.children.length == 0) && data.id != 0) {
-        return
-      }
       this.menuLeft = 80
-      this.menuTop = 30
-      this.visibleGroupMenu = true
+      if (data.id == -1) {
+        this.menuTop = 30
+        this.visibleGroupMenu = true
+        this.chooseGroupParentNode = node
+      } else if (!data.itemName) {
+        this.menuTop = 30 + event.layerY
+        this.visibleGroupChildMenu = true
+        this.chooseGroupData = data
+        this.chooseGroupParentNode = node.parent
+      }
     },
     /** 添加数据组事件 */
     createGroupEvent() {
@@ -331,7 +394,10 @@ export default {
             confirmButtonText: '确定',
             callback: action => {
               this.handleCancel()
+              this.chooseItemDataList = []
+              this.chooseItemDataView = false
               // 刷新组列表
+              this.refreshGroupData()
             }
           })
           return
@@ -348,9 +414,59 @@ export default {
         })
       })
     },
+    /** 更新组信息 */
+    updateGroup() {
+      console.log(this.chooseGroupData)
+    },
+    /** 删除组信息 */
+    delGroup() {
+      let _this = this
+      if (!this.chooseGroupData) {
+        _this.$message({
+          message: '删除失败!',
+          type: 'error'
+        })
+        return
+      }
+      _this.$confirm('您确定要删除该数据组吗?', '温馨提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消'
+      }).then(() => {
+        const loading = showLoading(_this, '删除中,请稍候···')
+        delItemGroupById(this.chooseGroupData.id).then(res => {
+          loading.close()
+          // 刷新数据组数据
+          _this.refreshGroupData()
+          _this.$message({
+            message: res.data,
+            type: 'success'
+          })
+        }).catch((e) => {
+          loading.close()
+          _this.$message({
+            message: '删除失败!',
+            type: 'error'
+          })
+        })
+      }).catch(() => {
+      })
+    },
+    /** 刷新数据组列表 */
+    refreshGroupData() {
+      if (this.chooseGroupParentNode) {
+        let node = this.chooseGroupParentNode
+        if (node) {
+          node.loaded = false
+          node.expand()
+        }
+      }
+    },
     /** 选择数据源值改变事件 */
     dataSourceChange(val) {
       this.groupBasicForm.dataSourceId = val
+      this.chooseItemDataList = []
+      this.chooseItemDataListByTree = []
+      this.chooseItemDataView = false
     },
     /** 读取模式值改变事件 */
     readModeChange(val) {
@@ -374,15 +490,6 @@ export default {
         console.error(e)
       })
     },
-    /** 查询组列表 */
-    getGroupList() {
-      getAllItemGroup().then(res => {
-        console.log(res)
-        this.groupDataList.children = res.data
-      }).catch((e) => {
-        console.error(e)
-      })
-    },
     /** 添加数据项 */
     addDataItem() {
       let id = this.groupBasicForm.dataSourceId
@@ -604,6 +711,7 @@ export default {
     /** 关闭右键弹出层 */
     closeMenu() {
       this.visibleGroupMenu = false
+      this.visibleGroupChildMenu = false
     },
     /** 弹出层取消事件 */
     handleCancel() {
@@ -700,37 +808,27 @@ export default {
   padding: 0 25px 30px;
 }
 
-.group-tree {
+.cy-group-tree {
   background: #646464;
   color: #ffffff;
-}
-
-.group-tree .el-tree-node__content .el-icon-caret-right:before {
-  content: url("~@/assets/images/groups.png");
-}
 
-.group-tree .el-tree-node__children .el-tree-node__content .el-icon-caret-right:before {
-  content: url("~@/assets/images/group.png");
-}
-
-.group-tree .el-tree-node__content:hover {
-  background-color: transparent;
-}
-
-.group-tree .el-tree-node__expand-icon.expanded {
-  transform: rotate(0);
-}
+  .el-tree-node:focus > .el-tree-node__content {
+    background-color: #7e7f7f;
+  }
 
-.group-tree .el-tree-node__expand-icon.is-leaf {
-  margin-left: 20px;
-}
+  .el-tree-node__content:hover {
+    background-color: transparent;
+  }
 
-.group-tree .el-tree-node:focus > .el-tree-node__content {
-  background-color: #7e7f7f;
-}
+  .custom-tree-node {
+    display: flex;
+    align-items: center;
+  }
 
-.group-tree .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
-  background-color: #7e7f7f;
+  .svg-icon {
+    width: 20px;
+    height: 20px;
+  }
 }
 
 .cy-form {
@@ -760,12 +858,14 @@ export default {
 
 .cy-transform-data {
   width: calc(50% - 60px);
-}
 
-.custom-tree-node {
-  white-space: nowrap;
-  text-overflow: ellipsis;
-  overflow: hidden;
+  .cy-line {
+    .custom-tree-node {
+      white-space: nowrap;
+      text-overflow: ellipsis;
+      overflow: hidden;
+    }
+  }
 }
 
 .cy-item-tag {
@@ -773,4 +873,4 @@ export default {
   margin-top: -7px;
   margin-right: 10px;
 }
-</style>
+</style>

+ 1 - 1
chuanyi_client2/src/components/HeaderPersonal/index.vue

@@ -2,7 +2,7 @@
   <div class="cy-person">
     <el-dropdown>
       <div class="menu-userinfo">
-        <el-avatar shape="square" size="small" :src="avatar" @error="errorHandler">
+        <el-avatar shape="square" size="small" @error="errorHandler">
           <img :src="avatarDefault"/>
         </el-avatar>
         <span>{{ name }}</span>

+ 1 - 0
chuanyi_client2/src/views/index.vue

@@ -11,6 +11,7 @@
           </template>
           <template slot="paneR">
             <header-personal></header-personal>
+            <router-view></router-view>
           </template>
         </split-pane>
       </el-main>