You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
8.1 KiB

2 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. AnnouncementList_Qry: 'Announcement_Qry',
  58. Exhibition_Qry: 'Exhibition_Qry',
  59. Customers_Qry: 'users'
  60. },
  61. /*
  62. * 目的 開啟畫面並刷新頁籤
  63. * @param {String} sModID 模組ID
  64. */
  65. openModule = function (sModID) {
  66. sModID = sModID || '';
  67. var list = "",
  68. saProgramList = g_db.GetDic('programList') || [];
  69. $.each(saProgramList, function (indx, oProgram) {
  70. if (oProgram.ModuleID === sModID) {
  71. list += '<div id="' + oProgram.ParentID + '" class="col-md-2 col-sm-4 col-xs-12 item-box" FilePath="#">';
  72. list += '<div class="item-w">';
  73. list += '<img src="/images/goback-01.png" />';
  74. list += '<h2 class="c__title"><span data-i18n="common.GoParent">返回上一級...</span></h2>';//╠common.GoParent⇒返回上一級...╣
  75. list += '</div></div>';
  76. }
  77. });
  78. $.each(saProgramList, function (indx, oProgram) {
  79. var saChild = Enumerable.From(saProgramList).Where(function (item) { return item.ParentID === oProgram.ModuleID && item.ShowInHome.toLowerCase() === 'y' && item.ShowTop !== 1; }).ToArray();
  80. if (oProgram.ParentID === sModID && oProgram.ShowInHome.toLowerCase() === 'y' && oProgram.FilePath === '#' && saChild.length > 0 ||
  81. sModID === '' && oProgram.ShowInHome.toLowerCase() === 'y' && oProgram.ShowTop) {
  82. list += '<div id="' + oProgram.ModuleID + '" class="col-md-2 col-sm-4 col-xs-12 item-box" FilePath="' + oProgram.FilePath + '">';
  83. list += '<div class="item-w">';
  84. list += '<img src="/images/' + (oProgram.FilePath === '#' ? 'folder' : oIcon[oProgram.ModuleID] || 'invoice') + '.png" />';
  85. list += '<h2 class="c__title"><span data-i18n="common.' + oProgram.ModuleID + '"></span></h2>';
  86. list += '</div></div>';
  87. }
  88. });
  89. $.each(saProgramList, function (indx, oProgram) {
  90. if (oProgram.ParentID === sModID && oProgram.ShowInHome.toLowerCase() === 'y' && oProgram.ShowTop !== 1 && oProgram.FilePath !== '#') {
  91. list += '<div id="' + oProgram.ModuleID + '" class="col-md-2 col-sm-4 col-xs-12 item-box" FilePath="' + oProgram.FilePath + '">';
  92. list += '<div class="item-w">';
  93. list += '<img src="/images/' + (oIcon[oProgram.ModuleID] || 'invoice') + '.png" />';
  94. list += '<h2 class="c__title"><span data-i18n="common.' + oProgram.ModuleID + '"></span></h2>';
  95. list += '</div></div>';
  96. }
  97. });
  98. list += " </ul>";
  99. return list;
  100. },
  101. /*
  102. * 目的 更新模組清單
  103. * @param {String} sModID 模組ID
  104. */
  105. GetDiv = function (sModID) {
  106. var sModList = openModule(sModID),
  107. sSortList = '';
  108. $("#layout").html(sModList).find('.item-box').click(function () {
  109. var sFilepath = $(this).attr('filepath'),
  110. sId = this.id;
  111. if (sFilepath === '#' || sId === '') {
  112. GetDiv(sId);
  113. }
  114. else {
  115. parent.openPageTab(sId);
  116. }
  117. });
  118. if (sModID) {
  119. sSortList = getSort(sModID);
  120. }
  121. $("#LocSort").html(sSortList).find('a').click(function () {
  122. GetDiv(this.id);
  123. });
  124. transLang($('#layout'));
  125. },
  126. /*
  127. * 獲取背景圖片
  128. * @return {Object} Ajax 物件
  129. */
  130. fnGetBackgroundImage = function () {
  131. return CallAjax(ComFn.W_Com, ComFn.GetOne, {
  132. Type: '',
  133. Params: {
  134. files: {
  135. ParentID: parent.OrgInfo.BackgroundImage
  136. }
  137. }
  138. }, function (res) {
  139. if (res.d) {
  140. var oFiles = $.parseJSON(res.d);
  141. if (oFiles.FileID) {
  142. $('.c__item01').attr('style', 'background: #222 url(' + gServerUrl + '/' + oFiles.FilePath.replace(/\\/g, "\/") + ') no-repeat center left;');
  143. }
  144. }
  145. });
  146. },
  147. /**
  148. * 初始化 function
  149. */
  150. init = function () {
  151. //$('#test').click(function () {
  152. // debugger;
  153. // parent.msgs.server.pushTransfer(parent.OrgID, 'EURPOTRAN', '轉換小助手~手動','',0);
  154. //});
  155. if (parent.OrgInfo) {
  156. $('.sys-cnname').text(parent.OrgInfo.SystemCName);
  157. $('.sys-enname').text(parent.OrgInfo.SystemEName);
  158. fnGetBackgroundImage();
  159. }
  160. GetDiv();
  161. goTop();//置頂
  162. onresize();
  163. };
  164. init();
  165. };
  166. require(['base', 'filer', 'util'], fnPageInit);