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.

241 lines
10 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. //公共参数
  2. let tableTags = "productionPlanData";//表格的id
  3. let currentRow;//临时的参数行
  4. //初始化
  5. $(function () {
  6. productionPlanInit();
  7. });
  8. //初始化备货计划建议
  9. function productionPlanInit() {
  10. $('#' + tableTags).bootstrapTable({
  11. url: '/shopOrderRequisition/searchShopOrderRequisitionList', //请求后台的URL(*)
  12. method: 'post', //请求方式(*)
  13. //contentType:'application/x-www-form-urlencoded',
  14. contentType: 'application/json;charset=utf-8',
  15. toolbar: '#toolbar', //工具按钮用哪个容器
  16. striped: true, //是否显示行间隔色
  17. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  18. pagination: false, //是否显示分页(*)
  19. sortable: false, //是否启用排序
  20. sortOrder: "asc", //排序方式
  21. queryParamsType: "undefined", //排序方式
  22. queryParams: function queryParams(params) { //设置查询参数
  23. var param = {
  24. };
  25. return JSON.stringify(param);
  26. },
  27. sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
  28. pageNumber: 1, //初始化加载第一页,默认第一页
  29. pageSize: 10, //每页的记录行数(*)
  30. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  31. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  32. searchTimeOut: 1000,
  33. // : true,
  34. showColumns: false, //是否显示所有的列
  35. showRefresh: false, //是否显示刷新按钮
  36. minimumCountColumns: 2, //最少允许的列数
  37. clickToSelect: true, //是否启用点击选中行
  38. singleSelect: false,
  39. height: 400, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
  40. uniqueId: "id", //每一行的唯一标识,一般为主键列
  41. // showToggle: true, //是否显示详细视图和列表视图的切换按钮
  42. cardView: false, //是否显示详细视图
  43. detailView: false, //是否显示父子表
  44. columns: [/*{
  45. checkbox: true
  46. },*/{
  47. field: 'partNo',
  48. title: 'SKU编号'
  49. }, {
  50. field: 'partDescription',
  51. title: 'SKU名称'
  52. }, {
  53. field: 'qtyRequired',
  54. title: '要求生产数量',
  55. width: 100,
  56. align : 'right',
  57. }, {
  58. field: 'needDate',
  59. title: '要求生产完成时间',
  60. formatter: function (value, row) {
  61. var date = formatLinuxDate(value);
  62. date = date.substring(0, 10);
  63. return date;
  64. },
  65. width: 100
  66. }, {
  67. field: 'createdBy',
  68. title: '录入人'
  69. }, {
  70. field: 'createdDate',
  71. title: '录入时间',
  72. formatter: function (value, row) {
  73. var date = formatLinuxDate(value);
  74. date = date.substring(0, 16);
  75. return date;
  76. },
  77. width: 120
  78. }, {
  79. field: 'status',
  80. title: '状态'
  81. }],
  82. onClickRow: function (row, $element) {
  83. $('.check_back').removeClass('check_back');
  84. $($element).addClass('check_back');
  85. currentRow = row;
  86. //调用自定义按钮的控制类
  87. customerBtnControl(tableTags, row, null);
  88. },
  89. onLoadSuccess: function (data) {
  90. //调用自定义按钮的控制类
  91. customerBtnControl(tableTags, null, null)
  92. },
  93. onDblClickRow: function (row, $element) {
  94. currentRow = row;
  95. openCalculationDetails()
  96. },
  97. //>>>>>>>>>>>>>>导出excel表格设置
  98. showExport: false, //是否显示导出按钮(此方法是自己写的目的是判断终端是电脑还是手机,电脑则返回true,手机返回falsee,手机不显示按钮)
  99. exportDataType: "basic", //basic', 'all', 'selected'.
  100. exportTypes: ['excel', 'xlsx'], //导出类型
  101. exportButton: $('#download_button'), //为按钮btn_export 绑定导出事件 自定义导出按钮(可以不用)
  102. exportOptions: {
  103. ignoreColumn: [8, 8], //忽略某一列的索引
  104. fileName: '生产计划' + generateTimeReqestNumber(), //文件名称设置
  105. worksheetName: '计划信息', //表格工作区名称
  106. tableName: '计划信息',
  107. excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
  108. onMsoNumberFormat: DoOnMsoNumberFormat
  109. }
  110. //导出excel表格设置<<<<<<<<<<<<<<<<
  111. });
  112. }
  113. function search(){
  114. $('#productionPlanData').bootstrapTable('refresh')
  115. }
  116. // 生产 production
  117. function production(){
  118. }
  119. // 打开计算详情
  120. function openCalculationDetails(){
  121. $('#infoPartDescription').text(currentRow.partDescription)
  122. $('#infoPartNo').text(currentRow.partNo)
  123. calculationDetails()
  124. $('#productionInfo').bootstrapTable('refresh')
  125. $('#production_modal').modal()
  126. }
  127. // 计算详情
  128. function calculationDetails(){
  129. $('#productionInfo').bootstrapTable({
  130. url: '/replenishment/searchMrpPlanDataList', //请求后台的URL(*)
  131. method: 'post', //请求方式(*)
  132. //contentType:'application/x-www-form-urlencoded',
  133. contentType: 'application/json;charset=utf-8',
  134. striped: true, //是否显示行间隔色
  135. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  136. pagination: false, //是否显示分页(*)
  137. sortable: false, //是否启用排序
  138. sortOrder: "asc", //排序方式
  139. queryParamsType: "undefined", //排序方式
  140. queryParams: function queryParams(params) { //设置查询参数
  141. let param = {
  142. partNo: currentRow.partNo,
  143. site: currentRow.site,
  144. calculationType: 'MPS'
  145. };
  146. return JSON.stringify(param);
  147. },
  148. sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
  149. pageNumber: 1, //初始化加载第一页,默认第一页
  150. pageSize: 10, //每页的记录行数(*)
  151. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  152. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  153. searchTimeOut: 1000,
  154. // : true,
  155. showColumns: false, //是否显示所有的列
  156. showRefresh: false, //是否显示刷新按钮
  157. minimumCountColumns: 2, //最少允许的列数
  158. clickToSelect: true, //是否启用点击选中行
  159. singleSelect: false,
  160. //height: 400, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
  161. uniqueId: "id", //每一行的唯一标识,一般为主键列
  162. // showToggle: true, //是否显示详细视图和列表视图的切换按钮
  163. cardView: false, //是否显示详细视图
  164. detailView: false, //是否显示父子表
  165. columns: [/*{
  166. checkbox: true
  167. },*//*{
  168. field: 'wareHouseId',
  169. title: '店铺编号'
  170. }, {
  171. field: 'warehousename',
  172. title: '店铺名称'
  173. }, {
  174. field: 'partNo',
  175. title: 'SKU编号'
  176. }, {
  177. field: 'partdescription',
  178. title: 'SKU名称'
  179. },*/ {
  180. field: 'planQty',
  181. title: '数量',
  182. align : 'right',
  183. }, {
  184. field: 'direction',
  185. title: '方向'
  186. }, {
  187. field: 'planDesc',
  188. title: '描述'
  189. }, {
  190. field: 'planQtys',
  191. title: '库存',
  192. align : 'right',
  193. formatter: function (value, row, index) {
  194. row.planQtys = $('#productionInfo').bootstrapTable('getData')[index].planQty;
  195. if (index == 0) {
  196. if (row.direction == '+'){
  197. row.planQtys = $('#productionInfo').bootstrapTable('getData')[0].planQty
  198. }else {
  199. row.planQtys = -$('#productionInfo').bootstrapTable('getData')[0].planQty
  200. }
  201. } else {
  202. if (row.direction == '+') {
  203. row.planQtys = $('#productionInfo').bootstrapTable('getData')[index - 1].planQtys + row.planQty
  204. } else {
  205. row.planQtys = $('#productionInfo').bootstrapTable('getData')[index - 1].planQtys - row.planQty
  206. }
  207. }
  208. return row.planQtys;
  209. }
  210. }, {
  211. field: 'planDate',
  212. title: '时间',
  213. formatter: function (value, row) {
  214. var date = formatLinuxDate(value);
  215. date = date.substring(0, 10);
  216. return date;
  217. }
  218. }, {
  219. field: 'status',
  220. title: '状态'
  221. }],
  222. onLoadSuccess: function (data) {
  223. $('#productionInfo').parents('.fixed-table-container').addClass("table-height");
  224. }
  225. });
  226. }