字典树;

添加字典;
pull/65/head
huangyao 4 years ago
parent 904837f28b
commit ad90aeb696

@ -9,6 +9,7 @@ import cn.stylefeng.roses.kernel.dict.modular.service.DictTypeService;
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.system.pojo.ztree.ZTreeNode;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -84,8 +85,8 @@ public class DictViewController {
*/
@GetResource(name = "字典管理-编辑-视图", path = "/editView")
public ModelAndView editView(ModelAndView view, @RequestParam Long dictId) {
SysDict dict = dictService.findDetail(dictId);
SysDictType dictType = dictTypeService.getById(dict.getDictId());
SysDictType dictType = extendDictService.getDictTypeByDictId(dictId);
view.addObject("dictTypeName", dictType.getDictTypeName());
view.addObject("dictTypeId", dictType.getDictTypeId());
view.addObject("dictTypeCode", dictType.getDictTypeCode());

@ -1,5 +1,6 @@
package cn.stylefeng.guns.modular.dict.service;
import cn.stylefeng.roses.kernel.dict.modular.entity.SysDictType;
import cn.stylefeng.roses.kernel.dict.modular.pojo.request.DictRequest;
import cn.stylefeng.roses.kernel.system.pojo.ztree.ZTreeNode;
@ -24,4 +25,14 @@ public interface ExtendDictService {
* @date 2021/1/10 16:26
*/
List<ZTreeNode> dictZTree(DictRequest dictRequest);
/**
* id
*
* @param
* @return
* @author huangyao
* @date 2021/1/11 21:39
*/
SysDictType getDictTypeByDictId(Long dictId);
}

@ -1,13 +1,19 @@
package cn.stylefeng.guns.modular.dict.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.stylefeng.guns.modular.dict.service.ExtendDictService;
import cn.stylefeng.roses.kernel.dict.api.exception.DictException;
import cn.stylefeng.roses.kernel.dict.api.exception.enums.DictExceptionEnum;
import cn.stylefeng.roses.kernel.dict.modular.entity.SysDict;
import cn.stylefeng.roses.kernel.dict.modular.entity.SysDictType;
import cn.stylefeng.roses.kernel.dict.modular.pojo.request.DictRequest;
import cn.stylefeng.roses.kernel.dict.modular.service.DictService;
import cn.stylefeng.roses.kernel.dict.modular.service.DictTypeService;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import cn.stylefeng.roses.kernel.system.pojo.ztree.ZTreeNode;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -27,6 +33,8 @@ public class ExtendDictServiceImpl implements ExtendDictService {
@Autowired
private DictService dictService;
@Autowired
private DictTypeService dictTypeService;
@Override
public List<ZTreeNode> dictZTree(DictRequest dictRequest) {
@ -45,10 +53,31 @@ public class ExtendDictServiceImpl implements ExtendDictService {
zTreeNodes.add(zTreeNode);
}
ZTreeNode zTreeNode = new ZTreeNode();
zTreeNode.setId(-1L);
zTreeNode.setpId(0L);
zTreeNode.setName("顶级");
zTreeNode.setOpen(true);
zTreeNodes.add(zTreeNode);
// 构建已选中的状态
return zTreeNodes;
}
@Override
public SysDictType getDictTypeByDictId(Long dictId) {
SysDict dict = dictService.getById(dictId);
// 根据字典类型编码获取字典类型
SysDictType dictType = dictTypeService.getOne(new QueryWrapper<SysDictType>().lambda()
.eq(SysDictType::getDelFlag, 'N')
.eq(SysDictType::getDictTypeCode, dict.getDictTypeCode()));
if (ObjectUtil.isEmpty(dictType)) {
throw new DictException(DictExceptionEnum.DICT_TYPE_NOT_EXISTED, dictType.getDictTypeCode());
}
return dictType;
}
/**
* wrapper
*

@ -20,19 +20,18 @@ layui.use(['treeTable', 'func', 'HttpRequest'], function () {
Dict.initColumn = function () {
return [
{type: 'checkbox'},
{field: 'name', align: "center", title: '字典名称'},
{field: 'code', align: "center", title: '字典编码'},
{field: 'description', align: "center", title: '字典的描述'},
{field: 'dictName', align: "center", title: '字典名称'},
{field: 'dictCode', align: "center", title: '字典编码'},
{field: 'dictNamePinYin', align: "center", title: '字典拼音'},
{
field: 'status', align: "center", title: '状态', templet: function (d) {
if (d.status === 'ENABLE') {
if (d.status === 1) {
return "启用";
} else {
return "禁用";
}
}
},
{field: 'createTime', align: "center", sort: true, title: '创建时间'},
{align: 'center', toolbar: '#tableBar', title: '操作'}
];
};
@ -42,7 +41,8 @@ layui.use(['treeTable', 'func', 'HttpRequest'], function () {
*/
Dict.search = function () {
var queryData = {};
queryData['condition'] = $("#condition").val();
queryData['dictName'] = $("#condition").val();
queryData['dictCode'] = $("#condition").val();
Dict.initTable(Dict.tableId, queryData);
};
@ -103,7 +103,6 @@ layui.use(['treeTable', 'func', 'HttpRequest'], function () {
Dict.initTable = function (dictId, data) {
return treeTable.render({
elem: '#' + dictId,
url: Feng.ctxPath + '/dict/getDictListPage?dictTypeId=' + $("#dictTypeId").val(),
tree: {
iconIndex: 1, // 折叠图标显示在第几列
idName: 'dictId', // 自定义id字段的名称
@ -115,23 +114,15 @@ layui.use(['treeTable', 'func', 'HttpRequest'], function () {
request: {pageName: 'pageNo', limitName: 'pageSize'}, //自定义分页参数
height: "full-98",
cols: Dict.initColumn(),
// reqData: function (data, callback) {
// // var ajax = new $ax(Feng.ctxPath + '/dictType/getDictTypePageList?dictTypeId=' + $("#dictTypeId").val(), function (res) {
// // callback(res.data);
// // }, function (res) {
// // Feng.error("删除失败!" + res.responseJSON.message + "!");
// // });
// // ajax.start();
// var httpRequest = new HttpRequest(Feng.ctxPath + '/dict/getDictListPage?dictTypeId=' + $("#dictTypeId").val(), 'get', function (data) {
// console.log(res.data)
// callback(res.data);
// }, function (data) {
// Feng.error("加载失败!" + data.message + "!");
// });
// httpRequest.set(data);
// httpRequest.start(true);
// },
parseData: Feng.parseData
reqData: function (d, callback) {
var httpRequest = new HttpRequest(Feng.ctxPath + 'dict/getDictTreeList?dictTypeCode=' + $("#dictTypeCode").val(), 'get', function (result) {
callback(result.data);
}, function (result) {
Feng.error("加载失败!" + result.message + "!");
});
httpRequest.set(data);
httpRequest.start();
},
});
};

@ -21,6 +21,7 @@ layui.use(['form', 'admin', 'HttpRequest'], function () {
var $ = layui.jquery;
var form = layui.form;
var admin = layui.admin;
var HttpRequest = layui.HttpRequest;
//表单提交事件
form.on('submit(btnSubmit)', function (data) {
@ -42,7 +43,6 @@ layui.use(['form', 'admin', 'HttpRequest'], function () {
var formName = encodeURIComponent("parent.DictInfoDlg.data.parentName");
var formId = encodeURIComponent("parent.DictInfoDlg.data.parentId");
var treeUrl = encodeURIComponent("/dict/zTree?dictTypeId=" + $("#dictTypeId").val());
// var treeUrl = encodeURIComponent("/dict/zTree?roleId=1339550467939639303");
layer.open({
type: 2,

@ -6,7 +6,6 @@ layui.use(['form', 'admin', 'HttpRequest'], function () {
//获取详情信息,填充表单
var request = new HttpRequest(Feng.ctxPath + "/dictType/getDictDetail?dictTypeId=" + Feng.getUrlParam("dictTypeId"), 'get', function (result) {
console.log(result)
if(result.data.dictTypeClass === 2){
$('input,select,textarea').attr("disabled",true).attr('readonly',true);
}

@ -36,7 +36,7 @@
<div class="layui-inline layui-col-md12">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">
<input id="sort" name="sort" placeholder="请输入字典排序" type="text" class="layui-input">
<input id="dictSort" name="dictSort" placeholder="请输入字典排序" type="text" class="layui-input">
</div>
</div>
<div class="layui-inline layui-col-md12">

Loading…
Cancel
Save