123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace Home\Controller;
- use Think\Controller;
- class MaintController extends ComController {
-
- public function _initialize() {
- parent::_initialize();
- $this->dbname ='wb_wuye';
- }
- public function wuye(){
- $Data=I();
- if(isset($Data['list'])){
- $UserVIew=M('wb_wuye');
- $GetPage=$Data['pageCurrent'];//第几页
- $GetSize=$Data['pageSize'];//每页条数
- $Page=($GetPage-1)*$GetSize;
- $Map=array();
- if(!empty($Data['name'])){
- $Map['yw_name']=array("LIKE",'%'.$Data['name'].'%');
- }
- if(!empty($Data['phone'])){
- $Map['yw_phone']=array("LIKE",'%'.$Data['phone'].'%');
- }
- $permdata=$this->permdata();
- if (!empty($permdata))
- {
- $Map['yw_edit']=$permdata;
- }
- $Count= $UserVIew->where($Map)->count();// 查询满足要求的总记录数
- $List = $UserVIew->field("id,yw_name,yw_phone,yw_time,yw_edit,yw_type")->where($Map)->order('yw_time desc')
- ->limit($Page,$GetSize)->select();
- $Info = array(
- 'totalRow' => $Count,
- //'pageSize' => $count,//分页时不传
- 'list' => $List,
- );
- echo json_encode($Info);
- }
- else
- {
- $this->display();
- }
-
- }
- public function add(){
- if (IS_POST) {
- $Tab=M('wb_wuye');
- $rules = array(
- array('phone','','电话号码重复!',0,'unique'),
- );
- if (!$Tab->validate($rules)->create())
- {
- // echo json_encode(array('statusCode'=>'300','message'=> $menu->getError()));
- $this->mtReturn(300,$Tab->getError());
- }
- else
- {
- /*$PhoneRes=M('')->query('SELECT openid FROM ztcrm.sp_customuser where phone='.$Data['phone']);
- if (empty($PhoneRes)) {
- $this->mtReturn(300,'该号码未关注公众号,请先关注公众号注册信息才能录入');
- }*/
- $Data=I();
- $Data['yw_time']=date('Y-m-d H:i:s');
- $Data['yw_edit']=session('zt_username');
- $res = $Tab->add($Data);
- if($res)
- $this->mtReturn(200,'维保公司新增成功');
- else
- $this->mtReturn(300,'维保公司新增失败');
- }
-
- }
- else
- {
- $this->assign('action','/home/Maint/add');
- $this->display();
- }
- }
- public function edit(){
- $Data=I();
- $Tab=M('wb_wuye');
- if(IS_POST)
- {
- $this->logcs(print_r($Data,ture));
- $res=$Tab->save($Data);
- if($res)
- $this->mtReturn(200,'编辑成功');
- else
- $this->mtReturn(300,'编辑失败');
-
- }
- else
- {
- $ResData = $Tab->field("id,yw_name,yw_phone,yw_time,yw_edit,yw_type")->where(array('id'=>$Data['id']))->select();
- $this->assign('ResData',$ResData[0]);
- $this->assign('action','/home/Maint/edit');
- $this->display();
- }
- }
-
-
- }
|