[云之家][智能审批][个性化]考勤假期提醒

120 阅读1分钟
<script type="text/javascript">

// 等待 CloudForm 初始化完毕

cf.ready(function () {

// 添加事件钩子,例如在表单提交前获取请假天数

cf.addEventHook(cf.EVENT_HOOKS.BEFORE_SUBMIT, function (next) {

// 获取明细控件值,假设明细控件的 ID 是 '_S_INT_LEAVE_DETAILED'

var detailWidgetValue = cf.form.getFieldValue('_S_INT_LEAVE_DETAILED');

  


// 如果明细控件有值

if (detailWidgetValue && detailWidgetValue.widgetValue) {

var widgetValue = detailWidgetValue.widgetValue; // 获取明细控件中的值

var totalLeaveDays = 0; // 初始化总请假天数为0

  


// 遍历每行明细值,计算请假天数

for (var i = 0; i < widgetValue.length; i++) {

var item = widgetValue[i]; // 取出当前行的项

// 确保这里转换为数字,并累加到总请假天数中

totalLeaveDays += Number(item['_S_INT_LEAVE_DAYS']) || 0; // 使用你提供的请假天数 ID

}

// 检查总请假天数是否大于或等于3

if (totalLeaveDays >= 3) {

// 弹出警告提示

var payload = {

title: "温馨提示", // 弹窗标题

content: "请合理安排休假时间,提前做好工作交接", // 弹窗内容

confirmBtnTxt: '我知道了' // 确认按钮文本

};

// 调用 alert 弹出警告弹窗

cf.call("alert", payload)

.then(() => {

// 用户点击确定后的逻辑

next(); // 继续提交表单

});

} else {

// 如果请假天数少于3天,继续提交表单

next();

}

}

});

});

</script>

image.png