当前位置:   article > 正文

vue中使用elementui实现对树组件tree右键增删改功能_element tree 右键功能

element tree 右键功能

功能描述:

1、自定义树节点前展开收起图标

2、可对节点数据进行模糊查询

3、右击第一级节点可以进行同级节点增加

4、双击节点或点击修改节点 都可以对节点获取焦点并进行修改,回车修改成功

5、可对节点进行拖拽,实现节点移动功能 

6、右击节点可进行增删改

 效果图:

 html布局:

 html代码

  1. <div class="tree-container">
  2. <el-input placeholder="输入关键字进行过滤" v-model="filterText" class="search">
  3. </el-input>
  4. <el-tree :data="treeData" node-key="id" default-expand-all @node-click="handleLeftclick"
  5. @node-drag-start="handleDragStart" @node-drag-enter="handleDragEnter" @node-drag-leave="handleDragLeave"
  6. @node-drag-over="handleDragOver" @node-drag-end="handleDragEnd" @node-drop="handleDrop"
  7. @node-contextmenu="rightClick" :filter-node-method="filterNode" draggable :allow-drop="allowDrop"
  8. :allow-drag="allowDrag" ref="tree" class="tree-line">
  9. <span class="slot-t-node" slot-scope="{ node, data }" @dblclick="editNode(data)">
  10. <span v-show="!data.isEdit">
  11. <span :class="[data.id >= 99 ? 'slot-t-node--label' : '']">
  12. <i v-if="data.type == 'catalog'" class="el-icon-folder" />
  13. <i v-if="data.type == 'menu'" class="el-icon-tickets" />
  14. <i v-if="data.type == 'submenu'" class="el-icon-document" />
  15. <span> {{ node.label }}</span>
  16. </span>
  17. </span>
  18. <span v-show="data.isEdit">
  19. <el-input class="slot-t-input" size="mini" autofocus v-model="data.label" :ref="'slotTreeInput' + data.id"
  20. @blur.stop="NodeBlur(node, data)" @keydown.native.enter="NodeBlur(node, data)"></el-input>
  21. </span>
  22. </span>
  23. </el-tree>
  24. <div class="box-menu" v-show="menuVisible" :style="{ left: menu_left + 'px', top: menu_top + 'px' }">
  25. <div @click="addSameLevelNode(0)" v-show="firstLevel">
  26. <i class="el-icon-circle-plus-outline"></i>&nbsp;&nbsp;同级增加
  27. </div>
  28. <div class="add" @click="addChildNode()">
  29. <i class="el-icon-circle-plus-outline"></i>&nbsp;&nbsp;子级增加
  30. </div>
  31. <div class="delete" @click="deleteNode()">
  32. <i class="el-icon-remove-outline"></i>&nbsp;&nbsp;删除节点
  33. </div>
  34. <div class="edit" @click="editNode()">
  35. <i class="el-icon-edit"></i>&nbsp;&nbsp;修改节点
  36. </div>
  37. </div>
  38. </div>

