mirror of https://gitee.com/karson/fastadmin.git
美化crud生成的代码格式
parent
572bdc2eb7
commit
d0373fc870
|
|
@ -703,14 +703,16 @@ class Crud extends Command
|
||||||
$addList = implode("\n", array_filter($addList));
|
$addList = implode("\n", array_filter($addList));
|
||||||
$editList = implode("\n", array_filter($editList));
|
$editList = implode("\n", array_filter($editList));
|
||||||
$javascriptList = implode(",\n", array_filter($javascriptList));
|
$javascriptList = implode(",\n", array_filter($javascriptList));
|
||||||
|
$langList = implode(",\n", array_filter($langList));
|
||||||
//数组等号对齐
|
//数组等号对齐
|
||||||
|
$langList = array_filter(explode(",\n", $langList . ",\n"));
|
||||||
foreach ($langList as &$line) {
|
foreach ($langList as &$line) {
|
||||||
if (preg_match("/^\s+'([^']+)'\s*=>\s*'([^']+)'\s*/is", $line, $matches)) {
|
if (preg_match("/^\s+'([^']+)'\s*=>\s*'([^']+)'\s*/is", $line, $matches)) {
|
||||||
$line = " '{$matches[1]}'" . str_pad('=>', ($this->fieldMaxLen - strlen($matches[1]) + 3), ' ', STR_PAD_LEFT) . " '{$matches[2]}'";
|
$line = " '{$matches[1]}'" . str_pad('=>', ($this->fieldMaxLen - strlen($matches[1]) + 3), ' ', STR_PAD_LEFT) . " '{$matches[2]}'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($line);
|
unset($line);
|
||||||
$langList = implode(",\n", array_filter($langList)) . ',';
|
$langList = implode(",\n", array_filter($langList)). ",";
|
||||||
|
|
||||||
//表注释
|
//表注释
|
||||||
$tableComment = $modelTableInfo['Comment'];
|
$tableComment = $modelTableInfo['Comment'];
|
||||||
|
|
@ -761,7 +763,7 @@ class Crud extends Command
|
||||||
'relationMethodList' => '',
|
'relationMethodList' => '',
|
||||||
'controllerIndex' => '',
|
'controllerIndex' => '',
|
||||||
'visibleFieldList' => $fields ? "\$row->visible(['" . implode("','", array_filter(explode(',', $fields))) . "']);" : '',
|
'visibleFieldList' => $fields ? "\$row->visible(['" . implode("','", array_filter(explode(',', $fields))) . "']);" : '',
|
||||||
'appendAttrList' => implode(",\n", $appendAttrList),
|
'appendAttrList' => implode(",\n", $appendAttrList) . ',',
|
||||||
'getEnumList' => implode("\n\n", $getEnumArr),
|
'getEnumList' => implode("\n\n", $getEnumArr),
|
||||||
'getAttrList' => implode("\n\n", $getAttrArr),
|
'getAttrList' => implode("\n\n", $getAttrArr),
|
||||||
'setAttrList' => implode("\n\n", $setAttrArr),
|
'setAttrList' => implode("\n\n", $setAttrArr),
|
||||||
|
|
@ -868,7 +870,7 @@ class Crud extends Command
|
||||||
public function {$methodName}()
|
public function {$methodName}()
|
||||||
{
|
{
|
||||||
return [{$itemString}];
|
return [{$itemString}];
|
||||||
}
|
}
|
||||||
EOD;
|
EOD;
|
||||||
$controllerAssignList[] = <<<EOD
|
$controllerAssignList[] = <<<EOD
|
||||||
\$this->view->assign("{$fieldList}", \$this->model->{$methodName}());
|
\$this->view->assign("{$fieldList}", \$this->model->{$methodName}());
|
||||||
|
|
@ -1047,7 +1049,7 @@ EOD;
|
||||||
}
|
}
|
||||||
$stringArr[] = "'" . $k . "' => " . ($is_var ? $v : "'{$v}'");
|
$stringArr[] = "'" . $k . "' => " . ($is_var ? $v : "'{$v}'");
|
||||||
}
|
}
|
||||||
return implode(",", $stringArr);
|
return implode(", ", $stringArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getItemArray($item, $field, $comment)
|
protected function getItemArray($item, $field, $comment)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="radio" id="c-{field}">
|
<div class="radio" id="c-{%field%}">
|
||||||
{foreach name="{%fieldList%}" item="vo"}
|
{foreach name="{%fieldList%}" item="vo"}
|
||||||
<label for="{%fieldName%}-{$key}"><input id="{%fieldName%}-{$key}" name="{%fieldName%}" type="radio" value="{$key}" {in name="key" value="{%selectedValue%}"}checked{/in} /> {$vo}</label>
|
<label for="{%fieldName%}-{$key}"><input id="{%fieldName%}-{$key}" name="{%fieldName%}" type="radio" value="{$key}" {in name="key" value="{%selectedValue%}"}checked{/in} /> {$vo}</label>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<select {%attrStr%}>
|
<select {%attrStr%}>
|
||||||
{foreach name="{%fieldList%}" item="vo"}
|
{foreach name="{%fieldList%}" item="vo"}
|
||||||
<option value="{$key}" {in name="key" value="{%selectedValue%}"}selected{/in}>{$vo}</option>
|
<option value="{$key}" {in name="key" value="{%selectedValue%}"}selected{/in}>{$vo}</option>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<div class="panel panel-default panel-intro">
|
<div class="panel panel-default panel-intro">
|
||||||
{:build_heading()}
|
{:build_heading()}
|
||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div id="myTabContent" class="tab-content">
|
<div id="myTabContent" class="tab-content">
|
||||||
<div class="tab-pane fade active in" id="one">
|
<div class="tab-pane fade active in" id="one">
|
||||||
|
|
@ -11,7 +10,6 @@
|
||||||
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('{%controllerUrl%}/edit')?'':'hide'}" title="{:__('Edit')}"><i class="fa fa-pencil"></i> {:__('Edit')}</a>
|
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('{%controllerUrl%}/edit')?'':'hide'}" title="{:__('Edit')}"><i class="fa fa-pencil"></i> {:__('Edit')}</a>
|
||||||
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('{%controllerUrl%}/del')?'':'hide'}" title="{:__('Delete')}"><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('{%controllerUrl%}/del')?'':'hide'}" title="{:__('Delete')}"><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
||||||
<!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('{%controllerUrl%}/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->
|
<!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('{%controllerUrl%}/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->
|
||||||
|
|
||||||
<div class="dropdown btn-group {:$auth->check('{%controllerUrl%}/multi')?'':'hide'}">
|
<div class="dropdown btn-group {:$auth->check('{%controllerUrl%}/multi')?'':'hide'}">
|
||||||
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
|
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
|
||||||
<ul class="dropdown-menu text-left" role="menu">
|
<ul class="dropdown-menu text-left" role="menu">
|
||||||
|
|
@ -27,7 +25,6 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -40,14 +40,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||||
{%javascriptList%}
|
{%javascriptList%}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
//禁用默认搜索
|
//禁用默认搜索
|
||||||
search: false,
|
search: false,
|
||||||
//启用普通表单搜索
|
//启用普通表单搜索
|
||||||
commonSearch: true,
|
commonSearch: true,
|
||||||
//可以控制是否默认显示搜索单表,false则隐藏,默认为false
|
//可以控制是否默认显示搜索单表,false则隐藏,默认为false
|
||||||
searchFormVisible: false,
|
searchFormVisible: false,
|
||||||
showColumns: false,
|
showColumns: false,
|
||||||
showToggle: false,
|
showToggle: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 为表格绑定事件
|
// 为表格绑定事件
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
public function {%methodName%}($value, $data)
|
public function {%methodName%}($value, $data)
|
||||||
{
|
{
|
||||||
$value = $value ? $value : $data['{%field%}'];
|
$value = $value ? $value : $data['{%field%}'];
|
||||||
$list = $this->{%listMethodName%}();
|
$list = $this->{%listMethodName%}();
|
||||||
return isset($list[$value]) ? $list[$value] : '';
|
return isset($list[$value]) ? $list[$value] : '';
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
public function {%methodName%}($value, $data)
|
public function {%methodName%}($value, $data)
|
||||||
{
|
{
|
||||||
$value = $value ? $value : $data['{%field%}'];
|
$value = $value ? $value : $data['{%field%}'];
|
||||||
$list = $this->{%listMethodName%}();
|
$list = $this->{%listMethodName%}();
|
||||||
return isset($list[$value]) ? $list[$value] : '';
|
return isset($list[$value]) ? $list[$value] : '';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue