services.yml
keshifens_export_map:
class: KeshifenPlugin\Component\Export\Factory
arguments: ['@service_container']
public: true
Factory.php
<?php
/*
* 作者:少宇 - 赛驰网络
* 联系:170 33333 111
* 时间:2022/3/10 上午2:56
* 网址:https://www.saichinet.com
*
* 山东赛驰网络科技有限公司
* Shandong Search Network Technology Co., Ltd.
* Copyright © 2012-2020 Search Network, All Rights Reserved
*/
namespace KeshifenPlugin\Component\Export;
class Factory
{
public function getMap()
{
return [
'keshifens:count' => 'KeshifenPlugin\Component\Export\Keshifen\CountExporter',
];
}
}
CountExporter
<?php
namespace KeshifenPlugin\Component\Export\Keshifen;
use AppBundle\Common\ArrayToolkit;
use AppBundle\Component\Export\Exporter;
use Biz\User\Service\UserService;
class CountExporter extends Exporter
{
protected $conditions;
public function getTitles()
{
return array(
'用户Id',
'用户名',
'手机号码',
);
}
public function canExport()
{
$user = $this->getUser();
if ($user->hasPermission('admin_operation_invite_record') || $user->hasPermission('admin_v2_operation_invite_record')) {
return true;
}
return false;
}
public function getCount()
{
return $this->getUserUidService()->countUserUids($this->conditions);
}
public function getContent($start, $limit)
{
return [];
}
public function buildCondition($conditions)
{
$conditions = ArrayToolkit::parts($conditions, array('keyword'));
if (!empty($conditions['keyword'])) {
$user = $this->getUserService()->getUserByLoginField($conditions['keyword']);
$conditions['user_id'] = empty($user) ? '0' : $user['id'];
}
return $conditions;
}
protected function exportDataByUserUid($user_uid, $users)
{
$content = [];
return $content;
}
/**
* @return UserService
*/
protected function getUserService()
{
return $this->getBiz()->service('User:UserService');
}
/**
* @return UserUidService
*/
protected function getUserUidService()
{
return $this->getBiz()->service('UserUidPlugin:UserUid:UserUidService');
}
protected function getSettingService()
{
return $this->getBiz()->service('System:SettingService');
}
}
index.html.twig
<form id="user-search-form" class="form-inline well well-sm" action="" method="get" novalidate>
<div class="form-group">
<input type="text" name="nickname" class="form-control" value="{{ app.request.query.get('nickname') }}"
placeholder="{{ 'admin.user.teacher.fields.nickname.input_placeholder'|trans }}">
</div>
<button class="btn btn-primary">{{ 'admin.user.form.btn.search_submit_btn'|trans }}</button>
{% include 'export/export-btn.html.twig' with
{
'exportFileName' : 'keshifens:count',
'targetFormId' : 'user-keshifen-form'
} %}
</form>