generated from liutk/owl-admin-base
Compare commits
24 Commits
2c1ef32db1
...
4489090552
| Author | SHA1 | Date |
|---|---|---|
|
|
4489090552 | |
|
|
64e4ce15e7 | |
|
|
62386555f1 | |
|
|
b4d06b89fa | |
|
|
41f4241308 | |
|
|
8f6d2dbd7c | |
|
|
caa22815f8 | |
|
|
eb3a01f6d9 | |
|
|
d94b00b0c7 | |
|
|
7f88707bf2 | |
|
|
764ce7b300 | |
|
|
c1cc36d27a | |
|
|
b7050a1918 | |
|
|
d43eebf310 | |
|
|
2358300875 | |
|
|
0360a5c93b | |
|
|
78ff55ca1c | |
|
|
acef8246e8 | |
|
|
6c787ec15f | |
|
|
62b994c3ea | |
|
|
e5296c5fc5 | |
|
|
3e354ad31f | |
|
|
57568e93ca | |
|
|
1fb02f9479 |
|
|
@ -15,9 +15,16 @@ DB_DATABASE=laravel
|
|||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
DJC_DB_CONNECTION=mysql
|
||||
DJC_DB_HOST=127.0.0.1
|
||||
DJC_DB_PORT=3306
|
||||
DJC_DB_DATABASE=laravel
|
||||
DJC_DB_USERNAME=root
|
||||
DJC_DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DISK=local
|
||||
FILESYSTEM_DISK=public
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use App\Services\Admin\AdService;
|
|||
use App\Admin\Components;
|
||||
use App\Models\Keyword;
|
||||
use App\Models\Ad;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
/**
|
||||
* 广告管理
|
||||
|
|
@ -19,13 +20,15 @@ use App\Models\Ad;
|
|||
*/
|
||||
class AdController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
|
||||
protected string $serviceName = AdService::class;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()->tableLayout('fixed')
|
||||
->headerToolbar([
|
||||
$this->createButton(),
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
...$this->baseHeaderToolBar(),
|
||||
])
|
||||
->filter($this->baseFilter()->labelWidth('80px')->body([
|
||||
|
|
@ -59,7 +62,7 @@ class AdController extends AdminController
|
|||
amis()->TableColumn('is_enable', __('admin.ads.is_enable'))->type('switch'),
|
||||
amis()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
|
||||
Operation::make()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditButton(),
|
||||
$this->rowEditTypeButton('drawer', 'md'),
|
||||
$this->rowDeleteButton(),
|
||||
])
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -4,14 +4,17 @@ namespace App\Admin\Controllers;
|
|||
|
||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||
use Slowlyo\OwlAdmin\Controllers\AdminRoleController as AdminRoleBaseController;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
class AdminRoleController extends AdminRoleBaseController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()
|
||||
->headerToolbar([
|
||||
$this->createButton(true),
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
...$this->baseHeaderToolBar(),
|
||||
])
|
||||
->filterTogglable(false)
|
||||
|
|
@ -32,7 +35,7 @@ class AdminRoleController extends AdminRoleBaseController
|
|||
->sortable(true),
|
||||
amis()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->setPermission()->visibleOn('${slug != "administrator"}'),
|
||||
$this->rowEditButton(true)->visibleOn('${slug != "administrator"}'),
|
||||
$this->rowEditTypeButton('drawer', 'md')->visibleOn('${slug != "administrator"}'),
|
||||
$this->rowDeleteButton()->visibleOn('${slug != "administrator"}'),
|
||||
]),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -10,19 +10,22 @@ use Slowlyo\OwlAdmin\Renderers\TableColumn;
|
|||
use App\Services\Admin\AdminUserService;
|
||||
use Slowlyo\OwlAdmin\Services\AdminRoleService;
|
||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
/**
|
||||
* @property AdminUserService $service
|
||||
*/
|
||||
class AdminUserController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
|
||||
protected string $serviceName = AdminUserService::class;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()
|
||||
->headerToolbar([
|
||||
$this->createButton(true),
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
...$this->baseHeaderToolBar(),
|
||||
])
|
||||
->filter($this->baseFilter()->body(
|
||||
|
|
@ -43,7 +46,7 @@ class AdminUserController extends AdminController
|
|||
amisMake()->TableColumn('lock', __('admin.admin_user.lock'))->quickEdit(SwitchControl::make()->saveImmediately(true)->mode('inline')->disabledOn('${id === 1}')),
|
||||
amisMake()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
|
||||
Operation::make()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditButton(true)->visibleOn('${id != 1}'),
|
||||
$this->rowEditTypeButton('drawer', 'md')->visibleOn('${id != 1}'),
|
||||
//单独修改密码
|
||||
$this->editPassword()->visibleOn('${id != 1}'),
|
||||
$this->rowDeleteButton()->visibleOn('${id != 1}'),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||
use App\Services\Admin\ArticleCategoryService;
|
||||
use App\Admin\Components;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
class ArticleCategoryController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
|
||||
protected string $serviceName = ArticleCategoryService::class;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()
|
||||
//去掉分页-start
|
||||
->loadDataOnce(true)
|
||||
->footerToolbar([])
|
||||
//去掉分页-end
|
||||
->headerToolbar([
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
amis('reload')->align('right'),
|
||||
amis('filter-toggler')->align('right'),
|
||||
])
|
||||
->filter($this->baseFilter()->body([
|
||||
|
||||
]
|
||||
))
|
||||
->columns([
|
||||
amis()->TableColumn()->make()->name('id')->label('ID')->sortable(true),
|
||||
amis()->TableColumn('name', __('admin.article_categories.name')),
|
||||
amis()->TableColumn('key', __('admin.article_categories.key'))->copyable(true),
|
||||
// amis()->TableColumn('cover', __('admin.article_categories.cover'))->type('image')->height('50px')->width('150px')->enlargeAble(true),
|
||||
amis()->TableColumn('is_enable', __('admin.article_categories.is_enable'))->type('switch'),
|
||||
amis()->TableColumn('is_show', __('admin.article_categories.is_show'))->type('switch'),
|
||||
amis()->TableColumn('is_recommend', __('admin.article_categories.is_recommend'))->type('switch'),
|
||||
amis()->TableColumn('sort', __('admin.article_categories.sort')),
|
||||
amis()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditTypeButton('drawer', 'md'),
|
||||
$this->rowDeleteButton(),
|
||||
]),
|
||||
]);
|
||||
|
||||
return $this->baseList($crud);
|
||||
}
|
||||
|
||||
public function form(): Form
|
||||
{
|
||||
return $this->baseForm()->body([
|
||||
Components::make()->parentControl(admin_url('api/article_categories/tree-list')),
|
||||
amis()->TextControl('name', __('admin.article_categories.name'))->required(true),
|
||||
// amis()->TextControl('key', __('admin.article_categories.key'))->required(true),
|
||||
Components::make()->cropImageControl('cover', __('admin.article_categories.cover')),
|
||||
Components::make()->sortControl('sort', __('admin.article_categories.sort')),
|
||||
amis()->SwitchControl('is_enable', __('admin.article_categories.is_enable'))->value(false),
|
||||
amis()->SwitchControl('is_show', __('admin.article_categories.is_show'))->value(false),
|
||||
amis()->SwitchControl('is_recommend', __('admin.article_categories.is_recommend'))->value(false),
|
||||
]);
|
||||
}
|
||||
|
||||
public function getTreeList(Request $request){
|
||||
return $this->service->getTree();
|
||||
}
|
||||
}
|
||||
|
|
@ -10,16 +10,18 @@ use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|||
use App\Services\Admin\ArticleService;
|
||||
use App\Admin\Components;
|
||||
use App\Models\Keyword;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
class ArticleController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
protected string $serviceName = ArticleService::class;
|
||||
|
||||
public function list():Page
|
||||
{
|
||||
$crud = $this->baseCRUD()->tableLayout('fixed')
|
||||
->headerToolbar([
|
||||
$this->createButton(),
|
||||
$this->createTypeButton('drawer', 'xl'),
|
||||
...$this->baseHeaderToolBar(),
|
||||
])
|
||||
->filter($this->baseFilter()->body([
|
||||
|
|
@ -59,9 +61,7 @@ class ArticleController extends AdminController
|
|||
->columns([
|
||||
amis()->TableColumn('id', __('admin.id'))->sortable(true),
|
||||
amis()->TableColumn('title', __('admin.articles.title'))->width('300px'),
|
||||
amis()->TableColumn('category', __('admin.articles.category'))->type('mapping')
|
||||
->map(Keyword::allChildrenOfKey('article_category')->pluck('name', 'key')->toArray())
|
||||
->itemSchema(amis()->Tag()->label('${item}')->color(Admin::setting()->get('system_theme_setting')['theme_color'] ?? '#1677ff')),
|
||||
amis()->TableColumn('cate.name', __('admin.articles.category')),
|
||||
amis()->TableColumn('tags', __('admin.articles.tags'))->type('mapping')->map(Keyword::tagsMap('article_tag')),
|
||||
amis()->TableColumn('cover', __('admin.articles.cover'))->type('image')->height('50px')->width('50px')->enlargeAble(true),
|
||||
amis()->TableColumn('published_at', __('admin.articles.published_at'))->remark(__('admin.articles.published_at_remark')),
|
||||
|
|
@ -69,7 +69,7 @@ class ArticleController extends AdminController
|
|||
amis()->TableColumn('is_recommend', __('admin.articles.is_recommend'))->type('switch'),
|
||||
amis()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
|
||||
amis()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditButton(),
|
||||
$this->rowEditTypeButton('drawer', 'xl'),
|
||||
$this->rowDeleteButton(),
|
||||
])
|
||||
]);
|
||||
|
|
@ -83,14 +83,14 @@ class ArticleController extends AdminController
|
|||
amis()->Grid()->columns([
|
||||
amis()->Wrapper()->body([
|
||||
amis()->TextControl('title', __('admin.articles.title'))->required(true),
|
||||
Components::make()->parentControl(admin_url('api/keywords/tree-list?parent_name=article_category&has_owner=0'), 'category', __('admin.articles.category'), 'name', 'key'),
|
||||
Components::make()->parentControl(admin_url('api/article_categories/tree-list'), 'category', __('admin.articles.category')),
|
||||
Components::make()->keywordsTagControl('t_ids', __('admin.articles.tags'), 'article_tag'),
|
||||
Components::make()->cropImageControl('cover', __('admin.articles.cover')),
|
||||
Components::make()->sortControl('sort', __('admin.articles.sort')),
|
||||
amis()->DateTimeControl('published_at', __('admin.articles.published_at'))->format('YYYY-MM-DD HH:mm:ss')->description(__('admin.articles.published_at_remark')),
|
||||
amis()->SwitchControl('is_enable', __('admin.articles.is_enable'))->value(false),
|
||||
amis()->SwitchControl('is_recommend', __('admin.articles.is_recommend'))->value(false),
|
||||
Components::make()->fileControl('appendixes', __('admin.articles.appendixes'), '.xsl,.xlsx,.txt,.doc,.docx,.pdf,.pptx'),
|
||||
Components::make()->fileControl('appendixes', __('admin.articles.appendixes'), '.xsl,.xlsx,.txt,.doc,.docx,.pdf,.pptx', true),
|
||||
])->md(4),
|
||||
amis()->Wrapper()->body([
|
||||
Components::make()->fuEditorControl('content', __('admin.articles.content')),
|
||||
|
|
|
|||
|
|
@ -11,20 +11,18 @@ use App\Services\Admin\BuildingService;
|
|||
use App\Models\Keyword;
|
||||
use App\Admin\Components;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
class BuildingController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
protected string $serviceName = BuildingService::class;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()
|
||||
//去掉分页-start
|
||||
->loadDataOnce(true)
|
||||
->footerToolbar([])
|
||||
//去掉分页-end
|
||||
->headerToolbar([
|
||||
$this->createButton(true),
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
amis('reload')->align('right'),
|
||||
amis('filter-toggler')->align('right'),
|
||||
])
|
||||
|
|
@ -44,7 +42,7 @@ class BuildingController extends AdminController
|
|||
TableColumn::make()->name('sort')->label('排序'),
|
||||
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditButton(true),
|
||||
$this->rowEditTypeButton('drawer', 'md'),
|
||||
$this->rowDeleteButton(),
|
||||
]),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
<?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\Services\Admin\FriendLinkService;
|
||||
use App\Admin\Components;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
class FriendLinkController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
protected string $serviceName = FriendLinkService::class;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()
|
||||
->headerToolbar([
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
amis('reload')->align('right'),
|
||||
amis('filter-toggler')->align('right'),
|
||||
])
|
||||
->filter($this->baseFilter()->body([
|
||||
|
||||
]
|
||||
))
|
||||
->columns([
|
||||
amis()->TableColumn()->make()->name('id')->label('ID')->width('50px')->sortable(true),
|
||||
amis()->TableColumn('name', __('admin.friend_links.name')),
|
||||
amis()->TableColumn('uri', __('admin.friend_links.uri')),
|
||||
amis()->TableColumn('cover', __('admin.friend_links.cover'))->type('image')->height('50px')->width('150px')->enlargeAble(true),
|
||||
amis()->TableColumn('sort', __('admin.friend_links.sort')),
|
||||
amis()->TableColumn('is_enable', __('admin.friend_links.is_enable'))->type('switch'),
|
||||
amis()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditTypeButton('drawer', 'md'),
|
||||
$this->rowDeleteButton(),
|
||||
]),
|
||||
]);
|
||||
|
||||
return $this->baseList($crud);
|
||||
}
|
||||
|
||||
public function form(): Form
|
||||
{
|
||||
return $this->baseForm()->body([
|
||||
amis()->TextControl('name', __('admin.friend_links.name'))->required(true),
|
||||
amis()->TextControl('uri', __('admin.friend_links.uri')),
|
||||
Components::make()->cropImageControl('cover', __('admin.friend_links.cover')),
|
||||
amis()->SwitchControl('is_enable', __('admin.friend_links.is_enable'))->value(true),
|
||||
Components::make()->sortControl('sort', __('admin.friend_links.sort')),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,16 +10,18 @@ use App\Services\Admin\InstitutionService;
|
|||
use App\Admin\Components;
|
||||
use App\Models\Keyword;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
class InstitutionController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
protected string $serviceName = InstitutionService::class;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()
|
||||
->headerToolbar([
|
||||
$this->createButton(true, 'md'),
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
amis('reload')->align('right'),
|
||||
amis('filter-toggler')->align('right'),
|
||||
])
|
||||
|
|
@ -38,7 +40,7 @@ class InstitutionController extends AdminController
|
|||
amis()->TableColumn('sort', __('admin.institutions.sort')),
|
||||
// amis()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditButton(true, 'md'),
|
||||
$this->rowEditTypeButton('drawer', 'md'),
|
||||
$this->rowDeleteButton(),
|
||||
]),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -11,9 +11,11 @@ use App\Services\Admin\KeywordService;
|
|||
use App\Models\Keyword;
|
||||
use App\Admin\Components;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Traits\CustomActionTrait;
|
||||
|
||||
class KeywordController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
protected string $serviceName = KeywordService::class;
|
||||
|
||||
protected array $menuData = ['financial_cate', 'file_cate', 'department', 'area_cate', 'organized_body', 'housing_estate', 'domicile', 'nation', 'political_face','educational_level','oral_disputes','sanitary_inspection', 'book_cate', 'business_area','money_cate', 'welfare_cate', 'job_cate'];
|
||||
|
|
@ -40,12 +42,12 @@ class KeywordController extends AdminController
|
|||
$columnsArr [] = TableColumn::make()->name('value')->label('值');
|
||||
}
|
||||
$crud = $this->baseCRUD()
|
||||
//去掉分页-start
|
||||
->loadDataOnce(true)
|
||||
// //去掉分页-start
|
||||
->loadDataOnce(false)
|
||||
->footerToolbar([])
|
||||
//去掉分页-end
|
||||
// //去掉分页-end
|
||||
->headerToolbar([
|
||||
$this->createButton(true),
|
||||
$this->createTypeButton('drawer', 'md'),
|
||||
amis('reload')->align('right'),
|
||||
amis('filter-toggler')->align('right'),
|
||||
])
|
||||
|
|
@ -63,7 +65,7 @@ class KeywordController extends AdminController
|
|||
TableColumn::make()->name('sort')->label('排序'),
|
||||
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowEditButton(true),
|
||||
$this->rowEditTypeButton('drawer', 'md'),
|
||||
$this->rowDeleteButton(),
|
||||
]),
|
||||
]));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\PersonChange;
|
||||
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;
|
||||
use App\Models\Keyword;
|
||||
|
||||
/**
|
||||
* 人口变动
|
||||
*
|
||||
*/
|
||||
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([
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->YearControl('year', __('admin.year'))->valueFormat('YYYY')->columnRatio(3),
|
||||
amis()->SelectControl('person.organized_body_id', __('admin.persons.organized_body'))->options(Keyword::where('parent_key', 'organized_body')->pluck('name', 'id')->toArray())->columnRatio(3)->clearable(true),
|
||||
// amis()->TextControl('person.name', __('admin.persons.name'))->placeholder(__('admin.persons.name'))->columnRatio(3),
|
||||
amis()->SelectControl('type', __('admin.person_changes.type'))->options(PersonChange::typeMap())->columnRatio(3)->clearable(true),
|
||||
]),
|
||||
]))
|
||||
->columns([
|
||||
amis()->TableColumn('person.organized_body.name', __('admin.persons.organized_body'))->width('100px'),
|
||||
amis()->TableColumn('changed_at', __('admin.person_changes.changed_at'))->width('100px'),
|
||||
amis()->TableColumn('type', __('admin.person_changes.type'))->type('mapping')->map(PersonChange::typeMap()),
|
||||
amis()->TableColumn('person.name', __('admin.persons.name'))->width('100px')->copyable()->searchable(),
|
||||
amis()->TableColumn('extends_mark', __('admin.person_changes.extends_mark')),
|
||||
amis()->TableColumn('phone', __('admin.person_changes.phone')),
|
||||
amis()->TableColumn('remark', __('admin.person_changes.remark')),
|
||||
amis()->TableColumn('created_at', __('admin.person_changes.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([
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,754 @@
|
|||
<?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\Services\Admin\PersonService;
|
||||
use App\Traits\CustomActionTrait;
|
||||
use App\Models\Keyword;
|
||||
use App\Models\PersonChange;
|
||||
use App\Admin\Components;
|
||||
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;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* 人口管理
|
||||
*
|
||||
* @property PersonService $service
|
||||
*/
|
||||
class PersonController extends AdminController
|
||||
{
|
||||
use CustomActionTrait;
|
||||
|
||||
protected string $serviceName = PersonService::class;
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
$crud = $this->baseCRUD()->tableLayout('fixed')->name('curd_list')
|
||||
->headerToolbar([
|
||||
$this->createTypeButton('drawer', '', '50%'),
|
||||
amis()->DialogAction()->icon('fas fa-people-arrows')->iconClassName('text-white text-sm')->level('danger')->label('分户')->dialog(
|
||||
amis()->Dialog()->title(__('admin.persons.split_master'))->body($this->splitMasterForm())->size('lg')
|
||||
),
|
||||
amis()->DialogAction()->icon('fas fa-users')->iconClassName('text-white text-sm')->level('success')->label('合户')->dialog(
|
||||
amis()->Dialog()->title(__('admin.persons.merge_master'))->body($this->mergeMasterForm())->size('lg')
|
||||
),
|
||||
amis('reload')->align('right'),
|
||||
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()->SelectControl('is_master', __('admin.persons.is_master'))->options([
|
||||
'1'=>'仅户主','0'=>'非户主'
|
||||
])->columnRatio(3)->clearable(true),
|
||||
]),
|
||||
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),
|
||||
]),
|
||||
]))
|
||||
->itemBadge([//行角标
|
||||
'text' => __('admin.persons.master'),
|
||||
'mode' => 'ribbon',
|
||||
'position' => 'top-left',
|
||||
'badgeLevel' => 'danger',
|
||||
'visibleOn' => '${is_master > 0}',
|
||||
'size' => 15
|
||||
])
|
||||
->columns([
|
||||
amis()->TableColumn('domicile_code', __('admin.persons.domicile_code'))->width('100px'),
|
||||
amis()->TableColumn('name', __('admin.persons.name'))->width('100px')->copyable()->searchable(),
|
||||
amis()->TableColumn('master_connect', __('admin.persons.master_connect'))->width('60px'),
|
||||
amis()->TableColumn('master.name', __('admin.persons.master_name'))->width('100px')->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'))->width('100px'),
|
||||
// amis()->TableColumn('age', __('admin.persons.age')),
|
||||
amis()->TableColumn('now_address', __('admin.persons.now_address'))->copyable(),
|
||||
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowShowTypeButton('drawer', 'xl'),
|
||||
$this->rowEditTypeButton('drawer', '', '50%'),
|
||||
$this->rowDeleteButton(),
|
||||
])
|
||||
]);
|
||||
|
||||
return $this->baseList($crud);
|
||||
}
|
||||
|
||||
public function form(): Form
|
||||
{
|
||||
return $this->baseForm()->body([
|
||||
amis()->Grid()->columns([
|
||||
amis()->Wrapper()->body([
|
||||
amis()->FieldSetControl()->title('基本信息')->body([
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
Components::make()->cropImageControl('avatar', __('admin.persons.avatar')),
|
||||
amis()->RadiosControl('type', __('admin.persons.type'))->options([
|
||||
'11'=>'出生人口', '12'=>'迁入人口'
|
||||
])->value('11')->required(),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('name', __('admin.persons.name'))->required(),
|
||||
amis()->TextControl('used_name', __('admin.persons.used_name')),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('idcard', __('admin.persons.idcard'))->required()->id('person_idcard')->onEvent([
|
||||
'blur'=>[//自定义JS联动字段填写
|
||||
'actions'=>[
|
||||
[
|
||||
"componentId" => "person_idcard",
|
||||
"actionType"=> "disabled"
|
||||
],
|
||||
[
|
||||
'actionType'=>'custom',
|
||||
'script' => 'var strBirthday="";
|
||||
var idcard=event.data.value;
|
||||
if((/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(idcard))){
|
||||
if(String(idcard).length == 18){
|
||||
strBirthday = idcard.substr(6,4)+"/"+idcard.substr(10,2)+"/"+idcard.substr(12,2);
|
||||
}
|
||||
event.setData({...event.data, "birthday":new Date(strBirthday)})
|
||||
}'
|
||||
],
|
||||
[
|
||||
'actionType'=>'setValue',
|
||||
"componentId" => "person_birthday",
|
||||
"args" => [
|
||||
'value'=>'${birthday}'
|
||||
],
|
||||
],
|
||||
[
|
||||
"componentId" => "person_idcard",
|
||||
"actionType"=> "enabled"
|
||||
],
|
||||
]
|
||||
]
|
||||
]),
|
||||
amis()->RadiosControl('gender', __('admin.persons.gender'))->options([
|
||||
'1'=>'男', '2'=>'女'
|
||||
])->required(),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->DateControl('birthday', __('admin.persons.birthday'))->valueFormat('YYYY-MM-DD')->required()->id('person_birthday')->columnRatio(6),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amisMake()->InputCityControl('origin_city_code', __('admin.persons.origin_city_code'))->placeholder('请选择城市地区')->itemClassName('w-52')->searchable('true')->required(true)->columnRatio(12),
|
||||
amis()->TextControl('origin_complete_address')->placeholder('若无法选择籍贯,可以手动填写籍贯'),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amisMake()->InputCityControl('card_city_code', __('admin.persons.card_city_code'))->placeholder('请选择城市地区')->itemClassName('w-52')->searchable('true')->required(true)->columnRatio(12),
|
||||
amis()->TextControl('card_address')->placeholder('详细地址'),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
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_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),
|
||||
amis()->TextControl('house_number', __('admin.persons.house_number')),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('real_address', __('admin.persons.real_address'))->placeholder('若无法选择小区,可以手动填写居住地址'),
|
||||
]),
|
||||
]),
|
||||
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_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_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'),
|
||||
amis()->TextControl('master_connect', __('admin.persons.master_connect'))->required(),
|
||||
]),
|
||||
]),
|
||||
amis()->FieldSetControl()->title('其他信息')->className('mt-10')->body([
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->SelectControl('military_service_status', __('admin.persons.military_service_status'))->options(Keyword::where('parent_key', 'military_service_status')->pluck('name', 'id')->toArray())->clearable(true),
|
||||
amis()->SwitchControl('is_voter', __('admin.persons.is_voter'))->value(true),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('job', __('admin.persons.job')),
|
||||
amis()->TextControl('health', __('admin.persons.health')),
|
||||
]),
|
||||
amis()->GroupControl()->mode('horizontal')->body([
|
||||
amis()->TextControl('phone', __('admin.persons.phone')),
|
||||
amis()->TextControl('remark', __('admin.persons.remark')),
|
||||
]),
|
||||
]),
|
||||
])->md(12),
|
||||
// amis()->Wrapper()->body([
|
||||
|
||||
// ])->md(6)
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function detail()
|
||||
{
|
||||
$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( __('admin.persons.avatar'))->height('80px')->width('80px')->thumbMode('cover'),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('name', __('admin.persons.name'))->copyable(['content'=>'${name}']),
|
||||
amis()->StaticExactControl('used_name', __('admin.persons.used_name')),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('idcard', __('admin.persons.idcard'))->copyable(['content'=>'${idcard}']),
|
||||
amis()->RadiosControl('gender', __('admin.persons.gender'))->options([
|
||||
'1'=>'男', '2'=>'女'
|
||||
]),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('birthday', __('admin.persons.birthday')),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('age', __('admin.persons.age')),
|
||||
amis()->StaticExactControl('origin_complete_address', __('admin.persons.origin_complete_address')),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('card_complete_address', __('admin.persons.card_complete_address')),
|
||||
amis()->StaticExactControl('now_address', __('admin.persons.now_address')),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('nation', __('admin.persons.nation'))->type('static-mapping')->map(
|
||||
Keyword::where('parent_key', 'nation')->pluck('name', 'id')->toArray()),
|
||||
amis()->StaticExactControl('political_face', __('admin.persons.political_face'))->type('static-mapping')->map(
|
||||
Keyword::where('parent_key', 'political_face')->pluck('name', 'id')->toArray()),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('educational_level', __('admin.persons.educational_level'))->type('static-mapping')->map(
|
||||
Keyword::where('parent_key', 'educational_level')->pluck('name', 'id')->toArray()),
|
||||
amis()->StaticExactControl('marry_state', __('admin.persons.marry_state'))->type('static-mapping')->map(
|
||||
Keyword::where('parent_key', 'marry_state')->pluck('name', 'id')->toArray()),
|
||||
]),
|
||||
]),
|
||||
amis()->FieldSetControl()->title('其他信息')->className('mt-10')->body([
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('military_service_status', __('admin.persons.military_service_status'))->type('static-mapping')->map(
|
||||
Keyword::where('parent_key', 'military_service_status')->pluck('name', 'id')->toArray()),
|
||||
amis()->StaticExactControl('is_voter', __('admin.persons.is_voter'))->type('static-mapping')->map(
|
||||
['0'=>'否','1'=>'是','*'=>'未知']),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('job', __('admin.persons.job')),
|
||||
amis()->StaticExactControl('health', __('admin.persons.health')),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('phone', __('admin.persons.phone')),
|
||||
amis()->StaticExactControl('remark', __('admin.persons.remark')),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
|
||||
return amisMake()->Grid()->columns([
|
||||
amis()->Column()->body($form)->md(6),
|
||||
amis()->Column()->body([
|
||||
amisMake()->form()->title('')->panelClassName('border-0')->mode('horizontal')
|
||||
->static(true)->actions([])
|
||||
->body([
|
||||
amis()->FieldSetControl()->title('户籍信息')->body([
|
||||
amisMake()->CRUDTable()->affixHeader(false)
|
||||
->title('')
|
||||
->itemBadge([//行角标
|
||||
'text' => __('admin.persons.master'),
|
||||
'mode' => 'ribbon',
|
||||
'position' => 'top-left',
|
||||
'badgeLevel' => 'danger',
|
||||
'visibleOn' => '${is_master > 0}',
|
||||
'size' => 15
|
||||
])
|
||||
->api(admin_url('persons?_action=getData&master[name]=${master.name}'))
|
||||
->columns([
|
||||
amis()->TableColumn('name', __('admin.persons.name'))->copyable(),
|
||||
amis()->TableColumn('master_connect', __('admin.persons.master_connect')),
|
||||
amis()->TableColumn('idcard', __('admin.persons.idcard'))->copyable(),
|
||||
amis()->TableColumn('gender', __('admin.persons.gender'))->type('mapping')->map([
|
||||
"1"=>"<span class='label label-info'>男</span>",
|
||||
"2"=>"<span class='label label-success'>女</span>",
|
||||
"*"=> '其他:${gender}'
|
||||
]),
|
||||
])
|
||||
]),
|
||||
amis()->FieldSetControl()->title('户籍变动')->className('mt-10')->body([
|
||||
amisMake()->CRUDTable()->affixHeader(false)->columnsTogglable(false)
|
||||
->api(admin_url('person_changes?_action=getData&person[id]=${id}'))
|
||||
->perPage(5)->loadDataOnce()
|
||||
->columns([
|
||||
amis()->TableColumn('changed_at', __('admin.person_changes.changed_at'))->width('100px'),
|
||||
amis()->TableColumn('type', __('admin.person_changes.type'))->type('mapping')->map(PersonChange::typeMap()),
|
||||
amis()->TableColumn('extends_mark', __('admin.person_changes.extends_mark')),
|
||||
amis()->TableColumn('phone', __('admin.person_changes.phone')),
|
||||
amis()->TableColumn('remark', __('admin.person_changes.remark')),
|
||||
amis()->TableColumn('created_at', __('admin.person_changes.created_at'))->type('datetime')->sortable(true),
|
||||
])
|
||||
])
|
||||
])
|
||||
])->md(6),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function detailActions()
|
||||
{
|
||||
return [
|
||||
//变更户主
|
||||
amis()->DialogAction()->level('warning')->label('变更户主')->dialog(
|
||||
amis()->Dialog()->title('变更户主')->body($this->editMasterForm())->size('lg')->actions([
|
||||
amis()->Button()->label('取消')->actionType('cancel'),
|
||||
amis()->Button()->label('确认')->actionType('submit')->primary()->close('detail_info'),
|
||||
])
|
||||
)->visibleOn('${state} < 2'),
|
||||
//迁移
|
||||
amis()->DialogAction()->level('info')->label('迁移')->dialog(
|
||||
amis()->Dialog()->title('迁移')->body($this->personMigrateForm())->size('lg')->actions([
|
||||
amis()->Button()->label('取消')->actionType('cancel'),
|
||||
amis()->Button()->label('确认')->actionType('submit')->primary()->close('detail_info'),
|
||||
])
|
||||
)->visibleOn('${state} < 2'),
|
||||
//迁出
|
||||
amis()->DialogAction()->level('success')->label('迁出')->dialog(
|
||||
amis()->Dialog()->title('迁出')->body($this->personOutForm())->size('lg')->actions([
|
||||
amis()->Button()->label('取消')->actionType('cancel'),
|
||||
amis()->Button()->label('确认')->actionType('submit')->primary()->close('detail_info'),
|
||||
])
|
||||
)->visibleOn('${state} < 2'),
|
||||
//死亡
|
||||
amis()->DialogAction()->level('danger')->label('死亡')->dialog(
|
||||
amis()->Dialog()->title('死亡')->body($this->personDieForm())->size('lg')->actions([
|
||||
amis()->Button()->label('取消')->actionType('cancel'),
|
||||
amis()->Button()->label('确认')->actionType('submit')->primary()->close('detail_info'),
|
||||
])
|
||||
)->visibleOn('${state} < 2'),
|
||||
//返回
|
||||
amis()->Button()->actionType('cancel')->label(__('admin.back'))->primary()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更户主
|
||||
*/
|
||||
public function editMasterForm()
|
||||
{
|
||||
return amis()->form()->title('')->reload('curd_list')
|
||||
->api(admin_url('edit_master'))
|
||||
->body([
|
||||
amis()->Service()
|
||||
->api(admin_url('persons?_action=getData&state=1&master[id]=${master_id}&perPage=10'))
|
||||
->onEvent([
|
||||
'fetchInited' => [
|
||||
'actions' => [
|
||||
[
|
||||
'actionType'=>'setValue',
|
||||
"componentId" => "new_master_arr",
|
||||
"args" => [
|
||||
'value'=>'${event.data.items}'
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
])
|
||||
->body(
|
||||
amis()->TableControl('new_master_arr', '户籍情况')->columnsTogglable(false)->id('new_master_arr')->columns([
|
||||
amis()->TableColumn('name', __('admin.persons.name'))->width('100px'),
|
||||
amis()->TableColumn('idcard', __('admin.persons.idcard')),
|
||||
amis()->TableColumn('master_connect', __('admin.persons.master_connect'))->width('60px'),
|
||||
amis()->RadioControl('is_new_master', '新户主')->disabledOn('is_master'),
|
||||
amis()->TextControl('new_master_connect', '新关系'),
|
||||
])->required()
|
||||
),
|
||||
amis()->Divider(),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->DateControl('editd_at', '变更日期')->valueFormat('YYYY-MM-DD')->required(),
|
||||
amis()->TextControl('edit_reason', '变更原因')->required()
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->TextControl('edit_phone', '联系方式')->required(),
|
||||
amis()->TextControl('edit_remark', '备注')
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function doEditMaster(Request $request)
|
||||
{
|
||||
$res = $this->service->EditMaster($request->input('new_master_arr'), $request->input());
|
||||
|
||||
return $this->autoResponse($res, '变更户主');
|
||||
}
|
||||
|
||||
/**
|
||||
* 迁移-迁移到其他户下面去
|
||||
*/
|
||||
public function personMigrateForm()
|
||||
{
|
||||
return amis()->form()->title('')->reload('curd_list')
|
||||
->api(admin_url('migrate_master'))
|
||||
->body([
|
||||
amis()->HiddenControl('id'),
|
||||
amis()->GroupControl()->body([
|
||||
$this->masterPicker('new_master_id', '新户主', '输入 户主姓名 进行筛选')->required(),
|
||||
amis()->TextControl('new_master_connect', '新关系')->required(),
|
||||
]),
|
||||
amis()->Divider()->visibleOn('${is_master}'),
|
||||
amis()->Service()
|
||||
->api(admin_url('persons?_action=getData&state=1&master[id]=${master_id}&perPage=10'))
|
||||
->onEvent([
|
||||
'fetchInited' => [
|
||||
'actions' => [
|
||||
[
|
||||
'actionType'=>'setValue',
|
||||
"componentId" => "old_master_arr",
|
||||
"args" => [
|
||||
'value'=>'${event.data.items}'
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
])
|
||||
->body(
|
||||
amis()->TableControl('old_master_arr', '原户籍情况')->columnsTogglable(false)->id('old_master_arr')->columns([
|
||||
amis()->TableColumn('name', __('admin.persons.name'))->width('100px'),
|
||||
amis()->TableColumn('idcard', __('admin.persons.idcard')),
|
||||
amis()->TableColumn('master_connect', __('admin.persons.master_connect'))->width('60px'),
|
||||
amis()->RadioControl('is_new_master', '新户主')->disabledOn('is_master'),
|
||||
amis()->TextControl('new_master_connect', '新关系')->disabledOn('is_master'),
|
||||
])->required()
|
||||
)->visibleOn('${is_master}'),
|
||||
amis()->Divider(),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->DateControl('migrated_at', '迁移日期')->valueFormat('YYYY-MM-DD')->required(),
|
||||
amis()->TextControl('migrate_reason', '迁移原因')->required()
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->TextControl('migrate_phone', '联系方式')->required(),
|
||||
amis()->TextControl('migrate_remark', '备注')
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function doPersonMigrate(Request $request)
|
||||
{
|
||||
$res = $this->service->personMigrate($request->input('id', 0), $request->input('new_master_id', 0), $request->input('new_master_connect', ''),
|
||||
$request->input('old_master_arr', []), $request->input());
|
||||
|
||||
return $this->autoResponse($res, '迁移');
|
||||
}
|
||||
|
||||
/**
|
||||
* 迁出-迁出本村
|
||||
*
|
||||
*/
|
||||
public function personOutForm(){
|
||||
return amis()->form()->title('')->reload('curd_list')
|
||||
->api(admin_url('person_out'))
|
||||
->body([
|
||||
amis()->HiddenControl('id'),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('name', __('admin.persons.name'))->copyable(['content'=>'${name}']),
|
||||
amis()->RadiosControl('gender', __('admin.persons.gender'))->options([
|
||||
'1'=>'男', '2'=>'女'
|
||||
])->static(),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('idcard', __('admin.persons.idcard'))->copyable(['content'=>'${idcard}']),
|
||||
amis()->StaticExactControl('birthday', __('admin.persons.birthday')),
|
||||
]),
|
||||
amis()->Divider()->visibleOn('${is_master}'),
|
||||
amis()->Service()
|
||||
->api(admin_url('persons?_action=getData&state=1&master[id]=${master_id}&perPage=10'))
|
||||
->onEvent([
|
||||
'fetchInited' => [
|
||||
'actions' => [
|
||||
[
|
||||
'actionType'=>'setValue',
|
||||
"componentId" => "old_master_arr",
|
||||
"args" => [
|
||||
'value'=>'${event.data.items}'
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
])
|
||||
->body(
|
||||
amis()->TableControl('old_master_arr', '户籍情况')->columnsTogglable(false)->id('old_master_arr')->columns([
|
||||
amis()->TableColumn('name', __('admin.persons.name'))->width('100px'),
|
||||
amis()->TableColumn('idcard', __('admin.persons.idcard')),
|
||||
amis()->TableColumn('master_connect', __('admin.persons.master_connect'))->width('60px'),
|
||||
amis()->RadioControl('is_new_master', '新户主')->disabledOn('is_master'),
|
||||
amis()->TextControl('new_master_connect', '新关系')->disabledOn('is_master'),
|
||||
])->required()
|
||||
)->visibleOn('${is_master}'),
|
||||
amis()->Divider(),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->DateControl('out_at', '迁出日期')->valueFormat('YYYY-MM-DD')->required(),
|
||||
amis()->TextControl('out_reason', '迁出原因')->required()
|
||||
]),
|
||||
amis()->TextControl('out_to_address', '迁出至')->required(),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->TextControl('out_phone', '联系方式')->required(),
|
||||
amis()->TextControl('out_remark', '备注')
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function doPersonOut(Request $request)
|
||||
{
|
||||
$res = $this->service->personOut($request->input('id'), $request->input('old_master_arr', []), $request->input());
|
||||
|
||||
return $this->autoResponse($res, '迁出');
|
||||
}
|
||||
|
||||
/**
|
||||
* 死亡
|
||||
*/
|
||||
public function personDieForm(){
|
||||
return amis()->form()->title('')->reload('curd_list')
|
||||
->api(admin_url('person_die'))
|
||||
->body([
|
||||
amis()->HiddenControl('id'),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('name', __('admin.persons.name'))->copyable(['content'=>'${name}']),
|
||||
amis()->RadiosControl('gender', __('admin.persons.gender'))->options([
|
||||
'1'=>'男', '2'=>'女'
|
||||
])->static(),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('idcard', __('admin.persons.idcard'))->copyable(['content'=>'${idcard}']),
|
||||
amis()->StaticExactControl('birthday', __('admin.persons.birthday')),
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->StaticExactControl('age', __('admin.persons.age'))->copyable(['content'=>'${idcard}']),
|
||||
amis()->StaticExactControl('master.name', __('admin.persons.master')),
|
||||
]),
|
||||
amis()->Divider()->visibleOn('${is_master}'),
|
||||
amis()->Service()
|
||||
->api(admin_url('persons?_action=getData&state=1&master[id]=${master_id}&perPage=10'))
|
||||
->onEvent([
|
||||
'fetchInited' => [
|
||||
'actions' => [
|
||||
[
|
||||
'actionType'=>'setValue',
|
||||
"componentId" => "old_master_arr",
|
||||
"args" => [
|
||||
'value'=>'${event.data.items}'
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
])
|
||||
->body(
|
||||
amis()->TableControl('old_master_arr', '户籍情况')->columnsTogglable(false)->id('old_master_arr')->columns([
|
||||
amis()->TableColumn('name', __('admin.persons.name'))->width('100px'),
|
||||
amis()->TableColumn('idcard', __('admin.persons.idcard')),
|
||||
amis()->TableColumn('master_connect', __('admin.persons.master_connect'))->width('60px'),
|
||||
amis()->RadioControl('is_new_master', '新户主')->disabledOn('is_master'),
|
||||
amis()->TextControl('new_master_connect', '新关系')->disabledOn('is_master'),
|
||||
])->required()
|
||||
)->visibleOn('${is_master}'),
|
||||
amis()->Divider(),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->DateControl('die_at', '死亡日期')->valueFormat('YYYY-MM-DD')->required(),
|
||||
amis()->TextControl('die_reason', '死亡原因')->required()
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->TextControl('die_phone', '联系方式')->required(),
|
||||
amis()->TextControl('die_remark', '备注')
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function doPersonDie(Request $request)
|
||||
{
|
||||
$res = $this->service->personDie($request->input('id'), $request->input('old_master_arr', []), $request->input());
|
||||
|
||||
return $this->autoResponse($res, '记录');
|
||||
}
|
||||
|
||||
/**
|
||||
* 合户
|
||||
*/
|
||||
public function mergeMasterForm()
|
||||
{
|
||||
return amis()->form()->title('')
|
||||
->api(admin_url('merge_master'))
|
||||
->body([
|
||||
amis()->GroupControl()->body([
|
||||
$this->masterPicker('master_id', '', '输入 户主姓名 进行筛选')->required(),
|
||||
$this->masterPicker('to_merge_master_id', '待合并户', '输入 户主姓名 进行筛选')->required(),
|
||||
]),
|
||||
amis()->Divider(),
|
||||
amis()->Service()
|
||||
->api(admin_url('persons?_action=getData&state=1&master[id]=${to_merge_master_id}&perPage=10'))
|
||||
->onEvent([
|
||||
'fetchInited' => [
|
||||
'actions' => [
|
||||
[
|
||||
'actionType'=>'setValue',
|
||||
"componentId" => "new_master_arr",
|
||||
"args" => [
|
||||
'value'=>'${event.data.items}'
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
])
|
||||
->body(
|
||||
amis()->TableControl('new_master_arr', '合户情况')->columnsTogglable(false)->id('new_master_arr')->columns([
|
||||
amis()->TableColumn('name', __('admin.persons.name'))->width('100px'),
|
||||
amis()->TableColumn('idcard', __('admin.persons.idcard')),
|
||||
amis()->TableColumn('master_connect', __('admin.persons.master_connect'))->width('60px'),
|
||||
amis()->TextControl('new_master_connect', '新关系'),
|
||||
])->required()
|
||||
),
|
||||
amis()->Divider(),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->DateControl('merged_at', '合户日期')->valueFormat('YYYY-MM-DD')->required(),
|
||||
amis()->TextControl('merge_reason', '合户原因')->required()
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->TextControl('phone', '联系方式')->required(),
|
||||
amis()->TextControl('remark', '备注')
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function doMergeMaster(Request $request)
|
||||
{
|
||||
$res = $this->service->mergeMaster($request->input('master_id'),$request->input('to_merge_master_id'), $request->input('new_master_arr'), $request->input());
|
||||
|
||||
return $this->autoResponse($res, '合户');
|
||||
}
|
||||
|
||||
/**
|
||||
* 分户
|
||||
*/
|
||||
public function splitMasterForm()
|
||||
{
|
||||
return amis()->form()->title('')
|
||||
->api(admin_url('split_master'))
|
||||
->body([
|
||||
amis()->GroupControl()->body([
|
||||
$this->masterPicker('split_master_id', '分户对象', '输入 户主姓名 进行筛选')->required(),
|
||||
]),
|
||||
amis()->Divider(),
|
||||
amis()->Service()
|
||||
->api(admin_url('persons?_action=getData&state=1&master[id]=${split_master_id}&perPage=10&no_master=1'))
|
||||
->onEvent([
|
||||
'fetchInited' => [
|
||||
'actions' => [
|
||||
[
|
||||
'actionType'=>'setValue',
|
||||
"componentId" => "new_master_arr",
|
||||
"args" => [
|
||||
'value'=>'${event.data.items}'
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
])
|
||||
->body(
|
||||
amis()->TableControl('new_master_arr', '分户情况')->columnsTogglable(false)->id('new_master_arr')->columns([
|
||||
amis()->TableColumn('name', __('admin.persons.name'))->width('100px'),
|
||||
amis()->TableColumn('idcard', __('admin.persons.idcard')),
|
||||
amis()->TableColumn('master_connect', __('admin.persons.master_connect'))->width('60px'),
|
||||
amis()->CheckboxControl('is_split', '是否分户')->value(false),
|
||||
amis()->RadioControl('is_new_master', '新户主')->disabledOn('! is_split'),
|
||||
amis()->TextControl('new_master_connect', '新关系')->disabledOn('! is_split'),
|
||||
])->required()
|
||||
),
|
||||
amis()->Divider(),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->DateControl('splited_at', '分户日期')->valueFormat('YYYY-MM-DD')->required(),
|
||||
amis()->TextControl('split_reason', '分户原因')->required()
|
||||
]),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->TextControl('phone', '联系方式')->required(),
|
||||
amis()->TextControl('remark', '备注')
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function doSplitMaster(Request $request)
|
||||
{
|
||||
$res = $this->service->splitMaster($request->input('split_master_id'), $request->input('new_master_arr'), $request->input());
|
||||
|
||||
return $this->autoResponse($res, '分户');
|
||||
}
|
||||
|
||||
private function masterPicker($name = 'master', $label = '', $description = '')
|
||||
{
|
||||
return amis()->PickerControl($name, $label ?:__('admin.persons.master'))
|
||||
->multiple(false)
|
||||
->valueField('id')
|
||||
->labelField('name')
|
||||
->size('lg')
|
||||
->source([
|
||||
'method' => 'get',
|
||||
'url' => admin_url('persons?_action=getData&state=1&is_master=1&perPage=10'),
|
||||
'data' => [
|
||||
'name'=>'${master_name}',
|
||||
'idcard'=>'${master_idcard}',
|
||||
'perPage'=>'${perPage}',
|
||||
'page'=>'${page}',
|
||||
]
|
||||
])
|
||||
->pickerSchema(
|
||||
[
|
||||
'mode' => 'table',
|
||||
'name' => 'monitor_list',
|
||||
'headerToolbar' => amis()->form()
|
||||
->wrapWithPanel(false)
|
||||
->className('text-right')
|
||||
->target('monitor_list')
|
||||
->mode('inline')
|
||||
->body([
|
||||
amis()->TextControl('master_idcard', __('admin.persons.idcard'))->size('md'),
|
||||
amis()->TextControl('master_name', __('admin.persons.name'))->size('md')->addOn(
|
||||
amis('submit')->label(__('admin.search'))->level('primary')
|
||||
),
|
||||
]),
|
||||
'columns' => [
|
||||
amis()->TableColumn('domicile_code', __('admin.persons.domicile_code'))->width('120px')->copyable(),
|
||||
amis()->TableColumn('name', __('admin.persons.name'))->width('150px')->copyable(),
|
||||
amis()->TableColumn('idcard', __('admin.persons.idcard'))->copyable(),
|
||||
amis()->TableColumn('gender', __('admin.persons.gender'))->type('mapping')->map([
|
||||
"1"=>"<span class='label label-info'>男</span>",
|
||||
"2"=>"<span class='label label-success'>女</span>",
|
||||
"*"=> '其他:${gender}'
|
||||
]),
|
||||
],
|
||||
]
|
||||
)->description($description);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
|
||||
// Admin::styles([
|
||||
// '.cxd-Panel-heading { border-width: 0; background: #4080ffc7 !important; }',
|
||||
// // '.cxd-Panel {box-shadow: none; }',
|
||||
// '.cxd-Panel-title { color:white;font-size: 16px; }'
|
||||
// ]);
|
||||
Admin::styles([
|
||||
'.cxd-Crud {border-width: 0 ;}',
|
||||
// '.cxd-Panel-heading { border-width: 0; background: #4080ffc7 !important; }',
|
||||
// // '.cxd-Panel {box-shadow: none; }',
|
||||
// '.cxd-Panel-title { color:white;font-size: 16px; }'
|
||||
]);
|
||||
|
|
@ -14,6 +14,7 @@ Route::group([
|
|||
], function (Router $router) {
|
||||
$router->get('keywords/tree-list', '\App\Admin\Controllers\KeywordController@getTreeList')->name('api.keywords.tree-list');
|
||||
$router->get('institutions/tree-list', '\App\Admin\Controllers\InstitutionController@getTreeList')->name('api.institution.tree-list');
|
||||
$router->get('article_categories/tree-list', '\App\Admin\Controllers\ArticleCategoryController@getTreeList')->name('api.article_categories.tree-list');
|
||||
});
|
||||
|
||||
$router->resource('index', \App\Admin\Controllers\HomeController::class);
|
||||
|
|
@ -33,6 +34,21 @@ Route::group([
|
|||
|
||||
$router->resource('ads', \App\Admin\Controllers\AdController::class);
|
||||
|
||||
$router->resource('friend_links', \App\Admin\Controllers\FriendLinkController::class);
|
||||
|
||||
$router->resource('article_categories', \App\Admin\Controllers\ArticleCategoryController::class);
|
||||
|
||||
$router->resource('persons', \App\Admin\Controllers\PersonController::class);
|
||||
$router->post('split_master', [\App\Admin\Controllers\PersonController::class, 'doSplitMaster']);
|
||||
$router->post('merge_master', [\App\Admin\Controllers\PersonController::class, 'doMergeMaster']);
|
||||
$router->post('edit_master', [\App\Admin\Controllers\PersonController::class, 'doEditMaster']);
|
||||
$router->post('person_migrate', [\App\Admin\Controllers\PersonController::class, 'doPersonMigrate']);
|
||||
$router->post('person_out', [\App\Admin\Controllers\PersonController::class, 'doPersonOut']);
|
||||
$router->post('person_die', [\App\Admin\Controllers\PersonController::class, 'doPersonDie']);
|
||||
|
||||
|
||||
$router->resource('person_changes', \App\Admin\Controllers\PersonChangeController::class);
|
||||
|
||||
|
||||
//数据管理
|
||||
$router->resource('financial_cate', \App\Admin\Controllers\KeywordController::class);
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ class Ad extends Model
|
|||
{
|
||||
return [
|
||||
self::TYPE_WEB => '网页跳转',
|
||||
self::TYPE_APP => '应用跳转',
|
||||
self::TYPE_MINI => '小程序跳转',
|
||||
// self::TYPE_APP => '应用跳转',
|
||||
// self::TYPE_MINI => '小程序跳转',
|
||||
self::TYPE_OFF => '无跳转',
|
||||
];
|
||||
}
|
||||
|
|
@ -56,22 +56,12 @@ class Ad extends Model
|
|||
return [
|
||||
self::TYPE_OFF => "<span class='label'>无跳转</span>",
|
||||
self::TYPE_WEB => "<span class='label label-info'>网页跳转</span>",
|
||||
self::TYPE_APP => "<span class='label label-warning'>应用跳转</span>",
|
||||
self::TYPE_MINI => "<span class='label label-green'>小程序跳转</span>",
|
||||
// self::TYPE_APP => "<span class='label label-warning'>应用跳转</span>",
|
||||
// self::TYPE_MINI => "<span class='label label-green'>小程序跳转</span>",
|
||||
'*'=>'其他:${jump_type}'
|
||||
];
|
||||
}
|
||||
|
||||
public static function typeMapLabel()
|
||||
{
|
||||
return [
|
||||
self::TYPE_IN => "<span class='label label-info'>入住缴费</span>",
|
||||
self::TYPE_CONTINUE => "<span class='label label-warning'>续住缴费</span>",
|
||||
self::TYPE_EXIT => "<span class='label label-danger'>离开结算</span>",
|
||||
'*'=>'其他:${live_in}'
|
||||
];
|
||||
}
|
||||
|
||||
public function scopeShow(){
|
||||
$q->where('is_enable', true)->where('published_at', '>=', now());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,4 +60,9 @@ class Article extends Model
|
|||
get: fn($value) => $this->t_ids ? explode(',', $this->t_ids) : [],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function cate(){
|
||||
return $this->belongsTo(ArticleCategory::class, 'category');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use EloquentFilter\Filterable;
|
||||
|
||||
class ArticleCategory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Filterable;
|
||||
protected function serializeDate(\DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'key', 'cover',
|
||||
'parent_id', 'parent_key', 'lv', 'path',
|
||||
'is_enable', 'is_show', 'is_recommend',
|
||||
'sort',
|
||||
];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
// 监听 Keyword 的创建事件,用于初始化 path 和 lv 字段值
|
||||
static::saving(function ($keyword) {
|
||||
// 如果创建的是一个根类目
|
||||
if (! $keyword->parent_id) {
|
||||
// 将层级设为 1
|
||||
$keyword->lv = 1;
|
||||
// 将 path 设为 -
|
||||
$keyword->path = '-';
|
||||
} else {
|
||||
// 将层级设为父类目的层级 + 1
|
||||
$keyword->lv = $keyword->parent->lv +1;
|
||||
$keyword->parent_key = $keyword->parent->key;
|
||||
// 将 path 值设为父类目的 path 追加父类目 ID 以及最后跟上一个 - 分隔符
|
||||
$keyword->path = $keyword->parent->path.$keyword->parent_id.'-';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(static::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(static::class, 'parent_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Filters;
|
||||
|
||||
use EloquentFilter\ModelFilter;
|
||||
use App\Models\ArticleCategory;
|
||||
|
||||
class ArticleCategoryFilter extends ModelFilter
|
||||
{
|
||||
/**
|
||||
* 关键字
|
||||
*/
|
||||
public function name($name)
|
||||
{
|
||||
return $this->where('name','like', '%'.$name.'%')
|
||||
->orWhere('key','like', '%'.$name.'%');
|
||||
}
|
||||
|
||||
public function parentName($parent_name)
|
||||
{
|
||||
if(request('has_owner', 1)){
|
||||
$this->where(function($q) use ($parent_name){
|
||||
$q->where('name','like', '%'.$parent_name.'%')
|
||||
->orWhere('key','like', '%'.$parent_name.'%');
|
||||
});
|
||||
}
|
||||
return $this->orWhere('path','like', '%-'.
|
||||
ArticleCategory::where('name','like', '%'.$parent_name.'%')->orWhere('key','like', '%'.$parent_name.'%')->value('id')
|
||||
. '-%' ?? '');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Filters;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use EloquentFilter\ModelFilter;
|
||||
|
||||
class FriendLinkFilter extends ModelFilter
|
||||
{
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
public function id($id)
|
||||
{
|
||||
return $this->where('id', $id);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Filters;
|
||||
|
||||
use EloquentFilter\ModelFilter;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Keyword;
|
||||
|
||||
class PersonChangeFilter extends ModelFilter
|
||||
{
|
||||
public function year($year)
|
||||
{
|
||||
return $this->whereYear('changed_at', $year);
|
||||
}
|
||||
|
||||
public function person($person)
|
||||
{
|
||||
return $this->whereHas('person', function(Builder $q) use ($person){
|
||||
foreach($person as $key => $value){
|
||||
$q->where($key, $value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function type($type)
|
||||
{
|
||||
return $this->where('type', $type);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Filters;
|
||||
|
||||
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'])){
|
||||
$query = $this->whereHas('master', function(Builder $q) use ($master){
|
||||
$q->where('name', $master['name']);
|
||||
});
|
||||
}elseif(isset($master['id'])){
|
||||
$query = $this->where('master_id', $master['id']);
|
||||
}else{
|
||||
$query = $this->where('master_id', 0);
|
||||
}
|
||||
|
||||
if(request('no_master', 0)){
|
||||
$query->where('is_master', 0);
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
/**
|
||||
* 身份证
|
||||
*/
|
||||
public function idcard($idcard)
|
||||
{
|
||||
return $this->where('idcard', $idcard);
|
||||
}
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
public function gender($gender)
|
||||
{
|
||||
return $this->where('gender', $gender);
|
||||
}
|
||||
|
||||
/**
|
||||
* 社别
|
||||
*/
|
||||
public function organizedBody($organizedBody)
|
||||
{
|
||||
return $this->where('organized_body_id', $organizedBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* 居住小区
|
||||
*/
|
||||
public function houseBuilding($houseBuilding)
|
||||
{
|
||||
if(Keyword::where('id', $houseBuilding)->value('lv') == 3)
|
||||
{
|
||||
return $this->where('building_id', $houseBuilding);
|
||||
}else{
|
||||
return $this->where('housing_estate_id', $houseBuilding);
|
||||
}
|
||||
}
|
||||
|
||||
public function state($state)
|
||||
{
|
||||
return $this->where('state', $state);
|
||||
}
|
||||
|
||||
public function birthday($birthday)
|
||||
{
|
||||
$birthday = explode(',', $birthday);
|
||||
|
||||
return $this->whereBetween('birthday', $birthday);
|
||||
}
|
||||
|
||||
public function isMaster($isMaster)
|
||||
{
|
||||
return $this->where('is_master', $isMaster);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use EloquentFilter\Filterable;
|
||||
|
||||
class FriendLink extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Filterable;
|
||||
|
||||
protected function serializeDate(\DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'uri', 'cover', 'is_enable', 'sort'
|
||||
];
|
||||
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ class Keyword extends Model
|
|||
use HasFactory;
|
||||
use Filterable;
|
||||
|
||||
protected $fillable = ['name', 'key', 'value', 'parent_id', 'parent_key', 'path', 'sort', 'lv'];
|
||||
protected $fillable = ['name', 'key', 'value', 'parent_id', 'parent_key', 'path', 'sort', 'lv', 'oid'];
|
||||
|
||||
protected function serializeDate(\DateTimeInterface $date)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
|
||||
class Person extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Filterable;
|
||||
|
||||
protected $table = 'persons';
|
||||
|
||||
protected $appends = ['age', 'now_address'];
|
||||
|
||||
protected function serializeDate(\DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
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
|
||||
if(in_array($person->type, [11, 12])){
|
||||
PersonChange::create([
|
||||
'person_id' => $person->id,
|
||||
'type' => $person->type == 11 ? PersonChange::TYPE_BIRTH : PersonChange::TYPE_IN,
|
||||
'changed_at' => $person->type == 11 ? $person->birthday : $person->created_at,
|
||||
'new_master' => $person->master_id
|
||||
]);
|
||||
}
|
||||
});
|
||||
static::saving(function ($person) {
|
||||
if($person->origin_city_code){
|
||||
list($originProvince, $originCity, $originArea) = Zone::codeToZone($person->origin_city_code);
|
||||
$person->origin_province_id = $originProvince?->id ?? 0;
|
||||
$person->origin_city_id = $originCity?->id ?? 0;
|
||||
$person->origin_area_id = $originArea?->id ?? 0;
|
||||
$person->origin_complete_address = ($originProvince?->name ?? '未知').'-'.($originCity?->name ?? '未知').'-'.($originArea?->name ?? '未知');
|
||||
}
|
||||
if($person->card_city_code){
|
||||
list($cardProvince, $cardCity, $cardArea) = Zone::codeToZone($person->card_city_code);
|
||||
$person->card_province_id = $cardProvince?->id ?? 0;
|
||||
$person->card_city_id = $cardCity?->id ?? 0;
|
||||
$person->card_area_id = $cardArea?->id ?? 0;
|
||||
$person->card_complete_address = ($cardProvince?->name ?? '未知').'-'.($cardCity?->name ?? '未知').'-'.($cardArea?->name ?? '未知').$person->card_address;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeValid($q){
|
||||
$q->where('valid', 1);
|
||||
}
|
||||
|
||||
public function scopeSort($q)
|
||||
{
|
||||
$q->orderBy('master_id', 'asc')->orderBy('id', 'asc');
|
||||
}
|
||||
|
||||
//户主
|
||||
public function master()
|
||||
{
|
||||
return $this->belongsTo(static::class, 'master_id');
|
||||
}
|
||||
|
||||
public function organizedBody()
|
||||
{
|
||||
return $this->belongsTo(Keyword::class, 'organized_body_id');
|
||||
}
|
||||
|
||||
//年龄
|
||||
protected function age():Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn($value) => $this->birthday ? Carbon::parse($this->birthday)->diffInYears(now()).'岁' : "未知",
|
||||
);
|
||||
}
|
||||
|
||||
protected function nowAddress(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn($value) => $this->house_complete_address ? : $this->real_address,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
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; //出生
|
||||
public const TYPE_OUT = 3; //迁出
|
||||
public const TYPE_DIE = 4; //死亡
|
||||
public const TYPE_MERGE = 5; //合户
|
||||
public const TYPE_SPLIT = 6; //分户
|
||||
public const TYPE_MIGRATE = 7; //迁移
|
||||
public const TYPE_CHANGE = 8; //变更户主
|
||||
|
||||
protected $fillable = ['person_id', 'type', 'changed_at', 'reason', 'old_master', 'new_master', 'phone', 'extends', 'extends_mark', 'remark'];
|
||||
|
||||
protected $casts = [
|
||||
'extends' => 'array',
|
||||
];
|
||||
|
||||
public function scopeSort($q)
|
||||
{
|
||||
$q->orderBy('changed_at', 'desc')->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
public static function typeMap()
|
||||
{
|
||||
return [
|
||||
self::TYPE_IN =>'迁入',
|
||||
self::TYPE_BIRTH =>'出生',
|
||||
self::TYPE_OUT =>'迁出',
|
||||
self::TYPE_DIE =>'死亡',
|
||||
self::TYPE_MERGE =>'合户',
|
||||
self::TYPE_SPLIT =>'分户',
|
||||
self::TYPE_MIGRATE =>'迁移',
|
||||
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,45 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Zone extends Model
|
||||
{
|
||||
use Filterable;
|
||||
|
||||
protected $fillable = ['name', 'parent_id', 'type', 'index', 'code'];
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(self::class, 'parent_id');
|
||||
}
|
||||
|
||||
public static function codeToZone($code = null)
|
||||
{
|
||||
$province = $city = $area = null;
|
||||
$zone = self::where('code', $code)->first();
|
||||
if($zone){
|
||||
if($zone->type == 'area'){
|
||||
$area = $zone;
|
||||
$city = $area->parent;
|
||||
$zone = $city;
|
||||
}
|
||||
if($zone->type == 'city'){
|
||||
$city = $zone;
|
||||
$province = $city->parent;
|
||||
$zone = $province;
|
||||
}
|
||||
if($zone->type == 'province'){
|
||||
$province = $zone;
|
||||
}
|
||||
}
|
||||
return array($province, $city, $area);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\Admin;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Models\ArticleCategory;
|
||||
use App\Models\Filters\ArticleCategoryFilter;
|
||||
use App\Traits\UploadTrait;
|
||||
|
||||
/**
|
||||
* @method ArticleCategory getModel()
|
||||
* @method ArticleCategory|\Illuminate\Database\Query\Builder query()
|
||||
*/
|
||||
class ArticleCategoryService extends BaseService
|
||||
{
|
||||
protected string $modelName = ArticleCategory::class;
|
||||
protected string $modelFilterName = ArticleCategoryFilter::class;
|
||||
|
||||
use UploadTrait;
|
||||
|
||||
public function getTree()
|
||||
{
|
||||
$list = $this->query()->filter(request()->all(), $this->modelFilterName)->get();
|
||||
$minNum = $list->min('parent_id');
|
||||
return !$list->isEmpty() ? array2tree($list->toArray(), $minNum) :[];
|
||||
}
|
||||
|
||||
public function parentIsChild($id, $pid): bool
|
||||
{
|
||||
$parent = $this->query()->find($pid);
|
||||
|
||||
do {
|
||||
if ($parent->parent_id == $id) {
|
||||
return true;
|
||||
}
|
||||
// 如果没有parent 则为顶级 退出循环
|
||||
$parent = $parent->parent;
|
||||
} while ($parent);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
return ['items' => $this->getTree()];
|
||||
}
|
||||
|
||||
public function store($data): bool
|
||||
{
|
||||
if ($this->hasRepeated($data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$columns = $this->getTableColumns();
|
||||
|
||||
$model = $this->getModel();
|
||||
|
||||
$data['cover'] = $this->saveImage('cover', 'article_category/cover')[0] ?? '';
|
||||
foreach ($data as $k => $v) {
|
||||
if (!in_array($k, $columns)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$model->setAttribute($k, $v);
|
||||
}
|
||||
|
||||
return $model->save();
|
||||
}
|
||||
|
||||
public function update($primaryKey, $data): bool
|
||||
{
|
||||
if ($this->hasRepeated($data, $primaryKey)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$columns = $this->getTableColumns();
|
||||
|
||||
$pid = Arr::get($data, 'parent_id');
|
||||
if ($pid != 0) {
|
||||
if ($this->parentIsChild($primaryKey, $pid)) {
|
||||
$this->setError('父级不允许设置为当前子级');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$model = $this->query()->whereKey($primaryKey)->first();
|
||||
|
||||
if(isset($data['cover'])){
|
||||
$data['cover'] = $this->saveImage('cover', 'article_category/cover')[0] ?? '';
|
||||
}
|
||||
foreach ($data as $k => $v) {
|
||||
if (!in_array($k, $columns)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$model->setAttribute($k, $v);
|
||||
}
|
||||
|
||||
return $model->save();
|
||||
}
|
||||
|
||||
|
||||
public function hasRepeated($data, $id = 0): bool
|
||||
{
|
||||
$query = $this->query()->when($id, fn($query) => $query->where('id', '<>', $id));
|
||||
|
||||
if (isset($data['key']) && (clone $query)->where('key', $data['key'])->exists()) {
|
||||
$this->setError('KEY重复');
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function delete(string $ids): mixed
|
||||
{
|
||||
$ids = explode(',', $ids);
|
||||
if(count($ids) == 1){
|
||||
$this->query()->where('path', 'like', '%-'.$ids[0].'-%')->delete();
|
||||
}
|
||||
|
||||
return $this->query()->whereIn('id', $ids)->delete();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\Admin;
|
||||
|
||||
use App\Models\FriendLink;
|
||||
use App\Models\Filters\FriendLinkFilter;
|
||||
use App\Traits\UploadTrait;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
/**
|
||||
* @method FriendLink getModel()
|
||||
* @method FriendLink|\Illuminate\Database\Query\Builder query()
|
||||
*/
|
||||
class FriendLinkService extends BaseService
|
||||
{
|
||||
use UploadTrait;
|
||||
|
||||
protected string $modelName = FriendLink::class;
|
||||
|
||||
protected string $modelFilterName = FriendLinkFilter::class;
|
||||
|
||||
// protected bool $modelSortAble = true;
|
||||
|
||||
public function store($data): bool
|
||||
{
|
||||
$columns = $this->getTableColumns();
|
||||
$model = $this->getModel();
|
||||
|
||||
$isEnable = Arr::get($data, 'is_enabled');
|
||||
$publishedAt = Arr::get($data, 'published_at');
|
||||
|
||||
if(isset($data['cover'])){
|
||||
$data['cover'] = $this->saveImage('cover', 'friend_links/cover')[0];
|
||||
}
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
if (!in_array($k, $columns)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$model->setAttribute($k, $v);
|
||||
}
|
||||
|
||||
return $model->save();
|
||||
}
|
||||
|
||||
public function update($primaryKey, $data): bool
|
||||
{
|
||||
$columns = $this->getTableColumns();
|
||||
$model = $this->query()->whereKey($primaryKey)->first();
|
||||
|
||||
if(isset($data['cover'])){
|
||||
$data['cover'] = $this->saveImage('cover', 'friend_links/cover')[0];
|
||||
}
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
if (!in_array($k, $columns)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$model->setAttribute($k, $v);
|
||||
}
|
||||
|
||||
return $model->save();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?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'];
|
||||
|
||||
protected bool $modelSortAble = true;
|
||||
}
|
||||
|
|
@ -0,0 +1,576 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\Admin;
|
||||
|
||||
use App\Models\Keyword;
|
||||
use App\Models\Person;
|
||||
use App\Models\Filters\PersonFilter;
|
||||
use App\Traits\UploadTrait;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\PersonChange;
|
||||
use DB;
|
||||
|
||||
/**
|
||||
* @method Person getModel()
|
||||
* @method Person|\Illuminate\Database\Query\Builder query()
|
||||
*/
|
||||
class PersonService extends BaseService
|
||||
{
|
||||
use UploadTrait;
|
||||
|
||||
protected string $modelName = Person::class;
|
||||
|
||||
protected string $modelFilterName = PersonFilter::class;
|
||||
|
||||
protected array $withRelationships = ['master'];
|
||||
|
||||
protected bool $modelSortAble = true;
|
||||
|
||||
public function query(): Builder
|
||||
{
|
||||
return $this->modelName::query()->valid()->whereIn('type', [11, 12]);
|
||||
}
|
||||
|
||||
public function store($data): bool
|
||||
{
|
||||
$columns = $this->getTableColumns();
|
||||
$model = $this->getModel();
|
||||
|
||||
$data['avatar'] = $this->saveImage('avatar', 'persons/avatar')[0] ?? '';
|
||||
|
||||
if(isset($data['master'])){
|
||||
$data['master_id'] = $data['master'];
|
||||
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;
|
||||
}
|
||||
|
||||
$model->setAttribute($k, $v);
|
||||
}
|
||||
|
||||
return $model->save();
|
||||
}
|
||||
|
||||
public function update($primaryKey, $data): bool
|
||||
{
|
||||
$columns = $this->getTableColumns();
|
||||
$model = $this->query()->whereKey($primaryKey)->first();
|
||||
|
||||
if(isset($data['avatar'])){
|
||||
$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;
|
||||
}
|
||||
|
||||
$model->setAttribute($k, $v);
|
||||
}
|
||||
|
||||
return $model->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* 软删除
|
||||
*
|
||||
* @param string $ids
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete(string $ids): mixed
|
||||
{
|
||||
return $this->query()->whereIn($this->primaryKey(), explode(',', $ids))->update(['valid'=> 0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分户
|
||||
*
|
||||
* @param int $masterId
|
||||
* @param array $personArr
|
||||
* @param array $extends
|
||||
*
|
||||
*/
|
||||
public function splitMaster($masterId, $personArr = [], $extends)
|
||||
{
|
||||
$personList = collect($personArr);
|
||||
$newMaster = $personList->first(function ($item) {
|
||||
return isset($item['is_split']) && $item['is_split'] && isset($item['is_new_master']) && $item['is_new_master'];
|
||||
});
|
||||
if(empty($newMaster)){
|
||||
return $this->setError('分户失败,未选择新户主');
|
||||
}
|
||||
try{
|
||||
DB::beginTransaction();
|
||||
$personChangeLogs = [];
|
||||
//遍历分户成员情况, 并更新户主与户主关系
|
||||
|
||||
foreach($personList as $person){
|
||||
if(!$person['is_split']){//是否参与分户
|
||||
continue;
|
||||
}
|
||||
|
||||
$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'].'】';
|
||||
}
|
||||
$personChangeLogs[] = [
|
||||
'person_id' => $person['id'],
|
||||
'type' => PersonChange::TYPE_SPLIT,
|
||||
'changed_at' => isset($extends['splited_at']) ? $extends['splited_at'] : null,
|
||||
'reason' => isset($extends['split_reason']) ? $extends['split_reason'] : null,
|
||||
'old_master' => $person['master_id'],
|
||||
'new_master' => $newMaster['id'],
|
||||
'phone' => isset($extends['phone']) ? $extends['phone'] : null,
|
||||
'extends_mark' => $changeMark,
|
||||
'remark' => isset($extends['remark']) ? $extends['remark'] : null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
];
|
||||
|
||||
Person::where('id', $person['id'])->update([
|
||||
'master_id' => $newMaster['id'],
|
||||
'is_master' => $newMaster['id'] == $person['id'] ? true : false,
|
||||
'master_connect' => (isset($person['new_master_connect']) && !empty($person['new_master_connect'])) ? $person['new_master_connect'] : ($newMaster['id'] == $person['id'] ? '户主':'')
|
||||
]);
|
||||
}
|
||||
//批量插入人口变动记录
|
||||
count($personChangeLogs) > 0 && PersonChange::insert($personChangeLogs);
|
||||
|
||||
DB::commit();
|
||||
}catch(Throwable $th){
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
return $this->setError('系统错误,请刷新后重试');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 合户
|
||||
* @param int $masterId
|
||||
* @param int $toMasterId
|
||||
* @param array $personArr
|
||||
* @param array $extends
|
||||
*/
|
||||
public function mergeMaster($masterId, $toMasterId, $personArr = [], $extends)
|
||||
{
|
||||
if($masterId == $toMasterId){
|
||||
return $this->setError('合并失败, 不能选择两个相同户主');
|
||||
}
|
||||
$newMaster = Person::where('id', $masterId)->first()->toArray();
|
||||
try{
|
||||
DB::beginTransaction();
|
||||
$personChangeLogs = [];
|
||||
//遍历分户成员情况, 并更合并户与新户主关系
|
||||
foreach($personList as $person){
|
||||
$changeMark = (isset($extends['merged_at']) ? $extends['merged_at'] : '某日'). '日,' .(isset($extends['merge_reason']) ? ('因' .$extends['merge_reason']) : '').'合户,';
|
||||
if($person['is_master']){
|
||||
$changeMark .= '与新户主关系更新为【'.$person['new_master_connect'].'】';
|
||||
}else{
|
||||
$changeMark .= '户主由【'.$person["master"]["name"].'】变更为【'.$newMaster["name"].'】,与新户主关系更新为【'.$person['new_master_connect'].'】';
|
||||
}
|
||||
$personChangeLogs[] = [
|
||||
'person_id' => $person['id'],
|
||||
'type' => PersonChange::TYPE_MERGE,
|
||||
'changed_at' => isset($extends['merged_at']) ? $extends['merged_at'] : null,
|
||||
'reason' => isset($extends['merge_reason']) ? $extends['merge_reason'] : null,
|
||||
'old_master' => $person['master_id'],
|
||||
'new_master' => $newMaster['id'],
|
||||
'phone' => isset($extends['phone']) ? $extends['phone'] : null,
|
||||
'extends_mark' => $changeMark,
|
||||
'remark' => isset($extends['remark']) ? $extends['remark'] : null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
];
|
||||
|
||||
Person::where('id', $person['id'])->update([
|
||||
'master_id' => $newMaster['id'],
|
||||
'is_master' => $newMaster['id'] == $person['id'] ? true : false,
|
||||
'master_connect' => isset($person['new_master_connect']) ? $person['new_master_connect'] : ''
|
||||
]);
|
||||
}
|
||||
//批量插入人口变动记录
|
||||
count($personChangeLogs) > 0 && PersonChange::insert($personChangeLogs);
|
||||
|
||||
DB::commit();
|
||||
}catch(Throwable $th){
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
return $this->setError('系统错误,请刷新后重试');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更户主
|
||||
*
|
||||
* @param array $personArr
|
||||
* @param array $extends
|
||||
*
|
||||
*/
|
||||
public function editMaster($personArr = [], $extends)
|
||||
{
|
||||
$personList = collect($personArr);
|
||||
$newMaster = $personList->first(function ($item) {
|
||||
return isset($item['is_new_master']) && $item['is_new_master'];
|
||||
});
|
||||
if(empty($newMaster)){
|
||||
return $this->setError('变更失败,未选择新户主');
|
||||
}
|
||||
try{
|
||||
DB::beginTransaction();
|
||||
$personChangeLogs = [];
|
||||
//遍历分户成员情况, 并更新与新户主关系
|
||||
foreach($personList as $person){
|
||||
|
||||
$changeMark = (isset($extends['editd_at']) ? $extends['editd_at'] : '某日'). '日,' .(isset($extends['edit_reason']) ? ('因' .$extends['edit_reason']) : '').'户主变更,';
|
||||
if($person['is_master']){
|
||||
$changeMark .= '与新户主关系更新为【'.(isset($person['new_master_connect']) ? $person['new_master_connect']:'').'】';
|
||||
}elseif($person['is_new_master']){
|
||||
$changeMark .= '成为户主';
|
||||
}else{
|
||||
$changeMark .= '户主由【'.$person["master"]["name"].'】变更为【'.$newMaster["name"].'】,与新户主关系更新为-'.$person['new_master_connect'];
|
||||
}
|
||||
$personChangeLogs[] = [
|
||||
'person_id' => $person['id'],
|
||||
'type' => PersonChange::TYPE_CHANGE,
|
||||
'changed_at' => isset($extends['editd_at']) ? $extends['editd_at'] : null,
|
||||
'reason' => isset($extends['edit_reason']) ? $extends['edit_reason'] : null,
|
||||
'old_master' => $person['master_id'],
|
||||
'new_master' => $newMaster['id'],
|
||||
'phone' => isset($extends['edit_phone']) ? $extends['edit_phone'] : null,
|
||||
'extends_mark' => $changeMark,
|
||||
'remark' => isset($extends['edit_remark']) ? $extends['edit_remark'] : null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
];
|
||||
|
||||
Person::where('id', $person['id'])->update([
|
||||
'master_id' => $newMaster['id'],
|
||||
'is_master' => $newMaster['id'] == $person['id'] ? true : false,
|
||||
'master_connect' => (isset($person['new_master_connect']) && !empty($person['new_master_connect'])) ? $person['new_master_connect'] : ($newMaster['id'] == $person['id'] ? '户主':'')
|
||||
]);
|
||||
}
|
||||
//批量插入人口变动记录
|
||||
count($personChangeLogs) > 0 && PersonChange::insert($personChangeLogs);
|
||||
|
||||
DB::commit();
|
||||
}catch(Throwable $th){
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
return $this->setError('系统错误,请刷新后重试');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 迁移
|
||||
*/
|
||||
public function personMigrate($personId, $newMasterId, $newMasterConnect, $oldMasterArr = [], $extends)
|
||||
{
|
||||
$person = Person::find($personId);
|
||||
|
||||
if($person->master_id == $newMasterId){
|
||||
return $this->setError('迁移失败, 迁移目前户主不能为当前户主');
|
||||
}
|
||||
|
||||
$newMaster = Person::find($newMasterId);
|
||||
if(! $newMaster?->is_master){
|
||||
return $this->setError('迁移失败, 未选择新户主');
|
||||
}
|
||||
if(!empty($oldMasterArr)){
|
||||
$oldPersonList = collect($oldMasterArr);
|
||||
$oldNewMaster = $oldPersonList->first(function ($item) {
|
||||
return isset($item['is_new_master']) && $item['is_new_master'];
|
||||
});
|
||||
if($oldPersonList->count() > 1 && empty($oldNewMaster)){
|
||||
return $this->setError('迁移失败, 未选择原户新户主');
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
DB::beginTransaction();
|
||||
$personChangeLogs = [];
|
||||
|
||||
$changeMark = (isset($extends['migrated_at']) ? $extends['migrated_at'] : '某日'). '日,' .(isset($extends['migrate_reason']) ? ('因' .$extends['migrate_reason']) : '');
|
||||
if($person->is_master){
|
||||
$changeMark .= '迁移至户主【'.$person->master->name.'】下,与新户主关系更新为【'.$newMasterConnect.'】';
|
||||
}else{
|
||||
$changeMark .= '由户主【'.$person->master->name.'】迁移至新户主【'.$newMaster->name.'】下,与新户主关系更新为【'.$newMasterConnect.'】';
|
||||
}
|
||||
$personChangeLogs[] = [
|
||||
'person_id' => $person->id,
|
||||
'type' => PersonChange::TYPE_MIGRATE,
|
||||
'changed_at' => isset($extends['migrated_at']) ? $extends['migrated_at'] : null,
|
||||
'reason' => isset($extends['migrate_reason']) ? $extends['migrate_reason'] : null,
|
||||
'old_master' => $person->master_id,
|
||||
'new_master' => $newMaster->id,
|
||||
'phone' => isset($extends['migrate_phone']) ? $extends['migrate_phone'] : null,
|
||||
'extends_mark' => $changeMark,
|
||||
'remark' => isset($extends['migrate_remark']) ? $extends['migrate_remark'] : null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
];
|
||||
|
||||
//如果迁移的是户主, 则更新原户内人口信息
|
||||
if($person->is_master){
|
||||
foreach($oldMasterArr as $oldPerson){
|
||||
if($oldPerson['id'] == $person->id){
|
||||
continue;
|
||||
}
|
||||
$changeMark = (isset($extends['migrated_at']) ? $extends['migrated_at'] : '某日'). '日,' .(isset($extends['migrate_reason']) ? ('因' .$extends['migrate_reason'].'导致') : '').'原户主【'.$person->name.'】迁移,';
|
||||
if($oldPerson['is_new_master']){
|
||||
$changeMark .= '成为户主';
|
||||
}else{
|
||||
$changeMark .= '户主由【'.$person->master->name.'】变更为【'.$oldNewMaster['name'].'】,与新户主关系更新为【'.$oldPerson['new_master_connect'].'】';
|
||||
}
|
||||
$personChangeLogs[] = [
|
||||
'person_id' => $person['id'],
|
||||
'type' => PersonChange::TYPE_CHANGE,
|
||||
'changed_at' => isset($extends['migrated_at']) ? $extends['migrated_at'] : null,
|
||||
'reason' => (isset($extends['migrate_reason']) ? $extends['migrate_reason'].'导致' : '').'户主迁移',
|
||||
'old_master' => $person->master_id,
|
||||
'new_master' => $oldNewMaster['id'],
|
||||
'phone' => isset($extends['migrate_phone']) ? $extends['migrate_phone'] : null,
|
||||
'extends_mark' => $changeMark,
|
||||
'remark' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
];
|
||||
|
||||
Person::where('id', $oldPerson['id'])->update([
|
||||
'master_id' => $oldNewMaster['id'],
|
||||
'is_master' => $oldNewMaster['id'] == $oldPerson['id'] ? true : false,
|
||||
'master_connect' => (isset($oldPerson['new_master_connect']) && !empty($oldPerson['new_master_connect'])) ? $oldPerson['new_master_connect'] : ($oldNewMaster['id'] == $oldPerson['id'] ? '户主':'')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Person::where('id', $person->id)->update([
|
||||
'is_master' => 0,
|
||||
'master_id' => $newMaster->id,
|
||||
'master_connect' => $newMasterConnect
|
||||
]);
|
||||
|
||||
count($personChangeLogs) > 0 && PersonChange::insert($personChangeLogs);
|
||||
|
||||
DB::commit();
|
||||
}catch(Throwable $th){
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
return $this->setError('系统错误,请刷新后重试');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 迁出
|
||||
*/
|
||||
public function personOut($personId, $oldMasterArr = [], $extends)
|
||||
{
|
||||
$person = Person::find($personId);
|
||||
|
||||
if(!empty($oldMasterArr)){
|
||||
$oldPersonList = collect($oldMasterArr);
|
||||
$oldNewMaster = $oldPersonList->first(function ($item) {
|
||||
return isset($item['is_new_master']) && $item['is_new_master'];
|
||||
});
|
||||
if($oldPersonList->count() > 1 && empty($oldNewMaster)){
|
||||
return $this->setError('迁出失败, 未选择原户新户主');
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
DB::beginTransaction();
|
||||
$personChangeLogs = [];
|
||||
|
||||
$changeMark = (isset($extends['out_at']) ? $extends['out_at'] : '某日'). '日,' .(isset($extends['out_reason']) ? ('因' .$extends['out_reason']) : '');
|
||||
$changeMark .= '迁出至'.$extends['out_to_address'];
|
||||
|
||||
$personChangeLogs[] = [
|
||||
'person_id' => $person->id,
|
||||
'type' => PersonChange::TYPE_OUT,
|
||||
'changed_at' => isset($extends['out_at']) ? $extends['out_at'] : null,
|
||||
'reason' => isset($extends['out_reason']) ? $extends['out_reason'] : null,
|
||||
'old_master' => $person->master_id,
|
||||
'new_master' => isset($oldNewMaster) ? $oldNewMaster['id']:null,
|
||||
'phone' => isset($extends['out_phone']) ? $extends['out_phone'] : null,
|
||||
'extends' => json_encode([
|
||||
'to_address' => isset($extends['out_to_address']) ? $extends['out_to_address'] : null
|
||||
]),
|
||||
'extends_mark' => $changeMark,
|
||||
'remark' => isset($extends['out_remark']) ? $extends['out_remark'] : null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
];
|
||||
//如果迁移的是户主, 则更新原户内人口信息
|
||||
if($person->is_master){
|
||||
foreach($oldMasterArr as $oldPerson){
|
||||
if($oldPerson['id'] == $person->id){
|
||||
continue;
|
||||
}
|
||||
$changeMark = (isset($extends['migrated_at']) ? $extends['migrated_at'] : '某日'). '日,' .(isset($extends['migrate_reason']) ? ('因' .$extends['migrate_reason'].'导致') : '').'原户主【'.$person->name.'】迁出本村,';
|
||||
if($oldPerson['is_new_master']){
|
||||
$changeMark .= '成为户主';
|
||||
}else{
|
||||
$changeMark .= '户主由【'.$person->master->name.'】变更为【'.$oldNewMaster['name'].'】,与新户主关系更新为【'.$oldPerson['new_master_connect'].'】';
|
||||
}
|
||||
$personChangeLogs[] = [
|
||||
'person_id' => $person['id'],
|
||||
'type' => PersonChange::TYPE_CHANGE,
|
||||
'changed_at' => isset($extends['out_at']) ? $extends['out_at'] : null,
|
||||
'reason' => (isset($extends['out_reason']) ? $extends['out_reason'].'导致' : '').'户主迁出本村',
|
||||
'old_master' => $person->master_id,
|
||||
'new_master' => $oldNewMaster['id'],
|
||||
'extends' => null,
|
||||
'phone' => isset($extends['out_phone']) ? $extends['out_phone'] : null,
|
||||
'extends_mark' => $changeMark,
|
||||
'remark' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
];
|
||||
|
||||
Person::where('id', $oldPerson['id'])->update([
|
||||
'master_id' => $oldNewMaster['id'],
|
||||
'is_master' => $oldNewMaster['id'] == $oldPerson['id'] ? true : false,
|
||||
'master_connect' => (isset($oldPerson['new_master_connect']) && !empty($oldPerson['new_master_connect'])) ? $oldPerson['new_master_connect'] : ($oldNewMaster['id'] == $oldPerson['id'] ? '户主':'')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Person::where('id', $person->id)->update([
|
||||
'domicile_code' => '99999999',
|
||||
'is_master' => 0,
|
||||
'master_id' => null,
|
||||
'master_connect' => null,
|
||||
'state' => 2,
|
||||
]);
|
||||
|
||||
count($personChangeLogs) > 0 && PersonChange::insert($personChangeLogs);
|
||||
|
||||
DB::commit();
|
||||
}catch(Throwable $th){
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
return $this->setError('系统错误,请刷新后重试');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 迁出
|
||||
*/
|
||||
public function personDie($personId, $oldMasterArr = [], $extends)
|
||||
{
|
||||
$person = Person::find($personId);
|
||||
|
||||
if(!empty($oldMasterArr)){
|
||||
$oldPersonList = collect($oldMasterArr);
|
||||
$oldNewMaster = $oldPersonList->first(function ($item) {
|
||||
return isset($item['is_new_master']) && $item['is_new_master'];
|
||||
});
|
||||
if($oldPersonList->count() > 1 && empty($oldNewMaster)){
|
||||
return $this->setError('记录失败, 未选择原户新户主');
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
DB::beginTransaction();
|
||||
$personChangeLogs = [];
|
||||
|
||||
$changeMark = (isset($extends['die_at']) ? $extends['die_at'] : '某日'). '日,' .(isset($extends['die_reason']) ? ($extends['die_reason']) : '去世');
|
||||
|
||||
$personChangeLogs[] = [
|
||||
'person_id' => $person->id,
|
||||
'type' => PersonChange::TYPE_DIE,
|
||||
'changed_at' => isset($extends['die_at']) ? $extends['die_at'] : null,
|
||||
'reason' => isset($extends['die_reason']) ? $extends['die_reason'] : null,
|
||||
'old_master' => $person->master_id,
|
||||
'new_master' => null,
|
||||
'phone' => isset($extends['die_phone']) ? $extends['die_phone'] : null,
|
||||
'extends_mark' => $changeMark,
|
||||
'remark' => isset($extends['die_remark']) ? $extends['die_remark'] : null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
];
|
||||
//如果死亡的是户主, 则更新原户内人口信息
|
||||
if($person->is_master){
|
||||
foreach($oldMasterArr as $oldPerson){
|
||||
if($oldPerson['id'] == $person->id){
|
||||
continue;
|
||||
}
|
||||
$changeMark = (isset($extends['die_at']) ? $extends['die_at'] : '某日'). '日,原户主' .(isset($extends['die_reason']) ? ($extends['die_reason']) : '去世');
|
||||
if($oldPerson['is_new_master']){
|
||||
$changeMark .= ',成为户主';
|
||||
}else{
|
||||
$changeMark .= ',户主由【'.$person->master->name.'】变更为【'.$oldNewMaster['name'].'】,与新户主关系更新为【'.$oldPerson['new_master_connect'].'】';
|
||||
}
|
||||
$personChangeLogs[] = [
|
||||
'person_id' => $person['id'],
|
||||
'type' => PersonChange::TYPE_CHANGE,
|
||||
'changed_at' => isset($extends['out_at']) ? $extends['out_at'] : null,
|
||||
'reason' => '原户主去世',
|
||||
'old_master' => $person->master_id,
|
||||
'new_master' => $oldNewMaster['id'],
|
||||
'extends' => null,
|
||||
'phone' => isset($extends['out_phone']) ? $extends['out_phone'] : null,
|
||||
'extends_mark' => $changeMark,
|
||||
'remark' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
];
|
||||
|
||||
Person::where('id', $oldPerson['id'])->update([
|
||||
'master_id' => $oldNewMaster['id'],
|
||||
'is_master' => $oldNewMaster['id'] == $oldPerson['id'] ? true : false,
|
||||
'master_connect' => (isset($oldPerson['new_master_connect']) && !empty($oldPerson['new_master_connect'])) ? $oldPerson['new_master_connect'] : ($oldNewMaster['id'] == $oldPerson['id'] ? '户主':'')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Person::where('id', $person->id)->update([
|
||||
'domicile_code' => '99999999',
|
||||
'is_master' => 0,
|
||||
'master_id' => null,
|
||||
'master_connect' => null,
|
||||
'state' => 2,
|
||||
]);
|
||||
|
||||
count($personChangeLogs) > 0 && PersonChange::insert($personChangeLogs);
|
||||
|
||||
DB::commit();
|
||||
}catch(Throwable $th){
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
return $this->setError('系统错误,请刷新后重试');
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
|
@ -63,6 +63,26 @@ return [
|
|||
]) : [],
|
||||
],
|
||||
|
||||
'djc_mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DJC_DATABASE_URL'),
|
||||
'host' => env('DJC_DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DJC_DB_PORT', '3306'),
|
||||
'database' => env('DJC_DB_DATABASE', 'forge'),
|
||||
'username' => env('DJC_DB_USERNAME', 'forge'),
|
||||
'password' => env('DJC_DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DJC_DB_SOCKET', ''),
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'url' => env('DATABASE_URL'),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$zoneFile = database_path('sql/zone.sql');
|
||||
DB::unprepared(file_get_contents($zoneFile));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('zones');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?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::create('friend_links', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->comment('名称');
|
||||
$table->string('uri')->comment('链接地址');
|
||||
|
||||
$table->string('cover')->nullable()->comment('图片');
|
||||
$table->unsignedTinyInteger('is_enable')->default(1)->comment('显示开关');
|
||||
$table->unsignedInteger('sort')->default(0)->comment('排序');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('friend_links');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?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::create('article_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->comment('名称');
|
||||
$table->string('key')->nullable()->unique();
|
||||
$table->string('cover')->nullable()->comment('封面');
|
||||
|
||||
$table->unsignedBigInteger('parent_id')->default(0)->comment('上级ID');
|
||||
$table->string('parent_key')->nullable('上级key');
|
||||
$table->unsignedInteger('lv')->default(1)->comment('层级');
|
||||
$table->string('path')->default('-')->comment('所有的父级ID');
|
||||
|
||||
$table->unsignedTinyInteger('is_enable')->default(1)->comment('启用开关');
|
||||
$table->unsignedTinyInteger('is_show')->default(0)->comment('显示开关');
|
||||
$table->unsignedTinyInteger('is_recommend')->default(0)->comment('推荐开关');
|
||||
|
||||
$table->unsignedInteger('sort')->default(0)->comment('排序');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('article_categories');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
<?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::create('persons', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->comment('姓名');
|
||||
|
||||
$table->string('avatar')->nullable()->comment('头像');
|
||||
$table->string('used_name')->nullable()->comment('曾用名');
|
||||
$table->string('idcard', 50)->nullable()->comment('身份证号码');
|
||||
$table->unsignedBigInteger('gender')->nullable()->comment('性别:0未知,1男,2女');
|
||||
$table->date('birthday')->nullable()->comment('生日');
|
||||
|
||||
$table->string('origin_city_code')->nullable()->comment('户籍地区代码');
|
||||
$table->unsignedBigInteger('origin_province_id')->nullable()->comment('籍贯-省');
|
||||
$table->unsignedBigInteger('origin_city_id')->nullable()->comment('籍贯-市');
|
||||
$table->unsignedBigInteger('origin_area_id')->nullable()->comment('籍贯-区');
|
||||
$table->string('origin_complete_address')->nullable()->comment('籍贯地址');
|
||||
|
||||
$table->string('card_city_code')->nullable()->comment('户籍地区代码');
|
||||
$table->unsignedBigInteger('card_province_id')->nullable()->comment('户籍-省');
|
||||
$table->unsignedBigInteger('card_city_id')->nullable()->comment('户籍-市');
|
||||
$table->unsignedBigInteger('card_area_id')->nullable()->comment('户籍-区');
|
||||
$table->string('card_address')->nullable()->comment('户籍-街道详细地址');
|
||||
$table->string('card_complete_address')->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_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('联系方式');
|
||||
$table->string('remark')->nullable()->comment('备注');
|
||||
|
||||
$table->unsignedTinyInteger('type')->nullable()->comment('类型11-出生人口,12-迁入人口(11、12统称户籍人口),2-流动人口,3-留守人口,4-境外人口');
|
||||
$table->unsignedTinyInteger('has_benefit')->default(0)->comment('是否享受福利');
|
||||
$table->unsignedBigInteger('organized_body_id')->nullable()->comment('社别');
|
||||
$table->string('t_ids')->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('是否户主');
|
||||
$table->string('master_connect')->nullable()->default('')->comment('户主关系');
|
||||
|
||||
$table->unsignedTinyInteger('is_voter')->default(0)->comment('是否参加选民投票');
|
||||
|
||||
$table->string('wx_openid')->nullable()->comment('微信openId');
|
||||
$table->string('baidu_face_id')->nullable()->comment('百度人脸ID');
|
||||
|
||||
$table->unsignedTinyInteger('state')->nullable()->comment('状态1正常2死亡3迁出');
|
||||
|
||||
|
||||
$table->date('deathday')->nullable()->comment('死亡日期');
|
||||
$table->unsignedTinyInteger('valid')->default(1)->comment('是否有效');
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['valid', 'idcard']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('persons');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?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('keywords', function (Blueprint $table) {
|
||||
//
|
||||
$table->unsignedBigInteger('oid')->nullable()->comment('老ID主键');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('keywords', function (Blueprint $table) {
|
||||
//
|
||||
$table->dropColumn('oid');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?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::create('person_changes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('person_id');
|
||||
$table->unsignedTinyInteger('type')->comment('变动类型(1-迁入,2-出生,3-迁出(迁出本村),4-死亡,5-合户,6-分户,7-迁移(内部变动),8-更换户主)');
|
||||
$table->date('changed_at')->nullable()->comment('发生时间');
|
||||
$table->string('reason')->nullable()->comment('原因');
|
||||
$table->unsignedBigInteger('old_master')->nullable()->comment('老户主');
|
||||
$table->unsignedBigInteger('new_master')->nullable()->comment('新户主');
|
||||
$table->string('phone')->nullable()->comment('联系电话');
|
||||
$table->text('extends')->nullable()->comment('额外信息');
|
||||
$table->string('extends_mark')->nullable()->comment('额外信息-简述');
|
||||
$table->string('remark')->nullable()->comment('备注');
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('person_changes');
|
||||
}
|
||||
};
|
||||
|
|
@ -19,8 +19,8 @@ class AdminMenuSeeder extends Seeder
|
|||
{
|
||||
//
|
||||
$menus = [
|
||||
['title' => 'index', 'icon' => 'line-md:home-twotone-alt', 'url' => '/index', 'is_home'=>1, 'order'=>1],
|
||||
['title' => 'admin_system', 'icon' => 'material-symbols:settings-outline', 'url' => '/system', 'order'=>2,
|
||||
['title' => 'index', 'icon' => 'line-md:home-twotone-alt', 'url' => '/index', 'is_home'=>1, 'order'=>0],
|
||||
['title' => 'admin_system', 'icon' => 'material-symbols:settings-outline', 'url' => '/system', 'order'=>1,
|
||||
'children' => [
|
||||
['title' => 'admin_users', 'icon' => 'ph:user-gear', 'url' => '/system/admin_users', 'order'=>1],
|
||||
['title' => 'admin_roles', 'icon' => 'carbon:user-role', 'url' => '/system/admin_roles', 'order'=>2],
|
||||
|
|
@ -30,7 +30,26 @@ class AdminMenuSeeder extends Seeder
|
|||
['title' => 'keywords', 'icon' => 'ph:codesandbox-logo-light', 'url' => '/system/keywords', 'order'=>6],//字典管理
|
||||
],
|
||||
],
|
||||
['title' => 'data_content', 'icon' => 'ph:codesandbox-logo-light', 'url' => '', 'order'=>3,
|
||||
['title' => 'djc_wind', 'icon' => 'tabler:brand-databricks', 'url' => '/djc', 'order'=>2,//道角枫云
|
||||
'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?state=1', 'order'=>0],
|
||||
['title'=>'person_changes', 'icon'=>'material-symbols:user-attributes-outline','url'=>'/person_changes', 'order'=>1],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
],
|
||||
|
||||
['title' => 'web_content', 'icon' => 'iconoir:internet', 'url' => '/web_content', 'order'=>3,//网站管理
|
||||
'children' => [
|
||||
['title'=>'ads', 'icon'=>'lets-icons:img-box','url'=>'/ads', 'order'=>0],
|
||||
['title'=>'friend_links', 'icon'=>'mdi:link-variant','url'=>'/friend_links', 'order'=>1],
|
||||
['title'=>'article_categories', 'icon'=>'tabler:category-2', 'url'=>'/article_categories', 'order'=>2],
|
||||
['title'=>'articles', 'icon'=>'ic:outline-article','url'=>'/articles', 'order'=>3],
|
||||
]
|
||||
],
|
||||
['title' => 'data_content', 'icon' => 'ph:codesandbox-logo-light', 'url' => '/data_content', 'order'=>4, //数据管理
|
||||
'children' =>[
|
||||
//财务报表类型,档案类型,部门管理,地区类型,社别管理,小区管理,楼栋管理,户籍类型,民族管理,政治面貌,文化程度,机构管理,口头纠纷类型,卫生检查类型,图书类型,企业地区管理,收支情况类型,福利类型,工种管理
|
||||
['title' => 'financial_cate', 'icon' => 'tabler:zoom-money', 'url' => '/financial_cate?parent_name=financial_cate&has_owner=0', 'order'=>0],//财务报表类型
|
||||
|
|
@ -52,10 +71,6 @@ class AdminMenuSeeder extends Seeder
|
|||
['title' => 'money_cate', 'icon' => 'streamline:subscription-cashflow', 'url' => '/money_cate?parent_name=money_cate&has_owner=0', 'order'=>16],//收支情况类型
|
||||
['title' => 'welfare_cate', 'icon' => 'material-symbols:redeem-rounded', 'url' => '/welfare_cate?parent_name=welfare_cate&has_owner=0', 'order'=>17],//福利类型
|
||||
['title' => 'job_cate', 'icon' => 'gravity-ui:person-worker', 'url' => '/job_cate?parent_name=job_cate&has_owner=0', 'order'=>18],//工种管理
|
||||
|
||||
|
||||
// ['title'=>'articles', 'icon'=>'ic:outline-article','url'=>'/articles', 'order'=>1],
|
||||
// ['title'=>'ads', 'icon'=>'lets-icons:img-box','url'=>'/ads', 'order'=>2],
|
||||
]
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@ class DatabaseSeeder extends Seeder
|
|||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//初始化迁移
|
||||
$this->call(AdminMenuSeeder::class);
|
||||
$this->call(KeywordSeeder::class);
|
||||
|
||||
//执行老数据迁移-todo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,23 @@ class KeywordSeeder extends Seeder
|
|||
{
|
||||
Keyword::truncate();
|
||||
$list = [
|
||||
['key' => 'article_category', 'name' => '文章分类', 'list' => []],
|
||||
// ['key' => 'article_category', 'name' => '文章分类', 'list' => []],
|
||||
//标签value填写色号,指定标签颜色
|
||||
['key' => 'article_tag', 'name' => '文章标签', 'list' => []],
|
||||
['key' => 'banner_address', 'name' => '广告位置', 'list' => []],
|
||||
['key' => 'institution_type', 'name' => '组织属性', 'list' => []],
|
||||
['key' => 'institution_type', 'name' => '组织属性', 'list' => [
|
||||
'网络化结构组织','道角村综治中心','群防群治组织','党组织','村组织'
|
||||
]],
|
||||
['key' => 'marry_state', 'name' => '婚姻状况', 'list' => [
|
||||
'未婚','已婚','离异','再婚','复婚','丧偶'
|
||||
]],
|
||||
['key' => 'military_service_status', 'name' => '兵役情况', 'list' => [
|
||||
'未服兵役','现役军人','退役军人'
|
||||
]],
|
||||
['key' => 'person_tag', 'name' => '人口标签', 'list' => [
|
||||
'刑满释放人员', '社区矫正人员', '肇事肇祸等严重精神障碍患者', '吸毒人员', '重点青少年','上访信访人员', '艾滋病危险人员','残疾人','低保五保','失独家庭','失业农民','其他困难人员','困难家庭','党员'
|
||||
]],
|
||||
|
||||
//菜单
|
||||
['key' => 'financial_cate', 'name' => '财务报表类型', 'list' => []],
|
||||
['key' => 'file_cate', 'name' => '档案类型', 'list' => []],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Database\Seeders\Migrations\{ArticleCategorySeeder, KeywordSeeder, BuildingSeeder,PersonSeeder};
|
||||
|
||||
class MigrationSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->call([
|
||||
// ArticleCategorySeeder::class,
|
||||
// KeywordSeeder::class,
|
||||
// BuildingSeeder::class,
|
||||
PersonSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders\Migrations;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
|
||||
class ArticleCategorySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
//老文章分类表
|
||||
$oldCates = DB::connection('djc_mysql')->table('t_article_type')->get()->sortBy('pid');
|
||||
|
||||
$newCategories = [];
|
||||
foreach($oldCates as $cate){
|
||||
if(empty($cate->name) || empty($dict->valid)){
|
||||
continue;
|
||||
}
|
||||
$_category = [
|
||||
'id' => $cate -> id,
|
||||
'parent_id' => $cate -> pid ?? 0,
|
||||
'name' => $cate->name,
|
||||
'cover' => $cate->icon ?? null,
|
||||
'sort' => $cate -> sorted,
|
||||
'is_recommend' => $cate->recommend,
|
||||
'is_show' => $cate->showInOut,
|
||||
'lv' => !empty($cate->pid) ? $newCategories[$cate->pid]['lv'] + 1:1,
|
||||
'path' => !empty($cate->pid) ? $newCategories[$cate->pid]['path'] . $cate->pid .'-':'-',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
|
||||
$newCategories[$cate->id] = $_category;
|
||||
}
|
||||
|
||||
if(count($newCategories) > 0){
|
||||
DB::table('article_categories')->truncate();
|
||||
try {
|
||||
DB::begintransaction();
|
||||
DB::table('article_categories')->insert($newCategories);
|
||||
DB::commit();
|
||||
} catch (Throwable $th) {
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders\Migrations;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
use App\Models\Keyword;
|
||||
|
||||
class BuildingSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$oldDicts = DB::connection('djc_mysql')->table('t_data_dict')->where('dictKey', 'building')->get();
|
||||
|
||||
$newKeywords = [];
|
||||
|
||||
$buildings = [];
|
||||
foreach($oldDicts as $dict){
|
||||
if(empty($dict->dictKey) || empty($dict->valid)){
|
||||
continue;
|
||||
}
|
||||
$_keyword = null;
|
||||
$_parent = Keyword::where('oid', $dict->parentId)->first();
|
||||
|
||||
if($_parent){
|
||||
$_keyword = [
|
||||
'key' => $_parent->key.$dict->id,
|
||||
'name' => $dict->txt,
|
||||
'sort' => $dict->sorted,
|
||||
'parent_id' => $_parent->id,
|
||||
'parent_key'=> $_parent->key,
|
||||
'lv' => $_parent->lv+1,
|
||||
'path' => $_parent->path.$_parent->id.'-',
|
||||
'oid' => $dict->id,
|
||||
'created_at'=>now(),
|
||||
'updated_at'=>now()
|
||||
];
|
||||
}
|
||||
if($_keyword){
|
||||
$newKeywords[$dict->id] = $_keyword;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($newKeywords) > 0){
|
||||
try {
|
||||
DB::begintransaction();
|
||||
DB::table('keywords')->insert($newKeywords);
|
||||
DB::commit();
|
||||
} catch (Throwable $th) {
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders\Migrations;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
use App\Models\Keyword;
|
||||
|
||||
class KeywordSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$oldDicts = DB::connection('djc_mysql')->table('t_data_dict')->get();
|
||||
|
||||
$newKeywords = [];
|
||||
|
||||
$parentList = Keyword::whereIn('key', ['financial_cate', 'file_cate', 'department', 'area_cate', 'organized_body', 'housing_estate', 'domicile', 'nation', 'political_face','educational_level','oral_disputes','sanitary_inspection', 'book_cate', 'business_area','money_cate', 'welfare_cate', 'job_cate'])->get();
|
||||
|
||||
$buildings = [];
|
||||
foreach($oldDicts as $dict){
|
||||
if(empty($dict->dictKey) || empty($dict->valid)){
|
||||
continue;
|
||||
}
|
||||
$_parent = $_keyword = null;
|
||||
switch($dict->dictKey){
|
||||
case 'financeReportType'://财务报表类型
|
||||
$_parent = $parentList->where('key', 'financial_cate')->first();
|
||||
break;
|
||||
case 'profileType'://档案类型
|
||||
$_parent = $parentList->where('key', 'file_cate')->first();
|
||||
break;
|
||||
case 'addrType'://企业地区管理
|
||||
$_parent = $parentList->where('key', 'business_area')->first();
|
||||
break;
|
||||
case 'bookType'://图书类型
|
||||
$_parent = $parentList->where('key', 'book_cate')->first();
|
||||
break;
|
||||
case 'court'://小区管理
|
||||
$_parent = $parentList->where('key', 'housing_estate')->first();
|
||||
break;
|
||||
case 'workType'://工种管理
|
||||
$_parent = $parentList->where('key', 'job_cate')->first();
|
||||
break;
|
||||
case 'welfType'://福利类型
|
||||
$_parent = $parentList->where('key', 'welfare_cate')->first();
|
||||
break;
|
||||
case 'society'://社别
|
||||
$_parent = $parentList->where('key', 'organized_body')->first();
|
||||
break;
|
||||
case 'regionType'://地区类型
|
||||
$_parent = $parentList->where('key', 'area_cate')->first();
|
||||
break;
|
||||
case 'politics'://政治面貌
|
||||
$_parent = $parentList->where('key', 'political_face')->first();
|
||||
break;
|
||||
case 'payType'://收支类型
|
||||
$_parent = $parentList->where('key', 'money_cate')->first();
|
||||
break;
|
||||
case 'hygieneType'://卫生检查类型
|
||||
$_parent = $parentList->where('key', 'sanitary_inspection')->first();
|
||||
break;
|
||||
case 'houseHold'://户籍管理
|
||||
$_parent = $parentList->where('key', 'domicile')->first();
|
||||
break;
|
||||
case 'folk'://民族管理
|
||||
$_parent = $parentList->where('key', 'nation')->first();
|
||||
break;
|
||||
case 'eduction'://文化程度
|
||||
$_parent = $parentList->where('key', 'educational_level')->first();
|
||||
break;
|
||||
case 'disputeType'://口头纠纷类型
|
||||
$_parent = $parentList->where('key', 'oral_disputes')->first();
|
||||
break;
|
||||
}
|
||||
if($_parent){
|
||||
$_keyword = [
|
||||
'key' => $_parent->key.$dict->id,
|
||||
'name' => $dict->txt,
|
||||
'sort' => $dict->sorted,
|
||||
'parent_id' => $_parent->id,
|
||||
'parent_key'=> $_parent->key,
|
||||
'lv' => $_parent->lv+1,
|
||||
'path' => $_parent->path.$_parent->id.'-',
|
||||
'oid' => $dict->id,
|
||||
'created_at'=>now(),
|
||||
'updated_at'=>now()
|
||||
];
|
||||
}
|
||||
if($_keyword){
|
||||
$newKeywords[$dict->id] = $_keyword;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($newKeywords) > 0){
|
||||
try {
|
||||
DB::begintransaction();
|
||||
DB::table('keywords')->insert($newKeywords);
|
||||
DB::commit();
|
||||
} catch (Throwable $th) {
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders\Migrations;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
use App\Models\Keyword;
|
||||
|
||||
class PersonSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('persons')->truncate();
|
||||
|
||||
DB::connection('djc_mysql')->table('t_person')->orderBy('id', 'ASC')->chunk(100, function($persons){
|
||||
|
||||
// $newPersons = [];
|
||||
if($persons->count() > 0){
|
||||
$typeArr = [
|
||||
5=>'刑满释放人员',
|
||||
6=>'社区矫正人员',
|
||||
7=>'肇事肇祸等严重精神障碍患者',
|
||||
8=>'吸毒人员',
|
||||
9=>'重点青少年',
|
||||
10=>'上访信访人员',
|
||||
11=>'艾滋病危险人员',
|
||||
13=>'残疾人',
|
||||
14=>'低保五保',
|
||||
15=>'失独家庭',
|
||||
16=>'失业农民',
|
||||
17=>'其他困难人员',
|
||||
18=>'困难家庭',
|
||||
20=>'党员'];
|
||||
foreach($persons as $person){
|
||||
if($person->valid){//有效的记录
|
||||
if(!empty($person->idcard) && DB::table('persons')->where('idcard', $person->idcard)->exists()){
|
||||
DB::table('persons')->where('idcard', $person->idcard)->delete();
|
||||
}
|
||||
$_person = [
|
||||
'id' => $person->id,
|
||||
'name'=> $person->useName,
|
||||
'used_name' => $person->usedName ?: null,
|
||||
'idcard' => $person->idcard ?: null,
|
||||
'gender' => $person->gender == '男' ? 1:($person->gender == '女' ? 2:0),
|
||||
'birthday' => (!empty(strtotime($person->birth)) && ($person->birth == date('Y-m-d', strtotime($person->birth)))) ? $person->birth:null,
|
||||
|
||||
'origin_province_id'=> null,
|
||||
'origin_city_id' => null,
|
||||
'origin_complete_address' => $person->nativePlace,
|
||||
'card_complete_address' => $person->birthAddr,
|
||||
|
||||
'housing_estate_id' => null,
|
||||
'building_id' => null,
|
||||
'house_number' => null,
|
||||
'house_complete_address' => null,
|
||||
'real_address' => null,
|
||||
|
||||
'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,
|
||||
'remark'=> $person->remark,
|
||||
|
||||
'type'=>$person->type,
|
||||
'has_benefit' => $person->benefit == '是' ? 1:0,
|
||||
'organized_body_id' => Keyword::where('parent_key', 'organized_body')->where('oid', $person->societyId)->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,
|
||||
'master_connect' => $person->houseHoldMasterRelative ?: null,
|
||||
|
||||
'is_voter' => $person->voter == '是' ? 1:0,
|
||||
|
||||
'wx_openid' => $person->openid ?: null,
|
||||
'baidu_face_id' => $person->baiduUserId ?: null,
|
||||
|
||||
'state' => $person->status,
|
||||
|
||||
't_ids' => null,
|
||||
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
//处理人物标签
|
||||
if(!empty($person->type1)){
|
||||
$_tIds = [];
|
||||
$_typeIds = explode(',',$person->type1);
|
||||
foreach($typeArr as $k => $typeName){
|
||||
if(in_array($k, $_typeIds)){
|
||||
$_tIds[] = Keyword::where('parent_key', 'person_tag')->where('name', $typeName)->value('id');
|
||||
}
|
||||
}
|
||||
if($_tIds){
|
||||
$_person['t_ids'] = implode(',', $_tIds);
|
||||
}
|
||||
}
|
||||
|
||||
//处理籍贯地址选中问题;如果是重庆市-巴南区,重庆市-九龙坡,重庆-巴县,重庆市-綦江区
|
||||
if(Str::startsWith($person->nativePlace, '重庆市') || Str::startsWith($person->nativePlace, '重庆')){
|
||||
$_person['origin_city_code'] = '500100';
|
||||
$_person['origin_province_id'] = 2221;
|
||||
$_person['origin_city_id'] = 2222;
|
||||
}
|
||||
|
||||
//处理户籍地址选中问题;如果是重庆市-巴南区,重庆市-九龙坡,重庆-巴县,重庆市-綦江区
|
||||
if(Str::startsWith($person->birthAddr, '重庆市') || Str::startsWith($person->birthAddr, '重庆')){
|
||||
$_person['origin_city_code'] = '500100';
|
||||
$_person['origin_province_id'] = 2221;
|
||||
$_person['origin_city_id'] = 2222;
|
||||
}
|
||||
//处理居住地址
|
||||
if($person->courtId){
|
||||
$houseCompleteAddress = '';
|
||||
$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_id'] = $housingEstate->id;
|
||||
$houseCompleteAddress .= $housingEstate->name;
|
||||
}
|
||||
if($building){
|
||||
$_person['building_id'] = $building->id;
|
||||
$houseCompleteAddress .= $building->name;
|
||||
}
|
||||
$_person['house_number'] = $person->door;
|
||||
$houseCompleteAddress .= ' '.$person->door;
|
||||
if($houseCompleteAddress){
|
||||
$_person['house_complete_address'] = $houseCompleteAddress;
|
||||
}
|
||||
}
|
||||
|
||||
$_person['real_address'] = $person->addr2;
|
||||
|
||||
// $newPersons[] = $_person;
|
||||
if($_person['is_master']){
|
||||
$_person['master_id'] = $person->id;
|
||||
}
|
||||
DB::table('persons')->insert($_person);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if(count($newPersons) > 0){
|
||||
// DB::table('persons')->insert($newPersons);
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -61,6 +61,7 @@ return [
|
|||
'please_login' => '请先登录',
|
||||
'unauthorized' => '无权访问',
|
||||
'id' => 'ID',
|
||||
'year' => '年份',
|
||||
|
||||
'components' => [
|
||||
'content' => '内容',
|
||||
|
|
@ -319,5 +320,74 @@ return [
|
|||
'person' => '负责人',
|
||||
'person_id' => '负责人',
|
||||
'sort' => '排序',
|
||||
],
|
||||
'friend_links' => [
|
||||
'name' => '名称',
|
||||
'uri' => '链接地址',
|
||||
'cover'=> '图片',
|
||||
'sort' => '排序',
|
||||
'is_enable'=>'显示',
|
||||
],
|
||||
'article_categories' => [
|
||||
'name' => '名称',
|
||||
'parent' => '上级分类',
|
||||
'parent_id' => '上级分类',
|
||||
'key' => 'KEY',
|
||||
'cover'=>'图标',
|
||||
'sort'=>'排序',
|
||||
'is_enable' => '启用',
|
||||
'is_show' => '展示',
|
||||
'is_recommend' => '推荐'
|
||||
],
|
||||
'persons' => [
|
||||
'name' => '姓名',
|
||||
'avatar' => '头像',
|
||||
'domicile_code' => '户籍编号',
|
||||
'master_connect' => '关系',
|
||||
'master_name' => '户主姓名',
|
||||
'idcard' =>'身份证号',
|
||||
'gender' => '性别',
|
||||
'birthday' => '出生日期',
|
||||
'age' => '年龄',
|
||||
'now_address' => '现住址',
|
||||
'organized_body' => '社别',
|
||||
'house_building' => '居住小区',
|
||||
'state' => '人口状态',
|
||||
'birthday'=> '出生日期',
|
||||
'type'=>'人口类别',
|
||||
'used_name'=>'曾用名',
|
||||
'origin_city_code' => '籍贯',
|
||||
'origin_complete_address' => '籍贯',
|
||||
'card_city_code' => '出生地址',
|
||||
'card_complete_address' => '出生地址',
|
||||
'domicile' => '户籍类型',
|
||||
'has_benefit'=>'是否享受福利',
|
||||
'master'=>'户主',
|
||||
'master_id' => '户主',
|
||||
'political_face'=>'政治面貌',
|
||||
'nation' => '民族',
|
||||
'educational_level'=>'文化程度',
|
||||
'marry_state' => '婚姻状况',
|
||||
'house_number'=> '门牌号',
|
||||
'real_address' => '现居地址',
|
||||
'military_service_status' => '兵役情况',
|
||||
'is_voter' => '是否参与选民',
|
||||
'job' => '职业',
|
||||
'health' => '身体状况',
|
||||
'phone' => '联系方式',
|
||||
'remark' => '备注',
|
||||
'is_master'=>'是否户主',
|
||||
|
||||
//分户操作
|
||||
'split_master' => '分户',
|
||||
'merge_master' => '合户',
|
||||
],
|
||||
'person_changes'=>[
|
||||
'changed_at' => '变动日期',
|
||||
'extends_mark'=>'变动明细',
|
||||
'type' => '变动类别',
|
||||
'phone'=>'联系方式',
|
||||
'created_at' => '操作时间',
|
||||
'remark' => '备注'
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ return [
|
|||
'admin_menu' => '菜单',
|
||||
'admin_setting' => '设置',
|
||||
'keywords' => '数据字典',
|
||||
'web_content' => '内容管理',
|
||||
'web_content' => '网站管理',
|
||||
'articles' => '文章管理',
|
||||
'ads' => '广告管理',
|
||||
'ads' => '海报管理',
|
||||
'data_content' => '数据管理',
|
||||
'financial_cate' => '财务报表类型',
|
||||
'file_cate' => '档案类型',
|
||||
|
|
@ -33,4 +33,11 @@ return [
|
|||
'money_cate' => '收支类型',
|
||||
'welfare_cate' => '福利类型',
|
||||
'job_cate' => '工种管理',
|
||||
'friend_links' => '友情链接',
|
||||
'article_categories'=> '文章分类',
|
||||
'djc_wind' => '道角枫云',
|
||||
'base_person_data' => '基础信息数据',
|
||||
'real_person_data' => '实有人口管理',
|
||||
'persons' => '户籍人口',
|
||||
'person_changes' => '户籍变动'
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue