diff --git a/hyhproject/admin/controller/TradeRule.php b/hyhproject/admin/controller/TradeRule.php index 35ea6a1..ff5442a 100644 --- a/hyhproject/admin/controller/TradeRule.php +++ b/hyhproject/admin/controller/TradeRule.php @@ -21,6 +21,21 @@ class TradeRule extends Base return WSTGrid($rs); } + /** + * 跳去新增/编辑页面 + */ + public function toEdit(){ + $id = Input("get.id/d",0); + $m = new M(); + if($id>0){ + $object = $m->getById($id); + }else{ + $object = $m->getEModel('trade_rule'); + } + $this->assign('object',$object); + return $this->fetch("edit"); + } + /** * 获取文章 */ @@ -65,5 +80,13 @@ class TradeRule extends Base $rs = $m->delByBatch(); return $rs; } + /** + * 设置是否显示/隐藏 + */ + public function editiIsShow(){ + $m = new M(); + $rs = $m->editiIsShow(); + return $rs; + } } \ No newline at end of file diff --git a/hyhproject/admin/model/TradeRule.php b/hyhproject/admin/model/TradeRule.php index 2c18088..62c3375 100644 --- a/hyhproject/admin/model/TradeRule.php +++ b/hyhproject/admin/model/TradeRule.php @@ -46,7 +46,7 @@ class TradeRule extends Base */ public function add(){ $data = input('post.'); - WSTUnset($data,'id,dataFlag'); + WSTUnset($data,'id,dataFlag,isShow'); $data['create_time'] = date('Y-m-d H:i:s'); Db::startTrans(); try{ @@ -68,7 +68,7 @@ class TradeRule extends Base public function edit(){ $id = input('post.id/d'); $data = input('post.'); - WSTUnset($data,'id,dataFlag,create_time'); + WSTUnset($data,'id,dataFlag,isShow,create_time'); Db::startTrans(); try{ $result = $this->validate('TradeRule.edit')->allowField(true)->save($data,['articleId'=>$articleId]); @@ -126,5 +126,22 @@ class TradeRule extends Base } + /** + + * 显示是否显示/隐藏 + + */ + public function editiIsShow(){ + $id = input('post.id/d'); + $isShow = (input('post.isShow/d')==1)?1:0; + $result = $this->where(['id'=>$id])->update(['isShow' => $isShow]); + if(false !== $result){ + WSTClearAllCache(); + return WSTReturn("操作成功", 1); + }else{ + return WSTReturn($this->getError(),-1); + } + + } } \ No newline at end of file diff --git a/hyhproject/admin/validate/TradeRule.php b/hyhproject/admin/validate/TradeRule.php index 8499e8c..1b5024f 100644 --- a/hyhproject/admin/validate/TradeRule.php +++ b/hyhproject/admin/validate/TradeRule.php @@ -9,7 +9,9 @@ namespace wstmart\admin\validate; -class TradeRule +use think\Validate; + +class TradeRule extends Validate { protected $rule = [ ['title' ,'require|max:150','请输入标题|文章不能超过150个字符'], diff --git a/hyhproject/admin/view/trade_rule/edit.html b/hyhproject/admin/view/trade_rule/edit.html index a5fe830..95eee9e 100644 --- a/hyhproject/admin/view/trade_rule/edit.html +++ b/hyhproject/admin/view/trade_rule/edit.html @@ -7,111 +7,43 @@ - + {/block} {block name="main"} - +
- - + + - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -143,9 +75,9 @@ $(function(){ }); //编辑器 KindEditor.ready(function(K) { - editor1 = K.create('textarea[name="articleContent"]', { + editor1 = K.create('textarea[name="content"]', { height:'350px', - uploadJson : WST.conf.ROOT+'/admin/articles/editorUpload', + uploadJson : WST.conf.ROOT+'/admin/trade_rule/editorUpload', allowFileManager : false, allowImageUpload : true, allowMediaUpload : false, diff --git a/hyhproject/admin/view/trade_rule/list.html b/hyhproject/admin/view/trade_rule/list.html index 49176fb..4f5364e 100644 --- a/hyhproject/admin/view/trade_rule/list.html +++ b/hyhproject/admin/view/trade_rule/list.html @@ -16,12 +16,8 @@ $(function(){initGrid();}) - {if WSTGrant('WZGL_03')} - {/if} - {if WSTGrant('WZGL_01')} - {/if}
diff --git a/hyhproject/admin/view/trade_rule/trade_rule.js b/hyhproject/admin/view/trade_rule/trade_rule.js index ef0bc87..494d0d6 100644 --- a/hyhproject/admin/view/trade_rule/trade_rule.js +++ b/hyhproject/admin/view/trade_rule/trade_rule.js @@ -2,18 +2,16 @@ var mmg,combo; function initGrid(){ var h = WST.pageHeight(); var cols = [ - {title:'文章ID', name:'articleId' ,width:30,sortable:true}, - {title:'标题', name:'articleTitle' ,width:200,sortable:true}, - {title:'分类', name:'catName' ,width:100,sortable:true}, + {title:'文章ID', name:'id' ,width:30,sortable:true}, + {title:'标题', name:'title' ,width:200,sortable:true}, {title:'是否显示', name:'isShow' ,width:50,sortable:true, renderer: function(val,item,rowIndex){ return ''; }}, - {title:'最后编辑者', name:'staffName' ,width:50,sortable:true}, - {title:'创建时间', name:'createTime' ,width:120,sortable:true}, + {title:'创建时间', name:'create_time' ,width:120,sortable:true}, {title:'操作', name:'' ,width:100, align:'center', renderer: function(val,item,rowIndex){ var h = ""; - if(WST.GRANT.WZGL_02)h += "修改 "; - if(WST.GRANT.WZGL_03)h += "删除 "; + h += "修改 "; + h += "删除 "; return h; }} ]; @@ -38,13 +36,12 @@ function initGrid(){ } function loadGrid(){ - mmg.load({key:$('#key').val(),catId:$('#catId').val(),page:1}); + mmg.load({page:1}); } function toggleIsShow(t,v){ - if(!WST.GRANT.WZGL_02)return; var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000}); - $.post(WST.U('admin/articles/editiIsShow'),{id:v,isShow:t},function(data,textStatus){ + $.post(WST.U('admin/trade_rule/editiIsShow'),{id:v,isShow:t},function(data,textStatus){ layer.close(loading); var json = WST.toAdminJson(data); if(json.status=='1'){ @@ -57,20 +54,20 @@ function toggleIsShow(t,v){ } function toEdit(id){ - location.href=WST.U('admin/articles/toEdit','id='+id); + location.href=WST.U('admin/trade_rule/toEdit','id='+id); } function toEdits(id){ var params = WST.getParams('.ipt'); params.id = id; var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000}); - $.post(WST.U('admin/articles/'+((id>0)?"edit":"add")),params,function(data,textStatus){ + $.post(WST.U('admin/trade_rule/'+((id>0)?"edit":"add")),params,function(data,textStatus){ layer.close(loading); var json = WST.toAdminJson(data); if(json.status=='1'){ WST.msg(json.msg,{icon:1}); setTimeout(function(){ - location.href=WST.U('admin/articles/index'); + location.href=WST.U('admin/trade_rule/index'); },1000); }else{ WST.msg(json.msg,{icon:2});
文章标题*标题*
分类类型* - -
- -
- -
是否显示* - -
关键字*
移动端布局样式预览图: -
  • - - -
  • -
  • - - -
  • -
  • - - -
  • -
    封面图片: -
    请上传封面图片
    图片大小:230x195(px),格式为 gif, jpg, jpeg, png - -
    预览图:
    {if ($object['articleId']!=0 && $object['coverImg'])}{/if}
    文章内容*内容* - +