rpt_tpl_cfg_helper.js 16 KB

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