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.

95 lines
4.4 KiB

2 years ago
  1. 'use strict';
  2. var fnPageInit = function () {
  3. var canDo = new CanDo({
  4. sortField: 'LoginTime',
  5. sortOrder: 'desc',
  6. inserting: true,
  7. /**
  8. * 當前程式所有ID名稱集合
  9. */
  10. idKeys: ['NO'],
  11. onItemEditing: function (args) {
  12. if (args.item.IsVerify === 'Y') {
  13. args.cancel = true;
  14. }
  15. },
  16. /**
  17. * Grid欄位設置可以是 function
  18. */
  19. gridFields: function (pargs) {
  20. return [
  21. { name: "RowIndex", title: 'common.RowNumber', editing: false, align: "center", inserting: false, type: "text", width: 50, sorting: false },
  22. {
  23. name: "UserID", title: 'common.UserId', editing: true, align: "left", type: "text", width: 80,
  24. validate: { validator: 'required', message: i18next.t('common.AuthID_required') }// ╠common.AuthID_required⇒請輸入授權ID╣
  25. },
  26. {
  27. name: "UserName", title: 'common.UserName', editing: true, align: "left", type: "text", width: 130,
  28. validate: { validator: 'required', message: i18next.t('common.AuthName_required') }// ╠common.AuthName_required⇒請輸入授權名稱╣
  29. },
  30. { name: "Token", title: 'common.Token', editing: false, inserting: false, align: "left", type: "text", width: 400 },//╠common.Token⇒Token╣
  31. { name: "LoginIp", title: 'common.LoginIp', type: "text", editing: false, inserting: false, align: "center", width: 100 },
  32. {
  33. name: "IsVerify", title: 'common.IsVerify', type: "text", editing: false, inserting: false, align: "center", width: 80,
  34. itemTemplate: function (val, item) {
  35. return val === 'Y' ? i18next.t('common.Yes') : i18next.t('common.No');
  36. }
  37. },
  38. {
  39. type: "control", width: 200, align: 'center',
  40. itemTemplate: function (val, item) {
  41. var oDom = [];
  42. if (item.IsVerify === 'N') {
  43. oDom.push($('<a/>', {
  44. html: i18next.t('common.ReSetTokenSignature'),//╠common.ReSetTokenSignature⇒重新產生Token和簽名╣
  45. class: 'a-url',
  46. click: function () {
  47. fnReSetToken(item);
  48. return false;
  49. }
  50. }), $('<a/>', {
  51. html: i18next.t('common.Toolbar_Del'),//╠common.Toolbar_Del⇒刪除╣
  52. class: 'a-url',
  53. click: function () {
  54. pargs.gridDelete(item).done(function () {
  55. pargs.getPage({});
  56. });
  57. return false;
  58. }
  59. }));
  60. }
  61. return $('<div>', { 'style': 'width:100%;text-align: center;' }).append(oDom);
  62. }
  63. }
  64. ];
  65. },
  66. /**
  67. * 頁面初始化
  68. * @param {Object} pargs CanDo 對象
  69. */
  70. pageInit: function (pargs) {
  71. pargs._reSetQueryPm();
  72. pargs._initGrid();
  73. }
  74. }),
  75. /**
  76. * 重新產生Token和簽名
  77. * @param {Object} data 表單資料
  78. */
  79. fnReSetToken = function (data) {
  80. data = packParams(data, true);
  81. g_api.ConnectLite(canDo.ProgramId, 'ReSetToken', { NO: data.NO }, function (res) {
  82. if (res.RESULT) {
  83. fnGet(oBaseQueryPm);
  84. showMsg(i18next.t("message.Create_Success"), 'success'); //╠message.Create_Success⇒產生成功╣
  85. }
  86. else {
  87. showMsg(i18next.t('message.Create_Failed') + '<br>' + res.MSG, 'error'); //╠message.Create_Failed⇒產生失敗╣
  88. }
  89. }, function () {
  90. showMsg(i18next.t("message.Create_Failed"), 'error');//╠message.Create_Failed⇒產生失敗╣
  91. });
  92. };
  93. };
  94. require(['base', 'jsgrid', 'cando'], fnPageInit);