好友
阅读权限10
听众
最后登录1970-1-1
|
75吾爱币
本帖最后由 a1chemy 于 2022-9-9 08:15 编辑
我的表单提交的原数据格式是这样的:
[JavaScript] 纯文本查看 复制代码 {
"task_number": "开发测试大任务编号",
"task_name": "开发测试大任务名称",
"task_desc": "开发测试任务说明",
"task_node": [
{
"id": 0,
"created_at": null,
"updated_at": null,
"deleted_at": null,
"task_id": 0,
"node_code": "1-2-1",
"node_name": "测试子任务编号",
"node_start": "2022-10-01 08:00:00",
"node_end": "2022-10-15 08:00:00",
"node_num": 2,
"node_subject": "乡镇纪委领导班子",
"node_desc": "暂无",
"node_demand": "测试子任务编号",
"node_attach_num": 3,
"time": [
"2022-10-01T00:00:00.000Z",
"2022-10-15T00:00:00.000Z"
],
"task_filling": [
"{\"full_name\":\"张飞\",\"user_id\":20}",
"{\"full_name\":\"王林\",\"user_id\":26}"
]
},
{
"id": 0,
"created_at": null,
"updated_at": null,
"deleted_at": null,
"task_id": 0,
"node_code": "1-2-1",
"node_name": "测试子任务编号",
"node_start": "2022-10-01 08:00:00",
"node_end": "2022-10-15 08:00:00",
"node_num": 2,
"node_subject": "乡镇纪委领导班子",
"node_desc": "暂无",
"node_demand": "测试子任务编号",
"node_attach_num": 3,
"time": [
"2022-10-01T00:00:00.000Z",
"2022-10-15T00:00:00.000Z"
],
"task_filling": [
"{\"full_name\":\"韩信\",\"user_id\":22}",
"{\"full_name\":\"李白\",\"user_id\":21}"
]
}
]
}
现在后端需要的格式是这样的:
[JavaScript] 纯文本查看 复制代码 {
"task_number": "开发测试大任务编号",
"task_name": "开发测试大任务名称",
"task_desc": "开发测试任务说明",
"task_filling": [
"{\"full_name\":\"张飞\",\"user_id\":20}",
"{\"full_name\":\"王林\",\"user_id\":26}"
]
"task_node": [
{
"id": 0,
"created_at": null,
"updated_at": null,
"deleted_at": null,
"task_id": 0,
"node_code": "1-2-1",
"node_name": "测试子任务编号",
"node_start": "2022-10-01 08:00:00",
"node_end": "2022-10-15 08:00:00",
"node_num": 2,
"node_subject": "乡镇纪委领导班子",
"node_desc": "暂无",
"node_demand": "测试子任务编号",
"node_attach_num": 3,
"time": [
"2022-10-01T00:00:00.000Z",
"2022-10-15T00:00:00.000Z"
],
},
]
},
{
"task_number": "开发测试大任务编号",
"task_name": "开发测试大任务名称",
"task_desc": "开发测试任务说明",
"task_filling": [
"{\"full_name\":\"韩信\",\"user_id\":22}",
"{\"full_name\":\"李白\",\"user_id\":21}"
]
"task_node": [
{
"id": 0,
"created_at": null,
"updated_at": null,
"deleted_at": null,
"task_id": 0,
"node_code": "1-2-1",
"node_name": "测试子任务编号",
"node_start": "2022-10-01 08:00:00",
"node_end": "2022-10-15 08:00:00",
"node_num": 2,
"node_subject": "乡镇纪委领导班子",
"node_desc": "暂无",
"node_demand": "测试子任务编号",
"node_attach_num": 3,
"time": [
"2022-10-01T00:00:00.000Z",
"2022-10-15T00:00:00.000Z"
],
},
]
}
就是要把task_node里的task_filling放到外面,根据task_node下的数量生成对应数量的新数组。还请各位大佬帮帮忙,非常感谢! |
最佳答案
查看完整内容
[mw_shl_code=javascript,true]
var obj = {
task_number: "开发测试大任务编号",
task_name: "开发测试大任务名称",
task_desc: "开发测试任务说明",
task_node: [
{
id: 0,
created_at: null,
updated_at: null,
deleted_at: null,
task_id: 0,
node_code: "1-2-1",
node_n ...
|