导出
This commit is contained in:
parent
6e8158e57a
commit
006c8e8966
@ -29,6 +29,7 @@ class Dicts extends Repository
|
|||||||
'transaction_status' => ['未收款', '已收款', '已退款'],
|
'transaction_status' => ['未收款', '已收款', '已退款'],
|
||||||
'company_transaction_status' => ['未付款', '已付款', '已退款'],
|
'company_transaction_status' => ['未付款', '已付款', '已退款'],
|
||||||
'logistics' => ['sf' => '顺丰速运', 'sto' => '申通快递','yto' => '圆通速递', 'zto' => '中通快递', 'best' => '百世快递', 'yunda' => '韵达快递', 'ttkd'=> '天天快递', 'ems' => 'EMS邮政特快专递'],
|
'logistics' => ['sf' => '顺丰速运', 'sto' => '申通快递','yto' => '圆通速递', 'zto' => '中通快递', 'best' => '百世快递', 'yunda' => '韵达快递', 'ttkd'=> '天天快递', 'ems' => 'EMS邮政特快专递'],
|
||||||
|
'export_status' => ['准备中', '写入中', '保存中', '已完成', '导出失败', '文件丢失'],
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
@ -14,6 +14,7 @@ use Dipper\Excel\Events\BeforeWriting;
|
|||||||
use Illuminate\Support\Facades\Request;
|
use Illuminate\Support\Facades\Request;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Dipper\Excel\Concerns\ShouldAutoSize;
|
use Dipper\Excel\Concerns\ShouldAutoSize;
|
||||||
|
use App\Domains\Stats\Repositories\ExportRepository;
|
||||||
|
|
||||||
abstract class AbstractExport implements WithEvents, WithTitle, ShouldAutoSize
|
abstract class AbstractExport implements WithEvents, WithTitle, ShouldAutoSize
|
||||||
{
|
{
|
||||||
@ -66,6 +67,8 @@ abstract class AbstractExport implements WithEvents, WithTitle, ShouldAutoSize
|
|||||||
];
|
];
|
||||||
|
|
||||||
Export::create($data);
|
Export::create($data);
|
||||||
|
|
||||||
|
app(ExportRepository::class)->forgetCached();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,6 +83,8 @@ abstract class AbstractExport implements WithEvents, WithTitle, ShouldAutoSize
|
|||||||
'status' => 1,
|
'status' => 1,
|
||||||
'progress' => 50,
|
'progress' => 50,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
app(ExportRepository::class)->forgetCached();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,10 +99,12 @@ abstract class AbstractExport implements WithEvents, WithTitle, ShouldAutoSize
|
|||||||
'status' => 2,
|
'status' => 2,
|
||||||
'progress' => 90,
|
'progress' => 90,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
app(ExportRepository::class)->forgetCached();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保持结束
|
* 保存结束
|
||||||
*
|
*
|
||||||
* @param AfterStore $event
|
* @param AfterStore $event
|
||||||
* @return void
|
* @return void
|
||||||
@ -111,6 +118,7 @@ abstract class AbstractExport implements WithEvents, WithTitle, ShouldAutoSize
|
|||||||
'filesize' => $disk->size($event->getFilePath()),
|
'filesize' => $disk->size($event->getFilePath()),
|
||||||
'status' => 3,
|
'status' => 3,
|
||||||
'progress' => 100,
|
'progress' => 100,
|
||||||
|
'disk' => $event->getDisk(),
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
Export::where(['sn' => $event->getConcernable()->sn])->update([
|
Export::where(['sn' => $event->getConcernable()->sn])->update([
|
||||||
@ -118,6 +126,8 @@ abstract class AbstractExport implements WithEvents, WithTitle, ShouldAutoSize
|
|||||||
'progress' => 100,
|
'progress' => 100,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app(ExportRepository::class)->forgetCached();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,6 +179,11 @@ abstract class AbstractExport implements WithEvents, WithTitle, ShouldAutoSize
|
|||||||
{
|
{
|
||||||
$className = get_class($this);
|
$className = get_class($this);
|
||||||
|
|
||||||
|
return self::transformerClassName($className);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function transformerClassName($className)
|
||||||
|
{
|
||||||
$baseName = array_last(explode('\\', $className));
|
$baseName = array_last(explode('\\', $className));
|
||||||
|
|
||||||
return str_replace('Export', '', $baseName);
|
return str_replace('Export', '', $baseName);
|
||||||
|
@ -5,6 +5,7 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Dipper\Excel\Facades\Excel;
|
use Dipper\Excel\Facades\Excel;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use App\Domains\Stats\Services\ExportService;
|
||||||
use App\Domains\Stats\Exports\CompanyCountExport;
|
use App\Domains\Stats\Exports\CompanyCountExport;
|
||||||
use App\Domains\Stats\Services\CompanyCountService;
|
use App\Domains\Stats\Services\CompanyCountService;
|
||||||
|
|
||||||
@ -48,8 +49,7 @@ class CompanyCountController extends Controller
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$export = new CompanyCountExport($conditions);
|
$export = new CompanyCountExport($conditions);
|
||||||
Excel::store($export, $export->filename(), $this->disk);
|
$url = ExportService::store($export, $this->disk);
|
||||||
$url = Storage::disk($this->disk)->url($filename);
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return err('导出失败,请稍后重试');
|
return err('导出失败,请稍后重试');
|
||||||
}
|
}
|
||||||
|
50
app/Domains/Stats/Http/Controllers/ExportController.php
Normal file
50
app/Domains/Stats/Http/Controllers/ExportController.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Domains\Stats\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use App\Domains\Stats\Services\ExportService;
|
||||||
|
|
||||||
|
class ExportController extends Controller
|
||||||
|
{
|
||||||
|
protected $request;
|
||||||
|
protected $exportService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造函数,自动注入.
|
||||||
|
*/
|
||||||
|
public function __construct(Request $request, ExportService $exportService)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
$this->exportService = $exportService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$conditions = $this->request->all();
|
||||||
|
|
||||||
|
$res = $this->exportService->index($conditions);
|
||||||
|
|
||||||
|
return res($res, '导出记录', 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy()
|
||||||
|
{
|
||||||
|
$ids = $this->request->ids();
|
||||||
|
|
||||||
|
$this->exportService->destroy($ids);
|
||||||
|
|
||||||
|
return res(true, '删除成功');
|
||||||
|
}
|
||||||
|
}
|
59
app/Domains/Stats/Http/Controllers/OrderController.php
Normal file
59
app/Domains/Stats/Http/Controllers/OrderController.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Domains\Stats\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Core\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class CompanyReportController extends Controller
|
||||||
|
{
|
||||||
|
protected $request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造函数,自动注入.
|
||||||
|
*/
|
||||||
|
public function __construct(Request $request)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
70
app/Domains/Stats/Repositories/ExportRepository.php
Normal file
70
app/Domains/Stats/Repositories/ExportRepository.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Stats\Repositories;
|
||||||
|
|
||||||
|
use App\Core\Repository;
|
||||||
|
use App\Models\Stats\Export as Model;
|
||||||
|
|
||||||
|
class ExportRepository extends Repository
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 是否关闭缓存
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected $cacheSkip = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否开启数据转化
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $needTransform = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fieldSearchable = [
|
||||||
|
'id' => '=',
|
||||||
|
'created_at' => 'like',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function model() {
|
||||||
|
return Model::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据格式化
|
||||||
|
*
|
||||||
|
* @param mixed $result
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function transform($model)
|
||||||
|
{
|
||||||
|
return $model->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询条件
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function withConditions(array $conditions = [])
|
||||||
|
{
|
||||||
|
if (isset($conditions['id'])) {
|
||||||
|
$conditions['id'] = array_wrap($conditions['id']);
|
||||||
|
$this->model = $this->model->whereIn('id', $conditions['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($conditions['starttime'])) {
|
||||||
|
$this->model = $this->model->where('created_at', '>=', $conditions['starttime']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($conditions['endtime'])) {
|
||||||
|
$this->model = $this->model->where('created_at', '<=', $conditions['endtime']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,10 @@
|
|||||||
// Prefix: /api/stats
|
// Prefix: /api/stats
|
||||||
$router->group(['prefix' => 'stats', 'as' => 'stats', 'middleware' => ['adminAuth']], function ($router) {
|
$router->group(['prefix' => 'stats', 'as' => 'stats', 'middleware' => ['adminAuth']], function ($router) {
|
||||||
|
|
||||||
|
// 导出记录
|
||||||
|
$router->get('/exports', ['as' => 'exports', 'uses' => 'ExportController@index']);
|
||||||
|
$router->post('/exports/destroy', ['as' => 'exports.destroy', 'uses' => 'ExportController@destroy']);
|
||||||
|
|
||||||
// 企业统计
|
// 企业统计
|
||||||
$router->get('/company-count', ['as' => 'company-count.index', 'uses' => 'CompanyCountController@index']);
|
$router->get('/company-count', ['as' => 'company-count.index', 'uses' => 'CompanyCountController@index']);
|
||||||
$router->get('/company-count/export', ['as' => 'company-count.export', 'uses' => 'CompanyCountController@export']);
|
$router->get('/company-count/export', ['as' => 'company-count.export', 'uses' => 'CompanyCountController@export']);
|
||||||
|
103
app/Domains/Stats/Services/ExportService.php
Normal file
103
app/Domains/Stats/Services/ExportService.php
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Domains\Stats\Services;
|
||||||
|
|
||||||
|
use App\Dicts;
|
||||||
|
use App\Core\Service;
|
||||||
|
use Dipper\Excel\Facades\Excel;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use App\Domains\Stats\Exports\AbstractExport;
|
||||||
|
use App\Domains\Stats\Repositories\ExportRepository;
|
||||||
|
|
||||||
|
class ExportService extends Service
|
||||||
|
{
|
||||||
|
protected $exportRepository;
|
||||||
|
|
||||||
|
protected static $status = ['数据准备中', '开始写入', '写入结束', '保存成功', '任务失败'];
|
||||||
|
|
||||||
|
protected static $maxRow = 30000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造函数
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(ExportRepository $exportRepository)
|
||||||
|
{
|
||||||
|
$this->exportRepository = $exportRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出记录
|
||||||
|
*
|
||||||
|
* @param array $conditions
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function index(array $conditions = [])
|
||||||
|
{
|
||||||
|
$limit = $conditions['limit'] ?? 20;
|
||||||
|
|
||||||
|
$exports = $this->exportRepository->withConditions($conditions)->applyConditions()->paginate($limit);
|
||||||
|
|
||||||
|
$classes = AbstractExport::$classes;
|
||||||
|
|
||||||
|
foreach ($classes as $key => $value) {
|
||||||
|
$new = AbstractExport::transformerClassName($key);
|
||||||
|
$classes[$new] = $value;
|
||||||
|
unset($classes[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = app(Dicts::class)->get('export_status');
|
||||||
|
|
||||||
|
$exports->transform(function ($item) use ($classes, $status) {
|
||||||
|
$exists = Storage::disk($item->disk)->exists($item->filename);
|
||||||
|
|
||||||
|
if ($item->status === 3) {
|
||||||
|
if (!$exists = Storage::disk($item->disk)->exists($item->filename)) {
|
||||||
|
$item->status = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => $item->id,
|
||||||
|
'tag_name' => $classes[$item['tag']] ?? '未知',
|
||||||
|
'filesize' => human_filesize($item->filesize),
|
||||||
|
'dateline' => !$item->conditions['starttime'] ? '所有' : $item->conditions['starttime'] . ' 至 ' . $item->conditions['endtime'],
|
||||||
|
'status' => $item->status,
|
||||||
|
'status_name' => $status[$item->status],
|
||||||
|
'url' => $status[$item->status] === 3 ? Storage::disk($item->disk)->url($item->filename) : '',
|
||||||
|
'created_at' => (string)$item->created_at,
|
||||||
|
'updated_at' => (string)$item->updated_at,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
return $exports;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function destroy($ids)
|
||||||
|
{
|
||||||
|
$ids = is_array($ids) ? $ids : [$ids];
|
||||||
|
|
||||||
|
$this->exportRepository->destroy($ids);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出
|
||||||
|
*/
|
||||||
|
public static function store($export, $disk, $total = 0)
|
||||||
|
{
|
||||||
|
if ($total < self::$maxRow) {
|
||||||
|
Excel::store($export, $export->filename, $disk);
|
||||||
|
$url = Storage::disk($disk)->url($export->filename);
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
Excel::queue($export, $export->filename, $disk);
|
||||||
|
}
|
||||||
|
}
|
115
app/Domains/Stats/Services/OrderService.php
Normal file
115
app/Domains/Stats/Services/OrderService.php
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Domains\Stats\Services;
|
||||||
|
|
||||||
|
use App\Core\Service;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use App\Exceptions\NotAllowedException;
|
||||||
|
use App\Domains\Virtual\Services\CommonService;
|
||||||
|
use App\Domains\Virtual\Repositories\OrderRepository;
|
||||||
|
use App\Domains\Virtual\Repositories\CompanyRepository;
|
||||||
|
use App\Domains\Virtual\Repositories\PackageRepository;
|
||||||
|
|
||||||
|
class OrderService extends Service
|
||||||
|
{
|
||||||
|
protected $companyRepository;
|
||||||
|
protected $packageRepository;
|
||||||
|
protected $orderRepository;
|
||||||
|
|
||||||
|
protected static $classes = [
|
||||||
|
\App\Domains\Virtual\Repositories\OrderCardRepository::class,
|
||||||
|
\App\Domains\Virtual\Repositories\OrderRenewalCardRepository::class,
|
||||||
|
\App\Domains\Virtual\Repositories\OrderRenewalPackageCardRepository::class,
|
||||||
|
\App\Domains\Virtual\Repositories\OrderFlowPackageCardsRepository::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造函数
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
CompanyRepository $companyRepository,
|
||||||
|
PackageRepository $packageRepository,
|
||||||
|
OrderRepository $orderRepository
|
||||||
|
) {
|
||||||
|
$this->companyRepository = $companyRepository;
|
||||||
|
$this->packageRepository = $packageRepository;
|
||||||
|
$this->orderRepository = $orderRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function index(array $conditions = [])
|
||||||
|
{
|
||||||
|
$conditions['source'] = 1;
|
||||||
|
|
||||||
|
$companies = $this->companyRepository->withTrashed()->get()->pluck('name', 'id')->toArray();
|
||||||
|
$packages = $this->packageRepository->withTrashed()->get()->pluck('name', 'id')->toArray();
|
||||||
|
|
||||||
|
$select = [
|
||||||
|
'id',
|
||||||
|
'company_id',
|
||||||
|
'package_id',
|
||||||
|
'unit_price',
|
||||||
|
'pay_channel',
|
||||||
|
DB::raw('SUM(counts) as counts'),
|
||||||
|
DB::raw('SUM(custom_price) as custom_price'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$orders = $this->orderRepository->select($select)->withConditions($conditions)->applyConditions()
|
||||||
|
->groupBy(['company_id', 'product_id', 'pay_channel'])->paginate($conditions['limit']);
|
||||||
|
|
||||||
|
$orders->map(function ($item) use ($companies, $packages) {
|
||||||
|
$item->company_name = $packages[$item->company_id];
|
||||||
|
$item->package_name = $packages[$item->package_id];
|
||||||
|
$item->pay_channel_name = CommonService::namePayChannel($item->pay_channel);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $orders;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 明细
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function detail(array $conditions = [])
|
||||||
|
{
|
||||||
|
if (!$class = self::$classes[$conditions['type']]) {
|
||||||
|
throw new NotAllowedException('统计类型不存在');
|
||||||
|
}
|
||||||
|
|
||||||
|
$repository = app($class);
|
||||||
|
|
||||||
|
$companies = $this->companyRepository->withTrashed()->get()->pluck('name', 'id')->toArray();
|
||||||
|
$packages = $this->packageRepository->withTrashed()->get()->pluck('name', 'id')->toArray();
|
||||||
|
|
||||||
|
|
||||||
|
$repository->withConditons()
|
||||||
|
|
||||||
|
$select = [
|
||||||
|
'id',
|
||||||
|
'company_id',
|
||||||
|
'package_id',
|
||||||
|
'unit_price',
|
||||||
|
'pay_channel',
|
||||||
|
DB::raw('SUM(counts) as counts'),
|
||||||
|
DB::raw('SUM(custom_price) as custom_price'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$orders = $this->orderRepository->select($select)->withConditions($conditions)->applyConditions()
|
||||||
|
->groupBy(['company_id', 'product_id', 'pay_channel'])->paginate($conditions['limit']);
|
||||||
|
|
||||||
|
$orders->map(function ($item) use ($companies, $packages) {
|
||||||
|
$item->company_name = $packages[$item->company_id];
|
||||||
|
$item->package_name = $packages[$item->package_id];
|
||||||
|
$item->pay_channel_name = CommonService::namePayChannel($item->pay_channel);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $orders;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Virtual\Repositories\Concerns;
|
||||||
|
|
||||||
|
trait OrderCardConcern
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否关闭缓存
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected $cacheSkip = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否开启数据转化
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $needTransform = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fieldSearchable = [
|
||||||
|
'id' => '=',
|
||||||
|
'created_at' => 'like',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据格式化
|
||||||
|
*
|
||||||
|
* @param mixed $result
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function transform($model)
|
||||||
|
{
|
||||||
|
return $model->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询条件
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function withConditions(array $conditions = [])
|
||||||
|
{
|
||||||
|
if (isset($conditions['id'])) {
|
||||||
|
$conditions['id'] = array_wrap($conditions['id']);
|
||||||
|
$this->model = $this->model->whereIn('id', $conditions['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($conditions['company_id'])) {
|
||||||
|
$this->model = $this->model->where('company_id', $conditions['company_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($conditions['package_id'])) {
|
||||||
|
$this->model = $this->model->where('package_id', $conditions['package_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($conditions['carrier_operator'])) {
|
||||||
|
$this->model = $this->model->whereHas('package', function ($relation) use ($conditions) {
|
||||||
|
$relation->where('carrier_operator', $conditions['carrier_operator']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($conditions['pay_channel'])) {
|
||||||
|
$this->model = $this->model->where('pay_channel', $conditions['pay_channel']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($conditions['company_name'])) {
|
||||||
|
$this->model = $this->model->whereHas('company', function ($relation) use ($conditions) {
|
||||||
|
$relation->where('name', $conditions['company_name']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($conditions['package_name'])) {
|
||||||
|
$this->model = $this->model->whereHas('package', function ($relation) use ($conditions) {
|
||||||
|
$relation->where('name', $conditions['package_name']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($conditions['starttime'])) {
|
||||||
|
$this->model = $this->model->where('order_at', '>=', $conditions['starttime']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($conditions['endtime'])) {
|
||||||
|
$this->model = $this->model->where('order_at', '<=', $conditions['endtime']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
@ -4,60 +4,14 @@ namespace App\Domains\Virtual\Repositories;
|
|||||||
|
|
||||||
use App\Core\Repository;
|
use App\Core\Repository;
|
||||||
use App\Models\Virtual\OrderCard as Model;
|
use App\Models\Virtual\OrderCard as Model;
|
||||||
|
use App\Domains\Virtual\Repositories\Concerns\OrderCardConcern;
|
||||||
|
|
||||||
class OrderCardRepository extends Repository
|
class OrderCardRepository extends Repository
|
||||||
{
|
{
|
||||||
/**
|
use OrderCardConcern;
|
||||||
* 是否关闭缓存
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
protected $cacheSkip = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否开启数据转化
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $needTransform = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fieldSearchable = [
|
|
||||||
'id' => '=',
|
|
||||||
'created_at' => 'like',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function model()
|
public function model()
|
||||||
{
|
{
|
||||||
return Model::class;
|
return Model::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据格式化
|
|
||||||
*
|
|
||||||
* @param mixed $result
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function transform($model)
|
|
||||||
{
|
|
||||||
return $model->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询条件
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function withConditions(array $conditions = [])
|
|
||||||
{
|
|
||||||
if (isset($conditions['id'])) {
|
|
||||||
$conditions['id'] = array_wrap($conditions['id']);
|
|
||||||
$this->model = $this->model->whereIn('id', $conditions['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,59 +4,14 @@ namespace App\Domains\Virtual\Repositories;
|
|||||||
|
|
||||||
use App\Core\Repository;
|
use App\Core\Repository;
|
||||||
use App\Models\Virtual\OrderFlowPackageCards as Model;
|
use App\Models\Virtual\OrderFlowPackageCards as Model;
|
||||||
|
use App\Domains\Virtual\Repositories\Concerns\OrderCardConcern;
|
||||||
|
|
||||||
class OrderFlowPackageCardsRepository extends Repository
|
class OrderFlowPackageCardsRepository extends Repository
|
||||||
{
|
{
|
||||||
/**
|
use OrderCardConcern;
|
||||||
* 是否关闭缓存
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
protected $cacheSkip = false;
|
|
||||||
|
|
||||||
/**
|
public function model()
|
||||||
* 是否开启数据转化
|
{
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $needTransform = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fieldSearchable = [
|
|
||||||
'id' => '=',
|
|
||||||
'created_at' => 'like',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function model() {
|
|
||||||
return Model::class;
|
return Model::class;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 数据格式化
|
|
||||||
*
|
|
||||||
* @param mixed $result
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function transform($model)
|
|
||||||
{
|
|
||||||
return $model->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询条件
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function withConditions(array $conditions = [])
|
|
||||||
{
|
|
||||||
if (isset($conditions['id'])) {
|
|
||||||
$conditions['id'] = array_wrap($conditions['id']);
|
|
||||||
$this->model = $this->model->whereIn('id', $conditions['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -4,59 +4,14 @@ namespace App\Domains\Virtual\Repositories;
|
|||||||
|
|
||||||
use App\Core\Repository;
|
use App\Core\Repository;
|
||||||
use App\Models\Virtual\OrderRenewalCard as Model;
|
use App\Models\Virtual\OrderRenewalCard as Model;
|
||||||
|
use App\Domains\Virtual\Repositories\Concerns\OrderCardConcern;
|
||||||
|
|
||||||
class OrderRenewalCardRepository extends Repository
|
class OrderRenewalCardRepository extends Repository
|
||||||
{
|
{
|
||||||
/**
|
use OrderCardConcern;
|
||||||
* 是否关闭缓存
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
protected $cacheSkip = false;
|
|
||||||
|
|
||||||
/**
|
public function model()
|
||||||
* 是否开启数据转化
|
{
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $needTransform = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fieldSearchable = [
|
|
||||||
'id' => '=',
|
|
||||||
'created_at' => 'like',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function model() {
|
|
||||||
return Model::class;
|
return Model::class;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 数据格式化
|
|
||||||
*
|
|
||||||
* @param mixed $result
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function transform($model)
|
|
||||||
{
|
|
||||||
return $model->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询条件
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function withConditions(array $conditions = [])
|
|
||||||
{
|
|
||||||
if (isset($conditions['id'])) {
|
|
||||||
$conditions['id'] = array_wrap($conditions['id']);
|
|
||||||
$this->model = $this->model->whereIn('id', $conditions['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -4,59 +4,14 @@ namespace App\Domains\Virtual\Repositories;
|
|||||||
|
|
||||||
use App\Core\Repository;
|
use App\Core\Repository;
|
||||||
use App\Models\Virtual\OrderRenewalPackageCard as Model;
|
use App\Models\Virtual\OrderRenewalPackageCard as Model;
|
||||||
|
use App\Domains\Virtual\Repositories\Concerns\OrderCardConcern;
|
||||||
|
|
||||||
class OrderRenewalPackageCardRepository extends Repository
|
class OrderRenewalPackageCardRepository extends Repository
|
||||||
{
|
{
|
||||||
/**
|
use OrderCardConcern;
|
||||||
* 是否关闭缓存
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
protected $cacheSkip = false;
|
|
||||||
|
|
||||||
/**
|
public function model()
|
||||||
* 是否开启数据转化
|
{
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $needTransform = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fieldSearchable = [
|
|
||||||
'id' => '=',
|
|
||||||
'created_at' => 'like',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function model() {
|
|
||||||
return Model::class;
|
return Model::class;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 数据格式化
|
|
||||||
*
|
|
||||||
* @param mixed $result
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function transform($model)
|
|
||||||
{
|
|
||||||
return $model->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询条件
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function withConditions(array $conditions = [])
|
|
||||||
{
|
|
||||||
if (isset($conditions['id'])) {
|
|
||||||
$conditions['id'] = array_wrap($conditions['id']);
|
|
||||||
$this->model = $this->model->whereIn('id', $conditions['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -143,3 +143,19 @@ if (! function_exists('array_merge_sum')) {
|
|||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! function_exists('human_filesize')) {
|
||||||
|
/**
|
||||||
|
* 文件大小可读性
|
||||||
|
*
|
||||||
|
* @param array $arr1
|
||||||
|
* @param array $arr2
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function human_filesize($bytes, $decimals = 2)
|
||||||
|
{
|
||||||
|
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
|
||||||
|
$factor = floor((strlen($bytes) - 1) / 3);
|
||||||
|
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -17,6 +17,7 @@ class CreateStatsExportsTable extends Migration
|
|||||||
$table->increments('id')->comment('自增ID');
|
$table->increments('id')->comment('自增ID');
|
||||||
$table->string('sn', 32)->default('')->comment('命令编号');
|
$table->string('sn', 32)->default('')->comment('命令编号');
|
||||||
$table->string('tag', 20)->default('')->comment('标记');
|
$table->string('tag', 20)->default('')->comment('标记');
|
||||||
|
$table->string('disk', 20)->default('')->comment('存储位置');
|
||||||
$table->string('filename')->default('')->comment('文件名');
|
$table->string('filename')->default('')->comment('文件名');
|
||||||
$table->integer('filesize')->unsigned()->default(0)->comment('文件大小');
|
$table->integer('filesize')->unsigned()->default(0)->comment('文件大小');
|
||||||
$table->text('conditions')->nullable()->comment('查询条件');
|
$table->text('conditions')->nullable()->comment('查询条件');
|
||||||
|
@ -130,7 +130,7 @@ class PermissionSeeder extends Seeder
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'virtual_stat_ctrl',
|
'name' => 'stats_ctrl',
|
||||||
'title' => '数据统计',
|
'title' => '数据统计',
|
||||||
'path' => '#',
|
'path' => '#',
|
||||||
'icon' => 'md-planet',
|
'icon' => 'md-planet',
|
||||||
@ -138,7 +138,13 @@ class PermissionSeeder extends Seeder
|
|||||||
'open' => 3,
|
'open' => 3,
|
||||||
'children' => [
|
'children' => [
|
||||||
[
|
[
|
||||||
'name' => 'virtual.stat.company-index', 'title' => '企业统计', 'path' => '/stats/company-count', 'icon' => 'md-pulse', 'type' => 0, 'open' => 3
|
'name' => 'stat.exports.index', 'title' => '导出记录', 'path' => '/stats/exports', 'icon' => 'ios-download', 'type' => 0, 'open' => 3,
|
||||||
|
'children' => [
|
||||||
|
['name' => 'stat.exports.destroy', 'title' => '删除', 'description' => 'destroy', 'type' => 1],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'stats.company-index', 'title' => '企业统计', 'path' => '/stats/company-count', 'icon' => 'md-pulse', 'type' => 0, 'open' => 3
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
@ -22,7 +22,8 @@ const routes = [
|
|||||||
{ path: '/products', name: 'Products', component: load('virtual/products/index'), meta: { title: '定价管理' } },
|
{ path: '/products', name: 'Products', component: load('virtual/products/index'), meta: { title: '定价管理' } },
|
||||||
{ path: '/orders', name: 'Orders', component: load('virtual/orders/index'), meta: { title: '订单列表' } },
|
{ path: '/orders', name: 'Orders', component: load('virtual/orders/index'), meta: { title: '订单列表' } },
|
||||||
{ path: '/packages', name: 'Packages', component: load('virtual/packages/index'), meta: { title: '套餐管理' } },
|
{ path: '/packages', name: 'Packages', component: load('virtual/packages/index'), meta: { title: '套餐管理' } },
|
||||||
{ path: '/stats/company-count', name: 'CompanyCount', component: load('stats/company-count/index'), meta: { title: '企业统计' } }
|
{ path: '/stats/exports', name: 'StatsExports', component: load('stats/exports/index'), meta: { title: '导出记录' } },
|
||||||
|
{ path: '/stats/company-count', name: 'StatsCompanyCount', component: load('stats/company-count/index'), meta: { title: '企业统计' } }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ path: '*', redirect: { path: '/home' } }
|
{ path: '*', redirect: { path: '/home' } }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Companies',
|
name: 'StatsCompanyCount',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
options: {
|
options: {
|
||||||
@ -115,7 +115,6 @@ export default {
|
|||||||
this.isShowLoading(true);
|
this.isShowLoading(true);
|
||||||
|
|
||||||
service.get('api/stats/company-count/export', { params }).then((res) => {
|
service.get('api/stats/company-count/export', { params }).then((res) => {
|
||||||
console.log(res);
|
|
||||||
this.downloadFile(res.data);
|
this.downloadFile(res.data);
|
||||||
this.isShowLoading(false);
|
this.isShowLoading(false);
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
73
frontend/src/views/stats/exports/index.vue
Normal file
73
frontend/src/views/stats/exports/index.vue
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page-wrap">
|
||||||
|
<ui-loading :show="page_loading.show"></ui-loading>
|
||||||
|
|
||||||
|
<div class="page-handle-wrap">
|
||||||
|
<ul class="handle-wraper bd-b">
|
||||||
|
<li class="f-l">
|
||||||
|
<div class="text-exp"><b>全部信息</b></div>
|
||||||
|
</li>
|
||||||
|
<li class="f-r">
|
||||||
|
<div class="handle-item">
|
||||||
|
<Button v-has="'destroy'" type="primary" icon="md-trash" @click="destroyBatch">删除</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="handle-item">
|
||||||
|
<Button type="primary" icon="ios-search" ghost @click="search.show=!search.show">搜索</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="handle-item">
|
||||||
|
<Button icon="md-refresh" @click="index(1)">刷新</Button>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="search-wrap" v-show="search.show">
|
||||||
|
<ul class="handle-wraper">
|
||||||
|
<li class="handle-item w-350">
|
||||||
|
<DatePicker
|
||||||
|
:editable="false"
|
||||||
|
type="daterange"
|
||||||
|
placement="bottom-start"
|
||||||
|
placeholder="请选择时间"
|
||||||
|
v-model.trim="other.time">
|
||||||
|
</DatePicker>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<ul class="handle-wraper">
|
||||||
|
<li class="f-r">
|
||||||
|
<div class="handle-item">
|
||||||
|
<Button type="primary" ghost @click="index(1)">立即搜索</Button>
|
||||||
|
</div>
|
||||||
|
<div class="handle-item">
|
||||||
|
<Button type="warning" ghost @click="resetSearch">重置搜索</Button>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="page-list-wrap">
|
||||||
|
<Alert show-icon class="page-tips">
|
||||||
|
已选<span class="num">{{selection.length}}</span>项
|
||||||
|
<span class="clear" @click="handleSelectAll(false)">清空</span>
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
<Table ref="table" :columns="table_titles" :data="list_data?list_data.data:[]" @on-selection-change="selectionChange"></Table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="page-turn-wrap" v-if="list_data && list_data.data.length">
|
||||||
|
<Page
|
||||||
|
show-total
|
||||||
|
show-elevator
|
||||||
|
:current="Number(list_data.current_page)"
|
||||||
|
:total="Number(list_data.total)"
|
||||||
|
:page-size="Number(list_data.per_page)"
|
||||||
|
@on-change="index">
|
||||||
|
</Page>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./js/index.js"></script>
|
206
frontend/src/views/stats/exports/js/index.js
Normal file
206
frontend/src/views/stats/exports/js/index.js
Normal file
@ -0,0 +1,206 @@
|
|||||||
|
export default {
|
||||||
|
name: 'Exports',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
params: {
|
||||||
|
request_param: ''
|
||||||
|
},
|
||||||
|
other: {
|
||||||
|
time: []
|
||||||
|
},
|
||||||
|
list_data: null,
|
||||||
|
search: {
|
||||||
|
show: false
|
||||||
|
},
|
||||||
|
selection: [], // 复选框选中项
|
||||||
|
table_titles: [
|
||||||
|
{
|
||||||
|
type: 'selection',
|
||||||
|
width: 60,
|
||||||
|
align: 'center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '序号',
|
||||||
|
key: '',
|
||||||
|
width: 80,
|
||||||
|
render: (h, { row, column, index }) => {
|
||||||
|
return h('span', index + 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '类型',
|
||||||
|
key: 'tag_name',
|
||||||
|
width: 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '查询范围',
|
||||||
|
key: 'dateline',
|
||||||
|
width: 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '文件大小',
|
||||||
|
key: 'filesize',
|
||||||
|
width: 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
key: 'status_name',
|
||||||
|
width: 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
key: 'created_at',
|
||||||
|
width: 170
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
render: (h, { row, column, index }) => {
|
||||||
|
let html = [];
|
||||||
|
|
||||||
|
if (row.status === 3) {
|
||||||
|
html.push(h('Button', {
|
||||||
|
props: {
|
||||||
|
type: 'success',
|
||||||
|
size: 'small',
|
||||||
|
disabled: false,
|
||||||
|
icon: 'md-trash',
|
||||||
|
target: '_blank',
|
||||||
|
to: row.url
|
||||||
|
},
|
||||||
|
class: ['btn']
|
||||||
|
}, '下载'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.haveJurisdiction('destroy')) {
|
||||||
|
html.push(h('Button', {
|
||||||
|
props: {
|
||||||
|
type: 'error',
|
||||||
|
size: 'small',
|
||||||
|
disabled: false,
|
||||||
|
icon: 'md-trash'
|
||||||
|
},
|
||||||
|
class: ['btn'],
|
||||||
|
on: {
|
||||||
|
click: () => {
|
||||||
|
this.destroy({ ids: row.id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, '删除'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (html.length) {
|
||||||
|
return h('div', html);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.index();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/**
|
||||||
|
* [index 列表]
|
||||||
|
* @param {Number} page [description]
|
||||||
|
* @return {[type]} [description]
|
||||||
|
*/
|
||||||
|
index(page = 1) {
|
||||||
|
this.scrollTop();
|
||||||
|
let data = this.searchDataHandle(this.params, { page }, this.other);
|
||||||
|
this.isShowLoading(true);
|
||||||
|
console.log(data);
|
||||||
|
service.get('api/stats/exports', { params: data }).then(res => {
|
||||||
|
this.isShowLoading(false);
|
||||||
|
if (res.code == 0) {
|
||||||
|
let result = res.data;
|
||||||
|
result.data = this.tableCheckboxHandle(result.data, this.selection);
|
||||||
|
this.list_data = result;
|
||||||
|
}
|
||||||
|
}).catch(err => {
|
||||||
|
this.isShowLoading(false);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [selectionChange 复选框事件]
|
||||||
|
* @return {[type]} [description]
|
||||||
|
*/
|
||||||
|
selectionChange(selection) {
|
||||||
|
this.selection = selection;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [destroyBatch 批量删除触发按钮]
|
||||||
|
* @return {[type]} [description]
|
||||||
|
*/
|
||||||
|
destroyBatch() {
|
||||||
|
if (this.selection.length) {
|
||||||
|
let arry = this.selection.map(item => {
|
||||||
|
return item.id;
|
||||||
|
});
|
||||||
|
this.destroy({ ids: arry.join(',') });
|
||||||
|
} else {
|
||||||
|
this.$Message.info('请勾选要删除的项');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [destroy 删除操作]
|
||||||
|
* @param {[type]} data [description]
|
||||||
|
* @return {[type]} [description]
|
||||||
|
*/
|
||||||
|
destroy(data) {
|
||||||
|
this.$Modal.confirm({
|
||||||
|
title: '提示',
|
||||||
|
content: '确认执行删除操作?',
|
||||||
|
onOk: () => {
|
||||||
|
service.post('api/stats/exports/destroy', data).then(res => {
|
||||||
|
if (res.code == 0) {
|
||||||
|
// 当有勾选项,删除操作的地方为每行的按钮,将复选框勾选项去除此id
|
||||||
|
const ids = data.ids.toString().split(',');
|
||||||
|
if (ids.length == 1) {
|
||||||
|
for (let i = 0, len = this.selection.length; i < len; i++) {
|
||||||
|
if (ids[0] == this.selection[i].id) {
|
||||||
|
this.selection.splice(i, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.$Message.success('删除成功');
|
||||||
|
this.request();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [request 刷新]
|
||||||
|
* @return {[type]} [description]
|
||||||
|
*/
|
||||||
|
request() {
|
||||||
|
const result = this.list_data;
|
||||||
|
let page = result.current_page;
|
||||||
|
|
||||||
|
if (this.list_data.data.length == 1) {
|
||||||
|
page = this.returnPage(result.total, result.current_page, result.per_page);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.index(page);
|
||||||
|
},
|
||||||
|
|
||||||
|
resetSearch() {
|
||||||
|
for (let k in this.params) {
|
||||||
|
this.params[k] = '';
|
||||||
|
}
|
||||||
|
this.other.time = [];
|
||||||
|
this.index(1);
|
||||||
|
},
|
||||||
|
|
||||||
|
handleSelectAll(bool) {
|
||||||
|
this.$refs.table.selectAll(bool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
2
public/css/chunk-a0b8384a.2b7901ac.css
Normal file
2
public/css/chunk-a0b8384a.2b7901ac.css
Normal file
File diff suppressed because one or more lines are too long
2
public/js/app.6330bcc5.js
Normal file
2
public/js/app.6330bcc5.js
Normal file
File diff suppressed because one or more lines are too long
1
public/js/app.6330bcc5.js.map
Normal file
1
public/js/app.6330bcc5.js.map
Normal file
File diff suppressed because one or more lines are too long
2
public/js/chunk-a0b8384a.d3cdc6cf.js
Normal file
2
public/js/chunk-a0b8384a.d3cdc6cf.js
Normal file
File diff suppressed because one or more lines are too long
1
public/js/chunk-a0b8384a.d3cdc6cf.js.map
Normal file
1
public/js/chunk-a0b8384a.d3cdc6cf.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-ede1b12e.28e22857.css rel=prefetch><link href=/js/chunk-00ae0766.16700330.js rel=prefetch><link href=/js/chunk-ede1b12e.8e8abefc.js rel=prefetch><link href=/css/app.36043160.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.8ed13520.js rel=preload as=script><link href=/js/chunk-vendors.02a4e5bc.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.36043160.css rel=stylesheet></head><body><noscript><strong>很抱歉,如果没有启用JavaScript,程序不能正常工作,若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.02a4e5bc.js></script><script src=/js/app.8ed13520.js></script></body></html>
|
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-a0b8384a.2b7901ac.css rel=prefetch><link href=/js/chunk-00ae0766.16700330.js rel=prefetch><link href=/js/chunk-a0b8384a.d3cdc6cf.js rel=prefetch><link href=/css/app.36043160.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.6330bcc5.js rel=preload as=script><link href=/js/chunk-vendors.02a4e5bc.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.36043160.css rel=stylesheet></head><body><noscript><strong>很抱歉,如果没有启用JavaScript,程序不能正常工作,若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.02a4e5bc.js></script><script src=/js/app.6330bcc5.js></script></body></html>
|
2
vendor/dipper/excel/src/Excel.php
vendored
2
vendor/dipper/excel/src/Excel.php
vendored
@ -106,7 +106,7 @@ class Excel implements Exporter, Importer
|
|||||||
|
|
||||||
$result = $this->filesystem->disk($disk)->put($filePath, fopen($file, 'r+'));
|
$result = $this->filesystem->disk($disk)->put($filePath, fopen($file, 'r+'));
|
||||||
|
|
||||||
$this->raise(new AfterStore($this->writer, $export));
|
$this->raise(new AfterStore($this->writer, $export, $filePath, $disk));
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user