generated from liutk/owl-admin-base
完善分户操作
parent
d94b00b0c7
commit
eb3a01f6d9
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||
use App\Admin\Components;
|
||||
use App\Services\Admin\PersonChangeService;
|
||||
|
||||
/**
|
||||
* 人口变动
|
||||
*
|
||||
*/
|
||||
class PersonChangeController extends AdminController
|
||||
{
|
||||
protected string $serviceName = PersonChangeService::class;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()->tableLayout('fixed')
|
||||
->headerToolbar([
|
||||
amis('reload')->align('right'),
|
||||
amis('filter-toggler')->align('right'),
|
||||
])
|
||||
->filter($this->baseFilter()->labelWidth('80px')->body([
|
||||
|
||||
]))
|
||||
->columns([
|
||||
amis()->TableColumn('person.organized_body.name', __('admin.persons.organized_body'))->width('100px'),
|
||||
amis()->TableColumn('person.name', __('admin.persons.name'))->width('100px')->copyable(),
|
||||
amis()->TableColumn('extends_mark', __('admin.person_changes.extends_mark')),
|
||||
amis()->TableColumn('phone', __('admin.person_changes.phone')),
|
||||
amis()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
|
||||
]);
|
||||
|
||||
return $this->baseList($crud);
|
||||
}
|
||||
|
||||
public function form(): Form
|
||||
{
|
||||
return $this->baseForm()->body([
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
public function detail(): Form
|
||||
{
|
||||
return $this->baseDetail()->body([
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -155,12 +155,12 @@ class PersonController extends AdminController
|
|||
amis()->TextControl('card_address')->placeholder('详细地址'),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->SelectControl('nation', __('admin.persons.nation'))->options(Keyword::where('parent_key', 'nation')->pluck('name', 'id')->toArray())->clearable(true)->required()->searchable(),
|
||||
amis()->SelectControl('political_face', __('admin.persons.political_face'))->options(Keyword::where('parent_key', 'political_face')->pluck('name', 'id')->toArray())->clearable(true)->required(),
|
||||
amis()->SelectControl('nation_id', __('admin.persons.nation'))->options(Keyword::where('parent_key', 'nation')->pluck('name', 'id')->toArray())->clearable(true)->required()->searchable(),
|
||||
amis()->SelectControl('political_face_id', __('admin.persons.political_face'))->options(Keyword::where('parent_key', 'political_face')->pluck('name', 'id')->toArray())->clearable(true)->required(),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->SelectControl('educational_level', __('admin.persons.educational_level'))->options(Keyword::where('parent_key', 'educational_level')->pluck('name', 'id')->toArray())->clearable(true)->required(),
|
||||
amis()->SelectControl('marry_state', __('admin.persons.marry_state'))->options(Keyword::where('parent_key', 'marry_state')->pluck('name', 'id')->toArray())->clearable(true)->required(),
|
||||
amis()->SelectControl('educational_level_id', __('admin.persons.educational_level'))->options(Keyword::where('parent_key', 'educational_level')->pluck('name', 'id')->toArray())->clearable(true)->required(),
|
||||
amis()->SelectControl('marry_state_id', __('admin.persons.marry_state'))->options(Keyword::where('parent_key', 'marry_state')->pluck('name', 'id')->toArray())->clearable(true)->required(),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
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')->onlyLeaf(true)->clearable(true),
|
||||
|
|
@ -173,11 +173,11 @@ class PersonController extends AdminController
|
|||
amis()->FieldSetControl()->title('户籍信息')->className('mt-10')->body([
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('domicile_code', __('admin.persons.domicile_code'))->required(),
|
||||
amis()->SelectControl('organized_body', __('admin.persons.organized_body'))->options(Keyword::where('parent_key', 'organized_body')->pluck('name', 'id')->toArray())->clearable(true)->required(),
|
||||
amis()->SelectControl('organized_body_id', __('admin.persons.organized_body'))->options(Keyword::where('parent_key', 'organized_body')->pluck('name', 'id')->toArray())->clearable(true)->required(),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->SwitchControl('has_benefit', __('admin.persons.has_benefit'))->value(false)->required(),
|
||||
amis()->SelectControl('domicile', __('admin.persons.domicile'))->options(Keyword::where('parent_key', 'domicile')->pluck('name', 'id')->toArray())->clearable(true)->required(),
|
||||
amis()->SelectControl('domicile_id', __('admin.persons.domicile'))->options(Keyword::where('parent_key', 'domicile')->pluck('name', 'id')->toArray())->clearable(true)->required(),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
$this->masterPicker('master', '', '输入 户主姓名 进行筛选,忽略则为添加户主')->disabledOn('this.id > 0'),
|
||||
|
|
@ -347,7 +347,7 @@ class PersonController extends AdminController
|
|||
}
|
||||
|
||||
/**
|
||||
* 分户-todo
|
||||
* 分户
|
||||
*/
|
||||
public function splitMasterForm()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ Route::group([
|
|||
$router->resource('persons', \App\Admin\Controllers\PersonController::class);
|
||||
$router->post('split_master', [\App\Admin\Controllers\PersonController::class, 'doSplitMaster']);
|
||||
|
||||
$router->resource('person_changes', \App\Admin\Controllers\PersonChangeController::class);
|
||||
|
||||
|
||||
//数据管理
|
||||
$router->resource('financial_cate', \App\Admin\Controllers\KeywordController::class);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Filters;
|
||||
|
||||
use EloquentFilter\ModelFilter;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Keyword;
|
||||
|
||||
class PersonChangeFilter extends ModelFilter
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ class PersonFilter extends ModelFilter
|
|||
*/
|
||||
public function houseBuilding($houseBuilding)
|
||||
{
|
||||
if(Keyword::where('id',$houseBuilding)->value('lv') == 3)
|
||||
if(Keyword::where('id', $houseBuilding)->value('lv') == 3)
|
||||
{
|
||||
return $this->where('building', $houseBuilding);
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -27,11 +27,14 @@ class Person extends Model
|
|||
parent::boot();
|
||||
// 监听 人口 的创建事件,用于初始化 位置信息
|
||||
static::created(function ($person) {
|
||||
//处理户主信息
|
||||
if(empty($person->master_id) && $person->master_connect){
|
||||
$person->master_id = $person->id;
|
||||
$person->is_master = 1;
|
||||
$person->save();
|
||||
}
|
||||
//处理新增时变动记录-todo
|
||||
|
||||
});
|
||||
static::saving(function ($person) {
|
||||
if($person->origin_city_code){
|
||||
|
|
@ -66,6 +69,11 @@ class Person extends Model
|
|||
return $this->belongsTo(static::class, 'master_id');
|
||||
}
|
||||
|
||||
public function organizedBody()
|
||||
{
|
||||
return $this->belongsTo(Keyword::class, 'organized_body_id');
|
||||
}
|
||||
|
||||
//年龄
|
||||
protected function age():Attribute
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,10 +4,12 @@ namespace App\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use EloquentFilter\Filterable;
|
||||
|
||||
class PersonChange extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Filterable;
|
||||
|
||||
public const TYPE_IN = 1; //迁入
|
||||
public const TYPE_BIRTH = 2; //出生
|
||||
|
|
@ -18,6 +20,10 @@ class PersonChange extends Model
|
|||
public const TYPE_MIGRATE = 7; //迁移
|
||||
public const TYPE_CHANGE = 8; //变更户主
|
||||
|
||||
protected $casts = [
|
||||
'extends' => 'array',
|
||||
];
|
||||
|
||||
public static function typeMap()
|
||||
{
|
||||
return [
|
||||
|
|
@ -31,4 +37,14 @@ class PersonChange extends Model
|
|||
self::TYPE_CHANGE =>'变更户主',
|
||||
];
|
||||
}
|
||||
|
||||
protected function serializeDate(\DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function person()
|
||||
{
|
||||
return $this->belongsTo(Person::class, 'person_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\Admin;
|
||||
|
||||
use App\Models\PersonChange;
|
||||
use App\Models\Filters\PersonChangeFilter;
|
||||
use App\Traits\UploadTrait;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
/**
|
||||
* @method PersonChange getModel()
|
||||
* @method PersonChange|\Illuminate\Database\Query\Builder query()
|
||||
*/
|
||||
class PersonChangeService extends BaseService
|
||||
{
|
||||
protected string $modelName = PersonChange::class;
|
||||
|
||||
protected string $modelFilterName = PersonChangeFilter::class;
|
||||
|
||||
protected array $withRelationships = ['person', 'person.organizedBody'];
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Services\Admin;
|
||||
|
||||
use App\Models\Keyword;
|
||||
use App\Models\Person;
|
||||
use App\Models\Filters\PersonFilter;
|
||||
use App\Traits\UploadTrait;
|
||||
|
|
@ -43,6 +44,13 @@ class PersonService extends BaseService
|
|||
unset($data['master']);
|
||||
}
|
||||
|
||||
//处理house_building字段
|
||||
if(isset($data['house_building']))
|
||||
{
|
||||
$data['housing_estate_id'] = Keyword::where('id', $data['house_building'])->value('parent_id') ?:0;
|
||||
$data['building_id'] = $data['house_building'];
|
||||
}
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
if (!in_array($k, $columns)) {
|
||||
continue;
|
||||
|
|
@ -63,6 +71,12 @@ class PersonService extends BaseService
|
|||
$data['avatar'] = $this->saveImage('avatar', 'persons/avatar')[0] ?? '';
|
||||
}
|
||||
|
||||
if(isset($data['house_building']))
|
||||
{
|
||||
$data['housing_estate_id'] = Keyword::where('id', $data['house_building'])->value('parent_id') ?:0;
|
||||
$data['building_id'] = $data['house_building'];
|
||||
}
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
if (!in_array($k, $columns)) {
|
||||
continue;
|
||||
|
|
@ -113,11 +127,11 @@ class PersonService extends BaseService
|
|||
continue;
|
||||
}
|
||||
|
||||
$changeMark = (isset($extends['splited_at']) ? $extends['splited_at'] : '某日'). (isset($extends['split_reason']) ? ('因' .$extends['split_reason']) : '').'分户, ';
|
||||
$changeMark = (isset($extends['splited_at']) ? $extends['splited_at'] : '某日'). '日,' .(isset($extends['split_reason']) ? ('因' .$extends['split_reason']) : '').'分户,';
|
||||
if($newMaster['id'] == $person['id']){
|
||||
$changeMark .= '成为新户主';
|
||||
}else{
|
||||
$changeMark .= '户主由['.$person["master"]["name"].']变更为['.$newMaster["name"].'], 与户主关系更新为['.$person['new_master_connect'].']';
|
||||
$changeMark .= '户主由【'.$person["master"]["name"].']变更为['.$newMaster["name"].'】,与户主关系更新为【'.$person['new_master_connect'].'】';
|
||||
}
|
||||
$personChangeLogs[] = [
|
||||
'person_id' => $person['id'],
|
||||
|
|
@ -128,6 +142,8 @@ class PersonService extends BaseService
|
|||
'new_master' => $newMaster['id'],
|
||||
'extends_mark' => $changeMark,
|
||||
'remark' => isset($extends['remark']) ? $extends['remark'] : null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
];
|
||||
|
||||
Person::where('id', $person['id'])->update([
|
||||
|
|
|
|||
|
|
@ -33,17 +33,17 @@ return new class extends Migration
|
|||
$table->unsignedBigInteger('card_area_id')->nullable()->comment('户籍-区');
|
||||
$table->string('card_address')->nullable()->comment('户籍-街道详细地址');
|
||||
$table->string('card_complete_address')->nullable()->comment('户籍-完整地址');
|
||||
$table->unsignedBigInteger('housing_estate')->nullable()->comment('小区');
|
||||
$table->unsignedBigInteger('building')->nullable()->comment('楼栋');
|
||||
$table->unsignedBigInteger('housing_estate_id')->nullable()->comment('小区');
|
||||
$table->unsignedBigInteger('building_id')->nullable()->comment('楼栋');
|
||||
$table->string('house_number')->nullable()->comment('门牌号');
|
||||
$table->string('house_complete_address')->nullable()->comment('小区完整地址');
|
||||
$table->string('real_address')->nullable()->comment('实际居住地址');
|
||||
|
||||
$table->unsignedBigInteger('nation')->nullable()->comment('民族');
|
||||
$table->unsignedBigInteger('political_face')->nullable()->comment('政治面貌');
|
||||
$table->unsignedBigInteger('educational_level')->nullable()->comment('文化程度');
|
||||
$table->unsignedBigInteger('marry_state')->nullable()->comment('婚姻状况');
|
||||
$table->unsignedBigInteger('job_cate')->nullable()->comment('工种');
|
||||
$table->unsignedBigInteger('nation_id')->nullable()->comment('民族');
|
||||
$table->unsignedBigInteger('political_face_id')->nullable()->comment('政治面貌');
|
||||
$table->unsignedBigInteger('educational_level_id')->nullable()->comment('文化程度');
|
||||
$table->unsignedBigInteger('marry_state_id')->nullable()->comment('婚姻状况');
|
||||
$table->unsignedBigInteger('job_cate_id')->nullable()->comment('工种');
|
||||
$table->string('job')->nullable()->comment('职业');
|
||||
$table->string('health')->nullable()->comment('身体状况');
|
||||
$table->string('phone')->nullable()->comment('联系方式');
|
||||
|
|
@ -51,10 +51,10 @@ return new class extends Migration
|
|||
|
||||
$table->unsignedTinyInteger('type')->nullable()->comment('类型11-出生人口,12-迁入人口(11、12统称户籍人口),2-流动人口,3-留守人口,4-境外人口');
|
||||
$table->unsignedTinyInteger('has_benefit')->default(0)->comment('是否享受福利');
|
||||
$table->unsignedBigInteger('organized_body')->nullable()->comment('社别');
|
||||
$table->unsignedBigInteger('organized_body_id')->nullable()->comment('社别');
|
||||
$table->string('t_ids')->nullable()->comment('标签');
|
||||
|
||||
$table->unsignedBigInteger('domicile')->nullable()->comment('户籍类型');
|
||||
$table->unsignedBigInteger('domicile_id')->nullable()->comment('户籍类型');
|
||||
$table->string('domicile_code')->nullable()->comment('户籍编号');
|
||||
$table->unsignedBigInteger('master_id')->nullable()->default(0)->comment('户主ID');
|
||||
$table->unsignedTinyInteger('is_master')->default(0)->comment('是否户主');
|
||||
|
|
|
|||
|
|
@ -56,17 +56,17 @@ class PersonSeeder extends Seeder
|
|||
'origin_complete_address' => $person->nativePlace,
|
||||
'card_complete_address' => $person->birthAddr,
|
||||
|
||||
'housing_estate' => null,
|
||||
'building' => null,
|
||||
'housing_estate_id' => null,
|
||||
'building_id' => null,
|
||||
'house_number' => null,
|
||||
'house_complete_address' => null,
|
||||
'real_address' => null,
|
||||
|
||||
'nation' => Keyword::where('parent_key', 'nation')->where('oid', $person->folkId)->value('id'),
|
||||
'political_face' => Keyword::where('parent_key', 'political_face')->where('oid', $person->politicsId)->value('id'),
|
||||
'educational_level' => Keyword::where('parent_key', 'educational_level')->where('oid', $person->educationId)->value('id'),
|
||||
'marry_state' => Keyword::where('parent_key', 'marry_state')->where('name', $person->marryStatus)->value('id'),
|
||||
'job_cate' => Keyword::where('parent_key', 'job_cate')->where('name', $person->workType)->value('id'),
|
||||
'nation_id' => Keyword::where('parent_key', 'nation')->where('oid', $person->folkId)->value('id'),
|
||||
'political_face_id' => Keyword::where('parent_key', 'political_face')->where('oid', $person->politicsId)->value('id'),
|
||||
'educational_level_id' => Keyword::where('parent_key', 'educational_level')->where('oid', $person->educationId)->value('id'),
|
||||
'marry_state_id' => Keyword::where('parent_key', 'marry_state')->where('name', $person->marryStatus)->value('id'),
|
||||
'job_cate_id' => Keyword::where('parent_key', 'job_cate')->where('name', $person->workType)->value('id'),
|
||||
'job' => $person->career,
|
||||
'health'=> $person->health,
|
||||
'phone' => $person->phone,
|
||||
|
|
@ -74,9 +74,9 @@ class PersonSeeder extends Seeder
|
|||
|
||||
'type'=>$person->type,
|
||||
'has_benefit' => $person->benefit == '是' ? 1:0,
|
||||
'organized_body' => Keyword::where('parent_key', 'organized_body')->where('oid', $person->societyId)->value('id'),
|
||||
'organized_body_id' => Keyword::where('parent_key', 'organized_body')->where('oid', $person->societyId)->value('id'),
|
||||
|
||||
'domicile'=> Keyword::where('parent_key', 'domicile')->where('oid', $person->houseHoldTypeId)->value('id'),
|
||||
'domicile_id'=> Keyword::where('parent_key', 'domicile')->where('oid', $person->houseHoldTypeId)->value('id'),
|
||||
'domicile_code' => $person->houseHoldNumber,
|
||||
'master_id' => $person->houseHoldMasterId,
|
||||
'is_master' => $person->houseHoldMasterRelative == '户主' ? 1:0,
|
||||
|
|
@ -127,11 +127,11 @@ class PersonSeeder extends Seeder
|
|||
$housingEstate = Keyword::where('parent_key', 'housing_estate')->where('oid', $person->courtId)->first();
|
||||
$building = Keyword::where('parent_key', 'like', 'housing_estate%')->where('oid', $person->buildingId ?:0)->first();
|
||||
if($housingEstate){
|
||||
$_person['housing_estate'] = $housingEstate->id;
|
||||
$_person['housing_estate_id'] = $housingEstate->id;
|
||||
$houseCompleteAddress .= $housingEstate->name;
|
||||
}
|
||||
if($building){
|
||||
$_person['building'] = $building->id;
|
||||
$_person['building_id'] = $building->id;
|
||||
$houseCompleteAddress .= $building->name;
|
||||
}
|
||||
$_person['house_number'] = $person->door;
|
||||
|
|
|
|||
|
|
@ -379,4 +379,8 @@ return [
|
|||
//分户操作
|
||||
'split_master' => '分户',
|
||||
],
|
||||
'person_changes'=>[
|
||||
'extends_mark'=>'变动明细',
|
||||
'phone'=>'联系方式'
|
||||
]
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue