<%--
  Created by IntelliJ IDEA.
  User: wuxuan
  Date: 2023/5/6
  Time: 10:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page pageEncoding="UTF-8" language="java" %>
<%
    String path = request.getContextPath();
%>
<%@ include file="../common/common.jsp" %>
<html>
<head>
    <title>空号检测充值记录</title>
</head>
<body>
<div class="page_container">
    <div class="page_head">
        <h3>空号用户充值</h3>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <form id="form" action="nullMobileCheckChargeList.html" method="post">
                <div class="panel">
                    <div class="table_operate">
                        <label>企业ID:
<%--                            <input type="text" name="spId" value="${modal.spId}" class="form_control form_white"/>--%>
                            <select id="spId" name="spId" class="form_control form_white singleSelect">
                                <option value="">请选择</option>
                                <c:forEach items="${spListOptions}" var="option">
                                    <option value="${option.value}" <c:if test="${option.value eq modal.spId}">selected</c:if>>${option.value} ${option.label}</option>
                                </c:forEach>
                            </select>
                        </label>
                        <label>操作人:
                            <input type="text" name="operator" value="${modal.operator}"
                                   class="form_control form_white"/>
                        </label>
                        <label>
                            类型:
                            <select name="chargeType" class="form_control form_white">
                                <option value="">全部</option>
                                <option value="0" <c:if test="${modal.chargeType == 0}">selected</c:if>>充值</option>
                                <option value="1" <c:if test="${modal.chargeType == 1}">selected</c:if>>扣费</option>
                            </select>
                        </label>
                        <label>创建时间:</label>&nbsp;<input
                            id="d12" name="startTime" type="text" style="width: 200px"
                            value="${modal.startTime}" pattern="yyyy-MM-dd"
                            class="Wdate form_control form_white Wdate1"
                            onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'d13\')||\'%y-%M-%d\'}',dateFmt:'yyyy-MM-dd',isShowClear:false,readOnly:true})"/>--
                        <input id="d13" name="endTime" type="text" style="width: 200px"
                               value="${modal.endTime}" pattern="yyyy-MM-dd"
                               class="Wdate form_control form_white Wdate1"
                               onfocus="WdatePicker({minDate:'#F{$dp.$D(\'d12\',{d:0});}',maxDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd',isShowClear:false,readOnly:true})"/>
                        <label>&nbsp;</label>
                        <button type="button" class="btn btn_orange btn_icon" onclick="submitThisForm()">
                            <span class="ico_16px ico_search"></span>查询
                        </button>

                        <label>&nbsp;</label>
                        <a class="btn btn_green" href="${basepage}/nullMobileCheckCharge.html?type=0" data-target="#ajax"
                           data-toggle="modal">条数充值</a>
                        <a class="btn btn_green" href="${basepage}/nullMobileCheckCharge.html?type=1" data-target="#ajax"
                           data-toggle="modal">条数扣减</a>
                    </div>

                    <div class="modal fade" id="ajax" role="basic" aria-hidden="true">
                        <div class="modal-dialog" style="width: 400px">
                            <div class="modal-content">
                            </div>
                        </div>
                    </div>

                    <div class="table_wrap">
                        <table class="datatable">
                            <thead>
                            <tr>
                                <th>企业ID</th>
                                <th>企业名称</th>
                                <th>类型</th>
                                <th>充值条数</th>
                                <th>充值后条数</th>
                                <th>操作人</th>
                                <th>充值时间</th>
                                <th>单价(分)</th>
                                <th>备注</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:choose>
                                <c:when test="${not empty list}">
                                    <c:forEach items="${list}" var="item" varStatus="vs">
                                        <tr class="main_info" id="tr${item.id}">
                                            <td>${item.spId}</td>
                                            <td>${item.spName}</td>
                                            <c:if test="${item.chargeType == 0}">
                                                <td style="color: green">充值</td>
                                            </c:if>
                                            <c:if test="${item.chargeType == 1}">
                                                <td style="color: red">扣费</td>
                                            </c:if>
                                            <td>${item.chargeValue}</td>
                                            <td>${item.chargeAfter}</td>
                                            <td>${item.operator}</td>
                                            <td>${item.createTime}</td>
                                            <td>${item.price}</td>
                                            <td width="300px">${item.remark}</td>
                                            <td>
                                                <button type="button" class="btn btn_green" onclick="queryBalance('${item.spId}')">该企业实时余额</button>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                </c:when>
                                <c:otherwise>
                                    <tr class="main_info">
                                        <td colspan="8">没有相关数据</td>
                                    </tr>
                                </c:otherwise>
                            </c:choose>
                            </tbody>
                            <tfoot>
                            <tr>
                                <td>${modal.page.pageStr}</td>
                            </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script>
    $(function () {
        $('.singleSelect').select2();
    });
    $(function () {
        $("#ajax").on("hidden.bs.modal", function () {
            $(this).removeData("bs.modal");
        });
    })

    function submitThisForm() {
        $("#form").submit();
    }

    function queryBalance(spId) {
        if (!spId) {
            Dialog.alertError("企业ID不能为空");
            return;
        }

        $.ajax({
            url: '${basepage}/queryNullMobileCheckBalance.html',
            type: 'post',
            data: {spId: spId},
            dataType: 'json',
            success: function (res) {
                if (res.code === 0) {
                    Dialog.alertSucc(res.data);
                } else {
                    Dialog.alertError(res.data);
                }
            },
            error: function () {
                Dialog.alertError("查询失败,请稍后重试");
            }
        })
    }
</script>
</html>
