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.

75 lines
3.3 KiB

2 years ago
  1. 'use strict';
  2. var fnPageInit = function () {
  3. var canDo = new CanDo({
  4. sortField: 'ModOrderBy,OrderByValue',
  5. sortOrder: 'asc',
  6. /**
  7. * 當前程式所有ID名稱集合
  8. */
  9. idKeys: ['OrgID', 'ProgramID'],
  10. /**
  11. * Grid欄位設置可以是 function
  12. */
  13. gridFields: [
  14. { name: "RowIndex", title: 'common.RowNumber', align: 'center', width: 50, sorting: false },
  15. { name: "ModuleName", title: 'common.ModuleName', width: 200 },
  16. { name: "ProgramID", title: 'common.ProgramCode', width: 200 },
  17. { name: "ProgramName", title: 'common.ProgramName', width: 200 },
  18. { name: "ProgramTypeName", title: 'ProgramMaintain_Upd.ProgramType', width: 200 },
  19. { name: "EffectiveName", title: 'common.Status', align: 'center', width: 100 },
  20. { name: "ShowInListName", title: 'ProgramMaintain_Upd.ShowInList', align: 'center', width: 100 },
  21. {
  22. name: "OrderByValue", title: 'common.OrderByValue', type: "select", width: 100,
  23. itemTemplate: function (val, item) {
  24. return this._createSelect = $("<select>", {
  25. class: 'w70',
  26. html: createOptions(item.OrderCount),
  27. change: function () {
  28. var sOldValue = val,
  29. sNewValue = this.value;
  30. g_api.ConnectLite(canDo.ProgramId, canDo._api.order, {
  31. ParentId: item.ModuleID,
  32. Id: item.ProgramID,
  33. OldOrderByValue: sOldValue,
  34. NewOrderByValue: sNewValue
  35. }, function (res) {
  36. if (res.RESULT) {
  37. showMsg(i18next.t('message.Update_Success'), 'success');// ╠message.Update_Success⇒更新成功╣
  38. canDo.Grid.openPage(canDo.options.toFirstPage ? 1 : canDo.options.queryPageidx);
  39. }
  40. else {
  41. showMsg(i18next.t('message.Update_Failed') + '<br>' + res.MSG, 'error'); // ╠message.Update_Failed⇒更新失敗╣
  42. }
  43. });
  44. }
  45. }).val(val);
  46. }
  47. }
  48. ],
  49. /**
  50. * 頁面初始化
  51. * @param {Object} pargs CanDo 對象
  52. */
  53. pageInit: function (pargs) {
  54. fnModuleNameDrop().done(function () {
  55. pargs._reSetQueryPm();
  56. pargs._initGrid();
  57. });
  58. }
  59. }),
  60. /**
  61. * 設置模組名稱下拉單
  62. * @return {Object} Ajax 物件
  63. */
  64. fnModuleNameDrop = function () {
  65. return g_api.ConnectLite('AuthantedPrograms', 'GetModulelist', { IncludeParent: true },
  66. function (res) {
  67. if (res.RESULT) {
  68. var saList = res.DATA.rel;
  69. $('#ModuleID').html(createOptions(saList, 'ModuleID', 'ModuleName', true));
  70. }
  71. });
  72. };
  73. };
  74. require(['base', 'jsgrid', 'cando'], fnPageInit);