diff --git a/application/admin/controller/aftersales/Aftersale.php b/application/admin/controller/aftersales/Aftersale.php index f137c9d..ec94f8a 100644 --- a/application/admin/controller/aftersales/Aftersale.php +++ b/application/admin/controller/aftersales/Aftersale.php @@ -2,7 +2,13 @@ namespace app\admin\controller\aftersales; +use app\admin\model\Order; use app\common\controller\Backend; +use Exception; +use think\Db; +use think\exception\DbException; +use think\exception\PDOException; +use think\exception\ValidateException; /** * 售后列管理 @@ -72,4 +78,119 @@ class Aftersale extends Backend return $this->view->fetch(); } + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add() + { + if (false === $this->request->isPost()) { + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; + $this->model->validateFailException()->validate($validate); + } + $order = Order::get($params['order_id'],['dispatch']); + if(empty($order)){ + $this->error('订单不存在'); + } + if($order->status != Order::STATUS_FINISHED){ + $this->error('订单不是完成状态,不可进行今后'); + } + if(\app\admin\model\Aftersale::where('order_id',$params['order_id'])->where('status',[1,2,3])->find()){ + $this->error('订单已存在售后信息,不可重复创建'); + } + $params['admin_id'] = $this->auth->id; + $params['admin_user'] = $this->auth->nickname; + $params['worker_id'] = $order->dispatch->worker_id; + $params['worker_name'] = $order->dispatch->worker_name; + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function edit($ids = null) + { + $row = $this->model->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { + $this->error(__('You have no permission')); + } + if (false === $this->request->isPost()) { + $order = Order::where($row->order_id)->find(); + if(empty($order)){ + $this->error('订单不存在'); + } + if($order->status != Order::STATUS_FINISHED){ + $this->error('订单不是完成状态,不可进行今后'); + } + + $this->view->assign('order',$order); + $this->view->assign('row', $row); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; + $row->validateFailException()->validate($validate); + } + $params['handle_admin_id'] = $this->auth->id; + $params['handle_admin_user'] = $this->auth->nickname; + $result = $row->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if (false === $result) { + $this->error(__('No rows were updated')); + } + $this->success(); + } + + } diff --git a/application/admin/view/aftersales/aftersale/add.html b/application/admin/view/aftersales/aftersale/add.html index 46dec49..0b8c088 100644 --- a/application/admin/view/aftersales/aftersale/add.html +++ b/application/admin/view/aftersales/aftersale/add.html @@ -1,7 +1,7 @@
- +
diff --git a/application/admin/view/aftersales/aftersale/edit.html b/application/admin/view/aftersales/aftersale/edit.html index b0afe98..7077adf 100644 --- a/application/admin/view/aftersales/aftersale/edit.html +++ b/application/admin/view/aftersales/aftersale/edit.html @@ -1,9 +1,9 @@
- +
- +
@@ -85,12 +85,22 @@
-
- -
- + +
+ +
+
+ +
+ + +
+ +
+
    +
    -
    +
    @@ -108,7 +118,7 @@
    - +
    @@ -124,28 +134,12 @@
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    + +
    - +
    @@ -163,10 +157,13 @@
    + + {if condition='$row.status eq 1'} + {/if}
    diff --git a/public/assets/js/backend/aftersales/aftersale.js b/public/assets/js/backend/aftersales/aftersale.js index 7593f64..7a67575 100644 --- a/public/assets/js/backend/aftersales/aftersale.js +++ b/public/assets/js/backend/aftersales/aftersale.js @@ -35,25 +35,28 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"-1":__('Status -1')}, formatter: Table.api.formatter.status}, {field: 'handle_type', title: __('Handle_type'), searchList: {"1":__('Handle_type 1'),"2":__('Handle_type 2'),"3":__('Handle_type 3'),"4":__('Handle_type 4')}, formatter: Table.api.formatter.normal}, {field: 'from', title: __('From'), searchList: {"1":__('From 1'),"2":__('From 2'),"3":__('From 3')}, formatter: Table.api.formatter.normal}, - {field: 'refund_amount', title: __('Refund_amount'), operate:'BETWEEN'}, - {field: 'company_refund_amount', title: __('Company_refund_amount'), operate:'BETWEEN'}, - {field: 'worker_refund_amount', title: __('Worker_refund_amount'), operate:'BETWEEN'}, + {field: 'refund_amount', title: __('Refund_amount'), operate:false}, + {field: 'company_refund_amount', title: __('Company_refund_amount'), operate:false}, + {field: 'worker_refund_amount', title: __('Worker_refund_amount'), operate:false}, {field: 'refund_type', title: __('Refund_type'), searchList: {"1":__('Refund_type 1'),"2":__('Refund_type 2')}, formatter: Table.api.formatter.normal}, {field: 'worker_refund_entry', title: __('Worker_refund_entry'), searchList: {"0":__('Worker_refund_entry 0'),"1":__('Worker_refund_entry 1')}, formatter: Table.api.formatter.normal}, {field: 'refund_time', title: __('Refund_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'customer_appeal', title: __('Customer_appeal'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'customer_qrcode', title: __('Customer_qrcode'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'customer_appeal', title: __('Customer_appeal'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + //{field: 'customer_qrcode', title: __('Customer_qrcode'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + + {field: 'customer_qrcode', title: __('Customer_qrcode'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images}, + {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images}, - {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'company_refund_time', title: __('Company_refund_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'worker_refund_time', title: __('Worker_refund_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'remark', title: __('Remark'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'company_refund_time', title: __('Company_refund_time'), operate:false, addclass:'datetimerange', autocomplete:false}, + {field: 'worker_refund_time', title: __('Worker_refund_time'), operate:false, addclass:'datetimerange', autocomplete:false}, //{field: 'admin_id', title: __('Admin_id')}, {field: 'admin_user', title: __('Admin_user'), operate: 'LIKE'}, //{field: 'handle_admin_id', title: __('Handle_admin_id')}, {field: 'handle_admin_user', title: __('Handle_admin_user'), operate: 'LIKE'}, - {field: 'star', title: __('Star')}, + {field: 'star', title: __('Star'),operate:false}, {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'update_time', title: __('Update_time'), operate:false, addclass:'datetimerange', autocomplete:false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/orders/auditorder.js b/public/assets/js/backend/orders/auditorder.js index b675927..e237786 100644 --- a/public/assets/js/backend/orders/auditorder.js +++ b/public/assets/js/backend/orders/auditorder.js @@ -64,7 +64,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, //{field: 'auditadmin.username', title: __('Admin.username'), operate: 'LIKE'}, {field: 'auditadmin.nickname', title: __('Admin.nickname'), operate: 'LIKE'}, - {field: 'audit_remark', title: __('Audit_remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'audit_remark', title: __('Audit_remark'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate, diff --git a/public/assets/js/backend/orders/configorder.js b/public/assets/js/backend/orders/configorder.js index ac4a2bb..7739065 100644 --- a/public/assets/js/backend/orders/configorder.js +++ b/public/assets/js/backend/orders/configorder.js @@ -59,7 +59,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // {field: 'dispatch_type', title: __('Dispatch_type')}, {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'update_time', title: __('Update_time'), operate:false, addclass:'datetimerange', autocomplete:false}, diff --git a/public/assets/js/backend/orders/revisitorder.js b/public/assets/js/backend/orders/revisitorder.js index ef78508..c77c9a6 100644 --- a/public/assets/js/backend/orders/revisitorder.js +++ b/public/assets/js/backend/orders/revisitorder.js @@ -34,13 +34,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"10":__('Status 10'),"20":__('Status 20'),"30":__('Status 30'),"40":__('Status 40'),"50":__('Status 50'),"60":__('Status 60'),"-10":__('Status -10')}, formatter: Table.api.formatter.status}, // {field: 'area_id', title: __('Area_id'), operate: 'LIKE'}, - {field: 'address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'address', title: __('Address'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content}, // {field: 'source_shop', title: __('Source_shop'), operate: 'LIKE'}, // {field: 'source', title: __('Source')}, {field: 'item_title', title: __('Item_title'), operate: 'LIKE'}, - {field: 'detail', title: __('Detail'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'detail', title: __('Detail'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'customer', title: __('Customer'), operate: 'LIKE'}, {field: 'tel', title: __('Tel'), operate: 'LIKE'}, // {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, @@ -63,13 +63,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // {field: 'audit_remark', title: __('Audit_remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, // {field: 'audit_admin_id', title: __('Audit_admin_id')}, - {field: 'review.pt_star', title: __('Review.pt_star')}, - {field: 'review.worker_star', title: __('Review.worker_star')}, - {field: 'review.remark', title: __('回访备注'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'review.admin_user', title: __('Review.admin_user'), operate: 'LIKE'}, + {field: 'review.pt_star', title: __('Review.pt_star'),operate: false}, + {field: 'review.worker_star', title: __('Review.worker_star'),operate: false}, + {field: 'review.remark', title: __('回访备注'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'review.admin_user', title: __('Review.admin_user'), operate: false}, - {field: 'review.create_time', title: __('回访时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'review.create_time', title: __('回访时间'), operate:false, addclass:'datetimerange', autocomplete:false}, + {field: 'create_time', title: __('Create_time'), operate:false, addclass:'datetimerange', autocomplete:false}, // {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, // {field: 'delete_time', title: __('Delete_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, // {field: 'dispatch_type', title: __('Dispatch_type')},