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.

79 lines
3.6 KiB

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