generated from liutk/owl-admin-base
完善人口列表搜索查看
parent
acef8246e8
commit
78ff55ca1c
|
|
@ -8,6 +8,7 @@ use Slowlyo\OwlAdmin\Renderers\Form;
|
|||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||
use App\Services\Admin\PersonService;
|
||||
use App\Traits\CustomActionTrait;
|
||||
use App\Models\Keyword;
|
||||
|
||||
/**
|
||||
* 人口管理
|
||||
|
|
@ -29,19 +30,34 @@ class PersonController extends AdminController
|
|||
amis('filter-toggler')->align('right'),
|
||||
])
|
||||
->filter($this->baseFilter()->labelWidth('80px')->body([
|
||||
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->SelectControl('organized_body', __('admin.persons.organized_body'))->options(Keyword::where('parent_key', 'organized_body')->pluck('name', 'id')->toArray())
|
||||
->columnRatio(3)->clearable(true),
|
||||
amis()->NestedSelectControl('house_building', __('admin.persons.house_building'))->source(admin_url('api/keywords/tree-list?parent_name=housing_estate&has_owner=0'))->labelField('name')->valueField('id')->columnRatio(6)->clearable(true),
|
||||
// amis()->TextControl('master.name', __('admin.persons.master_name'))->placeholder(__('admin.persons.master_name')),
|
||||
// amis()->TextControl('name', __('admin.persons.name'))->placeholder(__('admin.persons.name')),
|
||||
// amis()->TextControl('idcard', __('admin.persons.idcard'))->placeholder(__('admin.persons.idcard')),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->SelectControl('state', __('admin.persons.state'))->options([
|
||||
'1'=>'实有人口','2'=>'已死亡','3'=>'已迁出'
|
||||
])->columnRatio(3)->clearable(true),
|
||||
amis()->DateRangeControl()->label(__('admin.persons.birthday'))->name('birthday')->valueFormat('YYYY-MM-DD')->columnRatio(6),
|
||||
]),
|
||||
]))
|
||||
->columns([
|
||||
amis()->TableColumn('domicile_code', __('admin.persons.domicile_code'))->width('100px')->copyable(),
|
||||
amis()->TableColumn('name', __('admin.persons.name'))->width('150px')->copyable(),
|
||||
amis()->TableColumn('domicile_code', __('admin.persons.domicile_code'))->width('120px')->copyable(),
|
||||
amis()->TableColumn('name', __('admin.persons.name'))->width('150px')->copyable()->searchable(),
|
||||
amis()->TableColumn('master_connect', __('admin.persons.master_connect'))->width('100px'),
|
||||
amis()->TableColumn('master.name', __('admin.persons.master_name'))->width('150px')->copyable(),
|
||||
amis()->TableColumn('idcard', __('admin.persons.idcard'))->copyable(),
|
||||
amis()->TableColumn('master.name', __('admin.persons.master_name'))->width('150px')->copyable()->searchable(),
|
||||
amis()->TableColumn('idcard', __('admin.persons.idcard'))->copyable()->searchable(),
|
||||
amis()->TableColumn('gender', __('admin.persons.gender'))->type('mapping')->map([
|
||||
"1"=>"<span class='label label-info'>男</span>",
|
||||
"2"=>"<span class='label label-success'>女</span>",
|
||||
"*"=> '其他:${gender}'
|
||||
]),
|
||||
])->filterable(['options'=>[
|
||||
['label'=>'男', 'value'=>1], ['label'=> '女', 'value'=>2]
|
||||
]]),
|
||||
amis()->TableColumn('birthday', __('admin.persons.birthday')),
|
||||
amis()->TableColumn('age', __('admin.persons.age')),
|
||||
amis()->TableColumn('now_address', __('admin.persons.now_address'))->copyable(),
|
||||
|
|
|
|||
|
|
@ -2,11 +2,32 @@
|
|||
|
||||
namespace App\Models\Filters;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use EloquentFilter\ModelFilter;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Keyword;
|
||||
|
||||
class PersonFilter extends ModelFilter
|
||||
{
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
public function name($name)
|
||||
{
|
||||
return $this->where('name', $name);
|
||||
}
|
||||
/**
|
||||
* 户主姓名
|
||||
*/
|
||||
public function master($master)
|
||||
{
|
||||
if(isset($master['name'])){
|
||||
return $this->whereHas('master', function(Builder $q) use ($master){
|
||||
$q->where('name', $master['name']);
|
||||
});
|
||||
}else{
|
||||
return ;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 身份证
|
||||
*/
|
||||
|
|
@ -14,4 +35,45 @@ class PersonFilter extends ModelFilter
|
|||
{
|
||||
return $this->where('idcard', $idcard);
|
||||
}
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
public function gender($gender)
|
||||
{
|
||||
return $this->where('gender', $gender);
|
||||
}
|
||||
|
||||
/**
|
||||
* 社别
|
||||
*/
|
||||
public function organizedBody($organizedBody)
|
||||
{
|
||||
return $this->where('organized_body', $organizedBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* 居住小区
|
||||
*/
|
||||
public function houseBuilding($houseBuilding)
|
||||
{
|
||||
if(Keyword::where('id',$houseBuilding)->value('lv') == 3)
|
||||
{
|
||||
return $this->where('building', $houseBuilding);
|
||||
}else{
|
||||
return $this->where('housing_estate', $houseBuilding);
|
||||
}
|
||||
}
|
||||
|
||||
public function state($state)
|
||||
{
|
||||
return $this->where('state', $state);
|
||||
}
|
||||
|
||||
public function birthday($birthday)
|
||||
{
|
||||
$birthday = explode(',', $birthday);
|
||||
|
||||
return $this->whereBetween('birthday', $birthday);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Models\Person;
|
|||
use App\Models\Filters\PersonFilter;
|
||||
use App\Traits\UploadTrait;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
/**
|
||||
* @method Person getModel()
|
||||
|
|
@ -22,4 +23,9 @@ class PersonService extends BaseService
|
|||
protected array $withRelationships = ['master'];
|
||||
|
||||
protected bool $modelSortAble = true;
|
||||
|
||||
public function query(): Builder
|
||||
{
|
||||
return $this->modelName::query()->whereIn('type', [11, 12]);
|
||||
}
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ return new class extends Migration
|
|||
$table->string('wx_openid')->nullable()->comment('微信openId');
|
||||
$table->string('baidu_face_id')->nullable()->comment('百度人脸ID');
|
||||
|
||||
$table->unsignedTinyInteger('state')->nullable()->comment('状态');
|
||||
$table->unsignedTinyInteger('state')->nullable()->comment('状态1正常2死亡3迁出');
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class AdminMenuSeeder extends Seeder
|
|||
'children' => [
|
||||
['title'=>'base_person_data', 'icon'=>'carbon:data-center','url'=>'/base_person_data', 'order'=>1, 'children' => [
|
||||
['title'=>'real_person_data', 'icon'=>'material-symbols:frame-person-outline-rounded','url'=>'/real_person_data', 'order'=>0, 'children' => [
|
||||
['title'=>'persons', 'icon'=>'material-symbols:switch-account-outline','url'=>'/persons', 'order'=>0],
|
||||
['title'=>'persons', 'icon'=>'material-symbols:switch-account-outline','url'=>'/persons?state=1', 'order'=>0],
|
||||
['title'=>'person_changes', 'icon'=>'material-symbols:user-attributes-outline','url'=>'/person_changes', 'order'=>1],
|
||||
]],
|
||||
]],
|
||||
|
|
|
|||
|
|
@ -348,5 +348,9 @@ return [
|
|||
'birthday' => '出生日期',
|
||||
'age' => '年龄',
|
||||
'now_address' => '现住址',
|
||||
'organized_body' => '社别',
|
||||
'house_building' => '居住小区',
|
||||
'state' => '人口状态',
|
||||
'birthday'=> '出生日期',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue