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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章