编辑规则

master
sunke 5 years ago
parent 2c63e6e395
commit bdb688c985

@ -918,6 +918,7 @@ class ArticleController extends AdminController {
if ($_POST['type'] == 1 ) { if ($_POST['type'] == 1 ) {
$_POST['pop_time'] = strtotime($_POST['pop_time']); $_POST['pop_time'] = strtotime($_POST['pop_time']);
} }
if ($id) { if ($id) {
$pop_rules_model = M('document_pop_rules');//M('$this->$model_name','tab_'); $pop_rules_model = M('document_pop_rules');//M('$this->$model_name','tab_');
$res = $pop_rules_model->where(['id'=>$id])->save($_POST); $res = $pop_rules_model->where(['id'=>$id])->save($_POST);
@ -949,5 +950,25 @@ class ArticleController extends AdminController {
} }
$this->display('pop_rule_edit'); $this->display('pop_rule_edit');
} }
public function uploadDoc() {
$id = $_REQUEST['id'];
if(@is_uploaded_file($_FILES['file']['tmp_name'])){
$upfile = $_FILES["file"];
$name = $upfile["name"];
$type = $upfile["type"];
$size = $upfile["size"];
$tmp_name = $upfile["tmp_name"];
$savePath = $_SERVER['DOCUMENT_ROOT'].__ROOT__.'/Uploads/Documents/';
move_uploaded_file($tmp_name,$savePath.$name);
$file_name = $savePath.$name;
$error=$upfile["error"];//上传后系统返回的值
$data['document_route'] = 'Uploads/Documents/'.$name;
M('document_pop_rules')->where(['id' => $id])->save($data);
$backData['tmp'] = $file_name;
$this->ajaxReturn(json_encode($backData,TRUE));
}
}
} }

@ -14,6 +14,22 @@
<label>描述</label> <label>描述</label>
<textarea name="desc" class="" placeholder="描述" >{$rule.desc}</textarea> <textarea name="desc" class="" placeholder="描述" >{$rule.desc}</textarea>
</li> </li>
<li>
<label>规则性质</label>
<span class="form_radio"><label><input type="radio" name="belongs" value="1" <?php if ($rule['belongs'] == 1):?>checked<?php endif;?>> 外团</label>
<label><input type="radio" name="belongs" value="2" <?php if ($rule['belongs'] == 2):?>checked<?php endif;?>> 内团</label></span>
<span class="notice-text"></span>
</li>
<li>
<label>上传文档</label>
<input type="file" name="upfile" id="file_doc" style="width:200px"/>
<input type="button" onclick="suba({$rule['id']})" style="background: #3E96C9;color:white;border:none;outline: none;width:70px;height:30px;border-radius: 3px;" value="上传" />
</li>
<li> <li>
<label>排序</label> <label>排序</label>
<input name="sort" type="text" class="txt" placeholder="排序" value="{$rule.sort}" /> <input name="sort" type="text" class="txt" placeholder="排序" value="{$rule.sort}" />
@ -65,6 +81,26 @@
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script> <script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript"> <script type="text/javascript">
</script> </script>
<script>
function suba(id) {
var file_excel = $('#file_doc')[0].files[0]
var formData = new FormData();
formData.append("file",file_excel);
formData.append("id",id)
$.ajax({
url:"{:U('Article/uploadDoc')}",
dataType:'json',
type:'POST',
async:false,
data:formData,
processData : false, // 使数据不做处理
contentType : false, // 不要设置Content-Type请求头
success:function(res) {
// console.log(res)
}
})
}
</script>
<script type="text/javascript"> <script type="text/javascript">
highlight_subnav('{:U('Article/pop_rules')}'); highlight_subnav('{:U('Article/pop_rules')}');
function checkPopTime(first) function checkPopTime(first)

@ -251,7 +251,9 @@ class PromoteController extends BaseController
} else { } else {
$match_newrules = []; $match_newrules = [];
} }
$match_newrules_route = M("document_pop_rules")
->where(['id' => 2])
->getField('document_route');
$redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]); $redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]);
$cacheKey = "pop:rule:set"; $cacheKey = "pop:rule:set";
if (!$redis->sIsMember($cacheKey, get_pid())) { if (!$redis->sIsMember($cacheKey, get_pid())) {
@ -271,6 +273,7 @@ class PromoteController extends BaseController
$this->assign("match_rules_id", $match_rules ? json_encode(array_column($match_rules, 'id')) : 'null'); $this->assign("match_rules_id", $match_rules ? json_encode(array_column($match_rules, 'id')) : 'null');
$this->assign("match_newrules_id", $match_newrules ? json_encode(array_column($match_newrules, 'id')) : 'null'); $this->assign("match_newrules_id", $match_newrules ? json_encode(array_column($match_newrules, 'id')) : 'null');
$this->assign("match_newrules_route", $match_newrules_route);
$this->assign("user_count", $user_count); $this->assign("user_count", $user_count);
$this->assign("total_money", $total_money); $this->assign("total_money", $total_money);

@ -204,6 +204,7 @@
</empty> </empty>
</table> </table>
</div> </div>
<input type="hidden" id = "a" value="{$match_newrules_route}">
<div class="pagenation clearfix"> <div class="pagenation clearfix">
{$_page} {$_page}
</div> </div>
@ -216,6 +217,7 @@
var pop_ids = {$match_rules_id}; var pop_ids = {$match_rules_id};
var new_popids = {$match_newrules_id}; var new_popids = {$match_newrules_id};
var match_newrules_route = $('#a').val();
if (new_popids) { if (new_popids) {
pop_newrulus_content(new_popids, true); pop_newrulus_content(new_popids, true);
} }
@ -256,12 +258,14 @@
var index = 0; var index = 0;
layer.open({ layer.open({
type: 2, type: 2,
closeBtn: 0,
title: '平台规则', title: '平台规则',
area:['60%', '80%'], area:['60%', '80%'],
closeBtn: 0,
shadeClose: false, shadeClose: false,
skin: 'yourclass', skin: 'yourclass',
content: "{:U('Promote/popNewRuleDetail')}&id="+id+"&force="+force btn:['下载文档'],
content: "{:U('Promote/popNewRuleDetail')}&id="+id+"&force="+force,
yes:function(){window.location.href= match_newrules_route},
}); });
} else { } else {
layer.open({ layer.open({
@ -271,7 +275,6 @@
closeBtn: 0, closeBtn: 0,
shadeClose: false, shadeClose: false,
skin: 'yourclass', skin: 'yourclass',
//btn:['返回'],
content: "{:U('Promote/popNewRuleDetail')}&id="+id+"&force="+force, content: "{:U('Promote/popNewRuleDetail')}&id="+id+"&force="+force,
end:function(){ end:function(){
return false; return false;

Loading…
Cancel
Save