goodsissue.js 5.3 KB

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