更新功能
This commit is contained in:
@@ -33,4 +33,17 @@ class Admin extends BaseController {
|
|||||||
$this->data['config'] = $config;
|
$this->data['config'] = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function success($msg, $url){
|
||||||
|
$this->data['code'] = 0;
|
||||||
|
$this->data['msg'] = $msg;
|
||||||
|
$this->data['url'] = $url->__toString();
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function error($msg, $url){
|
||||||
|
$this->data['code'] = 1;
|
||||||
|
$this->data['msg'] = $msg;
|
||||||
|
$this->data['url'] = $url->__toString();
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,18 +35,19 @@ class Client extends Admin{
|
|||||||
public function add(ClientModel $client){
|
public function add(ClientModel $client){
|
||||||
if ($this->request->isPost()) {
|
if ($this->request->isPost()) {
|
||||||
$data = $this->request->param();
|
$data = $this->request->param();
|
||||||
$result = $client->validate(true)->save($data);
|
$result = $client->save($data);
|
||||||
if (false !== $result) {
|
if (false !== $result) {
|
||||||
return $this->success('成功添加', url('client/index'));
|
return $this->success('成功添加', url('/admin/client/index'));
|
||||||
}else{
|
}else{
|
||||||
return $this->error($this->model->getError());
|
return $this->error($this->model->getError());
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$info['appid'] = rand_string(10, 1); //八位数字appid
|
$info['appid'] = rand_string(10, 1); //八位数字appid
|
||||||
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
|
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
|
||||||
$data = array(
|
$this->data['data'] = array(
|
||||||
'info' => $info
|
'info' => $info
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,15 +58,20 @@ class Client extends Admin{
|
|||||||
public function edit(ClientModel $client){
|
public function edit(ClientModel $client){
|
||||||
if ($this->request->isPost()) {
|
if ($this->request->isPost()) {
|
||||||
$data = $this->request->param();
|
$data = $this->request->param();
|
||||||
$result = $client->validate(true)->save($data, array('id'=>$request->param('id')));
|
if (!isset($data['id']) || !$data['id']) {
|
||||||
|
return $this->error('非法操作!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $client->where(array('id'=>$data['id']))->save($data);
|
||||||
if (false !== $result) {
|
if (false !== $result) {
|
||||||
return $this->success('修改添加', url('client/index'));
|
return $this->success('修改成功', url('/admin/client/index'));
|
||||||
}else{
|
}else{
|
||||||
return $this->error($this->model->getError());
|
return $this->error($this->model->getError());
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$info = $client->where('id', $this->request->param('id'))->find();
|
$info = $client->where('id', $this->request->param('id'))->find();
|
||||||
$data = array(
|
$this->data['template'] = "add";
|
||||||
|
$this->data['data'] = array(
|
||||||
'info' => $info
|
'info' => $info
|
||||||
);
|
);
|
||||||
return $this->data;
|
return $this->data;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div class="main-box-body clearfix">
|
<div class="main-box-body clearfix">
|
||||||
<form method="post" class="form form-horizontal">
|
<form method="post" class="form form-horizontal" role="ajax">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-2 control-label">客户端名称</label>
|
<label class="col-md-2 control-label">客户端名称</label>
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<h2>{$meta_title|default='新功能'}</h2>
|
<h2>{$meta_title|default='新功能'}</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<a class="btn btn-primary" href="{:url('add')}">新 增</a>
|
<a class="btn btn-primary" href="{:url('/admin/client/add')}">新 增</a>
|
||||||
<button class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids">删 除</button>
|
<button class="btn btn-danger ajax-post confirm" url="{:url('/admin/client/del')}" target-form="ids">删 除</button>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div class="main-box-body clearfix">
|
<div class="main-box-body clearfix">
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
<th>名称</th>
|
<th>名称</th>
|
||||||
<th>APPID</th>
|
<th>APPID</th>
|
||||||
@@ -27,6 +28,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{volist name="list" id="item"}
|
{volist name="list" id="item"}
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
|
||||||
<td>{$item['id']}</td>
|
<td>{$item['id']}</td>
|
||||||
<td>{$item['title']}</td>
|
<td>{$item['title']}</td>
|
||||||
<td>{$item['appid']}</td>
|
<td>{$item['appid']}</td>
|
||||||
@@ -34,8 +36,8 @@
|
|||||||
<td>{$item['create_time']}</td>
|
<td>{$item['create_time']}</td>
|
||||||
<td>{$item['update_time']}</td>
|
<td>{$item['update_time']}</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{:url('client/edit?id='.$item['id'])}">编辑</a>
|
<a href="{:url('/admin/client/edit', array('id'=>$item['id']))}">编辑</a>
|
||||||
<a href="{:url('client/del?id='.$item['id'])}" class="ajax-post confirm">删除</a>
|
<a href="{:url('/admin/client/del', array('id'=>$item['id']))}" class="ajax-post confirm">删除</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/volist}
|
{/volist}
|
||||||
@@ -45,4 +47,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/block}
|
||||||
|
{block name="script"}
|
||||||
|
<script type="text/javascript">
|
||||||
|
var isLoadModule = true;
|
||||||
|
</script>
|
||||||
{/block}
|
{/block}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div class="main-box-body clearfix">
|
<div class="main-box-body clearfix">
|
||||||
<form method="post" class="form form-horizontal">
|
<form method="post" class="form form-horizontal" role="ajax">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-lg-2 control-label">配置标识</label>
|
<label class="col-lg-2 control-label">配置标识</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane fade in active" id="tab-home">
|
<div class="tab-pane fade in active" id="tab-home">
|
||||||
<form method="post" class="form form-horizontal" role="form">
|
<form method="post" class="form form-horizontal" role="ajax">
|
||||||
{volist name="list" id="item"}
|
{volist name="list" id="item"}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="inputEmail1" class="col-lg-2 control-label">{$item['title']}</label>
|
<label for="inputEmail1" class="col-lg-2 control-label">{$item['title']}</label>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div class="main-box-body clearfix">
|
<div class="main-box-body clearfix">
|
||||||
<form method="post" class="form form-horizontal" action="edit">
|
<form method="post" class="form form-horizontal" action="edit" role="ajax">
|
||||||
<div class="tabs-wrapper">
|
<div class="tabs-wrapper">
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
<li class="active"><a href="#pc" data-toggle="tab">PC端模板</a></li>
|
<li class="active"><a href="#pc" data-toggle="tab">PC端模板</a></li>
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ return [
|
|||||||
// 指定从服务器序号
|
// 指定从服务器序号
|
||||||
'slave_no' => '',
|
'slave_no' => '',
|
||||||
// 是否严格检查字段是否存在
|
// 是否严格检查字段是否存在
|
||||||
'fields_strict' => true,
|
'fields_strict' => false,
|
||||||
// 是否需要进行SQL性能分析
|
// 是否需要进行SQL性能分析
|
||||||
'sql_explain' => false,
|
'sql_explain' => false,
|
||||||
// 是否需要断线重连
|
// 是否需要断线重连
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ require.config({
|
|||||||
"nanoscroller":"/static/libs/nanoscroller/jquery.nanoscroller.min",
|
"nanoscroller":"/static/libs/nanoscroller/jquery.nanoscroller.min",
|
||||||
"slimscroll":"/static/js/jquery.slimscroll.min",
|
"slimscroll":"/static/js/jquery.slimscroll.min",
|
||||||
"bootstrap":"/static/libs/bootstrap/js/bootstrap.min",
|
"bootstrap":"/static/libs/bootstrap/js/bootstrap.min",
|
||||||
'bootstrap-table-commonsearch': 'bootstrap-table-commonsearch',
|
'bootstrap-table-commonsearch': '/static/js/bootstrap-table-commonsearch',
|
||||||
'bootstrap-table-template': 'bootstrap-table-template',
|
'bootstrap-table-template': '/static/js/bootstrap-table-template',
|
||||||
//
|
//
|
||||||
// 以下的包从bower的libs目录加载
|
// 以下的包从bower的libs目录加载
|
||||||
'jquery': '/static/libs/jquery/dist/jquery.min',
|
'jquery': '/static/libs/jquery/dist/jquery.min',
|
||||||
@@ -129,7 +129,7 @@ require.config({
|
|||||||
|
|
||||||
require(['jquery', 'sent'], function($, Sent){
|
require(['jquery', 'sent'], function($, Sent){
|
||||||
$(function($) {
|
$(function($) {
|
||||||
require(['backend', 'backend-init', 'addons'], function (Backend, undefined, Addons) {
|
require(['backend', 'addons'], function (Backend, Addons) {
|
||||||
// 避免目录冲突
|
// 避免目录冲突
|
||||||
require.config({baseUrl: '/static/admin/js/module/'});
|
require.config({baseUrl: '/static/admin/js/module/'});
|
||||||
|
|
||||||
|
|||||||
@@ -23,12 +23,45 @@ define(['jquery', 'toastr','layer'], function($, Toastr, Layer){
|
|||||||
|
|
||||||
init: function () {
|
init: function () {
|
||||||
|
|
||||||
|
//绑定表单提交事件
|
||||||
|
if($('form[role=ajax]').length > 0){
|
||||||
|
require(['form'], function(Form){
|
||||||
|
Form.api.bindevent($("form"));
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//绑定ajax请求事件
|
||||||
|
if($('.ajax-post').length > 0){
|
||||||
|
$('.ajax-post').on('click', function(e){
|
||||||
|
Sent.events.onAjaxRequest(this, e, 'post');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if($('.ajax-get').length > 0){
|
||||||
|
$('.ajax-post').on('click', function(e){
|
||||||
|
Sent.events.onAjaxRequest(this, e, 'get');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
//公共代码
|
//公共代码
|
||||||
//配置Toastr的参数
|
//配置Toastr的参数
|
||||||
Toastr.options = Sent.config.toastr;
|
Toastr.options = Sent.config.toastr;
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
|
//ajax请求
|
||||||
|
onAjaxRequest: function(obj, event, type){
|
||||||
|
event.preventDefault();
|
||||||
|
var url = $(obj).attr('href') ? $(obj).attr('href') : $(obj).attr('url');
|
||||||
|
if ($(obj).hasClass('confirm')) {
|
||||||
|
Layer.confirm('您确定需要'+$(obj).text()+'?', function(index){
|
||||||
|
Sent.api.ajax({type:type, url: url});
|
||||||
|
layer.close(index);
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
Sent.api.ajax({type:type, url: url});
|
||||||
|
}
|
||||||
|
},
|
||||||
//请求成功的回调
|
//请求成功的回调
|
||||||
onAjaxSuccess: function (ret, onAjaxSuccess) {
|
onAjaxSuccess: function (ret, onAjaxSuccess) {
|
||||||
var data = typeof ret.data !== 'undefined' ? ret.data : null;
|
var data = typeof ret.data !== 'undefined' ? ret.data : null;
|
||||||
@@ -85,6 +118,11 @@ define(['jquery', 'toastr','layer'], function($, Toastr, Layer){
|
|||||||
} else {
|
} else {
|
||||||
Sent.events.onAjaxError(ret, error);
|
Sent.events.onAjaxError(ret, error);
|
||||||
}
|
}
|
||||||
|
if (ret.url) {
|
||||||
|
setTimeout(function(){
|
||||||
|
window.location.href = ret.url;
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: function (xhr) {
|
error: function (xhr) {
|
||||||
index && Layer.close(index);
|
index && Layer.close(index);
|
||||||
@@ -249,19 +287,60 @@ define(['jquery', 'toastr','layer'], function($, Toastr, Layer){
|
|||||||
},
|
},
|
||||||
toastr: Toastr,
|
toastr: Toastr,
|
||||||
layer: Layer
|
layer: Layer
|
||||||
}
|
},
|
||||||
|
lang: function () {
|
||||||
|
var args = arguments,
|
||||||
|
string = args[0],
|
||||||
|
i = 1;
|
||||||
|
string = string.toLowerCase();
|
||||||
|
//string = typeof Lang[string] != 'undefined' ? Lang[string] : string;
|
||||||
|
if (typeof Lang !== 'undefined' && typeof Lang[string] !== 'undefined') {
|
||||||
|
if (typeof Lang[string] == 'object')
|
||||||
|
return Lang[string];
|
||||||
|
string = Lang[string];
|
||||||
|
} else if (string.indexOf('.') !== -1 && false) {
|
||||||
|
var arr = string.split('.');
|
||||||
|
var current = Lang[arr[0]];
|
||||||
|
for (var i = 1; i < arr.length; i++) {
|
||||||
|
current = typeof current[arr[i]] != 'undefined' ? current[arr[i]] : '';
|
||||||
|
if (typeof current != 'object')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (typeof current == 'object')
|
||||||
|
return current;
|
||||||
|
string = current;
|
||||||
|
} else {
|
||||||
|
string = args[0];
|
||||||
|
}
|
||||||
|
return string.replace(/%((%)|s|d)/g, function (m) {
|
||||||
|
// m is the matched format, e.g. %s, %d
|
||||||
|
var val = null;
|
||||||
|
if (m[2]) {
|
||||||
|
val = m[2];
|
||||||
|
} else {
|
||||||
|
val = args[i];
|
||||||
|
// A switch statement so that the formatter can be extended. Default is %s
|
||||||
|
switch (m) {
|
||||||
|
case '%d':
|
||||||
|
val = parseFloat(val);
|
||||||
|
if (isNaN(val)) {
|
||||||
|
val = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if($('form').length > 0){
|
|
||||||
require(['form'], function(Form){
|
|
||||||
Form.api.bindevent($("form"));
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//将Layer暴露到全局中去
|
//将Layer暴露到全局中去
|
||||||
window.Layer = Layer;
|
window.Layer = Layer;
|
||||||
//将Toastr暴露到全局中去
|
//将Toastr暴露到全局中去
|
||||||
window.Toastr = Toastr;
|
window.Toastr = Toastr;
|
||||||
//将Fast渲染至全局
|
//将语言方法暴露到全局中去
|
||||||
|
window.__ = Sent.lang;
|
||||||
|
//将Sent渲染至全局
|
||||||
window.Sent = Sent;
|
window.Sent = Sent;
|
||||||
|
|
||||||
Sent.init(); //默认初始化执行的代码
|
Sent.init(); //默认初始化执行的代码
|
||||||
|
|||||||
Reference in New Issue
Block a user