1
0

goodstransportinfodetail.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../goodstransportinfodetail/searchListByStatusAndSku',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'transItemId', name: 'transItemId', index: 'trans_item_id', key: true, hidden: true},
  7. {label: '是否在途', name: 'wayStatus', index: 'way_status', width: 100,align: 'center',formatter: function (value) {
  8. if (value == '0') {
  9. return '是(0)';
  10. } else if(value == '1'){
  11. return '否(1)';
  12. }
  13. }},
  14. {label: '商品sku', name: 'sku', index: 'sku', width: 180},
  15. {label: '供应商id', name: 'supplierId', index: 'supplier_id', width: 120},
  16. {label: '原产地', name: 'originCountry', index: 'origin_country', align: 'center',width: 120},
  17. {label: '数量', name: 'num', index: 'num', align: 'right',width: 120},
  18. {label: '创建人编号', name: 'createrSn', index: 'creater_sn',align: 'center', width: 180},
  19. {label: '创建时间', name: 'createTime', index: 'create_time', width: 180, align: 'center',formatter: function (value) {
  20. return transDate(value,'yyyy-MM-dd hh:mm:ss');
  21. }},
  22. {label: '修改人编号', name: 'moderSn', index: 'moder_sn', align: 'center',width: 180},
  23. {label: '修改时间', name: 'modTime', index: 'mod_time', width: 180, align: 'center',formatter: function (value) {
  24. return transDate(value,'yyyy-MM-dd hh:mm:ss');
  25. }
  26. }],
  27. viewrecords: true,
  28. height: 550,
  29. rowNum: 10,
  30. rowList: [10, 30, 50],
  31. rownumbers: true,
  32. rownumWidth: 25,
  33. autowidth: true,
  34. shrinkToFit: false,
  35. autoScroll: true, //开启水平滚动条
  36. width: 1500,
  37. multiselect: true,
  38. pager: "#jqGridPager",
  39. jsonReader: {
  40. root: "page.list",
  41. page: "page.currPage",
  42. total: "page.totalPage",
  43. records: "page.totalCount"
  44. },
  45. prmNames: {
  46. page: "page",
  47. rows: "limit",
  48. order: "order"
  49. },
  50. gridComplete: function () {
  51. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "scroll"});
  52. }
  53. });
  54. });
  55. let vm = new Vue({
  56. el: '#rrapp',
  57. data: {
  58. showList: true,
  59. title: null,
  60. goodsTransportInfoDetail: {},
  61. ruleValidate: {
  62. sku:{required: true, message: 'sku不能为空', trigger: 'blur'},
  63. supplierId:{required: true, message: '供应商id不能为空', trigger: 'blur'},
  64. originCountry:{required: true, message: '原产地不能为空', trigger: 'blur'},
  65. num:{required: true, message: '数量不能为空', trigger: 'blur'}
  66. },
  67. q: {
  68. wayStatus: null,
  69. sku: null
  70. }
  71. },
  72. methods: {
  73. query: function () {
  74. vm.reload();
  75. },
  76. add: function () {
  77. vm.showList = false;
  78. vm.title = "新增";
  79. vm.goodsTransportInfoDetail = {};
  80. },
  81. update: function (event) {
  82. let transItemId = getSelectedRow();
  83. if (transItemId == null) {
  84. return;
  85. }
  86. vm.showList = false;
  87. vm.title = "修改";
  88. vm.getInfo(transItemId)
  89. },
  90. saveOrUpdate: function (event) {
  91. let url = vm.goodsTransportInfoDetail.transItemId == null ? "../goodstransportinfodetail/save" : "../goodstransportinfodetail/update";
  92. $.ajax({
  93. type: "POST",
  94. url: url,
  95. contentType: "application/json",
  96. data: JSON.stringify(vm.goodsTransportInfoDetail),
  97. success: function (r) {
  98. if (r.code === 0) {
  99. alert('操作成功', function (index) {
  100. vm.reload();
  101. });
  102. } else {
  103. alert(r.msg);
  104. }
  105. }
  106. });
  107. },
  108. del: function (event) {
  109. let transItemIds = getSelectedRows();
  110. if (transItemIds == null){
  111. return;
  112. }
  113. confirm('确定要删除选中的记录?', function () {
  114. $.ajax({
  115. type: "POST",
  116. url: "../goodstransportinfodetail/delete",
  117. contentType: "application/json",
  118. data: JSON.stringify(transItemIds),
  119. success: function (r) {
  120. if (r.code == 0) {
  121. alert('操作成功', function (index) {
  122. $("#jqGrid").trigger("reloadGrid");
  123. });
  124. } else {
  125. alert(r.msg);
  126. }
  127. }
  128. });
  129. });
  130. },
  131. getInfo: function(transItemId){
  132. $.get("../goodstransportinfodetail/info/"+transItemId, function (r) {
  133. vm.goodsTransportInfoDetail = r.goodsTransportInfoDetail;
  134. });
  135. },
  136. reloadSearch: function() {
  137. vm.q = {
  138. wayStatus: null,
  139. sku: null
  140. }
  141. vm.reload();
  142. },
  143. reload: function (event) {
  144. vm.showList = true;
  145. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  146. $("#jqGrid").jqGrid('setGridParam', {
  147. postData: {'sku': vm.q.sku,'wayStatus' : vm.q.wayStatus},
  148. page: page
  149. }).trigger("reloadGrid");
  150. vm.handleReset('formValidate');
  151. },
  152. handleSubmit: function (name) {
  153. handleSubmitValidate(this, name, function () {
  154. vm.saveOrUpdate()
  155. });
  156. },
  157. handleReset: function (name) {
  158. handleResetForm(this, name);
  159. },
  160. uploadExcelSuccess: function () {
  161. alert('上传成功', function (index) {
  162. $("#jqGrid").trigger("reloadGrid");
  163. });
  164. },
  165. uploadExcelError: function () {
  166. alert('上传出现异常');
  167. },
  168. uploadExcelSuccess: function (data) {
  169. if(data.code==0){
  170. alert('导入成功', function (index) {
  171. vm.reload();
  172. });
  173. }else{
  174. if(data.msg == '导入成功!'){
  175. alert(data.msg);
  176. vm.reload();
  177. }else {
  178. alert(data.msg);
  179. }
  180. }
  181. },
  182. uploadExcelError: function (data) {
  183. console.log(data);
  184. alert('上传出现异常,请重试!');
  185. },
  186. uploadExcelFormatError: function (file) {
  187. this.$Notice.warning({
  188. title: '文件格式不正确',
  189. desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。'
  190. });
  191. }
  192. }
  193. });