66bb39d1-dfec-4d09-ab08-31d426d925判断值是否为是,解锁按钮,【表单展示是如果为是,也解锁按钮】
//预勘测不为是,则锁定是否提报
export async function checkdata() {
//判断是否预勘测
const bo = await sdk.getValue("text_12");
console.log(bo)
if (!bo || !bo.value || bo.value.text !== "是") {
//锁定提报按键,并且将单项选择设定否
const bbb = await sdk.setValue('text_15', { text: '否',value: "63e6f6b3-c7a7-03d7-729c-f0da4e13f0e3"})
console.log(bbb)
await sdk.disableField("text_15")
}
else {
//解锁提报按键
await sdk.enableField("text_15")
}
}
开工时间范围规定,包含数据执行条件
//验证日期填写规范
export async function KHD() {
// 获取项目经理
const xmjl = await sdk.getValue("text_18");
// 检查项目经理是否为空或未定义
if (!xmjl || xmjl.value === null || xmjl.value === undefined) {
// 如果项目经理为空或未定义,继续执行下面的代码
} else {
return; // 如果项目经理不为空,不执行下面的代码
}
// 获取用户选择的日期
const dd = await sdk.getValue("date_2");
// 检查用户是否已选择日期
if (!dd || !dd.value) {
console.log("错误:您还没有选择日期");
// 在这里可以添加更多逻辑,如显示错误提示给用户
return;
}
const selectedDate = new Date(dd.value * 1000);
// 获取当前日期
const currentDate = new Date();
console.log("选定日期:", selectedDate);
console.log("当前日期:", currentDate);
// 获取当前月份和年份
const currentMonth = currentDate.getMonth();
const currentYear = currentDate.getFullYear();
// 定义范围的起始日期和结束日期
let rangeStartDate, rangeEndDate;
if (currentDate.getDate() >= 1 && currentDate.getDate() <= 15) {
// 当月的1号到15号,用户只能选择当月的16号及之后的日期
rangeStartDate = new Date(currentYear, currentMonth, 16);
rangeEndDate = new Date(currentYear, currentMonth, 31);
console.log("在当前月的1号到15号范围内,只能选择当月的16号及之后的日期");
} else {
// 当月的16号之后,用户只能选择下个月的1号到15号的日期
const nextMonth = (currentMonth + 1) % 12;
const nextYear = (currentMonth === 11) ? currentYear + 1 : currentYear;
rangeStartDate = new Date(nextYear, nextMonth, 1);
rangeEndDate = new Date(nextYear, nextMonth, 15);
console.log("在当前月的16号之后,只能选择下个月的1号到15号的日期");
}
// 检查用户选择的日期是否在允许的范围内
if (selectedDate >= rangeStartDate && selectedDate <= rangeEndDate) {
console.log("选定日期在范围内");
// 在这里可以添加范围内日期的逻辑
} else {
console.log("错误:选定日期不在范围内");
await sdk.showToast({
type: "warning",
content: "预排期时间不在规定范围内,将无法提交!",
time: 3000
});
return false
// 在这里可以添加不在范围内日期的逻辑
}
}
验证数据是否可以继续执行
export async function KH(){
// 通过sdk.getValue获取信息
// 字段可以被隐藏
const 签单后服务开启 = await sdk.getValue("text_36");
// 使用console.log打印获取的结果
console.log("获取的是否签单后服务开启的值:", 签单后服务开启);
// 赋值信息到N
const N = 签单后服务开启.value;
// 使用console.log打印赋值后的N
console.log("赋值后的N:", N);
// 判断信息是否符合
if(N != "是"){
// 使用console.log打印不符合的提示
console.log("不满足开工报批的要求");
// 弹出提示
await sdk.showToast({
type: "warning",
content: "不满足开工的要求,请确认合同订单!"
});
// 拒绝数据提交
return false;
}
}
功能:通过判断数据,提交过程中,配置弹出窗口按钮赋值数据。 主要作用:做一个全局代码,来判断是否脚本是否执行,如果执行则跳过
//--------分割线--------
//提交前判单代码
let tijiaoExecuted = false; // 添加标志,表示是否已经执行过 tijiao
export async function infomsg() {
try {
//获取提报按键的值
const text15Value = (await sdk.getValue("text_15")).value;
console.log(text15Value);
//获取项目经理的值
const xmjlValue = (await sdk.getValue("text_18")).value;
console.log(xmjlValue);
//是否提报的值等于是 并且 项目经理的值等于undefined
// if (text15Value === "是" && xmjlValue === undefined) {
// await sdk.setValue('text_15', { text: '否', value: "63e6f6b3-c7a7-03d7-729c-f0da4e13f0e3" });
// console.log("text_15 的强制设置值为 '否'并且跳过执行。");
if(xmjlValue === undefined){
const res = await sdk.alert({
title: '温馨提示',
content: '交付部正在安排项目经理',
confirmButtonText: '确认'
});
if(res.confirm){
console.log("暂停表单提交点击后继续");
return;
}else{
console.log("取消阻塞");
return false;
}
}else{
console.log("继续执行下面指令")
}
// 继续执行下面的代码
// ...
// 获取登录用户信息
const userInfo = await sdk.getUserInfo();
console.log(userInfo.roleIds);
// 检查是否包含30727,如果包含则直接跳过后续操作
// 不能使用includes 备注未修改
if (userInfo.roleIds.includes("30727")) {
console.log("用户包含角色30727,跳过执行。");
return;
}
//如果不包含30727并且项目经理不等于空值,则继续执行下面操作
const [a, b, c, d] = await Promise.all([
sdk.getValue("date_2"),
sdk.getValue("text_12"),
sdk.getValue("text_18"),
sdk.getValue("text_11")
]);
//判断审核是否通过,如果为是,直接跳过后续指令
if(d.value.text === "是"){
console.log("审核通过,跳过执行")
return;
}
if (a.value !== null && b.value.text === '是' && c.value.text !== null) {
tijiaoExecuted = true; // 直接表示已经触发
const result = await sdk.confirm({
title: '温馨提示',
content: '是否通知核算部,开始审批【纸质资料】。',
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning'
});
const value = result.confirm
? { text: '是', value: "1e230627-e839-8320-11c7-101d2686c9e2" }
: { text: '否', value: "63e6f6b3-c7a7-03d7-729c-f0da4e13f0e3" };
await sdk.setValue('text_15', value);
// 在这里处理确认后的逻辑,主要起阻塞的作用。
if (result.confirm) {
// 处理确认后的逻辑
console.log("点击了确认按钮");
// 继续执行其他代码
console.log("继续执行其他代码");
} else {
// 处理取消后的逻辑
console.log("点击了取消按钮");
}
} else {
console.log("条件满足。");
return "条件满足。";
}
} catch (error) {
// 处理错误
console.error("发生错误:", error);
}
}
功能:根据情况配置字段 主要作用:优化条件来配置字段
//当项目经理变成空的时候,是否提交变成否
export async function xmjl1(){
const assd =await sdk.getValue("text_11")
const ass = await sdk.getValue("text_18")
if(assd.value.text === "否"){
if(ass.value === undefined){
await sdk.setValue('text_15', { text: '否', value: "63e6f6b3-c7a7-03d7-729c-f0da4e13f0e3" });
}
}
}
通过查询数据,来提示是否有重复的表单。
//延迟触发函数创建
async function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export async function chongcheck(){
try{//延迟触发,避免查询信息错误。
const datatype = await sdk.getLowCodeType();
if(datatype.type === "edit"){
console.log("编辑模式不继续执行。")
return;
}
await delay(3000);
//直接获取客户流水号值
const a = (await sdk.getValue("text_10")).value;
const b = await cc(a);
console.log(b)
if(b.data.paasFormDataESList && b.data.paasFormDataESList.length > 0){
await sdk.alert({
title: '温馨提示',
content: '您已创建过客户信息,请勿重新创建!',
confirmButtonText: '确认'
});
return false;
}else{
console.log("正常触发")
}
}
catch{
console.log("发生错误。")
}
}
async function cc(dateid,page = 1) {
return await sdk.getFormDataList({
appId: 758244,
menuId: 8313500,
saasMark: 2,
businessType: 0,
subBusinessType: 0,
formId: 7524824,
conditions: [{"attr":"text_10","fieldType":1,"symbol":"equal","value":[dateid]}],
page: page,
pageSize: 20
})
}