| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- <template>
- <div id="main" :style="{'height':testHeight+'px'}">
- <el-tree
- :data="treeData"
- show-checkbox
- node-key="id"
- default-expand-all
- @check-change="handleCheckChange"
- @check="currentChecked"
- ref="tree_data"
- :default-checked-keys="['personGraphicLayer']"
- :props="defaultProps"
- @key=""
- >
- </el-tree>
- </div>
- </template>
- <script>
- import InspectionList from './components/InspectionList.vue'
- import request from "../../utils/gw_ajax_request.js"
- import { getPersPlanType} from "../../api/duChaPlan.js";
- import { hasPriv } from '../../utils/gw_hasPriv.js'
- export default {
- name: 'SidebarItem',
- components: {
- InspectionList,
- },
- data() {
- return {
- testHeight:Number(window.innerHeight) - 92,
- treeData:[],
- treeData_per:{
- id: 'personGraphicLayer',
- label: '督查人员',
- checked:true,
- },
- treeData_sk:{
- id: '',
- label: '水库',
- checked:false,
- children: [{
- id: 'allSkGraphicLayer',
- label: '水库',
- checked:false,
- }, {
- id: 'skGraphicLayer2018',
- label: '2018年水库督查',
- checked:false,
- }, {
- id: 'skGraphicLayer2019',
- label: '2019年水库督查',
- checked:false,
- }, {
- id: 'fcskGraphicLayer',
- label: '复查水库',
- checked:false,
- }, {
- id: 'jhwskGraphicLayer',
- label: '督查计划外水库',
- checked:false,
- }]
- },
- treeData_ry:{
- id: '',
- label: '人饮',
- checked:false,
- children: [{
- id: 'ncysgcGraphicLayer',
- label: '农村饮水工程',
- checked:false,
- }, {
- id: 'sydGraphicLayer',
- label: '水源地',
- checked:false,
- }, {
- id: 'country150Layer',
- label: '督查县',
- checked:false,
- }, {
- id: 'xzcGraphicLayer',
- label: '督查行政村',
- checked:false,
- }]
- },
- treeData_sh:{
- id: 'shgcGraphicLayer',
- label: '水毁工程',
- checked:false,
- },
- treeData_dxs: {
- id: 'dxsGraphicLayer',
- label: '地下水',
- checked:false,
- },
- treeData_172: {
- id: 'graphicLayer172',
- label: '172工程',
- checked:false,
- },
- treeData_sz:{
- id: '',
- label: '水闸',
- checked:false,
- children: [{
- id: 'szGraphicLayerAll',
- label: '水闸',
- checked:false,
- }, {
- id: 'szGraphicLayer',
- label: '督查水闸',
- checked:false,
- }]
- },
- treeData_qsk: {
- id: 'graphicLayerQsk',
- label: '取水口',
- checked:false,
- },
- treeData1: [
- // {
- // id: '',
- // label: '图层选择',
- // children: [
- {
- id: 'personGraphicLayer',
- label: '督查人员',
- checked:true,
- },
- {
- id: '',
- label: '水库',
- checked:false,
- children: [{
- id: 'allSkGraphicLayer',
- label: '全部',
- checked:false,
- }, {
- id: 'skGraphicLayer2018',
- label: '2018年水库督查',
- checked:false,
- }, {
- id: 'skGraphicLayer2019',
- label: '2019年水库督查',
- checked:false,
- }, {
- id: 'fcskGraphicLayer',
- label: '复查水库',
- checked:false,
- }, {
- id: 'jhwskGraphicLayer',
- label: '督查计划外水库',
- checked:false,
- }]
- },
- {
- id: '',
- label: '人饮',
- checked:false,
- children: [{
- id: 'ncysgcGraphicLayer',
- label: '农村饮水工程',
- checked:false,
- }, {
- id: 'sydGraphicLayer',
- label: '水源地',
- checked:false,
- }, {
- id: 'country150Layer',
- label: '督查县',
- checked:false,
- }, {
- id: 'xzcGraphicLayer',
- label: '督查行政村',
- checked:false,
- }]
- },
- {
- id: 'shgcGraphicLayer',
- label: '水毁工程',
- checked:false,
- },
- // {
- // id: 'graphicLayer172',
- // label: '172工程',
- // checked:false,
- // },
- // {
- // id: 'szGraphicLayer',
- // label: '水闸',
- // checked:false,
- // },
- {
- id: 'dxsGraphicLayer',
- label: '地下水',
- checked:false,
- },
- // {
- // id: 'swzGraphicLayer',
- // label: '水文站',
- // checked:false,
- // },
- // ]
- // },
- ],
- defaultProps: {
- children: 'children',
- label: 'label'
- },
- isCheckData:[],
- }
- },
- computed:{
- userId: function () {
- return localStorage.getItem("userid") ?localStorage.getItem("userid") : "1098101939614724096";
- },
- },
- mounted:function(){
- // this.getPersonType();
- this.authentication();//身份验证
- },
- methods: {
- authentication(){
- this.treeData = [];
- if(hasPriv('per_layer')){//督查人员
- this.treeData.push(this.treeData_per);
- }
- if(hasPriv('rsvr_layer')){//小水库
- this.treeData.push(this.treeData_sk);
- }
- if(hasPriv('vill_layer')){//人饮
- this.treeData.push(this.treeData_ry);
- }
- if(hasPriv('rect_layer')){//水毁
- this.treeData.push(this.treeData_sh);
- }
- if(hasPriv('gc_layer')){//172
- this.treeData.push(this.treeData_172);
- }
- if(hasPriv('grw_layer')){//地下水监测站
- this.treeData.push(this.treeData_dxs);
- }
- if(hasPriv('sz_layer')){//水闸
- this.treeData.push(this.treeData_sz);
- }
- if(hasPriv('wint_layer')){//取水口
- this.treeData.push(this.treeData_qsk);
- }
- },
- // getPersonType(){ //获取当前人员类型 控制权限
- // this.treeData = [];
- // this.treeData.push(this.treeData_per);
- // getPersPlanType(this.userId).then((res)=>{
- // if(res.success){
- // var data = res.data;
- // data.forEach((item)=>{
- // if(item.id =="001"){//水库督查
- // this.treeData.push(this.treeData_sk);
- // }else if(item.id =="002"){//人饮督查
- // this.treeData.push(this.treeData_ry);
- // }else if(item.id =="003"){//水毁督查
- // this.treeData.push(this.treeData_sh);
- // }else if(item.id =="004"){//172工程督查
- // this.treeData.push(this.treeData_172);
- // }else if(item.id =="005"){//地下水督查
- // this.treeData.push(this.treeData_dxs);
- // }else if(item.id =="006"){//水闸督查
- // this.treeData.push(this.treeData_sz);
- // }
- // })
- // }
- // });
- // },
- handleCheckChange(event) {
- console.log(event)
- event.checked = !event.checked;
- this.$emit('isCheck',event);
- let checkedData = [];
- },
- currentChecked(data, currentChecked) {
- const { checkedNodes, halfCheckedNodes } = currentChecked;
- // console.log(checkedNodes,halfCheckedNodes);
- this.$emit('isChecks',checkedNodes);
- }
- }
- }
- </script>
- <style>
- #main{
- width: 190px;
- background: aliceblue;
- }
- #main .el-tree {
- height: 100%;
- }
- </style>
|