EasyUI 动态创建对话框Dialog

// 拒绝审批通过
function rejectApproval() {
    // 创建填写审批意见对话框
    $("<div id='reject-comment'> </div>").dialog({
        title: '请填写拒绝审批通过意见',
        closable: true,
        width: 350,
        height: 250,
        content: "<textarea id='input-comment' />",
        buttons: [{
            text: '确定',
            iconCls: 'icon-ok',
            handler: function () {
                if (canEdit == true) {
                    var year = parseInt($('#queryYear').numberbox('getValue'));
                    var month = parseInt($('#queryMonth').numberbox('getValue'));
                    var comment = $('#input-comment').val();

                    // 审批意见可能较长,不适合拼接在url中,使用表单传输
                    var fd = new FormData();
                    fd.append("comment", comment);

                    // 后台处理数据时先显示一个提示框,防止用户多次点击【保存】重复提交数据
                    $.messager.progress({
                        title: '提示',
                        msg: '正在保存,请稍候……',
                    });

                    $.ajax({
                        type: "delete",
                        url: '/api/Approval?year=' + year + '&month=' + month,
                        processData: false,
                        contentType: false,
                        data: fd,
                        success: function (data) {
                            if (!data.State) {
                                $.messager.alert('错误', data.Data, 'warning');
                            } else {
                                $('#dg').datagrid('reload');
                                editRow = -1;
                                $('#reject-comment').dialog('destroy');
                            }

                            $('#dg').datagrid('unselectAll');
                        },
                        error: function () {
                            $.messager.alert('警告', data.Data, 'info');
                            $('#dg').datagrid('unselectAll');
                        }
                    });
                }
            }
        }, {
            text: '取消',
            iconCls: 'icon-cancel',
            // 点击“取消”按钮,销毁对话框
            handler: function () {
                $('#reject-comment').dialog('destroy');
            }
        }],
        // 点击右上角的“X”图标时
        onClose: function () {
            $(this).dialog('destroy');
        }
    });
}

界面是酱紫滴……
这里写图片描述


PS:记几个 dialog 的用法

  • 获取 dialog 宽高
$('#dlg').dialog('panel').width();
$('#dlg').dialog('panel').height();
  • 更改 dialog 的弹出位置
    在弹出 dialog 的时候不用 $('#dialogDiv').dialog('open'); 打开。用 $('#dialogDiv').window('open'); 打开。再用 windowresize 方法重新布局即可。
var top = 200;
var left = window.innerWidth / 2 - $('#dlg').dialog('panel').width() / 2;
$('#dialogDiv').window('open').window('resize',{width:'250px', height:'500px', top: top, left: left});
发布了70 篇原创文章 · 获赞 39 · 访问量 29万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章