Appearance
织信组件库
该章节将讲解平台定义的组件库,具体的使用方法,以及文档。
织信运行时
织信运行时环境,提供了客户端脚本的所有能力。一般在嵌入系统的模块中使用。具体API文档参考客户端脚本
注意
引用了织信运行时组件库的组件无法在外部页面调用,只能依托于平台基座运行。如自定义组件字段,自定义视图等嵌入在平台里的模块
织信Web运行时
织信Web运行时环境,是客户端脚本的子集。继承了客户端脚本除上下文相关的API的能力。一般在外部页面中使用。
informatweb.callAutomatic
调用自动化
javascript
informatweb.callAutomatic({ automaticId, args })| 参数 | 类型 | 描述 |
|---|---|---|
| appId | String | 调用的自动化归属应用ID,不传递则默认为当前应用 |
| automaticId | String | 自动化的标识符 |
| args | Array | 自动化传递的参数 |
| withoutTimeoutLoading | bool | 是否展示系统的执行loading |
返回值 自动化调用结果
示例
javascript
//调用系统自动化
informatweb.callAutomatic({
// appId: 'msucfeq7305cn',
automaticId: 'a1',
args: ['123', 1]
}).then((result) => {
console.log(result);
})注意
织信运行时调用的自动化只执行服务端步骤,不执行客户端步骤,且被调用的自动化需要开启允许通过Http方式调用自动化
informatweb.attachmentUrl
获取数据表附件字段文件链接
javascript
informatweb.attachmentUrl(tableKey, fieldKey, fileId)| 参数 | 类型 | 描述 |
|---|---|---|
| tableKey | String | 模块标识符 |
| fieldKey | String | 字段标识符 |
| fileId | String | 文件ID |
返回值 类型为 String
示例
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织信Vue工具函数集
自定义的Vue指令和过滤器工具集合,提供常用的函数、过滤器。
$informatAge
日期转年龄
javascript
this.$informatAge(date)| 参数 | 类型 | 描述 |
|---|---|---|
| date | Date|Number|String | 日期 |
返回值 类型为 Number
示例
javascript
const age = this.$informatAge('2000-01-01');
console.log(age); // 24$informatArrReverse
将数组进行翻转
javascript
this.$informatArrReverse(arr)| 参数 | 类型 | 描述 |
|---|---|---|
| arr | Array | 原数组 |
返回值 类型为 Array
示例
javascript
const arr = [1,2,3,4]
const ret = this.$informatArrReverse(arr);
console.log(ret); // [4,3,2,1]$informatArrSort
将数组进行排序
javascript
this.$informatArrSort(arr, key, direction)| 参数 | 类型 | 描述 |
|---|---|---|
| arr | Array | 原数组 |
| key | String | 排序计算的属性key |
| direction | String | 排序方式(asc,desc) |
返回值 类型为 Array
示例
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
首字母大写
javascript
this.$informatCapitalize(value)| 参数 | 类型 | 描述 |
|---|---|---|
| value | String | 字符串内容 |
返回值 类型为 String
示例
javascript
const ret = this.$informatCapitalize('test');
console.log(ret); // Test$informatChop
字符串内容截取
javascript
this.$informatChop(value, length, location)| 参数 | 类型 | 描述 |
|---|---|---|
| value | String | 字符串内容 |
| length | Number | 截取长度 |
| location | String | 截取方式(start,end)默认end |
返回值 类型为 String示例
javascript
const ret = this.$informatChop('hello world', 5, 'end');
console.log(ret); // world$informatCurrency
在数字钱添加货币符号
javascript
this.$informatCurrency(value, code)| 参数 | 类型 | 描述 |
|---|---|---|
| value | Number | 金额 |
| code | String | 货币编码。如:PHP, USD, AUD, GBP, CNY |
返回值 类型为 String
示例
javascript
const ret = this.$informatCurrency(100, 'PHP');
console.log(ret); // ₱100$informatDateFormat
日期格式化
javascript
this.$informatDateFormat(date, format)| 参数 | 类型 | 描述 |
|---|---|---|
| date | Date,Long,String | 日期 |
| format | String | 格式 |
返回值 类型为 String
示例
javascript
const ret = this.$informatDateFormat(new Date(), 'yyyy-MM-dd HH:mm:ss');
console.log(ret); // 2024-05-21 19:46:56$informatFileSize
格式化文件展示的大小,将bytes转化为具体的文件大小
javascript
this.$informatFileSize(value)| 参数 | 类型 | 描述 |
|---|---|---|
| value | Number | 文件字节大小 |
返回值 类型为 String
示例
javascript
const ret = this.$informatFileSize(1024);
console.log(ret); // 1.0 Kb
const ret2 = this.$informatFileSize(10000000000);
console.log(ret2); // 9.3 Gb$informatJson
将对象JSON格式化展示
javascript
this.$informatJson(value, indent)| 参数 | 类型 | 描述 |
|---|---|---|
| value | Object | 对象 |
| indent | Number|String | 缩进内容 |
返回值 类型为 String
示例
javascript
const ret = this.$informatJson({"name":"张三"}, 2);
console.log(ret);
/*
{
"name": "张三"
}
*/$informatLowercase
将字母转换为小写
javascript
this.$informatLowercase(value)| 参数 | 类型 | 描述 |
|---|---|---|
| value | String | 字符串内容 |
返回值 类型为 String
示例
javascript
const ret = this.$informatLowercase('HELLO WORLD');
console.log(ret); // hello world$informatObjectSize
格式化输出给定对象的大小
javascript
this.$informatObjectSize(value)| 参数 | 类型 | 描述 |
|---|---|---|
| value | Object | 对象 |
返回值 类型为 String
示例
javascript
const ret = this.$informatObjectSize({"name":"张三"});
console.log(ret); // 17 B$informatReplace
字符串内容替换
javascript
this.$informatReplace(value, replacee, replacer)| 参数 | 类型 | 描述 |
|---|---|---|
| value | String | 字符串内容 |
| replacee | String | 替换的内容文本或正则 |
| replacer | String | 替换为的内容 |
返回值 类型为 String
示例
javascript
const ret = this.$informatReplace('In the end', /end/i, 'start.');
console.log(ret); // In the start.$informatReverse
字符串内容翻转
javascript
this.$informatReverse(value)| 参数 | 类型 | 描述 |
|---|---|---|
| value | String | 字符串内容 |
返回值 类型为 String
示例
javascript
const ret = this.$informatReverse('hello');
console.log(ret); // olleh$informatSandwich
在给定值周围预置和附加数据
javascript
this.$informatSandwich(value, start, end)| 参数 | 类型 | 描述 |
|---|---|---|
| value | String | 字符串内容 |
| start | String | 前部附加内容 |
| end | String | 后部附加内容(默认前部内容翻转) |
返回值 类型为 String
示例
javascript
const ret = this.$informatSandwich('中', '前', '后');
console.log(ret); // 前中后
const ret1 = this.$informatSandwich('内容', '<< ');
console.log(ret1); // << 内容 >>$informatTruncate
将字符串内容指定长度截取超出部分替换为省略号
javascript
this.$informatTruncate(value, length)| 参数 | 类型 | 描述 |
|---|---|---|
| value | String | 字符串内容 |
| length | Number | 截取长度 |
返回值 类型为 String
示例
javascript
const ret = this.$informatTruncate('这是一行很长很长的文本', 4);
console.log(ret); // 这是一行...$informatUppercase
将字符串内容字母转换为大写
javascript
this.$informatUppercase(value)| 参数 | 类型 | 描述 |
|---|---|---|
| value | String | 字符串内容 |
返回值 类型为 String
示例
javascript
const ret = this.$informatUppercase('test');
console.log(ret); // TEST
