242 lines
14 KiB
PHP
242 lines
14 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Models\{Keyword,Oldmen};
|
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
|
use Slowlyo\OwlAdmin\Renderers\TableColumn;
|
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|
use App\Services\Admin\LiveContinueService;
|
|
use Illuminate\Http\Request;
|
|
use App\Admin\Components;
|
|
|
|
class LiveContinueController extends AdminController
|
|
{
|
|
protected string $serviceName = LiveContinueService::class;
|
|
|
|
public function list(): Page
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->filterTogglable(false)
|
|
->headerToolbar([
|
|
amis('button')->label('续住')->icon('fa fa-plus')->actionType('link')->level('primary')->link('live-in-continue'),
|
|
])
|
|
->filter(
|
|
$this->baseFilter()->body([
|
|
amisMake()->TextControl('name', '名称')->size('md'),
|
|
amisMake()->TextControl('card_no', '身份证')->size('md'),
|
|
amisMake()->TextControl('floor_name', '楼栋')->size('md'),
|
|
amisMake()->SelectControl('nurse_lv', '护理等级')->options(Keyword::getByParentKey('nurse_lv')->pluck('name', 'value'))->checkAll(true)->multiple(true)->size('md'),
|
|
amis('button')->label(__('admin.reset'))->actionType('clear-and-submit'),
|
|
amis('submit')->label(__('admin.search'))->level('primary'),
|
|
])->actions([])
|
|
)
|
|
->columns([
|
|
// TableColumn::make()->name('id')->label('ID')->sortable(),
|
|
TableColumn::make()->name('name')->label('姓名'),
|
|
TableColumn::make()->name('age')->label('年龄')->sortable(),
|
|
TableColumn::make()->name('card_no')->label('身份证')->copyable(true),
|
|
TableColumn::make()->name('floor_name')->label('楼栋'),
|
|
TableColumn::make()->name('nurse_lv')->type('mapping')->map(Keyword::getByParentKey('nurse_lv')->pluck('name', 'value'))->label('护理等级')->className('text-primary')->sortable(),
|
|
TableColumn::make()->name('client_name')->label('委托人'),
|
|
TableColumn::make()->name('client_phone')->label('委托人-手机号')->copyable(true),
|
|
TableColumn::make()->name('avliable_at')->label('截至时间')->type('datetime')->sortable(true),
|
|
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
|
amisMake()->LinkAction()->label('续住')->icon('fa fa-plus')->link('live-continue-do?oldman_id=${id}')->level('link'),
|
|
amisMake()->LinkAction()->label('结算')->icon('fa fa-external-link-alt')->link('live-exit-do?oldman_id=${id}')->level('link')
|
|
]),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
public function form(): Form
|
|
{
|
|
return $this->baseForm()->body([
|
|
|
|
]);
|
|
}
|
|
|
|
public function doForm(){
|
|
|
|
$feeKeys =[];
|
|
$feeKeys['add_extends'] = '${add_extends}';
|
|
$feeKeys['del_extends'] = '${del_extends}';
|
|
$feeKeys['continue_fee'] = '${continue_fee}';
|
|
|
|
$page = $this->basePage()->body([
|
|
amisMake()->Card()->className('border-0')->body(
|
|
amisMake()->Wrapper()->className('p-0')->body(
|
|
amisMake()->Grid()->className('relative')->columns([
|
|
amisMake()->Wrapper()->sm(8)->body([
|
|
amisMake()->Panel()->title('续住表单')->body(
|
|
amisMake()->form()->title('')->panelClassName('border-0')->mode('horizontal')->name('base_form')
|
|
->api(admin_url('live-continue-do'))
|
|
->body([
|
|
amisMake()->FieldSetControl()->title('续住人信息')->collapsable(true)->body([
|
|
amisMake()->Service()->api([
|
|
"method"=>'get',
|
|
"url" => admin_url('oldmen/${oldman_id}/edit'),
|
|
"data"=>[
|
|
'_action' => 'getData',
|
|
],
|
|
"sendOn" => "this.oldman_id > 0 "
|
|
]),
|
|
amisMake()->GroupControl()->body([
|
|
amisMake()->PickerControl('oldman_id', '姓名')
|
|
->valueField('id')
|
|
->labelField('name')
|
|
->joinValues(false)->extractValue(true)
|
|
->size('lg')
|
|
->source([
|
|
'method' => 'get',
|
|
'url' => admin_url('oldmen?_action=getData&live_in='.Oldmen::STATUS_LIVE),
|
|
'data' => [
|
|
'name'=>'${term}',
|
|
]
|
|
])
|
|
->pickerSchema(
|
|
[
|
|
'mode' => 'table',
|
|
'name' => 'monitor_list',
|
|
'headerToolbar' => amisMake()->form()
|
|
->wrapWithPanel(false)
|
|
->className('text-right')
|
|
->target('monitor_list')
|
|
->mode('inline')
|
|
->body([
|
|
amisMake()->TextControl('term', '姓名/身份证号')->addOn(
|
|
amis('submit')->label(__('admin.search'))->level('primary')
|
|
)
|
|
]),
|
|
'columns' => [
|
|
TableColumn::make()->name('name')->label('姓名'),
|
|
TableColumn::make()->name('card_no')->label('身份证号码'),
|
|
]
|
|
]
|
|
)->value(0)
|
|
->required(true),
|
|
|
|
amisMake()->RadiosControl('sex', '性别')->options([
|
|
1=>'男',2=>'女'
|
|
])->disabled(true),
|
|
]),
|
|
amisMake()->GroupControl()->body([
|
|
amisMake()->TextControl('card_no', '身份证号码')->disabled(true),
|
|
amisMake()->DateControl('birthday', '出生日期')->format('YYYY-MM-DD')->disabled(true),
|
|
]),
|
|
|
|
amisMake()->GroupControl()->body([
|
|
amisMake()->TextControl('floor_name', '楼栋')->disabled(true),
|
|
amisMake()->TextControl('agreement_no', '协议号码')->disabled(true),
|
|
]),
|
|
amisMake()->GroupControl()->body([
|
|
amisMake()->RadiosControl('nurse_lv', '护理等级')->options(Keyword::getByParentKey('nurse_lv')->pluck('name', 'value'))->disabledOn('data.change_lv == 0')->required(true),
|
|
amisMake()->SwitchControl('change_lv', '变更护理等级')->value(0),
|
|
]),
|
|
|
|
amisMake()->GroupControl()->body([
|
|
amisMake()->TextControl('start_at', '开始时间')->disabled(true),
|
|
amisMake()->DateControl('end_at', '截至时间')->minDate('${start_at}')->value('${start_at}')->format('YYYY-MM-DD')->required(true),
|
|
]),
|
|
]),
|
|
|
|
|
|
amisMake()->FieldSetControl()->className('mt-10')->title('费用明细')->collapsable(true)->body([
|
|
amisMake()->FieldSetControl()->title('基础费用')->className('mt-5')->collapsable(true)->size('base')->body(
|
|
amisMake()->Service()->schemaApi([
|
|
"method"=>'get',
|
|
"url" => admin_url('live-fee-form').'?nurse_lv=${nurse_lv}&start_at=${start_at}&end_at=${end_at}&type=continue_fee',
|
|
])
|
|
),
|
|
]),
|
|
|
|
amisMake()->FieldSetControl()->className('mt-10')->title('附加项')->collapsable(true)->body([
|
|
amisMake()->ComboControl('add_extends','收费项')->multiple(true)->items([
|
|
amisMake()->TextControl('name', '名称'),
|
|
Components::make()->decimalControl('fee', '金额')
|
|
]),
|
|
amisMake()->ComboControl('del_extends','抵扣项')->multiple(true)->items([
|
|
amisMake()->TextControl('name', '名称'),
|
|
Components::make()->decimalControl('fee', '金额')
|
|
]),
|
|
]),
|
|
])
|
|
->actions([
|
|
amis('button')->label("生成清单")->level('primary')
|
|
->onEvent([
|
|
'click'=>[
|
|
'actions'=>[
|
|
[
|
|
'actionType'=>'reload',
|
|
'componentId'=>'fee_table'
|
|
],
|
|
[
|
|
'actionType'=>'setValue',
|
|
'componentId'=>'fee_table',
|
|
'args'=>[
|
|
'value'=> $feeKeys
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]),
|
|
amis('submit')->label('确认续住')->confirmText('是否确认续住,并且已查看续住费用清单?')
|
|
->redirect('live-in')
|
|
->level('danger'),
|
|
]),
|
|
),
|
|
]),
|
|
amisMake()->Wrapper()->sm(4)->className('absolute bottom-20 w-2/6')->body([
|
|
amisMake()->Panel()->title('结算清单')->body([
|
|
amisMake()->Service()->name('fee_table_name')->id('fee_table')
|
|
->data($feeKeys)
|
|
->body(
|
|
amisMake()->table()->affixHeader(false)
|
|
->title('')
|
|
->source('${rows}')
|
|
->combineNum(2)
|
|
->columns([
|
|
amisMake()->TableColumn()->name('name')->label('名称'),
|
|
amisMake()->TableColumn()->name('fee_name')->label('费用项'),
|
|
amisMake()->TableColumn()->name('fee_value')->label('费用'),
|
|
])->affixRow([
|
|
amis('text')->text('合计')->colSpan(2),
|
|
amis('tpl')->tpl('${SUM(ARRAYMAP(rows, item => item.fee_value))}')
|
|
]),
|
|
)->api([
|
|
'method'=>'get',
|
|
'data'=> $feeKeys,
|
|
'url' =>admin_url('live-feelist')
|
|
]),
|
|
]),
|
|
|
|
]),
|
|
]),
|
|
)
|
|
),
|
|
]);
|
|
|
|
return $this->response()->success($page);
|
|
}
|
|
|
|
public function do(Request $request){
|
|
$oldManId = $request->input('oldman_id');
|
|
|
|
$startDay = $request->input('start_at', null);
|
|
$endDay = $request->input('end_at', null);
|
|
|
|
$liveFee = $request->input('continue_fee', []);
|
|
$addFee = $request->input('add_extends', []);
|
|
$delFee = $request->input('del_extends', []);
|
|
|
|
$res = $this->service->do($oldManId, $startDay, $endDay, [
|
|
'live_fee' => $liveFee,
|
|
'add_fee' => $addFee,
|
|
'del_fee' => $delFee,
|
|
], $request->input('change_lv', 0), $request->input('nurse_lv', 0));
|
|
|
|
return $this->autoResponse($res, '续住');
|
|
}
|
|
}
|