Skip to main content

Page Context

当前列表页面的上下文引用。

API

graphql(gql)

通过这个方法直接将gql字符串传递给后端执行。

参数: 只有一个gql查询字符串

返回: Promise<ResponseData>

示例:


thisApp.listOnTableLoaded = async (ctx) => {
ctx.getListContext().getActionBar().addButton({
key: 'clickMe',
text: '点我',
onClick: async () => {
const resp = await ctx.getPageContext().graphql(
`
{
data: Department(criteriaStr: "((isLeaf=true) AND (exists(select orgDept.id from OrgDepartmentView orgDept where orgDept.legalEntityOrgId in (select ownerLegalEntityOrgId from Organization where id in ('K4WUXS50JUD0011')) and orgDept.departmentId = m.id) ) AND ((disabledTime IS NULL OR TO_TIMESTAMP(1678291200) < disabledTime)) AND ((disabledTime IS NULL OR TO_TIMESTAMP(1678291200) < disabledTime)))", firstResult: 0, maxResult: 200, sorts: [{name: "code", isDesending: false}], actionId: "add", contextField: "department", contextDataScopeOrgIds: ["K4WUXS50JUD0011"], contextObject: "RevenueConfirmation", contextOrgIds: ["K4WUXS50JUD0011"], isDisabledOrgScope: true) {
id
name
code
idPath
parents {
id
name
}
parent {
code
name
id
idPath
}
isLeaf
disabledTime
character {
id
title
}
manager {
id
name
}
executive {
id
name
}
annualNumber
description
_ctrlViewMethod
_ctrlViewFields
}
count: AggregateQueryOne(entity: "Department", criteriaStr: "((isLeaf=true) AND (exists(select orgDept.id from OrgDepartmentView orgDept where orgDept.legalEntityOrgId in (select ownerLegalEntityOrgId from Organization where id in ('K4WUXS50JUD0011')) and orgDept.departmentId = m.id) ) AND ((disabledTime IS NULL OR TO_TIMESTAMP(1678291200) < disabledTime)) AND ((disabledTime IS NULL OR TO_TIMESTAMP(1678291200) < disabledTime)))", actionId: "add", contextField: "department", contextDataScopeOrgIds: ["K4WUXS50JUD0011"], contextObject: "RevenueConfirmation", contextOrgIds: ["K4WUXS50JUD0011"], isDisabledOrgScope: true) {
count: aggr(expr: "count(*)")
}
}
`
);

console.log('api: ',resp.data);

},
})
};