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.

1650 lines
70 KiB

3 years ago
  1. var msgs,
  2. iCuryIndex = 0,
  3. iTipsCount = 0,
  4. online_Users = [],
  5. Ann = {
  6. div: $('div.notice-box'),
  7. ul: $('div.notice-box').find('ul'),
  8. li_class: 'li-list',
  9. active: 'li-active',
  10. fadeOut: 500,
  11. timer: null
  12. },
  13. AnnList = [],
  14. /**
  15. * @param {String} islogin 是否登入
  16. */
  17. fnRegister = function (islogin) {
  18. var orgid = UserInfo.OrgID,
  19. userid = UserInfo.MemberID,
  20. username = UserInfo.MemberName;
  21. //上線
  22. msgs.server.register(orgid, userid, username, islogin);
  23. },
  24. /**
  25. * 查看公告明細
  26. * @param {String} id 公告guid
  27. * @param {String} flag 是否包含關閉按鈕
  28. */
  29. fnOpenAnn = function (id, flag) {
  30. getHtmlTmp('/Page/Pop/AnnounceInfo.html').done(function (html) {
  31. var oAnnInfo = Enumerable.From(AnnList).Where(function (item) { return item.AnnouncementID === id; }).First();
  32. oAnnInfo.CategoryName = i18next.t('common.Announcement');// ╠common.Announcement⇒公 告╣
  33. oAnnInfo.CreateDate = newDate(oAnnInfo.CreateDate, 'date');
  34. var sHtml = $('<script type="text/x-jsrender"/>').html(html).render(oAnnInfo);
  35. layer.open({
  36. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  37. title: oAnnInfo.CategoryName,
  38. //title: false, //不显示标题栏
  39. area: '640px;',//寬度
  40. shade: 0.75,//遮罩
  41. closeBtn: flag ? 0 : 1,
  42. shadeClose: true,
  43. //maxmin: true, //开启最大化最小化按钮
  44. id: 'layer_Announce', //设定一个id,防止重复弹出
  45. offset: '100px',//右下角弹出
  46. anim: 0,//彈出動畫
  47. btn: flag ? [i18next.t('common.Gotit')] : [],
  48. btnAlign: 'c',//按鈕位置
  49. content: sHtml,
  50. success: function (layero, index) {
  51. layero.find('a').each(function () {
  52. if (($(this).attr('href') || '').indexOf('net/upload/file') > -1 && (($(this).prev().attr('src') || '').indexOf('icon_jpg') > -1 || ($(this).prev().attr('src') || '').indexOf('icon_pdf') > -1)) {
  53. $(this).attr('target', '_new');
  54. }
  55. });
  56. layero.find('.layui-layer-title').css({ 'text-align': 'center', 'padding': '0 30px 0 20px', 'font-size': '20px', 'font-weight': '600' });
  57. slimScroll();
  58. },
  59. yes: function (index, layero) {
  60. CallAjax(ComFn.W_Com, ComFn.GetCount, {
  61. Params: {
  62. read: {
  63. AnnouncementID: oAnnInfo.AnnouncementID,
  64. CreateUser: UserInfo.MemberID
  65. }
  66. }
  67. }, function (res) {
  68. if (res.d === 0) {
  69. CallAjax(ComFn.W_Com, ComFn.GetAdd, {
  70. Params: {
  71. read: {
  72. AnnouncementID: oAnnInfo.AnnouncementID,
  73. CreateUser: UserInfo.MemberID,
  74. CreateDate: newDate()
  75. }
  76. }
  77. });
  78. }
  79. });
  80. setTimeout(function () { fnGetAnnouncements(); }, 60000);
  81. layer.close(index);
  82. }
  83. });
  84. });
  85. },
  86. /**
  87. * 查看公告明細
  88. * @param {Object} tips 提示資料
  89. */
  90. fnShowTips = function (tips) {
  91. getHtmlTmp('/Page/Pop/AnnounceInfo.html').done(function (html) {
  92. var oTips = {};
  93. oTips.CategoryName = i18next.t('common.SystemTips');// ╠common.SystemTips⇒系統提醒╣
  94. oTips.CreateUserName = '';
  95. oTips.CreateDate = '';
  96. oTips.Description = '';
  97. var saTips = JSON.parse(tips);
  98. $.each(saTips, function (idx, _tips) {
  99. oTips.Description += '<p class="tipslink" data-from="' + _tips.SourceFrom + '" data-parm="' + _tips.Params + '"><a style="cursor: pointer;"><span style="font-size: 14px;">' + (idx + 1) + '. ' + _tips.EventName + ' </span></a><span>' + _tips.Important + ' ' + newDate(_tips.StartDate, true) + '~' + newDate(_tips.StartDate, true) + '</span></p>';
  100. });
  101. var sHtml = $('<script type="text/x-jsrender"/>').html(html).render(oTips);
  102. layer.open({
  103. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  104. title: oTips.CategoryName,
  105. area: '640px;',//寬度
  106. shade: 0.75,//遮罩
  107. closeBtn: 1,
  108. shadeClose: true,
  109. id: 'layer_Tips', //设定一个id,防止重复弹出
  110. offset: '100px',//右下角弹出
  111. anim: 0,//彈出動畫
  112. btn: [i18next.t('common.Gotit')], // ╠common.Gotit⇒知道了╣
  113. btnAlign: 'c',//按鈕位置
  114. content: sHtml,
  115. success: function (layero, index) {
  116. layero.find('.tipslink>a').click(function () {
  117. var sFrom = $(this).parent().attr('data-from').replace('_Qry', '_Upd'),
  118. sParm = $(this).parent().attr('data-parm');
  119. openPageTab(sFrom, sParm);
  120. layer.close(index);
  121. });
  122. layero.find('.layui-layer-title').css({ 'text-align': 'center', 'padding': '0 30px 0 20px', 'font-size': '20px', 'font-weight': '600' });
  123. slimScroll();
  124. }
  125. });
  126. });
  127. },
  128. /**
  129. * @param {Object} tips 提示資料
  130. */
  131. fnAttendanceTips = function (tips) {
  132. getHtmlTmp('/Page/Pop/AnnounceInfo.html').done(function (html) {
  133. var oTips = {};
  134. oTips.CategoryName = i18next.t('common.EiptemTips');// ╠common.EiptemTips⇒考勤未打卡提醒╣
  135. oTips.CreateUserName = '';
  136. oTips.CreateDate = '';
  137. oTips.Description = '';
  138. var saTips = JSON.parse(tips);
  139. $.each(saTips, function (idx, _tips) {
  140. oTips.Description += '<p class="tipslink" data-id="' + _tips.NO + '" data-user="' + _tips.Owner + '"><a style="cursor: pointer;"><span style="font-size: 14px;">' + (idx + 1) + '. ' + _tips.Title + ' </span></a>&nbsp;&nbsp;<a class="a-url" data-i18n="common.CancelTips">取消提醒</a></p>';// ╠common.CancelTips⇒取消提醒╣
  141. });
  142. var sHtml = $('<script type="text/x-jsrender"/>').html(html).render(oTips);
  143. layer.open({
  144. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  145. title: oTips.CategoryName,
  146. area: '680px;',//寬度
  147. shade: 0.75,//遮罩
  148. closeBtn: 1,
  149. shadeClose: true,
  150. id: 'layer_Tips', //设定一个id,防止重复弹出
  151. offset: '100px',//右下角弹出
  152. anim: 0,//彈出動畫
  153. btn: [i18next.t('common.Gotit'), i18next.t('common.CancelAllTips')], // ╠common.CancelAllTips⇒取消所有提醒╣
  154. btnAlign: 'c',//按鈕位置
  155. content: sHtml,
  156. success: function (layero, index) {
  157. layero.find('.a-url').click(function () {
  158. var oTips = $(this).parent(),
  159. sTipsId = oTips.attr('data-id');
  160. fnDeleteEipTips(sTipsId).done(function () {
  161. oTips.remove();
  162. });
  163. });
  164. layero.find('.layui-layer-title').css({ 'text-align': 'center', 'padding': '0 30px 0 20px', 'font-size': '20px', 'font-weight': '600' });
  165. slimScroll();
  166. },
  167. yes: function (index, layero) {
  168. layer.close(index);
  169. },
  170. btn2: function (index, layero) {
  171. var saIds = [];
  172. layero.find('.tipslink').each(function () {
  173. saIds.push({
  174. NO: $(this).attr('data-id')
  175. });
  176. });
  177. fnDeleteEipTips(saIds);
  178. }
  179. });
  180. });
  181. },
  182. /**
  183. * 公告實現輪播
  184. */
  185. fnAnnouncementTimer = function () {
  186. if (Ann.ul.find('li').length > 1) {
  187. Ann.ul.animate({
  188. marginTop: "-5.7rem"
  189. }, 1000, function () {
  190. $(this).css({ marginTop: "0rem" }).find("li:first").appendTo(this);
  191. });
  192. }
  193. },
  194. /**
  195. * 彈出公告訊息
  196. * @param {Object} list 公告list
  197. */
  198. fnShowAlertAnnouncement = function (list) {
  199. if (list) {
  200. $.each(list, function (index, item) {
  201. if (!item.IsAlert) {
  202. fnOpenAnn(item.AnnouncementID, true);
  203. return false;
  204. }
  205. });
  206. }
  207. },
  208. /**
  209. * 顯示一般輪播公告
  210. * @param {Object} list 公告list
  211. */
  212. fnShowSlideAnnouncement = function (list) {
  213. //加載公告
  214. var saLi = [];
  215. AnnList = list;
  216. $.each(list, function (idx, item) {
  217. var sFontColor = item.FontColor || '#000',
  218. sTitle = item.Title;
  219. if (sTitle.length > 27) {
  220. sTitle = sTitle.substr(0, 27) + ' . . .';
  221. }
  222. saLi.push($('<li />').addClass(Ann.li_class).attr('data-guid', item.AnnouncementID).append($('<a/>',
  223. {
  224. html: sTitle,
  225. click: function () {
  226. fnOpenAnn(item.AnnouncementID, false);
  227. }
  228. }).css('color', sFontColor)));
  229. });
  230. if (saLi.length > 0) {
  231. Ann.ul.html('').append(saLi);
  232. Ann.div.show();
  233. }
  234. else {
  235. Ann.div.hide();
  236. }
  237. if (Ann.timer) clearInterval(Ann.timer);
  238. Ann.timer = setInterval(fnAnnouncementTimer, 5000);
  239. Ann.ul.find('li').mousemove(function () {
  240. clearInterval(Ann.timer);
  241. }).mouseout(function () {
  242. Ann.timer = setInterval(fnAnnouncementTimer, 5000);
  243. });
  244. },
  245. /**
  246. * 獲取當前公告信息
  247. */
  248. fnGetAnnouncements = function () {
  249. if (!UserInfo.MemberID) { return; }
  250. g_api.ConnectLite(Service.com, 'GetAnnlist', {}, function (res) {
  251. if (res.RESULT) {
  252. AnnList = res.DATA.rel;
  253. fnShowSlideAnnouncement(AnnList);
  254. fnShowAlertAnnouncement(AnnList);
  255. }
  256. });
  257. },
  258. //提醒未打卡人員
  259. fnShowAbsenceNotification = function (saAttendances) {
  260. getHtmlTmp('/Page/Pop/AnnounceInfo.html').done(function (html) {
  261. let btnwords = i18next.t('common.Gotit');
  262. if (!btnwords)
  263. btnwords = "知道了";
  264. var oTips = {};
  265. oTips.CategoryName = i18next.t('common.EiptemTips');// ╠common.EiptemTips⇒考勤未打卡提醒╣
  266. oTips.CreateUserName = '';
  267. oTips.CreateDate = '';
  268. oTips.Description = '';
  269. var Days = '';
  270. $.each(saAttendances, function (idx, _sad) {
  271. let CardDate = new Date(_sad.CardDate);
  272. Days += CardDate.formate("yyyy.MM.dd (EEE)") + ',';
  273. });
  274. oTips.Description = '<span style="font-size: 18px;"><p>您於' + Days + '</P><p>刷卡紀錄異常,請盡快辦理請假程序。</p><p>如有疑問,請向管理員詢問,謝謝!</p></span>';
  275. var sHtml = $('<script type="text/x-jsrender"/>').html(html).render(oTips);
  276. layer.open({
  277. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  278. title: oTips.CategoryName,
  279. area: '680px;',//寬度,
  280. shade: 0.8,//遮罩
  281. closeBtn: 1,
  282. shadeClose: true,
  283. id: 'layer_Attendances', //设定一个id,防止重复弹出
  284. offset: '100px',//右下角弹出
  285. anim: 0,//彈出動畫
  286. btn: [btnwords],
  287. btnAlign: 'c',//按鈕位置
  288. content: sHtml,
  289. success: function (layero, index) {
  290. slimScroll();
  291. },
  292. yes: function (index, layero) {
  293. g_db.SetItem("AbsenceFromLastWeek", "True");
  294. layer.close(index);
  295. },
  296. });
  297. });
  298. }
  299. /**
  300. * 獲取上週未刷卡遲到早退周一僅提醒一次
  301. */
  302. fnGetAbsenceFromLastWeek = function () {
  303. let DayOfWeek = new Date().getDay();
  304. let HadNoticed = g_db.GetItem("AbsenceFromLastWeek");
  305. if (!UserInfo.MemberID) { return; }
  306. if (DayOfWeek !== 1) {
  307. g_db.SetItem("AbsenceFromLastWeek", "");
  308. }
  309. else if (!HadNoticed && DayOfWeek === 1) {
  310. g_api.ConnectLite(Service.com, 'GetAbsenceFromLastWeek', {}, function (res) {
  311. if (res.RESULT) {
  312. let AbsenceList = res.DATA.rel;
  313. if (AbsenceList.length > 0)
  314. fnShowAbsenceNotification(AbsenceList);
  315. else
  316. g_db.SetItem("AbsenceFromLastWeek", "True");
  317. }
  318. });
  319. }
  320. },
  321. /**
  322. * 獲取所有提示
  323. */
  324. fnGetTips = function () {
  325. CallAjax(ComFn.W_Com, ComFn.GetList, {
  326. Type: '',
  327. Params: {
  328. tips: {
  329. IsRead: 'N',
  330. Owner: window.UserID,
  331. OrgID: window.OrgID
  332. },
  333. sort: { CreateDate: 'desc' }
  334. }
  335. }, function (res) {
  336. if (res.d) {
  337. var saList = $.parseJSON(res.d),
  338. myHelpers = {
  339. dtformate: function (val) {
  340. return newDate(val);
  341. },
  342. setIcon: function (type) {
  343. var sIcon = 'icon-bell';
  344. if (type === 'fa-check') {
  345. sIcon = 'fa fa-check';
  346. }
  347. else if (type === 'fa-times') {
  348. sIcon = 'fa fa-times';
  349. }
  350. return sIcon;
  351. },
  352. setBgcolor: function (type) {
  353. var sBgcolor = 'success';
  354. if (type === 'fa-check') {
  355. sBgcolor = 'green';
  356. }
  357. else if (type === 'fa-times') {
  358. sBgcolor = 'red';
  359. }
  360. return sBgcolor;
  361. }
  362. };
  363. $.views.helpers(myHelpers);
  364. iTipsCount = saList.length;
  365. if (iTipsCount > 0) {
  366. var sHtml = $('#temp_tips').render(saList);//angularJS
  367. $('.tips-count').text(iTipsCount > 100 ? '99+' : iTipsCount);
  368. $('.tipscount').text(iTipsCount);
  369. $('#alltips').html(sHtml).find('.tips-item').on('click', function () {
  370. var saUrl = $(this).attr('data-url').split('|'),
  371. sPrgId = saUrl[0],
  372. sParam = saUrl[1];
  373. parent.openPageTab(sPrgId, sParam);
  374. fnRemoveTips(false, $(this));
  375. });
  376. $('.stop-prevent').off('click').on('click', function (e) {
  377. var that = this;
  378. if ($(that).hasClass('tips-delete')) {
  379. fnRemoveTips(false, $(that).parents('.tips-item'));
  380. }
  381. else if ($(that).hasClass('tips-clearall')) {
  382. fnRemoveTips(true);
  383. }
  384. return false;
  385. });
  386. $('.tips-has,.tips-count,.tipscount').show();
  387. $('.tips-empty').hide();
  388. }
  389. else {
  390. $('.tips-empty').show();
  391. $('.tips-has,.tips-count,.tipscount').hide();
  392. }
  393. }
  394. });
  395. },
  396. /**
  397. * 移除頁面提醒
  398. * @param {Boolean} clearall 是否清空全部
  399. * @param {HTMLElement} otips 當前資料物件
  400. */
  401. fnRemoveTips = function (clearall, otips) {
  402. var fnSet = function () {
  403. $('.tips-count').text(iTipsCount > 100 ? '99+' : iTipsCount);
  404. $('.tipscount').text(iTipsCount);
  405. if (iTipsCount) {
  406. $('.tips-has,.tips-count,.tipscount').show();
  407. $('.tips-empty').hide();
  408. }
  409. else {
  410. $('.tips-empty').show();
  411. $('.tips-has,.tips-count,.tipscount').hide();
  412. }
  413. };
  414. if (clearall) {
  415. var saIds = [];
  416. $('#alltips .tips-item').each(function () {
  417. saIds.push({
  418. NO: $(this).attr('data-id')
  419. });
  420. });
  421. fnDeleteTips(saIds).done(function (res) {
  422. if (res.d > 0) {
  423. iTipsCount = 0;
  424. $('#alltips').html('');
  425. fnSet();
  426. }
  427. });
  428. }
  429. else {
  430. fnDeleteTips(otips.attr('data-id')).done(function (res) {
  431. if (res.d > 0) {
  432. iTipsCount--;
  433. otips.remove();
  434. fnSet();
  435. }
  436. });
  437. }
  438. },
  439. /**
  440. * 刪除提醒資料
  441. * @param {HTMLElement} tips 要刪除的消息ID
  442. * @return {Function} ajax物件
  443. */
  444. fnDeleteTips = function (tips) {
  445. return CallAjax(ComFn.W_Com, ComFn.GetDel, {
  446. Params: {
  447. tips: typeof tips === 'string' ? { NO: tips } : tips
  448. }
  449. });
  450. },
  451. /**
  452. * 刪除EIP提醒
  453. * @param {HTMLElement} tips 要刪除的消息ID
  454. * @return {Function} ajax物件
  455. */
  456. fnDeleteEipTips = function (tips) {
  457. return CallAjax(ComFn.W_Com, ComFn.GetDel, {
  458. Params: {
  459. clocktips: typeof tips === 'string' ? { NO: tips } : tips
  460. }
  461. });
  462. },
  463. /**
  464. * 重組數組
  465. * @param {Array} tipsusers 人員列表
  466. * @return {Array} 人員組合ID
  467. */
  468. fnReleaseUsers = function (tipsusers) {
  469. var saUsers = [];
  470. if (tipsusers && tipsusers.length > 0) {
  471. $.each(tipsusers, function (idx, user) {
  472. if (user) {
  473. saUsers.push(window.OrgID + user);
  474. }
  475. });
  476. }
  477. return saUsers;
  478. },
  479. /**
  480. * 刪除提醒資料
  481. * @param {Array} data 提示資料
  482. * @param {Array} tipsusers 人員列表
  483. * @return {Object} ajax
  484. */
  485. fnAddTips = function (data, tipsusers) {
  486. return CallAjax(ComFn.W_Com, ComFn.GetAdd, {
  487. Params: {
  488. tips: data
  489. }
  490. }, function (res) {
  491. if (res.d > 0) {
  492. if (tipsusers) {
  493. var sTipsUsers = fnReleaseUsers(tipsusers);
  494. parent.msgs.server.pushTips(sTipsUsers);
  495. }
  496. }
  497. });
  498. },
  499. /**
  500. * 取得樹狀圖清單資料
  501. * @param {String} sModid 模組ID
  502. * @return {String} 當前模組下所有程式清單html字串
  503. */
  504. getListMenu = function (sModid) {
  505. var saProgramList = g_db.GetDic('programList') || [],
  506. sectionData = new Array(2),
  507. Menuli = '<ul class="nav nav-pills">', //左邊清單列表
  508. Listli = '<ul>', //右邊清單列表
  509. subStyle = ''; //設定模組樣式Class
  510. //set Menu
  511. $.each(saProgramList, function (i, program) {
  512. if (program.ParentID === '' && program.ModuleID === sModid && program.ShowInList.toLowerCase() === 'y') {
  513. Menuli += " <li id=\"" + program.ModuleID + "\" class='menu-layer-one onmenu active' onclick=\"setTreeMenu('" + program.Module + "'); setMenuStyle('" + program.ModuleID + "');return false;\"> ";
  514. Menuli += " <a href='#' data-toggle='tab' class='menu-layer-one' data-i18n=common." + program.ModuleID + "></a></li> ";
  515. } //功能清單中的管理模組頁簽標題轉換
  516. else if (program.ParentID === '' && program.ModuleID !== sModid && program.ShowInList.toLowerCase() === 'y') {
  517. Menuli += " <li id=\"" + program.ModuleID + "\" class='menu-layer-one drophide' onclick=\"setTreeMenu('" + program.ModuleID + "'); setMenuStyle('" + program.ModuleID + "');return false;\"> ";
  518. Menuli += " <a href='#' data-toggle='tab' class='menu-layer-one' data-i18n=common." + program.ModuleID + "></a></li> ";
  519. } //功能清單中的進出口頁簽標題轉換
  520. });
  521. //setList
  522. $.each(saProgramList, function (e, program) {
  523. if (program.ParentID === sModid && program.ShowInList.toLowerCase() === 'y') {
  524. var subModule = '<ul>';
  525. var moduleid = program.ModuleID;
  526. $.each(saProgramList, function (i, program1) {
  527. if (program1.ParentID === moduleid && program1.ShowInList.toLowerCase() === 'y') {
  528. var sub2Module = "<ul>";
  529. var sub2moduleid = program1.ModuleID;
  530. $.each(saProgramList, function (m, program2) {
  531. if (program2.ParentID === sub2moduleid && program2.ShowInList.toLowerCase() === 'y') {
  532. var sub3Module = "<ul>";
  533. var sub3moduleid = program2.ModuleID;
  534. $.each(saProgramList, function (m, program3) {
  535. if (program3.ParentID === sub3moduleid && program3.ShowInList.toLowerCase() === 'y') {
  536. if (program3.FilePath === '#') {
  537. sub3Module += " <li id=\"" + program3.ModuleID + "\" class='layer-four folderType'>";
  538. sub3Module += " <a>" + program3.ModuleName + "</a></li> ";
  539. }
  540. else {
  541. sub3Module += " <li id=\"" + program3.ModuleID + "\" class='layer-four ProgramType' onclick=\"if('" + program3.FilePath + "'!='#') parent.openPageTab('" + program3.ModuleID + "');if('" + program3.FilePath + "'=='#'){setTreeMenu('" + program3.ModuleID + "');}\"> ";
  542. sub3Module += " <a href='#' data-i18n=common." + program3.ModuleID + "></a></li> ";
  543. }//功能清單中系統管理子層(系統架構、參數管理、組織結構)的底層標題
  544. }
  545. });
  546. sub3Module += '</ul>';
  547. if (program2.FilePath === '#') {
  548. sub2Module += " <li id=\"" + program2.ModuleID + "\" class='layer-three folderType'>";
  549. sub2Module += " <a data-i18n=common." + program2.ModuleID + "></a>" + sub3Module + "</li> ";
  550. }//功能清單中的頁簽標題轉換
  551. else {
  552. sub2Module += " <li id=\"" + program2.ModuleID + "\" class='layer-three ProgramType' onclick=\"if('" + program2.FilePath + "'!='#') parent.openPageTab('" + program2.ModuleID + "');if('" + program2.FilePath + "'=='#'){setTreeMenu('" + program2.ModuleID + "');}\"> ";
  553. sub2Module += " <a href='#' data-i18n=common." + program2.ModuleID + "></a>" + sub3Module + "</li> ";
  554. }//功能清單中系統管理下層的標題
  555. }
  556. });
  557. sub2Module += '</ul>';
  558. if (program1.FilePath === '#') {
  559. subModule += " <li id=\"" + program1.ModuleID + "\" class='layer-two folderType noborder'> ";
  560. subModule += " <a data-i18n=common." + program1.ModuleID + "></a>" + sub2Module + "</li>";
  561. }//功能清單中系統管理的子層標題轉換
  562. else {
  563. subModule += " <li id=\"" + program1.ModuleID + "\" class='layer-two ProgramType' onclick=\"if('" + program1.FilePath + "'!='#') parent.openPageTab('" + program1.ModuleID + "');if('" + program1.FilePath + "'=='#'){setTreeMenu('" + program1.ModuleID + "');}\"> ";
  564. subModule += " <a href='#' data-i18n=common." + program1.ModuleID + "></a>" + sub2Module + "</li>";
  565. }//功能清單中我的工作下層的標題
  566. }
  567. });
  568. subModule += '</ul>';
  569. if (program.FilePath === '#') {
  570. Listli += " <br class='clear'><div class='map-menu-list'><li id=\"" + program.ModuleID + "\" class='layer-one folderType' > ";
  571. Listli += " <a data-i18n=common." + program.ModuleID + "></a>" + subModule + "</li></div>";
  572. }//功能清單中我的工作及系統管理的轉換
  573. else {
  574. Listli += " <br class='clear'><div class='map-menu-list'><li id=\"" + program.ModuleID + "\" class='layer-one ProgramType' onclick=\"if('" + program.FilePath + "'!='#') parent.openPageTab('" + program.ModuleID + "');if('" + program.FilePath + "'=='#'){setTreeMenu('" + program.ModuleID + "');}\"> ";
  575. Listli += " <a href='#' data-i18n=common." + program.ModuleID + "></a>" + subModule + "</li></div>";
  576. }//進出口頁面父層
  577. }
  578. });
  579. Menuli += '</ul>';
  580. Listli += '</ul>';
  581. sectionData[0] = Menuli;
  582. sectionData[1] = Listli;
  583. return sectionData;
  584. },
  585. /**
  586. * 設定左邊清單點選樣式
  587. * @param {String} sModid 模組ID
  588. */
  589. setMenuStyle = function (sModid) {
  590. //先透過foreach迴圈清除所有的onmenu樣式
  591. $('#sectionMenu ul > li').each(function () {
  592. $(this).removeClass('onmenu');
  593. });
  594. //設定當前點選到的樣式
  595. $('#sectionMenu').find('#' + sModid).addClass('onmenu');
  596. },
  597. /**
  598. * 模組清單設定
  599. * @param {String} sModid 模組ID
  600. */
  601. setTreeMenu = function (sModid) {
  602. var oMenu = getListMenu(sModid);
  603. $('#sectionMenu').html(oMenu[0]);
  604. $('#sectionList').html(oMenu[1]).find('.folderType').each(function () {
  605. var oNext = $(this).next();
  606. if (oNext.length > 0 && [0].tagName !== 'BR' && oNext[0].className !== 'clear') {
  607. $(this).after('<br class="clear">');
  608. }
  609. });
  610. refreshLang();
  611. };
  612. /**
  613. * 開啟畫面
  614. * @param {String} programId 當前程式ID
  615. * @param {String} parameters 參數
  616. * @param {String} title 當前程式名稱
  617. * @return {Boolean} 是否停止
  618. */
  619. function openPageTab(programId, parameters, title) {
  620. var noAuthPrgs = ['NotView', 'Index', 'Test_Calendar'];// ╠common.Index⇒首頁╣
  621. if (!g_db.GetDic('programList') && noAuthPrgs.indexOf(programId) === -1) window.location.href = '/Page/Login.html';
  622. var sTitle = "", //頁簽標題
  623. sUrl = "", //網址
  624. sGrouptag = "default", //頁簽屬性,相同屬性者共用同一個頁簽
  625. sOperation = "",
  626. sTabTemplate = "<li aria-controls='#{controls}' id='li_" + programId + "'><a href='#{href}' role='tab' data-toggle='tab' aria-expanded='true' id='#{id}'><i class='fa fa-times-circle' aria-hidden='true'></i><span data-i18n='{i18nkey}'></span><i class='fa fa-refresh' aria-hidden='true'></i></a></li>", //頁簽預設內容
  627. sPara = parameters === undefined ? '' : parameters;
  628. //抓取各頁面的相關參數
  629. switch (programId) {
  630. case "Calendar_Test"://首頁
  631. case "Index"://首頁
  632. case "Profile"://個人主頁
  633. case "NotView"://沒有檢視權限
  634. if (programId !== 'Profile') {
  635. sTabTemplate = "<li aria-controls='#{controls}' id='li_" + programId + "'><a href='#{href}' data-i18n='{i18nkey}' role='tab' data-toggle='tab' aria-expanded='true' id='#{id}'></a> </li>"; //沒有刪除和刷新的頁簽
  636. }
  637. sUrl = '/Page/' + programId + '.html';
  638. sTitle = programId === 'NotView' ? 'Index' : 'common.' + programId;
  639. sGrouptag = programId;
  640. sPara = ''; //清空參數,因為sUrl已經帶參數了
  641. break;
  642. default:
  643. var saProgramList = g_db.GetDic('programList') || [],
  644. oProgram = {},
  645. saCorrects = Enumerable.From(saProgramList).Where(function (item) { return item.ModuleID === programId; }).ToArray();
  646. if (saCorrects.length > 0) {
  647. oProgram = saCorrects[0];
  648. }
  649. sOperation = oProgram.ModuleID;
  650. sTitle = title === undefined ? "common." + oProgram.ModuleID : title;
  651. sUrl = oProgram.FilePath; //頁簽
  652. sGrouptag = oProgram.grouptag !== '' ? oProgram.grouptag : sGrouptag;
  653. break;
  654. }
  655. if (!sUrl) {
  656. showMsg(i18next.t("message.Permissions")); // ╠message.Permissions⇒您沒有檢視權限,請聯繫系統管理員╣
  657. return false;
  658. }
  659. if (programId.indexOf('ngn_') > -1) {
  660. var link = document.createElement('a');
  661. link.target = '_blank';
  662. link.href = sUrl;
  663. link.click();
  664. return false;
  665. }
  666. var tabs = $("#tabs").tabs();
  667. window.tabs = tabs;
  668. var id = "tabs-" + sGrouptag; //導航Id(程式Id)
  669. var li = sTabTemplate.replaceAll('#{href}', "#" + id).replaceAll('#{id}', sGrouptag).replaceAll('{i18nkey}', sTitle).replaceAll('#{controls}', id);
  670. //判斷內容IFrame是否存在,如果不存在就添加
  671. if (window.ShowMode === 'M') {
  672. if ($("li[aria-controls=" + id + ']').length === 0) {
  673. $("#tabsList").append(li); //添加頁簽導航部分
  674. }
  675. else {
  676. var licontrols = $("li[aria-controls=" + id + ']');
  677. licontrols.attr({ 'id': 'li_' + programId });
  678. licontrols.find('a span').attr('data-i18n', 'common.' + programId);
  679. }
  680. }
  681. else {
  682. $("#tabsList").find('li').slice(1).remove(); //如果是單頁簽模式則移除前頁簽
  683. if ($("li[aria-controls=" + id + ']').length === 0) {
  684. $("#tabsList").append(li); //添加頁簽導航部分
  685. }
  686. }
  687. if (tabs.find('#' + id).length === 0) {
  688. var sContentHtml = '<iframe src="' + sUrl + sPara + '" style="width:100%;" onload="javascript:fnframesize(this.id);" id="iframe' + id + '" name="' + (sOperation || "Index") + '" class="tabiframe" frameborder="0" border="0" cellspacing="0" allowtransparency="true" scrolling="yes" />'; //新頁簽的內容部分
  689. tabs.append("<div id='" + id + "' class='tab-pane fade'>" + sContentHtml + "</div>"); //添加頁簽內容部分
  690. }
  691. $('#iframe' + id).attr({ "src": sUrl + sPara, 'name': sOperation });
  692. tabs.tabs("refresh"); //強迫刷新頁面
  693. //取得目前的頁簽位置
  694. var iIndex = $("#tabsList").find('li').length === 0 ? 0 : $("#tabsList").find('li').length - 1;
  695. SetCuryLiShow(iIndex);
  696. $("#tabsList").find('#' + sGrouptag).click(); //最後再點選一次,確定在畫面裡面
  697. //Alt+Backspace鍵,刪除頁簽
  698. tabs.bind("keyup", function (event) {
  699. if (event.altKey && event.keyCode === $.ui.keyCode.BACKSPACE) {
  700. var PrevLi = tabs.find(".ui-tabs-active").prev().find('a'),
  701. LiId = tabs.find(".ui-tabs-active").remove().attr("aria-controls"),
  702. sPrgid = tabs.find(".ui-tabs-active")[0].id;
  703. //$("#" + LiId).remove();
  704. PrevLi.click();
  705. if (sPrgid.indexOf('_Upd') > -1) {//移除當前操作的程式
  706. msgs.server.removeEditPrg(sPrgid);
  707. }
  708. if (sPrgid.indexOf('_View') > -1) {//移除當前操作的程式
  709. msgs.server.removeEditPrg(sPrgid);
  710. }
  711. }
  712. });
  713. //刪除頁簽
  714. tabs.find(".fa-times-circle").unbind('click').click(function () {
  715. var sPrgid = $(this).closest("li")[0].id;
  716. var LiId = $(this).closest('li').attr("aria-controls"); //找到頁面ID(請搜尋<li><a href='#{href}' id='#{id}'>)
  717. if (sPrgid.indexOf('_Upd') > -1 || sPrgid.indexOf('_View') > -1){
  718. window.editClose = true;
  719. window.thisId = $(this);
  720. var getUrl = $('#iframe' + LiId).attr('src'); //取得目前的連結(src)
  721. $("#iframe" + LiId).contents().find('#Toolbar_Leave').click();
  722. } else {
  723. var PrevLi = $(this).closest("li").prev().find('a'),
  724. LiId = $(this).closest("li").remove().attr("aria-controls");
  725. PrevLi.click();
  726. }
  727. /* if (sPrgid.indexOf('_Upd') > -1 || sPrgid.indexOf('_View') > -1) {//移除當前操作的程式
  728. msgs.server.removeEditPrg(sPrgid.replace('li_', ''));
  729. } */
  730. /* var PrevLi = $(this).closest("li").prev().find('a'),
  731. LiId = $(this).closest("li").remove().attr("aria-controls"); */
  732. //$("#" + LiId).remove();
  733. //PrevLi.click();
  734. });
  735. //重新整理頁簽
  736. tabs.find('.fa-refresh').unbind('click').click(function () {
  737. var LiId = $(this).closest('li').attr("aria-controls"); //找到頁面ID(請搜尋<li><a href='#{href}' id='#{id}'>)
  738. var getUrl = $('#iframe' + LiId).attr('src'); //取得目前的連結(src)
  739. $("#iframe" + LiId).attr('src', getUrl); //重新載入連結,不等於清除功能
  740. });
  741. setContentHeight();
  742. transLang($('#tabsList'));
  743. }
  744. function setCurryIndex(intAdd) {
  745. var intCurryIndex = iCuryIndex;
  746. intCurryIndex = intCurryIndex + intAdd;
  747. if (intCurryIndex < 0) {
  748. intCurryIndex = 0;
  749. }
  750. if (intCurryIndex >= $("#tabsList").find("li").length - 2) {
  751. intCurryIndex = $("#tabsList").find("li").length - 2;
  752. }
  753. iCuryIndex = intCurryIndex;
  754. GetLiWidth();
  755. }
  756. function GetLiWidth() {
  757. $("#tabsList").find("li").each(function (n) {
  758. if (n <= iCuryIndex && n !== 0 && n !== $("#tabsList").find("li").length - 1) {
  759. $(this).hide();
  760. $("#divPrevNext").show();
  761. } else {
  762. $(this).show();
  763. }
  764. });
  765. $('#tabsList').css('width', $('#tabpanel')[0].offsetWidth - 130 + 'px');
  766. }
  767. function reSetLi(index, width) {
  768. this.index = index;
  769. this.width = width;
  770. return this;
  771. }
  772. function SetCuryLiShow(intLeftCount) {
  773. var aryWidth = new Array();
  774. $("#tabsList").find("li").each(function (n) {
  775. var li = new reSetLi(n, this.offsetWidth);
  776. aryWidth.push(li);
  777. });
  778. var windowsize = $(window).width() - 100; //屏幕分辨率
  779. if (navigator.userAgent.match(/mobile/i)) {
  780. windowsize = screen.width - 40;
  781. }
  782. var _itemwidth = 0;
  783. var intStartIndex = 0;
  784. var intEndIndex = intLeftCount;
  785. for (var i = intLeftCount; i >= 0; i--) {
  786. _itemwidth += aryWidth[i].width * 1;
  787. if (_itemwidth > windowsize) {
  788. intStartIndex = i + 1;
  789. setCurryIndex(1);
  790. break;
  791. }
  792. }
  793. $("#tabsList").find("li").each(function (n) {
  794. if (n >= intStartIndex) {
  795. $(this).show();
  796. if (n > intEndIndex) {
  797. $("#divPrevNext").show();
  798. }
  799. } else {
  800. if (n !== 0 && n !== $("#tabsList").find("li").length - 1) {
  801. $(this).hide();
  802. $("#divPrevNext").show();
  803. }
  804. }
  805. });
  806. iCuryIndex = intStartIndex;
  807. }
  808. /**
  809. * 消息組件初始化
  810. */
  811. function MsgApp() {
  812. var init = function () {
  813. //$.connection.hub.url = gServerUrl + '/signalr';
  814. var connection = $.connection.hub;
  815. msgs = $.connection.msgHub;
  816. connection.logging = true;
  817. fnFeed();
  818. //hub连接开启
  819. connection.start().done(function () {
  820. fnRegister(true);
  821. if (window.Outklook) {
  822. if (!window.OutklookSync) {
  823. $('.outlook-waiting').slideDown();
  824. outlookAPI(outlook.SynChronous, { flag: "auto" },
  825. function (res) {
  826. if (res === '1') {
  827. window.OutklookSync += 1;
  828. g_db.SetItem('outklooksync', window.OutklookSync);
  829. }
  830. });
  831. }
  832. }
  833. else {
  834. if (!window.OutlookTips) {
  835. setTimeout(function () {
  836. // ╠common.OutlookTips⇒當前未同步登入Outlook,操作行事曆可能不會同步或更新╣
  837. // ╠common.ReLoad⇒重新登入╣
  838. // ╠common.Close⇒關閉╣
  839. // ╠common.Or⇒或╣
  840. $('.outlook-waiting').html(
  841. [
  842. i18next.t('common.Tips'),
  843. ':',
  844. i18next.t('common.OutlookTips'),
  845. ' ',
  846. $('<a/>', {
  847. text: i18next.t('common.ReLoad'),
  848. class: 'link',
  849. click: function () {
  850. $('.log-out').trigger('click');
  851. }
  852. }),
  853. i18next.t('common.Or'),
  854. $('<a/>', {
  855. text: i18next.t('common.Close'),
  856. class: 'link',
  857. click: function () {
  858. $('.outlook-waiting').slideUp();
  859. window.OutlookTips += 1;
  860. g_db.SetItem('outlooktips', window.OutlookTips);
  861. }
  862. })
  863. ]).css({ 'font-size': '15px', 'padding-top': '5px', 'color': '#ff0000' }).slideDown();
  864. }, 3660);
  865. }
  866. }
  867. })
  868. .fail(function () {
  869. console.log("Could not Connect!");
  870. });
  871. connection.connectionSlow(function () {
  872. //console.log("connectionSlow");
  873. });
  874. connection.disconnected(function () {
  875. setTimeout(function () {//掉線後10秒內自動重新連線
  876. connection.start().done(function () {
  877. fnRegister(false);
  878. });
  879. }, 1000);
  880. });
  881. connection.error(function (error) {
  882. //console.log(error);
  883. });
  884. connection.reconnected(function () {
  885. //console.log("reconnected");
  886. });
  887. connection.reconnecting(function () {
  888. //console.log("reconnecting");
  889. });
  890. connection.starting(function () {
  891. //console.log("starting");
  892. });
  893. connection.stateChanged(function (state) {
  894. //console.log(state);
  895. });
  896. };
  897. init();
  898. }
  899. function fnFeed() {
  900. var init = function () {
  901. //后端登陸註冊调用后,产生的loginUser回调
  902. msgs.client.onConnected = function (connnectId, userName, onlineUsers) {
  903. //console.log(JSON.stringify(onlineUsers));
  904. online_Users = onlineUsers;
  905. if ($('#iframetabs-Profile').length > 0) {
  906. $('#iframetabs-Profile')[0].contentWindow.fnSetUserOnline();
  907. }
  908. };
  909. //后端断线时调用调用后,产生的loginUser回调
  910. msgs.client.onUserDisconnected = function (connnectId, onlineUsers, orgId, userId, userName, isLogin, tips) {
  911. online_Users = onlineUsers;
  912. if ($('#iframetabs-Profile').length > 0) {
  913. $('#iframetabs-Profile')[0].contentWindow.fnSetUserOnline();
  914. }
  915. if (isLogin && userId === UserInfo.MemberID) {
  916. // ╠message.VerifyOutTips⇒您的帳號已在別處登入╣ ╠common.Tips⇒提示╣
  917. layer.alert(i18next.t("message.VerifyOutTips") + '<br>' + tips, { icon: 0, closeBtn: 0, title: i18next.t("common.Tips") }, function (index) {
  918. window.top.location.href = '/Page/Login.html';
  919. });
  920. }
  921. };
  922. //推送公告
  923. msgs.client.broadcast = function (msg) {
  924. fnGetAnnouncements();
  925. };
  926. //推送是否可編輯結果(true or false)
  927. msgs.client.checkedit = function (isedit, prgid, username) {
  928. if (!isedit) {
  929. var oCurrentFn = $('iframe[name=' + prgid + ']');
  930. //oCurrentFn.contents().ready
  931. // ╠message.NotToEdit⇒當前資料正在編輯,稍後請刷新頁面再繼續操作╣ ╠common.Operator⇒操作人╣
  932. oCurrentFn[0].contentWindow.showTips(i18next.t("message.NotToEdit") + ',' + i18next.t("common.Operator") + ':' + username);
  933. parent.bLockDataForm0430 = false;
  934. var CheckTablelistType = oCurrentFn.contents().find('[role=\'tablist\']').length > 0;
  935. //tab-content: 多個子頁籤(例如進口編輯)
  936. if (CheckTablelistType) {
  937. oCurrentFn.contents().find(".tab-content").css('pointer-events', 'none');
  938. }
  939. //panel-body: 只有一個頁面(例如部門資料編輯)
  940. else {
  941. oCurrentFn.contents().find(".panel-body").css('pointer-events', 'none');
  942. }
  943. //toolbar
  944. oCurrentFn.contents().find('#Toolbar button').not('#Toolbar_Leave').attr('disabled', true);
  945. }
  946. };
  947. //更新提示
  948. msgs.client.pushtips = function (msg) {
  949. fnGetTips();
  950. };
  951. //推送系統消息
  952. msgs.client.pushmsgs = function (msg) {
  953. };
  954. //檢核文字檔小助手是否安裝
  955. msgs.client.existtrasfer = function (msg, bInstall) {
  956. if (bInstall) {
  957. var sPrgId = '';
  958. switch (msg) {
  959. case 'IM':
  960. sPrgId = 'ExhibitionImport';
  961. break;
  962. case 'EX':
  963. sPrgId = 'ExhibitionExport';
  964. break;
  965. }
  966. $('#iframetabs-' + sPrgId)[0].contentWindow.fnToAccountAudit();
  967. }
  968. else {
  969. layer.msg(i18next.t("message.Financial_InstallTransfer")); // ╠message.Financial_InstallTransfer⇒請先安裝文字檔小助手╣
  970. }
  971. };
  972. //提示安裝並運行文字檔小助手
  973. msgs.client.transfertips = function (connectionid) {
  974. layer.msg(i18next.t("message.Financial_InstallTransfer")); // ╠message.Financial_InstallTransfer⇒請先安裝文字檔小助手╣
  975. };
  976. //test
  977. msgs.client.hello = function (msg) {
  978. //debugger;
  979. };
  980. // msgs.server.offline();
  981. //推送消息
  982. msgs.client.message = function (data) {
  983. switch (data.Type) {
  984. case 0:
  985. break;
  986. case 1:
  987. break;
  988. case 2:
  989. break;
  990. case 3:
  991. break;
  992. case 4:
  993. break;
  994. case 5:
  995. break;
  996. case 6:
  997. break;
  998. case 7:
  999. break;
  1000. case 'OutlookSynChronous':
  1001. {
  1002. if (data.Flag === 'auto') {
  1003. if (data.Message === UserInfo.OutlookAccount) {
  1004. var elSuccess = $('.outlook-waiting');
  1005. elSuccess.find('span').text(i18next.t("message.SynchronousSuccess")).css({ 'color': 'green' });
  1006. elSuccess.find('img').attr('src', '../images/Success.png');
  1007. setTimeout(function () {
  1008. elSuccess.slideUp();
  1009. }, 2500);
  1010. }
  1011. }
  1012. else if (data.Flag === 'once') {
  1013. var iframe_Calendar = $('#iframetabs-Calendar');
  1014. if (iframe_Calendar.length > 0) {
  1015. iframe_Calendar[0].contentWindow.closeTips(data.Memo);
  1016. }
  1017. }
  1018. }
  1019. break;
  1020. }
  1021. };
  1022. //接收消息
  1023. msgs.client.receive = function (data) {
  1024. switch (data.Type) {
  1025. case 1://發送給自己
  1026. break;
  1027. case 2://發送給連線人員
  1028. break;
  1029. case 3://發送給制定人員ID
  1030. {
  1031. switch (data.Memo) {
  1032. case 'tips'://系統所有待辦定時提醒
  1033. fnShowTips(data.Content);
  1034. break;
  1035. case 'attendance'://EIP考勤提醒
  1036. fnAttendanceTips(data.Content);
  1037. break;
  1038. }
  1039. }
  1040. break;
  1041. case 4://發送給制定多個人員ID
  1042. break;
  1043. case 5://發送給制定群組
  1044. break;
  1045. }
  1046. };
  1047. };
  1048. init();
  1049. }
  1050. $(function () {
  1051. 'use strict';
  1052. var
  1053. /**
  1054. * 設定系統時間
  1055. */
  1056. Refresh = function () {
  1057. var Nowtime = new Date().formate("HH:mm:ss");
  1058. ltrdate.innerHTML = new Date().formate("yyyy.MM.dd (EEE)");
  1059. ltrtime.innerHTML = Nowtime;
  1060. setTimeout(Refresh, 1000);
  1061. },
  1062. /**
  1063. * 特殊處理由於階層的關係需要去判斷border-right的顯示下noborder代表不下樣式
  1064. */
  1065. setTreeViewCss = function () {
  1066. $("#sectionList li:not('.layer-one')").each(function () {
  1067. if ($(this).hasClass('folderType')) { //如果該li的class為folderType,在上上層的li加上 class noborder, 加在上上層的原因為folderType的li前面都會加上<br class="clear">的中斷點
  1068. $(this).prev().prev().addClass('noborder');
  1069. }
  1070. });
  1071. },
  1072. /**
  1073. * 設定頁簽顯示方式
  1074. */
  1075. setShowMode = function () {
  1076. if (window.ShowMode === "M") { //判斷當前是否開啟多頁簽
  1077. window.ShowMode = "S";
  1078. $("#divPrevNext,#tabpanel").hide();
  1079. } else {
  1080. window.ShowMode = "M";
  1081. $("#divPrevNext,#tabpanel").show();
  1082. }
  1083. CallAjax(ComFn.W_Com, ComFn.GetUpd, {
  1084. Params: {
  1085. members: {
  1086. values: { SysShowMode: window.ShowMode },
  1087. keys: {
  1088. MemberID: window.UserID,
  1089. OrgID: window.OrgID
  1090. }
  1091. }
  1092. }
  1093. }, function (res) {
  1094. if (res.d > 0) {
  1095. showMsg(i18next.t("message.SetTab_Successed"), 'success'); // ╠message.Delete_Success⇒設定頁簽模式成功╣
  1096. }
  1097. else {
  1098. showMsg(i18next.t("message.SetTab_Failed"), 'error'); // ╠message.SetTab_Failed⇒設定頁簽模式失敗╣
  1099. }
  1100. });
  1101. },
  1102. /**
  1103. * 更改語系國別
  1104. * @param {String} lang 當前語言
  1105. */
  1106. fnUpdCountry = function (lang) {
  1107. CallAjax(ComFn.W_Com, ComFn.GetUpd, {
  1108. Params: {
  1109. members: {
  1110. values: { Country: lang },
  1111. keys: {
  1112. MemberID: window.UserID,
  1113. OrgID: window.OrgID
  1114. }
  1115. }
  1116. }
  1117. }, function (res) { });
  1118. },
  1119. /**
  1120. * 獲取組織資料
  1121. * @return {Function} ajax物件
  1122. */
  1123. fnGetOrgData = function () {
  1124. return CallAjax(ComFn.W_Com, ComFn.GetOne, {
  1125. Type: '',
  1126. Params: {
  1127. organization: {
  1128. OrgID: window.OrgID
  1129. }
  1130. }
  1131. }).done(function (res) {
  1132. if (res.d) {
  1133. var oOrg = $.parseJSON(res.d);
  1134. window.OrgInfo = oOrg;
  1135. $('title').text(OrgInfo.SystemCName);
  1136. $('.logo-min').attr('src', '/Controller.ashx?action=getimg&folder=Organization&id=' + oOrg.LoGoId + '&orgid=' + oOrg.OrgID + '&times=' + $.now());
  1137. }
  1138. });
  1139. },
  1140. /**
  1141. * 獲取個人資料
  1142. * @return {Function} ajax物件
  1143. */
  1144. fnGetPersonalData = function () {
  1145. return $.whenArray([
  1146. g_api.ConnectLite('Authorize', 'GetUserInfo'),
  1147. g_api.ConnectLite(Service.com, ComFn.GetSysSet)])
  1148. .done(function (res1, res2) {
  1149. window.UserInfo = {};
  1150. window.SysSet = {};
  1151. if (res1[0].RESULT > 0) {
  1152. var oUser = res1[0].DATA.rel;
  1153. //$('#userName').text(oUser.MemberName);
  1154. $('<span>', { text: oUser.MemberName }).prependTo("#spUser");
  1155. window.UserInfo = oUser;
  1156. UserInfo.OrgID = window.OrgID;
  1157. UserInfo.roles = UserInfo.roles || '';
  1158. var sMemberPic = $.trim(UserInfo.MemberPic);
  1159. UserInfo.MemberPic = sMemberPic === '' ? guid() : sMemberPic;
  1160. fnSetArgDrop([
  1161. {
  1162. ArgClassID: 'LanCountry',
  1163. Select: $('#countrychange'),
  1164. ShowId: true,
  1165. DefultVal: UserInfo.Country,
  1166. CallBack: function () {
  1167. $('#countrychange')[0].remove(0);// 移除下拉選單第一個選項
  1168. }
  1169. }
  1170. ]);
  1171. fnGetAnnouncements();
  1172. var msgApp = new MsgApp();
  1173. }
  1174. if (res2[0].RESULT > 0) {
  1175. var saList = res2[0].DATA.rel;
  1176. $.each(saList, function (i, oSet) {
  1177. window.SysSet[oSet.SettingItem] = oSet.SettingValue;
  1178. });
  1179. window.SysSet.GridRecords = window.SysSet.GridRecords || 10;
  1180. window.SysSet.GridPages = window.SysSet.GridPages || 15;
  1181. window.SysSet.CustomersAuditUsers = window.SysSet.CustomersAuditUsers || '';
  1182. window.SysSet.BillAuditor = window.SysSet.BillAuditor || '';
  1183. window.SysSet.TaxRate = window.SysSet.TaxRate || '0';
  1184. window.SysSet.IsOpenMail = window.SysSet.IsOpenMail || 'N';
  1185. window.SysSet.CDDProUsers = window.SysSet.CDDProUsers || '';
  1186. UserInfo.IsManager = UserInfo.roles.indexOf(SysSet.Supervisor) > -1 || UserInfo.roles.indexOf('Manager') > -1;
  1187. }
  1188. fnGetHeadPic();
  1189. });
  1190. },
  1191. /**
  1192. * 獲取程式資料
  1193. * @return {Function} ajax物件
  1194. */
  1195. fnGetProgramList = function () {
  1196. return g_api.ConnectLite(Service.sys, 'GetSysFNList', {},
  1197. function (res) {
  1198. if (res.RESULT === 0) {
  1199. alert(res.MSG);
  1200. }
  1201. else {
  1202. var sPrgList = res.DATA.rel;
  1203. g_db.SetDic('programList', sPrgList);
  1204. if (sPrgList.length > 0) {
  1205. window.TopModID = sPrgList[0].ModuleID;
  1206. setTreeMenu(TopModID); //產生功能清單
  1207. setTreeViewCss();
  1208. }
  1209. }
  1210. });
  1211. },
  1212. /**
  1213. * 獲取頭像
  1214. * @return {Function} ajax物件
  1215. */
  1216. fnGetHeadPic = function () {
  1217. var callback = function (files) {
  1218. UserInfo.Filelist = files;
  1219. $('#imgUser').attr('src', '/Controller.ashx?action=getimg&folder=Members&id=' + UserInfo.MemberPic + '&orgid=' + UserInfo.OrgID + '&times=' + $.now());
  1220. };
  1221. return fnGetUploadFiles(UserInfo.MemberPic, callback);
  1222. },
  1223. /**
  1224. * 上傳頭像
  1225. * @param {Array} files 當前文件
  1226. * @param {HTMLElement} iframe 父層表單
  1227. */
  1228. fnUpload = function (files, iframe) {
  1229. var option = {};
  1230. option.input = iframe.find('#fileInput');
  1231. option.limit = 1;
  1232. option.extensions = ['jpg', 'jpeg', 'png', 'bmp', 'gif', 'png'];
  1233. option.theme = 'dragdropbox';
  1234. option.folder = 'Members';
  1235. option.type = 'one';
  1236. option.parentid = UserInfo.MemberPic;
  1237. option.uploadFile = {
  1238. url: '/Controller.ashx?action=upload&source=Members&userid=' + UserInfo.MemberID + '&orgid=' + UserInfo.OrgID + '&parentid=' + UserInfo.MemberPic,
  1239. data: null,
  1240. type: 'POST',
  1241. enctype: 'multipart/form-data',
  1242. beforeSend: function () { },
  1243. success: function (data, el) {
  1244. iframe.find('.jFiler-input-dragDrop').hide();
  1245. var parent = el.find(".jFiler-jProgressBar").parent();
  1246. fnGetHeadPic();
  1247. el.find(".jFiler-jProgressBar").fadeOut("slow", function () {
  1248. $("<div class=\"jFiler-item-others text-success\"><i class=\"icon-jfi-check-circle\"></i> Success</div>").hide().appendTo(parent).fadeIn("slow");
  1249. });
  1250. },
  1251. error: function (el) {
  1252. var parent = el.find(".jFiler-jProgressBar").parent();
  1253. el.find(".jFiler-jProgressBar").fadeOut("slow", function () {
  1254. $("<div class=\"jFiler-item-others text-error\"><i class=\"icon-jfi-minus-circle\"></i> Error</div>").hide().appendTo(parent).fadeIn("slow");
  1255. });
  1256. },
  1257. statusCode: null,
  1258. onProgress: null,
  1259. onComplete: null
  1260. };
  1261. option.uploadFile = {
  1262. url: '/Controller.ashx?action=upload&source=Members&userid=' + UserInfo.MemberID + '&orgid=' + UserInfo.OrgID + '&parentid=' + UserInfo.MemberPic,
  1263. data: null,
  1264. type: 'POST',
  1265. enctype: 'multipart/form-data',
  1266. beforeSend: function () { },
  1267. success: function (data, el) {
  1268. iframe.find('.jFiler-input-dragDrop').hide();
  1269. var parent = el.find(".jFiler-jProgressBar").parent();
  1270. fnGetHeadPic();
  1271. el.find(".jFiler-jProgressBar").fadeOut("slow", function () {
  1272. $("<div class=\"jFiler-item-others text-success\"><i class=\"icon-jfi-check-circle\"></i> Success</div>").hide().appendTo(parent).fadeIn("slow");
  1273. });
  1274. },
  1275. error: function (el) {
  1276. var parent = el.find(".jFiler-jProgressBar").parent();
  1277. el.find(".jFiler-jProgressBar").fadeOut("slow", function () {
  1278. $("<div class=\"jFiler-item-others text-error\"><i class=\"icon-jfi-minus-circle\"></i> Error</div>").hide().appendTo(parent).fadeIn("slow");
  1279. });
  1280. },
  1281. statusCode: null,
  1282. onProgress: null,
  1283. onComplete: null
  1284. };
  1285. option.onRemove = function (itemEl, file) {
  1286. DelFile(UserInfo.MemberPic, 'parent').done(function () {
  1287. iframe.find('.jFiler-input-dragDrop').show();
  1288. fnGetHeadPic();
  1289. });
  1290. };
  1291. if (files) {
  1292. option.files = files;
  1293. }
  1294. fnUploadRegister(option);
  1295. },
  1296. /**
  1297. * 初始化
  1298. */
  1299. init = function () {
  1300. if (!g_db.SupportLocalStorage()) {
  1301. if (sLang === 'en') {
  1302. alert('The current browser does not support local storage. Please turn off private browsing settings');
  1303. }
  1304. else if (sLang === 'zh') {
  1305. alert('当前浏览器不支持本地储存,请关闭无痕浏览模式');
  1306. }
  1307. else {
  1308. alert('當前瀏覽器不支持本地儲存,請關閉私密瀏覽設定');
  1309. }
  1310. $('body').html('');
  1311. return;
  1312. }
  1313. window.OrgID = g_db.GetItem('orgid');
  1314. window.UserID = g_db.GetItem('userid');
  1315. window.ShowMode = g_db.GetItem('mode');
  1316. window.Outklook = g_db.GetItem('outklook') === 'true';
  1317. window.OutklookSync = parseInt(g_db.GetItem('outklooksync') || 0);
  1318. window.OutlookTips = parseInt(g_db.GetItem('outlooktips') || 0);
  1319. if (!window.OrgID || !window.UserID) {
  1320. window.location.href = '/Page/Login.html';
  1321. return;
  1322. }
  1323. fnGetOrgData();
  1324. $.whenArray([
  1325. fnGetPersonalData(),
  1326. fnGetProgramList()
  1327. ]).done(function () {
  1328. var saProgramList = g_db.GetDic('programList') || [];
  1329. if (saProgramList.length) {
  1330. setLang(UserInfo.Country, undefined, function () {
  1331. openPageTab('Index', 'Index');
  1332. });
  1333. }
  1334. else {
  1335. openPageTab('NotView', 'NotView');
  1336. return false;
  1337. }
  1338. fnGetAbsenceFromLastWeek();
  1339. });
  1340. fnGetTips();
  1341. // Slimscroll
  1342. slimScroll();
  1343. Waves.displayEffect();//波浪
  1344. //$('#divPenlSetting').click(function () {
  1345. // setShowMode();
  1346. //});
  1347. if (window.ShowMode === "S") { //判斷當前是否開啟多頁簽
  1348. $("#divPrevNext,#tabpanel").hide();
  1349. }
  1350. $('.stop-prevent').on('click', function (e) {
  1351. return false;
  1352. });
  1353. ///登陸outlook
  1354. //$('.mail-box').on('click', function (e) {
  1355. // if (!UserInfo.OutLookId) {
  1356. // window.location.href = "/Home/Index";
  1357. // return false;
  1358. // }
  1359. //});
  1360. $('.log-out').on('click', function (e) {
  1361. var fnClear = function () {
  1362. g_db.RemoveItem('orgid');
  1363. g_db.RemoveItem('userid');
  1364. g_db.RemoveItem('loginname');
  1365. g_db.RemoveItem('usertype');
  1366. g_db.RemoveItem('mode');
  1367. g_db.RemoveItem('token');
  1368. g_db.RemoveItem('outklook');
  1369. };
  1370. fnClear();
  1371. if (window.Outklook) {
  1372. window.location.href = "/Login/Index?orgid=&userid=";
  1373. }
  1374. else {
  1375. window.location.href = '/Page/Login.html';
  1376. }
  1377. // ╠message.ToLogOut⇒是否同時退出Outlook?╣ ╠common.Tips⇒提示╣
  1378. /*layer.confirm(i18next.t("message.ToLogOut"),
  1379. {
  1380. icon: 3,
  1381. title: i18next.t("common.Tips"),
  1382. btn: [i18next.t('common.Yes'), i18next.t('common.No')] // ╠message.Yes⇒是╣ ╠common.No⇒否╣
  1383. },
  1384. function (index) {
  1385. fnClear();
  1386. window.location.href = "/Login/Index?orgid=&userid=";
  1387. layer.close(index);
  1388. },
  1389. function () {
  1390. fnClear();
  1391. window.location.href = '/Page/Login.html';
  1392. }
  1393. );*/
  1394. });
  1395. ///左移
  1396. $("#lbtnPrev").on('click', function () {
  1397. setCurryIndex(-1);
  1398. });
  1399. ///右移
  1400. $("#lbtnNext").on('click', function () {
  1401. setCurryIndex(1);
  1402. });
  1403. /**
  1404. * 行事曆
  1405. */
  1406. $(".person-list>li>a").on('click', function () {
  1407. var that = this;
  1408. switch (that.id) {
  1409. case 'profile':
  1410. openPageTab('Profile');
  1411. break;
  1412. case 'userinfo':
  1413. var oValidator = null;
  1414. layer.open({
  1415. id: 'memberinfo',
  1416. type: 2,
  1417. title: i18next.t('common.PersonalDataUpdate'),//╠common.PersonalDataUpdate⇒個人資料修改╣
  1418. offset: '100px',//右下角弹出
  1419. shade: 0.75,
  1420. area: ['660px', '600px'],
  1421. content: '/Page/Pop/UpdUserInfo.html', //iframe的url,
  1422. btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  1423. success: function (layero, index) {
  1424. var iframe = $('iframe').contents();
  1425. iframe.find('#MemberID').val(UserInfo.MemberID);
  1426. iframe.find('#MemberName').val(UserInfo.MemberName);
  1427. //自定義驗證屬性
  1428. $.validator.addMethod("notEqualTo", function (value, element, param) {
  1429. if (value === '' && iframe.find(param).val() === '') {
  1430. return true;
  1431. }
  1432. return value !== iframe.find(param).val();
  1433. });
  1434. $.validator.addMethod("EqualToNew", function (value, element, param) {
  1435. if (value === '' && iframe.find(param).val() === '') {
  1436. return true;
  1437. }
  1438. return value === iframe.find(param).val();
  1439. });
  1440. $.validator.addMethod("New_required", function (value, element, param) {
  1441. if (value === '' && iframe.find(param).val() !== '') {
  1442. return false;
  1443. }
  1444. return true;
  1445. });
  1446. oValidator = iframe.find("#form_UpdUserInfo").validate({ //表單欄位驗證
  1447. rules: {
  1448. OldPsw: { New_required: "#NewPsw" },
  1449. NewPsw: { notEqualTo: "#OldPsw" },
  1450. CheckNewPsw: {
  1451. EqualToNew: "#NewPsw"
  1452. }
  1453. },
  1454. messages: {
  1455. MemberName: i18next.t('UpdUserInfo.MemberName_required'),// ╠UpdUserInfo.MemberName_required⇒請輸入名稱╣
  1456. OldPsw: {
  1457. New_required: i18next.t('UpdUserInfo.OldPsw_required')// ╠UpdUserInfo.OldPsw_required⇒請輸入舊密碼╣
  1458. },
  1459. CalColor: i18next.t('UpdUserInfo.CalColor_required'),// ╠UpdUserInfo.CalColor_required⇒請輸入行事曆顏色╣
  1460. NewPsw: {
  1461. required: i18next.t('UpdUserInfo.NewPsw_required'),// ╠UpdUserInfo.NewPsw_required⇒請輸入新密碼╣
  1462. notEqualTo: i18next.t('UpdUserInfo.NotEqualTo')// ╠UpdUserInfo.NotEqualTo⇒舊密碼與新密碼不可相同╣
  1463. },//舊密碼與新密碼不可相同
  1464. CheckNewPsw: {
  1465. required: i18next.t('UpdUserInfo.CheckNewPsw_required'),// ╠UpdUserInfo.CheckNewPsw_required⇒再次輸入新密碼╣
  1466. EqualToNew: i18next.t('UpdUserInfo.EqualTo') // ╠UpdUserInfo.EqualTo⇒兩次密碼輸入不相符╣
  1467. }
  1468. }
  1469. });
  1470. fnUpload(UserInfo.Filelist, iframe);
  1471. if (UserInfo.Filelist.length > 0) {
  1472. iframe.find('.jFiler-input-dragDrop').hide();
  1473. }
  1474. transLang(iframe.find('#form_UpdUserInfo'));
  1475. },
  1476. yes: function (index, layero) {
  1477. var iframe = $('iframe').contents();
  1478. if (!iframe.find("#form_UpdUserInfo").valid()) {
  1479. oValidator.focusInvalid();
  1480. return false;
  1481. }
  1482. var data = {
  1483. UserName: iframe.find('#MemberName').val(),
  1484. OldPsw: iframe.find('#OldPsw').val(),
  1485. NewPsw: iframe.find('#NewPsw').val(),
  1486. CalColor: iframe.find('#CalColor').val(),
  1487. MemberPic: UserInfo.MemberPic
  1488. };
  1489. g_api.ConnectLite(Service.auth, 'UpdataPsw', data, function (res) {
  1490. if (res.RESULT) {
  1491. UserInfo.CalColor = data.CalColor;
  1492. showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Modify_Success⇒修改成功╣
  1493. layer.close(index);
  1494. }
  1495. else {
  1496. if (res.MSG === "1") {
  1497. showMsg(i18next.t("message.CheckOldPassword"), 'error');// ╠message.CheckOldPassword⇒舊密碼驗證失敗╣
  1498. }
  1499. else if (res.MSG === "2") {
  1500. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  1501. }
  1502. else {
  1503. showMsg(i18next.t("message.Modify_Failed") + '<br>' + res.MSG, 'error'); //╠message.Modify_Failed⇒修改失敗╣
  1504. }
  1505. }
  1506. }, function () {
  1507. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  1508. });
  1509. }
  1510. });
  1511. break;
  1512. case 'calendar':
  1513. openPageTab('Calendar');
  1514. break;
  1515. }
  1516. });
  1517. /**
  1518. * 語系國別設定
  1519. */
  1520. $('#countrychange').on('change', function () {
  1521. $('#setlistset').click();
  1522. var sLang = $(this).val();
  1523. fnUpdCountry(sLang);
  1524. setLang(sLang);
  1525. $('#tabsList>li').each(function () {
  1526. var sId = $(this).attr('aria-controls'),
  1527. iframe = $('#' + sId).find('iframe').contents();
  1528. setLang(sLang, iframe);
  1529. });
  1530. });
  1531. setTimeout(Refresh, 1000);
  1532. //closeWaiting(3000); //最長3秒鐘停止等待
  1533. //var sFileName = "John_Test",
  1534. // sInputPath = "C:\Users\Alina\Desktop\Temple\OfficeToPDF\Demo\土地建物分離估價適用版.xlsx";
  1535. //g_api.ConnectLite('Pdf', 'ExcelToPdf', {
  1536. // InputPath: sInputPath,
  1537. // FileName: sFileName
  1538. //}, function (res) {
  1539. // if (res.RESULT) {
  1540. // DownLoadFile(res.DATA.rel, sFileName);
  1541. // }
  1542. // else {
  1543. // showMsg(res.MSG, 'error');
  1544. // }
  1545. //});
  1546. //debugger;
  1547. };
  1548. init();
  1549. });