change - 传感器信息添加编号重复校验

main
wenjy 3 years ago
parent 7998c255ce
commit 4e2254d32c

@ -3,9 +3,11 @@ package com.ruoyi.web.controller.base;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.mysql.cj.xdevapi.JsonArray; import com.mysql.cj.xdevapi.JsonArray;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.BaseAlarmInfo; import com.ruoyi.system.domain.BaseAlarmInfo;
import com.ruoyi.system.domain.BaseAlarmType; import com.ruoyi.system.domain.BaseAlarmType;
@ -115,10 +117,20 @@ public class BaseSensorInfoController extends BaseController {
/** 新增传感器信息 */ /** 新增传感器信息 */
@GetMapping("/add") @GetMapping("/add")
public String add() { public String add(ModelMap mmap) {
return prefix + "/add"; return prefix + "/add";
} }
@PostMapping("/checkSensorIdUnique")
@ResponseBody
public String checkSensorIdUnique(BaseSensorInfo baseSensorInfo){
List<BaseSensorInfoDto> baseSensorInfoDtos = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo);
if(baseSensorInfoDtos.size() > 0){
return UserConstants.DEPT_NAME_NOT_UNIQUE;
}
return UserConstants.DEPT_NAME_UNIQUE;
}
/** 新增保存传感器信息 */ /** 新增保存传感器信息 */
@RequiresPermissions("base:sensorInfo:add") @RequiresPermissions("base:sensorInfo:add")
@Log(title = "传感器信息", businessType = BusinessType.INSERT) @Log(title = "传感器信息", businessType = BusinessType.INSERT)

@ -37,7 +37,7 @@
</div> </div>
</div> </div>
<div class="form-group"> <!--<div class="form-group">
<label class="col-sm-3 control-label">传感器状态:</label> <label class="col-sm-3 control-label">传感器状态:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<select name="sensorStatus" class="form-control m-b" <select name="sensorStatus" class="form-control m-b"
@ -45,7 +45,7 @@
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option> <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select> </select>
</div> </div>
</div> </div>-->
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">所属监控单元:</label> <label class="col-sm-3 control-label">所属监控单元:</label>
<div class="col-sm-8"> <div class="col-sm-8">
@ -87,6 +87,29 @@
<script th:inline="javascript"> <script th:inline="javascript">
var prefix = ctx + "base/sensorInfo" var prefix = ctx + "base/sensorInfo"
$("#form-sensorInfo-add").validate({ $("#form-sensorInfo-add").validate({
onkeyup: false,
rules:{
sensorId:{
remote: {
url: prefix + "/checkSensorIdUnique",
type: "post",
dataType: "json",
data: {
"sensorId": function() {
return $("input[name='sensorId']").val();
},
},
dataFilter: function(data, type) {
return $.validate.unique(data);
}
}
},
},
messages: {
"sensorId": {
remote: "编号已存在"
}
},
focusCleanup: true focusCleanup: true
}); });
@ -127,6 +150,14 @@
$("#treeName").val(num.cp_num_value.substring(num.cp_num_value.indexOf('/')+1,num.cp_num_value.length )); $("#treeName").val(num.cp_num_value.substring(num.cp_num_value.indexOf('/')+1,num.cp_num_value.length ));
} }
}) })
//onchange="sensorIdCheck(this)"
/*const sensorIdCheck = (res) =>{
let sensorInfo = [[${baseSensorInfoDtos}]];
if(sensorInfo.indexOf(res.value) != -1){
alert("已存在编号:"+res.value+";请勿添加重复编号");
}
}*/
</script> </script>
</body> </body>
</html> </html>

@ -17,7 +17,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">传感器编号:</label> <label class="col-sm-3 control-label">传感器编号:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="sensorId" th:field="*{sensorId}" class="form-control" type="text"> <input name="sensorId" th:field="*{sensorId}" class="form-control" type="text" readonly="true">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -35,14 +35,14 @@
</select> </select>
</div> </div>
</div> </div>
<div class="form-group"> <!--<div class="form-group">
<label class="col-sm-3 control-label">传感器状态:</label> <label class="col-sm-3 control-label">传感器状态:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<select name="sensorStatus" class="form-control m-b" th:with="type=${@dict.getType('base_sensor_status')}"> <select name="sensorStatus" class="form-control m-b" th:with="type=${@dict.getType('base_sensor_status')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{sensorStatus}"></option> <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{sensorStatus}"></option>
</select> </select>
</div> </div>
</div> </div>-->
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">所属监控单元:</label> <label class="col-sm-3 control-label">所属监控单元:</label>
<div class="col-sm-8"> <div class="col-sm-8">

@ -50,14 +50,14 @@
th:value="${dict.sensortypeId}"></option> th:value="${dict.sensortypeId}"></option>
</select> </select>
</li> </li>
<li> <!--<li>
<label>状态:</label> <label>状态:</label>
<select name="sensorStatus" th:with="type=${@dict.getType('base_sensor_status')}"> <select name="sensorStatus" th:with="type=${@dict.getType('base_sensor_status')}">
<option value="">所有</option> <option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
th:value="${dict.dictValue}"></option> th:value="${dict.dictValue}"></option>
</select> </select>
</li> </li>-->
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
class="fa fa-search"></i>&nbsp;搜索</a> class="fa fa-search"></i>&nbsp;搜索</a>
@ -191,7 +191,8 @@
title: '传感器状态', title: '传感器状态',
formatter: function (value, row, index) { formatter: function (value, row, index) {
return $.table.selectDictLabel(sensorStatusDatas, value); return $.table.selectDictLabel(sensorStatusDatas, value);
} },
visible: false
}, },
{ {
field: 'monitorunitName', field: 'monitorunitName',

Loading…
Cancel
Save