更新审批模板
POST
https://qyapi.weixin.qq.com/cgi-bin/oa/approval/update_template
• 所有应用都可以通过本接口更新自己的模板
• 『审批』系统应用可以修改管理员手动创建的模板
• 自建应用和代开发自建应用不可通过本接口更新其他应用创建的模板
\1. 当模板的控件为必填属性时,表单中对应的控件必须有值。
\2. 一个模版中只能拥有一类假勤控件类型,Vacation-假期;Attendance-外出/出差/加班 均为假勤控件类型。
附录:各控件config数介绍
注意:文本/多行文本控件中config不需要填写
注意:数字控件中config不需要填写
注意:金额控件中config不需要填写
{
"template_id": "C4RbNKm731MCFVgk6XLq1Rs9W4aNXPJV2mmXT4qGy",
"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_id": "C4RbNKm731MCFVgk6XLq1Rs9W4aNXPJV2mmXT4qGy",
"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, 每个key的名称不能相同,也不能为空 |
└ └ value | 选项说明,text和lang规则同上,当设置options时不能为空 |
{
"template_id": "C4RbNKm731MCFVgk6XLq1Rs9W4aNXPJV2mmXT4qGy",
"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_id": "C4RbNKm731MCFVgk6XLq1Rs9W4aNXPJV2mmXT4qGy",
"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_id": "C4RbNKm731MCFVgk6XLq1Rs9W4aNXPJV2mmXT4qGy",
"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_id": "C4RbNKm731MCFVgk6XLq1Rs9W4aNXPJV2mmXT4qGy",
"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_id": "C4RbNKm731MCFVgk6XLq1Rs9W4aNXPJV2mmXT4qGy",
"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_id": "C4RbNKm731MCFVgk6XLq1Rs9W4aNXPJV2mmXT4qGy",
"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_id": "C4RbNKm731MCFVgk6XLq1Rs9W4aNXPJV2mmXT4qGy",
"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 | 未知错误 |
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://qyapi.weixin.qq.com/cgi-bin/oa/approval/update_template' \
--header 'Content-Type: application/json' \
--data-raw '{
"template_id": "C4RbNKm731MCFVgk6XLq1Rs9W4aNXPJV2mmXT4qGy",
"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",
}
请求参数
Query 参数
Body 参数application/json