Browse Source

注销两个操作

chenyunyun 2 years ago
parent
commit
290155692d
2 changed files with 102 additions and 1 deletions
  1. 48 0
      application/admin/controller/Cannelorder.php
  2. 54 1
      public/assets/js/backend/cannelorder.js

+ 48 - 0
application/admin/controller/Cannelorder.php

@@ -109,4 +109,52 @@ class Cannelorder extends Backend
         return $this->view->fetch();
     }
 
+
+    /**
+     * 确认清点金额
+     */
+    public function confirm_amount($ids)
+    {
+
+        $row = $this->model->get(['id' => $ids]);
+        if (!$row) {
+            $this->error(__('No Results were found'));
+        }
+
+        if ($this->request->isPost()) {
+            $refund_money = $this->request->post('refund_money');
+            $param = [
+                'refund_money' => $refund_money,
+                'status' => 3,
+                'id' => $ids,
+            ];
+
+            $this->model->allowField(true)->isUpdate(true)->save($param);
+            $this->success("成功", null, ['id' => $ids]);
+        }
+        $this->view->assign("row", $row->toArray());
+        return $this->view->fetch();
+    }
+
+    /**
+     * 确认已退款
+     */
+    public function confirm_refund($ids)
+    {
+        $row = $this->model->get(['id' => $ids]);
+        if (!$row) {
+            $this->error(__('No Results were found'));
+        }
+        if ($this->request->isAjax()) {
+            $param = [
+                'status' => 4,
+                'id' => $ids,
+            ];
+
+            $this->model->allowField(true)->isUpdate(true)->save($param);
+
+            $this->success("成功", null, ['id' => $ids]);
+        }
+    }
+
 }

+ 54 - 1
public/assets/js/backend/cannelorder.js

@@ -11,6 +11,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     del_url: 'cannelorder/del',
                     multi_url: 'cannelorder/multi',
                     import_url: 'cannelorder/import',
+                    confirm_amount_url: 'cannelorder/confirm_amount',
+                    confirm_refund_url: 'cannelorder/confirm_refund',
                     table: 'user_cancel_order',
                 }
             });
@@ -93,7 +95,52 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                             title: __('Operate'),
                             table: table,
                             events: Table.api.events.operate,
-                            formatter: Table.api.formatter.operate
+                            formatter: Table.api.formatter.operate,
+                            buttons: [
+                                {
+                                    name: 'confirm_amount',
+                                    title: __('确认清点金额'),
+                                    classname: 'btn btn-xs btn-primary btn-dialog',
+                                    icon: 'fa fa-leaf',
+                                    url: 'cannelorder/confirm_amount',
+                                    visible: function (row) {
+                                        //重点在这
+                                        //返回true时按钮显示,返回false隐藏
+                                        if (row.status == 2) {
+                                            return true;
+                                        }
+                                        return false;
+                                    }
+                                },
+                                {
+                                    name: 'confirm_refund',
+                                    classname: 'btn btn-xs btn-primary btn-ajax',
+                                    icon: 'fa fa-magic',
+                                    confirm: '确认已退款?',
+                                    url: 'cannelorder/confirm_refund',
+                                    success: function (data, ret) {
+                                        //Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
+                                        //如果需要阻止成功提示,则必须使用return false;
+                                        Layer.alert(ret.msg);
+                                        table.bootstrapTable('refresh', {});
+                                        return false;
+                                    },
+                                    error: function (data, ret) {
+                                        console.log(data, ret);
+                                        Layer.alert(ret.msg);
+                                        table.bootstrapTable('refresh', {});
+                                        return false;
+                                    },
+                                    visible: function (row) {
+                                        //重点在这
+                                        //返回true时按钮显示,返回false隐藏
+                                        if (row.status == 3) {
+                                            return true;
+                                        }
+                                        return false;
+                                    }
+                                },
+                            ]
                         }
                     ]
                 ]
@@ -217,6 +264,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         edit: function () {
             Controller.api.bindevent();
         },
+        confirm_amount: function () {
+            Controller.api.bindevent();
+        },
+        confirm_refund: function () {
+            Controller.api.bindevent();
+        },
         api: {
             bindevent: function () {
                 Form.api.bindevent($("form[role=form]"));