1
0

mkdistchnl.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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: 280},
  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: 180},
  20. {label: '所属供应商', name: 'childSupplierName', index: 'childSupplierName', width: 180},
  21. {label: '排序', name: 'sortOrder', index: 'sort_order',align: 'center', width: 80},
  22. {label: '是否有效', name: 'isValid', index: 'is_valid', width: 80,align: 'center',
  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: 180},
  32. {label: '创建人编号', name: 'createrSn', index: 'creater_sn', width: 120},
  33. {label: '创建时间', name: 'createTime', index: 'create_time', width: 160,align: 'center',
  34. formatter: function (value) {
  35. return transDate(value, 'yyyy-MM-dd hh:mm:ss');
  36. }},
  37. {label: '修改人编号', name: 'moderSn', index: 'moder_sn', width: 120},
  38. {label: '修改时间', name: 'modTime', index: 'mod_time', width: 160,align: 'center',
  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. shrinkToFit: false,
  50. autoScroll: true, //开启水平滚动条
  51. width: 1500,
  52. multiselect: true,
  53. pager: "#jqGridPager",
  54. jsonReader: {
  55. root: "page.list",
  56. page: "page.currPage",
  57. total: "page.totalPage",
  58. records: "page.totalCount"
  59. },
  60. prmNames: {
  61. page: "page",
  62. rows: "limit",
  63. order: "order"
  64. },
  65. gridComplete: function () {
  66. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "scroll"});
  67. }
  68. });
  69. });
  70. let vm = new Vue({
  71. el: '#rrapp',
  72. data: {
  73. showList: true,
  74. title: null,
  75. mkDistChnl: {},
  76. ruleValidate: {
  77. name: [
  78. {required: true, message: '名称不能为空', trigger: 'blur'}
  79. ]
  80. },
  81. q: {
  82. distFlag: ''
  83. },
  84. suppliers: [],
  85. thirdMerchantBizList: []
  86. },
  87. methods: {
  88. query: function () {
  89. vm.reload();
  90. },
  91. add: function () {
  92. vm.showList = false;
  93. vm.title = "新增";
  94. vm.thirdMerchantBizList = [];
  95. vm.suppliers = [];
  96. vm.mkDistChnl = {isValid:0};
  97. vm.getThirdMerchantBizList();
  98. },
  99. update: function (event) {
  100. let distChnlId = getSelectedRow();
  101. if (distChnlId == null) {
  102. return;
  103. }
  104. vm.showList = false;
  105. vm.title = "修改";
  106. vm.getThirdMerchantBizList();
  107. vm.getInfo(distChnlId)
  108. },
  109. saveOrUpdate: function (event) {
  110. let url = vm.mkDistChnl.distChnlId == null ? "../mkdistchnl/save" : "../mkdistchnl/update";
  111. $.ajax({
  112. type: "POST",
  113. url: url,
  114. contentType: "application/json",
  115. data: JSON.stringify(vm.mkDistChnl),
  116. success: function (r) {
  117. if (r.code === 0) {
  118. alert('操作成功', function (index) {
  119. vm.reload();
  120. });
  121. } else {
  122. alert(r.msg);
  123. }
  124. }
  125. });
  126. },
  127. del: function (event) {
  128. let distChnlIds = getSelectedRows();
  129. if (distChnlIds == null){
  130. return;
  131. }
  132. confirm('确定要删除选中的记录?', function () {
  133. $.ajax({
  134. type: "POST",
  135. url: "../mkdistchnl/delete",
  136. contentType: "application/json",
  137. data: JSON.stringify(distChnlIds),
  138. success: function (r) {
  139. if (r.code == 0) {
  140. alert('操作成功', function (index) {
  141. $("#jqGrid").trigger("reloadGrid");
  142. });
  143. } else {
  144. alert(r.msg);
  145. }
  146. }
  147. });
  148. });
  149. },
  150. getInfo: function(distChnlId){
  151. $.get("../mkdistchnl/info/"+distChnlId, function (r) {
  152. vm.mkDistChnl = r.mkDistChnl;
  153. });
  154. },
  155. getThirdMerchantBizList: function() {
  156. $.get("../thirdmerchantbiz/queryAll", function (r) {
  157. vm.thirdMerchantBizList = r.list;
  158. });
  159. },
  160. showSupplier: function (thirdMerchSn) {
  161. $.get("../supplier/queryAll?thirdMerchSn=" + thirdMerchSn, function (r) {
  162. vm.suppliers = r.list;
  163. });
  164. },
  165. showStockShare:function(opt){
  166. var thirdMerchantCode = opt.value;
  167. vm.getSuppliers(thirdMerchantCode);
  168. },
  169. reloadSearch: function() {
  170. vm.q = {
  171. distFlag: ''
  172. }
  173. vm.reload();
  174. },
  175. reload: function (event) {
  176. vm.showList = true;
  177. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  178. $("#jqGrid").jqGrid('setGridParam', {
  179. postData: {'distFlag': vm.q.distFlag},
  180. page: page
  181. }).trigger("reloadGrid");
  182. vm.handleReset('formValidate');
  183. },
  184. handleSubmit: function (name) {
  185. handleSubmitValidate(this, name, function () {
  186. vm.saveOrUpdate()
  187. });
  188. },
  189. handleReset: function (name) {
  190. handleResetForm(this, name);
  191. }
  192. }
  193. });