123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- $(function() {
- $("#detailList").datagrid({});
-
- $("#handeleDetailList").datagrid({});
- var detailOperate = 'add';
-
- var $inventoryAdjustId= $("#inventoryAdjustForm").find("input[name='inventoryAdjustId']");
- /**
- * 跳转到明细页面
- */
- $("#addDetailBtn").bind("click",function() {
- if ($inventoryAdjustId.val() == "") {
- $.messager.alert("提示", "请先填写基本信息", "error");
- } else {
- showWindow({
- title:'新增明细',
- width:900,
- height:300,
- closed : false,
- cache : false,
- modal : true,
- onOpen:function() {
- document.getElementById("addDetailTabs").style.display="";
- $('#demoReasonTd').show();
- document.getElementById("adjustReason").style.display="none";
- $("#inventoryAdjustDetailForm").form('clear');
- }
- });
- }
- });
-
- // 保存明细的方法
- $("#submitDetailBtn").click(function() {
- if ($("#inventoryAdjustDetailForm").form('validate')) {
- var locationName = $("#inventoryAdjustDetailForm").find("input[name='locationName']").val();
- if (null == locationName || "" == locationName){
- showMsg('提示', '请点击“获取明细”按钮来获取明细');
- }
- else{
- var postData = {
- formData: $.encodeJSON($("#inventoryAdjustDetailForm").getFormValue()),
- updateFields : JSON.stringify($.InventoryAdjustDetailEdit.changeList),
- inventoryAdjustId : $("input[name='inventoryAdjustId']").val(),
- operate : detailOperate
- };
- ajaxRequest(WEBROOT + '/InventoryAdjust/doSaveDetail.action', postData, function(response) {
- if (response.code == "success") {// succeed
- showMsg('提示', '保存成功');
- $("#detailList").datagrid({
- width : '90%',
- checkOnSelect:true,
- nowrap : false,
- striped : true,
- collapsible : false,
- fitColumns : true,
- idField : 'id',
- url : WEBROOT + '/InventoryAdjust/showDetailList.action',
- queryParams : {
- inventoryAdId: $inventoryAdjustId.val()
- },
- remoteSort : true,
- rownumbers : true,
- onDblClickRow : function(index,rowdata){
- if($inventoryAdjustId.val() == "") {
- $.messager.alert("提示", "请先保存基本信息", "error");
- } else {
- //$("#addDetailTabs").tabs('enableTab',1);
- showWindow({
- title:'详细明细',
- width:900,
- height:300,
- onOpen:function() {
- ajaxRequest(WEBROOT + "/InventoryAdjust/showDetailEdit.action", {
- id : rowdata.id
- }, function(data) {
- $.InventoryAdjustDetailEdit.fillData(data);
- $('#demoReasonTd').hide();
- document.getElementById("adjustReason").style.display="";
- $("#inventoryAdjustDetailForm").find("input[name='adjustReason']").val(data.adjustReason);
- detailOperate = 'edit';
- });
- }
- });
- }
- }
- });
- } else {
- var errorDesc = response.errorDesc;
- showMsg('保存失败', errorDesc);
- };
- });
- // 关闭窗口前,回复明细的操作符为新增
- detailOperate = 'add';
- closeWindow();
- }
- }
- });
-
- // 删除明细的方法
- $("#removeDetailBtn").click(function() {
- var rows = $("#detailList").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) {
- var postData = {
- ids : $.encodeJSON(ids),
- adjustStatus : $("input[name='adjustStatus']").val()
- };
- ajaxRequest(WEBROOT + "/InventoryAdjust/doDeleteDetail.action", postData, function(response) {
- if (response.code == "success") {
- showMsg('提示', '删除成功');
- $("#detailList").datagrid('reload');
- } else {
- var errorDesc = response.errorDesc;
- showMsg('删除失败', errorDesc);
- };
- });
- }
- });
- } else {
- $.messager.alert("提示", "请选择要删除的行", "error");
- }
- });
-
- /**
- * 明细列表的展示
- */
- $("#detailList").datagrid({
- width : '90%',
- checkOnSelect:true,
- nowrap : false,
- striped : true,
- collapsible : false,
- fitColumns : true,
- idField : 'id',
- url : WEBROOT + '/InventoryAdjust/showDetailList.action',
- queryParams : {
- inventoryAdId: $inventoryAdjustId.val()
- },
- remoteSort : true,
- rownumbers : true,
- onDblClickRow : function(index,rowdata){
- if($inventoryAdjustId.val() == "") {
- $.messager.alert("提示", "请先保存基本信息", "error");
- } else {
- showWindow({
- title:'详细明细',
- width:800,
- height:200,
- onOpen:function() {
- document.getElementById("addDetailTabs").style.display="";
- ajaxRequest(WEBROOT + "/InventoryAdjust/showDetailEdit.action", {
- id : rowdata.id
- }, function(data) {
- $('#inventoryAdjustDetailForm').form('load',{
- locationName : data.locationName,
- relationedCustomerName : data.relationedCustomerName,
- itemCode : data.itemCode,
- itemName : data.itemName,
- normalFlag : data.normalFlag,
- quantity : data.quantity,
- id : rowdata.id
- });
-
- $('#adjustQuantity').numberbox('setValue', data.adjustQuantity);
-
- $('#demoReasonTd').hide();
- document.getElementById("adjustReason").style.display="";
- $("#inventoryAdjustDetailForm").find("input[name='adjustReason']").val(data.adjustReason);
- detailOperate = 'edit';
- });
- }
- });
- }
- }
- });
-
- /**
- * 弹出处理明细页面
- */
- $("#addHandeleDetailBtn").bind("click",function() {
- $('#addHandleDetail').window({
- title : '获取明细',
- width : 800,
- height : 350,
- closed : false,
- cache : false,
- modal : true
- });
-
- $("#locationContainerList").datagrid({
- width : '100%',
- checkOnSelect:true,
- nowrap : false,
- striped : true,
- collapsible : false,
- fitColumns : true,
- pagination : true,
- singleSelect : true,
- pageSize : 5,
- idField : 'id',
- url : locationContainerSearchUrl,
- queryParams : queryParams,
- remoteSort : true,
- rownumbers : true,
- pageList : [ 5, 10, 20, 30, 50, 100 ]
- });
- });
-
- /**
- * 库存明细数据列表填充以及查询
- */
- var locationContainerSearchForm = $("#locationContainerSearchForm").searchForm();
- // 处理明细的按钮查询事件
- $("#locationContainerSearch").bind("click",function() {
- $("#locationContainerList").datagrid('load', {
- locationName : $("#locationContainerSearchForm").find("input[name=queryLocationName]").val(),
- itemName : $("#locationContainerSearchForm").find("input[name=queryItemName]").val(),
- quantity : $("#locationContainerSearchForm").find("input[name=queryQuantity]").val(),
- inventoryAdjustId : inventoryAdjustId
- });
- });
-
- // 查询库存明细的URL
- var locationContainerSearchUrl = WEBROOT + '/InventoryAdjust/doSearchLocationContainer.action';
- locationContainerSearchUrl = locationContainerSearchUrl.format('LocationContainer');
-
- // 查询库存明细的参数
- var queryParams = {
- locationName : $("#locationContainerSearchForm").find("input[name=queryLocationName]").val(),
- itemName : $("#locationContainerSearchForm").find("input[name=queryItemName]").val(),
- quantity : $("#locationContainerSearchForm").find("input[name=queryQuantity]").val(),
- inventoryAdjustId : inventoryAdjustId
- };
-
- /**
- * 最后弹出窗口输入数量和新储位
- */
- $("#submitHandeleDetailBtn").bind("click",function() {
- var rows = $("#locationContainerList").datagrid('getSelections');
- var ids = [];
- for ( var i = 0; i < rows.length; i++) {
- if (rows[i].id) {
- ids.push(rows[i].id);
- }
- }
- if (ids.length != 1) {
- $.messager.alert("提示", "请选择一条具体明细", "error");
- }else{
-
- $('#addHandleDetail').window('close');
- $('#inventoryAdjustDetailForm').form('load',{
- locationContainerId:rows[0].id,
- quantity:rows[0].usableQuantity,
- locationId:rows[0].locationId,
- locationName:rows[0].locationName,
- itemId:rows[0].itemId,
- itemName:rows[0].itemName,
- itemCode:rows[0].itemCode,
- customerId:rows[0].customerId,
- customerCode:rows[0].customerCode,
- customerName:rows[0].customerName,
- zoneId:rows[0].zoneId,
- zoneName:rows[0].zoneName,
- relationedCustomerId:rows[0].relationedCustomerId,
- relationedCustomerCode:rows[0].relationedCustomerCode,
- relationedCustomerName:rows[0].relationedCustomerName,
- warehouseId:rows[0].warehouseId,
- warehouseName:rows[0].warehouseName,
- lotNumber:rows[0].lotNumber,
- normalFlag:rows[0].normalFlag
- });
- }
-
- });
-
- /**
- * 保存或修改处理明细至DB
- */
- $("#submitHandleDetailBtn").bind("click",function(){
-
- });
-
- // 删除处理明细的方法
- $("#removeHandleDetailBtn").click(function() {
- var rows = $("#handeleDetailList").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 + "/InventoryAdjust/doDeleteHandleDetail.action", {
- ids : $.encodeJSON(ids)
- }, function(data) {
- $("#handeleDetailList").datagrid('reload');
- showMsg('提示', '删除成功');
- });
- }
- });
- } else {
- $.messager.alert("提示", "请选择要删除的行", "error");
- }
- });
-
- // $('#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;
- // } });
- // }
- // }
- // });
-
- // $('#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;
- // }
- // });
- // }
- // }
- // });
- });
|