index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <div class="app-container page-nesting">
  3. <!-- 树形组件start -->
  4. <div class="grid-content treeDom">
  5. <div style="text-align: center" class="mb-20">
  6. <el-button type="primary">添加分组</el-button>
  7. <el-button type="primary">添加站点</el-button>
  8. </div>
  9. <el-input
  10. placeholder="输入关键字进行过滤"
  11. v-model="filterText"
  12. class="mb-20 searchInput"
  13. >
  14. <i class="el-icon-search el-input__icon" slot="suffix"> </i>
  15. </el-input>
  16. <el-tree
  17. class="filter-tree"
  18. :data="data"
  19. node-key="id"
  20. :props="defaultProps"
  21. :expand-on-click-node="false"
  22. :render-content="renderContent"
  23. default-expand-all
  24. :filter-node-method="filterNode"
  25. ref="tree"
  26. >
  27. </el-tree>
  28. </div>
  29. <!-- 树形组件end -->
  30. <!-- 站点主题start -->
  31. <div class="grid-content nestingDom" style="width: calc(100% -300px)">
  32. <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
  33. <el-tab-pane label="基本信息" name="first">
  34. <basic-info class="basicInfo"></basic-info>
  35. </el-tab-pane>
  36. <el-tab-pane label="监控设备" name="second">
  37. <watch-dog v-on:success="success(res)" :avtiveName="activeName"></watch-dog>
  38. </el-tab-pane>
  39. <el-tab-pane label="变量列表" name="third">
  40. <variable-list></variable-list>
  41. </el-tab-pane>
  42. <el-tab-pane label="摄像头" name="five">
  43. <camera></camera>
  44. </el-tab-pane>
  45. <el-tab-pane label="电能质量评分配置" name="six">
  46. <power-Score></power-Score>
  47. </el-tab-pane>
  48. </el-tabs>
  49. </div>
  50. <!-- 站点主题end -->
  51. </div>
  52. </template>
  53. <script>
  54. import basicInfo from "./basicInfo";
  55. import WatchDog from "./watchDog";
  56. import variableList from "./variableList";
  57. import camera from "./camera";
  58. import PowerScore from "./powerScore";
  59. export default {
  60. components: { basicInfo, WatchDog, variableList,camera,PowerScore},
  61. data() {
  62. return {
  63. activeName: "six",
  64. filterText: "",
  65. data: [
  66. {
  67. label: "所有站点",
  68. children: [
  69. {
  70. label: "分组一",
  71. children: [
  72. {
  73. label: "站点 1-1",
  74. },
  75. {
  76. label: "站点 1-2",
  77. },
  78. {
  79. label: "站点 1-3",
  80. },
  81. {
  82. label: "站点 1-4",
  83. },
  84. ],
  85. },
  86. {
  87. label: "分组二",
  88. children: [
  89. {
  90. label: "站点 2-1",
  91. },
  92. {
  93. label: "站点 2-2",
  94. },
  95. {
  96. label: "站点 2-3",
  97. },
  98. {
  99. label: "站点 2-4",
  100. },
  101. ],
  102. },
  103. {
  104. label: "其他分组",
  105. children: [
  106. {
  107. label: "其他 3-1",
  108. },
  109. {
  110. label: "其他 3-2",
  111. },
  112. {
  113. label: "其他 3-3",
  114. },
  115. {
  116. label: "其他 3-4",
  117. },
  118. ],
  119. },
  120. ],
  121. },
  122. ],
  123. defaultProps: {
  124. children: "children",
  125. label: "label",
  126. },
  127. };
  128. },
  129. watch: {
  130. success(res) {
  131. alert(1)
  132. // this.dialogCreate = res;
  133. // this.activeName = res;
  134. },
  135. filterText(val) {
  136. this.$refs.tree.filter(val);
  137. },
  138. },
  139. methods: {
  140. handleClick(tab, event) {
  141. console.log(tab, event);
  142. },
  143. filterNode(value, data) {
  144. if (!value) return true;
  145. return data.label.indexOf(value) !== -1;
  146. },
  147. handleNodeClick(data) {
  148. console.log(data);
  149. },
  150. append(data) {
  151. const newChild = { id: id++, label: "testtest", children: [] };
  152. if (!data.children) {
  153. this.$set(data, "children", []);
  154. }
  155. data.children.push(newChild);
  156. },
  157. remove(node, data) {
  158. const parent = node.parent;
  159. const children = parent.data.children || parent.data;
  160. const index = children.findIndex((d) => d.id === data.id);
  161. children.splice(index, 1);
  162. },
  163. renderContent(h, { node, data, store }) {
  164. return (
  165. <span class="custom-tree-node">
  166. <span>{node.label}</span>
  167. <span>
  168. <el-button
  169. size="mini"
  170. type="text"
  171. on-click={() => this.remove(node, data)}
  172. >
  173. <i class="el-icon-delete"></i>
  174. </el-button>
  175. </span>
  176. </span>
  177. );
  178. },
  179. },
  180. };
  181. </script>
  182. <style scoped lang="scss">
  183. .app-container.page-nesting {
  184. padding: 0;
  185. background: rgba(0, 0, 0, 0);
  186. }
  187. .grid-content {
  188. background: #fff;
  189. height: calc(100vh - 140px);
  190. overflow-y: auto;
  191. }
  192. .el-input__inner {
  193. border-radius: 20px !important;
  194. }
  195. .treeDom {
  196. width: 270px;
  197. position: absolute;
  198. left: 0;
  199. margin-left: 20px;
  200. padding: 20px;
  201. .el-icon-search {
  202. color: #409eff;
  203. }
  204. .el-button {
  205. width: 100px;
  206. }
  207. }
  208. .nestingDom {
  209. margin-left: 290px;
  210. }
  211. </style>
  212. <style lang="scss">
  213. // tab重置样式
  214. .el-tabs--card > .el-tabs__header .el-tabs__item {
  215. line-height: 50px;
  216. height: 50px;
  217. font-size: 16px;
  218. }
  219. .el-tabs--card > .el-tabs__header .el-tabs__item.is-active {
  220. border-bottom: 2px solid #409eff;
  221. }
  222. .el-tabs__header {
  223. margin-bottom: 0;
  224. }
  225. .el-tabs--card > .el-tabs__header .el-tabs__item,
  226. .el-tabs--card > .el-tabs__header .el-tabs__nav {
  227. border: none;
  228. }
  229. </style>