SelectGridWindow.jsp 4.91 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page pageEncoding="UTF-8"%>
<%@include file="/nui/common.jsp"%>
<html>
<!-- 
  - Author(s): JFree
  - Date: 2013-03-11 16:40:23
  - Description:
-->
<head>
    <title></title>
    <style type="text/css">
    body{
        margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;
    }
    </style>
</head>
<body>
    <div class="nui-toolbar" style="text-align:center;line-height:30px;" borderStyle="border:0;">
          <label>名称:</label>
          <input id="key" class="nui-textbox" style="width:150px;" onenter="onKeyEnter"/>
          <a class="nui-button" style="width:60px;" onclick="search()">查询</a>
    </div>
    <div class="nui-fit">
        <div id="grid1" class="nui-datagrid" style="width:100%;height:100%;" 
            idField="id"
            borderStyle="border-left:0;border-right:0;" onrowdblclick="onRowDblClick">
            <div property="columns">
                <div type="indexcolumn"></div>
                <div field="id" width="120" headerAlign="center">ID</div>    
                <div field="code" width="100%" headerAlign="center">编码</div>                                            
                <div field="locationCode" width="100" headerAlign="center">位置编码</div>                
            </div>
        </div>
    </div>                
    <div class="nui-toolbar" style="text-align:center;padding-top:8px;padding-bottom:8px;" borderStyle="border:0;">
        <a class="nui-button" style="width:60px;" onclick="onOk()">确定</a>
        <span style="display:inline-block;width:25px;"></span>
        <a class="nui-button" style="width:60px;" onclick="onCancel()">取消</a>
    </div>
    
    <script type="text/javascript">
        nui.parse();
    
        var grid = nui.get("grid1");
    
        // 动态设置URL
        var url = "com.huaheng.wms.wmsinventorydetailbiz.containerQuery.biz.ext";
        
        function loadData(params) {
            params = params || {};
            nui.ajax({
                url: url,
                type: 'post',
                contentType: 'application/json',
                data: JSON.stringify(params),
                success: function (data) {
                    if (data && data.containers) {
                        grid.setData(data.containers);
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    console.error("Error occurred: " + textStatus);
                }
            });
        }
    
        function GetData() {
            var row = grid.getSelected();
            return row;
        }
    
        function search() {
            var key = nui.get("key").getValue();
            loadData({ key: key });
        }
    
        function onKeyEnter(e) {
            search();
        }
    
        function onRowDblClick(e) {
            onOk();
        }
    
        function CloseWindow(action) {
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }
    
        function onOk() {            
                var rows = grid.getSelecteds();
    if (rows.length > 0) {
        nui.confirm("确定出库选中空容器?", "系统提示", function(action) {
            if (action == "ok") {
                var json = nui.encode({ wmsContainers: rows });
                grid.loading("正在执行中,请稍等...");
                $.ajax({
                    url: "com.huaheng.wms.wmstaskheaderbiz.createEmptyOut.biz.ext",
                    type: 'POST',
                    data: json,
                    cache: false,
                    contentType: 'application/json',
                    success: function(returnJson) {
                        console.log(returnJson); // 输出返回的 JSON 数据,以便调试
                        if (returnJson && returnJson.exception && returnJson.exception.code === 200) {
                            // 执行成功
							CloseWindow("ok");
                        } else {
                            // 执行失败
                            grid.unmask();
                            nui.alert(returnJson.exception.message, "失败");
                        }
                    },
                    error: function(xhr, textStatus, errorThrown) {
                        // 请求出错的处理
                        grid.unmask();
                        nui.alert("请求出错:" + errorThrown, "失败");
                    }
                });
            }
        });
    } else {
        nui.alert("请选中一条记录!");
    }
            
            
            
            
            
            
            
            
        }
    
        function onCancel() {
            CloseWindow("cancel");
        }
    
        // 初始化时加载数据
        loadData();
    </script>
</body>
</html>