同步企业微信审批模板~除”控件配置“外基本完成
This commit is contained in:
@@ -19,6 +19,17 @@ class WxWorkAPI:
|
||||
else:
|
||||
raise Exception(f"获取AccessToken失败: {result}")
|
||||
|
||||
def get_template_detail(self, template_data):
|
||||
url = f"https://qyapi.weixin.qq.com/cgi-bin/oa/gettemplatedetail?access_token={self.access_token}"
|
||||
headers = {'Content-Type': 'application/json'}
|
||||
response = requests.post(url, json=template_data, headers=headers)
|
||||
result = response.json()
|
||||
if result['errcode'] == 0:
|
||||
# print(result)
|
||||
return result
|
||||
else:
|
||||
raise Exception(f"获取模板详情请求失败: {result}")
|
||||
|
||||
def create_approval_request(self, approval_data):
|
||||
url = f"https://qyapi.weixin.qq.com/cgi-bin/oa/applyevent?access_token={self.access_token}"
|
||||
headers = {'Content-Type': 'application/json'}
|
||||
@@ -60,89 +71,89 @@ class WxWorkAPI:
|
||||
return result['media_id']
|
||||
|
||||
|
||||
template_id_dict = {"test": "ZvmJBAt7U2iUju9JLePxfkfuN22meQMVTAHymA"}
|
||||
creator_userid = "MaGuangWei"
|
||||
corid = 'wweaf7f1caab27a136'
|
||||
secret = 'L6z-kjrUBOWfhBiLOmX_fNSY3jydDkLUNNWnemafn00'
|
||||
wx = WxWorkAPI(corid, secret)
|
||||
media_id = wx.upload_temp_file()
|
||||
print(media_id)
|
||||
# access = wx.get_access_token()
|
||||
approval_datas = {
|
||||
"creator_userid": creator_userid,
|
||||
"template_id": template_id_dict['test'],
|
||||
"use_template_approver": 0,
|
||||
# "choose_department": 2,
|
||||
"approver": [
|
||||
{
|
||||
"attr": 2,
|
||||
"userid": ["MaGuangWei", "YangJinLing"]
|
||||
},
|
||||
{
|
||||
"attr": 1,
|
||||
"userid": ["MaGuangWei"]
|
||||
}
|
||||
],
|
||||
"notifyer": ["MaGuangWei", "PengYuBo"],
|
||||
# "notifyer": ["MaGuangWei"],
|
||||
"notify_type": 1,
|
||||
"apply_data": {
|
||||
"contents": [
|
||||
# 申请事项
|
||||
{
|
||||
"control": "Text",
|
||||
"id": "Text-1640339319582",
|
||||
"value": {
|
||||
"text": "测试测试测试测试测试"
|
||||
}
|
||||
},
|
||||
# 申请内容
|
||||
{
|
||||
"control": "Textarea",
|
||||
"id": "Textarea-1640339335659",
|
||||
"value": {
|
||||
"text": "odoo>>>企业微信审批"
|
||||
}
|
||||
},
|
||||
# 附件
|
||||
{
|
||||
"control": "File",
|
||||
"id": "File-1640339381728",
|
||||
"value": {
|
||||
"files": [
|
||||
{
|
||||
"file_id": media_id
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
"summary_list": [
|
||||
{
|
||||
"summary_info": [{
|
||||
"text": "测试附件上传",
|
||||
"lang": "zh_CN"
|
||||
}]
|
||||
},
|
||||
# {
|
||||
# "summary_info": [{
|
||||
# "text": "摘要第2行",
|
||||
# "lang": "zh_CN"
|
||||
# }]
|
||||
# },
|
||||
# {
|
||||
# "summary_info": [{
|
||||
# "text": "摘要第3行",
|
||||
# "lang": "zh_CN"
|
||||
# }]
|
||||
# }
|
||||
]
|
||||
}
|
||||
wx.create_approval_request(approval_datas)
|
||||
print('创建成功')
|
||||
# template_id_dict = {"test": "ZvmJBAt7U2iUju9JLePxfkfuN22meQMVTAHymA"}
|
||||
# creator_userid = "MaGuangWei"
|
||||
# corid = 'wweaf7f1caab27a136'
|
||||
# secret = 'L6z-kjrUBOWfhBiLOmX_fNSY3jydDkLUNNWnemafn00'
|
||||
# wx = WxWorkAPI(corid, secret)
|
||||
# media_id = wx.upload_temp_file()
|
||||
# print(media_id)
|
||||
# # access = wx.get_access_token()
|
||||
# approval_datas = {
|
||||
# "creator_userid": creator_userid,
|
||||
# "template_id": template_id_dict['test'],
|
||||
# "use_template_approver": 0,
|
||||
# # "choose_department": 2,
|
||||
# "approver": [
|
||||
# {
|
||||
# "attr": 2,
|
||||
# "userid": ["MaGuangWei", "YangJinLing"]
|
||||
# },
|
||||
# {
|
||||
# "attr": 1,
|
||||
# "userid": ["MaGuangWei"]
|
||||
# }
|
||||
# ],
|
||||
# "notifyer": ["MaGuangWei", "PengYuBo"],
|
||||
# # "notifyer": ["MaGuangWei"],
|
||||
# "notify_type": 1,
|
||||
# "apply_data": {
|
||||
# "contents": [
|
||||
# # 申请事项
|
||||
# {
|
||||
# "control": "Text",
|
||||
# "id": "Text-1640339319582",
|
||||
# "value": {
|
||||
# "text": "测试测试测试测试测试"
|
||||
# }
|
||||
# },
|
||||
# # 申请内容
|
||||
# {
|
||||
# "control": "Textarea",
|
||||
# "id": "Textarea-1640339335659",
|
||||
# "value": {
|
||||
# "text": "odoo>>>企业微信审批"
|
||||
# }
|
||||
# },
|
||||
# # 附件
|
||||
# {
|
||||
# "control": "File",
|
||||
# "id": "File-1640339381728",
|
||||
# "value": {
|
||||
# "files": [
|
||||
# {
|
||||
# "file_id": media_id
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
#
|
||||
# },
|
||||
#
|
||||
# ]
|
||||
# },
|
||||
# "summary_list": [
|
||||
# {
|
||||
# "summary_info": [{
|
||||
# "text": "测试附件上传",
|
||||
# "lang": "zh_CN"
|
||||
# }]
|
||||
# },
|
||||
# # {
|
||||
# # "summary_info": [{
|
||||
# # "text": "摘要第2行",
|
||||
# # "lang": "zh_CN"
|
||||
# # }]
|
||||
# # },
|
||||
# # {
|
||||
# # "summary_info": [{
|
||||
# # "text": "摘要第3行",
|
||||
# # "lang": "zh_CN"
|
||||
# # }]
|
||||
# # }
|
||||
# ]
|
||||
# }
|
||||
# wx.create_approval_request(approval_datas)
|
||||
# print('创建成功')
|
||||
|
||||
aa = {"errcode": 0, "errmsg": "ok", "template_names": [{"text": "对接开发测试", "lang": "zh_CN"}], "template_content": {
|
||||
"controls": [{"property": {"control": "Text", "id": "Text-1640339319582",
|
||||
|
||||
Reference in New Issue
Block a user