amis icon indicating copy to clipboard operation
amis copied to clipboard

可以通过 `Service` 返回的结果,清空一个表单项吗?

Open icodingx opened this issue 6 years ago • 10 comments

{"name": "tcode", "type": "text", "label": "条码" },
{
  "type": "service",
  "api": {
    "url": "/xx?tcode=${tcode}&wshid=${wshid}",
    "cache": 1000,
    "sendOn": "this.tcode"
  },
  "controls": [ ...

接口返回的数据,希望 service 返回后,清空 tcode 的内容,不晓得哪里出问题了?

{"msg":"操作成功","data":{"tcode":null,"prodinfo":"... }]},"status":0}

icodingx avatar Apr 02 '20 11:04 icodingx

这个 service 不加 cache 前,无限循环,也不知道如何解决?加 cache 肯定是治标不治本

icodingx avatar Apr 02 '20 11:04 icodingx

参数通过 data 配置如

{
  "type": "service",
  "api": {
    "method": "get",
    "url": "/xx",
    "data": {
      "tcode": "${tcode}",
      "wshid": "${wshid}"
    },
    "cache": 1000,
    "sendOn": "this.tcode"
  },
  "controls": [ ...

2betop avatar Apr 02 '20 11:04 2betop

接口返回的 {"msg":"操作成功","data":{"tcode":null,"prodinfo":"... }]},"status":0} 没有清空表单项 tcode 是什么原因呢 ?

icodingx avatar Apr 02 '20 13:04 icodingx

参数通过 data 配置 这种方式,请求都没发了,我是想通过 tcode 作为参数请求,再通过响应结果清空 tcode 表单项内容

icodingx avatar Apr 07 '20 03:04 icodingx

@2betop 请教一下,我这个需求可以实现吗 ?

icodingx avatar Apr 07 '20 03:04 icodingx

试试返回 {"tcode": ""}, 而不是 null

2betop avatar Apr 07 '20 03:04 2betop

你参考一下这个示例,刚试了下 空字符和 null 都是可以的。

https://baidu.github.io/amis/linkpage/form2

2betop avatar Apr 07 '20 03:04 2betop

你把你所有 form 下面的配置传不贴出来

2betop avatar Apr 07 '20 05:04 2betop

你的 tcode 要在 service 里面呢

2betop avatar Apr 07 '20 06:04 2betop

谢谢

icodingx avatar Apr 07 '20 06:04 icodingx