栏目管理

This commit is contained in:
zkr_liushenlu 2021-03-27 10:51:14 +08:00
parent d5a62a090d
commit 631870cbe8
6 changed files with 297 additions and 62 deletions

View File

@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.*; import java.util.*;
/** /**
@ -261,18 +262,138 @@ public class BaseCodeController extends BaseController {
*/ */
@RequestMapping(value = "/columnTree") @RequestMapping(value = "/columnTree")
@ResponseBody @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", "*"); response.setHeader("Access-Control-Allow-Origin", "*");
Message msg = new Message(); Message msg = new Message();
Map<String, Object> policyMap = new HashMap<String, Object>(); Map<String, Object> policyMap = new HashMap<String, Object>();
String codeCode = request.getParameter("codeCode"); String codeCode = request.getParameter("codeCode");
String codeType = request.getParameter("codeType");
// 查询栏目树 // 查询栏目树
List<BaseCodeTree> columnList = baseCodeService.columnTree(codeCode); List<BaseCodeTree> columnList = baseCodeService.columnTree(codeCode, codeType);
policyMap.put("columnList", columnList); // policyMap.put("columnList", columnList);
msg.setInfo("成功"); // msg.setInfo("成功");
msg.setObject(policyMap); // msg.setObject(policyMap);
msg.setResult(true); // msg.setResult(true);
return msg;
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;
}
} }
/** /**

View File

@ -21,4 +21,6 @@ public interface BaseCodeExMapper {
*/ */
public List<BaseCodeTree> columnTree(HashMap<String, String> parMap); public List<BaseCodeTree> columnTree(HashMap<String, String> parMap);
public List<BaseCodeTree> getNextNodeTree(HashMap<String, String> parMap);
} }

View File