CSS样式

  1. <style scoped lang="less">
  2. .el-tree>.is-leaf {
  3. color: transparent;
  4. }
  5. .tree-container /deep/ .el-tree-node__expand-icon.expanded {
  6. -webkit-transform: rotate(0deg);
  7. transform: rotate(0deg);
  8. }
  9. .tree-container /deep/ .el-tree-node__expand-icon.expanded {
  10. -webkit-transform: rotate(0deg);
  11. transform: rotate(0deg);
  12. }
  13. .tree-container /deep/ .el-icon-caret-right:before {
  14. background: url("../../assets/node-collapse.png") no-repeat;
  15. content: '';
  16. display: block;
  17. width: 12px;
  18. height: 12px;
  19. font-size: 12px;
  20. background-size: 10px;
  21. }
  22. /*
  23. //有子节点 且已展开*/
  24. .tree-container /deep/ .el-tree-node__expand-icon.expanded.el-icon-caret-right:before {
  25. background: url("../../assets/node-expand.png") no-repeat;
  26. content: '';
  27. display: block;
  28. width: 12px;
  29. height: 12px;
  30. font-size: 12px;
  31. background-size: 10px;
  32. }
  33. /* //没有子节点*/
  34. .tree-container /deep/ .el-tree-node__expand-icon.is-leaf::before {
  35. background: transparent no-repeat 0 3px;
  36. content: '';
  37. display: block;
  38. width: 12px;
  39. height: 12px;
  40. font-size: 12px;
  41. background-size: 10px;
  42. }
  43. /* 点击节点时的选中颜色 */
  44. .tree-container /deep/.el-tree-node.is-current>.el-tree-node__content {
  45. color: #3D5ECC !important;
  46. }
  47. .tree-container /deep/ .el-tree-node__expand-icon {
  48. margin-left: 15px;
  49. // padding: 0px;
  50. }
  51. .tree-container /deep/ .el-tree-node__expand-icon.is-leaf {
  52. margin-left: 0px;
  53. }
  54. .tree-container /deep/ .el-tree-node {
  55. position: relative;
  56. padding-left: 16px;
  57. }
  58. .tree-container /deep/ .el-tree-node__children {
  59. padding-left: 16px;
  60. }
  61. .tree-container /deep/ .el-tree>.el-tree-node:before {
  62. border-left: none;
  63. }
  64. .tree-container /deep/ .el-tree>.el-tree-node:after {
  65. border-top: none;
  66. }
  67. .tree-container /deep/ .el-tree>.el-tree-node:before {
  68. border-left: none;
  69. }
  70. .tree-container /deep/ .el-tree>.el-tree-node:after {
  71. border-top: none;
  72. }
  73. .tree-container /deep/ .el-tree-node:before {
  74. content: "";
  75. left: 10px;
  76. position: absolute;
  77. right: auto;
  78. border-width: 1px;
  79. }
  80. .tree-container /deep/ .el-tree-node:after {
  81. content: "";
  82. left: 10px;
  83. position: absolute;
  84. right: auto;
  85. border-width: 1px;
  86. }
  87. .tree-container /deep/ .el-tree-node:before {
  88. border-left: 1px dashed #ccc;
  89. bottom: 0px;
  90. height: 100%;
  91. top: -19px;
  92. width: 1px;
  93. }
  94. .tree-container /deep/ .el-tree-node:after {
  95. border-top: 1px dashed #ccc;
  96. height: 25px;
  97. top: 20px;
  98. width: 20px;
  99. }
  100. .el-tree-node :last-child:before {
  101. height: 40px;
  102. }
  103. .tree-container {
  104. margin: 10px;
  105. }
  106. .tree-container /deep/ .el-tree .el-tree-node {
  107. position: relative;
  108. }
  109. .tree-container /deep/ .el-tree-node .el-tree-node__content {
  110. height: 34px;
  111. padding-left: 0px !important;
  112. border: none;
  113. }
  114. .tree-container /deep/ .el-tree-node .el-tree-node__content::before {
  115. border-left: 1px dashed #ccc;
  116. height: 100%;
  117. top: 0;
  118. width: 1px;
  119. margin-left: 1px;
  120. margin-top: 0px;
  121. z-index: 8;
  122. }
  123. .tree-container /deep/ .el-tree-node .el-tree-node__children .el-tree-node__content::before {
  124. border-left: 0px dashed #ccc;
  125. height: 100%;
  126. top: 0;
  127. width: 1px;
  128. margin-left: 1px;
  129. margin-top: 0px;
  130. z-index: 8;
  131. }
  132. .tree-container /deep/ .el-tree-node .el-tree-node__content::after {
  133. border-top: 1px dashed #ccc;
  134. height: 1px;
  135. top: 18px;
  136. width: 13px;
  137. margin-left: 1px;
  138. z-index: 8;
  139. }
  140. .tree-container /deep/ .el-tree-node .el-tree-node__children .el-tree-node__content::after {
  141. border-top: 0px dashed #ccc;
  142. }
  143. .tree-container .el-tree-node .el-tree-node__content::before,
  144. .tree-container .el-tree-node .el-tree-node__content::after {
  145. content: "";
  146. position: absolute;
  147. right: auto;
  148. }
  149. .el-tree {
  150. width: 20%;
  151. margin-top: 10px;
  152. }
  153. .search {
  154. width: 20%;
  155. cursor: pointer;
  156. }
  157. .box-menu {
  158. width: 150px;
  159. position: absolute;
  160. z-index: 1000;
  161. background-color: #fff;
  162. box-shadow: 0px 0px 10px #ccc, 0px 0px 20px #ccc, 0px 0px 30px #ccc;
  163. padding: 10px;
  164. div {
  165. cursor: pointer;
  166. line-height: 30px;
  167. }
  168. div:active {
  169. color: blue;
  170. }
  171. }
  172. </style>

