Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
a1b27ced
提交
a1b27ced
编写于
12月 31, 2021
作者:
Shine-zwj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update:更新表格
上级
a9af16e2
变更
2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
231 行增加
和
60 行删除
+231
-60
grid-control.ts
...rc/ibiz-core/modules/widgets/grid-control/grid-control.ts
+179
-30
grid-service.ts
...s}}/src/ibiz-core/service/control-service/grid-service.ts
+52
-30
未找到文件。
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/ibiz-core/modules/widgets/grid-control/grid-control.ts
浏览文件 @
a1b27ced
...
...
@@ -349,16 +349,16 @@ export class GridControl extends MainControl {
const
{
viewSubject
,
controlName
}
=
this
.
controlState
;
const
load
=
async
(
opt
:
any
=
{})
=>
{
try
{
const
loadAction
=
this
.
controlState
.
controlAction
.
loadAction
;
const
{
controlService
,
context
,
viewParams
,
showBusyIndicator
,
noSort
,
minorSortDir
,
minorSortPSDEF
,
enablePagingBar
enablePagingBar
,
controlAction
}
=
this
.
controlState
;
const
dataRef
=
toRef
(
this
.
controlState
,
"items"
);
const
paginationRef
=
toRef
(
this
.
controlState
,
"pagination"
);
// if(!loadAction){
// return;
// }
if
(
!
controlAction
.
loadAction
){
return
;
}
const
arg
:
any
=
{
...
opt
};
let
_context
=
deepCopy
(
context
?
context
:
{});
let
_viewParams
=
deepCopy
(
viewParams
?
context
:
{});
if
(
noSort
&&
minorSortDir
&&
minorSortPSDEF
)
{
...
...
@@ -369,32 +369,22 @@ export class GridControl extends MainControl {
const
pageSizeRef
=
toRef
(
this
.
controlState
,
"pageSize"
);
Object
.
assign
(
_viewParams
,
{
page
:
currentRef
.
value
-
1
,
size
:
pageSizeRef
.
value
});
}
// const response = await controlService.get(loadAction, _context, {viewParams: _viewParams}, showBusyIndicator );
// if (!response.status || response.status !== 200) {
// return
// }
const
data
=
[];
for
(
let
i
=
0
;
i
<
40
;
i
++
)
{
data
.
push
({
group
:
i
%
2
===
1
?
"分组1"
:
"分组2"
,
srfkey
:
i
,
tefsubjecttypename
:
`Edrward
${
i
}
`
,
nian
:
i
,
testdata
:
i
,
updatedate
:
32
,
description
:
`London Park no.
${
i
}
`
,
});
}
dataRef
.
value
=
data
;
// dataRef.value = response.data;
if
(
enablePagingBar
)
{
// paginationRef.value['total'] = response.total;
paginationRef
.
value
[
"total"
]
=
40
;
Object
.
assign
(
arg
,
{
viewParams
:
_viewParams
});
const
response
=
await
controlService
.
get
(
_context
,
arg
,
{
action
:
controlAction
.
loadAction
,
isLoading
:
showBusyIndicator
}
);
if
(
response
.
status
||
response
.
status
==
200
)
{
dataRef
.
value
=
response
.
data
;
if
(
enablePagingBar
)
{
paginationRef
.
value
[
'total'
]
=
response
.
total
;
}
this
.
calcGridAuthState
();
this
.
handleDefaultSelect
();
this
.
handleGridGroup
();
this
.
handleDataAgg
();
}
this
.
calcGridAuthState
();
this
.
handleDefaultSelect
();
this
.
handleGridGroup
();
this
.
handleDataAgg
();
}
catch
(
error
)
{
// todo 错误异常处理
console
.
error
(
error
)
...
...
@@ -419,6 +409,165 @@ export class GridControl extends MainControl {
}
}
/**
* @description 使用保存功能模块
* @param {GridControlProps} props 传入的props
* @return {*}
* @memberof GridControl
*/
public
useSave
(
props
:
GridControlProps
)
{
const
{
viewSubject
,
controlName
}
=
this
.
controlState
;
const
save
=
async
(
opt
:
any
=
{})
=>
{
try
{
const
{
controlService
,
context
,
viewParams
,
showBusyIndicator
,
items
,
controlAction
}
=
this
.
controlState
;
// TODO 值规则校验处理
for
(
const
item
of
items
)
{
const
{
updateAction
,
createAction
}
=
controlAction
;
const
saveAction
:
any
=
item
.
rowDataState
==
"update"
?
updateAction
:
item
.
rowDataState
==
"create"
?
createAction
:
"create"
;
const
saveFunName
=
item
.
rowDataState
;
if
(
!
saveAction
||
!
saveFunName
)
{
return
;
}
const
arg
:
any
=
{
...
opt
};
let
_context
=
deepCopy
(
context
);
let
_viewParams
=
deepCopy
(
viewParams
);
Object
.
assign
(
arg
,
item
.
getDo
());
Object
.
assign
(
arg
,
{
viewParams
:
_viewParams
});
const
response
=
await
controlService
[
saveFunName
](
_context
,
arg
,
{
action
:
saveAction
,
isLoading
:
showBusyIndicator
},
);
if
(
response
.
status
||
response
.
status
==
200
)
{
}
}
}
catch
(
error
)
{
// TODO 错误异常处理
console
.
log
(
error
);
}
};
// 订阅viewSubject,监听load行为
if
(
viewSubject
)
{
let
subscription
=
viewSubject
.
subscribe
(({
tag
,
action
,
data
}:
IActionParam
)
=>
{
if
(
Object
.
is
(
controlName
,
tag
)
&&
Object
.
is
(
"save"
,
action
))
{
save
(
data
);
}
});
// 部件卸载时退订viewSubject
onUnmounted
(()
=>
{
subscription
.
unsubscribe
();
});
}
return
{
save
:
save
,
};
}
/**
* @description 使用删除功能模块
* @param {GridControlProps} props 传入的props
* @return {*}
* @memberof GridControl
*/
public
useRemove
(
props
:
GridControlProps
)
{
const
{
viewSubject
,
controlName
}
=
this
.
controlState
;
const
remove
=
async
(
opt
:
any
=
{})
=>
{
try
{
const
{
controlService
,
context
,
viewParams
,
showBusyIndicator
,
controlAction
}
=
this
.
controlState
;
if
(
!
controlAction
.
removeAction
)
{
return
;
}
let
_context
=
deepCopy
(
context
);
let
_viewParams
=
deepCopy
(
viewParams
);
const
arg
:
any
=
opt
[
0
];
Object
.
assign
(
arg
,
{
viewParams
:
_viewParams
});
const
response
=
await
controlService
.
remove
(
_context
,
arg
,
{
action
:
controlAction
.
removeAction
,
isLoading
:
showBusyIndicator
},
);
if
(
response
.
status
||
response
.
status
==
200
)
{
}
}
catch
(
error
)
{
// TODO 错误异常处理
console
.
log
(
error
);
}
};
// 订阅viewSubject,监听load行为
if
(
viewSubject
)
{
let
subscription
=
viewSubject
.
subscribe
(({
tag
,
action
,
data
}:
IActionParam
)
=>
{
if
(
Object
.
is
(
controlName
,
tag
)
&&
Object
.
is
(
"remove"
,
action
))
{
remove
(
data
);
}
});
// 部件卸载时退订viewSubject
onUnmounted
(()
=>
{
subscription
.
unsubscribe
();
});
}
return
{
remove
:
remove
,
};
}
/**
* @description 使用新建行功能模块
* @param {GridControlProps} props 传入的props
* @return {*}
* @memberof GridControl
*/
public
useNewRow
(
props
:
GridControlProps
)
{
const
{
viewSubject
,
controlName
}
=
this
.
controlState
;
const
newRow
=
async
(
opt
:
any
=
{})
=>
{
try
{
const
{
controlService
,
context
,
viewParams
,
showBusyIndicator
,
controlAction
}
=
this
.
controlState
;
if
(
!
controlAction
.
loadDraftAction
)
{
return
;
}
const
dataRef
=
toRef
(
this
.
controlState
,
"items"
);
let
_context
=
deepCopy
(
context
);
let
_viewParams
=
deepCopy
(
viewParams
);
const
arg
:
any
=
{...
opt
};
Object
.
assign
(
arg
,
{
viewParams
:
_viewParams
});
const
response
=
await
controlService
.
loadDraft
(
_context
,
arg
,
{
action
:
controlAction
.
loadDraftAction
,
isLoading
:
showBusyIndicator
},
);
if
(
response
.
status
||
response
.
status
==
200
)
{
dataRef
.
value
=
[...
dataRef
.
value
,[
response
.
data
]];
}
}
catch
(
error
)
{
// TODO 错误异常处理
console
.
log
(
error
);
}
};
// 订阅viewSubject,监听load行为
if
(
viewSubject
)
{
let
subscription
=
viewSubject
.
subscribe
(({
tag
,
action
,
data
}:
IActionParam
)
=>
{
if
(
Object
.
is
(
controlName
,
tag
)
&&
Object
.
is
(
"newRow"
,
action
))
{
newRow
(
data
);
}
});
// 部件卸载时退订viewSubject
onUnmounted
(()
=>
{
subscription
.
unsubscribe
();
});
}
return
{
remove
:
newRow
,
};
}
/**
* @description 处理编辑器事件
* @param {IActionParam} actionParam 行为参数
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/ibiz-core/service/control-service/grid-service.ts
浏览文件 @
a1b27ced
import
{
ControlServiceBase
,
ControlVOBase
,
hasFunction
}
from
'@ibiz-core'
;
import
{
ControlServiceBase
,
ControlVOBase
,
hasFunction
,
IParam
}
from
'@ibiz-core'
;
/**
* @description 表格部件服务
* @export
* @class
EditForm
Service
* @class
Grid
Service
* @extends {ControlServiceBase<T>}
* @template T 部件数据对象类型
*/
export
class
GridService
<
T
extends
ControlVOBase
>
extends
ControlServiceBase
<
T
>
{
/**
*
加载数据
*
* @param
[context={}] 上下文参数
* @param
[data={}] 视图
参数
* @
param opts
* @
return {*}
*
@description 加载草稿
*
@param {IParam} context 上下文
* @param
{IParam} data 行为数据
* @param
\{{ action: string; isLoading?: boolean }} opts 行为
参数
* @
return {*} {Promise<any>}
* @
memberof GridService
*/
public
async
get
(
context
:
any
,
data
:
any
,
opts
:
{
action
:
string
;
isLoading
?:
boolean
}):
Promise
<
any
>
{
public
async
loadDraft
(
context
:
IParam
,
data
:
IParam
,
opts
:
{
action
:
string
;
isLoading
?:
boolean
}):
Promise
<
any
>
{
let
_entityService
:
any
=
this
.
entityService
;
const
{
context
:
Context
,
data
:
Data
}
=
this
.
handleRequestData
(
context
,
data
,
opts
);
const
action
=
hasFunction
(
_entityService
,
opts
.
action
)
?
opts
.
action
:
'GET'
;
// todo主键
const
action
=
hasFunction
(
_entityService
,
opts
.
action
)
?
opts
.
action
:
'GetDraft'
;
const
response
=
await
_entityService
[
action
](
Context
,
Data
,
opts
.
isLoading
);
// this.setRemoteCopyData(response);
response
.
data
=
this
.
newControlVO
(
response
.
data
);
response
.
data
.
srfuf
=
'0'
;
return
this
.
handleResponse
(
response
,
opts
);
}
/**
* @description 加载数据
* @param {IParam} context 上下文
* @param {IParam} data 行为数据
* @param \{{ action: string; isLoading?: boolean }} opts 行为参数
* @return {*} {Promise<any>}
* @memberof GridService
*/
public
async
get
(
context
:
IParam
,
data
:
IParam
,
opts
:
{
action
:
string
;
isLoading
?:
boolean
}):
Promise
<
any
>
{
let
_entityService
:
any
=
this
.
entityService
;
const
{
context
:
Context
,
data
:
Data
}
=
this
.
handleRequestData
(
context
,
data
,
opts
);
const
action
=
hasFunction
(
_entityService
,
opts
.
action
)
?
opts
.
action
:
'GET'
;
const
response
=
await
_entityService
[
action
](
Context
,
Data
,
opts
.
isLoading
);
//this.setCopynativeData(response.data);
response
.
data
?.
forEach
((
item
:
IParam
)
=>
{
item
=
this
.
newControlVO
(
item
);
})
return
this
.
handleResponse
(
response
,
opts
);
}
/**
*
创
建数据
*
* @param
[context={}] 上下文参数
* @param
[data={}] 视图
参数
* @
param opts
* @
return {*}
*
@description 新
建数据
*
@param {IParam} context 上下文
* @param
{IParam} data 行为数据
* @param
\{{ action: string; isLoading?: boolean }} opts 行为
参数
* @
return {*} {Promise<any>}
* @
memberof GridService
*/
public
async
create
(
context
:
any
,
data
:
any
,
opts
:
{
action
:
string
;
isLoading
?:
boolean
}):
Promise
<
any
>
{
public
async
create
(
context
:
IParam
,
data
:
IParam
,
opts
:
{
action
:
string
;
isLoading
?:
boolean
}):
Promise
<
any
>
{
let
_entityService
:
any
=
this
.
entityService
;
const
{
context
:
Context
,
data
:
Data
}
=
this
.
handleRequestData
(
context
,
data
,
opts
);
const
action
=
hasFunction
(
_entityService
,
opts
.
action
)
?
opts
.
action
:
'Create'
;
...
...
@@ -45,14 +67,14 @@ export class GridService<T extends ControlVOBase> extends ControlServiceBase<T>
}
/**
* 删除数据
*
* @param
[context={}] 上下文参数
* @param
[data={}] 视图
参数
* @
param opts
* @
return {*}
*
@description
删除数据
*
@param {IParam} context 上下文
* @param
{IParam} data 行为数据
* @param
\{{ action: string; isLoading?: boolean }} opts 行为
参数
* @
return {*} {Promise<any>}
* @
memberof GridService
*/
public
async
remove
(
context
:
any
,
data
:
any
,
opts
:
{
action
:
string
;
isLoading
?:
boolean
}):
Promise
<
any
>
{
public
async
remove
(
context
:
IParam
,
data
:
IParam
,
opts
:
{
action
:
string
;
isLoading
?:
boolean
}):
Promise
<
any
>
{
let
_entityService
:
any
=
this
.
entityService
;
const
{
context
:
Context
,
data
:
Data
}
=
this
.
handleRequestData
(
context
,
data
,
opts
);
const
action
=
hasFunction
(
_entityService
,
opts
.
action
)
?
opts
.
action
:
'Remove'
;
...
...
@@ -62,12 +84,12 @@ export class GridService<T extends ControlVOBase> extends ControlServiceBase<T>
}
/**
*
更新数据
*
* @param
[context={}] 上下文参数
* @param
[data={}] 视图
参数
* @
param opts
* @
return {*}
*
@description 更新
*
@param {*} context 上下文
* @param
{*} data 行为数据
* @param
\{{ action: string; isLoading?: boolean }} opts 行为
参数
* @
return {*} {Promise<any>}
* @
memberof GridService
*/
public
async
update
(
context
:
any
,
data
:
any
,
opts
:
{
action
:
string
;
isLoading
?:
boolean
}):
Promise
<
any
>
{
let
_entityService
:
any
=
this
.
entityService
;
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录