addressinfo.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../addressinfo/list',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
  7. {label: '商家名称', name: 'storeName', index: 'store_name', width: 80},
  8. {label: '快递名称', name: 'expressName', index: 'express_name', width: 80},
  9. {label: '是否启用', name: 'isValid', index: 'is_valid', width: 80,
  10. formatter: function (value) {
  11. return value === 0 ?
  12. '<span class="label label-danger">禁用</span>' :
  13. '<span class="label label-success">正常</span>';
  14. }
  15. },
  16. {label: '创建人编号', name: 'createrSn', index: 'creater_sn', width: 80},
  17. {label: '创建时间', name: 'createTime', index: 'create_time', width: 80, formatter: function (value) {
  18. return transDate(value,'yyyy-MM-dd hh:mm:ss');
  19. }},
  20. {label: '修改人编号', name: 'moderSn', index: 'moder_sn', width: 80},
  21. {label: '修改时间', name: 'modTime', index: 'mod_time', width: 80, formatter: function (value) {
  22. return transDate(value,'yyyy-MM-dd hh:mm:ss');
  23. }}
  24. ],
  25. viewrecords: true,
  26. height: 550,
  27. rowNum: 10,
  28. rowList: [10, 30, 50],
  29. rownumbers: true,
  30. rownumWidth: 25,
  31. autowidth: true,
  32. multiselect: true,
  33. pager: "#jqGridPager",
  34. jsonReader: {
  35. root: "page.list",
  36. page: "page.currPage",
  37. total: "page.totalPage",
  38. records: "page.totalCount"
  39. },
  40. prmNames: {
  41. page: "page",
  42. rows: "limit",
  43. order: "order"
  44. },
  45. gridComplete: function () {
  46. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
  47. }
  48. });
  49. });
  50. let vm = new Vue({
  51. el: '#rrapp',
  52. data: {
  53. showList: true,
  54. title: null,
  55. storeId: '',
  56. addressInfo: {},
  57. ruleValidate: {
  58. storeId: [
  59. {required: true, message: '名称不能为空', trigger: 'blur'}
  60. ]
  61. },
  62. q: {
  63. storeId: ''
  64. }
  65. },
  66. methods: {
  67. query: function () {
  68. vm.reload();
  69. },
  70. add: function () {
  71. vm.showList = false;
  72. vm.title = "新增";
  73. vm.addressInfo = {};
  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. },
  84. saveOrUpdate: function (event) {
  85. let url = vm.addressInfo.id == null ? "../addressinfo/save" : "../addressinfo/update";
  86. $.ajax({
  87. type: "POST",
  88. url: url,
  89. contentType: "application/json",
  90. data: JSON.stringify(vm.addressInfo),
  91. success: function (r) {
  92. if (r.code === 0) {
  93. alert('操作成功', function (index) {
  94. vm.reload();
  95. });
  96. } else {
  97. alert(r.msg);
  98. }
  99. }
  100. });
  101. },
  102. del: function (event) {
  103. let ids = getSelectedRows();
  104. if (ids == null){
  105. return;
  106. }
  107. confirm('确定要删除选中的记录?', function () {
  108. $.ajax({
  109. type: "POST",
  110. url: "../addressinfo/delete",
  111. contentType: "application/json",
  112. data: JSON.stringify(ids),
  113. success: function (r) {
  114. if (r.code == 0) {
  115. alert('操作成功', function (index) {
  116. $("#jqGrid").trigger("reloadGrid");
  117. });
  118. } else {
  119. alert(r.msg);
  120. }
  121. }
  122. });
  123. });
  124. },
  125. checketStatus: function (event) {
  126. let id = getSelectedRow();
  127. if (id == null) {
  128. return;
  129. }
  130. vm.getInfo(id);
  131. let status = vm.addressInfo.isValid;
  132. let name = '';
  133. if (status == 1 ){
  134. name='禁用';
  135. status = 0;
  136. }else if (status == 0 ){
  137. name='启用';
  138. status= 1;
  139. }
  140. let pames={"id":id,"status":status};
  141. confirm('确定要'+name+'?', function () {
  142. $.ajax({
  143. type: "POST",
  144. url: "../addressinfo/getStatus",
  145. contentType: "application/json",
  146. data: JSON.stringify(pames),
  147. success: function (r) {
  148. if (r.code == 0) {
  149. alert('操作成功', function (index) {
  150. $("#jqGrid").trigger("reloadGrid");
  151. });
  152. } else {
  153. alert(r.msg);
  154. vm.reload();
  155. }
  156. }
  157. });
  158. });
  159. },
  160. getInfo: function(id){
  161. $.get("../addressinfo/info/"+id, function (r) {
  162. vm.addressInfo = r.addressInfo;
  163. });
  164. },
  165. reloadSearch: function() {
  166. vm.q = {
  167. storeId: ''
  168. }
  169. vm.reload();
  170. },
  171. reload: function (event) {
  172. vm.showList = true;
  173. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  174. $("#jqGrid").jqGrid('setGridParam', {
  175. postData: {'storeId': vm.q.storeId},
  176. page: page
  177. }).trigger("reloadGrid");
  178. vm.handleReset('formValidate');
  179. },
  180. handleSubmit: function (name) {
  181. handleSubmitValidate(this, name, function () {
  182. vm.saveOrUpdate()
  183. });
  184. },
  185. handleReset: function (name) {
  186. handleResetForm(this, name);
  187. }
  188. }
  189. });