From 2d109d3d9200f02e559bc464fbbd6515578bbfea Mon Sep 17 00:00:00 2001 From: wangwenrui Date: Wed, 6 Nov 2019 17:36:31 +0800 Subject: 1.监测类别添加文件上传 2.监测相关国际化 3.部分样式调整 4.增加文件下载controller 5.部分bug修复 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detect/controller/DeteTypeController.java | 24 ++- .../modules/detect/entity/DeteTypeInfoEntity.java | 1 + .../modules/detect/service/DeteCommonService.java | 5 + .../detect/service/DeteTypeInfoService.java | 7 +- .../detect/service/impl/DeteCommonServiceImpl.java | 98 ++++++++++++ .../service/impl/DeteTypeInfoServiceImpl.java | 37 ++++- .../nis/modules/sys/controller/DownloadFile.java | 64 ++++++++ .../templates/js/modules/common/componets.js | 164 ++++++++++++++++++++- .../templates/js/modules/detect/addType.js | 136 ++++++++++++++--- .../templates/js/modules/detect/deteSet.js | 23 ++- .../templates/js/modules/detect/deteType.js | 1 - .../templates/js/modules/detect/deteWarn.js | 12 +- .../templates/modules/common/template.html | 21 ++- .../templates/modules/detect/addTypeTemplate.html | 86 ++++++----- .../templates/modules/detect/deteSet.html | 12 +- .../templates/modules/detect/deteType.html | 2 + .../templates/modules/detect/metaMapping.html | 4 +- .../templates/modules/detect/warnTemplate.html | 24 +-- .../src/main/java/com/nis/common/utils/RCode.java | 5 +- 19 files changed, 607 insertions(+), 119 deletions(-) create mode 100644 nezha-admin/src/main/java/com/nis/modules/sys/controller/DownloadFile.java 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 extends IService{ boolean checkFieldExists(Long id,String field,String value); @@ -10,4 +11,8 @@ public interface DeteCommonService extends IService{ 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,T> extends ServiceImpl implements DeteCommonService , ApplicationRunner { @@ -29,6 +35,8 @@ public class DeteCommonServiceImpl,T> extends ServiceImp private SysDictService sysDictService; @Autowired private DeteTypeInfoService deteTypeInfoService; + @Autowired + private Environment environment; public static Map> sysDic=new HashMap>(); @@ -158,5 +166,95 @@ public class DeteCommonServiceImpl,T> extends ServiceImp sysDic.put(type,codes); } } + @Override + public String getUploadFileJson(MultipartFile file){ + + Map map=new HashMap(); + 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 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 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 deteTypeMetas = deteTypeInfo.getDeteTypeMetas(); @@ -132,7 +141,7 @@ public class DeteTypeInfoServiceImpl extends DeteCommonServiceImpl deteTypeMetas = deteTypeInfo.getDeteTypeMetas(); List deteTypeParams = deteTypeInfo.getDeteTypeParams(); @@ -142,7 +151,14 @@ public class DeteTypeInfoServiceImpl extends DeteCommonServiceImpl metaUpdateList = new ArrayList(); //需要添加表字段 @@ -302,11 +318,16 @@ public class DeteTypeInfoServiceImpl extends DeteCommonServiceImpl", 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'?"在线":"下线"; + {name: "<@spring.message 'common.status'/>", field: "state", width: 60,formatter:function(rowData){ + return rowData["state"]=='1'?"<@spring.message 'common.onLine'/>":"<@spring.message 'common.offLine'/>"; }} ], treeData: [], @@ -806,4 +806,156 @@ var selector = Vue.extend({ } }) - \ 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(); + } +}) + + + \ 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="
必填项
" + msg="
<@spring.message 'validate.common.required'/>
" } if(temp.$v.deteParam.name.$dirty&&!temp.$v.deteParam.name.inPageNameRepeat){ - msg="
名称重复
" + msg="
<@spring.message 'validate.common.name.repeat'/>
" } 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="
必填项
" + msg="
<@spring.message 'validate.common.required'/>
" } 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("
") + } + 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 @@ @@ -61,6 +61,25 @@ + + + \ 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 @@
{{title}}
-
名称:
+
<@spring.message 'common.name'/>
*
- 必填项 + <@spring.message 'validate.common.required'/>
名称重复 @@ -18,36 +18,50 @@
-
监测方式:
-
+
<@spring.message 'deteType.method'/>
+
-
监测间隔:
+
<@spring.message 'deteType.deteInterval'/>
- - * -
整数类型 -
+ s + + + +
-
内容:
-
- +
+
OID
+
+ +
+ +
-
元数据:
+
<@spring.message 'deteType.meta'/>
@@ -82,13 +96,13 @@
-
- 必填项 +
+ <@spring.message 'validate.common.required'/>
-
参数:
+
<@spring.message 'param'/>
@@ -112,11 +126,11 @@
-
必填项
+
<@spring.message 'validate.common.required'/>
-
备注:
+
<@spring.message 'common.remark'/>
@@ -146,10 +160,12 @@ class="fa fa-reply">
+
{{deteType}}