Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-Mob-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-Mob-R7-Res
提交
f87a3318
提交
f87a3318
编写于
9月 22, 2020
作者:
zhujiamin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加搜索历史组件
上级
7109dc25
变更
3
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
242 行增加
和
0 行删除
+242
-0
app-register.ts
src/app-register.ts
+2
-0
app-search-history.less
src/components/app-search-history/app-search-history.less
+21
-0
app-search-history.vue
src/components/app-search-history/app-search-history.vue
+219
-0
未找到文件。
src/app-register.ts
浏览文件 @
f87a3318
...
@@ -117,5 +117,7 @@ export const AppComponents = {
...
@@ -117,5 +117,7 @@ export const AppComponents = {
v
.
component
(
'app-setting'
,()
=>
import
(
'@/components/app-setting/app-setting.vue'
));
v
.
component
(
'app-setting'
,()
=>
import
(
'@/components/app-setting/app-setting.vue'
));
// 风格切换组件
// 风格切换组件
v
.
component
(
'app-mob-select-changeStyle'
,()
=>
import
(
'@/components/app-mob-select-changeStyle/app-mob-select-changeStyle.vue'
));
v
.
component
(
'app-mob-select-changeStyle'
,()
=>
import
(
'@/components/app-mob-select-changeStyle/app-mob-select-changeStyle.vue'
));
// 搜索历史组件
v
.
component
(
'app-search-history'
,()
=>
import
(
'@/components/app-search-history/app-search-history.vue'
));
},
},
};
};
\ No newline at end of file
src/components/app-search-history/app-search-history.less
0 → 100644
浏览文件 @
f87a3318
.app-seach-history{
.history{
.hisText{
display: flex;
justify-content: space-between;
font-size: 14px;
color: #777777;
margin:2px 15px;
ion-icon{
padding-top: 3px;
}
}
.hisItems{
margin: 5px 15px;
.van-tag{
margin-right: 15px;
margin-top: 6px;
}
}
}
}
\ No newline at end of file
src/components/app-search-history/app-search-history.vue
0 → 100644
浏览文件 @
f87a3318
<
template
>
<div
class=
"app-seach-history"
>
<ion-toolbar>
<ion-searchbar
style=
"height: 36px; padding-bottom: 0px;"
:placeholder=
"$t('app.fastsearch')"
debounce=
"500"
@
ionChange=
"quickValueChange($event)"
show-cancel-button=
"focus"
:cancel-button-text=
"$t('app.button.cancel')"
@
ionFocus=
"showHistory"
@
ionBlur=
"hideHistory"
@
search=
"searchVal"
></ion-searchbar>
<ion-button
v-if=
"showfilter"
class=
"filter-btn"
size=
"small"
slot=
"end"
@
click=
"openSearchform"
><ion-icon
slot=
"end"
name=
"filter-outline"
></ion-icon>
过滤
</ion-button>
</ion-toolbar>
<div
class=
"history"
v-if=
"hasHistory"
>
<div
class=
"hisText"
><div>
最近搜索
</div>
<ion-icon
name=
"trash-bin-outline"
@
click=
"clearHistory"
></ion-icon></div>
<div
class=
"hisItems"
>
<van-tag
type=
"primary"
v-for=
"item in historyList"
:key=
"item.index"
round
size=
"medium"
color=
"#ededed"
text-color=
"#333"
>
{{
item
}}
</van-tag>
</div>
</div>
</div>
</
template
>
<
script
lang=
"ts"
>
import
{
Vue
,
Component
,
Prop
,
Provide
,
Emit
,
Watch
}
from
"vue-property-decorator"
;
@
Component
({
components
:
{}
})
export
default
class
AppRoundList
extends
Vue
{
/**
* 视图模型数据
*
* @type {any}
* @memberof AppSearchHistory
*/
@
Prop
()
public
model
:
any
;
/**
* 是否展示过滤按钮
*
* @type {boolean}
* @memberof AppSearchHistory
*/
@
Prop
()
public
showfilter
:
boolean
=
false
;
/**
* 快速搜索值变化
*
* @param {*} event
* @returns
* @memberof AppSearchHistory
*/
public
quickValueChange
(
$event
:
any
){
this
.
$emit
(
'quickValueChange'
,
$event
);
}
/**
* 打开搜索表单
*
* @memberof AppSearchHistory
*/
public
openSearchform
(){
this
.
$emit
(
'openSearchform'
);
}
/**
* 搜索历史数组
*
* @type {Array}
* @memberof AppSearchHistory
*/
public
historyList
:
Array
<
any
>
=
[];
/**
* 每一类搜索历史
*
* @type {Object}
* @memberof AppSearchHistory
*/
public
historyLists
:
any
=
{};
/**
* 分类缓存搜索历史
*
* @type {Array}
* @memberof AppSearchHistory
*/
public
historyStorage
:
Array
<
any
>
=
[];
/**
* 是否展开搜索历史
*
* @type {boolean}
* @memberof AppSearchHistory
*/
public
hasHistory
:
boolean
=
false
;
/**
* 是否有搜索历史功能
*
* @type {boolean}
* @memberof AppSearchHistory
*/
public
enableHistory
:
boolean
=
true
;
/**
* 生命周期
*
* @memberof AppSearchHistory
*/
public
mounted
(){
this
.
afterMounted
();
}
/**
* 执行mounted后的逻辑
*
* @memberof AppSearchHistory
*/
public
afterMounted
(){
let
storage
:
any
=
localStorage
.
getItem
(
'historyStorage'
);
if
(
storage
)
{
// 后续拿
let
historystorage
:
any
=
JSON
.
parse
(
storage
);
this
.
historyLists
=
historystorage
.
find
((
historyLists
:
any
)
=>
{
return
historyLists
.
viewname
==
this
.
model
.
viewname
;
})
if
(
this
.
historyLists
)
{
// 如果是缓存过的模型
this
.
historyList
=
this
.
historyLists
.
historyList
;
this
.
historyStorage
=
historystorage
;
}
else
{
// 如果是未缓存过的模型 = 第一次拿
this
.
historyLists
=
{
viewname
:
this
.
model
.
viewname
,
historyList
:[]};
this
.
historyList
=
this
.
historyLists
.
historyList
;
historystorage
.
push
(
this
.
historyLists
);
this
.
historyStorage
=
historystorage
;
}
}
else
{
// 第一次拿
this
.
historyLists
=
{
viewname
:
this
.
model
.
viewname
,
historyList
:[]};
this
.
historyList
=
this
.
historyLists
.
historyList
;
this
.
historyStorage
.
push
(
this
.
historyLists
);
}
}
/**
* 聚焦搜索框时
* @memberof AppSearchHistory
*/
public
showHistory
(){
if
(
this
.
enableHistory
)
{
if
(
(
Array
.
isArray
(
this
.
historyLists
.
historyList
))
&&
(
this
.
historyLists
.
historyList
.
length
<=
0
)
)
{
this
.
hasHistory
=
false
;
}
else
{
console
.
log
(
'333'
);
this
.
hasHistory
=
true
;
}
}
}
/**
* 失焦搜索框时
* @memberof AppSearchHistory
*/
public
hideHistory
(){
setTimeout
(()
=>
{
this
.
hasHistory
=
false
;
},
100
);
}
/**
* 触发搜索
* @memberof AppSearchHistory
*/
public
searchVal
(
$event
:
any
){
let
val
:
any
=
$event
.
target
.
value
;
val
=
val
.
trim
();
if
(
this
.
historyList
.
length
>
0
)
{
if
(
this
.
historyList
.
indexOf
(
val
)
!==
-
1
)
{
this
.
historyList
.
splice
(
this
.
historyList
.
indexOf
(
val
),
1
);
this
.
historyList
.
unshift
(
val
);
}
else
{
this
.
historyList
.
unshift
(
val
);
}
}
else
{
this
.
historyList
.
unshift
(
val
);
}
if
(
this
.
historyList
.
length
>
10
)
{
this
.
historyList
.
pop
();
}
if
(
this
.
enableHistory
)
{
localStorage
.
setItem
(
'historyStorage'
,
JSON
.
stringify
(
this
.
historyStorage
))
}
}
/**
* 清除搜索历史
*
* @type {boolean}
* @memberof AppSearchHistory
*/
public
async
clearHistory
(){
const
result
=
await
this
.
$notice
.
confirm
(
'提醒'
,
'是否清除搜索历史?'
,
this
.
$store
);
if
(
result
)
{
this
.
historyList
=
[];
this
.
historyLists
.
historyList
=
[];
this
.
historyStorage
.
splice
(
this
.
historyStorage
.
indexOf
(
this
.
historyLists
),
1
);
localStorage
.
setItem
(
'historyStorage'
,
JSON
.
stringify
(
this
.
historyStorage
))
return
true
;
}
else
{
return
false
;
}
}
};
</
script
>
<
style
lang =
"less"
>
@import "./app-search-history.less";
</
style
>
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录