diff --git a/CoreCms.Net.Web.Admin/Controllers/Article/CoreCmsArticleController.cs b/CoreCms.Net.Web.Admin/Controllers/Article/CoreCmsArticleController.cs index b1510cec..9c694428 100644 --- a/CoreCms.Net.Web.Admin/Controllers/Article/CoreCmsArticleController.cs +++ b/CoreCms.Net.Web.Admin/Controllers/Article/CoreCmsArticleController.cs @@ -14,7 +14,6 @@ using CoreCms.Net.IServices; using CoreCms.Net.Model.Entities; using CoreCms.Net.Model.Entities.Expression; using CoreCms.Net.Model.FromBody; -using CoreCms.Net.Model.ViewModels.UI; using CoreCms.Net.Utility.Extensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Hosting; @@ -25,6 +24,7 @@ using System.ComponentModel; using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; +using CoreCms.Net.Model.ViewModels.UI; namespace CoreCms.Net.Web.Admin.Controllers { @@ -308,15 +308,14 @@ namespace CoreCms.Net.Web.Admin.Controllers /// /// 编辑数据 /// - /// /// [HttpPost] [Description("编辑数据")] - public async Task GetEdit([FromBody] FMIntId entity) + public async Task GetEdit(int id) { var jm = new AdminUiCallBack(); - var model = await _coreCmsArticleServices.QueryByIdAsync(entity.id); + var model = await _coreCmsArticleServices.QueryByIdAsync(id); if (model == null) { jm.msg = "不存在此信息"; diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/content/article/articles/create.html b/CoreCms.Net.Web.Admin/wwwroot/views/content/article/articles/create.html index bb473098..8bff8349 100644 --- a/CoreCms.Net.Web.Admin/wwwroot/views/content/article/articles/create.html +++ b/CoreCms.Net.Web.Admin/wwwroot/views/content/article/articles/create.html @@ -1,74 +1,91 @@ - @@ -79,7 +96,7 @@ var debug = layui.setter.debug; layui.data.done = function (d) { //开启调试情况下获取接口赋值数据 - if (debug) { console.log(d.params.data); } + if (debug) { console.log(d.data); } layui.use(['admin', 'form', 'laydate', 'upload', 'coreHelper', 'dtree', 'cropperImg'], function () { var $ = layui.$ @@ -148,11 +165,11 @@ const input = match['input']; return ( '
' + - `' + - '
' + `' + + '' ); } } @@ -200,8 +217,38 @@ verifybrief: [/^[\S]{0,100}$/, '简介最大只允许输入100位字符,且不能出现空格'], verifycoverImage: [/^[\S]{0,255}$/, '封面图最大只允许输入255位字符,且不能出现空格'], }); + + + form.on('submit(LAY-app-CoreCmsArticle-createForm-submit)', + function (data) { + var field = data.field; //获取提交的字段 + + field.isPub = field.isPub == 'on'; + field.isDel = field.isDel == 'on'; + field.contentBody = window.editor.getData(); + if (!!!field.contentBody) { + layer.msg('文章详情内容不能为空', { icon: 5 }); + return false; + } + + if (debug) { console.log(field); } //开启调试返回数据 + //提交 Ajax 成功后,关闭当前弹层并重载表格 + coreHelper.Post("Api/CoreCmsArticle/DoCreate", field, function (e) { + console.log(e) + if (e.code === 0) { + layer.msg(e.msg, { time: 1000 }, + function () { + location.hash = '/content/article/articles/'; + }); + } else { + layer.msg(e.msg); + } + }); + }); + //重载form form.render(null, 'LAY-app-CoreCmsArticle-createForm'); + }) }; \ No newline at end of file diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/content/article/articles/edit.html b/CoreCms.Net.Web.Admin/wwwroot/views/content/article/articles/edit.html index 607756d9..9c7241aa 100644 --- a/CoreCms.Net.Web.Admin/wwwroot/views/content/article/articles/edit.html +++ b/CoreCms.Net.Web.Admin/wwwroot/views/content/article/articles/edit.html @@ -1,77 +1,94 @@ - \ No newline at end of file + diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/content/article/articles/index.html b/CoreCms.Net.Web.Admin/wwwroot/views/content/article/articles/index.html index f01bf8f2..415729ea 100644 --- a/CoreCms.Net.Web.Admin/wwwroot/views/content/article/articles/index.html +++ b/CoreCms.Net.Web.Admin/wwwroot/views/content/article/articles/index.html @@ -88,18 +88,7 @@ , util = layui.util , view = layui.view; - laydate.render({ - elem: '#searchTime-CoreCmsArticle-createTime', - type: 'datetime', - range: '到', - }); - laydate.render({ - elem: '#searchTime-CoreCmsArticle-updateTime', - type: 'datetime', - range: '到', - }); - //重载form - form.render(); + var searchwhere; //监听搜索 form.on('submit(LAY-app-CoreCmsArticle-search)', @@ -188,108 +177,65 @@ }); //执行创建操作 function doCreate() { - - coreHelper.Post("Api/CoreCmsArticle/GetCreate", null, function (e) { - if (e.code === 0) { - admin.popup({ - shadeClose: false, - title: '创建数据', - area: ['1200px', '95%'], - id: 'LAY-popup-CoreCmsArticle-create', - success: function (layero, index) { - view(this.id).render('content/article/articles/create', { data: e.data }).done(function () { - //监听提交 - form.on('submit(LAY-app-CoreCmsArticle-createForm-submit)', - function (data) { - var field = data.field; //获取提交的字段 - - field.isPub = field.isPub == 'on'; - field.isDel = field.isDel == 'on'; - field.contentBody = window.editor.getData(); - if (!!!field.contentBody) { - layer.msg('文章详情内容不能为空', { icon: 5 }); - return false; - } - - if (debug) { console.log(field); } //开启调试返回数据 - //提交 Ajax 成功后,关闭当前弹层并重载表格 - coreHelper.Post("Api/CoreCmsArticle/DoCreate", field, function (e) { - console.log(e) - if (e.code === 0) { - layui.table.reloadData('LAY-app-CoreCmsArticle-tableBox'); //重载表格 - layer.close(index); //再执行关闭 - layer.msg(e.msg); - } else { - layer.msg(e.msg); - } - }); - }); - }); - } - , btn: ['确定', '取消'] - , yes: function (index, layero) { - layero.contents().find("#LAY-app-CoreCmsArticle-createForm-submit").click(); - } - }); - } else { - layer.msg(e.msg); - } - }); + location.hash = '/content/article/articles/create'; } //执行编辑操作 function doEdit(obj) { - coreHelper.Post("Api/CoreCmsArticle/GetEdit", { id: obj.data.id }, function (e) { - if (e.code === 0) { - admin.popup({ - shadeClose: false, - title: '编辑数据', - area: ['1200px', '95%'], - id: 'LAY-popup-CoreCmsArticle-edit', - success: function (layero, index) { - view(this.id).render('content/article/articles/edit', { data: e.data }).done(function () { - //监听提交 - form.on('submit(LAY-app-CoreCmsArticle-editForm-submit)', - function (data) { - var field = data.field; //获取提交的字段 - field.isPub = field.isPub == 'on'; - field.isDel = field.isDel == 'on'; + location.hash = '/content/article/articles/edit/id=' + obj.data.id; - if (!!!field.typeId) { - layer.msg("请选择文章分类", { icon: 5 }); - return false; - } + //coreHelper.Post("Api/CoreCmsArticle/GetEdit", { id: obj.data.id }, function (e) { + // if (e.code === 0) { + // admin.popup({ + // shadeClose: false, + // title: '编辑数据', + // area: ['1200px', '95%'], + // id: 'LAY-popup-CoreCmsArticle-edit', + // success: function (layero, index) { + // view(this.id).render('content/article/articles/edit', { data: e.data }).done(function () { + // //监听提交 + // form.on('submit(LAY-app-CoreCmsArticle-editForm-submit)', + // function (data) { + // var field = data.field; //获取提交的字段 - field.contentBody = window.editor.getData(); - if (!!!field.contentBody) { - layer.msg('文章详情内容不能为空', { icon: 5 }); - return false; - } + // field.isPub = field.isPub == 'on'; + // field.isDel = field.isDel == 'on'; - if (debug) { console.log(field); } //开启调试返回数据 - //提交 Ajax 成功后,关闭当前弹层并重载表格 - coreHelper.Post("Api/CoreCmsArticle/DoEdit", field, function (e) { - console.log(e) - if (e.code === 0) { - layui.table.reloadData('LAY-app-CoreCmsArticle-tableBox'); //重载表格 - layer.close(index); //再执行关闭 - layer.msg(e.msg); - } else { - layer.msg(e.msg); - } - }); - }); - }) - } - , btn: ['确定', '取消'] - , yes: function (index, layero) { - layero.contents().find("#LAY-app-CoreCmsArticle-editForm-submit").click(); - } - }); - } else { - layer.msg(e.msg); - } - }); + // if (!!!field.typeId) { + // layer.msg("请选择文章分类", { icon: 5 }); + // return false; + // } + + // field.contentBody = window.editor.getData(); + // if (!!!field.contentBody) { + // layer.msg('文章详情内容不能为空', { icon: 5 }); + // return false; + // } + + // if (debug) { console.log(field); } //开启调试返回数据 + // //提交 Ajax 成功后,关闭当前弹层并重载表格 + // coreHelper.Post("Api/CoreCmsArticle/DoEdit", field, function (e) { + // console.log(e) + // if (e.code === 0) { + // layui.table.reloadData('LAY-app-CoreCmsArticle-tableBox'); //重载表格 + // layer.close(index); //再执行关闭 + // layer.msg(e.msg); + // } else { + // layer.msg(e.msg); + // } + // }); + // }); + // }) + // } + // , btn: ['确定', '取消'] + // , yes: function (index, layero) { + // layero.contents().find("#LAY-app-CoreCmsArticle-editForm-submit").click(); + // } + // }); + // } else { + // layer.msg(e.msg); + // } + //}); } //执行单个删除 function doDelete(obj) { @@ -318,6 +264,14 @@ }); }); + laydate.render({ + elem: '#searchTime-CoreCmsArticle-createTime', + type: 'datetime', + range: '到', + }); + + //重载form + form.render(); }); };