Skip to content

Informat Component Library

This chapter explains the component libraries defined by the platform, their specific usage methods, and documentation.

Informat Runtime

Informat runtime environment provides all capabilities of client-side scripts. It is generally used in modules embedded in the system. For specific API documentation, please refer to Client Scripts

Note

Components that reference the Informat Runtime component library cannot be called on external pages and can only run 依托于 the platform base. Such as custom component fields, custom views, and other modules embedded in the platform.

Informat Web Runtime

The Informat Web runtime environment is a subset of client-side scripts. It inherits the capabilities of client-side scripts except for context-related APIs. It is generally used in external pages.

informatweb.callAutomatic

Call automation

javascript
informatweb.callAutomatic({ automaticId, args });
ParameterTypeDescription
appIdStringThe application ID to which the called automation belongs. If not passed, it defaults to the current application
automaticIdStringAutomation identifier
argsArrayParameters passed to the automation
withoutTimeoutLoadingboolWhether to display the system's execution loading

Return Value Automation call result

Example

javascript
//Call system automation
informatweb
  .callAutomatic({
    // appId: 'msucfeq7305cn',
    automaticId: "a1",
    args: ["123", 1],
  })
  .then((result) => {
    console.log(result);
  });

Note

Automations called by Informat Runtime only execute server-side steps, not client-side steps, and the called automation needs to enable Allow calling automations via Http

informatweb.attachmentUrl

Get data table attachment field file link

javascript
informatweb.attachmentUrl(tableKey, fieldKey, fileId);
ParameterTypeDescription
tableKeyStringModule identifier
fieldKeyStringField identifier
fileIdStringFile ID

Return Value Type is String

Example

javascript
const attachmentUrl = informatweb.attachmentUrl("testTable", "testField", "xxxx.png");
console.log(attachmentUrl); // https://next.informat.cn/web0/file/fieldkey/gx6wpgysmthb1/testTable/testField/xxxx.png?token=xxxxxxx

Informat Vue Utility Functions

A collection of custom Vue directives and filters, providing commonly used functions and filters.

$informatAge

Convert date to age

javascript
this.$informatAge(date);
ParameterTypeDescription
dateDate|Number|StringDate

Return Value Type is Number

Example

javascript
const age = this.$informatAge("2000-01-01");
console.log(age); // 24

$informatArrReverse

Reverse an array

javascript
this.$informatArrReverse(arr);
ParameterTypeDescription
arrArrayOriginal array

Return Value Type is Array

Example

javascript
const arr = [1, 2, 3, 4];
const ret = this.$informatArrReverse(arr);
console.log(ret); // [4,3,2,1]

$informatArrSort

Sort an array

javascript
this.$informatArrSort(arr, key, direction);
ParameterTypeDescription
arrArrayOriginal array
keyStringProperty key for sorting calculation
directionStringSorting method (asc, desc)

Return Value Type is Array

Example

javascript
const arr = [{ value: 1 }, { value: 5 }, { value: 3 }, { value: 2 }];
const ret = this.$informatArrSort(arr, "value", "asc");
console.log(ret); // arr = [{ value: 1 },{ value: 2 },{ value: 3 },{ value: 5 }]

$informatCapitalize

Capitalize the first letter

javascript
this.$informatCapitalize(value);
ParameterTypeDescription
valueStringString content

Return Value Type is String

Example

javascript
const ret = this.$informatCapitalize("test");
console.log(ret); // Test

$informatChop

String content truncation

javascript
this.$informatChop(value, length, location);
ParameterTypeDescription
valueStringString content
lengthNumberTruncation length
locationStringTruncation method (start, end) default end

Return Value Type is StringExample

javascript
const ret = this.$informatChop("hello world", 5, "end");
console.log(ret); // world

$informatCurrency

Add currency symbol to number

javascript
this.$informatCurrency(value, code);
ParameterTypeDescription
valueNumberAmount
codeStringCurrency code. Such as: PHP, USD, AUD, GBP, CNY

Return Value Type is String

Example

javascript
const ret = this.$informatCurrency(100, "PHP");
console.log(ret); // ₱100

$informatDateFormat

Date formatting

javascript
this.$informatDateFormat(date, format);
ParameterTypeDescription
dateDate,Long,StringDate
formatStringFormat

Return Value Type is String

Example

javascript
const ret = this.$informatDateFormat(new Date(), "yyyy-MM-dd HH:mm:ss");
console.log(ret); // 2024-05-21 19:46:56

$informatFileSize

Format file size display, convert bytes to specific file size

javascript
this.$informatFileSize(value);
ParameterTypeDescription
valueNumberFile byte size

Return Value Type is String

Example

javascript
const ret = this.$informatFileSize(1024);
console.log(ret); // 1.0 Kb

const ret2 = this.$informatFileSize(10000000000);
console.log(ret2); // 9.3 Gb

$informatJson

Format and display object as JSON

javascript
this.$informatJson(value, indent);
ParameterTypeDescription
valueObjectObject
indentNumber|StringIndent content

Return Value Type is String

Example

javascript
const ret = this.$informatJson({ name: "张三" }, 2);
console.log(ret);
/*
{
  "name": "张三"
}
*/

$informatLowercase

Convert letters to lowercase

javascript
this.$informatLowercase(value);
ParameterTypeDescription
valueStringString content

Return Value Type is String

Example

javascript
const ret = this.$informatLowercase("HELLO WORLD");
console.log(ret); // hello world

$informatObjectSize

Format and output the size of a given object

javascript
this.$informatObjectSize(value);
ParameterTypeDescription
valueObjectObject

Return Value Type is String

Example

javascript
const ret = this.$informatObjectSize({ name: "张三" });
console.log(ret); // 17 B

$informatReplace

String content replacement

javascript
this.$informatReplace(value, replacee, replacer);
ParameterTypeDescription
valueStringString content
replaceeStringContent text or regex to replace
replacerStringContent to replace with

Return Value Type is String

Example

javascript
const ret = this.$informatReplace("In the end", /end/i, "start.");
console.log(ret); // In the start.

$informatReverse

Reverse string content

javascript
this.$informatReverse(value);
ParameterTypeDescription
valueStringString content

Return Value Type is String

Example

javascript
const ret = this.$informatReverse("hello");
console.log(ret); // olleh

$informatSandwich

Prepend and append data around the given value

javascript
this.$informatSandwich(value, start, end);
ParameterTypeDescription
valueStringString content
startStringContent to prepend
endStringContent to append (default reversed start content)

Return Value Type is String

Example

javascript
const ret = this.$informatSandwich("中", "前", "后");
console.log(ret); // 前中后

const ret1 = this.$informatSandwich("内容", "<< ");
console.log(ret1); // << 内容 >>

$informatTruncate

Truncate string content to specified length and replace excess part with ellipsis

javascript
this.$informatTruncate(value, length);
ParameterTypeDescription
valueStringString content
lengthNumberTruncation length

Return Value Type is String

Example

javascript
const ret = this.$informatTruncate("这是一行很长很长的文本", 4);
console.log(ret); // 这是一行...

$informatUppercase

Convert string content letters to uppercase

javascript
this.$informatUppercase(value);
ParameterTypeDescription
valueStringString content

Return Value Type is String

Example

javascript
const ret = this.$informatUppercase("test");
console.log(ret); // TEST