Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-R7-Res
提交
25ac6660
提交
25ac6660
编写于
8月 06, 2020
作者:
tony001
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
单位、部门选择器无label字段
上级
b7bbbd1f
变更
3
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
164 行增加
和
19 行删除
+164
-19
app-department-select.vue
...omponents/app-department-select/app-department-select.vue
+74
-6
app-org-select.vue
src/components/app-org-select/app-org-select.vue
+79
-9
codelist-service.ts
src/service/app/codelist-service.ts
+11
-4
未找到文件。
src/components/app-department-select/app-department-select.vue
浏览文件 @
25ac6660
...
...
@@ -6,6 +6,7 @@
<
script
lang=
"ts"
>
import
{
Vue
,
Component
,
Watch
,
Prop
,
Model
}
from
'vue-property-decorator'
;
import
CodeListService
from
'@/service/app/codelist-service'
;
@
Component
({
})
export
default
class
AppDepartmentSelect
extends
Vue
{
...
...
@@ -18,6 +19,20 @@ export default class AppDepartmentSelect extends Vue {
*/
@
Prop
()
public
url
?:
any
;
/**
* 代码表标识
*
* @memberof AppDepartmentSelect
*/
@
Prop
()
public
tag
?:
string
;
/**
* 代码表类型
*
* @memberof AppDepartmentSelect
*/
@
Prop
()
public
codelistType
?:
string
;
/**
* 过滤项
*
...
...
@@ -121,14 +136,14 @@ export default class AppDepartmentSelect extends Vue {
}
this
.
oldurl
=
_url
;
// 缓存机制
const
result
:
any
=
this
.
$store
.
getters
.
getDepData
(
_url
);
const
result
:
any
=
this
.
$store
.
getters
.
getDepData
(
this
.
filter
);
if
(
result
){
this
.
Nodesdata
=
result
;
return
;
}
this
.
$http
.
get
(
_url
).
then
((
response
:
any
)
=>
{
this
.
Nodesdata
=
response
.
data
;
this
.
$store
.
commit
(
'addDepData'
,
{
srfkey
:
this
.
filter
,
org
Data
:
response
.
data
});
this
.
$store
.
commit
(
'addDepData'
,
{
srfkey
:
this
.
filter
,
dep
Data
:
response
.
data
});
}).
catch
((
response
:
any
)
=>
{
if
(
!
response
||
!
response
.
status
||
!
response
.
data
)
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.error'
)
as
string
),
desc
:
(
this
.
$t
(
'app.commonWords.sysException'
)
as
string
)
});
...
...
@@ -163,13 +178,19 @@ export default class AppDepartmentSelect extends Vue {
// 单选
if
(
!
this
.
multiple
){
if
(
this
.
fillMap
&&
Object
.
keys
(
this
.
fillMap
).
length
>
0
){
let
templateValue
=
{};
let
templateValue
:
any
=
{};
Object
.
keys
(
this
.
fillMap
).
forEach
((
item
:
any
)
=>
{
if
(
this
.
data
&&
this
.
data
[
this
.
fillMap
[
item
]]){
Object
.
assign
(
templateValue
,{[
item
]:
this
.
data
[
this
.
fillMap
[
item
]]});
}
})
this
.
selectTreeValue
=
JSON
.
stringify
([
templateValue
]);
if
(
!
templateValue
.
label
&&
templateValue
.
id
&&
this
.
tag
&&
this
.
codelistType
&&
Object
.
is
(
this
.
codelistType
,
"DYNAMIC"
)){
this
.
fillLabel
(
templateValue
,
templateValue
.
id
,(
templateValue
:
any
)
=>
{
this
.
selectTreeValue
=
JSON
.
stringify
([
templateValue
]);
});
}
else
{
this
.
selectTreeValue
=
JSON
.
stringify
([
templateValue
]);
}
}
}
else
{
// 多选
...
...
@@ -188,8 +209,30 @@ export default class AppDepartmentSelect extends Vue {
})
}
})
this
.
selectTreeValue
=
JSON
.
stringify
(
tempArray
);
let
tempflag
:
boolean
=
false
;
if
(
tempArray
.
length
>
0
&&
tempArray
.
length
>
0
){
tempArray
.
forEach
((
item
:
any
)
=>
{
if
(
!
item
.
label
)
tempflag
=
true
;
})
}
if
(
tempflag
&&
this
.
tag
&&
this
.
codelistType
&&
Object
.
is
(
this
.
codelistType
,
"DYNAMIC"
)){
let
tempStatus
:
number
=
0
;
tempArray
.
forEach
((
item
:
any
)
=>
{
if
(
!
item
.
label
){
tempStatus
+=
1
;
this
.
fillLabel
(
item
,
item
.
id
,(
result
:
any
)
=>
{
item
=
result
;
tempStatus
-=
1
;
if
(
tempStatus
===
0
){
this
.
selectTreeValue
=
JSON
.
stringify
(
tempArray
);
}
})
}
})
}
else
{
this
.
selectTreeValue
=
JSON
.
stringify
(
tempArray
);
}
}
}
}
...
...
@@ -208,10 +251,35 @@ export default class AppDepartmentSelect extends Vue {
let
_name
=
this
.
fillMap
[
attribute
];
let
values
=
selectArr
.
map
((
item
:
any
)
=>
item
[
attribute
]);
let
_value
=
$event
===
"[]"
?
null
:
values
.
join
(
","
);
this
.
$emit
(
'select-change'
,{
name
:
this
.
fillMap
[
attribute
],
value
:
_value
})
setTimeout
(()
=>
{
this
.
$emit
(
'select-change'
,{
name
:
this
.
fillMap
[
attribute
],
value
:
_value
});
},
0
);
});
}
}
/**
* 填充label
*
* @memberof AppOrgSelect
*/
public
fillLabel
(
tempObject
:
any
,
valueItem
:
any
,
callback
:
any
){
if
(
!
tempObject
.
label
&&
tempObject
.
id
&&
this
.
tag
&&
this
.
codelistType
&&
Object
.
is
(
this
.
codelistType
,
"DYNAMIC"
)){
let
codeListService
:
CodeListService
=
new
CodeListService
();
codeListService
.
getItems
(
this
.
tag
).
then
((
items
:
any
)
=>
{
if
(
items
&&
items
.
length
>
0
){
let
result
:
any
=
items
.
find
((
item
:
any
)
=>
{
return
item
.
id
===
valueItem
;
})
Object
.
assign
(
tempObject
,{
label
:
result
.
label
});
}
callback
(
tempObject
);
}).
catch
((
error
:
any
)
=>
{
console
.
log
(
error
);
})
}
}
}
</
script
>
...
...
src/components/app-org-select/app-org-select.vue
浏览文件 @
25ac6660
...
...
@@ -6,6 +6,8 @@
<
script
lang =
'ts'
>
import
{
Vue
,
Component
,
Prop
,
Watch
}
from
"vue-property-decorator"
;
import
{
Http
}
from
'@/utils'
;
import
CodeListService
from
"@service/app/codelist-service"
;
import
{
observable
}
from
'rxjs'
;
@
Component
({})
export
default
class
AppOrgSelect
extends
Vue
{
...
...
@@ -37,6 +39,20 @@ export default class AppOrgSelect extends Vue {
*/
@
Prop
()
public
filter
?:
string
;
/**
* 代码表标识
*
* @memberof AppOrgSelect
*/
@
Prop
()
public
tag
?:
string
;
/**
* 代码表类型
*
* @memberof AppOrgSelect
*/
@
Prop
()
public
codelistType
?:
string
;
/**
* 是否多选
*
...
...
@@ -138,13 +154,19 @@ export default class AppOrgSelect extends Vue {
// 单选
if
(
!
this
.
multiple
){
if
(
this
.
fillMap
&&
Object
.
keys
(
this
.
fillMap
).
length
>
0
){
let
templateValue
=
{};
Object
.
keys
(
this
.
fillMap
).
forEach
((
item
:
any
)
=>
{
if
(
this
.
data
&&
this
.
data
[
this
.
fillMap
[
item
]]){
Object
.
assign
(
templateValue
,{[
item
]:
this
.
data
[
this
.
fillMap
[
item
]]});
let
templateValue
:
any
=
{};
Object
.
keys
(
this
.
fillMap
).
forEach
((
item
:
any
)
=>
{
if
(
this
.
data
&&
this
.
data
[
this
.
fillMap
[
item
]]){
Object
.
assign
(
templateValue
,{[
item
]:
this
.
data
[
this
.
fillMap
[
item
]]});
}
})
if
(
!
templateValue
.
label
&&
templateValue
.
id
&&
this
.
tag
&&
this
.
codelistType
&&
Object
.
is
(
this
.
codelistType
,
"DYNAMIC"
)){
this
.
fillLabel
(
templateValue
,
templateValue
.
id
,(
templateValue
:
any
)
=>
{
this
.
selectTreeValue
=
JSON
.
stringify
([
templateValue
]);
});
}
else
{
this
.
selectTreeValue
=
JSON
.
stringify
([
templateValue
]);
}
})
this
.
selectTreeValue
=
JSON
.
stringify
([
templateValue
]);
}
}
else
{
// 多选
...
...
@@ -163,8 +185,30 @@ export default class AppOrgSelect extends Vue {
})
}
})
this
.
selectTreeValue
=
JSON
.
stringify
(
tempArray
);
let
tempflag
:
boolean
=
false
;
if
(
tempArray
.
length
>
0
&&
tempArray
.
length
>
0
){
tempArray
.
forEach
((
item
:
any
)
=>
{
if
(
!
item
.
label
)
tempflag
=
true
;
})
}
if
(
tempflag
&&
this
.
tag
&&
this
.
codelistType
&&
Object
.
is
(
this
.
codelistType
,
"DYNAMIC"
)){
let
tempStatus
:
number
=
0
;
tempArray
.
forEach
((
item
:
any
)
=>
{
if
(
!
item
.
label
){
tempStatus
+=
1
;
this
.
fillLabel
(
item
,
item
.
id
,(
result
:
any
)
=>
{
item
=
result
;
tempStatus
-=
1
;
if
(
tempStatus
===
0
){
this
.
selectTreeValue
=
JSON
.
stringify
(
tempArray
);
}
})
}
})
}
else
{
this
.
selectTreeValue
=
JSON
.
stringify
(
tempArray
);
}
}
}
}
...
...
@@ -209,7 +253,9 @@ export default class AppOrgSelect extends Vue {
tempValue
.
forEach
((
value
:
any
,
index
:
number
)
=>
{
tempResult
+=
index
>
0
?
`,
${
value
[
item
]}
`
:
`
${
value
[
item
]}
`
;
})
this
.
emitValue
(
this
.
fillMap
[
item
],
tempResult
);
setTimeout
(()
=>
{
this
.
emitValue
(
this
.
fillMap
[
item
],
tempResult
);
},
0
);
})
}
}
else
{
...
...
@@ -225,7 +271,9 @@ export default class AppOrgSelect extends Vue {
const
tempValue
:
any
=
JSON
.
parse
(
$event
)[
0
];
if
(
this
.
fillMap
&&
Object
.
keys
(
this
.
fillMap
).
length
>
0
){
Object
.
keys
(
this
.
fillMap
).
forEach
((
item
:
any
)
=>
{
this
.
emitValue
(
this
.
fillMap
[
item
],
tempValue
[
item
]);
setTimeout
(()
=>
{
this
.
emitValue
(
this
.
fillMap
[
item
],
tempValue
[
item
]);
},
0
);
})
}
}
else
{
...
...
@@ -247,6 +295,28 @@ export default class AppOrgSelect extends Vue {
this
.
$emit
(
'select-change'
,{
name
:
name
,
value
:
value
});
}
/**
* 填充label
*
* @memberof AppOrgSelect
*/
public
fillLabel
(
tempObject
:
any
,
valueItem
:
any
,
callback
:
any
){
if
(
!
tempObject
.
label
&&
tempObject
.
id
&&
this
.
tag
&&
this
.
codelistType
&&
Object
.
is
(
this
.
codelistType
,
"DYNAMIC"
)){
let
codeListService
:
CodeListService
=
new
CodeListService
();
codeListService
.
getItems
(
this
.
tag
).
then
((
items
:
any
)
=>
{
if
(
items
&&
items
.
length
>
0
){
let
result
:
any
=
items
.
find
((
item
:
any
)
=>
{
return
item
.
id
===
valueItem
;
})
Object
.
assign
(
tempObject
,{
label
:
result
.
label
});
}
callback
(
tempObject
);
}).
catch
((
error
:
any
)
=>
{
console
.
log
(
error
);
})
}
}
}
</
script
>
...
...
src/service/app/codelist-service.ts
浏览文件 @
25ac6660
...
...
@@ -100,10 +100,11 @@ export default class CodeListService {
if
(
items
.
length
>
0
)
resolve
(
items
);
}
const
callback
:
Function
=
(
tag
:
string
,
promise
:
Promise
<
any
>
)
=>
{
promise
.
then
((
result
:
any
)
=>
{
if
(
result
.
length
>
0
){
CodeListService
.
codelistCached
.
set
(
`
${
tag
}
`
,{
items
:
result
});
return
resolve
(
result
);
promise
.
then
((
res
:
any
)
=>
{
let
result
:
any
=
res
.
data
;
if
(
result
.
items
&&
result
.
items
.
length
>
0
){
CodeListService
.
codelistCached
.
set
(
`
${
tag
}
`
,{
items
:
result
.
items
});
return
resolve
(
result
.
items
);
}
else
{
return
resolve
([]);
}
...
...
@@ -137,6 +138,12 @@ export default class CodeListService {
}
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
this
.
getService
(
tag
).
then
((
codelist
:
any
)
=>
{
if
(
Object
.
is
(
codelist
.
predefinedType
,
"RUNTIME"
)){
this
.
getPredefinedItems
(
tag
).
then
((
res
:
any
)
=>
{
resolve
(
res
);
})
return
;
}
let
isEnableCache
:
boolean
=
codelist
.
isEnableCache
;
let
cacheTimeout
:
any
=
codelist
.
cacheTimeout
;
// 启用缓存
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录