Commit 2b128d86 by lujunyi

新增药品字段

parent 7a37a5c6
......@@ -33,20 +33,28 @@ protected function grid()
$grid->column('id')->sortable();
$grid->column('name');
$grid->column('code');
$grid->column('unit');
$grid->column('is_rx', '处方药')->using(DrugModel::RX_MAP);
$grid->column('is_si', '医保')->using(DrugModel::SI_MAP);
$grid->column('product_name');
$grid->column('spec');
$grid->column('preparation_pec');
$grid->column('dosage_form');
$grid->column('unit');
$grid->column('factory');
$grid->column('approval_no');
$grid->column('mnemonic');
$grid->column('standard_code');
$grid->column('category_code');
$grid->column('category_name');
$grid->column('is_foreign')->using(DrugModel::FOREIGN_MAP);
$grid->column('is_rx')->using(DrugModel::RX_MAP);
$grid->column('is_si')->using(DrugModel::SI_MAP);
$grid->column('limit_buy_7');
$grid->column('tag')->display(function ($tags) {
return collect($tags)->map(function ($tag) {
return "<span class='label' style='background:#6d8be6'>{$tag->tag_name}</span>";
})->implode('&nbsp;');
});
$grid->column('standard_code');
$grid->column('product_id');
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
......@@ -87,29 +95,7 @@ protected function grid()
* @param mixed $id
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new DrugRepository(), function (Show $show) {
$show->field('id')->width(4);
$show->field('name')->width(4);
$show->field('code')->width(4);
$show->field('unit')->width(4);
$show->field('spec')->width(4);
$show->field('dosage_form')->width(4);
$show->field('factory')->width(4);
$show->field('approval_no')->width(4);
$show->field('limit_buy_7')->width(4);
$show->field('is_rx')->using(DrugModel::RX_MAP)->width(4);
$show->field('tag')->width(4);
$show->field('standard_code')->width(4);
$show->field('created_at')->width(4);
$show->field('updated_at')->width(4);
$show->panel()->tools(function ($tools) {
$tools->disableDelete(); // 禁止删除按钮
});
});
}
protected function detail($id) {}
/**
* Make a form builder.
......@@ -119,35 +105,45 @@ protected function detail($id)
protected function form()
{
return Form::make(new DrugRepository('tag'), function (Form $form) {
$form->display('id')->width(4);
$form->text('name')->width(4)->required()->maxLength(64, '最多输入64个字符');
$form->display('code')->width(4);
$form->select('unit')->options(DrugUnitModel::all()->pluck('name', 'name'))->width(4);
$form->text('spec')->width(4)->required()->maxLength(128, '最多输入128个字符');
$form->text('dosage_form')->width(4)->required()->maxLength(128, '最多输入128个字符');
$form->text('factory')->width(4)->required()->maxLength(128, '最多输入128个字符');
$form->text('approval_no')->width(4)->required()->maxLength(64, '最多输入64个字符');
$array = range(1, 10);
$limitOption = array_combine($array, $array);
$form->select('limit_buy_7')->placeholder('请选择限购数量')->width(4)->options($limitOption)->help('限购数量')->required();
$form->switch('is_rx')->width(4);
$form->text('standard_code')->width(4)->required()->rules(function (Form $form) {
// 如果不是编辑状态,则添加字段唯一验证
if (! $id = $form->model()->id) {
return 'unique:App\Models\DrugModel,standard_code';
}
$form->column(6, function (Form $form) {
$form->display('id');
$form->display('code');
$form->text('name')->required()->maxLength(64);
$form->text('product_name')->maxLength(64);
$form->text('spec')->required()->maxLength(128);
$form->text('preparation_pec')->maxLength(128);
$form->text('dosage_form')->required()->maxLength(128);
$form->select('unit')->options(DrugUnitModel::all()->pluck('name', 'name'));
$form->text('factory')->required()->maxLength(128);
$form->text('approval_no')->required()->maxLength(64);
$form->text('mnemonic')->maxLength(64);
});
$form->column(6, function (Form $form) {
$form->text('standard_code')->required()->rules(function (Form $form) {
// 如果不是编辑状态,则添加字段唯一验证
if (! $id = $form->model()->id) {
return 'unique:App\Models\DrugModel,standard_code';
}
});
$form->text('category_code')->maxLength(32);
$form->text('category_name')->maxLength(32);
$form->switch('is_foreign');
$form->switch('is_rx');
$form->switch('is_si');
$array = range(1, 10);
$limitOption = array_combine($array, $array);
$form->select('limit_buy_7')->placeholder('请选择限购数量')->options($limitOption)->help('限购数量')->required();
$form->multipleSelect('tag', '标签')
->options(function () {
return DrugTagModel::all()->pluck('tag_name', 'id');
})
->customFormat(function ($v) {
return array_column($v, 'id');
});
$form->display('created_at');
$form->display('updated_at');
});
$form->multipleSelect('tag', '标签')
->options(function () {
return DrugTagModel::all()->pluck('tag_name', 'id');
})
->customFormat(function ($v) {
return array_column($v, 'id');
})->width(4);
$form->display('created_at')->width(4);
$form->display('updated_at')->width(4);
// 右上角按钮控制
$form->disableDeleteButton(); // 去掉删除按钮
$form->disableViewButton(); // 去掉跳转详情页按钮
......
......@@ -14,7 +14,7 @@ class DrugModel extends Model
protected $table = 'drug';
// 是否处方药[0=不是,1=是]
// 是否处方药[0=,1=是]
const RX_TRUE = 0;
const RX_FALSE = 1;
......@@ -25,7 +25,7 @@ class DrugModel extends Model
self::RX_FALSE => '否',
];
// 是否医保药品[0=不是,1=是]
// 是否医保药品[0=,1=是]
const SI_TRUE = 0;
const SI_FALSE = 1;
......@@ -36,6 +36,17 @@ class DrugModel extends Model
self::RX_FALSE => '否',
];
// 是否进口药[0=否,1=是]
const FOREIGN_TRUE = 0;
const FOREIGN_FALSE = 1;
// 是否进口药-文字映射
const FOREIGN_MAP = [
self::FOREIGN_TRUE => '是',
self::FOREIGN_FALSE => '否',
];
public function setNameAttribute($value)
{
$this->attributes['name'] = $value;
......
......@@ -19,7 +19,7 @@ public function up(): void
$table->string('code', 64)->index('idx_code')->comment('简码');
$table->string('standard_code', 64)->unique('uk_standardcode')->comment('本位码');
$table->string('unit', 20)->nullable()->comment('单位');
$table->string('spec', 128)->comment('规格');
$table->string('spec', 128)->comment('包装规格');
$table->string('dosage_form', 128)->comment('剂型');
$table->string('factory', 128)->index('idx_factory')->comment('生产厂家');
$table->string('approval_no', 64)->comment('批准文号');
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('drug', function (Blueprint $table) {
$table->string('preparation_pec', 128)->default('')->comment('制剂规格');
$table->string('product_name', 64)->default('')->comment('商品名');
$table->string('mnemonic', 64)->default('')->comment('助记码');
$table->string('category_code', 32)->default('')->comment('分类码');
$table->string('category_name', 32)->default('')->comment('分类名称');
$table->boolean('is_foreign')->default(false)->comment('是否进口药');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('drug', function (Blueprint $table) {
//
});
}
};
......@@ -5,17 +5,25 @@
'drug' => '药品',
],
'fields' => [
'name' => '药品名称',
'product_id' => '君元商品ID',
'name' => '通用名',
'product_name' => '商品名',
'code' => '简码',
'unit' => '单位',
'spec' => '规格',
'spec' => '包装规格',
'preparation_pec' => '制剂规格',
'dosage_form' => '剂型',
'unit' => '单位',
'factory' => '生产厂家',
'approval_no' => '批准文号',
'limit_buy_7' => '7天限购',
'mnemonic' => '助记码',
'standard_code' => '本位码',
'category_code' => '分类码',
'category_name' => '分类名称',
'is_foreign' => '是否进口药',
'is_rx' => '是否处方药',
'is_si' => '是否医保药',
'limit_buy_7' => '7天限购',
'tag' => '标签',
'standard_code' => '本位码',
],
'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