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.

65 lines
3.2 KiB

2 years ago
  1. 'use strict';
  2. var sProgramId = getProgramId(),
  3. sEditPrgId = getEditPrgId(),
  4. oGrid = null,
  5. fnPageInit = function () {
  6. var canDo = new CanDo({
  7. sortField: 'OrderByValue',
  8. sortOrder: 'asc',
  9. /**
  10. * 當前程式所有ID名稱集合
  11. */
  12. idKeys: ['OrgID', 'DepartmentID'],
  13. /**
  14. * Grid欄位設置可以是 function
  15. */
  16. gridFields: [
  17. { name: "RowIndex", title: 'common.RowNumber', align: 'center', width: 50, sorting: false },
  18. { name: "DepartmentName", title: 'common.DepartmentName', width: 200 },
  19. { name: "DepartmentID", title: 'common.DepartmentID', width: 150 },
  20. { name: "DepartmentShortName", title: 'DepartmentsMaintain_Upd.DepartmentShortName', width: 200 },
  21. { name: "ParentDepartmentID", title: 'DepartmentsMaintain_Upd.ParentDepartmentID', width: 200 },
  22. { name: "ChiefOfDepartmentID", title: 'DepartmentsMaintain_Upd.ChiefOfDepartmentID', width: 200 },
  23. {
  24. name: "Effective", title: 'common.Status', width: 100, align: 'center', itemTemplate: function (val) {
  25. return val === 'Y' ? i18next.t('common.Effective') : i18next.t('common.Invalid');
  26. }
  27. },
  28. {
  29. name: "OrderByValue", title: 'common.OrderByValue', type: "select", width: 100,
  30. itemTemplate: function (val, item) {
  31. return this._createSelect = $("<select>", {
  32. class: 'w70',
  33. html: createOptions(item.OrderCount),
  34. change: function () {
  35. var sOldValue = val,
  36. sNewValue = this.value;
  37. g_api.ConnectLite(canDo.ProgramId, canDo._api.order, {
  38. Id: item.DepartmentID,
  39. OldOrderByValue: sOldValue,
  40. NewOrderByValue: sNewValue
  41. }, function (res) {
  42. if (res.RESULT) {
  43. showMsg(i18next.t('message.Update_Success'), 'success');// ╠message.Update_Success⇒更新成功╣
  44. canDo.Grid.openPage(canDo.options.toFirstPage ? 1 : canDo.options.queryPageidx);
  45. }
  46. else {
  47. showMsg(i18next.t('message.Update_Failed') + '<br>' + res.MSG, 'error'); // ╠message.Update_Failed⇒更新失敗╣
  48. }
  49. });
  50. }
  51. }).val(val);
  52. }
  53. }
  54. ],
  55. /**
  56. * 頁面初始化
  57. * @param {Object} pargs CanDo 對象
  58. */
  59. pageInit: function (pargs) {
  60. pargs._reSetQueryPm();
  61. pargs._initGrid();
  62. }
  63. });
  64. };
  65. require(['base', 'jsgrid', 'cando'], fnPageInit);