注意:文本/多行文本控件中config不需要填写
注意:数字控件中config不需要填写
注意:金额控件中config不需要填写
{
"template_name": [{
"text": "我的api测试模版",
"lang": "zh_CN"
}],
"template_content": {
"controls": [{
"property": {
"control": "Date",
"id": "Date-01",
"title": [{
"text": "控件名称",
"lang": "zh_CN"
}],
"placeholder": [{
"text": "控件说明",
"lang": "zh_CN"
}],
"require": 0,
"un_print": 1
},
"config":{
"date":{
"type":"day"
}
}
}]
}
}| 参数 | 说明 |
|---|---|
| date | 日期/日期+时间内容 |
| └ type | 时间展示类型:day-日期;hour-日期+时间 ,和对应模板控件属性一致 |
{
"template_name": [{
"text": "我的api测试模版",
"lang": "zh_CN"
}],
"template_content": {
"controls": [{
"property": {
"control": "Selector",
"id": "Selector-01",
"title": [{
"text": "控件名称",
"lang": "zh_CN"
}],
"placeholder": [{
"text": "控件说明",
"lang": "zh_CN"
}],
"require": 0,
"un_print": 1
},
"config":{
"selector": {
"type": "multi",
"options": [
{
"key": "option-1",
"value":{
"text":"选项1",
"lang":"zh_CN"
}
},
{
"key": "option-2",
"value":{
"text":"选项2",
"lang":"zh_CN"
}
}
]
}
}
}]
}
}| 参数 | 说明 |
|---|---|
| selector | 选择控件内容,即申请人在此控件选择的选项内容 |
| └ type | 选择方式:single-单选;multi-多选 |
| └ options | 多选选项,多选属性的选择控件允许输入多个 |
| └ └ key | 选项key |
| └ └ value | 选项说明,text和lang规则同上 |
{
"template_name": [{
"text": "我的api测试模版",
"lang": "zh_CN"
}],
"template_content": {
"controls": [{
"property": {
"control": "Contact",
"id": "Contact-01",
"title": [{
"text": "控件名称",
"lang": "zh_CN"
}],
"placeholder": [{
"text": "控件说明",
"lang": "zh_CN"
}],
"require": 0,
"un_print": 1
},
"config":{
"contact": {
"type":"single",
"mode":"user"
}
}
}]
}
}| 参数 | 说明 |
|---|---|
| contact | 成员、部门控件 |
| └ type | single-单选、multi-多选 |
| └ mode | user-成员、department-部门 |
注意:说明文字控件中config不需要填写
{
"template_name": [{
"text": "我的api测试模版",
"lang": "zh_CN"
}],
"template_content": {
"controls": [{
"property": {
"control": "File",
"id": "File-01",
"title": [{
"text": "控件名称",
"lang": "zh_CN"
}],
"placeholder": [{
"text": "控件说明",
"lang": "zh_CN"
}],
"require": 0,
"un_print": 1
},
"config": {
"file": {
"is_only_photo": 1
}
}
}]
}
}| 参数 | 说明 |
|---|---|
| is_only_photo | 是否只允许拍照,1--是, 0--否 |
{
"template_name": [{
"text": "我的api测试模版",
"lang": "zh_CN"
}],
"template_content": {
"controls": [{
"property": {
"control": "Table",
"id": "Table-01",
"title": [{
"text": "控件名称",
"lang": "zh_CN"
}],
"placeholder": [{
"text": "控件说明",
"lang": "zh_CN"
}],
"require": 0,
"un_print": 1
},
"config": {
"table": {
"print_format": 0,
"children": [{
"property": {
"control": "File",
"id": "File-01",
"title": [{
"text": "File控件名称",
"lang": "zh_CN"
}],
"placeholder": [{
"text": "控件说明",
"lang": "zh_CN"
}],
"require": 0,
"un_print": 1
},
"config": {
"file": {
"is_only_photo": 1
}
}
},
{
"property": {
"control": "Date",
"id": "Date-01",
"title": [{
"text": "Date控件名称",
"lang": "zh_CN"
}],
"placeholder": [{
"text": "控件说明",
"lang": "zh_CN"
}],
"require": 0,
"un_print": 1
},
"config": {
"date": {
"type": "day"
}
}
}
]
}
}
}]
}
}| 参数 | 说明 |
|---|---|
| print_format | 打印格式;0-合并成一行打印,1-拆分成多行打印 |
| children | 明细内容,一个明细控件可能包含多个子明细,每个子明细相当于一个控件(可参照本篇内其他控件操作) |
注意:请假控件中config不需要填写
{
"template_name": [{
"text": "我的api测试模版",
"lang": "zh_CN"
}],
"template_content": {
"controls": [{
"property": {
"control": "Attendance",
"id": "Attendance-01",
"title": [{
"text": "控件名称",
"lang": "zh_CN"
}],
"placeholder": [{
"text": "控件说明",
"lang": "zh_CN"
}],
"require": 0,
"un_print": 1
},
"config": {
"attendance": {
"type": 3,
"date_range": {
"type": "halfday",
"official_holiday": 0,
"perday_duration": 86400
}
}
}
}]
}
}| 参数 | 说明 |
|---|---|
| attendance | 假勤内容,即申请人在此组件内选择的假勤信息 |
| └ date_range | 假勤组件时间选择范围 |
| └ └ type | 时间展示类型:halfday-日期;hour-日期+时间 |
| └ └ official_holiday | 0-自然日;1-工作日 |
| └ └ perday_duration | 一天的时长(单位为秒),必须大于0小于等于86400 |
| └ type | 假勤组件类型:3-出差;4-外出;5-加班 |
{
"template_name": [{
"text": "我的api测试模版",
"lang": "zh_CN"
}],
"template_content": {
"controls": [{
"property": {
"control": "Location",
"id": "Location-01",
"title": [{
"text": "控件名称",
"lang": "zh_CN"
}],
"placeholder": [{
"text": "控件说明",
"lang": "zh_CN"
}],
"require": 0,
"un_print": 1
},
"config": {
"location": {
"distance": 100
}
}
}]
}
}| 参数 | 说明 |
|---|---|
| distance | 距离,目前支持100、200、300 |
{
"template_name": [{
"text": "我的api测试模版",
"lang": "zh_CN"
}],
"template_content": {
"controls": [{
"property": {
"control": "RelatedApproval",
"id": "RelatedApproval-01",
"title": [{
"text": "控件名称",
"lang": "zh_CN"
}],
"placeholder": [{
"text": "控件说明",
"lang": "zh_CN"
}],
"require": 0,
"un_print": 1
},
"config": {
"related_approval": {
"template_id": ["C4RbNKm731MCFVgk6XLq1Rs9W4aNXPJV2mmXT4qGy"]
}
}
}]
}
}| 参数 | 说明 |
|---|---|
| template_id | 关联审批单的template_id ,不填时表示可以关联所有模版,该template_id可通过获取审批模版接口获取 |
{
"template_name": [{
"text": "我的api测试模版",
"lang": "zh_CN"
}],
"template_content": {
"controls": [{
"property": {
"control": "DateRange",
"id": "DateRange-01",
"title": [{
"text": "控件名称",
"lang": "zh_CN"
}],
"placeholder": [{
"text": "控件说明",
"lang": "zh_CN"
}],
"require": 0,
"un_print": 1
},
"config": {
"date_range": {
"type": "halfday",
"official_holiday": 0,
"perday_duration": 86400
}
}
}]
}
}| 参数 | 说明 |
|---|---|
| type | 按小时-hour 按天-halfday |
| official_holiday | 0:自然日,1:工作日 |
| perday_duration | 一天时长(秒),需大于0小于等于86400 |
| 错误码 | 说明 |
|---|---|
| 301088 | 无审批应用权限 |
| 301086 | 审批控件参数错误 |
| 301087 | 企业模版数超过上限 |
| 620004 | 服务器内部错误 |
| -1 | 未知错误 |
curl --location --request POST 'https://qyapi.weixin.qq.com/cgi-bin/oa/approval/create_template?access_token=ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"template_name": [{
"text": "我的api测试模版",
"lang": "zh_CN"
}],
"template_content": {
"controls": [{
"property": {
"control": "Text",
"id": "Text-01",
"title": [{
"text": "控件名称",
"lang": "zh_CN"
}],
"placeholder": [{
"text": "控件说明",
"lang": "zh_CN"
}],
"require": 0,
"un_print": 1
},
"config":{
}
}]
}
}'{
"errcode": 0,
"errmsg": "ok",
"template_id": "C4RbNKm731MCFVgk6XLq1Rs9W4aNXPJV2mmXT4qGy"
}