inventoryLocationMove.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. $(function() {
  2. var detailOperate = 'add';
  3. var $inventoryLocationMoveId= $("#inventoryLocationMoveForm").find("input[name='inventoryLocationMoveId']");
  4. /**
  5. * 跳转到明细页面
  6. */
  7. $("#addDetailBtn").bind("click",function() {
  8. if (operate == "add" && "" == ilmi) {
  9. $.messager.alert("提示", "请先填写基本信息", "error");
  10. }
  11. else{
  12. if (4902 == $("input[name='locationMoveStatus']").val()){
  13. showMsg('提示', '状态为完成,不允许新增明细信息');
  14. }
  15. else {
  16. showWindow({
  17. title:'新增明细',
  18. width:800,
  19. height:350,
  20. closed : false,
  21. cache : false,
  22. modal : true,
  23. onOpen:function() {
  24. document.getElementById("addDetailTabs").style.display="";
  25. $("#inventoryLocationMoveDetailForm").form('clear');
  26. detailOperate = 'add';
  27. }
  28. });
  29. }
  30. }
  31. });
  32. // 保存明细的方法
  33. $("#submitDetailBtn").click(function() {
  34. if ($("#inventoryLocationMoveDetailForm").form('validate')) {
  35. var postData = {
  36. formData: $.encodeJSON($("#inventoryLocationMoveDetailForm").getFormValue()),
  37. updateFields : JSON.stringify($.InventoryLocationMoveDetailEdit.changeList),
  38. inventoryLocationMoveId : $("input[name='inventoryLocationMoveId']").val(),
  39. operate : detailOperate
  40. };
  41. ajaxRequest(WEBROOT + '/InventoryLocationMove/doSaveDetail.action', postData, function(response) {
  42. if (response.code == "success") {// succeed
  43. showMsg('提示', '保存成功');
  44. $("#detailList").datagrid({
  45. width : '90%',
  46. checkOnSelect:true,
  47. nowrap : false,
  48. striped : true,
  49. collapsible : false,
  50. fitColumns : true,
  51. idField : 'id',
  52. url : WEBROOT + '/InventoryLocationMove/showDetailList.action',
  53. queryParams : {
  54. inventoryMoveId: $inventoryLocationMoveId.val()
  55. },
  56. remoteSort : true,
  57. rownumbers : true,
  58. onDblClickRow : function(index,rowdata){
  59. if($inventoryLocationMoveId.val() == "") {
  60. $.messager.alert("提示", "请先保存基本信息", "error");
  61. } else {
  62. showWindow({
  63. title:'详细明细',
  64. width:950,
  65. height:400,
  66. onOpen:function() {
  67. ajaxRequest(WEBROOT + "/InventoryLocationMove/showDetailEdit.action", {
  68. id : rowdata.id
  69. }, function(data) {
  70. $.InventoryLocationMoveDetailEdit.fillData(data);
  71. // if(4901 == $("#inventoryLocationMoveForm").find("input[name='locationMoveStatus']").val()){
  72. // $('#moveType').combobox({
  73. // disabled : true
  74. // });
  75. //
  76. // $("#isCachedMove").attr('disabled',true);
  77. // $("#locationContainerId").attr('disabled',true);
  78. // }
  79. detailOperate = 'edit';
  80. var moveType = data.moveType;
  81. if (1201 == moveType){
  82. $('#itemZeroTr').show();
  83. $('#quantityTd').show();
  84. $('#quantity').show();
  85. $('#itemOneTr').show();
  86. $('#itemTwoTr').show();
  87. $('#itemThreeTr').show();
  88. $('#itemFourTr').hide();
  89. $('#SnTr').hide();
  90. $('#addHandeleDetailBtn').show();
  91. $('#locationMoveQuantity').numberbox({
  92. required: true,
  93. value: 1
  94. });
  95. $('#scanType').combobox({
  96. required: false
  97. });
  98. $('#itemLocation').combobox({
  99. required: false
  100. });
  101. }
  102. else if(1202 == moveType){
  103. $('#itemZeroTr').hide();
  104. $('#itemOneTr').hide();
  105. $('#itemTwoTr').show();
  106. $('#itemThreeTr').hide();
  107. $('#itemFourTr').hide();
  108. $('#SnTr').show();
  109. $('#addHandeleDetailBtn').hide();
  110. $('#locationMoveQuantity').numberbox({
  111. required: false,
  112. value: 0
  113. });
  114. $('#scanType').combobox({
  115. required: true
  116. });
  117. $('#itemLocation').combobox({
  118. required: false
  119. });
  120. }
  121. else{
  122. $('#itemZeroTr').show();
  123. $('#quantityTd').hide();
  124. $('#quantity').hide();
  125. $('#itemOneTr').hide();
  126. $('#itemTwoTr').show();
  127. $('#SnTr').hide();
  128. $('#addHandeleDetailBtn').hide();
  129. $('#locationMoveQuantity').numberbox({
  130. required: false,
  131. value: 0
  132. });
  133. $('#itemThreeTr').hide();
  134. $('#itemFourTr').show();
  135. $('#scanType').combobox({
  136. required: false
  137. });
  138. }
  139. });
  140. }
  141. });
  142. }
  143. }
  144. });
  145. } else {
  146. var errorDesc = response.errorDesc;
  147. showMsg('保存失败', errorDesc);
  148. };
  149. });
  150. // 关闭窗口前,回复明细的操作符为新增
  151. detailOperate = 'add';
  152. closeWindow();
  153. }
  154. });
  155. // 删除明细的方法
  156. $("#removeDetailBtn").click(function() {
  157. if (4902 == $("input[name='locationMoveStatus']").val()){
  158. showMsg('提示', '状态为完成,不允许删除明细信息');
  159. }
  160. else {
  161. var rows = $("#detailList").datagrid('getSelections');
  162. var ids = [];
  163. for ( var i = 0; i < rows.length; i++) {
  164. if (rows[i].id) {
  165. ids.push(rows[i].id);
  166. }
  167. }
  168. if (ids.length > 0) {
  169. $.messager.confirm('提示', '共选择:' + ids.length + '条记录,确定要删除吗?',
  170. function(result) {
  171. if (result) {
  172. ajaxRequest(WEBROOT + "/InventoryLocationMove/doDeleteDetail.action", {
  173. ids : $.encodeJSON(ids),
  174. locationMoveStatus : $("input[name='locationMoveStatus']").val()
  175. }, function(data) {
  176. $("#detailList").datagrid('reload');
  177. showMsg('提示', '删除成功');
  178. });
  179. }
  180. });
  181. } else {
  182. $.messager.alert("提示", "请选择要删除的行", "error");
  183. }
  184. }
  185. });
  186. /**
  187. * 明细列表的展示
  188. */
  189. $("#detailList").datagrid({
  190. width : '90%',
  191. checkOnSelect:true,
  192. nowrap : false,
  193. striped : true,
  194. collapsible : false,
  195. fitColumns : true,
  196. pagination : true,
  197. pageSize : 5,
  198. idField : 'id',
  199. url : WEBROOT + '/InventoryLocationMove/showDetailList.action',
  200. queryParams : {
  201. inventoryMoveId: $inventoryLocationMoveId.val()
  202. },
  203. remoteSort : true,
  204. rownumbers : true,
  205. pageList : [ 5, 10, 20, 30, 50, 100 ],
  206. onDblClickRow : function(index,rowdata){
  207. if($inventoryLocationMoveId.val() == "") {
  208. $.messager.alert("提示", "请先保存基本信息", "error");
  209. } else {
  210. showWindow({
  211. title:'详细明细',
  212. width:950,
  213. height:400,
  214. onOpen:function() {
  215. document.getElementById("addDetailTabs").style.display="";
  216. ajaxRequest(WEBROOT + "/InventoryLocationMove/showDetailEdit.action", {
  217. id : rowdata.id
  218. }, function(data) {
  219. $.InventoryLocationMoveDetailEdit.fillData(data);
  220. // if(4901 == $("#inventoryLocationMoveForm").find("input[name='locationMoveStatus']").val()){
  221. // $('#moveType').combobox({
  222. // disabled : true
  223. // });
  224. //
  225. // $("#isCachedMove").attr('disabled',true);
  226. // $("#locationContainerId").attr('disabled',true);
  227. // }
  228. detailOperate = 'edit';
  229. var moveType = data.moveType;
  230. if (1201 == moveType){
  231. $('#itemZeroTr').show();
  232. $('#quantityTd').show();
  233. $('#quantity').show();
  234. $('#itemOneTr').show();
  235. $('#itemTwoTr').show();
  236. $('#itemThreeTr').show();
  237. $('#itemFourTr').hide();
  238. $('#SnTr').hide();
  239. $('#addHandeleDetailBtn').show();
  240. $('#locationMoveQuantity').numberbox({
  241. required: true,
  242. value: 1
  243. });
  244. $('#scanType').combobox({
  245. required: false
  246. });
  247. $('#itemLocation').combobox({
  248. required: false
  249. });
  250. }
  251. else if(1202 == moveType){
  252. $('#itemZeroTr').hide();
  253. $('#itemOneTr').hide();
  254. $('#itemTwoTr').show();
  255. $('#itemThreeTr').hide();
  256. $('#itemFourTr').hide();
  257. $('#SnTr').show();
  258. $('#addHandeleDetailBtn').hide();
  259. $('#locationMoveQuantity').numberbox({
  260. required: false,
  261. value: 0
  262. });
  263. $('#scanType').combobox({
  264. required: true
  265. });
  266. $('#itemLocation').combobox({
  267. required: false
  268. });
  269. }
  270. else{
  271. $('#itemZeroTr').show();
  272. $('#quantityTd').hide();
  273. $('#quantity').hide();
  274. $('#itemOneTr').hide();
  275. $('#itemTwoTr').show();
  276. $('#SnTr').hide();
  277. $('#addHandeleDetailBtn').hide();
  278. $('#locationMoveQuantity').numberbox({
  279. required: false,
  280. value: 0
  281. });
  282. $('#itemThreeTr').hide();
  283. $('#itemFourTr').show();
  284. $('#scanType').combobox({
  285. required: false
  286. });
  287. }
  288. });
  289. }
  290. });
  291. }
  292. }
  293. });
  294. var isCachedMove = "";
  295. /**
  296. * 弹出处理明细页面
  297. */
  298. $("#addHandeleDetailBtn").bind("click",function() {
  299. var isCachedMove = document.getElementsByName("isCachedMove");
  300. $('#addHandleDetail').window({
  301. title : '获取明细',
  302. width : 800,
  303. height : 350,
  304. closed : false,
  305. cache : false,
  306. modal : true
  307. });
  308. // 查询库存明细的URL
  309. var locationContainerSearchUrl = WEBROOT + '/InventoryLocationMove/doSearchLocationContainer.action';
  310. locationContainerSearchUrl = locationContainerSearchUrl.format('LocationContainer');
  311. // 查询库存明细的参数
  312. var queryParams = {
  313. inventoryLocationMoveId : $inventoryLocationMoveId.val(),
  314. locationName : "",
  315. itemName : $("#locationContainerSearchForm").find("input[name=queryItemName]").val(),
  316. itemCode : $("#locationContainerSearchForm").find("input[name=queryItemCode]").val(),
  317. isCachedMove : isCachedMove[0].checked
  318. };
  319. $("#locationContainerList").datagrid({
  320. width : '100%',
  321. checkOnSelect:true,
  322. nowrap : false,
  323. striped : true,
  324. collapsible : false,
  325. fitColumns : true,
  326. pagination : true,
  327. singleSelect : true,
  328. pageSize : 5,
  329. idField : 'id',
  330. url : locationContainerSearchUrl,
  331. queryParams : queryParams,
  332. remoteSort : true,
  333. rownumbers : true,
  334. pageList : [ 5, 10, 20, 30, 50, 100 ]
  335. });
  336. });
  337. // 处理明细的按钮查询事件
  338. $("#locationContainerSearch").bind("click",function() {
  339. var queryLocationName = $("#locationContainerSearchForm").find("input[name='queryLocationName']").val();
  340. $("#locationContainerList").datagrid('load', {
  341. inventoryLocationMoveId : $inventoryLocationMoveId.val(),
  342. locationName : queryLocationName,
  343. itemName : $("#locationContainerSearchForm").find("input[name=queryItemName]").val(),
  344. itemCode : $("#locationContainerSearchForm").find("input[name=queryItemCode]").val(),
  345. isCachedMove : isCachedMove
  346. });
  347. });
  348. /**
  349. * 最后弹出窗口输入数量和新储位
  350. */
  351. $("#submitHandeleDetailBtn").bind("click",function() {
  352. var rows = $("#locationContainerList").datagrid('getSelections');
  353. var ids = [];
  354. for ( var i = 0; i < rows.length; i++) {
  355. if (rows[i].id) {
  356. ids.push(rows[i].id);
  357. }
  358. }
  359. if (ids.length != 1) {
  360. $.messager.alert("提示", "请选择一条具体明细", "error");
  361. }else{
  362. $('#addHandleDetail').window('close');
  363. $('#inventoryLocationMoveDetailForm').form('load',{
  364. locationContainerId:rows[0].id,
  365. quantity:rows[0].usableQuantity,
  366. locationName:rows[0].locationName,
  367. itemId:rows[0].itemId,
  368. itemName:rows[0].itemName,
  369. itemCode:rows[0].itemCode,
  370. customerId:rows[0].customerId,
  371. customerCode:rows[0].customerCode,
  372. customerName:rows[0].customerName,
  373. zoneId:rows[0].zoneId,
  374. zoneName:rows[0].zoneName,
  375. relationedCustomerId:rows[0].relationedCustomerId,
  376. relationedCustomerCode:rows[0].relationedCustomerCode,
  377. relationedCustomerName:rows[0].relationedCustomerName,
  378. warehouseId:rows[0].warehouseId,
  379. warehouseName:rows[0].warehouseName,
  380. lotNumber:rows[0].lotNumber,
  381. normalFlag:rows[0].normalFlag
  382. });
  383. $('#locationId').combogrid('setValue', rows[0].locationName);
  384. ajaxRequest(WEBROOT + "/InventoryLocationMove/findLocationByItem.action", {
  385. itemId : rows[0].itemId
  386. }, function(data) {
  387. if(data.code == "success"){
  388. $('#toLocationId').combogrid('setValue', data.data.locationId).combogrid('setText', data.data.locationName);
  389. }
  390. });
  391. }
  392. });
  393. /**
  394. * 保存或修改处理明细至DB
  395. */
  396. $("#submitHandleDetailBtn").bind("click",function(){
  397. });
  398. // 删除处理明细的方法
  399. $("#removeHandleDetailBtn").click(function() {
  400. var rows = $("#handeleDetailList").datagrid('getSelections');
  401. var ids = [];
  402. for ( var i = 0; i < rows.length; i++) {
  403. if (rows[i].id) {
  404. ids.push(rows[i].id);
  405. }
  406. }
  407. if (ids.length > 0) {
  408. $.messager.confirm('提示', '共选择:' + ids.length + '条记录,确定要删除吗?',
  409. function(result) {
  410. if (result) {
  411. ajaxRequest(WEBROOT + "/InventoryLocationMove/doDeleteHandleDetail.action", {
  412. ids : $.encodeJSON(ids)
  413. }, function(data) {
  414. $("#handeleDetailList").datagrid('reload');
  415. showMsg('提示', '删除成功');
  416. });
  417. }
  418. });
  419. } else {
  420. $.messager.alert("提示", "请选择要删除的行", "error");
  421. }
  422. });
  423. // 新增明细:移库类型选择触发事件
  424. $('#moveType').combobox({
  425. onSelect: function(param){
  426. var moveType = $("#inventoryLocationMoveDetailForm").find("input[name='moveType']").val();
  427. if (1201 == moveType){
  428. $('#itemZeroTr').show();
  429. $('#quantityTd').show();
  430. $('#quantity').show();
  431. $('#itemOneTr').show();
  432. $('#itemTwoTr').show();
  433. $('#itemThreeTr').show();
  434. $('#itemFourTr').hide();
  435. $('#SnTr').hide();
  436. $('#addHandeleDetailBtn').show();
  437. $('#locationMoveQuantity').numberbox({
  438. required: true,
  439. value: 1
  440. });
  441. $('#scanType').combobox({
  442. required: false
  443. });
  444. $('#itemLocation').combobox({
  445. required: false
  446. });
  447. }
  448. else if(1202 == moveType){
  449. $('#itemZeroTr').hide();
  450. $('#itemOneTr').hide();
  451. $('#itemTwoTr').show();
  452. $('#itemThreeTr').hide();
  453. $('#itemFourTr').hide();
  454. $('#SnTr').show();
  455. $('#addHandeleDetailBtn').hide();
  456. $('#locationMoveQuantity').numberbox({
  457. required: false,
  458. value: 0
  459. });
  460. $('#scanType').combobox({
  461. required: true
  462. });
  463. $('#itemLocation').combobox({
  464. required: false
  465. });
  466. }
  467. else{
  468. $('#itemZeroTr').show();
  469. $('#quantityTd').hide();
  470. $('#quantity').hide();
  471. $('#itemOneTr').hide();
  472. $('#itemTwoTr').show();
  473. $('#SnTr').hide();
  474. $('#addHandeleDetailBtn').hide();
  475. $('#locationMoveQuantity').numberbox({
  476. required: false,
  477. value: 0
  478. });
  479. $('#itemThreeTr').hide();
  480. $('#itemFourTr').show();
  481. $('#scanType').combobox({
  482. required: false
  483. });
  484. }
  485. },
  486. onBeforeLoad:function(){
  487. $('#itemZeroTr').show();
  488. $('#itemOneTr').show();
  489. $('#itemTwoTr').show();
  490. $('#itemThreeTr').show();
  491. $('#itemFourTr').hide();
  492. $('#SnTr').hide();
  493. $('#addHandeleDetailBtn').show();
  494. $('#locationMoveQuantity').numberbox({
  495. required: true,
  496. value: 1
  497. });
  498. $('#scanType').combobox({
  499. required: false
  500. });
  501. }
  502. });
  503. });