diff --git a/.project b/.project index 0ac65519..cd875a81 100644 --- a/.project +++ b/.project @@ -5,6 +5,11 @@ + + org.eclipse.wst.jsdt.core.javascriptValidator + + + org.eclipse.wst.common.project.facet.core.builder @@ -62,8 +67,8 @@ org.eclipse.jem.workbench.JavaEMFNature com.genuitec.eclipse.j2eedt.core.webnature org.eclipse.jdt.core.javanature - org.eclipse.wst.jsdt.core.jsNature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.jsdt.core.jsNature diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope index 11dfb483..96608b55 100644 --- a/.settings/.jsdtscope +++ b/.settings/.jsdtscope @@ -1,6 +1,5 @@ - @@ -8,5 +7,6 @@ + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index 6f361dd8..e8d5fa15 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,7 +1,5 @@ - - diff --git a/WebRoot/js/HoorayOS_mini/js/hros.zoom.js b/WebRoot/js/HoorayOS_mini/js/hros.zoom.js index 7f048e05..f1b33356 100644 --- a/WebRoot/js/HoorayOS_mini/js/hros.zoom.js +++ b/WebRoot/js/HoorayOS_mini/js/hros.zoom.js @@ -16,7 +16,7 @@ HROS.zoom = (function(){ ** 使用SWFObject.js插入flash ** http://www.cnblogs.com/wuxinxi007/archive/2009/10/27/1590709.html */ - swfobject.embedSWF('js/zoom.swf?onchange=HROS.zoom.check', 'zoombox', '10', '10', '6.0.0', 'expressInstall.swf', '', {allowScriptAccess : 'always', wmode : 'transparent', scale : 'noScale'}, {id : 'accessory_zoom', name : 'zoom_detect'}); + //swfobject.embedSWF('js/zoom.swf?onchange=HROS.zoom.check', 'zoombox', '10', '10', '6.0.0', 'expressInstall.swf', '', {allowScriptAccess : 'always', wmode : 'transparent', scale : 'noScale'}, {id : 'accessory_zoom', name : 'zoom_detect'}); }, /* ** 为什么会有个参数o?其实我也不知道 diff --git a/WebRoot/js/pages/materials/in_out.js b/WebRoot/js/pages/materials/in_out.js index 1e73417f..155a4b9c 100644 --- a/WebRoot/js/pages/materials/in_out.js +++ b/WebRoot/js/pages/materials/in_out.js @@ -1,583 +1,551 @@ -//初始化界面 -$(function() -{ - var depotList = null; - var depotID = null; - var supplierList = null; - var supplierID = null; - var personList = null; - var personID = null; - var ProjectSearch=null; - var userBusinessList=null; - var userdepot=null; - var depotHeadMaxId=null; //获取最大的Id - var accepId=null; //保存的主表id + //初始化界面 + $(function(){ + var depotList = null; + var depotID = null; + var supplierList = null; + var supplierID = null; + var personList = null; + var personID = null; + var ProjectSearch=null; + var userBusinessList=null; + var userdepot=null; + var depotHeadMaxId=null; //获取最大的Id + var accepId=null; //保存的主表id + var url; + var depotHeadID = 0; + var orgDepotHead = ""; + var editIndex = undefined; + var listTitle = ""; //单据标题 + var listType = ""; //入库 出库 + var listSubType = ""; //采购 销售等 + var payTypeTitle = "";//付款 收款 + var organUrl = ""; //组织数据接口地址 + //初始化系统基础信息 + getType(); + initSystemData_UB(); + initSelectInfo_UB(); + initSystemData_depot(); + initSelectInfo_depot(); + initSystemData_person(); + initSelectInfo_person(); + initSystemData_account(); + initSelectInfo_account(); + initSupplier(); //供应商 + initTableData(); + ininPager(); + initForm(); + bindEvent();//绑定操作事件 + }); + //根据单据名称获取类型 + function getType(){ + listTitle = $("#tablePanel").prev().text(); + var supUrl = path + "/supplier/findBySelect_sup.action"; //供应商接口 + var cusUrl = path + "/supplier/findBySelect_cus.action"; //客户接口 + if(listTitle === "采购入库列表"){ + listType = "入库"; + listSubType = "采购"; + payTypeTitle = "付款"; + organUrl = supUrl; + } + else if(listTitle === "销售退货列表"){ + listType = "入库"; + listSubType = "销售退货"; + payTypeTitle = "付款"; + organUrl = cusUrl; + } + else if(listTitle === "其它入库列表"){ + listType = "入库"; + listSubType = "其它"; + payTypeTitle = "隐藏"; + organUrl = supUrl; + } + else if(listTitle === "销售出库列表"){ + listType = "出库"; + listSubType = "销售"; + payTypeTitle = "收款"; + organUrl = cusUrl; + } + else if(listTitle === "采购退货列表"){ + listType = "出库"; + listSubType = "采购退货"; + payTypeTitle = "收款"; + organUrl = supUrl; + } + else if(listTitle === "其它出库列表"){ + listType = "出库"; + listSubType = "其它"; + payTypeTitle = "隐藏"; + organUrl = cusUrl; + } + else if(listTitle === "调拨出库列表"){ + listType = "出库"; + listSubType = "调拨"; + payTypeTitle = "隐藏"; + organUrl = supUrl; + } + } //初始化系统基础信息 - initSystemData_UB(); - initSelectInfo_UB(); - initSystemData_depot(); - initSelectInfo_depot(); - initSystemData_person(); - initSelectInfo_person(); - initSystemData_account(); - initSelectInfo_account(); - initSupplier(); //供应商 - initTableData(); - ininPager(); - initForm(); - - -}); - -//初始化系统基础信息 -function initSystemData_UB() -{ - $.ajax({ - type:"post", - url: "<%=path%>/userBusiness/getBasicData.action", - data: ({ - KeyId:kid, - Type:"UserDepot" - }), - //设置为同步 - async:false, - dataType: "json", - success: function (systemInfo) - { - if(systemInfo) + function initSystemData_UB(){ + $.ajax({ + type:"post", + url: path + "/userBusiness/getBasicData.action", + data: ({ + KeyId:kid, + Type:"UserDepot" + }), + //设置为同步 + async:false, + dataType: "json", + success: function (systemInfo) { - userBusinessList = systemInfo.showModel.map.userBusinessList; + if(systemInfo) + { + userBusinessList = systemInfo.showModel.map.userBusinessList; + var msgTip = systemInfo.showModel.msgTip; + if(msgTip == "exceptoin") + { + $.messager.alert('提示','查找UserBusiness异常,请与管理员联系!','error'); + return; + } + } + else + { + userBusinessList=null; + } + } + }); + + } + //初始化页面选项卡 + function initSelectInfo_UB(){ + + if(userBusinessList !=null) + { + if(userBusinessList.length>0) + { + //用户对应的仓库列表 [1][2][3]... + userdepot =userBusinessList[0].value; + } + } + } + + + //初始化系统基础信息 + function initSystemData_depot(){ + $.ajax({ + type:"post", + url: path + "/depot/getBasicData.action", + //设置为同步 + async:false, + dataType: "json", + success: function (systemInfo) + { + depotList = systemInfo.showModel.map.depotList; var msgTip = systemInfo.showModel.msgTip; if(msgTip == "exceptoin") { - $.messager.alert('提示','查找UserBusiness异常,请与管理员联系!','error'); + $.messager.alert('提示','查找系统基础信息异常,请与管理员联系!','error'); return; - } + } } - else - { - userBusinessList=null; - } - } - }); - -} -//初始化页面选项卡 -function initSelectInfo_UB() -{ - - if(userBusinessList !=null) - { - if(userBusinessList.length>0) - { - //用户对应的仓库列表 [1][2][3]... - userdepot =userBusinessList[0].value; - } + }); } -} - - -//初始化系统基础信息 -function initSystemData_depot() -{ - $.ajax({ - type:"post", - url: "<%=path%>/depot/getBasicData.action", - //设置为同步 - async:false, - dataType: "json", - success: function (systemInfo) - { - depotList = systemInfo.showModel.map.depotList; - var msgTip = systemInfo.showModel.msgTip; - if(msgTip == "exceptoin") - { - $.messager.alert('提示','查找系统基础信息异常,请与管理员联系!','error'); - return; - } - } - }); -} -//初始化页面选项卡 -function initSelectInfo_depot() -{ - var options = ""; - - if(depotList !=null) - { - options = ""; - for(var i = 0 ;i < depotList.length;i ++) - { - var depot = depotList[i]; - - if(userdepot!=null) - { - if(userdepot.indexOf("["+depot.id+"]")!=-1) - { - options += '' + depot.name + ''; - } - } - } - $("#ProjectId").empty().append(options); - $("#searchProjectId").empty().append('全部').append(options); - } -} - -//初始化系统基础信息 -function initSupplier() -{ - $('#OrganId').combobox({ - url: "<%=path%>/supplier/findBySelect_sup.action", - valueField:'id', - textField:'supplier' - }); -} - -//初始化系统基础信息 -function initSystemData_person() -{ - $.ajax({ - type:"post", - url: "<%=path%>/person/getBasicData.action", - //设置为同步 - async:false, - dataType: "json", - success: function (systemInfo) - { - personList = systemInfo.showModel.map.personList; - var msgTip = systemInfo.showModel.msgTip; - if(msgTip == "exceptoin") - { - $.messager.alert('提示','查找系统基础信息异常,请与管理员联系!','error'); - return; - } - } - }); -} -//初始化页面选项卡 -function initSelectInfo_person() -{ - var options1 = ""; - - if(personList !=null) - { - for(var i = 0 ;i < personList.length;i ++) - { - var person = personList[i]; - if(0 == i) - { - personID = person.id; - } - if(person.type=="仓管员") - { - options1 += '' + person.name + ''; - } - } - $("#HandsPersonId").empty().append(options1); - } -} -//获取账户信息 -function initSystemData_account() -{ - $.ajax({ - type:"post", - url: "<%=path%>/account/getAccount.action", - //设置为同步 - async:false, - dataType: "json", - success: function (systemInfo) - { - accountList = systemInfo.showModel.map.accountList; - var msgTip = systemInfo.showModel.msgTip; - if(msgTip == "exceptoin") - { - $.messager.alert('提示','查找账户信息异常,请与管理员联系!','error'); - return; - } - } - }); -} -//获取账户信息 -function initSelectInfo_account() -{ - var options = ""; - if(accountList !=null) - { - options = ""; - for(var i = 0 ;i < accountList.length;i ++) - { - var account = accountList[i]; - options += '' + account.name + ''; - } - $("#AccountId").empty().append(options); - } -} - -//防止表单提交重复 -function initForm() -{ - $('#depotHeadFM').form({ - onSubmit: function(){ - return false; - } - }); -} - -//初始化表格数据 -function initTableData() -{ - $('#tableData').datagrid({ - //title:'采购入库列表', - //iconCls:'icon-save', - //width:700, - height:heightInfo, - rownumbers: false, - //动画效果 - animate:false, - //选中单行 - singleSelect : true, - collapsible:false, - selectOnCheck:false, - //fitColumns:true, - //单击行是否选中 - //checkOnSelect : false, - //url:'<%=path %>/depotHead/findBy.action?pageSize=' + initPageSize, - pagination: true, - //交替出现背景 - striped : true, - //loadFilter: pagerFilter, - pageSize: 5, - pageList: initPageNum, - columns:[[ - { field: 'Id',width:35,align:"center",checkbox:true}, - { title: '单据编号',field: 'Number',width:100}, - { title: '单据日期 ',field: 'OperTime',width:100}, - { title: '创建时间',field: 'CreateTime',width:100}, - { title: '操作员',field: 'OperPersonName',width:80}, - { title: '合计',field: 'TotalPrice',width:50}, - { title: '付款',field: 'ChangeAmount',width:50}, - { title: '单据备注',field: 'Remark',width:100}, - { title: '操作',field: 'op',align:"center",width:180,formatter:function(value,rec) - { - var str = ''; - var rowInfo = rec.Id + 'AaBb' + rec.ProjectId+ 'AaBb' + rec.Number+ 'AaBb' + rec.OperPersonName - + 'AaBb' + rec.OperTime+ 'AaBb' + rec.OrganId+ 'AaBb' + rec.HandsPersonId - + 'AaBb' + rec.AccountId+ 'AaBb' + rec.ChangeAmount+ 'AaBb' + rec.Remark - + 'AaBb' + rec.ProjectName+ 'AaBb' + rec.OrganName+ 'AaBb' + rec.HandsPersonName+ 'AaBb' + rec.AccountName + 'AaBb' + rec.TotalPrice; - if(1 == value) - { - str += ' 查看 '; - str += ' 编辑 '; - str += ' 删除'; - } - return str; - } - } - ]], - toolbar:[ - { - id:'addDepotHead', - text:'增加', - iconCls:'icon-add', - handler:function() - { - addDepotHead(); - } - }, - { - id:'deleteDepotHead', - text:'删除', - iconCls:'icon-remove', - handler:function() - { - batDeleteDepotHead(); - } - } - ], - onLoadError:function() - { - $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error'); - return; - } - }); -} - -//初始化表格数据-商品列表-编辑状态 -function initTableData_material(type,TotalPrice) -{ - $('#materialData').datagrid({ - height:300, - rownumbers: false, - //动画效果 - animate:false, - //选中单行 - singleSelect : true, - collapsible:false, - selectOnCheck:false, - //fitColumns:true, - //单击行是否选中 - //checkOnSelect : false, - pagination: true, - //交替出现背景 - striped : true, - showFooter: true, - //loadFilter: pagerFilter, - onClickRow: onClickRow, - pageSize: 50, - pageList: [50,100,150], - columns:[[ - { field: 'Id',width:35,align:"center",checkbox:true}, - { title: '商品名称',field: 'MaterialId',width:230, - formatter:function(value,row,index){ - return row.MaterialName; - }, - editor:{ - type:'combobox', - options:{ - valueField:'Id', - textField:'MaterialName', - method:'get', - url: "<%=path%>/material/findBySelect.action" - } - } - }, - { title: '数量',field: 'OperNumber',editor:'validatebox',width:50}, - { title: '单价',field: 'UnitPrice',editor:'validatebox',width:50}, - { title: '金额',field: 'AllPrice',editor:'validatebox',width:50}, - { title: '备注',field: 'Remark',editor:'validatebox',width:150} - ]], - toolbar:[ - { - id:'append', - text:'新增', - iconCls:'icon-add', - handler:function() - { - append(); //新增 - } - }, - { - id:'delete', - text:'删除', - iconCls:'icon-remove', - handler:function() - { - removeit(); //删除 - } - }, - { - id:'reject', - text:'撤销', - iconCls:'icon-undo', - handler:function() - { - reject(); //撤销 - } - } - ], - onLoadError:function() - { - $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error'); - return; - } - }); - $.ajax({ - type:"post", - url:'<%=path %>/depotItem/findBy.action?HeaderId=' + depotHeadID, - dataType: "json", - success: function (res) { - var AllPrice = 0 - if(type === "edit") { - AllPrice = TotalPrice; - } - var array = []; - array.push({ - "AllPrice": AllPrice - }); - res.footer = array; - $("#materialData").datagrid('loadData',res); + //初始化页面选项卡 + function initSelectInfo_depot(){ + var options = ""; - }, - error:function() { - $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error'); - } - }); -} - -//初始化表格数据-商品列表-查看状态 -function initTableData_material_show(TotalPrice) -{ - $('#materialDataShow').datagrid({ - height:300, - rownumbers: false, - //动画效果 - animate:false, - //选中单行 - singleSelect : true, - collapsible:false, - selectOnCheck:false, - //fitColumns:true, - //单击行是否选中 - //checkOnSelect : false, - pagination: true, - //交替出现背景 - striped : true, - showFooter: true, - //loadFilter: pagerFilter, - onClickRow: onClickRow, - pageSize: 50, - pageList: [50,100,150], - columns:[[ - { field: 'Id',width:35,align:"center",checkbox:true}, - { title: '商品名称',field: 'MaterialName',width:230}, - { title: '数量',field: 'OperNumber',width:50}, - { title: '单价',field: 'UnitPrice',width:50}, - { title: '金额',field: 'AllPrice',width:50}, - { title: '备注',field: 'Remark',width:150} - ]], - onLoadError:function() + if(depotList !=null) { - $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error'); - return; - } - }); - $.ajax({ - type:"post", - url:'<%=path %>/depotItem/findBy.action?HeaderId=' + depotHeadID, - dataType: "json", - success: function (res) { - var AllPrice = TotalPrice; - var array = []; - array.push({ - "AllPrice": AllPrice - }); - res.footer = array; - $("#materialDataShow").datagrid('loadData',res); - - }, - error:function() { - $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error'); - } - }); -} - -//初始化键盘enter事件 -$(document).keydown(function(event) -{ - //兼容 IE和firefox 事件 - var e = window.event || event; - var k = e.keyCode||e.which||e.charCode; - //兼容 IE,firefox 兼容 - var obj = e.srcElement ? e.srcElement : e.target; - //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题 - if(k == "13"&&(obj.id=="State"||obj.id=="Number")) - { - $("#saveDepotHead").click(); - } - //搜索按钮添加快捷键 - if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber")) - { - $("#searchBtn").click(); - } -}); -//分页信息处理 -function ininPager() -{ - try - { - var opts = $("#tableData").datagrid('options'); - var pager = $("#tableData").datagrid('getPager'); - pager.pagination({ - onSelectPage:function(pageNum, pageSize) - { - opts.pageNumber = pageNum; - opts.pageSize = pageSize; - pager.pagination('refresh', - { - pageNumber:pageNum, - pageSize:pageSize - }); - showDepotHeadDetails(pageNum,pageSize); - } - }); - } - catch (e) - { - $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error'); - } -} - -//删除采购入库信息 -function deleteDepotHead(depotHeadID) -{ - $.messager.confirm('删除确认','确定要删除此采购入库信息吗?',function(r) - { - if (r) - { - $.ajax({ - type:"post", - url: "<%=path %>/depotHead/delete.action", - dataType: "json", - data: ({ - depotHeadID : depotHeadID, - clientIp:'<%=clientIp %>' - }), - success: function (tipInfo) + options = ""; + for(var i = 0 ;i < depotList.length;i++) + { + var depot = depotList[i]; + + if(userdepot!=null) { - var msg = tipInfo.showModel.msgTip; - if(msg == '成功') + if(userdepot.indexOf("["+depot.id+"]")!=-1) { - //加载完以后重新初始化 - $("#searchBtn").click(); + options += '' + depot.name + ''; } - else - $.messager.alert('删除提示','删除采购入库信息失败,请稍后再试!','error'); - }, - //此处添加错误处理 - error:function() - { - $.messager.alert('删除提示','删除采购入库信息异常,请稍后再试!','error'); - return; } - }); - } - }); -} - -//批量删除采购入库 -function batDeleteDepotHead() -{ - var row = $('#tableData').datagrid('getChecked'); - if(row.length == 0) - { - $.messager.alert('删除提示','没有记录被选中!','info'); - return; + } + $("#ProjectId").empty().append(options); + $("#AllocationProjectId").empty().append(options); + $("#searchProjectId").empty().append('全部').append(options); + } } - if(row.length > 0) - { - $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条采购入库信息吗?',function(r) + + //初始化系统基础信息 + function initSupplier(){ + $('#OrganId').combobox({ + url: organUrl, + valueField:'id', + textField:'supplier' + }); + } + + //初始化系统基础信息 + function initSystemData_person(){ + $.ajax({ + type:"post", + url: path + "/person/getBasicData.action", + //设置为同步 + async:false, + dataType: "json", + success: function (systemInfo) + { + personList = systemInfo.showModel.map.personList; + var msgTip = systemInfo.showModel.msgTip; + if(msgTip == "exceptoin") + { + $.messager.alert('提示','查找系统基础信息异常,请与管理员联系!','error'); + return; + } + } + }); + } + //初始化页面选项卡 + function initSelectInfo_person(){ + var options1 = ""; + + if(personList !=null) + { + for(var i = 0 ;i < personList.length;i++) + { + var person = personList[i]; + if(0 == i) + { + personID = person.id; + } + if(person.type=="仓管员") + { + options1 += '' + person.name + ''; + } + } + $("#HandsPersonId").empty().append(options1); + } + } + //获取账户信息 + function initSystemData_account(){ + $.ajax({ + type:"post", + url: path + "/account/getAccount.action", + //设置为同步 + async:false, + dataType: "json", + success: function (systemInfo) + { + accountList = systemInfo.showModel.map.accountList; + var msgTip = systemInfo.showModel.msgTip; + if(msgTip == "exceptoin") + { + $.messager.alert('提示','查找账户信息异常,请与管理员联系!','error'); + return; + } + } + }); + } + //获取账户信息 + function initSelectInfo_account(){ + var options = ""; + if(accountList !=null) + { + options = ""; + for(var i = 0 ;i < accountList.length;i++) + { + var account = accountList[i]; + options += '' + account.name + ''; + } + $("#AccountId").empty().append(options); + } + } + + //防止表单提交重复 + function initForm(){ + $('#depotHeadFM').form({ + onSubmit: function(){ + return false; + } + }); + } + + //初始化表格数据 + function initTableData(){ + var hideType = undefined; + if(payTypeTitle === "隐藏"){ + hideType = true; //隐藏当前列 + } + $('#tableData').datagrid({ + //iconCls:'icon-save', + //width:700, + height:heightInfo, + rownumbers: false, + //动画效果 + animate:false, + //选中单行 + singleSelect : true, + collapsible:false, + selectOnCheck:false, + //fitColumns:true, + //单击行是否选中 + //checkOnSelect : false, + //url: path + '/depotHead/findBy.action?pageSize=' + initPageSize, + pagination: true, + //交替出现背景 + striped : true, + //loadFilter: pagerFilter, + pageSize: 5, + pageList: initPageNum, + columns:[[ + { field: 'Id',width:35,align:"center",checkbox:true}, + { title: '单据编号',field: 'Number',width:100}, + { title: '单据日期 ',field: 'OperTime',width:100}, + { title: '创建时间',field: 'CreateTime',width:100}, + { title: '操作员',field: 'OperPersonName',width:80}, + { title: '合计',field: 'TotalPrice',width:50}, + { title: payTypeTitle,field: 'ChangeAmount',width:50,hidden:hideType}, + { title: '单据备注',field: 'Remark',width:100}, + { title: '操作',field: 'op',align:"center",width:180,formatter:function(value,rec) + { + var str = ''; + var rowInfo = rec.Id + 'AaBb' + rec.ProjectId+ 'AaBb' + rec.Number+ 'AaBb' + rec.OperPersonName + + 'AaBb' + rec.OperTime+ 'AaBb' + rec.OrganId+ 'AaBb' + rec.HandsPersonId + + 'AaBb' + rec.AccountId+ 'AaBb' + rec.ChangeAmount+ 'AaBb' + rec.Remark + + 'AaBb' + rec.ProjectName+ 'AaBb' + rec.OrganName+ 'AaBb' + rec.HandsPersonName+ 'AaBb' + rec.AccountName + 'AaBb' + rec.TotalPrice; + if(1 == value) + { + str += ' 查看 '; + str += ' 编辑 '; + str += ' 删除'; + } + return str; + } + } + ]], + toolbar:[ + { + id:'addDepotHead', + text:'增加', + iconCls:'icon-add', + handler:function() + { + addDepotHead(); + } + }, + { + id:'deleteDepotHead', + text:'删除', + iconCls:'icon-remove', + handler:function() + { + batDeleteDepotHead(); + } + } + ], + onLoadError:function() + { + $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error'); + return; + } + }); + } + + //初始化表格数据-商品列表-编辑状态 + function initTableData_material(type,TotalPrice){ + $('#materialData').datagrid({ + height:300, + rownumbers: false, + //动画效果 + animate:false, + //选中单行 + singleSelect : true, + collapsible:false, + selectOnCheck:false, + //fitColumns:true, + //单击行是否选中 + //checkOnSelect : false, + pagination: true, + //交替出现背景 + striped : true, + showFooter: true, + //loadFilter: pagerFilter, + onClickRow: onClickRow, + pageSize: 50, + pageList: [50,100,150], + columns:[[ + { field: 'Id',width:35,align:"center",checkbox:true}, + { title: '商品名称',field: 'MaterialId',width:230, + formatter:function(value,row,index){ + return row.MaterialName; + }, + editor:{ + type:'combobox', + options:{ + valueField:'Id', + textField:'MaterialName', + method:'get', + url: path + "/material/findBySelect.action" + } + } + }, + { title: '数量',field: 'OperNumber',editor:'validatebox',width:50}, + { title: '单价',field: 'UnitPrice',editor:'validatebox',width:50}, + { title: '金额',field: 'AllPrice',editor:'validatebox',width:50}, + { title: '备注',field: 'Remark',editor:'validatebox',width:150} + ]], + toolbar:[ + { + id:'append', + text:'新增', + iconCls:'icon-add', + handler:function() + { + append(); //新增 + } + }, + { + id:'delete', + text:'删除', + iconCls:'icon-remove', + handler:function() + { + removeit(); //删除 + } + }, + { + id:'reject', + text:'撤销', + iconCls:'icon-undo', + handler:function() + { + reject(); //撤销 + } + } + ], + onLoadError:function() + { + $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error'); + return; + } + }); + $.ajax({ + type:"post", + url: path + '/depotItem/findBy.action?HeaderId=' + depotHeadID, + dataType: "json", + success: function (res) { + var AllPrice = 0 + if(type === "edit") { + AllPrice = TotalPrice; + } + var array = []; + array.push({ + "AllPrice": AllPrice + }); + res.footer = array; + $("#materialData").datagrid('loadData',res); + + }, + error:function() { + $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error'); + } + }); + } + + //初始化表格数据-商品列表-查看状态 + function initTableData_material_show(TotalPrice){ + $('#materialDataShow').datagrid({ + height:300, + rownumbers: false, + //动画效果 + animate:false, + //选中单行 + singleSelect : true, + collapsible:false, + selectOnCheck:false, + //fitColumns:true, + //单击行是否选中 + //checkOnSelect : false, + pagination: true, + //交替出现背景 + striped : true, + showFooter: true, + //loadFilter: pagerFilter, + rownumbers:true, + onClickRow: onClickRow, + pageSize: 50, + pageList: [50,100,150], + columns:[[ + { title: '商品名称',field: 'MaterialName',width:230}, + { title: '数量',field: 'OperNumber',width:50}, + { title: '单价',field: 'UnitPrice',width:50}, + { title: '金额',field: 'AllPrice',width:50}, + { title: '备注',field: 'Remark',width:150} + ]], + onLoadError:function() + { + $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error'); + return; + } + }); + $.ajax({ + type:"post", + url: path + '/depotItem/findBy.action?HeaderId=' + depotHeadID, + dataType: "json", + success: function (res) { + var AllPrice = TotalPrice; + var array = []; + array.push({ + "AllPrice": AllPrice + }); + res.footer = array; + $("#materialDataShow").datagrid('loadData',res); + + }, + error:function() { + $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error'); + } + }); + } + + //分页信息处理 + function ininPager(){ + try + { + var opts = $("#tableData").datagrid('options'); + var pager = $("#tableData").datagrid('getPager'); + pager.pagination({ + onSelectPage:function(pageNum, pageSize) + { + opts.pageNumber = pageNum; + opts.pageSize = pageSize; + pager.pagination('refresh', + { + pageNumber:pageNum, + pageSize:pageSize + }); + showDepotHeadDetails(pageNum,pageSize); + } + }); + } + catch (e) + { + $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error'); + } + } + + //删除采购入库信息 + function deleteDepotHead(depotHeadID){ + $.messager.confirm('删除确认','确定要删除此采购入库信息吗?',function(r) { - if (r) - { - var ids = ""; - for(var i = 0;i < row.length; i ++) - { - if(i == row.length-1) - { - ids += row[i].Id; - break; - } - //alert(row[i].id); - ids += row[i].Id + ","; - } - $.ajax({ + if (r) + { + $.ajax({ type:"post", - url: "<%=path %>/depotHead/batchDelete.action", + url: path + "/depotHead/delete.action", dataType: "json", - async : false, data: ({ - depotHeadIDs : ids, - clientIp:'<%=clientIp %>' + depotHeadID : depotHeadID, + clientIp: clientIp }), success: function (tipInfo) { @@ -586,7 +554,6 @@ function batDeleteDepotHead() { //加载完以后重新初始化 $("#searchBtn").click(); - $(":checkbox").attr("checked",false); } else $.messager.alert('删除提示','删除采购入库信息失败,请稍后再试!','error'); @@ -597,427 +564,502 @@ function batDeleteDepotHead() $.messager.alert('删除提示','删除采购入库信息异常,请稍后再试!','error'); return; } - }); - } - }); - } -} + }); + } + }); + } -//增加 -var url; -var depotHeadID = 0; -//保存编辑前的名称 -var orgDepotHead = ""; - -function addDepotHead() -{ - $("#clientIp").val('<%=clientIp %>'); - $('#depotHeadFM').form('clear'); - $('#depotHeadDlg').dialog('open').dialog('setTitle',' 增加采购入库信息'); - $(".window-mask").css({ width: webW ,height: webH}); - $("#Number").val("").focus(); - - orgDepotHead = ""; - depotHeadID = 0; - initTableData_material("add"); //商品列表 - reject(); //撤销下、刷新商品列表 - url = '<%=path %>/depotHead/create.action'; -} - -//保存信息 -$("#saveDepotHead").unbind().bind({ - click:function() - { - if(!$('#depotHeadFM').form('validate')) - return; - else + //批量删除采购入库 + function batDeleteDepotHead(){ + var row = $('#tableData').datagrid('getChecked'); + if(row.length == 0) { - $.ajax({ - type:"post", - url: url, - dataType: "json", - async : false, - data: ({ - Type:"入库", - SubType:"采购", - ProjectId : $.trim($("#ProjectId").val()), - Number : $.trim($("#Number").val()), - OperTime: $("#OperTime").val(), - OrganId: $('#OrganId').combobox('getValue'), - HandsPersonId: $.trim($("#HandsPersonId").val()), - AccountId: $.trim($("#AccountId").val()), - ChangeAmount: $.trim($("#ChangeAmount").val()), - TotalPrice: $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text(), - Remark: $.trim($("#Remark").val()), - clientIp:'<%=clientIp %>' - }), - success: function (tipInfo) - { - if(tipInfo) - { - //保存明细记录 - if(depotHeadID ==0) + $.messager.alert('删除提示','没有记录被选中!','info'); + return; + } + if(row.length > 0) + { + $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条采购入库信息吗?',function(r) + { + if (r) + { + var ids = ""; + for(var i = 0;i < row.length; i++) + { + if(i == row.length-1) + { + ids += row[i].Id; + break; + } + //alert(row[i].id); + ids += row[i].Id + ","; + } + $.ajax({ + type:"post", + url: path + "/depotHead/batchDelete.action", + dataType: "json", + async : false, + data: ({ + depotHeadIDs : ids, + clientIp: clientIp + }), + success: function (tipInfo) { - getMaxId(); //查找最大的Id - accept(depotHeadMaxId); //新增 - changeAmountFn(); //改变账户金额 + var msg = tipInfo.showModel.msgTip; + if(msg == '成功') + { + //加载完以后重新初始化 + $("#searchBtn").click(); + $(":checkbox").attr("checked",false); + } + else + $.messager.alert('删除提示','删除采购入库信息失败,请稍后再试!','error'); + }, + //此处添加错误处理 + error:function() + { + $.messager.alert('删除提示','删除采购入库信息异常,请稍后再试!','error'); + return; } - else - { - accept(depotHeadID); //修改 - changeAmountFn(); //改变账户金额 - } - } - else - { - $.messager.show({ - title: '错误提示', - msg: '保存采购入库信息失败,请稍后重试!' - }); - } - }, - //此处添加错误处理 - error:function() - { - $.messager.alert('提示','保存采购入库信息异常,请稍后再试!','error'); - return; - } - }); - } + }); + } + }); + } } -}); + //新增信息 + function addDepotHead(){ + $("#clientIp").val(clientIp); + $('#depotHeadFM').form('clear'); + var addTitle = listTitle.replace("列表","信息"); + $('#depotHeadDlg').dialog('open').dialog('setTitle',' 增加' + addTitle); + $(".window-mask").css({ width: webW ,height: webH}); + $("#Number").val("").focus(); + + orgDepotHead = ""; + depotHeadID = 0; + initTableData_material("add"); //商品列表 + reject(); //撤销下、刷新商品列表 + url = path + '/depotHead/create.action'; + } -//编辑信息 -function editDepotHead(depotHeadTotalInfo) -{ - var depotHeadInfo = depotHeadTotalInfo.split("AaBb"); - $("#clientIp").val('<%=clientIp %>'); - $("#ProjectId").focus().val(depotHeadInfo[1]); - var ProjectId=depotHeadInfo[1]; - if(ProjectId!='') - { - initSystemData_person(ProjectId); - initSelectInfo_person(); + //编辑信息 + function editDepotHead(depotHeadTotalInfo){ + var depotHeadInfo = depotHeadTotalInfo.split("AaBb"); + $("#clientIp").val(clientIp); + $("#ProjectId").focus().val(depotHeadInfo[1]); + var ProjectId=depotHeadInfo[1]; + if(ProjectId!='') + { + initSystemData_person(ProjectId); + initSelectInfo_person(); + } + $("#Number").val(depotHeadInfo[2]); + $("#OperTime").val(depotHeadInfo[4]); + $('#OrganId').combobox('setValue', depotHeadInfo[5]); + $("#HandsPersonId").val(depotHeadInfo[6]); + $("#AccountId").val(depotHeadInfo[7]); + $("#ChangeAmount").val(depotHeadInfo[8]); + $("#ChangeAmount").attr("data-changeamount", depotHeadInfo[8]); + $("#Remark").val(depotHeadInfo[9]); + var TotalPrice = depotHeadInfo[14]; + + //orgDepotHead = depotHeadInfo[1]; + var editTitle = listTitle.replace("列表","信息"); + $('#depotHeadDlg').dialog('open').dialog('setTitle',' 编辑' + editTitle); + $(".window-mask").css({ width: webW ,height: webH}); + depotHeadID = depotHeadInfo[0]; + + initTableData_material("edit",TotalPrice); //商品列表 + reject(); //撤销下、刷新商品列表 + url = path + '/depotHead/update.action?depotHeadID=' + depotHeadInfo[0]; } - $("#Number").val(depotHeadInfo[2]); - $("#OperTime").val(depotHeadInfo[4]); - $('#OrganId').combobox('setValue', depotHeadInfo[5]); - $("#HandsPersonId").val(depotHeadInfo[6]); - $("#AccountId").val(depotHeadInfo[7]); - $("#ChangeAmount").val(depotHeadInfo[8]); - $("#ChangeAmount").attr("data-changeamount", depotHeadInfo[8]); - $("#Remark").val(depotHeadInfo[9]); - var TotalPrice = depotHeadInfo[14]; - - //orgDepotHead = depotHeadInfo[1]; - $('#depotHeadDlg').dialog('open').dialog('setTitle',' 编辑采购入库信息'); - $(".window-mask").css({ width: webW ,height: webH}); - depotHeadID = depotHeadInfo[0]; - - initTableData_material("edit",TotalPrice); //商品列表 - reject(); //撤销下、刷新商品列表 - url = '<%=path %>/depotHead/update.action?depotHeadID=' + depotHeadInfo[0]; -} - -//查看信息 -function showDepotHead(depotHeadTotalInfo) -{ - var depotHeadInfo = depotHeadTotalInfo.split("AaBb"); - $("#ProjectIdShow").text(depotHeadInfo[10]); - $("#NumberShow").text(depotHeadInfo[2]); - $("#OperTimeShow").text(depotHeadInfo[4]); - $('#OrganIdShow').text(depotHeadInfo[11]); - $("#HandsPersonIdShow").text(depotHeadInfo[12]); - $("#AccountIdShow").text(depotHeadInfo[13]); - $("#ChangeAmountShow").text(depotHeadInfo[8]); - $("#RemarkShow").text(depotHeadInfo[9]); - var TotalPrice = depotHeadInfo[14]; - $('#depotHeadDlgShow').dialog('open').dialog('setTitle',' 查看采购入库信息'); - $(".window-mask").css({ width: webW ,height: webH}); - - depotHeadID = depotHeadInfo[0]; - initTableData_material_show(TotalPrice); //商品列表-查看状态 -} - -//搜索处理 -$("#searchBtn").unbind().bind({ - click:function() - { - if($("#searchProjectId").val()=="") - { - $.messager.alert('查询提示','请选择一个仓库!','info'); - } - else - { - showDepotHeadDetails(1,initPageSize); - var opts = $("#tableData").datagrid('options'); - var pager = $("#tableData").datagrid('getPager'); - opts.pageNumber = 1; - opts.pageSize = initPageSize; - pager.pagination('refresh', - { - pageNumber:1, - pageSize:initPageSize - }); - } + + //查看信息 + function showDepotHead(depotHeadTotalInfo){ + var depotHeadInfo = depotHeadTotalInfo.split("AaBb"); + $("#ProjectIdShow").text(depotHeadInfo[10]); + $("#NumberShow").text(depotHeadInfo[2]); + $("#OperTimeShow").text(depotHeadInfo[4]); + $('#OrganIdShow').text(depotHeadInfo[11]); + $("#HandsPersonIdShow").text(depotHeadInfo[12]); + $("#AccountIdShow").text(depotHeadInfo[13]); + $("#ChangeAmountShow").text(depotHeadInfo[8]); + $("#RemarkShow").text(depotHeadInfo[9]); + var TotalPrice = depotHeadInfo[14]; + var showTitle = listTitle.replace("列表","信息"); + $('#depotHeadDlgShow').dialog('open').dialog('setTitle',' 查看' + showTitle); + $(".window-mask").css({ width: webW ,height: webH}); + + depotHeadID = depotHeadInfo[0]; + initTableData_material_show(TotalPrice); //商品列表-查看状态 } -}); - -function showDepotHeadDetails(pageNo,pageSize) -{ - $.ajax({ - type:"post", - url: "<%=path %>/depotHead/findBy.action", - dataType: "json", - data: ({ - ProjectId:$.trim($("#searchProjectId").val()), - Type:"入库", - SubType:"采购", - State:$.trim($("#searchState").val()), - Number:$.trim($("#searchNumber").val()), - BeginTime:$("#searchBeginTime").val(), - EndTime:$("#searchEndTime").val(), - pageNo:pageNo, - pageSize:pageSize - }), - success: function (data) - { - $("#tableData").datagrid('loadData',data); - }, - //此处添加错误处理 - error:function() - { - $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error'); - return; - } - }); -} -//重置按钮 -$("#searchResetBtn").unbind().bind({ - click:function(){ - //$("#searchProjectId").val(""); - $("#searchState").val(""); - $("#searchBeginTime").val(""); - $("#searchEndTime").val(""); - //加载完以后重新初始化 - $("#searchBtn").click(); - } -}); -//自动计算事件 -function autoReckon() { - //延时绑定事件 - setTimeout(function(){ - var body =$("#depotHeadFM .datagrid-body"); - var footer =$("#depotHeadFM .datagrid-footer"); - var input = ".datagrid-editable-input"; - - //修改单价,自动计算金额和合计 - body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){ - var UnitPrice =$(this).val()-0; //单价 - var TotalPrice = 0; - var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量 - body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); - body.find("[field='AllPrice']").each(function(){ - if($(this).find("div").text()!==""){ - TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString()); - } - }); - TotalPrice = TotalPrice + UnitPrice*OperNumber; - footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); - }); - //修改数量,自动计算金额和合计 - body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){ - var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价 - var TotalPrice = 0; - var OperNumber =$(this).val()-0; //数量 - body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); - body.find("[field='AllPrice']").each(function(){ - if($(this).find("div").text()!==""){ - TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString()); - } - }); - TotalPrice = TotalPrice + UnitPrice*OperNumber; - footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); - }); - //修改金额,自动计算单价和合计 - body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){ - var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量 - var TotalPrice = 0; - var AllPrice =$(this).val()-0; //金额 - body.find("[field='UnitPrice']").find(input).val((AllPrice/OperNumber).toFixed(2)); - body.find("[field='AllPrice']").each(function(){ - if($(this).find("div").text()!==""){ - TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString()); - } - }); - TotalPrice = TotalPrice + AllPrice; - footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); - }); - },500); -} - -//结束编辑 -var editIndex = undefined; -function endEditing() { - if (editIndex == undefined) { return true } - if ($('#materialData').datagrid('validateRow', editIndex)) { - var ed = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'}); - var MaterialName = $(ed.target).combobox('getText'); - $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName; - $('#materialData').datagrid('endEdit', editIndex); - editIndex = undefined; - return true; - } else { - return false; - } -} -//单击 -function onClickRow(index) { - if (editIndex != index) { - if (endEditing()) { - $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index); - editIndex = index; - autoReckon(); - } else { - $('#materialData').datagrid('selectRow', editIndex); - } - } -} -//新增 -function append() -{ - if (endEditing()) { - $('#materialData').datagrid('appendRow', {}); - editIndex = $('#materialData').datagrid('getRows').length - 1; - $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex); - autoReckon(); - } -} -//删除 -function removeit() { - if (editIndex == undefined) { return } - $('#materialData').datagrid('cancelEdit', editIndex) - .datagrid('deleteRow', editIndex); - editIndex = undefined; -} -//撤销 -function reject() { - $('#materialData').datagrid('rejectChanges'); - editIndex = undefined; -} -//判断 -function CheckData() { - var row = $('#materialData').datagrid('getRows'); - var totalRowNum = ""; - for (var i = 0; i < row.length; i++) { - if (row[i].MaterialId == "") { - totalRowNum += (i + 1) + "、"; - } - } - if (totalRowNum != "") { - var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1); - $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info'); - return false; - } - return true; -} -//保存 -function accept(accepId) { - append(); - removeit(); - if ($("#materialData").datagrid('getChanges').length) { - if (!CheckData()) - return false; - var inserted = $("#materialData").datagrid('getChanges', "inserted"); - var deleted = $("#materialData").datagrid('getChanges', "deleted"); - var updated = $("#materialData").datagrid('getChanges', "updated"); - $.ajax({ - type: "post", - url: "<%=path%>/depotItem/saveDetials.action", - data: { - Inserted: JSON.stringify(inserted), - Deleted: JSON.stringify(deleted), - Updated: JSON.stringify(updated), - HeaderId:accepId, - clientIp:'<%=clientIp %>' - }, - success: function (tipInfo) - { - if (tipInfo) { - $.messager.alert('提示','保存成功!','info'); - } - else - $.messager.alert('提示','保存失败!','error'); - - }, - error: function (XmlHttpRequest, textStatus, errorThrown) - { - $.messager.alert('提示',XmlHttpRequest.responseText,'error'); - } - }); - } - if (endEditing()) { - $('#materialData').datagrid('acceptChanges'); - } -} -//获取MaxId -function getMaxId() -{ - var depotHeadMax=null; - $.ajax({ - type:"post", - url: "<%=path%>/depotHead/getMaxId.action", - //设置为同步 - async:false, - dataType: "json", - success: function (systemInfo) - { - if(systemInfo) + + //绑定操作事件 + function bindEvent(){ + //搜索处理 + $("#searchBtn").off("click").on("click",function(){ + if($("#searchProjectId").val()=="") { - depotHeadMax = systemInfo.showModel.map.depotHeadMax; - var msgTip = systemInfo.showModel.msgTip; - if(msgTip == "exceptoin") - { - $.messager.alert('提示','查找最大的Id异常,请与管理员联系!','error'); - return; - } + $.messager.alert('查询提示','请选择一个仓库!','info'); } else { - depotHeadMax=null; + showDepotHeadDetails(1,initPageSize); + var opts = $("#tableData").datagrid('options'); + var pager = $("#tableData").datagrid('getPager'); + opts.pageNumber = 1; + opts.pageSize = initPageSize; + pager.pagination('refresh', + { + pageNumber:1, + pageSize:initPageSize + }); + } + }); + + //重置按钮 + $("#searchResetBtn").unbind().bind({ + click:function(){ + //$("#searchProjectId").val(""); + $("#searchState").val(""); + $("#searchBeginTime").val(""); + $("#searchEndTime").val(""); + //加载完以后重新初始化 + $("#searchBtn").click(); + } + }); + + //保存信息 + $("#saveDepotHead").unbind().bind({ + click:function() + { + if(!$('#depotHeadFM').form('validate')) + return; + else + { + $.ajax({ + type:"post", + url: url, + dataType: "json", + async : false, + data: ({ + Type: listType, + SubType: listSubType, + ProjectId : $.trim($("#ProjectId").val()), + Number : $.trim($("#Number").val()), + OperTime: $("#OperTime").val(), + OrganId: $('#OrganId').combobox('getValue'), + HandsPersonId: $.trim($("#HandsPersonId").val()), + AccountId: $.trim($("#AccountId").val()), + ChangeAmount: $.trim($("#ChangeAmount").val()), + TotalPrice: $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text(), + Remark: $.trim($("#Remark").val()), + clientIp: clientIp + }), + success: function (tipInfo) + { + if(tipInfo) + { + //保存明细记录 + if(depotHeadID ==0) + { + getMaxId(); //查找最大的Id + accept(depotHeadMaxId); //新增 + changeAmountFn(); //改变账户金额 + } + else + { + accept(depotHeadID); //修改 + changeAmountFn(); //改变账户金额 + } + } + else + { + $.messager.show({ + title: '错误提示', + msg: '保存采购入库信息失败,请稍后重试!' + }); + } + }, + //此处添加错误处理 + error:function() + { + $.messager.alert('提示','保存采购入库信息异常,请稍后再试!','error'); + return; + } + }); + } + } + }); + + //初始化键盘enter事件 + $(document).keydown(function(event){ + //兼容 IE和firefox 事件 + var e = window.event || event; + var k = e.keyCode||e.which||e.charCode; + //兼容 IE,firefox 兼容 + var obj = e.srcElement ? e.srcElement : e.target; + //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题 + if(k == "13"&&(obj.id=="State"||obj.id=="Number")) + { + $("#saveDepotHead").click(); + } + //搜索按钮添加快捷键 + if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber")) + { + $("#searchBtn").click(); + } + }); + } + + + function showDepotHeadDetails(pageNo,pageSize){ + $.ajax({ + type:"post", + url: path + "/depotHead/findBy.action", + dataType: "json", + data: ({ + ProjectId:$.trim($("#searchProjectId").val()), + Type: listType, + SubType:listSubType, + State:$.trim($("#searchState").val()), + Number:$.trim($("#searchNumber").val()), + BeginTime:$("#searchBeginTime").val(), + EndTime:$("#searchEndTime").val(), + pageNo:pageNo, + pageSize:pageSize + }), + success: function (data) + { + $("#tableData").datagrid('loadData',data); + }, + //此处添加错误处理 + error:function() + { + $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error'); + return; + } + }); + } + + //自动计算事件 + function autoReckon() { + //延时绑定事件 + setTimeout(function(){ + var body =$("#depotHeadFM .datagrid-body"); + var footer =$("#depotHeadFM .datagrid-footer"); + var input = ".datagrid-editable-input"; + + //修改单价,自动计算金额和合计 + body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){ + var UnitPrice =$(this).val()-0; //单价 + var TotalPrice = 0; + var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量 + body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); + body.find("[field='AllPrice']").each(function(){ + if($(this).find("div").text()!==""){ + TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString()); + } + }); + TotalPrice = TotalPrice + UnitPrice*OperNumber; + footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); + }); + //修改数量,自动计算金额和合计 + body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){ + var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价 + var TotalPrice = 0; + var OperNumber =$(this).val()-0; //数量 + body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); + body.find("[field='AllPrice']").each(function(){ + if($(this).find("div").text()!==""){ + TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString()); + } + }); + TotalPrice = TotalPrice + UnitPrice*OperNumber; + footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); + }); + //修改金额,自动计算单价和合计 + body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){ + var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量 + var TotalPrice = 0; + var AllPrice =$(this).val()-0; //金额 + body.find("[field='UnitPrice']").find(input).val((AllPrice/OperNumber).toFixed(2)); + body.find("[field='AllPrice']").each(function(){ + if($(this).find("div").text()!==""){ + TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString()); + } + }); + TotalPrice = TotalPrice + AllPrice; + footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); + }); + },500); + } + + //结束编辑 + function endEditing() { + if (editIndex == undefined) { return true } + if ($('#materialData').datagrid('validateRow', editIndex)) { + var ed = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'}); + var MaterialName = $(ed.target).combobox('getText'); + $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName; + $('#materialData').datagrid('endEdit', editIndex); + editIndex = undefined; + return true; + } else { + return false; + } + } + //单击 + function onClickRow(index) { + if (editIndex != index) { + if (endEditing()) { + $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index); + editIndex = index; + autoReckon(); + } else { + $('#materialData').datagrid('selectRow', editIndex); + } + } + } + //新增 + function append(){ + if (endEditing()) { + $('#materialData').datagrid('appendRow', {}); + editIndex = $('#materialData').datagrid('getRows').length - 1; + $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex); + autoReckon(); + } + } + //删除 + function removeit(){ + if (editIndex == undefined) { return } + $('#materialData').datagrid('cancelEdit', editIndex) + .datagrid('deleteRow', editIndex); + editIndex = undefined; + } + //撤销 + function reject() { + $('#materialData').datagrid('rejectChanges'); + editIndex = undefined; + } + //判断 + function CheckData() { + var row = $('#materialData').datagrid('getRows'); + var totalRowNum = ""; + for (var i = 0; i < row.length; i++) { + if (row[i].MaterialId == "") { + totalRowNum += (i + 1) + "、"; + } + } + if (totalRowNum != "") { + var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1); + $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info'); + return false; + } + return true; + } + //保存 + function accept(accepId) { + append(); + removeit(); + if ($("#materialData").datagrid('getChanges').length) { + if (!CheckData()) + return false; + var inserted = $("#materialData").datagrid('getChanges', "inserted"); + var deleted = $("#materialData").datagrid('getChanges', "deleted"); + var updated = $("#materialData").datagrid('getChanges', "updated"); + $.ajax({ + type: "post", + url: path + "/depotItem/saveDetials.action", + data: { + Inserted: JSON.stringify(inserted), + Deleted: JSON.stringify(deleted), + Updated: JSON.stringify(updated), + HeaderId:accepId, + clientIp: clientIp + }, + success: function (tipInfo) + { + if (tipInfo) { + $.messager.alert('提示','保存成功!','info'); + } + else + $.messager.alert('提示','保存失败!','error'); + + }, + error: function (XmlHttpRequest, textStatus, errorThrown) + { + $.messager.alert('提示',XmlHttpRequest.responseText,'error'); + } + }); + } + if (endEditing()) { + $('#materialData').datagrid('acceptChanges'); + } + } + //获取MaxId + function getMaxId(){ + var depotHeadMax=null; + $.ajax({ + type:"post", + url: path + "/depotHead/getMaxId.action", + //设置为同步 + async:false, + dataType: "json", + success: function (systemInfo) + { + if(systemInfo) + { + depotHeadMax = systemInfo.showModel.map.depotHeadMax; + var msgTip = systemInfo.showModel.msgTip; + if(msgTip == "exceptoin") + { + $.messager.alert('提示','查找最大的Id异常,请与管理员联系!','error'); + return; + } + } + else + { + depotHeadMax=null; + } + } + }); + + if(depotHeadMax !=null) + { + if(depotHeadMax.length>0) + { + depotHeadMaxId=depotHeadMax[0]; } } - }); - - if(depotHeadMax !=null) - { - if(depotHeadMax.length>0) - { - depotHeadMaxId=depotHeadMax[0]; - } } -} -//改变账户金额 -function changeAmountFn() { - var currentAmount = $("#AccountId option:selected").attr("data-currentamount")-0; - var ChangeAmount = $("#ChangeAmount").val()-0; - var oldChangeAmount = $("#ChangeAmount").attr("data-changeamount")-0; - $.ajax({ - url: "<%=path %>/account/updateAmount.action", - type: "get", - dataType: "json", - data:{ - accountID: $("#AccountId").val(), - currentAmount: currentAmount + ChangeAmount - oldChangeAmount - }, - success: function(res){ - $('#depotHeadDlg').dialog('close'); - var opts = $("#tableData").datagrid('options'); - showDepotHeadDetails(opts.pageNumber,opts.pageSize); - }, - error:function(){ - $.messager.alert('提示','请检查网络连接!','error'); - return; - } - }); -} \ No newline at end of file + //改变账户金额 + function changeAmountFn(){ + var currentAmount = $("#AccountId option:selected").attr("data-currentamount")-0; + var ChangeAmount = $("#ChangeAmount").val()-0; + var oldChangeAmount = $("#ChangeAmount").attr("data-changeamount")-0; + $.ajax({ + url: path + "/account/updateAmount.action", + type: "get", + dataType: "json", + data:{ + accountID: $("#AccountId").val(), + currentAmount: currentAmount + ChangeAmount - oldChangeAmount + }, + success: function(res){ + $('#depotHeadDlg').dialog('close'); + var opts = $("#tableData").datagrid('options'); + showDepotHeadDetails(opts.pageNumber,opts.pageSize); + }, + error:function(){ + $.messager.alert('提示','请检查网络连接!','error'); + return; + } + }); + } + + + + + + diff --git a/WebRoot/pages/materials/allocation_out_list.jsp b/WebRoot/pages/materials/allocation_out_list.jsp index a2f152cf..1b874053 100644 --- a/WebRoot/pages/materials/allocation_out_list.jsp +++ b/WebRoot/pages/materials/allocation_out_list.jsp @@ -2,7 +2,6 @@ <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); - String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; String clientIp = Tools.getCurrentUserIP(); %> @@ -13,14 +12,20 @@ - - - - - + + + + + + + @@ -31,11 +36,11 @@ - 单据号: + 单据编号: - 出库时间: + 单据日期: @@ -66,31 +71,31 @@ - 出库时间: + 单据日期: - 收货仓库: + 经手人: - - + + - 经手人: + 收货仓库: - + - 备注: + 单据编号: + + + 单据备注: - 单据号: - - - + 商品列表: @@ -115,33 +120,33 @@ - 出库时间: + 单据日期: - 收货仓库: - - - + 经手人: + + + - 仓管员: - - + 收货仓库: + + - 备注: - - - - 单据号: + 单据编号: + 单据备注: + + + - + 商品列表: @@ -154,6 +159,7 @@ - - - - + + + + + + + @@ -31,11 +36,11 @@ - 单据号: + 单据编号: - 入库时间: + 单据日期: @@ -66,38 +71,32 @@ - 入库时间: + 单据日期: - 供应商: + 往来单位: - 采购人: - - - + + 经手人: - + - 结算方式: - - - 现金 - 记账 - - - 备注: + 单据编号: + + + + 单据备注: - 单据号: - - + + 商品列表: @@ -122,36 +121,32 @@ - 入库时间: + 单据日期: - 供应商: + 往来单位: - 采购人: - - - + + - 仓管员: + 经手人: - + - 结算方式: - - - - 备注: - - - - 单据号: + 单据编号: + 单据备注: + + + + + 商品列表: @@ -164,6 +159,7 @@ - - - - + + + + + + + @@ -31,11 +36,11 @@ - 单据号: + 单据编号: - 出库时间: + 单据日期: @@ -66,11 +71,11 @@ - 出库时间: + 单据日期: - 客户: + 往来单位: @@ -80,15 +85,15 @@ 经手人: - + - 备注: - - - - 单据号: + 单据编号: + 单据备注: + + + @@ -115,11 +120,11 @@ - 出库时间: + 单据日期: - 客户: + 往来单位: @@ -128,20 +133,20 @@ - 仓管员: + 经手人: - + - 备注: - - - - 单据号: + 单据编号: + 单据备注: + + + - + 商品列表: @@ -154,6 +159,7 @@ - - - - + + + + + + + @@ -31,11 +36,11 @@ - 单据号: + 单据编号: - 入库时间: + 单据日期: @@ -64,39 +69,37 @@ 发货仓库: - + - 入库时间: + 单据日期: - + - 供应商: + 收货单位: - + - 采购人: + 经手人: - + - 经手人: + 收款账户: - + - 结算方式: + 收款金额: - - 现金 - 记账 - + - 备注: + 单据编号: - + - 单据号: - + 单据备注: + + @@ -119,38 +122,38 @@ 发货仓库: - + - 入库时间: - + 单据日期: + - 供应商: - + 收货单位: + - 采购人: - + 经手人: + - 仓管员: + 收款账户: - + - 结算方式: + 收款金额: - + - 备注: - - - - 单据号: + 单据编号: + + 单据备注: + + @@ -164,6 +167,7 @@ + - - - - + + + + + + + @@ -86,7 +91,7 @@ 付款金额: - + 单据编号: @@ -114,7 +119,7 @@ - + 收货仓库: @@ -135,19 +140,19 @@ 付款账户: - + 付款金额: - + 单据编号: - + 单据备注: - + @@ -158,1010 +163,7 @@ - + - -