zoukankan      html  css  js  c++  java
  • 自定义弹窗

    • 按钮

    •   {
                                    field: 'buttons',
                                     "120px",
                                    title: __('按钮组'),
                                    table: table,
                                    events: Table.api.events.operate,
                                    buttons: [
                                        {
                                            name: 'fahuo',
                                            text: __('发货'),
                                            title: __('发货'),
                                            // classname: 'btn btn-xs btn-primary btn-dialog',
                                            classname: 'btn btn-xs btn-warning btn-dialog',
                                            icon: 'fa fa-list',
                                            url: 'jifen/jifenorders/fahuo',
                                            callback: function (data) {
                                                Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
                                            },
                                            visible: function (row) {
                                                //返回true时按钮显示,返回false隐藏
                                                return true;
                                            }
                                        }
                                    ],
                                    formatter: Table.api.formatter.buttons
                                }
      
    • js绑定事件

    •   fahuo: function () {
                    Controller.api.bindevent();
                },
      
    • 控制器

    •   public function fahuo($ids)
            {
                $row = $this->model->get(['id' => $ids]);
                if (!$row) {
                    $this->error(__('No Results were found'));
                }
                if ($this->request->isPost()) {
                    $params = $this->request->post("row/a");
                    if ($params) {
                        $params = $this->preExcludeFields($params);
                        $result = false;
                        Db::startTrans();
                        try {
                            //是否采用模型验证
        //                    if ($this->modelValidate) {
        //                        $name = str_replace("\model\", "\validate\", get_class($this->model));
        //                        $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.silver' : $name) : $this->modelValidate;
        //                        $row->validateFailException(true)->validate($validate);
        //                    }
                            $result = $row->allowField(true)->save($params);
                            Db::commit();
                        } catch (ValidateException $e) {
                            Db::rollback();
                            $this->error($e->getMessage());
                        } catch (PDOException $e) {
                            Db::rollback();
                            $this->error($e->getMessage());
                        } catch (Exception $e) {
                            Db::rollback();
                            $this->error($e->getMessage());
                        }
                        if ($result !== false) {
                            $this->success();
                        } else {
                            $this->error(__('No rows were updated'));
                        }
                    }
                    $this->error(__('Parameter %s can not be empty', ''));
                }
        
                $res=$row->toArray();
                $this->view->assign("order_id", $res['order_id']);
                $this->view->assign("row", $res);
                return $this->view->fetch();
            }
      
    • 页面

    •   <form id="silver-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
        
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">{:__('kuaidi')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <input id="c-kuaidi" class="form-control" name="row[kuaidi]" type="text" value="{$row.kuaidi|htmlentities}">
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">{:__('danhao')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <input id="c-danhao" class="form-control" name="row[danhao]" type="text" value="{$row.danhao|htmlentities}">
                </div>
            </div>
        
            <div class="form-group layer-footer">
                <label class="control-label col-xs-12 col-sm-2"></label>
                <div class="col-xs-12 col-sm-8">
                    <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
                    <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
                </div>
            </div>
        </form>
      
  • 相关阅读:
    dispatchTouchEvent
    Android中的dispatchTouchEvent()、onInterceptTouchEvent()和onTouchEvent()
    PHP在线提交留言直接发到邮箱
    php表单提交并发送邮件给某个邮箱(示例源码)
    使用 video.js 开发 HTML5 视频页面
    php匹配图片、视频文件、音乐文件的正则表达式
    HTML5的Video标签的属性,方法和事件汇总
    HTML5 Audio/Video 标签,属性,方法,事件汇总 (转)
    URL重写
    求助,后台跳转至前台,如何实现,谢谢
  • 原文地址:https://www.cnblogs.com/bufeetu/p/13968542.html
Copyright © 2011-2022 走看看