Commit 7d8a0fc351ed7585dc77597652e21aa655247439
1 parent
368716c9
fix():添加设备列表搜索,通道搜索
Showing
13 changed files
with
155 additions
and
38 deletions
src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java
| @@ -118,12 +118,14 @@ public interface IDeviceService { | @@ -118,12 +118,14 @@ public interface IDeviceService { | ||
| 118 | 118 | ||
| 119 | /** | 119 | /** |
| 120 | * 树形查询接口 | 120 | * 树形查询接口 |
| 121 | - * @param deviceId 设备ID | ||
| 122 | - * @param parentId 父ID | 121 | + * |
| 122 | + * @param deviceId 设备ID | ||
| 123 | + * @param parentId 父ID | ||
| 123 | * @param onlyCatalog 只获取目录 | 124 | * @param onlyCatalog 只获取目录 |
| 125 | + * @param onload | ||
| 124 | * @return | 126 | * @return |
| 125 | */ | 127 | */ |
| 126 | - List<BaseTree<DeviceChannel>> queryVideoDeviceTree(String deviceId, String parentId, boolean onlyCatalog); | 128 | + List<BaseTree<DeviceChannel>> queryVideoDeviceTree(String deviceId, String parentId, boolean onlyCatalog, String onload); |
| 127 | 129 | ||
| 128 | /** | 130 | /** |
| 129 | * 查询树节点下的通道 | 131 | * 查询树节点下的通道 |
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
| @@ -43,6 +43,7 @@ import java.text.ParseException; | @@ -43,6 +43,7 @@ import java.text.ParseException; | ||
| 43 | import java.time.Instant; | 43 | import java.time.Instant; |
| 44 | import java.util.*; | 44 | import java.util.*; |
| 45 | import java.util.concurrent.TimeUnit; | 45 | import java.util.concurrent.TimeUnit; |
| 46 | +import java.util.stream.Collectors; | ||
| 46 | 47 | ||
| 47 | /** | 48 | /** |
| 48 | * 设备业务(目录订阅) | 49 | * 设备业务(目录订阅) |
| @@ -427,7 +428,7 @@ public class DeviceServiceImpl implements IDeviceService { | @@ -427,7 +428,7 @@ public class DeviceServiceImpl implements IDeviceService { | ||
| 427 | 428 | ||
| 428 | 429 | ||
| 429 | @Override | 430 | @Override |
| 430 | - public List<BaseTree<DeviceChannel>> queryVideoDeviceTree(String deviceId, String parentId, boolean onlyCatalog) { | 431 | + public List<BaseTree<DeviceChannel>> queryVideoDeviceTree(String deviceId, String parentId, boolean onlyCatalog, String onload) { |
| 431 | Device device = deviceMapper.getDeviceByDeviceId(deviceId); | 432 | Device device = deviceMapper.getDeviceByDeviceId(deviceId); |
| 432 | if (device == null) { | 433 | if (device == null) { |
| 433 | return null; | 434 | return null; |
| @@ -435,7 +436,16 @@ public class DeviceServiceImpl implements IDeviceService { | @@ -435,7 +436,16 @@ public class DeviceServiceImpl implements IDeviceService { | ||
| 435 | if (ObjectUtils.isEmpty(parentId) ) { | 436 | if (ObjectUtils.isEmpty(parentId) ) { |
| 436 | parentId = deviceId; | 437 | parentId = deviceId; |
| 437 | } | 438 | } |
| 438 | - List<DeviceChannel> rootNodes = deviceChannelMapper.getSubChannelsByDeviceId(deviceId, parentId, onlyCatalog); | 439 | + List<DeviceChannel> rootNodes = null; |
| 440 | + if ("the".equals(onload)){ | ||
| 441 | + rootNodes = deviceChannelMapper.getSubChannelsByDeviceId(deviceId, parentId, onlyCatalog) | ||
| 442 | + .stream().filter(ch -> Objects.equals(ch.getChannelId(), "34020000001310000001") | ||
| 443 | + || Objects.equals(ch.getChannelId(), "34020000001310000002")).collect(Collectors.toList()); | ||
| 444 | + }else { | ||
| 445 | + rootNodes = deviceChannelMapper.getSubChannelsByDeviceId(deviceId, parentId, onlyCatalog); | ||
| 446 | + } | ||
| 447 | + | ||
| 448 | + | ||
| 439 | return transportChannelsToTree(rootNodes, ""); | 449 | return transportChannelsToTree(rootNodes, ""); |
| 440 | } | 450 | } |
| 441 | 451 |
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java
| @@ -10,17 +10,17 @@ import com.github.pagehelper.PageInfo; | @@ -10,17 +10,17 @@ import com.github.pagehelper.PageInfo; | ||
| 10 | 10 | ||
| 11 | import java.util.List; | 11 | import java.util.List; |
| 12 | 12 | ||
| 13 | -/** | 13 | +/** |
| 14 | * @description:视频设备数据存储接口 | 14 | * @description:视频设备数据存储接口 |
| 15 | * @author: swwheihei | 15 | * @author: swwheihei |
| 16 | - * @date: 2020年5月6日 下午2:14:31 | 16 | + * @date: 2020年5月6日 下午2:14:31 |
| 17 | */ | 17 | */ |
| 18 | @SuppressWarnings("rawtypes") | 18 | @SuppressWarnings("rawtypes") |
| 19 | public interface IVideoManagerStorage { | 19 | public interface IVideoManagerStorage { |
| 20 | 20 | ||
| 21 | - /** | 21 | + /** |
| 22 | * 根据设备ID判断设备是否存在 | 22 | * 根据设备ID判断设备是否存在 |
| 23 | - * | 23 | + * |
| 24 | * @param deviceId 设备ID | 24 | * @param deviceId 设备ID |
| 25 | * @return true:存在 false:不存在 | 25 | * @return true:存在 false:不存在 |
| 26 | */ | 26 | */ |
| @@ -40,10 +40,10 @@ public interface IVideoManagerStorage { | @@ -40,10 +40,10 @@ public interface IVideoManagerStorage { | ||
| 40 | * @param channelId 通道ID | 40 | * @param channelId 通道ID |
| 41 | */ | 41 | */ |
| 42 | public void stopPlay(String deviceId, String channelId); | 42 | public void stopPlay(String deviceId, String channelId); |
| 43 | - | ||
| 44 | - /** | 43 | + |
| 44 | + /** | ||
| 45 | * 获取设备 | 45 | * 获取设备 |
| 46 | - * | 46 | + * |
| 47 | * @param deviceId 设备ID | 47 | * @param deviceId 设备ID |
| 48 | * @return DShadow 设备对象 | 48 | * @return DShadow 设备对象 |
| 49 | */ | 49 | */ |
| @@ -58,7 +58,7 @@ public interface IVideoManagerStorage { | @@ -58,7 +58,7 @@ public interface IVideoManagerStorage { | ||
| 58 | * @return | 58 | * @return |
| 59 | */ | 59 | */ |
| 60 | public PageInfo<DeviceChannel> queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count); | 60 | public PageInfo<DeviceChannel> queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count); |
| 61 | - | 61 | + |
| 62 | public List<DeviceChannelExtend> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List<String> channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit); | 62 | public List<DeviceChannelExtend> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List<String> channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit); |
| 63 | 63 | ||
| 64 | 64 | ||
| @@ -87,11 +87,20 @@ public interface IVideoManagerStorage { | @@ -87,11 +87,20 @@ public interface IVideoManagerStorage { | ||
| 87 | 87 | ||
| 88 | /** | 88 | /** |
| 89 | * 获取多个设备 | 89 | * 获取多个设备 |
| 90 | - * @param page 当前页数 | ||
| 91 | - * @param count 每页数量 | 90 | + * |
| 91 | + * @param page 当前页数 | ||
| 92 | + * @param count 每页数量 | ||
| 93 | + * @param deviceId | ||
| 94 | + * @return List<Device> 设备对象数组 | ||
| 95 | + */ | ||
| 96 | + public PageInfo<Device> queryVideoDeviceList(int page, int count, Boolean online, String deviceId);/** | ||
| 97 | + * 获取多个设备 | ||
| 98 | + * | ||
| 99 | + * @param page 当前页数 | ||
| 100 | + * @param count 每页数量 | ||
| 92 | * @return List<Device> 设备对象数组 | 101 | * @return List<Device> 设备对象数组 |
| 93 | */ | 102 | */ |
| 94 | - public PageInfo<Device> queryVideoDeviceList(int page, int count,Boolean online); | 103 | + public PageInfo<Device> queryVideoDeviceList(int page, int count, Boolean online); |
| 95 | 104 | ||
| 96 | /** | 105 | /** |
| 97 | * 获取多个设备 | 106 | * 获取多个设备 |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
| @@ -540,8 +540,8 @@ public interface DeviceChannelMapper { | @@ -540,8 +540,8 @@ public interface DeviceChannelMapper { | ||
| 540 | "from wvp_device_channel " + | 540 | "from wvp_device_channel " + |
| 541 | "where device_id=#{deviceId}" + | 541 | "where device_id=#{deviceId}" + |
| 542 | " <if test='parentId != null and parentId != deviceId'> and parent_id = #{parentId} </if>" + | 542 | " <if test='parentId != null and parentId != deviceId'> and parent_id = #{parentId} </if>" + |
| 543 | - " <if test='parentId == null or parentId == deviceId'> and parent_id is null or parent_id = #{deviceId}</if>" + | ||
| 544 | - " <if test='onlyCatalog == true '> and parental = 1 </if>" + | 543 | + " <if test='parentId == null or parentId == deviceId'> and (parent_id is null or parent_id = #{deviceId} ) </if>" + |
| 544 | + " <if test='onlyCatalog == true '> and parental = 1 </if>" + | ||
| 545 | " </script>"}) | 545 | " </script>"}) |
| 546 | List<DeviceChannel> getSubChannelsByDeviceId(@Param("deviceId") String deviceId, @Param("parentId") String parentId, @Param("onlyCatalog") boolean onlyCatalog); | 546 | List<DeviceChannel> getSubChannelsByDeviceId(@Param("deviceId") String deviceId, @Param("parentId") String parentId, @Param("onlyCatalog") boolean onlyCatalog); |
| 547 | 547 | ||
| @@ -550,4 +550,6 @@ public interface DeviceChannelMapper { | @@ -550,4 +550,6 @@ public interface DeviceChannelMapper { | ||
| 550 | " <if test='channelId != null'> and channel_id = #{channelId} </if>" + | 550 | " <if test='channelId != null'> and channel_id = #{channelId} </if>" + |
| 551 | "</script>") | 551 | "</script>") |
| 552 | void updateChannelStreamIdentification(DeviceChannel channel); | 552 | void updateChannelStreamIdentification(DeviceChannel channel); |
| 553 | + | ||
| 554 | + | ||
| 553 | } | 555 | } |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
| @@ -170,6 +170,49 @@ public interface DeviceMapper { | @@ -170,6 +170,49 @@ public interface DeviceMapper { | ||
| 170 | ) | 170 | ) |
| 171 | List<Device> getDevices(Boolean onLine); | 171 | List<Device> getDevices(Boolean onLine); |
| 172 | 172 | ||
| 173 | + @Select( | ||
| 174 | + " <script>" + | ||
| 175 | + "SELECT " + | ||
| 176 | + "device_id, " + | ||
| 177 | + "coalesce(custom_name, name) as name, " + | ||
| 178 | + "password, " + | ||
| 179 | + "manufacturer, " + | ||
| 180 | + "model, " + | ||
| 181 | + "firmware, " + | ||
| 182 | + "transport," + | ||
| 183 | + "stream_mode," + | ||
| 184 | + "ip,"+ | ||
| 185 | + "sdp_ip,"+ | ||
| 186 | + "local_ip,"+ | ||
| 187 | + "port,"+ | ||
| 188 | + "host_address,"+ | ||
| 189 | + "expires,"+ | ||
| 190 | + "register_time,"+ | ||
| 191 | + "keepalive_time,"+ | ||
| 192 | + "create_time,"+ | ||
| 193 | + "update_time,"+ | ||
| 194 | + "charset,"+ | ||
| 195 | + "subscribe_cycle_for_catalog,"+ | ||
| 196 | + "subscribe_cycle_for_mobile_position,"+ | ||
| 197 | + "mobile_position_submission_interval,"+ | ||
| 198 | + "subscribe_cycle_for_alarm,"+ | ||
| 199 | + "ssrc_check,"+ | ||
| 200 | + "as_message_channel,"+ | ||
| 201 | + "broadcast_push_after_ack,"+ | ||
| 202 | + "geo_coord_sys,"+ | ||
| 203 | + "on_line,"+ | ||
| 204 | + "media_server_id,"+ | ||
| 205 | + "(SELECT count(0) FROM wvp_device_channel WHERE device_id=de.device_id) as channel_count " + | ||
| 206 | + "FROM wvp_device de" + | ||
| 207 | + "<where>" + | ||
| 208 | + " <if test=\"onLine != null\"> AND on_line=${onLine}</if>"+ | ||
| 209 | + " <if test=\"deviceId != null and deviceId != ''\"> AND coalesce(custom_name, name) like CONCAT('%',#{deviceId},'%')</if>" + | ||
| 210 | + "</where>"+ | ||
| 211 | + " order by on_line desc,create_time desc "+ | ||
| 212 | + " </script>" | ||
| 213 | + ) | ||
| 214 | + List<Device> getDevicesByDeviceId(@Param("onLine") Boolean onLine, @Param("deviceId") String deviceId); | ||
| 215 | + | ||
| 173 | @Delete("DELETE FROM wvp_device WHERE device_id=#{deviceId}") | 216 | @Delete("DELETE FROM wvp_device WHERE device_id=#{deviceId}") |
| 174 | int del(String deviceId); | 217 | int del(String deviceId); |
| 175 | 218 |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
| @@ -7,7 +7,6 @@ import com.genersoft.iot.vmp.gb28181.bean.*; | @@ -7,7 +7,6 @@ import com.genersoft.iot.vmp.gb28181.bean.*; | ||
| 7 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | 7 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 8 | import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; | 8 | import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; |
| 9 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; | 9 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 10 | -import com.genersoft.iot.vmp.service.IGbStreamService; | ||
| 11 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; | 10 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| 12 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 11 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 13 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 12 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| @@ -445,12 +444,20 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | @@ -445,12 +444,20 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | ||
| 445 | /** | 444 | /** |
| 446 | * 获取多个设备 | 445 | * 获取多个设备 |
| 447 | * | 446 | * |
| 448 | - * @param page 当前页数 | ||
| 449 | - * @param count 每页数量 | 447 | + * @param page 当前页数 |
| 448 | + * @param count 每页数量 | ||
| 449 | + * @param deviceId | ||
| 450 | * @return PageInfo<Device> 分页设备对象数组 | 450 | * @return PageInfo<Device> 分页设备对象数组 |
| 451 | */ | 451 | */ |
| 452 | @Override | 452 | @Override |
| 453 | - public PageInfo<Device> queryVideoDeviceList(int page, int count,Boolean online) { | 453 | + public PageInfo<Device> queryVideoDeviceList(int page, int count, Boolean online, String deviceId) { |
| 454 | + PageHelper.startPage(page, count); | ||
| 455 | + List<Device> all = deviceMapper.getDevicesByDeviceId(online,deviceId); | ||
| 456 | + return new PageInfo<>(all); | ||
| 457 | + } | ||
| 458 | + | ||
| 459 | + @Override | ||
| 460 | + public PageInfo<Device> queryVideoDeviceList(int page, int count, Boolean online) { | ||
| 454 | PageHelper.startPage(page, count); | 461 | PageHelper.startPage(page, count); |
| 455 | List<Device> all = deviceMapper.getDevices(online); | 462 | List<Device> all = deviceMapper.getDevices(online); |
| 456 | return new PageInfo<>(all); | 463 | return new PageInfo<>(all); |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
| @@ -112,10 +112,10 @@ public class DeviceQuery { | @@ -112,10 +112,10 @@ public class DeviceQuery { | ||
| 112 | @Parameter(name = "online", description = "在线状态") | 112 | @Parameter(name = "online", description = "在线状态") |
| 113 | @GetMapping("/devices") | 113 | @GetMapping("/devices") |
| 114 | @Options() | 114 | @Options() |
| 115 | - public PageInfo<Device> devices(int page, int count,Boolean online) { | 115 | + public PageInfo<Device> devices(int page, int count,Boolean online,String deviceId) { |
| 116 | // if (page == null) page = 0; | 116 | // if (page == null) page = 0; |
| 117 | // if (count == null) count = 20; | 117 | // if (count == null) count = 20; |
| 118 | - return storager.queryVideoDeviceList(page, count, online); | 118 | + return storager.queryVideoDeviceList(page, count, online, deviceId); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | /** | 121 | /** |
| @@ -541,6 +541,7 @@ public class DeviceQuery { | @@ -541,6 +541,7 @@ public class DeviceQuery { | ||
| 541 | public ResponseEntity<PageInfo> getTree(@PathVariable String deviceId, | 541 | public ResponseEntity<PageInfo> getTree(@PathVariable String deviceId, |
| 542 | @RequestParam(required = false) String parentId, | 542 | @RequestParam(required = false) String parentId, |
| 543 | @RequestParam(required = false) Boolean onlyCatalog, | 543 | @RequestParam(required = false) Boolean onlyCatalog, |
| 544 | + @RequestParam(required = false) String online, | ||
| 544 | int page, int count) { | 545 | int page, int count) { |
| 545 | 546 | ||
| 546 | 547 | ||
| @@ -551,7 +552,7 @@ public class DeviceQuery { | @@ -551,7 +552,7 @@ public class DeviceQuery { | ||
| 551 | onlyCatalog = false; | 552 | onlyCatalog = false; |
| 552 | } | 553 | } |
| 553 | 554 | ||
| 554 | - List<BaseTree<DeviceChannel>> treeData = deviceService.queryVideoDeviceTree(deviceId, parentId, onlyCatalog); | 555 | + List<BaseTree<DeviceChannel>> treeData = deviceService.queryVideoDeviceTree(deviceId, parentId, onlyCatalog, online); |
| 555 | if (treeData == null || (page - 1) * count > treeData.size()) { | 556 | if (treeData == null || (page - 1) * count > treeData.size()) { |
| 556 | PageInfo<BaseTree<DeviceChannel>> pageInfo = new PageInfo<>(); | 557 | PageInfo<BaseTree<DeviceChannel>> pageInfo = new PageInfo<>(); |
| 557 | pageInfo.setPageNum(page); | 558 | pageInfo.setPageNum(page); |
src/main/resources/application.yml
web_src/config/index.js
| @@ -11,14 +11,14 @@ module.exports = { | @@ -11,14 +11,14 @@ module.exports = { | ||
| 11 | assetsPublicPath: "/", | 11 | assetsPublicPath: "/", |
| 12 | proxyTable: { | 12 | proxyTable: { |
| 13 | "/debug": { | 13 | "/debug": { |
| 14 | - target: "http://192.168.20.215:18089", | 14 | + target: "http://127.0.0.1:16000", |
| 15 | changeOrigin: true, | 15 | changeOrigin: true, |
| 16 | pathRewrite: { | 16 | pathRewrite: { |
| 17 | "^/debug": "/", | 17 | "^/debug": "/", |
| 18 | }, | 18 | }, |
| 19 | }, | 19 | }, |
| 20 | "/static/snap": { | 20 | "/static/snap": { |
| 21 | - target: "http://61.169.120.202:18089", | 21 | + target: "http://127.0.0.1:16000", |
| 22 | changeOrigin: true, | 22 | changeOrigin: true, |
| 23 | // pathRewrite: { | 23 | // pathRewrite: { |
| 24 | // '^/static/snap': '/static/snap' | 24 | // '^/static/snap': '/static/snap' |
web_src/src/components/DeviceList.vue
| @@ -10,7 +10,8 @@ | @@ -10,7 +10,8 @@ | ||
| 10 | <el-option label="在线" value="true"></el-option> | 10 | <el-option label="在线" value="true"></el-option> |
| 11 | <el-option label="离线" value="false"></el-option> | 11 | <el-option label="离线" value="false"></el-option> |
| 12 | </el-select> | 12 | </el-select> |
| 13 | - | 13 | + <el-input size="mini" style="width: 8rem; margin-right: 1rem;" placeholder="请输入名称关键字" v-model="deviceId"></el-input> |
| 14 | + <el-button icon="el-icon-search" size="mini" style="margin-right: 1rem;" type="primary" @click="getDeviceList()">搜索</el-button> | ||
| 14 | <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="add">添加设备 | 15 | <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="add">添加设备 |
| 15 | </el-button> | 16 | </el-button> |
| 16 | <el-button icon="el-icon-refresh-right" circle size="mini" :loading="getDeviceListLoading" | 17 | <el-button icon="el-icon-refresh-right" circle size="mini" :loading="getDeviceListLoading" |
| @@ -114,7 +115,7 @@ export default { | @@ -114,7 +115,7 @@ export default { | ||
| 114 | return { | 115 | return { |
| 115 | deviceList: [], //设备列表 | 116 | deviceList: [], //设备列表 |
| 116 | currentDevice: {}, //当前操作设备对象 | 117 | currentDevice: {}, //当前操作设备对象 |
| 117 | - | 118 | + deviceId: '', |
| 118 | videoComponentList: [], | 119 | videoComponentList: [], |
| 119 | updateLooper: 0, //数据刷新轮训标志 | 120 | updateLooper: 0, //数据刷新轮训标志 |
| 120 | currentDeviceChannelsLenth: 0, | 121 | currentDeviceChannelsLenth: 0, |
| @@ -167,7 +168,8 @@ export default { | @@ -167,7 +168,8 @@ export default { | ||
| 167 | params: { | 168 | params: { |
| 168 | page: this.currentPage, | 169 | page: this.currentPage, |
| 169 | count: this.count, | 170 | count: this.count, |
| 170 | - online:this.online | 171 | + online:this.online, |
| 172 | + deviceId: this.deviceId | ||
| 171 | } | 173 | } |
| 172 | }).then( (res)=> { | 174 | }).then( (res)=> { |
| 173 | if (res.data.code === 0) { | 175 | if (res.data.code === 0) { |
web_src/src/components/common/DeviceTree.vue
| @@ -3,8 +3,17 @@ | @@ -3,8 +3,17 @@ | ||
| 3 | <el-container> | 3 | <el-container> |
| 4 | <el-header>设备列表</el-header> | 4 | <el-header>设备列表</el-header> |
| 5 | <el-main style="background-color: #ffffff;"> | 5 | <el-main style="background-color: #ffffff;"> |
| 6 | + <el-input v-model="filterText" placeholder="输入关键字进行过滤" | ||
| 7 | + clearable size="small" | ||
| 8 | + prefix-icon="el-icon-search" style="margin-bottom: 5px" /> | ||
| 6 | <div class="device-tree-main-box"> | 9 | <div class="device-tree-main-box"> |
| 7 | - <el-tree ref="gdTree" :props="defaultProps" :load="loadNode" lazy @node-click="handleNodeClick"@node-contextmenu="handleContextMenu" node-key="id" style="min-width: 100%; display:inline-block !important;"> | 10 | + <el-tree ref="gdTree" |
| 11 | + :props="defaultProps" | ||
| 12 | + :load="loadNode" lazy | ||
| 13 | + :filter-node-method="filterNode" | ||
| 14 | + @node-click="handleNodeClick" | ||
| 15 | + @node-contextmenu="handleContextMenu" | ||
| 16 | + node-key="id" style="min-width: 100%; display:inline-block !important;"> | ||
| 8 | <span class="custom-tree-node" slot-scope="{ node, data }" style="width: 100%"> | 17 | <span class="custom-tree-node" slot-scope="{ node, data }" style="width: 100%"> |
| 9 | <span v-if="node.data.type === 0 && node.data.online" title="在线设备" class="device-online iconfont icon-jiedianleizhukongzhongxin2"></span> | 18 | <span v-if="node.data.type === 0 && node.data.online" title="在线设备" class="device-online iconfont icon-jiedianleizhukongzhongxin2"></span> |
| 10 | <span v-if="node.data.type === 0 && !node.data.online " title="离线设备" class="device-offline iconfont icon-jiedianleizhukongzhongxin2"></span> | 19 | <span v-if="node.data.type === 0 && !node.data.online " title="离线设备" class="device-offline iconfont icon-jiedianleizhukongzhongxin2"></span> |
| @@ -37,6 +46,11 @@ import DeviceService from "../service/DeviceService.js"; | @@ -37,6 +46,11 @@ import DeviceService from "../service/DeviceService.js"; | ||
| 37 | 46 | ||
| 38 | export default { | 47 | export default { |
| 39 | name: 'DeviceTree', | 48 | name: 'DeviceTree', |
| 49 | + watch: { | ||
| 50 | + filterText(val) { | ||
| 51 | + this.$refs.gdTree.filter(val); | ||
| 52 | + } | ||
| 53 | + }, | ||
| 40 | data() { | 54 | data() { |
| 41 | return { | 55 | return { |
| 42 | deviceService: new DeviceService(), | 56 | deviceService: new DeviceService(), |
| @@ -44,11 +58,35 @@ export default { | @@ -44,11 +58,35 @@ export default { | ||
| 44 | children: 'children', | 58 | children: 'children', |
| 45 | label: 'name', | 59 | label: 'name', |
| 46 | isLeaf: 'isLeaf' | 60 | isLeaf: 'isLeaf' |
| 47 | - } | 61 | + }, |
| 62 | + filterText: '', | ||
| 63 | + online: 'the' | ||
| 48 | }; | 64 | }; |
| 49 | }, | 65 | }, |
| 50 | props: ['device', 'onlyCatalog', 'clickEvent', 'contextMenuEvent'], | 66 | props: ['device', 'onlyCatalog', 'clickEvent', 'contextMenuEvent'], |
| 51 | methods: { | 67 | methods: { |
| 68 | + /** | ||
| 69 | + * 模糊查询树 | ||
| 70 | + */ | ||
| 71 | + filterNode(value, data, node) { | ||
| 72 | + console.log('查询 ====》',value,node) | ||
| 73 | + if (!value) return true; | ||
| 74 | + return this.findSearKey(node, value) | ||
| 75 | + }, | ||
| 76 | + /** | ||
| 77 | + * 递归搜索父级是否包含关键字 | ||
| 78 | + */ | ||
| 79 | + findSearKey(node, key) { | ||
| 80 | + if (node.label.toLowerCase().indexOf(key) !== -1 || node.label.toUpperCase().indexOf(key) !== -1) { | ||
| 81 | + return true; | ||
| 82 | + } else { | ||
| 83 | + if (node.parent.parent == null) { | ||
| 84 | + return false; | ||
| 85 | + } else { | ||
| 86 | + return this.findSearKey(node.parent, key); | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + }, | ||
| 52 | handleNodeClick(data,node,element) { | 90 | handleNodeClick(data,node,element) { |
| 53 | let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId) | 91 | let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId) |
| 54 | if(typeof (this.clickEvent) == "function") { | 92 | if(typeof (this.clickEvent) == "function") { |
| @@ -104,9 +142,8 @@ export default { | @@ -104,9 +142,8 @@ export default { | ||
| 104 | } | 142 | } |
| 105 | }else { | 143 | }else { |
| 106 | let channelArray = [] | 144 | let channelArray = [] |
| 107 | - | 145 | + console.log("online ===> ", this.online) |
| 108 | this.deviceService.getTree(node.data.userData.deviceId, node.data.id, this.onlyCatalog, catalogData =>{ | 146 | this.deviceService.getTree(node.data.userData.deviceId, node.data.id, this.onlyCatalog, catalogData =>{ |
| 109 | - console.log(catalogData) | ||
| 110 | channelArray = channelArray.concat(catalogData) | 147 | channelArray = channelArray.concat(catalogData) |
| 111 | this.channelDataHandler(channelArray, resolve) | 148 | this.channelDataHandler(channelArray, resolve) |
| 112 | },(endCatalogData) => { | 149 | },(endCatalogData) => { |
web_src/src/components/live.vue
| @@ -149,10 +149,13 @@ export default { | @@ -149,10 +149,13 @@ export default { | ||
| 149 | } else { | 149 | } else { |
| 150 | that.$message.error(res.data.msg); | 150 | that.$message.error(res.data.msg); |
| 151 | } | 151 | } |
| 152 | + that.loading = false | ||
| 152 | }).catch(function (e) { | 153 | }).catch(function (e) { |
| 154 | + that.loading = false | ||
| 153 | }).finally(() => { | 155 | }).finally(() => { |
| 154 | that.loading = false | 156 | that.loading = false |
| 155 | }); | 157 | }); |
| 158 | + | ||
| 156 | }, | 159 | }, |
| 157 | setPlayUrl(url, idx) { | 160 | setPlayUrl(url, idx) { |
| 158 | this.$set(this.videoUrl, idx, url) | 161 | this.$set(this.videoUrl, idx, url) |
web_src/src/components/service/DeviceService.js
| @@ -134,7 +134,7 @@ class DeviceService{ | @@ -134,7 +134,7 @@ class DeviceService{ | ||
| 134 | }).catch(errorCallback); | 134 | }).catch(errorCallback); |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | - getTree(deviceId, parentId, onlyCatalog, callback, endCallback, errorCallback) { | 137 | + getTree(deviceId, parentId, onlyCatalog, callback, endCallback, errorCallback ) { |
| 138 | let currentPage = 1; | 138 | let currentPage = 1; |
| 139 | let count = 100; | 139 | let count = 100; |
| 140 | let catalogList = [] | 140 | let catalogList = [] |
| @@ -166,7 +166,8 @@ class DeviceService{ | @@ -166,7 +166,8 @@ class DeviceService{ | ||
| 166 | page: currentPage, | 166 | page: currentPage, |
| 167 | count: count, | 167 | count: count, |
| 168 | parentId: parentId, | 168 | parentId: parentId, |
| 169 | - onlyCatalog: onlyCatalog | 169 | + onlyCatalog: onlyCatalog, |
| 170 | + online: 'the' | ||
| 170 | } | 171 | } |
| 171 | }).then((res) =>{ | 172 | }).then((res) =>{ |
| 172 | if (typeof (callback) == "function") callback(res.data) | 173 | if (typeof (callback) == "function") callback(res.data) |