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

307 lines
7.5 KiB

4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks 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: 15%;">' +
  42. '<span>'+tableList[i].partNo+'</span></th>' +
  43. '<th class="" style="text-align:center;background-color: #ffff;width: 10%;">' +
  44. '<span>'+tableList[i].qtyOut+'</span></th>' +
  45. '<th class="" style="text-align:center;background-color: #ffff;width: 15%;">' +
  46. '<span>'+tableList[i].batchNo+'</span></th>' +
  47. '<th class="" style="text-align:center;background-color: #ffff;width: 15%;">' +
  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. getInventoryData()
  91. }
  92. function getInventoryData(){
  93. // rqrq:首张确定仓库,后续标签仓库必须一致
  94. if (tableList.length > 0 && tableList[0].warehouseId !== partNoData.wareHouseId) {
  95. layer.msg("仓库与首张标签不一致,不能混仓其他出库!当前应扫仓库:" + tableList[0].warehouseId);
  96. return false;
  97. }
  98. var jsonData = {
  99. site : partNoData.site,
  100. warehouseId : partNoData.wareHouseId,
  101. batchNo : partNoData.batchNo,
  102. locationId : partNoData.locationId,
  103. partNo : partNoData.partNo,
  104. }
  105. $.ajax({
  106. url: "/pdaOrder/getInventoryStockDataForOut",
  107. contentType: 'application/json',
  108. type:"POST",
  109. data:JSON.stringify(jsonData),//你的formid
  110. dataType:"JSON",
  111. async: true,
  112. beforeSend: function(request) {
  113. request.setRequestHeader("token", $.cookie("token"));
  114. },
  115. success: function (data) {
  116. if(data.code == 0){
  117. var row = data.row;
  118. if(row != null && row.site != null){
  119. inventoryData = row;
  120. wareHouseId = row.warehouseId;
  121. initIssueModel();
  122. }else {
  123. layer.msg("仓库无此物料信息!");
  124. }
  125. }else {
  126. layer.confirm(data.msg, {
  127. btn: ['确定']
  128. }, function (index) {
  129. layer.close(index);
  130. });
  131. }
  132. },
  133. error: function(data) {
  134. var responseText = data.responseText;
  135. var json_str = JSON.parse(responseText);
  136. var status = json_str.status;
  137. var message = json_str.message;
  138. //判断是否是session超时
  139. if(403==status){
  140. layer.alert(message,function(){
  141. window.location.href="/login";
  142. });
  143. }
  144. layer.closeAll('loading');
  145. }
  146. })
  147. }
  148. function initIssueModel(){
  149. $("#qtyOut").val(inventoryData.qtyOnHand);
  150. if(inventoryData.weightFactor!='-1'&&inventoryData.weightFactor!='0'&&inventoryData.weightFactor!=''&&inventoryData.weightFactor!=null){
  151. $("#qtyOutKG").val((inventoryData.qtyOnHand*inventoryData.weightFactor).toFixed(1));
  152. $("#qtyOutKG").removeAttr("disabled");
  153. }else {
  154. $("#qtyOutKG").val('');
  155. $("#qtyOutKG").attr("disabled", "disabled");
  156. }
  157. $("#issue_modal").modal();
  158. }
  159. //失去焦点事件
  160. $('#qtyOutKG').blur(function () {
  161. let qtyOutKG=$('#qtyOutKG').val();
  162. let weightFactor=inventoryData.weightFactor;
  163. if(weightFactor!=0&&weightFactor!=-1&&qtyOutKG!=''){
  164. $('#qtyOut').val((qtyOutKG/weightFactor).toFixed(1))
  165. }
  166. })
  167. //失去焦点事件
  168. $('#qtyOut').blur(function () {
  169. let qtyOut=$('#qtyOut').val();
  170. let weightFactor=inventoryData.weightFactor;
  171. if(weightFactor!=0&&weightFactor!=-1&&qtyOut!=''){
  172. $('#qtyOutKG').val((qtyOut*weightFactor).toFixed(1))
  173. }
  174. })
  175. //模态框显示触发
  176. $("#issue_modal").on("shown.bs.modal",function(){
  177. $("#qtyOut").focus();
  178. });
  179. //模态框隐藏触发
  180. $("#issue_modal").on("hidden.bs.modal",function(){
  181. $("#partNo_search").val("").focus();
  182. });
  183. $("#qtyOut").bind("keydown",function(event){
  184. if (event.keyCode == 13) {
  185. saveTable();
  186. }
  187. });
  188. function saveTable(){
  189. var qtyOut = $("#qtyOut").val();
  190. if(qtyOut == null || qtyOut == "" || qtyOut <= 0){
  191. layer.msg("其他出库数量错误!");
  192. return false;
  193. }
  194. changeTableList();
  195. }
  196. //下级界面页面跳转
  197. function clearAll(){
  198. $("#wareHouse").val("")
  199. $("#remark").val("库存报废")
  200. $("#partNo_search").val("")
  201. $("#qtyOut").val("")
  202. $("#qtyOutKG").val("")
  203. tableList= []
  204. changeTable();
  205. }
  206. /**
  207. * rqrq提交其他出库Inventory_Create_TransHeader_other + 逐行 Out_other
  208. */
  209. function saveData(){
  210. if (!tableList || tableList.length === 0) {
  211. layer.msg("请先扫描并添加出库明细");
  212. return;
  213. }
  214. var payload = {
  215. userName: userName,
  216. remark: ($("#remark").val() || ""),
  217. lines: tableList.map(function (r) {
  218. return {
  219. site: r.site,
  220. warehouseId: r.warehouseId,
  221. partNo: r.partNo,
  222. batchNo: r.batchNo,
  223. locationId: r.locationId,
  224. qtyOut: parseFloat(r.qtyOut)
  225. };
  226. })
  227. };
  228. if (payload.lines.some(function (x) { return isNaN(x.qtyOut) || x.qtyOut <= 0; })) {
  229. layer.msg("存在无效数量");
  230. return;
  231. }
  232. var loadIdx = layer.load(1, { shade: [0.2, '#000'] });
  233. console.log(payload);
  234. $.ajax({
  235. url: "/pda/stockOtherOut/save",
  236. contentType: "application/json",
  237. type: "POST",
  238. data: JSON.stringify(payload),
  239. dataType: "JSON",
  240. beforeSend: function (request) {
  241. request.setRequestHeader("token", $.cookie("token"));
  242. },
  243. success: function (data) {
  244. layer.close(loadIdx);
  245. if (data.code === 0) {
  246. layer.msg(data.msg || "保存成功");
  247. clearAll();
  248. } else {
  249. layer.msg(data.msg || "保存失败");
  250. }
  251. },
  252. error: function (xhr) {
  253. layer.close(loadIdx);
  254. var msg = "请求失败";
  255. try {
  256. var json = JSON.parse(xhr.responseText);
  257. if (json && json.msg) {
  258. msg = json.msg;
  259. }
  260. } catch (e) { }
  261. layer.msg(msg);
  262. if (xhr.status === 403) {
  263. layer.alert(msg, function () {
  264. window.location.href = "/login";
  265. });
  266. }
  267. }
  268. });
  269. }
  270. //初始化下拉框
  271. function selectInit(){
  272. $('.selectpicker').selectpicker({
  273. noneSelectedText: '',
  274. noneResultsText: '',
  275. liveSearch: true,
  276. width:140,
  277. size:5 //设置select高度,同时显示5个值
  278. });
  279. }