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.

86 lines
3.0 KiB

3 years ago
  1. 'use strict';
  2. var fnPageInit = function () {
  3. var canDo = new CanDo({
  4. /**
  5. * 當前程式所有ID名稱集合
  6. */
  7. idKeys: ['OrgID', 'RuleID'],
  8. /**
  9. * 當前程式所有參數名稱集合
  10. */
  11. paramKeys: ['RuleID'],
  12. /**
  13. * 處理新增資料參數
  14. * @param {Object} pargs CanDo 對象
  15. * @param {Object} data 當前表單資料
  16. */
  17. getInsertParams: function (pargs, data) {
  18. data.users = [];
  19. $('#lstRight option').each(function () {
  20. data.users.push(this.value);
  21. });
  22. return data;
  23. },
  24. /**
  25. * 處理修改資料參數
  26. * @param {Object} pargs CanDo 對象
  27. * @param {Object} data 當前表單資料
  28. */
  29. getUpdateParams: function (pargs, data) {
  30. data = pargs.options.getInsertParams(pargs, data);
  31. return data;
  32. },
  33. /**
  34. * 頁面初始化
  35. * @param {Object} pargs CanDo 對象
  36. */
  37. pageInit: function (pargs) {
  38. var pGet = null;
  39. if (pargs.action === 'upd') {
  40. $('#RuleID').prop('disabled', true);
  41. pGet = pargs._getOne();
  42. }
  43. else {
  44. }
  45. fnSetUserDrop([
  46. {
  47. Action: canDo.action,
  48. CallBack: function (data) {
  49. var saLeft = data,
  50. saRight = [],
  51. getOptions = function () {
  52. $('#lstLeft').html(createOptions(saLeft, 'MemberID', 'MemberName')).find('option:first').remove();
  53. $('#lstRight').html(createOptions(saRight, 'MemberID', 'MemberName')).find('option:first').remove();
  54. optionListSearch($('#lstLeft'), $('#lstRight'), $('#WorkSearch'));
  55. };
  56. if (pargs.action === 'upd') {
  57. pGet.done(function () {
  58. $.each(data, function (idx, item) {
  59. if ((canDo.data.ExFeild1 || '').indexOf(item.MemberID) > -1) {
  60. saRight.push(item);
  61. }
  62. else {
  63. saLeft.push(item);
  64. }
  65. });
  66. getOptions();
  67. });
  68. }
  69. else {
  70. getOptions();
  71. }
  72. }
  73. }
  74. ]);
  75. $('#btnToRight').click(function () {
  76. optionListMove($('#lstLeft'), $('#lstRight'));
  77. });
  78. $('#btnToLeft').click(function () {
  79. optionListMove($('#lstRight'), $('#lstLeft'));
  80. });
  81. }
  82. });
  83. };
  84. require(['base', 'cando'], fnPageInit);