ledger_tree_col.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const ledgerTreeCol = {
  10. readOnly: {
  11. unit_price: function (node) {
  12. return node.children && node.children.length > 0;
  13. },
  14. quantity: function (node) {
  15. return (node.children && node.children.length > 0) || _.isEmpty(node.b_code);
  16. },
  17. total_price: function (node) {
  18. return node.children && node.children.length > 0;
  19. }
  20. },
  21. getEvent: function (eventName) {
  22. const names = eventName.split('.');
  23. let event = this;
  24. for (let name of names) {
  25. if (event[name]) {
  26. event = event[name];
  27. } else {
  28. return null;
  29. }
  30. }
  31. if (event && Object.prototype.toString.apply(event) !== "[object Function]") {
  32. return null;
  33. } else {
  34. return event;
  35. }
  36. },
  37. initSpreadSetting(setting) {
  38. for (const col of setting.cols) {
  39. if (col.readOnly && Object.prototype.toString.apply(col.readOnly) === "[object String]") {
  40. col.readOnly = this.getEvent(col.readOnly);
  41. }
  42. }
  43. }
  44. };