天翎MyApps技术社区 - 低代码平台 | 流程管理系统 | BPM软件

 找回密码
 注册成为天翎用户
查看: 1337|回复: 0

[javascript] 接口调用示例

[复制链接]
smart 发表于 2020-12-14 18:36:39 | 显示全部楼层 |阅读模式
1.登录(获取token)
求路径:/runtime/login/loginWithCiphertext2

示例:http://localhost:8080/obpm/runtime/login/loginWithCiphertext2

请求包体:
{
    "username": "admin1",
    "password": "pORFUyTVQxSX",
    "remember": "0",
    "debug": "false",
    "domainName": "测试",
    "checkcode": "",
    "language": "CN"
}
参数        类型        说明
username        String        账号
password        String        密码
remember        String        是否记住密码
debug        String        是否调式模式
checkcode        String        验证码
language        String        多语言

返回数据:
{
    "msg": "登录成功",
    "checkcodeImg": "",
    "resultCode": "0",
    "returnUrl": "",
    "accessToken": ""
}

参数        类型        说明
msg        String        返回提示
checkcodeImg        String        验证码图片
resultCode        String        登录状态(1成功|0失败)
returnUrl        String        跳转url
accessToken        String        访问令牌

Js示例:
$.ajax({
    url: path + "runtime/login/loginWithCiphertext2",
    // url: "http://localhost:8080/signon2/runtime/login/loginWithCiphertext2",
    type: 'post',
    async: false,
    dataType: 'json',
    contentType: 'application/json',
    data: JSON.stringify(data)
})

保存表单数
请求路径:
/runtime/sOZu9kthmxyP8qQfq0e/documents/__V2CO11rKfS9oeyzchTm?accessToken={accessToken}

示例:
http://localhost:8080/obpm/runtime/sOZu9kthmx/documents/__V2CO11rKfS9oeyzchTm?accessToken={accessToken}

请求包体:
{
    "items": {
        "名称": "11",
        "单价": "22",
        "库存": "33",
        "备注": "444"
    },
    "applicationId": "sOZu9kthmxyP8qQfq0e",
    "id": "__V2CO11rKfS9oeyzchTm",
    "templateForm": "",
    "formId": "nkzNglZErhG8wqMeNhh",
    "sign": "",
    "parentId": "",
    "isRelate": "false",
    "subDocuments": [
        {
            "id": "__wDsIb0fnx4BMExMFLJ2",
            "formId": "__n7HJaHgn7RIWMOtGGMM",
            "formName": "下拉子表",
            "items": {},
            "parentId": "__AOyNIHmhaKG7EFDEcZv",
            "isRelate": "true",
            "delete": true
        },
        {
            "id": "__qdQWOs8p6f6mqRWTUAq",
            "formId": "__n7HJaHgn7RIWMOtGGMM",
            "items": {
                "章节": "6",
                "名称": "6",
                "总金额": "6",
                "计划总金额": "6"
            },
            "parentId": "__AOyNIHmhaKG7EFDEcZv",
            "isRelate": "true",
            "edit": true
        }
    ],
    "versions": "0"
}
参数        类型        说明
items        JSON        字段(控件名:值)
applicationId        String        软件id
id        String        文档id(主键)
templateForm        String        模板表单id
formId        String        表单id
sign        String        签章
parentId        String        父文档id
isRelate        String        是否父子关系
subDocuments        List        子表单数据(数据格式同主表)
subDocuments[0].delete        boolean        字表数据删除标识
subDocuments[1].edit        boolean        字表数据新建或者更新标识
versions        String        版本号

返回数据:
{
    "errcode": 0,
    "errmsg": "保存成功",
    "data": {
        "id": "__V2CO11rKfS9oeyzchTm",
        "authorDeptIndex": "ZMMMGm5mnGCE4WvWFeI",
        "created": 1592365094789,
        "lastmodified": 1592365094798,
        "istmp": false,
        "versions": 1,
        "auditorList": "{}",
        "coAuditorList": "{}",
        "stateInt": 0,
        "authorId": "M88FvL0rnPRvkCTzLkF",
        "stateLabelInfo": "[{\"nodes\":[{\"nodeId\":\"\",\"stateLabel\":\"\",\"state\":\"\",\"auditors\":[],\"coAuditors\":[]}]}]",
        "formname": "表单示例/表单操作/表单操作_保存类型",
        "formid": "nkzNglZErhG8wqMeNhh",
        "delete": false,
        "edit": false,
        "relateFlow": false,
        "items": {
            "单价": 22.0,
            "名称": "11",
            "备注": "444",
            "库存": 33.0
        }
    }
}

Js示例:
var result = null;
$.ajax({
    url: contextPath + '/runtime/' + appId + '/documents/' + docId,
    type: 'put',
    dataType: 'json',
    contentType: 'application/json',
    async: false,
    data: JSON.stringify(docJson),
    success: function (response) {
        result = response;
    }
})

3.上传附件
请求路径:
/portal/FrontFileAndImageUploadServlet?data=path:ITEM_PATH,fileSaveMode:00,fieldid:null,allowedTypes:null,applicationid:sOZu9kthmxyP8qQfq0e

示例:
http://localhost:8080/obpm/portal/FrontFileAndImageUploadServlet?data=path:ITEM_PATH,fileSaveMode:00,fieldid:null,allowedTypes:null,applicationid:sOZu9kthmxyP8qQfq0e

参数说明:
参数        类型        说明
path        String        存储路径
fileSaveMode        String        文件保存模式
fieldid        String        表单控件id
allowedTypes        String        允许上传的类型
applicationid        String        软件id

文件数据:


返回数据:一字符串
"PDF签章方案.doc,/uploads/item/2020/1ee334a5-f233-4ec1-a82c-6e17d1a6bdfa.doc"

Js示例:(百度的)
function uploadPic() {
  var form = document.getElementById('upload'),
    formData = new FormData(form);
  $.ajax({
   url:"https://sscpre.boe.com/v1/medical-console/medical/file/upload",
   type:"post",
   data:formData,
   processData:false,
   contentType:false,
   success:function(res){
    if(res){
     alert("上传成功!");
    }
    console.log(res);
    $("#pic").val("");
    $(".showUrl").html(res);
    $(".showPic").attr("src",res);
   },
   error:function(err){
    alert("网络连接失败,稍后重试",err);
   }
  
  })
  
}
想要上传的附件与表单关联,需再调用保存接口,将数据放在items里面

本版积分规则

QQ|手机版|天翎MyApps技术社区 ( 粤ICP备11093750号 )

GMT+8, 2026-8-12 05:41

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表