Index: ssts-web/src/main/webapp/disinfectsystem/borrowRecord/borrowRecordView.js =================================================================== diff -u -r32850 -r33461 --- ssts-web/src/main/webapp/disinfectsystem/borrowRecord/borrowRecordView.js (.../borrowRecordView.js) (revision 32850) +++ ssts-web/src/main/webapp/disinfectsystem/borrowRecord/borrowRecordView.js (.../borrowRecordView.js) (revision 33461) @@ -8,28 +8,28 @@ var isClickAdd = false; var isClickDel = false; -function createTousseAndInstanceNode(isParentNode,id,name,amount,type){ +function createTousseAndInstanceNode(isParentNode, id, name, amount, type) { var node; - if(isParentNode){ + if (isParentNode) { //创建父节点 node = new top.Ext.tree.TreeNode({ - id:Ext.id(), - text:name, - cls:'master-task', - iconCls:'task-folder', - uiProvider:top.Ext.tree.ColumnNodeUI, - leaf:false, - expanded:true + id: Ext.id(), + text: name, + cls: 'master-task', + iconCls: 'task-folder', + uiProvider: top.Ext.tree.ColumnNodeUI, + leaf: false, + expanded: true }); - }else{ + } else { //创建子节点 node = new top.Ext.tree.TreeNode({ - id:Ext.id(), - text:name, - iconCls:'task', - uiProvider:top.Ext.tree.ColumnNodeUI, - leaf:true, - expanded:true + id: Ext.id(), + text: name, + iconCls: 'task', + uiProvider: top.Ext.tree.ColumnNodeUI, + leaf: true, + expanded: true }); } node.attributes.id = id; @@ -39,36 +39,36 @@ return node; } -function addTousseItem(){ +function addTousseItem() { var name = top.Ext.getCmp('package1').getValue(); var count = top.Ext.getCmp('count1').getValue(); - if(name == ""){ + if (name == "") { showResult('请选择器械包!'); top.Ext.getCmp('package1').setValue(""); top.Ext.getCmp('package1').focus(); - }else if(count == ""){ + } else if (count == "") { showResult("请输入数量,数量必须大于0!"); - }else if(name != "" && count != ""){ + } else if (name != "" && count != "") { var isTousseExist = false; var rootNode = top.Ext.getCmp('borrowRecordItemTree').getRootNode(); - rootNode.eachChild(function(cNode){ - if(cNode.attributes.name == name){ - isTousseExist = true; + rootNode.eachChild(function (cNode) { + if (cNode.attributes.name == name) { + isTousseExist = true; return false; } }); - if(isTousseExist){ + if (isTousseExist) { showResult("该器械包已经在借还明细中,不能重复添加。"); return false; - }else{ - var tousseNode = createTousseAndInstanceNode(true,'',name,count,null); + } else { + var tousseNode = createTousseAndInstanceNode(true, '', name, count, null); rootNode.appendChild(tousseNode); top.Ext.getCmp('package1').setValue(""); top.Ext.getCmp('count1').setValue(""); top.Ext.getCmp('package1').focus(); } } - + } // 删除 @@ -81,8 +81,8 @@ } var ids = ""; for (var i = 0, len = records.length; i < len; i++) { - if(records[i].data['status'] != statusArr[0]){ - showResult("不能删除"+records[i].data['status']+"的借还信息!"); + if (records[i].data['status'] != statusArr[0]) { + showResult("不能删除" + records[i].data['status'] + "的借还信息!"); return false; } if (ids == "") { @@ -91,13 +91,13 @@ ids = ids + ';' + records[i].data['id']; } } - Ext.MessageBox.confirm("请确认", "是否确定要删除选中的" + entityName + "信息?", function( - button, text) { + Ext.MessageBox.confirm("请确认", "是否确定要删除选中的" + entityName + "信息?", function ( + button, text) { if ("yes" == button) { Ext.Ajax.request({ - url : WWWROOT + '/disinfectSystem/borrowRecordAction!deleteBorrowRecord.do', - params : {ids : ids}, - success : function(response, options) { + url: WWWROOT + '/disinfectSystem/borrowRecordAction!deleteBorrowRecord.do', + params: { ids: ids }, + success: function (response, options) { var result = Ext.decode(response.responseText); var success = result.success; if (true != success) { @@ -108,7 +108,7 @@ grid.dwrReload(); } }, - failure : function(response, options) { + failure: function (response, options) { var result = Ext.decode(response.responseText); MsgTip.msg('提示', result.cause, true, 3); } @@ -131,11 +131,11 @@ addOrEditBorrowRecord(records[0].data.id); } -function showTbar(){ +function showTbar() { top.Ext.getCmp('borrowRecordItemTree').getTopToolbar().show(); } -function hideTbar(){ +function hideTbar() { top.Ext.getCmp('borrowRecordItemTree').getTopToolbar().hide(); } @@ -145,105 +145,106 @@ */ function addOrEditBorrowRecord(id) { borrowedRecordItemTree = new top.Ext.tree.ColumnTree({ - id : 'borrowRecordItemTree', - height : 335, - rootVisible : false, + id: 'borrowRecordItemTree', + height: 335, + rootVisible: false, //autoScroll : true, //containerScroll : true, - columns : [ - {header : '名称',width : 492,dataIndex : 'name'}, - {header : '数量',width : 70,dataIndex : 'amount'}, - {header : '删除',width : 60,dataIndex : 'id', - renderer : function(v, p, record) { - var str = ""; - if (v == 'invoiceItem') { - str = ""; + columns: [ + { header: '名称', width: 492, dataIndex: 'name' }, + { header: '数量', width: 70, dataIndex: 'amount' }, + { + header: '删除', width: 60, dataIndex: 'id', + renderer: function (v, p, record) { + var str = ""; + if (v == 'invoiceItem') { + str = ""; + } + return str; } - return str; - } - }], - tbar : [{ - id : 'barcodeText', - text : '条码:' - },{ - xtype : 'textfield', - fieldLabel : '条码', - name : 'barcode', - id : 'barcode', - listeners : { - specialkey : function(field, ee) { + }], + tbar: [{ + id: 'barcodeText', + text: '条码:' + }, { + xtype: 'textfield', + fieldLabel: '条码', + name: 'barcode', + id: 'barcode', + listeners: { + specialkey: function (field, ee) { if (ee.getKey() == Ext.EventObject.ENTER) { - if(top.Ext.getCmp('barcode').getValue() == ''){ + if (top.Ext.getCmp('barcode').getValue() == '') { showResult('请扫描正确的条码。'); return false; } Ext.Ajax.request({ - url : WWWROOT + '/disinfectSystem/borrowRecordAction!loadTousseInstanceInfo.do', - params : {id:top.Ext.getCmp('id').getValue(),barcode : top.Ext.getCmp('barcode').getValue()}, - success : function(response, options) { + url: WWWROOT + '/disinfectSystem/borrowRecordAction!loadTousseInstanceInfo.do', + params: { id: top.Ext.getCmp('id').getValue(), barcode: top.Ext.getCmp('barcode').getValue() }, + success: function (response, options) { var result = Ext.decode(response.responseText); if (result != null && result != "null" && result.success) { var rootNode = top.Ext.getCmp('borrowRecordItemTree').getRootNode(); var isTousseExist = false; var needToBeReplacedNode = null; var newNode = null; - rootNode.eachChild(function(borrowNode) { - if(borrowNode.attributes.name == result.name){ + rootNode.eachChild(function (borrowNode) { + if (borrowNode.attributes.name == result.name) { isTousseExist = true; var isExisted = false; var nodesAmount = 1; - borrowNode.eachChild(function(tousseInstanceNode){ - if(tousseInstanceNode.attributes.name == result.barcode && tousseInstanceNode.attributes.amount == result.type){ + borrowNode.eachChild(function (tousseInstanceNode) { + if (tousseInstanceNode.attributes.name == result.barcode && tousseInstanceNode.attributes.amount == result.type) { isExisted = true; } - if(tousseInstanceNode.attributes.amount == result.type){ - nodesAmount=nodesAmount+1; + if (tousseInstanceNode.attributes.amount == result.type) { + nodesAmount = nodesAmount + 1; } }); - if(isExisted){ + if (isExisted) { showResult('该器械包已经存在于列表中,不能重复扫描。'); return false; } - if(nodesAmount > borrowNode.attributes.amount){ - if(result.type == "归还"){ + if (nodesAmount > borrowNode.attributes.amount) { + if (result.type == "归还") { showResult('归还物品数量不能大于借物数量!'); return false; } - newNode = createTousseAndInstanceNode(true,'',result.name,borrowNode.attributes.amount+1,null); - var instanceNode = createTousseAndInstanceNode(false,'',result.barcode,result.type,''); + newNode = createTousseAndInstanceNode(true, '', result.name, borrowNode.attributes.amount + 1, null); + var instanceNode = createTousseAndInstanceNode(false, '', result.barcode, result.type, ''); borrowNode.appendChild(instanceNode); needToBeReplacedNode = borrowNode; return false; } - var instanceNode = createTousseAndInstanceNode(false,'',result.barcode,result.type,''); + var instanceNode = createTousseAndInstanceNode(false, '', result.barcode, result.type, ''); borrowNode.appendChild(instanceNode); } }); - - if(needToBeReplacedNode != null){ + + if (needToBeReplacedNode != null) { var childNodes = needToBeReplacedNode.childNodes; - for(var i = 0;i 0){ + if (items.length > 0) { top.Ext.getCmp('tousseItems').setValue(JSON.stringify(items)); } } @@ -693,171 +694,171 @@ function renderColor(v, p, record) { var color = ""; - if(record.data.status == statusArr[0]){ + if (record.data.status == statusArr[0]) { color = "#F5A7FA"; - }else if(record.data.status == statusArr[1]){ + } else if (record.data.status == statusArr[1]) { color = "orange"; - }else if(record.data.status == statusArr[2]){ + } else if (record.data.status == statusArr[2]) { color = "yellow"; } return "

" + v + "

"; } -function getSelectedIds(){ +function getSelectedIds() { var records = grid.getSelectionModel().getSelections(); if (records.length == 0) { showResult("请选择要打印的单!"); return false; } var ids = []; - for ( var i = 0, len = records.length; i < len; i++) { + for (var i = 0, len = records.length; i < len; i++) { ids.push(records[i].data['id']); } return ids; } -function dateTimeFormat(date){ - if(date == null){ +function dateTimeFormat(date) { + if (date == null) { return ""; } - return Ext.util.Format.date(new Date(date.time),"Y-m-d H:i"); + return Ext.util.Format.date(new Date(date.time), "Y-m-d H:i"); } -function printBorrowRecordLocal(printType,borrowRecordid){ - if(borrowRecordid == null) - return; - top.Ext.MessageBox.show({ - title:'请等待', - msg:'打印中……', - width:350, - progress:true, - closable:false - }); - Ext.Ajax.timeout=300*000; - Ext.Ajax.request({ - timeout: 300*000, - url : WWWROOT + '/disinfectSystem/borrowRecordAction!loadPrintData.do', - params : {id : borrowRecordid}, - success : function(response){ - var result = Ext.decode(response.responseText); - result.goods=result.items; - result.formTypeOfPrinted = 'borrowRecord'; - result.lendingTime=dateTimeFormat(result.lendingTime); - result.receivingTime=dateTimeFormat(result.receivingTime); - printBorrowRecord(result, printType); - hideMessageBox(true); - }, - failure: function(response){ - showResult("打印失败!"); - hideMessageBox(true); - } - }); +function printBorrowRecordLocal(printType, borrowRecordid) { + if (borrowRecordid == null) + return; + top.Ext.MessageBox.show({ + title: '请等待', + msg: '打印中……', + width: 350, + progress: true, + closable: false + }); + Ext.Ajax.timeout = 300 * 000; + Ext.Ajax.request({ + timeout: 300 * 000, + url: WWWROOT + '/disinfectSystem/borrowRecordAction!loadPrintData.do', + params: { id: borrowRecordid }, + success: function (response) { + var result = Ext.decode(response.responseText); + result.goods = result.items; + result.formTypeOfPrinted = 'borrowRecord'; + result.lendingTime = dateTimeFormat(result.lendingTime); + result.receivingTime = dateTimeFormat(result.receivingTime); + printBorrowRecord(result, printType); + hideMessageBox(true); + }, + failure: function (response) { + showResult("打印失败!"); + hideMessageBox(true); + } + }); } -Ext.onReady(function() { +Ext.onReady(function () { Ext.QuickTips.init(); var columns = [ - {header : "借用科室",width : 120,dataIndex : 'departName',renderer : renderCallModifyFunction}, - {header : "借出科室",width : 120,dataIndex : 'rentalDepartName'}, - {header : "状态",width : 80,dataIndex : 'status',renderer : renderColor}, - {header : "出借人",width : 80,dataIndex : 'lender'}, - {header : "出借时间",width : 120,dataIndex : 'lendingTime',renderer : myDateFormatByMinute}, - {header : "接收者",width : 80,dataIndex : 'receiver'}, - {header : "接收时间",width : 120,dataIndex : 'receivingTime',renderer : myDateFormatByMinute}, - {id : 'operationRemark',header : "备注",width : 80,dataIndex : 'remark'} + { header: "借用科室", width: 120, dataIndex: 'departName', renderer: renderCallModifyFunction }, + { header: "借出科室", width: 120, dataIndex: 'rentalDepartName' }, + { header: "状态", width: 80, dataIndex: 'status', renderer: renderColor }, + { header: "出借人", width: 80, dataIndex: 'lender' }, + { header: "出借时间", width: 120, dataIndex: 'lendingTime', renderer: myDateFormatByMinute }, + { header: "接收者", width: 80, dataIndex: 'receiver' }, + { header: "接收时间", width: 120, dataIndex: 'receivingTime', renderer: myDateFormatByMinute }, + { id: 'operationRemark', header: "备注", width: 80, dataIndex: 'remark' } ]; var readerDetail = [ - {name : 'id'}, - {name : 'departName'}, - {name : 'rentalDepartName'}, - {name : 'status'}, - {name : 'lendingTime'}, - {name : 'receivingTime'}, - {name : 'lender'}, - {name : 'receiver'}, - {name : 'remark'} + { name: 'id' }, + { name: 'departName' }, + { name: 'rentalDepartName' }, + { name: 'status' }, + { name: 'lendingTime' }, + { name: 'receivingTime' }, + { name: 'lender' }, + { name: 'receiver' }, + { name: 'remark' } ]; var filters = new Ext.grid.GridFilters({ - filters : [ - {type : 'string',dataIndex : 'departName'}, - {type : 'string',dataIndex : 'rentalDepartName'}, - {type : 'list',dataIndex : 'status',options : statusArr,phpMode : true}, - {type : 'date',dataIndex : 'lendingTime'}, - {type : 'date',dataIndex : 'receivingTime'}, - {type : 'string',dataIndex : 'lender'}, - {type : 'string',dataIndex : 'receiver'}, - {type : 'string',dataIndex : 'remark'} + filters: [ + { type: 'string', dataIndex: 'departName' }, + { type: 'string', dataIndex: 'rentalDepartName' }, + { type: 'list', dataIndex: 'status', options: statusArr, phpMode: true }, + { type: 'date', dataIndex: 'lendingTime' }, + { type: 'date', dataIndex: 'receivingTime' }, + { type: 'string', dataIndex: 'lender' }, + { type: 'string', dataIndex: 'receiver' }, + { type: 'string', dataIndex: 'remark' } ] }); var tbar = [{ - text : '添加', - iconCls : 'btn_ext_application_add', - hidden : SSTS_borrowRecord_Create, - handler : function() { + text: '添加', + iconCls: 'btn_ext_application_add', + hidden: SSTS_borrowRecord_Create, + handler: function () { addOrEditBorrowRecord(); } }, '-', { - text : '修改', - iconCls : 'btn_ext_application_edit', - id : 'editTbar', - hidden : SSTS_borrowRecord_Update, - handler : function() { + text: '修改', + iconCls: 'btn_ext_application_edit', + id: 'editTbar', + hidden: SSTS_borrowRecord_Update, + handler: function () { loadFormData(grid); } }, '-', { - text : '删除', - iconCls : 'btn_ext_application_del', - hidden : SSTS_borrowRecord_Delete, - handler : function() { + text: '删除', + iconCls: 'btn_ext_application_del', + hidden: SSTS_borrowRecord_Delete, + handler: function () { deleteBorrowRecord(grid); } - },'-',{ - text : '打印', - iconCls : 'icon_print', - hidden : SSTS_borrowRecord_Select, - handler : function() { - var ids = getSelectedIds(); - if (ids && ids.length > 0){ - top.Ext.MessageBox.confirm("请确认", "要打印所选的单吗?", - function(btn) { - if (btn == 'yes') { - for (var i=0;i 0) { + top.Ext.MessageBox.confirm("请确认", "要打印所选的单吗?", + function (btn) { + if (btn == 'yes') { + for (var i = 0; i < ids.length; i++) { + printBorrowRecordLocal(0, ids[i]); + } + } + }); + } + } }]; grid = new Ext.ux.ForgonPageGrid({ - title : entityName + '列表', - tbar : tbar, - pageSize : 20, - defaultSortField : 'id', - defaultSortDirection : 'DESC', - isCheckboxSelectionModel : true, - rememberSelected : false, - isShowSearchField : true, - columns : columns, - plugins : filters, - autoExpandColumn : 'operationRemark', - renderTo : 'gridDiv', - frame : false - }, + title: entityName + '列表', + tbar: tbar, + pageSize: 20, + defaultSortField: 'id', + defaultSortDirection: 'DESC', + isCheckboxSelectionModel: true, + rememberSelected: false, + isShowSearchField: true, + columns: columns, + plugins: filters, + autoExpandColumn: 'operationRemark', + renderTo: 'gridDiv', + frame: false + }, readerDetail, BorrowRecordTableManager.findBorrowRecordTableList, null ); var viewport = new Ext.Viewport({ - layout : 'border', - items : [{ - region : 'center', - margins : '0 0 0 0', - layout : 'fit', - items : grid + layout: 'border', + items: [{ + region: 'center', + margins: '0 0 0 0', + layout: 'fit', + items: grid }] });