dhtmlxGrid——创建模板2

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/Content/dhtmlx/codebase/roboto.css" rel="stylesheet" />
    <link href="~/Content/dhtmlx/codebase/dhtmlx.css" rel="stylesheet" />
    <link href="~/Content/dhtmlx/skins/skyblue/dhtmlx.css" rel="stylesheet" />
    <script src="~/scripts/jquery-1.10.2.js"></script>
    <script src="~/Content/dhtmlx/codebase/dhtmlx.js"></script>
    <script src="~/Content/MES/toolbar.js"></script>
    <script src="~/Content/MES/dateFormater.js"></script>
    <title>Index</title>
    <script type="text/javascript">
        var myGrid;
        var dhxTabGridLim;
        $(document).ready(function () {
            doOnLoad();
            $("#btnSearch").click(function () {
                myGrid.clearAndLoad("../Journal/GetDataList?name=" + $("#name").val(), "js");
                //dhxTabGridLim.clearAndLoad("../Journal/GetDataListUser?id=" + $("#name").val(), "js");
                //window.top.index.closeLoading();
            });

            $("#btnSearchQuery").click(function () {

                var str = "";

                $.ajax({
                    url: "../Journal/GetPickDN",
                    type: "POST",
                    //data: { "": str },
                    success: function (res) {
                        if (res.state) {
                            alert("AAAA");
                            alert(res.msg);

                            $.ajax({
                                url: "http://172.30.7.28/uat03/api/Transaction/PostTransaction",
                                type: "POST",
                                data: { "": res.msg },
                                success: function (result) {
                                    if (result.Success)
                                        alert(result.Success);
                                    else {
                                        alert(result.Message);
                                    }
                                }
                            });
                            
                        }   
                        else
                            alert("BBBB")
                    }
                });
            });
        });
        function doOnLoad() {
            document.getElementById("tabber").style.width = "1100px";
            document.getElementById("tabber").style.height = "1000px";

            //创建页签
            var myTabbar = new dhtmlXTabBar("tabber");
            myTabbar.setSizes();

            //页签选项
            myTabbar.addTab("tabFlow", "适用流程", 200, 0, false, false);
            myTabbar.addTab("tabJournal", "日记账类型", 200, 0, true, false);

            //生成网格
            myTabbar.tabs("tabJournal").appendObject('gridbox');
            dhxTabGridLim = myTabbar.tabs("tabFlow").attachGrid();
            //myGrid = myTabbar.tabs("tabJournal").attachGrid();
            //dhxTabGridLim = myTabbar.tabs("tabFlow").attachGrid();

            //适用流程按钮
            var dhxToolBarLim = myTabbar.cells("tabFlow").attachToolbar();
            dhxToolBarLim.addButton("btnDel", 0, "删除", false, false);
            dhxToolBarLim.addButton("btnEdit", 0, "编辑", false, false);
            dhxToolBarLim.addButton("btnAdd", 0, "新增", false, false);

            dhxToolBarLim.attachEvent("onClick", function (id) {
                switch (id) {
                    case "btnDel":
                        var count = 0;
                        var ids = "";
                        dhxTabGridLim.forEachRow(function (rowId) {
                            var val = dhxTabGridLim.cells(rowId, 0).getValue();
                            if (val == 1) {
                                count += 1;
                                if (ids.length > 0)
                                    ids += ",";
                                ids += dhxTabGridLim.cells(rowId, 1).getValue();
                            }

                        });
                        if (count == 0) {
                            window.top.index.alert_warning("系统提示", "请至少选择一条记录!", "确定", null);
                        }
                        else {
                            window.top.index.confirm_warning("系统提示",
                                "确定删除选中的【" + count + "】条记录吗?",
                                function () {
                                    $.ajax({
                                        url: "../Journal/DelFlow",
                                        type: "POST",
                                        data: { ids: ids },
                                        success: function (res) {
                                            if (res.Result == 10)
                                                doOnLoad();
                                            else
                                                window.top.index.alert_warning("系统提示", res.Data, "确定", null);
                                        }
                                    });
                                },
                                function () {
                                    window.top.index.alert_warning("系统提示", "用户取消操作!", "确定", null);
                                });
                        }

                        break;
                    case "btnEdit":
                        var count = 0;
                        var sid;
                        dhxTabGridLim.forEachRow(function (rowId) {
                            var val = dhxTabGridLim.cells(rowId, 0).getValue();
                            if (val == 1) {
                                count += 1;
                                sid = dhxTabGridLim.cells(rowId, 1).getValue();
                            }
                        });
                        if (count == 0) {
                            window.top.index.alert_warning("系统提示", "请至少选择一条记录!", "确定", null);
                        } else if (count > 1) {
                            window.top.index.alert_warning("系统提示", "只能选择一条记录!", "确定", null);
                        } else {
                            window.top.index.createWindow("", "适用流程", "../Journal/EditFlow?Id=" + sid, 1280, 600, null, null);
                        }
                        break;
                    case "btnAdd":
                        //当前选中行
                        var checkIDs = myGrid.getSelectedRowId();
                        //选中行ID
                        var sid = myGrid.cells(checkIDs, 1).getValue();

                        var win = window.top.index.createWindow("",
                            "库位权限",
                            "../Journal/AddFlow?Id=" + sid,
                            1280,
                            600,
                            function () {
                                $("DataForm", ifr.contentWindow.document).submit();
                            },
                            function () {
                                window.top.index.message_err("执行取消动作!");
                            });
                        break;
                }
            });


            /***
             * 日记账资料
             *
             * */
            myGrid = new dhtmlXGridObject('gridbox');
            myGrid.selMultiRows = true;
            myGrid.setImagePath("../../../Content/dhtmlx/codebase/imgs/");
            //myGrid.setDateFormat("%Y/%m/%d");
            myGrid.setHeader(",Id,日记账类型,日记账描述,创建人,创建时间,修改人,修改时间,备注,权限角色组");
            myGrid.setColumnIds(",ID,JOURNALTYPE,JOURNALNAME,CREATE_USER,CREATE_TIME,UPDATE_USER,UPDATE_TIME,REMARK,JOURNAL_ROLENAME");
            myGrid.setInitWidths("40,100,100,100,100,100,100,100,100,300");
            myGrid.setColAlign("center,left,left,left,left,left,left,left,left,left");
            myGrid.setColTypes("ch,ed,ed,ed,ed,ed,ed,ed,ed,ed");
            myGrid.setColumnHidden(1, true);
            myGrid.enableAutoWidth(true);
            myGrid.enableAutoHeight(true);
            myGrid.enableAutoSaving(false);
            myGrid.enableEditEvents(true);
            myGrid.attachEvent("onRowSelect", function (rowId) {
                var data = myGrid.cells(rowId, 2).getValue();
                dhxTabGridLim.clearAndLoad("../Journal/GetDataListFlow?id=" + data, "js");
                //window.top.index.closeLoading();
            });
            //myGrid.attachEvent("onXLS", function () {
            //    window.top.index.openLoading();
            //});
            myGrid.init();
            myGrid.i18n.paging = {
                //results: "Results",
                records: "行记录从 ",
                to: " 到 ",
                page: "页面 ",
                perpage: "行每页",
                //first: "To first Page",
                //previous: "Previous Page",
                //found: "Found records",
                //next: "Next Page",
                //last: "To last Page",
                //of: " of ",
                notfound: "没找到记录"
            };
            myGrid.attachFooter(["<div id='grid_1_recinfoArea' style='width:100%;height:100%'></div>", "#cspan", "#cspan", "#cspan", "#cspan", "#cspan", "#cspan", "#cspan", "#cspan", "#cspan", "#cspan", "#cspan", "#cspan"], ['height:100%;text-align:left;background:transparent;border-color:white;padding:0px;']);
            myGrid.enablePaging(true, 15, 5, 'grid_1_recinfoArea');
            myGrid.setPagingSkin("toolbar", "dhx_skyblue");
            myGrid.load("../Journal/GetDataList?posStart=0&count=15", "js");
            myGrid.xmlFileUrl = "../Journal/GetDataList?name=" + $("#name").val();
            myGrid.attachEvent("onDataReady", function () {
                //window.top.index.closeLoading();

                var rowsBuffer = myGrid.rowsBuffer;
                for (var i = 0; i < rowsBuffer.length; i++) {
                    if (rowsBuffer[i] == undefined || rowsBuffer[i].data == undefined)
                        continue;
                    else {
                        var val = rowsBuffer[i].data.STATUS;
                        if (val == 10)
                            myGrid.rowsBuffer[i].data.STATUS = "启用";
                        else
                            myGrid.rowsBuffer[i].data.STATUS = "禁用";
                    }
                }
            });


            /***
             * 权限配置
             *
             * */
            dhxTabGridLim.selMultiRows = true;
            dhxTabGridLim.setImagePath("../../../Content/dhtmlx/codebase/imgs/");
            //myGrid.setDateFormat("%Y/%m/%d");
            dhxTabGridLim.setHeader(",Id,日记账类型,流程ID,默认流程,备注");
            dhxTabGridLim.setColumnIds(",ID,JOURNALTYPE,FLOWID,ISACTIVE,REMARK");
            dhxTabGridLim.setInitWidths("40,150,150,150,150,150");
            dhxTabGridLim.setColAlign("center,left,left,left,left,left");
            dhxTabGridLim.setColTypes("ch,ed,ed,ed,ed,ed");
            dhxTabGridLim.setColumnHidden(1, true);
            dhxTabGridLim.enableAutoWidth(true);
            dhxTabGridLim.enableAutoHeight(true);
            dhxTabGridLim.enableAutoSaving(false);
            dhxTabGridLim.enableEditEvents(true);

            //dhxTabGridLim.attachEvent("onXLS", function () {
            //    window.top.index.openLoading();
            //});
            dhxTabGridLim.init();
            dhxTabGridLim.i18n.paging = {
                //results: "Results",
                records: "行记录从 ",
                to: " 到 ",
                page: "页面 ",
                perpage: "行每页",
                //first: "To first Page",
                //previous: "Previous Page",
                //found: "Found records",
                //next: "Next Page",
                //last: "To last Page",
                //of: " of ",
                notfound: "没找到记录"
            };
            dhxTabGridLim.attachFooter(["<div id='grid_2_recinfoArea' style='width:100%;height:100%'></div>", "#cspan", "#cspan", "#cspan", "#cspan", "#cspan"], ['height:100%;text-align:left;background:transparent;border-color:white;padding:0px;']);
            dhxTabGridLim.enablePaging(true, 15, 5, 'grid_2_recinfoArea');
            dhxTabGridLim.setPagingSkin("toolbar", "dhx_skyblue");
            dhxTabGridLim.attachEvent("onDataReady", function () {
                //window.top.index.closeLoading();

                var rowsBuffer = dhxTabGridLim.rowsBuffer;
                for (var i = 0; i < rowsBuffer.length; i++) {
                    if (rowsBuffer[i] == undefined || rowsBuffer[i].data == undefined)
                        continue;
                    else {
                        var val = rowsBuffer[i].data.ISACTIVE;
                        if (val == 10)
                            dhxTabGridLim.rowsBuffer[i].data.ISACTIVE = "Y";
                        else
                            dhxTabGridLim.rowsBuffer[i].data.ISACTIVE = "N";
                    }
                }
            });
        }

        function getData() {
            var journaltype = $("#name").val();
            var data = { journaltype: journaltype };
            return data;
        }

        function GetFile(fileName) {
            window.location.href = "../Location/GetExportFile?fileName=" + fileName;
        }

        function checkStatus(operation) {
            return true;
        }
    </script>
