generated from liutk/owl-admin-base
Merge branch 'main' of https://gitea.hmily.club/pdkj/store-manage into main
commit
95723d58f2
|
|
@ -41,7 +41,7 @@ abstract class AdminController extends Controller
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (Throwable $th) {
|
} catch (Throwable $th) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
throw $this->prepareException($th);
|
return $this->renderException($th);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response()->successMessage(__('admin.save').__('admin.successfully'));
|
return $this->response()->successMessage(__('admin.save').__('admin.successfully'));
|
||||||
|
|
@ -70,7 +70,7 @@ abstract class AdminController extends Controller
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (Throwable $th) {
|
} catch (Throwable $th) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
throw $this->prepareException($th);
|
return $this->renderException($th);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response()->successMessage(__('admin.save').__('admin.successfully'));
|
return $this->response()->successMessage(__('admin.save').__('admin.successfully'));
|
||||||
|
|
@ -89,7 +89,7 @@ abstract class AdminController extends Controller
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (Throwable $th) {
|
} catch (Throwable $th) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
throw $this->prepareException($th);
|
return $this->renderException($th);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response()->successMessage(__('admin.delete').__('admin.successfully'));
|
return $this->response()->successMessage(__('admin.delete').__('admin.successfully'));
|
||||||
|
|
@ -106,16 +106,23 @@ abstract class AdminController extends Controller
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function prepareException(Throwable $e)
|
protected function renderException(Throwable $e)
|
||||||
{
|
{
|
||||||
|
report($e);
|
||||||
|
|
||||||
|
if ($e instanceof AdminException) {
|
||||||
|
return $e->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = $e->getMessage();
|
||||||
|
|
||||||
if ($e instanceof ValidationException) {
|
if ($e instanceof ValidationException) {
|
||||||
$message = Arr::first($e->errors());
|
$message = Arr::first($e->errors());
|
||||||
if (is_array($message)) {
|
if (is_array($message)) {
|
||||||
$message = Arr::first($message);
|
$message = Arr::first($message) ?: '参数错误';
|
||||||
}
|
}
|
||||||
$e = new AdminException($message ?: '参数错误');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $e;
|
return $this->response()->fail($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ class PlanController extends AdminController
|
||||||
amis()->TableColumn('name', __('plan.task.name')),
|
amis()->TableColumn('name', __('plan.task.name')),
|
||||||
amis()->TableColumn('taskable.date', __('plan.task_ledger.date')),
|
amis()->TableColumn('taskable.date', __('plan.task_ledger.date')),
|
||||||
amis()->TableColumn('taskable.store.title', __('plan.task_ledger.store')),
|
amis()->TableColumn('taskable.store.title', __('plan.task_ledger.store')),
|
||||||
amis()->TableColumn('taskable.store.master.name', __('plan.task_ledger.store_master')),
|
amis()->TableColumn('taskable.store_master.name', __('plan.task_ledger.store_master')),
|
||||||
amis()->TableColumn('task_status', __('plan.task.status'))->type('mapping')->map(TaskStatus::labelMap()),
|
amis()->TableColumn('task_status', __('plan.task.status'))->type('mapping')->map(TaskStatus::labelMap()),
|
||||||
amis()->TableColumn('completed_at', __('plan.task.completed_at')),
|
amis()->TableColumn('completed_at', __('plan.task.completed_at')),
|
||||||
amis()->TableColumn('created_at', __('plan.task.created_at')),
|
amis()->TableColumn('created_at', __('plan.task.created_at')),
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class TaskController extends AdminController
|
||||||
->with([
|
->with([
|
||||||
'taskable' => function (MorphTo $morphTo) {
|
'taskable' => function (MorphTo $morphTo) {
|
||||||
$morphTo->morphWith([
|
$morphTo->morphWith([
|
||||||
TaskLedger::class => ['store.master'],
|
TaskLedger::class => ['store', 'storeMaster'],
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
|
||||||
|
|
@ -56,14 +56,14 @@ class TaskLedgerGenerateCommand extends Command
|
||||||
$planable->save();
|
$planable->save();
|
||||||
|
|
||||||
$plan = $planable->plan()->create([
|
$plan = $planable->plan()->create([
|
||||||
'name' => "{$planable->date} 总账录入",
|
'name' => "【{$planable->date}】总账录入",
|
||||||
'plan_status' => PlanStatus::Published,
|
'plan_status' => PlanStatus::Published,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $planable->setRelation('plan', $plan);
|
return $planable->setRelation('plan', $plan);
|
||||||
});
|
});
|
||||||
|
|
||||||
$stores = Store::all();
|
$stores = Store::with(['master'])->get();
|
||||||
|
|
||||||
/** @var \App\Models\Store */
|
/** @var \App\Models\Store */
|
||||||
foreach ($stores as $store) {
|
foreach ($stores as $store) {
|
||||||
|
|
@ -71,6 +71,8 @@ class TaskLedgerGenerateCommand extends Command
|
||||||
$taskable = TaskLedger::firstOrNew([
|
$taskable = TaskLedger::firstOrNew([
|
||||||
'store_id' => $store->id,
|
'store_id' => $store->id,
|
||||||
'date' => $planable->date,
|
'date' => $planable->date,
|
||||||
|
], [
|
||||||
|
'store_master_id' => $store->master?->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($taskable->exists) {
|
if ($taskable->exists) {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use Illuminate\Http\{Request};
|
use Illuminate\Http\{Request};
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Slowlyo\OwlAdmin\Exceptions\AdminException;
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
{
|
{
|
||||||
|
|
@ -21,6 +22,7 @@ class Handler extends ExceptionHandler
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $dontReport = [
|
protected $dontReport = [
|
||||||
|
AdminException::class,
|
||||||
RuntimeException::class,
|
RuntimeException::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,9 @@ class TaskLedger extends Model
|
||||||
use HasFactory, HasDateTimeFormatter;
|
use HasFactory, HasDateTimeFormatter;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'store_id',
|
|
||||||
'date',
|
'date',
|
||||||
|
'store_id',
|
||||||
|
'store_master_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function task(): MorphOne
|
public function task(): MorphOne
|
||||||
|
|
@ -26,4 +27,9 @@ class TaskLedger extends Model
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Store::class);
|
return $this->belongsTo(Store::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function storeMaster(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Employee::class, 'store_master_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,9 @@ return new class extends Migration
|
||||||
{
|
{
|
||||||
Schema::create('task_ledgers', function (Blueprint $table) {
|
Schema::create('task_ledgers', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->foreignId('store_id')->comment('门店ID');
|
|
||||||
$table->date('date')->comment('日期');
|
$table->date('date')->comment('日期');
|
||||||
|
$table->foreignId('store_id')->comment('门店ID');
|
||||||
|
$table->foreignId('store_master_id')->comment('店长');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue