change - 监控单元信息中删除父级,子级依然保留的现象 改进-父级在删除时让用户确认是否删除全部子集,而且在删除父级后新建相同父级,子级无法重新添加父级,也要全部删除

main
wenjy 3 years ago
parent 9ba9a7d6d5
commit bacd30d4e6

@ -4,9 +4,13 @@ import java.util.Date;
import java.util.List;
import java.util.UUID;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.BaseAlarmInfo;
import com.ruoyi.system.domain.BaseDeviceParam;
import com.ruoyi.system.domain.BaseSensorInfo;
import com.ruoyi.system.domain.dto.BaseAlarmInfoDto;
import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
@ -15,11 +19,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BaseMonitorunitInfo;
@ -62,6 +62,17 @@ public class BaseMonitorunitInfoController extends BaseController {
return list;
}
@GetMapping("/listByParent")
@ResponseBody
public TableDataInfo listByParent(String parentId) {
startPage();
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
baseMonitorunitInfo.setParentId(parentId);
List<BaseMonitorunitInfoDto> list =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
return getDataTable(list);
}
/**
*
*
@ -217,6 +228,30 @@ public class BaseMonitorunitInfoController extends BaseController {
return toAjax(baseMonitorunitInfoService.deleteBaseMonitorunitInfoByObjId(ObjId));
}
/** 删除子项 */
@GetMapping("/deleteItem/{monitorunitId}")
public String deleteItem(@PathVariable("monitorunitId") String monitorunitId, ModelMap mmap) {
String info = monitorunitId;
mmap.put("monitorunitId", monitorunitId);
return prefix + "/deleteItem";
}
@PostMapping("/deleteItem")
@ResponseBody
public AjaxResult deleteItem(String ids) {
List<Long> longs = JSONArray.parseArray(ids, Long.class);
try{
for (Long aLong : longs) {
int i = baseMonitorunitInfoService.deleteBaseMonitorunitInfoByObjId(aLong);
}
}catch (Exception e){
return error();
}
return success();
}
/** 选择监控单元信息树 */
@GetMapping(value = {"/selectMonitorUnitInfoTree/{ObjId}", "/selectMonitorUnitInfoTree/"})
public String selectMonitorUnitInfoTree(

@ -0,0 +1,142 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('删除子项')"/>
<th:block th:include="include :: select2-css"/>
<th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-danger" onclick="deleteInBatches() ">
<i class="fa fa-remove"></i> 删除
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table" ></table>
</div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-suggest-js"/>
<th:block th:include="include :: bootstrap-typeahead-js"/>
<th:block th:include="include :: select2-js"/>
<script th:src="@{/js/jquery.tmpl.js}"></script>
<script th:inline="javascript">
var monitorunitStatusDatas = [[${@dict.getType('monitorunit_status')}]];
var prefix = ctx + "base/monitorUnitInfo";
$("#form-sensorInfo-edit").validate({
focusCleanup: true
});
$(function () {
//先销毁表格,必须先销毁才能实现动态加载数据
$('#bootstrap-table').bootstrapTable('destroy');
$('#bootstrap-table').bootstrapTable({
method: "get", //向服务器请求数据的方式
url: prefix+"/listByParent?parentId="+[[${monitorunitId}]],
striped: true, //表格显示条纹
pagination: false, //不启动分页
pageSize: 1, //每页显示的记录数
pageNumber: 1, //当前第几页
pageList: [5, 10, 15, 20, 25], //记录数可选列表
striped: true, //显示行间隔色
sortOrder: "asc", //排序方式
sidePagination: "server",
queryParamsType: "undefined",
columns: [
{
checkbox: true,
},
{
field: 'monitorunitName',
title: '监控单元',
align: 'left',
width:'160',
},
{
field: 'parentName',
title: '父级监控单元',
align: 'left',
width: '140',
},
{
field: 'monitorunitTypeName',
title: '监控单元类型',
align: 'left'
},
{
field: 'substationName',
title: '所属变电站',
align: 'left'
},
{
field: 'monitorunitImage',
title: '设备模型',
formatter: function(value, row, index) {
// 图片预览注意如存储在本地直接获取数据库路径如有配置context-path需要使用ctx+路径)
// 如:/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
if(index % 2 == 0){
return $.table.imageView('/img/profile.jpg');
}else {
return $.table.imageView(value);
}
}
},
{
field: 'monitorunitStatus',
title: '当前状态',
align: 'left',
formatter: function (value, row, index) {
return $.table.selectDictLabel(monitorunitStatusDatas, value);
}
},
{
field: 'enableFlag',
title: '是否启用',
align: 'left',
formatter: function (value, row, index) {
return $.table.selectDictLabel(enableFlagDatas, value);
},
visible: false
},
{
field: 'monitorunitId',
title: '监控单元编号',
align: 'left',
width: '280',
visible: false
},
],
onLoadSuccess: function () { //加载成功时执行
//layer.msg("加载成功");
},
onLoadError: function () { //加载失败时执行
layer.msg("加载数据失败", {time: 1500, icon: 2});
}
});
});
const deleteInBatches = () =>{
var row = $("#bootstrap-table").bootstrapTable('getSelections');
console.log(row)
if ($.common.isEmpty(row)) {
$.modal.alertWarning("请至少选择一条记录");
return;
}
$.modal.confirm("确定删除所选信息吗?", function() {
let ids = [];
row.map(x=>{
ids.push(x.objId);
})
var data = { "ids": JSON.stringify(ids) };
$.operate.submit(prefix+"/deleteItem", "post", "json", data);
location.reload();
});
}
</script>
</body>
</html>

@ -76,6 +76,9 @@
<a class="btn btn-info" id="expandAllBtn">
<i class="fa fa-exchange"></i> 展开/折叠
</a>
<a class="btn btn-danger" onclick="deleteItem() ">
<i class="fa fa-remove"></i> 删除子项
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-tree-table"></table>
@ -177,7 +180,6 @@
{
title: '操作',
align: 'center',
align: 'left',
formatter: function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.setParam(\'' + row.objId + '\')"><i class="fa fa-edit"></i>设备参数</a> ');
@ -190,6 +192,30 @@
};
$.treeTable.init(options);
});
const deleteItem = () => {
var row = $("#bootstrap-tree-table").bootstrapTreeTable('getSelections')[0];
if ($.common.isEmpty(row)) {
$.modal.alertWarning("请至少选择一条记录");
return;
}
if (row.parentName != null) {
$.modal.alertWarning("请选择父级数据");
return;
}
//$.modal.open("删除子项" , "/base/monitorUnitInfo/deleteItem/"+row.monitorunitId);
var options = {
title: '删除' + row.monitorunitName + '子项',
url: "/base/monitorUnitInfo/deleteItem/" + row.monitorunitId,
callBack: is
}
$.modal.openOptions(options);
}
const is = (index, layero) => {
$.modal.closeAll();
$.treeTable.refresh();
}
</script>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">

