|
|
<!DOCTYPE html>
|
|
|
<html>
|
|
|
<head>
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
|
<meta charset="UTF-8">
|
|
|
<title></title>
|
|
|
<link rel="stylesheet" type="text/css" href="__CSS__/base.css" media="all">
|
|
|
<link rel="stylesheet" type="text/css" href="__CSS__/common.css" media="all">
|
|
|
<link rel="stylesheet" type="text/css" href="__CSS__/style.css" media="all">
|
|
|
<link rel="stylesheet" type="text/css" href="__CSS__/default_color.css" media="all">
|
|
|
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
|
|
|
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
|
|
|
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
|
|
|
|
|
|
<script type="text/javascript" src="__STATIC__/jquery-2.0.3.min.js"></script>
|
|
|
<script type="text/javascript" src="__JS__/select2.min.js"></script>
|
|
|
<script type="text/javascript" src="__STATIC__/layer3/layer.js"></script>
|
|
|
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
|
|
|
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"charset="UTF-8"></script>
|
|
|
<script src="__STATIC__/juicer-min.js" type="text/javascript"></script>
|
|
|
</head>
|
|
|
<style>
|
|
|
html {
|
|
|
min-width:100%;
|
|
|
}
|
|
|
body {
|
|
|
max-width: 90%;
|
|
|
padding: 5% 0 0 5%;
|
|
|
}
|
|
|
.tabcon1711 table{
|
|
|
width: 480px;
|
|
|
}
|
|
|
table{
|
|
|
|
|
|
margin: auto;
|
|
|
}
|
|
|
.hidebox{
|
|
|
display: none;
|
|
|
}
|
|
|
.r{
|
|
|
width: 300px;
|
|
|
}
|
|
|
.l{
|
|
|
width: 180px;
|
|
|
}
|
|
|
.select2-container--default .select2-selection--single {
|
|
|
color: #000;
|
|
|
resize: none;
|
|
|
border-width: 1px;
|
|
|
border-style: solid;
|
|
|
border-color: #a7b5bc #ced9df #ced9df #a7b5bc;
|
|
|
box-shadow: 0px 3px 3px #F7F8F9 inset;
|
|
|
height: 35px;
|
|
|
height: 28px;
|
|
|
border-radius: 3px;
|
|
|
font-size: 12px;
|
|
|
}
|
|
|
|
|
|
.select2-container--default .select2-selection--single .select2-selection__rendered {
|
|
|
line-height: 35px;
|
|
|
line-height: 28px;
|
|
|
}
|
|
|
|
|
|
.select2-container--default .select2-selection--single .select2-selection__arrow {
|
|
|
height: 26px;
|
|
|
}
|
|
|
|
|
|
.select2-container--default .select2-search--dropdown .select2-search__field {
|
|
|
height: 26px;
|
|
|
line-height: 26px;
|
|
|
font-size: 12px;
|
|
|
}
|
|
|
|
|
|
.select2-results__option[aria-selected] {
|
|
|
font-size: 12px;
|
|
|
}
|
|
|
.input-list, .i_list {
|
|
|
float: left;
|
|
|
margin: 0;
|
|
|
}
|
|
|
|
|
|
</style>
|
|
|
|
|
|
<block name="body">
|
|
|
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
|
|
|
<link rel="stylesheet" href="__CSS__/pro_promote.css" type="text/css" />
|
|
|
<script src="__STATIC__/jquery.form.js"></script>
|
|
|
<script src="__STATIC__/layer/layer.js"></script>
|
|
|
<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
|
|
|
<script type="text/javascript" src="__JS__/select2.min.js"></script>
|
|
|
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script>
|
|
|
<link rel="stylesheet" href="__CSS__/promote.css" type="text/css"/>
|
|
|
<style>
|
|
|
.select2-container--default .select2-selection--single {
|
|
|
color: #000;
|
|
|
resize: none;
|
|
|
border-width: 1px;
|
|
|
border-style: solid;
|
|
|
border-color: #a7b5bc #ced9df #ced9df #a7b5bc;
|
|
|
box-shadow: 0px 3px 3px #F7F8F9 inset;height:35px;
|
|
|
height:28px;border-radius:3px;font-size:12px;
|
|
|
}
|
|
|
.select2-container--default .select2-selection--single .select2-selection__rendered {
|
|
|
line-height:35px;
|
|
|
line-height:28px;
|
|
|
}
|
|
|
.select2-container--default .select2-selection--single .select2-selection__arrow {
|
|
|
height:26px;
|
|
|
}
|
|
|
.select2-container--default .select2-search--dropdown .select2-search__field {
|
|
|
height:26px;line-height:26px;font-size:12px;
|
|
|
}
|
|
|
.select2-results__option[aria-selected] {font-size:12px;}
|
|
|
.butnbox {padding:10px 0 10px;}
|
|
|
.butnbox .butnlist {overflow:hidden;clear:both;}
|
|
|
.butnbox .butnlist .butn,.butnbox .butnlist .butn:hover {text-decoration:none;border:none;}
|
|
|
.butnbox .butnlist .butn {display:inline-block;width:120px;height:28px;line-height:28px;text-align:center;color:#FFF;background:#3C95C8;border-radius:3px;}
|
|
|
.butnbox .butnlist .butn.last {background:#009900;}
|
|
|
.butnbox .butnlist .butn~.butn {margin-left:20px;}
|
|
|
.butnbox a{
|
|
|
cursor:pointer
|
|
|
}
|
|
|
.data_list table tbody tr a.disabled,.data_list table tbody tr a.disabled:hover {color:#999;cursor:default;}
|
|
|
.data_list table td{
|
|
|
line-height: 2;
|
|
|
}
|
|
|
#tablebox tr{
|
|
|
border-bottom: 1px solid #e6e6e6;
|
|
|
}
|
|
|
</style>
|
|
|
|
|
|
<div class="cf top_nav_list">
|
|
|
<!-- <div class="fl button_list">
|
|
|
<div class="tools">
|
|
|
<a class=" " href="{:U('add')}"><span class="button_icon button_icon1"></span>新增推广游戏分成</a>
|
|
|
</div>
|
|
|
</div> -->
|
|
|
<!-- 高级搜索 -->
|
|
|
<div class="jssearch fl cf search_list" style="margin-bottom:12px">
|
|
|
<div class="input-list search-title-box" style="margin-left: 20px">
|
|
|
<label>公司类型:</label>
|
|
|
</div>
|
|
|
|
|
|
<div class="input-list input-list-promote search_label_rehab">
|
|
|
<select id="company_type" name="company_type" class="select_gallery" >
|
|
|
<option value="">请选择公司类型</option>
|
|
|
<option value="0">下游内团</option>
|
|
|
<option value="1">下游外团</option>
|
|
|
<option value="3">下游无</option>
|
|
|
</select>
|
|
|
</div>
|
|
|
<div class="input-list search-title-box" style="margin-left: 20px">
|
|
|
<label>选择下游公司:</label>
|
|
|
</div>
|
|
|
<div class="input-list input-list-game search_label_rehab">
|
|
|
<select id="company_id" name="company_id" class="select_gallery" >
|
|
|
<option value="">请选择下游合作公司</option>
|
|
|
</select>
|
|
|
</div>
|
|
|
|
|
|
<div class="input-list search-title-box" style="margin-left: 20px">
|
|
|
<label>结算时间:</label>
|
|
|
</div>
|
|
|
<div class="input-list">
|
|
|
<input type="text" readonly id="time_start" name="time_start" class="" value="{:I('time_start')}" placeholder="开始时间" />
|
|
|
-
|
|
|
<div class="input-append date" style="display:inline-block">
|
|
|
<input type="text" readonly id="time_end" name="time_end" class="" value="{:I('time_end')}" placeholder="结束时间" />
|
|
|
<span class="add-on"><i class="icon-th"></i></span>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="input-list search-title-box" style="margin-left: 20px">
|
|
|
<label>产品:</label>
|
|
|
</div>
|
|
|
<div class="input-list input-list-game search_label_rehab">
|
|
|
<select id="relation_game_id" name="relation_game_id[]" class="select_gallery" multiple="multiple">
|
|
|
<volist name="gameList" id="vo">
|
|
|
<option value="{$vo.relation_game_id}" <if condition="$vo.relation_game_id eq I('relation_game_id')">selected</if> >{$vo.relation_game_name}</option>
|
|
|
</volist>
|
|
|
</select>
|
|
|
</div>
|
|
|
|
|
|
<div class="input-list" style="margin-left: 20px">
|
|
|
<a class="sch-btn" href="javascript:;" id="add_company" url="{:U('index','&row='.I('row'),false)}">添加</a>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
<div class="butnbox" style="margin-bottom: 10px;">
|
|
|
<div class="butnlist jscheckbutn" style="margin-left: 2px">
|
|
|
<foreach name="menubtn" item="vo" >
|
|
|
{$vo}
|
|
|
</foreach>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<!-- 数据列表 -->
|
|
|
<div class="data_list">
|
|
|
<div class="">
|
|
|
<table id="tablebox">
|
|
|
<!-- 表头 -->
|
|
|
<thead>
|
|
|
<tr>
|
|
|
<th>公司</th>
|
|
|
<th>结算时间</th>
|
|
|
<th>产品</th>
|
|
|
<th>平台总额</th>
|
|
|
<th>分成比例</th>
|
|
|
<th>特殊补点</th>
|
|
|
<th>结算金额</th>
|
|
|
<th>操作</th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
|
|
|
<!-- 列表 -->
|
|
|
<tbody>
|
|
|
<td colspan="3"><span class="company_id">合计</span></td>
|
|
|
<td><span class="sum_pay_amount"></span></td>
|
|
|
<td colspan="2"></td>
|
|
|
<td><span class="sum_withdraw_amount"></span></td>
|
|
|
<td></td>
|
|
|
</tbody>
|
|
|
</table>
|
|
|
<button class="submit_btn ajax-post" id="submit" type="submit" target-form="form-horizontal" style="margin-top: 50px;float: right">
|
|
|
确认保存
|
|
|
</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<script type="text/javascript">
|
|
|
$(function(){
|
|
|
$("#company_type").select2();
|
|
|
$("#company_id").select2();
|
|
|
$("#relation_game_id").select2();
|
|
|
|
|
|
$('#time_start').datetimepicker({
|
|
|
format: 'yyyy-mm-dd',
|
|
|
language:"zh-CN",
|
|
|
minView:2,
|
|
|
autoclose:true,
|
|
|
endDate : new Date()
|
|
|
});
|
|
|
$('#time_end').datetimepicker({
|
|
|
format: 'yyyy-mm-dd',
|
|
|
language:"zh-CN",
|
|
|
minView:2,
|
|
|
autoclose:true,
|
|
|
endDate : new Date()
|
|
|
});
|
|
|
|
|
|
$('#datetimepicker').datetimepicker({
|
|
|
format: 'yyyy-mm-dd',
|
|
|
language:"zh-CN",
|
|
|
minView:2,
|
|
|
autoclose:true,
|
|
|
pickerPosition:'bottom-left'
|
|
|
});
|
|
|
var is_submit = 1;
|
|
|
$('#submit').on({
|
|
|
click: function () {
|
|
|
|
|
|
if (!is_submit) {
|
|
|
layer.msg("正在提交请勿重复提交...");
|
|
|
return;
|
|
|
}
|
|
|
var is_zero = 0;
|
|
|
layer.load(2);
|
|
|
is_submit = 0;
|
|
|
var time_start = $("#time_start").val();
|
|
|
var time_end = $("#time_end").val();
|
|
|
var send = [];
|
|
|
|
|
|
$('#tablebox').find('.company_id').each(function(ckey, cval) {
|
|
|
|
|
|
var data = {};
|
|
|
var sec_data = {};
|
|
|
var statement_info = [];
|
|
|
|
|
|
if ($(cval).html() == "合计") {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
data['company_id'] = $(cval).attr('data-company_id');
|
|
|
data['company_name'] = $(cval).html();
|
|
|
data['statement_begin_time'] = time_start;
|
|
|
data['statement_end_time'] = time_end;
|
|
|
|
|
|
sec_data['pay_amount'] = $(cval).next().next().next().text();
|
|
|
sec_data['sum_money'] = $(cval).next().next().next().next().next().next().text();
|
|
|
sec_data['relation_game_id'] = $(cval).next().next().next().next().next().next().next().find('a').attr('data-game_id');
|
|
|
sec_data['game_name'] = $(cval).next().next().text();
|
|
|
|
|
|
var ratio = $(cval).next().next().next().next().text();
|
|
|
// ratio = parseFloat(ratio.slice(0, -1)) + parseFloat($(cval).next().next().next().next().next().find('input').val());
|
|
|
sec_data['ratio'] = parseFloat(ratio.slice(0, -1));
|
|
|
sec_data['increment_ratio'] = parseFloat($(cval).next().next().next().next().next().find('input').val());
|
|
|
sec_data['statement_begin_time'] = $(cval).next().find('.begin_time').text();
|
|
|
sec_data['statement_end_time'] = $(cval).next().find('.end_time').text();
|
|
|
statement_info.push(sec_data);
|
|
|
if (sec_data['increment_ratio']<=0||sec_data['pay_amount']<=0) {
|
|
|
is_zero = 1;
|
|
|
layer.closeAll("loading");
|
|
|
return;
|
|
|
}
|
|
|
var _append = $(cval).parent();
|
|
|
var row = $(cval).attr('rowspan');
|
|
|
for (var i=0;i<row-1;i++) {
|
|
|
sec_data = {};
|
|
|
_append = _append.next();
|
|
|
sec_data['statement_begin_time'] = _append.find('.relation_game_name').prev().find('.begin_time').text();
|
|
|
sec_data['statement_end_time'] = _append.find('.relation_game_name').prev().find('.end_time').text();
|
|
|
sec_data['game_name'] = _append.find('.relation_game_name').text();
|
|
|
sec_data['pay_amount'] = _append.find('.relation_game_name').next().text();
|
|
|
sec_data['sum_money'] = _append.find('.relation_game_name').next().next().next().next().text();
|
|
|
sec_data['relation_game_id'] = _append.find('.relation_game_name').next().next().next().next().next().find('a').attr('data-game_id');
|
|
|
|
|
|
var ratio = _append.find('.relation_game_name').next().next().text();
|
|
|
// ratio = parseFloat(ratio.slice(0, -1)) + parseFloat(_append.find('.relation_game_name').next().next().next().find('input').val());
|
|
|
sec_data['ratio'] = ratio.slice(0, -1);
|
|
|
|
|
|
sec_data['increment_ratio'] = parseFloat(_append.find('.relation_game_name').next().next().next().find('input').val());
|
|
|
if (sec_data['increment_ratio']<=0||sec_data['pay_amount']<=0) {
|
|
|
|
|
|
is_zero = 1;
|
|
|
layer.closeAll("loading");
|
|
|
return;
|
|
|
}
|
|
|
statement_info.push(sec_data);
|
|
|
|
|
|
}
|
|
|
|
|
|
data['statement_info'] = statement_info;
|
|
|
send.push(data);
|
|
|
});
|
|
|
|
|
|
if (is_zero == 1) {
|
|
|
is_submit = 1;
|
|
|
layer.msg("不能提交补点比例为零或者流水为零的数据");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (send.length != 0) {
|
|
|
$.ajax({
|
|
|
url: '{:U("addSpecialComplementPost")}',
|
|
|
type: 'post',
|
|
|
dataType: 'json',
|
|
|
data: {data:JSON.stringify(send)},
|
|
|
success: function(result) {
|
|
|
if (result.status == 1) {
|
|
|
is_submit = 1;
|
|
|
layer.msg("插入成功");
|
|
|
parent.location.reload();
|
|
|
|
|
|
} else if (result.status==1001) {
|
|
|
is_submit = 1;
|
|
|
layer.msg("数据插入失败");
|
|
|
|
|
|
} else {
|
|
|
is_submit = 1;
|
|
|
layer.msg(result.msg);
|
|
|
}
|
|
|
layer.closeAll("loading");
|
|
|
}});
|
|
|
} else {
|
|
|
is_submit = 1;
|
|
|
layer.closeAll("loading");
|
|
|
layer.msg('数据为空不能提交');
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
});
|
|
|
var is_add = 1;
|
|
|
//添加公司比例操作
|
|
|
$('#add_company').click(function (e) {
|
|
|
|
|
|
layer.load(2);
|
|
|
is_add = 0;
|
|
|
var company_id = $("#company_id").find("option:selected").val();
|
|
|
var time_start = $("#time_start").val();
|
|
|
var time_end = $("#time_end").val();
|
|
|
var relation_game_id = $("#relation_game_id").val();
|
|
|
var company_type = $("#company_type").find("option:selected").val();
|
|
|
|
|
|
var sdate = Date.parse($('#time_start').val()) / 1000;
|
|
|
var edate = Date.parse($('#time_end').val()) / 1000;
|
|
|
if (sdate > edate) {
|
|
|
layer.closeAll("loading");
|
|
|
layer.msg('开始时间必须小于等于结束时间');
|
|
|
return false;
|
|
|
}
|
|
|
if ((edate - sdate) > 2592000) {
|
|
|
layer.closeAll("loading");
|
|
|
layer.msg('时间间隔不能超过31天,请重新选择日期');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
var s_start = time_start.split('-');
|
|
|
var s_month = s_start[1]; //获取当前日期的月份
|
|
|
|
|
|
var s_end = time_end.split('-');
|
|
|
var e_month = s_end[1]; //获取当前日期的月份
|
|
|
|
|
|
if (s_month != e_month) {
|
|
|
layer.closeAll("loading");
|
|
|
layer.msg('只能选择同一个月的补点结算');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (!company_type) {
|
|
|
layer.closeAll("loading");
|
|
|
layer.msg('请选择公司类型');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (!company_id) {
|
|
|
layer.closeAll("loading");
|
|
|
layer.msg('请选择公司');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (!time_start || !time_end) {
|
|
|
layer.closeAll("loading");
|
|
|
layer.msg('开始时间与结束时间至少选择一个');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (!relation_game_id) {
|
|
|
layer.closeAll("loading");
|
|
|
layer.msg('请选择游戏');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
url: '{:U("addSpecialComplement")}',
|
|
|
type: 'post',
|
|
|
dataType: 'json',
|
|
|
data: {company_id:company_id, time_start:time_start, time_end:time_end, relation_game_id:relation_game_id, company_type:company_type},
|
|
|
success: function(result) {
|
|
|
if (result.status == 1) {
|
|
|
// $('#tablebox').find('tbody').empty();
|
|
|
var data = result.data;
|
|
|
var html = '';
|
|
|
var is_continue = 0;
|
|
|
|
|
|
for (var item in data) {
|
|
|
is_continue = 0;
|
|
|
$('#tablebox').find('.company_id').each(function(ckey, cval) {
|
|
|
if ($(cval).html() == data[item]['company_name']) {
|
|
|
//时间数组定义用于判断当前选择的游戏是否有结算过的区间
|
|
|
var begin_time = [];
|
|
|
var end_time = [];
|
|
|
var get_time = $(cval).parent();
|
|
|
var row =$(cval).attr('rowspan');
|
|
|
|
|
|
for (var i=0; i<row; i++) {
|
|
|
for(var item_sec in data[item]['relation_game_name']) {
|
|
|
|
|
|
if (get_time.find('.relation_game_name').text() == data[item]['relation_game_name'][item_sec]
|
|
|
&& ((data[item]['begin_time'][item_sec] >= get_time.find('.begin_time').text()&&data[item]['begin_time'][item_sec] <= get_time.find('.end_time').text())
|
|
|
|| (data[item]['end_time'][item_sec] >= get_time.find('.begin_time').text()&&data[item]['end_time'][item_sec] <= get_time.find('.end_time').text())
|
|
|
||(data[item]['begin_time'][item_sec]<=get_time.find('.begin_time').text()&&data[item]['end_time'][item_sec]>=get_time.find('.end_time').text()))) {
|
|
|
|
|
|
begin_time.push(get_time.find('.begin_time').text());
|
|
|
end_time.push(get_time.find('.end_time').text());
|
|
|
|
|
|
}
|
|
|
}
|
|
|
get_time = get_time.next();
|
|
|
}
|
|
|
|
|
|
|
|
|
for (var time in begin_time) {
|
|
|
|
|
|
if ((begin_time[time]>=time_start && begin_time[time]<=time_end) || (end_time[time]>=time_start && end_time[time]<=time_end)||(begin_time[time]<=time_start && end_time[time] >= time_end)) {
|
|
|
layer.msg(data[item]['company_name'] + "结算日期"+begin_time[time]+"-"+end_time[time]+"有结算过的部分,请重新选择");
|
|
|
is_add = 1;
|
|
|
is_continue = 2;
|
|
|
layer.closeAll("loading");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
$(cval).attr('rowspan',parseInt(row)+parseInt(data[item]['row']));
|
|
|
|
|
|
for(var item_sec in data[item]['begin_time']) {
|
|
|
html += "<tr>" +
|
|
|
"<td><span class='begin_time'>"+data[item]['begin_time'][item_sec]+"</span>-<span class='end_time'>"+data[item]['end_time'][item_sec]+"</span></td>" +
|
|
|
"<td class='relation_game_name'>"+data[item]['relation_game_name'][item_sec]+"</td>" +
|
|
|
"<td class='pay_amount'>"+data[item]['pay_amount'][item_sec]+"</td>" +
|
|
|
"<td>"+data[item]['ratio'][item_sec]+"%</td>" +
|
|
|
"<td><input oninput='if($(this).val()>100){$(this).val(100);}' value='0' type='number' style='width: 50px;text-align: center' class='complement'/>%</td>" +
|
|
|
"<td class='withdraw_amount'>"+data[item]['withdraw_amount'][item_sec]+"</td>" +
|
|
|
"<td><a data-value='"+data[item]['company_name']+"' class='delete' data-game_id='"+data[item]['relation_game_id'][item_sec]+"'>删除</a></td></tr>";
|
|
|
}
|
|
|
|
|
|
//轮询寻找最后一个
|
|
|
var _append = $(cval).parent();
|
|
|
for (var i=0; i<row-1; i++) {
|
|
|
_append = _append.next();
|
|
|
}
|
|
|
_append.after(html);
|
|
|
is_continue = 1;
|
|
|
complementChange();
|
|
|
DeleteTd();
|
|
|
caculateAmount();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (is_continue == 1) {
|
|
|
continue;
|
|
|
} else if(is_continue == 2) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
html += "<tr><td class='company_id' rowspan='"+data[item]['row']+"' data-company_id='"+data[item]['company_id']+"'>"+data[item]['company_name']+"</td>" +
|
|
|
"<td><span class='begin_time'>"+data[item]['begin_time'][0]+"</span>-<span class='end_time'>"+data[item]['end_time'][0]+"</span></td>" +
|
|
|
"<td class='relation_game_name'>"+data[item]['relation_game_name'][0]+"</td>" +
|
|
|
"<td class='pay_amount'>"+data[item]['pay_amount'][0]+"</td>" +
|
|
|
"<td>"+data[item]['ratio'][0]+"%</td>" +
|
|
|
"<td><input oninput='if($(this).val()>100){$(this).val(100);}' value='0' type='number' style='width: 50px;text-align: center' class='complement'/>%</td>" +
|
|
|
"<td class='withdraw_amount'>"+data[item]['withdraw_amount'][0]+"</td>" +
|
|
|
"<td><a data-value='"+data[item]['company_name']+"' data-game_id='"+data[item]['relation_game_id'][0]+"' class='delete'>删除</a></td></tr>";
|
|
|
for(var item_sec in data[item]['begin_time']) {
|
|
|
if (item_sec != 0) {
|
|
|
html += "<tr>" +
|
|
|
"<td><span class='begin_time'>"+data[item]['begin_time'][item_sec]+"</span>-<span class='end_time'>"+data[item]['end_time'][item_sec]+"</span></td>" +
|
|
|
"<td class='relation_game_name'>"+data[item]['relation_game_name'][item_sec]+"</td>" +
|
|
|
"<td class='pay_amount'>"+data[item]['pay_amount'][item_sec]+"</td>" +
|
|
|
"<td>"+data[item]['ratio'][item_sec]+"%</td>" +
|
|
|
"<td><input oninput='if($(this).val()>100){$(this).val(100);}' value='0' type='number' style='width: 50px;text-align: center' class='complement'/>%</td>" +
|
|
|
"<td class='withdraw_amount'>"+data[item]['withdraw_amount'][item_sec]+"</td>" +
|
|
|
"<td><a data-value='"+data[item]['company_name']+"' class='delete' data-game_id='"+data[item]['relation_game_id'][item_sec]+"'>删除</a></td></tr>";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
$('#tablebox').find('tbody').prepend(html);
|
|
|
complementChange();
|
|
|
DeleteTd();
|
|
|
caculateAmount();
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
layer.msg(result.msg);
|
|
|
}
|
|
|
is_add = 1;
|
|
|
layer.closeAll("loading");
|
|
|
}
|
|
|
})
|
|
|
});
|
|
|
|
|
|
function caculateAmount() {
|
|
|
|
|
|
var pay_amount = 0;
|
|
|
var withdraw_amount = 0;
|
|
|
|
|
|
$('#tablebox').find('.pay_amount').each(function(ckey, cval) {
|
|
|
pay_amount += parseFloat($(cval).text());
|
|
|
});
|
|
|
$('#tablebox').find('.withdraw_amount').each(function(ckey, cval) {
|
|
|
withdraw_amount += parseFloat($(cval).text());
|
|
|
});
|
|
|
|
|
|
$(".sum_pay_amount").text(pay_amount.toFixed(2));
|
|
|
$(".sum_withdraw_amount").text(withdraw_amount.toFixed(2));
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
//补点改变函数
|
|
|
function complementChange() {
|
|
|
$(".complement").off("change");
|
|
|
$('.complement').change(function() {
|
|
|
//获取总流水
|
|
|
var pay_amount = parseFloat($(this).parent().prev().prev().text());
|
|
|
var show_ratio = $(this).parent().prev().text();
|
|
|
show_ratio = parseFloat(show_ratio.slice(0,show_ratio.length-1));
|
|
|
|
|
|
//计算最终分配比率
|
|
|
var ratio = parseFloat($(this).val());
|
|
|
|
|
|
if (ratio<0) {
|
|
|
$(this).val(0);
|
|
|
ratio = 0;
|
|
|
}
|
|
|
if(!ratio) {
|
|
|
$(this).val(0);
|
|
|
ratio=0;
|
|
|
}
|
|
|
// console.log(ratio+show_ratio);
|
|
|
if ((ratio+show_ratio)>100) {
|
|
|
$(this).val(100-show_ratio);
|
|
|
ratio = 100-show_ratio;
|
|
|
}
|
|
|
//最终的分配金额
|
|
|
var withdraw_amount = ((pay_amount * ratio)/100).toFixed(2);
|
|
|
|
|
|
$(this).parent().next().text(withdraw_amount);
|
|
|
caculateAmount();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//删除操作
|
|
|
function DeleteTd() {
|
|
|
|
|
|
$('.delete').off('click');
|
|
|
|
|
|
$('.delete').click(function() {
|
|
|
|
|
|
var company_name = $(this).data();
|
|
|
|
|
|
var is_first = $(this).parent().parent().children(":first").text();
|
|
|
var first_row = $(this).parent().parent().children(":first").attr('rowspan');
|
|
|
var company_id = $(this).parent().parent().children(":first").attr('data-company_id');
|
|
|
//判断公司是否隶属于该公司
|
|
|
if (is_first == company_name['value']) {
|
|
|
var html = "<td class='company_id' rowspan='"+(first_row-1)+"' data-company_id='"+company_id+"'>"+is_first+"</td>";
|
|
|
|
|
|
var next_company = $(this).parent().parent().next().find(".company_id").text();
|
|
|
|
|
|
//判断接下来还有没有该公司的比例,如有增添加公司名称行
|
|
|
if (!next_company&&next_company!="合计") {
|
|
|
$(this).parent().parent().next().prepend(html);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
$('#tablebox').find('.company_id').each(function(ckey, cval) {
|
|
|
|
|
|
if($(cval).html() == company_name['value']){
|
|
|
var rowspan = $(cval).attr('rowspan');
|
|
|
$(cval).attr('rowspan',rowspan-1);
|
|
|
}
|
|
|
|
|
|
});
|
|
|
}
|
|
|
$(this).parent().parent().remove();
|
|
|
caculateAmount();
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
var company_id = "{$_GET['company_id']??0}";
|
|
|
$("#company_type").on("change",function(){
|
|
|
var val = $(this).find("option:selected").val();
|
|
|
var url = "{:U('Ajax/getPromoteCompany')}"+"&company_belong="+val;
|
|
|
$.get(url,function(data){
|
|
|
var company = data;
|
|
|
var companystr = '<option value="">请选择下游合作公司</option>';
|
|
|
for (var i in company) {
|
|
|
if(company[i].id == company_id){
|
|
|
companystr += "<option value='" + company[i].id + "' data-value='"+ company[i].game_ids +"' selected='selected'>" + company[i].name + "</option>"
|
|
|
}else{
|
|
|
companystr += "<option value='" + company[i].id + "' data-value='"+ company[i].game_ids +"' >" + company[i].name + "</option>"
|
|
|
}
|
|
|
}
|
|
|
$("#company_id").html(companystr);
|
|
|
$("#company_id").select2();
|
|
|
$("#relation_game_id").html('')
|
|
|
$("#relation_game_id").select2();
|
|
|
})
|
|
|
});
|
|
|
var game_id = "{$_GET['game_id']??0}";
|
|
|
$("#company_id").on("change",function(){
|
|
|
layer.load(2);
|
|
|
var data = $(this).find("option:selected").data().value;
|
|
|
var company_id = $(this).find("option:selected").val();
|
|
|
|
|
|
var url = "{:U('Ajax/getPromoteGameList')}"+"&game_ids="+data+"&company_id="+company_id;
|
|
|
$.get(url,function(data){
|
|
|
var game = data;
|
|
|
var gamestr = '';
|
|
|
for (var i in game) {
|
|
|
if(game[i].id == game_id){
|
|
|
gamestr += "<option value='" + game[i].relation_game_id + "' selected='selected'>" + game[i].relation_game_name + "</option>"
|
|
|
}else{
|
|
|
gamestr += "<option value='" + game[i].relation_game_id + "'>" + game[i].relation_game_name + "</option>"
|
|
|
}
|
|
|
}
|
|
|
$("#relation_game_id").html(gamestr);
|
|
|
$("#relation_game_id").select2();
|
|
|
layer.closeAll("loading");
|
|
|
})
|
|
|
});
|
|
|
|
|
|
});
|
|
|
</script>
|
|
|
|
|
|
</block>
|
|
|
</html>
|