5 changed files with 146 additions and 2 deletions
@ -0,0 +1,49 @@ |
|||
<?php |
|||
|
|||
namespace app\admin\controller\setting; |
|||
|
|||
use app\admin\controller\Controller; |
|||
use app\common\dm\Dm; |
|||
use app\common\model\Pass; |
|||
|
|||
/** |
|||
* 配置 |
|||
* Class Index |
|||
* @package app\admin\controller |
|||
*/ |
|||
class Config extends Controller |
|||
{ |
|||
/** |
|||
* 清理缓存 |
|||
* @return mixed |
|||
*/ |
|||
public function index() |
|||
{ |
|||
|
|||
$dm = new Dm(); |
|||
|
|||
if ($this->request->isAjax()) { |
|||
|
|||
$request = $this->request->request(); |
|||
$threshold = $request['threshold']; |
|||
|
|||
if (empty($threshold)) $this->renderError('请填写阈值'); |
|||
if (is_numeric($threshold) && $threshold > 0) $this->renderError('阈值必须是数字'); |
|||
|
|||
# 修改阈值 |
|||
$dm->update('bt_config',['value' => $threshold],'"key"='."'threshold'"); |
|||
|
|||
return $this->renderSuccess('操作成功'); |
|||
} |
|||
|
|||
$configList = []; |
|||
|
|||
$configRes = $dm->find("bt_config",' "key" = ' . "'threshold'"); |
|||
$threshold = $configRes['value']; |
|||
|
|||
return $this->fetch('index', [ |
|||
'configList' => $configList, |
|||
'threshold' => $threshold, |
|||
]); |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
<style> |
|||
.tpl-form-input { |
|||
width: 60px!important; |
|||
display: inline-block!important; |
|||
text-align: center; |
|||
} |
|||
.am-checkbox-inline span{ |
|||
margin-right: 10px; |
|||
} |
|||
</style> |
|||
<div class="row"> |
|||
<div class="am-u-sm-12 am-u-md-12 am-u-lg-12"> |
|||
<div class="widget am-cf"> |
|||
<form id="my-form" class="am-form tpl-form-line-form" enctype="multipart/form-data" method="post"> |
|||
<div class="widget-body"> |
|||
<fieldset> |
|||
<div class="widget-head am-cf"> |
|||
<div class="widget-title am-fl">预警阈值</div> |
|||
</div> |
|||
<div class="am-form-group"> |
|||
<label class="am-u-sm-3 am-form-label form-require"> 阈值 </label> |
|||
<div class="am-u-sm-9"> |
|||
<label class="am-checkbox-inline"> |
|||
<input type="text" class="tpl-form-input" name="threshold" value="<?= $threshold ?>" required> |
|||
</label> |
|||
</div> |
|||
</div> |
|||
<div class="am-form-group"> |
|||
<div class="am-u-sm-9 am-u-sm-push-3 am-margin-top-lg"> |
|||
<button type="submit" class="j-submit am-btn am-btn-secondary">提交 |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</fieldset> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<script> |
|||
$(function () { |
|||
|
|||
/** |
|||
* 表单验证提交 |
|||
* @type {*} |
|||
*/ |
|||
$('#my-form').superForm(); |
|||
|
|||
}); |
|||
</script> |
|||
@ -0,0 +1,8 @@ |
|||
<?php |
|||
|
|||
namespace app\common\model; |
|||
|
|||
class Pass extends BaseModel |
|||
{ |
|||
public static $unit = [1 => '>', 2 => '<', 3 => '=', 4 => '≥', 5 => '<=', 6 => '!=']; |
|||
} |
|||
Loading…
Reference in new issue