//保存前校验

      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;
}

最新文章

  1. 解读ASP.NET 5 &amp; MVC6系列(5):Configuration配置信息管理
  2. js self = this的解释
  3. regexxx
  4. Eratosthenes筛选法构造1-n 素数表
  5. Scrum 项目 6.0 sprint演示
  6. AC自动机入门
  7. 【uTenux实验】写在开始实验之前
  8. Maven - 项目结构
  9. oracle 存储过程 基础
  10. 转 -Linux 自检和 SystemTap (强大的内核调试工具)---包含下载地址
  11. 使用VNC实现多用户登录linux系统
  12. lucene 从2.4.0—3.6.0—4.3.1版本升级
  13. VBS虚拟键码
  14. 【京东详情页】——原生js爬坑之标签页
  15. 部署Chart应用并使用.net core读取Kubernetes中的configMap
  16. redis的特点
  17. mycat使用之MySQL单库分表及均分数据
  18. Javascript数组系列三之迭代方法2
  19. 关于next.js中的css
  20. Java获取资源路径——(八)

热门文章

  1. 优化 Win11 资源管理器打开文件夹速度
  2. 溢出标志位OF与进位标志位CF判断
  3. mock模拟数据使用教程
  4. Spark Streaming实时计算
  5. react快速创建组件
  6. C++ MFC学习 (五)
  7. Cisco ASA防火墙恢复密码和基本配置
  8. Python 闭包,生成式,推导式
  9. 关于el-popover的箭头颜色
  10. Vue 项目中实现的微信、微博、QQ空间分享功能(亲测有效)