跳转至

其他函数

方法清单

函数名 参数 说明
getOptionsByDQL(dql, keyFieldName, blankFirst) dql:查询符合条件语句;keyFieldName:文档的字段名;blankFirst:默认是否为空选项 返回符合查询条件语句的文档中keyFieldName字段的所有值集合,作为下拉框控件的选项
getWorkingDayCount(startDate, endDate) startDate: "yyyy-MM-dd HH🇲🇲ss"格式的字符串 endDate: "yyyy-MM-dd HH🇲🇲ss"格式的字符串 获取相隔工作天数
getWorkingTimesCount(startDate, endDate) startDate: "yyyy-MM-dd HH🇲🇲ss"格式的字符串 endDate: "yyyy-MM-dd HH🇲🇲ss"格式的字符串 获取相隔工作小时数
isWorkingTime(currentDate) currentDate: "yyyy-MM-dd HH🇲🇲ss"或者"yyyy-MM-dd HH:mm"格式的字符串 判断输入的时间是否为工作时间
isWorkingTimeByCalendar(currentDate, calendarId) currentDate: "yyyy-MM-dd HH🇲🇲ss"或者"yyyy-MM-dd HH:mm"格式的字符串Calendared:工作日历Id 判断输入的时间是否为工作时间对应工作日历
isWorkingTimeByCalendarName(currentDate, calendarName, domainid) currentDate: "yyyy-MM-dd HH🇲🇲ss" 或者 "yyyy-MM-dd HH:mm" 格式的字符串 Calendared:工作日历Id domainid:企业域ID 判断输入的时间是否为工作时间对应工作日历
createPdf(fileName,formId) fileName: 生成pdf名称(有重复文件会覆盖)formId:表单id 返回pdf路径
recordSignatrueAmounts() 记录当前节点需要签章的数量(在提交执行后脚本使用)
checkIsAllUserDoSignature() 检查当前节点是否全部签章了(在提交执行后脚本使用)
isSignature(position) Position:签章位置文本 判断该位置是否已经签章(金格PDF签章),在金格电子签章按钮控件的隐藏脚本中使用
checkSignatureAmounts() 检查当前节点是否全部签章了(在提交执行后脚本使用)
deleteSignatures(deleteDocId) deleteDocId:对应删除的文档id 删除回退节点内的签章(在回退的执行后脚本中使用)
sendDingdingMessage(title,description, touser, url, doc, type); title:标 description:内容 touser:用户钉钉id(没有钉钉id传用户id) url:链接地址 doc:文档对象 type:发送类型(oa、text、link) 钉钉发送消息
recognizeAdvanced(url) url 图片文件URL 提取结果

方法示例

1.getOptionsByDQL(dql, keyFieldName, blankFirst)

作用:实现getOptionsByDQL(dql, keyFieldName, blank)函数的应用,返回符合查询条件语句的文档中keyFieldName字段的所有值集合,作为下拉框控件的选项

脚本示例:

//表单某控件的选项为指定表单指定指定字段的值
(() => {
    let opts = $TOOLS.createOptions();
    const dql = "$formname ='获取当前软件下的所有角色'";
    const n = getOptionsByDQL(dql, "角色", true);
    return n;
})()

2.getWorkingDayCount(startDate, endDate)

作用:实现getWorkingDayCount(startDate, endDate)函数的应用,获取相隔工作天数

脚本示例:

//表单某控件为两个指定日期相隔的工作天数
(() => {
    const starttime = getItemValueAsDate("开始日期");
    const deadline = getItemValueAsDate("结束日期");
    if (starttime != null && deadline != null) {
        const startDate = format(starttime, "yyyy-MM-dd HH:mm:ss");
        const endDate = format(deadline, "yyyy-MM-dd HH:mm:ss");
        const retvar = DATE.getWorkingDayCount(startDate, endDate);
    }
    return retvar;
})()

3.getWorkingTimesCount(startDate, endDate)

作用:实现getWorkingTimesCount(startDate, endDate)函数的应用,获取相隔工作小时数

脚本示例:

//表单某控件为两个指定日期相隔的工作小时数
(() => {
    const starttime = getItemValueAsDate("开始日期");
    const deadline = getItemValueAsDate("结束日期");
    if (starttime != null && deadline != null) {
        const startDate = format(starttime, "yyyy-MM-dd HH:mm:ss");
        const endDate = format(deadline, "yyyy-MM-dd HH:mm:ss");
        const retvar = DATE.getWorkingTimesCount(startDate, endDate);
    }
    return retvar;
})()

4.isWorkingTime(currentDate)

作用:实现isWorkingTime(currentDate)函数的应用,判断输入的时间是否为工作时间

脚本示例:

