1
0

helpissue.js 5.8 KB

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