1
0

addressinfo.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. expcomId:'',
  57. status:'',
  58. addressInfo: {},
  59. storeList: [],
  60. expressCompanySys:[],
  61. ruleValidate: {
  62. /*storeId: [
  63. {required: true, message: '门店不能为空', trigger: 'blur'}
  64. ],*/
  65. /*expcomId: [
  66. {required: true, message: '快递公司不能为空', trigger: 'blur'}
  67. ],*/
  68. },
  69. q: {
  70. storeId: ''
  71. }
  72. },
  73. methods: {
  74. query: function () {
  75. vm.reload();
  76. },
  77. add: function () {
  78. vm.showList = false;
  79. vm.title = "新增";
  80. vm.addressInfo = {};
  81. vm.storeList = [];
  82. vm.expressCompanySys=[];
  83. vm.status=2;
  84. vm.getStoresByMerch();
  85. vm.getCompantByThirdMerch();
  86. },
  87. update: function (event) {
  88. let id = getSelectedRow();
  89. if (id == null) {
  90. return;
  91. }
  92. vm.showList = false;
  93. vm.title = "修改";
  94. vm.status=1;
  95. vm.getInfo(id)
  96. },
  97. saveOrUpdate: function (event) {
  98. let url = vm.addressInfo.id == null ? "../addressinfo/save" : "../addressinfo/update";
  99. $.ajax({
  100. type: "POST",
  101. url: url,
  102. contentType: "application/json",
  103. data: JSON.stringify(vm.addressInfo),
  104. success: function (r) {
  105. if (r.code === 0) {
  106. alert('操作成功', function (index) {
  107. vm.reload();
  108. });
  109. } else {
  110. alert(r.msg);
  111. }
  112. }
  113. });
  114. },
  115. del: function (event) {
  116. let ids = getSelectedRows();
  117. if (ids == null){
  118. return;
  119. }
  120. confirm('确定要删除选中的记录?', function () {
  121. $.ajax({
  122. type: "POST",
  123. url: "../addressinfo/delete",
  124. contentType: "application/json",
  125. data: JSON.stringify(ids),
  126. success: function (r) {
  127. if (r.code == 0) {
  128. alert('操作成功', function (index) {
  129. $("#jqGrid").trigger("reloadGrid");
  130. });
  131. } else {
  132. alert(r.msg);
  133. }
  134. }
  135. });
  136. });
  137. },
  138. getStoresByMerch: function (opt) {
  139. $.get("../expresscompanysys/getStoresByMerch", function (r) {
  140. vm.storeList = r.list;
  141. });
  142. },
  143. getCompantByThirdMerch: function (opt) {
  144. $.get("../expresscompanysys/getCompantByThirdMerch", function (r) {
  145. vm.expressCompanySys = r.list;
  146. });
  147. },
  148. saveStoreAndComp: function (event) {
  149. let url = "../addressinfo/saveStoreAndComp";
  150. let storesId = vm.addressInfo.storeId;
  151. let expcomId = vm.addressInfo.expcomId;
  152. let pames={"outletsId":storesId,"exprId":expcomId};
  153. console.log(JSON.stringify(pames));
  154. $.ajax({
  155. type: "POST",
  156. url: url,
  157. contentType: "application/json",
  158. data: JSON.stringify(pames),
  159. success: function (r) {
  160. if (r.code === 0) {
  161. alert('操作成功', function (index) {
  162. vm.reload();
  163. });
  164. } else {
  165. alert(r.msg);
  166. }
  167. }
  168. });
  169. },
  170. checketStatus: function (event) {
  171. let id = getSelectedRow();
  172. if (id == null) {
  173. return;
  174. }
  175. vm.getInfo(id);
  176. let status = vm.addressInfo.isValid;
  177. let name = '';
  178. if (status == 1 ){
  179. name='禁用';
  180. status = 0;
  181. }else if (status == 0 ){
  182. name='启用';
  183. status= 1;
  184. }
  185. let pames={"id":id,"status":status};
  186. confirm('确定要'+name+'?', function () {
  187. $.ajax({
  188. type: "POST",
  189. url: "../addressinfo/getStatus",
  190. contentType: "application/json",
  191. data: JSON.stringify(pames),
  192. success: function (r) {
  193. if (r.code == 0) {
  194. alert('操作成功', function (index) {
  195. $("#jqGrid").trigger("reloadGrid");
  196. });
  197. } else {
  198. alert(r.msg);
  199. vm.reload();
  200. }
  201. }
  202. });
  203. });
  204. },
  205. getInfo: function(id){
  206. $.get("../addressinfo/info/"+id, function (r) {
  207. vm.addressInfo = r.addressInfo;
  208. });
  209. },
  210. reloadSearch: function() {
  211. vm.q = {
  212. storeId: ''
  213. }
  214. vm.reload();
  215. },
  216. reload: function (event) {
  217. vm.showList = true;
  218. vm.status='';
  219. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  220. $("#jqGrid").jqGrid('setGridParam', {
  221. postData: {'storeId': vm.q.storeId},
  222. page: page
  223. }).trigger("reloadGrid");
  224. vm.handleReset('formValidate');
  225. },
  226. handleSubmit: function (name) {
  227. handleSubmitValidate(this, name, function () {
  228. vm.saveOrUpdate()
  229. });
  230. },
  231. handleComSubmit: function (name) {
  232. handleSubmitValidate(this, name, function () {
  233. // vm.saveOrUpdate()
  234. vm.saveStoreAndComp();
  235. });
  236. },
  237. handleReset: function (name) {
  238. handleResetForm(this, name);
  239. }
  240. }
  241. });