添加批零订单备注功能
parent
3d43fefa9c
commit
42ac296c1c
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Actions\Show;
|
||||
|
||||
use App\Admin\Forms\DealerOrderRemark as DealerOrderRemarkForm;
|
||||
use Dcat\Admin\Show\AbstractTool;
|
||||
use Dcat\Admin\Widgets\Modal;
|
||||
|
||||
class DealerOrderRemark extends AbstractTool
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected $title = '<i class="feather icon-file-text"></i> 备注';
|
||||
|
||||
/**
|
||||
* 按钮样式定义,默认 btn btn-white waves-effect
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $style = 'btn-success';
|
||||
|
||||
public function render()
|
||||
{
|
||||
$form = DealerOrderRemarkForm::make()->payload(['id'=>$this->getKey()]);
|
||||
return Modal::make()
|
||||
->lg()
|
||||
->title($this->title)
|
||||
->body($form)
|
||||
->button("<a href=\"javascript:void(0)\" class=\"btn btn-sm {$this->style}\">{$this->title}</a> ");
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ namespace App\Admin\Controllers;
|
|||
use App\Admin\Actions\Grid\DealerOrderAllocate;
|
||||
use App\Admin\Actions\Grid\DealerOrderPaid;
|
||||
use App\Admin\Actions\Grid\DealerOrderShipping;
|
||||
use App\Admin\Actions\Show\DealerOrderRemark;
|
||||
use App\Admin\Repositories\DealerOrder;
|
||||
use App\Enums\DealerOrderStatus;
|
||||
use App\Models\DealerOrderProduct;
|
||||
|
|
@ -126,7 +127,7 @@ class DealerOrderController extends AdminController
|
|||
return $value??'系统';
|
||||
});
|
||||
$show->field('pay_image')->image();
|
||||
// $show->field('order_status')
|
||||
$show->field('remark');
|
||||
$show->divider();
|
||||
$show->field('consignee_name');
|
||||
$show->field('consignee_telephone');
|
||||
|
|
@ -185,6 +186,9 @@ class DealerOrderController extends AdminController
|
|||
->tools(function (Show\Tools $tools) use ($show) {
|
||||
$tools->disableEdit();
|
||||
$tools->disableDelete();
|
||||
if (Admin::user()->can('dcat.admin.dealer_orders.remark')) {
|
||||
$tools->append(new DealerOrderRemark());
|
||||
}
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Forms;
|
||||
|
||||
use App\Exceptions\BizException;
|
||||
use App\Models\DealerOrder;
|
||||
use Dcat\Admin\Contracts\LazyRenderable;
|
||||
use Dcat\Admin\Traits\LazyWidget;
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Throwable;
|
||||
|
||||
class DealerOrderRemark extends Form implements LazyRenderable
|
||||
{
|
||||
use LazyWidget;
|
||||
|
||||
/**
|
||||
* 权限判断,如不需要可以删除此方法
|
||||
*
|
||||
* @param Model|Authenticatable|HasPermissions|null $user
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorize($user): bool
|
||||
{
|
||||
return $user->can('dcat.admin.dealer_orders.remark');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the form request.
|
||||
*
|
||||
* @param array $input
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(array $input)
|
||||
{
|
||||
$orderId = $this->payload['id'] ?? 0;
|
||||
$order = DealerOrder::findOrFail($orderId);
|
||||
|
||||
$remark = $input['remark']??'';
|
||||
// try {
|
||||
// DB::beginTransaction();
|
||||
$order->update([
|
||||
'remark'=> $remark,
|
||||
]);
|
||||
// DB::commit();
|
||||
// } catch (Throwable $th) {
|
||||
// DB::rollBack();
|
||||
// report($th);
|
||||
// throw new BizException('操作失败:'.$th->getMessage());
|
||||
// }
|
||||
return $this->response()
|
||||
->success(__('admin.update_succeeded'))
|
||||
->refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a form here.
|
||||
*/
|
||||
public function form()
|
||||
{
|
||||
$orderId = $this->payload['id'] ?? 0;
|
||||
$order = DealerOrder::findOrFail($orderId);
|
||||
|
||||
$this->text('remark')->required()->value($order->remark);
|
||||
|
||||
$this->disableResetButton();
|
||||
}
|
||||
}
|
||||
|
|
@ -45,6 +45,7 @@ class DealerOrder extends Model
|
|||
'shipping_time',
|
||||
'shippinged_time',
|
||||
'allocated_at', //分配时间
|
||||
'remark',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddRemarkToDealerOrdersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('dealer_orders', function (Blueprint $table) {
|
||||
//
|
||||
$table->string('remark')->nullable()->comment('订单备注');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('dealer_orders', function (Blueprint $table) {
|
||||
//
|
||||
$table->dropColumn('remark');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -322,6 +322,7 @@ class AdminPermissionSeeder extends Seeder
|
|||
'shipping'=>['name' =>'确认发货'],
|
||||
'allocate'=>['name' =>'自动分配'],
|
||||
'manager'=>['name' =>'系统订单'],
|
||||
'remark'=>['name' =>'备注'],
|
||||
],
|
||||
],
|
||||
'dealer_earnings'=>[
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ return [
|
|||
'consignor' => [
|
||||
'phone' => '发货用户',
|
||||
],
|
||||
'remark' => '备注',
|
||||
'total_amount' => '订单价格',
|
||||
'status' => '状态',
|
||||
'order_status'=>'状态',
|
||||
|
|
|
|||
Loading…
Reference in New Issue