12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- class DpsbTypeAction extends CommonAction {
- const tableName = 'dpsb_type';
- const pkName = 'ID';
-
-
- function sys_list( ){
- $list = new \Jms\Gui\ClGrid();
- $list->right_filter = function($right,$type){
- $page = $_SERVER['PATH_INFO'];
- return \Jms\Ucenter\Right::defaultFilter($page,$right,$type);
- };
- $list->display($this);
- }
-
-
- function sys_addedit( ){
- $form = new \Jms\Gui\ClForm();
- $form->before_add = function(&$data){
- $data['TypeName'] = trim($data['TypeName']);
- $data['DeviceModel'] = trim($data['DeviceModel']);
- //检查设备型号是否重复
- $where = array('TypeName'=>$data['TypeName'],'DeviceModel'=>$data['DeviceModel']);
- $count = M('dpsb_type')->where($where)->count();
- if($count > 0){
- json_fail('设备型号已存在');
- }
- };
- $form->before_modify = function(&$data){
- $id = I('get.id');
- $data['TypeName'] = trim($data['TypeName']);
- $data['DeviceModel'] = trim($data['DeviceModel']);
- $where = array('TypeName'=>$data['TypeName'],'DeviceModel'=>$data['DeviceModel'],'ID'=>array('neq',$id));
- $count = M('dpsb_type')->where($where)->count();
- if($count > 0){
- json_fail('设备型号已存在');
- }
- };
- $form->display($this);
- }
-
-
- public function sys_del( ){
- $grid = new \Jiaruan\GridData();
- $grid->before_delete = function(&$data){
- $where = array('DeviceTypeId' => $data['ID']);//检查是否有设备存在
- $count = M('dpsb_device')->where($where)->count();
- if($count > 0){
- json_fail('该类型下有设备在使用,不能删除');
- }
- };
- $grid->deleteByPk($this);
- }
-
- }
|