refactor: 附件/视频搜索

This commit is contained in:
2025-04-16 13:39:19 +08:00
parent 721904f7e3
commit bc5022b2d6
9 changed files with 56 additions and 22 deletions

View File

@@ -21,6 +21,7 @@ class Attachment extends Common
{ {
$param = request()->param([ $param = request()->param([
'id', 'id',
'keyword',
'page/d' => 1, 'page/d' => 1,
'size/d' => 12, 'size/d' => 12,
]); ]);
@@ -47,6 +48,7 @@ class Attachment extends Common
'support_platform', 'support_platform',
'attach', 'attach',
]) ])
->withSearch(['name'], ['name' => $param['keyword']??null])
->language($this->lang_id) ->language($this->lang_id)
->category($param['id']??null) ->category($param['id']??null)
->order(['sort' => 'asc', 'id' => 'desc']) ->order(['sort' => 'asc', 'id' => 'desc'])
@@ -70,6 +72,7 @@ class Attachment extends Common
{ {
$param = request()->param([ $param = request()->param([
'id', 'id',
'keyword',
'page/d' => 1, 'page/d' => 1,
'size/d' => 12 'size/d' => 12
]); ]);
@@ -106,6 +109,7 @@ class Attachment extends Common
'video', 'video',
'link' 'link'
]) ])
->withSearch(['name'], ['name' => $param['keyword']??null])
->language($this->lang_id) ->language($this->lang_id)
->category($param['id']??null) ->category($param['id']??null)
->order(['sort' => 'asc', 'id' => 'desc']) ->order(['sort' => 'asc', 'id' => 'desc'])

View File

@@ -37,5 +37,6 @@ return [
'video' => 'Videos', 'video' => 'Videos',
'support_model' => 'Supported Models', 'support_model' => 'Supported Models',
'support_platform' => 'Supported Systems', 'support_platform' => 'Supported Systems',
'search_placeholder' => 'Search model',
] ]
]; ];

View File

@@ -37,5 +37,6 @@ return [
'video' => '视频', 'video' => '视频',
'support_model' => '支持型号', 'support_model' => '支持型号',
'support_platform' => '支持系统', 'support_platform' => '支持系统',
'search_placeholder' => '搜索型号',
] ]
]; ];

View File

@@ -22,6 +22,15 @@ class AttachmentModel extends AttachmentBaseModel
// 设置JSON数据返回数组 // 设置JSON数据返回数组
protected $jsonAssoc = true; protected $jsonAssoc = true;
// 附件名称搜索器
public function searchNameAttr($query, $value, $data)
{
if (is_null($value)) {
return;
}
$query->where('name', 'like', "%{$value}%");
}
// 所属语言范围查询 // 所属语言范围查询
public function scopeLanguage($query, $language) public function scopeLanguage($query, $language)
{ {

View File

@@ -18,6 +18,15 @@ class VideoModel extends VideoBaseModel
// 软删除字段 // 软删除字段
protected $deleteTime = 'deleted_at'; protected $deleteTime = 'deleted_at';
// 视频名称搜索器
public function searchNameAttr($query, $value, $data)
{
if (is_null($value)) {
return;
}
$query->where('name', 'like', "%{$value}%");
}
// 所属语言范围查询 // 所属语言范围查询
public function scopeLanguage($query, $language) public function scopeLanguage($query, $language)
{ {

View File

@@ -12,12 +12,13 @@
</div> </div>
<div class="contact_c"> <div class="contact_c">
<!-- 搜索 --> <!-- 搜索 -->
<form action="{:url('attachment/index')}" method="get">
<div class="search_all"> <div class="search_all">
<input type="text" name="textfield" placeholder="Search model" id="search_software"> <input type="hidden" name="id" value="{$Request.get.id}" />
<div class="searchbtn" id="search-btn"> <input type="text" name="keyword" placeholder="{:lang('attachment.search_placeholder')}" />
<img src="downloadImg/search.png" /> <button class="searchbtn" type="submit"><img src="__IMAGES__/search_blue.png" /></button>
</div>
</div> </div>
</form>
<!-- tab切换 --> <!-- tab切换 -->
<div class="tab"> <div class="tab">
{notempty name="categorys"} {notempty name="categorys"}
@@ -36,8 +37,8 @@
<a href="{:url('attachment/video')}"><div class="tabit">{:lang('attachment.video')}</div></a> <a href="{:url('attachment/video')}"><div class="tabit">{:lang('attachment.video')}</div></a>
</div> </div>
<!-- 切换的内容 --> <!-- 切换的内容 -->
{notempty name="attachements"}
<div class="softlist"> <div class="softlist">
{notempty name="attachements"}
{volist name="attachements" id="att"} {volist name="attachements" id="att"}
<div class="softit"> <div class="softit">
<div class="left_img"> <div class="left_img">
@@ -62,9 +63,11 @@
</div> </div>
{/volist} {/volist}
<div>{$page|raw}</div> <div>{$page|raw}</div>
</div> {else/}
<div class="softit">查询无结果!</div>
{/notempty} {/notempty}
</div> </div>
</div> </div>
</div> </div>
</div>
{/block} {/block}

View File

@@ -12,12 +12,12 @@
</div> </div>
<div class="contact_c"> <div class="contact_c">
<!-- 搜索 --> <!-- 搜索 -->
<form action="{:url('attachment/video')}" method="get">
<div class="search_all"> <div class="search_all">
<input type="text" name="textfield" placeholder="Search model" id="search_software"> <input type="text" name="keyword" placeholder="{:lang('attachment.search_placeholder')}" />
<div class="searchbtn" id="search-btn"> <button class="searchbtn" type="submit"><img src="__IMAGES__/search_blue.png" /></button>
<img src="downloadImg/search.png" />
</div>
</div> </div>
</form>
<!-- tab切换 --> <!-- tab切换 -->
<div class="tab"> <div class="tab">
{notempty name="attachment_categorys"} {notempty name="attachment_categorys"}
@@ -45,9 +45,9 @@
</div> </div>
{/notempty} {/notempty}
<!-- 视频内容 --> <!-- 视频内容 -->
{notempty name="videos"}
<div class="bdconten"> <div class="bdconten">
<ul > <ul >
{notempty name="videos"}
<dl class="video_hotul"> <dl class="video_hotul">
{volist name="videos" id="vo"} {volist name="videos" id="vo"}
<dd> <dd>
@@ -65,9 +65,11 @@
<div class="clear"></div> <div class="clear"></div>
</dl> </dl>
<div>{$page|raw}</div> <div>{$page|raw}</div>
{else/}
<dl class="video-empty">查询无结果!</dl>
{/notempty}
</ul> </ul>
</div> </div>
{/notempty}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -65,6 +65,8 @@
top: 50%; top: 50%;
margin-top: -0.75rem; margin-top: -0.75rem;
right: 6rem; right: 6rem;
border: 0;
background-color: transparent;
} }
.orico_Page_download .downloadMain .contact_c .search_all .searchbtn img { .orico_Page_download .downloadMain .contact_c .search_all .searchbtn img {
width: 100%; width: 100%;
@@ -259,3 +261,6 @@
margin-top: 16px; margin-top: 16px;
line-height: 20px; line-height: 20px;
} }
.orico_Page_download .downloadMain .contact_c .video-empty {
padding-bottom: 3rem;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B