<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Nav\Admin\Controller; use Illuminate\Routing\Controller; use ModStart\Admin\Concern\HasAdminQuickCRUD; use ModStart\Admin\Layout\AdminCRUDBuilder; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Type\TypeUtil; use ModStart\Field\AbstractField; use ModStart\Field\AutoRenderedFieldValue; use ModStart\Field\Type\FieldRenderMode; use ModStart\Form\Form; use ModStart\ModStart; use ModStart\Repository\Filter\ScopeFilter; use ModStart\Support\Concern\HasFields; use Module\Nav\Type\NavOpenType; use Module\Nav\Type\NavPosition; use Module\Nav\Util\NavUtil; class NavController extends Controller { use HasAdminQuickCRUD; protected function crud(AdminCRUDBuilder $enw1u) { goto VId4s; KWrht: $enw1u->scopeDefault(NavPosition::first()); goto LdkIq; VId4s: if ($enw1u->mode() == AdminCRUDBuilder::MODE_FORM) { goto A90tp; SPBMb: foreach (NavUtil::tree() as $qGgGl) { $MdME1[] = array('id' => $qGgGl['id'], 'position' => $qGgGl['position'], 'name' => $qGgGl['name']); if (!empty($qGgGl['_child'])) { foreach ($qGgGl['_child'] as $Ao4Fu) { $MdME1[] = array('id' => $Ao4Fu['id'], 'position' => $Ao4Fu['position'], 'name' => $qGgGl['name'] . ' → ' . $Ao4Fu['name']); } } } goto r40_P; A90tp: $MdME1 = array(); goto SPBMb; r40_P: ModStart::script('window.__positionNavs=' . json_encode($MdME1) . ';'); goto u67AN; u67AN: ModStart::scriptFile('module/Nav/Admin/Controller/NavEdit.js'); goto AVlRl; AVlRl: } goto KfXrD; LdkIq: $enw1u->hookSaved(function (Form $hUMbi) { $FSL7c = $hUMbi->item(); if ($FSL7c->pid > 0) { $n6kmv = ModelUtil::get('nav', $FSL7c->pid); ModelUtil::update('nav', $FSL7c->id, array('position' => $n6kmv['position'])); } })->hookChanged(function (Form $hUMbi) { NavUtil::clearCache(); })->canBatchDelete(true)->asTree('id', 'pid', 'sort', 'name')->treeMaxLevel(3)->title('导航设置'); goto j4gkD; KfXrD: $enw1u->init('nav')->field(function ($enw1u) { $enw1u->id('id', 'ID'); $enw1u->select('position', '位置')->optionType(NavPosition::class)->hookRendering(function (AbstractField $Wvq57, $FSL7c, $xZl3o) { switch ($Wvq57->renderMode()) { case FieldRenderMode::DETAIL: case FieldRenderMode::GRID: if ($FSL7c->pid) { return AutoRenderedFieldValue::make(''); } return AutoRenderedFieldValue::make(TypeUtil::name(NavPosition::class, $FSL7c->position)); } }); $enw1u->text('name', '名称'); $enw1u->icon('icon', '图标')->help('部分主题支持图标显示'); $enw1u->link('link', '链接'); $enw1u->switch('enable', '启用')->optionsYesNo()->gridEditable(true)->defaultValue(true); $enw1u->radio('openType', '打开方式')->optionType(NavOpenType::class)->defaultValue(NavOpenType::CURRENT_WINDOW); $enw1u->display('created_at', L('Created At'))->listable(false); $enw1u->display('updated_at', L('Updated At'))->listable(false); }); goto XYWWx; XYWWx: foreach (NavPosition::getList() as $OSU2M => $qQcPQ) { $enw1u->scopeFilter($OSU2M, $qQcPQ, function (ScopeFilter $zBPGV) use($OSU2M) { return $zBPGV->where('position', $OSU2M); }); } goto KWrht; j4gkD: } }