1
0

helpissue.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../helpissue/list',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
  7. {label: '商户编号', name: 'merchSn', index: 'merchSn', width: 60},
  8. {label: '门店名称', name: 'storeName', index: 'storeName', width: 80},
  9. {label: '问题分类', name: 'typeName', index: 'type_id', width: 60},
  10. {label: '问', name: 'question', index: 'question', width: 80},
  11. {label: '答', name: 'answer', index: 'answer', width: 280},
  12. {label: '排序', name: 'sort', index: 'sort', width: 80}],
  13. viewrecords: true,
  14. height: 385,
  15. rowNum: 10,
  16. rowList: [10, 30, 50],
  17. rownumbers: true,
  18. rownumWidth: 25,
  19. autowidth: true,
  20. multiselect: true,
  21. pager: "#jqGridPager",
  22. jsonReader: {
  23. root: "page.list",
  24. page: "page.currPage",
  25. total: "page.totalPage",
  26. records: "page.totalCount"
  27. },
  28. prmNames: {
  29. page: "page",
  30. rows: "limit",
  31. order: "order"
  32. },
  33. gridComplete: function () {
  34. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
  35. }
  36. });
  37. });
  38. let vm = new Vue({
  39. el: '#rrapp',
  40. data: {
  41. showList: true,
  42. title: null,
  43. helpIssue: {},
  44. ruleValidate: {
  45. question: [
  46. {required: true, message: '问题不能为空', trigger: 'blur'}
  47. ],
  48. answer: [
  49. {required: true, message: '答案不能为空', trigger: 'blur'}
  50. ],
  51. },
  52. q: {
  53. typeName: ''
  54. },
  55. helpTypes: [],
  56. storeList: [],
  57. merchList: []
  58. },
  59. methods: {
  60. query: function () {
  61. vm.reload();
  62. },
  63. add: function () {
  64. vm.showList = false;
  65. vm.title = "新增";
  66. vm.helpIssue = {};
  67. vm.getHelpType();
  68. vm.storeList = [];
  69. vm.merchList = [];
  70. vm.getMerchList();
  71. },
  72. update: function (event) {
  73. let id = getSelectedRow();
  74. if (id == null) {
  75. return;
  76. }
  77. vm.showList = false;
  78. vm.title = "修改";
  79. vm.getInfo(id);
  80. vm.getMerchList();
  81. var rowData = $("#jqGrid").jqGrid('getRowData', id);
  82. vm.getStoresByValue(rowData.merchSn);
  83. },
  84. getStoresByValue: function (value) {
  85. $.get("../store/getStoresByMerch?merchSn=" + value, function (r) {
  86. vm.storeList = r.list;
  87. });
  88. },
  89. getStoresByMerch: function (opt) {
  90. var value = opt.value;
  91. $.get("../store/getStoresByMerch?merchSn=" + value, function (r) {
  92. vm.storeList = r.list;
  93. });
  94. },
  95. getMerchList: function() {
  96. $.get("../merch/queryAll", function (r) {
  97. vm.merchList = r.list;
  98. });
  99. },
  100. saveOrUpdate: function (event) {
  101. let url = vm.helpIssue.id == null ? "../helpissue/save" : "../helpissue/update";
  102. $.ajax({
  103. type: "POST",
  104. url: url,
  105. contentType: "application/json",
  106. data: JSON.stringify(vm.helpIssue),
  107. success: function (r) {
  108. if (r.code === 0) {
  109. alert('操作成功', function (index) {
  110. vm.reload();
  111. });
  112. } else {
  113. alert(r.msg);
  114. }
  115. }
  116. });
  117. },
  118. del: function (event) {
  119. let ids = getSelectedRows();
  120. if (ids == null) {
  121. return;
  122. }
  123. confirm('确定要删除选中的记录?', function () {
  124. $.ajax({
  125. type: "POST",
  126. url: "../helpissue/delete",
  127. contentType: "application/json",
  128. data: JSON.stringify(ids),
  129. success: function (r) {
  130. if (r.code == 0) {
  131. alert('操作成功', function (index) {
  132. $("#jqGrid").trigger("reloadGrid");
  133. });
  134. } else {
  135. alert(r.msg);
  136. }
  137. }
  138. });
  139. });
  140. },
  141. getInfo: function (id) {
  142. $.get("../helpissue/info/" + id, function (r) {
  143. vm.helpIssue = r.helpIssue;
  144. vm.getHelpType();
  145. });
  146. },
  147. reloadSearch: function () {
  148. vm.q = {
  149. typeName: ''
  150. }
  151. vm.reload();
  152. },
  153. reload: function (event) {
  154. vm.showList = true;
  155. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  156. $("#jqGrid").jqGrid('setGridParam', {
  157. postData: {'typeName': vm.q.typeName},
  158. page: page
  159. }).trigger("reloadGrid");
  160. vm.handleReset('formValidate');
  161. },
  162. handleSubmit: function (name) {
  163. handleSubmitValidate(this, name, function () {
  164. vm.saveOrUpdate()
  165. });
  166. },
  167. handleReset: function (name) {
  168. handleResetForm(this, name);
  169. },
  170. getHelpType:function () {
  171. $.get("../helptype/queryAll", function (r) {
  172. vm.helpTypes = r.list;
  173. });
  174. }
  175. }
  176. });