<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('销售数据')"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-transfer-edit" th:object="${saleDataVo}">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">演出id：</label>
            <div class="col-sm-8">
                <input name="performancesId" th:field="*{performancesId}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">演出名称：</label>
            <div class="col-sm-8">
                <input name="title" th:field="*{title}" class="form-control" type="text" readonly>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">票提设置：</label>
            <table id="team-table" class="table table-condensed table-sm" th:border="1">
                <tr>
                    <td>票种名称</td>
                    <td>总代票提</td>
                    <td>普代票提</td>
                <tr/>
                <div th:each="item : *{showAgentVoList}">
                    <tr class="content-tr">
                        <td th:text="${item.title}">
                        </td>
                        <td th:text="${item.totalCarry}">
                        </td>
                        <td th:text="${item.ordCarry}">
                        </td>
                    </tr>
                </div>
            </table>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">代理数据：</label>
            <a style="margin-left: 500px" href="javascript:void(0)" class="btn btn-success btn-xs" onclick="onexport()"><i class="fa fa-edit"></i>导出</a>
            <table id="team-table2" class="table table-condensed table-sm" th:border="1">
                <tr>
                    <td>姓名</td>
                    <td>所属地区</td>
                    <td>身份</td>
                    <div th:each="item : *{showAgentVoList}">
                        <td th:text="${item.title}"></td>
                    </div>
                    <td>总销售张数</td>
                    <td>总销售金额</td>
                    <td>总销售佣金</td>
                    <td>打款状态</td>
                    <td>操作</td>
                <tr/>
                <div th:each="item : *{userDataList}">
                    <tr class="content-tr">
                        <td th:text="${item.username}"></td>
                        <td th:text="${item.cityName}"></td>
                        <!--                        <td th:name="uid" th:text="${item.uid}" hidden="hidden"></td>-->
                        <td th:if="${item.type==1}" th:text="总代"></td>
                        <td th:if="${item.type==2}" th:text="普代"></td>
                        <td th:each="itemAgent : ${item.dataAgentVos}" th:text="${itemAgent.number}"></td>
                        <td th:text="${#aggregates.sum(item.dataAgentVos.![number])}"></td>
                        <td th:text="${#aggregates.sum(item.dataAgentVos.![priceReal])}"></td>
                        <td th:text="${#aggregates.sum(item.dataAgentVos.![commission])}"></td>
                        <td th:if="${item.priceStatus!=0}" th:text="待打款"></td>
                        <td th:if="${item.priceStatus==0}" th:text="已打款"></td>
                        <td th:if="${item.priceStatus!=0}">
                            <button type="button" class="btn btn-success btn-xs"
                                    th:onclick="submitHandler([[${item.uid}]])">
                                打款
                            </button>
                        </td>
                    </tr>
                </div>
            </table>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
    var prefix = ctx + "smile/show";

    $("#form-transfer-edit").validate({
        focusCleanup: true
    });


    function submitHandler(uid) {
        var param = {
            performancesId: '[[${saleDataVo.performancesId}]]'.replaceAll("\"", ""),
            uid: uid,
            status: 0
        }

        $.ajax({
            type: 'post',
            url: prefix + "/price",
            headers: {"Content-Type": "application/json;charset=UTF-8"},
            data: JSON.stringify(param),
            success: function (e) {
                alert(e.msg)
                location.reload();
            }
        });
    }

    function onexport(){
        var params = {
            perId:'[[${saleDataVo.performancesId}]]'.replaceAll("\"", "")
        }

        $.ajax({
            type: 'get',
            url: "/smile/show/base/export",
            headers: {"Content-Type": "application/json;charset=UTF-8"},
            data: params,
            success: function (e) {
                window.location.replace('http://' + window.location.host + '/smile/show/base/export?perId=' + '[[${saleDataVo.performancesId}]]'.replaceAll("\"", "") + '&title=' + '[[${saleDataVo.title}]]')

            }
        });
    }
</script>
</body>
</html>
