feat(devices): 设备列表增加国家筛选项
与访问记录列表实现保持一致: - DeviceController::index() 向视图传入 countries (CfIpCountry::names()) - filtersFrom() 解析 country 参数 (CfIpCountry::normalize,支持 ISO 代码与中文名) - filteredQuery() 按 devices.country 过滤 - 视图在 iOS 版本与钱包之间新增 lay-search 国家下拉框 - 重置按钮 reload where 增加 country: ''
This commit is contained in:
@@ -45,6 +45,7 @@ class DeviceController extends Controller
|
|||||||
return view('admin.devices.index', [
|
return view('admin.devices.index', [
|
||||||
'portal' => $this->portal(),
|
'portal' => $this->portal(),
|
||||||
'agents' => $agents,
|
'agents' => $agents,
|
||||||
|
'countries' => CfIpCountry::names(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -851,6 +852,7 @@ class DeviceController extends Controller
|
|||||||
'model' => trim((string) $request->query('model', '')),
|
'model' => trim((string) $request->query('model', '')),
|
||||||
'ip' => trim((string) $request->query('ip', '')),
|
'ip' => trim((string) $request->query('ip', '')),
|
||||||
'ios' => trim((string) $request->query('ios', '')),
|
'ios' => trim((string) $request->query('ios', '')),
|
||||||
|
'country' => CfIpCountry::normalize((string) $request->query('country', '')),
|
||||||
'installed_from' => trim((string) $request->query('installed_from', '')),
|
'installed_from' => trim((string) $request->query('installed_from', '')),
|
||||||
'installed_to' => trim((string) $request->query('installed_to', '')),
|
'installed_to' => trim((string) $request->query('installed_to', '')),
|
||||||
'has_wallet' => $hasWalletInt,
|
'has_wallet' => $hasWalletInt,
|
||||||
@@ -860,7 +862,7 @@ class DeviceController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array{device_key: string, chain: ?int, channel_id: string, model: string, ip: string, ios: string, installed_from: string, installed_to: string, has_wallet: ?int, has_im: string, agent_user_id: ?int} $filters
|
* @param array{device_key: string, chain: ?int, channel_id: string, model: string, ip: string, ios: string, country: ?string, installed_from: string, installed_to: string, has_wallet: ?int, has_im: string, agent_user_id: ?int} $filters
|
||||||
*/
|
*/
|
||||||
private function filteredQuery(array $filters): Builder
|
private function filteredQuery(array $filters): Builder
|
||||||
{
|
{
|
||||||
@@ -885,6 +887,9 @@ class DeviceController extends Controller
|
|||||||
if ($filters['ios'] !== '') {
|
if ($filters['ios'] !== '') {
|
||||||
$q->where('devices.ios_version', 'like', '%'.$filters['ios'].'%');
|
$q->where('devices.ios_version', 'like', '%'.$filters['ios'].'%');
|
||||||
}
|
}
|
||||||
|
if ($filters['country'] !== null) {
|
||||||
|
$q->where('devices.country', $filters['country']);
|
||||||
|
}
|
||||||
if ($filters['installed_from'] !== '' && preg_match('/^\d{4}-\d{2}-\d{2}/', $filters['installed_from'])) {
|
if ($filters['installed_from'] !== '' && preg_match('/^\d{4}-\d{2}-\d{2}/', $filters['installed_from'])) {
|
||||||
$q->whereDate('devices.created_at', '>=', substr($filters['installed_from'], 0, 10));
|
$q->whereDate('devices.created_at', '>=', substr($filters['installed_from'], 0, 10));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,17 @@
|
|||||||
<input type="text" name="ios" placeholder="15.8" autocomplete="off" class="layui-input">
|
<input type="text" name="ios" placeholder="15.8" autocomplete="off" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label">国家</label>
|
||||||
|
<div class="layui-input-block" style="min-width: 180px;">
|
||||||
|
<select name="country" lay-search>
|
||||||
|
<option value="">全部</option>
|
||||||
|
@foreach ($countries as $code => $name)
|
||||||
|
<option value="{{ $code }}">{{ $name }} ({{ $code }})</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
<label class="layui-form-label">钱包</label>
|
<label class="layui-form-label">钱包</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
@@ -220,6 +231,7 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () {
|
|||||||
model: '',
|
model: '',
|
||||||
ip: '',
|
ip: '',
|
||||||
ios: '',
|
ios: '',
|
||||||
|
country: '',
|
||||||
has_wallet: '',
|
has_wallet: '',
|
||||||
has_im: '',
|
has_im: '',
|
||||||
installed_from: '',
|
installed_from: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user