1
0

mkdistchnl.js 6.1 KB

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