修正行政区域添加后无法选择
This commit is contained in:
parent
50ee24192f
commit
fb85089b38
|
@ -0,0 +1,40 @@
|
||||||
|
<?php namespace Gdoo\System\Hooks;
|
||||||
|
|
||||||
|
use DB;
|
||||||
|
use Gdoo\System\Models\Region;
|
||||||
|
|
||||||
|
class RegionHook
|
||||||
|
{
|
||||||
|
static $linkOptions = [];
|
||||||
|
|
||||||
|
public function onBeforeForm($params) {
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onAfterForm($params) {
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onBeforeStore($params) {
|
||||||
|
$master = $params['master'];
|
||||||
|
$master['parent_id'] = (int)$master['parent_id'];
|
||||||
|
|
||||||
|
$master['layer'] = 1;
|
||||||
|
if ($master['parent_id'] > 0) {
|
||||||
|
$parent = Db::table('region')->where('id', $master['parent_id'])->first();
|
||||||
|
$master['layer'] = $parent['layer'] + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$params['master'] = $master;
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onAfterStore($params) {
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onBeforeDelete($params) {
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,6 +10,9 @@ return [
|
||||||
'url' => 'system/region/dialog',
|
'url' => 'system/region/dialog',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
"listens" => [
|
||||||
|
'region' => 'Gdoo\System\Hooks\RegionHook',
|
||||||
|
],
|
||||||
"controllers" => [
|
"controllers" => [
|
||||||
"setting" => [
|
"setting" => [
|
||||||
"name" => "基础设置",
|
"name" => "基础设置",
|
||||||
|
|
Loading…
Reference in New Issue