You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

192 lines
6.8 KiB

5 years ago
  1. //公共参数
  2. let tableTags = "ware_data";//表格的id
  3. let currentRow;//临时的参数行
  4. //初始化
  5. $(function () {
  6. wareTableInit();
  7. });
  8. // 初始化店铺信息
  9. function storInit() {
  10. }
  11. //初始化表格
  12. function wareTableInit() {
  13. $('#' + tableTags).bootstrapTable({
  14. url: '/inventory/searchInventoryList', //请求后台的URL(*)
  15. method: 'post', //请求方式(*)
  16. //contentType:'application/x-www-form-urlencoded',
  17. contentType: 'application/json;charset=utf-8',
  18. toolbar: '#toolbar', //工具按钮用哪个容器
  19. striped: true, //是否显示行间隔色
  20. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  21. pagination: false, //是否显示分页(*)
  22. sortable: false, //是否启用排序
  23. sortOrder: "asc", //排序方式
  24. queryParamsType: "undefined", //排序方式
  25. queryParams: function queryParams(params) { //设置查询参数
  26. var param = {
  27. 'site': $('#current_site').val(),
  28. 'warehouseid': $('#warehouseid').val(),
  29. 'wareHouseName': $('#warehousename').val(),
  30. "partNo": $("#partNo").val(),
  31. "partDescription": $("#partDescription").val()
  32. };
  33. return JSON.stringify(param);
  34. },
  35. sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
  36. pageNumber: 1, //初始化加载第一页,默认第一页
  37. pageSize: 10, //每页的记录行数(*)
  38. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  39. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  40. searchTimeOut: 1000,
  41. // : true,
  42. showColumns: false, //是否显示所有的列
  43. showRefresh: false, //是否显示刷新按钮
  44. minimumCountColumns: 2, //最少允许的列数
  45. clickToSelect: true, //是否启用点击选中行
  46. singleSelect: false,
  47. height: 400, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
  48. uniqueId: "id", //每一行的唯一标识,一般为主键列
  49. // showToggle: true, //是否显示详细视图和列表视图的切换按钮
  50. cardView: false, //是否显示详细视图
  51. detailView: false, //是否显示父子表
  52. columns: [/*{
  53. checkbox: true
  54. },*/{
  55. field: 'warehouseid',
  56. title: '仓库编号',
  57. width: 200,
  58. }, {
  59. field: 'warehousename',
  60. title: '仓库名称',
  61. width: 200,
  62. }, {
  63. field: 'partno',
  64. title: '物料编号',
  65. width: 200,
  66. }, {
  67. field: 'partdescription',
  68. title: '物料名称',
  69. width: 200,
  70. }, {
  71. field: 'qtyonhand',
  72. title: '库存数量',
  73. width: 200,
  74. align: 'right',
  75. }, {
  76. field: 'warehousetype',
  77. title: '仓库类型',
  78. width: 200
  79. }, {
  80. field: '-',
  81. title: '-',
  82. }],
  83. onClickRow: function (row, $element) {
  84. $('.check_back').removeClass('check_back');
  85. $($element).addClass('check_back');
  86. currentRow = row;
  87. //调用自定义按钮的控制类
  88. customerBtnControl(tableTags, row, null);
  89. },
  90. onLoadSuccess: function (data) {
  91. //调用自定义按钮的控制类
  92. customerBtnControl(tableTags, null, null)
  93. },
  94. //>>>>>>>>>>>>>>导出excel表格设置
  95. showExport: false, //是否显示导出按钮(此方法是自己写的目的是判断终端是电脑还是手机,电脑则返回true,手机返回falsee,手机不显示按钮)
  96. exportDataType: "basic", //basic', 'all', 'selected'.
  97. exportTypes: ['excel', 'xlsx'], //导出类型
  98. exportButton: $('#download_button'), //为按钮btn_export 绑定导出事件 自定义导出按钮(可以不用)
  99. exportOptions: {
  100. ignoreColumn: [8, 8], //忽略某一列的索引
  101. fileName: '库存信息' + generateTimeReqestNumber(), //文件名称设置
  102. worksheetName: '库存信息', //表格工作区名称
  103. tableName: '库存信息',
  104. excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
  105. onMsoNumberFormat: DoOnMsoNumberFormat
  106. }
  107. //导出excel表格设置<<<<<<<<<<<<<<<<
  108. });
  109. }
  110. //处理搜索,刷新table
  111. function searchWare() {
  112. $('#ware_data').bootstrapTable('refresh');
  113. }
  114. // 产品入库
  115. function addWareModal() {
  116. $('#ware_modal').modal()
  117. }
  118. // 添加库存
  119. function addWare() {
  120. }
  121. // 编辑库存model
  122. function editWareModal() {
  123. }
  124. // 编辑库存
  125. function editWare() {
  126. }
  127. //删除库存信息确认
  128. function removerWare() {
  129. layer.confirm('确定要删除选中SKU信息!', {
  130. btn: ['确定', '取消']
  131. // 按钮
  132. }, function () {
  133. }, function () {
  134. });
  135. }
  136. function execl() {
  137. $('#execl_modal').modal()
  138. }
  139. function addExecl(){
  140. let data = new FormData();
  141. let file = $('#inventoryFile')[0].files[0]
  142. data.append("file",file);
  143. data.append("site",$('#current_site').val())
  144. data.append("userName",$('#current_username').val())
  145. $.ajax({
  146. url: '/inventory/saveInventoryList',
  147. type: "POST",
  148. async: false,
  149. data: data,
  150. cache: false,
  151. processData: false,
  152. contentType: false,
  153. success: function (data) {
  154. layer.msg(data.msg)
  155. if (data.success) {
  156. $('#storClose').click()
  157. $('#stor_data').bootstrapTable('refresh')
  158. $('#inventoryFile').val('')
  159. }
  160. },
  161. error: function (data) {
  162. var responseText = data.responseText;
  163. var json_str = JSON.parse(responseText);
  164. var status = json_str.status;
  165. var message = json_str.message;
  166. //判断是否是session超时
  167. if (403 == status) {
  168. layer.alert(message, function () {
  169. window.location.href = "/login";
  170. });
  171. }
  172. layer.closeAll('loading');
  173. }
  174. })
  175. }