@ -84,9 +84,10 @@ public interface BaseCodeService {
* 查询栏目树 * 查询栏目树
* *
* @param codeCode * @param codeCode
* @param codeType
* @return * @return
*/ */
public List<BaseCodeTree> columnTree(String codeCode); public List<BaseCodeTree> columnTree(String codeCode, String codeType);
/** /**
* 操作栏目排序 * 操作栏目排序

View File

@ -454,9 +454,9 @@ public class BaseCodeServiceImpl implements BaseCodeService {
} }
@Override @Override
public List<BaseCodeTree> columnTree(String codeCode) { public List<BaseCodeTree> columnTree(String codeCode, String codeType) {
logger.info("进入查询栏目树的方法"); logger.info("进入查询栏目树的方法");
if (StringUtils.isBlank(codeCode)) { if (StringUtils.isAllBlank(codeCode, codeType)) {
logger.info("查询栏目树请求参数不正确codeCode【{}】", codeCode); logger.info("查询栏目树请求参数不正确codeCode【{}】", codeCode);
throw new ParameterException("创建失败,参数不足!"); throw new ParameterException("创建失败,参数不足!");
} }
@ -468,13 +468,33 @@ public class BaseCodeServiceImpl implements BaseCodeService {
parMap.put("codeCode", codeCode); parMap.put("codeCode", codeCode);
parMap.put("companyId", companyId); parMap.put("companyId", companyId);
parMap.put("state", state); parMap.put("state", state);
parMap.put("codeType", codeType);
if (!"86".equals(branchId)) { if (!"86".equals(branchId)) {
parMap.put("branchId", branchId); parMap.put("branchId", branchId);
} }
list = baseCodeExMapper.columnTree(parMap); 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("查询栏目树结束,查询到的结果为【{}】" + JsonUtil.objectToJackson(list));
logger.info("查询栏目信息的方法结束!"); 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 @Override

View File

@ -35,7 +35,7 @@
UPDATE_REMARK, BUSINESS_AREA,COMPANY_ID,BRANCH_ID from UPDATE_REMARK, BUSINESS_AREA,COMPANY_ID,BRANCH_ID from
base_code base_code
where where
STATE in (0,1) STATE = '0'
<if test="companyId != null and companyId !=''"> <if test="companyId != null and companyId !=''">
and COMPANY_ID = #{companyId,jdbcType=VARCHAR} and COMPANY_ID = #{companyId,jdbcType=VARCHAR}
</if> </if>
@ -73,8 +73,8 @@
<result column="BUSINESS_AREA" property="businessArea" jdbcType="VARCHAR" /> <result column="BUSINESS_AREA" property="businessArea" jdbcType="VARCHAR" />
<result column="COMPANY_ID" property="companyId" jdbcType="VARCHAR" /> <result column="COMPANY_ID" property="companyId" jdbcType="VARCHAR" />
<result column="BRANCH_ID" property="branchId" 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" <!-- <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"/> <!-- ofType="com.ruoyi.content.domain.BaseCodeTree" select="getNextNodeTree"/>-->
</resultMap> </resultMap>
<select id="getNextNodeTree" resultMap="BaseTreeResultMap"> <select id="getNextNodeTree" resultMap="BaseTreeResultMap">
@ -106,6 +106,9 @@
<if test="codeCode != null and codeCode !=''"> <if test="codeCode != null and codeCode !=''">
and CODE_CODE = #{codeCode,jdbcType=VARCHAR} and CODE_CODE = #{codeCode,jdbcType=VARCHAR}
</if> </if>
<if test="codeType != null and codeType !=''">
and CODE_TYPE = #{codeType,jdbcType=VARCHAR}
</if>
<if test="companyId != null and companyId !=''"> <if test="companyId != null and companyId !=''">
and COMPANY_ID = #{companyId,jdbcType=VARCHAR} and COMPANY_ID = #{companyId,jdbcType=VARCHAR}
</if> </if>

View File

@ -2,22 +2,49 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org"> <html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head> <head>
<th:block th:include="include :: header('栏目列表')"/> <th:block th:include="include :: header('栏目列表')"/>
<th:block th:include="include :: layout-latest-css"/>
<th:block th:include="include :: ztree-css"/>
</head> </head>
<body class="gray-bg"> <body class="gray-bg">
<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="ui-layout-content">
<div id="tree" class="ztree"></div>
</div>
</div>
</div>
<div class="ui-layout-center">
<div class="container-div"> <div class="container-div">
<div class="row"> <div class="row">
<div class="col-sm-12 search-collapse"> <div class="col-sm-12 search-collapse">
<form id="formId"> <form id="formId">
<div class="select-list"> <div class="select-list">
<ul> <ul>
<li> <li style="display: none;">
<label style="width: 95px;">一级栏目名称:</label> <!-- <label style="width: 95px;">一级栏目名称:</label>-->
<select name="codeType" th:id="codeType"> <!-- <select name="codeType" th:id="codeType">-->
</select> <!-- </select>-->
<input type="text" name="codeType" th:id="codeType"/>
</li> </li>
<li> <li>
<label style="width: 95px;">二级栏目名称:</label> <label style="width: 95px;">栏目名称:</label>
<input type="text" name="codeCname"/> <input type="text" name="codeCname"/>
</li> </li>
<li> <li>
@ -29,7 +56,8 @@
class="fa fa-search"></i>&nbsp;搜索</a> class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
class="fa fa-refresh"></i>&nbsp;重置</a> class="fa fa-refresh"></i>&nbsp;重置</a>
<a class="btn btn-success btn-rounded btn-sm" data-toggle="modal" data-target="#myModal2" <a class="btn btn-success btn-rounded btn-sm" data-toggle="modal"
data-target="#myModal2"
onclick=""> onclick="">
<i class="fa fa-plus"></i> 添加 <i class="fa fa-plus"></i> 添加
</a> </a>
@ -43,6 +71,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="modal inmodal" id="myModal2" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal inmodal" id="myModal2" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content animated flipInY"> <div class="modal-content animated flipInY">
@ -112,13 +141,15 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label is-required">三级栏目名称:</label> <label class="col-sm-4 control-label is-required">三级栏目名称:</label>
<div class="col-sm-8"> <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> </div>
<br/><br/><br/> <br/><br/><br/>
<div class="form-group" style="display:none"> <div class="form-group" style="display:none">
<label class="col-sm-4 control-label">三级展示序号:</label> <label class="col-sm-4 control-label">三级展示序号:</label>
<div class="col-sm-8"> <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"/> value="1" style="width:210px"/>
<label class="red">序号越小,展示越靠前。</label> <label class="red">序号越小,展示越靠前。</label>
</div> </div>
@ -185,6 +216,8 @@
</div> </div>
</div> </div>
<th:block th:include="include :: footer"/> <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"> <script th:inline="javascript">
var prefix = ctx + 'column'; var prefix = ctx + 'column';
var prefix1 = ctx + 'ldcom/queryldcomList'; var prefix1 = ctx + 'ldcom/queryldcomList';
@ -197,6 +230,66 @@
var isClick = false; var isClick = false;
$(function () { $(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 = { var options = {
url: prefix + "/columnArry", url: prefix + "/columnArry",
createUrl: prefix + "/add", createUrl: prefix + "/add",
@ -315,12 +408,7 @@
}] }]
}; };
$.table.init(options); $.table.init(options);
}
getBaseCode("FIRST_COLUMN");
setValueTolist();
selectArticleSecColumn();
queryCompany();
});
function changeTab() { function changeTab() {
var radioValue = $("#sencondType option:selected").val(); var radioValue = $("#sencondType option:selected").val();
@ -402,13 +490,13 @@
// 给下拉列表赋值 // 给下拉列表赋值
function setValueTolist() { function setValueTolist() {
// 给搜索的下拉列表赋值 // 给搜索的下拉列表赋值
$("#codeType option").remove(); // $("#codeType option").remove();
var obj = baseDataList; var obj = baseDataList;
$("#codeType").append("<option value=''>请选择</option>"); // $("#codeType").append("<option value=''>请选择</option>");
for (var i = 0; i < obj.length; i++) { for (var i = 0; i < obj.length; i++) {
$("#codeType").append( // $("#codeType").append(
"<option value='" + obj[i].codeCode + "'>" + obj[i].codeCname // "<option value='" + obj[i].codeCode + "'>" + obj[i].codeCname
+ "</option>"); // + "</option>");
$("#codeTypes").append( $("#codeTypes").append(
"<option value='" + obj[i].codeCode + "'>" + obj[i].codeCname "<option value='" + obj[i].codeCode + "'>" + obj[i].codeCname
+ "</option>"); + "</option>");