zrg
2024-10-15 4322ae28f78e1c393eb85eece4d8a4485bb23f7c
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<!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" style="padding: 0;">
        <div class="layui-card" style="padding: 15px;">
            <div class="layui-card-body" style="padding: 1px;">
                <form class="layui-form" lay-filter="component-form-group" action="">
                    <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>
                    <!--子表1-->
                    <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
                </form>
            </div>
        </div>
    </div>
    <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/Scripts/json2.js" type="text/javascript"></script>
    <script src="../../../layuiadmin/Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script>
        function getUrlVars() {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        }
        var params = getUrlVars();
        var Type = params[params[0]];
        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());
            });
 
            //回车触发过滤
            $('#Value').on('keydown', function (event) {
                if (event.keyCode == 13) {
                    RoadQuery($('#Value').val());
                }
            });
 
            form.on('submit(FH)', function () {//选择客户
                //var sMainStr = JSON.stringify(table.cache['mainTable']);
                var checkStatus = table.checkStatus('mainTable')
                 , data = checkStatus.data;
                //parent.GetHSupValue(data);
 
                switch (Type) {
                    case "HAccCus":  //返回结算单位
                        parent.GetHAccCusValue(data);
                        break;
                    default:
                        parent.GetHSupValue(data);      //返回 客户
                }
 
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            });
            RoadQuery($('#Value').val());
            table.render({
                elem: '#mainTable'
                // , url: '/demo/table/user/'
               , data: []
              , cellMinWidth: 80 //全局定义常规单元格的最小宽度,layui 2.2.1 新增
              , cols: [[
                  { type: 'checkbox' }
                , { field: 'HItemID', width: 150, title: '客户ID', hide: true }
                , { field: 'HNumber', width: 150, title: '客户代码' }
                , { field: 'HName', width: 150, title: '客户名称', sort: true }
              ]]
                , page: true
                , limits: [50, 500, 5000, 50000],
                limit: 50
            });
 
            //#region 点击行选中高亮
            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;
                    }
                });
            })
            //#endregion
 
            //#region 双击返回数据
            table.on('rowDouble(mainTable)', function (obj) {
                var data = [];
                data.push(obj.data);
                switch (Type) {
                    case "HAccCus":  //返回结算单位
                        parent.GetHAccCusValue(data);
                        break;
                    default:
                        parent.GetHSupValue(data);      //返回 客户
                }
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            });
            //#endregion
 
            ///加载显示数据
            function RoadQuery(Where) {
                var Value = Where;
                if (Value == null) {
                    Value = '';
                }
 
                Value = "Where HStopFlag=0 and ( HNumber like '%" + Value + "%' or HName like '%" + Value + "%' ) " + getSWhereByHUser() + addSWhereByOpenType();
 
                $.ajax({
                    type: "get",
                    //url: "http://61.130.49.162:9090/WMSAPI///Web/GetCustomerList_Json",
                    //url: GetWEBURL() + "/Web/GetCustomerList_Json",
                    url: GetWEBURL() + "/Web/GetCustomerList_Json_New1",
                    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) {
 
                            }
                        });
                    },
                    error: function (result) {
                        console.log(result);
                        //layer.msg('获取采购订单出现异常', { icon: 2, time: 2000 });
                    }
                });
            };
 
 
            //#region 根据用户获取用户关联客户的过滤条件
            function getSWhereByHUser() {
                var res = "";
                $.ajax({
                    type: "GET",
                    async: false,
                    url: GetWEBURL() + "/Xs_SeOrderBill/getCusIDListByUser", //方法所在页面和方法名
                    data: { "CurUserID": sessionStorage["Czybm"], "CurUserName": sessionStorage["HUserName"] },
                    success: function (result) {
                        if (result.count == 1) {
                            res = result.data;
                        } else {
                            res = result.data;
                            layer.alert(result.code + result.Message, { icon: 5 });
                        }
                    }, error: function (err) {
                        res = " and 1 = 0";
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
 
                res = res.replace("HCusID", "HItemID");
 
                return res;
            }
            //#endregion
 
            //#region 判断是直接打开页面还是其它页面通过选择按钮打开,并显示相应数据
            function addSWhereByOpenType() {
                //获取参数
                var params = getUrlVars();
 
                var openType = params[params[1]]; //从参数中获取 打开方式  1直接打开 2其它页面通过选择按钮打开 3根据递入的职员内码,显示绑定该职员的用户所关联的客户
                var HEmpID = params[params[2]];     //职员ID
                var addSWhere = "";
 
                if (openType == 3 && HEmpID!=0) {
                    addSWhere = " and HItemID in (select b.HCusID HItemID from Gy_Czygl as a inner join Gy_UserCustomerRelation as b on a.Czybm = b.HUserID where a.HEmpID = " + HEmpID + ") "
                }
                return addSWhere;
            }
            //#endregion
        });
    </script>
 
</body>
</html>