IcePHP框架中的快速后台中的通用CRUD功能框架(三) 具体业务示例

黄舟
发布: 2016-12-27 09:51:53
原创
1537人浏览过

//用于测试crud
public function crudtest() {
// @todo:整个功能权限检查

// 创建一个crud主表对象
$crud = new scrud ( 'twh_adminstractor', $this->controller, $this->action );

// 对字段进行配置
$crud->field ( 'sort' )->isabandon = true;

$crud->field ( 'id' )->title = "编号";

$adm_pwd = $crud->field ( 'adm_pwd' );
$adm_pwd->ispassword = true;
$adm_pwd->encode ( function ($v) {
return md5 ( $v );
} );

$count = $crud->field ( 'count' );
$count->ininsert = false;
$count->inupdate = false;

$endip = $crud->field ( 'endip' );
$endip->ininsert = false;
$endip->inupdate = false;

$status = $crud->field ( 'status' );
$status->enum = array (
'0' => '禁用',
'1' => '启用' 
);
$status->title = "状态";
$status->updatetype = 'radio';

$createtime = $crud->field ( 'createtime' );
$createtime->iscreated = true;
$createtime->searchtype = 'daterange';
$createtime->decode ( function ($v) {
return date ( 'y-m-d h:i:s', intval ( $v ) );
} );

$endtime = $crud->field ( 'endtime' );
$endtime->isupdated = true;
$endtime->searchtype = 'daterange';
$endtime->decode ( function ($v) {
return date ( 'y-m-d h:i:s', intval ( $v ) );
} );

// 启用被禁止的用户
$enable = $crud->operationrow ( 'enable' );
$enable->title = "启用";
$enable->filter = function ($row) {
return $row ['status'] == 0 and $row ['id'] != 1;
};
$enable->do = array($this,'doenable');

// 禁用已经启用的用户
$disable = $crud->operationrow ( 'disable' );
$disable->title = "禁用";
$disable->filter = function ($row) {
return $row ['status'] == 1 and $row ['id'] != 1;
};
$disable->do=array($this,'dodisable');

// 权限设置
$auth = $crud->operationrow ( 'setauth' );
$auth->title = "权限管理";
$auth->filter = function ($row) {
return $row ['status'] == 1 and $row ['id'] != 1;
};
$auth->do=array($this,'dosetauth');


$toperation=$crud->operationtable('toperation');
$toperation->title="表级操作";
$toperation->do=array($this,'toperation');

$moperation=$crud->operationmulti('moperation');
$moperation->title="多选操作";
$moperation->confirm=false;
$moperation->do=array($this,'moperation');

$crud->process ( $this->request );
}

public function moperation(){
echo '测试通用多选操作';
dump($this->request->ids);
return array('msg'=>'执行了一个通用多选操作'); 
}

public function toperation(){
echo '测试通用表级操作';
return array('msg'=>'执行了一个通用表级操作','go'=>'list');
}

public function doenable(){
echo '启用一个用户';
return array('msg'=>'启用了一个用户','go'=>'list');
}

public function dodisable(){
echo '禁用一个用户';
return array('msg'=>'禁用了一个用户','go'=>'list');
}

public function dosetauth(){
echo '设置权限 ';
return array('msg'=>'设置权限,将要跳到另一个地址','go'=>lurl::ice().'/?c=maintain&a=setauth');

}

以上代码并不能独立运行,需要整个框架的支持,但开发人员可从中摘取相应的功能

 以上就是IcePHP框架中的快速后台中的通用CRUD功能框架(三) 具体业务示例的内容,更多相关内容请关注PHP中文网(www.php.cn)!

立即学习PHP免费学习笔记(深入)”;

文心智能体平台
文心智能体平台

百度推出的基于文心大模型的Agent智能体平台,已上架2000+AI智能体

文心智能体平台 0
查看详情 文心智能体平台

 以上就是IcePHP框架中的快速后台中的通用CRUD功能框架(三) 具体业务示例的内容,更多相关内容请关注PHP中文网(www.php.cn)!

立即学习PHP免费学习笔记(深入)”;

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号