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

update:调整表格加载逻辑

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