index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <div class="app-container page-nesting" style="position: relative">
  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. 添加分组
  8. </el-button>
  9. <el-button type="primary" v-else @click="addGroup()">
  10. 添加分组
  11. </el-button>
  12. <el-button v-if="this.treeLevel == 3" disabled @click="addSite()">
  13. 添加站点
  14. </el-button>
  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>
  23. <i class="el-icon-search el-input__icon"></i>
  24. </template>
  25. </el-input>
  26. <!-- <el-scrollbar> -->
  27. <el-tree
  28. class="filter-tree siteTree"
  29. :props="defaultProps"
  30. :data="data"
  31. @node-click="handleNodeClick"
  32. node-key="id"
  33. :expand-on-click-node="false"
  34. :highlight-current="showTree"
  35. default-expand-all
  36. :filter-node-method="filterNode"
  37. ref="tree"
  38. >
  39. <template #default="{ node, data }">
  40. <span
  41. class="custom-tree-node"
  42. style="width: 100%"
  43. @mouseenter="mouseenter(data)"
  44. @mouseleave="mouseleave(data)"
  45. >
  46. <span>{{ node.label }}</span>
  47. <!-- <el-tooltip
  48. class="item"
  49. effect="dark"
  50. :content="node.label"
  51. placement="top-start"
  52. >
  53. <span>{{ node.label }}</span>
  54. </el-tooltip> -->
  55. <span>
  56. <a
  57. class="deleteLink"
  58. v-show="data.show"
  59. @click="remove(node, data)"
  60. >
  61. <!-- <i size="mini" class="el-icon-delete"></i> -->
  62. </a>
  63. </span>
  64. </span>
  65. </template>
  66. </el-tree>
  67. <!-- </el-scrollbar> -->
  68. </div>
  69. <!-- 树形组件end -->
  70. <!-- 站点主题start -->
  71. <div class="grid-content nestingDom" style="width: calc(100% - 300px)">
  72. <el-tabs v-if="this.treeLevel == 3" v-model="activeName" type="card">
  73. <el-tab-pane label="基本信息" name="first">
  74. <basic-info class="basicInfo"></basic-info>
  75. </el-tab-pane>
  76. <el-tab-pane label="监控设备" name="second">
  77. <watch-dog
  78. v-on:success="success(res)"
  79. :avtiveName="activeName"
  80. @func="getMsgFormSon"
  81. ></watch-dog>
  82. </el-tab-pane>
  83. <el-tab-pane label="变量列表" name="third">
  84. <variable-list :activeName="activeName"></variable-list>
  85. </el-tab-pane>
  86. <el-tab-pane label="摄像头" name="five">
  87. <camera></camera>
  88. </el-tab-pane>
  89. <el-tab-pane label="电能质量评分配置" name="six">
  90. <power-Score></power-Score>
  91. </el-tab-pane>
  92. </el-tabs>
  93. <!-- 分组信息start -->
  94. <group-info-com
  95. v-if="this.treeLevel == 2 || this.treeLevel == 1"
  96. ></group-info-com>
  97. <!-- 分组信息end -->
  98. <!-- 新建分组start -->
  99. <add-group-com
  100. :dialogTitle="dialogTitle"
  101. :itemInfo="tableItem"
  102. @closeDialog="closeDialog"
  103. :flag="showDialog"
  104. ></add-group-com>
  105. <!-- 新建分组end -->
  106. <!-- 新建站点start -->
  107. <add-site-com
  108. :dialogTitle="dialogTitle"
  109. :itemInfo="tableItem"
  110. @closeDialog="closeDialog"
  111. :flag="showDialog2"
  112. ></add-site-com>
  113. <!-- 新建站点end -->
  114. </div>
  115. <!-- 站点主题end -->
  116. </div>
  117. </template>
  118. <script>
  119. import { defineComponent, ref, reactive, watch, onMounted } from 'vue'
  120. import basicInfo from './basicInfo'
  121. import WatchDog from './watchDog'
  122. import variableList from './variableList'
  123. import camera from './camera'
  124. import PowerScore from './powerScore'
  125. import groupInfoCom from './groupInfoCom'
  126. import addGroupCom from './addGroupCom'
  127. import addSiteCom from './addSiteCom'
  128. import * as api from '@/api/siteManage/index'
  129. import { ElMessage } from 'element-plus'
  130. export default defineComponent({
  131. components: {
  132. basicInfo,
  133. WatchDog,
  134. variableList,
  135. camera,
  136. PowerScore,
  137. groupInfoCom,
  138. addGroupCom,
  139. addSiteCom,
  140. },
  141. setup() {
  142. const showTree=ref(true)
  143. const showDialog = ref(false)
  144. const showDialog2 = ref(false)
  145. const dialogTitle = ref('')
  146. const treeLevel = ref(3)
  147. const activeName = ref('second')
  148. const filterText = ref('')
  149. const data = ref([
  150. {
  151. label: '所有站点',
  152. children: []
  153. },
  154. ])
  155. const defaultProps = ref({
  156. children: 'children',
  157. label: 'label',
  158. })
  159. const getMsgFormSon = () => {
  160. activeName.value = 'third'
  161. }
  162. function mouseenter(data) {
  163. data.show = true
  164. }
  165. function mouseleave(data) {
  166. data.show = false
  167. }
  168. function filterNode(value, data) {
  169. if (!value) return true
  170. return data.label.indexOf(value) !== -1
  171. }
  172. const handleNodeClick = (data, obj, node) => {
  173. data, node
  174. treeLevel.value = obj.level
  175. }
  176. const tree = ref(null)
  177. watch(filterText, (val) => {
  178. //直接监听
  179. val
  180. console.log(tree)
  181. // tree.value.filter(val)
  182. })
  183. // 关闭操作
  184. const closeDialog = () => {
  185. showDialog.value = false
  186. showDialog2.value = false
  187. treeLevel.value = 3
  188. }
  189. //新建分组
  190. const tableItem = reactive([])
  191. const addGroup = () => {
  192. tableItem.value = {
  193. id: '',
  194. stationName: '',
  195. xh: '',
  196. userName: '',
  197. list: [],
  198. done: '',
  199. guaZai: '',
  200. checked: true,
  201. }
  202. dialogTitle.value = '新建分组'
  203. showDialog.value = true
  204. }
  205. //新建站点
  206. const addSite = () => {
  207. tableItem.value = {
  208. id: '',
  209. stationName: '',
  210. xh: '',
  211. userName: '',
  212. list: [],
  213. done: '',
  214. guaZai: '',
  215. checked: true,
  216. }
  217. dialogTitle.value = '新建站点'
  218. showDialog2.value = true
  219. }
  220. const remove = (node, data) => {
  221. const parent = node.parent
  222. const children = parent.data.children || parent.data
  223. const index = children.findIndex((d) => d.id === data.id)
  224. children.splice(index, 1)
  225. this.dataSource = [...this.dataSource]
  226. }
  227. //左侧树结构列表
  228. function siteTreeList() {
  229. api.siteTreeList({}).then((requset) => {
  230. if (requset.status === 'SUCCESS') {
  231. var jsona = JSON.stringify(requset.data)
  232. var jsonb = jsona.replace(/"grouping_name"/g, '"label"');
  233. jsonb=jsonb.replace(/"site_list"/g, '"children"');
  234. jsonb=jsonb.replace(/"site_name"/g, '"label"');
  235. var jsonc = JSON.parse(jsonb)
  236. data.value[0].children=jsonc
  237. } else {
  238. ElMessage.error(requset.msg)
  239. }
  240. })
  241. }
  242. onMounted(() => {
  243. siteTreeList()
  244. })
  245. return {
  246. showDialog,
  247. showDialog2,
  248. treeLevel,
  249. activeName,
  250. filterText,
  251. dialogTitle,
  252. data,
  253. defaultProps,
  254. tableItem,
  255. showTree,
  256. getMsgFormSon,
  257. mouseenter,
  258. mouseleave,
  259. filterNode,
  260. handleNodeClick,
  261. closeDialog,
  262. addGroup,
  263. addSite,
  264. remove,
  265. }
  266. },
  267. })
  268. </script>
  269. <style scoped lang="scss">
  270. .app-container.page-nesting {
  271. padding: 0;
  272. background: rgba(0, 0, 0, 0);
  273. }
  274. .grid-content {
  275. background: #fff;
  276. height: calc(100vh - 130px);
  277. overflow-y: auto;
  278. }
  279. .el-input__inner {
  280. border-radius: 20px !important;
  281. }
  282. .treeDom {
  283. width: 290px;
  284. position: absolute;
  285. left: 0;
  286. // margin-left: 20px;
  287. padding: 20px;
  288. min-height: calc(100vh - 130px);
  289. .el-icon-search {
  290. color: #409eff;
  291. }
  292. .el-button {
  293. width: 100px;
  294. }
  295. }
  296. .nestingDom {
  297. margin-left: 300px;
  298. }
  299. </style>
  300. <style lang="scss">
  301. // tab重置样式
  302. .el-tabs--card > .el-tabs__header .el-tabs__item {
  303. line-height: 50px;
  304. height: 50px;
  305. font-size: 16px;
  306. }
  307. .el-tabs--card > .el-tabs__header .el-tabs__item.is-active {
  308. border-bottom: 2px solid #409eff;
  309. color: #409eff;
  310. }
  311. .el-tabs--card .el-tabs__header:hover,
  312. .el-tabs__item:hover {
  313. color: #409eff !important;
  314. }
  315. .el-tabs__header {
  316. margin-bottom: 0;
  317. }
  318. .el-tabs--card > .el-tabs__header .el-tabs__item,
  319. .el-tabs--card > .el-tabs__header .el-tabs__nav {
  320. border: none;
  321. }
  322. </style>