当前位置:   article > 正文

thinkcmf5默认后台模版文件资源管理修改_thinkcmf默认模板 怎么修改

thinkcmf默认模板 怎么修改

 

直接修改这个两个文件即可,如果没效果,将data\runtime里面的缓存文件删除即可

模板文件路径:

目录\public\themes\admin_simpleboot3\user\admin_asset\index.html

  1. <include file="public@header"/>
  2. </head>
  3. <body>
  4. <div class="wrap js-check-wrap">
  5.     <ul class="nav nav-tabs">
  6.         <li class="active"><a href="{:url('AdminAsset/index')}">资源列表</a></li>
  7.     </ul>
  8.     <!--新增搜索框-->
  9.     <form class="well form-inline margin-top-20" method="post" action="{:url('AdminAsset/search',array())}"> 
  10.         <input type="text" class="form-control" name="filename" style="width: 200px;" value="" placeholder="请输入关键字...">
  11.         <input type="submit" class="btn btn-primary" value="搜索">
  12.         <a class="btn btn-danger" href="{:url('AdminAsset/index')}">清空</a>
  13.     </form>
  14.     <!--新增功能按钮-->
  15.      <form  class="js-ajax-form" action="" method="post" novalidate="novalidate">
  16.     <div class="table-actions">
  17.         <a class="btn btn-sm btn-info" href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');" >图片上传</a>
  18.         <a class="btn btn-sm btn-warning" href="javascript:uploadMultiFile('附件上传','#files','files-item-tpl','file');">文件上传</a>
  19.         <button class="btn btn-sm btn-danger  js-ajax-submit" type="submit" data-action="{:url('AdminAsset/Multidelete',array())}" data-subcheck="true" data-msg="您确定删除吗?">批量删除</button>
  20.     </div>
  21.     
  22.     <php>$status=['不可用', '可用'];</php>
  23.     <table class="table table-hover table-bordered margin-top-20">
  24.         <thead>
  25.         <tr>
  26.             <th width="50"><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></th>
  27.             <th width="50">ID</th>
  28.             <th>用户</th>
  29.             <th>文件大小</th>
  30.             <th>文件名</th>
  31.             <th>图像</th>
  32.             <th>文件路径</th>
  33.             <th>状态</th>
  34.             <th width="160">{:lang('ACTIONS')}</th>
  35.         </tr>
  36.         </thead>
  37.         <tbody>
  38.         <php>
  39.             $asset_img_suffixes=['bmp','jpg','jpeg','png','gif','tiff'];/*TODO ADD MORE*/
  40.         </php>
  41.         
  42.         <foreach name="assets" item="vo">
  43.             <tr>
  44.                 <td>
  45.                 <input type="checkbox" class="js-check" name="id[]" data-yid="js-check-y" data-xid="js-check-x"  value="{$vo.id}" title="ID:{$vo.id}"></td>
  46.                 <td>{$vo.id}</td>
  47.                 <td>
  48.                     用户ID:{$vo.user_id} {$vo.user_login} {$vo.user_nickname}
  49.                 </td>
  50.                 <td>{$vo.file_size/1024|round}KB</td>
  51.                 <td>{$vo.filename}</td>
  52.                 <td>
  53.                     <if condition="in_array(strtolower($vo['suffix']),$asset_img_suffixes)">
  54.                         <a href="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo['file_path'])}');">
  55.                             <i class="fa fa-photo fa-fw"></i>
  56.                         </a>
  57.                     </if>
  58.                 </td>
  59.                 <td>
  60.                     {$vo.file_path}
  61.                     <if condition="!file_exists('upload/'.$vo['file_path'])">
  62.                         <span style='color:red;'>&nbsp;&nbsp(文件丢失)</span>
  63.                     </if>
  64.                 </td>
  65.                 <td>{$status[$vo['status']]}</td>
  66.                 <td>
  67.                     <a href="{:url('AdminAsset/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">{:lang('DELETE')}</a>
  68.                 </td>
  69.             </tr>
  70.         </foreach>
  71.         </tbody>
  72.     </table>
  73.     <div class="pagination">{$page|default=''}</div>
  74. </form>
  75. </div>
  76. <script src="__STATIC__/js/admin.js"></script>
  77. </body>
  78. </html>
  79. <!--多图片上传模板-->
  80. <div class="col-md-6 col-sm-10" id="photos"><div>
  81. <img  id="photos-item-tpl" width="0" height="0" style="cursor: pointer">
  82. <!--多图片上传模板-->
  83. <!--多文件上传模板-->
  84. <div class="col-md-6 col-sm-10" id="files"><div>
  85. <div id="files-item-tpl"></div>
  86. <!--多文件上传模板-->

模板控制器新增方法:

目录\app\user\controller\AdminAssetController.php

  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 小夏 < 449134904@qq.com>
  10. // | 二次修改 xzw 2018/8/19
  11. // +----------------------------------------------------------------------
  12. namespace app\user\controller;
  13. use think\Db;
  14. use cmf\controller\AdminBaseController;
  15. class AdminAssetController extends AdminBaseController
  16. {
  17.     /**
  18.      * 资源管理列表
  19.      * @adminMenu(
  20.      *     'name'   => '资源管理',
  21.      *     'parent' => '',
  22.      *     'display'=> false,
  23.      *     'hasView'=> true,
  24.      *     'order'  => 10000,
  25.      *     'icon'   => 'file',
  26.      *     'remark' => '资源管理列表',
  27.      *     'param'  => ''
  28.      * )
  29.      */
  30.     public function index()
  31.     {
  32.         $join   = [
  33.             ['__USER__ u''a.user_id = u.id']
  34.         ];
  35.         $result Db::name('asset')->field('a.*,u.user_login,u.user_email,u.user_nickname')
  36.             ->alias('a')->join($join)
  37.             ->order('create_time''DESC')
  38.             ->paginate(10);
  39.         $this->assign('assets'$result->items());
  40.         $this->assign('page'$result->render());
  41.         return $this->fetch();
  42.     }
  43.     /**
  44.      * 删除文件
  45.      * @adminMenu(
  46.      *     'name'   => '删除文件',
  47.      *     'parent' => 'index',
  48.      *     'display'=> false,
  49.      *     'hasView'=> false,
  50.      *     'order'  => 10000,
  51.      *     'icon'   => '',
  52.      *     'remark' => '删除文件',
  53.      *     'param'  => ''
  54.      * )
  55.      */
  56.     public function delete()
  57.     {
  58.         $id            $this->request->param('id');
  59.         $file_filePath Db::name('asset')->where('id'$id)->value('file_path');
  60.         $file          'upload/' . $file_filePath;
  61.         $res true;
  62.         if (file_exists($file)) {
  63.             $res unlink($file);
  64.         }
  65.         if ($res) {
  66.             Db::name('asset')->where('id'$id)->delete();
  67.             $this->success('删除成功');
  68.         } else {
  69.             $this->error('删除失败');
  70.         }
  71.     }
  72.      /**
  73.      * 批量删除文件
  74.      * @adminMenu(
  75.      *     'name'   => '批量删除文件',
  76.      *     'parent' => 'index',
  77.      *     'display'=> false,
  78.      *     'hasView'=> false,
  79.      *     'order'  => 10000,
  80.      *     'icon'   => '',
  81.      *     'remark' => '批量删除文件',
  82.      *     'param'  => 'id[]'
  83.      * )
  84.      */
  85.     public function Multidelete()
  86.     {
  87.         $Aid $this->request->param()['id'];
  88.         $success=[];
  89.         $error=[];
  90.         foreach ($Aid as $id ) {
  91.             $file_filePath Db::name('asset')->where('id'$id)->value('file_path');
  92.             $file          'upload/' . $file_filePath;
  93.             $res true;
  94.             if (file_exists($file)) {
  95.                 $res unlink($file);
  96.             }
  97.             if ($res) {
  98.                 Db::name('asset')->where('id'$id)->delete();
  99.                 $success[]=['id'=>$id,'res'=>'删除成功'];
  100.             } else {
  101.                 $error[]=['id'=>$id,'res'=>'删除失败'];
  102.                 
  103.             }
  104.         }
  105.         if(count($success)>0)
  106.         {
  107.             $this->success('批量删除成功:'.count($success).",删除失败:".count($error));
  108.         }
  109.         else
  110.         {
  111.             $this->error('批量删除成功:'.count($success).",删除失败:".count($error));
  112.         }
  113.     }
  114.     /**
  115.      * 搜索文件
  116.      * @adminMenu(
  117.      *     'name'   => '搜索文件',
  118.      *     'parent' => 'index',
  119.      *     'display'=> false,
  120.      *     'hasView'=> false,
  121.      *     'order'  => 10000,
  122.      *     'icon'   => '',
  123.      *     'remark' => '搜索文件',
  124.      *     'param'  => 'filename'
  125.      * )
  126.      */
  127.     public function search()
  128.     {
  129.         $filename  trim($this->request->param('filename'));
  130.         $join   = [
  131.             ['__USER__ u''a.user_id = u.id']
  132.         ];
  133.         $where['filename']=['like',"%".$filename."%"];
  134.         $result =Db::name('asset')
  135.             ->field('a.*,u.user_login,u.user_email,u.user_nickname')
  136.             ->alias('a')->join($join)
  137.             ->order('create_time''DESC')
  138.             ->where("filename","like","%".$filename."%")
  139.             ->paginate(10);
  140.         $this->assign('assets'$result->items());
  141.         $this->assign('page'$result->render());
  142.         return $this->fetch("index");
  143.     }
  144.     
  145. }

 

PS:资源管理默认是在左上角的小图标,开启左侧菜单在

资源管理:user/AdminAsset/index

image.png

 

最终效果:

image.png

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/291288
推荐阅读
相关标签
  

闽ICP备14008679号