🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 开始使用 0. 在从数据表生成选项后下拉框里选择需要从表生成的数据表,页面会刷新,载入数据表字段 1. 页面会根据表名自动生成一个控制器名,但对于多级控制器,默认生成的控制器名是错误的,需要手动修改,然后填写后面的控制器标题 2. 删除表单元素里的不需要的字段,例如 `id` 3. 完善表单元素信息 4. 勾选需要生成的首页菜单 5. 勾选是否创建模型和验证器 6. 点击生成 ![](https://box.kancloud.cn/e5b919c6f4714b827b076e22497b901f_1838x963.png) ![](https://box.kancloud.cn/ca9637421c67758524616282f8f47d4d_1835x963.png) ![](https://box.kancloud.cn/d091535ea9bede78a05800111a7409a8_1834x260.png) ![](https://box.kancloud.cn/d6040230a1f30f9b71a5718618854e62_1840x965.png) ![](https://box.kancloud.cn/8b42f2682eb2ede5e2b36c617644e9da_1850x963.png) >[info] 以下代码、日志全部是自动生成,没有做任何修改,包括缩进,严格的缩进非常方便二次编辑和查阅 ## 生成文件 ### controller/File.php ``` <?php namespace app\admin\controller; \think\Loader::import('controller/Controller', \think\Config::get('traits_path') , EXT); use app\admin\Controller; class File extends Controller { use \app\admin\traits\controller\Controller; // 方法黑名单 protected static $blacklist = []; protected static $isdelete = false; protected function filter(&$map) { if ($this->request->param("name")) { $map['name'] = ["like", "%" . $this->request->param("name") . "%"]; } if ($this->request->param("original")) { $map['original'] = ["like", "%" . $this->request->param("original") . "%"]; } if ($this->request->param("domain")) { $map['domain'] = ["like", "%" . $this->request->param("domain") . "%"]; } if ($this->request->param("type")) { $map['type'] = ["like", "%" . $this->request->param("type") . "%"]; } } } ``` ### view/file/index.html ``` {extend name="template/base" /} {block name="content"} <div class="page-container"> <form class="mb-20" method="get" action="{:\\think\\Url::build($Request.action)}"> <input type="text" class="input-text" style="width:250px" placeholder="文件名" name="name" value="{$Request.param.name}" > <input type="text" class="input-text" style="width:250px" placeholder="原文件名" name="original" value="{$Request.param.original}" > <input type="text" class="input-text" style="width:250px" placeholder="域名" name="domain" value="{$Request.param.domain}" > <input type="text" class="input-text" style="width:250px" placeholder="文件类型" name="type" value="{$Request.param.type}" > <button type="submit" class="btn btn-success"><i class="Hui-iconfont">&#xe665;</i> 搜索</button> </form> <div class="cl pd-5 bg-1 bk-gray"> <span class="l"> {tp:menu menu="add" /} </span> <span class="r pt-5 pr-5"> 共有数据 :<strong>{$count ?? '0'}</strong> 条 </span> </div> <table class="table table-border table-bordered table-hover table-bg mt-20"> <thead> <tr class="text-c"> <th width="25"><input type="checkbox"></th> <th width="">目录</th> <th width="">文件名</th> <th width="">原文件名</th> <th width="">域名</th> <th width="">文件类型</th> <th width="">{:sort_by('文件大小','size')}</th> <th width="">{:sort_by('修改时间','mtime')}</th> <th width="70">操作</th> </tr> </thead> <tbody> {volist name="list" id="vo"} <tr class="text-c"> <td><input type="checkbox" name="id[]" value="{$vo.id}"></td> <td>{$vo.cate}</td> <td>{$vo.name|high_light=$Request.param.name}</td> <td>{$vo.original|high_light=$Request.param.original}</td> <td>{$vo.domain|high_light=$Request.param.domain}</td> <td>{$vo.type|high_light=$Request.param.type}</td> <td>{$vo.size}</td> <td>{$vo.mtime}</td> <td class="f-14"> {tp:menu menu='sedit' /} {tp:menu menu='sdeleteforever' /} </td> </tr> {/volist} </tbody> </table> <div class="page-bootstrap">{$page ?? ''}</div> </div> {/block} ``` >[info] 因为没有选择创建回收站(recyclebin.html)自动合并 th.html、td.html、form.html 到 index.html 文件中 ### view/file/edit.html ``` {extend name="template/base" /} {block name="content"} <div class="page-container"> <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}"> <input type="hidden" name="id" value="{:isset($vo.id)?$vo.id:''}"> <div class="row cl"> <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>目录:</label> <div class="formControls col-xs-6 col-sm-6"> <div class="select-box"> <select name="cate" class="select" datatype="*" nullmsg="请选择目录"> <option value=""></option> </select> </div> </div> <div class="col-xs-3 col-sm-3"></div> </div> <div class="row cl"> <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>文件名:</label> <div class="formControls col-xs-6 col-sm-6"> <input type="text" class="input-text" placeholder="文件名" name="name" value="{$vo.name ?? ''}" > </div> <div class="col-xs-3 col-sm-3"></div> </div> <div class="row cl"> <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>原文件名:</label> <div class="formControls col-xs-6 col-sm-6"> <input type="text" class="input-text" placeholder="原文件名" name="original" value="{$vo.original ?? ''}" > </div> <div class="col-xs-3 col-sm-3"></div> </div> <div class="row cl"> <label class="form-label col-xs-3 col-sm-3">域名:</label> <div class="formControls col-xs-6 col-sm-6"> <input type="text" class="input-text" placeholder="域名" name="domain" value="{$vo.domain ?? ''}" > </div> <div class="col-xs-3 col-sm-3"></div> </div> <div class="row cl"> <label class="form-label col-xs-3 col-sm-3">文件类型:</label> <div class="formControls col-xs-6 col-sm-6"> <div class="select-box"> <select name="type" class="select"> <option value=""></option> </select> </div> </div> <div class="col-xs-3 col-sm-3"></div> </div> <div class="row cl"> <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>文件大小:</label> <div class="formControls col-xs-6 col-sm-6"> <input type="number" class="input-text" placeholder="文件大小" name="size" value="{$vo.size ?? ''}" > </div> <div class="col-xs-3 col-sm-3"></div> </div> <div class="row cl"> <label class="form-label col-xs-3 col-sm-3">修改时间:</label> <div class="formControls col-xs-6 col-sm-6"> <input type="text" class="input-text" placeholder="修改时间" name="mtime" value="{$vo.mtime ?? ''}" > </div> <div class="col-xs-3 col-sm-3"></div> </div> <div class="row cl"> <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3"> <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button> <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button> </div> </div> </form> </div> {/block} {block name="script"} <script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script> <script> $(function () { $("[name='cate']").find("[value='{$vo.cate ?? ''}']").attr("selected", true); $("[name='type']").find("[value='{$vo.type ?? ''}']").attr("selected", true); $('.skin-minimal input').iCheck({ checkboxClass: 'icheckbox-blue', radioClass: 'iradio-blue', increaseArea: '20%' }); $("#form").Validform({ tiptype: 2, ajaxPost: true, showAllError: true, callback: function (ret){ ajax_progress(ret); } }); }) </script> {/block} ``` ### view/file/config.php ``` <?php return array ( 'module' => 'admin', 'menu' => array ( 0 => 'add', ), 'create_config' => true, 'controller' => 'File', 'title' => '文件', 'form' => array ( 2 => array ( 'title' => '目录', 'name' => 'cate', 'type' => 'select', 'option' => '', 'default' => '', 'search_type' => 'text', 'require' => '1', 'validate' => array ( 'datatype' => '*', 'nullmsg' => '', 'errormsg' => '', ), ), 3 => array ( 'title' => '文件名', 'name' => 'name', 'type' => 'text', 'option' => '', 'default' => '', 'search' => '1', 'search_type' => 'text', 'require' => '1', 'validate' => array ( 'datatype' => '*', 'nullmsg' => '', 'errormsg' => '', ), ), 4 => array ( 'title' => '原文件名', 'name' => 'original', 'type' => 'text', 'option' => '', 'default' => '', 'search' => '1', 'search_type' => 'text', 'require' => '1', 'validate' => array ( 'datatype' => '*', 'nullmsg' => '', 'errormsg' => '', ), ), 5 => array ( 'title' => '域名', 'name' => 'domain', 'type' => 'text', 'option' => '', 'default' => '', 'search' => '1', 'search_type' => 'text', 'validate' => array ( 'datatype' => '', 'nullmsg' => '', 'errormsg' => '', ), ), 6 => array ( 'title' => '文件类型', 'name' => 'type', 'type' => 'select', 'option' => '', 'default' => '', 'search' => '1', 'search_type' => 'text', 'validate' => array ( 'datatype' => '', 'nullmsg' => '', 'errormsg' => '', ), ), 7 => array ( 'title' => '文件大小', 'name' => 'size', 'type' => 'number', 'option' => '', 'default' => '', 'sort' => '1', 'search_type' => 'text', 'require' => '1', 'validate' => array ( 'datatype' => '*', 'nullmsg' => '', 'errormsg' => '', ), ), 8 => array ( 'title' => '修改时间', 'name' => 'mtime', 'type' => 'text', 'option' => '', 'default' => '', 'sort' => '1', 'search_type' => 'text', 'validate' => array ( 'datatype' => '', 'nullmsg' => '', 'errormsg' => '', ), ), ), ); ```