Commit 47a63463 by 融溪 Committed by stylefeng

!40 优化部分代码

1. 增加自定义标签使用此标签可以方便的在前台form表单中使用系统中维护的字典,并且支持option搜索、并且可选selelct,checkbox,radio显示样式。说明文件:guns-admin\src\main\webapp\WEB-INF\view\common\tags\tag_tips
2. 原字典模板值为id只能为数字,适用性太窄,所以修改字典模块增加code(字符串)用来记录值,
3. 修改某些模块js取值的bug。
parent 822b0cc6
...@@ -147,10 +147,17 @@ ...@@ -147,10 +147,17 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork><!-- 如果没有该项配置,肯呢个devtools不会起作用,即应用不会restart -->
</configuration>
</plugin> </plugin>
</plugins> </plugins>
<resources> <resources>
......
...@@ -48,31 +48,34 @@ INSERT INTO `sys_dept` VALUES ('26', '3', '24', '[0],[24],', '运营部', '运 ...@@ -48,31 +48,34 @@ INSERT INTO `sys_dept` VALUES ('26', '3', '24', '[0],[24],', '运营部', '运
INSERT INTO `sys_dept` VALUES ('27', '4', '24', '[0],[24],', '战略部', '战略部', '', null); INSERT INTO `sys_dept` VALUES ('27', '4', '24', '[0],[24],', '战略部', '战略部', '', null);
-- ---------------------------- -- ----------------------------
-- ----------------------------
-- Table structure for sys_dict -- Table structure for sys_dict
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `sys_dict`; DROP TABLE IF EXISTS `sys_dict`;
CREATE TABLE `sys_dict` ( CREATE TABLE `sys_dict` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id', `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键id',
`num` int(11) DEFAULT NULL COMMENT '排序', `num` int(11) NULL DEFAULT NULL COMMENT '排序',
`pid` int(11) DEFAULT NULL COMMENT '父级字典', `pid` int(11) NULL DEFAULT NULL COMMENT '父级字典',
`name` varchar(255) DEFAULT NULL COMMENT '名称', `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '名称',
`tips` varchar(255) DEFAULT NULL COMMENT '提示', `tips` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '提示',
PRIMARY KEY (`id`) `code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '值',
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8 COMMENT='字典表'; PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 69 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '字典表' ROW_FORMAT = Dynamic;
-- ---------------------------- -- ----------------------------
-- Records of sys_dict -- Records of sys_dict
-- ---------------------------- -- ----------------------------
INSERT INTO `sys_dict` VALUES ('16', '0', '0', '状态', null); INSERT INTO `sys_dict` VALUES (50, 0, 0, '性别', NULL, 'sys_sex');
INSERT INTO `sys_dict` VALUES ('17', '1', '16', '启用', null); INSERT INTO `sys_dict` VALUES (51, 1, 50, '男', NULL, '1');
INSERT INTO `sys_dict` VALUES ('18', '2', '16', '禁用', null); INSERT INTO `sys_dict` VALUES (52, 2, 50, '女', NULL, '2');
INSERT INTO `sys_dict` VALUES ('29', '0', '0', '性别', null); INSERT INTO `sys_dict` VALUES (53, 0, 0, '状态', NULL, 'sys_state');
INSERT INTO `sys_dict` VALUES ('30', '1', '29', '男', null); INSERT INTO `sys_dict` VALUES (54, 1, 53, '启用', NULL, '1');
INSERT INTO `sys_dict` VALUES ('31', '2', '29', '女', null); INSERT INTO `sys_dict` VALUES (55, 2, 53, '禁用', NULL, '2');
INSERT INTO `sys_dict` VALUES ('35', '0', '0', '账号状态', null); INSERT INTO `sys_dict` VALUES (56, 0, 0, '账号状态', NULL, 'account_state');
INSERT INTO `sys_dict` VALUES ('36', '1', '35', '启用', null); INSERT INTO `sys_dict` VALUES (57, 1, 56, '启用', NULL, '1');
INSERT INTO `sys_dict` VALUES ('37', '2', '35', '冻结', null); INSERT INTO `sys_dict` VALUES (58, 2, 56, '冻结', NULL, '2');
INSERT INTO `sys_dict` VALUES ('38', '3', '35', '已删除', null); INSERT INTO `sys_dict` VALUES (59, 3, 56, '已删除', NULL, '3');
-- ---------------------------- -- ----------------------------
-- Table structure for sys_expense -- Table structure for sys_expense
......
package com.stylefeng.guns.core.beetl; package com.stylefeng.guns.core.beetl;
import com.stylefeng.guns.core.tag.DictSelectorTag;
import com.stylefeng.guns.core.util.KaptchaUtil; import com.stylefeng.guns.core.util.KaptchaUtil;
import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.core.util.ToolUtil;
import org.beetl.core.Context;
import org.beetl.core.Function;
import org.beetl.core.Tag;
import org.beetl.core.TagFactory;
import org.beetl.ext.spring.BeetlGroupUtilConfiguration; import org.beetl.ext.spring.BeetlGroupUtilConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import java.io.UnsupportedEncodingException;
/** /**
* beetl拓展配置,绑定一些工具类,方便在模板中直接调用 * beetl拓展配置,绑定一些工具类,方便在模板中直接调用
...@@ -12,10 +22,50 @@ import org.beetl.ext.spring.BeetlGroupUtilConfiguration; ...@@ -12,10 +22,50 @@ import org.beetl.ext.spring.BeetlGroupUtilConfiguration;
*/ */
public class BeetlConfiguration extends BeetlGroupUtilConfiguration { public class BeetlConfiguration extends BeetlGroupUtilConfiguration {
@Autowired
Environment env;
@Autowired
ApplicationContext applicationContext;
@Autowired
DictSelectorTag dictSelectorTag;
@Override @Override
public void initOther() { public void initOther() {
groupTemplate.registerFunctionPackage("shiro", new ShiroExt()); groupTemplate.registerFunctionPackage("shiro", new ShiroExt());
groupTemplate.registerFunctionPackage("tool", new ToolUtil()); groupTemplate.registerFunctionPackage("tool", new ToolUtil());
groupTemplate.registerFunctionPackage("kaptcha", new KaptchaUtil()); groupTemplate.registerFunctionPackage("kaptcha", new KaptchaUtil());
groupTemplate.registerTagFactory("dictSelector", new TagFactory() {
@Override
public Tag createTag() {
return dictSelectorTag;
}
});
groupTemplate.registerFunction("env", new Function() {
@Override
public String call(Object[] paras, Context ctx) {
String key = (String)paras[0];
String value = env.getProperty(key);
if(value!=null) {
return getStr(value);
}
if(paras.length==2) {
return (String)paras[1];
}
return null;
}
protected String getStr(String str) {
try {
return new String(str.getBytes("iso8859-1"),"UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
});
} }
} }
...@@ -32,14 +32,19 @@ public class MutiStrFactory { ...@@ -32,14 +32,19 @@ public class MutiStrFactory {
public static final String MUTI_STR_ID = "ID"; public static final String MUTI_STR_ID = "ID";
/** /**
* 拼接字符串的key * 拼接字符串的CODE
*/ */
public static final String MUTI_STR_KEY = "KEY"; public static final String MUTI_STR_CODE = "CODE";
/** /**
* 拼接字符串的value * 拼接字符串的NAME
*/ */
public static final String MUTI_STR_VALUE = "VALUE"; public static final String MUTI_STR_NAME = "NAME";
/**
* 拼接字符串的NUM
*/
public static final String MUTI_STR_NUM = "NUM";
/** /**
* 解析一个组合字符串(例如: "1:启用;2:禁用;3:冻结" 这样的字符串) * 解析一个组合字符串(例如: "1:启用;2:禁用;3:冻结" 这样的字符串)
...@@ -56,17 +61,18 @@ public class MutiStrFactory { ...@@ -56,17 +61,18 @@ public class MutiStrFactory {
for (String item : items) { for (String item : items) {
String[] attrs = item.split(ATTR_SPLIT); String[] attrs = item.split(ATTR_SPLIT);
HashMap<String, String> itemMap = new HashMap<>(); HashMap<String, String> itemMap = new HashMap<>();
itemMap.put(MUTI_STR_KEY,attrs[0]); itemMap.put(MUTI_STR_CODE,attrs[0]);
itemMap.put(MUTI_STR_VALUE,attrs[1]); itemMap.put(MUTI_STR_NAME,attrs[1]);
itemMap.put(MUTI_STR_NUM,attrs[2]);
results.add(itemMap); results.add(itemMap);
} }
return results; return results;
} }
} }
/** /**
* 解析id:key:value这样类型的字符串 * 解析id:key:value这样类型的字符串
* *
* @author fengshuonan * @author fengshuonan
* @Date 2017/4/28 11:06 * @Date 2017/4/28 11:06
*/ */
...@@ -79,9 +85,9 @@ public class MutiStrFactory { ...@@ -79,9 +85,9 @@ public class MutiStrFactory {
for (String item : items) { for (String item : items) {
String[] attrs = item.split(ATTR_SPLIT); String[] attrs = item.split(ATTR_SPLIT);
HashMap<String, String> itemMap = new HashMap<>(); HashMap<String, String> itemMap = new HashMap<>();
itemMap.put(MUTI_STR_ID,attrs[0]); itemMap.put(MUTI_STR_CODE,attrs[0]);
itemMap.put(MUTI_STR_KEY,attrs[1]); itemMap.put(MUTI_STR_NAME,attrs[1]);
itemMap.put(MUTI_STR_VALUE,attrs[2]); itemMap.put(MUTI_STR_NUM,attrs[2]);
results.add(itemMap); results.add(itemMap);
} }
return results; return results;
......
...@@ -15,6 +15,7 @@ public enum BizExceptionEnum implements ServiceExceptionEnum{ ...@@ -15,6 +15,7 @@ public enum BizExceptionEnum implements ServiceExceptionEnum{
DICT_EXISTED(400,"字典已经存在"), DICT_EXISTED(400,"字典已经存在"),
ERROR_CREATE_DICT(500,"创建字典失败"), ERROR_CREATE_DICT(500,"创建字典失败"),
ERROR_WRAPPER_FIELD(500,"包装字典属性失败"), ERROR_WRAPPER_FIELD(500,"包装字典属性失败"),
ERROR_CODE_EMPTY(500,"字典类型不能为空"),
/** /**
* 文件上传 * 文件上传
......
package com.stylefeng.guns.core.tag;
import com.stylefeng.guns.core.common.exception.BizExceptionEnum;
import com.stylefeng.guns.core.exception.GunsException;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.system.model.Dict;
import com.stylefeng.guns.modular.system.service.IDictService;
import org.beetl.core.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* 字典标签渲染
*
* @author zhangjiajia
* @Date 2018年6月4日17:33:32
*/
@Component
@Scope("prototype")
public class DictSelectorTag extends Tag {
@Autowired
IDictService iDictService;
@Override
public void render(){
//String tagName = (String) this.args[0];
Map attrs = (Map) args[1];
if(ToolUtil.isEmpty(attrs.get("code"))){
throw new GunsException(BizExceptionEnum.ERROR_CODE_EMPTY);
}
//字典类型编码
String code = attrs.get("code").toString();
//控件显示类型select 选择框,radio 单选按钮,checkbox 多选按钮
String type = ToolUtil.isNotEmpty(attrs.get("type"))?attrs.get("type").toString():"select";
//开启多选
String multiple = ToolUtil.isNotEmpty(attrs.get("multiple"))?attrs.get("multiple").toString():"";
//字典名称
String label = ToolUtil.isNotEmpty(attrs.get("label"))?attrs.get("label").toString():"";
//提示
String placeholder = (ToolUtil.isNotEmpty(attrs.get("placeholder"))?attrs.get("placeholder").toString():"");
//宽度
String width = ToolUtil.isNotEmpty(attrs.get("width"))?attrs.get("width").toString():"248";
//默认值
String value = ToolUtil.isNotEmpty(attrs.get("value"))?attrs.get("value").toString():"";
//id
String id = ToolUtil.isNotEmpty(attrs.get("id"))?attrs.get("id").toString():"";
//name
String name = ToolUtil.isNotEmpty(attrs.get("name"))?attrs.get("name").toString():"";
//分割线
String underline = ToolUtil.isNotEmpty(attrs.get("underline"))?attrs.get("underline").toString():"";
//onchange事件
String onchange = ToolUtil.isNotEmpty(attrs.get("onchange"))?attrs.get("onchange").toString():"";
//readonly属性
String readonly = ToolUtil.isNotEmpty(attrs.get("readonly"))?attrs.get("readonly").toString():"";
//disabled属性
String disabled = ToolUtil.isNotEmpty(attrs.get("disabled"))?attrs.get("disabled").toString():"";
//searchnum 下拉选项数量达到多少启用搜索,默认10
int searchnum = ToolUtil.isNum(attrs.get("searchnum"))?Integer.parseInt(attrs.get("searchnum").toString()):10;
//根据code查询字典数据
List<Dict> list = iDictService.selectByParentCode(code);
StringBuffer html = new StringBuffer();
html.append("<div class=\"form-group\">\r\n");
html.append("<label class=\"col-sm-3 control-label\">"+label+"</label>\r\n");
html.append("<div class=\"col-sm-9\">\r\n");
//单选按钮
if("radio".equals(type)) {
list.forEach(obj->{
html.append("<label class=\"radio-inline i-checks\">\r\n<input type=\"radio\" ");
//判断控件是否禁用
if("true".equals(disabled)||"disabled".equals(disabled)) {
html.append("disabled ");
}else{
if(ToolUtil.isNotEmpty(name)){
html.append("name=\""+name+"\" ");
}
}
if("true".equals(readonly)||"disabled".equals(readonly)) {
html.append("disabled ");
}
if(ToolUtil.isNotEmpty(value)&&value.equals(obj.getCode())){
html.append("checked ");
}
html.append("value=\""+obj.getCode()+"\" >"+obj.getName()+"</label>\r\n");
});
//多选按钮
}else if("checkbox".equals(type)){
list.forEach(obj->{
html.append("<label class=\"checkbox-inline i-checks\">\r\n<input type=\"checkbox\" ");
//判断控件是否禁用
if("true".equals(disabled)||"disabled".equals(disabled)) {
html.append("disabled ");
}else{
if(ToolUtil.isNotEmpty(name)){
html.append("name=\""+name+"\" ");
}
}
if("true".equals(readonly)||"disabled".equals(readonly)) {
html.append("disabled ");
}
if(ToolUtil.isNotEmpty(value)&&value.equals(obj.getCode())){
html.append("checked ");
}
html.append("value=\""+obj.getCode()+"\" >"+obj.getName()+"</label>\r\n");
});
//默认select
}else{
//开启多选
if("true".equals(multiple)){
if(list.size()>=searchnum) {
html.append("<select multiple ");
}else{
html.append("<select multiple=\"multiple\" size=\"10\" ");
}
}else{
html.append("<select ");
}
//判断控件是否启用提示
if(ToolUtil.isNotEmpty(placeholder)){
html.append(" data-placeholder=\""+placeholder+"\" ");
}
//判断控件是否禁用
if("true".equals(disabled)||"disabled".equals(disabled)) {
html.append("disabled=\"disabled\" ");
}else{
//启用
if(ToolUtil.isNotEmpty(id)){
html.append("id=\""+id+"\" ");
}
if(ToolUtil.isNotEmpty(name)){
html.append("name=\""+name+"\" ");
}
}
//判断是否启用搜索框
//判断下拉数据,如果查询出来的条数达到启用搜索的数量就启用
if(list.size()>=searchnum){
html.append("class=\"form-control chosen-select\" style=\"width:"+width+"px\" tabindex=\"1\" \r\n");
} else{
html.append("class=\"form-control\" style=\"width:"+width+"px\" \r\n");
}
//判断控件是否只读
if("true".equals(readonly)||"readonly".equals(readonly)) {
if(list.size()>=searchnum) {
html.append("disabled=\"disabled\" ");
}else{
html.append("onfocus=\"this.defaultIndex=this.selectedIndex;\" onchange=\"this.selectedIndex=this.defaultIndex;\" ");
}
}
//判断是否绑定onchange事件
if(ToolUtil.isNotEmpty(onchange)){
html.append("onchange=\""+onchange+"($(this).children('option:selected').val())\" ");
}
html.append(">");
if(ToolUtil.isNotEmpty(placeholder)){
html.append("<option value=\"\">"+placeholder+"</option>\r\n");
}
//将查询出来的数据添加到select中
list.forEach(obj->{
if(ToolUtil.isNotEmpty(value)&&value.equals(obj.getCode())){
html.append("<option selected value=\""+obj.getCode()+"\">"+obj.getName()+"</option>\r\n");
}else{
html.append("<option value=\""+obj.getCode()+"\">"+obj.getName()+"</option>\r\n");
}
});
html.append("</select>\r\n");
}
html.append("</div>\r\n</div>\r\n");
//判断是否添加分割线
if(ToolUtil.isNotEmpty(underline) && "true".equals(underline)) {
html.append("<div class=\"hr-line-dashed\" ></div >\r\n");
}
try{
this.ctx.byteWriter.writeString(html.toString());
}catch (IOException e){
throw new RuntimeException("输出字典标签错误");
}
}
}
...@@ -79,11 +79,11 @@ public class DictController extends BaseController { ...@@ -79,11 +79,11 @@ public class DictController extends BaseController {
@RequestMapping(value = "/add") @RequestMapping(value = "/add")
@Permission(Const.ADMIN_NAME) @Permission(Const.ADMIN_NAME)
@ResponseBody @ResponseBody
public Object add(String dictName, String dictValues) { public Object add(String dictCode,String dictTips,String dictName, String dictValues) {
if (ToolUtil.isOneEmpty(dictName, dictValues)) { if (ToolUtil.isOneEmpty(dictCode,dictName, dictValues)) {
throw new GunsException(BizExceptionEnum.REQUEST_NULL); throw new GunsException(BizExceptionEnum.REQUEST_NULL);
} }
this.dictService.addDict(dictName, dictValues); this.dictService.addDict(dictCode,dictName,dictTips,dictValues);
return SUCCESS_TIP; return SUCCESS_TIP;
} }
...@@ -115,11 +115,11 @@ public class DictController extends BaseController { ...@@ -115,11 +115,11 @@ public class DictController extends BaseController {
@RequestMapping(value = "/update") @RequestMapping(value = "/update")
@Permission(Const.ADMIN_NAME) @Permission(Const.ADMIN_NAME)
@ResponseBody @ResponseBody
public Object update(Integer dictId, String dictName, String dictValues) { public Object update(Integer dictId,String dictCode,String dictName, String dictTips,String dictValues) {
if (ToolUtil.isOneEmpty(dictId, dictName, dictValues)) { if (ToolUtil.isOneEmpty(dictId, dictCode, dictName, dictValues)) {
throw new GunsException(BizExceptionEnum.REQUEST_NULL); throw new GunsException(BizExceptionEnum.REQUEST_NULL);
} }
dictService.editDict(dictId, dictName, dictValues); dictService.editDict(dictId, dictCode,dictName, dictTips,dictValues);
return SUCCESS_TIP; return SUCCESS_TIP;
} }
......
...@@ -26,4 +26,9 @@ public interface DictMapper extends BaseMapper<Dict> { ...@@ -26,4 +26,9 @@ public interface DictMapper extends BaseMapper<Dict> {
* 查询字典列表 * 查询字典列表
*/ */
List<Map<String, Object>> list(@Param("condition") String conditiion); List<Map<String, Object>> list(@Param("condition") String conditiion);
/**
* 根据父类编码获取词典列表
*/
List<Dict> selectByParentCode(@Param("code") String code);
} }
\ No newline at end of file
...@@ -8,11 +8,12 @@ ...@@ -8,11 +8,12 @@
<result column="num" property="num"/> <result column="num" property="num"/>
<result column="pid" property="pid"/> <result column="pid" property="pid"/>
<result column="name" property="name"/> <result column="name" property="name"/>
<result column="code" property="code"/>
<result column="tips" property="tips"/> <result column="tips" property="tips"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, num, pid, name, tips id, num, pid, name,code,tips
</sql> </sql>
<select id="selectByCode" resultType="dict"> <select id="selectByCode" resultType="dict">
...@@ -22,6 +23,13 @@ ...@@ -22,6 +23,13 @@
where code = #{code} where code = #{code}
</select> </select>
<select id="selectByParentCode" resultType="dict">
select
<include refid="Base_Column_List"/>
from sys_dict
where pid in(select id from sys_dict where code = #{code}) order by num asc
</select>
<select id="list" resultType="map"> <select id="list" resultType="map">
select * from sys_dict select * from sys_dict
where pid = 0 where pid = 0
......
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotations.TableId; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType; import com.baomidou.mybatisplus.enums.IdType;
import java.io.Serializable; import java.io.Serializable;
/** /**
...@@ -18,28 +19,33 @@ import java.io.Serializable; ...@@ -18,28 +19,33 @@ import java.io.Serializable;
@TableName("sys_dict") @TableName("sys_dict")
public class Dict extends Model<Dict> { public class Dict extends Model<Dict> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 主键id * 主键id
*/ */
@TableId(value="id", type= IdType.AUTO) @TableId(value="id", type= IdType.AUTO)
private Integer id; private Integer id;
/** /**
* 排序 * 排序
*/ */
private Integer num; private Integer num;
/** /**
* 父级字典 * 父级字典
*/ */
private Integer pid; private Integer pid;
/** /**
* 名称 * 名称
*/ */
private String name; private String name;
/**
* 提示 /**
*/ * 编码
*/
private String code;
/**
* 提示
*/
private String tips; private String tips;
...@@ -88,14 +94,23 @@ public class Dict extends Model<Dict> { ...@@ -88,14 +94,23 @@ public class Dict extends Model<Dict> {
return this.id; return this.id;
} }
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@Override @Override
public String toString() { public String toString() {
return "Dict{" + return "Dict{" +
"id=" + id + "id=" + id +
", num=" + num + ", num=" + num +
", pid=" + pid + ", pid=" + pid +
", name=" + name + ", name='" + name + '\'' +
", tips=" + tips + ", code='" + code + '\'' +
"}"; ", tips='" + tips + '\'' +
'}';
} }
} }
...@@ -18,12 +18,12 @@ public interface IDictService extends IService<Dict> { ...@@ -18,12 +18,12 @@ public interface IDictService extends IService<Dict> {
/** /**
* 添加字典 * 添加字典
*/ */
void addDict(String dictName, String dictValues); void addDict(String dictCode,String dictName,String dictTips, String dictValues);
/** /**
* 编辑字典 * 编辑字典
*/ */
void editDict(Integer dictId, String dictName, String dicts); void editDict(Integer dictId,String dictCode, String dictName,String dictTips, String dicts);
/** /**
* 删除字典 * 删除字典
...@@ -36,6 +36,11 @@ public interface IDictService extends IService<Dict> { ...@@ -36,6 +36,11 @@ public interface IDictService extends IService<Dict> {
List<Dict> selectByCode(@Param("code") String code); List<Dict> selectByCode(@Param("code") String code);
/** /**
* 根据父类编码获取词典列表
*/
List<Dict> selectByParentCode(@Param("code") String code);
/**
* 查询字典列表 * 查询字典列表
*/ */
List<Map<String, Object>> list(@Param("condition") String conditiion); List<Map<String, Object>> list(@Param("condition") String conditiion);
......
...@@ -25,9 +25,9 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID ...@@ -25,9 +25,9 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID
private DictMapper dictMapper; private DictMapper dictMapper;
@Override @Override
public void addDict(String dictName, String dictValues) { public void addDict(String dictCode,String dictName,String dictTips, String dictValues) {
//判断有没有该字典 //判断有没有该字典
List<Dict> dicts = dictMapper.selectList(new EntityWrapper<Dict>().eq("name", dictName).and().eq("pid", 0)); List<Dict> dicts = dictMapper.selectList(new EntityWrapper<Dict>().eq("code", dictCode).and().eq("pid", 0));
if (dicts != null && dicts.size() > 0) { if (dicts != null && dicts.size() > 0) {
throw new GunsException(BizExceptionEnum.DICT_EXISTED); throw new GunsException(BizExceptionEnum.DICT_EXISTED);
} }
...@@ -38,17 +38,22 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID ...@@ -38,17 +38,22 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID
//添加字典 //添加字典
Dict dict = new Dict(); Dict dict = new Dict();
dict.setName(dictName); dict.setName(dictName);
dict.setCode(dictCode);
dict.setTips(dictTips);
dict.setNum(0); dict.setNum(0);
dict.setPid(0); dict.setPid(0);
this.dictMapper.insert(dict); this.dictMapper.insert(dict);
//添加字典条目 //添加字典条目
for (Map<String, String> item : items) { for (Map<String, String> item : items) {
String num = item.get(MUTI_STR_KEY); String code = item.get(MUTI_STR_CODE);
String name = item.get(MUTI_STR_VALUE); String name = item.get(MUTI_STR_NAME);
String num = item.get(MUTI_STR_NUM);
Dict itemDict = new Dict(); Dict itemDict = new Dict();
itemDict.setPid(dict.getId()); itemDict.setPid(dict.getId());
itemDict.setCode(code);
itemDict.setName(name); itemDict.setName(name);
try { try {
itemDict.setNum(Integer.valueOf(num)); itemDict.setNum(Integer.valueOf(num));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
...@@ -59,12 +64,12 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID ...@@ -59,12 +64,12 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID
} }
@Override @Override
public void editDict(Integer dictId, String dictName, String dicts) { public void editDict(Integer dictId,String dictCode, String dictName,String dictTips, String dicts) {
//删除之前的字典 //删除之前的字典
this.delteDict(dictId); this.delteDict(dictId);
//重新添加新的字典 //重新添加新的字典
this.addDict(dictName, dicts); this.addDict(dictCode,dictName,dictTips, dicts);
} }
@Override @Override
...@@ -84,6 +89,12 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID ...@@ -84,6 +89,12 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID
} }
@Override @Override
public List<Dict> selectByParentCode(String code) {
return this.baseMapper.selectByParentCode(code);
}
@Override
public List<Map<String, Object>> list(String conditiion) { public List<Map<String, Object>> list(String conditiion) {
return this.baseMapper.list(conditiion); return this.baseMapper.list(conditiion);
} }
......
...@@ -23,11 +23,11 @@ public class DictWarpper extends BaseControllerWarpper { ...@@ -23,11 +23,11 @@ public class DictWarpper extends BaseControllerWarpper {
@Override @Override
public void warpTheMap(Map<String, Object> map) { public void warpTheMap(Map<String, Object> map) {
StringBuffer detail = new StringBuffer(); StringBuffer detail = new StringBuffer();
Integer id = (Integer) map.get("id"); Integer id = Integer.valueOf(map.get("id").toString());
List<Dict> dicts = ConstantFactory.me().findInDict(id); List<Dict> dicts = ConstantFactory.me().findInDict(id);
if(dicts != null){ if(dicts != null){
for (Dict dict : dicts) { for (Dict dict : dicts) {
detail.append(dict.getNum() + ":" +dict.getName() + ","); detail.append(dict.getCode() + ":" +dict.getName() + ",");
} }
map.put("detail", ToolUtil.removeSuffix(detail.toString(),",")); map.put("detail", ToolUtil.removeSuffix(detail.toString(),","));
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<link rel="shortcut icon" href="${ctxPath}/static/favicon.ico"> <link rel="shortcut icon" href="${ctxPath}/static/favicon.ico">
<link href="${ctxPath}/static/css/bootstrap.min.css?v=3.3.6" rel="stylesheet"> <link href="${ctxPath}/static/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="${ctxPath}/static/css/font-awesome.css?v=4.4.0" rel="stylesheet"> <link href="${ctxPath}/static/css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="${ctxPath}/static/css/plugins/chosen/chosen.css" rel="stylesheet">
<link href="${ctxPath}/static/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet"> <link href="${ctxPath}/static/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="${ctxPath}/static/css/plugins/validate/bootstrapValidator.min.css" rel="stylesheet"> <link href="${ctxPath}/static/css/plugins/validate/bootstrapValidator.min.css" rel="stylesheet">
<link href="${ctxPath}/static/css/animate.css" rel="stylesheet"> <link href="${ctxPath}/static/css/animate.css" rel="stylesheet">
...@@ -33,6 +34,7 @@ ...@@ -33,6 +34,7 @@
<script src="${ctxPath}/static/js/plugins/jquery-treegrid/js/jquery.treegrid.bootstrap3.js"></script> <script src="${ctxPath}/static/js/plugins/jquery-treegrid/js/jquery.treegrid.bootstrap3.js"></script>
<script src="${ctxPath}/static/js/plugins/jquery-treegrid/extension/jquery.treegrid.extension.js"></script> <script src="${ctxPath}/static/js/plugins/jquery-treegrid/extension/jquery.treegrid.extension.js"></script>
<script src="${ctxPath}/static/js/plugins/layer/layer.min.js"></script> <script src="${ctxPath}/static/js/plugins/layer/layer.min.js"></script>
<script src="${ctxPath}/static/js/plugins/chosen/chosen.jquery.js"></script>
<script src="${ctxPath}/static/js/plugins/iCheck/icheck.min.js"></script> <script src="${ctxPath}/static/js/plugins/iCheck/icheck.min.js"></script>
<script src="${ctxPath}/static/js/plugins/layer/laydate/laydate.js"></script> <script src="${ctxPath}/static/js/plugins/layer/laydate/laydate.js"></script>
<script src="${ctxPath}/static/js/plugins/webuploader/webuploader.min.js"></script> <script src="${ctxPath}/static/js/plugins/webuploader/webuploader.min.js"></script>
......
1 dictSelector(字典选择器)
此标签是为了方便在前台form表单中使用系统中维护的字典而开发的,具体说明如下:
1.1 标签样例
<#dictSelector id="sex" name ="sex" code="sys_sex" readonly="readonly" label="性别" underline="true" value="${user.sex}" />
1.2 属性说明
id: (非必须) 控件的id
name: (非必须) 控件的name
code:(必须) 字典类型编码,根据code的值去后台查询该类型的字典。
type:(非必须) 控件类型,可选项为[select,radio,checkbox],标签会根据填写的类型,生成不同的控件。
searchnum:(非必须)下拉框达到多少个,开启搜索框,默认10个,type为select起效。
label:(非必须) 字典属性名称
width:(非必须) 控件的宽度单位为px,type为select起效。
value: (非必须) 控件默认值,多选时值要用,分隔。
placeholder:(非必须) 控件提示信息,type为select起效。
multiple:(非必须) 是否开启多选,可选值[true,false],默认为false,type为select起效。
underline:(非必须) 是否显示分割线,可选值[true,false],默认为false。
onchange:(非必须) onchange事件方法名称,会传入更改后的值作为参数,例:onchange="myOnChange" function myOnChange(newVal){}。
readonly:(非必须)只读控件,可选值[true,false],默认false
disabled:(非必须) 禁用控件,可选值[true,false],默认false
...@@ -8,14 +8,25 @@ ...@@ -8,14 +8,25 @@
<div class="row"> <div class="row">
<div class="col-sm-12" id="itemsArea"> <div class="col-sm-12" id="itemsArea">
<div class="form-group"> <div class="form-group">
<label class="col-sm-2 control-label">字典名称</label> <label class="col-sm-2 control-label">类型编码</label>
<div class="col-sm-2">
<input class="form-control" id="dictCode" type="text">
</div>
<label class="col-sm-2 control-label">类型名称</label>
<div class="col-sm-2"> <div class="col-sm-2">
<input class="form-control" id="dictName" type="text"> <input class="form-control" id="dictName" type="text">
</div> </div>
<div class="col-sm-2"> <div class="col-sm-2">
<#button btnCss="info" name="增加" icon="fa-plus" clickFun="DictInfoDlg.addItem()"/> <#button btnCss="info" name="增加" icon="fa-plus" clickFun="DictInfoDlg.addItem()"/>
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-sm-2 control-label">备注</label>
<div class="col-sm-8">
<input class="form-control" id="dictTips" type="text">
</div>
</div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
</div> </div>
...@@ -31,19 +42,23 @@ ...@@ -31,19 +42,23 @@
<script type="text/template" id="itemTemplate"> <script type="text/template" id="itemTemplate">
<div class="form-group" name="dictItem" id="dictItem"> <div class="form-group" name="dictItem" id="dictItem">
<label class="col-sm-2 control-label"></label> <label class="col-sm-1 control-label"></label>
<div class="col-sm-2"> <div class="col-sm-2">
<input class="form-control" type="text" name="itemNum"> <input class="form-control" type="text" name="itemCode">
</div> </div>
<label class="col-sm-2 control-label" style="width: 8%;">名称</label> <label class="col-sm-1 control-label" >名称</label>
<div class="col-sm-2"> <div class="col-sm-2">
<input class="form-control" type="text" name="itemName"> <input class="form-control" type="text" name="itemName">
</div> </div>
<div class="col-sm-4"> <label class="col-sm-1 control-label" >序号</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="itemNum">
</div>
<div class="col-sm-2">
<#button btnCss="danger" name="删除" id="cancel" icon="fa-remove" clickFun="DictInfoDlg.deleteItem(event)"/> <#button btnCss="danger" name="删除" id="cancel" icon="fa-remove" clickFun="DictInfoDlg.deleteItem(event)"/>
</div> </div>
</div> </div>
</script> </script>
<script src="${ctxPath}/static/modular/system/dict/dict_info.js"></script> <script src="${ctxPath}/static/modular/system/dict/dict_info.js"></script>
@} @}
\ No newline at end of file \ No newline at end of file
...@@ -9,57 +9,78 @@ ...@@ -9,57 +9,78 @@
<div class="col-sm-12" id="itemsArea"> <div class="col-sm-12" id="itemsArea">
<input type="hidden" id="itemSize" value="${subDicts.~size!0}" /> <input type="hidden" id="itemSize" value="${subDicts.~size!0}" />
<div class="form-group"> <div class="form-group">
<label class="col-sm-2 control-label">字典名称</label>
<label class="col-sm-2 control-label">类型编码</label>
<div class="col-sm-2">
<input class="form-control" id="dictCode" type="text" value="${dict.code}">
</div>
<label class="col-sm-2 control-label">类型名称</label>
<div class="col-sm-2"> <div class="col-sm-2">
<input class="form-control" id="dictName" type="text" value="${dict.name}"> <input class="form-control" id="dictName" type="text" value="${dict.name}">
<input type="hidden" id="dictId" value="${dict.id}"> <input type="hidden" id="dictId" value="${dict.id}">
</div> </div>
<div class="col-sm-2"> <div class="col-sm-2">
<#button btnCss="info" name="增加" icon="fa-plus" clickFun="DictInfoDlg.addItem()"/> <#button btnCss="info" name="增加" icon="fa-plus" clickFun="DictInfoDlg.addItem()"/>
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-sm-2 control-label">备注</label>
<div class="col-sm-8">
<input class="form-control" id="dictTips" type="text" value="${dict.tips}">
</div>
</div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
@for(item in subDicts){ @for(item in subDicts){
<div class="form-group" name="dictItem" id="dictItem${itemLP.index}"> <div class="form-group" name="dictItem" id="dictItem${itemLP.index}">
<label class="col-sm-2 control-label"></label> <label class="col-sm-1 control-label"></label>
<div class="col-sm-2"> <div class="col-sm-2">
<input class="form-control" type="text" name="itemNum" value="${item.num}"> <input class="form-control" type="text" name="itemCode" value="${item.code}">
</div> </div>
<label class="col-sm-2 control-label" style="width: 8%;">名称</label> <label class="col-sm-1 control-label" >名称</label>
<div class="col-sm-2"> <div class="col-sm-2">
<input class="form-control" type="text" name="itemName" value="${item.name}"> <input class="form-control" type="text" name="itemName" value="${item.name}">
</div> </div>
<div class="col-sm-4"> <label class="col-sm-1 control-label" >序号</label>
<#button btnCss="danger" name="删除" id="cancel" icon="fa-remove" clickFun="DictInfoDlg.deleteItem(event)"/> <div class="col-sm-2">
</div> <input class="form-control" type="text" name="itemNum" value="${item.num}">
</div> </div>
<div class="col-sm-2">
<#button btnCss="danger" name="删除" id="cancel" icon="fa-remove" clickFun="DictInfoDlg.deleteItem(event)"/>
</div>
</div>
@} @}
</input> </input>
</div> </div>
<div class="row btn-group-m-t"> <div class="row btn-group-m-t">
<div class="col-sm-10"> <div class="col-sm-10">
<#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="DictInfoDlg.editSubmit()"/> <#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="DictInfoDlg.editSubmit()"/>
<#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="DictInfoDlg.close()"/> <#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="DictInfoDlg.close()"/>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
<script type="text/template" id="itemTemplate"> <script type="text/template" id="itemTemplate">
<div class="form-group" name="dictItem" id="dictItem"> <div class="form-group" name="dictItem" id="dictItem">
<label class="col-sm-2 control-label"></label> <label class="col-sm-1 control-label"></label>
<div class="col-sm-2"> <div class="col-sm-2">
<input class="form-control" type="text" name="itemNum"> <input class="form-control" type="text" name="itemCode">
</div> </div>
<label class="col-sm-2 control-label" style="width: 8%;">名称</label> <label class="col-sm-1 control-label" >名称</label>
<div class="col-sm-2"> <div class="col-sm-2">
<input class="form-control" type="text" name="itemName"> <input class="form-control" type="text" name="itemName">
</div> </div>
<div class="col-sm-4"> <label class="col-sm-1 control-label" >序号</label>
<#button btnCss="danger" name="删除" id="cancel" icon="fa-remove" clickFun="DictInfoDlg.deleteItem(event)"/> <div class="col-sm-2">
<input class="form-control" type="text" name="itemNum">
</div>
<div class="col-sm-2">
<#button btnCss="danger" name="删除" id="cancel" icon="fa-remove" clickFun="DictInfoDlg.deleteItem(event)"/>
</div>
</div> </div>
</div> </script>
</script>
<script src="${ctxPath}/static/modular/system/dict/dict_info.js"></script> <script src="${ctxPath}/static/modular/system/dict/dict_info.js"></script>
@} @}
\ No newline at end of file \ No newline at end of file
...@@ -2,36 +2,34 @@ ...@@ -2,36 +2,34 @@
<div class="ibox float-e-margins"> <div class="ibox float-e-margins">
<div class="ibox-content"> <div class="ibox-content">
<div class="form-horizontal" id="userInfoForm"> <div class="form-horizontal" id="userInfoForm">
<input type="hidden" id="id" value=""> <input type="hidden" id="id" value="">
<div class="row"> <div class="row">
<div class="col-sm-6 b-r"> <div class="col-sm-6 b-r">
<#input id="account" name="账户" underline="true"/> <#input id="account" name="账户" underline="true"/>
<#select id="sex" name="性别" underline="true"> <#dictSelector id="sex" name ="sex" code="sys_sex" label="性别" underline="true" placeholder="-请选择-" />
<option value="1"></option>
<option value="2"></option>
</#select>
<#input id="password" name="密码" underline="true" type="password"/> <#input id="password" name="密码" underline="true" type="password"/>
<#input id="roleid" name="角色" underline="true" disabled="disabled"/> <#input id="roleid" name="角色" underline="true" disabled="disabled"/>
<#input id="email" name="邮箱" type="email"/> <#input id="email" name="邮箱" type="email"/>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div id="driverInfoContent"> <div id="driverInfoContent">
<#input id="name" name="姓名" underline="true"/> <#input id="name" name="姓名" underline="true"/>
<#input id="birthday" name="出生日期" underline="true" type="date" <#input id="birthday" name="出生日期" underline="true" type="date"
clickFun="laydate({istime: false, format: 'YYYY-MM-DD'})"/> clickFun="laydate({istime: false, format: 'YYYY-MM-DD'})"/>
<#input id="rePassword" name="确认密码" type="password" underline="true"/> <#input id="rePassword" name="确认密码" type="password" underline="true"/>
<#input id="citySel" name="部门" underline="true" readonly="readonly" hidden="deptid" <#input id="citySel" name="部门" underline="true" readonly="readonly" hidden="deptid"
clickFun="UserInfoDlg.showDeptSelectTree(); return false;" clickFun="UserInfoDlg.showDeptSelectTree(); return false;"
style="background-color: #ffffff !important;"/> style="background-color: #ffffff !important;"/>
<#input id="phone" name="电话"/> <#input id="phone" name="电话"/>
</div> </div>
...@@ -40,7 +38,7 @@ ...@@ -40,7 +38,7 @@
<!-- 这是部门选择的下拉框 --> <!-- 这是部门选择的下拉框 -->
<div id="menuContent" class="menuContent" <div id="menuContent" class="menuContent"
style="display: none; position: absolute; z-index: 200;"> style="display: none; position: absolute; z-index: 200;">
<ul id="treeDemo" class="ztree tree-box" style="width: 249px !important;"></ul> <ul id="treeDemo" class="ztree tree-box" style="width: 249px !important;"></ul>
</div> </div>
......
...@@ -2,19 +2,14 @@ ...@@ -2,19 +2,14 @@
<div class="ibox float-e-margins"> <div class="ibox float-e-margins">
<div class="ibox-content"> <div class="ibox-content">
<div class="form-horizontal" id="userInfoForm"> <div class="form-horizontal" id="userInfoForm">
<input type="hidden" id="id" value="${user.id}"> <input type="hidden" id="id" value="${user.id}">
<input type="hidden" id="sexValue" value="${user.sex}">
<div class="row"> <div class="row">
<div class="col-sm-6 b-r"> <div class="col-sm-6 b-r">
<#input id="account" name="账户" underline="true" value="${user.account}"/> <#input id="account" name="账户" underline="true" value="${user.account}"/>
<#select id="sex" name="性别" underline="true"> <#dictSelector id="sex" name ="sex" code="sys_sex" label="性别" underline="true" value="${user.sex}" />
<option value="1"></option>
<option value="2"></option>
</#select>
<#input id="roleid" name="角色" underline="true" value="${roleName}" disabled="disabled"/> <#input id="roleid" name="角色" underline="true" value="${roleName}" disabled="disabled"/>
...@@ -25,12 +20,12 @@ ...@@ -25,12 +20,12 @@
<#input id="name" name="姓名" underline="true" value="${user.name}"/> <#input id="name" name="姓名" underline="true" value="${user.name}"/>
<#input id="birthday" name="出生日期" underline="true" type="date" <#input id="birthday" name="出生日期" underline="true" type="date"
value="${user.birthday}" value="${user.birthday}"
clickFun="laydate({istime: false, format: 'YYYY-MM-DD'})" /> clickFun="laydate({istime: false, format: 'YYYY-MM-DD'})" />
<#input id="citySel" name="部门" underline="true" readonly="readonly" hidden="deptid" hiddenValue="${user.deptid}" value="${deptName}" <#input id="citySel" name="部门" underline="true" readonly="readonly" hidden="deptid" hiddenValue="${user.deptid}" value="${deptName}"
clickFun="UserInfoDlg.showDeptSelectTree(); return false;" clickFun="UserInfoDlg.showDeptSelectTree(); return false;"
style="background-color: #ffffff !important;"/> style="background-color: #ffffff !important;"/>
<#input id="phone" name="电话" value="${user.phone}"/> <#input id="phone" name="电话" value="${user.phone}"/>
</div> </div>
...@@ -39,7 +34,7 @@ ...@@ -39,7 +34,7 @@
<!-- 这是部门选择的下拉框 --> <!-- 这是部门选择的下拉框 -->
<div id="menuContent" class="menuContent" <div id="menuContent" class="menuContent"
style="display: none; position: absolute; z-index: 200;"> style="display: none; position: absolute; z-index: 200;">
<ul id="treeDemo" class="ztree tree-box" style="width: 249px !important;"></ul> <ul id="treeDemo" class="ztree tree-box" style="width: 249px !important;"></ul>
</div> </div>
......
...@@ -20,10 +20,7 @@ ...@@ -20,10 +20,7 @@
<#input id="account" name="账户" underline="true" value="${user.account}" disabled="disabled" /> <#input id="account" name="账户" underline="true" value="${user.account}" disabled="disabled" />
<#select id="sex" name="性别" underline="true" value="${user.sex}"> <#dictSelector id="sex" name ="sex" readonly="true" code="sys_sex" label="性别" underline="true" value="${user.sex}" />
<option value="1"></option>
<option value="2"></option>
</#select>
<#input id="roleid" name="角色" underline="true" value="${roleName}" disabled="disabled"/> <#input id="roleid" name="角色" underline="true" value="${roleName}" disabled="disabled"/>
......
...@@ -70,3 +70,29 @@ function WinMove() { ...@@ -70,3 +70,29 @@ function WinMove() {
}) })
.disableSelection(); .disableSelection();
}; };
$(function () {
//初始化下拉框
var config = {
'.chosen-select': {},
'.chosen-select-deselect': {
allow_single_deselect: true
},
'.chosen-select-no-single': {
disable_search_threshold: 10
},
'.chosen-select-no-results': {
no_results_text: '没有要显示的数据!'
},
'.chosen-select-width': {
width: "95%"
}
}
for (var selector in config) {
$(selector).chosen(config[selector]);
}
$('.i-checks').iCheck({
checkboxClass: 'icheckbox_square-green',
radioClass: 'iradio_square-green',
});
});
\ No newline at end of file
...@@ -87,7 +87,7 @@ $(function () { ...@@ -87,7 +87,7 @@ $(function () {
$("#pcodeTree").css('width',$("#parentMenuName").css('width')); $("#pcodeTree").css('width',$("#parentMenuName").css('width'));
}); });
Code.set = function (key, val) { Code.set = function (key, value) {
Code.submitData[key] = (typeof value == "undefined") ? $("#" + key).val() : value; Code.submitData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
return this; return this;
}; };
\ No newline at end of file
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
var DictInfoDlg = { var DictInfoDlg = {
count: $("#itemSize").val(), count: $("#itemSize").val(),
dictName: '', //字典的名称 dictName: '', //字典的名称
dictCode: '',//字典类型编码
dictTips: '',//字典备注
mutiString: '', //拼接字符串内容(拼接字典条目) mutiString: '', //拼接字符串内容(拼接字典条目)
itemTemplate: $("#itemTemplate").html() itemTemplate: $("#itemTemplate").html()
}; };
...@@ -63,11 +65,14 @@ DictInfoDlg.collectData = function () { ...@@ -63,11 +65,14 @@ DictInfoDlg.collectData = function () {
this.clearNullDom(); this.clearNullDom();
var mutiString = ""; var mutiString = "";
$("[name='dictItem']").each(function(){ $("[name='dictItem']").each(function(){
var num = $(this).find("[name='itemNum']").val(); var code = $(this).find("[name='itemCode']").val();
var name = $(this).find("[name='itemName']").val(); var name = $(this).find("[name='itemName']").val();
mutiString = mutiString + (num + ":" + name + ";"); var num = $(this).find("[name='itemNum']").val();
mutiString = mutiString + (code + ":" + name + ":"+ num+";");
}); });
this.dictName = $("#dictName").val(); this.dictName = $("#dictName").val();
this.dictCode = $("#dictCode").val();
this.dictTips = $("#dictTips").val();
this.mutiString = mutiString; this.mutiString = mutiString;
}; };
...@@ -86,6 +91,8 @@ DictInfoDlg.addSubmit = function () { ...@@ -86,6 +91,8 @@ DictInfoDlg.addSubmit = function () {
Feng.error("添加失败!" + data.responseJSON.message + "!"); Feng.error("添加失败!" + data.responseJSON.message + "!");
}); });
ajax.set('dictName',this.dictName); ajax.set('dictName',this.dictName);
ajax.set('dictCode',this.dictCode);
ajax.set('dictTips',this.dictTips);
ajax.set('dictValues',this.mutiString); ajax.set('dictValues',this.mutiString);
ajax.start(); ajax.start();
}; };
...@@ -104,6 +111,8 @@ DictInfoDlg.editSubmit = function () { ...@@ -104,6 +111,8 @@ DictInfoDlg.editSubmit = function () {
}); });
ajax.set('dictId',$("#dictId").val()); ajax.set('dictId',$("#dictId").val());
ajax.set('dictName',this.dictName); ajax.set('dictName',this.dictName);
ajax.set('dictCode',this.dictCode);
ajax.set('dictTips',this.dictTips);
ajax.set('dictValues',this.mutiString); ajax.set('dictValues',this.mutiString);
ajax.start(); ajax.start();
}; };
...@@ -56,7 +56,7 @@ MenuInfoDlg.clearData = function () { ...@@ -56,7 +56,7 @@ MenuInfoDlg.clearData = function () {
* @param key 数据的名称 * @param key 数据的名称
* @param val 数据的具体值 * @param val 数据的具体值
*/ */
MenuInfoDlg.set = function (key, val) { MenuInfoDlg.set = function (key, value) {
this.menuInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value; this.menuInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
return this; return this;
} }
......
...@@ -28,7 +28,7 @@ NoticeInfoDlg.clearData = function () { ...@@ -28,7 +28,7 @@ NoticeInfoDlg.clearData = function () {
* @param key 数据的名称 * @param key 数据的名称
* @param val 数据的具体值 * @param val 数据的具体值
*/ */
NoticeInfoDlg.set = function (key, val) { NoticeInfoDlg.set = function (key, value) {
this.noticeInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value; this.noticeInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
return this; return this;
} }
......
...@@ -43,7 +43,7 @@ RolInfoDlg.clearData = function () { ...@@ -43,7 +43,7 @@ RolInfoDlg.clearData = function () {
* @param key 数据的名称 * @param key 数据的名称
* @param val 数据的具体值 * @param val 数据的具体值
*/ */
RolInfoDlg.set = function (key, val) { RolInfoDlg.set = function (key, value) {
this.roleInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value; this.roleInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
return this; return this;
}; };
......
...@@ -63,8 +63,33 @@ UserInfoDlg.clearData = function () { ...@@ -63,8 +63,33 @@ UserInfoDlg.clearData = function () {
* @param key 数据的名称 * @param key 数据的名称
* @param val 数据的具体值 * @param val 数据的具体值
*/ */
UserInfoDlg.set = function (key, val) { UserInfoDlg.set = function (key, value) {
this.userInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value; if(typeof value == "undefined"){
if(typeof $("#" + key).val() =="undefined"){
var str="";
var ids="";
$("input[name='"+key+"']:checkbox").each(function(){
if(true == $(this).is(':checked')){
str+=$(this).val()+",";
}
});
if(str){
if(str.substr(str.length-1)== ','){
ids = str.substr(0,str.length-1);
}
}else{
$("input[name='"+key+"']:radio").each(function(){
if(true == $(this).is(':checked')){
ids=$(this).val()
}
});
}
this.userInfoData[key] = ids;
}else{
this.userInfoData[key]= $("#" + key).val();
}
}
return this; return this;
}; };
...@@ -254,8 +279,6 @@ $(function () { ...@@ -254,8 +279,6 @@ $(function () {
ztree.init(); ztree.init();
instance = ztree; instance = ztree;
//初始化性别选项
$("#sex").val($("#sexValue").val());
// 初始化头像上传 // 初始化头像上传
var avatarUp = new $WebUpload("avatar"); var avatarUp = new $WebUpload("avatar");
......
...@@ -26,14 +26,16 @@ public class DictTest extends BaseJunit { ...@@ -26,14 +26,16 @@ public class DictTest extends BaseJunit {
@Test @Test
public void addTest() { public void addTest() {
String dictName = "这是一个字典测试"; String dictCode = "test";
String dictValues = "1:测试1;2:测试2"; String dictName = "字典测试";
dictService.addDict(dictName, dictValues); String dictTips = "这是一个字典测试";
String dictValues = "1:测试1:1;2:测试2:2";
dictService.addDict(dictCode,dictName,dictTips, dictValues);
} }
@Test @Test
public void editTest() { public void editTest() {
dictService.editDict(16, "测试", "1:测试1;2:测试2"); dictService.editDict(16, "tes","测试","备注", "1:测试1;2:测试2");
} }
@Test @Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment