util.js 736 B

12345678910111213141516171819202122232425262728293031
  1. //项目指引类型
  2. const itemType = {
  3. job: 0,
  4. ration: 1
  5. };
  6. function _isDef(v) {
  7. return typeof v !== 'undefined' && v !== null;
  8. }
  9. // 是否为工序行
  10. function isProcessNode(node) {
  11. return node && node.depth() % 2 === 0 && _isDef(node.data.type) && node.data.type === itemType.job
  12. }
  13. // 是否是选项行
  14. function isOptionNode(node) {
  15. return node && node.depth() % 2 === 1 && _isDef(node.data.type) && node.data.type === itemType.job
  16. }
  17. function setTimeoutSync(handle, time) {
  18. return new Promise(function (resolve, reject) {
  19. setTimeout(function () {
  20. if (handle && typeof handle === 'function') {
  21. handle();
  22. }
  23. resolve();
  24. }, time);
  25. });
  26. }