fastadmin+workman环境搭建

发布于:2025-06-06 ⋅ 阅读:(28) ⋅ 点赞:(0)

一、出现错误

从git拉取到本地在配置网址登录后出现 unserialize(): Error at offset 0 of 17039 bytes

参考:https://blog.csdn.net/yqwwj001/article/details/88688675

找到 \thinkphp\library\think\cache\driver\Flie.php 中的

$content = substr($content, 17071);

二、启动workman

正式运行时关闭debug模式

    $mqtt = new Workerman\Mqtt\Client('mqtt://8.152.162.33:1883', array(
        'debug' => true,
        "username"=>"admin", "password"=>"ssss"
    ));

三、增加搜索

<?php

namespace app\admin\controller\example;

use app\common\controller\Backend;

/**
 * 自定义搜索
 *
 * @icon fa fa-search
 * @remark 自定义列表的搜索
 */
class Customsearch extends Backend
{
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = model('Zhonglvt');
        $ipList = $this->model->whereTime('createtime', '-37 days')->group("topic")->column("topic,topic as aa");
        $this->view->assign("ipList", $ipList);
    }
}

model也需要增加

<?php

namespace app\admin\model;

use app\admin\library\Auth;
use think\Model;
use think\Loader;

class Zhonglvt extends Model
{

    

    

    // 表名
    protected $name = 'Zhonglv_t';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = TRUE;

    // 定义时间戳字段名
    protected $createTime = TRUE;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];
    

<div class="panel panel-default panel-intro">
    {:build_heading()}

    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="one">
                <div class="widget-body no-padding">
                    <div id="toolbar" class="toolbar">
                        {:build_toolbar('refresh')}
                    </div>
                    <table id="table" class="table table-striped table-bordered table-hover" width="100%">

                    </table>

                </div>
            </div>

        </div>
    </div>
</div>

<script id="customformtpl" type="text/html">
    <!--form表单必须添加form-commsearch这个类-->
    <form action="" class="form-commonsearch">
        <div style="border-radius:2px;margin-bottom:10px;background:#f5f5f5;padding:15px 20px;">
            <h4>历史记录查询</h4>
            <hr>
            <div class="row">


                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="form-group">
                        <label class="control-label">搜索时间</label>
                        <input type="hidden" class="operate" data-name="createtime" value="RANGE"/>
                        <div>
                        <input type="text" class="form-control datetimerange" name="createtime" value=""/>
                        </div>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="form-group">
                        <label class="control-label"></label>
                        <div class="row">
                            <div class="col-xs-6">
                                <input type="submit" class="btn btn-success btn-block" value="提交"/>
                            </div>
                            <div class="col-xs-6">
                                <input type="reset" class="btn btn-primary btn-block" value="重置"/>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</script>

define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {
        index: function () {
            //
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'example/customsearch/index',
                    add_url: 'example/customsearch/add',
                    edit_url: '',
                    del_url: 'example/customsearch/del',
                    multi_url: 'example/customsearch/multi',
                    table: '',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                searchFormVisible: true,
                searchFormTemplate: 'customformtpl',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: 'ID', operate: false},
                        {field: 'topic', title: __('Topic'), operate:'BETWEEN'},
                        {field: 'T0', title: __('T0'), operate:'BETWEEN'},
                        {field: 'T1', title: __('T1'), operate:'BETWEEN'},
                        {field: 'T2', title: __('T2'), operate:'BETWEEN'},
                        {field: 'T3', title: __('T3'), operate:'BETWEEN'},
                        {field: 'T4', title: __('T4'), operate:'BETWEEN'},
                        {field: 'T5', title: __('T5'), operate:'BETWEEN'},
                        {field: 'T6', title: __('T6'), operate:'BETWEEN'},
                        {field: 'T7', title: __('T7'), operate:'BETWEEN'},
                        {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});

四、一键CURD生成

需要刷新的话

define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'ai40/index' + location.search,
                    add_url: 'ai40/add',
                    edit_url: 'ai40/edit',
                    del_url: 'ai40/del',
                    multi_url: 'ai40/multi',
                    import_url: 'ai40/import',
                    table: 'ai40',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'topic', title: __('Topic'), operate: 'LIKE'},
                        {field: 'FW_AI_0.varValue', title: __('温0')},
                        {field: 'FW_AI_1.varValue', title: __('温1')},
                        {field: 'FW_AI_2.varValue', title: __('温2')},
                        {field: 'FW_AI_3.varValue', title: __('温3')},
                        {field: 'FW_AI_4.varValue', title: __('温4')},
                        {field: 'FW_AI_5.varValue', title: __('温5')},
                        {field: 'FW_AI_6.varValue', title: __('温6')},
                        {field: 'FW_AI_7.varValue', title: __('温7')},
                        {field: 'pubdata', title: __('Pubdata'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});

setInterval( function()  {
	$(".btn-refresh").click();//9000表示9秒刷新列表
}, 9000);


网站公告

今日签到

点亮在社区的每一天
去签到