- <?php
- $this->widget('zii.widgets.CListView', array(
- 'dataProvider'=>$model->search(),
- 'itemView'=>'product_saleing_view',
- 'emptyText'=>'暂时没有数据',
- 'selectAll'=>array('ids[]','id[]'),
- 'artLink'=>array(
- //首页推荐
- array(Yii::t('cmp','Recommended home'),'/company/pruduct/recommend','确认推荐选中产品到首页!'),
- //取消推荐
- array(Yii::t('cmp','un Recommended home'),'/company/pruduct/uncommend','确认取消推荐选中产品!'),
- //下架
- array(Yii::t('cmp','downshelf'),'/company/pruduct/downshelf','确认上架选中产品!'),
- ),
- ));
- ?>
- <?php $this->endWidget(); ?>
控制器接收批处理操作
- public function actionRecommend(){
- //操作ID号格式处理
- $id = isset($_GET['id'])?$_GET['id']:$_POST['id'];
- $id = is_array($id)?join(',',$id):(int)$id;
- //处理条件
- $criteria=new CDbCriteria;
- $criteria->addCondition("zp_id in ($id)");
- //修改内容
- $set = array('zp_commend'=>'2');
- //执行操作
- if(Product::model()->updateAll($set,$criteria)){
- //成功跳转
- $this->render('../index/success',array(
- 'message'=>'恭喜,宝贝推荐成功!',
- 'links'=>array(
- array('返回商品管理页面','/company/product/saleing'),
- ),
- ));
- exit;
- }else{
- //失败跳转
- $this->render('../index/error',array(
- 'message'=>'恭喜,宝贝推荐失败!',
- 'links'=>array(
- array('返回商品管理页面','/company/product/saleing'),
- ),
- ));
- exit;
- }
- }
- js/art_show.js
//全选批操作 function batch(url,message){ art.dialog({ title: '批量操作', okValue:'确认', cancelValue:'取消', width: 230, height: 100, content: "<form id='art_dialog' method='post' action='"+url+"' ><div class='updtitle'><p class='fs_14 jg' style='margin-top:10px;'>"+message+"</p><p id='proid'></p></form>", ok: function () { $("#art_dialog").submit(); return false; }, cancel: function () { return true; }, }); var e = document.getElementsByName('id[]'); for (var i=0; i<e.length; i++) if(e[i].checked){ document.getElementById('proid').innerHTML +="<input type='hidden' name='id[]' value='"+e[i].value+"' />" } }