项目场景:
点击编辑之后,模态窗需要回显
问题描述
模态窗有表单下拉框,后端人员需要的是下拉框id,前端则需要展示的下拉框名称
表格数据如下
`{
“code”: 0,
“msg”: “请求成功”,
“count”: 25,
“data”: [
{
“id”: 52,
“description”: “”,
“createTime”: “2023-06-07 13:43:03”,
“updateTime”: “2023-07-19 17:07:59”,
“pipelineName”: “津华线”,
“pipelineType”: 1,
“pipelineTypeName”: null,
“siteInstanceNumber”: 0
},
{
“id”: 51,
“description”: “”,
“createTime”: “2023-06-07 13:43:03”,
“updateTime”: “2023-07-19 17:07:59”,
“pipelineName”: “兰郑长”,
“pipelineType”: 2,
“pipelineTypeName”: null,
“siteInstanceNumber”: 0
},
{
“id”: 50,
“description”: “”,
“createTime”: “2023-06-07 13:43:03”,
“updateTime”: “2023-07-19 17:07:59”,
“pipelineName”: “港枣线”,
“pipelineType”: 2,
“pipelineTypeName”: null,
“siteInstanceNumber”: 0
},
{
“id”: 49,
“description”: “”,
“createTime”: “2023-06-07 13:43:03”,
“updateTime”: “2023-07-19 17:07:59”,
“pipelineName”: “石兰线”,
“pipelineType”: 1,
“pipelineTypeName”: null,
“siteInstanceNumber”: 0
},
{
“id”: 48,
“description”: “”,
“createTime”: “2023-06-07 13:43:03”,
“updateTime”: “2023-07-19 17:07:59”,
“pipelineName”: “惠宁线”,
“pipelineType”: 1,
“pipelineTypeName”: null,
“siteInstanceNumber”: 0
},
{
“id”: 47,
“description”: “”,
“createTime”: “2023-06-07 13:43:03”,
“updateTime”: “2023-07-19 17:07:59”,
“pipelineName”: “惠银线”,
“pipelineType”: 1,
“pipelineTypeName”: null,
“siteInstanceNumber”: 0
},
{
“id”: 46,
“description”: “”,
“createTime”: “2023-06-07 13:43:03”,
“updateTime”: “2023-07-19 17:07:59”,
“pipelineName”: “日东线”,
“pipelineType”: 1,
“pipelineTypeName”: null,
“siteInstanceNumber”: 0
},
{
“id”: 45,
“description”: “”,
“createTime”: “2023-06-07 13:43:03”,
“updateTime”: “2023-07-19 17:07:59”,
“pipelineName”: “新大线”,
“pipelineType”: 1,
“pipelineTypeName”: null,
“siteInstanceNumber”: 0
},
{
“id”: 44,
“description”: “”,
“createTime”: “2023-06-07 13:43:03”,
“updateTime”: “2023-07-19 17:07:59”,
“pipelineName”: “中朝线”,
“pipelineType”: 1,
“pipelineTypeName”: null,
“siteInstanceNumber”: 0
},
{
“id”: 43,
“description”: “”,
“createTime”: “2023-06-07 13:43:03”,
“updateTime”: “2023-07-19 17:07:59”,
“pipelineName”: “铁大线”,
“pipelineType”: 1,
“pipelineTypeName”: null,
“siteInstanceNumber”: 0
}
]
}
需要回显下拉如下图
``
后端返回下拉框如下
表单逻辑
在这里表单 onFinish 方法拿到的是id,提交也是通过这个id传参给后端,回显我们只能拿到id去赋值,
发现表单select需要字符串,所以在传编辑数据的时候将后端的id转为字符串。
但是这样会导致表格数据那一列为空
在添加如图方
原因分析:
提示:这里填写问题的分析:
例如:Handler
发送消息有两种方式,分别是 Handler.obtainMessage()
和 Handler.sendMessage()
,其中 obtainMessage
方式当数据量过大时,由于 MessageQuene
大小也有限,所以当 message
处理不及时时,会造成先传的数据被覆盖,进而导致数据丢失。
解决方案:
提示:这里填写该问题的具体解决方案:
例如:新建一个 Message
对象,并将读取到的数据存入 Message
,然后 mHandler.obtainMessage(READ_DATA, bytes, -1, buffer).sendToTarget();
换成 mHandler.sendMessage()
。