@steedos-widgets/amis-lib 1.2.32 → 1.2.34
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 +110 -43
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +110 -43
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +110 -43
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/fields/editor.d.ts +24 -15
- package/dist/types/lib/converter/amis/fields/lookup.d.ts +4 -0
- package/dist/types/lib/converter/amis/toolbars/export_excel.d.ts +0 -1
- package/dist/types/lib/converter/amis/toolbars/setting_listview.d.ts +0 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -5112,7 +5112,8 @@ const getSettingListviewToolbarButtonSchema = ()=>{
|
|
|
5112
5112
|
"type": "dropdown-button",
|
|
5113
5113
|
"trigger": "click",
|
|
5114
5114
|
"icon": "fa fa-cog",
|
|
5115
|
-
|
|
5115
|
+
//TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
|
|
5116
|
+
// "tooltip": i18next.t('frontend_button_listview_control_tooltip'),
|
|
5116
5117
|
"btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded border-gray-300 text-gray-500",
|
|
5117
5118
|
"align": "right",
|
|
5118
5119
|
"visibleOn": "${!isLookup}",
|
|
@@ -5152,11 +5153,12 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
|
5152
5153
|
"rightIconClassName": "m-l-sm"
|
|
5153
5154
|
}
|
|
5154
5155
|
];
|
|
5155
|
-
|
|
5156
|
+
displayAs === 'split'? i18next.t('frontend_display_type_is_split') : i18next.t('frontend_display_type_is_table');
|
|
5156
5157
|
return {
|
|
5157
5158
|
"type": "dropdown-button",
|
|
5158
5159
|
"icon": "fa fa-table-columns",
|
|
5159
|
-
|
|
5160
|
+
//TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
|
|
5161
|
+
// "tooltip": `${i18next.t('frontend_display_as')} ${displayAsLabel}`,
|
|
5160
5162
|
"btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded border-gray-300 text-gray-500",
|
|
5161
5163
|
"align": "right",
|
|
5162
5164
|
"visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
|
|
@@ -5238,7 +5240,8 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5238
5240
|
// "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
|
|
5239
5241
|
"type": "button",
|
|
5240
5242
|
"align": "right",
|
|
5241
|
-
|
|
5243
|
+
//TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
|
|
5244
|
+
// "tooltip": i18next.t('frontend_button_reload_tooltip'),
|
|
5242
5245
|
"tooltipPlacement": "top",
|
|
5243
5246
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
5244
5247
|
"label": "",
|
|
@@ -5260,7 +5263,8 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5260
5263
|
"icon": "fa fa-search",
|
|
5261
5264
|
"type": "button",
|
|
5262
5265
|
"tooltipPlacement": "top",
|
|
5263
|
-
|
|
5266
|
+
//TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
|
|
5267
|
+
// "tooltip": i18next.t('frontend_button_search_tooltip'),
|
|
5264
5268
|
"badge": {
|
|
5265
5269
|
"offset": [
|
|
5266
5270
|
-5,
|
|
@@ -5305,7 +5309,9 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5305
5309
|
{
|
|
5306
5310
|
"type": "reload",
|
|
5307
5311
|
"align": "right",
|
|
5308
|
-
|
|
5312
|
+
//TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
|
|
5313
|
+
// "tooltip": i18next.t('frontend_button_reload_tooltip'),
|
|
5314
|
+
"tooltip":"",
|
|
5309
5315
|
"tooltipPlacement": "top",
|
|
5310
5316
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500"
|
|
5311
5317
|
},
|
|
@@ -5315,8 +5321,9 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5315
5321
|
filterVisible ? {
|
|
5316
5322
|
"label": i18next.t('frontend_button_search_tooltip'),
|
|
5317
5323
|
"icon": "fa fa-search",
|
|
5318
|
-
|
|
5319
|
-
"
|
|
5324
|
+
//TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
|
|
5325
|
+
// "tooltip": i18next.t('frontend_button_search_tooltip'),
|
|
5326
|
+
// "tooltipPlacement": "top",
|
|
5320
5327
|
"type": "button",
|
|
5321
5328
|
"badge": {
|
|
5322
5329
|
"offset": [
|
|
@@ -5422,9 +5429,16 @@ async function getSource(field, ctx) {
|
|
|
5422
5429
|
valueField = `${ctx.fieldNamePrefix}${valueField}`;
|
|
5423
5430
|
}
|
|
5424
5431
|
data.$value = `$${valueField}`;
|
|
5425
|
-
|
|
5432
|
+
data['$'] = `$$`;
|
|
5426
5433
|
const requestAdaptor = `
|
|
5427
5434
|
var filters = [['parent', '=', null]];
|
|
5435
|
+
const filtersFunction = ${field.filtersFunction || field._filtersFunction};
|
|
5436
|
+
if(filtersFunction){
|
|
5437
|
+
const _filters = filtersFunction(filters, api.data.$);
|
|
5438
|
+
if(_filters && _filters.length > 0){
|
|
5439
|
+
filters.push(_filters);
|
|
5440
|
+
}
|
|
5441
|
+
}
|
|
5428
5442
|
api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters));
|
|
5429
5443
|
var defaultValue = api.data.$value;
|
|
5430
5444
|
var optionsFiltersOp = "${field.multiple ? "in" : "="}";
|
|
@@ -5622,7 +5636,7 @@ function getLookupSapceUserTreeSchema(){
|
|
|
5622
5636
|
const tree = [{
|
|
5623
5637
|
"type": "input-tree",
|
|
5624
5638
|
"className": "",
|
|
5625
|
-
"inputClassName": "
|
|
5639
|
+
"inputClassName": "p-0",
|
|
5626
5640
|
"id": "u:7fd77b7915b0",
|
|
5627
5641
|
"source": {
|
|
5628
5642
|
"method": "post",
|
|
@@ -5683,7 +5697,7 @@ function getLookupSapceUserTreeSchema(){
|
|
|
5683
5697
|
"left": "-200px",
|
|
5684
5698
|
"width": "190px",
|
|
5685
5699
|
"bottom": 0,
|
|
5686
|
-
"top": "
|
|
5700
|
+
"top": "2px",
|
|
5687
5701
|
"overflow": "auto",
|
|
5688
5702
|
"min-height":"300px"
|
|
5689
5703
|
},
|
|
@@ -5949,7 +5963,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
5949
5963
|
"margin-left":"200px",
|
|
5950
5964
|
"min-height": "300px"
|
|
5951
5965
|
};
|
|
5966
|
+
pickerSchema.className = pickerSchema.className || "" + " steedos-select-user";
|
|
5952
5967
|
}
|
|
5968
|
+
|
|
5953
5969
|
pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, ctx.formFactor, { headerToolbarItems });
|
|
5954
5970
|
const isAllowCreate = refObjectConfig.permissions.allowCreate;
|
|
5955
5971
|
if (isAllowCreate) {
|
|
@@ -6046,6 +6062,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
6046
6062
|
modalTitle: i18next.t('frontend_form_please_select') + " " + refObjectConfig.label,
|
|
6047
6063
|
labelField: referenceTo.labelField.name,
|
|
6048
6064
|
valueField: referenceTo.valueField.name,
|
|
6065
|
+
// disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段。
|
|
6066
|
+
disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || (this.relatedKey ==='${field.name}') )`,
|
|
6049
6067
|
modalMode: 'dialog', //TODO 设置 dialog 或者 drawer,用来配置弹出方式
|
|
6050
6068
|
source: source,
|
|
6051
6069
|
size: "lg",
|
|
@@ -6226,6 +6244,8 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
6226
6244
|
joinValues: false,
|
|
6227
6245
|
extractValue: true,
|
|
6228
6246
|
clearable: true,
|
|
6247
|
+
// disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段。
|
|
6248
|
+
disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || (this.relatedKey ==='${field.name}') )`,
|
|
6229
6249
|
// labelField: labelField,
|
|
6230
6250
|
// valueField: valueField,
|
|
6231
6251
|
source: apiInfo,
|
|
@@ -6410,6 +6430,8 @@ async function getIdsPickerSchema(field, readonly, ctx){
|
|
|
6410
6430
|
valueField: referenceTo.valueField.name,
|
|
6411
6431
|
modalMode: 'dialog',
|
|
6412
6432
|
source: source,
|
|
6433
|
+
// disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段。
|
|
6434
|
+
disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || (this.relatedKey ==='${field.name}') )`,
|
|
6413
6435
|
size: "lg",
|
|
6414
6436
|
pickerSchema: pickerSchema,
|
|
6415
6437
|
joinValues: false,
|
|
@@ -6438,7 +6460,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
|
|
|
6438
6460
|
* @Author: baozhoutao@steedos.com
|
|
6439
6461
|
* @Date: 2023-01-13 17:27:54
|
|
6440
6462
|
* @LastEditors: liaodaxue
|
|
6441
|
-
* @LastEditTime: 2023-
|
|
6463
|
+
* @LastEditTime: 2023-07-24 15:23:12
|
|
6442
6464
|
* @Description:
|
|
6443
6465
|
*/
|
|
6444
6466
|
|
|
@@ -6460,21 +6482,39 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
|
|
|
6460
6482
|
}
|
|
6461
6483
|
}else {
|
|
6462
6484
|
return {
|
|
6463
|
-
"type": "
|
|
6485
|
+
"type": "control",
|
|
6486
|
+
"label": field.label,
|
|
6464
6487
|
"body": [
|
|
6465
6488
|
{
|
|
6466
|
-
"type": "
|
|
6467
|
-
"
|
|
6468
|
-
"
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6489
|
+
"type": "tabs",
|
|
6490
|
+
"tabsMode": "strong",
|
|
6491
|
+
"className": "steedos-markdown",
|
|
6492
|
+
"tabs": [
|
|
6493
|
+
{
|
|
6494
|
+
"title": "Write",
|
|
6495
|
+
"tab": [
|
|
6496
|
+
{
|
|
6497
|
+
"type": "editor",
|
|
6498
|
+
"name": field.name,
|
|
6499
|
+
"language": "markdown",
|
|
6500
|
+
}
|
|
6501
|
+
]
|
|
6502
|
+
},
|
|
6503
|
+
{
|
|
6504
|
+
"title": "Preview",
|
|
6505
|
+
"tab": [
|
|
6506
|
+
{
|
|
6507
|
+
"type": "markdown",
|
|
6508
|
+
"name": field.name,
|
|
6509
|
+
"options": {
|
|
6510
|
+
"linkify": true,
|
|
6511
|
+
"html": true,
|
|
6512
|
+
"breaks": true
|
|
6513
|
+
}
|
|
6514
|
+
}
|
|
6515
|
+
]
|
|
6516
|
+
}
|
|
6517
|
+
]
|
|
6478
6518
|
}
|
|
6479
6519
|
]
|
|
6480
6520
|
}
|
|
@@ -7420,26 +7460,45 @@ async function getQuickEditSchema(field, options){
|
|
|
7420
7460
|
let labelField = quickEditSchema.body[0].labelField || "label";
|
|
7421
7461
|
let valueField = quickEditSchema.body[0].valueField || "value";
|
|
7422
7462
|
if (field.multiple) {
|
|
7463
|
+
/*
|
|
7464
|
+
多选分两种情况。
|
|
7465
|
+
第一种是减少选项时(判断新的数据是否比老的数据短),按照index删除_display中对应选项,保证回显没问题;
|
|
7466
|
+
第二种是增加选项时,按照value的值,找到对应选项,并按照_display的规则为其赋值
|
|
7467
|
+
*/
|
|
7423
7468
|
TempDisplayField = `
|
|
7469
|
+
const preData = event.data.__super.${field.name};
|
|
7470
|
+
if(preData && event.data.${field.name}.length < preData.length){
|
|
7471
|
+
let deletedIndex;
|
|
7472
|
+
preData.forEach(function(item,index){
|
|
7473
|
+
if(_.indexOf(event.data.${field.name}, item) == -1) _display["${field.name}"].splice(index, 1);
|
|
7474
|
+
})
|
|
7475
|
+
}else{
|
|
7424
7476
|
_display["${field.name}"] = [];
|
|
7425
|
-
event.data.
|
|
7477
|
+
event.data.value.forEach(function(val,index){
|
|
7478
|
+
const item = _.find(event.data.selectedItems, { ${valueField}: val });
|
|
7426
7479
|
_display["${field.name}"].push(
|
|
7427
7480
|
{
|
|
7428
7481
|
"label": item.${labelField},
|
|
7429
|
-
"value": item
|
|
7482
|
+
"value": item[event.data.uiSchema.idFieldName],
|
|
7430
7483
|
"objectName": "${field.reference_to}"
|
|
7431
7484
|
}
|
|
7432
7485
|
)
|
|
7433
7486
|
})
|
|
7434
|
-
|
|
7487
|
+
}
|
|
7488
|
+
|
|
7489
|
+
`;
|
|
7435
7490
|
} else {
|
|
7436
7491
|
TempDisplayField = `
|
|
7492
|
+
if(event.data.value){
|
|
7437
7493
|
_display["${field.name}"] = {
|
|
7438
7494
|
"label": event.data.selectedItems.${labelField},
|
|
7439
|
-
"value": event.data.selectedItems
|
|
7495
|
+
"value": event.data.selectedItems[event.data.uiSchema.idFieldName],
|
|
7440
7496
|
"objectName": "${field.reference_to}"
|
|
7441
7497
|
}
|
|
7442
|
-
|
|
7498
|
+
}else{
|
|
7499
|
+
_display["${field.name}"] = {}
|
|
7500
|
+
}
|
|
7501
|
+
`;
|
|
7443
7502
|
}
|
|
7444
7503
|
quickEditSchema.body[0].onEvent["change"] = quickEditOnEvent(TempDisplayField);
|
|
7445
7504
|
break;
|
|
@@ -7549,10 +7608,25 @@ async function getQuickEditSchema(field, options){
|
|
|
7549
7608
|
return quickEditSchema;
|
|
7550
7609
|
}
|
|
7551
7610
|
|
|
7611
|
+
function getFieldWidth(width){
|
|
7612
|
+
const defaultWidth = "unset";//用于使table内的td标签下生成div,实现将快速编辑按钮固定在右侧的效果,并不是为了unset效果
|
|
7613
|
+
if(typeof width == 'string'){
|
|
7614
|
+
if(isNaN(width)){
|
|
7615
|
+
return width;
|
|
7616
|
+
}else {
|
|
7617
|
+
return Number(width);
|
|
7618
|
+
}
|
|
7619
|
+
}else if(typeof width == 'number'){
|
|
7620
|
+
return width;
|
|
7621
|
+
}else {
|
|
7622
|
+
return defaultWidth;
|
|
7623
|
+
}
|
|
7624
|
+
}
|
|
7625
|
+
|
|
7552
7626
|
async function getTableColumns(fields, options){
|
|
7553
7627
|
const columns = [{name: '_index',type: 'text', width: 32, placeholder: ""}];
|
|
7554
7628
|
const allowEdit = options.permissions?.allowEdit && options.permissions?.modifyAllRecords && !options.isLookup && options.enable_inline_edit != false;
|
|
7555
|
-
|
|
7629
|
+
|
|
7556
7630
|
for (const field of fields) {
|
|
7557
7631
|
//增加quickEdit属性,实现快速编辑
|
|
7558
7632
|
const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
|
|
@@ -7600,7 +7674,7 @@ async function getTableColumns(fields, options){
|
|
|
7600
7674
|
type: "switch",
|
|
7601
7675
|
name: field.name,
|
|
7602
7676
|
label: field.label,
|
|
7603
|
-
width: field.width
|
|
7677
|
+
width: getFieldWidth(field.width),
|
|
7604
7678
|
toggled: field.toggled,
|
|
7605
7679
|
static: true,
|
|
7606
7680
|
className:"whitespace-nowrap",
|
|
@@ -7611,7 +7685,7 @@ async function getTableColumns(fields, options){
|
|
|
7611
7685
|
type: "switch",
|
|
7612
7686
|
name: field.name,
|
|
7613
7687
|
label: field.label,
|
|
7614
|
-
width: field.width
|
|
7688
|
+
width: getFieldWidth(field.width),
|
|
7615
7689
|
toggled: field.toggled,
|
|
7616
7690
|
quickEdit: quickEditSchema,
|
|
7617
7691
|
static: true,
|
|
@@ -7631,7 +7705,7 @@ async function getTableColumns(fields, options){
|
|
|
7631
7705
|
label: field.label,
|
|
7632
7706
|
map: map,
|
|
7633
7707
|
sortable: field.sortable,
|
|
7634
|
-
width: field.width
|
|
7708
|
+
width: getFieldWidth(field.width),
|
|
7635
7709
|
toggled: field.toggled,
|
|
7636
7710
|
className,
|
|
7637
7711
|
static: true,
|
|
@@ -7665,7 +7739,7 @@ async function getTableColumns(fields, options){
|
|
|
7665
7739
|
label: field.label,
|
|
7666
7740
|
sortable: field.sortable,
|
|
7667
7741
|
// searchable: field.searchable,
|
|
7668
|
-
width: field.width
|
|
7742
|
+
width: getFieldWidth(field.width),
|
|
7669
7743
|
type: type,
|
|
7670
7744
|
tpl: tpl,
|
|
7671
7745
|
toggled: field.toggled,
|
|
@@ -7963,14 +8037,7 @@ async function getTableOperation(ctx){
|
|
|
7963
8037
|
onOpenApi: {
|
|
7964
8038
|
url: `\${context.rootUrl}/service/api/@\${objectName}/recordPermissions/\${_id}`,
|
|
7965
8039
|
method: "get",
|
|
7966
|
-
|
|
7967
|
-
$: "$$",
|
|
7968
|
-
objectName: "${objectName}",
|
|
7969
|
-
listViewId: "${listViewId}",
|
|
7970
|
-
appId: "${appId}",
|
|
7971
|
-
formFactor: "${formFactor}",
|
|
7972
|
-
context: `\${context}`
|
|
7973
|
-
},
|
|
8040
|
+
requestAdaptor: "api.data={}; return api;",
|
|
7974
8041
|
headers: {
|
|
7975
8042
|
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
7976
8043
|
},
|