完成数据字典后台管理
This commit is contained in:
@@ -249,7 +249,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
{
|
||||
item.FilePath = entity.FilePath;
|
||||
}
|
||||
listArticles.BatchUpdate();
|
||||
listArticles.Update();
|
||||
}
|
||||
}
|
||||
Core.Admin.WriteLogActions("修改文章栏目(id:" + entity.Id + ");");
|
||||
|
||||
@@ -196,5 +196,83 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存字典值详情
|
||||
[HttpPost]
|
||||
[MyAuthorize("add", "datadictionary", "JSON")]
|
||||
public IActionResult DoSaveDataDictionaryDetail(DataDictionaryDetail model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Val))
|
||||
{
|
||||
tip.Message = "请输入字典值";
|
||||
return Json(tip);
|
||||
}
|
||||
if(model.DataDictionaryId == 0)
|
||||
{
|
||||
tip.Message = "请先选择一个字典进行查看后再编辑或者添加!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (model.Id == 0 && DataDictionaryDetail.FindCount(DataDictionaryDetail._.Val == model.Val & DataDictionaryDetail._.DataDictionaryId == model.DataDictionaryId, null, null, 0, 0) > 0)
|
||||
{
|
||||
tip.Message = "此字典值已经存在,请填写其他的!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (model.Id > 0 && DataDictionaryDetail.FindCount(DataDictionaryDetail._.Val == model.Val & DataDictionaryDetail._.DataDictionaryId == model.DataDictionaryId & DataDictionaryDetail._.Id != model.Id, null, null, 0, 0) > 0)
|
||||
{
|
||||
tip.Message = "此字典值已经存在,请填写其他的!";
|
||||
return Json(tip);
|
||||
}
|
||||
DataDictionaryDetail entity = null;
|
||||
string tipMessage = "";
|
||||
if (model.Id > 0)
|
||||
{
|
||||
entity = DataDictionaryDetail.Find(DataDictionaryDetail._.Id == model.Id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
return Json(tip);
|
||||
}
|
||||
tipMessage = "修改";
|
||||
}
|
||||
else
|
||||
{
|
||||
entity = new DataDictionaryDetail();
|
||||
entity.AddTime = DateTime.Now;
|
||||
entity.DataDictionaryId = model.DataDictionaryId;
|
||||
tipMessage = "添加";
|
||||
}
|
||||
entity.Val = model.Val;
|
||||
entity.Description = model.Description;
|
||||
entity.Title = model.Title;
|
||||
entity.IsDefault = model.IsDefault;
|
||||
entity.Rank = model.Rank;
|
||||
entity.Save();
|
||||
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = $"{tipMessage}数据字典成功!";
|
||||
Admin.WriteLogActions($"{tipMessage}数据字典成功({entity.Id});");
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除数据字典
|
||||
[HttpPost]
|
||||
[MyAuthorize("del", "datadictionary", "JSON")]
|
||||
public IActionResult DelDataDictionaryDetail(int id)
|
||||
{
|
||||
var entity = DataDictionaryDetail.Find(DataDictionaryDetail._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
Admin.WriteLogActions($"删除数据字典详情({entity.Id});");
|
||||
entity.Delete();
|
||||
|
||||
tip.Message = "删除数据字典值详情成功!";
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,8 @@
|
||||
{
|
||||
field: 'id',
|
||||
title: '操作',
|
||||
formatter: 'actionFormatter'
|
||||
formatter: 'actionFormatter',
|
||||
width:215
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -128,7 +129,7 @@
|
||||
function actionFormatter(value, row, index) {
|
||||
return [
|
||||
'<a href="javascript:;" class="btn btn-xs btn-primary" title="编辑" onclick="app.getDataDictionary(' + value + ')"><i class="fa fa-edit"></i> 编辑</a>',
|
||||
'<a href="javascript:;" class="btn btn-xs btn-success" title="编辑" onclick="app.getDataDictionaryDetail(' + value + ')"><i class="fa fa-edit"></i> 管理字典值</a>',
|
||||
'<a href="javascript:;" class="btn btn-xs btn-success m-l-xs" title="编辑" onclick="app.getDataDictionaryDetail(' + value + ')"><i class="fa fa-edit"></i> 管理字典值</a>',
|
||||
'<a href="javascript:;" class="btn btn-xs btn-danger m-l-xs" title="删除" onclick="doDel(\'/AdminCP/DataDictionary/DelDataDictionary\',' + value + ');"><i class="fa fa-close"></i> 删除</a>',
|
||||
].join('');
|
||||
}
|
||||
@@ -198,7 +199,7 @@
|
||||
<div class="ibox-content">
|
||||
<div v-show="showDetail">
|
||||
<div id="toolbar" class="btn-group">
|
||||
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="top.showDialog('addarticle','添加文章','/AdminCP/Article/AddArticle',0,0)">
|
||||
<button id="btn_add" type="button" class="btn btn-outline btn-default" v-on:click="addDetail">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
|
||||
</button>
|
||||
</div>
|
||||
@@ -212,24 +213,24 @@
|
||||
<th>是否默认</th>
|
||||
<th>说明</th>
|
||||
<th>添加时间</th>
|
||||
<th>操作</th>
|
||||
<th style="width:125px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(item,index) in detailList" v-bind:key="id">
|
||||
<td>{{item.id}}</td>
|
||||
<td>{{item.id}}</td>
|
||||
<td>{{item.id}}</td>
|
||||
<td>{{item.id}}</td>
|
||||
<td>{{item.id}}</td>
|
||||
<td>{{item.id}}</td>
|
||||
<tr v-for="(item,index) in detailList">
|
||||
<td>{{item.id}}</td>
|
||||
<td>{{item.val}}</td>
|
||||
<td>{{item.title}}</td>
|
||||
<td>{{item.rank}}</td>
|
||||
<td>{{item.isDefault==1?'是':'否'}}</td>
|
||||
<td>{{item.description}}</td>
|
||||
<td>{{item.addTime}}</td>
|
||||
<td>
|
||||
<button class="btn btn-primary btn-xm" v-on:click="doEditDetail(item)"><i class="fa fa-edit"></i> 编辑</button>
|
||||
<button class="btn btn-danger btn-sm" v-on:click="doDelDetail(item.id)"><i class="fa fa-close"></i> 删除</button>
|
||||
<button class="btn btn-primary btn-xs" v-on:click="doEditDetail(item)"><i class="fa fa-edit"></i> 编辑</button>
|
||||
<button class="btn btn-danger btn-xs" v-on:click="doDelDetail(item.id)"><i class="fa fa-close"></i> 删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="detailList.length>0">
|
||||
<tr v-if="detailList.length<=0">
|
||||
<td colspan="8">暂无记录</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -243,27 +244,43 @@
|
||||
<h3 class="m-t-none m-b">{{detailModel.id==0?'添加新数据字典值':'编辑数据字典值'}}</h3>
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">字典值Key:</label>
|
||||
<label class="col-sm-3 control-label">字典值(存放数据库):</label>
|
||||
<div class="col-sm-8">
|
||||
<input v-model="model.key" type="text" class="form-control" maxlength="250" placeholder="字典Key,请填写英文" aria-required="true">
|
||||
<input v-model="detailModel.val" type="text" class="form-control" maxlength="250" placeholder="字典值(存放数据库)" aria-required="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">字典说明:</label>
|
||||
<label class="col-sm-3 control-label">字典值标签名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input v-model="model.description" type="text" class="form-control" maxlength="250" placeholder="字典说明" aria-required="true">
|
||||
<input v-model="detailModel.title" type="text" class="form-control" maxlength="250" placeholder="字典值标签名称(显示)" aria-required="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">字典排序:</label>
|
||||
<label class="col-sm-3 control-label">是否默认值:</label>
|
||||
<div class="col-sm-8">
|
||||
<input v-model="model.rank" type="number" class="form-control" maxlength="250" placeholder="字典排序,越小越前,仅后台" aria-required="true">
|
||||
<input type="radio" id="y" value="1" v-model="detailModel.isDefault">
|
||||
<label for="y">是(将默认选中)</label>
|
||||
|
||||
<input type="radio" id="n" value="0" v-model="detailModel.isDefault">
|
||||
<label for="n">否</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">字典值排序:</label>
|
||||
<div class="col-sm-8">
|
||||
<input v-model="detailModel.rank" type="number" class="form-control" maxlength="250" placeholder="字典排序,越小越前" aria-required="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">字典值备注:</label>
|
||||
<div class="col-sm-8">
|
||||
<input v-model="detailModel.description" type="text" class="form-control" maxlength="250" placeholder="字典说明" aria-required="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-5 col-sm-offset-3">
|
||||
<input type="hidden" v-model="model.id" />
|
||||
<button class="btn btn-primary" type="button" v-on:click="doSaveDataDictionary"><i class="fa fa-save"></i> 确定 </button>
|
||||
<input type="hidden" v-model="detailModel.id" />
|
||||
<button class="btn btn-primary" type="button" v-on:click="doSaveDataDictionaryDetail"><i class="fa fa-save"></i> 确定 </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -289,7 +306,8 @@
|
||||
optTitle: '添加字典',
|
||||
showDetail: false,
|
||||
detailList: [],
|
||||
detailModel: {}
|
||||
detailModel: { dataDictionaryId: 0, id: 0, val: '', title: '', description: '', rank: 0, isDefault:0},
|
||||
dataDictId:0
|
||||
},
|
||||
methods: {
|
||||
getDataDictionary: function (id) {
|
||||
@@ -359,7 +377,7 @@
|
||||
});
|
||||
},
|
||||
getDataDictionaryDetail: function (id) {
|
||||
let that = this;
|
||||
var that = this;
|
||||
var loading = layer.load(0, {
|
||||
shade: [0.2, '#000'] //0.1透明度的背景
|
||||
});
|
||||
@@ -373,6 +391,7 @@
|
||||
layer.close(loading);
|
||||
that.showDetail = true;
|
||||
that.detailList = data.detail;
|
||||
that.dataDictId = id;
|
||||
} else {
|
||||
layer.close(loading);
|
||||
layer.alert(data.message, { icon: 2 });
|
||||
@@ -385,10 +404,85 @@
|
||||
});
|
||||
},
|
||||
doEditDetail: function (item) {
|
||||
|
||||
this.detailModel = item;
|
||||
$("#detailModal").modal('show');
|
||||
},
|
||||
doDelDetail: function (id) {
|
||||
var that = this;
|
||||
top.layer.confirm('确认要删除当前记录?此操作不可恢复!', {
|
||||
icon: 3,
|
||||
title: '系统提示',
|
||||
btn: ['确定', '取消 '] //按钮
|
||||
}, function () {
|
||||
var loading = layer.load(0, {
|
||||
shade: [0.2, '#000'] //0.1透明度的背景
|
||||
});
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/AdminCP/DataDictionary/DelDataDictionaryDetail",
|
||||
data: { id: id },
|
||||
dataType: "JSON",
|
||||
success: function (data) {
|
||||
if (data.status == "success") {
|
||||
layer.close(loading);
|
||||
that.getDataDictionaryDetail(that.dataDictId);
|
||||
} else {
|
||||
layer.close(loading);
|
||||
layer.alert(data.message, { icon: 2 });
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
layer.close(loading);
|
||||
layer.alert('执行错误,请联系管理员!', { icon: 2 });
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
});
|
||||
|
||||
},
|
||||
addDetail() {
|
||||
this.detailModel = { dataDictionaryId: this.dataDictId, id: 0, val: '', title: '', description: '', rank: 0, isDefault: 0 };
|
||||
$("#detailModal").modal('show');
|
||||
return;
|
||||
},
|
||||
doSaveDataDictionaryDetail: function () {
|
||||
var that = this;
|
||||
if (!that.detailModel.val) {
|
||||
alert('请输入字典值!');
|
||||
return;
|
||||
}
|
||||
if (!that.detailModel.title) {
|
||||
alert('请输入字典值标签名称!');
|
||||
return;
|
||||
}
|
||||
var loading = layer.load(0, {
|
||||
shade: [0.2, '#000'] //0.1透明度的背景
|
||||
});
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/AdminCP/DataDictionary/DoSaveDataDictionaryDetail",
|
||||
data: that.detailModel,
|
||||
dataType: "JSON",
|
||||
success: function (data) {
|
||||
if (data.status == "success") {
|
||||
layer.close(loading);
|
||||
layer.msg(data.message, {
|
||||
time: 1000 //2秒关闭(如果不配置,默认是3秒)
|
||||
}, function () {
|
||||
$('#detailModal').modal('hide');
|
||||
that.getDataDictionaryDetail(that.dataDictId);
|
||||
//$("#tb_departments").bootstrapTable('refresh');
|
||||
});
|
||||
} else {
|
||||
layer.close(loading);
|
||||
layer.alert(data.message, { icon: 2 });
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
layer.close(loading);
|
||||
layer.alert('执行错误,请联系管理员!', { icon: 2 });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -127,16 +127,16 @@
|
||||
<ul class="dropdown-menu dropdown-messages">
|
||||
<li class="m-t-xs">
|
||||
@*<div class="dropdown-messages-box">
|
||||
<a href="profile.html" class="pull-left">
|
||||
<img alt="image" class="img-circle" src="~/images/ratuologo.jpg">
|
||||
</a>
|
||||
<div class="media-body">
|
||||
<small class="pull-right">46小时前</small>
|
||||
<strong>小四</strong> 这个在日本投降书上签字的军官,建国后一定是个不小的干部吧?
|
||||
<br>
|
||||
<small class="text-muted">3天前 2014.11.8</small>
|
||||
</div>
|
||||
</div>*@
|
||||
<a href="profile.html" class="pull-left">
|
||||
<img alt="image" class="img-circle" src="~/images/ratuologo.jpg">
|
||||
</a>
|
||||
<div class="media-body">
|
||||
<small class="pull-right">46小时前</small>
|
||||
<strong>小四</strong> 这个在日本投降书上签字的军官,建国后一定是个不小的干部吧?
|
||||
<br>
|
||||
<small class="text-muted">3天前 2014.11.8</small>
|
||||
</div>
|
||||
</div>*@
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
@@ -154,33 +154,36 @@
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-alerts">
|
||||
@*<li>
|
||||
<a href="mailbox.html">
|
||||
<div>
|
||||
<i class="fa fa-envelope fa-fw"></i> 您有16条未读消息
|
||||
<span class="pull-right text-muted small">4分钟前</span>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<a href="profile.html">
|
||||
<div>
|
||||
<i class="fa fa-qq fa-fw"></i> 3条新回复
|
||||
<span class="pull-right text-muted small">12分钟钱</span>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<div class="text-center link-block">
|
||||
<a class="J_menuItem" href="notifications.html">
|
||||
<strong>查看所有 </strong>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
</li>*@
|
||||
<a href="mailbox.html">
|
||||
<div>
|
||||
<i class="fa fa-envelope fa-fw"></i> 您有16条未读消息
|
||||
<span class="pull-right text-muted small">4分钟前</span>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<a href="profile.html">
|
||||
<div>
|
||||
<i class="fa fa-qq fa-fw"></i> 3条新回复
|
||||
<span class="pull-right text-muted small">12分钟钱</span>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<div class="text-center link-block">
|
||||
<a class="J_menuItem" href="notifications.html">
|
||||
<strong>查看所有 </strong>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
</li>*@
|
||||
</ul>
|
||||
</li>
|
||||
<li class="hidden-xs">
|
||||
<a onclick="requestFullScreen(document.documentElement)" data-index="0"><i class="fa fa-arrows-alt"></i> 全屏</a>
|
||||
</li>
|
||||
<li class="hidden-xs" style="padding-right:20px">
|
||||
<a href="/" target="_blank" data-index="0"><i class="fa fa-home"></i> 站点首页</a>
|
||||
</li>
|
||||
@@ -406,7 +409,33 @@
|
||||
|
||||
<!-- 第三方插件 -->
|
||||
<script src="~/hplus/js/plugins/pace/pace.min.js"></script>
|
||||
<script>
|
||||
function requestFullScreen(element) {
|
||||
if (document.fullscreenElement) {
|
||||
if (document.exitFullscreen) {
|
||||
document.exitFullscreen();
|
||||
} else if (document.msExitFullscreen) {
|
||||
document.msExitFullscreen();
|
||||
} else if (document.mozCancelFullScreen) {
|
||||
document.mozCancelFullScreen();
|
||||
} else if (document.webkitExitFullscreen) {
|
||||
document.webkitExitFullscreen();
|
||||
}
|
||||
} else {
|
||||
var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;
|
||||
if (requestMethod) {
|
||||
requestMethod.call(element);
|
||||
} else if (typeof window.ActiveXObject !== "undefined") {
|
||||
var wscript = new ActiveXObject("WScript.Shell");
|
||||
if (wscript !== null) {
|
||||
wscript.SendKeys("{F11}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user