系统调协完成
This commit is contained in:
1 parent
8ba90a9ca4
commit
36000b876c
7 files changed
+100
-194
No files matched your search
@@ -13,11 +13,9 @@ class SystemBase extends Base
|
||||
// 系统设置
|
||||
public function index()
|
||||
{
|
||||
$count = 1;
|
||||
|
||||
// 设置要给模板赋值的信息
|
||||
$list['title'] = '系统设置';
|
||||
$list['count'] = $count;
|
||||
|
||||
// 模板赋值
|
||||
$this->assign('list',$list);
|
||||
@@ -72,13 +70,41 @@ class SystemBase extends Base
|
||||
// 编辑系统设置
|
||||
public function edit($id)
|
||||
{
|
||||
return 'aa';
|
||||
// 获取用户信息
|
||||
$list = sysbasemod::field('id,title,keywords,description,copyright,thinks,danwei')
|
||||
->get($id);
|
||||
|
||||
|
||||
$this->assign('list',$list);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 更新资源
|
||||
public function update(Request $request, $id)
|
||||
public function update($id)
|
||||
{
|
||||
//
|
||||
$validate = new \app\system\validate\SystemBase;
|
||||
|
||||
// 获取表单数据
|
||||
$list = request()->only(['title','keywords','description','copyright','thinks','danwei'],'put');;
|
||||
|
||||
// 验证表单数据
|
||||
$result = $validate->check($list);
|
||||
$msg = $validate->getError();
|
||||
|
||||
// 如果验证不通过则停止保存
|
||||
if(!$result){
|
||||
return json(['msg'=>$msg,'val'=>0]);;
|
||||
}
|
||||
|
||||
|
||||
$data = sysbasemod::where('id',$id)->update($list);
|
||||
|
||||
// 根据更新结果设置返回提示信息
|
||||
$data>=0 ? $data=['msg'=>'更新成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
|
||||
|
||||
// 返回信息
|
||||
return json($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\system\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class SystemBase extends Validate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
* 格式:'字段名' => ['规则1','规则2'...]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'title|标题' => 'require|length:2,50',
|
||||
'keywords|关键字' => 'require|length:2,60',
|
||||
'description|描述' => 'require|length:1,100',
|
||||
'copyright|版权' => 'require|length:1,15',
|
||||
'thinks|感谢' => 'require|length:1,80',
|
||||
'danwei|单位' => 'require|length:2,80',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [];
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
{extend name="common@create" /}
|
||||
{block name="formaa"}
|
||||
<form action="/admin" method="POST" class="form form-horizontal" id="form-member-add">
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户姓名:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<input type="text" class="input-text" value="" placeholder="建议使用真实姓名" id="xingming" name="xingming">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户帐号:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<input type="text" class="input-text" value="" placeholder="由小写英语字母、数字-_组成,首字符为字母" id="username" name="username">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>分配角色:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9 skin-minimal">
|
||||
{php}
|
||||
$group = db('auth_group')->where('status',true)->field('id,title')->all();
|
||||
{/php}
|
||||
{volist name="group" id="vo"}
|
||||
<div class="radio-box">
|
||||
<input name="group_id" type="radio" id="group{$vo.id}" value="{$vo.id}">
|
||||
<label for="group{$vo.id}">{$vo.title}</label>
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>性别:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9 skin-minimal">
|
||||
<div class="radio-box">
|
||||
<input name="sex" type="radio" id="sex-1" value="1">
|
||||
<label for="sex-1">男</label>
|
||||
</div>
|
||||
<div class="radio-box">
|
||||
<input type="radio" id="sex-2" value="0" name="sex">
|
||||
<label for="sex-2">女</label>
|
||||
</div>
|
||||
<div class="radio-box">
|
||||
<input type="radio" id="sex-3" value="2" name="sex" checked>
|
||||
<label for="sex-3">保密</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-3">出生日期:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<input type="text" class="input-text Wdate" value="" placeholder="" id="shengri" name="shengri" onclick="WdatePicker({isShowClear:false,readOnly:true})">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-3">手机:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<input type="text" class="input-text" value="" placeholder="" id="phone" name="phone">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-3">备注:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<textarea name="beizhu" cols="" rows="" class="textarea" placeholder="说点什么...最少输入10个字符,最多80个字符" onKeyUp="$.Huitextarealength(this,100)"></textarea>
|
||||
<p class="textarea-numberbar"><em class="textarea-length">0</em>/80</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row cl">
|
||||
<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
|
||||
<input class="btn btn-primary radius" type="submit" value=" 提交 ">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{/block}
|
||||
{block name="yanzheng"}
|
||||
<script type="text/javascript">
|
||||
|
||||
// 匹配用户名
|
||||
$.validator.addMethod("zh",function(value,element){
|
||||
var tel = /^[\u4e00-\u9fa5]*$/;
|
||||
return this.optional(element) || tel.test(value);
|
||||
}, "请输入中文");
|
||||
|
||||
// 匹配帐号
|
||||
$.validator.addMethod("ustr",function(value,element){
|
||||
var tel = /^[a-z][a-z0-9-_]*$/;
|
||||
return this.optional(element) || tel.test(value);
|
||||
}, "用户名由小写字母和 _ - 组成,首字符为字母");
|
||||
|
||||
// 设置表单验证规则
|
||||
var myrules = {
|
||||
xingming:{
|
||||
required:true,
|
||||
zh:true,
|
||||
rangelength:[2,6]
|
||||
},
|
||||
username:{
|
||||
required:true,
|
||||
ustr:true,
|
||||
rangelength:[5,20]
|
||||
},
|
||||
group_id:{
|
||||
required:true,
|
||||
},
|
||||
sex:{
|
||||
required:true,
|
||||
},
|
||||
shengri:{
|
||||
dateISO:true
|
||||
},
|
||||
phone:{
|
||||
isMobile:true,
|
||||
},
|
||||
};
|
||||
|
||||
// 设置表单提交方式
|
||||
var mytype = 'POST';
|
||||
</script>
|
||||
{/block}
|
||||
Loaded 3 of 7 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user