</head>
<body class="form-inline container-fluid" style="overflow-y:auto; overflow-x:auto;">
    <table cellpadding="0" cellspacing="0" style="overflow-x: auto; clear:both;">
        <tr>
            <td>
                <div class="dhxform_obj_dhx_skyblue" style="font-size:12px;">
                    <div class="dhxform_base">
                        <div class="dhxform_item_label_left">
                            <div class="dhxform_label dhxform_label_align_left" style="font-weight:normal;">
                                <label>日记账类型:</label>
                            </div>
                            <div class="dhxform_control">
                                <input type="text" id="name" />
                            </div>
                        </div>
                    </div>
                    <div class="dhxform_base">
                        <div class="dhxform_item_label_left">
                            <div class="dhxform_btn" id="btnSearch" style="margin:-2px 5px 5px 5px;">
                                <div class="dhxform_btn_txt">查询</div>
                                <div class="dhxform_btn_filler" disabled="true"></div>
                            </div>
                        </div>
                    </div>

                    @*<div class="dhxform_base">
                        <div class="dhxform_item_label_left">
                            <div class="dhxform_btn" id="btnSearchQuery" style="margin:-2px 5px 5px 5px;">
                                <div class="dhxform_btn_txt">查询2</div>
                                <div class="dhxform_btn_filler" disabled="true"></div>
                            </div>
                        </div>
                    </div>*@
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div id="gridbox"></div>
            </td>
        </tr>

        <tr>
            <td>
                <div id="tabber"></div>
            </td>
        </tr>

        @*<tr>
            <td>
                <div id="recinfoArea"></div>
            </td>
        </tr>*@
    </table>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值