Commit 61efaa0d by lujunyi

调整

parent 65a19837
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Admin\Controllers; namespace App\Admin\Controllers;
use App\Admin\Repositories\DosageRepository; use App\Admin\Repositories\DosageRepository;
use App\Models\PharmacyModel;
use Dcat\Admin\Form; use Dcat\Admin\Form;
use Dcat\Admin\Grid; use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController; use Dcat\Admin\Http\Controllers\AdminController;
...@@ -18,10 +19,11 @@ class DosageController extends AdminController ...@@ -18,10 +19,11 @@ class DosageController extends AdminController
*/ */
protected function grid() protected function grid()
{ {
return Grid::make(new DosageRepository(), function (Grid $grid) { return Grid::make(new DosageRepository('pharmacy'), function (Grid $grid) {
$grid->model()->orderBy('id', 'DESC'); $grid->model()->orderBy('id', 'DESC');
$grid->column('id')->sortable(); $grid->column('id')->sortable();
$grid->column('pharmacy.name', '药店');
$grid->column('dosage_desc'); $grid->column('dosage_desc');
$grid->column('dosage_show'); $grid->column('dosage_show');
...@@ -70,8 +72,9 @@ protected function form() ...@@ -70,8 +72,9 @@ protected function form()
{ {
return Form::make(new DosageRepository(), function (Form $form) { return Form::make(new DosageRepository(), function (Form $form) {
$form->display('id')->width(4); $form->display('id')->width(4);
$form->select('pharmacy_id')->options(PharmacyModel::all()->pluck('name', 'id'))->width(4)->required();
$form->text('dosage_desc')->width(4)->required(); $form->text('dosage_desc')->width(4)->required();
$form->textarea('dosage_show')->width(4); $form->textarea('dosage_show')->width(4)->required();
$form->display('created_at')->width(4); $form->display('created_at')->width(4);
$form->display('updated_at')->width(4); $form->display('updated_at')->width(4);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
use App\Admin\Repositories\DrugRepository; use App\Admin\Repositories\DrugRepository;
use App\Models\DrugModel; use App\Models\DrugModel;
use App\Models\DrugTagModel; use App\Models\DrugTagModel;
use App\Models\DrugUnitModel;
use Dcat\Admin\Form; use Dcat\Admin\Form;
use Dcat\Admin\Grid; use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController; use Dcat\Admin\Http\Controllers\AdminController;
...@@ -107,7 +108,7 @@ protected function form() ...@@ -107,7 +108,7 @@ protected function form()
$form->display('id')->width(4); $form->display('id')->width(4);
$form->text('name')->width(4)->required(); $form->text('name')->width(4)->required();
$form->text('code')->readonly()->width(4); $form->text('code')->readonly()->width(4);
$form->text('unit')->width(4)->required(); $form->select('unit')->options(DrugUnitModel::all()->pluck('name', 'id'))->width(4);
$form->text('spec')->width(4)->required(); $form->text('spec')->width(4)->required();
$form->text('dosage_form')->width(4)->required(); $form->text('dosage_form')->width(4)->required();
$form->text('factory')->width(4)->required(); $form->text('factory')->width(4)->required();
......
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\DrugUnitRepository;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Show;
class DrugUnitController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new DrugUnitRepository(), function (Grid $grid) {
$grid->model()->orderBy('id', 'DESC');
$grid->column('id')->sortable();
$grid->column('name');
$grid->filter(function (Grid\Filter $filter) {
$filter->panel(); // 更改为 panel 布局
$filter->expand(); // 默认展开搜索框
$filter->like('name')->width(3);
});
// 行按钮控制
$grid->disableDeleteButton(); // 禁用删除按钮
$grid->disableViewButton(); // 禁用详情按钮
// 工具栏按钮控制
$grid->disableBatchDelete(); // 禁用批量删除
});
}
/**
* Make a show builder.
*
* @param mixed $id
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new DrugUnitRepository(), function (Show $show) {
$show->field('id');
$show->field('name');
$show->field('created_at');
$show->field('updated_at');
$show->panel()->tools(function ($tools) {
$tools->disableEdit(); // 禁止编辑
$tools->disableDelete(); // 禁止删除按钮
});
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new DrugUnitRepository(), function (Form $form) {
$form->display('id')->width(4);
$form->text('name')->width(4);
$form->display('created_at')->width(4);
$form->display('updated_at')->width(4);
// 右上角按钮控制
$form->disableDeleteButton(); // 去掉删除按钮
});
}
}
...@@ -7,7 +7,11 @@ ...@@ -7,7 +7,11 @@
use Dcat\Admin\Form; use Dcat\Admin\Form;
use Dcat\Admin\Grid; use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController; use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Models\Administrator;
use Dcat\Admin\Models\Role;
use Dcat\Admin\Show; use Dcat\Admin\Show;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
// 药店 // 药店
class PharmacyController extends AdminController class PharmacyController extends AdminController
...@@ -102,7 +106,7 @@ protected function form() ...@@ -102,7 +106,7 @@ protected function form()
{ {
return Form::make(new PharmacyRepository(), function (Form $form) { return Form::make(new PharmacyRepository(), function (Form $form) {
$form->display('id')->width(4); $form->display('id')->width(4);
$form->text('name')->width(4); $form->text('name')->width(4)->required();
$form->image('business_license')->accept('jpg,png,jpeg')->uniqueName()->autoUpload()->retainable()->removable(false)->width(4); $form->image('business_license')->accept('jpg,png,jpeg')->uniqueName()->autoUpload()->retainable()->removable(false)->width(4);
$form->image('drug_biz_license')->accept('jpg,png,jpeg')->uniqueName()->autoUpload()->retainable()->removable(false)->width(4); $form->image('drug_biz_license')->accept('jpg,png,jpeg')->uniqueName()->autoUpload()->retainable()->removable(false)->width(4);
$form->image('food_biz_license')->accept('jpg,png,jpeg')->uniqueName()->autoUpload()->retainable()->removable(false)->width(4); $form->image('food_biz_license')->accept('jpg,png,jpeg')->uniqueName()->autoUpload()->retainable()->removable(false)->width(4);
...@@ -111,15 +115,53 @@ protected function form() ...@@ -111,15 +115,53 @@ protected function form()
$form->image('pre_packaged_food')->accept('jpg,png,jpeg')->uniqueName()->autoUpload()->retainable()->removable(false)->width(4); $form->image('pre_packaged_food')->accept('jpg,png,jpeg')->uniqueName()->autoUpload()->retainable()->removable(false)->width(4);
$form->text('area')->width(4); $form->text('area')->width(4);
$form->text('address')->width(4); $form->text('address')->width(4);
$form->mobile('mobile')->width(4); $form->mobile('mobile')->width(4)->required()->help('药店登录账号');
$form->text('business_hours')->width(4); $form->text('business_hours')->width(4);
$form->map('lat', 'lng', '经纬度坐标'); $form->map('lat', 'lng', '经纬度坐标');
$form->select('user_id')->options(User::all()->pluck('openid', 'id'))->width(4); $form->select('user_id')->options(User::all()->pluck('openid', 'id'))->width(4)->help('实际后台操作可以不用关联');
$form->switch('status')->width(4); $form->switch('status')->width(4);
$form->display('created_at')->width(4); $form->display('created_at')->width(4);
$form->display('updated_at')->width(4); $form->display('updated_at')->width(4);
$form->saved(function (Form $form, $result) {
DB::beginTransaction();
try {
// 获取店铺管理员角色
$role = Role::where('slug', 'pharmacy')->first();
// 从表单模型获取手机号和其他信息
$mobile = $form->model()->mobile;
$name = $form->model()->name;
$pharmacyId = $form->model()->id;
// 查找当前是否已有管理员
$admin = Administrator::where('pharmacy_id', $pharmacyId)->first();
if ($admin) {
// 如果存在,更新相应字段
$admin->username = $mobile; // 更新账号名
$admin->name = $name; // 更新账号名
$admin->save();
} else {
// 如果不存在,新增管理员
$admin = new Administrator();
$admin->username = $mobile; // 药店手机号作为管理员账号
$admin->name = $name; // 药店名称当做用户的姓名
$admin->password = bcrypt(Str::random(10)); // 设置管理员密码
$admin->pharmacy_id = $pharmacyId; // 药店ID
$admin->save(); // 保存新管理员
// 关联药店管理员角色
$admin->roles()->attach($role->id);
}
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
throw new \Exception('创建或者更新店铺管理员错误~');
}
});
// 右上角按钮控制 // 右上角按钮控制
$form->disableDeleteButton(); // 去掉删除按钮 $form->disableDeleteButton(); // 去掉删除按钮
}); });
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
use App\Admin\Repositories\PharmacyDrugRepository; use App\Admin\Repositories\PharmacyDrugRepository;
use App\Models\DosageModel; use App\Models\DosageModel;
use App\Models\DrugModel; use App\Models\DrugModel;
use App\Models\DrugUnitModel;
use Dcat\Admin\Form; use Dcat\Admin\Form;
use Dcat\Admin\Grid; use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController; use Dcat\Admin\Http\Controllers\AdminController;
...@@ -58,6 +59,7 @@ protected function grid() ...@@ -58,6 +59,7 @@ protected function grid()
// 行按钮控制 // 行按钮控制
$grid->disableCreateButton(); // 禁用创建按钮 $grid->disableCreateButton(); // 禁用创建按钮
$grid->disableDeleteButton(); // 禁用删除按钮 $grid->disableDeleteButton(); // 禁用删除按钮
$grid->disableViewButton(); // 禁用详情按钮
// 工具栏按钮控制 // 工具栏按钮控制
$grid->disableBatchDelete(); // 禁用批量删除 $grid->disableBatchDelete(); // 禁用批量删除
...@@ -98,9 +100,10 @@ protected function form() ...@@ -98,9 +100,10 @@ protected function form()
$form->display('id')->width(4); $form->display('id')->width(4);
$form->text('pharmacy.name', '药店')->disable()->width(4); $form->text('pharmacy.name', '药店')->disable()->width(4);
$form->text('drug.name', '药品名称')->disable()->width(4); $form->text('drug.name', '药品名称')->disable()->width(4);
$form->select('unit')->options(DrugUnitModel::all()->pluck('name', 'id'))->width(4)->required();
$disageList = DosageModel::pluck('dosage_desc', 'id'); $disageList = DosageModel::pluck('dosage_desc', 'id');
$form->select('dosage_id', '用法用量')->options($disageList)->width(4); $form->select('dosage_id', '用法用量')->options($disageList)->width(4)->required();
$form->text('batch_no')->width(4); $form->text('batch_no')->width(4)->required();
$form->display('created_at')->width(4); $form->display('created_at')->width(4);
$form->display('updated_at')->width(4); $form->display('updated_at')->width(4);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Admin\Controllers; namespace App\Admin\Controllers;
use App\Admin\Repositories\PrescriptionLogRepository; use App\Admin\Repositories\PrescriptionLogRepository;
use App\Models\PharmacyModel;
use Dcat\Admin\Form; use Dcat\Admin\Form;
use Dcat\Admin\Grid; use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController; use Dcat\Admin\Http\Controllers\AdminController;
...@@ -77,9 +78,8 @@ protected function form() ...@@ -77,9 +78,8 @@ protected function form()
{ {
return Form::make(new PrescriptionLogRepository(), function (Form $form) { return Form::make(new PrescriptionLogRepository(), function (Form $form) {
$form->display('id')->width(4); $form->display('id')->width(4);
$form->text('pharmacy_id')->width(4); $form->select('pharmacy_id')->options(PharmacyModel::all()->pluck('name', 'id'))->width(4)->required();
$form->text('pharmacy_name')->width(4); $form->textarea('log_info')->width(4);
$form->text('log_info')->width(4);
$form->display('created_at')->width(4); $form->display('created_at')->width(4);
$form->display('updated_at')->width(4); $form->display('updated_at')->width(4);
......
<?php
namespace App\Admin\Repositories;
use App\Models\DrugUnitModel as Model;
use Dcat\Admin\Repositories\EloquentRepository;
class DrugUnitRepository extends EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected $eloquentClass = Model::class;
}
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
$router->resource('drug', 'DrugController'); $router->resource('drug', 'DrugController');
// 药品-标签 // 药品-标签
$router->resource('drug-tag', 'DrugTagController'); $router->resource('drug-tag', 'DrugTagController');
// 药品-单位
$router->resource('drug-unit', 'DrugUnitController');
// 问诊-问诊人 // 问诊-问诊人
$router->resource('patient', 'PatientController'); $router->resource('patient', 'PatientController');
......
...@@ -12,4 +12,10 @@ class DosageModel extends Model ...@@ -12,4 +12,10 @@ class DosageModel extends Model
use SoftDeletes; use SoftDeletes;
protected $table = 'dosage'; protected $table = 'dosage';
// 关联药店
public function pharmacy()
{
return $this->belongsTo(PharmacyModel::class, 'pharmacy_id', 'id');
}
} }
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class DrugUnitModel extends Model
{
use HasDateTimeFormatter;
use SoftDeletes;
protected $table = 'drug_unit';
}
...@@ -12,4 +12,11 @@ class PrescriptionLogModel extends Model ...@@ -12,4 +12,11 @@ class PrescriptionLogModel extends Model
use SoftDeletes; use SoftDeletes;
protected $table = 'prescription_log'; protected $table = 'prescription_log';
public function setPharmacyIdAttribute($pharmacyId)
{
$this->attributes['pharmacy_id'] = $pharmacyId;
$pharmacy_name = PharmacyModel::find($pharmacyId)->name;
$this->attributes['pharmacy_name'] = $pharmacy_name;
}
} }
...@@ -29,6 +29,8 @@ public function up() ...@@ -29,6 +29,8 @@ public function up()
$table->string('password', 80); $table->string('password', 80);
$table->string('name'); $table->string('name');
$table->string('avatar')->nullable(); $table->string('avatar')->nullable();
$table->boolean('is_block')->default(0)->comment('黑名单[0=未开启,1=开启]');
$table->bigInteger('pharmacy_id')->nullable()->unique('uk_pharmacyid')->comment('药店ID');
$table->string('remember_token', 100)->nullable(); $table->string('remember_token', 100)->nullable();
$table->timestamps(); $table->timestamps();
}); });
......
...@@ -19,7 +19,7 @@ public function up() ...@@ -19,7 +19,7 @@ public function up()
$table->string('name')->index('idx_name')->comment('药品名称'); $table->string('name')->index('idx_name')->comment('药品名称');
$table->string('code')->index('idx_code')->comment('简码'); $table->string('code')->index('idx_code')->comment('简码');
$table->string('standard_code')->unique('uk_standardcode')->comment('本位码'); $table->string('standard_code')->unique('uk_standardcode')->comment('本位码');
$table->string('unit')->comment('单位'); $table->integer('unit')->nullable()->comment('单位');
$table->string('spec')->comment('规格'); $table->string('spec')->comment('规格');
$table->string('dosage_form')->comment('剂型'); $table->string('dosage_form')->comment('剂型');
$table->string('factory')->index('idx_factory')->comment('生产厂家'); $table->string('factory')->index('idx_factory')->comment('生产厂家');
......
...@@ -16,8 +16,10 @@ public function up(): void ...@@ -16,8 +16,10 @@ public function up(): void
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->bigInteger('pharmacy_id')->comment('药店ID'); $table->bigInteger('pharmacy_id')->comment('药店ID');
$table->bigInteger('drug_id')->comment('药品池ID'); $table->bigInteger('drug_id')->comment('药品池ID');
$table->integer('unit')->nullable()->comment('单位');
$table->bigInteger('dosage_id')->default(0)->comment('用法用量表ID'); $table->bigInteger('dosage_id')->default(0)->comment('用法用量表ID');
$table->string('batch_no', 64)->nullable()->comment('批次号'); $table->string('batch_no', 64)->nullable()->comment('批次号');
$table->unique(['pharmacy_id', 'drug_id'], 'uk_pharmacyid_drugid');
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
}); });
......
...@@ -4,25 +4,31 @@ ...@@ -4,25 +4,31 @@
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
return new class extends Migration class CreateDrugUnitTable extends Migration
{ {
/** /**
* Run the migrations. * Run the migrations.
*
* @return void
*/ */
public function up(): void public function up()
{ {
Schema::table('admin_users', function (Blueprint $table) { Schema::create('drug_unit', function (Blueprint $table) {
$table->boolean('is_block')->unsigned()->default(false)->comment('黑名单。[0=未开启,1=开启]'); $table->comment('药品单位');
$table->bigIncrements('id');
$table->string('name', 32)->comment('单位');
$table->timestamps();
$table->softDeletes();
}); });
} }
/** /**
* Reverse the migrations. * Reverse the migrations.
*
* @return void
*/ */
public function down(): void public function down()
{ {
Schema::table('admin_users', function (Blueprint $table) { Schema::dropIfExists('drug_unit');
//
});
} }
}; }
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
'fields' => [ 'fields' => [
'dosage_desc' => '用法用量', 'dosage_desc' => '用法用量',
'dosage_show' => '显示内容', 'dosage_show' => '显示内容',
'pharmacy_id' => '药店',
], ],
'options' => [ 'options' => [
], ],
......
<?php
return [
'labels' => [
'DrugUnit' => '药品单位',
'drug-unit' => '药品单位',
],
'fields' => [
'name' => '单位',
],
'options' => [
],
];
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
'drug_id' => '药品池', 'drug_id' => '药品池',
'dosage_id' => '用法用量表', 'dosage_id' => '用法用量表',
'batch_no' => '批次号', 'batch_no' => '批次号',
'unit' => '单位',
'pharmacy_id' => '药店',
], ],
'options' => [ 'options' => [
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment