You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

661 lines
32 KiB
HTML

<extend name="Public/base" />
<block name="css">
<link rel="stylesheet" type="text/css" href="__CSS__/admin_table.css" media="all">
<link rel="stylesheet" type="text/css" href="__STATIC__/webuploader/webuploader.css" media="all">
<style>
#form .txt_area.download_url {width:400px;}
.tabcon1711 .table_radio2 .table_btn {width:215px;}
.bnt_add,.bnt_remove,.bnt_save, .settlement_bnt_add{
height: 30px;
width: 20px;
font-size: 20px;
line-height: 10px;
color: #3399ff;
background: none;
border: none;
margin-left: 20px;
cursor: pointer;
}
.bnt_remove{
color: #F70909;
}
.bnt_save{
color: #4DB361;
}
.data_list table td {
line-height:20px;
padding: 0px;
height: 30px;
text-indent: 0%;
}
</style>
<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;}
</style>
</block>
<!-- 管理员用户组新增和编辑页面 -->
<block name="body">
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script src="__STATIC__/layer/extend/layer.ext.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '
<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">
';
</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<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 type="text/javascript" src="__STATIC__/laydate/laydate.js"></script>
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<div class="tab-wrap" id='pop-form' hidden>
<div class="tab-content tabcon1711">
<!-- 表单 -->
<form id="item-form" method="post" class="form-horizontal" style="margin-bottom: 40px;">
<!-- 基础文档模型 -->
<div id="tab1" class="tab-pane in tab1">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="l"><i class="mustmark">*</i>类型:</td>
<td class="r">
<select name="type" id='form-type' class="form-pop-select">
<option value="1">奖励</option>
<option value="2">惩罚</option>
</select>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>公司类型:</td>
<td class="r">
<select name="company_type" id='form-company-type' class="form-pop-select">
<?php foreach($companyTypes as $index => $type):?>
<option value="{$index}">{$type}</option>
<?php endforeach;?>
</select>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>公司/部门:</td>
<td class="r">
<select name="company_id" id='form-company-id' class="select_gallery form-pop-select">
<option value="0">其他</option>
</select>
</td>
</tr>
<tr>
<td class="l"></td>
<td class="r">
<input type="text" name="company_name" id='form-company-name' autocomplete="off" placeholder="请填写公司/部门" />
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>会长账号:</td>
<td class="r">
<select name="promote_account" id="form-promote-account" class="select_gallery form-pop-select">
<option value="0">其他</option>
</select>
</td>
</tr>
<tr>
<td class="l"></td>
<td class="r">
<input type="text" name="promote_account_input" autocomplete="off" id='form-promote-account-input' placeholder="请填写会长账号" />
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>结算方式:</td>
<td class="r">
<select name="settlement_type" id='form-settlement-type' class="form-pop-select">
<?php foreach($settlementTypes as $index => $type):?>
<option value="{$index}">{$type}</option>
<?php endforeach;?>
</select>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>金额</td>
<td class="r">
<input type="text" name="amount" id='form-amount' autocomplete="off" value="0" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="form-item cf">
<button class="submit_btn mlspacing" id="add-item" type="button" target-form="form-horizontal" style="margin-top: 10px;">
新增
</button>
</div>
</form>
</div>
</div>
<form action="{:U('StatementMangement/rewardManageSave')}" enctype="application/x-www-form-urlencoded" method="POST"
class="form-horizontal form_info_ml" id="form">
<div class="formtitle"><span>奖惩<?php if ($_GET['id']):?>编辑 <?php else:?>新增<?php endif;?></span></div>
<ul class="form_info ">
<input type="hidden" name="id" value="{$data.id}" />
<li>
<a class="btn" onclick="openForm()">
添加奖惩信息
</a>
</li>
<li>
<div class="data_list">
<div class="">
<table id="record-table" border="1px solid #ccc" >
<!-- 表头 -->
<thead>
<tr>
<th colspan='6'>奖励</th>
<th colspan='6'>惩罚</th>
</tr>
</thead>
<!-- 表头 -->
<thead>
<tr>
<th>公司类型</th>
<th>公司/部门</th>
<th>会长账号</th>
<th>结算方式</th>
<th>金额</th>
<th>操作</th>
<th>公司类型</th>
<th>公司/部门</th>
<th>会长账号</th>
<th>结算方式</th>
<th>金额</th>
<th>操作</th>
</tr>
</thead>
<!-- 列表 -->
<tbody id="table-body">
<?php for($i=0; $i<$data['maxCount']; $i++):?>
<tr class="<?php if (!isset($details[1][$i])): php?>empty-reward<?php endif; php?> <?php if (!isset($details[2][$i])): php?>empty-punish<?php endif; php?>">
<!-- 奖励信息 -->
<td class="reward-data-info" hidden>
<input class="info" name="settlement_info[]" hidden value='<?=$details[1][$i]['info'] ? json_encode($details[1][$i]['info']) : ''?>' />
</td>
<td class="reward-td company-type"><?=$companyTypes[$details[1][$i]['company_type']] ?? '-'?></td>
<td class="reward-td company-name"><?=$details[1][$i]['company_name'] ?? '-'?></td>
<td class="reward-td promote-account"><?=$details[1][$i]['promote_account'] ?? '-'?></td>
<td class="reward-td settlement-type"><?=$settlementTypes[$details[1][$i]['settlement_type']] ?? '-'?></td>
<td class='reward-amount reward-td amount'><?=$details[1][$i]['amount'] ?? '-'?></td>
<td class='reward-opt reward-td opt'><?php if (isset($details[1][$i])): php?><a onclick="removeItem(this, 'reward')">删除</a><?php else: php?> <?php endif; php?></td>
<!-- 惩罚信息 -->
<td class="punish-data-info" hidden>
<input class="info" name="settlement_info[]" hidden value='<?=$details[2][$i]['info'] ? json_encode($details[2][$i]['info']) : ''?>' />
</td>
<td class="punish-td company-type"><?=$companyTypes[$details[2][$i]['company_type']] ?? ''?></td>
<td class="punish-td company-name"><?=$details[2][$i]['company_name'] ?? ''?></td>
<td class="punish-td promote-account"><?=$details[2][$i]['promote_account'] ?? ''?></td>
<td class="punish-td settlement-type"><?=$settlementTypes[$details[2][$i]['settlement_type']] ?? ''?></td>
<td class='punish-amount punish-td amount'><?=$details[2][$i]['amount'] ?? ''?></td>
<td class='punish-opt punish-td opt'><?php if (isset($details[2][$i])): php?><a onclick="removeItem(this, 'punish')">删除</a><?php else: php?> <?php endif; php?></td>
</tr>
<?php endfor;?>
<tr id='total-amount'>
<td></td>
<td></td>
<td></td>
<td>合计</td>
<td id='total-reward-amount'>{$data['rewardAmount']}</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>合计</td>
<td id='total-punish-amount'>{$data['punishAmount']}</td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</li>
<?php if ($data['accounts']):?>
<?php foreach ($data['accounts'] as $k => $account):?>
<?php if ($k == 0):?>
<li class="user-account">
<?php if ($k == 0):?>
<label>涉及账号</label>
<?php else:?>
<label>-</label>
<?php endif;?>
<select name="user_type[]" class="select_gallery user_type" onchange="userAccountChange(this)">
<option value="1" <?php if ($account['user_type'] == 1):?>selected<?php endif;?>>推广员</option>
<option value="2" <?php if ($account['user_type'] == 2):?>selected<?php endif;?>>玩家</option>
</select>
<input type="text" class="txt table_text_input" name="account[]" value="{$account['account']}" placeholder="账号">
<button type="button" class="bnt_add"></button>
</li>
<?php else:?>
<li class="user-account">
<label>涉及账号</label>
<select name="user_type[]" class="user_type" onchange="userAccountChange(this)">
<option value="1" <?php if ($account['user_type'] == 1):?>selected<?php endif;?>>推广员</option>
<option value="2" <?php if ($account['user_type'] == 2):?>selected<?php endif;?>>玩家</option>
</select>
<input type="text" class="txt table_text_input" name="account[]" value="{$account['account']}" placeholder="账号">
<button type="button" class="bnt_remove"></button>
</li>
<?php endif;?>
<?php endforeach;?>
<?php else:?>
<li class="user-account">
<label>涉及账号</label>
<select name="user_type[]" class="user_type" onchange="userAccountChange(this)">
<option value="1">推广员</option>
<option value="2">玩家</option>
</select>
<input type="text" class="txt table_text_input" name="account[]" value="" placeholder="账号">
<button type="button" class="bnt_add"></button>
</li>
<?php endif;?>
<li>
<label>游戏</label>
<select id="relation_game_id" name="relation_game_id" class="select_gallery">
<option value="0">其他</option>
<?php foreach ($games as $game):?>
<option value="{$game['relation_game_id']}" <?php if ($game['relation_game_id'] == $data['relation_game_id']):?>selected<?php endif;?> >{$game['relation_game_name']}</option>
<?php endforeach;?>
</select>
</li>
<li>
<label>事件</label>
<textarea name="content" class="" id='content' placeholder="事件" >{$data.content}</textarea>
</li>
<li>
<label>奖惩时间</label>
<input type="text" id="reward_time" readonly name="reward_time" class="" value="{:date('Y-m-d',$data['reward_time'])}" placeholder="奖惩时间" />
</li>
<li>
<label>奖惩结算时间</label>
<input type="text" id="settlement_time" readonly name="settlement_time" class="" value="<?=$data['settlement_time'] ? date('Y-m-d',$data['settlement_time']) : ''?>" placeholder="奖惩时间" />
</li>
<li>
<label>奖惩确认时间</label>
<input type="text" id="confirm_time" readonly name="confirm_time" class="" value="{$data['confirm_time']}" placeholder="奖惩确认时间" />
</li>
<li>
<label>备注</label>
<textarea name="remark" class="" placeholder="备注" >{$data.remark}</textarea>
</li>
<li>
<label>&nbsp;</label>
<button class="submit_btn ajax-post" id="submit-btn" type="submit" target-form="form-horizontal">
确认保存
</button>
<input type="button" value="返 回" target-form="form-horizontal" class="form_btn" onclick="javascript:void(window.history.go(-1))">
</li>
</ul>
</form>
<div class="common_settings">
<span class="plus_icon"><span><img src="__IMG__/zwmimages/icon_jia.png"></span></span>
<form class="addShortcutIcon">
<input type="hidden" name="title" value="{$m_title}">
<input type="hidden" name="url" value="AuthManager/index">
</form>
<a class="ajax-post add-butn <notempty name='commonset'>addSIsetted</notempty>" href="javascript:;" target-form="addShortcutIcon" url="{:U('Think/addShortcutIcon')}"><img src="__IMG__/zwmimages/icon_jia.png"><span><notempty name='commonset'>已添加<else />添加至常用设置</notempty></span></a>
</div>
</block>
<block name="script">
<script type="text/javascript">
highlight_subnav('{:U('StatementMangement/rewardManageList')}');
$(".bnt_add").bind("click",function(){
var a= '<li class="user-account"><label>-</label><select name="user_type[]" class="select_gallery user_type" onchange="userAccountChange(this)"><option value="1">推广员</option><option value="2">玩家</option></select><input type="text" class="txt table_text_input" name="account[]" value="" placeholder="账号"><button type="button" class="bnt_remove">✖</button>';
$(".user-account:last").after(a);
});
$(".select_gallery").select2();
$(document).on('click', '.bnt_remove', function(){
$(this).parents('li').remove();
countAmount();
});
$(document).on('input propertychange', '#form-amount', function(){
if (!Number($(this).val())) {
s=$(this).val().substring(0,$(this).val().Length-1);
$(this).val(s);
layer.msg('请输入数字');
//countAmount();
return false;
}
//countAmount();
});
var date = new Date();
var monthStart = date.getFullYear()+'-0'+(date.getMonth()+1)+'-01';
$("#reward_time, #confirm_time, #settlement_time").each(function(){
laydate.render({
elem: this //指定元素
,type: 'date'
});
});
function openForm()
{
layer.open({
type : 1 ,
title:"新增",
area:['30%','60%'],
content: $('#pop-form'),
zIndex: 1,
end : function(){
resetPopForm();
}
});
}
/* $('#reward_time').datetimepicker({
language:"zh-CN",
hour: 13,
minute: 15,
setStartDate:'2020-02-01',
todayHighlight : true,
todayBtn:true
});*/
function removeItem(obj, type)
{
$(obj).parents('tr').children('.'+type+'-data-info').find('.info').val('');
$(obj).parents('tr').addClass('empty-'+type);
if ($(obj).parents('tr').hasClass('empty-reward') && $(obj).parents('tr').hasClass('empty-punish')) {
$(obj).parents('tr').remove();
} else {
$(obj).parents('tr').children('.'+type+'-td').each(function(index, item){
if (index < 6) {
$(item).html('');
} else {
//$(item).html('<a onclick="openForm()">添加</a>')
}
});
}
countAmount();
}
$(document).on('click', '#add-item', function(){
var data = {
type : $("#form-type").val(),
company_type : $("#form-company-type").val(),
company_type_desc : $("#form-company-type option:selected").text(),
company_id : $("#form-company-id").val(),
company_name : $("#form-company-name").val(),
//promote_account : $("#form-promote-account").val() ?? $("#form-promote-account-input").val(),
settlement_type : $("#form-settlement-type").val(),
settlement_type_desc : $("#form-settlement-type option:selected").text(),
amount : $("#form-amount").val()
};
if ($("#form-promote-account").val() == 0) {
data['promote_account'] = $("#form-promote-account-input").val();
} else {
data['promote_account'] = $("#form-promote-account").val();
}
if (data['amount'] == '0') {
layer.msg('请填写金额');
return false;
}
if (data['company_id'] == '0' && data['company_name'] == '') {
layer.msg('请选择或者填写公司/部门');
return false;
}
if (data['promote_account'] == '') {
layer.msg('请选择或者填写会长账号');
return false;
}
var flag = false;
// 判断相反的是否已经存在该公司节点
$('.reward-data-info,.punish-data-info').each(function(){
var node_info = $(this).find('.info').val();
if (node_info) {
var otherData = JSON.parse(node_info);
// console.log(otherData)
// console.log((data['company_id'] != '0' ? data['company_id'] == otherData['company_id'] : data['company_name'] == otherData['company_name']) );
// console.log(data['company_type'] == otherData['company_type'] );
// 判断对立面是否有相同的公司或者部门
if ((data['company_type'] == otherData['company_type'])
&& (data['company_id'] != '0' ? data['company_id'] == otherData['company_id'] : data['company_name'] == otherData['company_name']) ) {
//console.log('已有相此公司的奖罚,请检查')
layer.closeAll();
layer.msg('已有此公司的奖罚,请检查');
flag = true;
}
}
});
if (flag) {
return false;
}
var type_dec = data['type'] == 1 ? 'reward' : 'punish';
// 找到空闲的节点,如果没有,则创建一行
var emptyNode = $('.table-body tr,.empty-'+type_dec+':first');
if (emptyNode.length == 0) {
var newNodeHtml =
`<tr class="empty-reward empty-punish">
<!-- 奖励信息 -->
<td class="reward-data-info" hidden>
<input class="info" name="settlement_info[]" hidden value='' />
</td>
<td class="reward-td company-type"></td>
<td class="reward-td company-name"></td>
<td class="reward-td promote-account"></td>
<td class="reward-td settlement-type"></td>
<td class='reward-amount reward-td amount'></td>
<td class='reward-opt reward-td opt'></td>
<!-- 惩罚信息 -->
<td class="punish-data-info" hidden>
<input class="info" name="settlement_info[]" hidden value='' />
</td>
<td class="punish-td company-type"></td>
<td class="punish-td company-name"></td>
<td class="punish-td promote-account"></td>
<td class="punish-td settlement-type"></td>
<td class='punish-amount punish-td amount'></td>
<td class='punish-opt punish-td opt'></td>
</tr>`;
$('#total-amount').before(newNodeHtml);
emptyNode = $('.table-body tr,.empty-'+type_dec+':first');
}
$(emptyNode).children('.'+type_dec+'-data-info').find('.info').val(JSON.stringify(data));
$(emptyNode).children('.'+type_dec+'-td').each(function(index, item){
if ($(item).hasClass('company-type')) {
$(item).text(data['company_type_desc'])
} else if ($(item).hasClass('company-name')) {
$(item).text(data['company_name'])
} else if ($(item).hasClass('promote-account')) {
$(item).text(data['promote_account'])
} else if ($(item).hasClass('settlement-type')) {
$(item).text(data['settlement_type_desc'])
} else if ($(item).hasClass('amount')) {
$(item).text(data['amount'])
} else if ($(item).hasClass('opt')) {
$(item).html(`<a onclick="removeItem(this, '`+type_dec+`')">删除</a>`)
}
});
$(emptyNode).removeClass('empty-'+type_dec);
countAmount();
resetPopForm();
layer.closeAll();
});
function resetPopForm()
{
$('#item-form')[0].reset() // 重置数据
$('.form-pop-select').select2();
companyTypeChange();
$('#form-company-name').attr('readonly', false);
$('#form-promote-account-input').attr('readonly', false);
var promoteData = "<option value='0' selected>其他</option>";
$("#form-promote-account").empty();
$('#form-promote-account').html(promoteData);
$("#form-promote-account").select2();
}
// 全部总金额重算
function countAmount()
{
var reward_amount = punish_amount = 0;
$('.reward-amount').each(function(index, item){
if (Number($(item).text()) != null) {
reward_amount += Number($(item).text());
}
});
$('#total-reward-amount').text(reward_amount);
$('.punish-amount').each(function(index, item){
if (Number($(item).text())) {
punish_amount += Number($(item).text());
}
});
$('#total-punish-amount').text(punish_amount);
}
// 修改公司类型时候
$(document).on('change', '#form-company-type', function(){
companyTypeChange();
});
$(document).on('change', '#form-company-id', function(){
promoteChange();
});
$(document).on('change', '#form-promote-account', function(){
var promoteAccount = $('#form-promote-account').val();
if (promoteAccount == 0) {
$("#form-promote-account-input").attr("readonly",false)
$("#form-promote-account-input").val('');
} else {
$("#form-promote-account-input").attr("readonly",true).val($(this).val());
}
});
function promoteChange() {
var companyId = $('#form-company-id').val();
var companyType = $('#form-company-type').val();
// 如果选择为其他,则开放填写
if (companyId == 0) {
$("#form-company-name").attr("readonly",false)
$("#form-company-name").val('');
} else if (companyType == 1) { // 上游公司没有下级会长
var promoteData = "<option value='0' selected>其他</option>";
$("#form-promote-account").empty();
$('#form-promote-account').html(promoteData);
$("#form-promote-account").select2();
$("#form-promote-account-input").attr("readonly",false)
$("#form-company-name").attr("readonly",true)
$("#form-company-name").val($('#form-company-id option:selected').text());
} else {
$.ajax({
url:"{:U('Ajax/getPromotersByCompanyid')}",
dataType:'JSON',
data: {'company_id':companyId},
success:function(response){
var promoteData = "<option value='0'>其他</option>";
$.each(response.data, function(index, item){
promoteData += "<option value='"+item.account+"' >"+item.account+"</option>";
});
$("#form-promote-account").empty();
$('#form-promote-account').html(promoteData);
$("#form-promote-account").select2();
$("#form-promote-account-input").attr("readonly",false)
$("#form-company-name").attr("readonly",true)
$("#form-company-name").val($('#form-company-id option:selected').text());
}
});
}
}
// var company_id = '{$data["company_id"]}';
function companyTypeChange()
{
var companyType = $('#form-company-type').val();
// 如果公司类型为内部的时候,公司部门仅其他
if (companyType == 3) {
var companyData = "<option value='0' selected>其他</option>";
$("#form-company-id").empty();
$('#form-company-id').html(companyData);
$("#form-company-id").select2();
$("#form-company-name").attr("readonly",false)
} else {
$.ajax({
url:"{:U('StatementMangement/getCompanys')}",
dataType:'JSON',
data: {'type':companyType},
success:function(response){
var companyData = "<option value='0'>其他</option>";
$.each(response.info, function(index, item){
companyData += "<option value='"+item.id+"' >"+item.name+"</option>";
});
$("#form-company-id").empty();
$('#form-company-id').html(companyData);
$("#form-company-id").select2();
$("#form-company-name").attr("readonly",true)
//$('#company_id').html(companyData);
promoteChange();
}
});
}
}
companyTypeChange();
// $('#submit-btn').on('click', function(){
// var data = {
// relation_game_id : $('#relation_game_id').val(),
// content : $('#content').text(),
// reward_time : $('#reward_time').val(),
// settlement_time : $('#settlement_time').val(),
// confirm_time : $('#confirm_time').val(),
// remark : $('#remark').val()
// };
// return false;
// })
</script>
</block>