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

385 lines
13 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years 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 wareHouseList = new Array();
  7. var wareHouseData = null;
  8. var batchType = "";
  9. //页面初始化
  10. $(function(){
  11. if(titleName != null && titleName != ""){
  12. $("#titleName").text(titleName);
  13. }else {
  14. window.location.href="/login";
  15. }
  16. var workData = $.cookie("production");
  17. if(workData != null && workData !==""){
  18. currentData = JSON.parse(workData);
  19. }
  20. InfoDates("warehousingDate");
  21. getWarehouse()
  22. getSOTask()
  23. getBatchType()
  24. // 初始化光标
  25. $("#orderNo_search").focus();
  26. });
  27. // 获取日记话
  28. function getSOTask(){
  29. let jsonData = {
  30. site : site,
  31. orderNo : currentData.orderNo,
  32. }
  33. $.ajax({
  34. url: "/pdaOrder/getSOTask",
  35. contentType: 'application/json',
  36. type:"POST",
  37. data:JSON.stringify(jsonData),//你的formid
  38. dataType:"JSON",
  39. beforeSend: function(request) {
  40. request.setRequestHeader("token", $.cookie("token"));
  41. },
  42. success: function (data) {
  43. var sotaskList = data.rows;
  44. if(sotaskList != null && sotaskList.length > 0){
  45. console.log(sotaskList)
  46. var sOTaskTags = '';
  47. for(var i = 0; i< sotaskList.length; i++){
  48. console.log(sotaskList[i])
  49. console.log(sotaskList[i].orderNo)
  50. sOTaskTags += '<option>'+sotaskList[i].orderNo+'</option>';
  51. }
  52. $("#soTaskNo").html(sOTaskTags).change();
  53. }
  54. },
  55. error: function(data) {
  56. var responseText = data.responseText;
  57. var json_str = JSON.parse(responseText);
  58. var status = json_str.status;
  59. var message = json_str.message;
  60. //判断是否是session超时
  61. if(403==status){
  62. layer.alert(message,function(){
  63. window.location.href="/login";
  64. });
  65. }
  66. layer.closeAll('loading');
  67. }
  68. })
  69. }
  70. // 获取库位信息
  71. function getWarehouse(){
  72. let jsonData = {
  73. site : site,
  74. userId : userId,
  75. functionName : "Get_Users_AccessWarehouse_List",
  76. }
  77. $.ajax({
  78. url: "/pdaOrder/getUsersAccessWarehouseList",
  79. contentType: 'application/json',
  80. type:"POST",
  81. data:JSON.stringify(jsonData),//你的formid
  82. dataType:"JSON",
  83. beforeSend: function(request) {
  84. request.setRequestHeader("token", $.cookie("token"));
  85. },
  86. success: function (data) {
  87. var list = data.rows;
  88. if(list != null && list.length > 0){
  89. wareHouseList = list;
  90. var departmentTags = '';
  91. for(var i = 0; i< list.length; i++){
  92. if(list[i].Active != null && list[i].Active === "Y" && list[i].WareHouseType_DB != null && list[i].WareHouseType_DB === "P"){
  93. departmentTags += '<option value="'+list[i].WareHouseID+'">'+list[i].WareHouseName+'</option>';
  94. }
  95. }
  96. $("#warehouse_id").html(departmentTags).change();
  97. }
  98. },
  99. error: function(data) {
  100. var responseText = data.responseText;
  101. var json_str = JSON.parse(responseText);
  102. var status = json_str.status;
  103. var message = json_str.message;
  104. //判断是否是session超时
  105. if(403==status){
  106. layer.alert(message,function(){
  107. window.location.href="/login";
  108. });
  109. }
  110. layer.closeAll('loading');
  111. }
  112. })
  113. }
  114. // 获取批号信息
  115. function getBatchType(){
  116. let jsonData = {
  117. site : site,
  118. partNo : currentData.partNo,
  119. functionName : "dbo.Get_Part_BatchCreatedMethod",
  120. }
  121. $.ajax({
  122. url: "/pdaOrder/getPartBatchCreatedMethod",
  123. contentType: 'application/json',
  124. type:"POST",
  125. data:JSON.stringify(jsonData),//你的formid
  126. dataType:"JSON",
  127. beforeSend: function(request) {
  128. request.setRequestHeader("token", $.cookie("token"));
  129. },
  130. success: function (data) {
  131. if(data.code == 0){
  132. batchType = data.result;
  133. $("#batchNo").val("");
  134. if(batchType == "基于入库单单号" || batchType == "基于入库时间" ||batchType == "不采用批号"){
  135. $('#batchNo').attr("disabled",true);
  136. }else if(batchType == "不采用批号"){
  137. $("#batchNo").val("*");
  138. $('#batchNo').attr("disabled",true);
  139. }else {
  140. $('#batchNo').attr("disabled",false);
  141. }
  142. }
  143. },
  144. error: function(data) {
  145. var responseText = data.responseText;
  146. var json_str = JSON.parse(responseText);
  147. var status = json_str.status;
  148. var message = json_str.message;
  149. //判断是否是session超时
  150. if(403==status){
  151. layer.alert(message,function(){
  152. window.location.href="/login";
  153. });
  154. }
  155. layer.closeAll('loading');
  156. }
  157. })
  158. }
  159. //为报废原因绑定一个失去焦点事件
  160. $("#warehouse_id").change(function() {
  161. var warehouseId = $(this).val();
  162. for (var i = 0; i < wareHouseList.length; i++) {
  163. if(wareHouseList[i].WareHouseID == warehouseId){
  164. $("#locationId").val("");
  165. wareHouseData = wareHouseList[i];
  166. if(wareHouseList[i].UseLocation != null && wareHouseList[i].UseLocation === "Y"){
  167. $("#locationId").val("");
  168. $('#locationNo').attr("disabled",false);
  169. }else {
  170. $("#locationId").val("*");
  171. $('#locationNo').attr("disabled",true);
  172. }
  173. break
  174. }
  175. }
  176. })
  177. // 获取获取工具实例编码
  178. function receiveFlag(){
  179. var warehouseDate = $("#warehousingDate").val();
  180. var warehouseQty = $("#warehouseQty").val();
  181. var warehouseId = $("#warehouse_id").val();
  182. var locationId = $("#locationId").val();
  183. var batchNo = $("#batchNo").val();
  184. var soTaskNo = $("#soTaskNo").val();
  185. if(warehouseDate == null || warehouseDate === ""){
  186. layer.msg("请选择入库日期!");
  187. return false
  188. }
  189. if(warehouseQty == null || warehouseQty === "" || warehouseQty <=0){
  190. layer.msg("请输入入库数量!");
  191. return false
  192. }
  193. if(soTaskNo == null || soTaskNo === ""){
  194. layer.msg("请选择日计划单号!");
  195. return false
  196. }
  197. if(warehouseId == null || warehouseId === ""){
  198. layer.msg("请选择仓库!");
  199. return false
  200. }
  201. if( wareHouseData.UseLocation === "Y" &&(locationId == null || locationId === "")){
  202. layer.msg("请输入库位!");
  203. return false
  204. }
  205. if(batchType != "基于入库单单号" && batchType != "基于入库时间" && batchType != "不采用批号"){
  206. if(batchNo == null || batchNo === ""){
  207. layer.msg("请输入批号!");
  208. return false
  209. }
  210. }
  211. let jsonData = {
  212. site : site,
  213. /*warehouseDate : warehouseDate,
  214. warehouseId : warehouseId,
  215. locationId : locationId,
  216. batchNo : batchNo,
  217. remark : remark,*/
  218. transQty : warehouseQty,
  219. functionName : "SO_Receive_FG_Confirm",
  220. orderNo : currentData.orderNo,
  221. }
  222. $.ajax({
  223. url: "/pdaOrder/getSOReceiveFGConfirm",
  224. contentType: 'application/json',
  225. type:"POST",
  226. data:JSON.stringify(jsonData),//你的formid
  227. dataType:"JSON",
  228. beforeSend: function(request) {
  229. request.setRequestHeader("token", $.cookie("token"));
  230. },
  231. success: function (data) {
  232. if(data.code == 200){
  233. saveProduction()
  234. }else {
  235. layer.confirm(data.msg, {
  236. btn : [ '确定', '取消' ]
  237. // 按钮
  238. }, function() {
  239. saveProduction();
  240. }, function() {
  241. });
  242. }
  243. },
  244. error: function(data) {
  245. var responseText = data.responseText;
  246. var json_str = JSON.parse(responseText);
  247. var status = json_str.status;
  248. var message = json_str.message;
  249. //判断是否是session超时
  250. if(403==status){
  251. layer.alert(message,function(){
  252. window.location.href="/login";
  253. });
  254. }
  255. layer.closeAll('loading');
  256. }
  257. })
  258. }
  259. // 获取获取工具实例编码
  260. function saveProduction(){
  261. var warehouseDate = $("#warehousingDate").val();
  262. var warehouseQty = $("#warehouseQty").val();
  263. var warehouseId = $("#warehouse_id").val();
  264. var locationId = $("#locationId").val();
  265. var batchNo = $("#batchNo").val();
  266. var remark = $("#remark").val();
  267. let jsonData = {
  268. site : site,
  269. orderNo : currentData.orderNo,
  270. transDate : warehouseDate,
  271. warehouseId : warehouseId,
  272. partnerId : "",
  273. partNo : currentData.partNo,
  274. batchNo : batchNo,
  275. locationId : locationId,
  276. transQty : warehouseQty,
  277. userId : userId,
  278. receiver : userName,
  279. remark : remark,
  280. soTaskNo: $("#soTaskNo").val(),
  281. functionName : "[dbo].[SO_Receive_FG_Hunlian]",
  282. }
  283. $.ajax({
  284. url: "/pdaOrder/saveSOReceiveFGHunlian",
  285. contentType: 'application/json',
  286. type:"POST",
  287. data:JSON.stringify(jsonData),//你的formid
  288. dataType:"JSON",
  289. beforeSend: function(request) {
  290. request.setRequestHeader("token", $.cookie("token"));
  291. },
  292. success: function (data) {
  293. // layer.msg(data.msg);
  294. if(data.code == 200){
  295. // cleanInput()
  296. pdaBaseJump2()
  297. }
  298. },
  299. error: function(data) {
  300. var responseText = data.responseText;
  301. var json_str = JSON.parse(responseText);
  302. var status = json_str.status;
  303. var message = json_str.message;
  304. //判断是否是session超时
  305. if(403==status){
  306. layer.alert(message,function(){
  307. window.location.href="/login";
  308. });
  309. }
  310. layer.closeAll('loading');
  311. }
  312. })
  313. }
  314. function cleanInput(){
  315. $("#warehouseQty").val(0);
  316. $("#batchNo").val("");
  317. $("#remark").val("");
  318. $("#warehouse_id option:first").prop("selected", 'selected').change();
  319. }
  320. //下级界面页面跳转
  321. function pdaBaseJump(){
  322. var menuId = $("#menuId").val();
  323. var titleName = $("#current_titleName").val();
  324. window.location.href = "/pda/hunlianWarehousing?menuId=" +menuId +"&titleName=" +titleName;
  325. }
  326. //下级界面页面跳转
  327. function pdaBaseJump2(){
  328. var menuId = $("#menuId").val();
  329. var titleName = '不要缓存';
  330. window.location.href = "/pda/hunlianWarehousing?menuId=" +menuId +"&titleName=" +titleName;
  331. }
  332. function InfoDates(date){
  333. var default_date = getNowFormatDate();
  334. $("#" + date).val(default_date);
  335. //初始化模态框的日期
  336. $.fn.datetimepicker.dates['zh-CN'] = {
  337. days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
  338. daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
  339. daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
  340. months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
  341. monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
  342. today: "今天",
  343. suffix: [],
  344. meridiem: ["上午", "下午"]
  345. };
  346. $("#"+date).datetimepicker({
  347. format : 'yyyy-mm-dd',//显示格式
  348. maxView : 4,//最高能展示的时间,Number, String类型 默认值:4, 年
  349. minView : 2,//日期时间选择器所能够提供的最精确的时间选择视图
  350. autoclose : true,//选择后自动关闭
  351. todayBtn : true,//开启选择今天的按钮
  352. todayHighlight: true,//今天日期高亮显示 如果为true, 高亮当前日期。Boolean类型 ,默认值:false ,
  353. language : 'zh-CN'//语言选择中文
  354. });
  355. }
  356. //初始化下拉框
  357. function selectInit(){
  358. $('.selectpicker').selectpicker({
  359. noneSelectedText: '',
  360. noneResultsText: '',
  361. liveSearch: true,
  362. width:140,
  363. size:5 //设置select高度,同时显示5个值
  364. });
  365. }