作者 申海龙

设置分类 列表添加

@@ -254,7 +254,7 @@ public class SDCARGONAMEController { @@ -254,7 +254,7 @@ public class SDCARGONAMEController {
254 public String tadd(Model model){ 254 public String tadd(Model model){
255 // 一级类名称 255 // 一级类名称
256 List<SDBIGTYPEEntity> alls = sdbigtypeService.findAlls(); 256 List<SDBIGTYPEEntity> alls = sdbigtypeService.findAlls();
257 - // 二级类名称 257 + // 货物名称
258 List<String> alls1 = sdCargoNameService.findAlls(); 258 List<String> alls1 = sdCargoNameService.findAlls();
259 model.addAttribute("big", alls); 259 model.addAttribute("big", alls);
260 model.addAttribute("cargo", alls1); 260 model.addAttribute("cargo", alls1);
@@ -354,5 +354,56 @@ public class SDCARGONAMEController { @@ -354,5 +354,56 @@ public class SDCARGONAMEController {
354 return responseModel; 354 return responseModel;
355 } 355 }
356 356
  357 + /**
  358 + * 分类跳转
  359 + * @param model
  360 + * @param id
  361 + * @return
  362 + */
  363 + @RequestMapping(value = "/doSaves")
  364 + public String doSaves(Model model, Long id){
  365 +
  366 + SDTWOTYPEEntity one = sdtwotypeService.findOne(id);
  367 + // 货物名称
  368 + List<String> alls1 = sdCargoNameService.findAlls();
  369 +
  370 + model.addAttribute("cargo", alls1);
  371 + model.addAttribute("one", one);
  372 +
  373 + return "sdtype/typeSave";
  374 + }
  375 +
  376 + /**
  377 + * 分类添加
  378 + * @param sd
  379 + * @param request
  380 + * @return
  381 + */
  382 + @RequestMapping(value = "/doSave")
  383 + @ResponseBody
  384 + public ResponseModel doSave(SDTWOTYPEEntity sd, String names, HttpServletRequest request){
  385 + ResponseModel model = new ResponseModel();
  386 + try {
  387 + // 如果为空 默认为0
  388 + if (sd.getTwo_type_order() == null){
  389 + sd.setTwo_type_order("0");
  390 + }
  391 + String[] split = names.split(",");
  392 + for (int i = 0; i < split.length; i++){
  393 + SDTWOTYPEEntity sdtwotypeEntity = new SDTWOTYPEEntity();
  394 + sdtwotypeEntity.setTwo_type_name(sd.getTwo_type_name());
  395 + sdtwotypeEntity.setBig_type_id(sd.getBig_type_id());
  396 + sdtwotypeEntity.setCargo_name(split[i]);
  397 + sdtwotypeEntity.setTwo_type_order(sd.getTwo_type_order());
  398 + sdtwotypeService.saves(sdtwotypeEntity);
  399 + }
  400 + model.setStatus(200);
  401 + return model;
  402 + }catch (Exception e){
  403 + e.printStackTrace();
  404 + model.setStatus(500);
  405 + return model;
  406 + }
  407 + }
357 408
358 } 409 }
@@ -50,19 +50,19 @@ @@ -50,19 +50,19 @@
50 <input id="two_type_name" name="two_type_name" type="text" required/> 50 <input id="two_type_name" name="two_type_name" type="text" required/>
51 </td> 51 </td>
52 </tr> 52 </tr>
53 - <tr>  
54 - <td class="kv-label">  
55 - 货物名称<span class="required_span">*</span>  
56 - </td>  
57 - <td class="kv-content">  
58 - <select id="cargo_name" name="cargo_name">  
59 - <%--<option value=""></option>--%>  
60 - <c:forEach items="${cargo}" var="cargo">  
61 - <option value="${cargo}">${cargo}</option>  
62 - </c:forEach>  
63 - </select>  
64 - </td>  
65 - </tr> 53 + <%--<tr>--%>
  54 + <%--<td class="kv-label">--%>
  55 + <%--货物名称<span class="required_span">*</span>--%>
  56 + <%--</td>--%>
  57 + <%--<td class="kv-content">--%>
  58 + <%--<select id="cargo_name" name="cargo_name">--%>
  59 + <%--&lt;%&ndash;<option value=""></option>&ndash;%&gt;--%>
  60 + <%--<c:forEach items="${cargo}" var="cargo">--%>
  61 + <%--<option value="${cargo}">${cargo}</option>--%>
  62 + <%--</c:forEach>--%>
  63 + <%--</select>--%>
  64 + <%--</td>--%>
  65 + <%--</tr>--%>
66 <%--<tr>--%> 66 <%--<tr>--%>
67 <%--<td class="kv-label">排序字段</td>--%> 67 <%--<td class="kv-label">排序字段</td>--%>
68 <%--<td class="kv-content">--%> 68 <%--<td class="kv-content">--%>
@@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@
47 <th field="bigName">一级类名称</th> 47 <th field="bigName">一级类名称</th>
48 <th field="two_type_name">二级类名称</th> 48 <th field="two_type_name">二级类名称</th>
49 <th field="cargo_name">货物品名</th> 49 <th field="cargo_name">货物品名</th>
50 - <%--<th field="two_type_order">排序字段</th>--%> 50 + <th field=".." formatter="operatorFormat">操作</th>
51 </tr> 51 </tr>
52 </thead> 52 </thead>
53 </table> 53 </table>
@@ -114,6 +114,10 @@ @@ -114,6 +114,10 @@
114 return html; 114 return html;
115 } 115 }
116 116
  117 + function operatorFormat(val, row, index) {
  118 + var html = "<a href='javascript:void(0)' onclick='doSaves("+row.id+")' style='text-decoration:none;color:blue;'>设置分类</a>";
  119 + return html;
  120 + }
