提交者
Karson
改进build_toolbar的import支持模版下载
正在显示
2 个修改的文件
包含
35 行增加
和
3 行删除
@@ -113,7 +113,7 @@ if (!function_exists('build_toolbar')) { | @@ -113,7 +113,7 @@ if (!function_exists('build_toolbar')) { | ||
113 | 'add' => ['javascript:;', 'btn btn-success btn-add', 'fa fa-plus', __('Add'), __('Add')], | 113 | 'add' => ['javascript:;', 'btn btn-success btn-add', 'fa fa-plus', __('Add'), __('Add')], |
114 | 'edit' => ['javascript:;', 'btn btn-success btn-edit btn-disabled disabled', 'fa fa-pencil', __('Edit'), __('Edit')], | 114 | 'edit' => ['javascript:;', 'btn btn-success btn-edit btn-disabled disabled', 'fa fa-pencil', __('Edit'), __('Edit')], |
115 | 'del' => ['javascript:;', 'btn btn-danger btn-del btn-disabled disabled', 'fa fa-trash', __('Delete'), __('Delete')], | 115 | 'del' => ['javascript:;', 'btn btn-danger btn-del btn-disabled disabled', 'fa fa-trash', __('Delete'), __('Delete')], |
116 | - 'import' => ['javascript:;', 'btn btn-danger btn-import', 'fa fa-upload', __('Import'), __('Import')], | 116 | + 'import' => ['javascript:;', 'btn btn-info btn-import', 'fa fa-upload', __('Import'), __('Import')], |
117 | ]; | 117 | ]; |
118 | $btnAttr = array_merge($btnAttr, $attr); | 118 | $btnAttr = array_merge($btnAttr, $attr); |
119 | $html = []; | 119 | $html = []; |
@@ -123,8 +123,39 @@ if (!function_exists('build_toolbar')) { | @@ -123,8 +123,39 @@ if (!function_exists('build_toolbar')) { | ||
123 | continue; | 123 | continue; |
124 | } | 124 | } |
125 | list($href, $class, $icon, $text, $title) = $btnAttr[$v]; | 125 | list($href, $class, $icon, $text, $title) = $btnAttr[$v]; |
126 | - $extend = $v == 'import' ? 'id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"' : ''; | ||
127 | - $html[] = '<a href="' . $href . '" class="' . $class . '" title="' . $title . '" ' . $extend . '><i class="' . $icon . '"></i> ' . $text . '</a>'; | 126 | + //$extend = $v == 'import' ? 'id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"' : ''; |
127 | + //$html[] = '<a href="' . $href . '" class="' . $class . '" title="' . $title . '" ' . $extend . '><i class="' . $icon . '"></i> ' . $text . '</a>'; | ||
128 | + if ($v == 'import') { | ||
129 | + $template = str_replace('/', '_', $controller); | ||
130 | + $download = ''; | ||
131 | + if (file_exists("./template/{$template}.xlsx")) { | ||
132 | + $download .= "\n <li><a href=\"/template/{$template}.xlsx\" target=\"_blank\">XLSX模版</a></li>"; | ||
133 | + } | ||
134 | + if (file_exists("./template/{$template}.xls")) { | ||
135 | + $download .= "\n <li><a href=\"/template/{$template}.xls\" target=\"_blank\">XLS模版</a></li>"; | ||
136 | + } | ||
137 | + if (file_exists("./template/{$template}.csv")) { | ||
138 | + $download .= empty($download) ? '' : "\n <li class=\"divider\"></li>"; | ||
139 | + $download .= "\n <li><a href=\"/template/{$template}.csv\" target=\"_blank\">CSV模版</a></li>"; | ||
140 | + } | ||
141 | + $download .= empty($download) ? '' : "\n "; | ||
142 | + if (!empty($download)) { | ||
143 | + $html[] = <<<EOT | ||
144 | + <div class="btn-group"> | ||
145 | + <button type="button" href="{$href}" class="btn btn-info btn-import" title="{$title}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="{$icon}"></i> {$text}</button> | ||
146 | + <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" title="下载批量导入模版"> | ||
147 | + <span class="caret"></span> | ||
148 | + <span class="sr-only">Toggle Dropdown</span> | ||
149 | + </button> | ||
150 | + <ul class="dropdown-menu" role="menu">{$download}</ul> | ||
151 | + </div> | ||
152 | +EOT; | ||
153 | + } else { | ||
154 | + $html[] = '<a href="' . $href . '" class="' . $class . '" title="' . $title . '" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="' . $icon . '"></i> ' . $text . '</a>'; | ||
155 | + } | ||
156 | + } else { | ||
157 | + $html[] = '<a href="' . $href . '" class="' . $class . '" title="' . $title . '"><i class="' . $icon . '"></i> ' . $text . '</a>'; | ||
158 | + } | ||
128 | } | 159 | } |
129 | return implode(' ', $html); | 160 | return implode(' ', $html); |
130 | } | 161 | } |
public/template/.gitkeep
0 → 100644
1 | + |
-
请 注册 或 登录 后发表评论