====JSON格式====
^名称 ^类型 ^注释 ^
|id |int |字段id,字段在创建的时候由系统自动分配|
|url |varchar |字段的资源url |
|name |varchar |字段名称|
|key |varchar |字段的唯一标识|
|type |int |字段类型,取值为:1-下拉列表,2-单行文本,3-多行文本,4-正整数,5-小数,6-复选框,8-日期(格式为:2018-02-03),12-附件,13-评星|
|custom_field_options |array |展示下拉列表选项或级联目录,如果字段类型是下拉列表,该字段会展示下拉列表的选项;如果字段是级联字段,会展示级联的多级目录;其他的字段类型展示为空。|
====JSON示例====
{
"id": 1,
"url": "https://www.bangwo8.com/api/v1/forms/221/form_fields/1.json",
"name": "爱好",
"key": "field_10",
"type": "1",
"system": "0",
"custom_field_options": [//key为下拉选项的ID
{
"key": "231",
"value": "读书"
},
{
"key": "232",
"value": "旅行"
},
{
"key": "233",
"value": "健身"
}
]
}
====查询指定表单的字段列表====
GET /api/v1/forms/{id}/form_fields.json
**调用者权限**
管理员
**调用示例**
curl https://www.bangwo8.com/api/v1/forms/91739/form_fields.json -u {account}:{password}
**返回值示例**
Status: 200 OK
{
"form_fields": [
{
"id": "24136421",
"name": "测试省市级联",
"key": "field_1",
"type": "18",
"custom_field_options": [
{
"key": "1",
"value": "北京市",
"subset_value": [
{
"key": "26",
"value": "海淀区"
},
{
"key": "27",
"value": "朝阳区"
},
{
"key": "28",
"value": "西城区"
}
]
},
{
"key": "6",
"value": "吉林省",
"subset_value": [
{
"key": "29",
"value": "长春市"
},
{
"key": "30",
"value": "吉林市"
},
{
"key": "31",
"value": "四平市"
}
...
]
}
]
}
]
}
====表单字段选项增加、更新接口====
PUT /api/v1/forms/{columnId}/form_fields.json
//说明:此接口针对于表单的级联字段和下拉字段,选项中原来库中已存在的会进行更新,原来库中不存在的进行新增。//
**调用者权限**
管理员
**请求参数**
^名称 ^类型 ^必填 ^描述 ^
|parentId |int |级联字段两个字段需要至少写一个 |帮我吧选项父级id(如果是一级,则该字段写0)|
|extendParentId |int |::: |选项外部扩展父级id(如果是一级,不要传该字段)|
|optionName |string |是 |字段选项名称 |
|optionId |int |否 |帮我吧内选项id |
|extendId |int |否 |外部扩展id(级联字段有,下拉暂时没有不可用) |
**调用示例** \\
级联字段示例:
curl https://www.bangwo8.com/api/v1/forms/235457/form_fields.json \
-H "Content-Type: application/json" \
-d '[
{
"parentId":"0",
"optionName":"选项1"
},
{
"parentId":"1",
"optionName":"选项3",
"optionId":"28"
}
]' \
-v -u {account}:{password} -X PUT
下拉字段示例:
curl https://www.bangwo8.com/api/v1/forms/24917015/form_fields.json \
-H "Content-Type: application/json" \
-d '[
{
"optionName":"选项1"
},
{
"optionName":"选项2",
"optionId":"002"
}
]' \
-v -u {account}:{password} -X PUT
**返回参数**
^名称 ^类型 ^描述 ^
|columnId |int |字段id |
|name |string |字段名称 |
|key |string |字段唯一标识 |
|type |int |字段类型(1为下拉字段,18-级联字段) |
|custom_field_options |array |字段选项列表 |
custom_field_options字段选项列表说明:
^名称 ^类型 ^描述 ^
|optionId |int |选项id |
|optionName |string |字段名称 |
|extendId |int |外部扩展id(级联字段展示)|
**返回值示例** \\
级联字段返回示例:
Status: 200 OK
{
"form_fields": [
{
"id": "24136421",
"name": "测试省市级联",
"key": "field_1",
"type": "18",
"custom_field_options": [
{
"key": "1",
"value": "北京市",
"subset_value": [
{
"key": "26",
"value": "海淀区"
},
{
"key": "27",
"value": "朝阳区"
},
{
"key": "28",
"value": "西城区"
}
]
},
{
"key": "6",
"value": "吉林省",
"subset_value": [
{
"key": "29",
"value": "长春市"
},
{
"key": "30",
"value": "吉林市"
},
{
"key": "31",
"value": "四平市"
}
...
]
}
]
}
]
}
下拉字段返回示例:
{
"columnId":"24917015",
"name":"ipaas下拉字段",
"key":"field_14",
"type":"1",
"custom_field_options":[
{
"optionId":"358769",
"optionName":"选项1"
},
{
"optionId":"358770",
"optionName":"选项2",
},
{
"optionId":"358771",
"optionName":"选项3"
}
]
}
====表单字段选项删除接口====
PUT /api/v1/forms/{columnId}/form_fields.json
**调用者权限**
管理员
**请求参数**
^名称 ^类型 ^必填 ^描述 ^
|optionId |int |两个参数至少使用一个 |帮我吧内选项id |
|extendId |int |::: |外部扩展id |
**调用示例**
curl -v -u {account}:{password} https://www.bangwo8.com/api/v1/forms/356780/form_fields.json?optionId=358771 \
-H "Content-Type: multipart/form-data"
-X DELETE
**返回参数**
^名称 ^类型 ^描述 ^
|optionId |int |帮我吧内选项id |
|optionName |string |字段选项名称 |
|extendId |int |外部扩展id|
**返回值示例**
{
"optionId":"358771",
"optionName":"选项3",
"extendId":"11"
}