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.

400 lines
16 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. //公共参数
  2. let tableTags = "deliveryRequisition_data";//表格的id
  3. let currentRow;//临时的参数行
  4. //初始化
  5. $(function () {
  6. wareTableInit();
  7. InfoDate('startDate')
  8. InfoDate('endDate')
  9. });
  10. //初始化备货计划建议
  11. function wareTableInit() {
  12. $('#' + tableTags).bootstrapTable({
  13. url: '/replenishment/searchReplenishmentList', //请求后台的URL(*)
  14. method: 'post', //请求方式(*)
  15. //contentType:'application/x-www-form-urlencoded',
  16. contentType: 'application/json;charset=utf-8',
  17. toolbar: '#toolbar', //工具按钮用哪个容器
  18. striped: true, //是否显示行间隔色
  19. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  20. pagination: false, //是否显示分页(*)
  21. sortable: false, //是否启用排序
  22. sortOrder: "asc", //排序方式
  23. queryParamsType: "undefined", //排序方式
  24. queryParams: function queryParams(params) { //设置查询参数
  25. var param = {
  26. 'site': $('#current_site').val(),
  27. 'warehousename': $('#warehousename').val(),
  28. "partdescription": $("#partDescription").val(),
  29. 'warehousetypeDb': 'T'
  30. };
  31. return JSON.stringify(param);
  32. },
  33. sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
  34. pageNumber: 1, //初始化加载第一页,默认第一页
  35. pageSize: 10, //每页的记录行数(*)
  36. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  37. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  38. searchTimeOut: 1000,
  39. // : true,
  40. showColumns: false, //是否显示所有的列
  41. showRefresh: false, //是否显示刷新按钮
  42. minimumCountColumns: 2, //最少允许的列数
  43. clickToSelect: true, //是否启用点击选中行
  44. singleSelect: false,
  45. height: 400, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
  46. uniqueId: "id", //每一行的唯一标识,一般为主键列
  47. // showToggle: true, //是否显示详细视图和列表视图的切换按钮
  48. cardView: false, //是否显示详细视图
  49. detailView: false, //是否显示父子表
  50. columns: [/*{
  51. checkbox: true
  52. },*/{
  53. field: 'wareHouseId',
  54. title: '店铺编号'
  55. }, {
  56. field: 'warehousename',
  57. title: '店铺名称'
  58. }, {
  59. field: 'partNo',
  60. title: 'SKU编号',
  61. formatter: function (value, row) {
  62. return value + " ";
  63. }
  64. }, {
  65. field: 'partdescription',
  66. title: 'SKU名称'
  67. }, {
  68. field: 'qtyRequired',
  69. title: '需求数量',
  70. width: 100,
  71. align: 'right',
  72. }, {
  73. field: 'needDate',
  74. title: '要求到货时间',
  75. formatter: function (value, row) {
  76. var date = formatLinuxDate(value);
  77. date = date.substring(0, 10);
  78. return date;
  79. },
  80. width: 100
  81. }, {
  82. field: 'createdBy',
  83. title: '录入人',
  84. width: 100
  85. }, {
  86. field: 'createdDate',
  87. title: '录入时间',
  88. formatter: function (value, row) {
  89. var date = formatLinuxDate(value);
  90. date = date.substring(0, 16);
  91. return date;
  92. },
  93. width: 120
  94. }, {
  95. field: 'status',
  96. title: '状态',
  97. width: 100
  98. }],
  99. onClickRow: function (row, $element) {
  100. $('.check_back').removeClass('check_back');
  101. $($element).addClass('check_back');
  102. currentRow = row;
  103. //调用自定义按钮的控制类
  104. customerBtnControl(tableTags, row, null);
  105. },
  106. onLoadSuccess: function (data) {
  107. var height_param = $(window).height() - 92;
  108. $('#' + tableTags).parents('.fixed-table-container').css("height", height_param + "px");
  109. //调用自定义按钮的控制类
  110. customerBtnControl(tableTags, null, null)
  111. },
  112. onDblClickRow: function (row, $element) {
  113. currentRow = row;
  114. editDeliveryModal()
  115. },
  116. //>>>>>>>>>>>>>>导出excel表格设置
  117. showExport: false, //是否显示导出按钮(此方法是自己写的目的是判断终端是电脑还是手机,电脑则返回true,手机返回falsee,手机不显示按钮)
  118. exportDataType: "basic", //basic', 'all', 'selected'.
  119. exportTypes: ['excel', 'xlsx'], //导出类型
  120. exportButton: $('#download_button'), //为按钮btn_export 绑定导出事件 自定义导出按钮(可以不用)
  121. exportOptions: {
  122. ignoreColumn: [8, 8], //忽略某一列的索引
  123. fileName: '备货建议' + generateTimeReqestNumber(), //文件名称设置
  124. worksheetName: '备货建议', //表格工作区名称
  125. tableName: '备货建议',
  126. excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
  127. onMsoNumberFormat: DoOnMsoNumberFormat,
  128. mso:{
  129. // fileFormat: 'xlsx',
  130. //修复导出数字不显示为科学计数法
  131. onMsoNumberFormat: function (cell, row, col) {
  132. return !isNaN($(cell).text())?'\\@':'';
  133. }
  134. }
  135. }
  136. //导出excel表格设置<<<<<<<<<<<<<<<<
  137. });
  138. }
  139. //处理搜索,刷新table
  140. function search() {
  141. $('#deliveryRequisition_data').bootstrapTable('refresh');
  142. }
  143. // 选择补货
  144. function calculation() {
  145. $('#delivery_modal').modal()
  146. }
  147. // 补货
  148. function addDelivey() {
  149. let mrpPlanDataQuery = {
  150. createdBy: $('#current_username').val(),
  151. site: $('#current_site').val(),
  152. days: $('#days').val(),
  153. wareHouseId: $("#wareHouseId").val(),
  154. partNo: $('#partNo').val(),
  155. calculationType: 'MS',
  156. wareHouseTypeDb: 'T',
  157. otherGroup2: $('#current_username').val()
  158. }
  159. $.ajax({
  160. url: '/mrpPlan/updateMrpPlanCalculation',
  161. contentType: 'application/json',
  162. type: "POST",
  163. async: false,
  164. data: JSON.stringify(mrpPlanDataQuery),
  165. dataType: "json",
  166. success: function (data) {
  167. layer.msg(data.msg)
  168. if (data.success) {
  169. $('#skuInfoClose').click()
  170. $('#deliveryRequisition_data').bootstrapTable('refresh')
  171. }
  172. },
  173. error: function (data) {
  174. var responseText = data.responseText;
  175. var json_str = JSON.parse(responseText);
  176. var status = json_str.status;
  177. var message = json_str.message;
  178. //判断是否是session超时
  179. if (403 == status) {
  180. layer.alert(message, function () {
  181. window.location.href = "/login";
  182. });
  183. }
  184. layer.closeAll('loading');
  185. }
  186. })
  187. }
  188. let lod = 'N'
  189. // 计划详情
  190. function editDeliveryModal() {
  191. $('#infoWareHouseName').text(currentRow.warehousename)
  192. $('#infoPartDescription').text(currentRow.partdescription)
  193. deliveryInfoTable()
  194. $('#deliveryRequisition_info').bootstrapTable('refresh')
  195. $('#edit_modal').modal()
  196. }
  197. // 计划详情列表
  198. function deliveryInfoTable() {
  199. $('#deliveryRequisition_info').bootstrapTable({
  200. url: '/replenishment/searchMrpPlanDataList', //请求后台的URL(*)
  201. method: 'post', //请求方式(*)
  202. //contentType:'application/x-www-form-urlencoded',
  203. contentType: 'application/json;charset=utf-8',
  204. striped: true, //是否显示行间隔色
  205. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  206. pagination: false, //是否显示分页(*)
  207. sortable: false, //是否启用排序
  208. sortOrder: "asc", //排序方式
  209. queryParamsType: "undefined", //排序方式
  210. queryParams: function queryParams(params) { //设置查询参数
  211. let param = {
  212. wareHouseId: currentRow.wareHouseId,
  213. partNo: currentRow.partNo,
  214. site: currentRow.site,
  215. planDesc: '临时补货',
  216. calculationType: 'MS'
  217. };
  218. return JSON.stringify(param);
  219. },
  220. sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
  221. pageNumber: 1, //初始化加载第一页,默认第一页
  222. pageSize: 10, //每页的记录行数(*)
  223. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  224. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  225. searchTimeOut: 1000,
  226. // : true,
  227. showColumns: false, //是否显示所有的列
  228. showRefresh: false, //是否显示刷新按钮
  229. minimumCountColumns: 2, //最少允许的列数
  230. clickToSelect: true, //是否启用点击选中行
  231. singleSelect: false,
  232. //height: 400, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
  233. uniqueId: "id", //每一行的唯一标识,一般为主键列
  234. // showToggle: true, //是否显示详细视图和列表视图的切换按钮
  235. cardView: false, //是否显示详细视图
  236. detailView: false, //是否显示父子表
  237. columns: [/*{
  238. checkbox: true
  239. },*//*{
  240. field: 'wareHouseId',
  241. title: '店铺编号'
  242. }, {
  243. field: 'warehousename',
  244. title: '店铺名称'
  245. }, {
  246. field: 'partNo',
  247. title: 'SKU编号'
  248. }, {
  249. field: 'partdescription',
  250. title: 'SKU名称'
  251. },*/ {
  252. field: 'planQty',
  253. title: '数量',
  254. align: 'right',
  255. }, {
  256. field: 'direction',
  257. title: '方向'
  258. }, {
  259. field: 'planDesc',
  260. title: '描述'
  261. }, {
  262. field: 'planQtys',
  263. title: '库存',
  264. align: 'right',
  265. formatter: function (value, row, index) {
  266. row.planQtys = $('#deliveryRequisition_info').bootstrapTable('getData')[index].planQty;
  267. if (index == 0) {
  268. if (row.direction == '+') {
  269. row.planQtys = $('#deliveryRequisition_info').bootstrapTable('getData')[0].planQty
  270. } else {
  271. row.planQtys = -$('#deliveryRequisition_info').bootstrapTable('getData')[0].planQty
  272. }
  273. } else {
  274. if (row.direction == '+') {
  275. row.planQtys = $('#deliveryRequisition_info').bootstrapTable('getData')[index - 1].planQtys + row.planQty
  276. } else {
  277. row.planQtys = $('#deliveryRequisition_info').bootstrapTable('getData')[index - 1].planQtys - row.planQty
  278. }
  279. }
  280. return row.planQtys;
  281. }
  282. }, {
  283. field: 'planDate',
  284. title: '时间',
  285. formatter: function (value, row) {
  286. var date = formatLinuxDate(value);
  287. date = date.substring(0, 10);
  288. return date;
  289. }
  290. }, {
  291. field: 'status',
  292. title: '状态'
  293. }],
  294. onLoadSuccess: function (data) {
  295. $('#deliveryRequisition_info').parents('.fixed-table-container').addClass("table-height");
  296. }
  297. });
  298. }
  299. // 删除计划
  300. function removeDelivery() {
  301. layer.confirm('确定要删除选中的信息!', {
  302. btn: ['确定', '取消']
  303. // 按钮
  304. }, function () {
  305. let mrpPlanDataQuery = {
  306. id: currentRow.id
  307. }
  308. $.ajax({
  309. url: '/replenishment/removeDeliveryRequisition',
  310. contentType: 'application/json',
  311. type: "POST",
  312. async: false,
  313. data: JSON.stringify(mrpPlanDataQuery),
  314. dataType: "json",
  315. success: function (data) {
  316. layer.msg(data.msg)
  317. if (data.success) {
  318. $('#deliveryRequisition_data').bootstrapTable('refresh')
  319. }
  320. },
  321. error: function (data) {
  322. var responseText = data.responseText;
  323. var json_str = JSON.parse(responseText);
  324. var status = json_str.status;
  325. var message = json_str.message;
  326. //判断是否是session超时
  327. if (403 == status) {
  328. layer.alert(message, function () {
  329. window.location.href = "/login";
  330. });
  331. }
  332. layer.closeAll('loading');
  333. }
  334. })
  335. }, function () {
  336. });
  337. }
  338. //格式化数字
  339. function DoOnMsoNumberFormat(cell, row, col) {
  340. var result = "";
  341. if (row > 0 && col == 0)
  342. debugger;
  343. result = "\\@";
  344. return result;
  345. }
  346. // 日期数字格式化
  347. function generateTimeReqestNumber() {
  348. var date = new Date();
  349. return date.getFullYear().toString() + pad2(date.getMonth() + 1) + pad2(date.getDate()) + pad2(date.getHours()) + pad2(date.getMinutes()) + pad2(date.getSeconds());
  350. }
  351. function pad2(n) {
  352. return n < 10 ? '0' + n : n
  353. }
  354. // 时间搜索框
  355. function InfoDate(date) {
  356. // var default_date = getNowFormatDate();
  357. // $("#"+date).val(default_date);
  358. $.fn.datetimepicker.dates['zh-CN'] = {
  359. days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
  360. daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
  361. daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
  362. months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
  363. monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
  364. today: "今天",
  365. suffix: [],
  366. meridiem: ["上午", "下午"]
  367. };
  368. //初始化模态框的日期
  369. $("#" + date).datetimepicker({
  370. format: 'yyyy-mm-dd',//显示格式
  371. startView: "month", //初始化视图是‘年’
  372. maxView: 4,//最高能展示的时间,Number, String类型 默认值:4, 年
  373. minView: 'year',//日期时间选择器所能够提供的最精确的时间选择视图
  374. autoclose: true,//选择后自动关闭
  375. todayBtn: true,//开启选择今天的按钮
  376. todayHighlight: true,//今天日期高亮显示 如果为true, 高亮当前日期。Boolean类型 ,默认值:false ,
  377. language: 'zh-CN'//语言选择中文
  378. });
  379. }