123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 |
- $(function() {
-
- var $stockTakingPlanForm = $('#stockTakingPlanForm');
- var $itemSearchForm = $('#itemListSearchForm');
- var $locationSearchForm = $('#locationListSearchForm');
- var $stockTakingPlanId = $stockTakingPlanForm.find("input[name='stockTakingPlanId']");
- var $itemLocationFlag = $("#itemLocationFlag").combobox("getValue");
-
-
- /**
- * 盘点的产品:添加
- */
- $("#addItemBtn").bind("click",function() {
- if($itemLocationFlag == 3){
- $.messager.alert('提示','不允许再次添加盘点产品');
- }else{
- var params = {
- stockTakingPlanId : $('#stockTakingPlanForm').find("input[name='stockTakingPlanId']").val()
- };
-
- // 查询产品列表url
- var url = WEBROOT + '/StockTakingPlan/findStockTakingPlan.action';
-
- ajaxRequest(url, params, function(data) {
- if ("fail" == data.code){
- showMsg('提示', data.errorDesc);
- }
- else{
- $('#itemList').window({
- title:'添加产品',
- width:860,
- height:400,
- closed : false,
- cache : false,
- modal : true,
- onOpen:function() {
- $itemSearchForm.form('reset');
- }
- });
- $("#itemListSearchForm").find("input[name='customerId']").val($("#stockTakingPlanForm").find("input[name='customerId']").val());
- $("#itemListMaingrid").datagrid({
- width : '100%',
- checkOnSelect:true,
- nowrap : false,
- striped : true,
- collapsible : false,
- fitColumns : true,
- pagination : true,
- singleSelect : false,
- pageSize : 5,
- idField : 'itemId',
- url : itemListSearchUrl,
- queryParams : queryParams,
- remoteSort : true,
- rownumbers : true,
- pageList : [ 5, 10, 20, 30, 50, 100 ]
- });
- }
- });
- }
-
- });
-
- // 查询产品列表的URL
- var itemListSearchUrl = WEBROOT + '/StockTakingPlan/findItemList.action';
-
- // 查询库存明细的参数
- var queryParams = {
- stockTakingPlanId : $stockTakingPlanId.val(),
- itemName : $("#itemListSearchForm").find("input[name=itemName]").val(),
- itemCode : $("#itemListSearchForm").find("input[name=itemCode]").val(),
- transceiverName : $("#itemListSearchForm").find("input[name=transceiverName]").val(),
- transceiverCode : $("#itemListSearchForm").find("input[name=transceiverCode]").val()
- };
-
- /**
- * 盘点的产品:查询按钮
- */
- $("#searchItemListBtn").bind("click",function() {
- $("#itemListMaingrid").datagrid('load', {
- stockTakingPlanId : $stockTakingPlanId.val(),
- itemName : $itemSearchForm.find("input[name='itemName']").val(),
- itemCode : $itemSearchForm.find("input[name='itemCode']").val(),
- transceiverName : $("#itemListSearchForm").find("input[name=transceiverName]").val(),
- transceiverCode : $("#itemListSearchForm").find("input[name=transceiverCode]").val()
- });
- });
-
- /**
- * 明细列表的展示
- */
- $("#itemListMaingrid").datagrid({
- width : '90%',
- checkOnSelect:true,
- nowrap : false,
- striped : true,
- collapsible : false,
- fitColumns : true,
- idField : 'itemId',
- url : WEBROOT + '/StockTakingPlan/findItemList.action',
- queryParams : {
- customerId : $stockTakingPlanForm.find("input[name='$stockTakingPlanForm']").val()
- },
- remoteSort : true,
- rownumbers : true,
- pageList : [ 5, 10, 20, 30, 50, 100 ]
- });
-
- /**
- * 添加产品:确认按钮
- */
- $("#submitItemListBtn").bind("click",function() {
- var rows = $("#itemListMaingrid").datagrid('getSelections');
-
- var itemIds = [];
-
- for ( var i = 0; i < rows.length; i++) {
- if (rows[i].itemId) {
- itemIds.push(rows[i].itemId);
- }
- }
-
- if (itemIds.length == 0) {
- alertMsg("提示", "请选择至少一个产品", "error");
- }else{
- var params = {
- stockTakingPlanId : $stockTakingPlanId.val(),
- itemIds : $.encodeJSON(itemIds)
- };
-
- // 查询产品列表url
- var saveItemListUrl = WEBROOT + '/StockTakingPlan/saveItemList.action';
-
- ajaxRequest(saveItemListUrl, params, function(data) {
- if ("fail" == data.code){
- showMsg('提示', data.errorDesc);
- }
- $("#itemMaingrid").datagrid('reload');
- });
-
- $('#itemList').window('close');
- }
- });
-
- /**
- * 盘点的产品:删除
- */
- $("#removeItemBtn").click(function() {
- var rows = $("#itemMaingrid").datagrid('getSelections');
- var ids = [];
- for ( var i = 0; i < rows.length; i++) {
- if (rows[i].id) {
- ids.push(rows[i].id);
- }
- }
- if (ids.length > 0) {
- $.messager.confirm('提示', '共选择:' + ids.length + '条记录,确定要删除吗?',
- function(result) {
- if (result) {
- ajaxRequest(WEBROOT + "/StockTakingPlan/removeItem.action", {
- ids : $.encodeJSON(ids)
- }, function(data) {
- if(data.code=='success')
- {
- $("#itemMaingrid").datagrid('reload');
- showMsg('提示', '删除成功');
- }
- else
- {
- showMsg('提示', '删除失败');
- }
-
- });
- }
- });
- } else {
- alertMsg("提示", "请选择要删除的行", "error");
- }
- });
-
-
- /**
- * 盘点的储位:添加
- */
- $("#addLocationBtn").bind("click",function() {
- if($itemLocationFlag == 2)
- {
- $.messager.alert('提示','不允许再次添加盘点储位');
- }else
- {
- var params = {
- stockTakingPlanId : $stockTakingPlanId.val()
- };
-
- // 查询产品列表url
- var url = WEBROOT + '/StockTakingPlan/findStockTakingPlan.action';
-
- ajaxRequest(url, params, function(data) {
- if ("fail" == data.code){
- showMsg('提示', data.errorDesc);
- }
- else{
- $('#locationList').window({
- title:'添加储位',
- width:860,
- height:400,
- closed : false,
- cache : false,
- modal : true,
- onOpen : function(){
- $locationSearchForm.form('reset');
- }
- });
-
- $("#locationListSearchForm").find("input[name='warehouseId']").val($("#stockTakingPlanForm").find("input[name='warehouseId']").val());
-
- $("#locationListMaingrid").datagrid({
- width : '100%',
- checkOnSelect:true,
- nowrap : false,
- striped : true,
- collapsible : false,
- fitColumns : true,
- pagination : true,
- singleSelect : false,
- pageSize : 5,
- idField : 'locationId',
- url : locationListSearchUrl,
- queryParams : queryLocationListParams,
- remoteSort : true,
- rownumbers : true,
- pageList : [ 5, 10, 20, 30, 50, 100 ]
- });
- }
- });
- }
-
-
- });
-
- // 查询产品列表的URL
- var locationListSearchUrl = WEBROOT + '/StockTakingPlan/findLocationList.action';
-
- // 查询库存明细的参数
- var queryLocationListParams = {
- stockTakingPlanId : $stockTakingPlanId.val(),
- locationName : $("#locationListSearchForm").find("input[name=locationName]").val(),
- zoneName : $("#locationListSearchForm").find("input[name=zoneName]").val(),
- locationStatus : $("#locationListSearchForm").find("input[name=locationStatus]").val()
- };
-
- /**
- * 盘点的产品:查询按钮
- */
- $("#searchLocationListBtn").bind("click",function() {
- $("#locationListMaingrid").datagrid('load', {
- stockTakingPlanId : $stockTakingPlanId.val(),
- locationName : $locationSearchForm.find("input[name='locationName']").val(),
- zoneName : $locationSearchForm.find("input[name='zoneName']").val(),
- locationStatus : $locationSearchForm.find("input[name='locationStatus']").val()
- });
- });
-
- /**
- * 添加储位:确认按钮
- */
- $("#submitLocationListBtn").bind("click",function() {
- var rows = $("#locationListMaingrid").datagrid('getSelections');
- var locationIds = [];
-
- for ( var i = 0; i < rows.length; i++) {
- if (rows[i].locationId) {
- locationIds.push(rows[i].locationId);
- }
- }
-
- if (locationIds.length == 0) {
- alertMsg("提示", "请选择至少一个储位", "error");
- }else{
- var params = {
- stockTakingPlanId : $stockTakingPlanId.val(),
- locationIds : $.encodeJSON(locationIds)
- };
-
- // 查询产品列表url
- var saveLocationListUrl = WEBROOT + '/StockTakingPlan/saveLocationList.action';
-
- ajaxRequest(saveLocationListUrl, params, function(data) {
- if("fail" == data.code){
- showMsg("提示", data.errorDesc);
- }
- $("#locationMaingrid").datagrid('reload');
- });
-
- $('#locationList').window('close');
- }
- });
-
- /**
- * 盘点的产品:删除
- */
- $("#removeLocationBtn").click(function() {
- var rows = $("#locationMaingrid").datagrid('getSelections');
- var ids = [];
- for ( var i = 0; i < rows.length; i++) {
- if (rows[i].id) {
- ids.push(rows[i].id);
- }
- }
- if (ids.length > 0) {
- $.messager.confirm('提示', '共选择:' + ids.length + '条记录,确定要删除吗?',
- function(result) {
- if (result) {
- ajaxRequest(WEBROOT + "/StockTakingPlan/removeLocation.action", {
- ids : $.encodeJSON(ids)
- }, function(data) {
- if(data.code=='success')
- {
- $("#locationMaingrid").datagrid('reload');
- showMsg('提示', '删除成功');
- }
- else
- {
- showMsg('提示', '删除失败');
- }
-
-
- });
- }
- });
- } else {
- alertMsg("提示", "请选择要删除的行", "error");
- }
- });
-
- // $('#warehouseId').combogrid({// 仓库
- // url : WEBROOT + "/loadData.action?entity=warehouse",
- // idField : 'warehouseId',
- // textField : 'warehouseName',
- // delay : 500,
- // showHeader : false,
- // mode : 'remote',
- // columns : [ [ {
- // field : 'warehouseName',
- // title : '仓库名称',
- // width : 155
- // } ] ],
- // onBeforeLoad : function(param) { // 此设置使控件不会自动加载数据 这里不能使用this
- // if (!$('#warehouseId').combogrid('getText')) {
- // return false;
- // } else {
- // return true;
- // }
- // },
- // onShowPanel : function() { // 在第一次触发下拉框事件是加载数据
- // if (!$(this).combogrid('getText')) {
- // $(this).combogrid({
- // onBeforeLoad : function(param) {
- // return true;
- // }
- // });
- // }
- // }
- // });
-
- // $('#customerId').combogrid({
- // panelWidth : 150,
- // url : WEBROOT + "/loadData.action?entity=customer",
- // idField : 'customerId',
- // textField : 'customerName',
- // showHeader : false,
- // delay : 500,
- // mode : 'remote',
- // columns : [ [
- // { field : 'customerId', hidden : true },
- // { field : 'customerName', title : '', width : 150 }
- // ] ],
- // //请勿使用onSelect避免和baseedit.js里的控件绑定事件冲突
- // onSelectAfter : function(rowIndex, record) {
- // $("#customerName").val(record.customerName);
- //
- // }, onBeforeLoad : function(param) {
- // //此设置使控件不会自动加载数据 这里不能使用this
- // if (!$('#customerId').combogrid('getText')) {
- // return false;
- // } else {
- // return true;
- // }
- // }, onShowPanel : function() {
- // //在第一次触发下拉框事件是加载数据
- // if (!$(this).combogrid('getText')) {
- // $(this).combogrid({ onBeforeLoad : function(param) {
- // return true;
- // } });
- // }
- // }
- // });
- });
|