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.

88 lines
3.0 KiB

2 years ago
  1. 'use strict';
  2. var fnPageInit = function () {
  3. var canDo = new CanDo({
  4. /**
  5. * 當前程式所有ID名稱集合
  6. */
  7. idKeys: ['OrgID', 'ArgumentClassID'],
  8. /**
  9. * 當前程式所有參數名稱集合
  10. */
  11. paramKeys: ['ArgumentClassID'],
  12. /**
  13. * 客製化驗證規則
  14. * @param {Object} pargs CanDo 對象
  15. */
  16. validRulesCus: function (pargs) {
  17. $.validator.addMethod("argumentclassidrule", function (value) {
  18. var bRetn = true;
  19. if (value) {
  20. g_api.ConnectLite(pargs.ProgramId, pargs._api.getcout,
  21. {
  22. ArgumentClassID: 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. ArgumentClassID: { argumentclassidrule: pargs.action === 'add' ? true : false },
  41. },
  42. messages: {
  43. ArgumentClassID: { argumentclassidrule: 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. $('#ArgumentClassID').prop('disabled', true);
  55. postArray.push(pargs._getOne());
  56. }
  57. postArray.push(fnSetOrderByValueDrop());
  58. $.whenArray(postArray).done(function (res) {
  59. if (pargs.action === 'upd' && res[0].RESULT) {
  60. var oRes = res[0].DATA.rel;
  61. pargs._setFormVal(oRes);
  62. pargs._getPageVal();//緩存頁面值,用於清除
  63. }
  64. });
  65. }
  66. }),
  67. /**
  68. * 設定報關類別下拉選單
  69. */
  70. fnSetOrderByValueDrop = function () {
  71. return g_api.ConnectLite(canDo.ProgramId, canDo._api.getcout, {},
  72. function (res) {
  73. if (res.RESULT) {
  74. var iCount = res.DATA.rel;
  75. if (canDo.action === 'add') {
  76. iCount++;
  77. }
  78. $('#OrderByValue').html(createOptions(iCount));
  79. if (canDo.action === 'add') {
  80. $('#OrderByValue').val(iCount);
  81. }
  82. }
  83. });
  84. };
  85. };
  86. require(['base', 'cando'], fnPageInit);