mirror of https://gitee.com/stylefeng/guns
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.ApiResource;
|
||||||
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
||||||
import cn.stylefeng.roses.kernel.system.pojo.ztree.ZTreeNode;
|
import cn.stylefeng.roses.kernel.system.pojo.ztree.ZTreeNode;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
@ -84,8 +85,8 @@ public class DictViewController {
|
||||||
*/
|
*/
|
||||||
@GetResource(name = "字典管理-编辑-视图", path = "/editView")
|
@GetResource(name = "字典管理-编辑-视图", path = "/editView")
|
||||||
public ModelAndView editView(ModelAndView view, @RequestParam Long dictId) {
|
public ModelAndView editView(ModelAndView view, @RequestParam Long dictId) {
|
||||||
SysDict dict = dictService.findDetail(dictId);
|
SysDictType dictType = extendDictService.getDictTypeByDictId(dictId);
|
||||||
SysDictType dictType = dictTypeService.getById(dict.getDictId());
|
|
||||||
view.addObject("dictTypeName", dictType.getDictTypeName());
|
view.addObject("dictTypeName", dictType.getDictTypeName());
|
||||||
view.addObject("dictTypeId", dictType.getDictTypeId());
|
view.addObject("dictTypeId", dictType.getDictTypeId());
|
||||||
view.addObject("dictTypeCode", dictType.getDictTypeCode());
|
view.addObject("dictTypeCode", dictType.getDictTypeCode());
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.stylefeng.guns.modular.dict.service;
|
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.dict.modular.pojo.request.DictRequest;
|
||||||
import cn.stylefeng.roses.kernel.system.pojo.ztree.ZTreeNode;
|
import cn.stylefeng.roses.kernel.system.pojo.ztree.ZTreeNode;
|
||||||
|
|
||||||
|
@ -24,4 +25,14 @@ public interface ExtendDictService {
|
||||||
* @date 2021/1/10 16:26
|
* @date 2021/1/10 16:26
|
||||||
*/
|
*/
|
||||||
List<ZTreeNode> dictZTree(DictRequest dictRequest);
|
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;
|
package cn.stylefeng.guns.modular.dict.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.stylefeng.guns.modular.dict.service.ExtendDictService;
|
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.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.pojo.request.DictRequest;
|
||||||
import cn.stylefeng.roses.kernel.dict.modular.service.DictService;
|
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.rule.enums.YesOrNotEnum;
|
||||||
import cn.stylefeng.roses.kernel.system.pojo.ztree.ZTreeNode;
|
import cn.stylefeng.roses.kernel.system.pojo.ztree.ZTreeNode;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -27,6 +33,8 @@ public class ExtendDictServiceImpl implements ExtendDictService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DictService dictService;
|
private DictService dictService;
|
||||||
|
@Autowired
|
||||||
|
private DictTypeService dictTypeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ZTreeNode> dictZTree(DictRequest dictRequest) {
|
public List<ZTreeNode> dictZTree(DictRequest dictRequest) {
|
||||||
|
@ -45,10 +53,31 @@ public class ExtendDictServiceImpl implements ExtendDictService {
|
||||||
zTreeNodes.add(zTreeNode);
|
zTreeNodes.add(zTreeNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZTreeNode zTreeNode = new ZTreeNode();
|
||||||
|
zTreeNode.setId(-1L);
|
||||||
|
zTreeNode.setpId(0L);
|
||||||
|
zTreeNode.setName("顶级");
|
||||||
|
zTreeNode.setOpen(true);
|
||||||
|
zTreeNodes.add(zTreeNode);
|
||||||
|
|
||||||
|
|
||||||
// 构建已选中的状态
|
// 构建已选中的状态
|
||||||
return zTreeNodes;
|
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
|
* 创建字典通用的条件查询wrapper
|
||||||
*
|
*
|
||||||
|
|
|
@ -20,19 +20,18 @@ layui.use(['treeTable', 'func', 'HttpRequest'], function () {
|
||||||
Dict.initColumn = function () {
|
Dict.initColumn = function () {
|
||||||
return [
|
return [
|
||||||
{type: 'checkbox'},
|
{type: 'checkbox'},
|
||||||
{field: 'name', align: "center", title: '字典名称'},
|
{field: 'dictName', align: "center", title: '字典名称'},
|
||||||
{field: 'code', align: "center", title: '字典编码'},
|
{field: 'dictCode', align: "center", title: '字典编码'},
|
||||||
{field: 'description', align: "center", title: '字典的描述'},
|
{field: 'dictNamePinYin', align: "center", title: '字典拼音'},
|
||||||
{
|
{
|
||||||
field: 'status', align: "center", title: '状态', templet: function (d) {
|
field: 'status', align: "center", title: '状态', templet: function (d) {
|
||||||
if (d.status === 'ENABLE') {
|
if (d.status === 1) {
|
||||||
return "启用";
|
return "启用";
|
||||||
} else {
|
} else {
|
||||||
return "禁用";
|
return "禁用";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{field: 'createTime', align: "center", sort: true, title: '创建时间'},
|
|
||||||
{align: 'center', toolbar: '#tableBar', title: '操作'}
|
{align: 'center', toolbar: '#tableBar', title: '操作'}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
@ -42,7 +41,8 @@ layui.use(['treeTable', 'func', 'HttpRequest'], function () {
|
||||||
*/
|
*/
|
||||||
Dict.search = function () {
|
Dict.search = function () {
|
||||||
var queryData = {};
|
var queryData = {};
|
||||||
queryData['condition'] = $("#condition").val();
|
queryData['dictName'] = $("#condition").val();
|
||||||
|
queryData['dictCode'] = $("#condition").val();
|
||||||
Dict.initTable(Dict.tableId, queryData);
|
Dict.initTable(Dict.tableId, queryData);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,7 +103,6 @@ layui.use(['treeTable', 'func', 'HttpRequest'], function () {
|
||||||
Dict.initTable = function (dictId, data) {
|
Dict.initTable = function (dictId, data) {
|
||||||
return treeTable.render({
|
return treeTable.render({
|
||||||
elem: '#' + dictId,
|
elem: '#' + dictId,
|
||||||
url: Feng.ctxPath + '/dict/getDictListPage?dictTypeId=' + $("#dictTypeId").val(),
|
|
||||||
tree: {
|
tree: {
|
||||||
iconIndex: 1, // 折叠图标显示在第几列
|
iconIndex: 1, // 折叠图标显示在第几列
|
||||||
idName: 'dictId', // 自定义id字段的名称
|
idName: 'dictId', // 自定义id字段的名称
|
||||||
|
@ -115,23 +114,15 @@ layui.use(['treeTable', 'func', 'HttpRequest'], function () {
|
||||||
request: {pageName: 'pageNo', limitName: 'pageSize'}, //自定义分页参数
|
request: {pageName: 'pageNo', limitName: 'pageSize'}, //自定义分页参数
|
||||||
height: "full-98",
|
height: "full-98",
|
||||||
cols: Dict.initColumn(),
|
cols: Dict.initColumn(),
|
||||||
// reqData: function (data, callback) {
|
reqData: function (d, callback) {
|
||||||
// // var ajax = new $ax(Feng.ctxPath + '/dictType/getDictTypePageList?dictTypeId=' + $("#dictTypeId").val(), function (res) {
|
var httpRequest = new HttpRequest(Feng.ctxPath + 'dict/getDictTreeList?dictTypeCode=' + $("#dictTypeCode").val(), 'get', function (result) {
|
||||||
// // callback(res.data);
|
callback(result.data);
|
||||||
// // }, function (res) {
|
}, function (result) {
|
||||||
// // Feng.error("删除失败!" + res.responseJSON.message + "!");
|
Feng.error("加载失败!" + result.message + "!");
|
||||||
// // });
|
});
|
||||||
// // ajax.start();
|
httpRequest.set(data);
|
||||||
// var httpRequest = new HttpRequest(Feng.ctxPath + '/dict/getDictListPage?dictTypeId=' + $("#dictTypeId").val(), 'get', function (data) {
|
httpRequest.start();
|
||||||
// console.log(res.data)
|
},
|
||||||
// callback(res.data);
|
|
||||||
// }, function (data) {
|
|
||||||
// Feng.error("加载失败!" + data.message + "!");
|
|
||||||
// });
|
|
||||||
// httpRequest.set(data);
|
|
||||||
// httpRequest.start(true);
|
|
||||||
// },
|
|
||||||
parseData: Feng.parseData
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ layui.use(['form', 'admin', 'HttpRequest'], function () {
|
||||||
var $ = layui.jquery;
|
var $ = layui.jquery;
|
||||||
var form = layui.form;
|
var form = layui.form;
|
||||||
var admin = layui.admin;
|
var admin = layui.admin;
|
||||||
|
var HttpRequest = layui.HttpRequest;
|
||||||
|
|
||||||
//表单提交事件
|
//表单提交事件
|
||||||
form.on('submit(btnSubmit)', function (data) {
|
form.on('submit(btnSubmit)', function (data) {
|
||||||
|
@ -42,7 +43,6 @@ layui.use(['form', 'admin', 'HttpRequest'], function () {
|
||||||
var formName = encodeURIComponent("parent.DictInfoDlg.data.parentName");
|
var formName = encodeURIComponent("parent.DictInfoDlg.data.parentName");
|
||||||
var formId = encodeURIComponent("parent.DictInfoDlg.data.parentId");
|
var formId = encodeURIComponent("parent.DictInfoDlg.data.parentId");
|
||||||
var treeUrl = encodeURIComponent("/dict/zTree?dictTypeId=" + $("#dictTypeId").val());
|
var treeUrl = encodeURIComponent("/dict/zTree?dictTypeId=" + $("#dictTypeId").val());
|
||||||
// var treeUrl = encodeURIComponent("/dict/zTree?roleId=1339550467939639303");
|
|
||||||
|
|
||||||
layer.open({
|
layer.open({
|
||||||
type: 2,
|
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) {
|
var request = new HttpRequest(Feng.ctxPath + "/dictType/getDictDetail?dictTypeId=" + Feng.getUrlParam("dictTypeId"), 'get', function (result) {
|
||||||
console.log(result)
|
|
||||||
if(result.data.dictTypeClass === 2){
|
if(result.data.dictTypeClass === 2){
|
||||||
$('input,select,textarea').attr("disabled",true).attr('readonly',true);
|
$('input,select,textarea').attr("disabled",true).attr('readonly',true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
<div class="layui-inline layui-col-md12">
|
<div class="layui-inline layui-col-md12">
|
||||||
<label class="layui-form-label">排序</label>
|
<label class="layui-form-label">排序</label>
|
||||||
<div class="layui-input-block">
|
<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>
|
</div>
|
||||||
<div class="layui-inline layui-col-md12">
|
<div class="layui-inline layui-col-md12">
|
||||||
|
|
Loading…
Reference in New Issue