输入框校验

  1. NodeBlur(Node, data) {
  2. console.log(Node, data)
  3. if (data.label.length === 0) {
  4. this.$message.error('菜单名不可为空!')
  5. return false
  6. } else {
  7. if (data.isEdit) {
  8. this.$set(data, 'isEdit', false)
  9. console.log(data.isEdit)
  10. }
  11. this.$nextTick(() => {
  12. this.$refs['slotTreeInput' + data.id].$refs.input.focus()
  13. })
  14. }
  15. },

查询功能

  1. // 查询
  2. filterNode(value, data) {
  3. if (!value) return true
  4. return data.label.indexOf(value) !== -1
  5. },
  6. watch: {
  7. filterText(val) {
  8. this.$refs.tree.filter(val)
  9. }
  10. },

拖拽功能

  1. allowDrop(draggingNode, dropNode, type) {
  2. if (dropNode.data.label === '二级 3-1') {
  3. return type !== 'inner'
  4. } else {
  5. return true
  6. }
  7. },
  8. allowDrag(draggingNode) {
  9. return draggingNode.data.label.indexOf('三级 3-2-2') === -1
  10. },
  11. handleDragStart(node, ev) {
  12. console.log('drag start', node)
  13. },
  14. handleDragEnter(draggingNode, dropNode, ev) {
  15. console.log('tree drag enter: ', dropNode.label)
  16. },
  17. handleDragLeave(draggingNode, dropNode, ev) {
  18. console.log('tree drag leave: ', dropNode.label)
  19. },
  20. handleDragOver(draggingNode, dropNode, ev) {
  21. console.log('tree drag over: ', dropNode.label)
  22. },
  23. handleDragEnd(draggingNode, dropNode, dropType, ev) {
  24. console.log('tree drag end: ', dropNode && dropNode.label, dropType)
  25. },
  26. handleDrop(draggingNode, dropNode, dropType, ev) {
  27. console.log('tree drop: ', dropNode.label, dropType)
  28. },

鼠标事件

  1. // 鼠标右击事件
  2. rightClick(event, object, Node, element) {
  3. console.log(event, object)
  4. this.currentData = object
  5. this.currentNode = Node
  6. if (Node.level === 1) {
  7. this.firstLevel = true
  8. } else {
  9. this.firstLevel = false
  10. }
  11. this.menuVisible = true
  12. document.addEventListener('click', this.foo)
  13. // 将菜单显示在鼠标点击旁边定位
  14. this.menu_left = event.clientX -140;
  15. this.menu_top = event.clientY - 40;
  16. },
  17. // 鼠标左击事件
  18. handleLeftclick(data, node) {
  19. this.foo()
  20. },
  21. // 取消鼠标监听事件 菜单栏
  22. foo() {
  23. this.menuVisible = false
  24. // 要及时关掉监听,不关掉的是一个坑,不信你试试,虽然前台显示的时候没有啥毛病,加一个alert你就知道了
  25. document.removeEventListener('click', this.foo)
  26. },

 增加同级节点事件

  1. // 增加同级节点事件
  2. addSameLevelNode() {
  3. let id = Math.ceil(Math.random() * 100)
  4. var data = { id: id, label: '新增节点' }
  5. this.$refs.tree.append(data, this.currentNode.parent)
  6. },

增加子级节点事件 

  1. // 增加子级节点事件
  2. addChildNode() {
  3. console.log(this.currentData)
  4. console.log(this.currentNode)
  5. if (this.currentNode.level >= 3) {
  6. this.$message.error('最多只支持三级!')
  7. return false
  8. }
  9. let id = Math.ceil(Math.random() * 100)
  10. var data = { id: id, label: '新增节点' }
  11. this.$refs.tree.append(data, this.currentNode)
  12. },

