diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitInfoController.java index 7a3f786..0c6a7e9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitInfoController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitInfoController.java @@ -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 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 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( diff --git a/ruoyi-admin/src/main/resources/templates/base/monitorUnitInfo/deleteItem.html b/ruoyi-admin/src/main/resources/templates/base/monitorUnitInfo/deleteItem.html new file mode 100644 index 0000000..f609dea --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/base/monitorUnitInfo/deleteItem.html @@ -0,0 +1,142 @@ + + + + + + + + + +
+ +
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/base/monitorUnitInfo/monitorUnitInfo.html b/ruoyi-admin/src/main/resources/templates/base/monitorUnitInfo/monitorUnitInfo.html index 5063521..53f6c38 100644 --- a/ruoyi-admin/src/main/resources/templates/base/monitorUnitInfo/monitorUnitInfo.html +++ b/ruoyi-admin/src/main/resources/templates/base/monitorUnitInfo/monitorUnitInfo.html @@ -76,6 +76,9 @@ 展开/折叠 + + 删除子项 +
@@ -119,7 +122,7 @@ field: 'monitorunitName', title: '监控单元', align: 'left', - width:'160', + width: '160', }, { field: 'parentName', @@ -140,12 +143,12 @@ { field: 'monitorunitImage', title: '设备模型', - formatter: function(value, row, index) { + formatter: function (value, row, index) { // 图片预览(注意:如存储在本地直接获取数据库路径,如有配置context-path需要使用ctx+路径) // 如:/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png - if(index % 2 == 0){ + if (index % 2 == 0) { return $.table.imageView('/img/profile.jpg'); - }else { + } else { return $.table.imageView(value); } } @@ -177,7 +180,6 @@ { title: '操作', align: 'center', - align: 'left', formatter: function (value, row, index) { var actions = []; actions.push('设备参数 '); @@ -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(); + }