rpt_tpl_cfg_helper.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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. $("#element_area_1")[0].style.display = "";
  76. $("#element_area_2")[0].style.display = "";
  77. if (treeNode[JV.PROP_FIELD_ID] || treeNode[JV.PROP_PARAM_ID]) {
  78. $("#element_pre_suff")[0].style.display = "";
  79. if (treeNode[JV.PROP_PREFIX]) {
  80. $("#elePrefix").get(0).value = treeNode[JV.PROP_PREFIX];
  81. } else {
  82. $("#elePrefix").get(0).value = "";
  83. }
  84. if (treeNode[JV.PROP_SUFFIX]) {
  85. $("#eleSuffix").get(0).value = treeNode[JV.PROP_SUFFIX];
  86. } else {
  87. $("#eleSuffix").get(0).value = "";
  88. }
  89. if (treeNode[JV.PROP_FORMAT]) {
  90. $("#eleFormat").get(0).value = treeNode[JV.PROP_FORMAT];
  91. } else {
  92. $("#eleFormat").get(0).value = "";
  93. }
  94. } else {
  95. $("#element_pre_suff")[0].style.display = "none";
  96. }
  97. //setup auto height
  98. if (treeNode[JV.PROP_IS_AUTO_HEIGHT]) {
  99. $("#eleAutoHeight").get(0).checked = true;
  100. } else {
  101. $("#eleAutoHeight").get(0).checked = false;
  102. }
  103. //setup font
  104. let fontDom = $("#elementFonts").get(0);
  105. fontDom.removeAttribute("disabled");
  106. let fontAttr = treeNode[JV.PROP_FONT];
  107. if (typeof treeNode[JV.PROP_FONT] !== "string") {
  108. fontAttr = "自定义";
  109. }
  110. let idx = me.reportCfg.fontArr.indexOf(fontAttr);
  111. fontDom.selectedIndex = idx;
  112. me.fontChange(fontDom);
  113. //setup border
  114. let borderDom = $("#elementBorders").get(0);
  115. let borderAttr = treeNode[JV.PROP_STYLE];
  116. idx = me.reportCfg.borderArr.indexOf(borderAttr);
  117. borderDom.selectedIndex = idx;
  118. me.borderChange(borderDom);
  119. //setup control
  120. let ctrlDom = $("#elementControls").get(0);
  121. let ctrlAttr = treeNode[JV.PROP_CONTROL];
  122. idx = me.reportCfg.controlArr.indexOf(ctrlAttr);
  123. ctrlDom.selectedIndex = idx;
  124. me.controlChange(ctrlDom);
  125. //setup area
  126. me.private_setup_area(treeNode);
  127. } else {
  128. $("#elementFonts").get(0).disabled = "disabled" ;
  129. $("#element_font")[0].style.display = "none";
  130. $("#element_border")[0].style.display = "none";
  131. $("#element_control")[0].style.display = "none";
  132. $("#element_area_1")[0].style.display = "none";
  133. $("#element_area_2")[0].style.display = "none";
  134. $("#element_pre_suff")[0].style.display = "none";
  135. }
  136. },
  137. fontChange: function(dom) {
  138. let me = rpt_tpl_cfg_helper, fontAttr = dom.value;
  139. //dataInfoMapTreeOprObj.currentNode
  140. if (fontAttr === "自定义") {
  141. fontAttr = dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT];
  142. if (typeof fontAttr === "string") {
  143. fontAttr = {};
  144. fontAttr[JV.FONT_PROPS[0]] = "宋体";
  145. fontAttr[JV.FONT_PROPS[1]] = 12;
  146. fontAttr[JV.FONT_PROPS[2]] = "BLACK";
  147. fontAttr[JV.FONT_PROPS[3]] = "F"; //bold
  148. fontAttr[JV.FONT_PROPS[4]] = "F"; //italic
  149. fontAttr[JV.FONT_PROPS[5]] = "F"; //underline
  150. fontAttr[JV.FONT_PROPS[6]] = "F"; //strikeout
  151. fontAttr[JV.FONT_PROPS[7]] = 0; //angle
  152. dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT] = fontAttr;
  153. }
  154. } else {
  155. dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT] = fontAttr;
  156. }
  157. me.private_setup_font(fontAttr);
  158. },
  159. private_setup_font: function(fontAttr) {
  160. let me = rpt_tpl_cfg_helper;
  161. if (typeof fontAttr === "string" && fontAttr !== "自定义") {
  162. $("#eleFontName").get(0).disabled = "disabled" ;
  163. $("#eleFontSize").get(0).disabled = "disabled" ;
  164. $("#eleFontBold").get(0).disabled = "disabled" ;
  165. $("#eleFontItalic").get(0).disabled = "disabled" ;
  166. $("#eleFontUnderline").get(0).disabled = "disabled" ;
  167. let idx = me.reportCfg.fontArr.indexOf(fontAttr);
  168. $("#elementFonts").get(0).selectedIndex = idx;
  169. let font = me.reportCfg.fonts[idx];
  170. $("#eleFontName").get(0).value = font.Name;
  171. $("#eleFontSize").get(0).value = parseInt(font.FontHeight);
  172. $("#eleFontBold").get(0).checked = stringUtil.convertStrToBoolean(font.FontBold);
  173. $("#eleFontItalic").get(0).checked = stringUtil.convertStrToBoolean(font.FontItalic);
  174. $("#eleFontUnderline").get(0).checked = stringUtil.convertStrToBoolean(font.FontUnderline);
  175. } else {
  176. //$("#elementFonts").get(0).selectedIndex = idx;
  177. $("#eleFontName").get(0).removeAttribute("disabled");
  178. $("#eleFontSize").get(0).removeAttribute("disabled");
  179. $("#eleFontBold").get(0).removeAttribute("disabled");
  180. $("#eleFontItalic").get(0).removeAttribute("disabled");
  181. $("#eleFontUnderline").get(0).removeAttribute("disabled");
  182. $("#eleFontName").get(0).value = fontAttr.Name;
  183. $("#eleFontSize").get(0).value = parseInt(fontAttr.FontHeight);
  184. $("#eleFontBold").get(0).checked = stringUtil.convertStrToBoolean(fontAttr.FontBold);
  185. $("#eleFontItalic").get(0).checked = stringUtil.convertStrToBoolean(fontAttr.FontItalic);
  186. $("#eleFontUnderline").get(0).checked = stringUtil.convertStrToBoolean(fontAttr.FontUnderline);
  187. }
  188. },
  189. private_setup_area: function (treeNode) {
  190. $("#elementArea_Left").get(0).value = parseFloat(treeNode[JV.PROP_AREA][JV.PROP_LEFT]);
  191. $("#elementArea_Right").get(0).value = parseFloat(treeNode[JV.PROP_AREA][JV.PROP_RIGHT]);
  192. $("#elementArea_Top").get(0).value = parseFloat(treeNode[JV.PROP_AREA][JV.PROP_TOP]);
  193. $("#elementArea_Bottom").get(0).value = parseFloat(treeNode[JV.PROP_AREA][JV.PROP_BOTTOM]);
  194. if (typeof treeNode[JV.PROP_AREA][JV.PROP_H_CALCULATION] === "string") {
  195. $("#isPercentage_Left").get(0).checked = treeNode[JV.PROP_AREA][JV.PROP_H_CALCULATION] === "percentage";
  196. $("#isPercentage_Right").get(0).checked = treeNode[JV.PROP_AREA][JV.PROP_H_CALCULATION] === "percentage";
  197. } else {
  198. $("#isPercentage_Left").get(0).checked = treeNode[JV.PROP_AREA][JV.PROP_H_CALCULATION][JV.PROP_LEFT] === "percentage";
  199. $("#isPercentage_Right").get(0).checked = treeNode[JV.PROP_AREA][JV.PROP_H_CALCULATION][JV.PROP_RIGHT] === "percentage";
  200. }
  201. if (typeof treeNode[JV.PROP_AREA][JV.PROP_V_CALCULATION] === "string") {
  202. $("#isPercentage_Top").get(0).checked = treeNode[JV.PROP_AREA][JV.PROP_V_CALCULATION] === "percentage";
  203. $("#isPercentage_Bottom").get(0).checked = treeNode[JV.PROP_AREA][JV.PROP_V_CALCULATION] === "percentage";
  204. } else {
  205. $("#isPercentage_Top").get(0).checked = treeNode[JV.PROP_AREA][JV.PROP_V_CALCULATION][JV.PROP_TOP] === "percentage";
  206. $("#isPercentage_Bottom").get(0).checked = treeNode[JV.PROP_AREA][JV.PROP_V_CALCULATION][JV.PROP_BOTTOM] === "percentage";
  207. }
  208. },
  209. fontNameChange: function(dom){
  210. let font = dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT];
  211. font[JV.FONT_PROPS[0]] = dom.value;
  212. },
  213. fontSizeChange: function(dom) {
  214. let font = dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT];
  215. font[JV.FONT_PROPS[1]] = dom.value;
  216. },
  217. fontBoldChange: function(dom) {
  218. let font = dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT];
  219. font[JV.FONT_PROPS[3]] = dom.checked?'T':'F';
  220. },
  221. fontItalicChange: function(dom) {
  222. let font = dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT];
  223. font[JV.FONT_PROPS[4]] = dom.checked?'T':'F';
  224. },
  225. fontUnderlineChange: function(dom) {
  226. let font = dataInfoMapTreeOprObj.currentNode[JV.PROP_FONT];
  227. font[JV.FONT_PROPS[5]] = dom.checked?'T':'F';
  228. },
  229. borderChange: function(dom) {
  230. if (dataInfoMapTreeOprObj.currentNode) {
  231. let me = this, borderAttr = dom.value;
  232. let idx = me.reportCfg.borderArr.indexOf(borderAttr);
  233. let border = me.reportCfg.styles[idx];
  234. dataInfoMapTreeOprObj.currentNode[JV.PROP_STYLE] = borderAttr;
  235. $("#eleBorderLeft").get(0).value = border[JV.PROP_BORDER_STYLE][JV.IDX_LEFT][JV.PROP_LINE_WEIGHT];
  236. $("#eleBorderRight").get(0).value = border[JV.PROP_BORDER_STYLE][JV.IDX_RIGHT][JV.PROP_LINE_WEIGHT];
  237. $("#eleBorderTop").get(0).value = border[JV.PROP_BORDER_STYLE][JV.IDX_TOP][JV.PROP_LINE_WEIGHT];
  238. $("#eleBorderBottom").get(0).value = border[JV.PROP_BORDER_STYLE][JV.IDX_BOTTOM][JV.PROP_LINE_WEIGHT];
  239. }
  240. },
  241. controlChange: function(dom) {
  242. if (dataInfoMapTreeOprObj.currentNode) {
  243. let me = this, ctrlAttr = dom.value;
  244. let idx = me.reportCfg.controlArr.indexOf(ctrlAttr);
  245. let ctrl = me.reportCfg.ctrls[idx];
  246. dataInfoMapTreeOprObj.currentNode[JV.PROP_CONTROL] = ctrlAttr;
  247. $("#elementAlignmentHorizon").get(0).selectedIndex = JV.OUTPUT_ALIGN.H.indexOf(ctrl[JV.CONTROL_PROPS[2]]);
  248. $("#elementAlignmentVertical").get(0).selectedIndex = JV.OUTPUT_ALIGN.V.indexOf(ctrl[JV.CONTROL_PROPS[3]]);
  249. $("#eleShrink").get(0).checked = stringUtil.convertStrToBoolean(ctrl[JV.CONTROL_PROPS[0]]);
  250. $("#eleShowZero").get(0).checked = stringUtil.convertStrToBoolean(ctrl[JV.CONTROL_PROPS[1]]);
  251. $("#eleAutoWrap").get(0).checked = stringUtil.convertStrToBoolean(ctrl[JV.CONTROL_PROPS[4]]);
  252. }
  253. },
  254. changeAlignment: function(dom, type) {
  255. let ctrl = dataInfoMapTreeOprObj.currentNode[JV.PROP_CONTROL];
  256. if (type === "horizon") {
  257. ctrl[JV.CONTROL_PROPS[2]] = JV.OUTPUT_ALIGN[dom.selectedIndex];
  258. } else {
  259. ctrl[JV.CONTROL_PROPS[3]] = JV.OUTPUT_ALIGN[dom.selectedIndex];
  260. }
  261. },
  262. changeArea: function(dom, typeStr) {
  263. if (dataInfoMapTreeOprObj.currentNode) {
  264. dataInfoMapTreeOprObj.currentNode[JV.PROP_AREA][typeStr] = dom.value;
  265. }
  266. },
  267. changeAreaCalcType: function (dom, typeStr) {
  268. if (dataInfoMapTreeOprObj.currentNode) {
  269. let otherSideStr = "", caclStr = "";
  270. switch (typeStr) {
  271. case JV.PROP_LEFT:
  272. caclStr = JV.PROP_H_CALCULATION;
  273. otherSideStr = JV.PROP_RIGHT;
  274. break;
  275. case JV.PROP_RIGHT:
  276. caclStr = JV.PROP_H_CALCULATION;
  277. otherSideStr = JV.PROP_LEFT;
  278. break;
  279. case JV.PROP_TOP:
  280. caclStr = JV.PROP_V_CALCULATION;
  281. otherSideStr = JV.PROP_BOTTOM;
  282. break;
  283. case JV.PROP_BOTTOM:
  284. caclStr = JV.PROP_V_CALCULATION;
  285. otherSideStr = JV.PROP_TOP;
  286. break;
  287. }
  288. if (typeof dataInfoMapTreeOprObj.currentNode[JV.PROP_AREA][caclStr] === "string") {
  289. let bk_type = dataInfoMapTreeOprObj.currentNode[JV.PROP_AREA][caclStr];
  290. dataInfoMapTreeOprObj.currentNode[JV.PROP_AREA][caclStr] = {};
  291. dataInfoMapTreeOprObj.currentNode[JV.PROP_AREA][caclStr][typeStr] = dom.checked?JV.CAL_TYPE[0]:JV.CAL_TYPE[1];
  292. dataInfoMapTreeOprObj.currentNode[JV.PROP_AREA][caclStr][otherSideStr] = bk_type;
  293. } else {
  294. dataInfoMapTreeOprObj.currentNode[JV.PROP_AREA][caclStr][typeStr] = dom.checked?JV.CAL_TYPE[0]:JV.CAL_TYPE[1];
  295. }
  296. }
  297. },
  298. changePreSuff: function (dom, typeStr) {
  299. if (dataInfoMapTreeOprObj.currentNode) {
  300. dataInfoMapTreeOprObj.currentNode[typeStr] = dom.value;
  301. }
  302. },
  303. changeFormat: function (dom) {
  304. if (dataInfoMapTreeOprObj.currentNode) {
  305. dataInfoMapTreeOprObj.currentNode[JV.PROP_FORMAT] = dom.value;
  306. }
  307. },
  308. changeAutoHeight: function(dom) {
  309. if (dataInfoMapTreeOprObj.currentNode) {
  310. dataInfoMapTreeOprObj.currentNode[JV.PROP_IS_AUTO_HEIGHT] = dom.checked;
  311. }
  312. }
  313. };