Explorar o código

车辆基本信息增加是否外部托管车辆标记功能

chenwen %!s(int64=3) %!d(string=hai) anos
pai
achega
5c3cfac7e9

+ 12 - 0
src/main/java/com/hb/proj/car/controller/CarController.java

@@ -219,6 +219,18 @@ public class CarController {
 		   }
 	}
 	
+	@RequestMapping("/setTag")
+	public void setTag(String carId,String tag,HttpServletResponse response){
+		try{
+			   service.updateForField(carId,"customTag",tag);
+			   JsonOutUtils.returnOk(response);
+		   }
+		   catch(Exception e){
+			   e.printStackTrace();
+			   JsonOutUtils.returnError(response, "服务出现错误");
+		   }
+	}
+	
 	
 	@RequestMapping("/importCar")
 	public void importCar(HttpServletRequest request,HttpServletResponse response){

+ 7 - 1
src/main/java/com/hb/proj/car/service/CarService.java

@@ -62,7 +62,7 @@ public class CarService {
 		StringBuilder sql=new StringBuilder(100);
 		sql.append("select * from (");
 		sql.append("select g.assist_code,g.org_name belong_org_name,d1.code_name coil_car_type_name, DATE_FORMAT(work_start,'%Y-%m') wk_start,");
-		sql.append(" t.car_num,t.custom_num,t.car_id,t.discard_if,");
+		sql.append(" t.car_num,t.custom_num,t.car_id,t.discard_if,t.custom_tag,");
 		sql.append(" r.oil_type,r.device_name,r.device_model,r.quota_power,r2.device_model alternator_model_name");
 		sql.append(" from t_car t ");
 		sql.append(" left join t_org g on t.belong_org=g.org_id ");
@@ -228,6 +228,12 @@ public class CarService {
 		return true;
 	}
 	
+	public boolean updateForField(String carId,String filed,Object val) {
+		String attr=FieldAttrConverter.getFieldName(filed);
+		int num=dao.getJdbcTemplate().update("update t_car set "+attr+"=?,modify_time=? where car_id=?",val,new Date(),carId);
+		return num>0;
+	}
+	
 	
 	public boolean existsCar(String carNum,String carId){
 		Map<String,Object> rst=null;

+ 17 - 0
src/main/webapp/page/car/car.html

@@ -10,6 +10,16 @@
 		  .layui-form-item{margin-bottom:5px;}
 		  .layui-table-view{margin:5px 0px;}
 		  .rpt-label{width:100px !important;}
+		  .discard-car{
+		    color:#ff0000;
+		  }
+		  .outside-car{
+		    color:#0f6ade;
+		  }
+		 
+		  td[data-field="customNum"] .layui-table-cell{
+		     padding:0px;
+		  }
 		</style>
 	</head>
 	<body>
@@ -84,6 +94,13 @@
 		  {{#  } else { }}
              <i class="layui-icon layui-icon-ok-circle my-operate-icon" title="恢复使用" lay-event="recoveryUse"></i>
            {{#  }  }}
+
+
+			{{#  if(d.customTag=='是'){ }}
+ 			  <i class="layui-icon layui-icon-radio my-operate-icon" title="标记为内部车辆" lay-event="insideTag"></i>
+		    {{#  } else { }}
+              <i class="layui-icon layui-icon-circle my-operate-icon" title="标记为外部车辆" lay-event="outsideTag"></i>
+           {{#  }  }}
 		</script>
 	</body>
 </html>

+ 25 - 3
src/main/webapp/page/js/car.js

@@ -71,11 +71,17 @@ layui.use(['element','mylayer','newtable','laydate','myform','page'], function (
 				  					 toolbarExtraData:setting.userId,
 				  					 cols:[[
 										 {type: 'numbers', title: '序号', width: '60',fixed: 'left'},
-										 {field: 'customNum', title: '自编号', width:120,fixed: 'left',templet:function(d){
-											 return d.discardIf==1?("<font color='red'>"+d.customNum+"</font>"):d.customNum;
+										 {field: 'customNum', title: '自编号', width:100,align:'center',fixed: 'left',templet:function(d){
+											 let cls=d.discardIf==1?'discard-car':'';
+											 if("是"==d.customTag){
+												 cls=cls+" outside-car";
+											 }
+											 return "<div class=\""+cls+"\">"+d.customNum+"</div>";
 										 }},
 				  						 {field: 'carNum', title: '牌照号', width:120,fixed: 'left'},
 				  						 {field: 'belongOrgName', title: '所属单位', width:180,align:'center'},
+				  						 {field: 'customTag', title: '是否托管', width:120,align:'center'},
+				  						
 				  						 {field: 'deviceName', title: '设备名称', width:220,sort:true},
 				  						 {field: 'deviceModel', title: '规格型号', width:260,sort:true},
 				  						 {field: 'quotaPower', title: '额定功率(kw)', width:160},
@@ -85,7 +91,7 @@ layui.use(['element','mylayer','newtable','laydate','myform','page'], function (
 				  						 {field: 'oilType', title: '燃油类型', width:110,align:'center'},
 				  						 
 				  						 {field: 'coilCarTypeName', title: '柴油车辆类型', width:140,align:'center'},
-				  						 {field: 'op', title: '操作', width:260,align:'center',toolbar:'#toolbar'}
+				  						 {field: 'op', title: '操作', width:300,align:'center',toolbar:'#toolbar'}
 				  						
 				  					 ]]
 							    });
@@ -240,6 +246,22 @@ layui.use(['element','mylayer','newtable','laydate','myform','page'], function (
 								maxmin :true
 							});
 						}
+						else if(layEvent === 'insideTag'||layEvent === 'outsideTag'){
+							page.ajax({
+								 url:"car/setTag.do",
+								 data:{carId:data.carId,tag:(layEvent === 'outsideTag'?'是':'否')}
+							 },function(resp){
+								 if(!resp.success){
+									 layer.msg(resp.exception);
+								 }
+								 else{
+									 layer.msg("操作成功");
+									 table.refresh("LAY-tab-car");
+								 }
+							 },function(){
+								 layer.msg("网络请求出现错误");
+							 });
+						}
 						
 					});
 				

+ 1 - 1
src/main/webapp/page/js/carUpdate.js

@@ -103,7 +103,7 @@ layui.use(['element','myform','page','mylayer','laydate'], function () {
 							 reqData:{carId:param.carId},
 							 afterInit:function(respData){
 								 $("#quotaPower").val(respData.quotaPower);
-								 $("#oldCustomNum").val(d.customNum); 
+								 $("#oldCustomNum").val(respData.customNum); 
 							 }
 						 });
 					 }