@ -261,22 +261,22 @@
dataType: 'JSON',
success: (res) => {
$("#access").html("");
$("#access").append(`<span>${res[0].alarmmoduleText}</span></br><span>${res[0].alarmModuleAmount}</span>`);
$("#access").append(`<span style="font-size: 75%;">${res[0].alarmmoduleText}</span></br><span>${res[0].alarmModuleAmount}</span>`);
$("#running").html("");
$("#running").append(`<span>${res[1].alarmmoduleText}</span></br><span>${res[1].alarmModuleAmount}</span>`);
$("#running").append(`<span style="font-size: 75%;">${res[1].alarmmoduleText}</span></br><span>${res[1].alarmModuleAmount}</span>`);
$("#standby").html("");
$("#standby").append(`<span>${res[2].alarmmoduleText}</span></br><span>${res[2].alarmModuleAmount}</span>`);
$("#standby").append(`<span style="font-size: 75%;">${res[2].alarmmoduleText}</span></br><span>${res[2].alarmModuleAmount}</span>`);
$("#failure").html("");
$("#failure").append(`<span>${res[3].alarmmoduleText}</span></br><span>${res[3].alarmModuleAmount}</span>`);
$("#failure").append(`<span style="font-size: 75%;">${res[3].alarmmoduleText}</span></br><span>${res[3].alarmModuleAmount}</span>`);
$("#repairing").html("");
$("#repairing").append(`<span>${res[4].alarmmoduleText}</span></br><span>${res[4].alarmModuleAmount}</span>`);
$("#repairing").append(`<span style="font-size: 75%;">${res[4].alarmmoduleText}</span></br><span>${res[4].alarmModuleAmount}</span>`);
$("#communication-failure").html("");
$("#communication-failure").append(`<span>${res[5].alarmmoduleText}</span></br><span>${res[5].alarmModuleAmount}</span>`);
$("#communication-failure").append(`<span style="font-size: 75%;">${res[5].alarmmoduleText}</span></br><span>${res[5].alarmModuleAmount}</span>`);
},
error: () => {
console.log("失败");

Loading…
Cancel
Save