@steedos-widgets/amis-lib 1.2.12 → 1.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +133 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +133 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +133 -11
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/fields/editor.d.ts +10 -0
- package/dist/types/lib/converter/amis/toolbars/setting_listview.d.ts +1 -0
- package/dist/types/schema/standard_import_data.amis.d.ts +16 -0
- package/dist/types/standard/button.d.ts +16 -0
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -1894,7 +1894,23 @@
|
|
|
1894
1894
|
{
|
|
1895
1895
|
name: "template_url",
|
|
1896
1896
|
label: "导入模板",
|
|
1897
|
-
type: "
|
|
1897
|
+
type: "button-group",
|
|
1898
|
+
buttons: [
|
|
1899
|
+
{
|
|
1900
|
+
type: "button",
|
|
1901
|
+
label: "下载",
|
|
1902
|
+
visibleOn: "${template_url}",
|
|
1903
|
+
level: "link",
|
|
1904
|
+
actionType: "download",
|
|
1905
|
+
api:{
|
|
1906
|
+
url: "${template_url}",
|
|
1907
|
+
method: "get",
|
|
1908
|
+
headers: {
|
|
1909
|
+
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
],
|
|
1898
1914
|
options: {
|
|
1899
1915
|
html: true
|
|
1900
1916
|
},
|
|
@@ -4654,12 +4670,13 @@
|
|
|
4654
4670
|
"type": "dropdown-button",
|
|
4655
4671
|
"trigger": "click",
|
|
4656
4672
|
"icon": "fa fa-cog",
|
|
4673
|
+
"tooltip": "列表视图控制",
|
|
4657
4674
|
"btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
4658
4675
|
"align": "right",
|
|
4659
4676
|
"visibleOn": "${!isLookup}",
|
|
4660
4677
|
"buttons": [
|
|
4661
4678
|
{
|
|
4662
|
-
"label": "
|
|
4679
|
+
"label": "列表视图控制",
|
|
4663
4680
|
"children": [
|
|
4664
4681
|
getNewListviewButtonSchema(),
|
|
4665
4682
|
getCopyListviewButtonSchema(),
|
|
@@ -4693,9 +4710,11 @@
|
|
|
4693
4710
|
"rightIconClassName": "m-l-sm"
|
|
4694
4711
|
}
|
|
4695
4712
|
];
|
|
4713
|
+
const displayAsLabel = displayAs === 'split'? "分栏视图" : "表格";
|
|
4696
4714
|
return {
|
|
4697
4715
|
"type": "dropdown-button",
|
|
4698
4716
|
"icon": "fa fa-table-columns",
|
|
4717
|
+
"tooltip": `显示为 ${displayAsLabel}`,
|
|
4699
4718
|
"btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
4700
4719
|
"align": "right",
|
|
4701
4720
|
"visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
|
|
@@ -4775,6 +4794,7 @@ else{
|
|
|
4775
4794
|
// "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
|
|
4776
4795
|
"type": "button",
|
|
4777
4796
|
"align": "right",
|
|
4797
|
+
"tooltip": "刷新",
|
|
4778
4798
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
4779
4799
|
"label": "",
|
|
4780
4800
|
"icon": "fa fa-sync",
|
|
@@ -4794,6 +4814,7 @@ else{
|
|
|
4794
4814
|
"label": "",
|
|
4795
4815
|
"icon": "fa fa-search",
|
|
4796
4816
|
"type": "button",
|
|
4817
|
+
"tooltip": "搜索",
|
|
4797
4818
|
"badge": {
|
|
4798
4819
|
"offset": [
|
|
4799
4820
|
-5,
|
|
@@ -4838,6 +4859,7 @@ else{
|
|
|
4838
4859
|
{
|
|
4839
4860
|
"type": "reload",
|
|
4840
4861
|
"align": "right",
|
|
4862
|
+
"tooltip": "刷新",
|
|
4841
4863
|
"tooltipPlacement": "bottom",
|
|
4842
4864
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500"
|
|
4843
4865
|
},
|
|
@@ -4845,6 +4867,8 @@ else{
|
|
|
4845
4867
|
filterVisible ? {
|
|
4846
4868
|
"label": "",
|
|
4847
4869
|
"icon": "fa fa-search",
|
|
4870
|
+
"tooltip": "搜索",
|
|
4871
|
+
"tooltipPlacement": "bottom",
|
|
4848
4872
|
"type": "button",
|
|
4849
4873
|
"align": "right",
|
|
4850
4874
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
@@ -5869,8 +5893,8 @@ else{
|
|
|
5869
5893
|
/*
|
|
5870
5894
|
* @Author: baozhoutao@steedos.com
|
|
5871
5895
|
* @Date: 2023-01-13 17:27:54
|
|
5872
|
-
* @LastEditors:
|
|
5873
|
-
* @LastEditTime: 2023-
|
|
5896
|
+
* @LastEditors: Please set LastEditors
|
|
5897
|
+
* @LastEditTime: 2023-05-31 13:34:22
|
|
5874
5898
|
* @Description:
|
|
5875
5899
|
*/
|
|
5876
5900
|
|
|
@@ -5912,8 +5936,12 @@ else{
|
|
|
5912
5936
|
const getHtmlFieldSchema = (field, readonly, ctx)=>{
|
|
5913
5937
|
if(readonly){
|
|
5914
5938
|
return {
|
|
5915
|
-
"type": "
|
|
5916
|
-
"
|
|
5939
|
+
"type": "control",
|
|
5940
|
+
"label": field.label,
|
|
5941
|
+
"body": {
|
|
5942
|
+
"type": "html",
|
|
5943
|
+
"name": field.name
|
|
5944
|
+
}
|
|
5917
5945
|
}
|
|
5918
5946
|
}else {
|
|
5919
5947
|
return {
|
|
@@ -5940,8 +5968,8 @@ else{
|
|
|
5940
5968
|
/*
|
|
5941
5969
|
* @Author: baozhoutao@steedos.com
|
|
5942
5970
|
* @Date: 2022-10-28 14:52:55
|
|
5943
|
-
* @LastEditors:
|
|
5944
|
-
* @LastEditTime:
|
|
5971
|
+
* @LastEditors: Please set LastEditors
|
|
5972
|
+
* @LastEditTime: 2023-05-31 13:25:53
|
|
5945
5973
|
* @Description:
|
|
5946
5974
|
*/
|
|
5947
5975
|
|
|
@@ -6490,8 +6518,19 @@ else{
|
|
|
6490
6518
|
break;
|
|
6491
6519
|
case 'url':
|
|
6492
6520
|
convertData = {
|
|
6493
|
-
type: getAmisStaticFieldType('url', readonly)
|
|
6521
|
+
type: getAmisStaticFieldType('url', readonly, field)
|
|
6494
6522
|
};
|
|
6523
|
+
if(readonly && field.show_as_qr){
|
|
6524
|
+
convertData = {
|
|
6525
|
+
type: "control",
|
|
6526
|
+
label: field.label,
|
|
6527
|
+
body: {
|
|
6528
|
+
type: "qr-code",
|
|
6529
|
+
codeSize: 128,
|
|
6530
|
+
name: field.name
|
|
6531
|
+
}
|
|
6532
|
+
};
|
|
6533
|
+
}
|
|
6495
6534
|
break;
|
|
6496
6535
|
case 'email':
|
|
6497
6536
|
convertData = {
|
|
@@ -6526,6 +6565,7 @@ else{
|
|
|
6526
6565
|
case 'code':
|
|
6527
6566
|
convertData = {
|
|
6528
6567
|
type: "editor",
|
|
6568
|
+
disabled: readonly ? true : false,
|
|
6529
6569
|
language: field.language,
|
|
6530
6570
|
editorDidMount: new Function('editor', 'monaco', field.editorDidMount)
|
|
6531
6571
|
};
|
|
@@ -7183,12 +7223,43 @@ else{
|
|
|
7183
7223
|
const fieldSchemaArray = getFieldSchemaArray(formFields);
|
|
7184
7224
|
const _sections = ___namespace.groupBy(fieldSchemaArray, 'group');
|
|
7185
7225
|
const sections = [];
|
|
7226
|
+
var sectionHeaderVisibleOn=[];
|
|
7186
7227
|
for (const key in _sections) {
|
|
7187
7228
|
const section = await getSection(formFields, permissionFields, fieldSchemaArray, key, ctx);
|
|
7188
7229
|
if(section.body.length > 0){
|
|
7230
|
+
if(section.visibleOn){
|
|
7231
|
+
sectionHeaderVisibleOn.push(section.visibleOn);
|
|
7232
|
+
}
|
|
7189
7233
|
sections.push(section);
|
|
7190
7234
|
}
|
|
7191
7235
|
}
|
|
7236
|
+
/*
|
|
7237
|
+
为了实现只有一个分组时隐藏该分组标题,需要分三种情况(分组如果没有visibleon属性就代表一定显示,有visibleon需要进行判断)
|
|
7238
|
+
1.所有分组中只有一个分组没有visibleon,还需要判断其他有visibleon的分组是否显示,只有其他都不显示时,才需要隐藏标题;反之,有任何一个显示,就不需要隐藏标题
|
|
7239
|
+
2.所有分组都有visibleon
|
|
7240
|
+
2.1 当前分组为隐藏时,标题就设置为隐藏
|
|
7241
|
+
2.2 当前分组为显示时,其他分组只要有一个是显示,就显示该分组标题
|
|
7242
|
+
2.3 当前分组为显示时,其他分组都隐藏,就隐藏该分组标题
|
|
7243
|
+
3.所有分组中有两个以上的分组没有visibleon(这种情况不用处理)
|
|
7244
|
+
*/
|
|
7245
|
+
if(ctx.mode == "edit"){
|
|
7246
|
+
if (sections.length - sectionHeaderVisibleOn.length == 1) {
|
|
7247
|
+
sections.forEach((section) => {
|
|
7248
|
+
section.headingClassName = {
|
|
7249
|
+
"hidden": `!(${sectionHeaderVisibleOn.join(" || ") || 'false'})`
|
|
7250
|
+
};
|
|
7251
|
+
});
|
|
7252
|
+
} else if (sections.length == sectionHeaderVisibleOn.length) {
|
|
7253
|
+
sections.forEach((section, index) => {
|
|
7254
|
+
var tempSectionHeaderVisibleOn = sectionHeaderVisibleOn.slice();
|
|
7255
|
+
tempSectionHeaderVisibleOn.splice(index, 1);
|
|
7256
|
+
section.headingClassName = {
|
|
7257
|
+
"hidden": `!((${tempSectionHeaderVisibleOn.join(" || ") || 'false'}) && ${sectionHeaderVisibleOn[index]})`
|
|
7258
|
+
};
|
|
7259
|
+
});
|
|
7260
|
+
}
|
|
7261
|
+
}
|
|
7262
|
+
|
|
7192
7263
|
return sections;
|
|
7193
7264
|
};
|
|
7194
7265
|
|
|
@@ -7703,6 +7774,8 @@ else{
|
|
|
7703
7774
|
type = 'tpl';
|
|
7704
7775
|
}else if(field.type === 'html'){
|
|
7705
7776
|
type = 'markdown';
|
|
7777
|
+
}else if(field.type === 'url' && field.show_as_qr){
|
|
7778
|
+
type = 'qr-code';
|
|
7706
7779
|
}
|
|
7707
7780
|
let className = "";
|
|
7708
7781
|
if(field.type === 'textarea'){
|
|
@@ -7730,7 +7803,13 @@ else{
|
|
|
7730
7803
|
|
|
7731
7804
|
}
|
|
7732
7805
|
// columns.push(getOperation(fields));
|
|
7733
|
-
|
|
7806
|
+
if(!___namespace.some(columns, { name: options.labelFieldName })){
|
|
7807
|
+
const href = Router.getObjectDetailPath({
|
|
7808
|
+
...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
|
|
7809
|
+
});
|
|
7810
|
+
columns[0].type = "tpl";
|
|
7811
|
+
columns[0].tpl = `<a href="${href}">\${${columns[0].name}}</a>`;
|
|
7812
|
+
}
|
|
7734
7813
|
return columns;
|
|
7735
7814
|
}
|
|
7736
7815
|
|
|
@@ -8096,6 +8175,8 @@ else{
|
|
|
8096
8175
|
|
|
8097
8176
|
const fileFields = {};
|
|
8098
8177
|
const fileFieldsKeys = [];
|
|
8178
|
+
// 含有optionsFunction属性, 无reference_to属性的lookup字段
|
|
8179
|
+
const lookupFields = {};
|
|
8099
8180
|
fields.forEach((item)=>{
|
|
8100
8181
|
if(___namespace.includes(['image','avatar','file'], item.type)){
|
|
8101
8182
|
fileFieldsKeys.push(item.name);
|
|
@@ -8105,6 +8186,9 @@ else{
|
|
|
8105
8186
|
multiple: item.multiple
|
|
8106
8187
|
};
|
|
8107
8188
|
}
|
|
8189
|
+
if(___namespace.includes(['lookup'], item.type) && !item.reference_to ){
|
|
8190
|
+
lookupFields[item.name] = item;
|
|
8191
|
+
}
|
|
8108
8192
|
});
|
|
8109
8193
|
|
|
8110
8194
|
let valueField = mainObject.key_field || '_id';
|
|
@@ -8121,6 +8205,7 @@ else{
|
|
|
8121
8205
|
api.data.filter = "$filter";
|
|
8122
8206
|
api.data.loaded = "${loaded}";
|
|
8123
8207
|
api.data.listViewId = "${listViewId}";
|
|
8208
|
+
api.data.listName = "${listName}";
|
|
8124
8209
|
api.requestAdaptor = `
|
|
8125
8210
|
// selfData 中的数据由 CRUD 控制. selfData中,只能获取到 CRUD 给定的data. 无法从数据链中获取数据.
|
|
8126
8211
|
let selfData = JSON.parse(JSON.stringify(api.data.$self));
|
|
@@ -8151,9 +8236,13 @@ else{
|
|
|
8151
8236
|
console.error("本地存储中crud参数解析异常:", ex);
|
|
8152
8237
|
}
|
|
8153
8238
|
${baseFilters ? `var systemFilters = ${JSON.stringify(baseFilters)};` : 'var systemFilters = [];'}
|
|
8239
|
+
var _ids = []
|
|
8154
8240
|
const filtersFunction = ${filtersFunction};
|
|
8155
8241
|
if(filtersFunction){
|
|
8156
8242
|
const _filters = filtersFunction(systemFilters, api.data.$self);
|
|
8243
|
+
if(api.data.listName == "recent"){
|
|
8244
|
+
_ids = _filters[2]
|
|
8245
|
+
}
|
|
8157
8246
|
if(_filters && _filters.length > 0){
|
|
8158
8247
|
if(_.isEmpty(systemFilters)){
|
|
8159
8248
|
systemFilters = _filters || [];
|
|
@@ -8265,6 +8354,7 @@ else{
|
|
|
8265
8354
|
filters = [filters, 'and', userFilters]
|
|
8266
8355
|
}
|
|
8267
8356
|
}
|
|
8357
|
+
api.data._ids = _ids;
|
|
8268
8358
|
api.data = {
|
|
8269
8359
|
query: api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim())
|
|
8270
8360
|
}
|
|
@@ -8272,6 +8362,11 @@ else{
|
|
|
8272
8362
|
return api;
|
|
8273
8363
|
`;
|
|
8274
8364
|
api.adaptor = `
|
|
8365
|
+
if(api.body.listName == "recent"){
|
|
8366
|
+
payload.data.rows = _.sortBy(payload.data.rows, function(item){
|
|
8367
|
+
return _.indexOf(api.body._ids, item._id)
|
|
8368
|
+
});
|
|
8369
|
+
}
|
|
8275
8370
|
const enable_tree = ${mainObject.enable_tree};
|
|
8276
8371
|
if(!enable_tree){
|
|
8277
8372
|
_.each(payload.data.rows, function(item, index){
|
|
@@ -8282,9 +8377,10 @@ else{
|
|
|
8282
8377
|
}
|
|
8283
8378
|
window.postMessage(Object.assign({type: "listview.loaded"}), "*");
|
|
8284
8379
|
let fileFields = ${JSON.stringify(fileFields)};
|
|
8380
|
+
let lookupFields = ${JSON.stringify(lookupFields)};
|
|
8285
8381
|
_.each(payload.data.rows, function(item, index){
|
|
8286
8382
|
_.each(fileFields , (field, key)=>{
|
|
8287
|
-
if(item[key] && item._display && item._display
|
|
8383
|
+
if(item[key] && item._display && item._display[key]){
|
|
8288
8384
|
let value = item._display[key];
|
|
8289
8385
|
if(!_.isArray(value)){
|
|
8290
8386
|
value = [value]
|
|
@@ -8296,6 +8392,14 @@ else{
|
|
|
8296
8392
|
}
|
|
8297
8393
|
}
|
|
8298
8394
|
})
|
|
8395
|
+
_.each(lookupFields , (field, key)=>{
|
|
8396
|
+
if(item[key]){
|
|
8397
|
+
if(field._optionsFunction){
|
|
8398
|
+
const optionsFunction = eval("(" + field._optionsFunction+ ")")(item);
|
|
8399
|
+
item[key + '__label'] = _.map(_.filter(optionsFunction, function(option){return _.includes(item[key], option.value)}), 'label').join(' ');
|
|
8400
|
+
}
|
|
8401
|
+
}
|
|
8402
|
+
})
|
|
8299
8403
|
})
|
|
8300
8404
|
|
|
8301
8405
|
if(enable_tree){
|
|
@@ -9625,6 +9729,24 @@ else{
|
|
|
9625
9729
|
|
|
9626
9730
|
ctx.defaults = defaults;
|
|
9627
9731
|
|
|
9732
|
+
if (listViewName == "recent") {
|
|
9733
|
+
listview_filters = `
|
|
9734
|
+
function(filters, data) {
|
|
9735
|
+
var result = Steedos.authRequest('/graphql', {
|
|
9736
|
+
type: 'POST',
|
|
9737
|
+
async: false,
|
|
9738
|
+
data: JSON.stringify({
|
|
9739
|
+
query: '{object_recent_viewed(filters: [["record.o","=","' + data.objectName + '"],["space","=","' + data.context.tenantId + '"],["owner","=","' + data.context.userId + '"]],sort:"modified desc",top:50){ _id,record} }'
|
|
9740
|
+
}),
|
|
9741
|
+
});
|
|
9742
|
+
var _ids = []
|
|
9743
|
+
result.data.object_recent_viewed.forEach(function (item) {
|
|
9744
|
+
_ids = _ids.concat(item.record.ids)
|
|
9745
|
+
})
|
|
9746
|
+
return ["_id", "=", _ids];
|
|
9747
|
+
}
|
|
9748
|
+
`;
|
|
9749
|
+
}
|
|
9628
9750
|
const amisSchema = {
|
|
9629
9751
|
"type": "steedos-object-table",
|
|
9630
9752
|
"objectApiName": objectName,
|