赫艾后端
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.

347 lines
8.4 KiB

6 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 months ago
6 months ago
6 months ago
6 months ago
​
​
6 months ago
6 months ago
6 months ago
6 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 months ago
​
​
6 months ago
​
​
​
6 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 months ago
​
​
6 months ago
6 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 months ago
​
​
​
​
​
​
​
​
​
​
​
  1. var userId = $("#current_id").val();
  2. var userName = $("#current_username").val();
  3. var site = $("#current_site").val();
  4. var titleName = $("#current_titleName").val();
  5. var currentData = null;
  6. var wareHouseId = '';
  7. var partNoData = null;
  8. var inventoryData = null;
  9. var tableList = new Array();
  10. //页面初始化
  11. $(function(){
  12. if(titleName != null && titleName != ""){
  13. $("#titleName").text(titleName);
  14. }else {
  15. window.location.href="/login";
  16. }
  17. $("#remark").val("库存报废")
  18. $("#partNo_search").focus();
  19. });
  20. function changeTableList(){
  21. var qtyOut = $("#qtyOut").val();
  22. var tableData = {
  23. site: inventoryData.site,
  24. partNo : inventoryData.partNo,
  25. qtyOut : qtyOut,
  26. batchNo : inventoryData.batchNo,
  27. locationId : inventoryData.locationId,
  28. warehouseId : inventoryData.warehouseId,
  29. }
  30. tableList.push(tableData);
  31. changeTable();
  32. }
  33. function changeTable(){
  34. var str = '';
  35. // rqrq:首张标签写入发料仓库展示,混仓在 getInventoryData 中拦截
  36. if(tableList.length > 0){
  37. $("#wareHouse").val(tableList[0].warehouseId);
  38. }
  39. for (let i = 0; i < tableList.length; i++) {
  40. str += '<tr id = '+tableList[i].partNo +'>' +
  41. '<th class="" style="text-align:center;background-color: #ffff;width: 20%;">' +
  42. '<span>'+tableList[i].partNo+'</span></th>' +
  43. '<th class="" style="text-align:center;background-color: #ffff;width: 20%;">' +
  44. '<span>'+tableList[i].qtyOut+'</span></th>' +
  45. '<th class="" style="text-align:center;background-color: #ffff;width: 39%;">' +
  46. '<span>'+tableList[i].batchNo+'</span></th>' +
  47. '<th class="" style="text-align:center;background-color: #ffff;width: 20%;">' +
  48. '<span>'+tableList[i].locationId+'</span></th>'+
  49. '</tr>';
  50. }
  51. $("#issue_table").html("").append(str);
  52. $("#issue_cancel").click();
  53. }
  54. $("#partNo_search").bind("keydown",function(event){
  55. if (event.keyCode == 13) {
  56. queryPart();
  57. }
  58. });
  59. function queryPart(){
  60. var partNoSearch = $("#partNo_search").val();
  61. if(partNoSearch == null || partNoSearch === ""){
  62. layer.msg("请扫描物料标签!");
  63. return false
  64. }
  65. var strList = partNoSearch.split("|");
  66. partNoData = {
  67. site : '',
  68. partNo : '',
  69. wareHouseId : '',
  70. batchNo: '',
  71. locationId : '',
  72. }
  73. if(strList.length < 5){
  74. layer.msg("物料标签错误!");
  75. return false
  76. }
  77. for (let i = 0; i < strList.length; i++) {
  78. if(i == 0){
  79. partNoData.site = strList[i];
  80. }else if(i == 1){
  81. partNoData.partNo = strList[i];
  82. }else if(i == 2){
  83. partNoData.wareHouseId = strList[i];
  84. }else if(i == 3){
  85. partNoData.batchNo = strList[i];
  86. }else if(i == 4){
  87. partNoData.locationId = strList[i];
  88. }
  89. }
  90. checkStockLabelPart()
  91. }
  92. /**
  93. * 参数212白名单通过后再查库存 - rqrq
  94. */
  95. function checkStockLabelPart(){
  96. var jsonData = {
  97. site : partNoData.site,
  98. partNo : partNoData.partNo
  99. };
  100. $.ajax({
  101. url: "/pda/stockOtherOut/checkPart",
  102. contentType: 'application/json',
  103. type:"POST",
  104. data:JSON.stringify(jsonData),
  105. dataType:"JSON",
  106. async: true,
  107. beforeSend: function(request) {
  108. request.setRequestHeader("token", $.cookie("token"));
  109. },
  110. success: function (data) {
  111. if(data.code == 0){
  112. getInventoryData();
  113. }else {
  114. layer.alert(data.msg || "物料不允许其他出库");
  115. }
  116. },
  117. error: function(data) {
  118. var responseText = data.responseText;
  119. var json_str = JSON.parse(responseText);
  120. var status = json_str.status;
  121. var message = json_str.message;
  122. if(403==status){
  123. layer.alert(message,function(){
  124. window.location.href="/login";
  125. });
  126. }
  127. layer.closeAll('loading');
  128. }
  129. })
  130. }
  131. function getInventoryData(){
  132. // rqrq:首张确定仓库,后续标签仓库必须一致
  133. if (tableList.length > 0 && tableList[0].warehouseId !== partNoData.wareHouseId) {
  134. layer.msg("仓库与首张标签不一致,不能混仓其他出库!当前应扫仓库:" + tableList[0].warehouseId);
  135. return false;
  136. }
  137. var jsonData = {
  138. site : partNoData.site,
  139. warehouseId : partNoData.wareHouseId,
  140. batchNo : partNoData.batchNo,
  141. locationId : partNoData.locationId,
  142. partNo : partNoData.partNo,
  143. }
  144. $.ajax({
  145. url: "/pdaOrder/getInventoryStockDataForOut",
  146. contentType: 'application/json',
  147. type:"POST",
  148. data:JSON.stringify(jsonData),//你的formid
  149. dataType:"JSON",
  150. async: true,
  151. beforeSend: function(request) {
  152. request.setRequestHeader("token", $.cookie("token"));
  153. },
  154. success: function (data) {
  155. if(data.code == 0){
  156. var row = data.row;
  157. if(row != null && row.site != null){
  158. inventoryData = row;
  159. wareHouseId = row.warehouseId;
  160. initIssueModel();
  161. }else {
  162. layer.msg("仓库无此物料信息!");
  163. }
  164. }else {
  165. layer.confirm(data.msg, {
  166. btn: ['确定']
  167. }, function (index) {
  168. layer.close(index);
  169. });
  170. }
  171. },
  172. error: function(data) {
  173. var responseText = data.responseText;
  174. var json_str = JSON.parse(responseText);
  175. var status = json_str.status;
  176. var message = json_str.message;
  177. //判断是否是session超时
  178. if(403==status){
  179. layer.alert(message,function(){
  180. window.location.href="/login";
  181. });
  182. }
  183. layer.closeAll('loading');
  184. }
  185. })
  186. }
  187. function initIssueModel(){
  188. $("#qtyOut").val(inventoryData.qtyOnHand);
  189. if(inventoryData.weightFactor!='-1'&&inventoryData.weightFactor!='0'&&inventoryData.weightFactor!=''&&inventoryData.weightFactor!=null){
  190. $("#qtyOutKG").val((inventoryData.qtyOnHand*inventoryData.weightFactor).toFixed(1));
  191. $("#qtyOutKG").removeAttr("disabled");
  192. }else {
  193. $("#qtyOutKG").val('');
  194. $("#qtyOutKG").attr("disabled", "disabled");
  195. }
  196. $("#issue_modal").modal();
  197. }
  198. //失去焦点事件
  199. $('#qtyOutKG').blur(function () {
  200. let qtyOutKG=$('#qtyOutKG').val();
  201. let weightFactor=inventoryData.weightFactor;
  202. if(weightFactor!=0&&weightFactor!=-1&&qtyOutKG!=''){
  203. $('#qtyOut').val((qtyOutKG/weightFactor).toFixed(1))
  204. }
  205. })
  206. //失去焦点事件
  207. $('#qtyOut').blur(function () {
  208. let qtyOut=$('#qtyOut').val();
  209. let weightFactor=inventoryData.weightFactor;
  210. if(weightFactor!=0&&weightFactor!=-1&&qtyOut!=''){
  211. $('#qtyOutKG').val((qtyOut*weightFactor).toFixed(1))
  212. }
  213. })
  214. //模态框显示触发
  215. $("#issue_modal").on("shown.bs.modal",function(){
  216. $("#qtyOut").focus();
  217. });
  218. //模态框隐藏触发
  219. $("#issue_modal").on("hidden.bs.modal",function(){
  220. $("#partNo_search").val("").focus();
  221. });
  222. $("#qtyOut").bind("keydown",function(event){
  223. if (event.keyCode == 13) {
  224. saveTable();
  225. }
  226. });
  227. function saveTable(){
  228. var qtyOut = $("#qtyOut").val();
  229. if(qtyOut == null || qtyOut == "" || qtyOut <= 0){
  230. layer.msg("其他出库数量错误!");
  231. return false;
  232. }
  233. changeTableList();
  234. }
  235. //下级界面页面跳转
  236. function clearAll(){
  237. $("#wareHouse").val("")
  238. $("#remark").val("库存报废")
  239. $("#partNo_search").val("")
  240. $("#qtyOut").val("")
  241. $("#qtyOutKG").val("")
  242. tableList= []
  243. changeTable();
  244. }
  245. /**
  246. * rqrq:提交其他出库(Inventory_Create_TransHeader_other + 逐行 Out_other)
  247. */
  248. function saveData(){
  249. if (!tableList || tableList.length === 0) {
  250. layer.msg("请先扫描并添加出库明细");
  251. return;
  252. }
  253. var payload = {
  254. userName: userName,
  255. remark: ($("#remark").val() || ""),
  256. lines: tableList.map(function (r) {
  257. return {
  258. site: r.site,
  259. warehouseId: r.warehouseId,
  260. partNo: r.partNo,
  261. batchNo: r.batchNo,
  262. locationId: r.locationId,
  263. qtyOut: parseFloat(r.qtyOut)
  264. };
  265. })
  266. };
  267. if (payload.lines.some(function (x) { return isNaN(x.qtyOut) || x.qtyOut <= 0; })) {
  268. layer.msg("存在无效数量");
  269. return;
  270. }
  271. var loadIdx = layer.load(1, { shade: [0.2, '#000'] });
  272. console.log(payload);
  273. $.ajax({
  274. url: "/pda/stockOtherOut/save",
  275. contentType: "application/json",
  276. type: "POST",
  277. data: JSON.stringify(payload),
  278. dataType: "JSON",
  279. beforeSend: function (request) {
  280. request.setRequestHeader("token", $.cookie("token"));
  281. },
  282. success: function (data) {
  283. layer.close(loadIdx);
  284. if (data.code === 0) {
  285. layer.msg(data.msg || "保存成功");
  286. clearAll();
  287. } else {
  288. layer.msg(data.msg || "保存失败");
  289. }
  290. },
  291. error: function (xhr) {
  292. layer.close(loadIdx);
  293. var msg = "请求失败";
  294. try {
  295. var json = JSON.parse(xhr.responseText);
  296. if (json && json.msg) {
  297. msg = json.msg;
  298. }
  299. } catch (e) { }
  300. layer.msg(msg);
  301. if (xhr.status === 403) {
  302. layer.alert(msg, function () {
  303. window.location.href = "/login";
  304. });
  305. }
  306. }
  307. });
  308. }
  309. //初始化下拉框
  310. function selectInit(){
  311. $('.selectpicker').selectpicker({
  312. noneSelectedText: '',
  313. noneResultsText: '',
  314. liveSearch: true,
  315. width:140,
  316. size:5 //设置select高度,同时显示5个值
  317. });
  318. }