工会信息bug修改

master
zhengyongxing 4 years ago
parent 7054f82fde
commit a199a12d4b

@ -0,0 +1,686 @@
<?php
namespace Admin\Controller;
use Base\Tool\AggregateClient;
use User\Api\UserApi as UserApi;
use Think\Controller;
use Base\Service\PartnerService;
/**
* 工会信息
*/
class SocietyInfoController extends ThinkController
{
private $modelName = 'SocietyInfo';
private $admininfo = '';
private $level = [
1=>'S',
2=>'A',
3=>'B',
4=>'其他'
];
public function _initialize()
{
$this->admininfo = $_SESSION['onethink_admin']['user_auth'];
parent::_initialize();
}
//列表
public function lists()
{
$model = M($this->modelName, 'tab_');
$map = [];
if ($this->admininfo['username'] == "admin" || isMarketLeader()) {
// admin 和 市场总监可以看所有数据
} else {
// 其他用户只能看自己的
$map['create_account'] = $this->admininfo['username'];
}
if ($_REQUEST['text']) {
$map['_string'] = "province like '%{$_REQUEST['text']}%' or city like '%{$_REQUEST['text']}%'
or company_name like '%{$_REQUEST['text']}%' or register_capital like '%{$_REQUEST['text']}%' or functionary like '%{$_REQUEST['text']}%'
or phone like '%{$_REQUEST['text']}%' or wechat like '%{$_REQUEST['text']}%' or qq like '%{$_REQUEST['text']}%' or game_type like '%{$_REQUEST['text']}%'
or game_name like '%{$_REQUEST['text']}%' or join_platform like '%{$_REQUEST['text']}%' or promote_scale like '%{$_REQUEST['text']}%' or turnover= '{$_REQUEST['text']}'
or address like '%{$_REQUEST['text']}%' or league_info like '%{$_REQUEST['text']}%' or remark like '%{$_REQUEST['text']}%' or interface_person like '%{$_REQUEST['text']}%'";
}
$page = intval(I('get.p', 0));
$page = $page ? $page : 1; //默认显示第一页数据
$row = intval(I('row', 0));
$row = empty($row) ? 10 : $row;//每页条数
$is_export= false;
if (isset($_REQUEST['export']) && $_REQUEST['export']==1){
$is_export = true;
}
$config = M('config', 'sys_')->where([
'name' => 'SOCIETY_INFO_COMMUNITION_GAP'
])->find();
$gap = $config['value'];
if (I('province') && I('province') != '请选择省份') $map['province'] = I('province');
if (I('city') && I('city') != '请选择城市') $map['city'] = I('city');
if (I('game_type') && I('game_type') != '请选择游戏类型') $map['game_type'] = array("exp", "like '%".I('game_type')."%'");
if (trim(I('interface_person'))) $map['interface_person'] = I('interface_person');
if (I('time_gap', '') == 1) {
$map['communication_time'] = array('gt', time() - $gap * 86400);
}
if (I('time_gap', -1) == 0) {
$map['communication_time'] = array('elt', time() - $gap * 86400);
}
if (I('sociaty_level') && I('sociaty_level') != '0') $map['sociaty_level'] = I('sociaty_level');
//获取分页数据
$query = $model->where($map)->order("communication_time desc");
$count = $query->count();
if($is_export){
$parseData = $query->field("province, city, company_name, register_capital, functionary, phone, wechat, qq, game_type, game_name, join_platform, promote_scale,sociaty_level, turnover, address, league_info, is_potential, remark, interface_person, create_time, communication_time, create_account")
->where($map)
->order("communication_time desc")
->select();
foreach ($parseData as &$v) {
$v['sociaty_level'] = $this->level[$v['sociaty_level']];
if ($v['is_potential'] == 1) $v['is_potential'] = "是";
else $v['is_potential'] = "否";
$v['communication_time'] = date('Y-m-d H:i:s', $v['communication_time']);
$v['create_time'] = date('Y-m-d H:i:s', $v['create_time']);
unset($v['id']);
unset($v['game_id']);
unset($v['update_time']);
}
addOperationLog(['op_type'=>3,'key'=>getNowDate(),'url'=>U(CONTROLLER_NAME.'/'.ACTION_NAME, I('get.*')),'menu'=>"推广-公会信息-导出"]);
$head = ["省份", "城市", "公司", "注册资本", "负责人", "电话", "微信", "QQ", "游戏类型", "所做游戏",
"合作平台", "推广规模", "公会等级", "流水", "地址", "联盟信息", "是否为意向客户", "备注信息", "对接人", "录入时间", "最后沟通时间", "录入员"];
$this->export($head, $parseData, "公会信息-".date('Ymd'));
return ;
} else {
$societyInfos = $model->where($map)->order("communication_time desc")->field("*")->page($page,$row)->select();
// dump($societyInfos);die();
}
//分页
$parameter = I("get.");
$parameter['p'] = $page;
$parameter['row'] = $row;
$page = set_pagination($count, $row, $parameter);
if ($page) {
$this->assign('_page', $page);
}
foreach ($societyInfos as $k => &$v) {
$v['num'] = $k+1+intval((I('get.p', 0)?I('get.p', 0):1)-1)*$row;
$v['sociaty_level_str'] = $this->level[$v['sociaty_level']];
if (time() - $v['communication_time'] > $gap * 86400
&& $v['is_potential'] == 1
)
$v['is_gap_time'] = 1;
}
$this->checkListOrCountAuthRestMap($map,[]);
if (IS_ROOT) {
$this->assign('timeset_check',true);
$this->assign('delset_check',true);
} else {
$this->assign('timeset_check',$this->checkRule("Admin/SocietyInfo/timeset" ,array('in','1,2')));
$this->assign('delset_check',$this->checkRule("Admin/SocietyInfo/delset" ,array('in','1,2')));
}
// $this->assign('time_gap', $config['value']);
$gameTypes = M('game_type', 'tab_')->field("id, type_name")->select();
$this->assign('game_types', $gameTypes);
$this->assign('listData', $societyInfos);
$this->assign('count', $count);
$this->meta_title = '公会信息登记表(说明:此功能是公会信息内容登记)';
$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() {
$config = M('config', 'sys_')->where([
'name' => 'SOCIETY_INFO_COMMUNITION_GAP'
])->find();
$num = $config['value'];
if (IS_POST) {
$num = I('num');
if ($num < 0) {
$this->error("时间设置不能小于0");
}
M('config', 'sys_')->where([
'name' => 'SOCIETY_INFO_COMMUNITION_GAP'
])->save([
'value' => $num
]);
$this->success("设置成功");
}
$this->assign('num', $num);
$this->display();
}
//审核列表
public function index()
{
$page = intval(I('get.p', 0));
$page = $page ? $page : 1; //默认显示第一页数据
$row = intval(I('row', 0));
$row = empty($row) ? 10 : $row;//每页条数
$p = $_REQUEST;
if(!IS_ROOT){
$this->OpAuthList= getModuleControllerAuth();
}
$map = [];
if (!empty(I('partner_name'))) {
$map['partner_name'] = ['like', '%' . I('partner_name') . '%'];
}
if (!empty($p['verify_type'])) {
if($p['verify_type'] == 1){
$map['partner_id'] = 0;
}else{
$map['partner_id'] = ["neq",0];
}
}
if (isset($p['verify_status'])) {
$map['verify_status'] = $p['verify_status'];
}
if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) {
$time_start = strtotime($_REQUEST['timestart']);
$time_end = strtotime($_REQUEST['timeend'])+ 86399;
$map["create_time"] =['BETWEEN',[$time_start, $time_end]];
} elseif (isset($_REQUEST['timestart'])) {
$time_start = strtotime($_REQUEST['timestart']);
$map["create_time"] =['EGT',$time_start];
} elseif (isset($_REQUEST['timeend'])) {
$time_end = strtotime($_REQUEST['timeend'])+ 86399;
$map["create_time"] = ['ELT',$time_end];
}
$model = M("partner_verify", 'tab_');
$data = $model->where($map)->page($page,$row)->order("FIELD(verify_status,0,1,-1),create_time desc")->select();
foreach ($data as $k => &$v) {
$v['partner_info'] = json_decode($v['partner_info'],true);
if($v['partner_id'] == 0){
$v['verify_type'] = "新增";
}else{
$v['verify_type'] = "修改";
}
$v['partner_info']['company_type'] = $v['partner_info']['company_type'] == 2 ? '个人' : '公司';
$contract_start_time = $v['partner_info']['contract_start_time'] ? time_format($v['partner_info']['contract_start_time'], 'Y/m/d') : '-';
if($v['partner_info']['contract_start_time']){
$contract_end_time = $v['partner_info']['contract_end_time'] ? date('Y/m/d', $v['partner_info']['contract_end_time']) : '永久';
}else{
$contract_end_time = $v['partner_info']['contract_end_time'] ? time_format($v['partner_info']['contract_end_time'], 'Y/m/d') : '-';
}
$v['contract_time'] = $contract_start_time . '-' . $contract_end_time;
$validity_start_time = $v['partner_info']['validity_start_time'] ?
time_format($v['partner_info']['validity_start_time'], 'Y/m/d') : '-';
if($v['partner_info']['validity_start_time']){
$validity_end_time = $v['partner_info']['validity_end_time'] ? date('Y/m/d', $v['partner_info']['validity_end_time']) : '永久';
}else{
$validity_end_time = $v['partner_info']['validity_end_time'] ? time_format($v['partner_info']['validity_end_time'], 'Y/m/d') : '-';
}
$v['validity_time'] = $validity_start_time . '-' . $validity_end_time;
$create_time = date("Y-m-d H:i:s",$v["create_time"]);
$v['verify_log'] = json_decode($v['verify_log'], true);
$v["create"]= "{$v['verify_log']['create_user']} <br> {$v['verify_log']['create_time']}";
if(isset($v['verify_log']['verify_user'])){
if($v['verify_status'] == -1){
$ts = "审核拒绝";
}else{
$ts = "审核通过";
}
$v["verify"]= "{$ts}({$v['verify_log']['verify_user']}) <br> {$v['verify_log']['verify_time']}";
}else{
$v["verify"] = '--';
}
}
$count = $model->where($map)->count();
$page = set_pagination($count, $row);
if ($page) {
$this->assign('_page', $page);
}
$this->assign('menubtn',$this->menuAuth());
$this->assign('listData', $data);
$this->assign('count', $count);
$this->assign('VerifyStatus', D("PartnerVerify")->VerifyStatus);
$this->meta_title = '上游CP审核列表';
$this->display();
}
//添加
public function add()
{
$gameTypes = M('game_type', 'tab_')->field("id, type_name")->select();
$this->assign("game_types", $gameTypes);
$this->assign("interface_person", $this->admininfo['username']);
if ($_POST) {
$save = I("post.");
if (empty($save['province'])) {
$this->error("省份为必填项");
}
if (empty($save['city'])) {
$this->error("城市为必填项");
}
if (empty($save['company_name'])) {
$this->error("公司为必填项");
}
if (empty($save['game_types'])) {
$this->error("游戏类型为必填项");
}
foreach ($save['game_types'] as $v) {
$save['game_type'] .= $v . "/";
}
$save['game_type'] = trim($save['game_type'], '/');
// dump($save['game_type']);die();
if ($save['province'] == "请选择省份") $save['province'] = '';
if ($save['city'] == "请选择城市") $save['city'] = '';
$save['create_time'] = time();
$save['update_time'] = time();
$save['communication_time'] = time();
$save['create_account'] = $this->admininfo['username'];
M('society_info', 'tab_')->add($save);
$this->success('保存成功', U('lists'));
} else {
$this->meta_title = '新增公会信息';
$this->display();
}
}
//编辑
public function edit()
{
$model = M($this->modelName, 'tab_');
if ($_POST) {
$save = I("post.");
$id = $save['id'];
foreach ($save['game_types'] as $v) {
$save['game_type'] .= $v . "/";
}
if ($save['province'] == '请选择省份') {
$save['province'] = '';
$save['city'] = '';
}
if (empty($save['city'])) {
$this->error("城市为必填项");
}
if (empty($save['company_name'])) {
$this->error("公司为必填项");
}
if (empty($save['game_type'])) {
$this->error("游戏类型为必填项");
}
$save['game_type'] = trim($save['game_type'], '/');
$save['communication_time'] = time();
$save['update_time'] = time();
unset($save['id']);
$res = M('society_info', 'tab_')->where(['id' => $id])->save($save);
if ($res === false) {
$this->error('保存失败');
} else {
\Think\Log::actionLog('SocietyInfo/edit', 'SocietyInfo', $id);
addOperationLog(array(
"op_type"=>1,
"key"=>$id,
"url"=>U("SocietyInfo/edit",array("id"=>$id))
));
$this->success('保存成功', U('index'));
}
} else {
$id = intval(I('get.id', 0));
$map['id'] = $id;
$data = $model->find($id);
if (empty($data)) {
$this->error('数据异常', U('lists'));
}
$gameTypes = M('game_type', 'tab_')->field("id, type_name")->select();
$myGameTypes = explode('/', $data['game_type']);
foreach ($gameTypes as &$v) {
$v['check'] = 0;
foreach ($myGameTypes as $item) {
if ($item == $v['type_name']) {
$v['check'] = 1;
}
}
}
$this->assign("game_types", $gameTypes);
$this->assign('data', $data);
$this->meta_title = '编辑';
$this->display();
}
}
//查看
public function view()
{
$model = M($this->modelName, 'tab_');
$id = intval(I('get.id', 0));
$map['id'] = $id;
$data = $model->find($id);
if (empty($data)) {
$this->error('数据异常', U('lists'));
}
$gameTypes = M('game_type', 'tab_')->field("id, type_name")->select();
$myGameTypes = explode('/', $data['game_type']);
foreach ($gameTypes as &$v) {
$v['check'] = 0;
foreach ($myGameTypes as $item) {
if ($item == $v['type_name']) {
$v['check'] = 1;
}
}
}
$this->assign("game_types", $gameTypes);
$this->assign('data', $data);
$this->meta_title = '编辑';
$this->display();
}
//删除
public function del()
{
if (!empty($_POST['ids'])) {
if (!is_array($_POST['ids'])) {
$this->error('参数异常');
}
$id = implode(',', $_POST['ids']);
} else {
$id = intval(I('get.id', 0));
if ($id == 0) {
$this->error('参数异常');
}
}
$res = M($this->modelName, 'tab_')->delete($id);
if ($res === false) {
$this->error('删除失败');
}
addOperationLog(array(
"op_type"=>2,
"key"=>$id,
"url"=>U("Society/lists")
));
$this->success('删除成功', U('lists'));
}
//批量删除
public function del_check() {
if (!empty($_POST['ids'])) {
if (!is_array($_POST['ids'])) {
$this->ajaxReturn(['status'=>0,'info'=>'参数异常']);
// $this->error('参数异常');
}
$id = implode(',', $_POST['ids']);
} else {
$id = intval(I('get.id', 0));
if ($id == 0) {
$this->ajaxReturn(['status'=>0,'info'=>'参数异常']);
// $this->error('参数异常');
}
}
$res = M($this->modelName, 'tab_')->delete($id);
if ($res === false) {
// $this->error('删除失败');
$this->ajaxReturn(['status'=>0,'info'=>'删除失败']);
}
addOperationLog(array(
"op_type"=>2,
"key"=>$id,
"url"=>U("Society/lists")
));
$this->ajaxReturn(['status'=>1,'info'=>'删除成功']);
}
// 导入
public function excelImport() {
header("Content-Type:text/html;charset=utf-8");
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize = 3145728 ;// 设置附件上传大小
$upload->exts = array('xls', 'xlsx');// 设置附件上传类
$upload->rootPath = './Uploads/'; // 设置附件上传目录
$upload->savePath = 'excel/'; // 设置附件上传目录
// 上传文件
$info = $upload->uploadOne($_FILES['excelData']);
$filename = './Uploads/'.$info['savepath'].$info['savename'];
$exts = $info['ext'];
if(!$info) {// 上传错误提示错误信息
$this->ajaxReturn(['msg'=>$upload->getError(),"status"=>0]);
// $this->error($upload->getError());
}
// 上传成功
$datas = $this->parseExcelIn($filename, $exts);
$inserts = [];
foreach ($datas as $k => $v) {
$flag = 0;
foreach ($v as $p) {
if (!empty($p)) {
$flag = 1;
}
}
if ($flag == 0) continue;
if ($k == 1) continue;
$inserts[$k-2]['province'] = $v['A'] ?? '';
if (!$v['A']) {
$this->ajaxReturn(['msg'=>"省份不能为空".$k,"status"=>0]);
}
$inserts[$k-2]['city'] = $v['B'] ?? '';
if (!$v['B']) {
$this->ajaxReturn(['msg'=>"城市不能为空".$k,"status"=>0]);
}
$inserts[$k-2]['company_name'] = $v['C'] ?? '';
if (mb_strlen($inserts[$k-2]['company_name'], "utf-8") > 100) {
$this->ajaxReturn(['msg'=>"公司名太长".$k,"status"=>0]);
}
if (!$inserts[$k-2]['company_name']) {
$this->ajaxReturn(['msg'=>"公司不能为空".$k,"status"=>0]);
}
$inserts[$k-2]['register_capital'] = $v['D'] ?? '';
if (strlen($inserts[$k-2]['register_capital']) > 50) {
$this->ajaxReturn(['msg'=>"推荐人太长".$k,"status"=>0]);
}
$inserts[$k-2]['functionary'] = $v['E'] ?? '';
if (strlen($inserts[$k-2]['functionary']) > 50) {
$this->ajaxReturn(['msg'=>"负责人太长".$k,"status"=>0]);
}
$inserts[$k-2]['phone'] = $v['F'] ?? '';
if (strlen($inserts[$k-2]['phone']) > 50) {
$this->ajaxReturn(['msg'=>"手机号太长".$k,"status"=>0]);
}
$inserts[$k-2]['wechat'] = $v['G'] ?? '';
if (strlen($inserts[$k-2]['wechat']) > 50) {
$this->ajaxReturn(['msg'=>"微信号太长".$k,"status"=>0]);
}
$inserts[$k-2]['qq'] = $v['H'] ?? '';
if (strlen($inserts[$k-2]['qq']) > 50) {
$this->ajaxReturn(['msg'=>"qq号太长".$k,"status"=>0]);
}
$inserts[$k-2]['game_type'] = $v['I'] ?? '';
$inserts[$k-2]['game_name'] = $v['J'] ?? '';
if (strlen($inserts[$k-2]['game_name']) > 50) {
$this->ajaxReturn(['msg'=>"游戏名太长".$k,"status"=>0]);
}
$inserts[$k-2]['join_platform'] = $v['K'] ?? '';
if (strlen($inserts[$k-2]['join_platform']) > 50) {
$this->ajaxReturn(['msg'=>"合作平台太长".$k,"status"=>0]);
}
$inserts[$k-2]['promote_scale'] = $v['L'] ?? '';
if (strlen($inserts[$k-2]['promote_scale']) > 50) {
$this->ajaxReturn(['msg'=>"推广规模太长".$k,"status"=>0]);
}
$inserts[$k-2]['turnover'] = $v['M'] ?? '';
if (strlen($inserts[$k-2]['turnover']) > 50) {
$this->ajaxReturn(['msg'=>"公会等级".$k,"status"=>0]);
}
$inserts[$k-2]['turnover'] = $v['N'] ?? '';
if (strlen($inserts[$k-2]['turnover']) > 50) {
$this->ajaxReturn(['msg'=>"流水太长".$k,"status"=>0]);
}
$inserts[$k-2]['address'] = $v['O'] ?? '';
if (mb_strlen($inserts[$k-2]['address'], 'utf-8') > 100) {
$this->ajaxReturn(['msg'=>"地址太长".$k,"status"=>0]);
}
$inserts[$k-2]['league_info'] = $v['P'] ?? '';
if (strlen($inserts[$k-2]['league_info']) > 100) {
$this->ajaxReturn(['msg'=>"联盟信息太长".$k,"status"=>0]);
}
if ($v['Q']) {
$inserts[$k-2]['is_potential'] = ($v['Q']=="是" ? 1 : 0);
} else {
$inserts[$k-2]['is_potential'] = 1;
}
$inserts[$k-2]['remark'] = $v['R'] ?? '';
if (strlen($inserts[$k-2]['remark']) > 100) {
$this->ajaxReturn(['msg'=>"备注太长".$k,"status"=>0]);
}
$inserts[$k-2]['interface_person'] = $v['S'] ?? '';
if (strlen($inserts[$k-2]['interface_person']) > 50) {
$this->ajaxReturn(['msg'=>"对接人太长".$k,"status"=>0]);
}
$inserts[$k-2]['create_time'] = time();
$inserts[$k-2]['update_time'] = time();
$inserts[$k-2]['communication_time'] = time();
$inserts[$k-2]['create_account'] = $this->admininfo['username'];
$gameTypes = explode('/', $v['I']);
foreach ($gameTypes as $gameType) {
if (!M('game_type', 'tab_')->where(["type_name" => $gameType])->find()) {
$this->ajaxReturn(['msg'=>"游戏类型有误:{$gameType}","status"=>0]);
return;
}
}
}
M('society_info', 'tab_')->addAll($inserts);
$this->ajaxReturn(['msg'=>"导入成功","status"=>1]);
// $this->success("导入成功");
}
private function parseExcelIn($filename, $exts) {
//导入PHPExcel类库因为PHPExcel没有用命名空间只能inport导入
//import("Org.Util.PHPExcel");
vendor("PHPExcel.PHPExcel");
//创建PHPExcel对象注意不能少了\
$PHPExcel=new \PHPExcel();
//如果excel文件后缀名为.xls导入这个类
if($exts == 'xls'){
//import("Org.Util.PHPExcel.Reader.Excel5");
$PHPReader=new \PHPExcel_Reader_Excel5();
}else if($exts == 'xlsx'){
//import("Org.Util.PHPExcel.Reader.Excel2007");
$PHPReader=new \PHPExcel_Reader_Excel2007();
}
//载入文件
$PHPExcel=$PHPReader->load($filename);
//获取表中的第一个工作表如果要获取第二个把0改为1依次类推
$currentSheet=$PHPExcel->getSheet(0);
//获取总列数
$allColumn=$currentSheet->getHighestColumn();
//获取总行数
$allRow=$currentSheet->getHighestRow();
//循环获取表中的数据,$currentRow表示当前行从哪行开始读取数据索引值从0开始
for($currentRow=1;$currentRow<=$allRow;$currentRow++){
//从哪列开始A表示第一列
for($currentColumn='A';$currentColumn<=$allColumn;$currentColumn++){
//数据坐标
$address=$currentColumn.$currentRow;
//读取到的数据,保存到数组$arr中
$data[$currentRow][$currentColumn]=$currentSheet->getCell($address)->getValue();
if(is_object($data[$currentRow][$currentColumn])) $data[$currentRow][$currentColumn] = $data[$currentRow][$currentColumn]->__toString();
}
}
return $data;
}
//模板导出
public function downloadSocial()
{
header("Content-type: text/html; charset=utf-8");
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
Vendor("PHPExcel.PHPExcel");
$objPHPExcel = new \PHPExcel();
$objReader = \PHPExcel_IOFactory::createReader('Excel2007');
//设置模板文件
$objPHPExcel = $objReader->load("Public/Admin/excel/social_template.xls");
$fileName = "公会信息模板";
ob_end_clean();//清除缓冲区,避免乱码
header('pragma:public');
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $fileName .'".xls');
header("Content-Disposition:attachment;filename={$fileName}.xls");//attachment新窗口打印inline本窗口打印
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
}
}

@ -0,0 +1,63 @@
var provinces = ['请选择省份','北京市','上海市','天津市','重庆市','河北省','山西省','内蒙古省','辽宁省','吉林省','黑龙江省','江苏省','浙江省','安徽省','福建省','江西省','山东省','河南省','湖北省','湖南省','广东省','广西省','海南省','四川省','贵州省','云南省','西藏省','陕西省','甘肃省','宁夏省','青海省','新疆省','香港','澳门','台湾','其他'];
var citys = [['请选择城市'],
["东城区", "西城区", "崇文区", "宣武区", "朝阳区", "丰台区", "石景山区", "海淀区", "门头沟区", "房山区", "通州区", "顺义区", "昌平区", "大兴区", "怀柔区", "平谷区", "密云县", "延庆县","其他"],
["黄浦区", "卢湾区", "徐汇区", "长宁区", "静安区", "普陀区", "虹口区", "杨浦区", "闵行区", "宝山区", "嘉定区", "浦东新区", "金山区", "松江区", "青浦区", "南汇区", "奉贤区", "崇明县","其他"],
["和平区", "河东区", "河西区", "南开区", "河北区", "红桥区", "塘沽区", "汉沽区", "大港区", "东丽区", "西青区", "津南区", "北辰区", "武清区", "宝坻区", "宁河县", "静海县", "蓟县","其他"],
["万州区", "涪陵区", "渝中区", "大渡口区", "江北区", "沙坪坝区", "九龙坡区", "南岸区", "北碚区", "万盛区", "双桥区", "渝北区", "巴南区", "黔江区", "长寿区", "綦江县", "潼南县", "铜梁县", "大足县", "荣昌县", "璧山县", "梁平县", "城口县", "丰都县", "垫江县", "武隆县", "忠县", "开县", "云阳县", "奉节县", "巫山县", "巫溪县", "石柱土家族自治县", "秀山土家族苗族自治县", "酉阳土家族苗族自治县", "彭水苗族土家族自治县", "江津市", "合川市", "永川市", "南川市","其他"],
["石家庄市","张家口市","承德市","秦皇岛市","唐山市","廊坊市","保定市","衡水市","沧州市","邢台市","邯郸市","其他"],
["太原市","朔州市","大同市","阳泉市","长治市","晋城市","忻州市","晋中市","临汾市","吕梁市","运城市","其他"],
["呼和浩特市","包头市","乌海市","赤峰市","通辽市","呼伦贝尔市","鄂尔多斯市","乌兰察布市","巴彦淖尔市","兴安盟","锡林郭勒盟","阿拉善盟","其他"],
["沈阳市","朝阳市","阜新市","铁岭市","抚顺市","本溪市","辽阳市","鞍山市","丹东市","大连市","营口市","盘锦市","锦州市","葫芦岛市","其他"],
["长春市","白城市","松原市","吉林市","四平市","辽源市","通化市","白山市","延边州","其他"],
["哈尔滨市","齐齐哈尔市","七台河市","黑河市","大庆市","鹤岗市","伊春市","佳木斯市","双鸭山市","鸡西市","牡丹江市","绥化市","大兴安岭地区","其他"],
["南京市","徐州市","连云港市","宿迁市","淮安市","盐城市","扬州市","泰州市","南通市","镇江市","常州市","无锡市","苏州市","其他"],
["杭州市","湖州市","嘉兴市","舟山市","宁波市","绍兴市","衢州市","金华市","台州市","温州市","丽水市","其他"],
["合肥市","宿州市","淮北市","亳州市","阜阳市","蚌埠市","淮南市","滁州市","马鞍山市","芜湖市","铜陵市","安庆市","黄山市","六安市","巢湖市","池州市","宣城市","其他"],
["福州市","南平市","莆田市","三明市","泉州市","厦门市","漳州市","龙岩市","宁德市","其他"],
["南昌市","九江市","景德镇市","鹰潭市","新余市","萍乡市","赣州市","上饶市","抚州市","宜春市","吉安市","其他"],
["济南市","青岛市","聊城市","德州市","东营市","淄博市","潍坊市","烟台市","威海市","日照市","临沂市","枣庄市","济宁市","泰安市","莱芜市","滨州市","菏泽市","其他"],
["郑州市","开封市","三门峡市","洛阳市","焦作市","新乡市","鹤壁市","安阳市","濮阳市","商丘市","许昌市","漯河市","平顶山市","南阳市","信阳市","周口市","驻马店市","济源市","其他"],
["武汉市","十堰市","襄樊市","荆门市","孝感市","黄冈市","鄂州市","黄石市","咸宁市","荆州市","宜昌市","随州市","省直辖县级行政单位","恩施州","其他"],
["长沙市","张家界市","常德市","益阳市","岳阳市","株洲市","湘潭市","衡阳市","郴州市","永州市","邵阳市","怀化市","娄底市","湘西州","其他"],
["广州市","深圳市","清远市","韶关市","河源市","梅州市","潮州市","汕头市","揭阳市","汕尾市","惠州市","东莞市","珠海市","中山市","江门市","佛山市","肇庆市","云浮市","阳江市","茂名市","湛江市","其他"],
["南宁市","桂林市","柳州市","梧州市","贵港市","玉林市","钦州市","北海市","防城港市","崇左市","百色市","河池市","来宾市","贺州市","其他"],
["海口市","三亚市","省直辖县级行政单位","其他"],
["成都市","广元市","绵阳市","德阳市","南充市","广安市","遂宁市","内江市","乐山市","自贡市","泸州市","宜宾市","攀枝花市","巴中市","达州市","资阳市","眉山市","雅安市","阿坝州","甘孜州","凉山州","其他"],
["贵阳市","六盘水市","遵义市","安顺市","毕节地区","铜仁地区","黔东南州","黔南州","黔西南州","其他"],
["昆明市","曲靖市","玉溪市","保山市","昭通市","丽江市","思茅市","临沧市","德宏州","怒江州","迪庆州","大理州","楚雄州","红河州","文山州","西双版纳州","其他"],
["拉萨市","那曲地区","昌都地区","林芝地区","山南地区","日喀则地区","阿里地区","其他"],
["西安市","延安市","铜川市","渭南市","咸阳市","宝鸡市","汉中市","榆林市","安康市","商洛市","其他"],
["兰州市","嘉峪关市","白银市","天水市","武威市","酒泉市","张掖市","庆阳市","平凉市","定西市","陇南市","临夏州","甘南州","其他"],
["西宁市","海东地区","海北州","海南州","黄南州","果洛州","玉树州","海西州","其他"],
["银川市","石嘴山市","吴忠市","固原市","中卫市","其他"],
["乌鲁木齐市","克拉玛依市","自治区直辖县级行政单位","喀什地区","阿克苏地区","和田地区","吐鲁番地区","哈密地区","克孜勒苏柯州","博尔塔拉州","昌吉州","巴音郭楞州","伊犁州","塔城地区","阿勒泰地区","其他"],
["香港","其他"],
["澳门","其他"],
["台北市","高雄市","台中市","花莲市","基隆市","嘉义市","金门市","连江市","苗栗市","南投市","澎湖市","屏东市","台东市","台南市","桃园市","新竹市","宜兰市","云林市","彰化市","其他"],
["其他"]
];
function areaInit(){
// 注意这里是要通过 id 获取元素,而不是通过 class 获取
var province = document.getElementById('province');
//给选择框一个高度可直接写进数据不然要先创建dom元素option再录值
province.length=provinces.length;
for(var i=0;i<provinces.length;i++){
province.options[i].text=provinces[i];
province.options[i].value=provinces[i];
}
document.getElementById("province").onchange = provinceChange;
}
function provinceChange(){
var province = document.getElementById("province");
var num = province.selectedIndex; // 选中option索引
var city = document.getElementById('city');
var citystemp=citys[num];
city.length=citystemp.length;
for(var i=0;i<citystemp.length;i++){
city.options[i].text=citystemp[i];
city.options[i].value=citystemp[i];
}
city.options[0].selected=true;
}
Loading…
Cancel
Save