fastadmin 打开新串口 ajax传参

        lock_list: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'chip_cupboard/chip_cupboard/lock_list',
                    table: 'chip_lock',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search:false,
                commonSearch: false,
                showExport: false,
                showColumns: false,
                columns: [
                    [
                        // {checkbox: true},
                        {field: 'id', title: __('Id'), sortable: true},
                        {field: 'sid', title: __('锁id(柜子id)'), operate: 'LIKE'},
                        {field: 'open_lock', title: __('开锁指令'), operate: 'LIKE'},
                        {field: 'status_lock', title: __('查询锁指令'),  operate: 'LIKE'},
                        {field: 'chip_id', title: __('开锁指令'), operate: 'LIKE'},
                        {field: 'order_id', title: __('查询锁指令'),  operate: 'LIKE'},
                        {field: 'load_time', title: __('更新时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {field: 'pick_time', title: __('更新时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {field: 'check_status', title: __('更新时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {field: 'code_src', title: __('更新时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {field: 'status', title: __('更新时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {field: 'createtime', title: __('更新时间'), 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}
                    ]
                ],
                queryParams: function (params) {
                    console.log(params);
                    // 自定义搜索条件
                    var filter = params.filter ? JSON.parse(params.filter) : {};
                    var op = params.op ? JSON.parse(params.op) : {};
                    //filter.后跟的是在ajax里使用的名称只需修改这两行
                    filter.chip_id = Config.chip_id;
                    //opop后跟的也是ajax里使用的名称,后面是条件
                    // op.id = '=';
                    params.filter = JSON.stringify(filter);
                    params.op = JSON.stringify(op);
                    // console.log(params);
                    return params;
                },
                showToggle: false   //关闭切换按钮
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },

PHP 接收参数代码

    public function lock_list()
    {
        $chip_id = $this->request->get('chip_id');

        $this->request->filter(['strip_tags', 'trim']);
        if ($this->request->isAjax()) {
            //如果发送的来源是Selectpage,则转发到Selectpage
            if ($this->request->request('keyField')) {
                return $this->selectpage();
            }

            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
            $filter = $this->request->get('filter');
            $chip_id = json_decode($filter,true);
            $list = $this->chiplock->where($chip_id)->paginate($limit)->toArray();
//            if($list['data']){
//                foreach ($list['data'] as &$value){
//                    $value['service_name'] = ServiceCell::where(['id' => $value['serving_cell_id']])->value('name');
//                }
//            }
            $result = array("total" => $list['total'], "rows" => $list['data']);
            return json($result);
        }

        $this->assignconfig('chip_id',$chip_id);
        return $this->view->fetch('locklist');
    }

 

posted @ 2023-11-20 10:13  blog_zss小帅-博客猿  阅读(345)  评论(0编辑  收藏  举报