diff --git a/application/common/model/Order.php b/application/common/model/Order.php index 24737de..8604719 100644 --- a/application/common/model/Order.php +++ b/application/common/model/Order.php @@ -61,4 +61,18 @@ class Order extends Model return $images; } + + public function getMaterialImagesAttr($val) + { + if (empty($val)) { + return []; + } + + $images = explode(',', $val); + foreach ($images as $k => $v) { + $images[$k] = cdnurl($v, true); + } + + return $images; + } } diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index d7e7cc1..20b6911 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -228,6 +228,9 @@ class OrderDispatchService extends BaseService 'images', 'status', 'coupon_id', + 'is_material_used', + 'material_cost', + 'material_images', ]; $orderDispatchFields = [ 'id', @@ -384,6 +387,18 @@ class OrderDispatchService extends BaseService $orderDispatch->images = $this->removeStrCdnUrl($params['complete_images']); $orderDispatch->finish_time = $time; + // 材料相关 + $order = $this->getOrderModel()->where('id', $orderDispatch->order_id)->find(); + // 是否使用材料 + $order->is_material_used = $params['is_material_used']; + if ($order->is_material_used == 1) { + // 材料成本 + $order->material_cost = $params['material_cost']; + // 材料凭证图片组 + $order->material_images = $this->removeStrCdnUrl($params['material_images']); + $order->save(); + } + if ($params['receive_type'] == 1) { $orderDispatch->image = $this->removeStrCdnUrl($params['payment_image']); $orderDispatch->offline_total_type = $params['offline_total_type']; diff --git a/application/worker/validate/OrderDispatch.php b/application/worker/validate/OrderDispatch.php index 4e5553e..eef48e1 100644 --- a/application/worker/validate/OrderDispatch.php +++ b/application/worker/validate/OrderDispatch.php @@ -27,6 +27,11 @@ class OrderDispatch extends Validate 'is_finish_today|今日完成' => 'require|in:0,1', 'estimated_finish_time|完成时间' => 'require|date', 'work_progress|当前施工进度' => 'max:200', + + //材料相关 + 'is_material_used|是否使用材料' => 'require|in:0,1', + 'material_cost|材料成本' => 'requireIf:is_material_used,1|number|between:0,10000000', + 'material_images|材料凭证' => 'requireIf:is_material_used,1|max:1000', ]; protected $message = [ @@ -39,7 +44,7 @@ class OrderDispatch extends Validate 'info' => ['order_dispatch_id'], 'appointmentTime' => ['order_dispatch_id', 'plan_time'], 'arrivedOnSite' => ['order_dispatch_id', 'images'], - 'completeService' => ['order_dispatch_id', 'complete_images', 'offline_total_type', 'amount', 'payment_image', 'offline_total_type'], + 'completeService' => ['order_dispatch_id', 'complete_images', 'offline_total_type', 'amount', 'payment_image', 'offline_total_type', 'is_material_used', 'material_cost', 'material_images'], 'saveWorkerRemark' => ['order_dispatch_id', 'worker_remark'], 'updateProgress' => ['order_dispatch_id', 'is_finish_today', 'estimated_finish_time', 'work_progress'], ]; diff --git a/public/assets/js/backend/orders/configorder.js b/public/assets/js/backend/orders/configorder.js index 124f56d..715a0ba 100644 --- a/public/assets/js/backend/orders/configorder.js +++ b/public/assets/js/backend/orders/configorder.js @@ -61,7 +61,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'refund_amount', title: __('Refund_amount'), operate:false}, {field: 'real_amount', title: __('Real_amount'), operate:false}, {field: 'cost', title: __('Cost'), operate:false}, - {field: 'material_cost', title: __('材料成本'), operate:false}, + { + field: 'material_cost_text', title: '材料成本', + operate: false, + cellStyle: {css: {"text-align": "left !important"}}, + formatter: function (val, row) { + if (row.is_material_used === 1) { + return `¥${row.material_cost}` + } + return '无' + }}, + {field: 'material_images', title: __('材料凭证'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images}, {field: 'performance', title: __('Performance'), operate:false}, // {field: 'dispatch_type', title: __('Dispatch_type')},