公会信息导入导出

master
tping 4 years ago
parent 24fcfc4b90
commit 824b7b3f06

@ -13,8 +13,6 @@ use Base\Service\PartnerService;
class SocietyInfoController extends ThinkController class SocietyInfoController extends ThinkController
{ {
private $modelName = 'SocietyInfo'; private $modelName = 'SocietyInfo';
public $OpAuthList=[];
public $aggregatePackageName = [];
public function _initialize() public function _initialize()
{ {
@ -61,17 +59,19 @@ class SocietyInfoController extends ThinkController
$query = $model->where($map)->order("id desc"); $query = $model->where($map)->order("id desc");
$count = $query->count(); $count = $query->count();
if($is_export){ if($is_export){
$parseData = $query->field("*")->select(); $parseData = $query->field("province, city, company_name, register_capital, functionary, phone, wechat, qq, game_type, game_name, join_platform, promote_scale, turnover, address, league_info, is_potential, remark, interface_person, create_time, communication_time, create_account")->select();
foreach ($parseData as &$v) { foreach ($parseData as &$v) {
if ($v['is_potential'] == 1) $v['is_potential'] = "是"; if ($v['is_potential'] == 1) $v['is_potential'] = "是";
else $v['is_potential'] = "否"; else $v['is_potential'] = "否";
unset($v['id']);
unset($v['game_id']);
unset($v['update_time']);
} }
$this->assign('listData', $parseData); addOperationLog(['op_type'=>3,'key'=>getNowDate(),'url'=>U(CONTROLLER_NAME.'/'.ACTION_NAME, I('get.*')),'menu'=>"推广-公会信息-导出"]);
$GetData = $_GET; $head = ["省份", "城市", "公司", "注册资本", "负责人", "电话", "微信", "QQ", "游戏类型", "所做游戏",
unset($GetData['export']); "合作平台", "推广规模", "流水", "地址", "联盟信息", "是否为意向客户", "备注信息", "对接人", "录入时间", "最后沟通时间", "录入员"];
addOperationLog(['op_type'=>3,'key'=>getNowDate(),'url'=>U(CONTROLLER_NAME.'/'.ACTION_NAME,$GetData),'menu'=>"推广-公会信息-导出"]); $this->export($head, $parseData, "公会信息-".date('Ymd'));
$this->display("export"); return ;
die();
} else { } else {
$societyInfos = $model->where($map)->order("id desc")->field("*")->page($page,$row)->select(); $societyInfos = $model->where($map)->order("id desc")->field("*")->page($page,$row)->select();
} }
@ -101,7 +101,40 @@ class SocietyInfoController extends ThinkController
$this->display(); $this->display();
} }
// // 导出
public function export($head, $body, $filename, $title='') {
Vendor("PHPExcel.PHPExcel");
$objPHPExcel = new \PHPExcel();
$startRow = 1; //从第一行开始
$i='A';
foreach($head as $item){
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($i.$startRow, $item);
$i++;
}
//主体数据
foreach($body as $key=>$value){
$startRow++;
$index='A';
foreach($value as $k=>$v){
$objPHPExcel->getActiveSheet()->getStyle($index.$startRow)->getNumberFormat()->setFormatCode("@"); //文本格式
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($index.$startRow, $v);
$index++;
}
}
if ($title) {
$objPHPExcel->getActiveSheet()->setTitle($title);
}
$objPHPExcel->setActiveSheetIndex(0);
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$filename.'.xlsx"');
header('Cache-Control: max-age=0');
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
ob_end_clean();
$objWriter->save('php://output');
}
// 时间间隔设置
public function timeset() { public function timeset() {
$config = M('config', 'sys_')->where([ $config = M('config', 'sys_')->where([
'name' => 'SOCIETY_INFO_COMMUNITION_GAP' 'name' => 'SOCIETY_INFO_COMMUNITION_GAP'
@ -227,6 +260,9 @@ class SocietyInfoController extends ThinkController
if ($_POST) { if ($_POST) {
$save = I("post."); $save = I("post.");
if (empty($save['company_name'])) {
$this->error("公司为必填项");
}
if ($save['province'] == "请选择省份") $save['province'] = ''; if ($save['province'] == "请选择省份") $save['province'] = '';
if ($save['city'] == "请选择城市") $save['city'] = ''; if ($save['city'] == "请选择城市") $save['city'] = '';
$save['create_time'] = time(); $save['create_time'] = time();
@ -340,31 +376,34 @@ class SocietyInfoController extends ThinkController
$datas = $this->parseExcelIn($filename, $exts); $datas = $this->parseExcelIn($filename, $exts);
$inserts = []; $inserts = [];
foreach ($datas as $k => $v) { foreach ($datas as $k => $v) {
foreach ($v as $p) { /*foreach ($v as $p) {
if (!$p) { if (!$p) {
$this->error("数据不能为空"); $this->error("数据不能为空");
} }
} }*/
if ($k == 1) continue; if ($k == 1) continue;
$inserts[$k-2]['province'] = $v['A']; $inserts[$k-2]['province'] = $v['A'] ?? '';
$inserts[$k-2]['city'] = $v['B']; $inserts[$k-2]['city'] = $v['B'] ?? '';
$inserts[$k-2]['company_name'] = $v['C']; $inserts[$k-2]['company_name'] = $v['C'] ?? '';
$inserts[$k-2]['register_capital'] = $v['D']; if (!$inserts[$k-2]['company_name']) {
$inserts[$k-2]['functionary'] = $v['E']; $this->error("公司不能为空");
$inserts[$k-2]['phone'] = $v['F']; }
$inserts[$k-2]['wechat'] = $v['G']; $inserts[$k-2]['register_capital'] = $v['D'] ?? '';
$inserts[$k-2]['qq'] = $v['H']; $inserts[$k-2]['functionary'] = $v['E'] ?? '';
$inserts[$k-2]['game_type'] = $v['I']; $inserts[$k-2]['phone'] = $v['F'] ?? '';
$inserts[$k-2]['game_name'] = $v['J']; $inserts[$k-2]['wechat'] = $v['G'] ?? '';
$inserts[$k-2]['join_platform'] = $v['K']; $inserts[$k-2]['qq'] = $v['H'] ?? '';
$inserts[$k-2]['promote_scale'] = $v['L']; $inserts[$k-2]['game_type'] = $v['I'] ?? '';
$inserts[$k-2]['turnover'] = $v['M']; $inserts[$k-2]['game_name'] = $v['J'] ?? '';
$inserts[$k-2]['address'] = $v['N']; $inserts[$k-2]['join_platform'] = $v['K'] ?? '';
$inserts[$k-2]['league_info'] = $v['O']; $inserts[$k-2]['promote_scale'] = $v['L'] ?? '';
$inserts[$k-2]['turnover'] = $v['M'] ?? '';
$inserts[$k-2]['address'] = $v['N'] ?? '';
$inserts[$k-2]['league_info'] = $v['O'] ?? '';
$inserts[$k-2]['is_potential'] = $v['P']=="是" ? 1 : 0; $inserts[$k-2]['is_potential'] = $v['P']=="是" ? 1 : 0;
$inserts[$k-2]['remark'] = $v['Q']; $inserts[$k-2]['remark'] = $v['Q'] ?? '';
$inserts[$k-2]['interface_person'] = $v['R']; $inserts[$k-2]['interface_person'] = $v['R'] ?? '';
$inserts[$k-2]['create_time'] = time(); $inserts[$k-2]['create_time'] = time();
$inserts[$k-2]['update_time'] = time(); $inserts[$k-2]['update_time'] = time();
$inserts[$k-2]['communication_time'] = time(); $inserts[$k-2]['communication_time'] = time();

@ -1,147 +0,0 @@
<extend name="Public/base"/>
<block name="body">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<script src="__STATIC__/table2excel.js"></script>
<style>
html{
opacity: 0;
}
.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;}
.data_list table td{
text-indent:0;
}
</style>
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">{$meta_title}</h3>
</div>
<!-- 数据列表 -->
<div class="data_list data_game_list">
<!-- <div style="margin:auto;font-size: 20px;color: red;line-height: 3;padding: 20px;">
导出进行中。。。<br/>
如果导出成功你也可以手动关闭此页面
</div> -->
<div class="">
<table border="1" id="exporttable">
<!-- 表头 -->
<thead>
<tr>
<th>省份</th>
<th>城市</th>
<th>公司</th>
<th>注册资本</th>
<th>负责人</th>
<th>电话</th>
<th>微信</th>
<th>QQ</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>
<empty name ="listData">
<td colspan="15" class="text-center">aOh! 暂时还没有内容!</td>
<else />
<volist name="listData" id="data">
<tr>
<td rowspan="{$data.row}">{$data.province}</td>
<td rowspan="{$data.row}">{$data.city}</td>
<td rowspan="{$data.row}">{$data.company_name}</td>
<td rowspan="{$data.row}">{$data.register_capital}</td>
<td rowspan="{$data.row}">{$data.functionary}</td>
<td rowspan="{$data.row}">{$data.phone}</td>
<td rowspan="{$data.row}">{$data.wechat}</td>
<td rowspan="{$data.row}">{$data.qq}</td>
<td rowspan="{$data.row}">{$data.game_type}</td>
<td rowspan="{$data.row}">{$data.game_name}</td>
<td rowspan="{$data.row}">{$data.join_platform}</td>
<td rowspan="{$data.row}">{$data.promote_scale}</td>
<td rowspan="{$data.row}">{$data.turnover}</td>
<td rowspan="{$data.row}">{$data.address}</td>
<td rowspan="{$data.row}">{$data.league_info}</td>
<td rowspan="{$data.row}">{$data.is_potential}</td>
<td rowspan="{$data.row}">{$data.remark}</td>
<td rowspan="{$data.row}">{$data.interface_person}</td>
<td rowspan="{$data.row}">{$data.create_time|date='Y-m-d H:i:s', ###}</td>
<td rowspan="{$data.row}">{$data.communication_time|date='Y-m-d H:i:s', ###}</td>
</tr>
</volist>
</empty>
</tbody>
</table>
</div>
</div>
<div class="page">
{$_page|default=''}
</div>
</block>
<block name="script">
<script src="__STATIC__/layer/layer.js"></script>
<script src="__STATIC__/layer/extend/layer.ext.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>
<style>
.layui-layer-demo .layui-layer-title {background:#F0F5F7;font-weight:bold;}
.layui-layer-demo .layui-layer-content {}
.layui-layer-demo .layui-layer-content table{width:100%;border:0;border-spacing:0;padding:0;}
.layui-layer-demo .layui-layer-content td {height:42px;padding-left:20px;}
.layui-layer-demo .layui-layer-content tr:hover {background:#F0F5F7;}
.layui-layer-demo .layui-layer-content tr~tr {border-top:1px solid #ccc;}
.layui-layer-demo .layui-layer-content td~td {border-left:1px solid #ccc;}
.layui-layer-demo .layui-layer-content tr:last-child td {}
</style>
<script>
<volist name=":I('get.')" id="vo">
Think.setValue('{$key}',"{$vo}");
</volist>
$(".select_gallery").select2();
</script>
<script type="text/javascript">
$("#exporttable").table2excel({
filename: "公会信息.xls", // do include extension
preserveColors: false // set to true if you want background colors and font colors preserved
});
</script>
</block>

@ -192,7 +192,7 @@
</table> </table>
</div> </div>
</div> </div>
<div class="data_list data_game_list model"> <div class="data_list data_game_list model" style="display: none;">
<div class=""> <div class="">
<table border="1"> <table border="1">
<!-- 表头 --> <!-- 表头 -->
@ -323,21 +323,7 @@
$("#downloadexcel").on("click",function(){ $("#downloadexcel").on("click",function(){
var url = $(this).attr("url"); var url = $(this).attr("url");
var title = '公会信息导出'; window.location.href = url;
var index = layer.load(2);
layer.open({
type: 2,
title: title,
shadeClose: true,
shade: 0,
area: ['40%', '60%'],
content: url,
zIndex :-5,
success:function(){
layer.closeAll();
}
});
// window.open(url, "blank");
}); });
//搜索功能 //搜索功能

Loading…
Cancel
Save