parent
a45719001d
commit
c167b547ad
@ -0,0 +1,41 @@
|
||||
package com.ruoyi.business.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.business.domain.HwOfflineTarget;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 离线报警规则目标Mapper接口
|
||||
*
|
||||
* @author xins
|
||||
* @date 2023-11-13
|
||||
*/
|
||||
public interface HwOfflineTargetMapper {
|
||||
/**
|
||||
* 批量新增离线报警规则目标列表
|
||||
*
|
||||
* @param offlineTargetList 离线报警规则分配目标列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchInsertOfflineTarget(List<HwOfflineTarget> offlineTargetList);
|
||||
|
||||
/**
|
||||
* 删除离线报警规则和目标关联信息
|
||||
*
|
||||
* @param offlineTarget 离线报警规则和目标关联信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteOfflineTarget(HwOfflineTarget offlineTarget);
|
||||
|
||||
/**
|
||||
* 批量取消已分配离线报警规则目标列表
|
||||
*
|
||||
* @param offlineRuleId 离线报警规则ID
|
||||
* @param targetType 目标类型
|
||||
* @param targetIds 需要删除的目标数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteOfflineTargets(@Param("offlineRuleId") Long offlineRuleId,
|
||||
@Param("targetType") String targetType, @Param("targetIds") Long[] targetIds);
|
||||
}
|
@ -0,0 +1,239 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.business.mapper.HwOfflineRuleMapper">
|
||||
|
||||
<resultMap type="HwOfflineRule" id="HwOfflineRuleResult">
|
||||
<result property="offlineRuleId" column="offline_rule_id" />
|
||||
<result property="offlineRuleName" column="offline_rule_name" />
|
||||
<result property="tenantId" column="tenant_id" />
|
||||
<result property="sceneId" column="scene_id" />
|
||||
<result property="alarmLevelId" column="alarm_level_id" />
|
||||
<result property="ruleType" column="rule_type" />
|
||||
<result property="offlineTime" column="offline_time" />
|
||||
<result property="offlineNumberTime" column="offline_number_time" />
|
||||
<result property="offlineNumber" column="offline_number" />
|
||||
<result property="triggerTimeFrame" column="trigger_time_frame" />
|
||||
<result property="consumeTraffic" column="consume_traffic" />
|
||||
<result property="batteryLevel" column="battery_level" />
|
||||
<result property="powerDownFlag" column="power_down_flag" />
|
||||
<result property="linkFlag" column="link_flag" />
|
||||
<result property="alarmRuleStatus" column="alarm_rule_status" />
|
||||
<result property="alarmPushFlag" column="alarm_push_flag" />
|
||||
<result property="alarmPushContent" column="alarm_push_content" />
|
||||
<result property="alarmRecoverContent" column="alarm_recover_content" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="offlineRuleField" column="offline_rule_field" />
|
||||
<result property="tenantName" column="tenant_name" />
|
||||
<result property="sceneName" column="scene_name" />
|
||||
<result property="alarmLevelName" column="alarm_level_name" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="HwOfflineRuleHwAlarmRuleLinkResult" type="HwOfflineRule" extends="HwOfflineRuleResult">
|
||||
<collection property="hwAlarmRuleLinkList" notNullColumn="sub_rule_link_id" javaType="java.util.List" resultMap="HwAlarmRuleLinkResult" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="HwAlarmRuleLink" id="HwAlarmRuleLinkResult">
|
||||
<result property="ruleLinkId" column="sub_rule_link_id" />
|
||||
<result property="alarmRuleType" column="sub_alarm_rule_type" />
|
||||
<result property="alarmRuleId" column="sub_alarm_rule_id" />
|
||||
<result property="linkType" column="sub_link_type" />
|
||||
<result property="linkDeviceId" column="sub_link_device_id" />
|
||||
<result property="linkDeviceFunctionId" column="sub_link_device_function_id" />
|
||||
<result property="linkDeviceFunctionIdentifier" column="sub_link_device_function_identifier" />
|
||||
<result property="linkDeviceFunctionData" column="sub_link_device_function_data" />
|
||||
<result property="linkDeviceName" column="sub_link_device_name" />
|
||||
<result property="linkDeviceModeFunctionName" column="sub_link_device_mode_function_name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectHwOfflineRuleVo">
|
||||
select offline_rule_id, offline_rule_name, tenant_id, scene_id, alarm_level_id, rule_type, offline_time, offline_number_time, offline_number, trigger_time_frame, consume_traffic, battery_level, power_down_flag, link_flag, alarm_rule_status, alarm_push_flag, alarm_push_content, alarm_recover_content, remark, create_by, create_time, update_by, update_time, offline_rule_field from hw_offline_rule
|
||||
</sql>
|
||||
|
||||
<select id="selectHwOfflineRuleList" parameterType="HwOfflineRule" resultMap="HwOfflineRuleResult">
|
||||
<include refid="selectHwOfflineRuleVo"/>
|
||||
<where>
|
||||
<if test="offlineRuleName != null and offlineRuleName != ''"> and offline_rule_name like concat('%', #{offlineRuleName}, '%')</if>
|
||||
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
|
||||
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
|
||||
<if test="alarmLevelId != null "> and alarm_level_id = #{alarmLevelId}</if>
|
||||
<if test="ruleType != null and ruleType != ''"> and rule_type = #{ruleType}</if>
|
||||
<if test="offlineTime != null "> and offline_time = #{offlineTime}</if>
|
||||
<if test="offlineNumberTime != null "> and offline_number_time = #{offlineNumberTime}</if>
|
||||
<if test="offlineNumber != null "> and offline_number = #{offlineNumber}</if>
|
||||
<if test="triggerTimeFrame != null and triggerTimeFrame != ''"> and trigger_time_frame = #{triggerTimeFrame}</if>
|
||||
<if test="consumeTraffic != null "> and consume_traffic = #{consumeTraffic}</if>
|
||||
<if test="batteryLevel != null "> and battery_level = #{batteryLevel}</if>
|
||||
<if test="powerDownFlag != null and powerDownFlag != ''"> and power_down_flag = #{powerDownFlag}</if>
|
||||
<if test="linkFlag != null and linkFlag != ''"> and link_flag = #{linkFlag}</if>
|
||||
<if test="alarmRuleStatus != null and alarmRuleStatus != ''"> and alarm_rule_status = #{alarmRuleStatus}</if>
|
||||
<if test="alarmPushFlag != null and alarmPushFlag != ''"> and alarm_push_flag = #{alarmPushFlag}</if>
|
||||
<if test="alarmPushContent != null and alarmPushContent != ''"> and alarm_push_content = #{alarmPushContent}</if>
|
||||
<if test="alarmRecoverContent != null and alarmRecoverContent != ''"> and alarm_recover_content = #{alarmRecoverContent}</if>
|
||||
<if test="offlineRuleField != null and offlineRuleField != ''"> and offline_rule_field = #{offlineRuleField}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectHwOfflineRuleByOfflineRuleId" parameterType="Long" resultMap="HwOfflineRuleHwAlarmRuleLinkResult">
|
||||
select a.offline_rule_id, a.offline_rule_name, a.tenant_id, a.scene_id, a.alarm_level_id, a.rule_type, a.offline_time, a.offline_number_time, a.offline_number, a.trigger_time_frame, a.consume_traffic, a.battery_level, a.power_down_flag, a.link_flag, a.alarm_rule_status, a.alarm_push_flag, a.alarm_push_content, a.alarm_recover_content, a.remark, a.create_by, a.create_time, a.update_by, a.update_time, a.offline_rule_field,
|
||||
b.rule_link_id as sub_rule_link_id, b.alarm_rule_type as sub_alarm_rule_type, b.alarm_rule_id as sub_alarm_rule_id, b.link_type as sub_link_type, b.link_device_id as sub_link_device_id, b.link_device_function_id as sub_link_device_function_id, b.link_device_function_identifier as sub_link_device_function_identifier, b.link_device_function_data as sub_link_device_function_data,
|
||||
hd.device_name as sub_link_device_name,hdmf.function_name as sub_link_device_mode_function_name from hw_offline_rule a
|
||||
left join hw_alarm_rule_link b on b.alarm_rule_id = a.offline_rule_id and b.alarm_rule_type=2
|
||||
left join hw_device hd on b.link_device_id = hd.device_id
|
||||
left join hw_device_mode_function hdmf on b.link_device_function_id=hdmf.mode_function_id
|
||||
where a.offline_rule_id = #{offlineRuleId}
|
||||
</select>
|
||||
|
||||
<insert id="insertHwOfflineRule" parameterType="HwOfflineRule" useGeneratedKeys="true" keyProperty="offlineRuleId">
|
||||
insert into hw_offline_rule
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="offlineRuleName != null and offlineRuleName != ''">offline_rule_name,</if>
|
||||
<if test="tenantId != null">tenant_id,</if>
|
||||
<if test="sceneId != null">scene_id,</if>
|
||||
<if test="alarmLevelId != null">alarm_level_id,</if>
|
||||
<if test="ruleType != null and ruleType != ''">rule_type,</if>
|
||||
<if test="offlineTime != null">offline_time,</if>
|
||||
<if test="offlineNumberTime != null">offline_number_time,</if>
|
||||
<if test="offlineNumber != null">offline_number,</if>
|
||||
<if test="triggerTimeFrame != null">trigger_time_frame,</if>
|
||||
<if test="consumeTraffic != null">consume_traffic,</if>
|
||||
<if test="batteryLevel != null">battery_level,</if>
|
||||
<if test="powerDownFlag != null">power_down_flag,</if>
|
||||
<if test="linkFlag != null and linkFlag != ''">link_flag,</if>
|
||||
<if test="alarmRuleStatus != null and alarmRuleStatus != ''">alarm_rule_status,</if>
|
||||
<if test="alarmPushFlag != null and alarmPushFlag != ''">alarm_push_flag,</if>
|
||||
<if test="alarmPushContent != null">alarm_push_content,</if>
|
||||
<if test="alarmRecoverContent != null">alarm_recover_content,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="offlineRuleField != null">offline_rule_field,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="offlineRuleName != null and offlineRuleName != ''">#{offlineRuleName},</if>
|
||||
<if test="tenantId != null">#{tenantId},</if>
|
||||
<if test="sceneId != null">#{sceneId},</if>
|
||||
<if test="alarmLevelId != null">#{alarmLevelId},</if>
|
||||
<if test="ruleType != null and ruleType != ''">#{ruleType},</if>
|
||||
<if test="offlineTime != null">#{offlineTime},</if>
|
||||
<if test="offlineNumberTime != null">#{offlineNumberTime},</if>
|
||||
<if test="offlineNumber != null">#{offlineNumber},</if>
|
||||
<if test="triggerTimeFrame != null">#{triggerTimeFrame},</if>
|
||||
<if test="consumeTraffic != null">#{consumeTraffic},</if>
|
||||
<if test="batteryLevel != null">#{batteryLevel},</if>
|
||||
<if test="powerDownFlag != null">#{powerDownFlag},</if>
|
||||
<if test="linkFlag != null and linkFlag != ''">#{linkFlag},</if>
|
||||
<if test="alarmRuleStatus != null and alarmRuleStatus != ''">#{alarmRuleStatus},</if>
|
||||
<if test="alarmPushFlag != null and alarmPushFlag != ''">#{alarmPushFlag},</if>
|
||||
<if test="alarmPushContent != null">#{alarmPushContent},</if>
|
||||
<if test="alarmRecoverContent != null">#{alarmRecoverContent},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="offlineRuleField != null">#{offlineRuleField},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateHwOfflineRule" parameterType="HwOfflineRule">
|
||||
update hw_offline_rule
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="offlineRuleName != null and offlineRuleName != ''">offline_rule_name = #{offlineRuleName},</if>
|
||||
<if test="tenantId != null">tenant_id = #{tenantId},</if>
|
||||
<if test="sceneId != null">scene_id = #{sceneId},</if>
|
||||
<if test="alarmLevelId != null">alarm_level_id = #{alarmLevelId},</if>
|
||||
<if test="ruleType != null and ruleType != ''">rule_type = #{ruleType},</if>
|
||||
<if test="offlineTime != null">offline_time = #{offlineTime},</if>
|
||||
<if test="offlineNumberTime != null">offline_number_time = #{offlineNumberTime},</if>
|
||||
<if test="offlineNumber != null">offline_number = #{offlineNumber},</if>
|
||||
<if test="triggerTimeFrame != null">trigger_time_frame = #{triggerTimeFrame},</if>
|
||||
<if test="consumeTraffic != null">consume_traffic = #{consumeTraffic},</if>
|
||||
<if test="batteryLevel != null">battery_level = #{batteryLevel},</if>
|
||||
<if test="powerDownFlag != null">power_down_flag = #{powerDownFlag},</if>
|
||||
<if test="linkFlag != null and linkFlag != ''">link_flag = #{linkFlag},</if>
|
||||
<if test="alarmRuleStatus != null and alarmRuleStatus != ''">alarm_rule_status = #{alarmRuleStatus},</if>
|
||||
<if test="alarmPushFlag != null and alarmPushFlag != ''">alarm_push_flag = #{alarmPushFlag},</if>
|
||||
<if test="alarmPushContent != null">alarm_push_content = #{alarmPushContent},</if>
|
||||
<if test="alarmRecoverContent != null">alarm_recover_content = #{alarmRecoverContent},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="offlineRuleField != null">offline_rule_field = #{offlineRuleField},</if>
|
||||
</trim>
|
||||
where offline_rule_id = #{offlineRuleId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteHwOfflineRuleByOfflineRuleId" parameterType="Long">
|
||||
delete from hw_offline_rule where offline_rule_id = #{offlineRuleId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteHwOfflineRuleByOfflineRuleIds" parameterType="String">
|
||||
update hw_offline_rule set deleted_flag='1' where offline_rule_id in
|
||||
<foreach item="offlineRuleId" collection="array" open="(" separator="," close=")">
|
||||
#{offlineRuleId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteHwAlarmRuleLinkByAlarmRuleIds" parameterType="String">
|
||||
delete from hw_alarm_rule_link where alarm_rule_id in
|
||||
<foreach item="alarmRuleId" collection="array" open="(" separator="," close=")">
|
||||
#{alarmRuleId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteHwAlarmRuleLinkByAlarmRuleId" parameterType="Long">
|
||||
delete from hw_alarm_rule_link where alarm_rule_id = #{alarmRuleId}
|
||||
</delete>
|
||||
|
||||
<insert id="batchHwAlarmRuleLink">
|
||||
insert into hw_alarm_rule_link( rule_link_id, alarm_rule_type, alarm_rule_id, link_type, link_device_id, link_device_function_id, link_device_function_identifier, link_device_function_data) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
( #{item.ruleLinkId}, #{item.alarmRuleType}, #{item.alarmRuleId}, #{item.linkType}, #{item.linkDeviceId}, #{item.linkDeviceFunctionId}, #{item.linkDeviceFunctionIdentifier}, #{item.linkDeviceFunctionData})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
<select id="selectHwOfflineRuleJoinList" parameterType="HwOfflineRule" resultMap="HwOfflineRuleResult">
|
||||
select hor.offline_rule_id,hor.offline_rule_name,hor.tenant_id,hor.scene_id,hor.alarm_level_id,hor.rule_type,hor.link_flag,hor.alarm_rule_status,
|
||||
ht.tenant_name,hs.scene_name,hal.alarm_level_name
|
||||
from hw_offline_rule hor left join hw_tenant ht on hor.tenant_id = ht.tenant_id
|
||||
left join hw_scene hs on hor.scene_id=hs.scene_id
|
||||
left join hw_alarm_level hal on hor.alarm_level_id=hal.alarm_level_id
|
||||
<where>
|
||||
hor.deleted_flag = '0'
|
||||
<if test="offlineRuleName != null and offlineRuleName != ''">and hor.offline_rule_name like concat('%',
|
||||
#{offlineRuleName}, '%')
|
||||
</if>
|
||||
<if test="tenantId != null ">and hor.tenant_id = #{tenantId}</if>
|
||||
<if test="sceneId != null ">and hor.scene_id = #{sceneId}</if>
|
||||
<if test="alarmLevelId != null ">and hor.alarm_level_id = #{alarmLevelId}</if>
|
||||
<if test="ruleType != null and ruleType != ''">and hor.rule_type = #{ruleType}</if>
|
||||
<if test="offlineTime != null ">and hor.offline_time = #{offlineTime}</if>
|
||||
<if test="offlineNumberTime != null ">and hor.offline_number_time = #{offlineNumberTime}</if>
|
||||
<if test="offlineNumber != null ">and hor.offline_number = #{offlineNumber}</if>
|
||||
<if test="triggerTimeFrame != null and triggerTimeFrame != ''">and hor.trigger_time_frame =
|
||||
#{triggerTimeFrame}
|
||||
</if>
|
||||
<if test="linkFlag != null and linkFlag != ''">and hor.link_flag = #{linkFlag}</if>
|
||||
<if test="alarmRuleStatus != null and alarmRuleStatus != ''">and hor.alarm_rule_status = #{alarmRuleStatus}
|
||||
</if>
|
||||
<if test="alarmPushFlag != null and alarmPushFlag != ''">and hor.alarm_push_flag = #{alarmPushFlag}</if>
|
||||
|
||||
<!-- 租户数据范围过滤 -->
|
||||
${params.tenantDataScope}
|
||||
</where>
|
||||
order by hor.offline_rule_id desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.business.mapper.HwOfflineTargetMapper">
|
||||
|
||||
<resultMap type="HwOfflineTarget" id="HwOfflineTargetResult">
|
||||
<result property="offlineRuleId" column="offline_rule_id" />
|
||||
<result property="targetType" column="target_type" />
|
||||
<result property="targetId" column="target_id" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchInsertOfflineTarget">
|
||||
insert into hw_offline_target (offline_rule_id, target_type,target_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.offlineRuleId},#{item.targetType},#{item.targetId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
<delete id="deleteOfflineTarget" parameterType="HwOfflineTarget">
|
||||
delete from hw_offline_target where offline_rule_id=#{offlineRuleId} and target_type=#{targetType} and target_id=#{targetId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteOfflineTargets">
|
||||
delete from hw_offline_target where offline_rule_id=#{offlineRuleId} and target_type=#{targetType} and target_id in
|
||||
<foreach collection="targetIds" item="targetId" open="(" separator="," close=")">
|
||||
#{targetId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,134 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询离线报警规则列表
|
||||
export function listOfflineRule(query) {
|
||||
return request({
|
||||
url: '/business/offlineRule/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询离线报警规则详细
|
||||
export function getOfflineRule(offlineRuleId) {
|
||||
return request({
|
||||
url: '/business/offlineRule/' + offlineRuleId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增离线报警规则
|
||||
export function addOfflineRule(data) {
|
||||
return request({
|
||||
url: '/business/offlineRule',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改离线报警规则
|
||||
export function updateOfflineRule(data) {
|
||||
return request({
|
||||
url: '/business/offlineRule',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除离线报警规则
|
||||
export function delOfflineRule(offlineRuleId) {
|
||||
return request({
|
||||
url: '/business/offlineRule/' + offlineRuleId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 查询场景信息列表供查询页面选择使用(例如下拉列表)
|
||||
export function getScenes(query) {
|
||||
return request({
|
||||
url: '/business/alarmRule/getScenes',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询场景信息列表供编辑页面选择使用(例如下拉列表)
|
||||
export function getEditedScenes(query) {
|
||||
return request({
|
||||
url: '/business/alarmRule/getEditedScenes',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function getSelectListBySceneId(sceneId) {
|
||||
return request({
|
||||
url: '/business/alarmRule/getSelectListBySceneId/' + sceneId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getDeviceModeByDeviceId(deviceId) {
|
||||
return request({
|
||||
url: '/business/alarmRule/getDeviceModeByDeviceId/' + deviceId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 查询监控单元树
|
||||
export function monitorUnitTree(query) {
|
||||
return request({
|
||||
url: '/business/offlineRule/allocateDevice/monitorUnitTree',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询离线报警规则已分配设备列表
|
||||
export function allocatedDeviceList(query) {
|
||||
return request({
|
||||
url: '/business/offlineRule/allocateDevice/allocatedList',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询离线报警规则未分配设备列表
|
||||
export function unallocatedDeviceList(query) {
|
||||
return request({
|
||||
url: '/business/offlineRule/allocateDevice/unallocatedList',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 批量分配离线报警规则目标列表
|
||||
export function batchInsertOfflineTarget(data) {
|
||||
return request({
|
||||
url: '/business/offlineRule/allocateTarget/batchInsertOfflineTarget',
|
||||
method: 'put',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 取消离线报警规则分配目标
|
||||
export function cancelAllocateDevice(data) {
|
||||
return request({
|
||||
url: '/business/offlineRule/allocateTarget/cancelAllocateDevice',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 批量取消离线报警规则目标列表
|
||||
export function cancelAllocateDevices(data) {
|
||||
return request({
|
||||
url: '/business/offlineRule/allocateTarget/cancelAllocateDevices',
|
||||
method: 'put',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
@ -0,0 +1,253 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
|
||||
<el-form-item label="设备类型" prop="deviceType">
|
||||
<el-select v-model="queryParams.deviceType" placeholder="请选择设备类型" clearable>
|
||||
<el-option
|
||||
v-for="dict in dict.type.hw_device_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="设备编号" prop="deviceCode">
|
||||
<el-input
|
||||
v-model="queryParams.deviceCode"
|
||||
placeholder="请输入设备编号"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备名称" prop="deviceName">
|
||||
<el-input
|
||||
v-model="queryParams.deviceName"
|
||||
placeholder="请输入设备名称"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="所属监控单元" prop="monitorUnitId">
|
||||
<treeselect v-model="queryParams.monitorUnitId" :options="monitorUnitTreeData" :show-count="true"
|
||||
style="width: 240px" placeholder="请选择所属监控单元" @keyup.enter.native="handleQuery"/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="openSelectDevice"
|
||||
v-hasPermi="['business:offlineRule:add']"
|
||||
>添加设备
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-circle-close"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="cancelAllocateDevices"
|
||||
v-hasPermi="['business:offlineRule:remove']"
|
||||
>批量取消分配
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-close"
|
||||
size="mini"
|
||||
@click="handleClose"
|
||||
>关闭
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="deviceList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<el-table-column label="设备类型" prop="deviceType" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.hw_device_type" :value="scope.row.deviceType"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="设备编号" prop="deviceCode" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="设备名称" prop="deviceName" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="所属监控单元" prop="monitorUnitName" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="发布时间" align="center" prop="publishTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.publishTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-circle-close"
|
||||
@click="cancelAllocateDevice(scope.row)"
|
||||
v-hasPermi="['business:offlineRule:remove']"
|
||||
>取消分配
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
<select-device ref="select" :offlineRuleId="queryParams.offlineRuleId" :sceneId="queryParams.sceneId" @ok="handleQuery"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
monitorUnitTree,
|
||||
allocatedDeviceList,
|
||||
cancelAllocateDevice,
|
||||
cancelAllocateDevices
|
||||
} from "@/api/business/offlineRule";
|
||||
import selectDevice from "./selectDevie.vue";
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
|
||||
export default {
|
||||
name: "AllocateDevice",
|
||||
dicts: ['hw_device_type'],
|
||||
components: {Treeselect, selectDevice},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中设备列表
|
||||
targetIds: [],
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
|
||||
//监控单元树数据
|
||||
monitorUnitTreeData: [],
|
||||
// 设备表格数据
|
||||
deviceList: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
offlineRuleId: undefined,
|
||||
sceneId: undefined,
|
||||
monitorUnitId: undefined,
|
||||
deviceCode: undefined,
|
||||
deviceName: undefined
|
||||
},
|
||||
|
||||
OFFLINE_TARGET_TYPE_DEVICE: '1',
|
||||
};
|
||||
},
|
||||
created() {
|
||||
const offlineRuleId = this.$route.params && this.$route.params.offlineRuleId;
|
||||
const sceneId = this.$route.params && this.$route.params.sceneId;
|
||||
if (offlineRuleId && sceneId) {
|
||||
this.queryParams.offlineRuleId = offlineRuleId;
|
||||
this.queryParams.sceneId = sceneId;
|
||||
this.monitorUnitTree(sceneId);
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
monitorUnitTree(sceneId) {
|
||||
monitorUnitTree({sceneId:sceneId}).then(response => {
|
||||
this.monitorUnitTreeData = response.data;
|
||||
})
|
||||
},
|
||||
|
||||
/** 查询授权用户列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
allocatedDeviceList(this.queryParams).then(response => {
|
||||
this.deviceList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
},
|
||||
// 返回按钮
|
||||
handleClose() {
|
||||
const obj = {path: "/alarm/offlineRule"};
|
||||
this.$tab.closeOpenPage(obj);
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.targetIds = selection.map(item => item.deviceId)
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 打开设备列表弹窗 */
|
||||
openSelectDevice() {
|
||||
this.$refs.select.show();
|
||||
},
|
||||
/** 取消分配按钮操作 */
|
||||
cancelAllocateDevice(row) {
|
||||
const offlineRuleId = this.queryParams.offlineRuleId;
|
||||
const OFFLINE_TARGET_TYPE_DEVICE = this.OFFLINE_TARGET_TYPE_DEVICE;
|
||||
this.$modal.confirm('确认要取消分配该设备"' + row.deviceName + '"吗?').then(function () {
|
||||
return cancelAllocateDevice({
|
||||
offlineRuleId: offlineRuleId,
|
||||
targetType: OFFLINE_TARGET_TYPE_DEVICE,
|
||||
targetId: row.deviceId
|
||||
});
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("取消分配成功");
|
||||
}).catch(() => {
|
||||
});
|
||||
},
|
||||
/** 批量取消分配按钮操作 */
|
||||
cancelAllocateDevices(row) {
|
||||
const offlineRuleId = this.queryParams.offlineRuleId;
|
||||
const targetIds = this.targetIds.join(",");
|
||||
const OFFLINE_TARGET_TYPE_DEVICE = this.OFFLINE_TARGET_TYPE_DEVICE;
|
||||
this.$modal.confirm('是否取消分配选中设备项?').then(function () {
|
||||
return cancelAllocateDevices({
|
||||
offlineRuleId: offlineRuleId,
|
||||
targetType: OFFLINE_TARGET_TYPE_DEVICE,
|
||||
targetIds: targetIds
|
||||
});
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("取消分配成功");
|
||||
}).catch(() => {
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,866 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="规则名称" prop="offlineRuleName">
|
||||
<el-input
|
||||
v-model="queryParams.offlineRuleName"
|
||||
placeholder="请输入离线报警规则名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="所属场景" prop="sceneId">
|
||||
<el-select v-model="queryParams.sceneId" placeholder="请选择所属场景" @input="sceneChange" clearable>
|
||||
<el-option
|
||||
v-for="(scene, index) in scenes"
|
||||
:key="index"
|
||||
:label="scene.sceneName"
|
||||
:value="scene.sceneId"
|
||||
></el-option>
|
||||
</el-select>
|
||||
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="报警级别" prop="alarmLevelId">
|
||||
<el-select v-model="queryParams.alarmLevelId" placeholder="请选择报警级别" clearable>
|
||||
<el-option
|
||||
v-for="(alarmLevel, index) in alarmLevels"
|
||||
:key="index"
|
||||
:label="alarmLevel.alarmLevelName"
|
||||
:value="alarmLevel.alarmLevelId"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="规则类型" prop="ruleType">
|
||||
<el-select v-model="queryParams.ruleType" placeholder="请选择规则类型" clearable>
|
||||
<el-option
|
||||
v-for="dict in dict.type.hw_offline_rule_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item label="联动标识" prop="linkFlag">
|
||||
<el-select v-model="queryParams.linkFlag" placeholder="请选择联动标识" clearable>
|
||||
<el-option
|
||||
v-for="dict in dict.type.hw_alarm_rule_link_flag"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="状态" prop="alarmRuleStatus">
|
||||
<el-select v-model="queryParams.alarmRuleStatus" placeholder="请选择状态">
|
||||
<el-option
|
||||
v-for="dict in dict.type.hw_alarm_rule_status"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['business:offlineRule:add']"
|
||||
>新增
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['business:offlineRule:edit']"
|
||||
>修改
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['business:offlineRule:remove']"
|
||||
>删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['business:offlineRule:export']"
|
||||
>导出
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="offlineRuleList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<el-table-column label="规则ID" align="center" prop="offlineRuleId"/>
|
||||
<el-table-column label="规则名称" align="center" prop="offlineRuleName"/>
|
||||
<el-table-column label="所属租户" align="center" prop="tenantName"/>
|
||||
<el-table-column label="所属场景" align="center" prop="sceneName"/>
|
||||
<el-table-column label="报警级别" align="center" prop="alarmLevelName"/>
|
||||
<el-table-column label="规则类型" align="center" prop="ruleType">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.hw_offline_rule_type" :value="scope.row.ruleType"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="联动标识" align="center" prop="linkFlag">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.hw_alarm_rule_link_flag" :value="scope.row.linkFlag"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" align="center" prop="alarmRuleStatus">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.hw_alarm_rule_status" :value="scope.row.alarmRuleStatus"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['business:offlineRule:edit']"
|
||||
>修改
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-s-order"
|
||||
v-if="scope.row.ruleType=='1'"
|
||||
@click="handleAllocateDevice(scope.row)"
|
||||
v-hasPermi="['business:offlineRule:edit']"
|
||||
>设备列表
|
||||
</el-button>
|
||||
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['business:offlineRule:remove']"
|
||||
>删除
|
||||
</el-button>
|
||||
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改离线报警规则对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="660px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="130px">
|
||||
<el-form-item label="规则名称" prop="offlineRuleName">
|
||||
<el-input v-model="form.offlineRuleName" placeholder="请输入规则名称"/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="所属场景" prop="sceneId">
|
||||
<el-select v-model="form.sceneId" placeholder="请选择所属场景" @input="editedSceneChange"
|
||||
:disabled="sceneDisabled">
|
||||
<el-option
|
||||
v-for="(scene, index) in editedScenes"
|
||||
:key="index"
|
||||
:label="scene.sceneName"
|
||||
:value="scene.sceneId"
|
||||
:disabled="scene.selectedDisable && scene.selectedDisable == 1"
|
||||
></el-option>
|
||||
</el-select>
|
||||
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item label="报警级别" prop="alarmLevelId">
|
||||
<el-select v-model="form.alarmLevelId" placeholder="请选择报警级别">
|
||||
<el-option
|
||||
v-for="(alarmLevel, index) in editedAlarmLevels"
|
||||
:key="index"
|
||||
:label="alarmLevel.alarmLevelName"
|
||||
:value="alarmLevel.alarmLevelId"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="规则类型" prop="ruleType">
|
||||
<el-radio-group v-model="form.ruleType" :disabled="editedDisabled">
|
||||
<el-radio
|
||||
v-for="dict in dict.type.hw_offline_rule_type"
|
||||
:key="dict.value"
|
||||
:label="dict.value"
|
||||
>{{ dict.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item label="报警规则" prop="offlineNumber">
|
||||
<el-input-number v-model="form.offlineNumberTime" placeholder="分钟" style="width:120px;"
|
||||
show-overflow-tooltip="true" min="1" max="999999"/>
|
||||
分钟内,
|
||||
离线次数>=
|
||||
<el-input-number v-model="form.offlineNumber" placeholder="次数" style="width:120px;"
|
||||
:show-overflow-tooltip="true" min="1" max="999999"/>
|
||||
次
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="状态" prop="alarmRuleStatus">
|
||||
<el-radio-group v-model="form.alarmRuleStatus">"
|
||||
<el-radio
|
||||
v-for="dict in dict.type.hw_alarm_rule_status"
|
||||
:key="dict.value"
|
||||
:label="dict.value"
|
||||
>{{ dict.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item label="联动标识" prop="linkFlag">
|
||||
<el-radio-group v-model="form.linkFlag" @input="linkFlagChange">
|
||||
<el-radio
|
||||
v-for="dict in dict.type.hw_alarm_rule_link_flag"
|
||||
:key="dict.value"
|
||||
:label="dict.value"
|
||||
>{{ dict.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
|
||||
<el-button type="primary" @click="handleAddAlarmRuleLink" icon="el-icon-plus" size="mini"
|
||||
v-if="alarmRuleLinkVisible">添加联动设备
|
||||
</el-button>
|
||||
|
||||
<el-table :data="alarmRuleLinkData" :row-class-name="rowHwAlarmRuleLinkIndex"
|
||||
ref="hwAlarmRuleLink" v-if="alarmRuleLinkVisible">
|
||||
<el-table-column label="序号" align="center" prop="index" width="50"/>
|
||||
<el-table-column
|
||||
label="联动类型"
|
||||
prop="linkType"
|
||||
min-width="8%"
|
||||
:show-overflow-tooltip="true"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.hw_alarm_rule_link_type" :value="scope.row.linkType"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="联动设备"
|
||||
prop="linkDeviceName"
|
||||
min-width="12%"
|
||||
:show-overflow-tooltip="true"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="联动设备服务"
|
||||
prop="linkDeviceModeFunctionName"
|
||||
min-width="10%"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
|
||||
<el-table-column label="操作" align="center" min-width="10%">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdateAlarmRuleLink(scope.row)"
|
||||
>修改
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDeleteAlarmRuleLink(scope.row)"
|
||||
>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
</el-table>
|
||||
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="描述" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
|
||||
<!-- 添加或修改联动设备对话框-->
|
||||
<el-dialog :title="alarmRuleLinkTitle" :visible.sync="alarmRuleLinkOpen" width="500px" append-to-body>
|
||||
<el-form ref="alarmRuleLinkForm" :model="alarmRuleLinkForm" :rules="alarmRuleLinkRules" label-width="80px">
|
||||
|
||||
<el-form-item label="联动类型" prop="linkType">
|
||||
<el-select v-model="alarmRuleLinkForm.linkType" placeholder="请选择联动类型">
|
||||
<el-option
|
||||
v-for="dict in dict.type.hw_alarm_rule_link_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
|
||||
</el-form-item>
|
||||
|
||||
<el-row>
|
||||
<el-col span="12">
|
||||
<el-form-item label="设备" prop="linkDeviceId">
|
||||
<el-select v-model="alarmRuleLinkForm.linkDeviceId" placeholder="请选择设备"
|
||||
@input="editedLinkDeviceChange">
|
||||
<el-option
|
||||
v-for="(device, index) in editedDevices"
|
||||
:key="index"
|
||||
:label="device.deviceName"
|
||||
:value="device.deviceId"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col span="12">
|
||||
<el-form-item label="设备服务" prop="linkDeviceFunctionId">
|
||||
<el-select v-model="alarmRuleLinkForm.linkDeviceFunctionId" placeholder="请选择设备服务"
|
||||
@input="editedLinkDeviceModeServiceChange">
|
||||
<el-option
|
||||
v-for="(deviceModeFunction, index) in editedDeviceModeServices"
|
||||
:key="index"
|
||||
:label="deviceModeFunction.functionName"
|
||||
:value="deviceModeFunction.modeFunctionId"
|
||||
></el-option>
|
||||
</el-select>
|
||||
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
</el-row>
|
||||
|
||||
|
||||
<!--el-form-item
|
||||
v-for="(parameter,index) in modeFunctionParameters"
|
||||
:label="parameter.parameterName"
|
||||
:key="parameter.parameterIdentifier"
|
||||
:prop="'parameters'+index"
|
||||
>
|
||||
<el-input v-model="alarmRuleLinkForm.parameters" placeholder="请输入内容"/>
|
||||
</el-form-item-->
|
||||
|
||||
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitRuleLinkForm">确 定</el-button>
|
||||
<el-button @click="cancelAlarmRuleLink">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
listOfflineRule, getOfflineRule, delOfflineRule, addOfflineRule, updateOfflineRule,
|
||||
getScenes, getEditedScenes, getSelectListBySceneId, getDeviceModeByDeviceId
|
||||
} from "@/api/business/offlineRule";
|
||||
import {addDeviceModeFunction} from "@/api/business/deviceModeFunction";
|
||||
|
||||
export default {
|
||||
name: "OfflineRule",
|
||||
dicts: ['hw_offline_rule_type', 'hw_alarm_rule_link_flag', 'hw_alarm_rule_status', 'hw_alarm_rule_push_flag', 'hw_alarm_rule_trigger_condition', 'hw_alarm_rule_link_type'],
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 子表选中数据
|
||||
checkedHwAlarmRuleLink: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 离线报警规则表格数据
|
||||
offlineRuleList: [],
|
||||
// 报警规则联动信息表格数据
|
||||
hwAlarmRuleLinkList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
offlineRuleName: null,
|
||||
tenantId: null,
|
||||
sceneId: null,
|
||||
alarmLevelId: null,
|
||||
ruleType: null,
|
||||
offlineTime: undefined,
|
||||
offlineNumberTime: undefined,
|
||||
offlineNumber: undefined,
|
||||
triggerTimeFrame: null,
|
||||
consumeTraffic: null,
|
||||
batteryLevel: null,
|
||||
powerDownFlag: null,
|
||||
linkFlag: null,
|
||||
alarmRuleStatus: null,
|
||||
alarmPushFlag: null,
|
||||
alarmPushContent: null,
|
||||
alarmRecoverContent: null,
|
||||
offlineRuleField: null
|
||||
},
|
||||
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
offlineRuleName: [
|
||||
{required: true, message: "离线报警规则名称不能为空", trigger: "blur"}
|
||||
],
|
||||
|
||||
sceneId: [
|
||||
{required: true, message: "所属场景不能为空", trigger: "change"}
|
||||
],
|
||||
alarmLevelId: [
|
||||
{required: true, message: "报警级别不能为空", trigger: "change"}
|
||||
],
|
||||
ruleType: [
|
||||
{required: true, message: "规则类型不能为空", trigger: "change"}
|
||||
],
|
||||
linkFlag: [
|
||||
{required: true, message: "联动标识不能为空", trigger: "change"}
|
||||
],
|
||||
alarmRuleStatus: [
|
||||
{required: true, message: "状态不能为空", trigger: "change"}
|
||||
],
|
||||
offlineNumber: [
|
||||
{required: true, message: "报警规则不能为空", trigger: "blur"}
|
||||
],
|
||||
|
||||
},
|
||||
|
||||
|
||||
FUNCTION_MODE_ATTRIBUTE: "1", //设备模型属性
|
||||
FUNCTION_MODE_SERVICE: "2",//设备模型服务
|
||||
DATA_MORE_THAN_A_AND_LESS_THAN_B: 3,//大于A且小于B
|
||||
DATA_LESS_THAN_A_OR_MORE_THAN_B: 4,//小于A或大于B
|
||||
LINK_FLAG_YES: "1",
|
||||
|
||||
scenes: [],
|
||||
alarmLevels: [],
|
||||
alarmTypes: [],
|
||||
devices: [],
|
||||
|
||||
alarmRuleFlag: "1",
|
||||
editedScenes: [],
|
||||
editedDisabled: true,
|
||||
sceneDisabled: true,
|
||||
editedAlarmLevels: [],
|
||||
editedAlarmTypes: [],
|
||||
editedDevices: [],
|
||||
editedDeviceModeAttributes: [],
|
||||
editedDeviceModeServices: [],
|
||||
|
||||
alarmRuleLinkVisible: false,
|
||||
alarmRuleLinkData: [],
|
||||
alarmRuleLinkTitle: "",
|
||||
alarmRuleLinkOpen: false,
|
||||
alarmRuleLinkForm: {},
|
||||
modeFunctionParameters: [],
|
||||
alarmRuleLinkRules: {
|
||||
linkType: [
|
||||
{required: true, message: "联动类型不能为空", trigger: "change"}
|
||||
],
|
||||
linkDeviceId: [
|
||||
{required: true, message: "设备不能为空", trigger: "change"},
|
||||
],
|
||||
linkDeviceFunctionId: [
|
||||
{required: true, message: "设备服务不能为空", trigger: "change"},
|
||||
],
|
||||
},
|
||||
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getScenes();
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询离线报警规则列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listOfflineRule(this.queryParams).then(response => {
|
||||
this.offlineRuleList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.editedDevices = [];
|
||||
this.editedAlarmLevels = [];
|
||||
this.alarmRuleLinkData = [];
|
||||
this.form = {
|
||||
offlineRuleId: null,
|
||||
offlineRuleName: null,
|
||||
tenantId: null,
|
||||
sceneId: null,
|
||||
alarmLevelId: null,
|
||||
ruleType: '3',
|
||||
offlineTime: undefined,
|
||||
offlineNumberTime: 1,
|
||||
offlineNumber: 1,
|
||||
triggerTimeFrame: null,
|
||||
consumeTraffic: null,
|
||||
batteryLevel: null,
|
||||
powerDownFlag: null,
|
||||
linkFlag: '0',
|
||||
alarmRuleStatus: '1',
|
||||
alarmPushFlag: null,
|
||||
alarmPushContent: null,
|
||||
alarmRecoverContent: null,
|
||||
remark: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null,
|
||||
offlineRuleField: null
|
||||
};
|
||||
this.hwAlarmRuleLinkList = [];
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.offlineRuleId)
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.editedDisabled = false;
|
||||
this.sceneDisabled = false;
|
||||
this.reset();
|
||||
this.getEditedScenes();
|
||||
this.open = true;
|
||||
this.title = "添加离线报警规则";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
this.editedDisabled = true;
|
||||
this.sceneDisabled = true;
|
||||
this.getEditedScenes();
|
||||
const offlineRuleId = row.offlineRuleId || this.ids
|
||||
getOfflineRule(offlineRuleId).then(response => {
|
||||
this.form = response.data;
|
||||
this.form.offlineTime = this.form.offlineTime || undefined;
|
||||
this.form.offlineNumberTime = this.form.offlineNumberTime || undefined;
|
||||
this.form.offlineNumber = this.form.offlineNumber || undefined;
|
||||
|
||||
this.getEditedSelectListBySceneId(this.form.sceneId);
|
||||
this.alarmRuleLinkData = response.data.hwAlarmRuleLinkList;
|
||||
this.alarmRuleLinkVisible = response.data.linkFlag === this.LINK_FLAG_YES;
|
||||
this.open = true;
|
||||
this.title = "修改离线报警规则";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.linkFlag == this.LINK_FLAG_YES &&
|
||||
(this.alarmRuleLinkData == null || this.alarmRuleLinkData.length <= 0)) {
|
||||
this.$modal.msgWarning("请添加联动设备");
|
||||
return;
|
||||
}
|
||||
this.form.hwAlarmRuleLinkList = this.alarmRuleLinkData;
|
||||
|
||||
if (this.form.offlineRuleId != null) {
|
||||
updateOfflineRule(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addOfflineRule(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const offlineRuleIds = row.offlineRuleId || this.ids;
|
||||
this.$modal.confirm('是否确认删除离线报警规则编号为"' + offlineRuleIds + '"的数据项?').then(function () {
|
||||
return delOfflineRule(offlineRuleIds);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {
|
||||
});
|
||||
},
|
||||
/** 报警规则联动信息序号 */
|
||||
rowHwAlarmRuleLinkIndex({row, rowIndex}) {
|
||||
row.index = rowIndex + 1;
|
||||
},
|
||||
|
||||
/** 报警规则联动信息删除按钮操作 */
|
||||
handleDeleteHwAlarmRuleLink() {
|
||||
if (this.checkedHwAlarmRuleLink.length == 0) {
|
||||
this.$modal.msgError("请先选择要删除的报警规则联动信息数据");
|
||||
} else {
|
||||
const hwAlarmRuleLinkList = this.hwAlarmRuleLinkList;
|
||||
const checkedHwAlarmRuleLink = this.checkedHwAlarmRuleLink;
|
||||
this.hwAlarmRuleLinkList = hwAlarmRuleLinkList.filter(function (item) {
|
||||
return checkedHwAlarmRuleLink.indexOf(item.index) == -1
|
||||
});
|
||||
}
|
||||
},
|
||||
/** 复选框选中数据 */
|
||||
handleHwAlarmRuleLinkSelectionChange(selection) {
|
||||
this.checkedHwAlarmRuleLink = selection.map(item => item.index)
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('business/offlineRule/export', {
|
||||
...this.queryParams
|
||||
}, `offlineRule_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
|
||||
|
||||
getScenes() {
|
||||
getScenes().then(response => {
|
||||
this.scenes = response.data;
|
||||
});
|
||||
},
|
||||
|
||||
sceneChange(sceneId) {
|
||||
this.devices = [];
|
||||
this.alarmLevels = [];
|
||||
this.queryParams.alarmLevelId = null;
|
||||
this.queryParams.ruleDeviceId = null;
|
||||
this.getSelectListBySceneId(sceneId);
|
||||
},
|
||||
|
||||
getSelectListBySceneId(sceneId) {
|
||||
if (sceneId != null && sceneId !== '') {
|
||||
getSelectListBySceneId(sceneId).then(response => {
|
||||
this.devices = response.data["devices"];
|
||||
this.alarmLevels = response.data["alarmLevels"];
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getEditedScenes() {
|
||||
getEditedScenes().then(response => {
|
||||
this.editedScenes = response.data;
|
||||
});
|
||||
},
|
||||
|
||||
getEditedSelectListBySceneId(sceneId) {
|
||||
getSelectListBySceneId(sceneId).then(response => {
|
||||
this.editedDevices = response.data["devices"];
|
||||
this.editedAlarmLevels = response.data["alarmLevels"];
|
||||
})
|
||||
},
|
||||
|
||||
editedSceneChange(sceneId) {
|
||||
this.editedDevices = [];
|
||||
this.editedAlarmLevels = [];
|
||||
this.form.alarmLevelId = null;
|
||||
this.form.ruleDeviceId = null;
|
||||
this.alarmRuleLinkData = [];
|
||||
this.alarmRuleLinkVisible = this.form.linkFlag === "1";
|
||||
this.getEditedSelectListBySceneId(sceneId);
|
||||
},
|
||||
|
||||
getDeviceModeServicesByDeviceId(deviceId) {
|
||||
getDeviceModeByDeviceId(deviceId).then(response => {
|
||||
const hwDeviceModeFunctionList = response.data["hwDeviceModeFunctionList"];
|
||||
if (hwDeviceModeFunctionList != null) {
|
||||
this.editedDeviceModeServices = hwDeviceModeFunctionList.filter(item => item.functionMode == this.FUNCTION_MODE_SERVICE)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
editedLinkDeviceChange(deviceId) {
|
||||
this.editedDeviceModeServices = [];
|
||||
this.alarmRuleLinkForm.linkDeviceFunctionId = null;
|
||||
const selectedOption = this.editedDevices.find(option => option.deviceId === deviceId);
|
||||
this.alarmRuleLinkForm.linkDeviceName = selectedOption.deviceName;
|
||||
this.getDeviceModeServicesByDeviceId(deviceId);
|
||||
},
|
||||
|
||||
editedLinkDeviceModeServiceChange(modeFunctionId) {
|
||||
const selectedOption = this.editedDeviceModeServices.find(option => option.modeFunctionId === modeFunctionId);
|
||||
this.alarmRuleLinkForm.linkDeviceModeFunctionName = selectedOption.functionName;
|
||||
this.alarmRuleLinkForm.linkDeviceFunctionIdentifier = selectedOption.functionIdentifier;
|
||||
|
||||
// getModeFunctionParametersByModeFunctionId(modeFunctionId).then(response => {
|
||||
// const modeFunctionParameters = response.data;
|
||||
// if(modeFunctionParameters!=null){
|
||||
// this.modeFunctionParameters = modeFunctionParameters[1];
|
||||
// }
|
||||
// })
|
||||
|
||||
},
|
||||
|
||||
|
||||
linkFlagChange(linkFlag) {
|
||||
this.alarmRuleLinkVisible = linkFlag === "1" && this.form.sceneId != null;
|
||||
},
|
||||
|
||||
// 报警规则联动设备表单重置
|
||||
resetAlarmRuleLink() {
|
||||
this.alarmRuleLinkForm = {
|
||||
alarmRuleType: '2',
|
||||
linkType: null,
|
||||
linkDeviceId: null,
|
||||
linkDeviceFunctionId: null,
|
||||
linkDeviceFunctionIdentifier: null,
|
||||
linkDeviceFunctionData: null,
|
||||
linkDeviceName: null,
|
||||
linkDeviceModeFunctionName: null
|
||||
};
|
||||
//this.resetForm("inputParameterForm");
|
||||
},
|
||||
|
||||
handleAddAlarmRuleLink() {
|
||||
this.resetAlarmRuleLink();
|
||||
this.alarmRuleLinkOpen = true;
|
||||
this.alarmRuleLinkTitle = "添加联动设备";
|
||||
},
|
||||
|
||||
handleUpdateAlarmRuleLink(row) {
|
||||
this.alarmRuleLinkIndex = this.alarmRuleLinkData.indexOf(row);
|
||||
const linkDeviceId = row.linkDeviceId;
|
||||
this.getDeviceModeServicesByDeviceId(linkDeviceId);
|
||||
this.alarmRuleLinkForm = JSON.parse(JSON.stringify(row));
|
||||
this.alarmRuleLinkOpen = true;
|
||||
this.alarmRuleLinkTitle = "修改联动设备";
|
||||
},
|
||||
|
||||
handleDeleteAlarmRuleLink(row) {
|
||||
this.alarmRuleLinkData.splice(this.alarmRuleLinkData.indexOf(row), 1);
|
||||
},
|
||||
|
||||
submitRuleLinkForm() {
|
||||
this.$refs['alarmRuleLinkForm'].validate(valid => {
|
||||
if (valid) {
|
||||
/** 联动设备添加后在list中添加 */
|
||||
if (this.deviceModeId && this.deviceModeId !== '') {
|
||||
let modeFunctionId = this.form.modeFunctionId;
|
||||
this.form.deviceModeId = this.deviceModeId;
|
||||
if (modeFunctionId !== undefined && modeFunctionId != null) {
|
||||
let attributeDataIndex = this.attributeDataIndex;
|
||||
this.doUpdateDeviceModeFunction();
|
||||
} else {
|
||||
addDeviceModeFunction(this.form).then(res => {
|
||||
this.$modal.msgSuccess(res.msg);
|
||||
if (res.code === 200) {
|
||||
this.open = false;
|
||||
this.form.modeFunctionId = res.data;
|
||||
this.pushData();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.alarmRuleLinkOpen = false;
|
||||
this.pushData();
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
pushData() {
|
||||
let alarmRuleLinkIndex = this.alarmRuleLinkIndex;
|
||||
if (alarmRuleLinkIndex > -1) {
|
||||
this.alarmRuleLinkIndex = -1;
|
||||
this.alarmRuleLinkData.splice(alarmRuleLinkIndex, 1, this.alarmRuleLinkForm);
|
||||
} else {
|
||||
this.alarmRuleLinkData.push(this.alarmRuleLinkForm)
|
||||
}
|
||||
},
|
||||
|
||||
// 联动设备弹窗取消按钮
|
||||
cancelAlarmRuleLink() {
|
||||
this.alarmRuleLinkOpen = false;
|
||||
this.resetAlarmRuleLink();
|
||||
},
|
||||
|
||||
/** 配置设备操作 */
|
||||
handleAllocateDevice: function (row) {
|
||||
const offlineRuleId = row.offlineRuleId;
|
||||
const sceneId = row.sceneId;
|
||||
this.$router.push("/offlineRule/offline-device/device/" + offlineRuleId + "/" + sceneId);
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,182 @@
|
||||
<template>
|
||||
<!-- 分配设备 -->
|
||||
<el-dialog title="选择设备" :visible.sync="visible" width="800px" top="5vh" append-to-body>
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
|
||||
<el-form-item label="设备类型" prop="deviceType">
|
||||
<el-select v-model="queryParams.deviceType" placeholder="请选择设备类型" style="width: 180px" clearable>
|
||||
<el-option
|
||||
v-for="dict in dict.type.hw_device_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="设备编号" prop="deviceCode">
|
||||
<el-input
|
||||
v-model="queryParams.deviceCode"
|
||||
placeholder="请输入设备编号"
|
||||
clearable
|
||||
style="width: 180px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备名称" prop="deviceName">
|
||||
<el-input
|
||||
v-model="queryParams.deviceName"
|
||||
placeholder="请输入设备名称"
|
||||
clearable
|
||||
style="width: 180px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="所属监控单元" prop="monitorUnitId">
|
||||
<treeselect v-model="queryParams.monitorUnitId" :options="monitorUnitTreeData" :show-count="true"
|
||||
style="width: 180px" placeholder="请选择所属监控单元" @keyup.enter.native="handleQuery"/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-row>
|
||||
<el-table @row-click="clickRow" ref="table" :data="deviceList" @selection-change="handleSelectionChange"
|
||||
height="260px">
|
||||
<el-table-column type="selection" width="55"></el-table-column>
|
||||
<el-table-column label="设备类型" prop="deviceType" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.hw_device_type" :value="scope.row.deviceType"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="设备编号" prop="deviceCode" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="设备名称" prop="deviceName" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="所属监控单元" prop="monitorUnitName" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="发布时间" align="center" prop="publishTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.publishTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</el-row>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="handleSelectDevice">确 定</el-button>
|
||||
<el-button @click="visible = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
monitorUnitTree,
|
||||
unallocatedDeviceList,
|
||||
batchInsertOfflineTarget,
|
||||
} from "@/api/business/offlineRule";
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
|
||||
export default {
|
||||
dicts: ['hw_device_type'],
|
||||
components: {Treeselect},
|
||||
props: {
|
||||
offlineRuleId: {
|
||||
type: [Number, String]
|
||||
},
|
||||
sceneId: {
|
||||
type: [Number, String]
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
visible: false,
|
||||
// 选中数组值
|
||||
targetIds: [],
|
||||
// 总条数
|
||||
total: 0,
|
||||
//监控单元树数据
|
||||
monitorUnitTreeData: [],
|
||||
// 未分配设备表格数据
|
||||
deviceList: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
offlineRuleId: undefined,
|
||||
sceneId: undefined,
|
||||
monitorUnitId: undefined,
|
||||
deviceCode: undefined,
|
||||
deviceName: undefined
|
||||
},
|
||||
OFFLINE_TARGET_TYPE_DEVICE: '1',
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
monitorUnitTree(sceneId) {
|
||||
monitorUnitTree({sceneId: sceneId}).then(response => {
|
||||
this.monitorUnitTreeData = response.data;
|
||||
})
|
||||
},
|
||||
// 显示弹框
|
||||
show() {
|
||||
this.queryParams.offlineRuleId = this.offlineRuleId;
|
||||
this.queryParams.sceneId = this.sceneId;
|
||||
this.monitorUnitTree(this.sceneId);
|
||||
this.getList();
|
||||
this.visible = true;
|
||||
},
|
||||
clickRow(row) {
|
||||
this.$refs.table.toggleRowSelection(row);
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.targetIds = selection.map(item => item.deviceId);
|
||||
},
|
||||
// 查询表数据
|
||||
getList() {
|
||||
unallocatedDeviceList(this.queryParams).then(res => {
|
||||
this.deviceList = res.rows;
|
||||
this.total = res.total;
|
||||
});
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 选择分配设备操作 */
|
||||
handleSelectDevice() {
|
||||
const offlineRuleId = this.queryParams.offlineRuleId;
|
||||
const targetIds = this.targetIds.join(",");
|
||||
if (targetIds == "") {
|
||||
this.$modal.msgError("请选择要分配的设备");
|
||||
return;
|
||||
}
|
||||
batchInsertOfflineTarget({
|
||||
offlineRuleId: offlineRuleId,
|
||||
targetType: this.OFFLINE_TARGET_TYPE_DEVICE,
|
||||
targetIds: targetIds
|
||||
}).then(res => {
|
||||
this.$modal.msgSuccess(res.msg);
|
||||
if (res.code === 200) {
|
||||
this.visible = false;
|
||||
this.$emit("ok");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue