作者 刘朕
1 个管道 的构建 通过 耗费 1 秒

合并分支 '1iuzhen' 到 'master'

字段导出、订单导出修改



查看合并请求 !226
... ... @@ -114,6 +114,9 @@ class OrderController extends AdminBaseController
if(isset($param['status']) && $param['status'] >= 0) {
$where['status'] = $param['status'];
}
if(!empty($param['pay_type'])) {
$where['pay_type'] = $param['pay_type'];
}
if(isset($param['is_excel']) && $param['is_excel'] >= 0) {
$where['is_excel'] = $param['is_excel'];
}
... ... @@ -323,6 +326,9 @@ class OrderController extends AdminBaseController
if(isset($param['status']) && $param['status'] >= 0) {
$where['status'] = $param['status'];
}
if(!empty($param['pay_type'])) {
$where['pay_type'] = $param['pay_type'];
}
if(isset($param['is_excel']) && $param['is_excel'] >= 0) {
$where['is_excel'] = $param['is_excel'];
}
... ... @@ -400,6 +406,7 @@ class OrderController extends AdminBaseController
$objPHPExcel->getActiveSheet()->getColumnDimension('AO')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('AP')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('AQ')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('AR')->setWidth(20);
// 设置水平居中
$objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
// 设置垂直居中
... ... @@ -412,43 +419,44 @@ class OrderController extends AdminBaseController
->setCellValue('D1', '销售用户名')
->setCellValue('E1', '订单确认码')
->setCellValue('F1', '订单状态')
->setCellValue('G1', '收集状态')
->setCellValue('H1', '发布时间')
->setCellValue('I1', '失效时间')
->setCellValue('J1', '订购方式')
->setCellValue('K1', '来源渠道')
->setCellValue('L1', '销售人员')
->setCellValue('M1', '小朋友姓名')
->setCellValue('N1', '小朋友性别')
->setCellValue('O1', '小朋友生日')
->setCellValue('P1', '家长姓名')
->setCellValue('Q1', '家长身份')
->setCellValue('R1', '其他身份')
->setCellValue('S1', '家长电话')
->setCellValue('T1', '手机备用电话')
->setCellValue('U1', '座机备用电话')
->setCellValue('V1', '地址')
->setCellValue('W1', '收货地址')
->setCellValue('X1', '详细收货地址')
->setCellValue('Y1', '收货人姓名')
->setCellValue('Z1', '收货人电话')
->setCellValue('AA1', '收货区域')
->setCellValue('AB1', '商品选择')
->setCellValue('AC1', '具体版本')
->setCellValue('AD1', '其他版本')
->setCellValue('AE1', '订购长度')
->setCellValue('AF1', '其他订购长度')
->setCellValue('AG1', '订购起始月')
->setCellValue('AH1', '订购价格')
->setCellValue('AI1', '礼物选择')
->setCellValue('AJ1', '加赠礼物')
->setCellValue('AK1', '加赠礼物名称')
->setCellValue('AL1', '是否适龄')
->setCellValue('AM1', '不适龄备注')
->setCellValue('AN1', '图片')
->setCellValue('AO1', '月龄版升级年份')
->setCellValue('AP1', '备注')
->setCellValue('AQ1', '客户编号');
->setCellValue('G1', '支付方式')
->setCellValue('H1', '收集状态')
->setCellValue('I1', '发布时间')
->setCellValue('J1', '失效时间')
->setCellValue('K1', '订购方式')
->setCellValue('L1', '来源渠道')
->setCellValue('M1', '销售人员')
->setCellValue('N1', '小朋友姓名')
->setCellValue('O1', '小朋友性别')
->setCellValue('P1', '小朋友生日')
->setCellValue('Q1', '家长姓名')
->setCellValue('R1', '家长身份')
->setCellValue('S1', '其他身份')
->setCellValue('R1', '家长电话')
->setCellValue('U1', '手机备用电话')
->setCellValue('V1', '座机备用电话')
->setCellValue('W1', '地址')
->setCellValue('X1', '收货地址')
->setCellValue('Y1', '详细收货地址')
->setCellValue('Z1', '收货人姓名')
->setCellValue('AA1', '收货人电话')
->setCellValue('AB1', '收货区域')
->setCellValue('AC1', '商品选择')
->setCellValue('AD1', '具体版本')
->setCellValue('AE1', '其他版本')
->setCellValue('AF1', '订购长度')
->setCellValue('AG1', '其他订购长度')
->setCellValue('AH1', '订购起始月')
->setCellValue('AI1', '订购价格')
->setCellValue('AJ1', '礼物选择')
->setCellValue('AK1', '加赠礼物')
->setCellValue('AL1', '加赠礼物名称')
->setCellValue('AM1', '是否适龄')
->setCellValue('AN1', '不适龄备注')
->setCellValue('AO1', '图片')
->setCellValue('AP1', '月龄版升级年份')
->setCellValue('AQ1', '备注')
->setCellValue('AR1', '客户编号');
$i = 2;
... ... @@ -462,6 +470,13 @@ class OrderController extends AdminBaseController
if($v['is_stop'] == 1) {
$is_stop = '已停止';
}
$pay_type = '';
if($v['pay_type'] == 1) {
$pay_type = '微信';
}
if($v['pay_type'] == 2) {
$pay_type = '支付宝';
}
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A' . $i, $v['id'])
->setCellValueExplicit('B' . $i, $v['order_sn'],\PHPExcel_Cell_DataType::TYPE_STRING)
... ... @@ -470,9 +485,10 @@ class OrderController extends AdminBaseController
->setCellValue('D' . $i, $v['user_login'])
->setCellValue('E' . $i, $v['number'])
->setCellValue('F' . $i, $status)
->setCellValue('G' . $i, $is_stop)
->setCellValue('H' . $i, date('Y-m-d H:i',$v['create_time']))
->setCellValue('I' . $i, date('Y-m-d H:i',$v['over_time']));
->setCellValue('G' . $i, $pay_type)
->setCellValue('H' . $i, $is_stop)
->setCellValue('I' . $i, date('Y-m-d H:i',$v['create_time']))
->setCellValue('J' . $i, date('Y-m-d H:i',$v['over_time']));
$v['options'] = json_decode($v['options'],true);
foreach ($v['options'] as $ks=>$vs) {
$where = [
... ...
... ... @@ -242,4 +242,91 @@ class OrderOptionController extends AdminBaseController
$this->success('成功','',explode(',',$values));
}
}
/**
* 字段数据导出
* @adminMenu(
* 'name' => '字段数据导出',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> false,
* 'order' => 6,
* 'icon' => '',
* 'remark' => '字段数据导出',
* 'param' => ''
* )
*/
public function excel()
{
$param = $this->request->param();
// 进行查询条件的处理
$where = [
'delete_time'=>0
];
if(isset($param['keyword'])) {
$where['name|values'] = ['like','%'.$param['keyword'].'%'];
}
if(!empty($param['sort'])) {
$where['sort'] = $param['sort'];
}
// 查询数据并导出
$list = $this->singleData($this->table,$where,1,['create_time'=>'DESC']);
$this->expList($list);
}
// 数据导出
private function expList($array)
{
//导出Excel
$objPHPExcel = new \PHPExcel();
// 设置单元格宽度
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
// 设置水平居中
$objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
// 设置垂直居中
$objPHPExcel->getDefaultStyle()->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//Add some data
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'ID')
->setCellValue('B1', '字段名称')
->setCellValue('C1', '字段类型')
->setCellValue('D1', '取值范围')
->setCellValue('E1', '用户是否可见')
->setCellValue('F1', '更新时间')
->setCellValue('G1', '发布时间');
$i = 2;
// 循环到导出数据
foreach ($array as $v) {
$is_show = '否';
if($v['is_show'] == 1) {
$is_show = '是';
}
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A' . $i, $v['id'])
->setCellValue('B' . $i, $v['name'])
->setCellValue('C' . $i, $this->type[$v['sort']])
->setCellValue('D' . $i, $v['values'])
->setCellValue('E' . $i, $is_show)
->setCellValue('F' . $i, date('Y-m-d H:i',$v['update_time']))
->setCellValue('G' . $i, date('Y-m-d H:i',$v['create_time']));
$i++;
}
$filename = '字段数据导出'. date('Y-m-d').'.xls';
ob_end_clean();
header("Content-type:application/vnd.ms-excel;charset=UTF-8");
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . $filename . '"');
header('Cache-Control: max-age=0');
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
}
}
\ No newline at end of file
... ...
... ... @@ -245,7 +245,7 @@ class OrderController extends HomeBaseController
$orderInfo['options'] = json_decode($orderInfo['options'],true);
$order_price = 0;
foreach ($orderInfo['options'] as $k=>$v) {
if($v['id'] == 25) {
if($v['id'] == 64) {
$order_price = $v['user_choose'];
}
}
... ...
... ... @@ -30,6 +30,12 @@
<option value="0" <eq name="is_over" value="0">selected</eq>>否</option>
<option value="1" <eq name="is_over" value="1">selected</eq>>是</option>
</select>&nbsp; &nbsp;
支付类型:
<select class="form-control" name="pay_type" style="width: 140px;">
<option value="0">请选择</option>
<option value="1" <eq name="pay_type" value="0">selected</eq>>微信</option>
<option value="2" <eq name="pay_type" value="1">selected</eq>>支付宝</option>
</select>&nbsp; &nbsp;
导出状态:
<select class="form-control" name="is_excel" style="width: 140px;">
<option value="-1">请选择</option>
... ... @@ -146,6 +152,7 @@
var url2 = url1.split('.',5);
var sort_id = $('select[name=sort_id]').val();
var status = $('select[name=status]').val();
var pay_type = $('select[name=pay_type]').val();
var is_over = $('select[name=is_over]').val();
var is_excel = $('select[name=is_excel]').val();
var keyword = $('input[name=keyword]').val();
... ... @@ -169,6 +176,9 @@
if(status.length > 0) {
param += '/status/'+status;
}
if(pay_type.length > 0) {
param += '/pay_type/'+pay_type;
}
if(is_over.length > 0) {
param += '/is_over/'+is_over;
}
... ...
... ... @@ -4,7 +4,7 @@
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li class="active"><a href="javascript:;">所有字段</a></li>
<li><a href="{:url('OrderOption/add')}">添加字段</a></li>
<!--<li><a href="{:url('OrderOption/add')}">添加字段</a></li>-->
</ul>
<form class="well form-inline margin-top-20" method="post" action="{:url('OrderOption/index')}">
字段类型:
... ... @@ -19,14 +19,15 @@
value="{$keyword|default=''}" placeholder="请输入关键字...">
<input type="submit" class="btn btn-primary" value="搜索"/>
<a class="btn btn-danger" href="{:url('OrderOption/index')}">清空</a>
<input type="button" class="btn btn-primary" id="excel" value="导出"/>
</form>
<form class="js-ajax-form" action="" method="post">
<div class="table-actions">
<button class="btn btn-danger btn-sm js-ajax-submit" type="submit"
data-action="{:url('OrderOption/delete')}" data-subcheck="true" data-msg="您确定删除吗?">
{:lang('DELETE')}
</button>
</div>
<!--<div class="table-actions">-->
<!--<button class="btn btn-danger btn-sm js-ajax-submit" type="submit"-->
<!--data-action="{:url('OrderOption/delete')}" data-subcheck="true" data-msg="您确定删除吗?">-->
<!--{:lang('DELETE')}-->
<!--</button>-->
<!--</div>-->
<table class="table table-hover table-bordered table-list">
<thead>
<tr>
... ... @@ -63,7 +64,7 @@
<td>{:date('Y-m-d H:i',$vo.update_time)}</td>
<td>
<a href="{:url('OrderOption/edit',array('id'=>$vo['id']))}">{:lang('EDIT')}</a>
<a href="{:url('OrderOption/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">{:lang('DELETE')}</a>
<!--<a href="{:url('OrderOption/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">{:lang('DELETE')}</a>-->
</td>
</tr>
</foreach>
... ... @@ -82,17 +83,43 @@
</tr>
</tfoot>
</table>
<div class="table-actions">
<button class="btn btn-danger btn-sm js-ajax-submit" type="submit"
data-action="{:url('OrderOption/delete')}" data-subcheck="true" data-msg="您确定删除吗?">
{:lang('DELETE')}
</button>
</div>
<!--<div class="table-actions">-->
<!--<button class="btn btn-danger btn-sm js-ajax-submit" type="submit"-->
<!--data-action="{:url('OrderOption/delete')}" data-subcheck="true" data-msg="您确定删除吗?">-->
<!--{:lang('DELETE')}-->
<!--</button>-->
<!--</div>-->
<ul class="pagination">{$page|default=''}</ul>
</form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
$('#excel').click(function () {
var url1 = "{:url('OrderOption/excel')}";
var url2 = url1.split('.',5);
var sort = $('select[name=sort]').val();
var keyword = $('input[name=keyword]').val();
var param = '/excel/1';
var ids = [];
$('.js-check').each(function(index,element) {
if($(this).prop('checked') == true) {
ids.push($(this).val());
}
});
console.log(ids);
if(ids.length>0) {
ids = ids.join(',');
param += '/ids/' + ids;
}
if(sort.length > 0) {
param += '/sort/'+sort;
}
if(keyword.length > 0) {
param += '/keyword/'+keyword;
}
var url = url2[0]+param+'.html';
window.open(url);
});
function reloadPage(win) {
win.location.reload();
}
... ...