supplier.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../supplier/list',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
  7. {label: '一级商户编号', name: 'levelMerchSn', index: 'level_merch_sn', width: 80},
  8. {label: '一级商户标识', name: 'levelMerchFlag', index: 'level_merch_flag', width: 80},
  9. {label: '二级供货商名称', name: 'childSupplierSn', index: 'child_supplier_sn', width: 80},
  10. {label: '二级供货商标识', name: 'childSupplierFlag', index: 'child_supplier_flag', width: 80},
  11. {label: '排序', name: 'sortOrder', index: 'sort_order', width: 80},
  12. {label: '是否禁用:0:否;1:是', name: 'isShow', index: 'is_show', 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. supplier: {childSupplierSn: '', childSupplierFlag: '', isShow: 0},
  44. ruleValidate: {
  45. childSupplierSn: [
  46. {required: true, message: '二级供货商名称不能为空', trigger: 'blur'}
  47. ],
  48. childSupplierFlag: [
  49. {required: true, message: '二级供货商标识不能为空', trigger: 'blur'}
  50. ],
  51. isShow: [
  52. {required: true, message: '是否禁用不能为空', trigger: 'blur'}
  53. ]
  54. },
  55. q: {
  56. name: ''
  57. }
  58. },
  59. methods: {
  60. query: function () {
  61. vm.reload();
  62. },
  63. add: function () {
  64. vm.showList = false;
  65. vm.title = "新增";
  66. vm.supplier = {};
  67. vm.getInfo(0)
  68. },
  69. update: function (event) {
  70. let id = getSelectedRow();
  71. if (id == null) {
  72. return;
  73. }
  74. vm.showList = false;
  75. vm.title = "修改";
  76. vm.getInfo(id)
  77. },
  78. saveOrUpdate: function (event) {
  79. let url = vm.supplier.id == null ? "../supplier/save" : "../supplier/update";
  80. $.ajax({
  81. type: "POST",
  82. url: url,
  83. contentType: "application/json",
  84. data: JSON.stringify(vm.supplier),
  85. success: function (r) {
  86. if (r.code === 0) {
  87. alert('操作成功', function (index) {
  88. vm.reload();
  89. });
  90. } else {
  91. alert(r.msg);
  92. }
  93. }
  94. });
  95. },
  96. del: function (event) {
  97. let ids = getSelectedRows();
  98. if (ids == null){
  99. return;
  100. }
  101. confirm('确定要删除选中的记录?', function () {
  102. $.ajax({
  103. type: "POST",
  104. url: "../supplier/delete",
  105. contentType: "application/json",
  106. data: JSON.stringify(ids),
  107. success: function (r) {
  108. if (r.code == 0) {
  109. alert('操作成功', function (index) {
  110. $("#jqGrid").trigger("reloadGrid");
  111. });
  112. } else {
  113. alert(r.msg);
  114. }
  115. }
  116. });
  117. });
  118. },
  119. getInfo: function(id){
  120. $.get("../supplier/info/"+id, function (r) {
  121. vm.supplier = r.supplier;
  122. });
  123. },
  124. reloadSearch: function() {
  125. vm.q = {
  126. name: ''
  127. }
  128. vm.reload();
  129. },
  130. reload: function (event) {
  131. vm.showList = true;
  132. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  133. $("#jqGrid").jqGrid('setGridParam', {
  134. postData: {'name': vm.q.name},
  135. page: page
  136. }).trigger("reloadGrid");
  137. vm.handleReset('formValidate');
  138. },
  139. handleSubmit: function (name) {
  140. handleSubmitValidate(this, name, function () {
  141. vm.saveOrUpdate()
  142. });
  143. },
  144. handleReset: function (name) {
  145. handleResetForm(this, name);
  146. }
  147. }
  148. });