企业内部开发 服务端API 审批 创建审批模板
创建审批模板
最后更新:2024/01/16
可联系渠道经理采购或代理智慧硬件接口已支持设备 联系渠道经理
创建审批模板
最后更新:2024/01/16

目录

  • 附录:各控件config数介绍
  •       附1 文本/多行文本控件(control参数为Text或Textarea)
  •       附2 数字控件(control参数为Number)
  •       附3 金额控件(control参数为Money)
  •       附4 日期/日期+时间控件(control参数为Date)
  •       附5 单选/多选控件(control参数为Selector)
  •       附6 成员控件(control参数为Contact)
  •       附7 说明文字控件(control参数为Tips)
  •       附8 附件控件(control参数为File,且value参数为files)
  •       附9 明细控件(control参数为Table)
  •       附10 假勤组件-请假组件(control参数为Vacation)
  •       附11 假勤组件-出差/外出/加班组件(control参数为Attendance)
  •       附12 位置控件(control参数为Location)
  •       附13 关联审批单控件(control参数为RelatedApproval)
  •       附14 时长组件(control参数为DateRange)
  •       附15 收款账户控件(control参数为BankAccount)
  • 错误说明
  • 可以调用此接口创建审批模板。创建新模板后,管理后台及审批应用内将生成对应模板,并生效默认流程和规则配置。

    请求方式:POST(HTTPS
    请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/approval/create_template?access_token=ACCESS_TOKEN

    请求示例:

    {
        "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":{
                    
                }
            }]
        }
    }

    参数说明:

    参数必须说明
    access_token调用接口凭证
    template_name模版名称数组
    └ text模版名称。需满足以下条件:1-模版名称不得和现有模版名称重复;2-长度不得超过40个字符。
    └ lang显示语言,中文:zh_CN(注意不是zh-CN)
    template_content审批模版控件设置,由多个表单控件及其内容组成,其中包含需要对控件赋值的信息
    └ controls控件数组,模版中可以设置多个控件类型,排列顺序和管理端展示的相同
    └└ property控件的基础属性
    └└└ control控件类型:Text-文本;Textarea-多行文本;Number-数字;Money-金额;Date-日期/日期+时间;Selector-单选/多选;;Contact-成员/部门;Tips-说明文字;File-附件;Table-明细;Location-位置;RelatedApproval-关联审批单;DateRange-时长;PhoneNumber-电话号码;Vacation-假期;Attendance-外出/出差/加班;BankAccount-收款账户 。以上为目前可支持的控件类型
    └└└ id控件id。1-模版内控件id必须唯一;2-控件id格式:control-数字,如"Text-01"
    └└└ title控件名称
    └└└└ text控件名称。需满足以下条件:1-控件名称不得和现有控件名称重复;2-长度不得超过40个字符。
    └└└└ lang显示语言,中文:zh_CN(注意不是zh-CN)
    └└└ placeholder控件说明
    └└└└ text控件说明。需满足以下条件:长度不得超过80个字符。
    └└└└ lang显示语言,中文:zh_CN(注意不是zh-CN);若text填写,则该项为必填
    └└└ require控件是否必填。0-非必填;1-必填;默认为0
    └└└ un_print控件是否可打印。0-可打印;1-不可打印;默认为0
    └└ config是or否控件配置。控件的类型不同,其中填的参数不相同,下方将为每一个控件配置进行详细说明

    权限说明

    应用类型权限要求
    自建应用配置到「审批 - 可调用接口的应用」中
    代开发应用具有「审批」权限
    第三方应用暂不支持
    1.第三方应用可以获取第三方应用添加的模板详情。
    2.自建应用的Secret可获取企业自建模板的模板详情。
    3.接口调用频率限制为600次/分钟。

    注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情

     

    注意
    1. 当模板的控件为必填属性时,表单中对应的控件必须有值。
    2. 一个模版中只能拥有一类假勤控件类型,Vacation-假期;Attendance-外出/出差/加班 均为假勤控件类型。

    返回结果:

    {
        "errcode":0,
        "errmsg":"ok",
        "template_id":"C4RbNKm731MCFVgk6XLq1Rs9W4aNXPJV2mmXT4qGy"
    }

    参数说明:

    参数说明
    errcode错误码,详情见错误码说明
    errmsg错误码对应的错误信息提示
    template_id模版创建成功后返回的模版id

     

    附录:各控件config数介绍

    附1 文本/多行文本控件(control参数为Text或Textarea)

    注意:文本/多行文本控件中config不需要填写

     

    附2 数字控件(control参数为Number)

    注意:数字控件中config不需要填写

     

    附3 金额控件(control参数为Money)

    注意:金额控件中config不需要填写

     

    附4 日期/日期+时间控件(control参数为Date)

    {
        "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-日期+时间 ,和对应模板控件属性一致

     

    附5 单选/多选控件(control参数为Selector)

    {
        "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规则同上

     

    附6 成员控件(control参数为Contact)

    {
        "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成员、部门控件
    └ typesingle-单选、multi-多选
    └ modeuser-成员、department-部门

     

    附7 说明文字控件(control参数为Tips)

    {
        "tips": {
            "tips_content": [
                {
                    "text": {
                        "sub_text": [
                            {
                                "type": 1,
                                "content": {
                                    "plain_text": {
                                        "content": "说明文字"
                                    }
                                }
                            },
                            {
                                "type": 2,
                                "content": {
                                    "link": {
                                        "title": "这是一个链接",
                                        "url": "https://work.weixin.qq.com"
                                    }
                                }
                            }
                        ]
                    },
                    "lang": "zh_CN"
                },
                {
                    "text": {
                        "sub_text": [
                            {
                                "type": 1,
                                "content": {
                                    "plain_text": {
                                        "content": "tips"
                                    }
                                }
                            },
                            {
                                "type": 2,
                                "content": {
                                    "link": {
                                        "title": "this is a link",
                                        "url": "https://work.weixin.qq.com"
                                    }
                                }
                            }
                        ]
                    },
                    "lang": "en"
                }
            ]
        }
    }
    参数说明
    tips_content说明文字数组,元素为不同语言的富文本说明文字
    └ text某个语言的富文本说明文字数组,元素为不同文本类型的说明文字分段
    └lang语言类型
    └└ sub_text说明文字分段
    └└└ type文本类型 1:纯文本 2:链接,每个说明文字中只支持包含一个链接
    └└└ content内容
    └└└└plain_text纯文本类型的内容
    └└└└└content纯文本文字
    └└└└link链接类型的内容
    └└└└└title链接标题
    └└└└└url链接url,不能超过600个字符
    注意 :纯文本+链接标题总长度不能超过 800个字符

    附8 附件控件(control参数为File,且value参数为files)

    {
        "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--否

     

    附9 明细控件(control参数为Table)

    {
        "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明细内容,一个明细控件可能包含多个子明细,每个子明细相当于一个控件(可参照本篇内其他控件操作)

    注意:1、不能为空数组,至少需要包含一个子明细,子明细中必须包括模板中设置的全部子控件,如果子明细为空,则需要将所有子控件的值设为空;2、明细中不能设置假勤控件、明细控件|

    附10 假勤组件-请假组件(control参数为Vacation)

    注意:请假控件中config不需要填写

     

    附11 假勤组件-出差/外出/加班组件(control参数为Attendance)

    {
        "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_holiday0-自然日;1-工作日
    └ └ perday_duration一天的时长(单位为秒),必须大于0小于等于86400
    └ type假勤组件类型:3-出差;4-外出;5-加班

    附12 位置控件(control参数为Location)

    {
        "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

     

    附13 关联审批单控件(control参数为RelatedApproval)

    {
        "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可通过获取审批模版接口获取

     

    附14 时长组件(control参数为DateRange)

    {
        "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_holiday0:自然日,1:工作日
    perday_duration一天时长(秒),需大于0小于等于86400

     

    附15 收款账户控件(control参数为BankAccount)

    注意:收款账户控件中config不需要填写

     

    错误说明

    错误码说明
    301088无审批应用权限
    301086审批控件参数错误
    301087企业模版数超过上限
    620004服务器内部错误
    -1未知错误
    上一篇
    审批流程引擎
    下一篇
    更新审批模板