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.

1633 lines
70 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 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. var id = "tabs-" + sGrouptag; //導航Id(程式Id)
  668. var li = sTabTemplate.replaceAll('#{href}', "#" + id).replaceAll('#{id}', sGrouptag).replaceAll('{i18nkey}', sTitle).replaceAll('#{controls}', id);
  669. //判斷內容IFrame是否存在,如果不存在就添加
  670. if (window.ShowMode === 'M') {
  671. if ($("li[aria-controls=" + id + ']').length === 0) {
  672. $("#tabsList").append(li); //添加頁簽導航部分
  673. }
  674. else {
  675. var licontrols = $("li[aria-controls=" + id + ']');
  676. licontrols.attr({ 'id': 'li_' + programId });
  677. licontrols.find('a span').attr('data-i18n', 'common.' + programId);
  678. }
  679. }
  680. else {
  681. $("#tabsList").find('li').slice(1).remove(); //如果是單頁簽模式則移除前頁簽
  682. if ($("li[aria-controls=" + id + ']').length === 0) {
  683. $("#tabsList").append(li); //添加頁簽導航部分
  684. }
  685. }
  686. if (tabs.find('#' + id).length === 0) {
  687. 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" />'; //新頁簽的內容部分
  688. tabs.append("<div id='" + id + "' class='tab-pane fade'>" + sContentHtml + "</div>"); //添加頁簽內容部分
  689. }
  690. $('#iframe' + id).attr({ "src": sUrl + sPara, 'name': sOperation });
  691. tabs.tabs("refresh"); //強迫刷新頁面
  692. //取得目前的頁簽位置
  693. var iIndex = $("#tabsList").find('li').length === 0 ? 0 : $("#tabsList").find('li').length - 1;
  694. SetCuryLiShow(iIndex);
  695. $("#tabsList").find('#' + sGrouptag).click(); //最後再點選一次,確定在畫面裡面
  696. //Alt+Backspace鍵,刪除頁簽
  697. tabs.bind("keyup", function (event) {
  698. if (event.altKey && event.keyCode === $.ui.keyCode.BACKSPACE) {
  699. var PrevLi = tabs.find(".ui-tabs-active").prev().find('a'),
  700. LiId = tabs.find(".ui-tabs-active").remove().attr("aria-controls"),
  701. sPrgid = tabs.find(".ui-tabs-active")[0].id;
  702. $("#" + LiId).remove();
  703. PrevLi.click();
  704. if (sPrgid.indexOf('_Upd') > -1) {//移除當前操作的程式
  705. msgs.server.removeEditPrg(sPrgid);
  706. }
  707. if (sPrgid.indexOf('_View') > -1) {//移除當前操作的程式
  708. msgs.server.removeEditPrg(sPrgid);
  709. }
  710. }
  711. });
  712. //刪除頁簽
  713. tabs.find(".fa-times-circle").unbind('click').click(function () {
  714. var PrevLi = $(this).closest("li").prev().find('a'),
  715. LiId = $(this).closest("li").remove().attr("aria-controls"),
  716. sPrgid = $(this).closest("li")[0].id;
  717. $("#" + LiId).remove();
  718. PrevLi.click();
  719. if (sPrgid.indexOf('_Upd') > -1) {//移除當前操作的程式
  720. msgs.server.removeEditPrg(sPrgid.replace('li_', ''));
  721. }
  722. if (sPrgid.indexOf('_View') > -1) {//移除當前操作的程式
  723. msgs.server.removeEditPrg(sPrgid.replace('li_', ''));
  724. }
  725. });
  726. //重新整理頁簽
  727. tabs.find('.fa-refresh').unbind('click').click(function () {
  728. var LiId = $(this).closest('li').attr("aria-controls"); //找到頁面ID(請搜尋<li><a href='#{href}' id='#{id}'>)
  729. var getUrl = $('#iframe' + LiId).attr('src'); //取得目前的連結(src)
  730. $("#iframe" + LiId).attr('src', getUrl); //重新載入連結,不等於清除功能
  731. });
  732. setContentHeight();
  733. transLang($('#tabsList'));
  734. }
  735. function setCurryIndex(intAdd) {
  736. var intCurryIndex = iCuryIndex;
  737. intCurryIndex = intCurryIndex + intAdd;
  738. if (intCurryIndex < 0) {
  739. intCurryIndex = 0;
  740. }
  741. if (intCurryIndex >= $("#tabsList").find("li").length - 2) {
  742. intCurryIndex = $("#tabsList").find("li").length - 2;
  743. }
  744. iCuryIndex = intCurryIndex;
  745. GetLiWidth();
  746. }
  747. function GetLiWidth() {
  748. $("#tabsList").find("li").each(function (n) {
  749. if (n <= iCuryIndex && n !== 0 && n !== $("#tabsList").find("li").length - 1) {
  750. $(this).hide();
  751. $("#divPrevNext").show();
  752. } else {
  753. $(this).show();
  754. }
  755. });
  756. $('#tabsList').css('width', $('#tabpanel')[0].offsetWidth - 130 + 'px');
  757. }
  758. function reSetLi(index, width) {
  759. this.index = index;
  760. this.width = width;
  761. return this;
  762. }
  763. function SetCuryLiShow(intLeftCount) {
  764. var aryWidth = new Array();
  765. $("#tabsList").find("li").each(function (n) {
  766. var li = new reSetLi(n, this.offsetWidth);
  767. aryWidth.push(li);
  768. });
  769. var windowsize = $(window).width() - 100; //屏幕分辨率
  770. if (navigator.userAgent.match(/mobile/i)) {
  771. windowsize = screen.width - 40;
  772. }
  773. var _itemwidth = 0;
  774. var intStartIndex = 0;
  775. var intEndIndex = intLeftCount;
  776. for (var i = intLeftCount; i >= 0; i--) {
  777. _itemwidth += aryWidth[i].width * 1;
  778. if (_itemwidth > windowsize) {
  779. intStartIndex = i + 1;
  780. setCurryIndex(1);
  781. break;
  782. }
  783. }
  784. $("#tabsList").find("li").each(function (n) {
  785. if (n >= intStartIndex) {
  786. $(this).show();
  787. if (n > intEndIndex) {
  788. $("#divPrevNext").show();
  789. }
  790. } else {
  791. if (n !== 0 && n !== $("#tabsList").find("li").length - 1) {
  792. $(this).hide();
  793. $("#divPrevNext").show();
  794. }
  795. }
  796. });
  797. iCuryIndex = intStartIndex;
  798. }
  799. /**
  800. * 消息組件初始化
  801. */
  802. function MsgApp() {
  803. var init = function () {
  804. //$.connection.hub.url = gServerUrl + '/signalr';
  805. var connection = $.connection.hub;
  806. msgs = $.connection.msgHub;
  807. connection.logging = true;
  808. fnFeed();
  809. //hub连接开启
  810. connection.start().done(function () {
  811. fnRegister(true);
  812. if (window.Outklook) {
  813. //if (!window.OutklookSync) {
  814. // $('.outlook-waiting').slideDown();
  815. // outlookAPI(outlook.SynChronous, { flag: "auto" },
  816. // function (res) {
  817. // if (res === '1') {
  818. // window.OutklookSync += 1;
  819. // g_db.SetItem('outklooksync', window.OutklookSync);
  820. // }
  821. // });
  822. //}
  823. }
  824. else {
  825. //if (!window.OutlookTips) {
  826. // setTimeout(function () {
  827. // // ╠common.OutlookTips⇒當前未同步登入Outlook,操作行事曆可能不會同步或更新╣
  828. // // ╠common.ReLoad⇒重新登入╣
  829. // // ╠common.Close⇒關閉╣
  830. // // ╠common.Or⇒或╣
  831. // $('.outlook-waiting').html(
  832. // [
  833. // i18next.t('common.Tips'),
  834. // ':',
  835. // i18next.t('common.OutlookTips'),
  836. // ' ',
  837. // $('<a/>', {
  838. // text: i18next.t('common.ReLoad'),
  839. // class: 'link',
  840. // click: function () {
  841. // $('.log-out').trigger('click');
  842. // }
  843. // }),
  844. // i18next.t('common.Or'),
  845. // $('<a/>', {
  846. // text: i18next.t('common.Close'),
  847. // class: 'link',
  848. // click: function () {
  849. // $('.outlook-waiting').slideUp();
  850. // window.OutlookTips += 1;
  851. // g_db.SetItem('outlooktips', window.OutlookTips);
  852. // }
  853. // })
  854. // ]).css({ 'font-size': '15px', 'padding-top': '5px', 'color': '#ff0000' }).slideDown();
  855. // }, 3660);
  856. //}
  857. }
  858. })
  859. .fail(function () {
  860. console.log("Could not Connect!");
  861. });
  862. connection.connectionSlow(function () {
  863. //console.log("connectionSlow");
  864. });
  865. connection.disconnected(function () {
  866. setTimeout(function () {//掉線後10秒內自動重新連線
  867. connection.start().done(function () {
  868. fnRegister(false);
  869. });
  870. }, 1000);
  871. });
  872. connection.error(function (error) {
  873. //console.log(error);
  874. });
  875. connection.reconnected(function () {
  876. //console.log("reconnected");
  877. });
  878. connection.reconnecting(function () {
  879. //console.log("reconnecting");
  880. });
  881. connection.starting(function () {
  882. //console.log("starting");
  883. });
  884. connection.stateChanged(function (state) {
  885. //console.log(state);
  886. });
  887. };
  888. init();
  889. }
  890. function fnFeed() {
  891. var init = function () {
  892. //后端登陸註冊调用后,产生的loginUser回调
  893. msgs.client.onConnected = function (connnectId, userName, onlineUsers) {
  894. //console.log(JSON.stringify(onlineUsers));
  895. online_Users = onlineUsers;
  896. if ($('#iframetabs-Profile').length > 0) {
  897. $('#iframetabs-Profile')[0].contentWindow.fnSetUserOnline();
  898. }
  899. };
  900. //后端断线时调用调用后,产生的loginUser回调
  901. msgs.client.onUserDisconnected = function (connnectId, onlineUsers, orgId, userId, userName, isLogin, tips) {
  902. online_Users = onlineUsers;
  903. if ($('#iframetabs-Profile').length > 0) {
  904. $('#iframetabs-Profile')[0].contentWindow.fnSetUserOnline();
  905. }
  906. if (isLogin && userId === UserInfo.MemberID) {
  907. // ╠message.VerifyOutTips⇒您的帳號已在別處登入╣ ╠common.Tips⇒提示╣
  908. layer.alert(i18next.t("message.VerifyOutTips") + '<br>' + tips, { icon: 0, closeBtn: 0, title: i18next.t("common.Tips") }, function (index) {
  909. window.top.location.href = '/Page/Login.html';
  910. });
  911. }
  912. };
  913. //推送公告
  914. msgs.client.broadcast = function (msg) {
  915. fnGetAnnouncements();
  916. };
  917. //推送是否可編輯結果(true or false)
  918. msgs.client.checkedit = function (isedit, prgid, username) {
  919. if (!isedit) {
  920. var oCurrentFn = $('iframe[name=' + prgid + ']');
  921. //oCurrentFn.contents().ready
  922. // ╠message.NotToEdit⇒當前資料正在編輯,稍後請刷新頁面再繼續操作╣ ╠common.Operator⇒操作人╣
  923. oCurrentFn[0].contentWindow.showTips(i18next.t("message.NotToEdit") + ',' + i18next.t("common.Operator") + ':' + username);
  924. parent.bLockDataForm0430 = false;
  925. var CheckTablelistType = oCurrentFn.contents().find('[role=\'tablist\']').length > 0;
  926. //tab-content: 多個子頁籤(例如進口編輯)
  927. if (CheckTablelistType) {
  928. oCurrentFn.contents().find(".tab-content").css('pointer-events', 'none');
  929. }
  930. //panel-body: 只有一個頁面(例如部門資料編輯)
  931. else {
  932. oCurrentFn.contents().find(".panel-body").css('pointer-events', 'none');
  933. }
  934. //toolbar
  935. oCurrentFn.contents().find('#Toolbar button').not('#Toolbar_Leave').attr('disabled', true);
  936. }
  937. };
  938. //更新提示
  939. msgs.client.pushtips = function (msg) {
  940. fnGetTips();
  941. };
  942. //推送系統消息
  943. msgs.client.pushmsgs = function (msg) {
  944. };
  945. //檢核文字檔小助手是否安裝
  946. msgs.client.existtrasfer = function (msg, bInstall) {
  947. if (bInstall) {
  948. var sPrgId = '';
  949. switch (msg) {
  950. case 'IM':
  951. sPrgId = 'ExhibitionImport';
  952. break;
  953. case 'EX':
  954. sPrgId = 'ExhibitionExport';
  955. break;
  956. }
  957. $('#iframetabs-' + sPrgId)[0].contentWindow.fnToAccountAudit();
  958. }
  959. else {
  960. layer.msg(i18next.t("message.Financial_InstallTransfer")); // ╠message.Financial_InstallTransfer⇒請先安裝文字檔小助手╣
  961. }
  962. };
  963. //提示安裝並運行文字檔小助手
  964. msgs.client.transfertips = function (connectionid) {
  965. layer.msg(i18next.t("message.Financial_InstallTransfer")); // ╠message.Financial_InstallTransfer⇒請先安裝文字檔小助手╣
  966. };
  967. //test
  968. msgs.client.hello = function (msg) {
  969. //debugger;
  970. };
  971. // msgs.server.offline();
  972. //推送消息
  973. msgs.client.message = function (data) {
  974. switch (data.Type) {
  975. case 0:
  976. break;
  977. case 1:
  978. break;
  979. case 2:
  980. break;
  981. case 3:
  982. break;
  983. case 4:
  984. break;
  985. case 5:
  986. break;
  987. case 6:
  988. break;
  989. case 7:
  990. break;
  991. case 'OutlookSynChronous':
  992. {
  993. if (data.Flag === 'auto') {
  994. //if (data.Message === UserInfo.OutlookAccount) {
  995. // var elSuccess = $('.outlook-waiting');
  996. // elSuccess.find('span').text(i18next.t("message.SynchronousSuccess")).css({ 'color': 'green' });
  997. // elSuccess.find('img').attr('src', '../images/Success.png');
  998. // setTimeout(function () {
  999. // elSuccess.slideUp();
  1000. // }, 2500);
  1001. //}
  1002. }
  1003. else if (data.Flag === 'once') {
  1004. var iframe_Calendar = $('#iframetabs-Calendar');
  1005. if (iframe_Calendar.length > 0) {
  1006. iframe_Calendar[0].contentWindow.closeTips(data.Memo);
  1007. }
  1008. }
  1009. }
  1010. break;
  1011. }
  1012. };
  1013. //接收消息
  1014. msgs.client.receive = function (data) {
  1015. switch (data.Type) {
  1016. case 1://發送給自己
  1017. break;
  1018. case 2://發送給連線人員
  1019. break;
  1020. case 3://發送給制定人員ID
  1021. {
  1022. switch (data.Memo) {
  1023. case 'tips'://系統所有待辦定時提醒
  1024. fnShowTips(data.Content);
  1025. break;
  1026. case 'attendance'://EIP考勤提醒
  1027. fnAttendanceTips(data.Content);
  1028. break;
  1029. }
  1030. }
  1031. break;
  1032. case 4://發送給制定多個人員ID
  1033. break;
  1034. case 5://發送給制定群組
  1035. break;
  1036. }
  1037. };
  1038. };
  1039. init();
  1040. }
  1041. $(function () {
  1042. 'use strict';
  1043. var
  1044. /**
  1045. * 設定系統時間
  1046. */
  1047. Refresh = function () {
  1048. var Nowtime = new Date().formate("HH:mm:ss");
  1049. ltrdate.innerHTML = new Date().formate("yyyy.MM.dd (EEE)");
  1050. ltrtime.innerHTML = Nowtime;
  1051. setTimeout(Refresh, 1000);
  1052. },
  1053. /**
  1054. * 特殊處理由於階層的關係需要去判斷border-right的顯示下noborder代表不下樣式
  1055. */
  1056. setTreeViewCss = function () {
  1057. $("#sectionList li:not('.layer-one')").each(function () {
  1058. if ($(this).hasClass('folderType')) { //如果該li的class為folderType,在上上層的li加上 class noborder, 加在上上層的原因為folderType的li前面都會加上<br class="clear">的中斷點
  1059. $(this).prev().prev().addClass('noborder');
  1060. }
  1061. });
  1062. },
  1063. /**
  1064. * 設定頁簽顯示方式
  1065. */
  1066. setShowMode = function () {
  1067. if (window.ShowMode === "M") { //判斷當前是否開啟多頁簽
  1068. window.ShowMode = "S";
  1069. $("#divPrevNext,#tabpanel").hide();
  1070. } else {
  1071. window.ShowMode = "M";
  1072. $("#divPrevNext,#tabpanel").show();
  1073. }
  1074. CallAjax(ComFn.W_Com, ComFn.GetUpd, {
  1075. Params: {
  1076. members: {
  1077. values: { SysShowMode: window.ShowMode },
  1078. keys: {
  1079. MemberID: window.UserID,
  1080. OrgID: window.OrgID
  1081. }
  1082. }
  1083. }
  1084. }, function (res) {
  1085. if (res.d > 0) {
  1086. showMsg(i18next.t("message.SetTab_Successed"), 'success'); // ╠message.Delete_Success⇒設定頁簽模式成功╣
  1087. }
  1088. else {
  1089. showMsg(i18next.t("message.SetTab_Failed"), 'error'); // ╠message.SetTab_Failed⇒設定頁簽模式失敗╣
  1090. }
  1091. });
  1092. },
  1093. /**
  1094. * 更改語系國別
  1095. * @param {String} lang 當前語言
  1096. */
  1097. fnUpdCountry = function (lang) {
  1098. CallAjax(ComFn.W_Com, ComFn.GetUpd, {
  1099. Params: {
  1100. members: {
  1101. values: { Country: lang },
  1102. keys: {
  1103. MemberID: window.UserID,
  1104. OrgID: window.OrgID
  1105. }
  1106. }
  1107. }
  1108. }, function (res) { });
  1109. },
  1110. /**
  1111. * 獲取組織資料
  1112. * @return {Function} ajax物件
  1113. */
  1114. fnGetOrgData = function () {
  1115. return CallAjax(ComFn.W_Com, ComFn.GetOne, {
  1116. Type: '',
  1117. Params: {
  1118. organization: {
  1119. OrgID: window.OrgID
  1120. }
  1121. }
  1122. }).done(function (res) {
  1123. if (res.d) {
  1124. var oOrg = $.parseJSON(res.d);
  1125. window.OrgInfo = oOrg;
  1126. //$('title').text(OrgInfo.SystemCName);
  1127. //$('.logo-min').attr('src', '/Controller.ashx?action=getimg&folder=Organization&id=' + oOrg.LoGoId + '&orgid=' + oOrg.OrgID + '&times=' + $.now());
  1128. }
  1129. });
  1130. },
  1131. /**
  1132. * 獲取個人資料
  1133. * @return {Function} ajax物件
  1134. */
  1135. fnGetPersonalData = function () {
  1136. return $.whenArray([
  1137. g_api.ConnectLite('Authorize', 'GetUserInfo'),
  1138. g_api.ConnectLite(Service.com, ComFn.GetSysSet)])
  1139. .done(function (res1, res2) {
  1140. window.UserInfo = {};
  1141. window.SysSet = {};
  1142. if (res1[0].RESULT > 0) {
  1143. var oUser = res1[0].DATA.rel;
  1144. //$('#userName').text(oUser.MemberName);
  1145. $('<span>', { text: oUser.MemberName }).prependTo("#spUser");
  1146. window.UserInfo = oUser;
  1147. UserInfo.OrgID = window.OrgID;
  1148. UserInfo.roles = UserInfo.roles || '';
  1149. var sMemberPic = $.trim(UserInfo.MemberPic);
  1150. UserInfo.MemberPic = sMemberPic === '' ? guid() : sMemberPic;
  1151. fnSetArgDrop([
  1152. {
  1153. ArgClassID: 'LanCountry',
  1154. Select: $('#countrychange'),
  1155. ShowId: true,
  1156. DefultVal: UserInfo.Country,
  1157. CallBack: function () {
  1158. $('#countrychange')[0].remove(0);// 移除下拉選單第一個選項
  1159. }
  1160. }
  1161. ]);
  1162. fnGetAnnouncements();
  1163. var msgApp = new MsgApp();
  1164. }
  1165. if (res2[0].RESULT > 0) {
  1166. var saList = res2[0].DATA.rel;
  1167. $.each(saList, function (i, oSet) {
  1168. window.SysSet[oSet.SettingItem] = oSet.SettingValue;
  1169. });
  1170. window.SysSet.GridRecords = window.SysSet.GridRecords || 10;
  1171. window.SysSet.GridPages = window.SysSet.GridPages || 15;
  1172. window.SysSet.CustomersAuditUsers = window.SysSet.CustomersAuditUsers || '';
  1173. window.SysSet.BillAuditor = window.SysSet.BillAuditor || '';
  1174. window.SysSet.TaxRate = window.SysSet.TaxRate || '0';
  1175. window.SysSet.IsOpenMail = window.SysSet.IsOpenMail || 'N';
  1176. window.SysSet.CDDProUsers = window.SysSet.CDDProUsers || '';
  1177. UserInfo.IsManager = UserInfo.roles.indexOf(SysSet.Supervisor) > -1 || UserInfo.roles.indexOf('Manager') > -1;
  1178. }
  1179. fnGetHeadPic();
  1180. });
  1181. },
  1182. /**
  1183. * 獲取程式資料
  1184. * @return {Function} ajax物件
  1185. */
  1186. fnGetProgramList = function () {
  1187. return g_api.ConnectLite(Service.sys, 'GetSysFNList', {},
  1188. function (res) {
  1189. if (res.RESULT === 0) {
  1190. alert(res.MSG);
  1191. }
  1192. else {
  1193. var sPrgList = res.DATA.rel;
  1194. g_db.SetDic('programList', sPrgList);
  1195. if (sPrgList.length > 0) {
  1196. window.TopModID = sPrgList[0].ModuleID;
  1197. setTreeMenu(TopModID); //產生功能清單
  1198. setTreeViewCss();
  1199. }
  1200. }
  1201. });
  1202. },
  1203. /**
  1204. * 獲取頭像
  1205. * @return {Function} ajax物件
  1206. */
  1207. fnGetHeadPic = function () {
  1208. var callback = function (files) {
  1209. UserInfo.Filelist = files;
  1210. $('#imgUser').attr('src', '/Controller.ashx?action=getimg&folder=Members&id=' + UserInfo.MemberPic + '&orgid=' + UserInfo.OrgID + '&times=' + $.now());
  1211. };
  1212. return fnGetUploadFiles(UserInfo.MemberPic, callback);
  1213. },
  1214. /**
  1215. * 上傳頭像
  1216. * @param {Array} files 當前文件
  1217. * @param {HTMLElement} iframe 父層表單
  1218. */
  1219. fnUpload = function (files, iframe) {
  1220. var option = {};
  1221. option.input = iframe.find('#fileInput');
  1222. option.limit = 1;
  1223. option.extensions = ['jpg', 'jpeg', 'png', 'bmp', 'gif', 'png'];
  1224. option.theme = 'dragdropbox';
  1225. option.folder = 'Members';
  1226. option.type = 'one';
  1227. option.parentid = UserInfo.MemberPic;
  1228. option.uploadFile = {
  1229. url: '/Controller.ashx?action=upload&source=Members&userid=' + UserInfo.MemberID + '&orgid=' + UserInfo.OrgID + '&parentid=' + UserInfo.MemberPic,
  1230. data: null,
  1231. type: 'POST',
  1232. enctype: 'multipart/form-data',
  1233. beforeSend: function () { },
  1234. success: function (data, el) {
  1235. iframe.find('.jFiler-input-dragDrop').hide();
  1236. var parent = el.find(".jFiler-jProgressBar").parent();
  1237. fnGetHeadPic();
  1238. el.find(".jFiler-jProgressBar").fadeOut("slow", function () {
  1239. $("<div class=\"jFiler-item-others text-success\"><i class=\"icon-jfi-check-circle\"></i> Success</div>").hide().appendTo(parent).fadeIn("slow");
  1240. });
  1241. },
  1242. error: function (el) {
  1243. var parent = el.find(".jFiler-jProgressBar").parent();
  1244. el.find(".jFiler-jProgressBar").fadeOut("slow", function () {
  1245. $("<div class=\"jFiler-item-others text-error\"><i class=\"icon-jfi-minus-circle\"></i> Error</div>").hide().appendTo(parent).fadeIn("slow");
  1246. });
  1247. },
  1248. statusCode: null,
  1249. onProgress: null,
  1250. onComplete: null
  1251. };
  1252. option.uploadFile = {
  1253. url: '/Controller.ashx?action=upload&source=Members&userid=' + UserInfo.MemberID + '&orgid=' + UserInfo.OrgID + '&parentid=' + UserInfo.MemberPic,
  1254. data: null,
  1255. type: 'POST',
  1256. enctype: 'multipart/form-data',
  1257. beforeSend: function () { },
  1258. success: function (data, el) {
  1259. iframe.find('.jFiler-input-dragDrop').hide();
  1260. var parent = el.find(".jFiler-jProgressBar").parent();
  1261. fnGetHeadPic();
  1262. el.find(".jFiler-jProgressBar").fadeOut("slow", function () {
  1263. $("<div class=\"jFiler-item-others text-success\"><i class=\"icon-jfi-check-circle\"></i> Success</div>").hide().appendTo(parent).fadeIn("slow");
  1264. });
  1265. },
  1266. error: function (el) {
  1267. var parent = el.find(".jFiler-jProgressBar").parent();
  1268. el.find(".jFiler-jProgressBar").fadeOut("slow", function () {
  1269. $("<div class=\"jFiler-item-others text-error\"><i class=\"icon-jfi-minus-circle\"></i> Error</div>").hide().appendTo(parent).fadeIn("slow");
  1270. });
  1271. },
  1272. statusCode: null,
  1273. onProgress: null,
  1274. onComplete: null
  1275. };
  1276. option.onRemove = function (itemEl, file) {
  1277. DelFile(UserInfo.MemberPic, 'parent').done(function () {
  1278. iframe.find('.jFiler-input-dragDrop').show();
  1279. fnGetHeadPic();
  1280. });
  1281. };
  1282. if (files) {
  1283. option.files = files;
  1284. }
  1285. fnUploadRegister(option);
  1286. },
  1287. /**
  1288. * 初始化
  1289. */
  1290. init = function () {
  1291. if (!g_db.SupportLocalStorage()) {
  1292. if (sLang === 'en') {
  1293. alert('The current browser does not support local storage. Please turn off private browsing settings');
  1294. }
  1295. else if (sLang === 'zh') {
  1296. alert('当前浏览器不支持本地储存,请关闭无痕浏览模式');
  1297. }
  1298. else {
  1299. alert('當前瀏覽器不支持本地儲存,請關閉私密瀏覽設定');
  1300. }
  1301. $('body').html('');
  1302. return;
  1303. }
  1304. window.OrgID = g_db.GetItem('orgid');
  1305. window.UserID = g_db.GetItem('userid');
  1306. window.ShowMode = g_db.GetItem('mode');
  1307. window.Outklook = g_db.GetItem('outklook') === 'true';
  1308. window.OutklookSync = parseInt(g_db.GetItem('outklooksync') || 0);
  1309. window.OutlookTips = parseInt(g_db.GetItem('outlooktips') || 0);
  1310. if (!window.OrgID || !window.UserID) {
  1311. window.location.href = '/Page/Login.html';
  1312. return;
  1313. }
  1314. fnGetOrgData();
  1315. $.whenArray([
  1316. fnGetPersonalData(),
  1317. fnGetProgramList()
  1318. ]).done(function () {
  1319. var saProgramList = g_db.GetDic('programList') || [];
  1320. if (saProgramList.length) {
  1321. setLang(UserInfo.Country, undefined, function () {
  1322. openPageTab('Index', 'Index');
  1323. });
  1324. }
  1325. else {
  1326. openPageTab('NotView', 'NotView');
  1327. return false;
  1328. }
  1329. fnGetAbsenceFromLastWeek();
  1330. });
  1331. fnGetTips();
  1332. // Slimscroll
  1333. slimScroll();
  1334. Waves.displayEffect();//波浪
  1335. //$('#divPenlSetting').click(function () {
  1336. // setShowMode();
  1337. //});
  1338. if (window.ShowMode === "S") { //判斷當前是否開啟多頁簽
  1339. $("#divPrevNext,#tabpanel").hide();
  1340. }
  1341. $('.stop-prevent').on('click', function (e) {
  1342. return false;
  1343. });
  1344. ///登陸outlook
  1345. //$('.mail-box').on('click', function (e) {
  1346. // if (!UserInfo.OutLookId) {
  1347. // window.location.href = "/Home/Index";
  1348. // return false;
  1349. // }
  1350. //});
  1351. $('.log-out').on('click', function (e) {
  1352. var fnClear = function () {
  1353. g_db.RemoveItem('orgid');
  1354. g_db.RemoveItem('userid');
  1355. g_db.RemoveItem('loginname');
  1356. g_db.RemoveItem('usertype');
  1357. g_db.RemoveItem('mode');
  1358. g_db.RemoveItem('token');
  1359. g_db.RemoveItem('outklook');
  1360. };
  1361. fnClear();
  1362. if (window.Outklook) {
  1363. window.location.href = "/Login/Index?orgid=&userid=";
  1364. }
  1365. else {
  1366. window.location.href = '/Page/Login.html';
  1367. }
  1368. // ╠message.ToLogOut⇒是否同時退出Outlook?╣ ╠common.Tips⇒提示╣
  1369. /*layer.confirm(i18next.t("message.ToLogOut"),
  1370. {
  1371. icon: 3,
  1372. title: i18next.t("common.Tips"),
  1373. btn: [i18next.t('common.Yes'), i18next.t('common.No')] // ╠message.Yes⇒是╣ ╠common.No⇒否╣
  1374. },
  1375. function (index) {
  1376. fnClear();
  1377. window.location.href = "/Login/Index?orgid=&userid=";
  1378. layer.close(index);
  1379. },
  1380. function () {
  1381. fnClear();
  1382. window.location.href = '/Page/Login.html';
  1383. }
  1384. );*/
  1385. });
  1386. ///左移
  1387. $("#lbtnPrev").on('click', function () {
  1388. setCurryIndex(-1);
  1389. });
  1390. ///右移
  1391. $("#lbtnNext").on('click', function () {
  1392. setCurryIndex(1);
  1393. });
  1394. /**
  1395. * 行事曆
  1396. */
  1397. $(".person-list>li>a").on('click', function () {
  1398. var that = this;
  1399. switch (that.id) {
  1400. case 'profile':
  1401. openPageTab('Profile');
  1402. break;
  1403. case 'userinfo':
  1404. var oValidator = null;
  1405. layer.open({
  1406. id: 'memberinfo',
  1407. type: 2,
  1408. title: i18next.t('common.PersonalDataUpdate'),//╠common.PersonalDataUpdate⇒個人資料修改╣
  1409. offset: '100px',//右下角弹出
  1410. shade: 0.75,
  1411. area: ['660px', '600px'],
  1412. content: '/Page/Pop/UpdUserInfo.html', //iframe的url,
  1413. btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  1414. success: function (layero, index) {
  1415. var iframe = $('iframe').contents();
  1416. iframe.find('#MemberID').val(UserInfo.MemberID);
  1417. iframe.find('#MemberName').val(UserInfo.MemberName);
  1418. //自定義驗證屬性
  1419. $.validator.addMethod("notEqualTo", function (value, element, param) {
  1420. if (value === '' && iframe.find(param).val() === '') {
  1421. return true;
  1422. }
  1423. return value !== iframe.find(param).val();
  1424. });
  1425. $.validator.addMethod("EqualToNew", function (value, element, param) {
  1426. if (value === '' && iframe.find(param).val() === '') {
  1427. return true;
  1428. }
  1429. return value === iframe.find(param).val();
  1430. });
  1431. $.validator.addMethod("New_required", function (value, element, param) {
  1432. if (value === '' && iframe.find(param).val() !== '') {
  1433. return false;
  1434. }
  1435. return true;
  1436. });
  1437. oValidator = iframe.find("#form_UpdUserInfo").validate({ //表單欄位驗證
  1438. rules: {
  1439. OldPsw: { New_required: "#NewPsw" },
  1440. NewPsw: { notEqualTo: "#OldPsw" },
  1441. CheckNewPsw: {
  1442. EqualToNew: "#NewPsw"
  1443. }
  1444. },
  1445. messages: {
  1446. MemberName: i18next.t('UpdUserInfo.MemberName_required'),// ╠UpdUserInfo.MemberName_required⇒請輸入名稱╣
  1447. OldPsw: {
  1448. New_required: i18next.t('UpdUserInfo.OldPsw_required')// ╠UpdUserInfo.OldPsw_required⇒請輸入舊密碼╣
  1449. },
  1450. CalColor: i18next.t('UpdUserInfo.CalColor_required'),// ╠UpdUserInfo.CalColor_required⇒請輸入行事曆顏色╣
  1451. NewPsw: {
  1452. required: i18next.t('UpdUserInfo.NewPsw_required'),// ╠UpdUserInfo.NewPsw_required⇒請輸入新密碼╣
  1453. notEqualTo: i18next.t('UpdUserInfo.NotEqualTo')// ╠UpdUserInfo.NotEqualTo⇒舊密碼與新密碼不可相同╣
  1454. },//舊密碼與新密碼不可相同
  1455. CheckNewPsw: {
  1456. required: i18next.t('UpdUserInfo.CheckNewPsw_required'),// ╠UpdUserInfo.CheckNewPsw_required⇒再次輸入新密碼╣
  1457. EqualToNew: i18next.t('UpdUserInfo.EqualTo') // ╠UpdUserInfo.EqualTo⇒兩次密碼輸入不相符╣
  1458. }
  1459. }
  1460. });
  1461. fnUpload(UserInfo.Filelist, iframe);
  1462. if (UserInfo.Filelist.length > 0) {
  1463. iframe.find('.jFiler-input-dragDrop').hide();
  1464. }
  1465. transLang(iframe.find('#form_UpdUserInfo'));
  1466. },
  1467. yes: function (index, layero) {
  1468. var iframe = $('iframe').contents();
  1469. if (!iframe.find("#form_UpdUserInfo").valid()) {
  1470. oValidator.focusInvalid();
  1471. return false;
  1472. }
  1473. var data = {
  1474. UserName: iframe.find('#MemberName').val(),
  1475. OldPsw: iframe.find('#OldPsw').val(),
  1476. NewPsw: iframe.find('#NewPsw').val(),
  1477. CalColor: iframe.find('#CalColor').val(),
  1478. MemberPic: UserInfo.MemberPic
  1479. };
  1480. g_api.ConnectLite(Service.auth, 'UpdataPsw', data, function (res) {
  1481. if (res.RESULT) {
  1482. UserInfo.CalColor = data.CalColor;
  1483. showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Modify_Success⇒修改成功╣
  1484. layer.close(index);
  1485. }
  1486. else {
  1487. if (res.MSG === "1") {
  1488. showMsg(i18next.t("message.CheckOldPassword"), 'error');// ╠message.CheckOldPassword⇒舊密碼驗證失敗╣
  1489. }
  1490. else if (res.MSG === "2") {
  1491. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  1492. }
  1493. else {
  1494. showMsg(i18next.t("message.Modify_Failed") + '<br>' + res.MSG, 'error'); //╠message.Modify_Failed⇒修改失敗╣
  1495. }
  1496. }
  1497. }, function () {
  1498. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  1499. });
  1500. }
  1501. });
  1502. break;
  1503. case 'calendar':
  1504. openPageTab('Calendar');
  1505. break;
  1506. }
  1507. });
  1508. /**
  1509. * 語系國別設定
  1510. */
  1511. $('#countrychange').on('change', function () {
  1512. $('#setlistset').click();
  1513. var sLang = $(this).val();
  1514. fnUpdCountry(sLang);
  1515. setLang(sLang);
  1516. $('#tabsList>li').each(function () {
  1517. var sId = $(this).attr('aria-controls'),
  1518. iframe = $('#' + sId).find('iframe').contents();
  1519. setLang(sLang, iframe);
  1520. });
  1521. });
  1522. setTimeout(Refresh, 1000);
  1523. //closeWaiting(3000); //最長3秒鐘停止等待
  1524. //var sFileName = "John_Test",
  1525. // sInputPath = "C:\Users\Alina\Desktop\Temple\OfficeToPDF\Demo\土地建物分離估價適用版.xlsx";
  1526. //g_api.ConnectLite('Pdf', 'ExcelToPdf', {
  1527. // InputPath: sInputPath,
  1528. // FileName: sFileName
  1529. //}, function (res) {
  1530. // if (res.RESULT) {
  1531. // DownLoadFile(res.DATA.rel, sFileName);
  1532. // }
  1533. // else {
  1534. // showMsg(res.MSG, 'error');
  1535. // }
  1536. //});
  1537. //debugger;
  1538. };
  1539. init();
  1540. });