使用自定义事件修改/检查表数据
事件配置
json
{
"type": "page",
"body": {
"type": "form",
"api": "/amis/api/mock2/form/saveForm",
"data": {
"table": [
{
"id": 1,
"a": "a1",
"b": "b1"
}
]
},
"body": [
{
"showIndex": true,
"type": "input-table",
"name": "table",
"columns": [
{
"name": "a",
"label": "A"
},
{
"name": "b",
"label": "B"
}
],
"addable": true,
"onEvent": {
"change": {
"actions": [
{
"actionType": "custom",
"script": "debugger;"
},
{
"actionType": "toast",
"args": {
"msgType": "info",
"position": "top-right",
"title": "change事件",
"msg": "value: ${event.data.value | json}"
}
}
]
}
}
}
]
}
}
具体脚本:
js
let newItems = JSON.parse(JSON.stringify(event.data.InvPurchaseItems));
newItems.forEach(function (item) {
if (item.InStockQty < item.PurchaseQty) {
item.InStockQty = item.PurchaseQty;
}
});
doAction({
actionType: 'setValue',
componentId: 'inputtable',
args: {
value: newItems,
},
});