123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565 |
- $(function() {
- var detailOperate = 'add';
-
- var $inventoryLocationMoveId= $("#inventoryLocationMoveForm").find("input[name='inventoryLocationMoveId']");
-
- /**
- * 跳转到明细页面
- */
- $("#addDetailBtn").bind("click",function() {
-
- if (operate == "add" && "" == ilmi) {
- $.messager.alert("提示", "请先填写基本信息", "error");
- }
- else{
- if (4902 == $("input[name='locationMoveStatus']").val()){
- showMsg('提示', '状态为完成,不允许新增明细信息');
- }
- else {
- showWindow({
- title:'新增明细',
- width:800,
- height:350,
- closed : false,
- cache : false,
- modal : true,
- onOpen:function() {
- document.getElementById("addDetailTabs").style.display="";
- $("#inventoryLocationMoveDetailForm").form('clear');
- detailOperate = 'add';
- }
- });
- }
- }
- });
-
- // 保存明细的方法
- $("#submitDetailBtn").click(function() {
- if ($("#inventoryLocationMoveDetailForm").form('validate')) {
- var postData = {
- formData: $.encodeJSON($("#inventoryLocationMoveDetailForm").getFormValue()),
- updateFields : JSON.stringify($.InventoryLocationMoveDetailEdit.changeList),
- inventoryLocationMoveId : $("input[name='inventoryLocationMoveId']").val(),
- operate : detailOperate
- };
- ajaxRequest(WEBROOT + '/InventoryLocationMove/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 + '/InventoryLocationMove/showDetailList.action',
- queryParams : {
- inventoryMoveId: $inventoryLocationMoveId.val()
- },
- remoteSort : true,
- rownumbers : true,
- onDblClickRow : function(index,rowdata){
- if($inventoryLocationMoveId.val() == "") {
- $.messager.alert("提示", "请先保存基本信息", "error");
- } else {
- showWindow({
- title:'详细明细',
- width:950,
- height:400,
- onOpen:function() {
- ajaxRequest(WEBROOT + "/InventoryLocationMove/showDetailEdit.action", {
- id : rowdata.id
- }, function(data) {
- $.InventoryLocationMoveDetailEdit.fillData(data);
-
- // if(4901 == $("#inventoryLocationMoveForm").find("input[name='locationMoveStatus']").val()){
- // $('#moveType').combobox({
- // disabled : true
- // });
- //
- // $("#isCachedMove").attr('disabled',true);
- // $("#locationContainerId").attr('disabled',true);
- // }
- detailOperate = 'edit';
-
- var moveType = data.moveType;
-
- if (1201 == moveType){
- $('#itemZeroTr').show();
- $('#quantityTd').show();
- $('#quantity').show();
-
- $('#itemOneTr').show();
- $('#itemTwoTr').show();
- $('#itemThreeTr').show();
- $('#itemFourTr').hide();
- $('#SnTr').hide();
- $('#addHandeleDetailBtn').show();
-
- $('#locationMoveQuantity').numberbox({
- required: true,
- value: 1
- });
-
- $('#scanType').combobox({
- required: false
- });
-
- $('#itemLocation').combobox({
- required: false
- });
- }
- else if(1202 == moveType){
- $('#itemZeroTr').hide();
- $('#itemOneTr').hide();
- $('#itemTwoTr').show();
- $('#itemThreeTr').hide();
- $('#itemFourTr').hide();
- $('#SnTr').show();
- $('#addHandeleDetailBtn').hide();
-
- $('#locationMoveQuantity').numberbox({
- required: false,
- value: 0
- });
-
- $('#scanType').combobox({
- required: true
- });
-
- $('#itemLocation').combobox({
- required: false
- });
- }
- else{
- $('#itemZeroTr').show();
- $('#quantityTd').hide();
- $('#quantity').hide();
-
- $('#itemOneTr').hide();
- $('#itemTwoTr').show();
- $('#SnTr').hide();
- $('#addHandeleDetailBtn').hide();
-
- $('#locationMoveQuantity').numberbox({
- required: false,
- value: 0
- });
- $('#itemThreeTr').hide();
- $('#itemFourTr').show();
- $('#scanType').combobox({
- required: false
- });
- }
- });
- }
- });
- }
- }
- });
- } else {
- var errorDesc = response.errorDesc;
- showMsg('保存失败', errorDesc);
- };
- });
- // 关闭窗口前,回复明细的操作符为新增
- detailOperate = 'add';
- closeWindow();
- }
- });
-
- // 删除明细的方法
- $("#removeDetailBtn").click(function() {
- if (4902 == $("input[name='locationMoveStatus']").val()){
- showMsg('提示', '状态为完成,不允许删除明细信息');
- }
- else {
- 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) {
- ajaxRequest(WEBROOT + "/InventoryLocationMove/doDeleteDetail.action", {
- ids : $.encodeJSON(ids),
- locationMoveStatus : $("input[name='locationMoveStatus']").val()
- }, function(data) {
- $("#detailList").datagrid('reload');
- showMsg('提示', '删除成功');
- });
- }
- });
- } else {
- $.messager.alert("提示", "请选择要删除的行", "error");
- }
- }
- });
-
- /**
- * 明细列表的展示
- */
- $("#detailList").datagrid({
- width : '90%',
- checkOnSelect:true,
- nowrap : false,
- striped : true,
- collapsible : false,
- fitColumns : true,
- pagination : true,
- pageSize : 5,
- idField : 'id',
- url : WEBROOT + '/InventoryLocationMove/showDetailList.action',
- queryParams : {
- inventoryMoveId: $inventoryLocationMoveId.val()
- },
- remoteSort : true,
- rownumbers : true,
- pageList : [ 5, 10, 20, 30, 50, 100 ],
- onDblClickRow : function(index,rowdata){
- if($inventoryLocationMoveId.val() == "") {
- $.messager.alert("提示", "请先保存基本信息", "error");
- } else {
- showWindow({
- title:'详细明细',
- width:950,
- height:400,
- onOpen:function() {
- document.getElementById("addDetailTabs").style.display="";
-
- ajaxRequest(WEBROOT + "/InventoryLocationMove/showDetailEdit.action", {
- id : rowdata.id
- }, function(data) {
- $.InventoryLocationMoveDetailEdit.fillData(data);
-
- // if(4901 == $("#inventoryLocationMoveForm").find("input[name='locationMoveStatus']").val()){
- // $('#moveType').combobox({
- // disabled : true
- // });
- //
- // $("#isCachedMove").attr('disabled',true);
- // $("#locationContainerId").attr('disabled',true);
- // }
- detailOperate = 'edit';
-
- var moveType = data.moveType;
-
- if (1201 == moveType){
- $('#itemZeroTr').show();
- $('#quantityTd').show();
- $('#quantity').show();
-
- $('#itemOneTr').show();
- $('#itemTwoTr').show();
- $('#itemThreeTr').show();
- $('#itemFourTr').hide();
- $('#SnTr').hide();
- $('#addHandeleDetailBtn').show();
-
- $('#locationMoveQuantity').numberbox({
- required: true,
- value: 1
- });
-
- $('#scanType').combobox({
- required: false
- });
-
- $('#itemLocation').combobox({
- required: false
- });
- }
- else if(1202 == moveType){
- $('#itemZeroTr').hide();
- $('#itemOneTr').hide();
- $('#itemTwoTr').show();
- $('#itemThreeTr').hide();
- $('#itemFourTr').hide();
- $('#SnTr').show();
- $('#addHandeleDetailBtn').hide();
-
- $('#locationMoveQuantity').numberbox({
- required: false,
- value: 0
- });
-
- $('#scanType').combobox({
- required: true
- });
-
- $('#itemLocation').combobox({
- required: false
- });
- }
- else{
- $('#itemZeroTr').show();
- $('#quantityTd').hide();
- $('#quantity').hide();
-
- $('#itemOneTr').hide();
- $('#itemTwoTr').show();
- $('#SnTr').hide();
- $('#addHandeleDetailBtn').hide();
-
- $('#locationMoveQuantity').numberbox({
- required: false,
- value: 0
- });
- $('#itemThreeTr').hide();
- $('#itemFourTr').show();
- $('#scanType').combobox({
- required: false
- });
- }
- });
- }
- });
- }
- }
- });
-
- var isCachedMove = "";
-
- /**
- * 弹出处理明细页面
- */
- $("#addHandeleDetailBtn").bind("click",function() {
-
- var isCachedMove = document.getElementsByName("isCachedMove");
-
- $('#addHandleDetail').window({
- title : '获取明细',
- width : 800,
- height : 350,
- closed : false,
- cache : false,
- modal : true
- });
-
- // 查询库存明细的URL
- var locationContainerSearchUrl = WEBROOT + '/InventoryLocationMove/doSearchLocationContainer.action';
- locationContainerSearchUrl = locationContainerSearchUrl.format('LocationContainer');
-
- // 查询库存明细的参数
- var queryParams = {
- inventoryLocationMoveId : $inventoryLocationMoveId.val(),
- locationName : "",
- itemName : $("#locationContainerSearchForm").find("input[name=queryItemName]").val(),
- itemCode : $("#locationContainerSearchForm").find("input[name=queryItemCode]").val(),
- isCachedMove : isCachedMove[0].checked
- };
-
- $("#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 ]
- });
- });
-
- // 处理明细的按钮查询事件
- $("#locationContainerSearch").bind("click",function() {
- var queryLocationName = $("#locationContainerSearchForm").find("input[name='queryLocationName']").val();
-
- $("#locationContainerList").datagrid('load', {
- inventoryLocationMoveId : $inventoryLocationMoveId.val(),
- locationName : queryLocationName,
- itemName : $("#locationContainerSearchForm").find("input[name=queryItemName]").val(),
- itemCode : $("#locationContainerSearchForm").find("input[name=queryItemCode]").val(),
- isCachedMove : isCachedMove
- });
- });
-
- /**
- * 最后弹出窗口输入数量和新储位
- */
- $("#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');
-
- $('#inventoryLocationMoveDetailForm').form('load',{
- locationContainerId:rows[0].id,
- quantity:rows[0].usableQuantity,
- 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
- });
-
- $('#locationId').combogrid('setValue', rows[0].locationName);
-
- ajaxRequest(WEBROOT + "/InventoryLocationMove/findLocationByItem.action", {
- itemId : rows[0].itemId
- }, function(data) {
- if(data.code == "success"){
- $('#toLocationId').combogrid('setValue', data.data.locationId).combogrid('setText', data.data.locationName);
- }
- });
- }
- });
-
- /**
- * 保存或修改处理明细至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 + "/InventoryLocationMove/doDeleteHandleDetail.action", {
- ids : $.encodeJSON(ids)
- }, function(data) {
- $("#handeleDetailList").datagrid('reload');
- showMsg('提示', '删除成功');
- });
- }
- });
- } else {
- $.messager.alert("提示", "请选择要删除的行", "error");
- }
- });
-
- // 新增明细:移库类型选择触发事件
- $('#moveType').combobox({
- onSelect: function(param){
- var moveType = $("#inventoryLocationMoveDetailForm").find("input[name='moveType']").val();
-
- if (1201 == moveType){
- $('#itemZeroTr').show();
- $('#quantityTd').show();
- $('#quantity').show();
-
- $('#itemOneTr').show();
- $('#itemTwoTr').show();
- $('#itemThreeTr').show();
- $('#itemFourTr').hide();
- $('#SnTr').hide();
- $('#addHandeleDetailBtn').show();
-
- $('#locationMoveQuantity').numberbox({
- required: true,
- value: 1
- });
-
- $('#scanType').combobox({
- required: false
- });
-
- $('#itemLocation').combobox({
- required: false
- });
- }
- else if(1202 == moveType){
- $('#itemZeroTr').hide();
- $('#itemOneTr').hide();
- $('#itemTwoTr').show();
- $('#itemThreeTr').hide();
- $('#itemFourTr').hide();
- $('#SnTr').show();
- $('#addHandeleDetailBtn').hide();
-
- $('#locationMoveQuantity').numberbox({
- required: false,
- value: 0
- });
-
- $('#scanType').combobox({
- required: true
- });
-
- $('#itemLocation').combobox({
- required: false
- });
- }
- else{
- $('#itemZeroTr').show();
- $('#quantityTd').hide();
- $('#quantity').hide();
-
- $('#itemOneTr').hide();
- $('#itemTwoTr').show();
- $('#SnTr').hide();
- $('#addHandeleDetailBtn').hide();
-
- $('#locationMoveQuantity').numberbox({
- required: false,
- value: 0
- });
- $('#itemThreeTr').hide();
- $('#itemFourTr').show();
- $('#scanType').combobox({
- required: false
- });
- }
- },
- onBeforeLoad:function(){
- $('#itemZeroTr').show();
- $('#itemOneTr').show();
- $('#itemTwoTr').show();
- $('#itemThreeTr').show();
- $('#itemFourTr').hide();
- $('#SnTr').hide();
- $('#addHandeleDetailBtn').show();
-
- $('#locationMoveQuantity').numberbox({
- required: true,
- value: 1
- });
-
- $('#scanType').combobox({
- required: false
- });
- }
- });
-
- });
|