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"} - +