@steedos-widgets/amis-lib 1.3.22-beta.2 → 3.6.0-beta.3
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 +169 -112
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +169 -112
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +109 -62
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1626,6 +1626,7 @@ async function getQuickEditSchema(field, options){
|
|
|
1626
1626
|
{
|
|
1627
1627
|
"actionType": "custom",
|
|
1628
1628
|
"script": `
|
|
1629
|
+
|
|
1629
1630
|
var _display = _.cloneDeep(event.data._display);
|
|
1630
1631
|
${displayField}
|
|
1631
1632
|
doAction({actionType: 'setValue', "args": {"value": {_display}},componentId: "${quickEditId}"});
|
|
@@ -1797,7 +1798,7 @@ async function getQuickEditSchema(field, options){
|
|
|
1797
1798
|
"actions":[
|
|
1798
1799
|
{
|
|
1799
1800
|
"actionType": "setValue",
|
|
1800
|
-
"componentId":
|
|
1801
|
+
"componentId": quickEditId,
|
|
1801
1802
|
"args": {
|
|
1802
1803
|
"value":{
|
|
1803
1804
|
"quickedit_record_permissions_loading": true
|
|
@@ -1822,7 +1823,7 @@ async function getQuickEditSchema(field, options){
|
|
|
1822
1823
|
},
|
|
1823
1824
|
{
|
|
1824
1825
|
"actionType": "setValue",
|
|
1825
|
-
"componentId":
|
|
1826
|
+
"componentId": quickEditId,
|
|
1826
1827
|
"args": {
|
|
1827
1828
|
"value":{
|
|
1828
1829
|
"quickedit_record_permissions_loading": false
|
|
@@ -1831,7 +1832,7 @@ async function getQuickEditSchema(field, options){
|
|
|
1831
1832
|
},
|
|
1832
1833
|
{
|
|
1833
1834
|
"actionType": "setValue",
|
|
1834
|
-
"componentId":
|
|
1835
|
+
"componentId": quickEditId,
|
|
1835
1836
|
"args": {
|
|
1836
1837
|
"value":{
|
|
1837
1838
|
"quickedit_record_permissions": "${event.data}"
|
|
@@ -2010,9 +2011,9 @@ function getFieldWidth(width){
|
|
|
2010
2011
|
async function getTableColumns(fields, options){
|
|
2011
2012
|
const columns = [];
|
|
2012
2013
|
if(!options.isLookup && !options.isInputTable){
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2014
|
+
if(!options.enable_tree){
|
|
2015
|
+
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
|
|
2016
|
+
}
|
|
2016
2017
|
}
|
|
2017
2018
|
const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;
|
|
2018
2019
|
|
|
@@ -2554,6 +2555,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2554
2555
|
if(!isLookup && !hiddenColumnOperation){
|
|
2555
2556
|
columns.push(await getTableOperation(options));
|
|
2556
2557
|
}
|
|
2558
|
+
|
|
2557
2559
|
}
|
|
2558
2560
|
|
|
2559
2561
|
return {
|
|
@@ -2863,7 +2865,21 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2863
2865
|
|
|
2864
2866
|
if(enable_tree){
|
|
2865
2867
|
const records = payload.data.rows || [];
|
|
2866
|
-
const getTreeOptions = SteedosUI.getTreeOptions
|
|
2868
|
+
const getTreeOptions = SteedosUI.getTreeOptions;
|
|
2869
|
+
const assignIndexToTreeRecords = function(tree, parentIndex) {
|
|
2870
|
+
tree.forEach(function (node, index) {
|
|
2871
|
+
// 构建当前节点的 _index
|
|
2872
|
+
var currentIndex = parentIndex ? parentIndex + '-' + (index + 1) : '' + (index + 1);
|
|
2873
|
+
|
|
2874
|
+
// 赋值给节点
|
|
2875
|
+
node._index = currentIndex;
|
|
2876
|
+
|
|
2877
|
+
// 如果有子节点,递归调用函数
|
|
2878
|
+
if (node.children && node.children.length > 0) {
|
|
2879
|
+
assignIndexToTreeRecords(node.children, currentIndex);
|
|
2880
|
+
}
|
|
2881
|
+
});
|
|
2882
|
+
};
|
|
2867
2883
|
let isTreeOptionsComputed = false;
|
|
2868
2884
|
if(records.length === 1 && records[0].children){
|
|
2869
2885
|
isTreeOptionsComputed = true;
|
|
@@ -2871,6 +2887,7 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2871
2887
|
if(!isTreeOptionsComputed){
|
|
2872
2888
|
// 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
|
|
2873
2889
|
payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
|
|
2890
|
+
assignIndexToTreeRecords(payload.data.rows, '');
|
|
2874
2891
|
}
|
|
2875
2892
|
try{
|
|
2876
2893
|
setTimeout(() => {
|
|
@@ -3647,6 +3664,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
3647
3664
|
"dialog": {
|
|
3648
3665
|
"type": "dialog",
|
|
3649
3666
|
"title": title,
|
|
3667
|
+
data,
|
|
3650
3668
|
"body": [
|
|
3651
3669
|
{
|
|
3652
3670
|
"type": "steedos-object-form",
|
|
@@ -8227,7 +8245,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8227
8245
|
let tableOptions = Object.assign({
|
|
8228
8246
|
idFieldName: objectSchema.idFieldName, labelFieldName: labelFieldName,
|
|
8229
8247
|
permissions:objectSchema.permissions,enable_inline_edit:objectSchema.enable_inline_edit,
|
|
8230
|
-
crudId: listSchema.id || id
|
|
8248
|
+
crudId: listSchema.id || id, enable_tree: objectSchema.enable_tree
|
|
8231
8249
|
}, options);
|
|
8232
8250
|
tableOptions.amisData = createObject(options.amisData || {}, {});
|
|
8233
8251
|
const table = await getTableSchema$1(fields, tableOptions);
|
|
@@ -8319,6 +8337,11 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8319
8337
|
crudModeClassName = `steedos-crud-mode-${body.mode}`;
|
|
8320
8338
|
}
|
|
8321
8339
|
|
|
8340
|
+
if(body.columns && options.formFactor != 'SMALL'){
|
|
8341
|
+
//将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
8342
|
+
body.columns.splice(body.columns.length - 1, 0, {name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
|
|
8343
|
+
}
|
|
8344
|
+
|
|
8322
8345
|
if (defaults) {
|
|
8323
8346
|
const headerSchema = defaults.headerSchema;
|
|
8324
8347
|
const footerSchema = defaults.footerSchema;
|
|
@@ -8343,6 +8366,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8343
8366
|
body = wrappedBody;
|
|
8344
8367
|
}
|
|
8345
8368
|
}
|
|
8369
|
+
|
|
8346
8370
|
// console.timeEnd('getObjectCRUD');
|
|
8347
8371
|
// TODO: data应该只留loaded,其他属性都改为从上层传递下来
|
|
8348
8372
|
return {
|
|
@@ -10545,6 +10569,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10545
10569
|
*/
|
|
10546
10570
|
return payload;
|
|
10547
10571
|
}
|
|
10572
|
+
if(!payload.data.rows){
|
|
10573
|
+
payload.data.rows = [];
|
|
10574
|
+
}
|
|
10548
10575
|
if(enable_tree){
|
|
10549
10576
|
const records = payload.data.rows;
|
|
10550
10577
|
const treeRecords = [];
|
|
@@ -12414,7 +12441,7 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12414
12441
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12415
12442
|
* @Date: 2023-11-15 09:50:22
|
|
12416
12443
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12417
|
-
* @LastEditTime: 2023-12-
|
|
12444
|
+
* @LastEditTime: 2023-12-27 13:50:26
|
|
12418
12445
|
*/
|
|
12419
12446
|
|
|
12420
12447
|
/**
|
|
@@ -12442,20 +12469,22 @@ function getInputTableCell(field, showAsInlineEditMode) {
|
|
|
12442
12469
|
name: field.name,
|
|
12443
12470
|
quickEdit: {
|
|
12444
12471
|
"type": "steedos-field",
|
|
12445
|
-
"config": field,
|
|
12446
|
-
|
|
12472
|
+
"config": Object.assign({}, field, {
|
|
12473
|
+
label: false
|
|
12474
|
+
})
|
|
12447
12475
|
}
|
|
12448
12476
|
}
|
|
12449
12477
|
}
|
|
12450
12478
|
else {
|
|
12451
12479
|
return {
|
|
12452
12480
|
"type": "steedos-field",
|
|
12453
|
-
"config": field,
|
|
12481
|
+
"config": Object.assign({}, field, {
|
|
12482
|
+
label: false
|
|
12483
|
+
}),
|
|
12454
12484
|
"static": true,
|
|
12455
12485
|
"readonly": true,
|
|
12456
12486
|
label: field.label,
|
|
12457
|
-
name: field.name
|
|
12458
|
-
hideLabel: true
|
|
12487
|
+
name: field.name
|
|
12459
12488
|
}
|
|
12460
12489
|
}
|
|
12461
12490
|
}
|
|
@@ -12661,7 +12690,7 @@ function getFormPagination(props, mode) {
|
|
|
12661
12690
|
* @returns 带翻页容器的wrapper
|
|
12662
12691
|
*/
|
|
12663
12692
|
function getFormPaginationWrapper(props, form, mode) {
|
|
12664
|
-
console.log("==getFormPaginationWrapper===", props, mode);
|
|
12693
|
+
// console.log("==getFormPaginationWrapper===", props, mode);
|
|
12665
12694
|
let serviceId = getComponentId("form_pagination", props.id);
|
|
12666
12695
|
let tableServiceId = getComponentId("table_service", props.id);
|
|
12667
12696
|
let innerForm = Object.assign({}, form, {
|
|
@@ -12701,8 +12730,28 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12701
12730
|
let __wrapperServiceId = "${tableServiceId}";
|
|
12702
12731
|
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
12703
12732
|
let wrapperServiceData = wrapperService.getData();
|
|
12704
|
-
|
|
12733
|
+
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12734
|
+
// 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
|
|
12735
|
+
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
|
|
12705
12736
|
//不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
|
|
12737
|
+
let mode = "${mode}";
|
|
12738
|
+
if(mode === "new"){
|
|
12739
|
+
// 点击子表组件底部新增按钮时新增一条空白行并自动翻页到新增行
|
|
12740
|
+
// 注意点击弹出的子表行详细表单中的新增按钮不会进此service init事件函数中
|
|
12741
|
+
let newItem = {};
|
|
12742
|
+
event.data.__tableItems.push(newItem);
|
|
12743
|
+
lastestFieldValue.push(newItem);
|
|
12744
|
+
event.data.index = lastestFieldValue.length - 1;
|
|
12745
|
+
event.data.__page = lastestFieldValue.length;
|
|
12746
|
+
// 这里新增空白行时要把值同步保存到子表组件中,如果不同步保存的话,用户点击弹出表单右上角的关闭窗口时不会自动删除这里自动增加的空白行,同步后可以让用户手动删除此行
|
|
12747
|
+
doAction({
|
|
12748
|
+
"componentId": "${props.id}",
|
|
12749
|
+
"actionType": "setValue",
|
|
12750
|
+
"args": {
|
|
12751
|
+
"value": lastestFieldValue
|
|
12752
|
+
}
|
|
12753
|
+
});
|
|
12754
|
+
}
|
|
12706
12755
|
event.data.__tableItems.forEach(function(n,i){
|
|
12707
12756
|
event.data.__tableItems[i] = lastestFieldValue[i];
|
|
12708
12757
|
});
|
|
@@ -12766,7 +12815,8 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
12766
12815
|
"canAccessSuperData": false,
|
|
12767
12816
|
"className": "steedos-object-form steedos-amis-form"
|
|
12768
12817
|
};
|
|
12769
|
-
if (mode === "edit") {
|
|
12818
|
+
if (mode === "edit" || mode === "new") {
|
|
12819
|
+
// 新增行弹出编辑行表单,在弹出之前已经不用先增加一行,因为在翻页service初始化的时候会判断mode为new时自动新增一行
|
|
12770
12820
|
let onEditItemSubmitScript = `
|
|
12771
12821
|
// let fieldValue = _.cloneDeep(event.data["${props.name}"]);
|
|
12772
12822
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
@@ -12805,66 +12855,66 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
12805
12855
|
}
|
|
12806
12856
|
});
|
|
12807
12857
|
}
|
|
12808
|
-
else if (mode === "new") {
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12812
|
-
|
|
12813
|
-
|
|
12814
|
-
|
|
12815
|
-
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
|
|
12827
|
-
|
|
12828
|
-
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
}
|
|
12858
|
+
// else if (mode === "new") {
|
|
12859
|
+
// let onNewItemSubmitScript = `
|
|
12860
|
+
// let newItem = JSON.parse(JSON.stringify(event.data));
|
|
12861
|
+
// if(event.data["${props.name}"]){
|
|
12862
|
+
// // let fieldValue = event.data.__tableItems;
|
|
12863
|
+
// // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
12864
|
+
// let fieldValue = event.data["${props.name}"];
|
|
12865
|
+
// fieldValue.push(newItem);
|
|
12866
|
+
// doAction({
|
|
12867
|
+
// "componentId": "${props.id}",
|
|
12868
|
+
// "actionType": "setValue",
|
|
12869
|
+
// "args": {
|
|
12870
|
+
// "value": fieldValue
|
|
12871
|
+
// }
|
|
12872
|
+
// });
|
|
12873
|
+
// }
|
|
12874
|
+
// else{
|
|
12875
|
+
// // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
|
|
12876
|
+
// doAction({
|
|
12877
|
+
// "componentId": "${props.id}",
|
|
12878
|
+
// "actionType": "setValue",
|
|
12879
|
+
// "args": {
|
|
12880
|
+
// "value": [newItem]
|
|
12881
|
+
// }
|
|
12882
|
+
// });
|
|
12883
|
+
// }
|
|
12884
|
+
// `;
|
|
12885
|
+
// Object.assign(schema, {
|
|
12886
|
+
// "onEvent": {
|
|
12887
|
+
// "submit": {
|
|
12888
|
+
// "weight": 0,
|
|
12889
|
+
// "actions": [
|
|
12890
|
+
// {
|
|
12891
|
+
// "actionType": "custom",
|
|
12892
|
+
// "script": onNewItemSubmitScript
|
|
12893
|
+
// },
|
|
12894
|
+
// // {
|
|
12895
|
+
// // "componentId": props.id,
|
|
12896
|
+
// // "actionType": "addItem",//input-table组件的needConfirm属性为true时,addItem动作会把新加的行显示为编辑状态,所以只能使用上面的custom script来setValue实现添加行
|
|
12897
|
+
// // "args": {
|
|
12898
|
+
// // "index": `\${${props.name}.length || 9000}`,//这里加9000是因为字段如果没放在form组件内,props.name.length拿不到值
|
|
12899
|
+
// // "item": {
|
|
12900
|
+
// // "&": "$$"
|
|
12901
|
+
// // }
|
|
12902
|
+
// // }
|
|
12903
|
+
// // }
|
|
12904
|
+
// ]
|
|
12905
|
+
// }
|
|
12906
|
+
// }
|
|
12907
|
+
// });
|
|
12908
|
+
// }
|
|
12859
12909
|
schema = getFormPaginationWrapper(props, schema, mode);
|
|
12860
12910
|
return schema;
|
|
12861
12911
|
}
|
|
12862
12912
|
|
|
12863
12913
|
|
|
12864
12914
|
/**
|
|
12865
|
-
*
|
|
12915
|
+
* 编辑、新增、删除、查看按钮actions
|
|
12866
12916
|
* @param {*} props
|
|
12867
|
-
* @param {*} mode edit/new/readonly
|
|
12917
|
+
* @param {*} mode edit/new/readonly/delete
|
|
12868
12918
|
*/
|
|
12869
12919
|
async function getButtonActions(props, mode) {
|
|
12870
12920
|
let actions = [];
|
|
@@ -12955,6 +13005,7 @@ async function getButtonActions(props, mode) {
|
|
|
12955
13005
|
}
|
|
12956
13006
|
];
|
|
12957
13007
|
if(props.addable){
|
|
13008
|
+
// 有新增行权限时额外添加新增和复制按钮
|
|
12958
13009
|
dialogButtons = [
|
|
12959
13010
|
{
|
|
12960
13011
|
"type": "button",
|
|
@@ -13019,7 +13070,8 @@ async function getButtonActions(props, mode) {
|
|
|
13019
13070
|
// "__tableItems": `\${${props.name}}`
|
|
13020
13071
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13021
13072
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13022
|
-
"__tableItems": `\${${props.name}|json|toJson}`
|
|
13073
|
+
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13074
|
+
"__tableItems": `\${(${props.name} || [])|json|toJson}`
|
|
13023
13075
|
},
|
|
13024
13076
|
"actions": dialogButtons,
|
|
13025
13077
|
"onEvent": {
|
|
@@ -13042,11 +13094,12 @@ async function getButtonActions(props, mode) {
|
|
|
13042
13094
|
Object.assign(actionShowEditDialog.dialog, props.dialog);
|
|
13043
13095
|
}
|
|
13044
13096
|
if (mode == "new") {
|
|
13045
|
-
|
|
13097
|
+
`
|
|
13046
13098
|
let newItem = {};
|
|
13047
13099
|
if(event.data["${props.name}"]){
|
|
13048
13100
|
// let fieldValue = event.data.__tableItems;
|
|
13049
13101
|
// 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
13102
|
+
// let fieldValue = _.clone(event.data["${props.name}"]);
|
|
13050
13103
|
let fieldValue = event.data["${props.name}"];
|
|
13051
13104
|
fieldValue.push(newItem);
|
|
13052
13105
|
doAction({
|
|
@@ -13070,11 +13123,9 @@ async function getButtonActions(props, mode) {
|
|
|
13070
13123
|
event.data.index = 1;
|
|
13071
13124
|
}
|
|
13072
13125
|
`;
|
|
13073
|
-
|
|
13074
|
-
|
|
13075
|
-
|
|
13076
|
-
};
|
|
13077
|
-
actions = [actionNewLine, actionShowEditDialog];
|
|
13126
|
+
// 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
|
|
13127
|
+
// actions = [actionNewLine, actionShowEditDialog];
|
|
13128
|
+
actions = [actionShowEditDialog];
|
|
13078
13129
|
}
|
|
13079
13130
|
else if (mode == "edit") {
|
|
13080
13131
|
actions = [actionShowEditDialog];
|
|
@@ -13112,9 +13163,44 @@ async function getButtonActions(props, mode) {
|
|
|
13112
13163
|
// "__tableItems": `\${${props.name}}`
|
|
13113
13164
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13114
13165
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13115
|
-
"__tableItems": `\${${props.name}|json|toJson}`
|
|
13116
|
-
|
|
13166
|
+
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13167
|
+
"__tableItems": `\${(${props.name} || [])|json|toJson}`
|
|
13168
|
+
},
|
|
13169
|
+
}
|
|
13170
|
+
}
|
|
13171
|
+
];
|
|
13172
|
+
}
|
|
13173
|
+
else if (mode == "delete") {
|
|
13174
|
+
let tableServiceId = getComponentId("table_service", props.id);
|
|
13175
|
+
let onDeleteItemScript = `
|
|
13176
|
+
// let fieldValue = event.data["${props.name}"];
|
|
13177
|
+
let scope = event.context.scoped;
|
|
13178
|
+
let __wrapperServiceId = "${tableServiceId}";
|
|
13179
|
+
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
13180
|
+
let wrapperServiceData = wrapperService.getData();
|
|
13181
|
+
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13182
|
+
// 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
|
|
13183
|
+
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
|
|
13184
|
+
lastestFieldValue.splice(event.data.index, 1);
|
|
13185
|
+
doAction({
|
|
13186
|
+
"componentId": "${props.id}",
|
|
13187
|
+
"actionType": "setValue",
|
|
13188
|
+
"args": {
|
|
13189
|
+
"value": lastestFieldValue
|
|
13117
13190
|
}
|
|
13191
|
+
});
|
|
13192
|
+
`;
|
|
13193
|
+
actions = [
|
|
13194
|
+
// {
|
|
13195
|
+
// "actionType": "deleteItem",
|
|
13196
|
+
// "args": {
|
|
13197
|
+
// "index": "${index+','}" //这里不加逗号后续会报错,语法是逗号分隔可以删除多行
|
|
13198
|
+
// },
|
|
13199
|
+
// "componentId": props.id
|
|
13200
|
+
// },
|
|
13201
|
+
{
|
|
13202
|
+
"actionType": "custom",
|
|
13203
|
+
"script": onDeleteItemScript
|
|
13118
13204
|
}
|
|
13119
13205
|
];
|
|
13120
13206
|
}
|
|
@@ -13163,24 +13249,7 @@ async function getButtonView(props) {
|
|
|
13163
13249
|
};
|
|
13164
13250
|
}
|
|
13165
13251
|
|
|
13166
|
-
function getButtonDelete(props) {
|
|
13167
|
-
let tableServiceId = getComponentId("table_service", props.id);
|
|
13168
|
-
let onDeleteItemScript = `
|
|
13169
|
-
// let fieldValue = event.data["${props.name}"];
|
|
13170
|
-
let scope = event.context.scoped;
|
|
13171
|
-
let __wrapperServiceId = "${tableServiceId}";
|
|
13172
|
-
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
13173
|
-
let wrapperServiceData = wrapperService.getData();
|
|
13174
|
-
let lastestFieldValue = wrapperServiceData["${props.name}"];//这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13175
|
-
lastestFieldValue.splice(event.data.index, 1);
|
|
13176
|
-
doAction({
|
|
13177
|
-
"componentId": "${props.id}",
|
|
13178
|
-
"actionType": "setValue",
|
|
13179
|
-
"args": {
|
|
13180
|
-
"value": lastestFieldValue
|
|
13181
|
-
}
|
|
13182
|
-
});
|
|
13183
|
-
`;
|
|
13252
|
+
async function getButtonDelete(props) {
|
|
13184
13253
|
return {
|
|
13185
13254
|
"type": "button",
|
|
13186
13255
|
"label": "",
|
|
@@ -13188,19 +13257,7 @@ function getButtonDelete(props) {
|
|
|
13188
13257
|
"level": "link",
|
|
13189
13258
|
"onEvent": {
|
|
13190
13259
|
"click": {
|
|
13191
|
-
"actions":
|
|
13192
|
-
// {
|
|
13193
|
-
// "actionType": "deleteItem",
|
|
13194
|
-
// "args": {
|
|
13195
|
-
// "index": "${index+','}" //这里不加逗号后续会报错,语法是逗号分隔可以删除多行
|
|
13196
|
-
// },
|
|
13197
|
-
// "componentId": props.id
|
|
13198
|
-
// },
|
|
13199
|
-
{
|
|
13200
|
-
"actionType": "custom",
|
|
13201
|
-
"script": onDeleteItemScript
|
|
13202
|
-
}
|
|
13203
|
-
]
|
|
13260
|
+
"actions": await getButtonActions(props, "delete")
|
|
13204
13261
|
}
|
|
13205
13262
|
}
|
|
13206
13263
|
};
|
|
@@ -13240,7 +13297,7 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13240
13297
|
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13241
13298
|
}
|
|
13242
13299
|
if (props.removable) {
|
|
13243
|
-
let buttonDeleteSchema = getButtonDelete(props);
|
|
13300
|
+
let buttonDeleteSchema = await getButtonDelete(props);
|
|
13244
13301
|
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13245
13302
|
}
|
|
13246
13303
|
let inputTableSchema = {
|
|
@@ -13267,7 +13324,7 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13267
13324
|
"name": "__op__",
|
|
13268
13325
|
"type": "operation",
|
|
13269
13326
|
"buttons": buttonsForColumnOperations,
|
|
13270
|
-
"width": buttonsForColumnOperations.length > 1 ? "
|
|
13327
|
+
"width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
|
|
13271
13328
|
});
|
|
13272
13329
|
}
|
|
13273
13330
|
if (showAsInlineEditMode) {
|