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.

78 lines
2.4 KiB

2 years ago
  1. 'use strict';
  2. let sProgramID = 'CurrencySetup_Upd';
  3. var fnPageInit = function () {
  4. var canDo = new CanDo({
  5. /**
  6. * 當前程式所有ID名稱集合
  7. */
  8. idKeys: ['year', 'month', 'currency'],
  9. /**
  10. * 當前程式所有參數名稱集合
  11. */
  12. paramKeys: ['year', 'month', 'currency'],
  13. /**
  14. * 頁面初始化
  15. * @param {Object} pargs CanDo 對象
  16. */
  17. pageInit: function (pargs) {
  18. fpLoadYears();
  19. fpLoadMonth();
  20. fpLoadCurrency().done(() => {
  21. if (pargs.action === 'upd') {
  22. $('#year,#month,#currency').prop('disabled', true);
  23. pargs._getOne();
  24. }
  25. })
  26. }
  27. }),
  28. /**
  29. * 載入年份
  30. */
  31. fpLoadYears = function () {
  32. let dtCurrentDate = new Date();
  33. let ibaseYear = dtCurrentDate.getFullYear();
  34. let saYearList = [];
  35. //抓取當年度加減20年
  36. for (let y = ibaseYear - 20; y <= ibaseYear + 20; y++) {
  37. saYearList.push({
  38. year: y,
  39. value: y
  40. });
  41. }
  42. var sOptionHtml = createOptions(saYearList, 'year', 'value', false);
  43. $('#year').html(sOptionHtml).val(dtCurrentDate.getFullYear());
  44. },
  45. /**
  46. * 載入月份
  47. */
  48. fpLoadMonth = function () {
  49. let dtCurrentDate = new Date();
  50. let saMonthList = [];
  51. //抓取當年度加減20年
  52. for (let m = 1; m <= 12; m++) {
  53. saMonthList.push({
  54. month: m,
  55. value: m
  56. });
  57. }
  58. var sOptionHtml = createOptions(saMonthList, 'month', 'value', false);
  59. $('#month').html(sOptionHtml).val(dtCurrentDate.getMonth() + 1);
  60. },
  61. /**
  62. * 載入幣別
  63. */
  64. fpLoadCurrency = function () {
  65. return g_api.ConnectLite('CurrencySetup_Qry', 'CurrencyList', {},
  66. function (res) {
  67. if (res.RESULT) {
  68. var saList = res.DATA.rel;
  69. var sOptionHtml = createOptions(saList, 'ArgumentID', 'ArgumentValue', true);
  70. $('#currency').html(sOptionHtml);
  71. }
  72. });
  73. };
  74. };
  75. require(['base', 'cando'], fnPageInit);