helpissue.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. $(function () {
  2. $("#jqGrid").Grid({
  3. url: '../helpissue/list',
  4. rownumWidth:60,
  5. colModel: [
  6. {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
  7. {label: '问题分类', name: 'typeName', index: 'type_id', width: 80},
  8. {label: '问', name: 'question', index: 'question', width: 80},
  9. {label: '答', name: 'answer', index: 'answer', width: 80},
  10. {label: '排序', name: 'sort', index: 'sort', width: 80}]
  11. });
  12. });
  13. let vm = new Vue({
  14. el: '#rrapp',
  15. data: {
  16. showList: true,
  17. title: null,
  18. helpIssue: {},
  19. ruleValidate: {
  20. name: [
  21. {required: true, message: '名称不能为空', trigger: 'blur'}
  22. ]
  23. },
  24. q: {
  25. typeName: ''
  26. },
  27. helpTypes: []
  28. },
  29. methods: {
  30. query: function () {
  31. vm.reload();
  32. },
  33. add: function () {
  34. vm.showList = false;
  35. vm.title = "新增";
  36. vm.helpIssue = {};
  37. vm.getHelpType();
  38. },
  39. update: function (event) {
  40. let id = getSelectedRow();
  41. if (id == null) {
  42. return;
  43. }
  44. vm.showList = false;
  45. vm.title = "修改";
  46. vm.getInfo(id);
  47. },
  48. saveOrUpdate: function (event) {
  49. let url = vm.helpIssue.id == null ? "../helpissue/save" : "../helpissue/update";
  50. Ajax.request({
  51. type: "POST",
  52. url: url,
  53. contentType: "application/json",
  54. params: JSON.stringify(vm.helpIssue),
  55. successCallback: function (r) {
  56. alert('操作成功', function (index) {
  57. vm.reload();
  58. });
  59. }
  60. });
  61. },
  62. del: function (event) {
  63. let ids = getSelectedRows();
  64. if (ids == null) {
  65. return;
  66. }
  67. confirm('确定要删除选中的记录?', function () {
  68. Ajax.request({
  69. type: "POST",
  70. url: "../helpissue/delete",
  71. contentType: "application/json",
  72. params: JSON.stringify(ids),
  73. successCallback: function (r) {
  74. alert('操作成功', function (index) {
  75. vm.reload();
  76. });
  77. }
  78. });
  79. });
  80. },
  81. getInfo: function (id) {
  82. Ajax.request({
  83. url: "../helpissue/info/" + id,
  84. async: true,
  85. successCallback: function (r) {
  86. vm.helpIssue = r.helpIssue;
  87. vm.getHelpType();
  88. }
  89. });
  90. },
  91. reloadSearch: function () {
  92. vm.q = {
  93. typeName: ''
  94. };
  95. vm.reload();
  96. },
  97. reload: function (event) {
  98. vm.showList = true;
  99. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  100. $("#jqGrid").jqGrid('setGridParam', {
  101. postData: {'typeName': vm.q.typeName},
  102. page: page
  103. }).trigger("reloadGrid");
  104. vm.handleReset('formValidate');
  105. },
  106. handleSubmit: function (name) {
  107. handleSubmitValidate(this, name, function () {
  108. vm.saveOrUpdate()
  109. });
  110. },
  111. handleReset: function (name) {
  112. handleResetForm(this, name);
  113. },
  114. getHelpType: function () {
  115. Ajax.request({
  116. url: "../helptype/queryAll",
  117. async: true,
  118. successCallback: function (r) {
  119. vm.helpTypes = r.list;
  120. }
  121. });
  122. }
  123. }
  124. });