rpt_tpl_cfg_helper.js 17 KB

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