admin
2024-09-27 17caebabf7a6a529b7039c71e21e5a324e31ea20
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<!DOCTYPE html>
<html>
 
    <head>
        <meta charset="UTF-8">
        <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,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <title>提现列表</title>
        <link rel="stylesheet" type="text/css" href="layui/css/layui.css" />
        <link rel="stylesheet" type="text/css" href="css/admin.css" />
        <style>
            #add_client {
                padding: 10px;
            }
        </style>
    </head>
 
    <body>
        <div class="page-content-wrap">
            <form class="layui-form" action="" lay-filter='search'>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <input type="text" name="key" id="key" placeholder="按渠道ID搜索" autocomplete="off"
                            class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="startTime" placeholder="开始时间" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="endTime" placeholder="结束时间" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <select name="status">
                            <option value="-1">全部</option>
                            <option value="2">未处理</option>
                            <option value="3">已通过</option>
                            <option value="4">已驳回</option>
                        </select>
                    </div>
                    <div class="layui-inline">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="search" id="search"><i
                            class="layui-icon layui-icon-search"></i>搜索</button>
                    <a href="javascript:void();" class="layui-btn layui-disabled"  onclick="passWidthdraw()" id="pass"> 通过</a>
                    <a href="javascript:void();" class="layui-btn layui-btn-danger layui-disabled"   onclick="rejectWidthdraw()" id="reject"> 驳回</a>
                    </div>
                    </div>
            </form>
            <div class="layui-form" id="table-list">
                <table class="layui-table" lay-even lay-skin="nob" id="table" lay-filter="table">
 
                </table>
            </div>
        </div>
 
        <script src="layui/layui.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/http_api.js"></script>
        <!-- <script src="js/common.js" type="text/javascript" charset="utf-8"></script> -->
        <script>
            function passWidthdraw() {
                var checkStatus = layui.table.checkStatus('table'); 
                if(checkStatus.data.length<=0){
                        layer.msg("尚未选中数据");
                    return;
                }
                console.log(checkStatus.data) //获取选中行的数据
                let ids=[];
                checkStatus.data.forEach(function(e){
                    ids.push(e.id);
                });
 
                layer.confirm('您确定要执行此操作吗?', {
                    icon: 3,
                    title: '提示'
                }, function(index) {
                    // 确认操作
                    layer.close(index);
                    $.post("/admin/api/agentsettle/pass", {
                        "ids": JSON.stringify(ids)
                    }, function(response) {
                        if (response.code == 0) {
                            layer.msg("执行成功");
                            $("#search").click();
                        } else {
                            layer.msg(response.msg);
                        }
                    }, 'json').fail(function(jqXHR, textStatus, errorThrown) {
                        layer.close(index);
                        layer.msg("网络请求失败");
                    });
                }.bind(this));
            }
 
            function rejectWidthdraw() {
 
                var checkStatus = layui.table.checkStatus('table');
                if(checkStatus.data.length<=0){
                        layer.msg("尚未选中数据");
                    return;
                }
                console.log(checkStatus.data) //获取选中行的数据
                let ids=[];
                checkStatus.data.forEach(function(e){
                    ids.push(e.id);
                });
                
                layer.confirm('您确定要执行此操作吗?', {
                    icon: 3,
                    title: '提示'
                }, function(index) {
                    // 确认操作
                    layer.close(index);
                    $.post("/admin/api/agentsettle/reject", {
                        "ids": JSON.stringify(ids)
                    }, function(response) {
                        if (response.code == 0) {
                            layer.msg("执行成功");
                            $("#search").click();
                        } else {
                            layer.msg(response.msg);
                        }
                    }, 'json').fail(function(jqXHR, textStatus, errorThrown) {
                        layer.close(index);
                        layer.msg("网络请求失败");
                    });
                }.bind(this));
            }
 
            layui.use(['form', 'jquery', 'layer', 'table', 'laydate'], function() {
                var table = layui.table;
                var form = layui.form;
                var $ = layui.jquery;
                var laydate = layui.laydate;
 
                laydate.render({
                    elem: "input[name=startTime]",
                    type: "datetime",
                    value: new Date(),
                    isInitValue: false
                });
                laydate.render({
                    elem: "input[name=endTime]",
                    type: "datetime",
                    value: new Date(),
                    isInitValue: false
                });
 
                let table_option = {
                    id: "table",
                    elem: '#table',
                    url: '/admin/api/agentsettle/listWithdraw', //数据接口
                    where: {
                        'key': $("#key").val(),
                        'day': $("input[name=day]").val(),
                    },
                    parseData: function(res) { //res 即为原始返回的数据
                        let flist = new Array();
                        res.data.list.forEach(function(e) {
                            var fdata = {}
                            for (let key in e) {
                                // 判断属性是否是对象自身的属性而非继承的属性
                                if (e.hasOwnProperty(key)) {
                                    //console.log(key + ": " + json[key]);
                                    if (typeof e[key] == 'object') {
                                        for (let k1 in e[key]) {
                                            fdata[key + "." + k1] = e[key][k1];
                                        }
                                    } else {
                                        fdata[key] = e[key];
                                    }
                                }
                            }
                            console.log(fdata);
                            flist.push(fdata);
                        });
                        return {
                            "code": res.code, //解析接口状态
                            "msg": res.msg, //解析提示文本
                            "count": res.data.count, //解析数据长度
                            "data": flist //解析数据列表
                        }
                    },
                    page: true, //开启分页
                    cols: [
                        [ //表头
                            {
                                checkbox: true
                            },
                            {
                                field: 'id',
                                title: 'ID',
                                width: 100,
                            }, {
                                field: 'agentId',
                                title: '渠道',
                                width: 100,
                                sort: false,
                                templet: function(d) {
                                    return d["agent.name"] + "<br>" + d["agent.id"];
                                }
                            },
                            {
                                field: 'settleDay',
                                title: '订单发生日期',
                                width: 100,
                                sort: false,
                            },
                            {
                                field: 'actualSettleMoney',
                                title: '提现金额',
                                width: 100,
                                sort: false,
                            }, {
                                field: 'alipayName',
                                title: '支付宝姓名',
                                width: 100,
                                sort: false,
                            }, {
                                field: 'alipayAccount',
                                title: '支付宝账号',
                                width: 100,
                                sort: false,
                            },
                            {
                                field: 'withDrawApplyTime',
                                title: '发起提现时间',
                                width: 180,
                            },
                            {
                                field: '',
                                title: '状态',
                                width: 100,
                                sort: false,
                                templet: function(d) {
                                    switch (d.status) {
                                        case 2:
                                            return "未处理";
                                        case 3:
                                            return "支付成功";
                                        case 4:
                                            return "被驳回";
                                        default:
                                            return "未知";
                                    }
                                }
                            },
                            {
                                field: 'withDrawProcessTime',
                                title: '处理时间',
                                width: 100,
                                sort: false
                            },
                            {
                                field: '',
                                title: '操作',
                                sort: false,
                                templet: function(d) {
                                    var html = "";
                                    html += "<div><a href='javascript:void' onclick='delete_agent(" + d.id +
                                        ")' class='layui-table-link'>删除</a></div>";
                                    return html;
                                }
                            }
                        ]
                    ]
                };
                //第一个实例
                let tableIns = table.render(table_option);
                table.on('checkbox(table)', function(obj) {
                    
                    // 查询是否要选中
                    var checkStatus = table.checkStatus('table');
                    console.log(checkStatus)
                    if (checkStatus.data.length <= 0) {
                        $("#pass").addClass("layui-disabled");
                        $("#reject").addClass("layui-disabled");
                    } else {
                        $("#pass").removeClass("layui-disabled");
                        $("#reject").removeClass("layui-disabled");
                    }
 
                });
 
                //监听提交
                form.on('submit(search)', function(data) {
                    tableIns.reload({
                        where: data.field,
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                    });
                    return false;
                });
 
            });
        </script>
    </body>
 
</html>