字典表更改一些名称,字典类别使用下拉框

This commit is contained in:
Argo-Lenovo 2016-11-03 21:53:10 +08:00
parent 9d930457bd
commit 29798406b7
5 changed files with 114 additions and 103 deletions

View File

@ -13,7 +13,7 @@ namespace Bootstrap.Admin.Models
/// <summary>
/// 字典种类
/// </summary>
public string Category { get; set; }
public string Define { get; set; }
/// <summary>
/// 字典表查询
/// </summary>
@ -25,9 +25,9 @@ namespace Bootstrap.Admin.Models
{
data = data.Where(t => t.Name.Contains(Name));
}
if (!string.IsNullOrEmpty(Category))
if (!string.IsNullOrEmpty(Define))
{
data = data.Where(t => t.Category.Contains(Category));
data = data.Where(t => t.Define.ToString() == Define);
}
var ret = new QueryData<Dict>();
ret.total = data.Count();

View File

@ -15,13 +15,13 @@
$('table').smartTable({
url: '../api/Dicts', //请求后台的URL*
sortName: 'Category',
queryParams: function (params) { return $.extend(params, { name: $("#txt_dict_name").val(), category: $("#txt_dict_cate").val() }); },
queryParams: function (params) { return $.extend(params, { name: $("#txt_dict_name").val(), define: $("#txt_dict_cate").val() }); },
columns: [{ checkbox: true },
{ title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter },
{ title: "字典种类", field: "Category", sortable: true },
{ title: "字典名称", field: "Name", sortable: false },
{ title: "字典代码", field: "Code", sortable: true },
{ title: "字典定义", field: "Define", sortable: false }
{ title: "字典分项", field: "Category", sortable: true },
{ title: "字典名称", field: "Name", sortable: true },
{ title: "字典代码", field: "Code", sortable: false },
{ title: "字典类别", field: "DefineName", sortable: true }
]
});

View File

@ -15,12 +15,24 @@
@section query {
<form class="form-inline" role="form">
<div class="form-group col-lg-5">
<label class="control-label" for="txt_dict_name">字典名称</label>
<label class="control-label" for="txt_dict_name">字典分项</label>
<input type="text" class="form-control" id="txt_dict_name" />
</div>
<div class="form-group col-lg-5">
<label class="control-label" for="txt_dict_cate">字典种类</label>
<input type="text" class="form-control" id="txt_dict_cate" />
<label class="control-label" for="txt_dict_cate">字典类别</label>
<input type="text" class="form-control hide" id="txt_dict_cate" />
<div class="btn-group">
<button type="button" class="btn btn-default">未选择</button>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">下拉按钮</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#" data-val="">未选择</a></li>
<li><a href="#" data-val="1">自定义</a></li>
<li><a href="#" data-val="0">系统使用</a></li>
</ul>
</div>
</div>
<div class="form-group col-lg-2">
<button type="button" id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search" aria-hidden="true"></span>查询</button>
@ -35,7 +47,7 @@
<div class="modal-body">
<form class="form-inline" id="dataForm" name="dataForm" role="form">
<div class="form-group col-lg-6">
<label class="control-label" for="dictCate">字典种类</label>
<label class="control-label" for="dictCate">字典分项</label>
<input type="text" class="form-control" id="dictCate" name="dictCate" maxlength="50" />
</div>
<div class="form-group col-lg-6">
@ -48,7 +60,7 @@
<input type="text" class="form-control" id="dictCode" name="dictCode" maxlength="50" />
</div>
<div class="form-group col-lg-6">
<label class="control-label" for="dictDefine">字典定义</label>
<label class="control-label" for="dictDefine">字典类别</label>
<input type="text" class="form-control" id="dictDefine" name="dictDefine" maxlength="50" />
</div>
</form>

View File

@ -8,30 +8,28 @@
public class Dict
{
/// <summary>
/// 字典主键
/// 数据库自增
/// 字典主键 数据库自增
/// </summary>
public int ID { get; set; }
/// <summary>
/// 分类
/// </summary>
public string Category { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 代号
/// </summary>
public string Code { get; set; }
/// <summary>
/// 1表示系统使用0表示用户自定义
/// 默认为1
/// 1表示系统使用0表示用户自定义 默认为1
/// </summary>
public int Define { get; set; }
/// <summary>
/// 获得/设置 字典定义类别名称
/// </summary>
public string DefineName { get; set; }
}
}

View File

@ -23,7 +23,7 @@ namespace Bootstrap.DataAccess
{
var ret = CacheManager.GetOrAdd(DictDataKey, CacheSection.RetrieveIntervalByKey(DictDataKey), key =>
{
string sql = "select * from Dicts";
string sql = "select ID, Category, Name, Code, Define, case Define when 0 then '系统使用' else '用户自定义' end DefineName from Dicts";
List<Dict> Dicts = new List<Dict>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try
@ -38,7 +38,8 @@ namespace Bootstrap.DataAccess
Category = (string)reader[1],
Name = (string)reader[2],
Code = (string)reader[3],
Define = (int)reader[4]
Define = (int)reader[4],
DefineName = (string)reader[5]
});
}
}