rpt_tpl_cfg_helper.js 16 KB

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