117 121
118 function doSearch(){ 122 function doSearch(){
119 $('#dg').datagrid("options").queryParams=$("#searchForm").serializeJson(); 123 $('#dg').datagrid("options").queryParams=$("#searchForm").serializeJson();
@@ -141,6 +145,16 @@ @@ -141,6 +145,16 @@
141 }); 145 });
142 } 146 }
143 147
  148 + function doSaves(id) {
  149 + layer.open({
  150 + type : 2,
  151 + title : '设置分类',
  152 + maxmin : true,
  153 + shadeClose : false, // 点击遮罩关闭层
  154 + area : [ '1000px', '500px' ],
  155 + content : '<%=basePath %>type/doSaves?id=' + id
  156 + });
  157 + }
144 function tUpdate(id) { 158 function tUpdate(id) {
145 // iframe层 159 // iframe层
146 layer.open({ 160 layer.open({
  1 +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  2 +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
  3 +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  4 +<%
  5 + String path = request.getContextPath();
  6 + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
  7 +%>
  8 +<!DOCTYPE html>
  9 +<html lang="en">
  10 +<head>
  11 + <meta charset="utf-8">
  12 + <meta name="viewport" content="width=device-width, initial-scale=1">
  13 + <link href="<%=basePath %>resource/css/base.css" rel="stylesheet">
  14 + <link href="<%=basePath %>resource/css/basic_info.css" rel="stylesheet">
  15 + <link rel="stylesheet" href="<%=basePath %>resource/easyui/uimaker/easyui.css">
  16 + <link href="<%=basePath %>resource/css/form.css" rel="stylesheet">
  17 + <script type="text/javascript" src="<%=basePath %>resource/easyui/jquery.min.js"></script>
  18 + <script type="text/javascript" src="<%=basePath %>resource/validate/jquery.validate.js"></script>
  19 + <script type="text/javascript" src="<%=basePath %>resource/validate/validate-extends.js"></script>
  20 + <link rel="stylesheet" href="<%=basePath %>resource/css/form.css">
  21 + <script type="text/javascript" src="<%=basePath %>resource/js/tools.js"></script>
  22 + <!-- validate 验证中英文 -->
  23 + <script type="text/javascript" src="<%=basePath %>resource/validate/jquery.validate-${pageContext.response.locale}.js"></script>
  24 +</head>
  25 +<body>
  26 + <div class="container">
  27 +
  28 + <div class="content">
  29 + <form class="layui-form" id="form">
  30 + <table class="kv-table">
  31 + <tbody>
  32 + <input type="hidden" name="big_type_id" id="big_type_id" value="${one.big_type_id}">
  33 + <input type="hidden" name="two_type_name" id="two_type_name" value="${one.two_type_name}">
  34 + <tr>
  35 + <%--<td class="kv-label">--%>
  36 + <%--货物品名<span class="required_span"></span>--%>
  37 + <%--</td>--%>
  38 + <th class="kv-content">
  39 + <c:forEach items="${cargo}" var="cargo">
  40 + <input type="checkbox" name="names" id="nams" title="${cargo}" value="${cargo}" lay-skin="primary">${cargo}
  41 + </c:forEach>
  42 + </th>
  43 + </tr>
  44 + <tr>
  45 + <td colspan="6">
  46 + <div class="opt-buttons" style="padding-top:20px;">
  47 + <button type="submit" class="easyui-linkbutton l-btn l-btn-small l-btn-selected " data-options="selected:true">
  48 + <span class="l-btn-left"><span class="l-btn-text"><spring:message code="opt.save" /></span></span>
  49 + </button>
  50 + </div>
  51 + </td>
  52 + </tr>
  53 + </tbody>
  54 + </table>
  55 + </form>
  56 + </div>
  57 + </div>
  58 + <script type="text/javascript" src="<%=basePath %>resource/layer-v3.0.3/layer/layer.js"></script>
  59 + <script src="<%=basePath %>resource/easyui/jquery.easyui.min.js"></script>
  60 + <script src="<%=basePath %>resource/js/tools.js"></script>
  61 + <script type="text/javascript">
  62 + $("#form").validate({
  63 + submitHandler:function(form){
  64 + submit();
  65 + }
  66 + });
  67 +
  68 + var selectFals = false;
  69 + function submit(){
  70 + // if (selectFals == true){
  71 + var data = $("#form").serialize();
  72 + $.post("<%=basePath%>type/doSave",data,function(data){
  73 + if(data.status==200){
  74 + layer.confirm("<spring:message code="opt.savesuccess" />!",{btn:['<spring:message code="opt.confirm" />','<spring:message code="opt.cancel" />']},function(){
  75 + var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
  76 + parent.layer.close(index);
  77 + window.parent.location.reload();
  78 + })
  79 + }else {
  80 + alert("网络异常")
  81 + }
  82 + })
  83 +
  84 + }
  85 +
  86 + $(document).ready(function () {
  87 + var form = layui.form;
  88 + form.render();
  89 + })
  90 + </script>
  91 +</body>
  92 +</html>