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.

74 lines
3.2 KiB

2 years ago
  1. 'use strict';
  2. var fnPageInit = function () {
  3. var canDo = new CanDo({
  4. sortField: 'StartDateTime',
  5. sortOrder: 'desc',
  6. /**
  7. * 當前程式所有ID名稱集合
  8. */
  9. idKeys: ['OrgID', 'AnnouncementID'],
  10. /**
  11. * Grid欄位設置可以是 function
  12. */
  13. gridFields: [
  14. { name: "RowIndex", title: 'common.RowNumber', align: 'center', width: 50, sorting: false },
  15. {
  16. name: "Ann_Type", title: 'Announcement_Upd.Ann_Type', width: 120, align: 'center', itemTemplate: function (val, item) {
  17. return $('#Ann_Type option[value=' + val + ']').text().split('-')[1];
  18. }
  19. },
  20. { name: "Title", title: 'Announcement_Upd.Title', width: 300 },
  21. {
  22. name: "Description", title: 'common.Toolbar_Download', width: 200, align: 'center', itemTemplate: function (val, item) {
  23. var oVal = $('<div />').css('text-align', 'left'),
  24. oDiv = $('<div />', { html: val });
  25. oDiv.find('img').each(function () {
  26. var sSrc = $(this).attr('src') || '';
  27. if (sSrc.indexOf('attachment/fileTypeImages/icon_') > -1) {
  28. var sHref = $(this).parent('p').find('a').attr('href') || '';
  29. $(this).attr('src', sSrc.replace('http:', 'https:'));
  30. if (sSrc.indexOf('icon_jpg') > -1 || sSrc.indexOf('icon_pdf') > -1) {
  31. $(this).parent('p').find('a').attr('target', '_new');
  32. }
  33. $(this).parent('p').find('a').attr('href', sHref.replace('http:', 'https:'));
  34. oVal.append($(this).parent('p'));
  35. }
  36. });
  37. return oVal[0].outerHTML;
  38. }
  39. },
  40. {
  41. name: "StartDateTime", title: 'Announcement_Upd.StartDateTime', width: 120, align: 'center', itemTemplate: function (val, item) {
  42. return newDate(val, 'date');
  43. }
  44. },
  45. {
  46. name: "EndDateTime", title: 'Announcement_Upd.EndDateTime', width: 120, align: 'center', itemTemplate: function (val, item) {
  47. return newDate(val, 'date');
  48. }
  49. },
  50. //{
  51. // name: "Description", title: 'Announcement_Upd.Description', width: 300, itemTemplate: function (val, item) {
  52. // return val.length > 30 ? val.substring(0, 30) + '...' : val;
  53. // }
  54. //}
  55. ],
  56. /**
  57. * 頁面初始化
  58. * @param {Object} pargs CanDo 對象
  59. */
  60. pageInit: function (pargs) {
  61. $.when(fnSetArgDrop([
  62. {
  63. ArgClassID: 'Ann_Type',
  64. Select: $('#Ann_Type'),
  65. ShowId: true
  66. }
  67. ])).done(function () {
  68. pargs._reSetQueryPm();
  69. pargs._initGrid();
  70. });
  71. }
  72. });
  73. };
  74. require(['base', 'jsgrid', 'cando'], fnPageInit);