提交 1980ad1d 编写于 作者: tony001's avatar tony001

update:调整表格加载逻辑

上级 4a907049
......@@ -6,7 +6,8 @@
removeAction: '{{ctrl.removePSControlAction.psAppDEMethod.codeName}}',
updateAction: '{{ctrl.updatePSControlAction.psAppDEMethod.codeName}}',
loadDraftAction: '{{ctrl.getDraftPSControlAction.psAppDEMethod.codeName}}',
createAction: '{{ctrl.getDraftPSControlAction.psAppDEMethod.codeName}}',
createAction: '{{ctrl.createPSControlAction.psAppDEMethod.codeName}}',
fetchAction:'{{ctrl.fetchPSControlAction.psAppDEMethod.codeName}}'
},
{{/neq}}
{{/page.ctrls}}
......
......@@ -352,15 +352,15 @@ export class GridControl extends MainControl {
* @return {*}
* @memberof GridControl
*/
public useLoad(props: GridControlProps){
public useLoad(props: GridControlProps) {
const { viewSubject, controlName } = this.controlState;
const load = async (opt: any = {})=>{
const load = async (opt: any = {}) => {
try {
const {
controlService, context, viewParams, showBusyIndicator, controlAction, gridSort
} = this.controlState;
const { gridPaging, data } = toRefs(this.controlState);
if (!controlAction.loadAction) {
if (!controlAction.fetchAction) {
return;
}
const { noSort, minorSortDir, minorSortPSDEF } = gridSort;
......@@ -369,16 +369,16 @@ export class GridControl extends MainControl {
let _context = deepCopy(context ? context : {});
let _viewParams = deepCopy(viewParams ? viewParams : {});
if (noSort && minorSortDir && minorSortPSDEF) {
Object.assign(_viewParams, { sort: `${minorSortPSDEF},${minorSortDir}`});
Object.assign(_viewParams, { sort: `${minorSortPSDEF},${minorSortDir}` });
}
if (enablePagingBar) {
Object.assign(_viewParams, { page: current - 1, size: pageSize});
Object.assign(_viewParams, { page: current - 1, size: pageSize });
}
Object.assign(arg, { viewParams: _viewParams });
Object.assign(arg, _viewParams);
const response = await controlService.get(
_context,
arg,
{ action: controlAction.loadAction, isLoading: showBusyIndicator}
{ action: controlAction.fetchAction, isLoading: showBusyIndicator }
);
if (response.status || response.status == 200) {
data.value = response.data;
......@@ -395,20 +395,18 @@ export class GridControl extends MainControl {
console.log(error);
}
}
// 订阅viewSubject,监听load行为
if(viewSubject){
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam)=>{
if(Object.is(controlName, tag) && Object.is("load", action) ){
if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
if (Object.is(controlName, tag) && Object.is("load", action)) {
load(data)
}
})
// 部件卸载时退订viewSubject
onUnmounted(()=>{
onUnmounted(() => {
subscription.unsubscribe();
})
}
return {
load: load
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册