/** * electricity 网店管理标签 */ public function electricity() { $Model = new \Think\Model(); //实例化空模型 $ecid = session($this->_userCfg['ECID']); $opt = " dealers.ecid = {$ecid} AND dealers.id=electricity.dealerId"; //判断是否为经销商登陆 if (session($this->_userCfg['DEALERID'])) { $id = session($this->_userCfg['DEALERID']); $root = session($this->_userCfg['DEALERID']); $opt .= " AND (dealers.id ={$id} OR dealers.root ={$root})"; } $this->assign('bindType', $Model->distinct(true)->field('dealers.id,dealers.name as dealerName')->table(array('sz12365_fw_company_dealers' => 'dealers', 'sz12365_fw_company_dealers_electricity' => 'electricity'))->where($opt)->select()); //获取所有经销商 if (I('post.id') != 'all' && I('post.id') != '') { $dealerId = I('post.id'); //经销商选择查询 $opt .= " AND electricity.dealerId = {$dealerId}"; } /** * 蒋东芸 * 2014/6/17 */ $count = $Model->field('dealers.name as dealerName,electricity.id,electricity.name as electriName')->table(array('sz12365_fw_company_dealers' => 'dealers', 'sz12365_fw_company_dealers_electricity' => 'electricity'))->where($opt)->order('dealers.id asc')->limit($page->firstRow . ',' . $page->listRows)->count(); $page = new \Think\Page($count, 15); // 实例化分页类 传入总记录数 $show = $page->show(); // 分页显示输出 // 进行分页数据查询 $result = $Model->field('dealers.name as dealerName,electricity.id,electricity.name as electriName')->table(array('sz12365_fw_company_dealers' => 'dealers', 'sz12365_fw_company_dealers_electricity' => 'electricity'))->where($opt)->order('dealers.id asc')->limit($page->firstRow . ',' . $page->listRows)->select(); $this->assign("item", $result); //赋值数据 $this->assign('page', $show); $this->display(); }