智云srmLayUi(安瑞和瑞琪)(通用版本)
yusijie
2025-06-29 c069cda9561a17bc2f036cb528bac21b1a7b0df9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>物料列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-card">
            <!--<div class="layui-card-header"></div>-->
            <div class="layui-card-body" style="padding: 15px;">
                <form class="layui-form" action="" lay-filter="component-form-group">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">过滤列</label>
                            <div class="layui-input-inline">
                                <input type="text" name="Value" id="Value" lay-verify="Value" autocomplete="off" placeholder="请输入过滤列" class="layui-input">
                            </div>
                            <button type="button" lay-submit="" class="layui-btn" lay-filter="HQuery">快速查询</button>
                            <button type="button" lay-submit="" class="layui-btn" lay-filter="FH">返回</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
    <script src="../../layuiadmin/layui/layui.js" charset="utf-8"></script>
    <script src="../../../../Scripts/webConfig.js"></script>
    <script>
        layui.use(['table', 'form', 'layer'], function () {
            var table = layui.table
                , form = layui.form
                , layer = layui.layer
                , $ = layui.$;
 
            form.on('submit(HQuery)', function () {//选择物料
                //var sMainStr = JSON.stringify(table.cache['mainTable']);
                RoadQuery($('#Value').val());
            });
            form.on('submit(FH)', function () {//选择物料
                //var sMainStr = JSON.stringify(table.cache['mainTable']);
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                parent.GetHMaterNameValue(data);
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            });
 
            table.on('row(mainTable)', function (obj) {
                //选中行改变颜色
                var flag = !obj.tr.find(':checkbox:first').prop('checked');
                obj.tr.find(':checkbox').prop('checked', flag);
                if (flag) {
                    obj.tr.find('.layui-form-checkbox').addClass('layui-form-checked');  //设置复选框选中样式
                    $(obj.tr.selector).attr({ "style": "background:#ceedfa;color:black" });//改变当前tr背景颜色和字体颜色
                } else {
                    obj.tr.find('.layui-form-checkbox').removeClass('layui-form-checked');//取消复选框选中样式
                    $(obj.tr.selector).attr({ "style": "background:" });//取消当前tr颜色
                }
                //mainTable 为表格ID   注意此处如果ID不正确将导致你在监听复选框时获取不到你选择的数据,前面的只是添加或删除选中未选中样式以及设置背景色,字体颜色
                layui.each(table.cache.mainTable, function (i, l) {
                    if (obj.tr.index() == l.LAY_TABLE_INDEX) {
                        l.LAY_CHECKED = flag;
                    }
                });
            })
 
 
            RoadQuery($('#Value').val());
            table.render({
                elem: '#mainTable'
                // , url: '/demo/table/user/'
                , data: []
                , cellMinWidth: 80 //全局定义常规单元格的最小宽度,layui 2.2.1 新增
                , cols: [[
                    { type: 'checkbox', fixed: 'left' }
                    , { field: 'HItemID', title: '物料ID', hide: true }
                    , { field: 'HNumber', title: '物料代码' }
                    , { field: 'HName', title: '物料名称', sort: true }
                    , { field: 'HModel', title: '规格型号' }
                    , { field: 'HUnitID', title: '计量单位ID', hide: true }
                    , { field: 'HUnitNumber', title: '计量单位代码' }
                    , { field: 'HUnitName', title: '计量单位名称' }
                ]]
                , page: true
                , limits: [50, 500, 5000, 50000],
                limit: 50
            });
            ///加载显示数据
            function RoadQuery(Where) {
                var Value = Where;
                if (Value == null) {
                    Value = " Where HStopFlag=0  and HEndFlag=1 and HUSEORGID = " + sessionStorage["OrganizationID"];
                    //layer.alert("请输入物料代码或名称进行过滤");
                    //return;
                } else {
                    Value = " Where HStopFlag=0  and HEndFlag=1 and HUSEORGID = " + sessionStorage["OrganizationID"] + " and ( HNumber like '%" + Where + "%' or HName like '%" + Where + "%' ) "
                }
                var index = layer.load();
                $.ajax({
                    type: "get",
                    //url: "http://61.130.49.162:9090/WMSAPI///Web/GetDepartmentList_Json",
                    url: GetWEBURL() + "/Web/GetMaterialList_Json",
                    async: true,
                    data: { "sWhere": Value },
                    //data: { "Value": Value },
                    success: function (result) {
                        ajaxReturnData = JSON.parse(JSON.stringify(result)).data;
                        table.reload('mainTable', {
                            data: ajaxReturnData
                            , height: 'full-10'
                            , loading: false
                            , done: function (index, res) {
 
                            }
                        });
                        layer.close(index);
                    },
                    error: function (result) {
                        layer.close(index);
                        console.log(result);
                        //layer.msg('获取采购订单出现异常', { icon: 2, time: 2000 });
                    }
                });
            };
        });
    </script>
 
</body>
</html>