Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-R7-Res
提交
9d7b89de
提交
9d7b89de
编写于
5月 23, 2020
作者:
WodahsOrez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lxm-- 部门选择组件--fix2
上级
23a6dffc
变更
4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
98 行增加
和
30 行删除
+98
-30
app-department-select.vue
...omponents/app-department-select/app-department-select.vue
+74
-29
getters.ts
src/store/getters.ts
+10
-0
mutations.ts
src/store/mutations.ts
+13
-1
state.ts
src/store/state.ts
+1
-0
未找到文件。
src/components/app-department-select/app-department-select.vue
浏览文件 @
9d7b89de
<
template
>
<div
class=
"app-department-select"
>
<ibiz-select-tree
:NodesData=
"Nodesdata"
:value=
"v
alue"
:multiple=
"multiple"
@
select=
"onSelect"
></ibiz-select-tree>
<ibiz-select-tree
:NodesData=
"Nodesdata"
v-model=
"selectTreeV
alue"
:multiple=
"multiple"
@
select=
"onSelect"
></ibiz-select-tree>
</div>
</
template
>
...
...
@@ -43,14 +43,6 @@ export default class AppDepartmentSelect extends Vue {
*/
@
Prop
({
default
:
false
})
public
multiple
?:
any
;
/**
* 表单项名称
*
* @type {*}
* @memberof AppDepartmentSelect
*/
@
Prop
()
public
name
!
:
any
;
/**
* 表单数据
*
...
...
@@ -60,20 +52,20 @@ export default class AppDepartmentSelect extends Vue {
@
Prop
()
public
data
!
:
any
;
/**
*
表单项值
*
上下文变量
*
* @type {*}
* @memberof AppDepartmentSelect
*/
@
Prop
()
public
value
!
:
any
;
@
Prop
()
public
context
!
:
any
;
/**
*
上下文变量
*
选中数值
*
* @type {*}
* @memberof AppDepartmentSelect
*/
@
Prop
()
public
context
!
:
any
;
public
selectTreeValue
:
any
=
""
;
/**
* 树节点数据
...
...
@@ -96,26 +88,41 @@ export default class AppDepartmentSelect extends Vue {
*
* @memberof AppDepartmentSelect
*/
public
searchNodesData
(){
// 处理请求参数
let
param
=
''
public
handleFilter
(){
if
(
this
.
filter
){
if
(
this
.
data
&&
this
.
data
[
this
.
filter
]){
param
=
this
.
data
[
this
.
filter
];
return
this
.
data
[
this
.
filter
];
}
else
if
(
this
.
context
&&
this
.
context
[
this
.
filter
]){
param
=
this
.
context
[
this
.
filter
];
return
this
.
context
[
this
.
filter
];
}
}
else
{
param
=
this
.
context
.
srforgid
;
return
this
.
context
.
srforgid
;
}
}
/**
* 获取节点数据
*
* @memberof AppDepartmentSelect
*/
public
searchNodesData
(){
// 处理过滤参数,生成url
let
param
=
this
.
handleFilter
();
let
_url
=
this
.
url
.
replace
(
/{orgid}/
,
param
)
if
(
this
.
oldurl
===
_url
){
return
;
}
this
.
oldurl
=
_url
;
// 缓存机制
const
result
:
any
=
this
.
$store
.
getters
.
getCopyData
(
_url
);
if
(
result
){
this
.
Nodesdata
=
result
;
return
;
}
this
.
$http
.
get
(
_url
).
then
((
response
:
any
)
=>
{
console
.
log
(
response
)
this
.
Nodesdata
=
response
.
data
;
this
.
oldurl
=
_url
;
this
.
$store
.
commit
(
'addDepData'
,
{
srfkey
:
this
.
filter
,
orgData
:
response
.
data
})
;
}).
catch
((
response
:
any
)
=>
{
if
(
!
response
||
!
response
.
status
||
!
response
.
data
)
{
this
.
$Notice
.
error
({
title
:
'错误'
,
desc
:
'系统异常!'
});
...
...
@@ -131,11 +138,55 @@ export default class AppDepartmentSelect extends Vue {
* @param {*} oldVal
* @memberof AppDepartmentSelect
*/
@
Watch
(
'data'
,{
deep
:
true
})
@
Watch
(
'data'
,{
immediate
:
true
,
deep
:
true
})
public
onValueChange
(
newVal
:
any
,
oldVal
:
any
)
{
this
.
searchNodesData
();
if
(
newVal
){
this
.
computedSelectedData
();
this
.
$nextTick
(()
=>
{
this
.
searchNodesData
();
});
}
}
/**
* 计算选中值
*
* @memberof AppOrgSelect
*/
public
computedSelectedData
(){
// 单选
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
]]});
}
})
this
.
selectTreeValue
=
JSON
.
stringify
([
templateValue
]);
}
}
else
{
// 多选
if
(
this
.
fillMap
&&
Object
.
keys
(
this
.
fillMap
).
length
>
0
){
let
tempArray
:
Array
<
any
>
=
[];
Object
.
keys
(
this
.
fillMap
).
forEach
((
item
:
any
)
=>
{
if
(
this
.
data
&&
this
.
data
[
this
.
fillMap
[
item
]]){
let
tempDataArray
:
Array
<
any
>
=
(
this
.
data
[
this
.
fillMap
[
item
]]).
split
(
","
);
tempDataArray
.
forEach
((
tempData
:
any
,
index
:
number
)
=>
{
if
(
tempArray
.
length
<
tempDataArray
.
length
){
let
singleData
:
any
=
{[
item
]:
tempData
};
tempArray
.
push
(
singleData
);
}
else
{
Object
.
assign
(
tempArray
[
index
],{[
item
]:
tempData
});
}
})
}
})
this
.
selectTreeValue
=
JSON
.
stringify
(
tempArray
);
}
}
}
/**
* select事件处理
*
...
...
@@ -145,18 +196,12 @@ export default class AppDepartmentSelect extends Vue {
public
onSelect
(
$event
:
any
){
// 组件自身抛值事件
let
selectArr
=
JSON
.
parse
(
$event
);
if
(
selectArr
.
length
===
0
){
this
.
$emit
(
'select-change'
,
{
name
:
this
.
name
,
value
:
$event
});
return
;
}
let
valueArr
=
selectArr
.
map
((
item
:
any
)
=>
{
return
{
id
:
item
.
id
,
label
:
item
.
label
}});
this
.
$emit
(
'select-change'
,
{
name
:
this
.
name
,
value
:
JSON
.
stringify
(
valueArr
)
});
// fillMap抛值事件
if
(
this
.
fillMap
&&
Object
.
keys
(
this
.
fillMap
).
length
>
0
){
Object
.
keys
(
this
.
fillMap
).
forEach
((
attribute
:
string
)
=>
{
let
_name
=
this
.
fillMap
[
attribute
];
let
_value
=
selectArr
.
map
((
item
:
any
)
=>
item
[
attribute
]);
this
.
$emit
(
'select-change'
,{
name
:
_name
,
value
:
_value
.
join
(
","
)})
this
.
$emit
(
'select-change'
,{
name
:
this
.
fillMap
[
attribute
]
,
value
:
_value
.
join
(
","
)})
});
}
...
...
src/store/getters.ts
浏览文件 @
9d7b89de
...
...
@@ -98,4 +98,14 @@ export const getCopyData = (state: any) => (srfkey: string) => {
export
const
getOrgData
=
(
state
:
any
)
=>
(
srfkey
:
string
)
=>
{
let
orgData
=
state
.
orgDataMap
[
srfkey
];
return
orgData
;
}
/**
* 获取部门数据
*
* @param state
*/
export
const
getDepData
=
(
state
:
any
)
=>
(
srfkey
:
string
)
=>
{
let
depData
=
state
.
depDataMap
[
srfkey
];
return
depData
;
}
\ No newline at end of file
src/store/mutations.ts
浏览文件 @
9d7b89de
...
...
@@ -277,4 +277,16 @@ export const addOrgData = (state: any, args: {srfkey: string,orgData: any}) => {
if
(
args
&&
args
.
srfkey
&&
args
.
orgData
){
state
.
orgDataMap
[
args
.
srfkey
]
=
JSON
.
parse
(
JSON
.
stringify
(
args
.
orgData
));
}
}
\ No newline at end of file
}
/**
* 添加部门数据
*
* @param state
* @param args
*/
export
const
addDepData
=
(
state
:
any
,
args
:
{
srfkey
:
string
,
depData
:
any
})
=>
{
if
(
args
&&
args
.
srfkey
&&
args
.
depData
){
state
.
depDataMap
[
args
.
srfkey
]
=
JSON
.
parse
(
JSON
.
stringify
(
args
.
depData
));
}
}
\ No newline at end of file
src/store/state.ts
浏览文件 @
9d7b89de
...
...
@@ -15,4 +15,5 @@ export const rootstate: any = {
viewSplit
:
{},
copyDataMap
:{},
orgDataMap
:{},
depDataMap
:{},
}
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录