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.

115 lines
4.8 KiB

2 years ago
  1. 'use strict';
  2. var fnPageInit = function () {
  3. var sAction = getUrlParam('Action') || 'Add',
  4. canDo = new CanDo({
  5. /**
  6. * 當前程式所有ID名稱集合
  7. */
  8. idKeys: ['OrgID', 'Guid'],
  9. /**
  10. * 當前程式所有參數名稱集合
  11. */
  12. //paramKeys: ['ArgumentClassID', 'ArgumentID'],
  13. /**
  14. * 新增資料
  15. * @param {Object} pargs CanDo 對象
  16. * @param {Object} data 當前新增的資料
  17. * @param {String} flag 新增 or 儲存后新增
  18. */
  19. getInsertBack: function (pargs, data, flag) {
  20. if (flag == 'add') {
  21. showMsgAndGo(i18next.t("message.Save_Success"), pargs.ProgramId, '?Action=Upd&Guid=' + data.guid); // ╠message.Save_Success⇒新增成功╣
  22. }
  23. else {
  24. showMsgAndGo(i18next.t("message.Save_Success"), pargs.ProgramId, '?Action=Add'); // ╠message.Save_Success⇒新增成功╣
  25. }
  26. },
  27. /**
  28. * 修改資料
  29. * @param {Object} pargs CanDo 對象
  30. * @param {Object} data 當前修改的資料
  31. */
  32. getUpdateBack: function (pargs, data) {
  33. if (typeof pargs.data.Contactors === 'string') {
  34. pargs.data.Contactors = $.parseJSON(pargs.data.Contactors || '[]');
  35. }
  36. showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Modify_Success⇒修改成功╣
  37. if (window.bLeavePage) {
  38. setTimeout(function () {
  39. pargs._pageLeave();
  40. }, 1000);
  41. }
  42. else {
  43. pargs._setFormVal(data);
  44. //location.reload();
  45. }
  46. },
  47. /**
  48. * 驗證規則
  49. */
  50. validRules: {
  51. onfocusout: false,
  52. rules: {
  53. ArgumentID: { argumentidrule: true },
  54. },
  55. messages: {
  56. ArgumentID: { argumentidrule: i18next.t("message.Data_Repeat") }// ╠message.Data_Repeat⇒此筆資料已建檔╣
  57. }
  58. },
  59. /**
  60. * 頁面初始化
  61. * @param {Object} pargs CanDo 對象
  62. */
  63. pageInit: function (pargs) {
  64. var postArray = [];
  65. if (pargs.action === 'upd') {
  66. //$('#ArgumentClassID,#ArgumentID').prop('disabled', true);
  67. postArray.push(pargs._getOne());
  68. }
  69. postArray.push(
  70. fnSetUserDrop([{
  71. Select: $('#MemberID'),
  72. ShowId: true,
  73. Action: sAction,
  74. //Select2: true,
  75. }]),
  76. fnSetArgDrop([{
  77. ArgClassID: 'LeaveType',
  78. Select: $('#Leave'),
  79. ShowId: true,
  80. CallBack: function (data) {
  81. data = Enumerable.From(data).Where(function (val) { return val.Correlation.trim() !== ''; }).ToArray();
  82. $('#Leave').html(createOptions(data, 'id', 'text', true))
  83. .on('change', function () {
  84. if ($('#Leave').OnChange && typeof $('#Leave').OnChange === 'function') {
  85. $('#Leave').OnChange(this.value);
  86. }
  87. });
  88. }
  89. }])
  90. );
  91. //加載報關類別,加載報價頁簽,加載運輸方式, 加載機場, 加載貨棧場, 加載倉庫
  92. $.whenArray(postArray).done(function (res) {
  93. $('#Leave').find("[value='09']").remove();
  94. if (pargs.action === 'upd' && res[0].RESULT) {
  95. var oRes = res[0].DATA.rel;
  96. oRes.CreateUserName = oRes.CreateUser;
  97. oRes.ModifyUserName = oRes.ModifyUser;
  98. pargs._setFormVal(oRes);
  99. $('#UsedHours').val(oRes.UsedHours)
  100. $('#RemainHours').val(oRes.RemainHours)
  101. $('#PaymentHours').attr('readonly',true);
  102. $('.UpdLeaveHoursArea').show();
  103. }
  104. else {
  105. $('.UpdLeaveHoursArea').hide();
  106. }
  107. });
  108. },
  109. });
  110. };
  111. require(['base', 'select2', 'jsgrid', 'filer', 'timepicker', 'common_eip', 'cando'], fnPageInit, 'timepicker');