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

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

@ -7,7 +7,7 @@
Category: "dictCate",
Name: "dictName",
Code: "dictCode",
Define:"dictDefine"
Define: "dictDefine"
}
})
});
@ -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

@ -1,56 +1,68 @@
@model NavigatorBarModel
@{
ViewBag.Title = "字典表管理";
Layout = "~/Views/Shared/_Default.cshtml";
}
@section Javascript {
<script src="~/scripts/Dicts.js"></script>
}
@section header {
@Html.Partial("Header", Model)
}
@section navigator {
@Html.Partial("Navigator", Model)
}
@section query {
<form class="form-inline" role="form">
<div class="form-group col-lg-5">
<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" />
</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>
</div>
</form>
}
@section modal {
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">字典编辑窗口</h4>
</div>
<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>
<input type="text" class="form-control" id="dictCate" name="dictCate" maxlength="50" />
</div>
<div class="form-group col-lg-6">
<label class="control-label" for="dictName">字典名称</label>
<input type="text" class="form-control" id="dictName" name="dictName" maxlength="50" />
<input type="text" class="form-control hide" id="dictID" name="dictID" />
</div>
<div class="form-group col-lg-6">
<label class="control-label" for="dictCode">字典代码</label>
<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>
<input type="text" class="form-control" id="dictDefine" name="dictDefine" maxlength="50" />
</div>
</form>
</div>
@model NavigatorBarModel
@{
ViewBag.Title = "字典表管理";
Layout = "~/Views/Shared/_Default.cshtml";
}
@section Javascript {
<script src="~/scripts/Dicts.js"></script>
}
@section header {
@Html.Partial("Header", Model)
}
@section navigator {
@Html.Partial("Navigator", Model)
}
@section query {
<form class="form-inline" role="form">
<div class="form-group col-lg-5">
<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 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>
</div>
</form>
}
@section modal {
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">字典编辑窗口</h4>
</div>
<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>
<input type="text" class="form-control" id="dictCate" name="dictCate" maxlength="50" />
</div>
<div class="form-group col-lg-6">
<label class="control-label" for="dictName">字典名称</label>
<input type="text" class="form-control" id="dictName" name="dictName" maxlength="50" />
<input type="text" class="form-control hide" id="dictID" name="dictID" />
</div>
<div class="form-group col-lg-6">
<label class="control-label" for="dictCode">字典代码</label>
<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>
<input type="text" class="form-control" id="dictDefine" name="dictDefine" maxlength="50" />
</div>
</form>
</div>
}

View File

@ -1,37 +1,35 @@
namespace Bootstrap.DataAccess
{
/// <summary>
/// 字典表实体
/// author:renshuo
/// date:2016.10.27
/// </summary>
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
/// </summary>
public int Define { get; set; }
}
}
namespace Bootstrap.DataAccess
{
/// <summary>
/// 字典表实体
/// author:renshuo
/// date:2016.10.27
/// </summary>
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
/// </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]
});
}
}