示例SQL
CREATE TABLE `fa_baiduyun_cachefile` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`user_id` int(11) NOT NULL COMMENT '用户ID',
`filesize` int(11) DEFAULT NULL COMMENT '文件大小',
`filename` varchar(500) DEFAULT NULL COMMENT '文件名字',
`files` varchar(500) DEFAULT NULL COMMENT '文件',
`createtime` datetime DEFAULT NULL COMMENT '创建时间',
`updatetime` datetime DEFAULT NULL COMMENT '更新时间',
`deletetime` datetime DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='百度云缓存文件表';
1、字段为时间类型
参考资料:https://ask.fastadmin.net/question/6157.html
因为fastamdin默认是int,很不爽,想在数据库保存的是 2021-05-09 13:40:09 这种形式。
`createtime` datetime DEFAULT NULL COMMENT '创建时间',
`updatetime` datetime DEFAULT NULL COMMENT '更新时间',
`deletetime` datetime DEFAULT NULL COMMENT '删除时间',
在模型写
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
protected $dateFormat = 'Y-m-d H:i:s';
这样就可以了。
2、下拉选
参考文档:
单字段下拉选
https://doc.fastadmin.net/doc/178.html
data-field : 要显示的字段,默认值是name
data-params : 要过滤的字段,意思是过滤一下接口返回的数据。
//筛选status为normal,type为1的数据
data-params=’{“custom[status]”:”normal”,”custom[type]”:”1”}’
data-primary-key:保存到数据库的字段,默认值是id
data-source : 接口,返回json格式。建议分页
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Article_category_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-article_category_id" data-rule="required" data-field="name" data-params='{"custom[type]":"test"}' data-primary-key="id" data-source="category/selectpage" class="form-control selectpage" name="row[article_category_id]" type="text" value="">
</div>
</div>
category 的controller加上selectpage方法
/**
* Selectpage搜索
*
* @internal
*/
public function selectpage()
{
return parent::selectpage();
}