123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444 |
- <template>
- <div class="app-container page-nesting" style="position: relative">
- <!-- 树形组件start -->
- <div class="grid-content treeDom">
- <div style="text-align: center" class="mb-20">
- <el-button v-if="treeLevel == 3 || groupingId == 0" disabled>
- 添加分组
- </el-button>
- <el-button v-else type="primary" @click="addGroup()">
- 添加分组
- </el-button>
- <el-button v-if="treeLevel == 3 || groupingId == 0" disabled>
- 添加站点
- </el-button>
- <el-button v-else type="primary" @click="addSite()">添加站点</el-button>
- </div>
- <el-input
- placeholder="输入关键字进行过滤"
- v-model="filterText"
- class="mb-20 searchInput"
- >
- <template>
- <i class="el-icon-search el-input__icon"></i>
- </template>
- </el-input>
- <!-- <el-scrollbar> -->
- <!-- <el-tree
- :data="data2"
- show-checkbox
- node-key="id"
- :default-expanded-keys="[1]"
- :default-checked-keys="[368]"
- :props="defaultProps2"
- /> -->
- <el-tree
- class="filter-tree siteTree"
- :props="defaultProps"
- :data="data"
- @node-click="handleNodeClick"
- node-key="id"
- :expand-on-click-node="false"
- :highlight-current="showTree"
- default-expand-all
- :filter-node-method="filterNode"
- ref="tree"
- :current-node-key="defaultExpand"
- >
- <template #default="{ node, data }">
- <span
- class="custom-tree-node"
- style="width: 100%"
- @mouseenter="mouseenter(data)"
- @mouseleave="mouseleave(data)"
- >
- <span>{{ node.label }}</span>
- <!-- <el-tooltip
- class="item"
- effect="dark"
- :content="node.label"
- placement="top-start"
- >
- <span>{{ node.label }}</span>
- </el-tooltip> -->
- <span>
- <a
- class="deleteLink"
- v-show="data.show"
- @click="remove(node, data)"
- >
- <!-- <i size="mini" class="el-icon-delete"></i> -->
- </a>
- </span>
- </span>
- </template>
- </el-tree>
- <!-- </el-scrollbar> -->
- </div>
- <!-- 树形组件end -->
- <!-- 站点主题start -->
- <div class="grid-content nestingDom" style="width: calc(100% - 300px)" v-if="flag2">
- <el-tabs
- v-if="treeLevel == 3 || groupingId == 0"
- v-model="activeName"
- type="card"
- >
- <el-tab-pane label="基本信息" name="first">
- <basic-info class="basicInfo" :siteId="siteId" ></basic-info>
- </el-tab-pane>
- <el-tab-pane label="监控设备" name="second" >
- <watch-dog
- v-on:success="success(res)"
- :avtiveName="activeName"
- @func="getMsgFormSon"
- :siteId="siteId"
- ></watch-dog>
- </el-tab-pane>
- <el-tab-pane label="变量列表" name="third">
- <variable-list :activeName="activeName" ></variable-list>
- </el-tab-pane>
- <el-tab-pane label="摄像头" name="five" >
- <camera :siteId="siteId"></camera>
- </el-tab-pane>
- <el-tab-pane label="电能质量评分配置" name="six">
- <power-Score :siteId="siteId"></power-Score>
- </el-tab-pane>
- </el-tabs>
- <!-- 分组信息start -->
- <group-info-com
- :groupingId="groupingId"
- :label="label"
- @func="getMsgFormSon2"
- v-else
- ></group-info-com>
- <!-- 分组信息end -->
- <!-- 新建分组start -->
- <add-group-com
- :dialogTitle="dialogTitle"
- :itemInfo="tableItem"
- @closeDialog="closeDialog"
- :flag="showDialog"
- ></add-group-com>
- <!-- 新建分组end -->
- <!-- 新建站点start -->
- <add-site-com
- :dialogTitle="dialogTitle"
- :itemInfo="tableItem"
- @closeDialog="closeDialog"
- :flag="showDialog2"
- ></add-site-com>
- <!-- 新建站点end -->
- </div>
- <!-- 站点主题end -->
- </div>
- </template>
- <script>
- import { defineComponent, ref, reactive, watch, onMounted,nextTick } from 'vue'
- import basicInfo from './basicInfo'
- import WatchDog from './watchDog'
- import variableList from './variableList'
- import camera from './camera'
- import PowerScore from './powerScore'
- import groupInfoCom from './groupInfoCom'
- import addGroupCom from './addGroupCom'
- import addSiteCom from './addSiteCom'
- import * as api from '@/api/siteManage/index'
- import { ElMessage } from 'element-plus'
- export default defineComponent({
- components: {
- basicInfo,
- WatchDog,
- variableList,
- camera,
- PowerScore,
- groupInfoCom,
- addGroupCom,
- addSiteCom,
- },
- setup() {
- const flag2=ref(false)
- const showTree = ref(true)
- const defaultExpand=ref(0)
- const showDialog = ref(false)
- const showDialog2 = ref(false)
- const dialogTitle = ref('')
- const treeLevel = ref(3)
- const groupingId = ref(1)
- const siteId = ref(368)
- const label = ref('')
- const activeName = ref('first')
- const filterText = ref('')
- const data = ref([
- {
- label: '所有站点',
- children: [],
- },
- ])
- // const data2 = ref([
- // {
- // grouping_id: 1,
- // id: 1,
- // label: '所有站点',
- // children: [
- // {
- // id: 1,
- // label: '分组测试1',
- // grouping_id: 1,
- // children: [
- // {
- // id: 368,
- // label: '测试站点89',
- // },
- // {
- // id: 367,
- // label: '测试站点88',
- // },
- // ],
- // },
- // {
- // grouping_id: 0,
- // id: 5,
- // label: '中国铁路上海...',
- // },
- // {
- // grouping_id: 0,
- // id: 5,
- // label: '上海拓石...',
- // },
- // ],
- // },
- // ])
- // const defaultProps2 = ref({
- // children: 'children',
- // label: 'label',
- // })
- const defaultProps = ref({
- children: 'children',
- label: 'label',
- })
- const getMsgFormSon = () => {
- activeName.value = 'third'
- }
- const getMsgFormSon2 = () => {
- siteTreeList()
- }
- function mouseenter(data) {
- data.show = true
- }
- function mouseleave(data) {
- data.show = false
- }
- function filterNode(value, data) {
- if (!value) return true
- return data.label.indexOf(value) !== -1
- }
- const handleNodeClick = (data, obj, node) => {
- data, node
- flag2.value=true
- console.log(obj.data)
- treeLevel.value = obj.level
- groupingId.value = obj.data.grouping_id
- label.value = obj.data.label
- console.log('obj.data')
- console.log(obj.data)
- if (treeLevel.value == 3) {
- siteId.value = obj.data.id
- }
- if (treeLevel.value == 2 && groupingId.value == 0) {
- // console.log(obj.data)
- siteId.value = obj.data.id
- }
- console.log('父组件的siteId')
- console.log(siteId.value)
- }
- const tree = ref(null)
- watch(filterText, (val) => {
- //直接监听
- val
- console.log(tree)
- // tree.value.filter(val)
- })
- // 关闭操作
- const closeDialog = () => {
- showDialog.value = false
- showDialog2.value = false
- siteTreeList()
- flag2.value=false
- treeLevel.value = 3
- }
- //新建分组
- const tableItem = reactive([])
- const addGroup = () => {
- tableItem.value = {
- groupingName: '',
- }
- dialogTitle.value = '新建分组'
- showDialog.value = true
- }
- //新建站点
- const addSite = () => {
- tableItem.value = {
- id: '',
- stationName: '',
- xh: '',
- userName: '',
- list: [],
- done: '',
- guaZai: '',
- checked: true,
- }
- dialogTitle.value = '新建站点'
- showDialog2.value = true
- }
- const remove = (node, data) => {
- const parent = node.parent
- const children = parent.data.children || parent.data
- const index = children.findIndex((d) => d.id === data.id)
- children.splice(index, 1)
- this.dataSource = [...this.dataSource]
- }
- //左侧树结构列表
- function siteTreeList() {
- api.siteTreeList({}).then((requset) => {
- if (requset.status === 'SUCCESS') {
- var jsona = JSON.stringify(requset.data)
- var jsonb = jsona.replace(/"grouping_name"/g, '"label"')
- jsonb = jsonb.replace(/"site_list"/g, '"children"')
- jsonb = jsonb.replace(/"site_name"/g, '"label"')
- jsonb = jsonb.replace(/"site_id"/g, '"id"')
- var jsonc = JSON.parse(jsonb)
- data.value[0].children = jsonc
- // data2.value[0].children = jsonc
- console.log(data)
- // console.log(data2)
- } else {
- ElMessage.error(requset.msg)
- }
- })
- }
- onMounted(() => {
- // console.log(groupingId.value)
- siteTreeList();
-
- })
- nextTick(() => {
- // defaultExpand.value = data.value[0].children.id
- // tree.value.setCurrentKey(tree[0].node.id)
- })
- return {
- showDialog,
- showDialog2,
- treeLevel,
- activeName,
- filterText,
- dialogTitle,
- data,
- defaultProps,
- tableItem,
- groupingId,
- siteId,
- label,
- flag2,
- showTree,
- // data2,
- // defaultProps2,
- defaultExpand,
- getMsgFormSon,
- getMsgFormSon2,
- mouseenter,
- mouseleave,
- filterNode,
- handleNodeClick,
- closeDialog,
- addGroup,
- addSite,
- remove,
- }
- },
- })
- </script>
- <style scoped lang="scss">
- .app-container.page-nesting {
- padding: 0;
- background: rgba(0, 0, 0, 0);
- }
- .grid-content {
- background: #fff;
- height: calc(100vh - 130px);
- overflow-y: auto;
- }
- .el-input__inner {
- border-radius: 20px !important;
- }
- .treeDom {
- width: 290px;
- position: absolute;
- left: 0;
- // margin-left: 20px;
- padding: 20px;
- min-height: calc(100vh - 130px);
- .el-icon-search {
- color: #409eff;
- }
- .el-button {
- width: 100px;
- }
- }
- .nestingDom {
- margin-left: 300px;
- }
- </style>
- <style lang="scss">
- // tab重置样式
- .el-tabs--card > .el-tabs__header .el-tabs__item {
- line-height: 50px;
- height: 50px;
- font-size: 16px;
- }
- .el-tabs--card > .el-tabs__header .el-tabs__item.is-active {
- border-bottom: 2px solid #409eff;
- color: #409eff;
- }
- .el-tabs--card .el-tabs__header:hover,
- .el-tabs__item:hover {
- color: #409eff !important;
- }
- .el-tabs__header {
- margin-bottom: 0;
- }
- .el-tabs--card > .el-tabs__header .el-tabs__item,
- .el-tabs--card > .el-tabs__header .el-tabs__nav {
- border: none;
- }
- </style>
|