浏览代码

多选编辑

zealerChina 1 年之前
父节点
当前提交
65e73348c7

+ 51 - 0
application/admin/controller/Produceorder.php

@@ -985,4 +985,55 @@ class Produceorder extends Backend
 
         $this->success();
     }
+
+    /**
+     * 批量编辑
+     *
+     * @param [type] $ids
+     * @return void
+     */
+    public function multi_edit($ids)
+    {
+        if($this->request->isGet()) {
+            // 获取旗子数据
+            $flags = [
+                '#FF0000' => "<span style='color: #FF0000;font-size: 24px; '>&#127987;</span>",
+                '#FFFF00' => "<span style='color: #FFFF00;font-size: 24px; '>&#127987;</span>",
+                '#00FF33' => "<span style='color: #00FF33;font-size: 24px; '>&#127987;</span>",
+                '#0033FF' => "<span style='color: #0033FF;font-size: 24px; '>&#127987;</span>",
+                '#9900FF' => "<span style='color: #9900FF;font-size: 24px; '>&#127987;</span>",
+                '#00CCFF' => "<span style='color: #00CCFF;font-size: 24px; '>&#127987;</span>",
+            ];
+            $this->assign('flags', $flags);
+
+            return view();
+        }else{
+            $tempData=input('row/a');
+            $data=[];
+            $infoData=[];
+
+            if(!empty($tempData['flag'])){
+                $data['flag']=$tempData['flag'];
+            }
+            if(!empty($tempData['produce_id'])){
+                $data['produce_id']=$tempData['produce_id'];
+            }
+            if(!empty($tempData['remark'])){
+                $data['remark']=$tempData['remark'];
+            }
+
+            if($data) {
+                $orders = $this->model->whereIn('id', $ids)->select();
+                foreach ($orders as $order) {
+                    foreach ($data as $key => $value) {
+                        $order->$key = $value;
+                        $order->save();
+                    }
+                }
+            }
+
+            $this->success();
+        }
+    }
+
 }

+ 1 - 0
application/admin/view/produceorder/index.html

@@ -54,6 +54,7 @@
                         <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
                         <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('mobile_order/add')?'':'hide'}" title="{:__('Add')}" > {:__('Add')}</a>
                         <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('produceorder/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-multi-edit btn-disabled disabled {:$auth->check('mobile/multi_edit')?'':'hide'}" title="{:__('Edit')}" > {:__('批量编辑')}</a>
                         <!--                        <a target="_blank" class="btn btn-info btn-export" title="{:__('导出')}" style="display: none"> 导出</a>-->
                         <!--                        {eq name="is_proxy" value="0"}-->
                         <!--                        <a href="javascript:;" class="btn btn-default" style="font-size:14px;color:dodgerblue;">-->

+ 32 - 0
application/admin/view/produceorder/multi_edit.html

@@ -0,0 +1,32 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('产品ID')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-produce_id" min="0" data-source="produce/index" class="form-control selectpage" name="row[produce_id]" type="text" value="">
+        </div>
+    </div>
+
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('备注')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <textarea id="c-remark" class="form-control" name="row[remark]" type="text"></textarea>
+        </div>
+    </div>
+    
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('旗子')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            {foreach name="flags" item="vo"}
+            <label for="row[flag]-{$key}"><input id="row[flag]-{$key}" name="row[flag]" type="radio" value="{$key}"  /> {$vo}</label>
+            {/foreach}
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 17 - 1
public/assets/js/backend/produceorder.js

@@ -15,11 +15,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','clipboard'],
                         show_open_data_url: 'Produceorder/show_open_data',
                         detail_url: 'Produceorder/detail', // 详情
                         table: 'Produceorder',
+                        multi_edit_url: 'produceorder/multi_edit',
                     }
                 });
 
                 var table = $("#table");
 
+                $('.btn-multi-edit').click(function (){
+                    let ids=[]
+                    $('#table').bootstrapTable('getSelections').forEach(item=>{
+                        ids.push(item.id)
+                    })
+                    if(!ids.length){
+                        layer.alert('请选择')
+                        return
+                    }
+                    Fast.api.open(`${$.fn.bootstrapTable.defaults.extend.multi_edit_url}/ids/${ids.join(',')}`,'批量编辑')
+                })
+
                 table.on('post-common-search.bs.table', function (event, table) {
                     var form = $("form", table.$commonsearch);
                     $("input[name='s_id']", form).addClass("selectpage").data("source", "auth/admin/index2").data("primaryKey", "id").data("params",{"custom[proxy]":"0","custom[sub]":"1"}).data("field", "nickname").data("orderBy", "id asc");
@@ -125,7 +138,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','clipboard'],
                     {field: 'no', title: __('订单更新时间'),visible: false,operate: 'LIKE'},
                     {field: 'order_no', title: __('订单信息'),operate: false,formatter(_,order){
                             let a=[]
-                            a.push(`<div>订单号:<b class="btn-order_link" data-link="${order.order_no}">${order.order_no}</b></div>`)
+                            a.push(`<div>订单号:<b class="btn-order_link" data-link="${order.order_no}">${order.order_no}</b><span style='color: ${order.flag};font-size: 24px; '>&#127987;</span></div>`)
                             if(order.pay_no){
                                 a.push(`<div>支付单号:<b class="btn-order_link" data-link="${order.pay_no}">${order.pay_no}</b></div>`)
                             }
@@ -374,6 +387,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','clipboard'],
             add: function () {
                 Controller.api.bindevent();
             },
+            multi_edit: function () {
+                Controller.api.bindevent();
+            },
             edit: function () {
                 Controller.api.bindevent();
                 $(document).on('input propertychange','#c-trans_no',function (){