TradeRule后台完成
This commit is contained in:
parent
d5f22242de
commit
4854268cd2
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,9 @@
|
||||
namespace wstmart\admin\validate;
|
||||
|
||||
|
||||
class TradeRule
|
||||
use think\Validate;
|
||||
|
||||
class TradeRule extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
['title' ,'require|max:150','请输入标题|文章不能超过150个字符'],
|
||||
|
@ -7,111 +7,43 @@
|
||||
<script src="__ADMIN__/js/ztree/jquery.ztree.all-3.5.js?v={$v}"></script>
|
||||
<script src="__STATIC__/plugins/webuploader/webuploader.js?v={$v}" type="text/javascript" ></script>
|
||||
<script src="__STATIC__/plugins//kindeditor/kindeditor.js?v={$v}" type="text/javascript" ></script>
|
||||
<script src="__ADMIN__/articles/articles.js?v={$v}" type="text/javascript"></script>
|
||||
<script src="__ADMIN__/trade_rule/trade_rule.js?v={$v}" type="text/javascript"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
initCombo(0);
|
||||
{if condition="$object['articleId'] !=0 "}
|
||||
{if condition="$object['id'] !=0 "}
|
||||
WST.setValues({$object});
|
||||
{/if}
|
||||
$('#articleForm').validator({
|
||||
fields: {
|
||||
articleTitle: {
|
||||
tip: "请输入文章名称",
|
||||
rule: '文章名称:required;length[~50];'
|
||||
title: {
|
||||
tip: "请输入标题",
|
||||
rule: '标题:required;length[~50];'
|
||||
},
|
||||
catIds: {
|
||||
tip: "请选择文章分类",
|
||||
rule: "文章分类:required;",
|
||||
target:"#catIdt"
|
||||
},
|
||||
articleKey: {
|
||||
tip: "请输入关键字",
|
||||
rule: '关键字:required;length[~100];'
|
||||
},
|
||||
layoutType: {
|
||||
tip: "请选择移动端布局样式",
|
||||
rule: '关键字:required;length[~100];'
|
||||
},
|
||||
articleContent: {
|
||||
tip: "请输入文章内容",
|
||||
rule: '文章内容:required;'
|
||||
content: {
|
||||
tip: "请输入内容",
|
||||
rule: '内容:required;'
|
||||
}
|
||||
},
|
||||
valid: function(form){
|
||||
var articleId = $('#articleId').val();
|
||||
toEdits(articleId);
|
||||
var id = $('#id').val();
|
||||
toEdits(id);
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
{block name="main"}
|
||||
<input type='hidden' id='articleId' value='{$object["articleId"]}'/>
|
||||
<input type='hidden' id='id' value='{$object["id"]}'/>
|
||||
<form id='articleForm' autocomplete="off">
|
||||
<table class='wst-form wst-box-top '>
|
||||
<tr>
|
||||
<th width='150'>文章标题<font color='red'>*</font>:</th>
|
||||
<td><input type="text" id='articleTitle' name='articleTitle' maxLength='50' style='width:300px;' class='ipt'/></td>
|
||||
<th width='150'>标题<font color='red'>*</font>:</th>
|
||||
<td><input type="text" id='title' name='title' maxLength='50' style='width:300px;' class='ipt'/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width='150' align='right'>分类类型<font color='red'>*</font>:</th>
|
||||
<td>
|
||||
<input id="catSel" type="text" readonly onclick="showMenu();" style='width:250px;' value="{$object.catName}"/>
|
||||
<div id="ztreeMenuContent" class="ztreeMenuContent">
|
||||
<ul id="dropDownTree" class="ztree" style="margin-top:0; width:250px; height: 300px;"></ul>
|
||||
</div>
|
||||
<input id="catId" class="text ipt" autocomplete="off" type="hidden" value=""/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width='150'>是否显示<font color='red'>*</font>:</th>
|
||||
<td height='24' class="layui-form">
|
||||
<input type="checkbox" id="isShow" {if $object['isShow']==1}checked{/if} name="isShow" value="1" class="ipt" lay-skin="switch" lay-filter="isShow" lay-text="显示|隐藏">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width='150'>关键字<font color='red'>*</font>:</th>
|
||||
<td><input type="text" id='articleKey' name='articleKey' maxLength='120' style='width:600px;' class='ipt'/></td>
|
||||
</tr>
|
||||
<tr >
|
||||
<th>移动端布局样式预览图:</th>
|
||||
<td class="typeState" style="padding-top: 10px;">
|
||||
<li>
|
||||
<input type='radio' name='TypeStatus' class='ipt' value='1'/>
|
||||
<label>
|
||||
<img src="__ADMIN__/img/news_1.png" style="width:150px;height:80px;">
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<input type='radio' name='TypeStatus' class='ipt' value='2' />
|
||||
<label>
|
||||
<img src="__ADMIN__/img/news_2.png" style="width:150px;height:80px;">
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<input type='radio' name='TypeStatus' class='ipt' value='3' />
|
||||
<label>
|
||||
<img src="__ADMIN__/img/news_3.png" style="width:150px;height:80px;">
|
||||
</label>
|
||||
</li>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>封面图片:</th>
|
||||
<td>
|
||||
<div id='coverImgPicker'>请上传封面图片</div><span id='coverImgMsg'></span>图片大小:230x195(px),格式为 gif, jpg, jpeg, png
|
||||
<input type="hidden" id='coverImg' name="coverImg" class="ipt"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>预览图:</th>
|
||||
<td><div style="min-height:70px;" id="preview">{if ($object['articleId']!=0 && $object['coverImg'])}<img src="__IMGURL__/{$object['coverImg']}" height="152" />{/if}</div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width='150'>文章内容<font color='red'>*</font>:</th>
|
||||
<th width='150'>内容<font color='red'>*</font>:</th>
|
||||
<td>
|
||||
<textarea id='articleContent' name='articleContent' class="form-control ipt" style='width:80%;height:400px'></textarea>
|
||||
<textarea id='content' name='content' class="form-control ipt" style='width:80%;height:400px'></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -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,
|
||||
|
@ -16,12 +16,8 @@ $(function(){initGrid();})
|
||||
</div>
|
||||
<input type='text' id='key' placeholder='规则标题'/>
|
||||
<button class="btn btn-primary" onclick='javascript:loadGrid()'><i class='fa fa-search'></i>查询</button>
|
||||
{if WSTGrant('WZGL_03')}
|
||||
<button class="btn btn-danger f-right btn-fixtop" onclick='javascript:toBatchDel()' style='margin-left:10px;'><i class='fa fa-trash'></i>批量删除</button>
|
||||
{/if}
|
||||
{if WSTGrant('WZGL_01')}
|
||||
<button class="btn btn-success f-right btn-fixtop" onclick='javascript:toEdit(0)'><i class='fa fa-plus'></i>新增</button>
|
||||
{/if}
|
||||
<div style='clear:both'></div>
|
||||
</div>
|
||||
<div class='wst-grid'>
|
||||
|
@ -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 '<form autocomplete="off" class="layui-form" lay-filter="gridForm"><input type="checkbox" id="isShow" name="isShow" '+((item['isShow']==1)?"checked":"")+' lay-skin="switch" value="1" lay-filter="isShow" lay-text="显示|隐藏" data="'+item['articleId']+'"></form>';
|
||||
}},
|
||||
{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 += "<a class='btn btn-blue' onclick='javascript:toEdit("+item['articleId']+")'><i class='fa fa-pencil'></i>修改</a> ";
|
||||
if(WST.GRANT.WZGL_03)h += "<a class='btn btn-red' onclick='javascript:toDel(" + item['articleId'] + ")'><i class='fa fa-trash-o'></i>删除</a> ";
|
||||
h += "<a class='btn btn-blue' onclick='javascript:toEdit("+item['id']+")'><i class='fa fa-pencil'></i>修改</a> ";
|
||||
h += "<a class='btn btn-red' onclick='javascript:toDel(" + item['id'] + ")'><i class='fa fa-trash-o'></i>删除</a> ";
|
||||
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});
|
||||
|
Loading…
x
Reference in New Issue
Block a user