栏目管理
This commit is contained in:
parent
d5a62a090d
commit
631870cbe8
|
|
@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
|
@ -261,18 +262,138 @@ public class BaseCodeController extends BaseController {
|
|||
*/
|
||||
@RequestMapping(value = "/columnTree")
|
||||
@ResponseBody
|
||||
public Message columnTree(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
public List<Ztree> columnTree(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
Message msg = new Message();
|
||||
Map<String, Object> policyMap = new HashMap<String, Object>();
|
||||
String codeCode = request.getParameter("codeCode");
|
||||
String codeType = request.getParameter("codeType");
|
||||
// 查询栏目树
|
||||
List<BaseCodeTree> columnList = baseCodeService.columnTree(codeCode);
|
||||
policyMap.put("columnList", columnList);
|
||||
msg.setInfo("成功");
|
||||
msg.setObject(policyMap);
|
||||
msg.setResult(true);
|
||||
return msg;
|
||||
List<BaseCodeTree> columnList = baseCodeService.columnTree(codeCode, codeType);
|
||||
// policyMap.put("columnList", columnList);
|
||||
// msg.setInfo("成功");
|
||||
// msg.setObject(policyMap);
|
||||
// msg.setResult(true);
|
||||
|
||||
return initZtree(columnList);
|
||||
}
|
||||
|
||||
public List<Ztree> initZtree(List<BaseCodeTree> deptList) {
|
||||
|
||||
List<Ztree> ztreeList = new ArrayList<>();
|
||||
if (deptList != null && deptList.size() > 0) {
|
||||
Ztree z = new Ztree();
|
||||
z.setId("FIRST_COLUMN");
|
||||
z.setpId("");
|
||||
z.setName("栏目");
|
||||
z.setTitle("栏目");
|
||||
ztreeList.add(z);
|
||||
for (BaseCodeTree dept : deptList) {
|
||||
Ztree ztree = new Ztree();
|
||||
ztree.setId(dept.getCodeCode());
|
||||
ztree.setpId(dept.getCodeType());
|
||||
ztree.setName(dept.getCodeCname());
|
||||
ztree.setTitle(dept.getCodeCname());
|
||||
ztreeList.add(ztree);
|
||||
}
|
||||
}
|
||||
return ztreeList;
|
||||
}
|
||||
|
||||
static class Ztree implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 节点ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 节点父ID
|
||||
*/
|
||||
private String pId;
|
||||
|
||||
/**
|
||||
* 节点名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 节点标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 是否勾选
|
||||
*/
|
||||
private boolean checked = false;
|
||||
|
||||
/**
|
||||
* 是否展开
|
||||
*/
|
||||
private boolean open = false;
|
||||
|
||||
/**
|
||||
* 是否能勾选
|
||||
*/
|
||||
private boolean nocheck = false;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getpId() {
|
||||
return pId;
|
||||
}
|
||||
|
||||
public void setpId(String pId) {
|
||||
this.pId = pId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public boolean isChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return open;
|
||||
}
|
||||
|
||||
public void setOpen(boolean open) {
|
||||
this.open = open;
|
||||
}
|
||||
|
||||
public boolean isNocheck() {
|
||||
return nocheck;
|
||||
}
|
||||
|
||||
public void setNocheck(boolean nocheck) {
|
||||
this.nocheck = nocheck;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,4 +21,6 @@ public interface BaseCodeExMapper {
|
|||
*/
|
||||
public List<BaseCodeTree> columnTree(HashMap<String, String> parMap);
|
||||
|
||||
public List<BaseCodeTree> getNextNodeTree(HashMap<String, String> parMap);
|
||||
|
||||
}
|
||||
|
|
@ -84,9 +84,10 @@ public interface BaseCodeService {
|
|||
* 查询栏目树
|
||||
*
|
||||
* @param codeCode
|
||||
* @param codeType
|
||||
* @return
|
||||
*/
|
||||
public List<BaseCodeTree> columnTree(String codeCode);
|
||||
public List<BaseCodeTree> columnTree(String codeCode, String codeType);
|
||||
|
||||
/**
|
||||
* 操作栏目排序
|
||||
|
|
|
|||
|
|
@ -454,9 +454,9 @@ public class BaseCodeServiceImpl implements BaseCodeService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<BaseCodeTree> columnTree(String codeCode) {
|
||||
public List<BaseCodeTree> columnTree(String codeCode, String codeType) {
|
||||
logger.info("进入查询栏目树的方法");
|
||||
if (StringUtils.isBlank(codeCode)) {
|
||||
if (StringUtils.isAllBlank(codeCode, codeType)) {
|
||||
logger.info("查询栏目树请求参数不正确codeCode【{}】", codeCode);
|
||||
throw new ParameterException("创建失败,参数不足!");
|
||||
}
|
||||
|
|
@ -468,13 +468,33 @@ public class BaseCodeServiceImpl implements BaseCodeService {
|
|||
parMap.put("codeCode", codeCode);
|
||||
parMap.put("companyId", companyId);
|
||||
parMap.put("state", state);
|
||||
parMap.put("codeType", codeType);
|
||||
if (!"86".equals(branchId)) {
|
||||
parMap.put("branchId", branchId);
|
||||
}
|
||||
list = baseCodeExMapper.columnTree(parMap);
|
||||
List<BaseCodeTree> baseCodeList = new ArrayList<>();
|
||||
if (list != null && list.size() > 0) {
|
||||
recursion(list, baseCodeList);
|
||||
}
|
||||
logger.info("查询栏目树结束,查询到的结果为【{}】" + JsonUtil.objectToJackson(list));
|
||||
logger.info("查询栏目信息的方法结束!");
|
||||
return list;
|
||||
return baseCodeList;
|
||||
}
|
||||
|
||||
private void recursion(List<BaseCodeTree> baseCodeList, List<BaseCodeTree> list1) {
|
||||
for (BaseCodeTree baseCode : baseCodeList) {
|
||||
HashMap map = new HashMap();
|
||||
map.put("CODE_CODE", baseCode.getCodeCode());
|
||||
map.put("parentCompanyId", baseCode.getCompanyId());
|
||||
map.put("parentState", baseCode.getState());
|
||||
map.put("parentBranchId", baseCode.getBranchId());
|
||||
List<BaseCodeTree> list = baseCodeExMapper.getNextNodeTree(map);
|
||||
list1.add(baseCode);
|
||||
if (list != null && list.size() > 0) {
|
||||
recursion(list, list1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
UPDATE_REMARK, BUSINESS_AREA,COMPANY_ID,BRANCH_ID from
|
||||
base_code
|
||||
where
|
||||
STATE in (0,1)
|
||||
STATE = '0'
|
||||
<if test="companyId != null and companyId !=''">
|
||||
and COMPANY_ID = #{companyId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
|
|
@ -73,8 +73,8 @@
|
|||
<result column="BUSINESS_AREA" property="businessArea" jdbcType="VARCHAR" />
|
||||
<result column="COMPANY_ID" property="companyId" jdbcType="VARCHAR" />
|
||||
<result column="BRANCH_ID" property="branchId" jdbcType="VARCHAR" />
|
||||
<collection column="CODE_CODE=CODE_CODE,parentCompanyId=parentCompanyId,parentState=parentState,parentBranchId=parentBranchId" property="child" javaType="java.util.ArrayList"
|
||||
ofType="com.ruoyi.content.domain.BaseCodeTree" select="getNextNodeTree"/>
|
||||
<!-- <collection column="CODE_CODE=CODE_CODE,parentCompanyId=parentCompanyId,parentState=parentState,parentBranchId=parentBranchId" property="child" javaType="java.util.ArrayList"-->
|
||||
<!-- ofType="com.ruoyi.content.domain.BaseCodeTree" select="getNextNodeTree"/>-->
|
||||
</resultMap>
|
||||
|
||||
<select id="getNextNodeTree" resultMap="BaseTreeResultMap">
|
||||
|
|
@ -106,6 +106,9 @@
|
|||
<if test="codeCode != null and codeCode !=''">
|
||||
and CODE_CODE = #{codeCode,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="codeType != null and codeType !=''">
|
||||
and CODE_TYPE = #{codeType,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="companyId != null and companyId !=''">
|
||||
and COMPANY_ID = #{companyId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
|
|
|
|||
|
|
@ -2,44 +2,73 @@
|
|||
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<th:block th:include="include :: header('栏目列表')"/>
|
||||
<th:block th:include="include :: layout-latest-css"/>
|
||||
<th:block th:include="include :: ztree-css"/>
|
||||
</head>
|
||||
<body class="gray-bg">
|
||||
<div class="container-div">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 search-collapse">
|
||||
<form id="formId">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
<label style="width: 95px;">一级栏目名称:</label>
|
||||
<select name="codeType" th:id="codeType">
|
||||
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<label style="width: 95px;">二级栏目名称:</label>
|
||||
<input type="text" name="codeCname"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>展示序号:</label>
|
||||
<input type="text" name="orderNo"/>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
|
||||
class="fa fa-search"></i> 搜索</a>
|
||||
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
|
||||
class="fa fa-refresh"></i> 重置</a>
|
||||
<a class="btn btn-success btn-rounded btn-sm" data-toggle="modal" data-target="#myModal2"
|
||||
onclick="">
|
||||
<i class="fa fa-plus"></i> 添加
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
<div class="ui-layout-west">
|
||||
<div class="box box-main">
|
||||
<div class="box-header">
|
||||
<div class="box-title">
|
||||
<i class="fa icon-grid"></i> 栏目管理
|
||||
</div>
|
||||
<div class="box-tools pull-right">
|
||||
<a type="button" class="btn btn-box-tool" href="#" onclick="" title="管理部门" style="display:none;"><i
|
||||
class="fa fa-edit"></i></a>
|
||||
<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i
|
||||
class="fa fa-chevron-up"></i></button>
|
||||
<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i
|
||||
class="fa fa-chevron-down"></i></button>
|
||||
<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i
|
||||
class="fa fa-refresh"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
<div class="ui-layout-content">
|
||||
<div id="tree" class="ztree"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui-layout-center">
|
||||
<div class="container-div">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 search-collapse">
|
||||
<form id="formId">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li style="display: none;">
|
||||
<!-- <label style="width: 95px;">一级栏目名称:</label>-->
|
||||
<!-- <select name="codeType" th:id="codeType">-->
|
||||
|
||||
<!-- </select>-->
|
||||
<input type="text" name="codeType" th:id="codeType"/>
|
||||
</li>
|
||||
<li>
|
||||
<label style="width: 95px;">栏目名称:</label>
|
||||
<input type="text" name="codeCname"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>展示序号:</label>
|
||||
<input type="text" name="orderNo"/>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
|
||||
class="fa fa-search"></i> 搜索</a>
|
||||
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
|
||||
class="fa fa-refresh"></i> 重置</a>
|
||||
<a class="btn btn-success btn-rounded btn-sm" data-toggle="modal"
|
||||
data-target="#myModal2"
|
||||
onclick="">
|
||||
<i class="fa fa-plus"></i> 添加
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -112,13 +141,15 @@
|
|||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label is-required">三级栏目名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" class="form-control" th:id="thirdCodeCnames" name="thirdCodeCnames">
|
||||
<input type="text" class="form-control" th:id="thirdCodeCnames"
|
||||
name="thirdCodeCnames">
|
||||
</div>
|
||||
<br/><br/><br/>
|
||||
<div class="form-group" style="display:none">
|
||||
<label class="col-sm-4 control-label">三级展示序号:</label>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" class="form-control" th:id="thirdOrderNos" name="thirdOrderNos"
|
||||
<input type="text" class="form-control" th:id="thirdOrderNos"
|
||||
name="thirdOrderNos"
|
||||
value="1" style="width:210px"/>
|
||||
<label class="red">序号越小,展示越靠前。</label>
|
||||
</div>
|
||||
|
|
@ -185,6 +216,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<th:block th:include="include :: footer"/>
|
||||
<th:block th:include="include :: layout-latest-js"/>
|
||||
<th:block th:include="include :: ztree-js"/>
|
||||
<script th:inline="javascript">
|
||||
var prefix = ctx + 'column';
|
||||
var prefix1 = ctx + 'ldcom/queryldcomList';
|
||||
|
|
@ -197,6 +230,66 @@
|
|||
var isClick = false;
|
||||
|
||||
$(function () {
|
||||
var panehHidden = false;
|
||||
if ($(this).width() < 769) {
|
||||
panehHidden = true;
|
||||
}
|
||||
$('body').layout({initClosed: panehHidden, west__size: 185});
|
||||
// 回到顶部绑定
|
||||
if ($.fn.toTop !== undefined) {
|
||||
var opt = {
|
||||
win: $('.ui-layout-center'),
|
||||
doc: $('.ui-layout-center')
|
||||
};
|
||||
$('#scroll-up').toTop(opt);
|
||||
}
|
||||
|
||||
queryTableList();
|
||||
|
||||
queryColumnTree();
|
||||
|
||||
getBaseCode("FIRST_COLUMN");
|
||||
setValueTolist();
|
||||
selectArticleSecColumn();
|
||||
queryCompany();
|
||||
|
||||
$('#btnRefresh').click(function () {
|
||||
queryColumnTree();
|
||||
});
|
||||
|
||||
$('#btnCollapse').click(function () {
|
||||
$._tree.expandAll(false);
|
||||
$(this).hide();
|
||||
$('#btnExpand').show();
|
||||
});
|
||||
|
||||
$('#btnExpand').click(function () {
|
||||
$._tree.expandAll(true);
|
||||
$(this).hide();
|
||||
$('#btnCollapse').show();
|
||||
});
|
||||
});
|
||||
|
||||
function queryColumnTree() {
|
||||
var url = ctx + "column/columnTree?codeType=FIRST_COLUMN";
|
||||
var options = {
|
||||
url: url,
|
||||
expandLevel: 1,
|
||||
onClick: zOnClick
|
||||
};
|
||||
$.tree.init(options);
|
||||
|
||||
function zOnClick(event, treeId, treeNode) {
|
||||
if (treeNode.id != "FIRST_COLUMN") {
|
||||
$("#codeType").val(treeNode.id);
|
||||
} else {
|
||||
$("#codeType").val("");
|
||||
}
|
||||
$.table.search();
|
||||
}
|
||||
}
|
||||
|
||||
function queryTableList() {
|
||||
var options = {
|
||||
url: prefix + "/columnArry",
|
||||
createUrl: prefix + "/add",
|
||||
|
|
@ -315,12 +408,7 @@
|
|||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
|
||||
getBaseCode("FIRST_COLUMN");
|
||||
setValueTolist();
|
||||
selectArticleSecColumn();
|
||||
queryCompany();
|
||||
});
|
||||
}
|
||||
|
||||
function changeTab() {
|
||||
var radioValue = $("#sencondType option:selected").val();
|
||||
|
|
@ -402,13 +490,13 @@
|
|||
// 给下拉列表赋值
|
||||
function setValueTolist() {
|
||||
// 给搜索的下拉列表赋值
|
||||
$("#codeType option").remove();
|
||||
// $("#codeType option").remove();
|
||||
var obj = baseDataList;
|
||||
$("#codeType").append("<option value=''>请选择</option>");
|
||||
// $("#codeType").append("<option value=''>请选择</option>");
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
$("#codeType").append(
|
||||
"<option value='" + obj[i].codeCode + "'>" + obj[i].codeCname
|
||||
+ "</option>");
|
||||
// $("#codeType").append(
|
||||
// "<option value='" + obj[i].codeCode + "'>" + obj[i].codeCname
|
||||
// + "</option>");
|
||||
$("#codeTypes").append(
|
||||
"<option value='" + obj[i].codeCode + "'>" + obj[i].codeCname
|
||||
+ "</option>");
|
||||
|
|
|
|||
Loading…
Reference in New Issue