Prechádzať zdrojové kódy

provider_group DelAll button

xiaoyu 3 rokov pred
rodič
commit
f4cf38627e

+ 17 - 0
admin/control/provider_group.php

@@ -71,6 +71,23 @@ class provider_groupControl extends SystemControl
             Tpl::showpage('provider.group.edit');
         }
     }
+    
+    public function DelGroupsOp()
+    {
+        $group_ids = $_GET['group_ids'];
+        $cond['group_id'] = ['in', $group_ids];
+        try {
+            $mod = Model('provider_group');
+            $trans = new trans_wapper($mod, __METHOD__);
+            $mod->delGroup($cond);
+            $mod->delGroupInfo($cond);
+            $trans->commit();
+            showMessage('操作成功', 'index.php?act=provider_group&op=index');
+        } catch (Exception $e) {
+            $trans->rollback();
+            showMessage('操作失败', '');
+        }
+    }
 
     public function provider_chooseOp()
     {

+ 53 - 14
admin/templates/default/provider.group.list.php

@@ -30,25 +30,25 @@
             </tbody>
         </table>
     </form>
-    <!--   <table class="table tb-type2" id="prompt">-->
-    <!--    <tbody>-->
-    <!--      <tr class="space odd">-->
-    <!--        <th colspan="12"><div class="title">-->
-    <!--            <h5>--><?php //echo $lang['nc_prompts'];?><!--</h5>-->
-    <!--            <span class="arrow"></span></div></th>-->
-    <!--      </tr>-->
-    <!--      <tr>-->
-    <!--        <td><ul>-->
-    <!--            <li>--><?php //echo $lang['store_help1'];?><!--</li>-->
-    <!--          </ul></td>-->
-    <!--      </tr>-->
-    <!--    </tbody>-->
-    <!--  </table>-->
+    <table class="tb-type1 noborder search">
+        <tr>
+            <td>
+                <a href="#" class="btns"  id="hDel">
+                    <span><i class="icon-edit"></i>批量删除</span>
+                </a>
+            </td>
+        </tr>
+    </table>
     <form method="post" id="merchant_name_form">
         <input type="hidden" name="form_submit" value="ok"/>
         <table class="table tb-type2">
             <thead>
             <tr class="thead">
+                <th class="align-left" id="selectAll">
+                    <label>
+                        <input type="checkbox" name="chbox" value="">
+                    </label>
+                </th>
                 <th>通道组ID</th>
                 <th>通道组名称</th>
                 <th>备注信息</th>
@@ -60,6 +60,9 @@
             <?php if (!empty($output['group_list']) && is_array($output['group_list'])) { ?>
                 <?php foreach ($output['group_list'] as $k => $v) { ?>
                     <tr class="trFlex">
+                        <td class="align-left">
+                            <label for="checkBoxList"><input type="checkbox" id="checkBoxList" name="checkbox" value="<?php echo $v['group_id'];?>"></label>
+                        </td>
                         <td><?php echo $v['group_id']; ?></td>
                         <td><?php echo $v['group_name']; ?></td>
                         <td><?php echo $v['bz']; ?></td>
@@ -87,6 +90,7 @@
         </table>
     </form>
 </div>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/refill/layer.js"></script>
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.edit.js" charset="utf-8"></script>
 <script>
     $(function () {
@@ -102,5 +106,40 @@
                 $(this)[0].style.backgroundColor = '#fff'
             })
         })
+        //全选
+        $('#selectAll' ).click ( function () {
+            if ($("input[name='chbox']").is(':checked')) {
+                $("input[name='checkbox']").each(function() {
+                    this.checked = true;
+                })
+            } else {
+                $("input[name='checkbox']").each(function() {
+                    this.checked = false;
+                })
+            }
+        })
+        let get_sel_id = function (){
+            let arr = [];
+            $("input:checkbox:checked").each(function () {
+                let sel_id = $(this).val();
+                if(sel_id !== '') {
+                    arr.push(sel_id);
+                }
+            })
+            if (arr.length <= 0) { return}
+            return arr.join(",")
+        }
+        //批量删除
+        $('#hDel').click(function () {
+            layer.confirm('您确定要批量删除', {
+                btn: ['确定', '取消'],
+                title: '批量删除'
+            }, function () {
+                const batch = get_sel_id();
+                window.location.href = `index.php?act=provider_group&op=DelGroups&group_ids= ${batch ? batch : ''}`
+            }, function () {
+                layer.msg('取消成功')
+            });
+        })
     });
 </script>

+ 3 - 0
data/model/provider_group.model.php

@@ -27,6 +27,9 @@ class provider_groupModel extends Model
     {
         return $this->field($field)->where($condition)->order($order)->limit($limit)->page($page)->select();
     }
+    public function delGroup($condition){
+        return $this->where($condition)->delete();
+    }
 
     public function getGroupInfo($condition, $field = '*')
     {