@model string
<div class="current-location">
    <ul>
        <li class="left"><i class="glyphicon glyphicon-home"></i><a href="javascript:void(0)" onclick="location.href=location.href">财务记录</a></li>
        <li class="right"><a href="javascript:void(0)" onclick="LoadData()" title="刷新"><span class="glyphicon glyphicon-refresh"></span></a></li>
    </ul>
</div>
@*<div class="head-tab head-tab_hasa">
    <ul>
        <li class="tabhead" num="0"><a href="@Url.Action("Index","FinanceLst")?num=0"></a></li>
        <li class="tabhead" num="1"><a href="@Url.Action("Index","FinanceLst")?num=1&act=r"></a></li>
        <li class="tabhead" num="2"><a href="@Url.Action("Index","FinanceLst")?num=2&act=k"></a></li>
        <li class="tabhead" num="3"><a href="@Url.Action("Index","FinanceLst")?num=3&act=f"></a></li>
    </ul>
</div>*@
<div class="head-tab" id="head_tab">
    <ul>
        <li data-state="" class="current">所有记录</li>
        <li data-state="r">入款记录</li>
        <li data-state="k">扣款记录</li>
        <li data-state="f">返款记录</li>
    </ul>
</div>
<div class="main no-top-border">
    <table class="tb-head" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td class="btn-group left">
                <button type="button" class="btn btn-default btn-sm ui-selectInvert">反选</button>
                <button type="button" class="btn btn-default btn-sm ui-deleteMultiple" data-custom-params="url:'@Url.Action("Delete")'">删除</button>
            </td>
            <td class="form-inline form-group-sm right">
                <select id="order" name="order" class="form-control ui-queryString option_jj">
                    <option value="thedate desc">按时间↓</option>
                    <option value="thedate asc">按时间↑</option>
                </select>
                <input type="text" id="thedate" name="thedate" maxlength="19" style="width:105px" placeholder="开始日期" onclick="laydate({istime:true,format:'YYYY-MM-DD'})" class="laydate-icon form-control ui-queryString">
                <input type="text" id="thedate" name="thedate" maxlength="19" style="width:105px" placeholder="结束日期" onclick="laydate({istime:true,format:'YYYY-MM-DD'})" class="laydate-icon form-control ui-queryString">
                <select id="s_field" name="s_field" class="form-control ui-queryString ui-setName option_jj">
                    <option value="username">按会员名</option>
                    <option value="operator">按操作人</option>
                    <option value="remark">按说明</option>
                    <option value="beizhu">按备注</option>
                </select>
                <input type="hidden" class="ui-queryString" name="act" id="act" value="">
                <input text="text" id="s_keyword" name="s_keyword" placeholder="请输入关键词" style="width:120px;" class="form-control ui-queryString ui-keyword">
                <button type="button" class="btn btn-default btn-sm ui-queryString-search">确定</button>
            </td>
        </tr>
    </table>
    <table border=0 cellpadding=0 cellspacing=0 width=100% class="table table-bordered" id="tb_list">
        <thead><tr>
            <td align="center"  style="width:40px"><input type="checkbox" title="选择" class="ui-selectInvert" data-custom-params="isReverse:false"></td>
            <td align="center" width=10%>事项</td>
            <td align="center" width=10%>金额</td>
            <td align="center" width=10%>成本</td>
            <td align="center" width=10%>用户</td>
            <td align="center" width=12%>说明</td>
            <td align="center" width=15%>备注</td>
            <td align="center" width=10%>时间</td>
            <td align="center" width=10%>操作人</td>
            <td align="center" width=10%>管理</td>
        </tr>
        <tr class="item fnc_list" id="item_{id}">
            <td align="center"><input type="checkbox" id="id" name="id" value="{id}"></td>
            <td align="center" class="act">{act}</td>
            <td align="center" class="amount">{amount}</td>
            <td align="center" class="cost">{cost}</td>
            <td align="center" class="username">{username}</td>
            <td align="center">{remark}</td>
            <td align="left">{beizhu}</td>
            <td align="center">{thedate}</td>
            <td align="center">{operator}</td>
            <td align="center">
                <div class="btn-group btn-group-sm">
                    <a href="javascript:void(0)" class="btn btn-default btn-sm ui-deleteSingle" data-custom-params="url:'@Url.Action("Delete")',id:'{id}'">删除</a>
                </div>
            </td>
        </tr>
    </table>
</div>

<div class="main no-border no-padding" style="margin-top:10px;">
    <table border=0 cellpadding=0 cellspacing=0 width=100% class="table table-bordered">
        <thead><tr>
            <td align="center" width=20%>统计</td>
            <td align="center" width=20%>入款总额</td>
            <td align="center" width=20%>扣款总额</td>
            <td align="center" width=20%>成本总额</td>
            <td align="center" width=20%>返款总额</td>
        </tr>
        <tr class="item">
            <td align="center">当前页</td>
            <td align="center" class="rk_Total"></td>
            <td align="center" class="kk_Total"></td>
            <td align="center" class="cb_Total"></td>
            <td align="center" class="fk_Total"></td>
        </tr>
        <tr class="item">
            <td align="center">总记录</td>
            <td align="center">@ViewBag.Rcouts</td>
            <td align="center">@ViewBag.Kcouts</td>
            <td align="center">@ViewBag.Kcost</td>
            <td align="center">@ViewBag.Fcouts</td>
        </tr>
    </table>
</div>
<script type="text/javascript">
    function LoadData()
    {
        var url = "@Url.Action("PageListData")";
        $("#tb_list").ListBind(url, {callBack: "LoadedInit" });
        ReplaceField();
       // $(".tabhead").eq(parseInt(Request("num"))).addClass("current").siblings().removeClass("current")
    }
    LoadData();
    function ReplaceField() {
        var Rcouts = 0;
        var Kcouts = 0;
        var Kcost = 0;
        var Fcouts = 0;
        $(".item").each(function () {
            var $this_act = $(this).find(".act");
            var $this_amount = $(this).find(".amount");
            var $this_cost = $(this).find(".cost"); 
            if ($this_act.text() == "r") {
                $this_act.text("入款");
                Rcouts += (parseFloat($this_amount.text()));
            } else if ($this_act.text() == "k") {
                $this_act.text("扣除");
                Kcouts += (parseFloat($this_amount.text()));
                Kcost += (parseFloat($this_cost.text()));
            } else if ($this_act.text() == "f") {
                $this_act.text("返款");
                Fcouts += (parseFloat($this_amount.text()));
            }
        })
        $(".rk_Total").text(Rcouts);
        $(".kk_Total").text(Kcouts);
        $(".cb_Total").text(Kcost);
        $(".fk_Total").text(Fcouts);
    }
    var $state = $("#act");
    var $head_tab_item = $("#head_tab").children("ul").children("li");
    $head_tab_item.click(function () {
        var $this = $(this);
        var state = $this.attr("data-state");
        $state.val(state);
        $this.addClass("current").siblings().removeClass("current");
        LoadData();
    })
</script>