删除节点

  1. // 删除节点
  2. deleteNode() {
  3. this.$refs.tree.remove(this.currentNode)
  4. },

编辑节点

  1. // 编辑节点
  2. editNode(data) {
  3. console.log(data)
  4. this.currentData = data ? data : this.currentData
  5. if (!this.currentData.isEdit) {
  6. this.$set(this.currentData, 'isEdit', true)
  7. }
  8. // 获取焦点
  9. this.$nextTick(() => {
  10. this.$refs['slotTreeInput' + this.currentData.id].focus()
  11. })
  12. },

整体代码

  1. <template>
  2. <div class="tree-container">
  3. <el-input placeholder="输入关键字进行过滤" v-model="filterText" class="search">
  4. </el-input>
  5. <el-tree :data="treeData" node-key="id" default-expand-all @node-click="handleLeftclick"
  6. @node-drag-start="handleDragStart" @node-drag-enter="handleDragEnter" @node-drag-leave="handleDragLeave"
  7. @node-drag-over="handleDragOver" @node-drag-end="handleDragEnd" @node-drop="handleDrop"
  8. @node-contextmenu="rightClick" :filter-node-method="filterNode" draggable :allow-drop="allowDrop"
  9. :allow-drag="allowDrag" ref="tree" class="tree-line">
  10. <span class="slot-t-node" slot-scope="{ node, data }" @dblclick="editNode(data)">
  11. <span v-show="!data.isEdit">
  12. <span :class="[data.id >= 99 ? 'slot-t-node--label' : '']">
  13. <i v-if="data.type == 'catalog'" class="el-icon-folder" />
  14. <i v-if="data.type == 'menu'" class="el-icon-tickets" />
  15. <i v-if="data.type == 'submenu'" class="el-icon-document" />
  16. <span> {{ node.label }}</span>
  17. </span>
  18. </span>
  19. <span v-show="data.isEdit">
  20. <el-input class="slot-t-input" size="mini" autofocus v-model="data.label" :ref="'slotTreeInput' + data.id"
  21. @blur.stop="NodeBlur(node, data)" @keydown.native.enter="NodeBlur(node, data)"></el-input>
  22. </span>
  23. </span>
  24. </el-tree>
  25. <!-- <el-card class="box-card" ref="card" v-show="menuVisible">
  26. <div @click="addSameLevelNode()" v-show="firstLevel">
  27. <i class="el-icon-circle-plus-outline"></i>&nbsp;&nbsp;同级增加
  28. </div>
  29. <div class="add" @click="addChildNode()">
  30. <i class="el-icon-circle-plus-outline"></i>&nbsp;&nbsp;子级增加
  31. </div>
  32. <div class="delete" @click="deleteNode()">
  33. <i class="el-icon-remove-outline"></i>&nbsp;&nbsp;删除节点
  34. </div>
  35. <div class="edit" @click="editNode()">
  36. <i class="el-icon-edit"></i>&nbsp;&nbsp;修改节点
  37. </div>
  38. </el-card> -->
  39. <div class="box-menu" v-show="menuVisible" :style="{ left: menu_left + 'px', top: menu_top + 'px' }">
  40. <div @click="addSameLevelNode(0)" v-show="firstLevel">
  41. <i class="el-icon-circle-plus-outline"></i>&nbsp;&nbsp;同级增加
  42. </div>
  43. <div class="add" @click="addChildNode()">
  44. <i class="el-icon-circle-plus-outline"></i>&nbsp;&nbsp;子级增加
  45. </div>
  46. <div class="delete" @click="deleteNode()">
  47. <i class="el-icon-remove-outline"></i>&nbsp;&nbsp;删除节点
  48. </div>
  49. <div class="edit" @click="editNode()">
  50. <i class="el-icon-edit"></i>&nbsp;&nbsp;修改节点
  51. </div>
  52. </div>
  53. </div>
  54. </template>
  55. <script>
  56. export default {
  57. name: 'tree',
  58. data() {
  59. return {
  60. eleId: '',
  61. isShow: false,
  62. currentData: '',
  63. currentNode: '',
  64. menuVisible: false,
  65. firstLevel: false,
  66. filterText: '',
  67. maxexpandId: 4,
  68. menu_left: 0,
  69. menu_top: 0,
  70. treeData: [{
  71. id: 1,
  72. label: '一级 1',
  73. isEdit: false,
  74. type: 'catalog',
  75. children: [{
  76. id: 4,
  77. label: '二级 1-1',
  78. isEdit: false,
  79. type: 'menu',
  80. children: [{
  81. id: 9,
  82. label: '三级 1-1-1',
  83. isEdit: false,
  84. type: 'submenu',
  85. }, {
  86. id: 10,
  87. label: '三级 1-1-2',
  88. isEdit: false,
  89. type: 'submenu',
  90. }]
  91. }]
  92. }, {
  93. id: 2,
  94. label: '一级 2',
  95. isEdit: false,
  96. type: 'catalog',
  97. children: [{
  98. id: 5,
  99. label: '二级 2-1',
  100. isEdit: false,
  101. type: 'menu',
  102. }, {
  103. id: 6,
  104. label: '二级 2-2',
  105. isEdit: false,
  106. type: 'menu',
  107. }]
  108. }, {
  109. id: 3,
  110. label: '一级 3',
  111. isEdit: false,
  112. type: 'catalog',
  113. children: [{
  114. id: 7,
  115. label: '二级 3-1',
  116. isEdit: false,
  117. type: 'menu',
  118. }, {
  119. id: 8,
  120. label: '二级 3-2',
  121. isEdit: false,
  122. type: 'menu',
  123. children: [{
  124. id: 11,
  125. label: '三级 3-2-1',
  126. isEdit: false,
  127. type: 'submenu',
  128. }, {
  129. id: 12,
  130. label: '三级 3-2-2',
  131. isEdit: false,
  132. type: 'submenu',
  133. }, {
  134. id: 13,
  135. label: '三级 3-2-3',
  136. isEdit: false,
  137. type: 'submenu',
  138. }]
  139. }]
  140. }],
  141. defaultProps: {
  142. children: 'children',
  143. label: 'label'
  144. }
  145. }
  146. },
  147. methods: {
  148. NodeBlur(Node, data) {
  149. console.log(Node, data)
  150. if (data.label.length === 0) {
  151. this.$message.error('菜单名不可为空!')
  152. return false
  153. } else {
  154. if (data.isEdit) {
  155. this.$set(data, 'isEdit', false)
  156. console.log(data.isEdit)
  157. }
  158. this.$nextTick(() => {
  159. this.$refs['slotTreeInput' + data.id].$refs.input.focus()
  160. })
  161. }
  162. },
  163. // 查询
  164. filterNode(value, data) {
  165. if (!value) return true
  166. return data.label.indexOf(value) !== -1
  167. },
  168. allowDrop(draggingNode, dropNode, type) {
  169. if (dropNode.data.label === '二级 3-1') {
  170. return type !== 'inner'
  171. } else {
  172. return true
  173. }
  174. },
  175. allowDrag(draggingNode) {
  176. return draggingNode.data.label.indexOf('三级 3-2-2') === -1
  177. },
  178. // 鼠标右击事件
  179. rightClick(event, object, Node, element) {
  180. console.log(event, object)
  181. this.currentData = object
  182. this.currentNode = Node
  183. if (Node.level === 1) {
  184. this.firstLevel = true
  185. } else {
  186. this.firstLevel = false
  187. }
  188. this.menuVisible = true
  189. document.addEventListener('click', this.foo)
  190. // 将菜单显示在鼠标点击旁边定位
  191. this.menu_left = event.clientX -140;
  192. this.menu_top = event.clientY - 40;
  193. },
  194. // 鼠标左击事件
  195. handleLeftclick(data, node) {
  196. this.foo()
  197. },
  198. // 取消鼠标监听事件 菜单栏
  199. foo() {
  200. this.menuVisible = false
  201. // 要及时关掉监听,不关掉的是一个坑,不信你试试,虽然前台显示的时候没有啥毛病,加一个alert你就知道了
  202. document.removeEventListener('click', this.foo)
  203. },
  204. // 增加同级节点事件
  205. addSameLevelNode() {
  206. let id = Math.ceil(Math.random() * 100)
  207. var data = { id: id, label: '新增节点' }
  208. this.$refs.tree.append(data, this.currentNode.parent)
  209. },
  210. // 增加子级节点事件
  211. addChildNode() {
  212. console.log(this.currentData)
  213. console.log(this.currentNode)
  214. if (this.currentNode.level >= 3) {
  215. this.$message.error('最多只支持三级!')
  216. return false
  217. }
  218. let id = Math.ceil(Math.random() * 100)
  219. var data = { id: id, label: '新增节点' }
  220. this.$refs.tree.append(data, this.currentNode)
  221. },
  222. // 删除节点
  223. deleteNode() {
  224. this.$refs.tree.remove(this.currentNode)
  225. },
  226. // 编辑节点
  227. editNode(data) {
  228. console.log(data)
  229. this.currentData = data ? data : this.currentData
  230. if (!this.currentData.isEdit) {
  231. this.$set(this.currentData, 'isEdit', true)
  232. }
  233. // 获取焦点
  234. this.$nextTick(() => {
  235. this.$refs['slotTreeInput' + this.currentData.id].focus()
  236. })
  237. },
  238. handleDragStart(node, ev) {
  239. console.log('drag start', node)
  240. },
  241. handleDragEnter(draggingNode, dropNode, ev) {
  242. console.log('tree drag enter: ', dropNode.label)
  243. },
  244. handleDragLeave(draggingNode, dropNode, ev) {
  245. console.log('tree drag leave: ', dropNode.label)
  246. },
  247. handleDragOver(draggingNode, dropNode, ev) {
  248. console.log('tree drag over: ', dropNode.label)
  249. },
  250. handleDragEnd(draggingNode, dropNode, dropType, ev) {
  251. console.log('tree drag end: ', dropNode && dropNode.label, dropType)
  252. },
  253. handleDrop(draggingNode, dropNode, dropType, ev) {
  254. console.log('tree drop: ', dropNode.label, dropType)
  255. },
  256. },
  257. watch: {
  258. filterText(val) {
  259. this.$refs.tree.filter(val)
  260. }
  261. },
  262. mounted() {
  263. }
  264. }
  265. </script>
  266. <style scoped lang="less">
  267. .el-tree>.is-leaf {
  268. color: transparent;
  269. }
  270. .tree-container /deep/ .el-tree-node__expand-icon.expanded {
  271. -webkit-transform: rotate(0deg);
  272. transform: rotate(0deg);
  273. }
  274. .tree-container /deep/ .el-tree-node__expand-icon.expanded {
  275. -webkit-transform: rotate(0deg);
  276. transform: rotate(0deg);
  277. }
  278. .tree-container /deep/ .el-icon-caret-right:before {
  279. background: url("../../assets/node-collapse.png") no-repeat;
  280. content: '';
  281. display: block;
  282. width: 12px;
  283. height: 12px;
  284. font-size: 12px;
  285. background-size: 10px;
  286. }
  287. /*
  288. //有子节点 且已展开*/
  289. .tree-container /deep/ .el-tree-node__expand-icon.expanded.el-icon-caret-right:before {
  290. background: url("../../assets/node-expand.png") no-repeat;
  291. content: '';
  292. display: block;
  293. width: 12px;
  294. height: 12px;
  295. font-size: 12px;
  296. background-size: 10px;
  297. }
  298. /* //没有子节点*/
  299. .tree-container /deep/ .el-tree-node__expand-icon.is-leaf::before {
  300. background: transparent no-repeat 0 3px;
  301. content: '';
  302. display: block;
  303. width: 12px;
  304. height: 12px;
  305. font-size: 12px;
  306. background-size: 10px;
  307. }
  308. /* 点击节点时的选中颜色 */
  309. .tree-container /deep/.el-tree-node.is-current>.el-tree-node__content {
  310. color: #3D5ECC !important;
  311. }
  312. .tree-container /deep/ .el-tree-node__expand-icon {
  313. margin-left: 15px;
  314. }
  315. .tree-container /deep/ .el-tree-node__expand-icon.is-leaf {
  316. margin-left: 0px;
  317. }
  318. .tree-container /deep/ .el-tree-node {
  319. position: relative;
  320. padding-left: 16px;
  321. }
  322. .tree-container /deep/ .el-tree-node__children {
  323. padding-left: 16px;
  324. }
  325. .tree-container /deep/ .el-tree>.el-tree-node:before {
  326. border-left: none;
  327. }
  328. .tree-container /deep/ .el-tree>.el-tree-node:after {
  329. border-top: none;
  330. }
  331. .tree-container /deep/ .el-tree>.el-tree-node:before {
  332. border-left: none;
  333. }
  334. .tree-container /deep/ .el-tree>.el-tree-node:after {
  335. border-top: none;
  336. }
  337. .tree-container /deep/ .el-tree-node:before {
  338. content: "";
  339. left: 10px;
  340. position: absolute;
  341. right: auto;
  342. border-width: 1px;
  343. }
  344. .tree-container /deep/ .el-tree-node:after {
  345. content: "";
  346. left: 10px;
  347. position: absolute;
  348. right: auto;
  349. border-width: 1px;
  350. }
  351. .tree-container /deep/ .el-tree-node:before {
  352. border-left: 1px dashed #ccc;
  353. bottom: 0px;
  354. height: 100%;
  355. top: -19px;
  356. width: 1px;
  357. }
  358. .tree-container /deep/ .el-tree-node:after {
  359. border-top: 1px dashed #ccc;
  360. height: 25px;
  361. top: 20px;
  362. width: 20px;
  363. }
  364. .el-tree-node :last-child:before {
  365. height: 40px;
  366. }
  367. .tree-container {
  368. margin: 10px;
  369. }
  370. .tree-container /deep/ .el-tree .el-tree-node {
  371. position: relative;
  372. }
  373. .tree-container /deep/ .el-tree-node .el-tree-node__content {
  374. height: 34px;
  375. padding-left: 0px !important;
  376. border: none;
  377. }
  378. .tree-container /deep/ .el-tree-node .el-tree-node__content::before {
  379. border-left: 1px dashed #ccc;
  380. height: 100%;
  381. top: 0;
  382. width: 1px;
  383. margin-left: 1px;
  384. margin-top: 0px;
  385. z-index: 8;
  386. }
  387. .tree-container /deep/ .el-tree-node .el-tree-node__children .el-tree-node__content::before {
  388. border-left: 0px dashed #ccc;
  389. height: 100%;
  390. top: 0;
  391. width: 1px;
  392. margin-left: 1px;
  393. margin-top: 0px;
  394. z-index: 8;
  395. }
  396. .tree-container /deep/ .el-tree-node .el-tree-node__content::after {
  397. border-top: 1px dashed #ccc;
  398. height: 1px;
  399. top: 18px;
  400. width: 13px;
  401. margin-left: 1px;
  402. z-index: 8;
  403. }
  404. .tree-container /deep/ .el-tree-node .el-tree-node__children .el-tree-node__content::after {
  405. border-top: 0px dashed #ccc;
  406. }
  407. .tree-container .el-tree-node .el-tree-node__content::before,
  408. .tree-container .el-tree-node .el-tree-node__content::after {
  409. content: "";
  410. position: absolute;
  411. right: auto;
  412. }
  413. .el-tree {
  414. width: 20%;
  415. margin-top: 10px;
  416. }
  417. .search {
  418. width: 20%;
  419. }
  420. .item {
  421. padding: 18px 0;
  422. }
  423. .search {
  424. cursor: pointer;
  425. }
  426. .box-menu {
  427. width: 150px;
  428. position: absolute;
  429. z-index: 1000;
  430. background-color: #fff;
  431. box-shadow: 0px 0px 10px #ccc, 0px 0px 20px #ccc, 0px 0px 30px #ccc;
  432. padding: 10px;
  433. div {
  434. cursor: pointer;
  435. line-height: 30px;
  436. }
  437. div:active {
  438. color: blue;
  439. }
  440. }
  441. </style>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/119232
推荐阅读
相关标签
  

闽ICP备14008679号