stockTakingPlanEdit.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. $(function() {
  2. var $stockTakingPlanForm = $('#stockTakingPlanForm');
  3. var $itemSearchForm = $('#itemListSearchForm');
  4. var $locationSearchForm = $('#locationListSearchForm');
  5. var $stockTakingPlanId = $stockTakingPlanForm.find("input[name='stockTakingPlanId']");
  6. var $itemLocationFlag = $("#itemLocationFlag").combobox("getValue");
  7. /**
  8. * 盘点的产品:添加
  9. */
  10. $("#addItemBtn").bind("click",function() {
  11. if($itemLocationFlag == 3){
  12. $.messager.alert('提示','不允许再次添加盘点产品');
  13. }else{
  14. var params = {
  15. stockTakingPlanId : $('#stockTakingPlanForm').find("input[name='stockTakingPlanId']").val()
  16. };
  17. // 查询产品列表url
  18. var url = WEBROOT + '/StockTakingPlan/findStockTakingPlan.action';
  19. ajaxRequest(url, params, function(data) {
  20. if ("fail" == data.code){
  21. showMsg('提示', data.errorDesc);
  22. }
  23. else{
  24. $('#itemList').window({
  25. title:'添加产品',
  26. width:860,
  27. height:400,
  28. closed : false,
  29. cache : false,
  30. modal : true,
  31. onOpen:function() {
  32. $itemSearchForm.form('reset');
  33. }
  34. });
  35. $("#itemListSearchForm").find("input[name='customerId']").val($("#stockTakingPlanForm").find("input[name='customerId']").val());
  36. $("#itemListMaingrid").datagrid({
  37. width : '100%',
  38. checkOnSelect:true,
  39. nowrap : false,
  40. striped : true,
  41. collapsible : false,
  42. fitColumns : true,
  43. pagination : true,
  44. singleSelect : false,
  45. pageSize : 5,
  46. idField : 'itemId',
  47. url : itemListSearchUrl,
  48. queryParams : queryParams,
  49. remoteSort : true,
  50. rownumbers : true,
  51. pageList : [ 5, 10, 20, 30, 50, 100 ]
  52. });
  53. }
  54. });
  55. }
  56. });
  57. // 查询产品列表的URL
  58. var itemListSearchUrl = WEBROOT + '/StockTakingPlan/findItemList.action';
  59. // 查询库存明细的参数
  60. var queryParams = {
  61. stockTakingPlanId : $stockTakingPlanId.val(),
  62. itemName : $("#itemListSearchForm").find("input[name=itemName]").val(),
  63. itemCode : $("#itemListSearchForm").find("input[name=itemCode]").val(),
  64. transceiverName : $("#itemListSearchForm").find("input[name=transceiverName]").val(),
  65. transceiverCode : $("#itemListSearchForm").find("input[name=transceiverCode]").val()
  66. };
  67. /**
  68. * 盘点的产品:查询按钮
  69. */
  70. $("#searchItemListBtn").bind("click",function() {
  71. $("#itemListMaingrid").datagrid('load', {
  72. stockTakingPlanId : $stockTakingPlanId.val(),
  73. itemName : $itemSearchForm.find("input[name='itemName']").val(),
  74. itemCode : $itemSearchForm.find("input[name='itemCode']").val(),
  75. transceiverName : $("#itemListSearchForm").find("input[name=transceiverName]").val(),
  76. transceiverCode : $("#itemListSearchForm").find("input[name=transceiverCode]").val()
  77. });
  78. });
  79. /**
  80. * 明细列表的展示
  81. */
  82. $("#itemListMaingrid").datagrid({
  83. width : '90%',
  84. checkOnSelect:true,
  85. nowrap : false,
  86. striped : true,
  87. collapsible : false,
  88. fitColumns : true,
  89. idField : 'itemId',
  90. url : WEBROOT + '/StockTakingPlan/findItemList.action',
  91. queryParams : {
  92. customerId : $stockTakingPlanForm.find("input[name='$stockTakingPlanForm']").val()
  93. },
  94. remoteSort : true,
  95. rownumbers : true,
  96. pageList : [ 5, 10, 20, 30, 50, 100 ]
  97. });
  98. /**
  99. * 添加产品:确认按钮
  100. */
  101. $("#submitItemListBtn").bind("click",function() {
  102. var rows = $("#itemListMaingrid").datagrid('getSelections');
  103. var itemIds = [];
  104. for ( var i = 0; i < rows.length; i++) {
  105. if (rows[i].itemId) {
  106. itemIds.push(rows[i].itemId);
  107. }
  108. }
  109. if (itemIds.length == 0) {
  110. alertMsg("提示", "请选择至少一个产品", "error");
  111. }else{
  112. var params = {
  113. stockTakingPlanId : $stockTakingPlanId.val(),
  114. itemIds : $.encodeJSON(itemIds)
  115. };
  116. // 查询产品列表url
  117. var saveItemListUrl = WEBROOT + '/StockTakingPlan/saveItemList.action';
  118. ajaxRequest(saveItemListUrl, params, function(data) {
  119. if ("fail" == data.code){
  120. showMsg('提示', data.errorDesc);
  121. }
  122. $("#itemMaingrid").datagrid('reload');
  123. });
  124. $('#itemList').window('close');
  125. }
  126. });
  127. /**
  128. * 盘点的产品:删除
  129. */
  130. $("#removeItemBtn").click(function() {
  131. var rows = $("#itemMaingrid").datagrid('getSelections');
  132. var ids = [];
  133. for ( var i = 0; i < rows.length; i++) {
  134. if (rows[i].id) {
  135. ids.push(rows[i].id);
  136. }
  137. }
  138. if (ids.length > 0) {
  139. $.messager.confirm('提示', '共选择:' + ids.length + '条记录,确定要删除吗?',
  140. function(result) {
  141. if (result) {
  142. ajaxRequest(WEBROOT + "/StockTakingPlan/removeItem.action", {
  143. ids : $.encodeJSON(ids)
  144. }, function(data) {
  145. if(data.code=='success')
  146. {
  147. $("#itemMaingrid").datagrid('reload');
  148. showMsg('提示', '删除成功');
  149. }
  150. else
  151. {
  152. showMsg('提示', '删除失败');
  153. }
  154. });
  155. }
  156. });
  157. } else {
  158. alertMsg("提示", "请选择要删除的行", "error");
  159. }
  160. });
  161. /**
  162. * 盘点的储位:添加
  163. */
  164. $("#addLocationBtn").bind("click",function() {
  165. if($itemLocationFlag == 2)
  166. {
  167. $.messager.alert('提示','不允许再次添加盘点储位');
  168. }else
  169. {
  170. var params = {
  171. stockTakingPlanId : $stockTakingPlanId.val()
  172. };
  173. // 查询产品列表url
  174. var url = WEBROOT + '/StockTakingPlan/findStockTakingPlan.action';
  175. ajaxRequest(url, params, function(data) {
  176. if ("fail" == data.code){
  177. showMsg('提示', data.errorDesc);
  178. }
  179. else{
  180. $('#locationList').window({
  181. title:'添加储位',
  182. width:860,
  183. height:400,
  184. closed : false,
  185. cache : false,
  186. modal : true,
  187. onOpen : function(){
  188. $locationSearchForm.form('reset');
  189. }
  190. });
  191. $("#locationListSearchForm").find("input[name='warehouseId']").val($("#stockTakingPlanForm").find("input[name='warehouseId']").val());
  192. $("#locationListMaingrid").datagrid({
  193. width : '100%',
  194. checkOnSelect:true,
  195. nowrap : false,
  196. striped : true,
  197. collapsible : false,
  198. fitColumns : true,
  199. pagination : true,
  200. singleSelect : false,
  201. pageSize : 5,
  202. idField : 'locationId',
  203. url : locationListSearchUrl,
  204. queryParams : queryLocationListParams,
  205. remoteSort : true,
  206. rownumbers : true,
  207. pageList : [ 5, 10, 20, 30, 50, 100 ]
  208. });
  209. }
  210. });
  211. }
  212. });
  213. // 查询产品列表的URL
  214. var locationListSearchUrl = WEBROOT + '/StockTakingPlan/findLocationList.action';
  215. // 查询库存明细的参数
  216. var queryLocationListParams = {
  217. stockTakingPlanId : $stockTakingPlanId.val(),
  218. locationName : $("#locationListSearchForm").find("input[name=locationName]").val(),
  219. zoneName : $("#locationListSearchForm").find("input[name=zoneName]").val(),
  220. locationStatus : $("#locationListSearchForm").find("input[name=locationStatus]").val()
  221. };
  222. /**
  223. * 盘点的产品:查询按钮
  224. */
  225. $("#searchLocationListBtn").bind("click",function() {
  226. $("#locationListMaingrid").datagrid('load', {
  227. stockTakingPlanId : $stockTakingPlanId.val(),
  228. locationName : $locationSearchForm.find("input[name='locationName']").val(),
  229. zoneName : $locationSearchForm.find("input[name='zoneName']").val(),
  230. locationStatus : $locationSearchForm.find("input[name='locationStatus']").val()
  231. });
  232. });
  233. /**
  234. * 添加储位:确认按钮
  235. */
  236. $("#submitLocationListBtn").bind("click",function() {
  237. var rows = $("#locationListMaingrid").datagrid('getSelections');
  238. var locationIds = [];
  239. for ( var i = 0; i < rows.length; i++) {
  240. if (rows[i].locationId) {
  241. locationIds.push(rows[i].locationId);
  242. }
  243. }
  244. if (locationIds.length == 0) {
  245. alertMsg("提示", "请选择至少一个储位", "error");
  246. }else{
  247. var params = {
  248. stockTakingPlanId : $stockTakingPlanId.val(),
  249. locationIds : $.encodeJSON(locationIds)
  250. };
  251. // 查询产品列表url
  252. var saveLocationListUrl = WEBROOT + '/StockTakingPlan/saveLocationList.action';
  253. ajaxRequest(saveLocationListUrl, params, function(data) {
  254. if("fail" == data.code){
  255. showMsg("提示", data.errorDesc);
  256. }
  257. $("#locationMaingrid").datagrid('reload');
  258. });
  259. $('#locationList').window('close');
  260. }
  261. });
  262. /**
  263. * 盘点的产品:删除
  264. */
  265. $("#removeLocationBtn").click(function() {
  266. var rows = $("#locationMaingrid").datagrid('getSelections');
  267. var ids = [];
  268. for ( var i = 0; i < rows.length; i++) {
  269. if (rows[i].id) {
  270. ids.push(rows[i].id);
  271. }
  272. }
  273. if (ids.length > 0) {
  274. $.messager.confirm('提示', '共选择:' + ids.length + '条记录,确定要删除吗?',
  275. function(result) {
  276. if (result) {
  277. ajaxRequest(WEBROOT + "/StockTakingPlan/removeLocation.action", {
  278. ids : $.encodeJSON(ids)
  279. }, function(data) {
  280. if(data.code=='success')
  281. {
  282. $("#locationMaingrid").datagrid('reload');
  283. showMsg('提示', '删除成功');
  284. }
  285. else
  286. {
  287. showMsg('提示', '删除失败');
  288. }
  289. });
  290. }
  291. });
  292. } else {
  293. alertMsg("提示", "请选择要删除的行", "error");
  294. }
  295. });
  296. // $('#warehouseId').combogrid({// 仓库
  297. // url : WEBROOT + "/loadData.action?entity=warehouse",
  298. // idField : 'warehouseId',
  299. // textField : 'warehouseName',
  300. // delay : 500,
  301. // showHeader : false,
  302. // mode : 'remote',
  303. // columns : [ [ {
  304. // field : 'warehouseName',
  305. // title : '仓库名称',
  306. // width : 155
  307. // } ] ],
  308. // onBeforeLoad : function(param) { // 此设置使控件不会自动加载数据 这里不能使用this
  309. // if (!$('#warehouseId').combogrid('getText')) {
  310. // return false;
  311. // } else {
  312. // return true;
  313. // }
  314. // },
  315. // onShowPanel : function() { // 在第一次触发下拉框事件是加载数据
  316. // if (!$(this).combogrid('getText')) {
  317. // $(this).combogrid({
  318. // onBeforeLoad : function(param) {
  319. // return true;
  320. // }
  321. // });
  322. // }
  323. // }
  324. // });
  325. // $('#customerId').combogrid({
  326. // panelWidth : 150,
  327. // url : WEBROOT + "/loadData.action?entity=customer",
  328. // idField : 'customerId',
  329. // textField : 'customerName',
  330. // showHeader : false,
  331. // delay : 500,
  332. // mode : 'remote',
  333. // columns : [ [
  334. // { field : 'customerId', hidden : true },
  335. // { field : 'customerName', title : '', width : 150 }
  336. // ] ],
  337. // //请勿使用onSelect避免和baseedit.js里的控件绑定事件冲突
  338. // onSelectAfter : function(rowIndex, record) {
  339. // $("#customerName").val(record.customerName);
  340. //
  341. // }, onBeforeLoad : function(param) {
  342. // //此设置使控件不会自动加载数据 这里不能使用this
  343. // if (!$('#customerId').combogrid('getText')) {
  344. // return false;
  345. // } else {
  346. // return true;
  347. // }
  348. // }, onShowPanel : function() {
  349. // //在第一次触发下拉框事件是加载数据
  350. // if (!$(this).combogrid('getText')) {
  351. // $(this).combogrid({ onBeforeLoad : function(param) {
  352. // return true;
  353. // } });
  354. // }
  355. // }
  356. // });
  357. });