Commit 3c4f2ac8 by lujunyi

药品功能开发

parent 67950b2e
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\DrugRepository;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Show;
class DrugController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new DrugRepository(), function (Grid $grid) {
$grid->model()->orderBy('id', 'DESC');
$grid->column('id')->sortable();
$grid->column('name');
$grid->column('code');
$grid->column('unit');
$grid->column('is_rx', '处方药')->using([0 => '否', 1 => '是']);
$grid->column('spec');
$grid->column('dosage_form');
$grid->column('factory');
$grid->column('approval_no');
$grid->column('limit_buy_7');
$grid->column('tag');
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
$grid->filter(function (Grid\Filter $filter) {
$filter->panel(); // 更改为 panel 布局
$filter->expand(); // 默认展开搜索框
$filter->like('name')->width(3);
$filter->like('code')->width(3);
$filter->like('factory')->width(3);
});
// 行按钮控制
$grid->disableDeleteButton(); // 禁用删除按钮
// 工具栏按钮控制
$grid->disableBatchDelete(); // 禁用批量删除
// 导出按钮
$grid->export()->filename('药品');
});
}
/**
* Make a show builder.
*
* @param mixed $id
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new DrugRepository(), function (Show $show) {
$show->field('id');
$show->field('name');
$show->field('code');
$show->field('unit');
$show->field('spec');
$show->field('dosage_form');
$show->field('factory');
$show->field('approval_no');
$show->field('limit_buy_7');
$show->field('is_rx');
$show->field('tag');
$show->field('created_at');
$show->field('updated_at');
$show->panel()->tools(function ($tools) {
$tools->disableDelete(); // 禁止删除按钮
});
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new DrugRepository(), function (Form $form) {
$form->display('id')->width(4);
$form->text('name')->width(4);
$form->text('code')->width(4);
$form->text('unit')->width(4);
$form->text('spec')->width(4);
$form->text('dosage_form')->width(4);
$form->text('factory')->width(4);
$form->text('approval_no')->width(4);
$form->select('limit_buy_7')->width(4)->options([1 => 1, 2 => 2, 3 => 3]);
$form->switch('is_rx')->width(4);
$form->text('tag')->width(4);
$form->display('created_at')->width(4);
$form->display('updated_at')->width(4);
// 右上角按钮控制
$form->disableDeleteButton(); // 去掉删除按钮
});
}
}
<?php
namespace App\Admin\Repositories;
use App\Models\DrugModel as Model;
use Dcat\Admin\Repositories\EloquentRepository;
class DrugRepository extends EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected $eloquentClass = Model::class;
}
......@@ -14,6 +14,9 @@
$router->resource('auth/users', 'AdminUserController');
$router->get('/', 'HomeController@index');
// 药品
$router->resource('drug', 'DrugController');
// 导入日志
$router->resource('/import-log', 'Common\ImportLogController')->names('import-log');
});
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class DrugModel extends Model
{
use HasDateTimeFormatter;
use SoftDeletes;
protected $table = 'drug';
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('drug', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name')->index('idx_name')->comment('药品名称');
$table->string('code')->index('idx_code')->comment('简码');
$table->string('unit')->comment('单位');
$table->string('spec')->comment('规格');
$table->string('dosage_form')->comment('剂型');
$table->string('factory')->index('idx_factory')->comment('生产厂家');
$table->string('approval_no')->comment('批准文号');
$table->integer('limit_buy_7')->default(0)->comment('7天内限购数量');
$table->boolean('is_rx')->default(false)->comment('是否处方药');
$table->text('tag')->nullable()->comment('标签');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('drug');
}
};
......@@ -145,11 +145,11 @@ public function run()
'order' => 4,
'title' => '药品列表',
'icon' => null,
'uri' => null,
'uri' => 'drug',
'extension' => '',
'show' => 1,
'created_at' => '2024-11-03 23:32:28',
'updated_at' => '2024-11-03 23:39:55',
'updated_at' => '2024-11-04 00:06:21',
],
[
'id' => 12,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
<?php
return [
'labels' => [
'Drug' => '药品',
'drug' => '药品',
],
'fields' => [
'name' => '药品名称',
'code' => '简码',
'unit' => '单位',
'spec' => '规格',
'dosage_form' => '剂型',
'factory' => '生产厂家',
'approval_no' => '批准文号',
'limit_buy_7' => '7天限购',
'is_rx' => '是否处方药',
'tag' => '标签',
],
'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