切换导航条
此项目
正在载入...
登录
何书鹏
/
recruit
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
Karson
7 years ago
提交
1b08595857b7199a3edacbaef26774e9bd3aba53
1 个父辈
52712b64
新增模型支持目录结构命名
新增Table.api.formatter.normal格式化 优化CRUD删除模式移除空目录 优化多个表格内容格式化方法
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
215 行增加
和
91 行删除
application/admin/command/Crud.php
application/admin/command/Crud/stubs/controller.stub
application/admin/library/traits/Backend.php
public/assets/js/bootstrap-table-commonsearch.js
public/assets/js/require-backend.min.js
public/assets/js/require-table.js
application/admin/command/Crud.php
查看文件 @
1b08595
...
...
@@ -46,6 +46,11 @@ class Crud extends Command
protected
$switchSuffix
=
[
'switch'
];
/**
* 富文本后缀
*/
protected
$editorSuffix
=
[
'content'
];
/**
* 城市后缀
*/
protected
$citySuffix
=
[
'city'
];
...
...
@@ -64,12 +69,13 @@ class Crud extends Command
* 以指定字符结尾的字段格式化函数
*/
protected
$fieldFormatterSuffix
=
[
'status'
=>
[
'type'
=>
[
'varchar'
],
'name'
=>
'status'
],
'status'
=>
[
'type'
=>
[
'varchar'
,
'enum'
],
'name'
=>
'status'
],
'icon'
=>
'icon'
,
'flag'
=>
'flag'
,
'url'
=>
'url'
,
'image'
=>
'image'
,
'images'
=>
'images'
,
'switch'
=>
'toggle'
,
'time'
=>
[
'type'
=>
[
'int'
,
'timestamp'
],
'name'
=>
'datetime'
]
];
...
...
@@ -145,6 +151,8 @@ class Crud extends Command
$controller
=
$input
->
getOption
(
'controller'
);
//自定义模型
$model
=
$input
->
getOption
(
'model'
);
//验证器类
$validate
=
$model
;
//自定义显示字段
$fields
=
$input
->
getOption
(
'fields'
);
//强制覆盖
...
...
@@ -220,6 +228,11 @@ class Crud extends Command
$dbname
=
Config
::
get
(
'database.database'
);
$prefix
=
Config
::
get
(
'database.prefix'
);
//模块
$moduleName
=
'admin'
;
$modelModuleName
=
$local
?
$moduleName
:
'common'
;
$validateModuleName
=
$local
?
$moduleName
:
'common'
;
//检查主表
$modelName
=
$table
=
stripos
(
$table
,
$prefix
)
===
0
?
substr
(
$table
,
strlen
(
$prefix
))
:
$table
;
$modelTableType
=
'table'
;
...
...
@@ -257,9 +270,7 @@ class Crud extends Command
$relationTableInfo
=
$relationTableInfo
[
0
];
$relationModel
=
isset
(
$relationModel
[
$index
])
?
$relationModel
[
$index
]
:
''
;
//关联模型默认以表名进行处理,以下划线进行分隔,如果需要自定义则需要传入relationmodel,不支持目录层级
$relationName
=
$this
->
getModelName
(
$relationModel
,
$relationName
);
$relationFile
=
(
$local
?
$adminPath
:
APP_PATH
.
'common'
.
DS
)
.
'model'
.
DS
.
$relationName
.
'.php'
;
list
(
$relationNamespace
,
$relationName
,
$relationFile
)
=
$this
->
getModelData
(
$modelModuleName
,
$relationModel
,
$relationName
);
$relations
[]
=
[
//关联表基础名
...
...
@@ -292,28 +303,25 @@ class Crud extends Command
$iconPath
=
ROOT_PATH
.
str_replace
(
'/'
,
DS
,
'/public/assets/libs/font-awesome/less/variables.less'
);
$iconName
=
is_file
(
$iconPath
)
&&
stripos
(
file_get_contents
(
$iconPath
),
'@fa-var-'
.
$table
.
':'
)
?
'fa fa-'
.
$table
:
'fa fa-circle-o'
;
//控制器默认以表名进行处理,以下划线进行分隔,如果需要自定义则需要传入controller,格式为目录层级
$controller
=
str_replace
(
'_'
,
''
,
$controller
);
$controllerArr
=
!
$controller
?
explode
(
'_'
,
strtolower
(
$table
))
:
explode
(
'/'
,
strtolower
(
$controller
));
$controllerUrl
=
implode
(
'/'
,
$controllerArr
);
$controllerName
=
ucfirst
(
array_pop
(
$controllerArr
));
$controllerDir
=
implode
(
DS
,
$controllerArr
);
$controllerFile
=
(
$controllerDir
?
$controllerDir
.
DS
:
''
)
.
$controllerName
.
'.php'
;
$viewDir
=
$adminPath
.
'view'
.
DS
.
$controllerUrl
.
DS
;
//控制器
list
(
$controllerNamespace
,
$controllerName
,
$controllerFile
,
$controllerArr
)
=
$this
->
getControllerData
(
$moduleName
,
$controller
,
$table
);
//模型
list
(
$modelNamespace
,
$modelName
,
$modelFile
,
$modelArr
)
=
$this
->
getModelData
(
$modelModuleName
,
$model
,
$table
);
//验证器
list
(
$validateNamespace
,
$validateName
,
$validateFile
,
$validateArr
)
=
$this
->
getValidateData
(
$validateModuleName
,
$validate
,
$table
);
$controllerUrl
=
strtolower
(
implode
(
'/'
,
$controllerArr
));
$controllerBaseName
=
strtolower
(
implode
(
DS
,
$controllerArr
));
//视图文件
$viewDir
=
$adminPath
.
'view'
.
DS
.
$controllerBaseName
.
DS
;
//最终将生成的文件路径
$controllerFile
=
$adminPath
.
'controller'
.
DS
.
$controllerFile
;
$javascriptFile
=
ROOT_PATH
.
'public'
.
DS
.
'assets'
.
DS
.
'js'
.
DS
.
'backend'
.
DS
.
$controllerUrl
.
'.js'
;
$javascriptFile
=
ROOT_PATH
.
'public'
.
DS
.
'assets'
.
DS
.
'js'
.
DS
.
'backend'
.
DS
.
$controllerBaseName
.
'.js'
;
$addFile
=
$viewDir
.
'add.html'
;
$editFile
=
$viewDir
.
'edit.html'
;
$indexFile
=
$viewDir
.
'index.html'
;
$langFile
=
$adminPath
.
'lang'
.
DS
.
Lang
::
detect
()
.
DS
.
$controllerUrl
.
'.php'
;
//模型默认以表名进行处理,以下划线进行分隔,如果需要自定义则需要传入model,不支持目录层级
$modelName
=
$this
->
getModelName
(
$model
,
$table
);
$modelFile
=
(
$local
?
$adminPath
:
APP_PATH
.
'common'
.
DS
)
.
'model'
.
DS
.
$modelName
.
'.php'
;
$validateFile
=
$adminPath
.
'validate'
.
DS
.
$modelName
.
'.php'
;
$langFile
=
$adminPath
.
'lang'
.
DS
.
Lang
::
detect
()
.
DS
.
$controllerBaseName
.
'.php'
;
//是否为删除模式
$delete
=
$input
->
getOption
(
'delete'
);
...
...
@@ -332,6 +340,14 @@ class Crud extends Command
foreach
(
$readyFiles
as
$k
=>
$v
)
{
if
(
file_exists
(
$v
))
unlink
(
$v
);
//删除空文件夹
if
(
$v
==
$modelFile
)
{
$this
->
removeEmptyBaseDir
(
$v
,
$modelArr
);
}
else
if
(
$v
==
$validateFile
)
{
$this
->
removeEmptyBaseDir
(
$v
,
$validateArr
);
}
else
{
$this
->
removeEmptyBaseDir
(
$v
,
$controllerArr
);
}
}
$output
->
info
(
"Delete Successed"
);
...
...
@@ -457,8 +473,10 @@ class Crud extends Command
$itemArr
=
[];
// 这里构建Enum和Set类型的列表数据
if
(
in_array
(
$v
[
'DATA_TYPE'
],
[
'enum'
,
'set'
,
'tinyint'
]))
{
$itemArr
=
substr
(
$v
[
'COLUMN_TYPE'
],
strlen
(
$v
[
'DATA_TYPE'
])
+
1
,
-
1
);
$itemArr
=
explode
(
','
,
str_replace
(
"'"
,
''
,
$itemArr
));
if
(
$v
[
'DATA_TYPE'
]
!==
'tinyint'
)
{
$itemArr
=
substr
(
$v
[
'COLUMN_TYPE'
],
strlen
(
$v
[
'DATA_TYPE'
])
+
1
,
-
1
);
$itemArr
=
explode
(
','
,
str_replace
(
"'"
,
''
,
$itemArr
));
}
$itemArr
=
$this
->
getItemArray
(
$itemArr
,
$field
,
$v
[
'COLUMN_COMMENT'
]);
//如果类型为tinyint且有使用备注数据
if
(
$itemArr
&&
$v
[
'DATA_TYPE'
]
==
'tinyint'
)
{
...
...
@@ -563,7 +581,7 @@ class Crud extends Command
$formAddElement
=
$this
->
getReplacedStub
(
'html/'
.
$inputType
,
[
'field'
=>
$field
,
'fieldName'
=>
$fieldName
,
'fieldList'
=>
$this
->
getFieldListName
(
$field
),
'attrStr'
=>
Form
::
attributes
(
$attrArr
),
'selectedValue'
=>
$defaultValue
]);
$formEditElement
=
$this
->
getReplacedStub
(
'html/'
.
$inputType
,
[
'field'
=>
$field
,
'fieldName'
=>
$fieldName
,
'fieldList'
=>
$this
->
getFieldListName
(
$field
),
'attrStr'
=>
Form
::
attributes
(
$attrArr
),
'selectedValue'
=>
"
\$
row.
{
$field
}
"
]);
}
else
if
(
$inputType
==
'textarea'
)
{
$cssClassArr
[]
=
substr
(
$field
,
-
7
)
==
'content'
?
$this
->
editorClass
:
''
;
$cssClassArr
[]
=
$this
->
isMatchSuffix
(
$field
,
$this
->
editorSuffix
)
?
$this
->
editorClass
:
''
;
$attrArr
[
'class'
]
=
implode
(
' '
,
$cssClassArr
);
$attrArr
[
'rows'
]
=
5
;
$formAddElement
=
Form
::
textarea
(
$fieldName
,
$defaultValue
,
$attrArr
);
...
...
@@ -577,6 +595,9 @@ class Crud extends Command
$no
=
$defaultValue
;
$yes
=
$defaultValue
===
'0'
?
'1'
:
'Y'
;
}
if
(
!
$itemArr
)
{
$itemArr
=
[
$yes
=>
'Yes'
,
$no
=>
'No'
];
}
$formAddElement
=
$formEditElement
=
Form
::
hidden
(
$fieldName
,
$no
,
array_merge
([
'checked'
=>
''
],
$attrArr
));
$attrArr
[
'id'
]
=
$fieldName
.
"-switch"
;
$formAddElement
.=
sprintf
(
Form
::
label
(
"
{
$attrArr
[
'id'
]}
", "
%
s
{
:
__
(
'Yes'
)}
", ['class' => 'control-label']), Form::checkbox(
$fieldName
,
$yes
,
$defaultValue
===
$yes
,
$attrArr
));
...
...
@@ -603,6 +624,10 @@ class Crud extends Command
$attrArr['
data
-
params
'] = '
##replacetext##';
$search
=
'"##replacetext##"'
;
$replace
=
'\'{"custom[type]":"'
.
$table
.
'"}\''
;
}
elseif (
$selectpageController
== 'admin') {
$attrArr['data-source']
= 'auth/admin/selectpage';
} elseif (
$selectpageController
== 'user') {
$attrArr['data-source']
= 'user/user/index';
}
if (
$this->isMatchSuffix
(
$field
,
$this->selectpagesSuffix
)) {
$attrArr['data-multiple']
= 'true';
...
...
@@ -696,13 +721,6 @@ class Crud extends Command
$tableComment
=
$modelTableInfo['Comment']
;
$tableComment
= mb_substr(
$tableComment
, -1) == '表' ? mb_substr(
$tableComment
, 0, -1) . '管理' :
$tableComment
;
$appNamespace
= Config::get('app_namespace');
$moduleName
= 'admin';
$controllerNamespace
= "
{
$appNamespace
}
\\
{
$moduleName
}
\\controller
" . (
$controllerDir
? "
\\
" : "") . str_replace('/', "
\\
",
$controllerDir
);
$modelNamespace
= "
{
$appNamespace
}
\\
" . (
$local
?
$moduleName
: "
common
") . "
\\model
";
$validateNamespace
= "
{
$appNamespace
}
\\
" .
$moduleName
. "
\\validate
";
$validateName
=
$modelName
;
$modelInit
= '';
if (
$priKey
!=
$order
) {
$modelInit
=
$this->getReplacedStub
('mixins' . DS . 'modelinit', ['order' =>
$order
]);
...
...
@@ -713,7 +731,6 @@ class Crud extends Command
'modelNamespace' =>
$modelNamespace
,
'validateNamespace' =>
$validateNamespace
,
'controllerUrl' =>
$controllerUrl
,
'controllerDir' =>
$controllerDir
,
'controllerName' =>
$controllerName
,
'controllerAssignList' => implode("
\n
",
$controllerAssignList
),
'modelName' =>
$modelName
,
...
...
@@ -890,18 +907,91 @@ EOD;
EOD;
}
protected function getModelName(
$model
,
$table
)
/**
* 移除相对的空目录
* @param
$parseFile
* @param
$parseArr
* @return bool
*/
protected function removeEmptyBaseDir(
$parseFile
,
$parseArr
)
{
if (count(
$parseArr
) > 1) {
$parentDir
= dirname(
$parseFile
);
for (
$i
= 0;
$i
< count(
$parseArr
);
$i
++) {
$iterator
= new \FilesystemIterator(
$parentDir
);
$isDirEmpty
= !
$iterator->valid
();
if (
$isDirEmpty
) {
rmdir(
$parentDir
);
$parentDir
= dirname(
$parentDir
);
} else {
return true;
}
}
}
return true;
}
/**
* 获取控制器相关信息
* @param
$module
* @param
$controller
* @param
$table
* @return array
*/
protected function getControllerData(
$module
,
$controller
,
$table
)
{
return
$this->getParseNameData
(
$module
,
$controller
,
$table
, 'controller');
}
/**
* 获取模型相关信息
* @param
$module
* @param
$model
* @param
$table
* @return array
*/
protected function getModelData(
$module
,
$model
,
$table
)
{
if (!
$model
) {
$modelarr
= explode('_', strtolower(
$table
));
foreach (
$modelarr
as
$k
=> &
$v
)
$v
= ucfirst(
$v
);
unset(
$v
);
$modelName
= implode('',
$modelarr
);
return
$this->getParseNameData
(
$module
,
$model
,
$table
, 'model');
}
/**
* 获取验证器相关信息
* @param
$module
* @param
$validate
* @param
$table
* @return array
*/
protected function getValidateData(
$module
,
$validate
,
$table
)
{
return
$this->getParseNameData
(
$module
,
$validate
,
$table
, 'validate');
}
/**
* 获取已解析相关信息
* @param
$module
* @param
$name
* @param
$table
* @param
$type
* @return array
*/
protected function getParseNameData(
$module
,
$name
,
$table
,
$type
)
{
$arr
= [];
if (!
$name
) {
$arr
= explode('_', strtolower(
$table
));
} else {
$modelName
= ucfirst(
$model
);
$name
= str_replace(['.', '/', '
\\
'], '/',
$name
);
$arr
= explode('/',
$name
);
}
return
$modelName
;
$parseName
= ucfirst(array_pop(
$arr
));
$appNamespace
= Config::get('app_namespace');
$parseNamespace
= "
{
$appNamespace
}
\\
{
$module
}
\\
{
$type
}
" . (
$arr
? "
\\
" . implode("
\\
",
$arr
) : "");
$moduleDir
= APP_PATH .
$module
. DS;
$parseFile
=
$moduleDir
.
$type
. DS . (
$arr
? implode(DS,
$arr
) . DS : '') .
$parseName
. '.php';
$parseArr
=
$arr
;
$parseArr
[] =
$parseName
;
return [
$parseNamespace
,
$parseName
,
$parseFile
,
$parseArr
];
}
/**
...
...
@@ -1199,25 +1289,19 @@ EOD;
}
}
}
if (
$formatter
) {
$extend
= '';
}
$html
= str_repeat("
", 24) . "
{
field
:
'{$field}{$extend}'
,
title
:
__
(
'{$lang}'
)
";
//
$formatter
=
$extend
? '' :
$formatter
;
if (
$extend
) {
$html
.= "
,
operate
:
false
";
if (
$datatype
== 'set') {
$formatter
= 'label';
}
$html
= str_repeat("
", 24) . "
{
field
:
'{$field}'
,
title
:
__
(
'{$lang}'
)
";
if (
$datatype
== 'set') {
$formatter
= 'label';
}
foreach (
$itemArr
as
$k
=> &
$v
) {
if (substr(
$v
, 0, 3) !== '__(')
$v
= "
__
(
'" .
$v
. "'
)
";
$v
= "
__
(
'" .
mb_ucfirst($v)
. "'
)
";
}
unset(
$v
);
$searchList
= json_encode(
$itemArr
, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE);
$searchList
= str_replace(['"
:
"', '"
}
', '
)
","
'], ['
":', '}', '),"
'], $searchList);
if ($itemArr
&& !$extend
) {
if ($itemArr) {
$html .= ", searchList: " . $searchList;
}
if (in_array($datatype, ['
date
', '
datetime
']) || $formatter === '
datetime
') {
...
...
@@ -1225,18 +1309,16 @@ EOD;
} else if (in_array($datatype, ['
float
', '
double
', '
decimal
'])) {
$html .= ", operate:'
BETWEEN
'";
}
if (in_array($datatype, ['
set
'])) {
$html .= ", operate:'
FIND_IN_SET
'";
}
if ($itemArr && !$formatter) {
$formatter = '
normal
';
}
if ($formatter)
$html .= ", formatter: Table.api.formatter." . $formatter . "}";
else
$html .= "}";
if ($extend) {
$origin = str_repeat(" ", 24) . "{field: '
{
$field
}
', title: __('
{
$lang
}
'), visible:false";
if ($searchList) {
$origin .= ", searchList: " . $searchList;
}
$origin .= "}";
$html = $origin . ",\n" . $html;
}
return $html;
}
...
...
application/admin/command/Crud/stubs/controller.stub
查看文件 @
1b08595
...
...
@@ -21,7 +21,7 @@ class {%controllerName%} extends Backend
public function _initialize()
{
parent::_initialize();
$this->model =
model('{%modelName%}')
;
$this->model =
new \{%modelNamespace%}\{%modelName%}
;
{%controllerAssignList%}
}
...
...
application/admin/library/traits/Backend.php
查看文件 @
1b08595
...
...
@@ -80,7 +80,7 @@ trait Backend
try
{
//是否采用模型验证
if
(
$this
->
modelValidate
)
{
$name
=
basename
(
str_replace
(
'\\'
,
'/'
,
get_class
(
$this
->
model
)
));
$name
=
str_replace
(
"
\\
model
\\
"
,
"
\\
validate
\\
"
,
get_class
(
$this
->
model
));
$validate
=
is_bool
(
$this
->
modelValidate
)
?
(
$this
->
modelSceneValidate
?
$name
.
'.add'
:
true
)
:
$this
->
modelValidate
;
$this
->
model
->
validate
(
$validate
);
}
...
...
public/assets/js/bootstrap-table-commonsearch.js
查看文件 @
1b08595
...
...
@@ -326,7 +326,6 @@
if
(
obj
.
size
()
>
0
)
{
var
value
=
$
(
this
).
data
(
"value"
);
if
(
obj
.
is
(
"select"
))
{
console
.
log
(
$
(
"option[value='"
+
value
+
"']"
,
obj
));
$
(
"option[value='"
+
value
+
"']"
,
obj
).
prop
(
"selected"
,
true
);
}
else
if
(
obj
.
size
()
>
1
)
{
$
(
"form [name='"
+
$
(
this
).
data
(
"field"
)
+
"'][value='"
+
value
+
"']"
,
that
.
$commonsearch
).
prop
(
"checked"
,
true
);
...
...
public/assets/js/require-backend.min.js
查看文件 @
1b08595
...
...
@@ -9192,7 +9192,6 @@ define('form',['jquery', 'bootstrap', 'upload', 'validator'], function ($, undef
if
(
obj
.
size
()
>
0
)
{
var
value
=
$
(
this
).
data
(
"value"
);
if
(
obj
.
is
(
"select"
))
{
console
.
log
(
$
(
"option[value='"
+
value
+
"']"
,
obj
));
$
(
"option[value='"
+
value
+
"']"
,
obj
).
prop
(
"selected"
,
true
);
}
else
if
(
obj
.
size
()
>
1
)
{
$
(
"form [name='"
+
$
(
this
).
data
(
"field"
)
+
"'][value='"
+
value
+
"']"
,
that
.
$commonsearch
).
prop
(
"checked"
,
true
);
...
...
@@ -9732,19 +9731,35 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
return
html
.
join
(
' '
);
},
status
:
function
(
value
,
row
,
index
)
{
//颜色状态数组,可使用red/yellow/aqua/blue/navy/teal/olive/lime/fuchsia/purple/maroon
var
colorArr
=
{
normal
:
'success'
,
hidden
:
'grey'
,
deleted
:
'danger'
,
locked
:
'info'
};
//如果字段列有定义custom
var
custom
=
{
normal
:
'success'
,
hidden
:
'gray'
,
deleted
:
'danger'
,
locked
:
'info'
};
if
(
typeof
this
.
custom
!==
'undefined'
)
{
c
olorArr
=
$
.
extend
(
colorArr
,
this
.
custom
);
c
ustom
=
$
.
extend
(
custom
,
this
.
custom
);
}
this
.
custom
=
custom
;
this
.
icon
=
'fa fa-circle'
;
return
Table
.
api
.
formatter
.
normal
.
call
(
this
,
value
,
row
,
index
);
},
normal
:
function
(
value
,
row
,
index
)
{
var
colorArr
=
[
"primary"
,
"success"
,
"danger"
,
"warning"
,
"info"
,
"gray"
,
"red"
,
"yellow"
,
"aqua"
,
"blue"
,
"navy"
,
"teal"
,
"olive"
,
"lime"
,
"fuchsia"
,
"purple"
,
"maroon"
];
var
custom
=
{};
if
(
typeof
this
.
custom
!==
'undefined'
)
{
custom
=
$
.
extend
(
custom
,
this
.
custom
);
}
var
keys
=
typeof
this
.
searchList
===
'object'
?
Object
.
keys
(
this
.
searchList
)
:
[];
var
index
=
keys
.
indexOf
(
value
);
value
=
value
===
null
?
''
:
value
.
toString
();
var
color
=
value
&&
typeof
colorArr
[
value
]
!==
'undefined'
?
colorArr
[
value
]
:
'primary'
;
var
newValue
=
value
.
charAt
(
0
).
toUpperCase
()
+
value
.
slice
(
1
);
//渲染状态
var
html
=
'<span class="text-'
+
color
+
'"><i class="fa fa-circle"></i> '
+
__
(
newValue
)
+
'</span>'
;
var
color
=
value
&&
typeof
custom
[
value
]
!==
'undefined'
?
custom
[
value
]
:
null
;
var
display
=
index
>
-
1
?
this
.
searchList
[
value
]
:
null
;
var
icon
=
typeof
this
.
icon
!==
'undefined'
?
this
.
icon
:
null
;
if
(
!
color
)
{
color
=
index
>
-
1
&&
typeof
colorArr
[
index
]
!==
'undefined'
?
colorArr
[
index
]
:
'primary'
;
}
if
(
!
display
)
{
display
=
value
.
charAt
(
0
).
toUpperCase
()
+
value
.
slice
(
1
);
}
var
html
=
'<span class="text-'
+
color
+
'">'
+
(
icon
?
'<i class="'
+
icon
+
'"></i> '
:
''
)
+
display
+
'</span>'
;
if
(
this
.
operate
!=
false
)
{
html
=
'<a href="javascript:;" class="searchit" data-toggle="tooltip" title="'
+
__
(
'Click to search %s'
,
__
(
newValue
)
)
+
'" data-field="'
+
this
.
field
+
'" data-value="'
+
value
+
'">'
+
html
+
'</a>'
;
html
=
'<a href="javascript:;" class="searchit" data-toggle="tooltip" title="'
+
__
(
'Click to search %s'
,
display
)
+
'" data-field="'
+
this
.
field
+
'" data-value="'
+
value
+
'">'
+
html
+
'</a>'
;
}
return
html
;
},
...
...
@@ -9754,7 +9769,8 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
var
no
=
typeof
this
.
no
!==
'undefined'
?
this
.
no
:
0
;
return
"<a href='javascript:;' data-toggle='tooltip' title='"
+
__
(
'Click to toggle'
)
+
"' class='btn-change' data-id='"
+
row
.
id
+
"' data-params='"
+
this
.
field
+
"="
+
(
value
?
no
:
yes
)
+
"'><i class='fa fa-toggle-on "
+
(
value
==
yes
?
'text-'
+
color
:
'fa-flip-horizontal text-gray'
)
+
" fa-2x'></i></a>"
;
},
}
,
url
:
function
(
value
,
row
,
index
)
{
return
'<div class="input-group input-group-sm" style="width:250px;margin:0 auto;"><input type="text" class="form-control input-sm" value="'
+
value
+
'"><span class="input-group-btn input-group-sm"><a href="'
+
value
+
'" target="_blank" class="btn btn-default btn-sm"><i class="fa fa-link"></i></a></span></div>'
;
},
...
...
@@ -9772,15 +9788,19 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
return
'<a href="'
+
Fast
.
api
.
fixurl
(
url
)
+
'" class="dialogit" data-value="'
+
value
+
'" title="'
+
title
+
'">'
+
value
+
'</a>'
;
},
flag
:
function
(
value
,
row
,
index
)
{
var
that
=
this
;
value
=
value
===
null
?
''
:
value
.
toString
();
var
colorArr
=
{
index
:
'success'
,
hot
:
'warning'
,
recommend
:
'danger'
,
'new'
:
'info'
};
//如果字段列有定义custom
if
(
typeof
this
.
custom
!==
'undefined'
)
{
colorArr
=
$
.
extend
(
colorArr
,
this
.
custom
);
}
var
field
=
this
.
field
;
if
(
typeof
this
.
customField
!==
'undefined'
&&
typeof
row
[
this
.
customField
]
!==
'undefined'
)
{
value
=
row
[
this
.
customField
];
field
=
this
.
customField
;
}
//渲染Flag
var
html
=
[];
var
arr
=
value
.
split
(
','
);
...
...
@@ -9789,8 +9809,8 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
if
(
value
==
''
)
return
true
;
var
color
=
value
&&
typeof
colorArr
[
value
]
!==
'undefined'
?
colorArr
[
value
]
:
'primary'
;
value
=
value
.
charAt
(
0
).
toUpperCase
()
+
value
.
slice
(
1
);
html
.
push
(
'<span class="label label-'
+
color
+
'">'
+
__
(
value
)
+
'</span>'
);
var
display
=
typeof
that
.
searchList
!==
'undefined'
&&
typeof
that
.
searchList
[
value
]
!==
'undefined'
?
that
.
searchList
[
value
]
:
value
.
charAt
(
0
).
toUpperCase
()
+
value
.
slice
(
1
);
html
.
push
(
'<a href="javascript:;" class="searchit" data-toggle="tooltip" title="'
+
__
(
'Click to search %s'
,
display
)
+
'" data-field="'
+
field
+
'" data-value="'
+
value
+
'"><span class="label label-'
+
color
+
'">'
+
display
+
'</span></a>'
);
});
return
html
.
join
(
' '
);
},
...
...
@@ -9841,7 +9861,8 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
});
}
return
Table
.
api
.
buttonlink
(
this
,
buttons
,
value
,
row
,
index
,
'operate'
);
},
}
,
buttons
:
function
(
value
,
row
,
index
)
{
// 默认按钮组
var
buttons
=
$
.
extend
([],
this
.
buttons
||
[]);
...
...
public/assets/js/require-table.js
查看文件 @
1b08595
...
...
@@ -386,19 +386,35 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
return
html
.
join
(
' '
);
},
status
:
function
(
value
,
row
,
index
)
{
//颜色状态数组,可使用red/yellow/aqua/blue/navy/teal/olive/lime/fuchsia/purple/maroon
var
colorArr
=
{
normal
:
'success'
,
hidden
:
'grey'
,
deleted
:
'danger'
,
locked
:
'info'
};
//如果字段列有定义custom
var
custom
=
{
normal
:
'success'
,
hidden
:
'gray'
,
deleted
:
'danger'
,
locked
:
'info'
};
if
(
typeof
this
.
custom
!==
'undefined'
)
{
c
olorArr
=
$
.
extend
(
colorArr
,
this
.
custom
);
c
ustom
=
$
.
extend
(
custom
,
this
.
custom
);
}
this
.
custom
=
custom
;
this
.
icon
=
'fa fa-circle'
;
return
Table
.
api
.
formatter
.
normal
.
call
(
this
,
value
,
row
,
index
);
},
normal
:
function
(
value
,
row
,
index
)
{
var
colorArr
=
[
"primary"
,
"success"
,
"danger"
,
"warning"
,
"info"
,
"gray"
,
"red"
,
"yellow"
,
"aqua"
,
"blue"
,
"navy"
,
"teal"
,
"olive"
,
"lime"
,
"fuchsia"
,
"purple"
,
"maroon"
];
var
custom
=
{};
if
(
typeof
this
.
custom
!==
'undefined'
)
{
custom
=
$
.
extend
(
custom
,
this
.
custom
);
}
var
keys
=
typeof
this
.
searchList
===
'object'
?
Object
.
keys
(
this
.
searchList
)
:
[];
var
index
=
keys
.
indexOf
(
value
);
value
=
value
===
null
?
''
:
value
.
toString
();
var
color
=
value
&&
typeof
colorArr
[
value
]
!==
'undefined'
?
colorArr
[
value
]
:
'primary'
;
var
newValue
=
value
.
charAt
(
0
).
toUpperCase
()
+
value
.
slice
(
1
);
//渲染状态
var
html
=
'<span class="text-'
+
color
+
'"><i class="fa fa-circle"></i> '
+
__
(
newValue
)
+
'</span>'
;
var
color
=
value
&&
typeof
custom
[
value
]
!==
'undefined'
?
custom
[
value
]
:
null
;
var
display
=
index
>
-
1
?
this
.
searchList
[
value
]
:
null
;
var
icon
=
typeof
this
.
icon
!==
'undefined'
?
this
.
icon
:
null
;
if
(
!
color
)
{
color
=
index
>
-
1
&&
typeof
colorArr
[
index
]
!==
'undefined'
?
colorArr
[
index
]
:
'primary'
;
}
if
(
!
display
)
{
display
=
value
.
charAt
(
0
).
toUpperCase
()
+
value
.
slice
(
1
);
}
var
html
=
'<span class="text-'
+
color
+
'">'
+
(
icon
?
'<i class="'
+
icon
+
'"></i> '
:
''
)
+
display
+
'</span>'
;
if
(
this
.
operate
!=
false
)
{
html
=
'<a href="javascript:;" class="searchit" data-toggle="tooltip" title="'
+
__
(
'Click to search %s'
,
__
(
newValue
)
)
+
'" data-field="'
+
this
.
field
+
'" data-value="'
+
value
+
'">'
+
html
+
'</a>'
;
html
=
'<a href="javascript:;" class="searchit" data-toggle="tooltip" title="'
+
__
(
'Click to search %s'
,
display
)
+
'" data-field="'
+
this
.
field
+
'" data-value="'
+
value
+
'">'
+
html
+
'</a>'
;
}
return
html
;
},
...
...
@@ -408,7 +424,8 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
var
no
=
typeof
this
.
no
!==
'undefined'
?
this
.
no
:
0
;
return
"<a href='javascript:;' data-toggle='tooltip' title='"
+
__
(
'Click to toggle'
)
+
"' class='btn-change' data-id='"
+
row
.
id
+
"' data-params='"
+
this
.
field
+
"="
+
(
value
?
no
:
yes
)
+
"'><i class='fa fa-toggle-on "
+
(
value
==
yes
?
'text-'
+
color
:
'fa-flip-horizontal text-gray'
)
+
" fa-2x'></i></a>"
;
},
}
,
url
:
function
(
value
,
row
,
index
)
{
return
'<div class="input-group input-group-sm" style="width:250px;margin:0 auto;"><input type="text" class="form-control input-sm" value="'
+
value
+
'"><span class="input-group-btn input-group-sm"><a href="'
+
value
+
'" target="_blank" class="btn btn-default btn-sm"><i class="fa fa-link"></i></a></span></div>'
;
},
...
...
@@ -426,15 +443,19 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
return
'<a href="'
+
Fast
.
api
.
fixurl
(
url
)
+
'" class="dialogit" data-value="'
+
value
+
'" title="'
+
title
+
'">'
+
value
+
'</a>'
;
},
flag
:
function
(
value
,
row
,
index
)
{
var
that
=
this
;
value
=
value
===
null
?
''
:
value
.
toString
();
var
colorArr
=
{
index
:
'success'
,
hot
:
'warning'
,
recommend
:
'danger'
,
'new'
:
'info'
};
//如果字段列有定义custom
if
(
typeof
this
.
custom
!==
'undefined'
)
{
colorArr
=
$
.
extend
(
colorArr
,
this
.
custom
);
}
var
field
=
this
.
field
;
if
(
typeof
this
.
customField
!==
'undefined'
&&
typeof
row
[
this
.
customField
]
!==
'undefined'
)
{
value
=
row
[
this
.
customField
];
field
=
this
.
customField
;
}
//渲染Flag
var
html
=
[];
var
arr
=
value
.
split
(
','
);
...
...
@@ -443,8 +464,8 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
if
(
value
==
''
)
return
true
;
var
color
=
value
&&
typeof
colorArr
[
value
]
!==
'undefined'
?
colorArr
[
value
]
:
'primary'
;
value
=
value
.
charAt
(
0
).
toUpperCase
()
+
value
.
slice
(
1
);
html
.
push
(
'<span class="label label-'
+
color
+
'">'
+
__
(
value
)
+
'</span>'
);
var
display
=
typeof
that
.
searchList
!==
'undefined'
&&
typeof
that
.
searchList
[
value
]
!==
'undefined'
?
that
.
searchList
[
value
]
:
value
.
charAt
(
0
).
toUpperCase
()
+
value
.
slice
(
1
);
html
.
push
(
'<a href="javascript:;" class="searchit" data-toggle="tooltip" title="'
+
__
(
'Click to search %s'
,
display
)
+
'" data-field="'
+
field
+
'" data-value="'
+
value
+
'"><span class="label label-'
+
color
+
'">'
+
display
+
'</span></a>'
);
});
return
html
.
join
(
' '
);
},
...
...
@@ -495,7 +516,8 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
});
}
return
Table
.
api
.
buttonlink
(
this
,
buttons
,
value
,
row
,
index
,
'operate'
);
},
}
,
buttons
:
function
(
value
,
row
,
index
)
{
// 默认按钮组
var
buttons
=
$
.
extend
([],
this
.
buttons
||
[]);
...
...
请
注册
或
登录
后发表评论