准备工作
yarn add @cvte/cir-csb-common-view@1.1.11-0
使用方式
以使用默认值表达式获取用户信息作为示例
获取用户/组织信息
app/modules/App/global.js
示例如下:【在模版页加载的阶段之前获取均可】
import { observe } from 'mobx';
import globalStore from '@cvte/cir-tools/utils/globalStore';
import { pluginStore } from '@cvte/cir-framework';
import menuEntity from '@cvte/cir-antdframe/entities/menu';
import { generatorGlobalContext } from '@cvte/cir-csb-common-view';
observe(globalStore.userInfo, (change) => {
const { newValue, name } = change;
if (name === 'data') {
generatorGlobalContext?.getContext?.()?.session?.setUser?.(newValue);
}
});
observe(menuEntity.globalMultiOrgData, (change) => {
const { newValue, name } = change;
if (name === 'data') {
const xOrgId = pluginStore.get(menuEntity.surrentOrgId);
if (xOrgId) {
const currentData = newValue?.find?.((item) => item.id === xOrgId);
if (currentData) {
generatorGlobalContext?.getContext?.()?.session?.setOrg?.(currentData);
}
}
}
});
默认值表达式
属性的基础配置
中选择默认值类型
为表达式
表达式的格式内容为${a.b.c}
a
:上下文类型,目前支持session
、page
b
:上下文属性键,例如user
、org
c
:上下文路径
上下文操作类
export
Table of contents
Methods
Methods
clearPage
▸ clearPage(pageId
): boolean
清空指定页面上下文
memberof
Context
Parameters
Name | Type |
---|---|
pageId |
string |
Returns
boolean
clearSession
▸ clearSession(): boolean
清空当前会话上下文
memberof
Context
Returns
boolean
getContext
▸ getContext(): ICSBContext
获取全局所有类型上下文
memberof
Context
Returns
ICSBContext
getPage
▸ getPage(pageId
): PageContext
获取指定页面上下文
memberof
Context
Parameters
Name | Type | Description |
---|---|---|
pageId |
string |
上下文的页面唯一标识 |
Returns
PageContext
getPageContext
▸ getPageContext(pageId
): ICSBCurrentContext
获取指定页面的所有类型上下文
memberof
Context
Parameters
Name | Type |
---|---|
pageId |
string |
Returns
ICSBCurrentContext
getSession
▸ getSession(): SessionContext
获取当前会话上下文
memberof
Context
Returns
SessionContext
setPage
▸ setPage(pageId
, page
): void
设置页面上下文
memberof
Context
Parameters
Name | Type | Description |
---|---|---|
pageId |
string |
上下文的页面唯一标识 |
page |
Object |
页面上下文键值对象;如已有对应键,则覆盖新的值;如没有,则追加键值; |
Returns
void
setSession
▸ setSession(session
): void
设置会话上下文
memberof
Context
Parameters
Name | Type |
---|---|
session |
SessionContext |
Returns
void
getDetailPageId
▸ Static
getDetailPageId(data
): string
获取详情页页面ID
编辑时用页面id
创建无页面id,则用设计方案id
使用默认详情视图时无设计方案id,则用表单分类id
预览时无表单分类id,则用页面Code
static
memberof
Context
Parameters
Name | Type |
---|---|
data |
any |
Returns
string
最后编辑:袁子涵 更新时间:2022-11-10 10:58