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.

102 lines
3.5 KiB

2 years ago
  1. 'use strict';
  2. var fnPageInit = function () {
  3. var canDo = new CanDo({
  4. /**
  5. * 當前程式所有ID名稱集合
  6. */
  7. idKeys: ['OrgID', 'ModuleID'],
  8. /**
  9. * 當前程式所有參數名稱集合
  10. */
  11. paramKeys: ['ModuleID'],
  12. /**
  13. * 客製化驗證規則
  14. * @param {Object} pargs CanDo 對象
  15. */
  16. validRulesCus: function (pargs) {
  17. $.validator.addMethod("moduleidrule", function (value) {
  18. var bRetn = true;
  19. if (value) {
  20. g_api.ConnectLite(pargs.ProgramId, pargs._api.getcout,
  21. {
  22. ModuleID: value
  23. },
  24. function (res) {
  25. if (res.RESULT && res.DATA.rel > 0) {
  26. bRetn = false;
  27. }
  28. }, null, false);
  29. }
  30. return bRetn;
  31. });
  32. },
  33. /**
  34. * 驗證規則
  35. */
  36. validRules: function (pargs) {
  37. return {
  38. onfocusout: false,
  39. rules: {
  40. ModuleID: { moduleidrule: pargs.action === 'add' ? true : false },
  41. },
  42. messages: {
  43. ModuleID: { moduleidrule: i18next.t("message.Data_Repeat") }// ╠message.Data_Repeat⇒此筆資料已建檔╣
  44. }
  45. };
  46. },
  47. /**
  48. * 頁面初始化
  49. * @param {Object} pargs CanDo 對象
  50. */
  51. pageInit: function (pargs) {
  52. var postArray = [];
  53. if (pargs.action === 'upd') {
  54. $('#ModuleID').prop('disabled', true);
  55. postArray.push(pargs._getOne());
  56. }
  57. postArray.push(fnSetOrderByValueDrop(), fnSetParentIDDrop());
  58. $.whenArray(postArray).done(function (res) {
  59. if (pargs.action === 'upd' && res[0].RESULT) {
  60. var oRes = res[0].DATA.rel;
  61. $('#BackgroundCSS').spectrum("set", oRes.BackgroundCSS);
  62. pargs._setFormVal(oRes);
  63. pargs._getPageVal();//緩存頁面值,用於清除
  64. }
  65. });
  66. }
  67. }),
  68. /**
  69. * 設定報關類別下拉選單
  70. */
  71. fnSetOrderByValueDrop = function () {
  72. return g_api.ConnectLite(canDo.ProgramId, canDo._api.getcout, {},
  73. function (res) {
  74. if (res.RESULT) {
  75. var iCount = res.DATA.rel;
  76. if (canDo.action === 'add') {
  77. iCount++;
  78. }
  79. $('#OrderByValue').html(createOptions(iCount));
  80. if (canDo.action === 'add') {
  81. $('#OrderByValue').val(iCount);
  82. }
  83. }
  84. });
  85. },
  86. /**
  87. * 設定上層模組下拉選單
  88. * @return {Object} Ajax 物件
  89. */
  90. fnSetParentIDDrop = function () {
  91. return g_api.ConnectLite(canDo._service.sys, 'GetModuleList', {},
  92. function (res) {
  93. if (res.RESULT) {
  94. var saData = res.DATA.rel;
  95. $('#ParentID').html(createOptions(saData, 'ModuleID', 'AccountNameSort', true));
  96. }
  97. });
  98. };
  99. };
  100. require(['base', 'jsgrid', 'spectrum', 'cando'], fnPageInit);