国标通道编辑支持仅保存修改的字段

This commit is contained in:
lin 2025-11-06 15:50:42 +08:00
parent f89dee6393
commit 01e72407ac
10 changed files with 198 additions and 66 deletions

View File

@ -22,6 +22,7 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -33,6 +34,7 @@ import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
import java.beans.PropertyDescriptor;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
@ -86,13 +88,26 @@ public class ChannelController {
@Operation(summary = "更新通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "更新通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/update") @PostMapping("/update")
public void update(@RequestBody CommonGBChannel channel){ public void update(@RequestBody CommonGBChannel channel){
BeanWrapperImpl wrapper = new BeanWrapperImpl(channel);
int count = 0;
for (PropertyDescriptor pd : wrapper.getPropertyDescriptors()) {
String name = pd.getName();
if ("class".equals(name)) continue;
if (pd.getReadMethod() == null) continue;
Object val = wrapper.getPropertyValue(name);
if (val != null) count++;
}
Assert.isTrue(count > 1, "未进行任何修改");
channelService.update(channel); channelService.update(channel);
} }
@Operation(summary = "重置国标通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "重置国标通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/reset") @PostMapping("/reset")
public void reset(Integer id){ public void reset(ResetParam param){
channelService.reset(id); Assert.notNull(param.getId(), "通道ID不能为空");
Assert.notEmpty(param.getChanelFields(), "待重置字段不可以空");
channelService.reset(param.getId(), param.getChanelFields());
} }
@Operation(summary = "增加通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "增加通道", security = @SecurityRequirement(name = JwtUtils.HEADER))

View File

@ -0,0 +1,15 @@
package com.genersoft.iot.vmp.gb28181.controller.bean;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class ResetParam {
private Integer id;
private List<String> chanelFields;
}

View File

@ -117,40 +117,40 @@ public interface CommonGBChannelMapper {
@Update(value = {" <script>" + @Update(value = {" <script>" +
"UPDATE wvp_device_channel " + "UPDATE wvp_device_channel " +
"SET update_time=#{updateTime}" + "SET update_time=#{updateTime}" +
", gb_device_id = #{gbDeviceId}" + "<if test='gbDeviceId != null' > , gb_device_id = #{gbDeviceId}</if> " +
", gb_name = #{gbName}" + "<if test='gbName != null' > , gb_name = #{gbName}</if> " +
", gb_manufacturer = #{gbManufacturer}" + "<if test='gbManufacturer != null' > , gb_manufacturer = #{gbManufacturer}</if> " +
", gb_model = #{gbModel}" + "<if test='gbModel != null' > , gb_model = #{gbModel}</if> " +
", gb_owner = #{gbOwner}" + "<if test='gbOwner != null' > , gb_owner = #{gbOwner}</if> " +
", gb_civil_code = #{gbCivilCode}" + "<if test='gbCivilCode != null' > , gb_civil_code = #{gbCivilCode}</if> " +
", gb_block = #{gbBlock}" + "<if test='gbBlock != null' > , gb_block = #{gbBlock}</if> " +
", gb_address = #{gbAddress}" + "<if test='gbAddress != null' > , gb_address = #{gbAddress}</if> " +
", gb_parental = #{gbParental}" + "<if test='gbParental != null' > , gb_parental = #{gbParental}</if> " +
", gb_parent_id = #{gbParentId}" + "<if test='gbParentId != null' > , gb_parent_id = #{gbParentId}</if> " +
", gb_safety_way = #{gbSafetyWay}" + "<if test='gbSafetyWay != null' > , gb_safety_way = #{gbSafetyWay}</if> " +
", gb_register_way = #{gbRegisterWay}" + "<if test='gbRegisterWay != null' > , gb_register_way = #{gbRegisterWay}</if> " +
", gb_cert_num = #{gbCertNum}" + "<if test='gbCertNum != null' > , gb_cert_num = #{gbCertNum}</if> " +
", gb_certifiable = #{gbCertifiable}" + "<if test='gbCertifiable != null' > , gb_certifiable = #{gbCertifiable}</if> " +
", gb_err_code = #{gbErrCode}" + "<if test='gbErrCode != null' > , gb_err_code = #{gbErrCode}</if> " +
", gb_end_time = #{gbEndTime}" + "<if test='gbEndTime != null' > , gb_end_time = #{gbEndTime}</if> " +
", gb_ip_address = #{gbIpAddress}" + "<if test='gbIpAddress != null' > , gb_ip_address = #{gbIpAddress}</if> " +
", gb_port = #{gbPort}" + "<if test='gbPort != null' > , gb_port = #{gbPort}</if> " +
", gb_password = #{gbPassword}" + "<if test='gbPassword != null' > , gb_password = #{gbPassword}</if> " +
", gb_status = #{gbStatus}" + "<if test='gbStatus != null' > , gb_status = #{gbStatus}</if> " +
", gb_longitude = #{gbLongitude}" + "<if test='gbLongitude != null' > , gb_longitude = #{gbLongitude}</if> " +
", gb_latitude = #{gbLatitude}" + "<if test='gbLatitude != null' > , gb_latitude = #{gbLatitude}</if> " +
", gb_ptz_type = #{gbPtzType}" + "<if test='gbPtzType != null' > , gb_ptz_type = #{gbPtzType}</if> " +
", gb_position_type = #{gbPositionType}" + "<if test='gbPositionType != null' > , gb_position_type = #{gbPositionType}</if> " +
", gb_room_type = #{gbRoomType}" + "<if test='gbRoomType != null' > , gb_room_type = #{gbRoomType}</if> " +
", gb_use_type = #{gbUseType}" + "<if test='gbUseType != null' > , gb_use_type = #{gbUseType}</if> " +
", gb_supply_light_type = #{gbSupplyLightType}" + "<if test='gbSupplyLightType != null' > , gb_supply_light_type = #{gbSupplyLightType}</if> " +
", gb_direction_type = #{gbDirectionType}" + "<if test='gbDirectionType != null' > , gb_direction_type = #{gbDirectionType}</if> " +
", gb_resolution = #{gbResolution}" + "<if test='gbResolution != null' > , gb_resolution = #{gbResolution}</if> " +
", gb_business_group_id = #{gbBusinessGroupId}" + "<if test='gbBusinessGroupId != null' > , gb_business_group_id = #{gbBusinessGroupId}</if> " +
", gb_download_speed = #{gbDownloadSpeed}" + "<if test='gbDownloadSpeed != null' > , gb_download_speed = #{gbDownloadSpeed}</if> " +
", gb_svc_space_support_mod = #{gbSvcSpaceSupportMod}" + "<if test='gbSvcSpaceSupportMod != null' > , gb_svc_space_support_mod = #{gbSvcSpaceSupportMod}</if> " +
", gb_svc_time_support_mode = #{gbSvcTimeSupportMode}" + "<if test='gbSvcTimeSupportMode != null' > , gb_svc_time_support_mode = #{gbSvcTimeSupportMode}</if> " +
", enable_broadcast = #{enableBroadcast}" + "<if test='enableBroadcast != null' > , enable_broadcast = #{enableBroadcast}</if> " +
" WHERE id = #{gbId}"+ " WHERE id = #{gbId}"+
" </script>"}) " </script>"})
int update(CommonGBChannel commonGBChannel); int update(CommonGBChannel commonGBChannel);
@ -236,17 +236,13 @@ public interface CommonGBChannelMapper {
@Update(value = {" <script>" + @Update(value = {" <script>" +
" UPDATE wvp_device_channel " + " UPDATE wvp_device_channel " +
" SET update_time=#{updateTime}, gb_device_id = null, gb_name = null, gb_manufacturer = null," + " SET update_time=#{updateTime}" +
" gb_model = null, gb_owner = null, gb_block = null, gb_address = null," + "<foreach collection='fields' index='index' item='item' separator=';'> " +
" gb_parental = null, gb_parent_id = null, gb_safety_way = null, gb_register_way = null, gb_cert_num = null," + ", #{item} = null" +
" gb_certifiable = null, gb_err_code = null, gb_end_time = null, gb_secrecy = null, gb_ip_address = null, " + "</foreach> " +
" gb_port = null, gb_password = null, gb_status = null, gb_longitude = null, gb_latitude = null, " + " WHERE id = #{id}"+
" gb_ptz_type = null, gb_position_type = null, gb_room_type = null, gb_use_type = null, gb_supply_light_type = null, " +
" gb_direction_type = null, gb_resolution = null, gb_business_group_id = null, gb_download_speed = null, gb_svc_space_support_mod = null, " +
" gb_svc_time_support_mode = null" +
" WHERE id = #{id} and data_type = #{dataType} and data_device_id = #{dataDeviceId}"+
" </script>"}) " </script>"})
void reset(@Param("id") int id, @Param("dataType") Integer dataType, @Param("dataDeviceId") int dataDeviceId, @Param("updateTime") String updateTime); void reset(@Param("id") int id, List<String> fields, @Param("updateTime") String updateTime);
@SelectProvider(type = ChannelProvider.class, method = "queryByIds") @SelectProvider(type = ChannelProvider.class, method = "queryByIds")
@ -421,7 +417,7 @@ public interface CommonGBChannelMapper {
", gb_ip_address=#{item.gbIpAddress}" + ", gb_ip_address=#{item.gbIpAddress}" +
", gb_port=#{item.gbPort}" + ", gb_port=#{item.gbPort}" +
", gb_password=#{item.gbPassword}" + ", gb_password=#{item.gbPassword}" +
", gb_status=#{item.gbStatus}" + "<if test='item.gbStatus != null' > , gb_status=#{item.gbStatus}</if> " +
", gb_longitude=#{item.gbLongitude}" + ", gb_longitude=#{item.gbLongitude}" +
", gb_latitude=#{item.gbLatitude}" + ", gb_latitude=#{item.gbLatitude}" +
", gb_ptz_type=#{item.gbPtzType}" + ", gb_ptz_type=#{item.gbPtzType}" +

View File

@ -309,12 +309,12 @@ public interface GroupMapper {
@Select("<script>" + @Select("<script>" +
" SELECT " + " SELECT " +
" ANY_VALUE(coalesce( wdc.gb_parent_id, wdc.parent_id)) as deviceId," + " MIN(coalesce( wdc.gb_parent_id, wdc.parent_id)) as deviceId," +
" COUNT(*) AS allCount," + " COUNT(*) AS allCount," +
" SUM(CASE WHEN coalesce( wdc.gb_status, wdc.status) = 'ON' THEN 1 ELSE 0 END) AS onlineCount" + " SUM(CASE WHEN coalesce( wdc.gb_status, wdc.status) = 'ON' THEN 1 ELSE 0 END) AS onlineCount" +
" FROM " + " FROM " +
" wvp_device_channel wdc " + " wvp_device_channel wdc " +
" where wdc.channel_type = 0 AND wdc.data_type != 2 AND (wdc.gb_ptz_type is null || ( wdc.gb_ptz_type != 98 AND wdc.gb_ptz_type != 99)) " + " where wdc.channel_type = 0 AND wdc.data_type != 2 AND (wdc.gb_ptz_type is null or ( wdc.gb_ptz_type != 98 AND wdc.gb_ptz_type != 99)) " +
" AND coalesce( wdc.gb_parent_id, wdc.parent_id) in " + " AND coalesce( wdc.gb_parent_id, wdc.parent_id) in " +
" <foreach collection='groupList' item='item' open='(' separator=',' close=')' > #{item.deviceId}</foreach>" + " <foreach collection='groupList' item='item' open='(' separator=',' close=')' > #{item.deviceId}</foreach>" +
" GROUP BY coalesce(wdc.gb_parent_id, wdc.parent_id)" + " GROUP BY coalesce(wdc.gb_parent_id, wdc.parent_id)" +

View File

@ -42,7 +42,7 @@ public interface IGbChannelService {
List<NetworkIdentificationType> getNetworkIdentificationTypeList(); List<NetworkIdentificationType> getNetworkIdentificationTypeList();
void reset(int id); void reset(int id, List<String> chanelFields);
PageInfo<CommonGBChannel> queryListByCivilCode(int page, int count, String query, Boolean online, Integer channelType, String civilCode); PageInfo<CommonGBChannel> queryListByCivilCode(int page, int count, String query, Boolean online, Integer channelType, String civilCode);

View File

@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.service.impl;
import com.alibaba.excel.support.cglib.beans.BeanMap; import com.alibaba.excel.support.cglib.beans.BeanMap;
import com.alibaba.excel.util.BeanMapUtils; import com.alibaba.excel.util.BeanMapUtils;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.common.enums.ChannelDataType; import com.genersoft.iot.vmp.common.enums.ChannelDataType;
import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.DynamicTask;
@ -25,11 +26,13 @@ import com.genersoft.iot.vmp.utils.TileUtils;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.google.common.base.CaseFormat;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import no.ecc.vectortile.VectorTileEncoder; import no.ecc.vectortile.VectorTileEncoder;
import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.Point; import org.locationtech.jts.geom.Point;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -165,26 +168,28 @@ public class GbChannelServiceImpl implements IGbChannelService {
CommonGBChannel oldChannel = commonGBChannelMapper.queryById(commonGBChannel.getGbId()); CommonGBChannel oldChannel = commonGBChannelMapper.queryById(commonGBChannel.getGbId());
commonGBChannel.setUpdateTime(DateUtil.getNow()); commonGBChannel.setUpdateTime(DateUtil.getNow());
int result = commonGBChannelMapper.update(commonGBChannel); int result = commonGBChannelMapper.update(commonGBChannel);
if (result > 0) { if (result > 0) {
try { try {
CommonGBChannel newChannel = commonGBChannelMapper.queryById(commonGBChannel.getGbId());
// 发送通知 // 发送通知
eventPublisher.channelEventPublishForUpdate(commonGBChannel, oldChannel); eventPublisher.channelEventPublishForUpdate(newChannel, oldChannel);
if (commonGBChannel.getGbLongitude() != null && !Objects.equals(oldChannel.getGbLongitude(), commonGBChannel.getGbLongitude()) if (newChannel.getGbLongitude() != null && !Objects.equals(oldChannel.getGbLongitude(), newChannel.getGbLongitude())
&& commonGBChannel.getGbLatitude() != null && !Objects.equals(oldChannel.getGbLatitude(), commonGBChannel.getGbLatitude())) { && newChannel.getGbLatitude() != null && !Objects.equals(oldChannel.getGbLatitude(), newChannel.getGbLatitude())) {
MobilePosition mobilePosition = new MobilePosition(); MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setDeviceId(commonGBChannel.getGbDeviceId()); mobilePosition.setDeviceId(newChannel.getGbDeviceId());
mobilePosition.setChannelId(commonGBChannel.getGbId()); mobilePosition.setChannelId(newChannel.getGbId());
mobilePosition.setDeviceName(commonGBChannel.getGbName()); mobilePosition.setDeviceName(newChannel.getGbName());
mobilePosition.setCreateTime(DateUtil.getNow()); mobilePosition.setCreateTime(DateUtil.getNow());
mobilePosition.setTime(DateUtil.getNow()); mobilePosition.setTime(DateUtil.getNow());
mobilePosition.setLongitude(commonGBChannel.getGbLongitude()); mobilePosition.setLongitude(newChannel.getGbLongitude());
mobilePosition.setLatitude(commonGBChannel.getGbLatitude()); mobilePosition.setLatitude(newChannel.getGbLatitude());
eventPublisher.mobilePositionEventPublish(mobilePosition); eventPublisher.mobilePositionEventPublish(mobilePosition);
} }
} catch (Exception e) { } catch (Exception e) {
log.warn("[更新通道通知] 发送失败,{}", commonGBChannel.getGbDeviceId(), e); log.warn("[更新通道通知] 发送失败,{}", JSONObject.toJSONString(commonGBChannel), e);
} }
} }
return result; return result;
@ -422,8 +427,9 @@ public class GbChannelServiceImpl implements IGbChannelService {
} }
@Override @Override
public void reset(int id) { public void reset(int id, List<String> chanelFields) {
log.info("[重置国标通道] id: {}", id); log.info("[重置国标通道] id: {}", id);
Assert.notEmpty(chanelFields, "待重置字段为空");
CommonGBChannel channel = getOne(id); CommonGBChannel channel = getOne(id);
if (channel == null) { if (channel == null) {
log.warn("[重置国标通道] 未找到对应Id的通道: id: {}", id); log.warn("[重置国标通道] 未找到对应Id的通道: id: {}", id);
@ -433,8 +439,18 @@ public class GbChannelServiceImpl implements IGbChannelService {
log.warn("[重置国标通道] 非国标下级通道无法重置: id: {}", id); log.warn("[重置国标通道] 非国标下级通道无法重置: id: {}", id);
throw new ControllerException(ErrorCode.ERROR100.getCode(), "非国标下级通道无法重置"); throw new ControllerException(ErrorCode.ERROR100.getCode(), "非国标下级通道无法重置");
} }
List<String> dbFields = new ArrayList<>();
for (String chanelField : chanelFields) {
BeanWrapperImpl wrapper = new BeanWrapperImpl(channel);
if (wrapper.isReadableProperty(chanelField)) {
dbFields.add(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, chanelField));
}
}
Assert.notEmpty(dbFields, "待重置字段为空");
// 这个多加一个参数,为了防止将非国标的通道通过此方法清空内容,导致意外发生 // 这个多加一个参数,为了防止将非国标的通道通过此方法清空内容,导致意外发生
commonGBChannelMapper.reset(id, ChannelDataType.GB28181, channel.getDataDeviceId(), DateUtil.getNow()); commonGBChannelMapper.reset(id, dbFields, DateUtil.getNow());
CommonGBChannel channelNew = getOne(id); CommonGBChannel channelNew = getOne(id);
// 发送通过更新通知 // 发送通过更新通知
try { try {

View File

@ -102,7 +102,9 @@ public class RedisPushStreamListMsgListener implements MessageListener {
streamPush.setUpdateTime(DateUtil.getNow()); streamPush.setUpdateTime(DateUtil.getNow());
streamPush.setGbDeviceId(pushStreamMessage.getGbId()); streamPush.setGbDeviceId(pushStreamMessage.getGbId());
streamPush.setGbName(pushStreamMessage.getName()); streamPush.setGbName(pushStreamMessage.getName());
streamPush.setGbStatus(pushStreamMessage.isStatus() ? "ON" : "OFF"); if (pushStreamMessage.getStatus() != null) {
streamPush.setGbStatus(pushStreamMessage.getStatus() ? "ON" : "OFF");
}
//存在就只修改 name和gbId //存在就只修改 name和gbId
streamPushItemForUpdate.add(streamPush); streamPushItemForUpdate.add(streamPush);
} }

View File

@ -9,7 +9,7 @@ public class RedisPushStreamMessage {
private String app; private String app;
private String stream; private String stream;
private String name; private String name;
private boolean status; private Boolean status;
// 终端所属的虚拟组织 // 终端所属的虚拟组织
private String groupGbId; private String groupGbId;
// 终端所属的虚拟组织别名 可选可作为地方同步组织结构到wvp时的关联关系 // 终端所属的虚拟组织别名 可选可作为地方同步组织结构到wvp时的关联关系
@ -31,7 +31,9 @@ public class RedisPushStreamMessage {
push.setGbManufacturer(manufacturer); push.setGbManufacturer(manufacturer);
push.setGbModel(model); push.setGbModel(model);
push.setGbPtzType(ptzType); push.setGbPtzType(ptzType);
push.setGbStatus(status?"ON":"OFF"); if (status != null) {
push.setGbStatus(status?"ON":"OFF");
}
push.setEnableBroadcast(0); push.setEnableBroadcast(0);
return push; return push;
} }

76
web/src/utils/diff.js Normal file
View File

@ -0,0 +1,76 @@
// utils/diff.js
// 返回 newObj 相对于 oldObj 的变化部分(新增/修改)。
// 可选 includeRemoved=true 时把被删除字段以 removedValue 标记返回。
// 使用示例: diff(oldObj, newObj) 或 diff(oldObj, newObj, { includeRemoved: true })
export function diff(oldObj, newObj, options = {}) {
const { includeRemoved = false, removedValue = null, comparator } = options
function isObject(v) {
return v && typeof v === 'object' && !Array.isArray(v) && !(v instanceof Date)
}
function isDate(v) {
return v instanceof Date
}
function equal(a, b) {
if (typeof comparator === 'function') return comparator(a, b)
if (isDate(a) && isDate(b)) return a.getTime() === b.getTime()
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) return false
for (let i = 0; i < a.length; i++) if (!equal(a[i], b[i])) return false
return true
}
if (isObject(a) && isObject(b)) {
const aKeys = Object.keys(a)
const bKeys = Object.keys(b)
if (aKeys.length !== bKeys.length) return false
for (const k of aKeys) {
if (!Object.prototype.hasOwnProperty.call(b, k) || !equal(a[k], b[k])) return false
}
return true
}
return a === b
}
function inner(o, n) {
// Normalize undefined -> empty object for easier handling in object branch.
const oIsObj = isObject(o)
const nIsObj = isObject(n)
if (equal(o, n)) return undefined
if (oIsObj && nIsObj) {
const result = {}
const keys = new Set([...Object.keys(o || {}), ...Object.keys(n || {})])
for (const k of keys) {
console.log(k)
const hasO = Object.prototype.hasOwnProperty.call(o || {}, k)
const hasN = Object.prototype.hasOwnProperty.call(n || {}, k)
if (hasN) {
const sub = inner(hasO ? o[k] : undefined, n[k])
if (sub !== undefined) result[k] = sub
} else if (hasO && includeRemoved) {
// key existed before but removed now
result[k] = removedValue
}
}
return Object.keys(result).length ? result : undefined
}
if (Array.isArray(o) && Array.isArray(n)) {
return equal(o, n) ? undefined : n
}
if (isDate(n)) return n
// Different primitive or type change -> return new value
return n
}
const res = inner(oldObj ?? {}, newObj ?? {})
return res === undefined ? {} : res
}
export default diff

View File

@ -248,6 +248,7 @@
import channelCode from './../dialog/channelCode' import channelCode from './../dialog/channelCode'
import ChooseCivilCode from '../dialog/chooseCivilCode.vue' import ChooseCivilCode from '../dialog/chooseCivilCode.vue'
import ChooseGroup from '../dialog/chooseGroup.vue' import ChooseGroup from '../dialog/chooseGroup.vue'
import diff from '../../utils/diff'
export default { export default {
name: 'CommonChannelEdit', name: 'CommonChannelEdit',
@ -288,7 +289,7 @@ export default {
if (!this.dataForm.gbDeviceId) { if (!this.dataForm.gbDeviceId) {
this.dataForm.gbDeviceId = '' this.dataForm.gbDeviceId = ''
} }
this.form = this.dataForm this.form = window.structuredClone(this.dataForm)
this.getPaths() this.getPaths()
} }
}, },
@ -309,8 +310,16 @@ export default {
this.form.gbDownloadSpeed = this.form.gbDownloadSpeedArray.join('/') this.form.gbDownloadSpeed = this.form.gbDownloadSpeedArray.join('/')
} }
this.form.enableBroadcast = this.form.enableBroadcastForBool ? 1 : 0 this.form.enableBroadcast = this.form.enableBroadcastForBool ? 1 : 0
//
let diffData = diff(this.dataForm, this.form)
diffData['gbId'] = this.form.gbId
console.log(diffData)
console.log(this.dataForm)
console.log(this.form)
if (this.form.gbId) { if (this.form.gbId) {
this.$store.dispatch('commonChanel/update', this.form) this.$store.dispatch('commonChanel/update', diffData)
.then(data => { .then(data => {
this.$message.success({ this.$message.success({
showClose: true, showClose: true,
@ -368,6 +377,7 @@ export default {
if (data.gbDownloadSpeed) { if (data.gbDownloadSpeed) {
data.gbDownloadSpeedArray = data.gbDownloadSpeed.split('/') data.gbDownloadSpeedArray = data.gbDownloadSpeed.split('/')
} }
this.dataForm = window.structuredClone(data)
this.form = data this.form = data
this.$set(this.form, 'enableBroadcastForBool', this.form.enableBroadcast === 1) this.$set(this.form, 'enableBroadcastForBool', this.form.enableBroadcast === 1)
this.getPaths() this.getPaths()