作者 jinglong

增加导出

... ... @@ -2,6 +2,7 @@
namespace app\admin\controller;
use app\api\controller\Common;
use app\common\controller\Backend;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
... ... @@ -88,4 +89,70 @@ class AdminCommon extends Backend
return $returnValue-3600*8;// 返回时间戳
}
//导出套餐订单列表
public static function exportOrderList($where){
$expTableData = Common::selectWhereData('order',$where,'r_id,order_sn,price,content,total_num,use_num,not_use_num,advice,address,organization,pin_user,mark','id asc');
//查询手机号
$r_ids = array_unique(array_column($expTableData,'r_id'));
$res_mobile = Common::selectWhereData('registers',['id'=>['in',$r_ids]],'id,mobile');
$expCellName = [
['order_sn','订单编号',15],
['price','订单金额',15],
['content','购买服务内容',20],
['total_num','购买次数',15],
['use_num','已用服务次数',15],
['not_use_num','剩余服务次数',15],
['advice','所属顾问',10],
['mobile','VIP手机号',20],
['address','详细地址',30],
['organization','归属机构',30],
['pin_user','品拓人员',15],
['mark','备注',40],
];
foreach ($expTableData as &$v) {
$v['mobile'] = '';
foreach ($res_mobile as $value){
if($v['r_id'] == $value['id']){
$v['mobile'] = $value['mobile'];
}
}
}
$expTitle = "套餐订单列表";
$fileName = "套餐订单列表";//文件名
self::exportExcel($expTitle,$expCellName,$expTableData,$fileName);
}
//导出服务订单列表
public static function exportServiceList($where){
$expTableData = Common::selectWhereData('service_order',$where,'r_id,order_sn,customer_name,service_time,service_content,service_name,assess,mark','id asc');
//查询手机号
$r_ids = array_unique(array_column($expTableData,'r_id'));
$res_mobile = Common::selectWhereData('registers',['id'=>['in',$r_ids]],'id,mobile');
$expCellName = [
['order_sn','服务订单编号',20],
['customer_name','客户姓名',10],
['service_time','服务时间',20],
['service_content','服务项目',30],
['service_name','服务员',10],
['mobile','VIP手机号',20],
['assess','评价',30],
['mark','备注',40],
];
foreach ($expTableData as &$v) {
$v['mobile'] = '';
foreach ($res_mobile as $value){
if($v['r_id'] == $value['id']){
$v['mobile'] = $value['mobile'];
}
}
$v['service_time'] = date('Y-m-d H:i:s',$v['service_time']);
}
$expTitle = "服务订单列表";
$fileName = "服务订单列表";//文件名
self::exportExcel($expTitle,$expCellName,$expTableData,$fileName);
}
}
... ...
... ... @@ -2,6 +2,7 @@
namespace app\admin\controller;
use app\api\controller\Common;
use app\common\controller\Backend;
/**
* 导入订单管理
... ... @@ -63,4 +64,14 @@ class Order extends Backend
return $this->view->fetch();
}
//导出excel
public function export(){
$ids = $this->request->param('ids');
if(!$ids){
return;
}
$ids = explode(',',$ids);
AdminCommon::exportOrderList(['id'=>['in',$ids]]);
}
}
... ...
... ... @@ -298,43 +298,14 @@ class Registers extends Backend
$this->success();
}
//导出excel
//导出套餐订单列表excel
public function export(){//导出Excel
$ids = $this->request->param('ids');
if(!$ids){
return;
}
$ids = explode(',',$ids);
$expTableData = Common::selectWhereData('order',['r_id'=>['in',$ids]],'r_id,order_sn,price,content,total_num,use_num,not_use_num,advice,address,organization,pin_user,mark','id asc');
//查询手机号
$r_ids = array_unique(array_column($expTableData,'r_id'));
$res_mobile = Common::selectWhereData('registers',['id'=>['in',$r_ids]],'id,mobile');
$expCellName = [
['order_sn','订单编号',15],
['price','订单金额',15],
['content','购买服务内容',20],
['total_num','购买次数',15],
['use_num','已用服务次数',15],
['not_use_num','剩余服务次数',15],
['advice','所属顾问',10],
['mobile','VIP手机号',20],
['address','详细地址',30],
['organization','归属机构',30],
['pin_user','品拓人员',15],
['mark','备注',40],
];
foreach ($expTableData as &$v) {
$v['mobile'] = '';
foreach ($res_mobile as $value){
if($v['r_id'] == $value['id']){
$v['mobile'] = $value['mobile'];
}
}
}
$expTitle = "套餐订单列表";
$fileName = "套餐订单列表";//文件名
AdminCommon::exportExcel($expTitle,$expCellName,$expTableData,$fileName);
AdminCommon::exportOrderList(['r_id'=>['in',$ids]]);
}
//导出服务列表excel
... ... @@ -344,32 +315,6 @@ class Registers extends Backend
return;
}
$ids = explode(',',$ids);
$expTableData = Common::selectWhereData('service_order',['r_id'=>['in',$ids]],'r_id,order_sn,customer_name,service_time,service_content,service_name,assess,mark','id asc');
//查询手机号
$r_ids = array_unique(array_column($expTableData,'r_id'));
$res_mobile = Common::selectWhereData('registers',['id'=>['in',$r_ids]],'id,mobile');
$expCellName = [
['order_sn','服务订单编号',20],
['customer_name','客户姓名',10],
['service_time','服务时间',20],
['service_content','服务项目',30],
['service_name','服务员',10],
['mobile','VIP手机号',20],
['assess','评价',30],
['mark','备注',40],
];
foreach ($expTableData as &$v) {
$v['mobile'] = '';
foreach ($res_mobile as $value){
if($v['r_id'] == $value['id']){
$v['mobile'] = $value['mobile'];
}
}
$v['service_time'] = date('Y-m-d H:i:s',$v['service_time']);
}
$expTitle = "服务订单列表";
$fileName = "服务订单列表";//文件名
AdminCommon::exportExcel($expTitle,$expCellName,$expTableData,$fileName);
AdminCommon::exportServiceList(['r_id'=>['in',$ids]]);
}
}
... ...
... ... @@ -62,4 +62,14 @@ class ServiceOrder extends Backend
$this->assignconfig("r_id",$ids);
return $this->view->fetch();
}
//导出服务列表excel
public function export(){//导出Excel
$ids = $this->request->param('ids');
if(!$ids){
return;
}
$ids = explode(',',$ids);
AdminCommon::exportServiceList(['id'=>['in',$ids]]);
}
}
... ...
... ... @@ -11,7 +11,7 @@
<!--<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('order/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>-->
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('order/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('order/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->
<a href="javascript:;" class="btn btn-success btn-export {:$auth->check('order/export')?'':'hide'}" title="{:__('Export')}" id="btn-export-file"><i class="fa fa-download"></i>导出</a>
<!--<div class="dropdown btn-group {:$auth->check('order/multi')?'':'hide'}">-->
<!--<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!--<ul class="dropdown-menu text-left" role="menu">-->
... ...
... ... @@ -10,6 +10,7 @@
<!--<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('service_order/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>-->
<!--<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('service_order/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>-->
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('service_order/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-success btn-export {:$auth->check('service_order/export')?'':'hide'}" title="{:__('Export')}" id="btn-export-file"><i class="fa fa-download"></i>导出</a>
<!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('service_order/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->
<!--<div class="dropdown btn-group {:$auth->check('service_order/multi')?'':'hide'}">-->
... ...
... ... @@ -20,6 +20,28 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
});
var table = $("#table");
var submitForm = function (ids, layero) {
if(!ids){
return false;
}
$("input[name=ids]", layero).val(ids);
$("form", layero).submit();
Layer.closeAll();
};
$(document).on("click", ".btn-export", function () {
var ids = Table.api.selectedids(table);
Layer.confirm("选择导出的选项<form action='" + Fast.api.fixurl("order/export") + "' method='post'><input type='hidden' name='ids' value=''/></form>", {
title: '导出数据',
btn: ["选中项(" + ids.length + "条)"],
success: function (layero, index) {
$(".layui-layer-btn a", layero).addClass("layui-layer-btn0");
}, yes: function (index, layero) {
submitForm(ids.join(","), layero);
return false;
}
});
});
// 初始化表格
table.bootstrapTable({
... ...
... ... @@ -19,7 +19,28 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
});
var table = $("#table");
var submitForm = function (ids, layero) {
if(!ids){
return false;
}
$("input[name=ids]", layero).val(ids);
$("form", layero).submit();
Layer.closeAll();
};
$(document).on("click", ".btn-export", function () {
var ids = Table.api.selectedids(table);
Layer.confirm("选择导出的选项<form action='" + Fast.api.fixurl("service_order/export") + "' method='post'><input type='hidden' name='ids' value=''/></form>", {
title: '导出数据',
btn: ["选中项(" + ids.length + "条)"],
success: function (layero, index) {
$(".layui-layer-btn a", layero).addClass("layui-layer-btn0");
}, yes: function (index, layero) {
submitForm(ids.join(","), layero);
return false;
}
});
});
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
... ...