BIP 两个请求成功后,才能做某一件事
2024-10-21 17:47:03
//保存前校验 let SetXStatus = 0;
viewModel.on("beforeSave", function (args) {
let _this = this;
console.log(_this); let rows = viewModel.getGridModel().getRows();
if (rows <= 0) {
cb.utils.alert("未匹配到认证方案,无法保存单据!", "error");
return false;
} var promisex = new cb.promise();
this.SetXStatus = 0; Promise.all([supMaterial(_this), SetsupCertTask(_this)]).then((res) => { if (_this.SetXStatus == 0) {
console.log("失败");
promisex.reject(); // 失败
} else if (_this.SetXStatus == 1) {
console.log("失败");
promisex.reject(); // 失败
} else if (_this.SetXStatus == 2) {
console.log("放行");
promisex.resolve(); // 放行
}
}); return promisex; // -------------------------------
}); function supMaterial(_this) {
// let _this = this;
let proxy = viewModel.setProxy({
ensure: {
url: "/supCertTask/supMaterial",
method: "POST",
},
});
let param = {
state: viewModel.getParams().mode,
certMaterialClass: viewModel.get("certMaterialClass").getValue(),
certSupplier: viewModel.get("certSupplier").getValue(),
}; var promise = new cb.promise();
proxy.ensure(param, function (error, result) {
if (_this.SetXStatus == 0) {
_this.SetXStatus = 1;
} else if (_this.SetXStatus == 1) {
_this.SetXStatus = 2;
} if (!result) {
_this.SetXStatus = 0;
cb.utils.alert(
"存在同一供应商和物料分类的未完成的供应商认证任务,当前不允许新增同一维度的认证任务!",
"error"
);
promise.reject(); // 失败
}
promise.resolve(); // 放行
});
return promise;
} function SetsupCertTask(_this) {
// let _this = this;
var prom = new cb.promise();
let proxy = viewModel.setProxy({
ensure: {
url: "/supCertTask/savebefore",
method: "POST",
},
}); let tempIds = [];
let Rows = viewModel.getGridModel().getRows(); if (Rows.length > 0) {
for (let i = 0; i < Rows.length; i++) {
tempIds.push(Rows[i]["tempId"]);
}
} let param = {
tempIds: tempIds,
count: viewModel.getGridModel().getRows().length,
id: viewModel.get("certstepId").getValue(),
};
proxy.ensure(param, function (error, result) {
if (_this.SetXStatus == 0) {
_this.SetXStatus = 1;
} else if (_this.SetXStatus == 1) {
_this.SetXStatus = 2;
} if (result.flag == "true") {
} else {
_this.SetXStatus = 0;
cb.utils.alert(
result.msg || "上游任认证方案数据异常,请确认和重试",
"error"
);
prom.reject(); // 失败
}
prom.resolve(); // 放行
});
return prom;
}
最新文章
- 解读ASP.NET 5 &; MVC6系列(5):Configuration配置信息管理
- js self = this的解释
- regexxx
- Eratosthenes筛选法构造1-n 素数表
- Scrum 项目 6.0 sprint演示
- AC自动机入门
- 【uTenux实验】写在开始实验之前
- Maven - 项目结构
- oracle 存储过程 基础
- 转 -Linux 自检和 SystemTap (强大的内核调试工具)---包含下载地址
- 使用VNC实现多用户登录linux系统
- lucene 从2.4.0—3.6.0—4.3.1版本升级
- VBS虚拟键码
- 【京东详情页】——原生js爬坑之标签页
- 部署Chart应用并使用.net core读取Kubernetes中的configMap
- redis的特点
- mycat使用之MySQL单库分表及均分数据
- Javascript数组系列三之迭代方法2
- 关于next.js中的css
- Java获取资源路径——(八)