amis 使用自定义js给表格编辑框组件赋值只能执行一次,第二次不生效

oo7oh9g9  于 3个月前  发布在  其他
关注(0)|答案(1)|浏览(49)
描述问题:

按钮上添加了自定义事件,给表格编辑框赋值,使用了setValue事件

截图或视频:

如何复现(请务必完整填写下面内容):
  1. 你是如何使用 amis 的?
    sdk
  2. amis 版本是什么?请先在最新 beta 版本测试问题是否存在
    6.0, 最新版本中也有问题
  3. 粘贴有问题的完整 amis schema 代码:
    {
    "type": "form",
    "title": "",
    "canAccessSuperData": false,
    "mode": "horizontal",
    "staticOn": "${_id&&isEdit!= '1'}",
    "wrapWithPanel": false,
    "body": [
    {
    "type": "grid",
    "columns": [
    {
    "body": [
    {
    "type": "input-text",
    "label": "利率表",
    "name": "changeElementCd",
    "required": false,
    "id": "u:hybf82bba68d42"
    }
    ],
    "id": "u:a65f65f900523"
    },
    {
    "body": [
    {
    "type": "button",
    "label": "重置计划测试",
    "btnDescription": "",
    "onEvent": {
    "click": {
    "actions": [
    {
    "actionType": "custom",
    "script": "/* 自定义JS使用说明:\n * 1.动作执行函数doAction,可以执行所有类型的动作\n * 2.通过上下文对象context可以获取当前组件实例,例如context.props可以获取该组件相关属性\n * 3.事件对象event,在doAction之后执行event.stopPropagation();可以阻止后续动作执行\n*/\nlet _list = context.props.data.affIntResetTrxVos || [];\n_list.map(item => {\n item.elementCd = context.props.data.changeElementCd\n})\nconsole.log('_list',_list)\ndoAction({\n actionType: 'setValue',\n componentId: "u:b3abe5b70bef111",\n args: {\n value: _list\n }\n});\n"
    }
    ]
    }
    },
    "id": "u:m9194592db054",
    "mode": "all",
    "level": "danger"
    }
    ],
    "id": "u:m90df8c9222b3"
    },
    {
    "body": [
    {
    "type": "hidden",
    "name": "affIntResetTrxVos",
    "id": "u:hy6f1ec080f824",
    "value": "${[{intRt:'88888'},{intRt:'444444'},{intRt:'5555555'}]}"
    }
    ],
    "id": "u:undefined9312896bd78b"
    }
    ],
    "className": "m-t-sm",
    "id": "u:undefined1adf14a944d5"
    },
    {
    "type": "input-table",
    "columns": [
    {
    "quickEdit": {
    "type": "input-date",
    "name": "effectiveDt",
    "id": "u:zf96d473af236",
    "mode": "popOver"
    },
    "name": "effectiveDt",
    "width": 150,
    "tableCellContentEllipsis": true,
    "className": "white-space-nowrap",
    "label": "重置日期",
    "id": "u:b62288848324",
    "placeholder": "-",
    "type": "date",
    "format": "YYYY-MM-DD",
    "valueFormat": "YYYY-MM-DD"
    },
    {
    "quickEdit": {
    "type": "input-date",
    "name": "periodStartDt",
    "id": "u:gb9860c6b7d0c",
    "mode": "popOver"
    },
    "name": "periodStartDt",
    "width": 150,
    "tableCellContentEllipsis": true,
    "className": "white-space-nowrap",
    "label": "开始日期",
    "id": "u:f41edf27eee9",
    "placeholder": "-",
    "type": "date",
    "valueFormat": "YYYY-MM-DD"
    },
    {
    "quickEdit": {
    "type": "input-date",
    "name": "periodEndDt",
    "id": "u:ce30226885891",
    "mode": "popOver"
    },
    "name": "periodEndDt",
    "width": 150,
    "tableCellContentEllipsis": true,
    "className": "white-space-nowrap",
    "label": "结束日期",
    "id": "u:92705bdaebc1",
    "placeholder": "-",
    "type": "date",
    "valueFormat": "YYYY-MM-DD"
    },
    {
    "quickEdit": {
    "type": "picker",
    "name": "elementCd",
    "id": "u:864e8f7c76af",
    "modalMode": "dialog",
    "pickerSchema": {
    "mode": "table",
    "filter": {
    "id": "form1691378544997",
    "title": "查询条件",
    "body": [
    {
    "columns": [
    {
    "id": "u:e563aaf229f0",
    "body": [
    {
    "strictMode": true,
    "multiple": false,
    "label": "利率编号",
    "type": "combo",
    "addBtn": {
    "size": "sm",
    "level": "primary",
    "icon": "fa fa-plus",
    "label": "新增",
    "id": "u:6feffc8f00fd"
    },
    "mode": "horizontal",
    "addable": false,
    "draggable": false,
    "removable": false,
    "flat": false,
    "name": "elementCd",
    "removableMode": "icon",
    "id": "u:efeac60842ac",
    "items": [
    {
    "modalMode": "dialog",
    "clearable": true,
    "multiple": false,
    "columnClassName": "no-grow w-1/4",
    "select_type": "default",
    "label": "",
    "source": "",
    "type": "select",
    "valueField": "value",
    "searchable": true,
    "required": false,
    "labelField": "label",
    "size": "sm",
    "onEvent": {
    "change": {
    "weight": 0,
    "actions": [
    {
    "args": {
    "value": "${""}"
    },
    "actionType": "setValue",
    "componentId": "u:d414936f00eb",
    "expression": "${!event.data.value}"
    }
    ]
    }
    },
    "name": "operator",
    "options": [
    {
    "label": "等于",
    "value": "eq"
    },
    {
    "label": "包含",
    "value": "like"
    }
    ],
    "id": "u:4ada90013ce2"
    },
    {
    "onEvent": {
    "change": {
    "weight": 0,
    "actions": [
    {
    "args": {
    "value": "${operator ? operator : "eq"}"
    },
    "actionType": "setValue",
    "componentId": "u:4ada90013ce2"
    }
    ]
    }
    },
    "name": "value",
    "label": "",
    "id": "u:d414936f00eb",
    "editorPath": "input.base.default",
    "type": "input-text",
    "value": "",
    "required": false,
    "trimContents": true
    }
    ],
    "syncFields": []
    }
    ]
    },
    {
    "id": "u:c859effe102d",
    "body": [
    {
    "strictMode": true,
    "multiple": false,
    "label": "利率名称",
    "type": "combo",
    "addBtn": {
    "size": "sm",
    "level": "primary",
    "icon": "fa fa-plus",
    "label": "新增",
    "id": "u:a6e861a2425e"
    },
    "mode": "horizontal",
    "addable": false,
    "draggable": false,
    "removable": false,
    "flat": false,
    "name": "elementNm",
    "removableMode": "icon",
    "id": "u:a478475f71ab",
    "items": [
    {
    "modalMode": "dialog",
    "clearable": true,
    "multiple": false,
    "columnClassName": "no-grow w-1/4",
    "select_type": "default",
    "label": "",
    "source": "",
    "type": "select",
    "valueField": "value",
    "searchable": true,
    "required": false,
    "labelField": "label",
    "size": "sm",
    "onEvent": {
    "change": {
    "weight": 0,
    "actions": [
    {
    "args": {
    "value": "${""}"
    },
    "actionType": "setValue",
    "componentId": "u:60c24adf9ff7",
    "expression": "${!event.data.value}"
    }
    ]
    }
    },
    "name": "operator",
    "options": [
    {
    "label": "等于",
    "value": "eq"
    },
    {
    "label": "包含",
    "value": "like"
    }
    ],
    "id": "u:32d7c05e97fe"
    },
    {
    "onEvent": {
    "change": {
    "weight": 0,
    "actions": [
    {
    "args": {
    "value": "${operator ? operator : "eq"}"
    },
    "actionType": "setValue",
    "componentId": "u:32d7c05e97fe"
    }
    ]
    }
    },
    "name": "value",
    "label": "",
    "id": "u:60c24adf9ff7",
    "type": "input-text",
    "required": false,
    "trimContents": true
    }
    ],
    "syncFields": []
    }
    ]
    }
    ],
    "className": "m-t-sm",
    "id": "u:bb8962a2804d",
    "type": "grid"
    }
    ],
    "actions": [
    {
    "buttons": [
    {
    "level": "primary",
    "onEvent": {
    "click": {
    "actions": [
    {
    "args": {},
    "actionType": "submit",
    "componentId": "form1691378544997",
    "outputVar": "responseResult"
    }
    ]
    }
    },
    "className": "className-f386c496e984",
    "label": "查询",
    "id": "u:9e0c149222c5",
    "themeConfig": {},
    "type": "button",
    "btnType": ""
    },
    {
    "actionType": "reset",
    "level": "light",
    "onEvent": {},
    "label": "重置",
    "id": "u:04bc4179582e",
    "type": "reset",
    "btnType": "reset"
    }
    ],
    "id": "u:6ed129bef9bb",
    "type": "button-group"
    }
    ],
    "canAccessSuperData": false
    },
    "filterToGroup": true,
    "pageField": "current",
    "perPageAvailable": [
    10,
    20,
    30
    ],
    "columns": [
    {
    "condition": "eq",
    "name": "elementCd",
    "label": "利率编号",
    "id": "u:19e821e55d22",
    "placeholder": "-",
    "type": "text"
    },
    {
    "condition": "eq",
    "buttons": [],
    "name": "elementNm",
    "label": "利率名称",
    "id": "u:55b5d6d21b07",
    "placeholder": "-",
    "type": "text"
    },
    {
    "condition": "eq",
    "buttons": [],
    "name": "elementRt",
    "label": "基本利率",
    "id": "u:d7bd492d3523",
    "placeholder": "-",
    "type": "text"
    }
    ],
    "messages": {},
    "id": "u:7892593f28fb",
    "perPageField": "size",
    "isInit": "0"
    },
    "strictMode": false,
    "multiple": false,
    "labelTpl": "${elementCd}(${elementNm})",
    "label": "",
    "source": {
    "method": "post",
    "url": "209850102"
    },
    "valueField": "elementCd",
    "required": true,
    "labelField": "elementNm",
    "defaultValueSearch": [
    {
    "value": "${{"operator":"eq","value":elementCd}}",
    "key": "elementCd"
    }
    ],
    "size": "xl",
    "modalClassName": "app-popover",
    "onEvent": {},
    "options": [],
    "disabled": false
    },
    "name": "elementCd",
    "width": 100,
    "tableCellContentEllipsis": true,
    "className": "white-space-nowrap",
    "label": "利率表",
    "id": "u:874533772a4d",
    "placeholder": "-",
    "type": "text"
    },
    {
    "quickEdit": {
    "type": "input-number",
    "name": "intRt",
    "id": "u:x4ff7be8d79f4",
    "keyboard": true,
    "editorPath": "inputNumber.base.base",
    "precision": 8,
    "mode": "popOver"
    },
    "name": "intRt",
    "width": 100,
    "tableCellContentEllipsis": true,
    "className": "white-space-nowrap",
    "label": "利率",
    "id": "u:fd82d878e8507",
    "placeholder": "-",
    "type": "text"
    },
    {
    "quickEdit": {
    "type": "select",
    "name": "spreadType",
    "id": "u:5de17378f967",
    "source": "",
    "select_type": "default",
    "multiple": false,
    "modalMode": "dialog",
    "onEvent": {},
    "label": "",
    "searchable": true,
    "required": true,
    "options": [
    {
    "label": "利差[SP]",
    "value": "SP"
    },
    {
    "label": "百分比[PE]",
    "value": "PE"
    },
    {
    "label": "基点[BP]",
    "value": "BP"
    }
    ]
    },
    "name": "spreadType",
    "width": 100,
    "tableCellContentEllipsis": true,
    "className": "white-space-nowrap",
    "label": "浮动类型",
    "id": "u:g11619b6e8edf",
    "placeholder": "-",
    "type": "text",
    "select_type": "default"
    },
    {
    "quickEdit": {
    "type": "select",
    "name": "updownInd",
    "id": "u:9a0009963fff",
    "modalMode": "dialog",
    "multiple": false,
    "select_type": "default",
    "label": "",
    "source": "",
    "searchable": true,
    "required": true,
    "onEvent": {},
    "options": [
    {
    "label": "上浮[UP]",
    "value": "UP"
    },
    {
    "label": "下浮[DN]",
    "value": "DN"
    }
    ]
    },
    "name": "updownInd",
    "width": 100,
    "tableCellContentEllipsis": true,
    "className": "white-space-nowrap",
    "label": "上浮下浮",
    "id": "u:g8bcd98063d3e",
    "placeholder": "-",
    "type": "text",
    "select_type": "default"
    },
    {
    "quickEdit": {
    "type": "input-number",
    "name": "spreadRt",
    "id": "u:c4c15d532abc8",
    "keyboard": true,
    "editorPath": "inputNumber.base.base",
    "precision": 8
    },
    "name": "spreadRt",
    "width": 100,
    "tableCellContentEllipsis": true,
    "className": "white-space-nowrap",
    "label": "浮动区间",
    "id": "u:cc64fd153e453",
    "placeholder": "-",
    "type": "text"
    },
    {
    "quickEdit": false,
    "name": "counterpartyCd",
    "width": 120,
    "tableCellContentEllipsis": true,
    "className": "white-space-nowrap",
    "label": "客户编码",
    "id": "u:41eeaaeefff3",
    "placeholder": "-",
    "type": "text"
    },
    {
    "quickEdit": false,
    "name": "productNm",
    "width": 100,
    "tableCellContentEllipsis": true,
    "className": "white-space-nowrap",
    "label": "模块",
    "id": "u:96605d8a27cb",
    "placeholder": "-"
    },
    {
    "quickEdit": false,
    "name": "currencyNm",
    "width": 100,
    "tableCellContentEllipsis": true,
    "className": "white-space-nowrap",
    "label": "币种",
    "id": "u:f10a7fe01a13",
    "placeholder": "-"
    },
    {
    "quickEdit": false,
    "name": "cshStatusText",
    "width": 100,
    "tableCellContentEllipsis": true,
    "className": "white-space-nowrap",
    "label": "状态",
    "id": "u:fcedc82f7f46",
    "placeholder": "-"
    }
    ],
    "editable": true,
    "strictMode": false,
    "minLength": 0,
    "canAccessSuperData": false,
    "copyable": true,
    "addable": false,
    "footerAddBtn": {
    "icon": "fa fa-plus",
    "label": "新增",
    "id": "u:40ae4802ae73"
    },
    "removable": true,
    "needConfirm": true,
    "id": "u:b3abe5b70bef111",
    "static": false,
    "copyBtnLabel": "复制",
    "editBtnLabel": "编辑",
    "deleteBtnLabel": "删除",
    "copyBtnIcon": "",
    "editBtnIcon": "",
    "deleteBtnIcon": "",
    "name": "affIntResetTrxVos",
    "label": false
    }
    ],
    "isInit": "0",
    "id": "u:hyd1e5b804be12",
    "feat": "Insert",
    "dsType": "api",
    "debug": true
    }
  4. 操作步骤
    文本框输入值,点击按钮,此时表格编辑框中可以赋值,再次修改文本框中的值,点击按钮,此时数据域中的数据已经更新,但是页面UI未生效
atmip9wb

atmip9wb1#

👍 Thanks for this!
🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

相关问题