inventoryAdjust.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. $(function() {
  2. $("#detailList").datagrid({});
  3. $("#handeleDetailList").datagrid({});
  4. var detailOperate = 'add';
  5. var $inventoryAdjustId= $("#inventoryAdjustForm").find("input[name='inventoryAdjustId']");
  6. /**
  7. * 跳转到明细页面
  8. */
  9. $("#addDetailBtn").bind("click",function() {
  10. if ($inventoryAdjustId.val() == "") {
  11. $.messager.alert("提示", "请先填写基本信息", "error");
  12. } else {
  13. showWindow({
  14. title:'新增明细',
  15. width:900,
  16. height:300,
  17. closed : false,
  18. cache : false,
  19. modal : true,
  20. onOpen:function() {
  21. document.getElementById("addDetailTabs").style.display="";
  22. $('#demoReasonTd').show();
  23. document.getElementById("adjustReason").style.display="none";
  24. $("#inventoryAdjustDetailForm").form('clear');
  25. }
  26. });
  27. }
  28. });
  29. // 保存明细的方法
  30. $("#submitDetailBtn").click(function() {
  31. if ($("#inventoryAdjustDetailForm").form('validate')) {
  32. var locationName = $("#inventoryAdjustDetailForm").find("input[name='locationName']").val();
  33. if (null == locationName || "" == locationName){
  34. showMsg('提示', '请点击“获取明细”按钮来获取明细');
  35. }
  36. else{
  37. var postData = {
  38. formData: $.encodeJSON($("#inventoryAdjustDetailForm").getFormValue()),
  39. updateFields : JSON.stringify($.InventoryAdjustDetailEdit.changeList),
  40. inventoryAdjustId : $("input[name='inventoryAdjustId']").val(),
  41. operate : detailOperate
  42. };
  43. ajaxRequest(WEBROOT + '/InventoryAdjust/doSaveDetail.action', postData, function(response) {
  44. if (response.code == "success") {// succeed
  45. showMsg('提示', '保存成功');
  46. $("#detailList").datagrid({
  47. width : '90%',
  48. checkOnSelect:true,
  49. nowrap : false,
  50. striped : true,
  51. collapsible : false,
  52. fitColumns : true,
  53. idField : 'id',
  54. url : WEBROOT + '/InventoryAdjust/showDetailList.action',
  55. queryParams : {
  56. inventoryAdId: $inventoryAdjustId.val()
  57. },
  58. remoteSort : true,
  59. rownumbers : true,
  60. onDblClickRow : function(index,rowdata){
  61. if($inventoryAdjustId.val() == "") {
  62. $.messager.alert("提示", "请先保存基本信息", "error");
  63. } else {
  64. //$("#addDetailTabs").tabs('enableTab',1);
  65. showWindow({
  66. title:'详细明细',
  67. width:900,
  68. height:300,
  69. onOpen:function() {
  70. ajaxRequest(WEBROOT + "/InventoryAdjust/showDetailEdit.action", {
  71. id : rowdata.id
  72. }, function(data) {
  73. $.InventoryAdjustDetailEdit.fillData(data);
  74. $('#demoReasonTd').hide();
  75. document.getElementById("adjustReason").style.display="";
  76. $("#inventoryAdjustDetailForm").find("input[name='adjustReason']").val(data.adjustReason);
  77. detailOperate = 'edit';
  78. });
  79. }
  80. });
  81. }
  82. }
  83. });
  84. } else {
  85. var errorDesc = response.errorDesc;
  86. showMsg('保存失败', errorDesc);
  87. };
  88. });
  89. // 关闭窗口前,回复明细的操作符为新增
  90. detailOperate = 'add';
  91. closeWindow();
  92. }
  93. }
  94. });
  95. // 删除明细的方法
  96. $("#removeDetailBtn").click(function() {
  97. var rows = $("#detailList").datagrid('getSelections');
  98. var ids = [];
  99. for ( var i = 0; i < rows.length; i++) {
  100. if (rows[i].id) {
  101. ids.push(rows[i].id);
  102. }
  103. }
  104. if (ids.length > 0) {
  105. $.messager.confirm('提示', '共选择:' + ids.length + '条记录,确定要删除吗?',
  106. function(result) {
  107. if (result) {
  108. var postData = {
  109. ids : $.encodeJSON(ids),
  110. adjustStatus : $("input[name='adjustStatus']").val()
  111. };
  112. ajaxRequest(WEBROOT + "/InventoryAdjust/doDeleteDetail.action", postData, function(response) {
  113. if (response.code == "success") {
  114. showMsg('提示', '删除成功');
  115. $("#detailList").datagrid('reload');
  116. } else {
  117. var errorDesc = response.errorDesc;
  118. showMsg('删除失败', errorDesc);
  119. };
  120. });
  121. }
  122. });
  123. } else {
  124. $.messager.alert("提示", "请选择要删除的行", "error");
  125. }
  126. });
  127. /**
  128. * 明细列表的展示
  129. */
  130. $("#detailList").datagrid({
  131. width : '90%',
  132. checkOnSelect:true,
  133. nowrap : false,
  134. striped : true,
  135. collapsible : false,
  136. fitColumns : true,
  137. idField : 'id',
  138. url : WEBROOT + '/InventoryAdjust/showDetailList.action',
  139. queryParams : {
  140. inventoryAdId: $inventoryAdjustId.val()
  141. },
  142. remoteSort : true,
  143. rownumbers : true,
  144. onDblClickRow : function(index,rowdata){
  145. if($inventoryAdjustId.val() == "") {
  146. $.messager.alert("提示", "请先保存基本信息", "error");
  147. } else {
  148. showWindow({
  149. title:'详细明细',
  150. width:800,
  151. height:200,
  152. onOpen:function() {
  153. document.getElementById("addDetailTabs").style.display="";
  154. ajaxRequest(WEBROOT + "/InventoryAdjust/showDetailEdit.action", {
  155. id : rowdata.id
  156. }, function(data) {
  157. $('#inventoryAdjustDetailForm').form('load',{
  158. locationName : data.locationName,
  159. relationedCustomerName : data.relationedCustomerName,
  160. itemCode : data.itemCode,
  161. itemName : data.itemName,
  162. normalFlag : data.normalFlag,
  163. quantity : data.quantity,
  164. id : rowdata.id
  165. });
  166. $('#adjustQuantity').numberbox('setValue', data.adjustQuantity);
  167. $('#demoReasonTd').hide();
  168. document.getElementById("adjustReason").style.display="";
  169. $("#inventoryAdjustDetailForm").find("input[name='adjustReason']").val(data.adjustReason);
  170. detailOperate = 'edit';
  171. });
  172. }
  173. });
  174. }
  175. }
  176. });
  177. /**
  178. * 弹出处理明细页面
  179. */
  180. $("#addHandeleDetailBtn").bind("click",function() {
  181. $('#addHandleDetail').window({
  182. title : '获取明细',
  183. width : 800,
  184. height : 350,
  185. closed : false,
  186. cache : false,
  187. modal : true
  188. });
  189. $("#locationContainerList").datagrid({
  190. width : '100%',
  191. checkOnSelect:true,
  192. nowrap : false,
  193. striped : true,
  194. collapsible : false,
  195. fitColumns : true,
  196. pagination : true,
  197. singleSelect : true,
  198. pageSize : 5,
  199. idField : 'id',
  200. url : locationContainerSearchUrl,
  201. queryParams : queryParams,
  202. remoteSort : true,
  203. rownumbers : true,
  204. pageList : [ 5, 10, 20, 30, 50, 100 ]
  205. });
  206. });
  207. /**
  208. * 库存明细数据列表填充以及查询
  209. */
  210. var locationContainerSearchForm = $("#locationContainerSearchForm").searchForm();
  211. // 处理明细的按钮查询事件
  212. $("#locationContainerSearch").bind("click",function() {
  213. $("#locationContainerList").datagrid('load', {
  214. locationName : $("#locationContainerSearchForm").find("input[name=queryLocationName]").val(),
  215. itemName : $("#locationContainerSearchForm").find("input[name=queryItemName]").val(),
  216. quantity : $("#locationContainerSearchForm").find("input[name=queryQuantity]").val(),
  217. inventoryAdjustId : inventoryAdjustId
  218. });
  219. });
  220. // 查询库存明细的URL
  221. var locationContainerSearchUrl = WEBROOT + '/InventoryAdjust/doSearchLocationContainer.action';
  222. locationContainerSearchUrl = locationContainerSearchUrl.format('LocationContainer');
  223. // 查询库存明细的参数
  224. var queryParams = {
  225. locationName : $("#locationContainerSearchForm").find("input[name=queryLocationName]").val(),
  226. itemName : $("#locationContainerSearchForm").find("input[name=queryItemName]").val(),
  227. quantity : $("#locationContainerSearchForm").find("input[name=queryQuantity]").val(),
  228. inventoryAdjustId : inventoryAdjustId
  229. };
  230. /**
  231. * 最后弹出窗口输入数量和新储位
  232. */
  233. $("#submitHandeleDetailBtn").bind("click",function() {
  234. var rows = $("#locationContainerList").datagrid('getSelections');
  235. var ids = [];
  236. for ( var i = 0; i < rows.length; i++) {
  237. if (rows[i].id) {
  238. ids.push(rows[i].id);
  239. }
  240. }
  241. if (ids.length != 1) {
  242. $.messager.alert("提示", "请选择一条具体明细", "error");
  243. }else{
  244. $('#addHandleDetail').window('close');
  245. $('#inventoryAdjustDetailForm').form('load',{
  246. locationContainerId:rows[0].id,
  247. quantity:rows[0].usableQuantity,
  248. locationId:rows[0].locationId,
  249. locationName:rows[0].locationName,
  250. itemId:rows[0].itemId,
  251. itemName:rows[0].itemName,
  252. itemCode:rows[0].itemCode,
  253. customerId:rows[0].customerId,
  254. customerCode:rows[0].customerCode,
  255. customerName:rows[0].customerName,
  256. zoneId:rows[0].zoneId,
  257. zoneName:rows[0].zoneName,
  258. relationedCustomerId:rows[0].relationedCustomerId,
  259. relationedCustomerCode:rows[0].relationedCustomerCode,
  260. relationedCustomerName:rows[0].relationedCustomerName,
  261. warehouseId:rows[0].warehouseId,
  262. warehouseName:rows[0].warehouseName,
  263. lotNumber:rows[0].lotNumber,
  264. normalFlag:rows[0].normalFlag
  265. });
  266. }
  267. });
  268. /**
  269. * 保存或修改处理明细至DB
  270. */
  271. $("#submitHandleDetailBtn").bind("click",function(){
  272. });
  273. // 删除处理明细的方法
  274. $("#removeHandleDetailBtn").click(function() {
  275. var rows = $("#handeleDetailList").datagrid('getSelections');
  276. var ids = [];
  277. for ( var i = 0; i < rows.length; i++) {
  278. if (rows[i].id) {
  279. ids.push(rows[i].id);
  280. }
  281. }
  282. if (ids.length > 0) {
  283. $.messager.confirm('提示', '共选择:' + ids.length + '条记录,确定要删除吗?',
  284. function(result) {
  285. if (result) {
  286. ajaxRequest(WEBROOT + "/InventoryAdjust/doDeleteHandleDetail.action", {
  287. ids : $.encodeJSON(ids)
  288. }, function(data) {
  289. $("#handeleDetailList").datagrid('reload');
  290. showMsg('提示', '删除成功');
  291. });
  292. }
  293. });
  294. } else {
  295. $.messager.alert("提示", "请选择要删除的行", "error");
  296. }
  297. });
  298. // $('#customerId').combogrid({
  299. // panelWidth : 150,
  300. // url : WEBROOT + "/loadData.action?entity=customer",
  301. // idField : 'customerId',
  302. // textField : 'customerName',
  303. // showHeader : false,
  304. // delay : 500,
  305. // mode : 'remote',
  306. // columns : [ [
  307. // { field : 'customerId', hidden : true },
  308. // { field : 'customerName', title : '', width : 150 }
  309. // ] ],
  310. // //请勿使用onSelect避免和baseedit.js里的控件绑定事件冲突
  311. // onSelectAfter : function(rowIndex, record) {
  312. // $("#customerName").val(record.customerName);
  313. //
  314. // }, onBeforeLoad : function(param) {
  315. // //此设置使控件不会自动加载数据 这里不能使用this
  316. // if (!$('#customerId').combogrid('getText')) {
  317. // return false;
  318. // } else {
  319. // return true;
  320. // }
  321. // }, onShowPanel : function() {
  322. // //在第一次触发下拉框事件是加载数据
  323. // if (!$(this).combogrid('getText')) {
  324. // $(this).combogrid({ onBeforeLoad : function(param) {
  325. // return true;
  326. // } });
  327. // }
  328. // }
  329. // });
  330. // $('#warehouseId').combogrid({// 仓库
  331. // url : WEBROOT + "/loadData.action?entity=warehouse",
  332. // idField : 'warehouseId',
  333. // textField : 'warehouseName',
  334. // delay : 500,
  335. // showHeader : false,
  336. // mode : 'remote',
  337. // columns : [ [ {
  338. // field : 'warehouseName',
  339. // title : '仓库名称',
  340. // width : 155
  341. // } ] ],
  342. // onBeforeLoad : function(param) { // 此设置使控件不会自动加载数据 这里不能使用this
  343. // if (!$('#warehouseId').combogrid('getText')) {
  344. // return false;
  345. // } else {
  346. // return true;
  347. // }
  348. // },
  349. // onShowPanel : function() { // 在第一次触发下拉框事件是加载数据
  350. // if (!$(this).combogrid('getText')) {
  351. // $(this).combogrid({
  352. // onBeforeLoad : function(param) {
  353. // return true;
  354. // }
  355. // });
  356. // }
  357. // }
  358. // });
  359. });