index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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 v-if="this.treeLevel == 3" disabled @click="addGroup()"
  7. >添加分组</el-button
  8. >
  9. <el-button type="primary" v-else @click="addGroup()"
  10. >添加分组</el-button
  11. >
  12. <el-button v-if="this.treeLevel == 3" disabled @click="addSite()"
  13. >添加站点</el-button
  14. >
  15. <el-button type="primary" v-else @click="addSite()">添加站点</el-button>
  16. </div>
  17. <el-input
  18. placeholder="输入关键字进行过滤"
  19. v-model="filterText"
  20. class="mb-20 searchInput"
  21. >
  22. <template #suffix>
  23. <i class="el-icon-search el-input__icon"></i>
  24. </template>
  25. </el-input>
  26. <el-tree
  27. class="filter-tree"
  28. :data="data"
  29. node-key="id"
  30. :props="defaultProps"
  31. :expand-on-click-node="false"
  32. default-expand-all
  33. @node-click="handleNodeClick"
  34. :filter-node-method="filterNode"
  35. ref="tree"
  36. >
  37. <template #default="{ node, data }">
  38. <span
  39. class="custom-tree-node"
  40. style="width: 100%"
  41. @mouseenter="mouseenter(data)"
  42. @mouseleave="mouseleave(data)"
  43. >
  44. <span>{{ node.label }}</span>
  45. <span>
  46. <a class="deleteLink" v-show="data.show" @click="remove(node, data)">
  47. <i size="mini" class="el-icon-delete"></i>
  48. </a>
  49. </span>
  50. </span>
  51. </template>
  52. </el-tree>
  53. </div>
  54. <!-- 树形组件end -->
  55. <!-- 站点主题start -->
  56. <div class="grid-content nestingDom" style="width: calc(100% -300px)">
  57. <el-tabs
  58. v-if="this.treeLevel == 3"
  59. v-model="activeName"
  60. type="card"
  61. @tab-click="handleClick"
  62. >
  63. <el-tab-pane label="基本信息" name="first">
  64. <basic-info class="basicInfo"></basic-info>
  65. </el-tab-pane>
  66. <el-tab-pane label="监控设备" name="second">
  67. <watch-dog
  68. v-on:success="success(res)"
  69. :avtiveName="activeName"
  70. ></watch-dog>
  71. </el-tab-pane>
  72. <el-tab-pane label="变量列表" name="third">
  73. <variable-list></variable-list>
  74. </el-tab-pane>
  75. <el-tab-pane label="摄像头" name="five">
  76. <camera></camera>
  77. </el-tab-pane>
  78. <el-tab-pane label="电能质量评分配置" name="six">
  79. <power-Score></power-Score>
  80. </el-tab-pane>
  81. </el-tabs>
  82. <!-- 分组信息start -->
  83. <group-info-com
  84. v-if="this.treeLevel == 2 || this.treeLevel == 1"
  85. ></group-info-com>
  86. <!-- 分组信息end -->
  87. <!-- 新建分组start -->
  88. <add-group-com
  89. v-if="showDialog"
  90. ref="addGroupCom"
  91. :dialog-title="dialogTitle"
  92. :item-info="tableItem"
  93. @closeDialog="closeDialog"
  94. ></add-group-com>
  95. <!-- 新建分组end -->
  96. <!-- 新建站点start -->
  97. <add-site-com
  98. v-if="showDialog"
  99. ref="addSiteCom"
  100. :dialog-title="dialogTitle"
  101. :item-info="tableItem"
  102. @closeDialog="closeDialog"
  103. ></add-site-com>
  104. <!-- 新建站点end -->
  105. </div>
  106. <!-- 站点主题end -->
  107. </div>
  108. </template>
  109. <script>
  110. import basicInfo from "./basicInfo";
  111. import WatchDog from "./watchDog";
  112. import variableList from "./variableList";
  113. import camera from "./camera";
  114. import PowerScore from "./powerScore";
  115. import groupInfoCom from "./groupInfoCom";
  116. import addGroupCom from "./addGroupCom";
  117. import addSiteCom from "./addSiteCom";
  118. export default {
  119. components: {
  120. basicInfo,
  121. WatchDog,
  122. variableList,
  123. camera,
  124. PowerScore,
  125. groupInfoCom,
  126. addGroupCom,
  127. addSiteCom,
  128. },
  129. data() {
  130. return {
  131. deleteShow: false,
  132. showDialog: false,
  133. treeLevel: 0,
  134. activeName: "first",
  135. filterText: "",
  136. data: [
  137. {
  138. label: "所有站点",
  139. children: [
  140. {
  141. label: "分组一",
  142. children: [
  143. {
  144. label: "站点 1-1",
  145. show: false,
  146. },
  147. {
  148. label: "站点 1-2",
  149. show: false,
  150. },
  151. {
  152. label: "站点 1-3",
  153. show: false,
  154. },
  155. {
  156. label: "站点 1-4",
  157. show: false,
  158. },
  159. ],
  160. },
  161. {
  162. label: "分组二",
  163. children: [
  164. {
  165. label: "站点 2-1",
  166. show: false,
  167. },
  168. {
  169. label: "站点 2-2",
  170. show: false,
  171. },
  172. {
  173. label: "站点 2-3",
  174. show: false,
  175. },
  176. {
  177. label: "站点 2-4",
  178. show: false,
  179. },
  180. ],
  181. },
  182. {
  183. label: "其他分组",
  184. children: [
  185. {
  186. label: "其他 3-1",
  187. show: false,
  188. },
  189. {
  190. label: "其他 3-2",
  191. show: false,
  192. },
  193. {
  194. label: "其他 3-3",
  195. show: false,
  196. },
  197. {
  198. label: "其他 3-4",
  199. show: false,
  200. },
  201. ],
  202. },
  203. ],
  204. },
  205. ],
  206. defaultProps: {
  207. children: "children",
  208. label: "label",
  209. },
  210. };
  211. },
  212. watch: {
  213. success(res) {
  214. alert(1);
  215. // this.dialogCreate = res;
  216. // this.activeName = res;
  217. },
  218. filterText(val) {
  219. this.$refs.tree.filter(val);
  220. },
  221. },
  222. methods: {
  223. mouseenter(data) {
  224. // console.log("移入");
  225. // console.log(data);
  226. data.show = true;
  227. // console.log(data.show);
  228. },
  229. mouseleave(data) {
  230. // console.log("移出");
  231. // console.log(data);
  232. data.show = false;
  233. },
  234. handleClick(tab, event) {
  235. console.log(tab, event);
  236. },
  237. filterNode(value, data) {
  238. if (!value) return true;
  239. return data.label.indexOf(value) !== -1;
  240. },
  241. handleNodeClick(data, obj, node) {
  242. this.treeLevel = obj.level;
  243. // console.log(this.treeLevel);
  244. // console.log(node);
  245. },
  246. // 关闭操作
  247. closeDialog(flag) {
  248. if (flag) {
  249. // 重新刷新表格内容
  250. this.fetchData();
  251. }
  252. this.showDialog = false;
  253. },
  254. addGroup() {
  255. this.tableItem = {
  256. id: "",
  257. stationName: "",
  258. watchName: "",
  259. watchCode: "",
  260. siteList: [],
  261. done: "",
  262. guaZai: "",
  263. checked: true,
  264. resource: "",
  265. };
  266. this.dialogTitle = "新建分组";
  267. this.showDialog = true;
  268. this.$nextTick(() => {
  269. this.$refs["addGroupCom"].showDialog = true;
  270. });
  271. },
  272. addSite() {
  273. this.tableItem = {
  274. id: "",
  275. region: "",
  276. stationName: "",
  277. watchName: "",
  278. watchCode: "",
  279. siteList: [],
  280. done: "",
  281. guaZai: "",
  282. checked: true,
  283. resource: "",
  284. };
  285. this.dialogTitle = "新建站点";
  286. this.showDialog = true;
  287. this.$nextTick(() => {
  288. this.$refs["addSiteCom"].showDialog = true;
  289. });
  290. },
  291. append(data) {
  292. var id;
  293. const newChild = { id: id++, label: "testtest", children: [] };
  294. if (!data.children) {
  295. this.$set(data, "children", []);
  296. }
  297. data.children.push(newChild);
  298. },
  299. remove(node, data) {
  300. const parent = node.parent;
  301. const children = parent.data.children || parent.data;
  302. const index = children.findIndex((d) => d.id === data.id);
  303. children.splice(index, 1);
  304. this.dataSource = [...this.dataSource];
  305. },
  306. },
  307. };
  308. </script>
  309. <style scoped lang="scss">
  310. .app-container.page-nesting {
  311. padding: 0;
  312. background: rgba(0, 0, 0, 0);
  313. }
  314. .grid-content {
  315. background: #fff;
  316. height: calc(100vh - 140px);
  317. overflow-y: auto;
  318. }
  319. .el-input__inner {
  320. border-radius: 20px !important;
  321. }
  322. .treeDom {
  323. width: 270px;
  324. position: absolute;
  325. left: 0;
  326. margin-left: 20px;
  327. padding: 20px;
  328. .el-icon-search {
  329. color: #409eff;
  330. }
  331. .el-button {
  332. width: 100px;
  333. }
  334. }
  335. .nestingDom {
  336. margin-left: 290px;
  337. }
  338. </style>
  339. <style lang="scss">
  340. // tab重置样式
  341. .el-tabs--card > .el-tabs__header .el-tabs__item {
  342. line-height: 50px;
  343. height: 50px;
  344. font-size: 16px;
  345. }
  346. .el-tabs--card > .el-tabs__header .el-tabs__item.is-active {
  347. border-bottom: 2px solid #409eff;
  348. }
  349. .el-tabs__header {
  350. margin-bottom: 0;
  351. }
  352. .el-tabs--card > .el-tabs__header .el-tabs__item,
  353. .el-tabs--card > .el-tabs__header .el-tabs__nav {
  354. border: none;
  355. }
  356. </style>