1
0
Fork 0
master
panliang 2023-08-31 18:00:27 +08:00
parent d5180b9043
commit 53f60bbf94
7 changed files with 42 additions and 7 deletions

View File

@ -5,6 +5,7 @@ namespace App\Admin;
use Slowlyo\OwlAdmin\Renderers\BaseRenderer; use Slowlyo\OwlAdmin\Renderers\BaseRenderer;
use Slowlyo\OwlAdmin\Renderers\WangEditor; use Slowlyo\OwlAdmin\Renderers\WangEditor;
use Slowlyo\OwlAdmin\Models\AdminUser; use Slowlyo\OwlAdmin\Models\AdminUser;
use Slowlyo\OwlAdmin\Services\AdminUserService;
class Components extends BaseRenderer class Components extends BaseRenderer
{ {
@ -122,7 +123,7 @@ class Components extends BaseRenderer
public function adminUserSelectControl() public function adminUserSelectControl()
{ {
$options = AdminUser::get(); $options = AdminUserService::make()->query()->get();
return amisMake()->SelectControl() return amisMake()->SelectControl()
->options($options) ->options($options)
->searchable() ->searchable()

View File

@ -8,7 +8,8 @@ use App\Admin\Services\PatientService;
use Slowlyo\OwlAdmin\Controllers\AdminController; use Slowlyo\OwlAdmin\Controllers\AdminController;
use Slowlyo\OwlAdmin\Renderers\Form; use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\Page; use Slowlyo\OwlAdmin\Renderers\Page;
use App\Models\Keyword; use App\Models\{Keyword, Patient};
use Illuminate\Http\Request;
/** /**
* 病人管理 * 病人管理
@ -145,4 +146,13 @@ class PatientController extends AdminController
return $this->typeOptions; return $this->typeOptions;
} }
public function getSelectOptions(Request $request)
{
$list = Patient::filter($request->all())->select(['id as value', 'name as label'])->sort()->get();
return $this->response()->success([
'items' => $list->items()
]);
}
} }

View File

@ -10,6 +10,7 @@ use App\Admin\Services\PatientRecordService;
use Slowlyo\OwlAdmin\Controllers\AdminController; use Slowlyo\OwlAdmin\Controllers\AdminController;
use Slowlyo\OwlAdmin\Renderers\Form; use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\Page; use Slowlyo\OwlAdmin\Renderers\Page;
use Slowlyo\OwlAdmin\Services\AdminUserService;
/** /**
* 病历管理 * 病历管理
@ -69,7 +70,7 @@ class PatientRecordController extends AdminController
] ]
]), ]),
amisMake()->DateTimeControl()->name('treat_at')->label(__('patient_record.treat_at'))->value(now())->required(), amisMake()->DateTimeControl()->name('treat_at')->label(__('patient_record.treat_at'))->value(now())->required(),
amisMake()->SelectControl()->options($this->getAdminUserOptions())->name('doctor_id')->label(__('patient_record.doctor_id'))->required(), amisMake()->SelectControl()->options($this->getAdminUserOptions())->searchable()->name('doctor_id')->label(__('patient_record.doctor_id'))->required(),
amisMake()->NumberControl()->name('origin_price')->label(__('patient_record.origin_price'))->required(), amisMake()->NumberControl()->name('origin_price')->label(__('patient_record.origin_price'))->required(),
amisMake()->NumberControl()->name('sell_price')->label(__('patient_record.sell_price'))->required(), amisMake()->NumberControl()->name('sell_price')->label(__('patient_record.sell_price'))->required(),
amisMake()->SelectControl()->options(OrderStatus::options())->name('order_status')->label(__('patient_record.order_status'))->default(OrderStatus::Success->value)->required(), amisMake()->SelectControl()->options(OrderStatus::options())->name('order_status')->label(__('patient_record.order_status'))->default(OrderStatus::Success->value)->required(),
@ -80,7 +81,7 @@ class PatientRecordController extends AdminController
->initFetch(false) ->initFetch(false)
->body(amisMake()->TextareaControl()->name('content')->label(__('patient_record.content'))), ->body(amisMake()->TextareaControl()->name('content')->label(__('patient_record.content'))),
amisMake()->DateTimeControl()->name('next_treat_at')->label(__('patient_record.next_treat_at')), amisMake()->DateTimeControl()->name('next_treat_at')->label(__('patient_record.next_treat_at')),
amisMake()->SelectControl()->options($this->getAdminUserOptions())->name('notify_user_id')->label(__('patient_record.notify_user_id')), amisMake()->SelectControl()->options($this->getAdminUserOptions())->searchable()->name('notify_user_id')->label(__('patient_record.notify_user_id')),
amisMake()->DateTimeControl()->name('notify_at')->label(__('patient_record.notify_at')), amisMake()->DateTimeControl()->name('notify_at')->label(__('patient_record.notify_at')),
amisMake()->TextControl()->name('notify_remarks')->label(__('patient_record.notify_remarks')), amisMake()->TextControl()->name('notify_remarks')->label(__('patient_record.notify_remarks')),
amisMake()->TextControl()->label(__('patient_record.creator_id'))->value($this->user()->name)->staitc(), amisMake()->TextControl()->label(__('patient_record.creator_id'))->value($this->user()->name)->staitc(),
@ -119,7 +120,7 @@ class PatientRecordController extends AdminController
public function getPatientOptions() public function getPatientOptions()
{ {
if (!$this->patientOptions) { if (!$this->patientOptions) {
$this->patientOptions = Patient::select(['id as value', 'name as label'])->get(); $this->patientOptions = Patient::select(['id as value', 'name as label'])->sort()->get();
} }
return $this->patientOptions; return $this->patientOptions;
@ -128,7 +129,7 @@ class PatientRecordController extends AdminController
public function getAdminUserOptions() public function getAdminUserOptions()
{ {
if (!$this->adminUserOptions) { if (!$this->adminUserOptions) {
$this->adminUserOptions = AdminUser::select(['id as value', 'name as label'])->get(); $this->adminUserOptions = AdminUserService::make()->query()->select(['id as value', 'name as label'])->get();
} }
return $this->adminUserOptions; return $this->adminUserOptions;

View File

@ -79,7 +79,7 @@ class BaseService extends AdminService
public function update($primaryKey, $data): bool public function update($primaryKey, $data): bool
{ {
$data = $this->resloveData($data); $data = $this->resloveData($data);
$model = $this->query()->whereKey($primaryKey)->first(); $model = $this->query()->whereKey($primaryKey)->firstOrFail();
$validate = $this->validate($data, $model->id); $validate = $this->validate($data, $model->id);
if ($validate !== true) { if ($validate !== true) {
$this->setError($validate); $this->setError($validate);

View File

@ -14,6 +14,23 @@ class PatientService extends BaseService
protected string $modelFilterName = PatientFilter::class; protected string $modelFilterName = PatientFilter::class;
public function listQuery()
{
$model = $this->getModel();
$filter = $this->getModelFilter();
$query = $this->query();
if ($this->withRelationships) {
$query->with($this->withRelationships);
}
if ($filter) {
$query->filter(request()->input(), $filter);
}
return $query->sort();
}
/** /**
* 处理表单数据 * 处理表单数据
* *

View File

@ -25,6 +25,7 @@ Route::group([
$router->get('keywords/tree-list', '\App\Admin\Controllers\KeywordsController@getTreeList')->name('api.keywords.tree-list'); $router->get('keywords/tree-list', '\App\Admin\Controllers\KeywordsController@getTreeList')->name('api.keywords.tree-list');
$router->get('keywords/list', '\App\Admin\Controllers\KeywordsController@getList')->name('api.keywords.get_list'); $router->get('keywords/list', '\App\Admin\Controllers\KeywordsController@getList')->name('api.keywords.get_list');
$router->get('category/content', '\App\Admin\Controllers\CategoryController@getContent')->name('api.category.content'); $router->get('category/content', '\App\Admin\Controllers\CategoryController@getContent')->name('api.category.content');
$router->get('patient/options', '\App\Admin\Controllers\PatientController@getSelectOptions')->name('api.patient.options');
}); });
// 字典表 // 字典表

View File

@ -58,4 +58,9 @@ class Patient extends Model
{ {
return $this->belongsTo(AdminUser::class, 'doctor_id'); return $this->belongsTo(AdminUser::class, 'doctor_id');
} }
public function scopeSort($q)
{
return $q->orderBy('id', 'desc');
}
} }