Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-R7-Res
提交
abac0a97
提交
abac0a97
编写于
7月 09, 2020
作者:
JunZai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
3f5ef732
变更
2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
152 行增加
和
22 行删除
+152
-22
filter-mode.vue
src/components/filter-tree/filter-mode.vue
+65
-4
filter-tree.vue
src/components/filter-tree/filter-tree.vue
+87
-18
未找到文件。
src/components/filter-tree/filter-mode.vue
浏览文件 @
abac0a97
<
template
>
<el-select
size=
"small"
class=
"filter-mode"
:placeholder=
"$t('components.filterMode.placeholder')"
v-model=
"curVal"
@
change=
"onChange"
>
<el-option
v-for=
"mode in filterMode"
v-for=
"mode in fi
eldFi
lterMode"
:key=
"mode.value"
:label=
"getLabel(mode)"
:value=
"mode.value"
...
...
@@ -11,7 +11,7 @@
</
template
>
<
script
lang=
"ts"
>
import
{
Vue
,
Component
,
Model
}
from
"vue-property-decorator"
;
import
{
Vue
,
Component
,
Model
,
Prop
,
Watch
}
from
"vue-property-decorator"
;
@
Component
({})
export
default
class
FilterMode
extends
Vue
{
...
...
@@ -24,6 +24,19 @@ export default class FilterMode extends Vue {
*/
@
Model
(
'change'
)
readonly
value
:
any
;
/**
* 自定义逻辑集合
*
* @type {*}
* @memberof FilterMode
*/
@
Prop
()
modes
!
:
any
[];
@
Watch
(
'modes'
)
onModesChange
(
newVal
:
any
)
{
this
.
setDefValue
();
}
get
curVal
()
{
return
this
.
value
;
}
...
...
@@ -34,6 +47,21 @@ export default class FilterMode extends Vue {
this
.
$emit
(
'change'
,
val
);
}
get
fieldFilterMode
()
{
if
(
this
.
modes
&&
this
.
modes
.
length
>
0
)
{
let
index
:
number
=
this
.
modes
.
findIndex
((
mode
:
any
)
=>
Object
.
is
(
mode
.
mode
,
'all'
));
if
(
index
<
0
)
{
let
items
:
any
[]
=
[];
this
.
modes
.
forEach
((
mode
:
any
)
=>
{
let
item
:
any
=
this
.
filterMode
.
find
((
filter
:
any
)
=>
Object
.
is
(
filter
[
'en-US'
],
mode
.
mode
));
items
.
push
(
item
);
})
return
items
;
}
}
return
this
.
filterMode
;
}
/**
* 过滤模式
*
...
...
@@ -60,13 +88,37 @@ export default class FilterMode extends Vue {
// { 'zh-CN': '', en: 'NOTEXISTS', value: '$notExists' }
];
/**
* 生命周期
*
* @return {void}
* @memberof FilterMode
*/
public
mounted
()
{
this
.
setDefValue
()
}
/**
* 设置默认值
*
* @return {void}
* @memberof FilterMode
*/
public
setDefValue
()
{
if
(
this
.
fieldFilterMode
.
length
>
0
)
{
this
.
curVal
=
this
.
fieldFilterMode
[
0
].
value
;
this
.
onChange
();
}
}
/**
* 获取语言文本
*
* @return {string}
* @memberof FilterMode
*/
getLabel
(
mode
:
any
):
string
{
public
getLabel
(
mode
:
any
):
string
{
if
(
this
.
$i18n
.
locale
)
{
return
mode
[
this
.
$i18n
.
locale
];
}
...
...
@@ -79,7 +131,16 @@ export default class FilterMode extends Vue {
* @memberof FilterMode
*/
public
onChange
()
{
this
.
$emit
(
'mode-change'
,
this
.
value
);
this
.
$nextTick
(()
=>
{
let
item
:
any
=
this
.
filterMode
.
find
((
filter
:
any
)
=>
Object
.
is
(
filter
.
value
,
this
.
curVal
));
if
(
this
.
modes
&&
this
.
modes
.
length
>
0
)
{
let
mode
:
any
=
this
.
modes
.
find
((
mode
:
any
)
=>
Object
.
is
(
mode
.
mode
,
item
[
'en-US'
]));
if
(
!
mode
)
{
mode
=
this
.
modes
.
find
((
mode
:
any
)
=>
Object
.
is
(
mode
.
mode
,
'all'
));
}
this
.
$emit
(
'on-change'
,
mode
);
}
})
}
}
...
...
src/components/filter-tree/filter-tree.vue
浏览文件 @
abac0a97
...
...
@@ -15,17 +15,17 @@
</
template
>
<
template
v-else
>
<div
class=
"filter-tree-item"
>
<el-select
size=
"small"
class=
"filter-item-field"
v-model=
"data.field"
clearable
:placeholder=
"$t('components.filterTree.placeholder')"
@
change=
"onFieldChange(data)"
>
<el-select
size=
"small"
class=
"filter-item-field"
v-model=
"data.field"
clearable
:placeholder=
"$t('components.filterTree.placeholder')"
>
<el-option
v-for=
"item in fields"
:key=
"item.
prop
"
v-for=
"item in field
Item
s"
:key=
"item.
value
"
:label=
"item.label"
:value=
"item.
nam
e"
>
:value=
"item.
valu
e"
>
</el-option>
</el-select>
<filter-mode
class=
"filter-item-mode"
v-model=
"data.mode"
></filter-mode>
<filter-mode
class=
"filter-item-mode"
v-model=
"data.mode"
:modes=
"getModes(data.field)"
@
on-change=
"onModeChange($event, data)"
></filter-mode>
<div
class=
"filter-item-value"
>
<i-input
v-if=
"!data.
field
"
></i-input>
<i-input
v-if=
"!data.
editor
"
></i-input>
<slot
v-else
:data=
"data"
></slot>
</div>
<div
class=
"filter-tree-action"
>
...
...
@@ -64,6 +64,14 @@ export default class FilterTree extends Vue {
*/
@
Prop
()
fields
:
any
;
/**
* 属性项集合
*
* @type {*}
* @memberof FilterTree
*/
protected
fieldItems
:
any
[]
=
[];
/**
* 组条件集合
*
...
...
@@ -93,29 +101,77 @@ export default class FilterTree extends Vue {
return
[
root
];
}
/**
*
获取语言文本
*
生命周期
*
* @return {
string
}
* @return {
void
}
* @memberof FilterTree
*/
getLabel
(
mode
:
any
):
string
{
if
(
this
.
$i18n
.
locale
)
{
return
mode
[
this
.
$i18n
.
locale
]
;
public
created
()
{
if
(
!
this
.
fields
)
{
return
;
}
return
mode
[
'zh-CN'
];
this
.
fields
.
forEach
((
field
:
any
)
=>
{
let
index
:
number
=
this
.
fieldItems
.
findIndex
((
item
:
any
)
=>
Object
.
is
(
item
.
value
,
field
.
prop
));
if
(
index
<
0
)
{
this
.
fieldItems
.
push
({
label
:
field
.
label
,
value
:
field
.
prop
,
modes
:
this
.
getFieldModes
(
field
.
prop
)
})
}
});
}
/**
*
属性变化
*
获取逻辑模式集合
*
* @return {*}
* @return {void}
* @memberof FilterTree
*/
public
getModes
(
field
:
string
)
{
if
(
this
.
fieldItems
.
length
>
0
)
{
let
item
:
any
=
this
.
fieldItems
.
find
((
item
:
any
)
=>
Object
.
is
(
item
.
value
,
field
));
if
(
item
)
{
return
item
.
modes
;
}
}
return
[];
}
/**
* 获取属性逻辑模式集合
*
* @return {void}
* @memberof FilterTree
*/
public
onFieldChange
(
data
:
any
)
{
if
(
!
data
.
mode
)
{
data
.
mode
=
'$eq'
;
public
getFieldModes
(
name
:
string
)
{
let
modes
:
any
[]
=
[];
for
(
let
i
=
0
;
i
<
this
.
fields
.
length
;
i
++
)
{
let
field
:
any
=
this
.
fields
[
i
];
if
(
!
Object
.
is
(
field
.
prop
,
name
))
{
continue
;
}
modes
.
push
({
name
:
field
.
name
,
mode
:
field
.
mode
?
field
.
mode
:
'all'
})
}
return
modes
;
}
/**
* 获取语言文本
*
* @return {string}
* @memberof FilterTree
*/
getLabel
(
mode
:
any
):
string
{
if
(
this
.
$i18n
.
locale
)
{
return
mode
[
this
.
$i18n
.
locale
];
}
return
mode
[
'zh-CN'
];
}
/**
...
...
@@ -128,7 +184,8 @@ export default class FilterTree extends Vue {
if
(
data
&&
data
.
children
)
{
data
.
children
.
push
({
field
:
null
,
mode
:
null
mode
:
null
,
editor
:
null
});
}
}
...
...
@@ -162,6 +219,18 @@ export default class FilterTree extends Vue {
}
}
}
/**
* 条件逻辑变化
*
* @return {*}
* @memberof FilterTree
*/
public
onModeChange
(
mode
:
any
,
data
:
any
)
{
if
(
mode
&&
data
)
{
data
.
editor
=
mode
.
name
;
}
}
}
</
script
>
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录