178 lines
8.2 KiB

3 years ago
  1. 'use strict';
  2. var sProgramId = getProgramId(),
  3. sQueryPrgId = getQueryPrgId(),
  4. fnPageInit = function () {
  5. /**
  6. * 目的 取得路徑功能
  7. * @param {String} sModID 模組ID
  8. * @return {Array} 菜單標籤
  9. */
  10. var getSort = function (sModID) {
  11. var list = "",
  12. saProgramList = g_db.GetDic('programList') || [];
  13. $.each(saProgramList, function (indx, oProgram) {
  14. if (oProgram.ModuleID === sModID) {
  15. if (oProgram.AccountNameSort !== "") {
  16. var sAccNameList = oProgram.AccountNameSort,
  17. saAccNameList = sAccNameList.split("/"),
  18. sModList = oProgram.ModuleIDSort,
  19. saModList = sModList.split("/"),
  20. color, //定義路徑顏色
  21. DivRow = "",
  22. intLenght;
  23. for (intLenght = 0; intLenght < saAccNameList.length; intLenght++) {
  24. switch (intLenght) {
  25. case 0: //第一層
  26. color = "Blue";
  27. DivRow = intLenght;
  28. break;
  29. case 1: //第二層
  30. color = "Red";
  31. DivRow = intLenght;
  32. break;
  33. case 2: //第三層
  34. color = "Green";
  35. DivRow = intLenght;
  36. break;
  37. case 3: //第四層
  38. color = "#C4B23B";
  39. DivRow = intLenght;
  40. break;
  41. }
  42. var sName = saAccNameList[intLenght] + (intLenght < saAccNameList.length - 1 ? " >" : "");
  43. list += "<a id='" + saModList[intLenght] + "' style='cursor:pointer;color:" + color + "'>" + sName + "</a>";
  44. }
  45. }
  46. }
  47. }
  48. );
  49. return list;
  50. },
  51. oIcon = {
  52. ExhibitionImport_Qry: 'import-s',
  53. ExhibitionExport_Qry: 'export-s',
  54. ComlyExhibitionImport_Qry: 'import',
  55. ComlyExhibitionExport_Qry: 'export',
  56. OtherBusiness_Qry: 'OtherBusiness_Qry',
  57. OtherExhibitionTG_Qry: 'OtherExhibitionTG_Qry',
  58. AnnouncementList_Qry: 'Announcement_Qry',
  59. Exhibition_Qry: 'Exhibition_Qry',
  60. Customers_Qry: 'users'
  61. },
  62. /*
  63. * 目的 開啟畫面並刷新頁籤
  64. * @param {String} sModID 模組ID
  65. */
  66. openModule = function (sModID) {
  67. sModID = sModID || '';
  68. var list = "",
  69. saProgramList = g_db.GetDic('programList') || [];
  70. $.each(saProgramList, function (indx, oProgram) {
  71. if (oProgram.ModuleID === sModID) {
  72. list += '<div id="' + oProgram.ParentID + '" class="col-md-2 col-sm-4 col-xs-12 item-box" FilePath="#">';
  73. list += '<div class="item-w">';
  74. list += '<img src="/images/goback-01.png" />';
  75. list += '<h2 class="c__title"><span data-i18n="common.GoParent">返回上一級...</span></h2>';//╠common.GoParent⇒返回上一級...╣
  76. list += '</div></div>';
  77. }
  78. });
  79. $.each(saProgramList, function (indx, oProgram) {
  80. var saChild = Enumerable.From(saProgramList).Where(function (item) { return item.ParentID === oProgram.ModuleID && item.ShowInHome.toLowerCase() === 'y' && item.ShowTop !== 1; }).ToArray();
  81. if (oProgram.ParentID === sModID && oProgram.ShowInHome.toLowerCase() === 'y' && oProgram.FilePath === '#' && saChild.length > 0 ||
  82. sModID === '' && oProgram.ShowInHome.toLowerCase() === 'y' && oProgram.ShowTop) {
  83. list += '<div id="' + oProgram.ModuleID + '" class="col-md-2 col-sm-4 col-xs-12 item-box" FilePath="' + oProgram.FilePath + '">';
  84. list += '<div class="item-w">';
  85. list += '<img src="/images/' + (oProgram.FilePath === '#' ? 'folder' : oIcon[oProgram.ModuleID] || 'invoice') + '.png" />';
  86. list += '<h2 class="c__title"><span data-i18n="common.' + oProgram.ModuleID + '"></span></h2>';
  87. list += '</div></div>';
  88. }
  89. });
  90. $.each(saProgramList, function (indx, oProgram) {
  91. if (oProgram.ParentID === sModID && oProgram.ShowInHome.toLowerCase() === 'y' && oProgram.ShowTop !== 1 && oProgram.FilePath !== '#') {
  92. list += '<div id="' + oProgram.ModuleID + '" class="col-md-2 col-sm-4 col-xs-12 item-box" FilePath="' + oProgram.FilePath + '">';
  93. list += '<div class="item-w">';
  94. list += '<img src="/images/' + (oIcon[oProgram.ModuleID] || 'invoice') + '.png" />';
  95. list += '<h2 class="c__title"><span data-i18n="common.' + oProgram.ModuleID + '"></span></h2>';
  96. list += '</div></div>';
  97. }
  98. });
  99. list += " </ul>";
  100. return list;
  101. },
  102. /*
  103. * 目的 更新模組清單
  104. * @param {String} sModID 模組ID
  105. */
  106. GetDiv = function (sModID) {
  107. var sModList = openModule(sModID),
  108. sSortList = '';
  109. $("#layout").html(sModList).find('.item-box').click(function () {
  110. var sFilepath = $(this).attr('filepath'),
  111. sId = this.id;
  112. if (sFilepath === '#' || sId === '') {
  113. GetDiv(sId);
  114. }
  115. else {
  116. parent.openPageTab(sId);
  117. }
  118. });
  119. if (sModID) {
  120. sSortList = getSort(sModID);
  121. }
  122. $("#LocSort").html(sSortList).find('a').click(function () {
  123. GetDiv(this.id);
  124. });
  125. transLang($('#layout'));
  126. },
  127. /*
  128. * 獲取背景圖片
  129. * @return {Object} Ajax 物件
  130. */
  131. fnGetBackgroundImage = function () {
  132. return CallAjax(ComFn.W_Com, ComFn.GetOne, {
  133. Type: '',
  134. Params: {
  135. files: {
  136. ParentID: parent.OrgInfo.BackgroundImage
  137. }
  138. }
  139. }, function (res) {
  140. if (res.d) {
  141. var oFiles = $.parseJSON(res.d);
  142. if (oFiles.FileID) {
  143. $('.c__item01').attr('style', 'background: #222 url(' + gServerUrl + '/' + oFiles.FilePath.replace(/\\/g, "\/") + ') no-repeat center left;');
  144. }
  145. }
  146. });
  147. },
  148. /**
  149. * 初始化 function
  150. */
  151. init = function () {
  152. //$('#test').click(function () {
  153. // debugger;
  154. // parent.msgs.server.pushTransfer(parent.OrgID, 'EURPOTRAN', '轉換小助手~手動','',0);
  155. //});
  156. if (parent.OrgInfo) {
  157. $('.sys-cnname').text(parent.OrgInfo.SystemCName);
  158. $('.sys-enname').text(parent.OrgInfo.SystemEName);
  159. fnGetBackgroundImage();
  160. }
  161. GetDiv();
  162. goTop();//置頂
  163. onresize();
  164. };
  165. init();
  166. };
  167. require(['base', 'filer', 'util'], fnPageInit);