//表单中有一个日期控件,日期的格式为年月日时分,然后单行文本框的值脚本写代码,
//根据日期控件的值是否为工作时间来确实给单行文本框不同的值,具体的代码如下(第二个方法中的第二个参数是工作日历的id)
(() => {
    const value = getItemValueAsDate("时间");
    let rtn = "";
    if (value != null) {
        const datevalue = $TOOLS.DATE_UTIL.getDateTimeStr(value);
        if (DATE.isWorkingTime(datevalue)) {
            rtn = "当前输入的时间是该用户的工作时间";
        } else {
            rtn = "当前输入的时间是该用户的非工作时间,用户可以自由安排";
        }
    }
    return rtn;
})()

5.isWorkingTimeByCalendar(currentDate, calendarId)

作用:实现isWorkingTimeByCalendar(currentDate, calendarId)函数的应用,判断输入的时间是否为工作时间

脚本示例:

//表单中有一个日期控件,日期的格式为年月日时分,然后单行文本框的值脚本写代码,
//根据日期控件的值是否为工作时间来确实给单行文本框不同的值,具体的代码如下(第二个方法中的第二个参数是工作日历的id)
(() => {
    const value = getItemValueAsDate("时间");
    let rtn = "";
    if (value != null) {
        const datevalue = $TOOLS.DATE_UTIL.getDateTimeStr(value);
        if (DATE.isWorkingTimeByCalendar(datevalue, '11e2-05e6-8f8919db-8903-4be494916f5a')) {
            rtn = "当前输入的时间是该用户的工作时间";
        } else {
            rtn = "当前输入的时间是该用户的非工作时间,用户可以自由安排";
        }
    }
    return rtn;
})()

6.isWorkingTimeByCalendarName(currentDate, calendarId, domainid)

作用:实现isWorkingTimeByCalendarName(currentDate, calendarId, domainid)函数的应用,判断输入的时间是否为工作时间

脚本示例:

//表单中有一个日期控件,日期的格式为年月日时分,然后单行文本框的值脚本写代码,
(() => {
    const value = getItemValueAsDate("时间");
    let rtn = "";
    if (value != null) {
        const datevalue = $TOOLS.DATE_UTIL.getDateTimeStr(value);
        if (DATE.isWorkingTimeByCalendarName(datevalue, '11e2-05e6-8f8919db-8903-4be494916f5a',getDomainid())) {
            rtn = "当前输入的时间是该用户的工作时间";
        } else {
            rtn = "当前输入的时间是该用户的非工作时间,用户可以自由安排";
        }
    }
    return rtn;
})()

7.createPdf(fileName,formId)

作用:实现createPdf(fileName,formId)函数的应用,返回pdf路径

脚本示例:

(() => {     
    const fileName = "我是pdf";  
    const formId = "AJDI0_ADA_ADARQ_QE";
    //调用生成pdf方法
    PDF.createPdf(fileName,formId);         
})()

8.recordSignatrueAmounts()

作用:实现recordSignatrueAmounts()函数的应用

脚本示例:

//调用记录当前节点需要签章的数量方法
(() => {
    PDF.recordSignatrueAmounts();
})()

9.checkIsAllUserDoSignature()

作用:checkIsAllUserDoSignature()函数的应用

脚本示例:

//检查当前节点是否全部签章了
(() => {
    PDF.checkIsAllUserDoSignature();
})()

10.isSignature(position)

作用:实现isSignature(position)函数的应用,返回是否已经签章

脚本示例:

//判断该位置是否已经签章方法
(() => {
    const position = "主管签章";
    const result = PDF.isSignature(position);
})()

11.checkSignatureAmounts()

作用:实现checkSignatureAmounts()函数的应用

脚本示例:

//调用检查当前节点是否全部签章了方法
(() => {
    PDF.checkSignatureAmounts();
})()

12.deleteSignatures(deleteDocId)

作用:实现deleteSignatures(deleteDocId)函数的应用

脚本示例:

//调用删除回退节点内的签章方法
(() => {
    var deleteDocId = "AJDI0_ADA_ADARQ_QE";
    PDF.deleteSignatures(deleteDocId)
})()

13.sendDingdingMessage(title,description, touser, url, doc, type)

作用:实现钉钉发送消息

脚本示例:

//消息类型为text时,title和url可传空,消息为oa时,url可传空
(() => {
    const doc = getCurrentDocument();
    sendDingdingMessage("标题1", "内容1", "manager1234", "https://www.baidu.com/", doc, "link");
})()

14.recognizeAdvanced(url)

作用:通用文字识别-高精版 OCR 文字识别

脚本示例:

//高精版 OCR 文字识别 解析url中图片文字内容返回 需要绑定企业域中云能力账号使用
(() => {
    const url = "xxxxx"     // 图片的url
    const OcrUtilValue = recognizeAdvanced(url);
    return OcrUtilValue;
})();