sjs_setting.js 4.5 KB

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