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.

467 lines
18 KiB
HTML

<extend name="Public/base" />
<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>
<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;
}
a:link ,a:visited,a:hover,a:active { text-decoration: none;}
.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;}
.data_list table tbody tr a.disabled,.data_list table tbody tr a.disabled:hover {color:#999;cursor:default;}
.layui-layer-title {
text-align: center;
height: 80px;
line-height: 80px;
font-weight: 600;
font-size: 18px;
}
.data_list table td{
line-height: 2;
}
.layui-layer-title {
text-align: center;
height: 42px;
line-height: 42px;
font-weight: 400;
font-size: 14px;
}
.main-place .question_content:before{
right: 20px;
left: auto;
}
.tabcon1711 td:first-child {
width: auto;
}
</style>
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">新增excel导入</h3>
<p class="description_text">说明:奖惩绩效数据</p>
</div>
<!-- 标签页导航 -->
<div class="tab-wrap" style="display: flex;">
<div class="tab-content tabcon1711" style="min-width:700px;">
<!-- 基础文档模型 -->
<div id="tab1" class="tab-pane in tab1">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="l">本次批次号:</td>
<td class="r">
<div class="input-list" id="batch" style="margin-left: 0;line-height: 30px;font-size: 16px;">
</div>
<span class="notice-text" style="margin-left: 20px;">用于检索使用</span>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>文件上传:</td>
<td class="r">
<div class="input-list" style="margin-left: 0;">
<input type="file" id="fileinput" name="file">
</div>
<span class="notice-text" style="margin-left: 0;">暂只支持.xls .xlsx 格式文件</span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="form-item cf">
<button class="submit_btn" id="submit_btn">
保存
</button>
<a class="submit_btn " alt="下载模板" title="下载模板" href="{:U('download')}">
下载模板
</a>
<a class="submit_btn " alt="返回上一页" title="返回上一页" href="javascript:window.history.back();">
返回
</a>
</div>
</div>
</div>
<div style="margin-top: 60px;" id="firle">
<div style="width: 100%;height: 45px;font-size: 16px;">
文件格式参考:<span style="color: #777;font-size: 12px;margin-left: 20px;">请严格按此格式,文件的第一行必须是字段名,且字段名不允许修改</span>
</div>
<style>
#firle td,#firle th{
padding: 10px 5px;
}
</style>
<table id="cktable" style="width: 100%;margin: 0;padding: 0;text-align: center;border: 1px solid #777;" border="1px">
<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>
<th>奖惩金额</th>
<th>结算方式</th>
<th>奖惩类型</th>
<th>结算公司类型</th>
<th>结算方</th>
<th>会长账号</th>
<th>奖惩金额</th>
<th>结算方式</th>
<th>添加人</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>九天仙尘</td>
<td>广州乐牛软件科技有限公司</td>
<td>2021-01-01</td>
<td>2021-01-01</td>
<td>2021-01-01</td>
<td>私聊非自己的玩家并发微信给玩家存在换端的嫌疑违反平台规则罚款1500元</td>
<td>双向</td>
<td>惩罚方</td>
<td>下游公司</td>
<td>南昌醉游网络科技有限公司</td>
<td>ncsywl</td>
<td>-1501</td>
<td>线上结算</td>
<td>奖励方</td>
<td>下游公司</td>
<td>万盟天下科技</td>
<td>kefuguanlian</td>
<td>1500</td>
<td>线上结算</td>
<td>wmtxhh</td>
</tr>
</tbody>
</table>
</div>
<div style="width: 100vw;height: 100vh;padding: 0;position: absolute;top: 0;z-index: 9999;display: none;" id="creat_msg">
<div class="layui-layer layui-layer-dialog layui-layer-border layui-layer-msg layui-layer-hui"
type="dialog" times="1" showtime="50000" contype="string" style="z-index: 19891015; top:30%; left:30%;">
<div class="layui-layer-content" style="padding: 15px 0 5px;font-size: 20px;font-weight: 600;">执行进度</div>
<div id="tip_msg" class="layui-layer-content">开始时间与结束时间都不允许为空</div>
<div class="layui-layer-content" style="padding: 5px 10px 15px;font-size: 10px;color: #BBB;">TIP:未执行完成之前请勿刷新或关闭此页面</div>
<span class="layui-layer-setwin"></span>
</div>
</div>
</block>
<block name="script">
<script>
<volist name=":I('get.')" id="vo">
Think.setValue('{$key}',"{$vo}");
</volist>
$(".select_gallery").select2();
</script>
<script type="text/javascript" src="__STATIC__/xlsx.core.min.js" charset="UTF-8"></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__/layer3/layer.js"></script>
<script type="text/javascript">
//导航高亮
highlight_subnav('{:U('rewardManageList')}');
var MSG={
showmsg:function(str){
$("#creat_msg").show();
$("#tip_msg").html(str);
},
hidemsg:function(){
$("#creat_msg").hide();
$("#tip_msg").html('');
}
}
var COMPARE={
publiucAjax:function(url,senddata,callback){
$.ajax({
type: 'post',
url: url,
data:senddata,
success: function(data) {
if(data.status == 1){
callback();
}else{
MSG.hidemsg();
layer.alert(data.msg);
return false;
}
},
error:function(){
MSG.hidemsg();
layer.alert("网络错误或超时");
return false;
}
});
},
//循环比较
loopCheck:function(page,callback){
if(page > sendDefaultData.check_page){
MSG.showmsg("添加成功,执行跳转中");
callback();
return;
}
var senddata = {
statement_begin_time:sendDefaultData.begin_time,
statement_end_time:sendDefaultData.end_time,
batch:sendDefaultData.batch,
checkarr:sendDefaultData.filedata.splice(0,check_size)
}
COMPARE.publiucAjax("{:U('loopAdd')}",senddata,function(data){
var checkok = page*check_size > sendDefaultData.filedata_count ? sendDefaultData.filedata_count : page*check_size;
MSG.showmsg("数据插入 ["+checkok+"/"+sendDefaultData.filedata_count+"] ......");
page++;
COMPARE.loopCheck(page,callback)
});
},
checkData:function(callback){
MSG.showmsg("数据校验中...");
var d = sendDefaultData.filedata;
for (const key in d) {
var c = d[key].company_info;
}
callback();
}
}
</script>
<script type="text/javascript">
var isfile = false;
var rABS = false; //是否将文件读取为二进制字符串
var check_size = 999;//每次验证的数量
var batch = '{$batch}';
var sendDefaultData = {
"filedata_count": 0,
"check_page":0,
"filedata":[],
"pay_way":-1,
"batch":batch
}
$("#batch").html(batch);
$(function () {
$("#submit_btn").on("click", function () {
//获取文件
if (!isfile) {
layer.msg('excel文件不能为空');
return false;
}
//执行
readFileInput(function () {
if(sendDefaultData.filedata_count == 0){
MSG.hidemsg();
layer.msg('excel内容不能为空');
return false;
}
//获取需要循环的次数
sendDefaultData.check_page = Math.ceil(sendDefaultData.filedata_count/check_size);
COMPARE.checkData(function(){
COMPARE.loopCheck(1,function(){
setTimeout(function(){
window.location.href="{:U('rewardManageList')}";
},1500);
})
});
})
})
$("#fileinput").change(function () {
var p = $(this).val();
var ext = p.substr(p.lastIndexOf(".")).toLowerCase();
if (ext != ".xls" && ext != ".xlsx") {
layer.msg("文件仅支持excel文件格式");
$(this).val('');
p = '';
}
if (p != '') {
isfile = true;
} else {
isfile = false;
}
})
});
function readFileInput(callback) {
MSG.showmsg("读取excle中。。。");
var wb;//读取完成的数据
var f = $("#fileinput")[0].files[0];
var reader = new FileReader();
if (rABS) {
reader.readAsArrayBuffer(f);
} else {
reader.readAsBinaryString(f);
}
reader.onload = function (e) {
MSG.showmsg("文件读取完成,添加命令初始化。。。");
var data = e.target.result;
if (rABS) {
wb = XLSX.read(btoa(fixdata(data)), {
type: 'base64'
});
} else {
wb = XLSX.read(data, {
type: 'binary'
});
}
// console.log(wb);
try {
var filedata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
sendDefaultData.filedata = resetCount(filedata);
sendDefaultData.filedata_count = sendDefaultData.filedata.length;
callback();
} catch (error) {
MSG.hidemsg();
isfile = false;
layer.msg('excel内容不符或不能为空');
return false;
}
// document.getElementById("demo").innerHTML= JSON.stringify( XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]) );
};
}
function resetCount(fdata){
var titleKey={
"序号": "sort",
"游戏名": "game_name",
"游戏合作方": "partner",
"奖惩时间":"reward_time",
"结算时间":"settlement_time",
"奖惩确认时间":"confirm_time",
"事件说明":"content",
"奖惩性质":"reward_type",
"奖惩类型":"type",
"结算公司类型":"company_type",
"结算方":"company_name",
"会长账号":"promote_account",
"奖惩金额":"amount",
"结算方式":"settlement_type",
"奖惩类型_1":"type_1",
"结算公司类型_1":"company_type_1",
"结算方_1":"company_name_1",
"会长账号_1":"promote_account_1",
"奖惩金额_1":"amount_1",
"结算方式_1":"settlement_type_1",
"添加人":"creater_id",
};
var data = [];
//临时公司
var temp ={};
for (let index = 0; index < fdata.length; index++) {
const e = fdata[index];
//全量公司
if (e.hasOwnProperty("序号")) {
for (const k in e) {
temp[titleKey[k]] = e[k];
console.log(e[k]);
}
data.push(temp);//上次的走掉
temp ={};//重置
}
}
data.push(temp);//最后一次
return data;
}
function getNowDate(){
var da = new Date();
var trade =da.getFullYear();
var mt =da.getMonth() + 1 >10 ? da.getMonth() + 1 : "0"+(da.getMonth() + 1);
var dt =da.getDate() >=10 ? da.getDate() : "0"+da.getDate();
var dh =da.getHours() >=10 ? da.getHours() : "0"+da.getHours();
var dm =da.getMinutes() >=10 ? da.getMinutes() : "0"+da.getMinutes();
var ds =da.getSeconds() >=10 ? da.getSeconds() : "0"+da.getSeconds();
var dms =(Array(3).join(0) + da.getMilliseconds()).slice(-3);
return trade+=""+mt+""+dt+""+dh+""+dm+""+ds+''+dms;
}
function fixdata(data) { //文件流转BinaryString
var o = "",
l = 0,
w = 10240;
for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
return o;
}
$('#time_start').datetimepicker({
format: 'yyyy-mm-dd',
language: "zh-CN",
minView: 2,
autoclose: true
});
$('#datetimepicker').datetimepicker({
format: 'yyyy-mm-dd',
language: "zh-CN",
minView: 2,
autoclose: true,
pickerPosition: 'bottom-left'
})
</script>
</block>