sjs_setting.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. const sjsSettingObj = (function () {
  2. const FxTreeStyle = {
  3. jz: 'jianzhu',
  4. };
  5. const setJzFxTreeStyle = function (setting) {
  6. setting.selectedBackColor = '#fffacd';
  7. setting.tree = {
  8. getFont: function (sheet, data, row, col, defaultFont) {
  9. if (sheet.zh_tree) {
  10. const levelField = sheet.zh_tree.setting.level;
  11. return data[levelField] === 1 ? 'bold ' + defaultFont : defaultFont;
  12. } else {
  13. return defaultFont;
  14. }
  15. },
  16. getColor: function (sheet, data, row, col, defaultColor) {
  17. if (sheet.zh_tree) {
  18. const levelField = sheet.zh_tree.setting.level;
  19. if (data[levelField] === 2) {
  20. return '#C4CAFB';
  21. } else if ((!data.b_code || data.b_code === '') && data[levelField] > 2) {
  22. return '#DFE8F9';
  23. } else {
  24. return defaultColor;
  25. }
  26. } else {
  27. return defaultColor;
  28. }
  29. }
  30. }
  31. };
  32. const setFxTreeStyle = function (setting, tag) {
  33. switch (tag) {
  34. case FxTreeStyle.jz:
  35. setJzFxTreeStyle(setting);
  36. break;
  37. }
  38. };
  39. const setGridSelectStyle = function (setting) {
  40. setting.selectedBackColor = '#fffacd';
  41. };
  42. const setTpThousandthFormat = function (setting, fields = []) {
  43. for (const col of setting.cols) {
  44. if (col.field === 'total_price' || col.field.indexOf('tp') >= 0 || fields.indexOf(col.field) >= 0)
  45. col.formatter = '#,##0.######';
  46. }
  47. };
  48. const setThousandthFormat = function (setting, fields) {
  49. for (const f of fields) {
  50. const col = setting.cols.find(function (x) {
  51. return x.field === f
  52. });
  53. if (col) col.formatter = '#,##0.######';
  54. }
  55. };
  56. const setTpColsThousandthFormat = function (cols, fields = []) {
  57. for (const col of cols) {
  58. if (col.field === 'total_price' || col.field.indexOf('tp') >= 0 || fields.indexOf(col.field) >= 0)
  59. col.formatter = '#,##0.######';
  60. }
  61. };
  62. const setPropValue = function (setting, fields, prop, value) {
  63. for (const f of fields) {
  64. const col = setting.cols.find(function (x) {
  65. return x.field === f
  66. });
  67. if (col) col[prop] = value;
  68. }
  69. };
  70. const set3FCols = function (cols, rela) {
  71. for (const r of rela) {
  72. const col = _.find(cols, {field: r.field});
  73. if (col) {
  74. col.getValue = r.getValue;
  75. col.cellType = 'imageBtn';
  76. col.normalImg = '#rela-file-icon';
  77. col.indent = 12;
  78. col.imgAlign = 2;
  79. col.showImage = function (data) { return data && data[r.url_field]; }
  80. }
  81. }
  82. };
  83. const setQcCols = function (cols, rela){
  84. for (const r of rela) {
  85. const col = _.find(cols, {field: r.field});
  86. if (!col) continue;
  87. col.readOnly = true;
  88. col.cellType = 'activeImageBtn';
  89. col.normalImg = '#ellipsis-icon';
  90. col.indent = 5;
  91. col.showImage = r.showImage;
  92. }
  93. };
  94. const setOrgPriceCol = function (cols, rela) {
  95. for (const r of rela) {
  96. const col = _.find(cols, {field: r.field});
  97. if (col) {
  98. col.getValue = function (data) { return data.contract_pc_tp || data.qc_pc_tp || data.pc_tp ? data.org_price : null; };
  99. }
  100. }
  101. };
  102. const setNodeTypeCol = function (cols, rela) {
  103. for (const r of rela) {
  104. const col = _.find(cols, {field: r.field});
  105. if (col) {
  106. col.comboItems = nodeType;
  107. col.cellType = 'specCombo';
  108. col.comboEdit = function (sheet, data) {
  109. if (!data) return false;
  110. const tree = sheet.zh_tree;
  111. if (!tree) return false;
  112. const parent = tree.getParent(data);
  113. if (!parent) return false;
  114. const topParent = tree.getTopParent(data);
  115. return [1, 5].indexOf(topParent.node_type) >= 0;
  116. };
  117. }
  118. }
  119. };
  120. return {
  121. setFxTreeStyle, FxTreeStyle, setGridSelectStyle,
  122. setTpThousandthFormat, setThousandthFormat, setTpColsThousandthFormat,
  123. setPropValue, set3FCols, setQcCols, setOrgPriceCol, setNodeTypeCol,
  124. };
  125. })();