mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
后台内容管理
This commit is contained in:
parent
e9890b771a
commit
a9afd0d23d
@ -25,7 +25,8 @@ namespace FreeSql.Site.DAL
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool Update(DocumentContent model)
|
public bool Update(DocumentContent model)
|
||||||
{
|
{
|
||||||
return DataBaseType.MySql.DB().Update<DocumentContent>(model.ID).ExecuteUpdated().Count > 0;
|
var runsql = DataBaseType.MySql.DB().Update<DocumentContent>().SetSource(model);
|
||||||
|
return runsql.ExecuteAffrows() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -30,6 +30,7 @@ namespace FreeSql.Site.Entity
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文档内容
|
/// 文档内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(DbType = "text")]
|
||||||
public string DocContent { get; set; }
|
public string DocContent { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -29,7 +29,6 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers
|
|||||||
this.DocumentContentDAL = new DocumentContentDAL();
|
this.DocumentContentDAL = new DocumentContentDAL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
DocumentContent model = new DocumentContent();
|
DocumentContent model = new DocumentContent();
|
||||||
@ -87,7 +86,8 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers
|
|||||||
DocumentContent model = new DocumentContent();
|
DocumentContent model = new DocumentContent();
|
||||||
if (!string.IsNullOrEmpty(id))
|
if (!string.IsNullOrEmpty(id))
|
||||||
{
|
{
|
||||||
model = DocumentContentDAL.GetByOne(w => w.ID == 1);
|
int _id = Convert.ToInt32(id);
|
||||||
|
model = DocumentContentDAL.GetByOne(w => w.ID == _id);
|
||||||
}
|
}
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
@ -108,6 +108,24 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers
|
|||||||
return Json(resdata);
|
return Json(resdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// POST: Documents/Create
|
||||||
|
[HttpPost]
|
||||||
|
//[ValidateAntiForgeryToken]
|
||||||
|
public ActionResult DocContentUpdate([FromBody]DocumentContent model)
|
||||||
|
{
|
||||||
|
var resdata = AutoException.Excute<bool>((result) =>
|
||||||
|
{
|
||||||
|
model.UpdateBy = "admin";
|
||||||
|
model.UpdateDt = DateTime.Now;
|
||||||
|
result.Data = DocumentContentDAL.Update(model);
|
||||||
|
if (result.Data == false)
|
||||||
|
{
|
||||||
|
throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
return Json(resdata);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
public ActionResult DocContentDelete(int id, IFormCollection collection)
|
public ActionResult DocContentDelete(int id, IFormCollection collection)
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
<script type="text/html" id="toolbarDemo">
|
<script type="text/html" id="toolbarDemo">
|
||||||
<div class="layui-btn-container">
|
<div class="layui-btn-container">
|
||||||
<button class="layui-btn layui-btn-sm" lay-event="add">添加</button>
|
<button class="layui-btn layui-btn-sm" lay-event="add">添加</button>
|
||||||
<button class="layui-btn layui-btn-sm" lay-event="delete">删除</button>
|
@*<button class="layui-btn layui-btn-sm" lay-event="delete">删除</button>
|
||||||
<button class="layui-btn layui-btn-sm" lay-event="update">编辑</button>
|
<button class="layui-btn layui-btn-sm" lay-event="update">编辑</button>*@
|
||||||
<div style="float:right;border:0px solid red;">
|
<div style="float:right;border:0px solid red;">
|
||||||
<input type="text" name="search_txt" lay-verify="title" autocomplete="off" placeholder="标题" class="layui-input" style="height: 30px;width:160px;float:left;">
|
<input type="text" name="search_txt" lay-verify="title" autocomplete="off" placeholder="标题" class="layui-input" style="height: 30px;width:160px;float:left;">
|
||||||
<a href="#" style="line-height:30px;margin-left:8px;">高级查询</a>
|
<a href="#" style="line-height:30px;margin-left:8px;">高级查询</a>
|
||||||
@ -65,24 +65,33 @@
|
|||||||
, { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150 }
|
, { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150 }
|
||||||
]]
|
]]
|
||||||
, page: true
|
, page: true
|
||||||
|
, id : 'docContentTable'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var reloadTable = function () {
|
||||||
|
//执行重载
|
||||||
|
table.reload('docContentTable', {
|
||||||
|
page: {
|
||||||
|
curr: 1 //重新从第 1 页开始
|
||||||
|
}, where: { searchContent: $("input[type=search_txt]").val(), seniorQueryJson: "" }
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
//监听事件
|
//监听事件
|
||||||
table.on('toolbar(test)', function (obj) {
|
table.on('toolbar(test)', function (obj) {
|
||||||
var checkStatus = table.checkStatus(obj.config.id);
|
var checkStatus = table.checkStatus(obj.config.id);
|
||||||
switch (obj.event) {
|
switch (obj.event) {
|
||||||
case 'add':
|
case 'add':
|
||||||
dialogWindow.open({
|
var options = {
|
||||||
type: 1,
|
url: "/Admin/Document/DocContentEditModule", paramters: { id: "" },
|
||||||
maxmin: true,
|
|
||||||
title: "新增文档",
|
title: "新增文档",
|
||||||
area: ['1100px', '660px'],
|
area: ['1100px', '660px'],
|
||||||
shadeClose: false, //点击遮罩关闭
|
|
||||||
content: $("#docContentEdit").html(),
|
|
||||||
submit: {
|
submit: {
|
||||||
url: "/Admin/Document/DocContentCreate",
|
url: "/Admin/Document/DocContentCreate",
|
||||||
}
|
},
|
||||||
}, form);
|
callback: reloadTable
|
||||||
|
};
|
||||||
|
dialogWindow.create(options);
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
layer.msg('删除');
|
layer.msg('删除');
|
||||||
@ -102,7 +111,7 @@
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/Admin/Document/DocContentDelete",
|
url: "/Admin/Document/DocContentDelete",
|
||||||
data: { id: docid },
|
data: { id: data.ID },
|
||||||
dataType: "html",
|
dataType: "html",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
obj.del();
|
obj.del();
|
||||||
@ -115,26 +124,16 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if (obj.event === 'edit') {
|
} else if (obj.event === 'edit') {
|
||||||
$("#docContentEdit").load("/Admin/Document/DocContentEditModule", { id: data.ID }, function (responseText, textStatus, jqXHR) {
|
var options = {
|
||||||
switch (textStatus) {
|
url: "/Admin/Document/DocContentEditModule", paramters: { id: data.ID },
|
||||||
case "success":
|
|
||||||
dialogWindow.open({
|
|
||||||
type: 1,
|
|
||||||
maxmin: true,
|
|
||||||
title: "编辑文档",
|
title: "编辑文档",
|
||||||
area: ['1100px', '660px'],
|
area: ['1100px', '660px'],
|
||||||
shadeClose: false, //点击遮罩关闭
|
|
||||||
content: responseText,
|
|
||||||
submit: {
|
submit: {
|
||||||
url: "/Admin/Document/DocContentCreate",
|
url: "/Admin/Document/DocContentUpdate",
|
||||||
}
|
},
|
||||||
}, form);
|
callback: reloadTable
|
||||||
break;
|
};
|
||||||
case "error":
|
dialogWindow.create(options);
|
||||||
freejs.showMessage({ title: "提示", msg: "页面加载失败", type: 2 });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//form.render();
|
//form.render();
|
||||||
//layer.prompt({
|
//layer.prompt({
|
||||||
@ -151,6 +150,28 @@
|
|||||||
|
|
||||||
//先简单封装下
|
//先简单封装下
|
||||||
var dialogWindow = {
|
var dialogWindow = {
|
||||||
|
create: function (options, formpage) {
|
||||||
|
$("#docContentEdit").load(options.url, options.paramters, function (responseText, textStatus, jqXHR) {
|
||||||
|
switch (textStatus) {
|
||||||
|
case "success":
|
||||||
|
dialogWindow.open($.extend({
|
||||||
|
type: 1,
|
||||||
|
maxmin: true,
|
||||||
|
title: "编辑",
|
||||||
|
area: ['1100px', '660px'],
|
||||||
|
shadeClose: false, //点击遮罩关闭
|
||||||
|
content: responseText,
|
||||||
|
submit: {
|
||||||
|
url: "/Admin/Document/DocContentCreate",
|
||||||
|
}
|
||||||
|
}, options), form);
|
||||||
|
break;
|
||||||
|
case "error":
|
||||||
|
freejs.showMessage({ title: "提示", msg: "页面加载失败", type: 2 });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
open: function (options, form) {
|
open: function (options, form) {
|
||||||
var base_options = {
|
var base_options = {
|
||||||
type: 1,
|
type: 1,
|
||||||
@ -171,7 +192,6 @@
|
|||||||
});
|
});
|
||||||
//监听提交
|
//监听提交
|
||||||
form.on('submit(formDemo)', function (data) {
|
form.on('submit(formDemo)', function (data) {
|
||||||
debugger
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: options.submit.url,//"/Admin/Document/DocContentCreate",
|
url: options.submit.url,//"/Admin/Document/DocContentCreate",
|
||||||
@ -179,7 +199,14 @@
|
|||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (e) {
|
success: function (e) {
|
||||||
alert(JSON.stringify(e));
|
if (e.Status == 1) {
|
||||||
|
freejs.showMessage({ title: "提示", msg: e.Msg || "保存成功", type: 1 });
|
||||||
|
if ($.isFunction(new_options.callback)) new_options.callback();
|
||||||
|
layer.close(index);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
freejs.showMessage({ title: "提示", msg: e.Msg, type: 2 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
|
@ -2,18 +2,23 @@
|
|||||||
@model FreeSql.Site.Entity.DocumentContent
|
@model FreeSql.Site.Entity.DocumentContent
|
||||||
|
|
||||||
<form class="layui-form" action="" id="frm_DocContentEdit">
|
<form class="layui-form" action="" id="frm_DocContentEdit">
|
||||||
|
@Html.HiddenFor(m => m.ID)
|
||||||
|
@Html.HiddenFor(m => m.CreateBy)
|
||||||
|
@Html.HiddenFor(m => m.CreateDt)
|
||||||
|
@Html.HiddenFor(m => m.WatchCount)
|
||||||
|
@Html.HiddenFor(m => m.StarCount)
|
||||||
<div class="form-module-content">
|
<div class="form-module-content">
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">文章分类</label>
|
<label class="layui-form-label">文章分类</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
@*@Html.DropDownList("TypeID", ViewBag.DocumentTypeList as List<SelectListItem>, "", new Dictionary<string, object> { { "class", "plate_text" } })*@
|
@Html.DropDownList("TypeID", ViewBag.DocumentTypeList as List<SelectListItem>, "", new Dictionary<string, object> { { "class", "plate_text" } })
|
||||||
<select name="interest" lay-filter="aihao">
|
@*<select name="TypeID" lay-filter="aihao">
|
||||||
<option value=""></option>
|
<option value="0" selected="selected">--请选择--</option>
|
||||||
@foreach (var item in (List<SelectListItem>)ViewBag.DocumentTypeList)
|
@foreach (var item in (List<SelectListItem>)ViewBag.DocumentTypeList)
|
||||||
{
|
{
|
||||||
<option value="@item.Value">@item.Text</option>
|
<option value="@item.Value">@item.Text</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>*@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -49,13 +54,13 @@
|
|||||||
<div class="layui-form-item layui-form-text">
|
<div class="layui-form-item layui-form-text">
|
||||||
<label class="layui-form-label">文本域</label>
|
<label class="layui-form-label">文本域</label>
|
||||||
<div class="layui-input-block" id="md_DocContent">
|
<div class="layui-input-block" id="md_DocContent">
|
||||||
<textarea style="display:none;" placeholder="请输入内容" name="DocContent"></textarea>
|
@Html.TextAreaFor(m => m.DocContent, new Dictionary<string, object> { { "autocomplete", "off" }, { "placeholder", "请输入内容" } })
|
||||||
|
@*<textarea style="display:none;" placeholder="请输入内容" name="DocContent"></textarea>*@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-module-footer">
|
<div class="form-module-footer">
|
||||||
<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
|
<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
|
||||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
Loading…
x
Reference in New Issue
Block a user