rpt_tpl_cfg_helper.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /**
  2. * Created by Tony on 2017/12/8.
  3. */
  4. let rpt_tpl_cfg_helper = {
  5. reportCfg: null,
  6. getReportTplCfg: function() {
  7. let me = this, params = {};
  8. params.userId = userID;
  9. CommonAjax.postEx("report_tpl_api/getUserRptCfg", params, 20000, true, function(result){
  10. me.reportCfg = result;
  11. me.refreshRptCfgs();
  12. }, null, null
  13. );
  14. },
  15. refreshRptCfgs: function () {
  16. let me = this;
  17. if (me.reportCfg) {
  18. me.reportCfg.borderArr = [];
  19. for (let style of me.reportCfg.styles) {
  20. me.reportCfg.borderArr.push(style.ID);
  21. $("#borderStyles").append("<option value='" + style.ID + "'>" + style.CfgDispName + "</option>");
  22. $("#elementBorders").append("<option value='" + style.ID + "'>" + style.CfgDispName + "</option>");
  23. }
  24. me.reportCfg.fontArr = [];
  25. for (let font of me.reportCfg.fonts) {
  26. if (font.CfgDispName) {
  27. me.reportCfg.fontArr.push(font.ID);
  28. $("#elementFonts").append("<option value='" + font.ID + "'>" + font.CfgDispName + "</option>");
  29. } else {
  30. // me.reportCfg.fontArr.push("dummy font");
  31. }
  32. }
  33. me.reportCfg.fontArr.push('自定义');
  34. $("#elementFonts").append("<option value='自定义'>自定义</option>");
  35. me.reportCfg.controlArr = [];
  36. for (let control of me.reportCfg.ctrls) {
  37. if (control.CfgDispName) {
  38. me.reportCfg.controlArr.push(control.ID);
  39. $("#elementControls").append("<option value='" + control.ID + "'>" + control.CfgDispName + "</option>");
  40. } else {
  41. me.reportCfg.controlArr.push("dummy control");
  42. }
  43. }
  44. }
  45. let pf = $("#pageFrequency");
  46. pf.append("<option value='" + JV.PAGE_STATUS[0] + "'>每页</option>");
  47. pf.append("<option value='" + JV.PAGE_STATUS[1] + "'>首页</option>");
  48. pf.append("<option value='" + JV.PAGE_STATUS[2] + "'>尾页</option>");
  49. pf.append("<option value='" + JV.PAGE_STATUS[3] + "'>章首页</option>");
  50. pf.append("<option value='" + JV.PAGE_STATUS[4] + "'>章尾页</option>");
  51. pf.append("<option value='" + JV.PAGE_STATUS[5] + "'>分组</option>");
  52. pf.append("<option value='" + JV.PAGE_STATUS[6] + "'>交叉行尾页</option>");
  53. pf.append("<option value='" + JV.PAGE_STATUS[7] + "'>交叉列尾页</option>");
  54. let ba = $("#bandAlignment");
  55. ba.append("<option value='" + JV.LAYOUT[0] + "'>上</option>");
  56. ba.append("<option value='" + JV.LAYOUT[1] + "'>下</option>");
  57. ba.append("<option value='" + JV.LAYOUT[2] + "'>左</option>");
  58. ba.append("<option value='" + JV.LAYOUT[3] + "'>右</option>");
  59. ba.append("<option value='" + JV.LAYOUT[4] + "'>填充</option>");
  60. let ha = $("#elementAlignmentHorizon");
  61. ha.append("<option value='" + JV.OUTPUT_ALIGN.H[0] + "'>左</option>");
  62. ha.append("<option value='" + JV.OUTPUT_ALIGN.H[1] + "'>中</option>");
  63. ha.append("<option value='" + JV.OUTPUT_ALIGN.H[2] + "'>右</option>");
  64. let va = $("#elementAlignmentVertical");
  65. va.append("<option value='" + JV.OUTPUT_ALIGN.V[0] + "'>上</option>");
  66. va.append("<option value='" + JV.OUTPUT_ALIGN.V[1] + "'>中</option>");
  67. va.append("<option value='" + JV.OUTPUT_ALIGN.V[2] + "'>下</option>");
  68. },
  69. checkAndSetSelectedNodeCfg: function (treeNode) {
  70. let me = rpt_tpl_cfg_helper;
  71. if (treeNode[JV.PROP_AREA]) {
  72. $("#element_font")[0].style.display = "";
  73. $("#element_border")[0].style.display = "";
  74. $("#element_control")[0].style.display = "";
  75. //setup font
  76. let fontDom = $("#elementFonts").get(0);
  77. fontDom.removeAttribute("disabled")
  78. let fontAttr = treeNode[JV.PROP_FONT];
  79. if (typeof treeNode[JV.PROP_FONT] !== "string") {
  80. fontAttr = "自定义";
  81. }
  82. let idx = me.reportCfg.fontArr.indexOf(fontAttr);
  83. fontDom.selectedIndex = idx;
  84. me.fontChange(fontDom);
  85. //setup border
  86. let borderDom = $("#elementBorders").get(0);
  87. let borderAttr = treeNode[JV.PROP_STYLE];
  88. idx = me.reportCfg.borderArr.indexOf(borderAttr);
  89. borderDom.selectedIndex = idx;
  90. me.borderChange(borderDom);
  91. //setup control
  92. let ctrlDom = $("#elementControls").get(0);
  93. let ctrlAttr = treeNode[JV.PROP_CONTROL];
  94. idx = me.reportCfg.controlArr.indexOf(ctrlAttr);
  95. ctrlDom.selectedIndex = idx;
  96. me.controlChange(ctrlDom);
  97. } else {
  98. $("#elementFonts").get(0).disabled = "disabled" ;
  99. $("#element_font")[0].style.display = "none";
  100. $("#element_border")[0].style.display = "none";
  101. $("#element_control")[0].style.display = "none";
  102. }
  103. },
  104. fontChange: function(dom) {
  105. let me = rpt_tpl_cfg_helper, fontAttr = dom.value;
  106. //dataInfoMapTreeOprObj.currentNode
  107. if (fontAttr === "自定义") {
  108. fontAttr = dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT];
  109. if (typeof fontAttr === "string") {
  110. fontAttr = {};
  111. fontAttr[JV.FONT_PROPS[0]] = "宋体";
  112. fontAttr[JV.FONT_PROPS[1]] = 12;
  113. fontAttr[JV.FONT_PROPS[2]] = "BLACK";
  114. fontAttr[JV.FONT_PROPS[3]] = "F"; //bold
  115. fontAttr[JV.FONT_PROPS[4]] = "F"; //italic
  116. fontAttr[JV.FONT_PROPS[5]] = "F"; //underline
  117. fontAttr[JV.FONT_PROPS[6]] = "F"; //strikeout
  118. fontAttr[JV.FONT_PROPS[7]] = 0; //angle
  119. dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT] = fontAttr;
  120. }
  121. } else {
  122. dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT] = fontAttr;
  123. }
  124. me.private_setup_font(fontAttr);
  125. },
  126. private_setup_font: function(fontAttr) {
  127. let me = rpt_tpl_cfg_helper;
  128. if (typeof fontAttr === "string" && fontAttr !== "自定义") {
  129. $("#eleFontName").get(0).disabled = "disabled" ;
  130. $("#eleFontSize").get(0).disabled = "disabled" ;
  131. $("#eleFontBold").get(0).disabled = "disabled" ;
  132. $("#eleFontItalic").get(0).disabled = "disabled" ;
  133. $("#eleFontUnderline").get(0).disabled = "disabled" ;
  134. let idx = me.reportCfg.fontArr.indexOf(fontAttr);
  135. $("#elementFonts").get(0).selectedIndex = idx;
  136. let font = me.reportCfg.fonts[idx];
  137. $("#eleFontName").get(0).value = font.Name;
  138. $("#eleFontSize").get(0).value = parseInt(font.FontHeight);
  139. $("#eleFontBold").get(0).checked = stringUtil.convertStrToBoolean(font.FontBold);
  140. $("#eleFontItalic").get(0).checked = stringUtil.convertStrToBoolean(font.FontItalic);
  141. $("#eleFontUnderline").get(0).checked = stringUtil.convertStrToBoolean(font.FontUnderline);
  142. } else {
  143. //$("#elementFonts").get(0).selectedIndex = idx;
  144. $("#eleFontName").get(0).removeAttribute("disabled");
  145. $("#eleFontSize").get(0).removeAttribute("disabled");
  146. $("#eleFontBold").get(0).removeAttribute("disabled");
  147. $("#eleFontItalic").get(0).removeAttribute("disabled");
  148. $("#eleFontUnderline").get(0).removeAttribute("disabled");
  149. $("#eleFontName").get(0).value = fontAttr.Name;
  150. $("#eleFontSize").get(0).value = parseInt(fontAttr.FontHeight);
  151. $("#eleFontBold").get(0).checked = stringUtil.convertStrToBoolean(fontAttr.FontBold);
  152. $("#eleFontItalic").get(0).checked = stringUtil.convertStrToBoolean(fontAttr.FontItalic);
  153. $("#eleFontUnderline").get(0).checked = stringUtil.convertStrToBoolean(fontAttr.FontUnderline);
  154. }
  155. },
  156. fontNameChange: function(dom){
  157. let font = dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT];
  158. font[JV.FONT_PROPS[0]] = dom.value;
  159. },
  160. fontSizeChange: function(dom) {
  161. let font = dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT];
  162. font[JV.FONT_PROPS[1]] = dom.value;
  163. },
  164. fontBoldChange: function(dom) {
  165. let font = dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT];
  166. font[JV.FONT_PROPS[3]] = dom.checked?'T':'F';
  167. },
  168. fontItalicChange: function(dom) {
  169. let font = dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT];
  170. font[JV.FONT_PROPS[4]] = dom.checked?'T':'F';
  171. },
  172. fontUnderlineChange: function(dom) {
  173. let font = dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT];
  174. font[JV.FONT_PROPS[5]] = dom.checked?'T':'F';
  175. },
  176. borderChange: function(dom) {
  177. if (dataInfoMapTreeOprObj.currentNode) {
  178. let me = this, borderAttr = dom.value;
  179. let idx = me.reportCfg.borderArr.indexOf(borderAttr);
  180. let border = me.reportCfg.styles[idx];
  181. dataInfoMapTreeOprObj.currentNode[JV.PROP_STYLE] = borderAttr;
  182. $("#eleBorderLeft").get(0).value = border[JV.PROP_BORDER_STYLE][JV.IDX_LEFT][JV.PROP_LINE_WEIGHT];
  183. $("#eleBorderRight").get(0).value = border[JV.PROP_BORDER_STYLE][JV.IDX_RIGHT][JV.PROP_LINE_WEIGHT];
  184. $("#eleBorderTop").get(0).value = border[JV.PROP_BORDER_STYLE][JV.IDX_TOP][JV.PROP_LINE_WEIGHT];
  185. $("#eleBorderBottom").get(0).value = border[JV.PROP_BORDER_STYLE][JV.IDX_BOTTOM][JV.PROP_LINE_WEIGHT];
  186. }
  187. },
  188. controlChange: function(dom) {
  189. if (dataInfoMapTreeOprObj.currentNode) {
  190. let me = this, ctrlAttr = dom.value;
  191. let idx = me.reportCfg.controlArr.indexOf(ctrlAttr);
  192. let ctrl = me.reportCfg.ctrls[idx];
  193. dataInfoMapTreeOprObj.currentNode[JV.PROP_CONTROL] = ctrlAttr;
  194. $("#elementAlignmentHorizon").get(0).selectedIndex = JV.OUTPUT_ALIGN.H.indexOf(ctrl[JV.CONTROL_PROPS[2]]);
  195. $("#elementAlignmentVertical").get(0).selectedIndex = JV.OUTPUT_ALIGN.V.indexOf(ctrl[JV.CONTROL_PROPS[3]]);
  196. $("#eleShrink").get(0).checked = stringUtil.convertStrToBoolean(ctrl[JV.CONTROL_PROPS[0]]);
  197. $("#eleShowZero").get(0).checked = stringUtil.convertStrToBoolean(ctrl[JV.CONTROL_PROPS[1]]);
  198. $("#eleAutoWrap").get(0).checked = stringUtil.convertStrToBoolean(ctrl[JV.CONTROL_PROPS[4]]);
  199. }
  200. },
  201. changeAlignment: function(dom, type) {
  202. if (type === "horizon") {
  203. //
  204. } else {
  205. //vertical
  206. }
  207. }
  208. };