diff options
19 files changed, 607 insertions, 119 deletions
diff --git a/nezha-admin/src/main/java/com/nis/modules/detect/controller/DeteTypeController.java b/nezha-admin/src/main/java/com/nis/modules/detect/controller/DeteTypeController.java index e3dd41e9..d3681ee2 100644 --- a/nezha-admin/src/main/java/com/nis/modules/detect/controller/DeteTypeController.java +++ b/nezha-admin/src/main/java/com/nis/modules/detect/controller/DeteTypeController.java @@ -1,5 +1,6 @@ package com.nis.modules.detect.controller; +import com.alibaba.fastjson.JSON; import com.nis.common.exception.NZException; import com.nis.common.smartvalidate.ValidateUtils; import com.nis.common.utils.Constant; @@ -22,7 +23,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import java.io.File; import java.util.Date; import java.util.List; import java.util.Map; @@ -59,29 +62,33 @@ public class DeteTypeController { return R.ok(deteTypeInfo); } - @PostMapping(value = "/save", produces = MediaType.APPLICATION_JSON_VALUE) +// @PostMapping(value = "/save", produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(value = "/save") @ResponseBody @ApiOperation(value = "保存监测类别") - public R save(@RequestBody DeteTypeInfoEntity deteTypeInfo) { - deteTypeInfoService.validatePassDate(deteTypeInfo); + public R save(@RequestParam(value="deteTypeInfo",required = true) String jsonTypeInfo,@RequestParam(value="file",required = false) MultipartFile file) { + DeteTypeInfoEntity deteTypeInfo= JSON.parseObject(jsonTypeInfo,DeteTypeInfoEntity.class); + deteTypeInfoService.validatePassDate(deteTypeInfo,file); if(deteTypeInfo.getDeteInterval()==null||deteTypeInfo.getDeteInterval()<0){ deteTypeInfo.setDeteInterval(60); } - deteTypeInfoService.saveEntity(deteTypeInfo); + deteTypeInfoService.saveEntity(deteTypeInfo,file); return R.ok(); } - @PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE) + @PutMapping(value = "/update") +// @PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody @ApiOperation(value = "更新监测类别") - public R update(@RequestBody DeteTypeInfoEntity deteTypeInfo) { + public R update(@RequestParam(value="deteTypeInfo",required = true) String jsonTypeInfo,@RequestParam(value="file",required = false) MultipartFile file) { + DeteTypeInfoEntity deteTypeInfo= JSON.parseObject(jsonTypeInfo,DeteTypeInfoEntity.class); if(deteTypeInfoService.isBuildIn(deteTypeInfo)){ //内置配置,不允许修改 throw new NZException(RCode.BUILDIN_CONFIG); } - deteTypeInfoService.validatePassDate(deteTypeInfo); - deteTypeInfoService.updateEntity(deteTypeInfo); + deteTypeInfoService.validatePassDate(deteTypeInfo,file); + deteTypeInfoService.updateEntity(deteTypeInfo,file); return R.ok(); } @@ -176,4 +183,5 @@ public class DeteTypeController { return R.ok("true"); } } + } diff --git a/nezha-admin/src/main/java/com/nis/modules/detect/entity/DeteTypeInfoEntity.java b/nezha-admin/src/main/java/com/nis/modules/detect/entity/DeteTypeInfoEntity.java index cc61836c..2c75d613 100644 --- a/nezha-admin/src/main/java/com/nis/modules/detect/entity/DeteTypeInfoEntity.java +++ b/nezha-admin/src/main/java/com/nis/modules/detect/entity/DeteTypeInfoEntity.java @@ -3,6 +3,7 @@ package com.nis.modules.detect.entity; import com.baomidou.mybatisplus.annotation.*; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; +import org.springframework.web.multipart.MultipartFile; import java.io.Serializable; import java.util.Date; diff --git a/nezha-admin/src/main/java/com/nis/modules/detect/service/DeteCommonService.java b/nezha-admin/src/main/java/com/nis/modules/detect/service/DeteCommonService.java index 8f2bde07..a3289505 100644 --- a/nezha-admin/src/main/java/com/nis/modules/detect/service/DeteCommonService.java +++ b/nezha-admin/src/main/java/com/nis/modules/detect/service/DeteCommonService.java @@ -1,6 +1,7 @@ package com.nis.modules.detect.service; import com.baomidou.mybatisplus.extension.service.IService; +import org.springframework.web.multipart.MultipartFile; public interface DeteCommonService<T> extends IService<T>{ boolean checkFieldExists(Long id,String field,String value); @@ -10,4 +11,8 @@ public interface DeteCommonService<T> extends IService<T>{ boolean checkFieldIsValide(String type,String code); boolean checkViewLevelValide(String code); boolean checkTypeExists(Long typeId); + + String getUploadFileJson(MultipartFile file); + void uploadFile(String jsonInfo,MultipartFile file); + void delUploadFile(String jsonInfo); } diff --git a/nezha-admin/src/main/java/com/nis/modules/detect/service/DeteTypeInfoService.java b/nezha-admin/src/main/java/com/nis/modules/detect/service/DeteTypeInfoService.java index 052b5f01..d65545fc 100644 --- a/nezha-admin/src/main/java/com/nis/modules/detect/service/DeteTypeInfoService.java +++ b/nezha-admin/src/main/java/com/nis/modules/detect/service/DeteTypeInfoService.java @@ -2,6 +2,7 @@ package com.nis.modules.detect.service; import com.nis.common.utils.PageUtils; import com.nis.modules.detect.entity.DeteTypeInfoEntity; +import org.springframework.web.multipart.MultipartFile; import java.util.Map; @@ -10,13 +11,13 @@ public interface DeteTypeInfoService extends DeteCommonService<DeteTypeInfoEntit DeteTypeInfoEntity queryDetail(Long id); - void saveEntity(DeteTypeInfoEntity deteTypeInfo); + void saveEntity(DeteTypeInfoEntity deteTypeInfo,MultipartFile file); - void updateEntity(DeteTypeInfoEntity deteTypeInfo); + void updateEntity(DeteTypeInfoEntity deteTypeInfo,MultipartFile file); boolean checkTablesExists(String tableName); - void validatePassDate(DeteTypeInfoEntity deteTypeInfo); + void validatePassDate(DeteTypeInfoEntity deteTypeInfo, MultipartFile file); void deleteEntity(Long... id); diff --git a/nezha-admin/src/main/java/com/nis/modules/detect/service/impl/DeteCommonServiceImpl.java b/nezha-admin/src/main/java/com/nis/modules/detect/service/impl/DeteCommonServiceImpl.java index 3b0d02e7..e65b761d 100644 --- a/nezha-admin/src/main/java/com/nis/modules/detect/service/impl/DeteCommonServiceImpl.java +++ b/nezha-admin/src/main/java/com/nis/modules/detect/service/impl/DeteCommonServiceImpl.java @@ -1,5 +1,6 @@ package com.nis.modules.detect.service.impl; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; @@ -10,6 +11,7 @@ import com.nis.common.utils.RCode; import com.nis.modules.detect.entity.DeteTypeInfoEntity; import com.nis.modules.detect.service.DeteCommonService; import com.nis.modules.detect.service.DeteTypeInfoService; +import com.nis.modules.mission.utils.FileUtil; import com.nis.modules.sys.entity.PermissionInfoEntity; import com.nis.modules.sys.entity.SysDictEntity; import com.nis.modules.sys.entity.UserUsergroupEntity; @@ -18,7 +20,11 @@ import com.nis.modules.sys.service.UserUsergroupService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; +import org.springframework.core.env.Environment; +import org.springframework.util.ResourceUtils; +import org.springframework.web.multipart.MultipartFile; +import java.io.File; import java.util.*; public class DeteCommonServiceImpl<M extends BaseMapper<T>,T> extends ServiceImpl<M ,T> implements DeteCommonService<T> , ApplicationRunner { @@ -29,6 +35,8 @@ public class DeteCommonServiceImpl<M extends BaseMapper<T>,T> extends ServiceImp private SysDictService sysDictService; @Autowired private DeteTypeInfoService deteTypeInfoService; + @Autowired + private Environment environment; public static Map<String,Set<String>> sysDic=new HashMap<String, Set<String>>(); @@ -158,5 +166,95 @@ public class DeteCommonServiceImpl<M extends BaseMapper<T>,T> extends ServiceImp sysDic.put(type,codes); } } + @Override + public String getUploadFileJson(MultipartFile file){ + + Map<String,String> map=new HashMap<String,String>(); + String originalFilename = file.getOriginalFilename(); + map.put("fileName",originalFilename); + + long size = file.getSize(); + String formetSize = new FileUtil().FormetFileSize(size); + + map.put("fileSize",formetSize); + +// String rootPath=null; +// try{ +// rootPath= ResourceUtils.getURL("classpath:").getPath(); +// System.out.println(rootPath); +// }catch (Exception e){ +// e.printStackTrace(); +// } + + String configUploadPath= environment.getProperty("upload.path"); + +// String uploadPath=rootPath+configUploadPath; + map.put("uploadPath",configUploadPath); + + String fileName=configUploadPath+ FileUtil.addTimeTagForUploadFileName(originalFilename); + + map.put("filePath",fileName); + + return JSON.toJSONString(map); + } + @Override + public void uploadFile(String jsonInfo,MultipartFile file){ + + Map<String,String> map=JSON.parseObject(jsonInfo,HashMap.class); + + String rootPath=null; + try{ + rootPath= ResourceUtils.getURL("classpath:").getPath(); + }catch (Exception e){ + e.printStackTrace(); + } + + String uploadPath=rootPath+map.get("uploadPath"); + String filePath=map.get("filePath"); + File uploadDir=new File(uploadPath); + if(!uploadDir.exists()){ + uploadDir.mkdirs(); + }else{//存在同名文件/文件夹 + if(!uploadDir.isDirectory()){//是一个同名文件 + uploadDir.delete(); + uploadDir.mkdirs(); + } + } + + File destFile=new File(rootPath+filePath); + if(destFile.exists()){ + destFile.delete(); + } + try{ + file.transferTo(destFile); + + }catch (Exception e){ + System.out.println(e); + e.printStackTrace(); + } + + } + + public void delUploadFile(String jsonInfo){ + try { + Map<String,String> map=JSON.parseObject(jsonInfo,HashMap.class); + String filePath = map.get("filePath"); + + String rootPath=null; + try{ + rootPath= ResourceUtils.getURL("classpath:").getPath(); + }catch (Exception e){ + e.printStackTrace(); + } + + File file=new File(rootPath+filePath); + if(file.exists()){ + file.delete(); + } + }catch (Exception e){ + e.printStackTrace(); + } + + } } diff --git a/nezha-admin/src/main/java/com/nis/modules/detect/service/impl/DeteTypeInfoServiceImpl.java b/nezha-admin/src/main/java/com/nis/modules/detect/service/impl/DeteTypeInfoServiceImpl.java index 20ed7a4e..38928c17 100644 --- a/nezha-admin/src/main/java/com/nis/modules/detect/service/impl/DeteTypeInfoServiceImpl.java +++ b/nezha-admin/src/main/java/com/nis/modules/detect/service/impl/DeteTypeInfoServiceImpl.java @@ -14,6 +14,7 @@ import com.nis.modules.detect.entity.DeteTypeMetaEntity; import com.nis.modules.detect.entity.DeteTypeParamEntity; import com.nis.modules.detect.service.*; import com.nis.modules.sys.shiro.ShiroUtils; +import io.netty.util.internal.StringUtil; import org.apache.commons.lang.StringUtils; import org.apache.http.impl.auth.NTLMEngineException; import org.slf4j.Logger; @@ -23,7 +24,9 @@ import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; +import java.nio.channels.MulticastChannel; import java.util.*; @Service("deteTypeInfoService") @@ -69,12 +72,18 @@ public class DeteTypeInfoServiceImpl extends DeteCommonServiceImpl<DeteTypeInfoD @Override @Transactional(rollbackFor = Exception.class) - public void saveEntity(DeteTypeInfoEntity deteTypeInfo) { + public void saveEntity(DeteTypeInfoEntity deteTypeInfo,MultipartFile file) { Long userId = ShiroUtils.getUserId();//操作员 deteTypeInfo.setOperator(userId); Date date = new Date(); //操作时间 deteTypeInfo.setOpTime(date); deteTypeInfo.setBuildIn(Constant.SYSTEM_BUILDIN_NO); + if(Constant.DETE_DETEMETHOD_SCRIPT.equals(deteTypeInfo.getMethod())){ + + String content=this.getUploadFileJson(file); + this.uploadFile(content,file); + deteTypeInfo.setContent(content); + } List<DeteTypeMetaEntity> deteTypeMetas = deteTypeInfo.getDeteTypeMetas(); @@ -132,7 +141,7 @@ public class DeteTypeInfoServiceImpl extends DeteCommonServiceImpl<DeteTypeInfoD @Override @Transactional(rollbackFor = Exception.class) - public void updateEntity(DeteTypeInfoEntity deteTypeInfo) { + public void updateEntity(DeteTypeInfoEntity deteTypeInfo,MultipartFile file) { DeteTypeInfoEntity old = this.getById(deteTypeInfo.getId()); List<DeteTypeMetaEntity> deteTypeMetas = deteTypeInfo.getDeteTypeMetas(); List<DeteTypeParamEntity> deteTypeParams = deteTypeInfo.getDeteTypeParams(); @@ -142,7 +151,14 @@ public class DeteTypeInfoServiceImpl extends DeteCommonServiceImpl<DeteTypeInfoD deteTypeInfo.setOpTime(date); deteTypeInfo.setTableName(old.getTableName()); deteTypeInfo.setBuildIn(old.getBuildIn());//buildIn 字段不允许修改 - + if(Constant.DETE_DETEMETHOD_SCRIPT.equals(deteTypeInfo.getMethod())&&file!=null&&!file.isEmpty()){ + if(StringUtils.isNotBlank(old.getContent())){ + this.delUploadFile(old.getContent());//删除旧文件 + } + String content=this.getUploadFileJson(file); + this.uploadFile(content,file); + deteTypeInfo.setContent(content); + } //需要修改表字段 List<DeteTypeMetaEntity> metaUpdateList = new ArrayList<DeteTypeMetaEntity>(); //需要添加表字段 @@ -302,11 +318,16 @@ public class DeteTypeInfoServiceImpl extends DeteCommonServiceImpl<DeteTypeInfoD public void deleteEntity(Long... ids) { Long userId = ShiroUtils.getUserId(); Date date=new Date(); - //drop对应的表 + for (Long id :ids){ DeteTypeInfoEntity oldType = this.getById(id); if(oldType!=null&& StringUtils.isNotBlank(oldType.getTableName())&&checkTablesExists(oldType.getTableName())){ + //drop对应的表 this.dropTable(oldType.getTableName()); + //如果是脚本监测,删除脚本 + if(Constant.DETE_DETEMETHOD_SCRIPT.equals(oldType.getMethod())){ + this.delUploadFile(oldType.getContent()); + } } } @@ -509,13 +530,17 @@ public class DeteTypeInfoServiceImpl extends DeteCommonServiceImpl<DeteTypeInfoD * @Return * @Exception */ - public void validatePassDate(DeteTypeInfoEntity deteTypeInfo) { + public void validatePassDate(DeteTypeInfoEntity deteTypeInfo, MultipartFile file) { ValidateUtils.is(deteTypeInfo).notNull(RCode.DETE_ERROR); if(!checkDeteMethodIsValide(deteTypeInfo)){ throw new NZException(RCode.TYPE_METHOD_INVALID); } - + if(Constant.DETE_DETEMETHOD_SCRIPT.equals(deteTypeInfo.getMethod())){ + if(!StringUtils.isNotBlank(deteTypeInfo.getContent()) && (file==null||file.isEmpty())){ + throw new NZException(RCode.DETE_UPLOAD_FILE_ISNULL); + } + } if(!checkFieldTypeIsValide(deteTypeInfo)){ throw new NZException(RCode.META_FIELDTYPE_INVALID); } diff --git a/nezha-admin/src/main/java/com/nis/modules/sys/controller/DownloadFile.java b/nezha-admin/src/main/java/com/nis/modules/sys/controller/DownloadFile.java new file mode 100644 index 00000000..fa8e82a0 --- /dev/null +++ b/nezha-admin/src/main/java/com/nis/modules/sys/controller/DownloadFile.java @@ -0,0 +1,64 @@ +package com.nis.modules.sys.controller; + +import com.nis.common.exception.NZException; +import com.nis.common.utils.RCode; +import io.swagger.annotations.ApiOperation; +import org.springframework.util.ResourceUtils; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; + +@RestController +@RequestMapping("/sys/") +public class DownloadFile { + @GetMapping("/download") + @ResponseBody + @ApiOperation(value="文件下载") + public String download(HttpServletRequest request, HttpServletResponse response){ + String filePath=request.getParameter("filePath"); + String fileName=request.getParameter("fileName"); + String rootPath=null; + try{ + rootPath= ResourceUtils.getURL("classpath:").getPath(); + }catch (Exception e){ + e.printStackTrace(); + } + File file = new File(rootPath+filePath); + if(!file.exists()){ + throw new NZException(RCode.SYS_DOWNLOAD_NO_FILE); + } + try { + fileName = new String(fileName.getBytes("GBK"), "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + response.reset(); + response.setContentType("application/octet-stream"); + response.setCharacterEncoding("utf-8"); + response.setContentLength((int) file.length()); + response.setHeader("Content-Disposition", "attachment;filename=" + fileName); + byte[] buff = new byte[1024]; + BufferedInputStream bis = null; + OutputStream os = null; + try { + os = response.getOutputStream(); + bis = new BufferedInputStream(new FileInputStream(file)); + int i = 0; + while ((i = bis.read(buff)) != -1) { + os.write(buff, 0, i); + os.flush(); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + bis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return null; + } +} diff --git a/nezha-admin/src/main/resources/templates/js/modules/common/componets.js b/nezha-admin/src/main/resources/templates/js/modules/common/componets.js index c68a052f..2886a949 100644 --- a/nezha-admin/src/main/resources/templates/js/modules/common/componets.js +++ b/nezha-admin/src/main/resources/templates/js/modules/common/componets.js @@ -601,13 +601,13 @@ var selector = Vue.extend({ treeSelectedKeyPre:"tree-checked-", key: "uuid", //数据的唯一标识 colModel: [ - {name: "名称", field: "name", width: 120}, + {name: "<@spring.message 'common.name'/>", field: "name", width: 120}, {name: "IP", field: "ip", width: 120}, - {name: "类型", field: "type", width: 70,formatter:function(rowData){ - return rowData["type"]=='1'?"服务器":"网元"; + {name: "<@spring.message 'node.type'/>", field: "type", width: 70,formatter:function(rowData){ + return rowData["type"]=='1'?"<@spring.message 'node.type.server'/>":"<@spring.message 'node.type.net'/>"; }}, - {name: "状态", field: "state", width: 60,formatter:function(rowData){ - return rowData["state"]=='1'?"在线":"<span style='color:#cccccc;'>下线</span>"; + {name: "<@spring.message 'common.status'/>", field: "state", width: 60,formatter:function(rowData){ + return rowData["state"]=='1'?"<@spring.message 'common.onLine'/>":"<span style='color:#cccccc;'><@spring.message 'common.offLine'/></span>"; }} ], treeData: [], @@ -806,4 +806,156 @@ var selector = Vue.extend({ } }) -</script>
\ No newline at end of file + +var fileUpload = Vue.extend({ + template: "#fileInput", + components: {}, + props: { + name:{ + type:String, + default:'file' + }, + accept:{ + type:String, + default:'.*' + }, + hasOld:{ + type:Boolean, + default:false + }, + oldFile:{ + type:Object //{filePath:String,remark:String} + } + }, + data: function () { + return { + value:null, + viewInputId:'location', + viewInputSelector:'', + fileInputId:'i-file', + fileInputSelector:'', + dirty:false, + required:true, + error:false + + }; + }, + validations: function() { + + }, + created: function () { + var temp=this; + }, + methods: { + init:function(){ + var temp=this; + temp.viewInputSelector='#'+temp.viewInputId; + temp.fileInputSelector='#'+temp.fileInputId; + }, + fileInput:function(event){ + var temp=this; + if(event.target.files.length<1){ + temp.required=false; + temp.error=true; + }else{ + temp.error=false; + temp.required=true; + } + $(temp.viewInputSelector).val('') + var text=$(temp.fileInputSelector).val(); + $(temp.viewInputSelector).val(text); + temp.value=text; + }, + viewInputClick:function(){ + var temp=this; + temp.fileInputClick(); + }, + selectBtnClick:function(){ + var temp=this; + temp.fileInputClick(); + }, + fileInputClick:function(){ + var temp=this; + temp.dirty=true; + $(temp.fileInputSelector).click(); + }, + reset:function(){ + var temp=this; + temp.dirty=false; + temp.required=true; + temp.error=false; + }, + touch:function(){ + var temp=this; + temp.dirty=true; + }, + historyFileClick:function(){ + var temp=this; + // window.location.href=baseURL+'sys/download?fileName='+encodeURI(temp.oldFile.remark)+"&filePath="+encodeURI(temp.oldFile.filePath) + var url=baseURL+'sys/download?fileName='+encodeURI(temp.oldFile.remark)+"&filePath="+encodeURI(temp.oldFile.filePath); + // var elemIF = document.createElement('iframe') + // elemIF.src = url + // elemIF.style.display = 'none' + // document.body.appendChild(elemIF); + // var form=document.createElement('form'); + // form.style.display='none' + // form.action=baseURL+'sys/download?fileName='; + // form.method='GET'; + // var fileNameInput=document.createElement("input"); + // fileNameInput.type='hidden'; + // fileNameInput.name='fileName'; + // fileNameInput.value=temp.oldFile.remark; + // var filePathInput=document.createElement("input"); + // filePathInput.type='hidden'; + // filePathInput.name='filePath'; + // filePathInput.value=temp.oldFile.filePath; + // $(form).append($(fileNameInput)) + // $(form).append($(filePathInput)) + // $('body').append($(form)); + // form.submit(); + + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, true); + xhr.responseType = "blob"; + xhr.onload = function () { + if (this.status === 200) { + var URL = window.URL || window.webkitURL; //兼容处理 + var content = this.response; + var aTag = document.createElement('a'); + var blob = new Blob([content]); + var headerName = xhr.getResponseHeader("Content-disposition"); + var fileName = decodeURIComponent(headerName).substring(20); + if(fileName==''){ + alert("<@spring.message 'common.noFile'/>") + return; + } + aTag.download = fileName; + aTag.href = URL.createObjectURL(blob); + aTag.click(); + URL.revokeObjectURL(blob); + } + }; + xhr.send() + + } + }, + computed: {}, + watch: { + value:{ + handler:function(){ + if(this.value==null||this.value==''||typeof this.value =='undefined'){ + this.required=false; + this.error=true; + } + }, + immediate: true + } + }, + + mounted: function () { + this.init(); + } +}) + + + </script>
\ No newline at end of file diff --git a/nezha-admin/src/main/resources/templates/js/modules/detect/addType.js b/nezha-admin/src/main/resources/templates/js/modules/detect/addType.js index 0af03d67..01be0dfd 100644 --- a/nezha-admin/src/main/resources/templates/js/modules/detect/addType.js +++ b/nezha-admin/src/main/resources/templates/js/modules/detect/addType.js @@ -600,10 +600,10 @@ var addParam=Vue.extend({ $("#r-param-name-input-"+temp.index).blur(); var msg=''; if(temp.$v.deteParam.name.$dirty&&!temp.$v.deteParam.name.required){ - msg="<div class=\"form-control_error-msg\">必填项</div>" + msg="<div class=\"form-control_error-msg\"><@spring.message 'validate.common.required'/></div>" } if(temp.$v.deteParam.name.$dirty&&!temp.$v.deteParam.name.inPageNameRepeat){ - msg="<div class=\"form-control_error-msg\">名称重复</div>" + msg="<div class=\"form-control_error-msg\"><@spring.message 'validate.common.name.repeat'/></div>" } if(temp.editSwitch){ layer.tips(msg, "#r-param-name-input-"+temp.index,{ @@ -622,7 +622,7 @@ var addParam=Vue.extend({ $("#r-param-defval-input-"+this.index).blur(); var msg=''; if(temp.$v.deteParam.defVal.$dirty&&!temp.$v.deteParam.defVal.required){ - msg="<div class=\"form-control_error-msg\">必填项</div>" + msg="<div class=\"form-control_error-msg\"><@spring.message 'validate.common.required'/></div>" } if(temp.editSwitch){ layer.tips(msg, "#r-param-defval-input-"+temp.index,{ @@ -658,7 +658,8 @@ var addType=Vue.extend({ template:"#addTypeTemplate", components: { "nz-add-meta":addMeta, - "nz-add-param":addParam + "nz-add-param":addParam, + "nz-fileupload":fileUpload }, props: { typeId:{ @@ -674,7 +675,7 @@ var addType=Vue.extend({ }, data: function () { return { - title:"监测类别", + title:"<@spring.message 'deteType'/>", deteType:{ id: null, name: '', @@ -685,7 +686,7 @@ var addType=Vue.extend({ i18nCode: '', remark: '', deteTypeMetas: [], - deteTypeParams: [] + deteTypeParams: [], }, deteMethods:[], defaultMethod:{}, @@ -694,9 +695,20 @@ var addType=Vue.extend({ dicTypes:[], metaReset:true, paramReset:true, + uploadReset:true, + metaDirty:false, metaRequired:true, + paramDirty:false, paramRequired:true, - typeNotLayer: true + typeNotLayer: true,//判断是否是在layer中打开, + isUpdate:false, //是否是更新操作,更新不容许修改监测方式 + file:null, + acceptFile:".sh", + hasOldFile:false, + oldFile:{ + filePath:'', + remark:'No File' + } } }, validations:{ @@ -736,8 +748,8 @@ var addType=Vue.extend({ initDeteType:function(){ var temp=this; temp.$v.deteType.$reset(); - console.log("typeId-->"+temp.typeId) if(temp.typeId==null){ + temp.isUpdate=false; temp.deteType={ id: null, name: '', @@ -748,11 +760,16 @@ var addType=Vue.extend({ i18nCode: '', remark: '', deteTypeMetas: [], - deteTypeParams: [] + deteTypeParams: [], } }else{ + temp.isUpdate=true; temp.getTypeInfo(); } + + temp.resetMetaDom(); + temp.resetParamDom(); + temp.resetFileUploadDom(); }, getTypeInfo: function () { var temp=this; @@ -779,6 +796,7 @@ var addType=Vue.extend({ }, openMetaWindow: function(i) { var temp=this; + temp.metaDirty=true; var parentLayer=null; if(temp.parentLayerId!=undefined&&temp.parentLayerId!=null) { $("#metaWindow").appendTo($('body')) @@ -789,7 +807,7 @@ var addType=Vue.extend({ var index = layer.open({ area: ['600px', '100%'], shade: 0.01, - title: "元数据", + title: "<@spring.message 'deteType.meta'/>", type: 1, maxmin: false, scrollbar: false, @@ -803,6 +821,10 @@ var addType=Vue.extend({ if(!temp.parentLayerId){ $(parentLayer).animate({right: "600px"}); } + + if(temp.deteType.deteTypeMetas.length<1){ + temp.$refs.addMetaWindow.addMeta(); + } }, cancel:function(){ metaComponets=temp.$refs.addMetaWindow.$refs['r-detect-meta']; @@ -866,7 +888,9 @@ var addType=Vue.extend({ $.each(temp.deteType.deteTypeMetas, function (i, v) { temp.deteType.deteTypeMetas[i].fieldType = v.fieldType.code; temp.deteType.deteTypeMetas[i].dataType = v.dataType.code; - temp.deteType.deteTypeMetas[i].dicType=v.dicType.type; + if(typeof v.dicType!='undefined' && v.dicType!=null){ + temp.deteType.deteTypeMetas[i].dicType=v.dicType.type; + } }); }, formatDeteTypeToObject: function () { @@ -875,15 +899,45 @@ var addType=Vue.extend({ for (var i = 0; i < temp.fieldTypes.length; i++) { if (temp.fieldTypes[i].code == value.fieldType) { temp.deteType.deteTypeMetas[index].fieldType = temp.fieldTypes[i]; + break; } } for (var i = 0; i < temp.dataTypes.length; i++) { if (temp.dataTypes[i].code == value.dataType) { temp.deteType.deteTypeMetas[index].dataType = temp.dataTypes[i]; + break; + } + } + + for (var i = 0; i < temp.dicTypes.length; i++){ + if(temp.dicTypes[i].type == value.dicType){ + temp.deteType.deteTypeMetas[index].dicType=temp.dicTypes[i]; + break; } } }); + if(temp.deteType.method=='1'){ + temp.hasOldFile=true; + if(typeof temp.deteType.content != 'undefined'&&temp.deteType.content!=null&&temp.deteType.content!=''){ + try { + var file=JSON.parse(temp.deteType.content); + temp.oldFile.filePath=file.filePath; + temp.oldFile.remark=file.fileName; + }catch (e) { + temp.oldFile.filePath=''; + temp.oldFile.remark='No File'; + } + + }else{ + temp.oldFile.filePath=''; + temp.oldFile.remark='No File'; + } + }else{ + temp.hasOldFile=false; + temp.oldFile.filePath=''; + temp.oldFile.remark='No File'; + } }, delMeta:function(index){ var temp=this; @@ -905,6 +959,7 @@ var addType=Vue.extend({ }, addParam:function(){ var temp=this; + temp.paramDirty=true; var param={ id:null, name:'', @@ -933,6 +988,13 @@ var addType=Vue.extend({ temp.paramReset = true }); }, + resetFileUploadDom:function(){ + var temp = this; + temp.uploadReset = false; + temp.$nextTick(() => { + temp.uploadReset = true + }); + }, saveOrUpdate:function(){ var temp=this; if(temp.validate()){ @@ -945,13 +1007,16 @@ var addType=Vue.extend({ //处理json数据 temp.formatDeteTypeToSimple(); - console.log(temp.deteType) - + let formData=new FormData; + formData.append('deteTypeInfo',JSON.stringify(temp.deteType)) + formData.append('file',temp.file); $.ajax({ type: method, url: baseURL + url, - contentType: "application/json", - data: JSON.stringify(temp.deteType), + // contentType: "application/json", + contentType:false, + processData:false, + data:formData, success: function (r) { if (r.code === 200) { temp.reload(); @@ -968,7 +1033,7 @@ var addType=Vue.extend({ }, validate:function(){ var temp=this; - temp.$v.deteType.$touch(); + temp.touchType(); var typeError=temp.$v.deteType.$error; var metaErrorArr=[] @@ -1012,8 +1077,29 @@ var addType=Vue.extend({ } } } - console.log(typeError+"|"+metaError+"|"+paramError); - return typeError||metaError||paramError; + var uploadError=false; + if(temp.deteType.method=='1'&&!temp.isUpdate) { + var uploadComponet = temp.$refs.scriptUpload; + if (typeof uploadComponet != "undefined") { + uploadError = uploadComponet.error; + } + } + + console.log(typeError+"|"+metaError+"|"+paramError+"|"+uploadError); + return typeError||metaError||paramError||uploadError; + }, + touchType:function(){ + var temp=this; + temp.$v.deteType.$touch(); + temp.metaDirty=true; + temp.paramDirty=true; + if(temp.deteType.method=='1'&&!temp.isUpdate){ + var uploadComponet=temp.$refs.scriptUpload; + if(typeof uploadComponet != "undefined"){ + uploadComponet.touch(); + } + } + } }, computed: { @@ -1022,6 +1108,20 @@ var addType=Vue.extend({ watch: { typeId:function(){ this.initDeteType(); + }, + 'deteType.deteTypeMetas':function(){ + if(this.deteType.deteTypeMetas.length<1){ + this.metaRequired=false; + }else{ + this.metaRequired=true; + } + }, + 'deteType.deteTypeParams':function(){ + if(this.deteType.deteTypeParams.length<1){ + this.paramRequired=false; + }else{ + this.paramRequired=true; + } } }, mounted: function () { diff --git a/nezha-admin/src/main/resources/templates/js/modules/detect/deteSet.js b/nezha-admin/src/main/resources/templates/js/modules/detect/deteSet.js index cf5209fd..d0c85bab 100644 --- a/nezha-admin/src/main/resources/templates/js/modules/detect/deteSet.js +++ b/nezha-admin/src/main/resources/templates/js/modules/detect/deteSet.js @@ -18,7 +18,7 @@ $(function () { }, {label: '<@spring.message "param"/>', name: 'params', sortable: false, width: 100}, { - label: '告警', + label: '<@spring.message "deteWarn"/>', sortable: false, width: 100, formatter:function(value, options, rowData){ @@ -53,18 +53,14 @@ $(function () { gridComplete: function () { //隐藏grid底部滚动条 $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"}); - // $(".td-warn-win").each(function(index,e){ - // - // var setId=parseInt($(e).attr('setId')); - // var id=$(e).attr('id'); - // new warmComponet({ - // propsData:{ - // trIndex:index, - // setId:setId - // } - // }).$mount('#'+id) - // }); - new warnComponets().$mount('#warnSpace'); + console.log('set2') + console.log($("#warnSpace").get(0)) + if(typeof $("#warnSpace").get(0)!='undefined'){ + new warnComponets().$mount('#warnSpace');//这种方式挂载会将挂载的element替换掉,并不是在内部挂载!!! + $('body').append("<div id='warnSpace'></div>") + } + console.log('set3') + console.log($("#warnSpace").get(0)) }, onSelectAll: function(rowids, status) { if (status) { @@ -81,7 +77,6 @@ $(function () { Vue.component("nz-node-selector",selector); Vue.component("nz-detect-addtype",addType); -// Vue.component("nz-warn",warmComponet); var nameRepeat = function (name, deteSet) { diff --git a/nezha-admin/src/main/resources/templates/js/modules/detect/deteType.js b/nezha-admin/src/main/resources/templates/js/modules/detect/deteType.js index c7895566..77fc9a67 100644 --- a/nezha-admin/src/main/resources/templates/js/modules/detect/deteType.js +++ b/nezha-admin/src/main/resources/templates/js/modules/detect/deteType.js @@ -99,7 +99,6 @@ var vm = new Vue({ } vm.typeId=id; this.$refs['nz-add-type'].initDeteType(); - console.log("update-->"+vm.typeId); vm.showList=false; }, del: function (event) { diff --git a/nezha-admin/src/main/resources/templates/js/modules/detect/deteWarn.js b/nezha-admin/src/main/resources/templates/js/modules/detect/deteWarn.js index dadf88f9..921ff1c8 100644 --- a/nezha-admin/src/main/resources/templates/js/modules/detect/deteWarn.js +++ b/nezha-admin/src/main/resources/templates/js/modules/detect/deteWarn.js @@ -54,17 +54,17 @@ var warnComponet = Vue.extend({ state:2,//1,告警个数 2,告警列表 3,编辑告警 counter:0, colModel:[ - {name: "名称", field: "name", width: 120}, - {name: "触发方式", field: "triggerType", width: 120}, - {name: "告警模式", field: "warnMode", width: 120,formatter:function(rowData){ + {name: "<@spring.message 'common.name'/>", field: "name", width: 120}, + {name: "<@spring.message 'detect.triggerType'/>", field: "triggerType", width: 120}, + {name: "<@spring.message 'detect.warnMode'/>", field: "warnMode", width: 120,formatter:function(rowData){ return rowData.warnMode; }}, - {name: "回调方式", field: "callbackType", width: 120,formatter:function(rowData){ + {name: "<@spring.message 'deteWarn.callbackType'/>", field: "callbackType", width: 120,formatter:function(rowData){ return rowData.callbackType; }}, - {name: "操作时间", field: "opTime", width: 240}, - {name: "备注", field: "remark", width: 240} + {name: "<@spring.message 'common.opTime'/>", field: "opTime", width: 240}, + {name: "<@spring.message 'common.remark'/>", field: "remark", width: 240} ], headSpan:'warn-span-', headSpanSelector:'', diff --git a/nezha-admin/src/main/resources/templates/modules/common/template.html b/nezha-admin/src/main/resources/templates/modules/common/template.html index 4f3389b6..8eb3b78d 100644 --- a/nezha-admin/src/main/resources/templates/modules/common/template.html +++ b/nezha-admin/src/main/resources/templates/modules/common/template.html @@ -24,7 +24,7 @@ </template> <template v-if="tableData.length==0" > <tr> - <td :colspan="colLen" class="text-center">暂无数据</td> + <td :colspan="colLen" class="text-center"><@spring.message 'common.noData'/></td> </tr> </template> </tbody> @@ -61,6 +61,25 @@ </div> </div> </script> + <script id="nzTree" type="text/x-template"> <ul id="beTree" class="ztree"></ul> </script> + +<script type="text/x-template" id="fileInput"> + <div > + <div class="col-sm-2 control-label"><@spring.message 'common.scriptFile'/></div> + <div class="col-sm-9"> + <div class="input-group"> + <input :id='viewInputId' class="form-control" @click="viewInputClick" /> + <div class="input-group-btn" style="right: 31px;"> + <button type="button" class="btn btn-default" @click="selectBtnClick"><i class="fa fa-file-text"></i></button> + <button type="button" class="btn btn-default" @click="historyFileClick" :disabled="!hasOld||oldFile.filePath==''" :title="oldFile.remark"><i class="fa fa-download"></i></button> + </div> + <input type="file" :name="name" :id='fileInputId' @input="$emit('input', $event.target.files[0])" :accept="accept" @change="fileInput($event)" style="display: none"> + </div> + <span class="required-symbol">*</span> + <div class="form-control_error-msg" v-if="dirty&&!required"><@spring.message 'validate.common.required'/></div> + </div> + </div> +</script>
\ No newline at end of file diff --git a/nezha-admin/src/main/resources/templates/modules/detect/addTypeTemplate.html b/nezha-admin/src/main/resources/templates/modules/detect/addTypeTemplate.html index f8b00fb8..6135bd4d 100644 --- a/nezha-admin/src/main/resources/templates/modules/detect/addTypeTemplate.html +++ b/nezha-admin/src/main/resources/templates/modules/detect/addTypeTemplate.html @@ -3,14 +3,14 @@ <div v-show="typeNotLayer" class="panel-heading">{{title}}</div> <form class="form-horizontal"> <div class="form-group"> - <div class="col-sm-2 control-label">名称:</div> + <div class="col-sm-2 control-label"><@spring.message 'common.name'/></div> <div class="col-sm-9"><!--名称--> <input type="text" class="form-control" :class="{'form-control--error': $v.deteType.name.$dirty && !$v.deteType.name.required|| !$v.deteType.name.nameRepeat}" v-model.trim="$v.deteType.name.$model"/> <span class="required-symbol">*</span> <div class="form-control_error-msg" v-if="$v.deteType.name.$dirty && !$v.deteType.name.required"> - 必填项 + <@spring.message 'validate.common.required'/> </div> <div class="form-control_error-msg" v-if="$v.deteType.name.$dirty && !$v.deteType.name.nameRepeat"> 名称重复 @@ -18,36 +18,50 @@ </div> </div> <div class="form-group"> <!--监测方式--> - <div class="col-sm-2 control-label">监测方式:</div> - <div class="col-sm-9"> + <div class="col-sm-2 control-label"><@spring.message 'deteType.method'/></div> + <div class="col-sm-9" style="z-index:99999;"> <multiselect v-model="defaultMethod" :options="deteMethods" placeholder="..." track-by="code" - label="value" :searchable="false" :allow-empty="false" + label="value" :searchable="false" :allow-empty="false" :disabled="isUpdate" :show-labels="false"></multiselect> </div> </div> <div class="form-group"><!--监测间隔--> - <div class="col-sm-2 control-label">监测间隔:</div> + <div class="col-sm-2 control-label"><@spring.message 'deteType.deteInterval'/></div> <div class="col-sm-9"> - <input type="text" class="form-control" + <input type="text" class="form-control input-small input-with-unit" :class="{'form-control--error': $v.deteType.deteInterval.$dirty && !$v.deteType.deteInterval.integer}" v-model.trim="$v.deteType.deteInterval.$model"/> - <span class="required-symbol">*</span> - <div class="form-control_error-msg" - v-if="$v.deteType.deteInterval.$dirty && !$v.deteType.deteInterval.integer">整数类型 - </div> + <span class="input-unit">s</span> +<!-- <span class="required-symbol">*</span>--> +<!-- <div class="form-control_error-msg"--> +<!-- v-if="$v.deteType.deteInterval.$dirty && !$v.deteType.deteInterval.integer">整数类型--> +<!-- </div>--> </div> </div> <div class="form-group"><!--内容--> - <div class="col-sm-2 control-label">内容:</div> - <div class="col-sm-9"> - <textarea v-model.trim="$v.deteType.content.$model" class="form-control"></textarea> + <div v-if="defaultMethod.code=='2'"> + <div class="col-sm-2 control-label">OID</div> + <div class="col-sm-9" > + <input v-model.trim="$v.deteType.content.$model" class="form-control"></input> + </div> </div> + + <template v-if="defaultMethod.code=='1'"> + <nz-fileupload + v-if="uploadReset" + :hasOld="hasOldFile" + :oldFile="oldFile" + :accept="acceptFile" + v-model="file" + ref="scriptUpload" + ></nz-fileupload> + </template> </div> <div class="form-group"><!--元数据--> - <div class="col-sm-2 control-label">元数据:</div> + <div class="col-sm-2 control-label"><@spring.message 'deteType.meta'/></div> <div class="col-sm-9"> <div class="add-box"> <div class="add-box_head"> @@ -82,13 +96,13 @@ </div> </div> - <div class="form-control_error-msg" v-if="!metaRequired"> - 必填项 + <div class="form-control_error-msg" v-if="metaDirty&&!metaRequired"> + <@spring.message 'validate.common.required'/> </div> </div> </div> <div class="form-group"> - <div class="col-sm-2 control-label">参数:</div> + <div class="col-sm-2 control-label"><@spring.message 'param'/></div> <div class="col-sm-9"> <div class="add-box"> <div class="add-box_head"> @@ -112,11 +126,11 @@ <i @click="addParam" class="fa fa-plus"></i> </div> </div> - <div class="form-control_error-msg" v-if="!paramRequired">必填项</div> + <div class="form-control_error-msg" v-if="paramDirty&&!paramRequired"><@spring.message 'validate.common.required'/></div> </div> </div> <!--<div class="form-group"> - <div class="col-sm-2 control-label">I18n Code:</div> + <div class="col-sm-2 control-label">I18n Code</div> <div class="col-sm-9"> <input type="text" class="form-control" :class="{'form-control--error': $v.deteType.i18nCode.$dirty && !$v.deteType.i18nCode.required }" @@ -131,7 +145,7 @@ </div>--> <div class="form-group"><!--备注--> - <div class="col-sm-2 control-label">备注:</div> + <div class="col-sm-2 control-label"><@spring.message 'common.remark'/> </div> <div class="col-sm-9"> <textarea v-model.trim="$v.deteType.remark.$model" class="form-control"></textarea> </div> @@ -146,10 +160,12 @@ class="fa fa-reply"></i></button> </div> </div> + <pre>{{deteType}}</pre> </form> <div id="metaWindow" style="height:100%;display:none;"> <nz-add-meta + v-if="metaReset" ref="addMetaWindow" :dete-metas="deteType.deteTypeMetas" :dete-method="defaultMethod" @@ -210,7 +226,7 @@ <form class="form-horizontal form-horizontal_400" > <div> <div class="form-group"> - <div class="col-sm-3 control-label"><@spring.message 'common.name'/>:</div> + <div class="col-sm-3 control-label"><@spring.message 'common.name'/></div> <div class="col-sm-9"> <input type="text" class="form-control nameEvent" v-model="$v.deteMeta.name.$model"/> <span class="required-symbol_400">*</span> @@ -219,7 +235,7 @@ </div> </div> <div class="form-group"> - <div class="col-sm-3 control-label"><@spring.message 'deteType.fieldType'/>:</div> + <div class="col-sm-3 control-label"><@spring.message 'deteType.fieldType'/></div> <div class="col-sm-9"> <multiselect :options="fieldTypes" @@ -238,12 +254,12 @@ </template> </multiselect> - <span class="required-symbol_400">*</span> - <div class="form-control_error-msg" v-if="$v.deteMeta.fieldType.$dirty&&!$v.deteMeta.fieldType.required"><@spring.message 'validate.common.required'/></div> +<!-- <span class="required-symbol_400">*</span>--> +<!-- <div class="form-control_error-msg" v-if="$v.deteMeta.fieldType.$dirty&&!$v.deteMeta.fieldType.required"><@spring.message 'validate.common.required'/></div>--> </div> </div> <div class="form-group"> - <div class="col-sm-3 control-label"><@spring.message 'deteType.dataType'/>:</div> + <div class="col-sm-3 control-label"><@spring.message 'deteType.dataType'/></div> <div class="col-sm-9"> <multiselect :options="dataTypes" @@ -261,16 +277,16 @@ </div> </template> </multiselect> - <span class="required-symbol_400">*</span> - <div class="form-control_error-msg" v-if="$v.deteMeta.dataType.$dirty&&!$v.deteMeta.dataType.required"><@spring.message 'validate.common.required'/></div> +<!-- <span class="required-symbol_400">*</span>--> +<!-- <div class="form-control_error-msg" v-if="$v.deteMeta.dataType.$dirty&&!$v.deteMeta.dataType.required"><@spring.message 'validate.common.required'/></div>--> </div> </div> <div class="form-group"> - <div class="col-sm-3 control-label"><@spring.message 'deteType.dataLenth'/>:</div> + <div class="col-sm-3 control-label"><@spring.message 'deteType.dataLenth'/></div> <div class="col-sm-9"> <input type="text" class="form-control" v-model="$v.deteMeta.dataLenth.$model"/> - <span class="required-symbol_400">*</span> - <div class="form-control_error-msg" v-if="$v.deteMeta.dataLenth.$dirty&&!$v.deteMeta.dataLenth.required"><@spring.message 'validate.common.required'/></div> +<!-- <span class="required-symbol_400">*</span>--> +<!-- <div class="form-control_error-msg" v-if="$v.deteMeta.dataLenth.$dirty&&!$v.deteMeta.dataLenth.required"><@spring.message 'validate.common.required'/></div>--> </div> </div> <div class="form-group" v-show="deteMethod.code=='2'"> @@ -282,7 +298,7 @@ </div> </div> <div class="form-group"> - <div class="col-sm-3 control-label"><@spring.message 'deteType.unit'/>:</div> + <div class="col-sm-3 control-label"><@spring.message 'deteType.unit'/></div> <div class="col-sm-9"> <input type="text" class="form-control" v-model="$v.deteMeta.unit.$model"/> <span class="required-symbol_400">*</span> @@ -290,7 +306,7 @@ </div> </div> <div class="form-group"> - <div class="col-sm-3 control-label"><@spring.message 'deteType.dicType'/>:</div> + <div class="col-sm-3 control-label"><@spring.message 'deteType.dicType'/></div> <div class="col-sm-9"> <multiselect :options="dicTypes" @@ -317,7 +333,7 @@ </div> </div> <div class="form-group"> - <div class="col-sm-3 control-label"><@spring.message "common.remark"/>:</div> + <div class="col-sm-3 control-label"><@spring.message "common.remark"/></div> <div class="col-sm-9"> <textarea class="form-control" v-model="$v.deteMeta.remark.$model"></textarea> </div> @@ -326,7 +342,7 @@ <div> <!-- <button title="<@spring.message 'common.submit'/>" type="button" class="btn btn-primary" style="width: 45px; padding: 3px 0;" @click="saveOrUpdate"><i class="fa fa-check"></i></button>--> <div style="display:inline-block;width:130px;"></div> - <button title="删除" @click="delSelf(index)" type="button" class="btn btn-danger" style="width: 45px; padding: 3px 0;"><i class="fa fa-trash-o"></i></button> + <button title="<@spring.message 'common.delete'/>" @click="delSelf(index)" type="button" class="btn btn-danger" style="width: 45px; padding: 3px 0;"><i class="fa fa-trash-o"></i></button> <!-- <button title="恢复" @click="recMeta($event)" type="button" class="btn btn-success" style="width: 45px; padding: 3px 0;display: none;"><i class="fa fa-undo"></i></button>--> </div> </div> diff --git a/nezha-admin/src/main/resources/templates/modules/detect/deteSet.html b/nezha-admin/src/main/resources/templates/modules/detect/deteSet.html index 17516f91..970bfd6b 100644 --- a/nezha-admin/src/main/resources/templates/modules/detect/deteSet.html +++ b/nezha-admin/src/main/resources/templates/modules/detect/deteSet.html @@ -42,7 +42,7 @@ <div class="panel-heading">{{title}}</div> <form class="form-horizontal"> <div class="form-group"> - <div class="col-sm-2 control-label"><@spring.message 'common.name'/>:</div> + <div class="col-sm-2 control-label"><@spring.message 'common.name'/></div> <div class="col-sm-9"> <input type="text" class="form-control" :class="{'form-control--error': $v.deteSet.name.$dirty && (!$v.deteSet.name.required || !$v.deteSet.name.nameRepeat)}" @@ -55,7 +55,7 @@ </div> </div> <div class="form-group"> - <div class="col-sm-2 control-label"><@spring.message 'deteType'/>:</div> + <div class="col-sm-2 control-label"><@spring.message 'deteType'/></div> <div class="col-sm-9"> <multiselect v-model="$v.deteSet.typeId.$model" :value="deteSet.typeId" @@ -98,7 +98,7 @@ </div> </div> <div class="form-group"> - <div class="col-sm-2 control-label"><@spring.message 'common.selectNodeOrNodeGroup'/>:</div> + <div class="col-sm-2 control-label"><@spring.message 'common.selectNodeOrNodeGroup'/></div> <div class="col-sm-9"> <!-- <a class="btn btn-default" href="#" @click="openNodePannel">节点/节点组</a>--> <div class="add-box add-box_first" :class="{'form-control--error': nodeOrGroupEmpty}"> @@ -150,14 +150,14 @@ <!-- <div class="form-group"> - <div class="col-sm-2 control-label"><@spring.message 'common.i18nCode'/>:</div> + <div class="col-sm-2 control-label"><@spring.message 'common.i18nCode'/></div> <div class="col-sm-9"> <input type="text" class="form-control" v-model.trim="$v.deteSet.i18nCode.$model"/> </div> </div> --> <div class="form-group"> - <div class="col-sm-2 control-label"><@spring.message 'common.viewPermission'/>:</div> + <div class="col-sm-2 control-label"><@spring.message 'common.viewPermission'/></div> <div class="col-sm-9"> <div style="margin-bottom: 10px;"> <template v-for="vl in viewLevels"> @@ -183,7 +183,7 @@ </div> <div class="form-group"> - <div class="col-sm-2 control-label"><@spring.message 'common.remark'/>:</div> + <div class="col-sm-2 control-label"><@spring.message 'common.remark'/></div> <div class="col-sm-9"> <textarea v-model.trim="$v.deteSet.remark.$model" class="form-control"></textarea> </div> diff --git a/nezha-admin/src/main/resources/templates/modules/detect/deteType.html b/nezha-admin/src/main/resources/templates/modules/detect/deteType.html index a62953c9..76f6622e 100644 --- a/nezha-admin/src/main/resources/templates/modules/detect/deteType.html +++ b/nezha-admin/src/main/resources/templates/modules/detect/deteType.html @@ -30,7 +30,9 @@ ></nz-detect-addtype> </div> </div> +<#include "/modules/common/template.html"/> <#include "/modules/detect/addTypeTemplate.html"/> +<#include "/js/modules/common/componets.js"/> <#include "/js/modules/detect/addType.js"/> <#include "/js/modules/detect/deteType.js"/> diff --git a/nezha-admin/src/main/resources/templates/modules/detect/metaMapping.html b/nezha-admin/src/main/resources/templates/modules/detect/metaMapping.html index 7fa865c3..c2c9482a 100644 --- a/nezha-admin/src/main/resources/templates/modules/detect/metaMapping.html +++ b/nezha-admin/src/main/resources/templates/modules/detect/metaMapping.html @@ -29,7 +29,7 @@ <div class="panel-heading">{{title}}</div> <form class="form-horizontal"> <div class="form-group"> - <div class="col-sm-2 control-label"><@spring.message "metaMapping.type"/>:</div> + <div class="col-sm-2 control-label"><@spring.message "metaMapping.type"/></div> <div class="col-sm-9"> <input type="text" class="form-control" :class="{'form-control--error': $v.metaMappings.type.$dirty && !$v.metaMappings.type.required}" @@ -45,7 +45,7 @@ </div> </div> <div class="form-group"> - <div class="col-sm-2 control-label"><@spring.message 'param'/>:</div> + <div class="col-sm-2 control-label"><@spring.message 'param'/></div> <div class="col-sm-9" > <div style="width:90%; padding:8px 0px 4px 0px;"> <div style="position:relative;" v-for="mapping,index in metaMappings.mappings"> diff --git a/nezha-admin/src/main/resources/templates/modules/detect/warnTemplate.html b/nezha-admin/src/main/resources/templates/modules/detect/warnTemplate.html index 7ec2901e..16e76665 100644 --- a/nezha-admin/src/main/resources/templates/modules/detect/warnTemplate.html +++ b/nezha-admin/src/main/resources/templates/modules/detect/warnTemplate.html @@ -30,7 +30,7 @@ <div :id="footDiv+setId" v-show="state==3" class="panel panel-default"> <form class="form-horizontal"> <div class="form-group"> - <div class="col-sm-2 control-label"><@spring.message 'common.name'/>:</div> + <div class="col-sm-2 control-label"><@spring.message 'common.name'/></div> <div class="col-sm-9"> <input type="text" class="form-control" :class="{'form-control--error': $v.deteWarn.name.$dirty && (!$v.deteWarn.name.required || !$v.deteWarn.name.nameRepeat)}" @@ -43,7 +43,7 @@ </div> </div> <div class="form-group"> - <div class="col-sm-2 control-label">告警字段:</div> + <div class="col-sm-2 control-label"><@spring.message 'deteWarn.warnField'/></div> <div class="col-sm-9"> <multiselect v-model="$v.deteWarn.metaId.$model" :options="deteMetas" @@ -61,7 +61,7 @@ </div> </div> <div class="form-group"> - <div class="col-sm-2 control-label">告警模式:</div> + <div class="col-sm-2 control-label"><@spring.message 'detect.warnMode'/></div> <div class="col-sm-9"> <multiselect v-model="defaultWarnMode" :options="warnModes" @@ -76,7 +76,7 @@ </div> </div> <div class="form-group" v-show="defaultWarnMode.code=='2'"> - <div class="col-sm-2 control-label">统计方式:</div> + <div class="col-sm-2 control-label"><@spring.message 'deteWarn.statType'/></div> <div class="col-sm-9"> <multiselect v-model="defaultStatType" :options="statTypes" @@ -92,7 +92,7 @@ </div> <div class="form-group"> - <div class="col-sm-2 control-label">触发条件:</div> + <div class="col-sm-2 control-label"><@spring.message 'detect.triggerType'/></div> <div class="col-sm-9"> <multiselect v-model="defaultTrigger" :options="triggerTypes" @@ -107,7 +107,7 @@ </div> </div> <div class="form-group" v-show="defaultTrigger.code=='1'"> - <div class="col-sm-2 control-label">阈值:</div> + <div class="col-sm-2 control-label"><@spring.message 'dashboard.threshold'/>:</div> <div class="col-sm-9"> <input type="text" class="form-control" :class="{'form-control--error':defaultTrigger.code=='1'&& $v.deteWarn.threshold.$dirty && !$v.deteWarn.threshold.required}" @@ -117,7 +117,7 @@ </div> </div> <div class="form-group" v-show="defaultTrigger.code=='1'"> - <div class="col-sm-2 control-label">比较符:</div> + <div class="col-sm-2 control-label"><@spring.message 'deteWarn.symbol'/></div> <div class="col-sm-9"> <multiselect v-model="defaultSymbol" :options="symbols" @@ -133,7 +133,7 @@ </div> <div class="form-group"> - <div class="col-sm-2 control-label">告警级别:</div> + <div class="col-sm-2 control-label"><@spring.message 'deteWarn.warnLevel'/></div> <div class="col-sm-9"> <multiselect v-model="defaultWarnLevel" :options="warnLevels" @@ -148,7 +148,7 @@ </div> </div> <div class="form-group"> - <div class="col-sm-2 control-label">告警提示:</div> + <div class="col-sm-2 control-label"><@spring.message 'deteWarn.tips'/></div> <div class="col-sm-9"> <input type="text" class="form-control" :class="{'form-control--error': $v.deteWarn.tips.$dirty && !$v.deteWarn.tips.required}" @@ -159,7 +159,7 @@ </div> </div> <div class="form-group"> - <div class="col-sm-2 control-label">回调方式:</div> + <div class="col-sm-2 control-label"><@spring.message 'deteWarn.callbackType'/></div> <div class="col-sm-9"> <div style="margin-bottom: 10px;"> <template v-for="cbt in callbackTypes"> @@ -171,7 +171,7 @@ </div> </div> <div class="form-group" v-show="deteWarn.callbackType!='0'"> - <div class="col-sm-2 control-label">回调内容:</div> + <div class="col-sm-2 control-label"><@spring.message 'deteWarn.callbackContent'/></div> <div class="col-sm-9"> <textarea v-model.trim="$v.deteWarn.callbackContent.$model" class="form-control"></textarea> <span class="required-symbol">*</span> @@ -179,7 +179,7 @@ </div> </div> <div class="form-group"> - <div class="col-sm-2 control-label"><@spring.message 'common.remark'/>:</div> + <div class="col-sm-2 control-label"><@spring.message 'common.remark'/></div> <div class="col-sm-9"> <textarea v-model.trim="$v.deteWarn.remark.$model" class="form-control"></textarea> </div> diff --git a/nezha-common/src/main/java/com/nis/common/utils/RCode.java b/nezha-common/src/main/java/com/nis/common/utils/RCode.java index 2758d278..112a916c 100644 --- a/nezha-common/src/main/java/com/nis/common/utils/RCode.java +++ b/nezha-common/src/main/java/com/nis/common/utils/RCode.java @@ -44,6 +44,8 @@ public enum RCode { SYS_DICT_VALUE_ISNULL(106003,"sys_dict_value_isnull"), // 字典值不能为空 SYS_DICT_VALUE_DUPLICATE(106004,"sys_dict_value_duplicate"),// 字典值重复 + SYS_DOWNLOAD_NO_FILE(107001,"sys_download_no_file"), //下载文件不存在 + NODE_ERROR(200000, "node_error"), //20xxxx,设备类(节点、节点组、机房、机柜)通用错误 NODE_IPADDRESS_FORMAT(201001, "ipaddress_format_error"), // ip 地址不合法 格式错误 @@ -115,7 +117,8 @@ public enum RCode { DETE_ERROR(300000, "dete_error"), //30xxxx,监测类(类别、设置、告警)通用错误 VIEWLEVEL_INVALID(300001,"viewlevel_invalid"), - BUILDIN_CONFIG(300002,"BUILDIN_CONFIG"),//内置配置,不允许修改 + BUILDIN_CONFIG(300002,"buildin_config"),//内置配置,不允许修改 + DETE_UPLOAD_FILE_ISNULL(300003,"dete_upload_file_isnull"),//上传的文件为空 /** * 301xxx 监测类别相关异常 * 302xxx 监测设置相关异常 |
