面板绘制器脚本
可根据面板数据自定义绘制脚本代码,需返回一段html格式的字符串,绘制面板项时会将返回的字符串以v-html的形式替换掉面板项内容。
参数
名称 | 类型 | 描述 |
---|---|---|
data | IApiData | 当前业务数据 |
document | Document | 当前文档对象 |
selector | (className: string) => HTMLCollectionOf<Element> | 元素选择器 |
env | IEnvironment | 当前环境对象 |
appSession | IApiData | 当前应用会话对象 |
app | IApiAppHubController | 当前应用 |
util | { message: IApiMessageUtil, notification: IApiNotificationUtil,modal: IApiModalUtil,confirm: IApiConfirmUtil,openView: IApiOpenViewUtil} | 工具集 |
调用示例
基于当前数据绘制自定义标题
typescript
`<h1>${data.title}</hl>`
根据数据业务条件绘制面板项内容
根据数据中的starttime
判断是否超时。
typescript
let str = data.starttime;
let num = Number(str);
const start = new Date(data.starttime);
const overTime = Date.now() - start.getTime() - 60000;
if (overTime > 0) {
return `<span>已超时 ${overTime/1000} s</span>`
} else {
return "";
}