财务比较3

master
chenzhi 5 years ago
parent def286ec80
commit effe6c572e

@ -13,8 +13,18 @@ class FinanceCompareController extends ThinkController
} }
public function creatCompare() public function creatCompare()
{ {
$adddata = I("post.");
# code... $adddata['create_time'] = time();
$adddata['begin_time'] = strtotime($adddata['begin_time']);
$adddata['end_time'] = strtotime($adddata['end_time'])+ 86399;
$res = M("finance_compare","tab_")->add($adddata);
if($res){
$this->ajaxReturn(array("success"=>"ok","code"=>0,"data"=>["id"=>$res]));
}else{
$this->ajaxReturn(array("error"=>"creat error","code"=>4000));
}
} }
public function compareData() public function compareData()
{ {

@ -1,164 +1,309 @@
<extend name="Public/base" /> <extend name="Public/base" />
<block name="body"> <block name="body">
<link rel="stylesheet" type="text/css" href="__CSS__/admin_table.css" media="all"> <link rel="stylesheet" type="text/css" href="__CSS__/admin_table.css" media="all">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css"> <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> <php>if(C('COLOR_STYLE')=='blue_color') echo '
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css"> <link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<style> <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
.tabcon1711 td:first-child{ <style>
width:auto; .tabcon1711 td:first-child {
width: auto;
}
</style> }
</style>
<div class="cf main-place top_nav_list navtab_list"> <div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">新增推广员</h3> <h3 class="page_title">新增推广员</h3>
<p class="description_text">说明:此功是创建推广员时所需填写信息</p> <p class="description_text">说明:此功是创建推广员时所需填写信息</p>
</div> </div>
<!-- 标签页导航 --> <!-- 标签页导航 -->
<div class="tab-wrap" style="display: flex;"> <div class="tab-wrap" style="display: flex;">
<div class="tab-content tabcon1711" style="min-width:50%;"> <div class="tab-content tabcon1711" style="min-width:50%;">
<!-- 基础文档模型 --> <!-- 基础文档模型 -->
<div id="tab1" class="tab-pane in tab1"> <div id="tab1" class="tab-pane in tab1">
<table border="0" cellspacing="0" cellpadding="0"> <table border="0" cellspacing="0" cellpadding="0">
<tbody> <tbody>
<tr> <tr>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>校验时间:</td> <td class="l"><i class="mustmark" style="margin-left:-7px">*</i>校验时间:</td>
<td class="r"> <td class="r">
<div class="input-list" style="margin-left: 0;"> <div class="input-list" style="margin-left: 0;">
<input type="text" readonly id="time_start" name="time_start" class="" value="{:I('time_start')}" placeholder="开始时间" /> <input type="text" readonly id="time_start" name="time_start" class=""
&nbsp;-&nbsp; value="{:I('time_start')}" placeholder="开始时间" />
<div class="input-append date" id="datetimepicker" style="display:inline-block"> &nbsp;-&nbsp;
<input type="text" readonly id="time_end" name="time_end" class="" value="{:I('time_end')}" placeholder="结束时间" /> <div class="input-append date" id="datetimepicker" style="display:inline-block">
<span class="add-on"><i class="icon-th"></i></span> <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>
<span class="notice-text" style="margin-left: 0;">请选择不超过31天的时间</span>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>支付渠道:</td>
<td class="r">
<select name="pay_way" id="pay_way">
<option value="-1">请选择支付渠道</option>
<option value="1">支付宝</option>
<option value="2">微信</option>
<option value="3">易宝</option>
</select>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>Excel文件上传:</td>
<td class="r">
<div class="input-list" style="margin-left: 0;">
<input type="file" id="fileinput" name="file">
</div> </div>
</div> <span class="notice-text" style="margin-left: 0;">暂只支持.xls .xlsx 格式文件</span>
<span class="notice-text" style="margin-left: 0;">请选择不超过31天的时间</span> </td>
</td> </tr>
</tr>
<tr> </tbody>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>支付渠道:</td> </table>
<td class="r"> </div>
<select name="company_id" id="company_id"> <div class="form-item cf">
<option value="-1">请选择支付渠道</option> <button class="submit_btn" id="submit_btn">
<option value="1">支付宝</option> 保存
<option value="2">微信</option> </button>
<option value="3">易宝</option> <a class="submit_btn " alt="返回上一页" title="返回上一页" href="javascript:window.history.back();">
</select> 返回
</td> </a>
</tr> </div>
<tr> </div>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>Excel文件上传:</td> <div>
<td class="r"> 4654654646
<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>
<div class="form-item cf">
<button class="submit_btn ajax-post mlspacing" id="submit" type="submit" target-form="form-horizontal">
保存
</button>
<a class="submit_btn " alt="返回上一页" title="返回上一页" href="javascript:window.history.back();" >
返回
</a>
</div>
</div> </div>
<div> <div style="width: 100vw;height: 100vh;padding: 0;position: absolute;top: 0;z-index: 9999;display: none;" id="creat_msg">
4654654646 <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: 45%;">
<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> </div>
</div>
</block> </block>
<block name="script"> <block name="script">
<script type="text/javascript" src="__STATIC__/xlsx.core.min.js" charset="UTF-8"></script> <script type="text/javascript" src="__STATIC__/xlsx.core.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.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 type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"
<script type="text/javascript"> charset="UTF-8"></script>
//导航高亮 <script type="text/javascript" src="__STATIC__/layer3/layer.js"></script>
highlight_subnav('{:U('Promote/lists')}'); <script type="text/javascript">
Think.setValue("game_type_id", {$data.game_type_id|default = 0}); //导航高亮
Think.setValue("category", {$data.category|default = 0}); highlight_subnav("{:U('Promote/lists')}");
</script> var MSG={
<script type="text/javascript"> showmsg:function(str){
$("#creat_msg").show();
$(function(){ $("#tip_msg").html(str);
showTab(); },
var wb;//读取完成的数据 hidemsg:function(){
var rABS = false; //是否将文件读取为二进制字符串 $("#creat_msg").hide();
function fixdata(data) { //文件流转BinaryString $("#tip_msg").html('');
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;
}
$("#fileinput").change(function(){
if(!this.files) {
return;
}
var f = this.files[0];
var reader = new FileReader();
if(rABS) {
reader.readAsArrayBuffer(f);
} else {
reader.readAsBinaryString(f);
} }
reader.onload = function(e) { var COMPARE={
var data = e.target.result; publiucAjax:function(url,senddata,callback){
if(rABS) { $.ajax({
wb = XLSX.read(btoa(fixdata(data)),{ type: 'post',
type: 'base64' url: url,
data:senddata,
success: function(data) {
if(data.success){
callback(data.data);
}else{
MSG.hidemsg();
layer.msg(data.error);
return false;
}
},
}); });
} else { },
wb = XLSX.read(data,{ //创建面单
type: 'binary' creatCompare:function(senddata,callback){
COMPARE.publiucAjax("{:U('creatCompare')}",senddata,function(data){
sendDefaultData.compare_id = data.id;
MSG.showmsg("初始化完成,开始比较数据 [0/"+sendDefaultData.filedata_count+"] ......");
callback();
}); });
},
//循环比较
loopCheck:function(page,callback){
if(page > sendDefaultData.check_page){
callback();
return;
}
var checkarr = sendDefaultData.filedata.splice(0,check_size);
console.log(checkarr);
page++;
COMPARE.loopCheck(page,callback)
} }
console.log(wb.Sheets[wb.SheetNames[0]])
console.log(wb.Sheets[wb.SheetNames[0]]["A1"]["v"])
console.log(wb.Sheets[wb.SheetNames[0]]["B1"]["v"])
console.log(XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]) )
// document.getElementById("demo").innerHTML= JSON.stringify( XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]) );
};
})
}
</script>
<script type="text/javascript">
var isfile = false;
var rABS = false; //是否将文件读取为二进制字符串
var check_size = 10;//每次验证的数量
}); var sendDefaultData = {
"keys": [],
"filedata_count": 0,
"compare_id": 0,
"check_page":0,
"filedata":[]
}
$('#time_start').datetimepicker({ $(function () {
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> $("#submit_btn").on("click", function () {
</block> var start = $("#time_start").val();
var end = $("#time_end").val();
var sdate = Date.parse(start) / 1000;
var edate = Date.parse(end) / 1000;
if (start == '' || end == '') {
layer.msg('开始时间与结束时间都不允许为空');
return false;
}
if (sdate > edate) {
layer.msg('开始时间必须小于等于结束时间');
return false;
}
if ((edate - sdate) > 2592000) {
layer.msg('时间间隔不能超过31天请重新选择日期');
return false;
}
//获取渠道
var paychannel = $("#pay_way option:selected").val();
if (paychannel == -1) {
layer.msg('请选择支付渠道');
return false;
}
//获取文件
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);
//创建面单
var senddata = {
begin_time:start,
end_time:end,
pay_way:paychannel,
check_count:sendDefaultData.filedata_count
}
COMPARE.creatCompare(senddata,function(){
COMPARE.loopCheck(1,function(){
})
})
})
})
$("#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'
});
}
try {
sendDefaultData.keys.push(wb.Sheets[wb.SheetNames[0]]["A1"]["v"]);
sendDefaultData.keys.push(wb.Sheets[wb.SheetNames[0]]["B1"]["v"]);
sendDefaultData.filedata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
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 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>
Loading…
Cancel
Save