Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-R7-Res
提交
e23de87c
提交
e23de87c
编写于
8月 05, 2020
作者:
tony001
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
支持树状代码表
上级
2845dcce
变更
4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
234 行增加
和
24 行删除
+234
-24
dropdown-list-mpicker.less
...mponents/dropdown-list-mpicker/dropdown-list-mpicker.less
+12
-1
dropdown-list-mpicker.vue
...omponents/dropdown-list-mpicker/dropdown-list-mpicker.vue
+121
-17
dropdown-list.less
src/components/dropdown-list/dropdown-list.less
+15
-4
dropdown-list.vue
src/components/dropdown-list/dropdown-list.vue
+86
-2
未找到文件。
src/components/dropdown-list-mpicker/dropdown-list-mpicker.less
浏览文件 @
e23de87c
.ivu-select-multiple .ivu-select-item-selected:after{
display: none;
}
.dropdown-list-mpicker-container{
.tree-dropdown-list-mpicker{
width: 100%;
.el-input__inner{
height: 32px !important;
line-height: 32px !important;
}
.el-input__icon{
line-height: 32px;
}
}
}
src/components/dropdown-list-mpicker/dropdown-list-mpicker.vue
浏览文件 @
e23de87c
<
template
>
<i-select
class=
'dropdown-list-mpicker'
multiple
:transfer=
"true"
transfer-class-name=
"dropdown-list-mpicker-transfer"
v-model=
"currentVal"
:disabled=
"disabled === true ? true : false"
:clearable=
"true"
:filterable=
"filterable === true ? true : false"
@
on-open-change=
"onClick"
:placeholder=
"$t('components.dropDownListMpicker.placeholder')"
>
<i-option
v-for=
"(item, index) in items"
:key=
"index"
:value=
"item.value.toString()"
:label=
"item.text"
>
<Checkbox
:value =
"(currentVal.indexOf(item.value.toString()))==-1?false:true"
>
{{
Object
.
is
(
codelistType
,
'STATIC'
)
?
$t
(
'codelist.'
+
tag
+
'.'
+
item
.
value
)
:
item
.
text
}}
</Checkbox>
</i-option>
</i-select>
<div
class=
"dropdown-list-mpicker-container"
>
<i-select
v-if=
"!hasChildren"
class=
'dropdown-list-mpicker'
multiple
:transfer=
"true"
transfer-class-name=
"dropdown-list-mpicker-transfer"
v-model=
"currentVal"
:disabled=
"disabled === true ? true : false"
:clearable=
"true"
:filterable=
"filterable === true ? true : false"
@
on-open-change=
"onClick"
:placeholder=
"$t('components.dropDownListMpicker.placeholder')"
>
<i-option
v-for=
"(item, index) in items"
:key=
"index"
:value=
"item.value.toString()"
:label=
"item.text"
>
<Checkbox
:value =
"(currentVal.indexOf(item.value.toString()))==-1?false:true"
>
{{
Object
.
is
(
codelistType
,
'STATIC'
)
?
$t
(
'codelist.'
+
tag
+
'.'
+
item
.
value
)
:
item
.
text
}}
</Checkbox>
</i-option>
</i-select>
<ibiz-select-tree
v-if=
"hasChildren"
class=
"tree-dropdown-list-mpicker"
:disabled=
"disabled"
:NodesData=
"items"
v-model=
"currentVal"
:multiple=
"true"
></ibiz-select-tree>
</div>
</
template
>
<
script
lang=
"ts"
>
import
{
Vue
,
Component
,
Prop
,
Model
}
from
'vue-property-decorator'
;
import
CodeListService
from
"@service/app/codelist-service"
;
import
{
Util
}
from
'@/utils'
;
@
Component
({
})
export
default
class
DropDownListMpicker
extends
Vue
{
...
...
@@ -32,6 +37,13 @@ export default class DropDownListMpicker extends Vue {
*/
public
codeListService
:
CodeListService
=
new
CodeListService
({
$store
:
this
.
$store
});
/**
* 是否有子集
* @type {boolean}
* @memberof DropDownListMpicker
*/
public
hasChildren
:
boolean
=
false
;
/**
* 当前选中值
* @type {any}
...
...
@@ -131,6 +143,14 @@ export default class DropDownListMpicker extends Vue {
* @memberof DropDownListMpicker
*/
set
currentVal
(
val
:
any
)
{
if
(
this
.
hasChildren
&&
val
){
let
tempVal
:
any
=
JSON
.
parse
(
val
);
if
(
tempVal
.
length
>
0
){
val
=
tempVal
.
map
((
item
:
any
)
=>
{
return
item
.
value
;
})
}
}
const
type
:
string
=
this
.
$util
.
typeOf
(
val
);
val
=
Object
.
is
(
type
,
'null'
)
||
Object
.
is
(
type
,
'undefined'
)
?
[]
:
val
;
let
value
=
val
.
length
>
0
?
val
.
join
(
this
.
valueSeparator
)
:
''
;
...
...
@@ -143,9 +163,45 @@ export default class DropDownListMpicker extends Vue {
* @memberof DropDownListMpicker
*/
get
currentVal
()
{
if
(
this
.
hasChildren
){
if
(
this
.
itemValue
){
let
list
:
Array
<
any
>
=
[];
let
selectedvalueArray
:
Array
<
any
>
=
[];
let
curSelectedValue
:
Array
<
any
>
=
this
.
itemValue
.
split
(
this
.
valueSeparator
);
this
.
getItemList
(
list
,
this
.
items
);
if
(
curSelectedValue
.
length
>
0
){
curSelectedValue
.
forEach
((
selectedVal
:
any
)
=>
{
let
tempResult
:
any
=
list
.
find
((
item
:
any
)
=>
{
return
item
.
value
==
selectedVal
;
})
selectedvalueArray
.
push
(
tempResult
);
})
}
return
selectedvalueArray
.
length
>
0
?
JSON
.
stringify
(
selectedvalueArray
):
null
;
}
else
{
return
null
;
}
}
return
this
.
itemValue
?
this
.
itemValue
.
split
(
this
.
valueSeparator
):[];
}
/**
* 获取代码表列表
*
* @memberof DropDownListMpicker
*/
public
getItemList
(
list
:
Array
<
any
>
,
items
:
Array
<
any
>
){
if
(
items
&&
items
.
length
>
0
){
items
.
forEach
((
item
:
any
)
=>
{
if
(
item
.
children
){
this
.
getItemList
(
list
,
item
.
children
);
}
list
.
push
(
item
);
})
}
}
/**
* 代码表
*
...
...
@@ -186,6 +242,7 @@ export default class DropDownListMpicker extends Vue {
const
codelist
=
this
.
$store
.
getters
.
getCodeList
(
this
.
tag
);
if
(
codelist
)
{
this
.
items
=
[...
JSON
.
parse
(
JSON
.
stringify
(
codelist
.
items
))];
this
.
handleLevelCodeList
(
Util
.
deepCopy
(
this
.
items
));
}
else
{
console
.
log
(
`----
${
this
.
tag
}
----
${(
this
.
$t
(
'app.commonWords.codeNotExist'
)
as
string
)}
`
);
}
...
...
@@ -198,6 +255,7 @@ export default class DropDownListMpicker extends Vue {
let
_param
=
data
.
param
;
this
.
codeListService
.
getItems
(
this
.
tag
,
_context
,
_param
).
then
((
res
:
any
)
=>
{
this
.
items
=
res
;
this
.
handleLevelCodeList
(
Util
.
deepCopy
(
this
.
items
));
}).
catch
((
error
:
any
)
=>
{
console
.
log
(
`----
${
this
.
tag
}
----
${(
this
.
$t
(
'app.commonWords.codeNotExist'
)
as
string
)}
`
);
});
...
...
@@ -220,11 +278,57 @@ export default class DropDownListMpicker extends Vue {
let
_param
=
data
.
param
;
this
.
codeListService
.
getItems
(
this
.
tag
,
_context
,
_param
).
then
((
res
:
any
)
=>
{
this
.
items
=
res
;
this
.
handleLevelCodeList
(
Util
.
deepCopy
(
this
.
items
));
}).
catch
((
error
:
any
)
=>
{
console
.
log
(
`----
${
this
.
tag
}
----
${(
this
.
$t
(
'app.commonWords.codeNotExist'
)
as
string
)}
`
);
});
}
}
/**
* 处理层级代码表
*
* @param {*} items
* @memberof DropDownListMpicker
*/
public
handleLevelCodeList
(
items
:
Array
<
any
>
){
if
(
items
&&
items
.
length
>
0
){
this
.
hasChildren
=
items
.
some
((
item
:
any
)
=>
{
return
item
.
pvalue
;
})
if
(
this
.
hasChildren
){
let
list
:
Array
<
any
>
=
[];
items
.
forEach
((
codeItem
:
any
)
=>
{
if
(
!
codeItem
.
pvalue
){
let
valueField
:
string
=
codeItem
.
value
;
this
.
setChildCodeItems
(
valueField
,
items
,
codeItem
);
list
.
push
(
codeItem
);
}
})
this
.
items
=
list
;
}
}
}
/**
* 计算子类代码表
*
* @param {*} items
* @memberof DropDownListMpicker
*/
public
setChildCodeItems
(
pValue
:
string
,
result
:
Array
<
any
>
,
codeItem
:
any
){
result
.
forEach
((
item
:
any
)
=>
{
if
(
item
.
pvalue
==
pValue
){
let
valueField
:
string
=
item
.
value
;
this
.
setChildCodeItems
(
valueField
,
result
,
item
);
if
(
!
codeItem
.
children
){
codeItem
.
children
=
[];
}
codeItem
.
children
.
push
(
item
);
}
})
}
}
</
script
>
...
...
src/components/dropdown-list/dropdown-list.less
浏览文件 @
e23de87c
.dropdown-list{
display: inline-block;
}
.dropdown-list-container{
.dropdown-list{
display: inline-block;
}
.tree-dropdown-list{
width: 100%;
.el-input__inner{
height: 32px !important;
line-height: 32px !important;
}
.el-input__icon{
line-height: 32px;
}
}
}
\ No newline at end of file
src/components/dropdown-list/dropdown-list.vue
浏览文件 @
e23de87c
<
template
>
<i-select
<div
class=
"dropdown-list-container"
>
<i-select
v-if=
"!hasChildren"
class=
'dropdown-list'
:transfer=
"true"
v-model=
"currentVal"
...
...
@@ -9,12 +10,15 @@
@
on-open-change=
"onClick"
:placeholder=
"$t('components.dropDownList.placeholder')"
>
<i-option
v-for=
"(item, index) in items"
:key=
"index"
:value=
"item.value"
>
{{
(
$t
(
'codelist.'
+
tag
+
'.'
+
item
.
value
)
!==
(
'codelist.'
+
tag
+
'.'
+
item
.
value
))?
$t
(
'codelist.'
+
tag
+
'.'
+
item
.
value
)
:
item
.
text
}}
</i-option>
</i-select>
</i-select>
<ibiz-select-tree
v-if=
"hasChildren"
class=
"tree-dropdown-list"
:disabled=
"disabled"
:NodesData=
"items"
v-model=
"currentVal"
:multiple=
"false"
></ibiz-select-tree>
</div>
</
template
>
<
script
lang=
"ts"
>
import
{
Vue
,
Component
,
Watch
,
Prop
,
Model
}
from
'vue-property-decorator'
;
import
CodeListService
from
"@service/app/codelist-service"
;
import
{
Util
}
from
'@/utils'
;
@
Component
({
})
...
...
@@ -42,6 +46,13 @@ export default class DropDownList extends Vue {
*/
public
queryParam
:
any
;
/**
* 是否有子集
* @type {boolean}
* @memberof DropDownList
*/
public
hasChildren
:
boolean
=
false
;
/**
* 当前选中值
* @type {any}
...
...
@@ -152,6 +163,10 @@ export default class DropDownList extends Vue {
* @memberof DropDownList
*/
set
currentVal
(
val
:
any
)
{
if
(
this
.
hasChildren
&&
val
){
let
tempVal
:
any
=
JSON
.
parse
(
val
);
val
=
tempVal
.
length
>
0
?
tempVal
[
0
].
value
:
null
;
}
const
type
:
string
=
this
.
$util
.
typeOf
(
val
);
val
=
Object
.
is
(
type
,
'null'
)
||
Object
.
is
(
type
,
'undefined'
)
?
undefined
:
val
;
this
.
$emit
(
'change'
,
val
);
...
...
@@ -163,9 +178,33 @@ export default class DropDownList extends Vue {
* @memberof DropDownList
*/
get
currentVal
()
{
if
(
this
.
hasChildren
&&
this
.
itemValue
){
let
list
:
Array
<
any
>
=
[];
this
.
getItemList
(
list
,
this
.
items
);
let
result
:
any
=
list
.
find
((
item
:
any
)
=>
{
return
item
.
value
==
this
.
itemValue
;
})
return
JSON
.
stringify
([
result
]);
}
return
this
.
itemValue
;
}
/**
* 获取代码表列表
*
* @memberof DropDownList
*/
public
getItemList
(
list
:
Array
<
any
>
,
items
:
Array
<
any
>
){
if
(
items
&&
items
.
length
>
0
){
items
.
forEach
((
item
:
any
)
=>
{
if
(
item
.
children
){
this
.
getItemList
(
list
,
item
.
children
);
}
list
.
push
(
item
);
})
}
}
/**
* 代码表
*
...
...
@@ -287,6 +326,51 @@ export default class DropDownList extends Vue {
}
catch
(
error
){
console
.
warn
(
'代码表值类型和属性类型不匹配,自动强制转换异常,请修正代码表值类型和属性类型匹配'
);
}
this
.
handleLevelCodeList
(
Util
.
deepCopy
(
this
.
items
));
}
/**
* 处理层级代码表
*
* @param {*} items
* @memberof DropDownList
*/
public
handleLevelCodeList
(
items
:
Array
<
any
>
){
if
(
items
&&
items
.
length
>
0
){
this
.
hasChildren
=
items
.
some
((
item
:
any
)
=>
{
return
item
.
pvalue
;
})
if
(
this
.
hasChildren
){
let
list
:
Array
<
any
>
=
[];
items
.
forEach
((
codeItem
:
any
)
=>
{
if
(
!
codeItem
.
pvalue
){
let
valueField
:
string
=
codeItem
.
value
;
this
.
setChildCodeItems
(
valueField
,
items
,
codeItem
);
list
.
push
(
codeItem
);
}
})
this
.
items
=
list
;
}
}
}
/**
* 计算子类代码表
*
* @param {*} items
* @memberof DropDownList
*/
public
setChildCodeItems
(
pValue
:
string
,
result
:
Array
<
any
>
,
codeItem
:
any
){
result
.
forEach
((
item
:
any
)
=>
{
if
(
item
.
pvalue
==
pValue
){
let
valueField
:
string
=
item
.
value
;
this
.
setChildCodeItems
(
valueField
,
result
,
item
);
if
(
!
codeItem
.
children
){
codeItem
.
children
=
[];
}
codeItem
.
children
.
push
(
item
);
}
})
}
}
</
script
>
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录