diff --git a/application/admin/common.php b/application/admin/common.php index 2b61dde6..c3232f8e 100755 --- a/application/admin/common.php +++ b/application/admin/common.php @@ -113,7 +113,7 @@ if (!function_exists('build_toolbar')) { 'add' => ['javascript:;', 'btn btn-success btn-add', 'fa fa-plus', __('Add'), __('Add')], 'edit' => ['javascript:;', 'btn btn-success btn-edit btn-disabled disabled', 'fa fa-pencil', __('Edit'), __('Edit')], 'del' => ['javascript:;', 'btn btn-danger btn-del btn-disabled disabled', 'fa fa-trash', __('Delete'), __('Delete')], - 'import' => ['javascript:;', 'btn btn-danger btn-import', 'fa fa-upload', __('Import'), __('Import')], + 'import' => ['javascript:;', 'btn btn-info btn-import', 'fa fa-upload', __('Import'), __('Import')], ]; $btnAttr = array_merge($btnAttr, $attr); $html = []; @@ -123,8 +123,39 @@ if (!function_exists('build_toolbar')) { continue; } list($href, $class, $icon, $text, $title) = $btnAttr[$v]; - $extend = $v == 'import' ? 'id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"' : ''; - $html[] = ' ' . $text . ''; + //$extend = $v == 'import' ? 'id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"' : ''; + //$html[] = ' ' . $text . ''; + if ($v == 'import') { + $template = str_replace('/', '_', $controller); + $download = ''; + if (file_exists("./template/{$template}.xlsx")) { + $download .= "\n
  • XLSX模版
  • "; + } + if (file_exists("./template/{$template}.xls")) { + $download .= "\n
  • XLS模版
  • "; + } + if (file_exists("./template/{$template}.csv")) { + $download .= empty($download) ? '' : "\n
  • "; + $download .= "\n
  • CSV模版
  • "; + } + $download .= empty($download) ? '' : "\n "; + if (!empty($download)) { + $html[] = << + + + + +EOT; + } else { + $html[] = ' ' . $text . ''; + } + } else { + $html[] = ' ' . $text . ''; + } } return implode(' ', $html); } diff --git a/public/template/.gitkeep b/public/template/.gitkeep new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/public/template/.gitkeep @@ -0,0 +1 @@ +