Merge branch 'develop' of https://gitea.hmily.club/liutk/internet-everythings-agricultural into develop
commit
9cd82c64bc
|
|
@ -53,7 +53,7 @@ class AdminUserController extends AdminController
|
|||
amisMake()->TextControl('username', __('admin.username'))->required(),
|
||||
amisMake()->TextControl('name', __('admin.admin_user.name'))->required(),
|
||||
amisMake()->TextControl('password', __('admin.password'))->type('input-password')->required()->validations(['minLength' => 6]),
|
||||
amisMake()->TextControl('confirm_password', __('admin.confirm_password'))->type('input-password')->validations(['minLength' => 6]),
|
||||
amisMake()->TextControl('confirm_password', __('admin.confirm_password'))->type('input-password')->required()->validations(['minLength' => 6]),
|
||||
amisMake()->SelectControl('roles', __('admin.admin_user.roles'))
|
||||
->searchable()
|
||||
->multiple()
|
||||
|
|
|
|||
|
|
@ -2,9 +2,76 @@
|
|||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Slowlyo\OwlAdmin\Controllers\AuthController as AdminAuthController;
|
||||
use Slowlyo\OwlAdmin\Renderers\{Page, Form, TextControl, ImageControl};
|
||||
|
||||
class AuthController extends AdminAuthController
|
||||
{
|
||||
public function userSetting(): \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\JsonResource
|
||||
{
|
||||
$user = $this->user();
|
||||
|
||||
$form = Form::make()
|
||||
->title()
|
||||
->panelClassName('px-48 m:px-0')
|
||||
->mode('horizontal')
|
||||
->data(Arr::only($user->toArray(), ['avatar', 'name']))
|
||||
->api('put:' . admin_url('/user_setting'))
|
||||
// ->persistDataKeys(['avatar', 'name'])
|
||||
// ->resetAfterSubmit()
|
||||
->body([
|
||||
ImageControl::make()
|
||||
->label(__('admin.admin_user.avatar'))
|
||||
->name('avatar')
|
||||
->receiver($this->uploadImagePath()),
|
||||
TextControl::make()
|
||||
->label(__('admin.admin_user.name'))
|
||||
->name('name')
|
||||
->required(),
|
||||
TextControl::make()
|
||||
->type('input-password')
|
||||
->label(__('admin.old_password'))
|
||||
->name('old_password'),
|
||||
TextControl::make()
|
||||
->type('input-password')
|
||||
->label('新密码')
|
||||
->name('password')
|
||||
->validations(['minLength' => 6])
|
||||
->requiredOn('!!this.old_password'),
|
||||
TextControl::make()
|
||||
->type('input-password')
|
||||
->label(__('admin.confirm_password'))
|
||||
->name('confirm_password')
|
||||
->validations(['minLength' => 6])
|
||||
->requiredOn('!!this.old_password'),
|
||||
]);
|
||||
|
||||
return $this->response()->success(Page::make()->body($form));
|
||||
}
|
||||
|
||||
public function saveUserSetting(): \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\JsonResource
|
||||
{
|
||||
$request = request();
|
||||
$request->validate([
|
||||
'old_password' => ['nullable', 'current_password:sanctum'],
|
||||
'password' => Rule::requiredIf($request->filled('old_password')),
|
||||
'confirm_password' => [Rule::requiredIf($request->filled('old_password')), 'same:password'],
|
||||
], [
|
||||
'password.required' => '新密码必填',
|
||||
'confirm_password.required' => '确认密码必填',
|
||||
'old_password.current_password' => __('admin.admin_user.old_password_error'),
|
||||
'confirm_password.same' => __('admin.admin_user.password_confirmation'),
|
||||
]);
|
||||
$user = $this->user();
|
||||
$attributes = $request->only(['avatar', 'name']);
|
||||
if ($request->filled('old_password')) {
|
||||
$attributes['password']
|
||||
= Hash::make($request->input('password'));
|
||||
}
|
||||
$user->update($attributes);
|
||||
return $this->response()->successMessage(__('admin.action_success'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,17 +44,23 @@ class CropPlantController extends AdminController
|
|||
amisMake()->TableColumn()->name('area')->label('收获面积m²'),
|
||||
amisMake()->TableColumn()->name('output')->label('收获产量kg'),
|
||||
amisMake()->TableColumn()->name('harvest_at')->label('收获时间'),
|
||||
])->itemActions([
|
||||
\amisMake()->DialogAction()->label('编辑')->dialog(
|
||||
Dialog::make()->title('编辑种植记录')->body($this->harvestEditForm())
|
||||
),
|
||||
\amisMake()->AjaxAction()->label('删除')->level('link')
|
||||
->actionType('ajax')
|
||||
->confirmText(__('admin.confirm_delete'))
|
||||
->api([
|
||||
'method' => 'delete',
|
||||
'url' => admin_url('crop-harvestes/${id}')
|
||||
])
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
\amisMake()
|
||||
->DialogAction()
|
||||
->label('编辑')
|
||||
->level('link')
|
||||
->dialog(Dialog::make()->title('编辑种植记录')->body($this->harvestEditForm())),
|
||||
\amisMake()
|
||||
->AjaxAction()
|
||||
->label('删除')
|
||||
->level('link')
|
||||
->actionType('ajax')
|
||||
->confirmText(__('admin.confirm_delete'))
|
||||
->api([
|
||||
'method' => 'delete',
|
||||
'url' => admin_url('crop-harvestes/${id}')
|
||||
])
|
||||
]),
|
||||
])
|
||||
]),
|
||||
]),
|
||||
|
|
|
|||
|
|
@ -108,6 +108,20 @@ class CustomRegionController extends AdminController
|
|||
1 => ['label' => '种植中','icon' => 'fa fa-warning','color' => '#ff9326'],
|
||||
2 => ['label' => '已结束','icon' => 'fa fa-check-circle','color' => '#ffb6b3']
|
||||
])->label('种植状态'),
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
amisMake()
|
||||
->DialogAction()
|
||||
->label('编辑')
|
||||
->level('link')
|
||||
->dialog(Dialog::make()->title('编辑种植记录')->body($this->plantEditForm())),
|
||||
amisMake()->AjaxAction()->label('删除')->level('link')
|
||||
->actionType('ajax')
|
||||
->confirmText(__('admin.confirm_delete'))
|
||||
->api([
|
||||
'method' => 'delete',
|
||||
'url' => admin_url('crop-plants/${id}')
|
||||
])
|
||||
]),
|
||||
])
|
||||
->itemAction([
|
||||
'type'=>'button',
|
||||
|
|
@ -136,18 +150,6 @@ class CustomRegionController extends AdminController
|
|||
])
|
||||
])
|
||||
])
|
||||
->itemActions([
|
||||
\amisMake()->DialogAction()->label('编辑')->dialog(
|
||||
Dialog::make()->title('编辑种植记录')->body($this->plantEditForm())
|
||||
),
|
||||
\amisMake()->AjaxAction()->label('删除')->level('link')
|
||||
->actionType('ajax')
|
||||
->confirmText(__('admin.confirm_delete'))
|
||||
->api([
|
||||
'method' => 'delete',
|
||||
'url' => admin_url('crop-plants/${id}')
|
||||
])
|
||||
])
|
||||
])
|
||||
]),
|
||||
])
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class RegionController extends AdminController
|
|||
Components::make()->decimalControl('area', '面积m²'),
|
||||
Components::make()->sortControl(),
|
||||
\amisMake()->SwitchControl()->name('is_enable')->value(1)->label('显示'),
|
||||
\amisMake()->TransferControl()->name('monitorModes')->label('关联监测')
|
||||
\amisMake()->TransferControl()->name('monitorModes')->label(__('region.monitor'))
|
||||
->selectMode('chained')->searchable(true)
|
||||
->joinValues(false)->extractValue(true)
|
||||
->options($monitorModeType),
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ Route::group([
|
|||
$router->get('/_settings', '\App\Admin\Controllers\IndexController@settings');
|
||||
$router->resource('system/admin_users', App\Admin\Controllers\AdminUserController::class);
|
||||
|
||||
// 用户设置
|
||||
$router->get('user_setting', [App\Admin\Controllers\AuthController::class, 'userSetting']);
|
||||
$router->put('user_setting', [App\Admin\Controllers\AuthController::class, 'saveUserSetting']);
|
||||
|
||||
$router->group([
|
||||
'prefix' => 'api',
|
||||
], function (Router $router) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ return [
|
|||
'logout' => '退出登录',
|
||||
'username' => '用户名',
|
||||
'password' => '密码',
|
||||
'old_password' => '旧密码',
|
||||
'old_password' => '原密码',
|
||||
'confirm_password' => '确认密码',
|
||||
'captcha' => '验证码',
|
||||
'captcha_error' => '验证码有误',
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
return [
|
||||
'cover' => '封面图',
|
||||
'monitor' => '关联监测点位',
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue