南昌市物联网技防平台-前端
Administrator
2021-06-29 8bdc5825f7ea8fcc5059d3fd77859ecb0b4e3963
新增设备信息管理页面,并提供curd 操作
1 files modified
2 files added
1500 ■■■■ changed files
src/api/equipmentInfo/equipmentInfo.js 71 ●●●●● patch | view | raw | blame | history
src/router/views/index.js 860 ●●●● patch | view | raw | blame | history
src/views/equipmentInfo/equipmentInfo.vue 569 ●●●●● patch | view | raw | blame | history
src/api/equipmentInfo/equipmentInfo.js
New file
@@ -0,0 +1,71 @@
import request from '@/router/axios';
export const getList = (current, size, params, pid) => {
    return request({
        url: '/api/blade-jfpts/equipmentInfo/selectEquipmentInfoDeptPages',
        method: 'get',
        params: {
            ...params,
            current,
            size,
            pid
        }
    })
}
export const remove = (ids) => {
    return request({
        url: '/api/blade-jfpts/equipmentInfo/delete',
        method: 'post',
        params: {
            ids,
        }
    })
}
export const add = (row) => {
    return request({
        url: '/api/blade-jfpts/equipmentInfo/submit',
        method: 'post',
        data: row
    })
}
export const update = (row) => {
    return request({
        url: '/api/blade-jfpts/equipmentInfo/submit',
        method: 'post',
        data: row
    })
}
export const getclient = (id) => {
    return request({
        url: '/api/blade-jfpts/equipmentInfo/detail',
        method: 'get',
        params: {
            id
        }
    })
}
export const getDeptLazyTree = (parentId) => {
    return request({
        url: '/api/blade-system/dept/lazy-trees',
        method: 'get',
        params: {
            parentId
        }
    })
}
export const getDeptTree = (tenantId) => {
    return request({
        url: '/api/blade-system/dept/tree',
        method: 'get',
        params: {
            tenantId,
        }
    })
}
src/router/views/index.js
@@ -1,435 +1,449 @@
import Layout from '@/page/index/'
export default [{
    path: '/wel',
    component: Layout,
    redirect: '/wel/index',
    children: [{
        path: 'index',
        name: '首页',
        meta: {
            i18n: 'dashboard'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/dataL/homeL')
    }]
},
        path: '/wel',
        component: Layout,
        redirect: '/wel/index',
        children: [{
            path: 'index',
            name: '首页',
            meta: {
                i18n: 'dashboard'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/dataL/homeL')
        }]
    },
// {
//     path: '/wel',
//     component: Layout,
//     redirect: '/wel/index',
//     children: [{
//         path: 'index',
//         name: '首页',
//         meta: {
//             i18n: 'dashboard'
//         },
//         component: () =>
//             import ( /* webpackChunkName: "views" */ '@/views/home/home')
//     }, {
//         path: 'dashboard',
//         name: '控制台',
//         meta: {
//             i18n: 'dashboard',
//             menu: false,
//         },
//         component: () =>
//             import ( /* webpackChunkName: "views" */ '@/views/wel/dashboard')
//     }]
// },
{
    path: '/distribution',
    component: Layout,
    redirect: '/distribution/index',
    children: [{
        path: 'index',
        name: '警情分发处置',
        meta: {
            i18n: 'distribution'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/distribution/index')
    }]
},
{
    path: '/test',
    component: Layout,
    redirect: '/test/index',
    children: [{
        path: 'index',
        name: '测试页',
        meta: {
            i18n: 'test'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/util/test')
    }]
}, {
    path: '/dict-horizontal',
    component: Layout,
    redirect: '/dict-horizontal/index',
    children: [{
        path: 'index',
        name: '字典管理',
        meta: {
            i18n: 'dict'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/util/demo/dict-horizontal')
    }]
}, {
    path: '/dict-vertical',
    component: Layout,
    redirect: '/dict-vertical/index',
    children: [{
        path: 'index',
        name: '字典管理',
        meta: {
            i18n: 'dict'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/util/demo/dict-vertical')
    }]
}, {
    path: '/info',
    component: Layout,
    redirect: '/info/index',
    children: [{
        path: 'index',
        name: '个人信息',
        meta: {
            i18n: 'info'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/system/userinfo')
    }]
},
{
    path: '/real',
    component: Layout,
    redirect: '/real/video',
    children: [{
        path: 'video',
        name: '视频',
        meta: {
            i18n: 'real'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/Video/video')
    // {
    //     path: '/wel',
    //     component: Layout,
    //     redirect: '/wel/index',
    //     children: [{
    //         path: 'index',
    //         name: '首页',
    //         meta: {
    //             i18n: 'dashboard'
    //         },
    //         component: () =>
    //             import ( /* webpackChunkName: "views" */ '@/views/home/home')
    //     }, {
    //         path: 'dashboard',
    //         name: '控制台',
    //         meta: {
    //             i18n: 'dashboard',
    //             menu: false,
    //         },
    //         component: () =>
    //             import ( /* webpackChunkName: "views" */ '@/views/wel/dashboard')
    //     }]
    // },
    {
        path: '/distribution',
        component: Layout,
        redirect: '/distribution/index',
        children: [{
            path: 'index',
            name: '警情分发处置',
            meta: {
                i18n: 'distribution'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/distribution/index')
        }]
    },
    {
        path: '/test',
        component: Layout,
        redirect: '/test/index',
        children: [{
            path: 'index',
            name: '测试页',
            meta: {
                i18n: 'test'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/util/test')
        }]
    }, {
        path: 'history/:historyId',
        name: '设备历史',
        meta: {
            i18n: 'real'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/realTimePolice/realHistory')
    }]
},
{
    path: '/welcomeData',
    component: Layout,
    redirect: '/welcomeData/data',
    children: [{
        path: 'data',
        name: '数据模式',
        meta: {
            i18n: 'data'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/supervisoryConsole/data')
        path: '/dict-horizontal',
        component: Layout,
        redirect: '/dict-horizontal/index',
        children: [{
            path: 'index',
            name: '字典管理',
            meta: {
                i18n: 'dict'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/util/demo/dict-horizontal')
        }]
    }, {
        path: 'map',
        name: '地图模式',
        meta: {
            i18n: 'map'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/supervisoryConsole/map')
        path: '/dict-vertical',
        component: Layout,
        redirect: '/dict-vertical/index',
        children: [{
            path: 'index',
            name: '字典管理',
            meta: {
                i18n: 'dict'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/util/demo/dict-vertical')
        }]
    }, {
        path: 'card',
        name: '卡片模式',
        meta: {
            i18n: 'card'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/supervisoryConsole/card')
    }]
},
        path: '/info',
        component: Layout,
        redirect: '/info/index',
        children: [{
            path: 'index',
            name: '个人信息',
            meta: {
                i18n: 'info'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/system/userinfo')
        }]
    },
    {
        path: '/real',
        component: Layout,
        redirect: '/real/video',
        children: [{
            path: 'video',
            name: '视频',
            meta: {
                i18n: 'real'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/Video/video')
        }, {
            path: 'history/:historyId',
            name: '设备历史',
            meta: {
                i18n: 'real'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/realTimePolice/realHistory')
        }]
    },
    {
        path: '/welcomeData',
        component: Layout,
        redirect: '/welcomeData/data',
        children: [{
            path: 'data',
            name: '数据模式',
            meta: {
                i18n: 'data'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/supervisoryConsole/data')
        }, {
            path: 'map',
            name: '地图模式',
            meta: {
                i18n: 'map'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/supervisoryConsole/map')
        }, {
            path: 'card',
            name: '卡片模式',
            meta: {
                i18n: 'card'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/supervisoryConsole/card')
        }]
    },
{
    path: '/work/process/leave',
    component: Layout,
    redirect: '/work/process/leave/form',
    children: [{
        path: 'form/:processDefinitionId',
        name: '请假流程',
        meta: {
            i18n: 'work'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/work/process/leave/form')
    }, {
        path: 'handle/:taskId/:processInstanceId/:businessId',
        name: '处理请假流程',
        meta: {
            i18n: 'work'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/work/process/leave/handle')
    }, {
        path: 'detail/:processInstanceId/:businessId',
        name: '请假流程详情',
        meta: {
            i18n: 'work'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/work/process/leave/detail')
    }]
},
{
    path: '/realTimePolice',
    component: Layout,
    redirect: '/realTimePolice/index',
    children: [{
        path: 'index',
        name: '实时报警',
        meta: {
            i18n: 'real'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/realTimePolice/real')
    }]
},
{
    path: '/home',
    component: Layout,
    redirect: '/home/index',
    children: [{
        path: 'index',
        name: '研判洞察',
        meta: {
            i18n: 'home'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/home/home')
    }]
},
{
    path: '/attendance',
    component: Layout,
    redirect: '/attendance/attendance',
    children: [{
        path: 'index',
        name: '考勤管理',
        meta: {
            i18n: 'attendance'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/attendance/attendance')
    }]
},
{
    path: '/clientManagement',
    component: Layout,
    redirect: '/clientManagement/clientManagement',
    children: [{
    {
        path: '/work/process/leave',
        component: Layout,
        redirect: '/work/process/leave/form',
        children: [{
            path: 'form/:processDefinitionId',
            name: '请假流程',
            meta: {
                i18n: 'work'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/work/process/leave/form')
        }, {
            path: 'handle/:taskId/:processInstanceId/:businessId',
            name: '处理请假流程',
            meta: {
                i18n: 'work'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/work/process/leave/handle')
        }, {
            path: 'detail/:processInstanceId/:businessId',
            name: '请假流程详情',
            meta: {
                i18n: 'work'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/work/process/leave/detail')
        }]
    },
    {
        path: '/realTimePolice',
        component: Layout,
        redirect: '/realTimePolice/index',
        children: [{
            path: 'index',
            name: '实时报警',
            meta: {
                i18n: 'real'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/realTimePolice/real')
        }]
    },
    {
        path: '/home',
        component: Layout,
        redirect: '/home/index',
        children: [{
            path: 'index',
            name: '研判洞察',
            meta: {
                i18n: 'home'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/home/home')
        }]
    },
    {
        path: '/attendance',
        component: Layout,
        redirect: '/attendance/attendance',
        children: [{
            path: 'index',
            name: '考勤管理',
            meta: {
                i18n: 'attendance'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/attendance/attendance')
        }]
    },
    {
        path: '/clientManagement',
        component: Layout,
        redirect: '/clientManagement/clientManagement',
        children: [{
        path: 'index',
        name: '设备管理',
        meta: {
            i18n: 'clientManagement'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/clientManagement/clientManagement')
    }]
},
{
    path: '/suser',
    component: Layout,
    redirect: '/suser',
    children: [{
        path: 'index',
        name: '客户管理',
        meta: {
            i18n: 'suser'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/system/cs')
    }]
}, {
    path: '/policeTracking',
    component: Layout,
    redirect: '/policeTracking/track',
    children: [{
        path: 'track',
        name: '警情追踪',
        meta: {
            i18n: 'track'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/policeTracking/policeTracking')
    }]
}, {
    path: '/healthcode',
    component: Layout,
    redirect: '/healthcode/healthcodePage',
    children: [{
        path: 'healthcodePage',
        name: '健康码',
        meta: {
            i18n: 'healthcode'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/healthcode/healthcode')
    }]
}, {
    path: '/animalHeat',
    component: Layout,
    redirect: '/animalHeat/animalHeatPage',
    children: [{
        path: 'animalHeatPage',
        name: '体温检测',
        meta: {
            i18n: 'animalHeat'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/animalHeat/animalHeat')
    }]
}, {
    path: '/alarm',
    component: Layout,
    redirect: '/alarm/alarmPage',
    children: [{
        path: 'alarmPage',
        name: '实时警情',
        meta: {
            i18n: 'alarm'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/alarm/alarm')
    }]
}, {
    path: '/parcel',
    component: Layout,
    redirect: '/parcel/index',
    children: [{
        path: 'index',
        name: '安检包裹',
        meta: {
            i18n: 'parcel'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/parcel/parcel')
    }]
}, {
    path: '/parcelKind',
    component: Layout,
    redirect: '/parcelKind/index',
    children: [{
        path: 'index',
        name: '违禁品',
        meta: {
            i18n: 'parcelKind'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/parcel/parcelKind')
    }]
}, {
    path: '/dataL',
    component: Layout,
    redirect: '/dataL/dataL',
    children: [{
        path: 'dataL',
        name: '详情页',
        meta: {
            i18n: 'dataL'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/dataL/dataL')
    }]
},{//路由占位
    path: '/dataL',
    redirect: '/dataL/hFive',
    component: Layout,
    children: [{
        path: 'hFive',
        name: '提交激活路口',
        meta: {
            i18n: 'dataL'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/dataL/hFive')
    }]
},
{
    path: '/patrolManagement',
    redirect: '/policeInformationDistribution/patrolManagement',
    component: Layout,
    children: [{
        path: 'patrolManagement',
        name: '巡逻管理',
        meta: {
            i18n: 'policeInformationDistribution'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/policeInformationDistribution/patrolManagement')
    }]
},{
    path: '/policeInformationDistribution',
    redirect: '/policeInformationDistribution/policeManagementTeam',
    component: Layout,
    children: [{
        path: 'policeManagementTeam',
        name: '处警队伍管理',
        meta: {
            i18n: 'policeInformationDistribution'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/policeInformationDistribution/policeManagementTeam')
    }]
},{
    path: '/report',
    redirect: '/report/reportConfiguration',
    component: Layout,
    children: [{
        path: 'reportConfiguration',
        name: '报表配置',
        meta: {
            i18n: 'report'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/report/reportConfiguration')
    }]
},{
    path: '/report',
    redirect: '/report/announcementReport',
    component: Layout,
    children: [{
        path: 'announcementReport',
        name: '公告报表',
        meta: {
            i18n: 'report'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/views/report/announcementReport')
    }]
},
{
    path: '/real-popup',
    redirect: '/real-popup/kongbai',
    component: Layout,
    children: [{
        path: 'kongbai',
        name: '首页',
        meta: {
            i18n: 'report'
        },
        component: () =>
            import( /* webpackChunkName: "views" */ '@/components/real-popup/kongbai')
    }]
},
            path: 'index',
            name: '设备管理',
            meta: {
                i18n: 'clientManagement'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/clientManagement/clientManagement')
        }]
    },
    {
        path: '/equipmentInfo',
        component: Layout,
        redirect: '/equipmentInfo/equipmentInfo',
        children: [{
            path: 'index',
            name: '设备管理',
            meta: {
                i18n: 'equipmentInfo'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/equipmentInfo/equipmentInfo')
        }]
    },
    {
        path: '/suser',
        component: Layout,
        redirect: '/suser',
        children: [{
            path: 'index',
            name: '客户管理',
            meta: {
                i18n: 'suser'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/system/cs')
        }]
    }, {
        path: '/policeTracking',
        component: Layout,
        redirect: '/policeTracking/track',
        children: [{
            path: 'track',
            name: '警情追踪',
            meta: {
                i18n: 'track'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/policeTracking/policeTracking')
        }]
    }, {
        path: '/healthcode',
        component: Layout,
        redirect: '/healthcode/healthcodePage',
        children: [{
            path: 'healthcodePage',
            name: '健康码',
            meta: {
                i18n: 'healthcode'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/healthcode/healthcode')
        }]
    }, {
        path: '/animalHeat',
        component: Layout,
        redirect: '/animalHeat/animalHeatPage',
        children: [{
            path: 'animalHeatPage',
            name: '体温检测',
            meta: {
                i18n: 'animalHeat'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/animalHeat/animalHeat')
        }]
    }, {
        path: '/alarm',
        component: Layout,
        redirect: '/alarm/alarmPage',
        children: [{
            path: 'alarmPage',
            name: '实时警情',
            meta: {
                i18n: 'alarm'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/alarm/alarm')
        }]
    }, {
        path: '/parcel',
        component: Layout,
        redirect: '/parcel/index',
        children: [{
            path: 'index',
            name: '安检包裹',
            meta: {
                i18n: 'parcel'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/parcel/parcel')
        }]
    }, {
        path: '/parcelKind',
        component: Layout,
        redirect: '/parcelKind/index',
        children: [{
            path: 'index',
            name: '违禁品',
            meta: {
                i18n: 'parcelKind'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/parcel/parcelKind')
        }]
    }, {
        path: '/dataL',
        component: Layout,
        redirect: '/dataL/dataL',
        children: [{
            path: 'dataL',
            name: '详情页',
            meta: {
                i18n: 'dataL'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/dataL/dataL')
        }]
    }, { //路由占位
        path: '/dataL',
        redirect: '/dataL/hFive',
        component: Layout,
        children: [{
            path: 'hFive',
            name: '提交激活路口',
            meta: {
                i18n: 'dataL'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/dataL/hFive')
        }]
    },
    {
        path: '/patrolManagement',
        redirect: '/policeInformationDistribution/patrolManagement',
        component: Layout,
        children: [{
            path: 'patrolManagement',
            name: '巡逻管理',
            meta: {
                i18n: 'policeInformationDistribution'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/policeInformationDistribution/patrolManagement')
        }]
    }, {
        path: '/policeInformationDistribution',
        redirect: '/policeInformationDistribution/policeManagementTeam',
        component: Layout,
        children: [{
            path: 'policeManagementTeam',
            name: '处警队伍管理',
            meta: {
                i18n: 'policeInformationDistribution'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/policeInformationDistribution/policeManagementTeam')
        }]
    }, {
        path: '/report',
        redirect: '/report/reportConfiguration',
        component: Layout,
        children: [{
            path: 'reportConfiguration',
            name: '报表配置',
            meta: {
                i18n: 'report'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/report/reportConfiguration')
        }]
    }, {
        path: '/report',
        redirect: '/report/announcementReport',
        component: Layout,
        children: [{
            path: 'announcementReport',
            name: '公告报表',
            meta: {
                i18n: 'report'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/report/announcementReport')
        }]
    },
    {
        path: '/real-popup',
        redirect: '/real-popup/kongbai',
        component: Layout,
        children: [{
            path: 'kongbai',
            name: '首页',
            meta: {
                i18n: 'report'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/components/real-popup/kongbai')
        }]
    },
src/views/equipmentInfo/equipmentInfo.vue
New file
@@ -0,0 +1,569 @@
<template>
  <el-row>
    <el-col :span="3">
      <basic-container>
        <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/>
      </basic-container>
    </el-col>
    <el-col :span="21">
      <basic-container>
        <avue-crud :option="option"
                   :table-loading="loading"
                   :data="data"
                   :page.sync="page"
                   ref="crud"
                   @row-del="rowDel"
                   v-model="form"
                   :permission="permissionList"
                   @row-update="rowUpdate"
                   @row-save="rowSave"
                   :row-style="rowStyle"
                   @contextmenu.prevent.native=""
                   @row-contextmenu="rightClick"
                   row-class-name="tabFontSize"
                   :before-open="beforeOpen"
                   @search-change="searchChange"
                   @search-reset="searchReset"
                   @selection-change="selectionChange"
                   @current-change="currentChange"
                   @size-change="sizeChange"
                   @refresh-change="refreshChange"
                   @on-load="onLoad"
                   @row-click="rowClick">
          <template slot="menuLeft">
            <el-button type="danger"
                       size="mini"
                       icon="el-icon-delete"
                       plain
                       v-if="permission.clientManagement_delete"
                       @click="handleDelete">删 除
            </el-button>
          </template>
        </avue-crud>
      </basic-container>
    </el-col>
  </el-row>
</template>
<script>
  import {getList, remove, update, add, getclient, updates,getDeptLazyTree,getBaTree} from "@/api/equipmentInfo/equipmentInfo";
  // import {getDeptTree} from "@/api/system/dept";
  import {mapGetters} from "vuex";
  import axios from "axios";
  import Legend from '../../components/liu-legend/Legend'
  import AvueMap from "avue-plugin-map";
  import website from '@/config/website';
  export default {
    components:{
      Legend,
    },
    created() {
      //this.payWin();
    },
    data() {
      return {
        dataLIU:{
          color:"#DFDFDF"
        },
        form: {},
        query: {},
        showMap: false,
        selectRow:null,
        initFlag: true,
        loading: true,
        menuVisible:false,
        isEdit:false,
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0
        },
        dialogTableVisible: false,
        realjf: false,
        gridData: null,
        selectionList: [],
        treeDeptId: '',
        treeData: [],
        treeOption: {
          nodeKey: 'id',
          lazy: true,
          treeLoad: function (node, resolve) {
            const parentId = (node.level === 0) ? 0 : node.data.id;
            getDeptLazyTree(parentId).then(res => {
              resolve(res.data.data.map(item => {
                return {
                  ...item,
                  leaf: !item.hasChildren
                }
              }))
            });
          },
          addBtn: false,
          menu: false,
          size: 'small',
          props: {
            labelText: '标题',
            label: 'title',
            value: 'value',
            children: 'children'
          }
        },
        option: {
          height: 'auto',
          indexLabel: '序号',
          calcHeight: 54,
          labelWidth: '125',
          dialogWidth: 1150,
          menuWidth: 250,
          align:"center",
          size: "mini",
          tip: false,
          searchShow: true,
          searchMenuSpan: 4,
          searchSpan: 4,
          border: false,
          stripe:true,
          index: true,
          viewBtn: true,
          selection: true,
          dialogClickModal: false,
          indexFixed:false,
          column: [
            {
              label: "设备名称",
              width: 200,
              prop: "name",
              searchPlaceholder: "设备名称",
              search: true,
              sortable:true,
              rules: [{
                required: true,
                message: "请输入设备名称",
                trigger: "blur"
              }],
            },
            {
              label: "设备类型",
              prop: "type",
              width: 130,
              rules: [
                {
                  required: true,
                  message: "请输入设备类型",
                  trigger: "click"
                }
              ]
            },
            {
              label: "使用方",
              prop: "deptName",
              display: false
            },
            {
              label: "使用方",
              prop: "deptId",
              width: 200,
              type: "cascader",
              dicUrl: "/api/blade-system/dept/trees",
              dicData: [],
              checkStrictly:true,
              hide:true,
              props: {
                label: "title"
              },
              rules: [
                {
                  required: true,
                  message: "请选择使用方",
                  trigger: "click"
                }
              ]
            },
            {
              label: "序列号",
              prop: "serialNumber",
              search:true,
              addDisplay: true,
              editDisplay: true,
              viewDisplay: true,
              rules: [{
                required: true,
                message: "请输入序列号",
                trigger: "blur"
              }],
            },{
              label: "省份",
              prop: "province",
              search: true,
              searchSpan: 3,
              labelWidth: '115',
              searchLabelWidth: 45,
              placeholder: "省份",
              type: "select",
              props: {
                label: "name",
                value: "code"
              },
              cascaderItem: ["city", "district"],
              dicUrl: "/api/blade-system/region/select",
              // span: 8,
              className: "city1",
              // hide: true,
              addDisplay: true,
              editDisplay: true,
              viewDisplay: true,
            },
            {
              label: "地市",
              prop: "city",
              type: "select",
              searchPlaceholder: "地市",
              placeholder: "地市",
              searchLabelWidth: 1,
              searchSpan: 2,
              search: true,
              props: {
                label: "name",
                value: "code"
              },
              dicUrl: "/api/blade-system/region/select?code={{key}}",
              // span: 2,
              labelWidth: "0",
              className: "city2",
              // hide: true,
              addDisplay: true,
              editDisplay: true,
              viewDisplay: true,
            },
            {
              label: "区县",
              searchSpan: 2,
              searchLabelWidth: 1,
              searchPlaceholder: "区县",
              placeholder: "区县",
              search: true,
              prop: "district",
              type: "select",
              props: {
                label: "name",
                value: "code"
              },
              dicUrl: "/api/blade-system/region/select?code={{key}}",
              // span: 2,
              labelWidth: "0",
              className: "city3",
              // hide: true,
              addDisplay: true,
              editDisplay: true,
              viewDisplay: true,
            },
            {
              label: "地址",
              prop: "street",
              labelWidth:235,
              searchSpan:10,
            },
            {
              label: null,
              prop: "map",
              labelWidth: "0",
              searchSpan:0,
              maxlength:0,
              hide: true,
              viewDisplay: false,
              span: 2,
              component: "AvueMap"
            },
            {
              label: "备注",
              prop: "remark",
              addDisplay: true,
              editDisplay: true,
              viewDisplay: true,
              hide: true,
              rules: [{
                required: false,
                message: "请输入备注",
                trigger: "blur"
              }],
            }
          ]
        },
        data: []
      };
    },
    watch: {
      "form.map": {
        // form是表单或者表格绑定的数据集,v-model='form'
        handler(val) {
          if (val) {
            var that = this;
            //地址截取,从县/区开始截取,并且取从县区第一个出现的位置开始
            var address = val.formattedAddress.toString();
            if(address.search("县") != -1){
                this.form.street = address.substring(address.indexOf("县")+1,address.length);
            }
            if(address.search("区") != -1){
              this.form.street = address.substring(address.indexOf("区")+1,address.length);
            }
          }
        },
        immediate: true,
      }
    },
    computed: {
      ...mapGetters(["permission"]),
      permissionList() {
        return {
          addBtn: this.vaildData(this.permission.clientManagement_add, false),
          viewBtn: this.vaildData(this.permission.clientManagement_view, false),
          delBtn: this.vaildData(this.permission.clientManagement_delete, false),
          editBtn: this.vaildData(this.permission.clientManagement_edit, false)
        };
      },
      ids() {
        let ids = [];
        this.selectionList.forEach(ele => {
          ids.push(ele.id);
        });
        return ids.join(",");
      }
    },
    mounted(){
      // 租户模式默认加载管理组数据
      // var that = this;
      //that.tenantId = website.tenantId;
    },
    methods: {
      handleClick(row) {
        this.form = row;
        this.dialogTableVisible = true;
        this.realjf = true;
      },
      nodeClick(data) {
        this.treeDeptId = data.id;
        this.page.currentPage = 1;
        this.onLoad(this.page);
      },
      rowSave(row, done, loading) {
        row.deptId = row.deptId.join(",");
        add(row).then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        }, error => {
          window.console.log(error);
          loading();
        });
      },
      rowUpdate(row, index, done, loading) {
        if(Array.isArray(row.deptId)){
            row.deptId = row.deptId.join(",");
        }
        update(row).then(() => {
          // this.initFlag = false;
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        }, error => {
          window.console.log(error);
          loading();
        });
      },
      updateDtype(row){
        row.dtype = "0";
        update(row).then(() => {
          // this.initFlag = false;
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          this.onLoad(this.page);
        }, error => {
          window.console.log(error);
        });
      },
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            return remove(row.id);
          })
          .then(() => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
          });
      },
      searchReset() {
        this.treeDeptId = "";
        this.query = {};
        this.onLoad(this.page);
      },
      searchChange(params, done) {
        console.log(params,done)
        this.query = params;
        this.page.currentPage = 1;
        this.onLoad(this.page, params);
        done();
      },
      selectionChange(list) {
        this.selectionList = list;
      },
      selectionClear() {
        this.selectionList = [];
        this.$refs.crud.toggleSelection();
      },
      handleDelete() {
        if (this.selectionList.length === 0) {
          this.$message.warning("请选择至少一条数据");
          return;
        }
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            return remove(this.ids);
          })
          .then(() => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
            this.$refs.crud.toggleSelection();
          });
      },
      beforeOpen(done, type) {
        if (["edit", "view"].includes(type)) {
          getclient(this.form.id).then(res => {
            this.form = res.data.data;
            this.isEdit=true;
          });
        }
        if (["add"].includes(type)) {
          this.isEdit=false;
        }
        // this.initFlag = true;
        done();
      },
      currentChange(currentPage) {
        this.page.currentPage = currentPage;
      },
      sizeChange(pageSize) {
        this.page.pageSize = pageSize;
      },
      refreshChange() {
        this.onLoad(this.page, this.query);
      },
      onLoad(page, params = {}) {
        const {releaseTimeRange} = this.query;
        let values = {
          ...params,
        };
        if (releaseTimeRange) {
          values = {
            ...params,
            beginTime: releaseTimeRange[0],
            endTime: releaseTimeRange[1],
            ...this.query
          };
          values.releaseTimeRange = null;
        } else {
          values = {
            ...params,
            ...this.query
          };
        }
        this.loading = true;
        getList(page.currentPage, page.pageSize, values, this.treeDeptId).then(res => {
          const data = res.data.data;
          this.page.total = data.total;
          var Dqdate = new Date().getTime();
          for (var i = 0; i < data.records.length; i++) {
            var date = new Date(data.records[i].heartbeat).getTime();
              if(data.records[i].dtype==1){
                  data.records[i].dxzt = 1;
              }
              if(data.records[i].dtype==2){
                  data.records[i].dxzt = 2;
              }
              if(data.records[i].dtype==3){
                  data.records[i].dxzt = 3;
              }
              if(data.records[i].dtype=="" || data.records[i].dtype==0){
                  data.records[i].dxzt = 0;
              }
          }
          this.data = data.records;
          this.loading = false;
          this.selectionClear();
        });
      }, rowStyle({row, column, rowIndex}) {
        if(row.dtype!=null && row.dtype!=""){
          if(row.dtype=='2'){
            return {
              color: "#F34A4A"
            };
          }
        }
      },
      handleManage(row) {
        this.form;
        this.dialogTableVisible = true;
      },rightClick(row, event) {
        this.selectRow = row;
        this.menuVisible = false; // 先把模态框关死,目的是 第二次或者第n次右键鼠标的时候 它默认的是true
        this.menuVisible = true; // 显示模态窗口,跳出自定义菜单栏
        var menu = document.querySelector('#menu');
        this.styleMenu(menu);
      },
      foo() {
        // 取消鼠标监听事件 菜单栏
        this.menuVisible = false;
        document.removeEventListener('click', this.foo); // 要及时关掉监听,不关掉的是一个坑,不信你试试,虽然前台显示的时候没有啥毛病,加一个alert你就知道了
      },
      styleMenu(menu) {
        let cha = document.body.clientHeight - event.clientY
        //console.log(document.body.clientHeight,event.clientY,cha)
        // 防止菜单太靠底,根据可视高度调整菜单出现位置
        if (cha < 150) {
          menu.style.top = event.clientY -120 - (100) + 'px'
        } else {
          menu.style.top = event.clientY -10 - (100) + 'px'
        }
        menu.style.left = event.clientX + 10 - (60) + 'px'
        document.addEventListener('click', this.foo); // 给整个document新增监听鼠标事件,点击任何位置执行foo方法
      }
    }
  };
</script>
<style lang="scss" scoped>
</style>