@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.cjs.js
CHANGED
|
@@ -1653,6 +1653,7 @@ async function getQuickEditSchema(field, options){
|
|
|
1653
1653
|
{
|
|
1654
1654
|
"actionType": "custom",
|
|
1655
1655
|
"script": `
|
|
1656
|
+
|
|
1656
1657
|
var _display = _.cloneDeep(event.data._display);
|
|
1657
1658
|
${displayField}
|
|
1658
1659
|
doAction({actionType: 'setValue', "args": {"value": {_display}},componentId: "${quickEditId}"});
|
|
@@ -1824,7 +1825,7 @@ async function getQuickEditSchema(field, options){
|
|
|
1824
1825
|
"actions":[
|
|
1825
1826
|
{
|
|
1826
1827
|
"actionType": "setValue",
|
|
1827
|
-
"componentId":
|
|
1828
|
+
"componentId": quickEditId,
|
|
1828
1829
|
"args": {
|
|
1829
1830
|
"value":{
|
|
1830
1831
|
"quickedit_record_permissions_loading": true
|
|
@@ -1849,7 +1850,7 @@ async function getQuickEditSchema(field, options){
|
|
|
1849
1850
|
},
|
|
1850
1851
|
{
|
|
1851
1852
|
"actionType": "setValue",
|
|
1852
|
-
"componentId":
|
|
1853
|
+
"componentId": quickEditId,
|
|
1853
1854
|
"args": {
|
|
1854
1855
|
"value":{
|
|
1855
1856
|
"quickedit_record_permissions_loading": false
|
|
@@ -1858,7 +1859,7 @@ async function getQuickEditSchema(field, options){
|
|
|
1858
1859
|
},
|
|
1859
1860
|
{
|
|
1860
1861
|
"actionType": "setValue",
|
|
1861
|
-
"componentId":
|
|
1862
|
+
"componentId": quickEditId,
|
|
1862
1863
|
"args": {
|
|
1863
1864
|
"value":{
|
|
1864
1865
|
"quickedit_record_permissions": "${event.data}"
|
|
@@ -2037,9 +2038,9 @@ function getFieldWidth(width){
|
|
|
2037
2038
|
async function getTableColumns(fields, options){
|
|
2038
2039
|
const columns = [];
|
|
2039
2040
|
if(!options.isLookup && !options.isInputTable){
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2041
|
+
if(!options.enable_tree){
|
|
2042
|
+
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
|
|
2043
|
+
}
|
|
2043
2044
|
}
|
|
2044
2045
|
const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;
|
|
2045
2046
|
|
|
@@ -2581,6 +2582,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2581
2582
|
if(!isLookup && !hiddenColumnOperation){
|
|
2582
2583
|
columns.push(await getTableOperation(options));
|
|
2583
2584
|
}
|
|
2585
|
+
|
|
2584
2586
|
}
|
|
2585
2587
|
|
|
2586
2588
|
return {
|
|
@@ -2890,7 +2892,21 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2890
2892
|
|
|
2891
2893
|
if(enable_tree){
|
|
2892
2894
|
const records = payload.data.rows || [];
|
|
2893
|
-
const getTreeOptions = SteedosUI.getTreeOptions
|
|
2895
|
+
const getTreeOptions = SteedosUI.getTreeOptions;
|
|
2896
|
+
const assignIndexToTreeRecords = function(tree, parentIndex) {
|
|
2897
|
+
tree.forEach(function (node, index) {
|
|
2898
|
+
// 构建当前节点的 _index
|
|
2899
|
+
var currentIndex = parentIndex ? parentIndex + '-' + (index + 1) : '' + (index + 1);
|
|
2900
|
+
|
|
2901
|
+
// 赋值给节点
|
|
2902
|
+
node._index = currentIndex;
|
|
2903
|
+
|
|
2904
|
+
// 如果有子节点,递归调用函数
|
|
2905
|
+
if (node.children && node.children.length > 0) {
|
|
2906
|
+
assignIndexToTreeRecords(node.children, currentIndex);
|
|
2907
|
+
}
|
|
2908
|
+
});
|
|
2909
|
+
};
|
|
2894
2910
|
let isTreeOptionsComputed = false;
|
|
2895
2911
|
if(records.length === 1 && records[0].children){
|
|
2896
2912
|
isTreeOptionsComputed = true;
|
|
@@ -2898,6 +2914,7 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2898
2914
|
if(!isTreeOptionsComputed){
|
|
2899
2915
|
// 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
|
|
2900
2916
|
payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
|
|
2917
|
+
assignIndexToTreeRecords(payload.data.rows, '');
|
|
2901
2918
|
}
|
|
2902
2919
|
try{
|
|
2903
2920
|
setTimeout(() => {
|
|
@@ -3674,6 +3691,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
3674
3691
|
"dialog": {
|
|
3675
3692
|
"type": "dialog",
|
|
3676
3693
|
"title": title,
|
|
3694
|
+
data,
|
|
3677
3695
|
"body": [
|
|
3678
3696
|
{
|
|
3679
3697
|
"type": "steedos-object-form",
|
|
@@ -8254,7 +8272,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8254
8272
|
let tableOptions = Object.assign({
|
|
8255
8273
|
idFieldName: objectSchema.idFieldName, labelFieldName: labelFieldName,
|
|
8256
8274
|
permissions:objectSchema.permissions,enable_inline_edit:objectSchema.enable_inline_edit,
|
|
8257
|
-
crudId: listSchema.id || id
|
|
8275
|
+
crudId: listSchema.id || id, enable_tree: objectSchema.enable_tree
|
|
8258
8276
|
}, options);
|
|
8259
8277
|
tableOptions.amisData = createObject(options.amisData || {}, {});
|
|
8260
8278
|
const table = await getTableSchema$1(fields, tableOptions);
|
|
@@ -8346,6 +8364,11 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8346
8364
|
crudModeClassName = `steedos-crud-mode-${body.mode}`;
|
|
8347
8365
|
}
|
|
8348
8366
|
|
|
8367
|
+
if(body.columns && options.formFactor != 'SMALL'){
|
|
8368
|
+
//将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
8369
|
+
body.columns.splice(body.columns.length - 1, 0, {name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
|
|
8370
|
+
}
|
|
8371
|
+
|
|
8349
8372
|
if (defaults) {
|
|
8350
8373
|
const headerSchema = defaults.headerSchema;
|
|
8351
8374
|
const footerSchema = defaults.footerSchema;
|
|
@@ -8370,6 +8393,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8370
8393
|
body = wrappedBody;
|
|
8371
8394
|
}
|
|
8372
8395
|
}
|
|
8396
|
+
|
|
8373
8397
|
// console.timeEnd('getObjectCRUD');
|
|
8374
8398
|
// TODO: data应该只留loaded,其他属性都改为从上层传递下来
|
|
8375
8399
|
return {
|
|
@@ -10572,6 +10596,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10572
10596
|
*/
|
|
10573
10597
|
return payload;
|
|
10574
10598
|
}
|
|
10599
|
+
if(!payload.data.rows){
|
|
10600
|
+
payload.data.rows = [];
|
|
10601
|
+
}
|
|
10575
10602
|
if(enable_tree){
|
|
10576
10603
|
const records = payload.data.rows;
|
|
10577
10604
|
const treeRecords = [];
|
|
@@ -12441,7 +12468,7 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12441
12468
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12442
12469
|
* @Date: 2023-11-15 09:50:22
|
|
12443
12470
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12444
|
-
* @LastEditTime: 2023-12-
|
|
12471
|
+
* @LastEditTime: 2023-12-27 13:50:26
|
|
12445
12472
|
*/
|
|
12446
12473
|
|
|
12447
12474
|
/**
|
|
@@ -12469,20 +12496,22 @@ function getInputTableCell(field, showAsInlineEditMode) {
|
|
|
12469
12496
|
name: field.name,
|
|
12470
12497
|
quickEdit: {
|
|
12471
12498
|
"type": "steedos-field",
|
|
12472
|
-
"config": field,
|
|
12473
|
-
|
|
12499
|
+
"config": Object.assign({}, field, {
|
|
12500
|
+
label: false
|
|
12501
|
+
})
|
|
12474
12502
|
}
|
|
12475
12503
|
}
|
|
12476
12504
|
}
|
|
12477
12505
|
else {
|
|
12478
12506
|
return {
|
|
12479
12507
|
"type": "steedos-field",
|
|
12480
|
-
"config": field,
|
|
12508
|
+
"config": Object.assign({}, field, {
|
|
12509
|
+
label: false
|
|
12510
|
+
}),
|
|
12481
12511
|
"static": true,
|
|
12482
12512
|
"readonly": true,
|
|
12483
12513
|
label: field.label,
|
|
12484
|
-
name: field.name
|
|
12485
|
-
hideLabel: true
|
|
12514
|
+
name: field.name
|
|
12486
12515
|
}
|
|
12487
12516
|
}
|
|
12488
12517
|
}
|
|
@@ -12688,7 +12717,7 @@ function getFormPagination(props, mode) {
|
|
|
12688
12717
|
* @returns 带翻页容器的wrapper
|
|
12689
12718
|
*/
|
|
12690
12719
|
function getFormPaginationWrapper(props, form, mode) {
|
|
12691
|
-
console.log("==getFormPaginationWrapper===", props, mode);
|
|
12720
|
+
// console.log("==getFormPaginationWrapper===", props, mode);
|
|
12692
12721
|
let serviceId = getComponentId("form_pagination", props.id);
|
|
12693
12722
|
let tableServiceId = getComponentId("table_service", props.id);
|
|
12694
12723
|
let innerForm = Object.assign({}, form, {
|
|
@@ -12728,8 +12757,28 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12728
12757
|
let __wrapperServiceId = "${tableServiceId}";
|
|
12729
12758
|
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
12730
12759
|
let wrapperServiceData = wrapperService.getData();
|
|
12731
|
-
|
|
12760
|
+
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12761
|
+
// 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
|
|
12762
|
+
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
|
|
12732
12763
|
//不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
|
|
12764
|
+
let mode = "${mode}";
|
|
12765
|
+
if(mode === "new"){
|
|
12766
|
+
// 点击子表组件底部新增按钮时新增一条空白行并自动翻页到新增行
|
|
12767
|
+
// 注意点击弹出的子表行详细表单中的新增按钮不会进此service init事件函数中
|
|
12768
|
+
let newItem = {};
|
|
12769
|
+
event.data.__tableItems.push(newItem);
|
|
12770
|
+
lastestFieldValue.push(newItem);
|
|
12771
|
+
event.data.index = lastestFieldValue.length - 1;
|
|
12772
|
+
event.data.__page = lastestFieldValue.length;
|
|
12773
|
+
// 这里新增空白行时要把值同步保存到子表组件中,如果不同步保存的话,用户点击弹出表单右上角的关闭窗口时不会自动删除这里自动增加的空白行,同步后可以让用户手动删除此行
|
|
12774
|
+
doAction({
|
|
12775
|
+
"componentId": "${props.id}",
|
|
12776
|
+
"actionType": "setValue",
|
|
12777
|
+
"args": {
|
|
12778
|
+
"value": lastestFieldValue
|
|
12779
|
+
}
|
|
12780
|
+
});
|
|
12781
|
+
}
|
|
12733
12782
|
event.data.__tableItems.forEach(function(n,i){
|
|
12734
12783
|
event.data.__tableItems[i] = lastestFieldValue[i];
|
|
12735
12784
|
});
|
|
@@ -12793,7 +12842,8 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
12793
12842
|
"canAccessSuperData": false,
|
|
12794
12843
|
"className": "steedos-object-form steedos-amis-form"
|
|
12795
12844
|
};
|
|
12796
|
-
if (mode === "edit") {
|
|
12845
|
+
if (mode === "edit" || mode === "new") {
|
|
12846
|
+
// 新增行弹出编辑行表单,在弹出之前已经不用先增加一行,因为在翻页service初始化的时候会判断mode为new时自动新增一行
|
|
12797
12847
|
let onEditItemSubmitScript = `
|
|
12798
12848
|
// let fieldValue = _.cloneDeep(event.data["${props.name}"]);
|
|
12799
12849
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
@@ -12832,66 +12882,66 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
12832
12882
|
}
|
|
12833
12883
|
});
|
|
12834
12884
|
}
|
|
12835
|
-
else if (mode === "new") {
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12860
|
-
|
|
12861
|
-
|
|
12862
|
-
|
|
12863
|
-
|
|
12864
|
-
|
|
12865
|
-
|
|
12866
|
-
|
|
12867
|
-
|
|
12868
|
-
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
-
|
|
12885
|
-
}
|
|
12885
|
+
// else if (mode === "new") {
|
|
12886
|
+
// let onNewItemSubmitScript = `
|
|
12887
|
+
// let newItem = JSON.parse(JSON.stringify(event.data));
|
|
12888
|
+
// if(event.data["${props.name}"]){
|
|
12889
|
+
// // let fieldValue = event.data.__tableItems;
|
|
12890
|
+
// // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
12891
|
+
// let fieldValue = event.data["${props.name}"];
|
|
12892
|
+
// fieldValue.push(newItem);
|
|
12893
|
+
// doAction({
|
|
12894
|
+
// "componentId": "${props.id}",
|
|
12895
|
+
// "actionType": "setValue",
|
|
12896
|
+
// "args": {
|
|
12897
|
+
// "value": fieldValue
|
|
12898
|
+
// }
|
|
12899
|
+
// });
|
|
12900
|
+
// }
|
|
12901
|
+
// else{
|
|
12902
|
+
// // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
|
|
12903
|
+
// doAction({
|
|
12904
|
+
// "componentId": "${props.id}",
|
|
12905
|
+
// "actionType": "setValue",
|
|
12906
|
+
// "args": {
|
|
12907
|
+
// "value": [newItem]
|
|
12908
|
+
// }
|
|
12909
|
+
// });
|
|
12910
|
+
// }
|
|
12911
|
+
// `;
|
|
12912
|
+
// Object.assign(schema, {
|
|
12913
|
+
// "onEvent": {
|
|
12914
|
+
// "submit": {
|
|
12915
|
+
// "weight": 0,
|
|
12916
|
+
// "actions": [
|
|
12917
|
+
// {
|
|
12918
|
+
// "actionType": "custom",
|
|
12919
|
+
// "script": onNewItemSubmitScript
|
|
12920
|
+
// },
|
|
12921
|
+
// // {
|
|
12922
|
+
// // "componentId": props.id,
|
|
12923
|
+
// // "actionType": "addItem",//input-table组件的needConfirm属性为true时,addItem动作会把新加的行显示为编辑状态,所以只能使用上面的custom script来setValue实现添加行
|
|
12924
|
+
// // "args": {
|
|
12925
|
+
// // "index": `\${${props.name}.length || 9000}`,//这里加9000是因为字段如果没放在form组件内,props.name.length拿不到值
|
|
12926
|
+
// // "item": {
|
|
12927
|
+
// // "&": "$$"
|
|
12928
|
+
// // }
|
|
12929
|
+
// // }
|
|
12930
|
+
// // }
|
|
12931
|
+
// ]
|
|
12932
|
+
// }
|
|
12933
|
+
// }
|
|
12934
|
+
// });
|
|
12935
|
+
// }
|
|
12886
12936
|
schema = getFormPaginationWrapper(props, schema, mode);
|
|
12887
12937
|
return schema;
|
|
12888
12938
|
}
|
|
12889
12939
|
|
|
12890
12940
|
|
|
12891
12941
|
/**
|
|
12892
|
-
*
|
|
12942
|
+
* 编辑、新增、删除、查看按钮actions
|
|
12893
12943
|
* @param {*} props
|
|
12894
|
-
* @param {*} mode edit/new/readonly
|
|
12944
|
+
* @param {*} mode edit/new/readonly/delete
|
|
12895
12945
|
*/
|
|
12896
12946
|
async function getButtonActions(props, mode) {
|
|
12897
12947
|
let actions = [];
|
|
@@ -12982,6 +13032,7 @@ async function getButtonActions(props, mode) {
|
|
|
12982
13032
|
}
|
|
12983
13033
|
];
|
|
12984
13034
|
if(props.addable){
|
|
13035
|
+
// 有新增行权限时额外添加新增和复制按钮
|
|
12985
13036
|
dialogButtons = [
|
|
12986
13037
|
{
|
|
12987
13038
|
"type": "button",
|
|
@@ -13046,7 +13097,8 @@ async function getButtonActions(props, mode) {
|
|
|
13046
13097
|
// "__tableItems": `\${${props.name}}`
|
|
13047
13098
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13048
13099
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13049
|
-
"__tableItems": `\${${props.name}|json|toJson}`
|
|
13100
|
+
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13101
|
+
"__tableItems": `\${(${props.name} || [])|json|toJson}`
|
|
13050
13102
|
},
|
|
13051
13103
|
"actions": dialogButtons,
|
|
13052
13104
|
"onEvent": {
|
|
@@ -13069,11 +13121,12 @@ async function getButtonActions(props, mode) {
|
|
|
13069
13121
|
Object.assign(actionShowEditDialog.dialog, props.dialog);
|
|
13070
13122
|
}
|
|
13071
13123
|
if (mode == "new") {
|
|
13072
|
-
|
|
13124
|
+
`
|
|
13073
13125
|
let newItem = {};
|
|
13074
13126
|
if(event.data["${props.name}"]){
|
|
13075
13127
|
// let fieldValue = event.data.__tableItems;
|
|
13076
13128
|
// 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
13129
|
+
// let fieldValue = _.clone(event.data["${props.name}"]);
|
|
13077
13130
|
let fieldValue = event.data["${props.name}"];
|
|
13078
13131
|
fieldValue.push(newItem);
|
|
13079
13132
|
doAction({
|
|
@@ -13097,11 +13150,9 @@ async function getButtonActions(props, mode) {
|
|
|
13097
13150
|
event.data.index = 1;
|
|
13098
13151
|
}
|
|
13099
13152
|
`;
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
};
|
|
13104
|
-
actions = [actionNewLine, actionShowEditDialog];
|
|
13153
|
+
// 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
|
|
13154
|
+
// actions = [actionNewLine, actionShowEditDialog];
|
|
13155
|
+
actions = [actionShowEditDialog];
|
|
13105
13156
|
}
|
|
13106
13157
|
else if (mode == "edit") {
|
|
13107
13158
|
actions = [actionShowEditDialog];
|
|
@@ -13139,9 +13190,44 @@ async function getButtonActions(props, mode) {
|
|
|
13139
13190
|
// "__tableItems": `\${${props.name}}`
|
|
13140
13191
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13141
13192
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13142
|
-
"__tableItems": `\${${props.name}|json|toJson}`
|
|
13143
|
-
|
|
13193
|
+
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13194
|
+
"__tableItems": `\${(${props.name} || [])|json|toJson}`
|
|
13195
|
+
},
|
|
13196
|
+
}
|
|
13197
|
+
}
|
|
13198
|
+
];
|
|
13199
|
+
}
|
|
13200
|
+
else if (mode == "delete") {
|
|
13201
|
+
let tableServiceId = getComponentId("table_service", props.id);
|
|
13202
|
+
let onDeleteItemScript = `
|
|
13203
|
+
// let fieldValue = event.data["${props.name}"];
|
|
13204
|
+
let scope = event.context.scoped;
|
|
13205
|
+
let __wrapperServiceId = "${tableServiceId}";
|
|
13206
|
+
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
13207
|
+
let wrapperServiceData = wrapperService.getData();
|
|
13208
|
+
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13209
|
+
// 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
|
|
13210
|
+
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
|
|
13211
|
+
lastestFieldValue.splice(event.data.index, 1);
|
|
13212
|
+
doAction({
|
|
13213
|
+
"componentId": "${props.id}",
|
|
13214
|
+
"actionType": "setValue",
|
|
13215
|
+
"args": {
|
|
13216
|
+
"value": lastestFieldValue
|
|
13144
13217
|
}
|
|
13218
|
+
});
|
|
13219
|
+
`;
|
|
13220
|
+
actions = [
|
|
13221
|
+
// {
|
|
13222
|
+
// "actionType": "deleteItem",
|
|
13223
|
+
// "args": {
|
|
13224
|
+
// "index": "${index+','}" //这里不加逗号后续会报错,语法是逗号分隔可以删除多行
|
|
13225
|
+
// },
|
|
13226
|
+
// "componentId": props.id
|
|
13227
|
+
// },
|
|
13228
|
+
{
|
|
13229
|
+
"actionType": "custom",
|
|
13230
|
+
"script": onDeleteItemScript
|
|
13145
13231
|
}
|
|
13146
13232
|
];
|
|
13147
13233
|
}
|
|
@@ -13190,24 +13276,7 @@ async function getButtonView(props) {
|
|
|
13190
13276
|
};
|
|
13191
13277
|
}
|
|
13192
13278
|
|
|
13193
|
-
function getButtonDelete(props) {
|
|
13194
|
-
let tableServiceId = getComponentId("table_service", props.id);
|
|
13195
|
-
let onDeleteItemScript = `
|
|
13196
|
-
// let fieldValue = event.data["${props.name}"];
|
|
13197
|
-
let scope = event.context.scoped;
|
|
13198
|
-
let __wrapperServiceId = "${tableServiceId}";
|
|
13199
|
-
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
13200
|
-
let wrapperServiceData = wrapperService.getData();
|
|
13201
|
-
let lastestFieldValue = wrapperServiceData["${props.name}"];//这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13202
|
-
lastestFieldValue.splice(event.data.index, 1);
|
|
13203
|
-
doAction({
|
|
13204
|
-
"componentId": "${props.id}",
|
|
13205
|
-
"actionType": "setValue",
|
|
13206
|
-
"args": {
|
|
13207
|
-
"value": lastestFieldValue
|
|
13208
|
-
}
|
|
13209
|
-
});
|
|
13210
|
-
`;
|
|
13279
|
+
async function getButtonDelete(props) {
|
|
13211
13280
|
return {
|
|
13212
13281
|
"type": "button",
|
|
13213
13282
|
"label": "",
|
|
@@ -13215,19 +13284,7 @@ function getButtonDelete(props) {
|
|
|
13215
13284
|
"level": "link",
|
|
13216
13285
|
"onEvent": {
|
|
13217
13286
|
"click": {
|
|
13218
|
-
"actions":
|
|
13219
|
-
// {
|
|
13220
|
-
// "actionType": "deleteItem",
|
|
13221
|
-
// "args": {
|
|
13222
|
-
// "index": "${index+','}" //这里不加逗号后续会报错,语法是逗号分隔可以删除多行
|
|
13223
|
-
// },
|
|
13224
|
-
// "componentId": props.id
|
|
13225
|
-
// },
|
|
13226
|
-
{
|
|
13227
|
-
"actionType": "custom",
|
|
13228
|
-
"script": onDeleteItemScript
|
|
13229
|
-
}
|
|
13230
|
-
]
|
|
13287
|
+
"actions": await getButtonActions(props, "delete")
|
|
13231
13288
|
}
|
|
13232
13289
|
}
|
|
13233
13290
|
};
|
|
@@ -13267,7 +13324,7 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13267
13324
|
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13268
13325
|
}
|
|
13269
13326
|
if (props.removable) {
|
|
13270
|
-
let buttonDeleteSchema = getButtonDelete(props);
|
|
13327
|
+
let buttonDeleteSchema = await getButtonDelete(props);
|
|
13271
13328
|
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13272
13329
|
}
|
|
13273
13330
|
let inputTableSchema = {
|
|
@@ -13294,7 +13351,7 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13294
13351
|
"name": "__op__",
|
|
13295
13352
|
"type": "operation",
|
|
13296
13353
|
"buttons": buttonsForColumnOperations,
|
|
13297
|
-
"width": buttonsForColumnOperations.length > 1 ? "
|
|
13354
|
+
"width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
|
|
13298
13355
|
});
|
|
13299
13356
|
}
|
|
13300
13357
|
if (showAsInlineEditMode) {
|