generated from liutk/owl-admin-base
Compare commits
4 Commits
f30c68bc09
...
9a666e77de
| Author | SHA1 | Date |
|---|---|---|
|
|
9a666e77de | |
|
|
85949ca756 | |
|
|
a3ebeb10a7 | |
|
|
d82f8bec23 |
|
|
@ -6,6 +6,8 @@ use Slowlyo\OwlAdmin\Renderers\Page;
|
|||
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||
use App\Services\Admin\ManageService;
|
||||
use App\Admin\Components;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
/**
|
||||
* 专家管理
|
||||
|
|
@ -14,12 +16,31 @@ use App\Services\Admin\ManageService;
|
|||
*/
|
||||
class ManageController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
protected string $serviceName = ManageService::class;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()
|
||||
->filterTogglable(false)
|
||||
$crud = $this->baseCRUD()->tableLayout('fixed')
|
||||
->headerToolbar([
|
||||
amis()->LinkAction()->link(admin_url('/manages/create'))->label('新增')->icon('fa fa-add')->level('primary'),
|
||||
...$this->baseHeaderToolBar(),
|
||||
])
|
||||
->filter($this->baseFilter()->labelWidth('80px')->body([
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('name', '姓名')->columnRatio(3),
|
||||
amis()->SelectControl('gender', '性别')->options([
|
||||
'1'=>'男', '2'=>'女'
|
||||
])->columnRatio(3)->clearable(true),
|
||||
amis()->TextControl('technical_position', '专业技术职务')->columnRatio(3),
|
||||
amis()->TextControl('subject', '学科门类')->columnRatio(3),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('research_direction', '研究方向')->columnRatio(3),
|
||||
amis()->TextControl('company', '工作单位')->columnRatio(3),
|
||||
amis()->TextControl('mobile_phone', '移动电话')->columnRatio(3),
|
||||
]),
|
||||
]))
|
||||
->columns([
|
||||
amis()->TableColumn('id', 'ID')->sortable(),
|
||||
amis()->TableColumn('name', '姓名'),
|
||||
|
|
@ -39,43 +60,421 @@ class ManageController extends AdminController
|
|||
amis()->TableColumn('subject', '学科门类'),
|
||||
amis()->TableColumn('research_direction', '研究方向'),
|
||||
amis()->TableColumn('address', '通讯地址(邮编)'),
|
||||
amis()->TableColumn('work_phone', '电话'),
|
||||
amis()->TableColumn('work_phone', '办公电话'),
|
||||
amis()->TableColumn('mobile_phone', '移动电话'),
|
||||
amis()->TableColumn('email', '邮箱'),
|
||||
$this->rowActions()
|
||||
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowShowTypeButton('drawer', 'xl'),
|
||||
$this->rowEditButton(),
|
||||
$this->rowDeleteButton(),
|
||||
])
|
||||
]);
|
||||
|
||||
return $this->baseList($crud);
|
||||
}
|
||||
|
||||
public function createManage()
|
||||
{
|
||||
$wizard = amis()
|
||||
->Card()
|
||||
->header(['title' => __('admin.create')])
|
||||
->toolbar([$this->backButton()])
|
||||
->body(
|
||||
amis()->Wizard()->className('min-h-screen')
|
||||
->api($this->getStorePath())
|
||||
->steps([
|
||||
amis()->WizardStep()->title('基本信息')->body([
|
||||
amis()->FieldSetControl()->title('基础资料')->body([
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('name', '姓名')->required(true),
|
||||
Components::make()->cropImageControl('avatar', '寸照')->required(true),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('nation', '民族')->required(true),
|
||||
amis()->RadiosControl('gender', '性别')->options([
|
||||
'1'=>'男', '2'=>'女'
|
||||
])->required(),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->DateControl('birthday', '出生年月')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('political_face', '政治面貌')->required(true),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('educational_level', '学历学位')->required(true),
|
||||
amis()->TextControl('company', '工作单位')->required(true),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('strative_position', '行政职务')->required(true),
|
||||
amis()->TextControl('technical_position', '专业技术职务')->required(true),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('subject', '学科门类')->required(true),
|
||||
amis()->TextControl('research_direction', '研究方向')->required(true),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('address', '通讯地址(邮编)')->required(true),
|
||||
amis()->TextControl('email', '个人邮箱')->required(true),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('work_phone', '办公电话')->required(true),
|
||||
amis()->TextControl('mobile_phone', '移动电话')->required(true),
|
||||
]),
|
||||
]),
|
||||
amis()->FieldSetControl()->title('个人简历')->className('mt-10')->body([
|
||||
amis()->TableControl('jobs', '')->columnsTogglable(false)->columns([
|
||||
amis()->DateControl('start_at', '开始时间')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->DateControl('end_at', '截止时间')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('company', '工作单位以及所在部门')->required(true),
|
||||
amis()->TextControl('job_name', '职务、职称')->required(true),
|
||||
])->needConfirm(false)->addable()->removable()->minLength(1)
|
||||
]),
|
||||
amis()->FieldSetControl()->title('获奖情况')->className('mt-10')->body([
|
||||
amis()->TableControl('ranks', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('rank_name', '获奖名称')->required(true),
|
||||
amis()->TextControl('rank_cate', '获奖类别(等级)')->required(true),
|
||||
amis()->TextControl('rank_company', '授予单位')->required(true),
|
||||
amis()->DateControl('rank_at', '获奖时间')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('rank_lv', '本人排名')->required(true),
|
||||
])->needConfirm(false)->addable()->removable()->minLength(1)
|
||||
])
|
||||
]),
|
||||
amis()->WizardStep()->title('科研项目情况')->body([
|
||||
amis()->TableControl('projects', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('project_name', '项目名称')->required(true),
|
||||
amis()->TextControl('project_source', '项目来源')->required(true),
|
||||
amis()->SelectControl('join_type', '主持或者参加')->options([
|
||||
'1'=>'主持', '2'=>'参加'
|
||||
])->required(true),
|
||||
amis()->DateControl('start_at', '开始时间')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->DateControl('end_at', '截止时间')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('result_name', '成果名称')->required(true),
|
||||
amis()->TextControl('result_use', '成果转化')->required(true),
|
||||
])->needConfirm(false)->addable()->removable()->minLength(1)
|
||||
]),
|
||||
amis()->WizardStep()->title('论著发表出版情况')->body([
|
||||
amis()->TableControl('articles', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('artcile_name', '论文或著作名称')->required(true),
|
||||
amis()->TextControl('press_name', '出版社/期刊/报纸')->required(true),
|
||||
amis()->YearControl('year', '年份')->valueFormat('YYYY')->required(true),
|
||||
amis()->TextControl('source_page', '期/卷/版/页')->required(true),
|
||||
amis()->TextControl('author_rank', '作者名次')->required(true),
|
||||
])->needConfirm(false)->addable()->removable()->minLength(1)
|
||||
]),
|
||||
amis()->WizardStep()->title('决策咨询情况')->body([
|
||||
amis()->TableControl('consults', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('consult_title', '决策咨询报告题目')->required(true),
|
||||
amis()->TextControl('consult_channel', '报送渠道')->required(true),
|
||||
amis()->SelectControl('join_type', '主持或者参加')->options([
|
||||
'1'=>'主持', '2'=>'参加'
|
||||
])->required(true),
|
||||
amis()->TextControl('leader_instruction', '领导批示')->required(true),
|
||||
amis()->DateControl('consult_at', '日期')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('result_use', '成果转化')->required(true),
|
||||
])->needConfirm(false)->addable()->removable()->minLength(1)
|
||||
]),
|
||||
amis()->WizardStep()->title('学术交流情况')->body([
|
||||
amis()->TableControl('meetings', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('meeting_name', '学术活动名称')->required(true),
|
||||
amis()->TextControl('meeting_company', '主办单位')->required(true),
|
||||
amis()->TextControl('meeting_cate', '类型')->required(true),
|
||||
amis()->DateControl('meeting_at', '日期')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('result_name', '成果名称')->required(true),
|
||||
amis()->TextControl('result_use', '成果转化')->required(true),
|
||||
])->needConfirm(false)->addable()->removable()->minLength(1)
|
||||
]),
|
||||
amis()->WizardStep()->title('社科普及项目情况')->body([
|
||||
amis()->TableControl('socials', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('social_name', '社科普及项目名称')->required(true),
|
||||
amis()->TextControl('social_company', '主办单位')->required(true),
|
||||
amis()->TextControl('social_cate', '类型')->required(true),
|
||||
amis()->DateControl('social_at', '日期')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('result_name', '成果名称')->required(true),
|
||||
amis()->TextControl('result_use', '成果转化')->required(true),
|
||||
])->needConfirm(false)->addable()->removable()->minLength(1)
|
||||
]),
|
||||
amis()->WizardStep()->title('其他注意事项')->body([
|
||||
amis()->TextareaControl('others', '')->minRows(10)->placeholder('请填写其他注意事项,若无则无需填写'),
|
||||
]),
|
||||
])
|
||||
->redirect($this->getListPath())
|
||||
);
|
||||
|
||||
$page = $this->basePage()->body($wizard);
|
||||
|
||||
return $this->response()->success($page);
|
||||
}
|
||||
|
||||
public function editManage()
|
||||
{
|
||||
$wizard = amis()
|
||||
->Card()
|
||||
->header(['title' => __('admin.create')])
|
||||
->toolbar([$this->backButton()])
|
||||
->body(
|
||||
amis()->Wizard()->className('min-h-screen')
|
||||
->api($this->getUpdatePath())->initApi($this->getEditGetDataPath())
|
||||
->steps([
|
||||
amis()->WizardStep()->title('基本信息')->body([
|
||||
amis()->FieldSetControl()->title('基础资料')->body([
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('name', '姓名')->required(true),
|
||||
Components::make()->cropImageControl('avatar', '寸照')->required(true),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('nation', '民族')->required(true),
|
||||
amis()->RadiosControl('gender', '性别')->options([
|
||||
'1'=>'男', '2'=>'女'
|
||||
])->required(),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->DateControl('birthday', '出生年月')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('political_face', '政治面貌')->required(true),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('educational_level', '学历学位')->required(true),
|
||||
amis()->TextControl('company', '工作单位')->required(true),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('strative_position', '行政职务')->required(true),
|
||||
amis()->TextControl('technical_position', '专业技术职务')->required(true),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('subject', '学科门类')->required(true),
|
||||
amis()->TextControl('research_direction', '研究方向')->required(true),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('address', '通讯地址(邮编)')->required(true),
|
||||
amis()->TextControl('email', '个人邮箱')->required(true),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('work_phone', '办公电话')->required(true),
|
||||
amis()->TextControl('mobile_phone', '移动电话')->required(true),
|
||||
]),
|
||||
]),
|
||||
amis()->FieldSetControl()->title('个人简历')->className('mt-10')->body([
|
||||
amis()->TableControl('jobs', '')->columnsTogglable(false)->columns([
|
||||
amis()->DateControl('start_at', '开始时间')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->DateControl('end_at', '截止时间')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('company', '工作单位以及所在部门')->required(true),
|
||||
amis()->TextControl('job_name', '职务、职称')->required(true),
|
||||
])->needConfirm(false)->addable()->removable()->minLength(1)
|
||||
]),
|
||||
amis()->FieldSetControl()->title('获奖情况')->className('mt-10')->body([
|
||||
amis()->TableControl('ranks', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('rank_name', '获奖名称')->required(true),
|
||||
amis()->TextControl('rank_cate', '获奖类别(等级)')->required(true),
|
||||
amis()->TextControl('rank_company', '授予单位')->required(true),
|
||||
amis()->DateControl('rank_at', '获奖时间')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('rank_lv', '本人排名')->required(true),
|
||||
])->needConfirm(false)->addable()->removable()->minLength(1)
|
||||
])
|
||||
]),
|
||||
amis()->WizardStep()->title('科研项目情况')->body([
|
||||
amis()->TableControl('projects', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('project_name', '项目名称')->required(true),
|
||||
amis()->TextControl('project_source', '项目来源')->required(true),
|
||||
amis()->SelectControl('join_type', '主持或者参加')->options([
|
||||
'1'=>'主持', '2'=>'参加'
|
||||
])->required(true),
|
||||
amis()->DateControl('start_at', '开始时间')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->DateControl('end_at', '截止时间')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('result_name', '成果名称')->required(true),
|
||||
amis()->TextControl('result_use', '成果转化')->required(true),
|
||||
])->needConfirm(false)->addable()->removable()->minLength(1)
|
||||
]),
|
||||
amis()->WizardStep()->title('论著发表出版情况')->body([
|
||||
amis()->TableControl('articles', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('artcile_name', '论文或著作名称')->required(true),
|
||||
amis()->TextControl('press_name', '出版社/期刊/报纸')->required(true),
|
||||
amis()->YearControl('year', '年份')->valueFormat('YYYY')->required(true),
|
||||
amis()->TextControl('source_page', '期/卷/版/页')->required(true),
|
||||
amis()->TextControl('author_rank', '作者名次')->required(true),
|
||||
])->needConfirm(false)->addable()->removable()->minLength(1)
|
||||
]),
|
||||
amis()->WizardStep()->title('决策咨询情况')->body([
|
||||
amis()->TableControl('consults', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('consult_title', '决策咨询报告题目')->required(true),
|
||||
amis()->TextControl('consult_channel', '报送渠道')->required(true),
|
||||
amis()->SelectControl('join_type', '主持或者参加')->options([
|
||||
'1'=>'主持', '2'=>'参加'
|
||||
])->required(true),
|
||||
amis()->TextControl('leader_instruction', '领导批示')->required(true),
|
||||
amis()->DateControl('consult_at', '日期')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('result_use', '成果转化')->required(true),
|
||||
])->needConfirm(false)->addable()->removable()->minLength(1)
|
||||
]),
|
||||
amis()->WizardStep()->title('学术交流情况')->body([
|
||||
amis()->TableControl('meetings', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('meeting_name', '学术活动名称')->required(true),
|
||||
amis()->TextControl('meeting_company', '主办单位')->required(true),
|
||||
amis()->TextControl('meeting_cate', '类型')->required(true),
|
||||
amis()->DateControl('meeting_at', '日期')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('result_name', '成果名称')->required(true),
|
||||
amis()->TextControl('result_use', '成果转化')->required(true),
|
||||
])->needConfirm(false)->addable()->removable()->minLength(1)
|
||||
]),
|
||||
amis()->WizardStep()->title('社科普及项目情况')->body([
|
||||
amis()->TableControl('socials', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('social_name', '社科普及项目名称')->required(true),
|
||||
amis()->TextControl('social_company', '主办单位')->required(true),
|
||||
amis()->TextControl('social_cate', '类型')->required(true),
|
||||
amis()->DateControl('social_at', '日期')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('result_name', '成果名称')->required(true),
|
||||
amis()->TextControl('result_use', '成果转化')->required(true),
|
||||
])->needConfirm(false)->addable()->removable()->minLength(1)
|
||||
]),
|
||||
amis()->WizardStep()->title('其他注意事项')->body([
|
||||
amis()->TextareaControl('others', '')->minRows(10)->placeholder('请填写其他注意事项,若无则无需填写'),
|
||||
]),
|
||||
])->redirect($this->getListPath())
|
||||
);
|
||||
|
||||
$page = $this->basePage()->body($wizard);
|
||||
|
||||
return $this->response()->success($page);
|
||||
}
|
||||
|
||||
public function form($isEdit = false): Form
|
||||
{
|
||||
return $this->baseForm()->body([
|
||||
amis()->TextControl('name', '姓名'),
|
||||
amis()->ImageControl('avatar', '头像'),
|
||||
amis()->TextControl('gender', '性别:0未知,1男,2女'),
|
||||
amis()->TextControl('birthday', '生日'),
|
||||
amis()->TextControl('nation', '民族'),
|
||||
amis()->TextControl('political_face', '政治面貌'),
|
||||
amis()->TextControl('educational_level', '学历学位'),
|
||||
amis()->TextControl('company', '工作单位'),
|
||||
amis()->TextControl('strative_position', '行政职务'),
|
||||
amis()->TextControl('technical_position', '专业技术职务'),
|
||||
amis()->TextControl('subject', '学科门类'),
|
||||
amis()->TextControl('research_direction', '研究方向'),
|
||||
amis()->TextControl('address', '通讯地址(邮编)'),
|
||||
amis()->TextControl('email', '个人邮箱'),
|
||||
amis()->TextControl('work_phone', '办公电话'),
|
||||
amis()->TextControl('mobile_phone', '移动电话'),
|
||||
amis()->TextControl('remarks', '备注'),
|
||||
amis()->TextControl('others', '补充说明'),
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
public function detail(): Form
|
||||
public function detail()
|
||||
{
|
||||
return $this->baseDetail()->body([
|
||||
$form = amisMake()->form()->title('')->panelClassName('border-r border-t-0 border-b-0 border-l-0')->mode('horizontal')
|
||||
->static(true)->actions([])
|
||||
->body([
|
||||
amis()->FieldSetControl()->title('基本信息')->body([
|
||||
|
||||
amis()->GroupControl()->body([
|
||||
amis()->Image()->type('static-image')->name('avatar')->label('寸照')->height('80px')->width('80px')->thumbMode('cover'),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('name', '姓名')->copyable(['content'=>'${name}']),
|
||||
amis()->RadiosControl('gender', '性别')->options([
|
||||
'1'=>'男', '2'=>'女'
|
||||
]),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('birthday', '出生年月'),
|
||||
amis()->StaticExactControl('political_face', '政治面貌'),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('educational_level', '学历学位'),
|
||||
amis()->StaticExactControl('company', '工作单位'),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('strative_position', '行政职务'),
|
||||
amis()->StaticExactControl('technical_position', '专业技术职务'),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('subject', '学科门类'),
|
||||
amis()->StaticExactControl('research_direction', '研究方向'),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('address', '通讯地址(邮编)'),
|
||||
amis()->StaticExactControl('email', '个人邮箱'),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('work_phone', '办公电话'),
|
||||
amis()->StaticExactControl('mobile_phone', '移动电话'),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('others', '其他注意事项'),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
|
||||
return amisMake()->Grid()->columns([
|
||||
amis()->Column()->body($form)->md(6),
|
||||
amis()->Column()->body([
|
||||
amis()->FieldSetControl()->title('个人简历')->body([
|
||||
amis()->TableControl('jobs', '')->columnsTogglable(false)->columns([
|
||||
amis()->DateControl('start_at', '开始时间')->valueFormat('YYYY-MM-DD'),
|
||||
amis()->DateControl('end_at', '截止时间')->valueFormat('YYYY-MM-DD'),
|
||||
amis()->TextControl('company', '工作单位以及所在部门'),
|
||||
amis()->TextControl('job_name', '职务、职称'),
|
||||
])->needConfirm(false)->static()
|
||||
]),
|
||||
amis()->FieldSetControl()->title('获奖情况')->body([
|
||||
amis()->TableControl('ranks', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('rank_name', '获奖名称'),
|
||||
amis()->TextControl('rank_cate', '获奖类别(等级)'),
|
||||
amis()->TextControl('rank_company', '授予单位'),
|
||||
amis()->DateControl('rank_at', '获奖时间')->valueFormat('YYYY-MM-DD'),
|
||||
amis()->TextControl('rank_lv', '本人排名'),
|
||||
])->needConfirm(false)->static()
|
||||
]),
|
||||
amis()->FieldSetControl()->title('科研项目情况')->body([
|
||||
amis()->TableControl('projects', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('project_name', '项目名称')->required(true),
|
||||
amis()->TextControl('project_source', '项目来源')->required(true),
|
||||
amis()->SelectControl('join_type', '主持或者参加')->options([
|
||||
'1'=>'主持', '2'=>'参加'
|
||||
])->required(true),
|
||||
amis()->DateControl('start_at', '开始时间')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->DateControl('end_at', '截止时间')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('result_name', '成果名称')->required(true),
|
||||
amis()->TextControl('result_use', '成果转化')->required(true),
|
||||
])->needConfirm(false)->static()
|
||||
]),
|
||||
amis()->FieldSetControl()->title('论著发表出版情况')->body([
|
||||
amis()->TableControl('articles', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('artcile_name', '论文或著作名称')->required(true),
|
||||
amis()->TextControl('press_name', '出版社/期刊/报纸')->required(true),
|
||||
amis()->YearControl('year', '年份')->valueFormat('YYYY')->required(true),
|
||||
amis()->TextControl('source_page', '期/卷/版/页')->required(true),
|
||||
amis()->TextControl('author_rank', '作者名次')->required(true),
|
||||
])->needConfirm(false)->static()
|
||||
]),
|
||||
amis()->FieldSetControl()->title('决策咨询情况')->body([
|
||||
amis()->TableControl('consults', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('consult_title', '决策咨询报告题目')->required(true),
|
||||
amis()->TextControl('consult_channel', '报送渠道')->required(true),
|
||||
amis()->SelectControl('join_type', '主持或者参加')->options([
|
||||
'1'=>'主持', '2'=>'参加'
|
||||
])->required(true),
|
||||
amis()->TextControl('leader_instruction', '领导批示')->required(true),
|
||||
amis()->DateControl('consult_at', '日期')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('result_use', '成果转化')->required(true),
|
||||
])->needConfirm(false)->static()
|
||||
]),
|
||||
amis()->FieldSetControl()->title('学术交流情况')->body([
|
||||
amis()->TableControl('meetings', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('meeting_name', '学术活动名称')->required(true),
|
||||
amis()->TextControl('meeting_company', '主办单位')->required(true),
|
||||
amis()->TextControl('meeting_cate', '类型')->required(true),
|
||||
amis()->DateControl('meeting_at', '日期')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('result_name', '成果名称')->required(true),
|
||||
amis()->TextControl('result_use', '成果转化')->required(true),
|
||||
])->needConfirm(false)->static()
|
||||
]),
|
||||
amis()->FieldSetControl()->title('社科普及项目情况')->body([
|
||||
amis()->TableControl('socials', '')->columnsTogglable(false)->columns([
|
||||
amis()->TextControl('social_name', '社科普及项目名称')->required(true),
|
||||
amis()->TextControl('social_company', '主办单位')->required(true),
|
||||
amis()->TextControl('social_cate', '类型')->required(true),
|
||||
amis()->DateControl('social_at', '日期')->valueFormat('YYYY-MM-DD')->required(true),
|
||||
amis()->TextControl('result_name', '成果名称')->required(true),
|
||||
amis()->TextControl('result_use', '成果转化')->required(true),
|
||||
])->needConfirm(false)->static()
|
||||
]),
|
||||
])->md(6),
|
||||
]);
|
||||
}
|
||||
|
||||
public function detailActions()
|
||||
{
|
||||
return [
|
||||
//返回
|
||||
amis()->Button()->actionType('cancel')->label(__('admin.back'))->primary()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ Route::group([
|
|||
|
||||
$router->resource('ads', \App\Admin\Controllers\AdController::class);
|
||||
|
||||
$router->resource('manages', \App\Admin\Controllers\ManageController::class);
|
||||
$router->get('manages/create', [\App\Admin\Controllers\ManageController::class, 'createManage']);
|
||||
$router->get('manages/{manage}/edit', [\App\Admin\Controllers\ManageController::class, 'editManage']);
|
||||
$router->resource('manages', \App\Admin\Controllers\ManageController::class)->only(['index', 'store', 'update', 'show', 'destroy']);
|
||||
|
||||
//修改上传
|
||||
$router->post('upload_file', [\App\Admin\Controllers\IndexController::class, 'uploadFile']);
|
||||
|
|
|
|||
|
|
@ -6,5 +6,66 @@ use EloquentFilter\ModelFilter;
|
|||
|
||||
class ManageFilter extends ModelFilter
|
||||
{
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
public function id($id)
|
||||
{
|
||||
return $this->where('id', $id);
|
||||
}
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
public function name($name)
|
||||
{
|
||||
return $this->where('name','like', '%'.$name.'%');
|
||||
}
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
public function gender($gender)
|
||||
{
|
||||
return $this->where('gender', $gender);
|
||||
}
|
||||
|
||||
/**
|
||||
* 专业技术职务
|
||||
*/
|
||||
public function technicalPosition($technicalPosition)
|
||||
{
|
||||
return $this->where('technical_position','like', '%'.$technicalPosition.'%');
|
||||
}
|
||||
|
||||
/**
|
||||
* 学科门类
|
||||
*/
|
||||
public function subject($subject)
|
||||
{
|
||||
return $this->where('subject','like', '%'.$subject.'%');
|
||||
}
|
||||
|
||||
/**
|
||||
* 研究方向
|
||||
*/
|
||||
public function researchDirection($researchDirection)
|
||||
{
|
||||
return $this->where('research_direction','like', '%'.$researchDirection.'%');
|
||||
}
|
||||
|
||||
/**
|
||||
* 工作单位
|
||||
*/
|
||||
public function company($company)
|
||||
{
|
||||
return $this->where('company','like', '%'.$company.'%');
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动电话
|
||||
*/
|
||||
public function mobilePhone($mobilePhone)
|
||||
{
|
||||
return $this->where('mobile_phone','like', '%'.$mobilePhone.'%');
|
||||
}
|
||||
}
|
||||
|
|
@ -17,37 +17,37 @@ class Manage extends Model
|
|||
}
|
||||
|
||||
|
||||
public function article()
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasMany(ManageArticle::class, 'manage_id');
|
||||
}
|
||||
|
||||
public function consult()
|
||||
public function consults()
|
||||
{
|
||||
return $this->hasMany(ManageConsult::class, 'manage_id');
|
||||
}
|
||||
|
||||
public function job()
|
||||
public function jobs()
|
||||
{
|
||||
return $this->hasMany(ManageJob::class, 'manage_id');
|
||||
}
|
||||
|
||||
public function meeting()
|
||||
public function meetings()
|
||||
{
|
||||
return $this->hasMany(ManageMeeting::class, 'manage_id');
|
||||
}
|
||||
|
||||
public function project()
|
||||
public function projects()
|
||||
{
|
||||
return $this->hasMany(ManageProject::class, 'manage_id');
|
||||
}
|
||||
|
||||
public function rank()
|
||||
public function ranks()
|
||||
{
|
||||
return $this->hasMany(ManageRank::class, 'manage_id');
|
||||
}
|
||||
|
||||
public function social()
|
||||
public function socials()
|
||||
{
|
||||
return $this->hasMany(ManageSocial::class, 'manage_id');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
class ManageArticle extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'manage_id', 'artcile_name', 'press_name', 'year', 'source_page', 'author_rank'
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
class ManageConsult extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'manage_id', 'consult_title', 'consult_channel', 'join_type', 'leader_instruction', 'consult_at', 'result_use'
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
class ManageJob extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'manage_id', 'start_at', 'end_at', 'company', 'job_name'
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,9 @@ use Illuminate\Database\Eloquent\Model;
|
|||
class ManageMeeting extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'manage_id', 'meeting_name', 'meeting_company', 'meeting_cate', 'meeting_at', 'result_name', 'result_use'
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
class ManageProject extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'manage_id', 'project_name', 'project_source', 'join_type', 'start_at', 'end_at', 'result_name', 'result_use'
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
class ManageRank extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'manage_id', 'rank_name', 'rank_cate', 'rank_company', 'rank_at', 'rank_lv'
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
class ManageSocial extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'manage_id', 'social_name', 'social_company', 'social_cate', 'social_at', 'result_name', 'result_use'
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
namespace App\Services\Admin;
|
||||
|
||||
use App\Models\Manage;
|
||||
use App\Models\{Manage,ManageSocial,ManageJob,ManageRank,ManageArticle,ManageProject,ManageConsult,ManageMeeting};
|
||||
use App\Models\Filters\ManageFilter;
|
||||
use App\Traits\UploadTrait;
|
||||
use Illuminate\Support\Arr;
|
||||
use DB;
|
||||
|
||||
/**
|
||||
* @method Manage getModel()
|
||||
|
|
@ -19,4 +20,123 @@ class ManageService extends BaseService
|
|||
|
||||
protected string $modelFilterName = ManageFilter::class;
|
||||
|
||||
protected array $withRelationships = ['articles', 'consults', 'jobs', 'meetings', 'projects', 'ranks', 'socials'];
|
||||
|
||||
public function store($data): bool
|
||||
{
|
||||
$columns = $this->getTableColumns();
|
||||
$model = $this->getModel();
|
||||
|
||||
$data['avatar'] = $this->saveImage('avatar', 'manages/avatar')[0] ?? '';
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
if (!in_array($k, $columns)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$model->setAttribute($k, $v);
|
||||
}
|
||||
try{
|
||||
DB::beginTransaction();
|
||||
|
||||
$model->save();
|
||||
$model->jobs()->createMany($data['jobs']);
|
||||
$model->ranks()->createMany($data['ranks']);
|
||||
$model->projects()->createMany($data['projects']);
|
||||
$model->articles()->createMany($data['articles']);
|
||||
$model->consults()->createMany($data['consults']);
|
||||
$model->meetings()->createMany($data['meetings']);
|
||||
$model->socials()->createMany($data['socials']);
|
||||
|
||||
DB::commit();
|
||||
}catch(\Throwable $th){
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
return $this->setError('系统错误,请刷新后重试');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function update($primaryKey, $data): bool
|
||||
{
|
||||
$columns = $this->getTableColumns();
|
||||
$model = $this->query()->whereKey($primaryKey)->first();
|
||||
|
||||
if(isset($data['avatar'])){
|
||||
$data['avatar'] = $this->saveImage('avatar', 'manages/cover')[0] ?? '';
|
||||
}
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
if (!in_array($k, $columns)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$model->setAttribute($k, $v);
|
||||
}
|
||||
|
||||
try{
|
||||
DB::beginTransaction();
|
||||
|
||||
$model->save();
|
||||
$model->jobs()->delete();
|
||||
$model->jobs()->createMany($data['jobs']);
|
||||
$model->ranks()->delete();
|
||||
$model->ranks()->createMany($data['ranks']);
|
||||
$model->projects()->delete();
|
||||
$model->projects()->createMany($data['projects']);
|
||||
$model->articles()->delete();
|
||||
$model->articles()->createMany($data['articles']);
|
||||
$model->consults()->delete();
|
||||
$model->consults()->createMany($data['consults']);
|
||||
$model->meetings()->delete();
|
||||
$model->meetings()->createMany($data['meetings']);
|
||||
$model->socials()->delete();
|
||||
$model->socials()->createMany($data['socials']);
|
||||
|
||||
DB::commit();
|
||||
}catch(\Throwable $th){
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
return $this->setError('系统错误,请刷新后重试');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param string $ids
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete(string $ids): mixed
|
||||
{
|
||||
$result = $this->query()->whereIn($this->primaryKey(), explode(',', $ids))->delete();
|
||||
|
||||
if ($result) {
|
||||
$this->deleted($ids);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除钩子
|
||||
*
|
||||
* @param string $ids
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function deleted(string $ids)
|
||||
{
|
||||
ManageJob::whereIn('manage_id', explode(',', $ids))->delete();
|
||||
ManageRank::whereIn('manage_id', explode(',', $ids))->delete();
|
||||
ManageProject::whereIn('manage_id', explode(',', $ids))->delete();
|
||||
ManageArticle::whereIn('manage_id', explode(',', $ids))->delete();
|
||||
ManageConsult::whereIn('manage_id', explode(',', $ids))->delete();
|
||||
ManageMeeting::whereIn('manage_id', explode(',', $ids))->delete();
|
||||
ManageSocial::whereIn('manage_id', explode(',', $ids))->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use Slowlyo\OwlAdmin\Renderers\Drawer;
|
||||
use Slowlyo\OwlAdmin\Renderers\Dialog;
|
||||
use Slowlyo\OwlAdmin\Renderers\DrawerAction;
|
||||
use Slowlyo\OwlAdmin\Renderers\DialogAction;
|
||||
use Slowlyo\OwlAdmin\Renderers\LinkAction;
|
||||
|
||||
trait CustomActionTrait
|
||||
{
|
||||
/**
|
||||
* 新增按钮
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $size
|
||||
* @param string $width
|
||||
*
|
||||
* @return DialogAction|DrawerAction|LinkAction
|
||||
*/
|
||||
protected function createTypeButton(string $type = '', string $size = '', string $width = ''): DialogAction|DrawerAction|LinkAction
|
||||
{
|
||||
switch ($type) {
|
||||
case 'drawer':
|
||||
$form = $this->form(false)->api($this->getStorePath())->onEvent([]);
|
||||
|
||||
$drawer = Drawer::make()->title(__('admin.create'))->body($form)->closeOnOutside();
|
||||
if($width){
|
||||
$drawer->width($width);
|
||||
}else{
|
||||
$drawer->size($size);
|
||||
}
|
||||
$button = DrawerAction::make()->drawer($drawer);
|
||||
break;
|
||||
case 'dialog':
|
||||
$form = $this->form(false)->api($this->getStorePath())->onEvent([]);
|
||||
|
||||
$button = DialogAction::make()->dialog(
|
||||
Dialog::make()->title(__('admin.create'))->body($form)->size($size)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$button = LinkAction::make()->link($this->getCreatePath());
|
||||
break;
|
||||
}
|
||||
|
||||
return $button->label(__('admin.create'))->icon('fa fa-add')->level('primary');
|
||||
}
|
||||
|
||||
/**
|
||||
* 行编辑按钮
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $size
|
||||
* @param string $width
|
||||
*
|
||||
* @return DialogAction|DrawerAction|LinkAction
|
||||
*/
|
||||
protected function rowEditTypeButton(string $type = '', string $size = '', string $width = ''): DialogAction|DrawerAction|LinkAction
|
||||
{
|
||||
switch ($type) {
|
||||
case 'drawer':
|
||||
$form = $this->form(true)
|
||||
->api($this->getUpdatePath())
|
||||
->initApi($this->getEditGetDataPath())
|
||||
->redirect('')
|
||||
->onEvent([]);
|
||||
|
||||
$drawer = Drawer::make()->title(__('admin.edit'))->body($form)->closeOnOutside();
|
||||
|
||||
if($width){
|
||||
$drawer->width($width);
|
||||
}else{
|
||||
$drawer->size($size);
|
||||
}
|
||||
|
||||
$button = DrawerAction::make()->drawer($drawer);
|
||||
break;
|
||||
case 'dialog':
|
||||
$form = $this->form(true)
|
||||
->api($this->getUpdatePath())
|
||||
->initApi($this->getEditGetDataPath())
|
||||
->redirect('')
|
||||
->onEvent([]);
|
||||
|
||||
$button = DialogAction::make()->dialog(
|
||||
Dialog::make()->title(__('admin.edit'))->body($form)->size($size)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$button = LinkAction::make()->link($this->getEditPath());
|
||||
break;
|
||||
}
|
||||
|
||||
return $button->label(__('admin.edit'))->icon('fa-regular fa-pen-to-square')->level('link');
|
||||
}
|
||||
|
||||
/**
|
||||
* 行详情按钮
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $size
|
||||
* @param string $width
|
||||
*
|
||||
* @return DialogAction|DrawerAction|LinkAction
|
||||
*/
|
||||
protected function rowShowTypeButton(string $type = '', string $size = '', string $width = ''): DialogAction|DrawerAction|LinkAction
|
||||
{
|
||||
switch ($type) {
|
||||
case 'drawer':
|
||||
$drawer = Drawer::make()->title(__('admin.show'))->name('detail_info')->body($this->detail('$id'))->closeOnOutside();
|
||||
|
||||
if($width){
|
||||
$drawer->width($width);
|
||||
}else{
|
||||
$drawer->size($size);
|
||||
}
|
||||
//补充详情操作按钮扩展
|
||||
try{
|
||||
$actions = $this->detailActions();
|
||||
}catch(\BadMethodCallException $e){
|
||||
$actions = [];
|
||||
}
|
||||
$drawer->actions($actions);
|
||||
|
||||
$button = DrawerAction::make()->drawer($drawer);
|
||||
break;
|
||||
case 'dialog':
|
||||
//补充详情操作按钮扩展
|
||||
$dialog = Dialog::make()->title(__('admin.show'))->name('detail_info')->body($this->detail('$id'))->size($size);
|
||||
try{
|
||||
$actions = $this->detailActions();
|
||||
}catch(\BadMethodCallException $e){
|
||||
$actions = [];
|
||||
}
|
||||
$dialog->actions($actions);
|
||||
$button = DialogAction::make()->dialog($dialog);
|
||||
break;
|
||||
default:
|
||||
$button = LinkAction::make()->link($this->getShowPath());
|
||||
break;
|
||||
}
|
||||
|
||||
return $button->label(__('admin.show'))->icon('fa-regular fa-eye')->level('link');
|
||||
}
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ return [
|
|||
|
||||
'layout' => [
|
||||
// 浏览器标题, 功能名称使用 %title% 代替
|
||||
'title' => '%title% | OwlAdmin',
|
||||
'title' => '%title% | 专家管理',
|
||||
'header' => [
|
||||
// 是否显示 [刷新] 按钮
|
||||
'refresh' => true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue