Index: ssts-web/src/main/webapp/systemmanage/operationNameView.js
===================================================================
diff -u -r12331 -r15387
--- ssts-web/src/main/webapp/systemmanage/operationNameView.js (.../operationNameView.js) (revision 12331)
+++ ssts-web/src/main/webapp/systemmanage/operationNameView.js (.../operationNameView.js) (revision 15387)
@@ -1,18 +1,6 @@
-//********* 按钮响应函数 ***********
-var currentClickType = '';//删除标识字符
-function setClickType(v){
- currentClickType=v;
-}
-function isClickDel(){
- return (currentClickType=='del'?true:false);
-}
-function replaceStr(str){
- var replaceV = "";
- if(str){
- replaceV = str.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,"\"");
- }
- return replaceV;
-}
+var useTousseStore;
+var tousseAndDiposableGoodsStore;
+var formWindow;
function submitForm(form,window,callMethodAction,callBack){
form.form.submit({
url : WWWROOT + '/disinfectsystem/basedatamanager/operationOrgAction!'+callMethodAction+'.do',
@@ -29,335 +17,355 @@
return true;
}
-function deleteGiveBackColumnTreeItem(clickNode){
- if(clickNode.leaf) {
- clickNode.remove();
- } else {
- var pNode = clickNode.parentNode;
- clickNode.remove();
+var goodsRecord = Ext.data.Record.create([
+ {name : 'itemId'},
+ {name : 'tousseDefinitionId'},
+ {name : 'name'},
+ {name : 'amount'}
+]);
+
+function addUseTousseItem(){
+ var goodsName = top.Ext.getCmp('goodsSearch').getValue();
+ var amount = top.Ext.getCmp('amount').getValue();
+ if(goodsName == ""){
+ showResult("请选择物品!");
+ return ;
}
-}
-function subOrgName(orgunitName){
- var index;
- if(orgunitName && (index=orgunitName.lastIndexOf(NODE_PATH_SEPARATOR))!=-1){
- orgunitName = orgunitName.substr(index+1);
+ if(amount == ""){
+ showResult("请输入数量!");
+ return ;
}
- return orgunitName;
-}
-function getItemTreeDataForOperationOrg(dataTree){
- var rootNode = dataTree.getRootNode();
- var valArr = new Array();
- rootNode.eachChild(function(pNode){
- valArr.push("{id:'");
- valArr.push("'");
- valArr.push(",orgUnitName:'");
- valArr.push(replaceStr(pNode.attributes.text));
- valArr.push("'");
- valArr.push(",orgUnitCoding:'");
- valArr.push(replaceStr(pNode.attributes.keyId));
- valArr.push("'");
- valArr.push("}");
-
- if(!pNode.isLast()){
- valArr.push(",");
- }
- });
- return valArr.join("");
-}
-function getItemTreeDataForOperationName(dataTree){
- var rootNode = dataTree.getRootNode();
- var valArr = new Array();
- rootNode.eachChild(function(pNode){
- valArr.push("{id:'");
- valArr.push("'");
- valArr.push(",operationName:'");
- valArr.push(replaceStr(pNode.attributes.text));
- valArr.push("'");
- valArr.push("}");
- if(!pNode.isLast()){
- valArr.push(",");
- }
- });
- return valArr.join("");
-}
-/**
- * 创建节点
- */
-function createChildNode(keyId,text){
- //创建子节点
- var node = new top.Ext.tree.TreeNode({
- id:Ext.id(),
- //text:'',
- iconCls:'task',
- uiProvider:top.Ext.tree.ColumnNodeUI,
- leaf:true,
- expanded:true
- });
- //********************** 节点保存的属性值 ****************************//
- node.attributes.keyId=keyId;
- node.attributes.text=text;
- return node;
-}
-
-function addItem(dataTree, isOrgUnitWin){
- var rootNode = dataTree.getRootNode();
var isExist = false;
- var templateVal = top.Ext.getCmp("templateName").getValue();
- if(templateVal == '') {
- showResult("录入的"+(isOrgUnitWin?"科室":"手术")+"名称不能为空!");
- return false;
- }
- rootNode.eachChild(function(pNode){
- if(pNode.attributes.keyId == templateVal) {
- //showResult("该科室信息已经存在当前列表中!");
+ var count = useTousseStore.getCount();
+ for(var i = 0 ; i < count ; i++){
+ var record = useTousseStore.getAt(i);
+ if(record.get("name") == goodsName){
isExist = true;
+ break;
}
- });
- if(isExist) {
- return;
}
-
- var templateName = top.Ext.getCmp("templateName").getRawValue();
- if(isOrgUnitWin){
- templateName = subOrgName(templateName);
+ if(!isExist){
+ var index = tousseAndDiposableGoodsStore.find("name",goodsName);
+ var id = tousseAndDiposableGoodsStore.getAt(index).data['id'];
+ var record = new goodsRecord({
+ itemId : "",
+ tousseDefinitionId : id,
+ name : goodsName,
+ amount : amount
+ });
+ useTousseStore.add(record);
+ top.Ext.getCmp('goodsSearch').setValue();
+ top.Ext.getCmp('amount').setValue();
+ top.Ext.getCmp('goodsSearch').focus();
+ }else{
+ showResult(goodsName + ",已添加!");
}
-
- var childNode = createChildNode(templateVal,templateName);
- rootNode.appendChild(childNode);
}
-//添加科室
-function openTreePanalWin(isOrgUnitWin){
- var textName = isOrgUnitWin?'科室名称':'手术名称';
- var dataTree = new top.Ext.tree.ColumnTree({
- rootVisible:false,
- autoScroll:true,
- bodyStyle : 'border:1px solid #afd7af',
- containerScroll : true,
-// height:220,
- columns:[{
- header:textName,
- width:380,
- dataIndex:'text'
- },{
- header:'科室编码',
- width:320,
- dataIndex:'keyId',
- hidden:true
- },{
- header:'删除',
- width:40,
- dataIndex:'del',
- renderer:function(v,p,record){
- return "
";
- }
- }],
+function deleteGoodsItem(rowIndex){
+ if(rowIndex != null){
+ var record = useTousseStore.getAt(rowIndex);
+ if(record){
+ useTousseStore.remove(record);
+ }
+ }
+}
- loader: new top.Ext.tree.TreeLoader({
- uiProviders:{
- 'col': top.Ext.tree.ColumnNodeUI
- }
- }),
+function setOperationUseTousse(id){
+ var rd = new Ext.data.JsonReader({
+ fields : [{
+ id : 'itemId',
+ tousseDefinitionId : 'tousseDefinitionId',
+ name : 'name',
+ amount : 'amount'
+ }]
+ });
+ useTousseStore = new top.Ext.data.Store({
+ proxy : new Ext.data.HttpProxy({
+ url : WWWROOT + '/jasperreports/jasperreportsAction!getGoodsOption.do',
+ method : 'POST'
+ }),
+ baseParams : {id : id},
+ reader : rd
+ });
+ useTousseStore.load();
+
+ var cm = new top.Ext.grid.ColumnModel([new top.Ext.grid.RowNumberer({header:"序号",width:40}),{
+ id:'id',
+ name:'id',
+ hidden :true,
+ dataIndex : 'id'
+ },{
+ id : 'name',
+ header : "物品名称",
+ width:240,
+ dataIndex : 'name'
+ },{
+ id : 'amount',
+ header : "数量",
+ width:100,
+ dataIndex : 'amount'
+ },{
+ id : 'deleteItem',
+ header:'删除',
+ width :80,
+ menuDisabled: true,
+ dataIndex:'button',
+ renderer: function(v,p,record,rowIndex){
+ return "
";
+ }
+ }]);
- root: new top.Ext.tree.AsyncTreeNode({
- text:'名称'
- })
- });
-
- var btArr = new Array();
- btArr.push({text:textName+':'},{
- id:'treeItemData',
- name:'treeItemData',
- xtype:'hidden'
- });
+ var searchUrl = WWWROOT + '/disinfectSystem/baseData/tousseDefinitionAction!searchComboTousseData.do';
+
+ tousseAndDiposableGoodsStore = new Ext.data.Store({
+ proxy : new Ext.data.HttpProxy({
+ url : searchUrl,
+ method : 'POST'
+ }),
+ reader : new Ext.data.JsonReader({
+ totalProperty : 'totalCount',
+ root : 'data'
+ }, [
+ {name : 'id',mapping : 'id'},
+ {name : 'spelling',mapping : 'spelling'},
+ {name : 'name',mapping : 'name'},
+ {name : 'displayName',mapping : 'displayName'},
+ {name : 'amount',mapping : 'amount'}]
+ )
+ });
- if(!isOrgUnitWin){
- var treeEditer = new top.Ext.tree.ColumnTreeEditor(dataTree, {
- completeOnEnter : true,
- autosize : true,
- allowBlank: false,
- // cancelOnEsc : true,
- revertInvalid:true,
- ignoreNoChange : true
- });
-
- treeEditer.on("beforestartedit", function(thiz,el,v){
- var tempNode = thiz.editNode;//将要编辑的节点
- if(tempNode.attributes.text==v ){
- return true;
- }else {
- return false;
- }
- });
-
- btArr.push({
- xtype : 'textfield',
- id : 'templateName',
- name : 'templateName',
- minChars : 0,
- width : 320,
- anchor : '97%',
- listeners:{
- specialkey : function(field, ee) {
- if (ee.getKey() == Ext.EventObject.ENTER) {
- addItem(dataTree, isOrgUnitWin);
- top.Ext.getCmp('templateName').setValue("");
- }
- }
+ var tbar = [ {
+ text : '选择物品'
+ },{
+ xtype : 'combo',
+ id : 'goodsSearch',
+ name : 'goodsSearch',
+ queryParam : 'spell',
+ fieldLabel : '物品名称',
+ minChars : 0,
+ valueField : 'id',
+ displayField : 'displayName',
+ anchor : '100%',
+ width:300,
+ store : tousseAndDiposableGoodsStore,
+ lazyInit : true,
+ triggerAction : 'all',
+ hideTrigger : true,
+ typeAhead : false,
+ allowBlank : true,
+ listeners : {
+ select : function(combo, record, index) {
+ top.Ext.getCmp('goodsSearch').setValue(record.data.name);
+ },
+ specialkey : function(field, e) {
+ if (e.getKey() == Ext.EventObject.ENTER) {
+ top.Ext.getCmp('amount').focus();
}
- });
- }else{
- var departJsonStore = new Ext.data.Store({
- proxy : new Ext.data.HttpProxy({
- url : WWWROOT + '/disinfectSystem/baseData/supplyRoomConfigAction!getAllOrgUnitName.do',
- method : 'POST'
- }),
- reader : new Ext.data.JsonReader({
- root : 'data'
- },[
- {name : 'id',mapping : 'id'},
- {name : 'name',mapping : 'name'}
- ]
- )
- });
-
- btArr.push({
- xtype : 'combo',
- id : 'templateName',
- name : 'templateName',
- queryParam : 'spell',
- minChars : 0,
- valueField : 'id',
- displayField : 'name',
- store : departJsonStore,
- forceSelection : true,
- lazyInit : true,
- triggerAction : 'all',
- hideTrigger : true,
- typeAhead : false,
- allowBlank : true,
- width : 320,
- anchor : '97%',
- listeners:{
- specialkey : function(field, ee) {
- if (ee.getKey() == Ext.EventObject.ENTER) {
- addItem(dataTree, isOrgUnitWin);
- top.Ext.getCmp('templateName').setValue("");
- }
- }
+ }
+ }
+ },{
+ text : '数量'
+ },{
+ xtype : 'textfield',
+ id : 'amount',
+ name : 'amount',
+ allowBlank:true,
+ width : 80,
+ regex: /^\d+$/,
+ regexText:'只能输入数字',
+ anchor : '95%',
+ tabIndex : 2,
+ listeners : {
+ specialkey : function(field, e) {
+ if (e.getKey() == Ext.EventObject.ENTER) {
+ addUseTousseItem();
}
- });
- }
- btArr.push({
- text : '添加',
- id:'addButton',
- iconCls : 'btn_ext_add',
- handler : function() {
- addItem(dataTree, isOrgUnitWin);
- top.Ext.getCmp('templateName').setValue("");
- }
- });
-
- var form = new top.Ext.FormPanel({
- id : 'operationForm',
+ }
+ }
+ },{
+ text : '添加',
+ handler:function(){
+ addUseTousseItem();
+ }
+ }];
+
+ formObj = new top.Ext.FormPanel({
+ id : 'deviceMaintenanceForm',
frame : true,
- border : 0,
- labelSeparator : ':',
- bodyStyle : 'padding:5px 5px 0px 5px',
- width : 390,
labelAlign:'right',
+ labelWidth:60,
+ labelSeparator : ':',
+ bodyStyle : 'padding:0px 0px 0px 0px',
+ autoWidth : true,
autoHeight : true,
- items : [{
- xtype:'hidden',
- id:'orgCoding',
- name:'orgCoding'
- },{
- xtype:"fieldset",
- autoScroll:true,
- height:335,
- tbar:btArr,
- items:[
- dataTree
- ]
+ autoScroll : true,
+ items:[{
+ layout : 'column',
+ items : [
+ {
+ xtype:'hidden',
+ id:'currentSelectOrgUnitCoding',
+ name:'currentSelectOrgUnitCoding'
+ },{
+ xtype : 'hidden',
+ name : 'id',
+ id : 'id'
+ },{
+ columnWidth : 1,
+ layout : 'form',
+ items : [{
+ layout : 'form',
+ items : [{
+ xtype:'textfield',
+ fieldLabel: '手术名称',
+ width : 298,
+ id: 'operationNameStr',
+ name: 'operationNameStr',
+ allowBlank: false
+ }]
+ }]
+ },{
+ columnWidth : 1,
+ layout: 'form',
+ items : [
+ new top.Ext.grid.GridPanel({
+ id : 'configGrid',
+ store : useTousseStore,
+ tbar : tbar,
+ cm : cm,
+ width : 350,
+ height: 350,
+ isCheckboxSelectionModel : true,
+ frame : false,
+ viewConfig: {
+ forceFit:true
+ },
+ bodyStyle : 'border:1px solid #afd7af',
+ anchor : '100%',
+ selModel : new top.Ext.grid.RowSelectionModel({
+ singleSelect : false
+ })
+ })
+ ]
+ }]
}],
- buttonAlign :'center',
- buttons : [{
+ buttons : [{
+ id : 'saveBtn',
text : '保存',
- id :'saveBtn',
handler : function(){
- //获取columnTreePanel数据
- var treeData = "";
- var actionMethodName = "";
- if(isOrgUnitWin){
- actionMethodName = "saveOperationOrg";
- treeData = getItemTreeDataForOperationOrg(dataTree);
- }else{
- actionMethodName = "saveOperationName";
- treeData = getItemTreeDataForOperationName(dataTree);
- top.Ext.getCmp("orgCoding").setValue(currentClickNode.attributes.keyId);
- }
- if(treeData==""){
- showResult(textName+'列表不能为空!');
+ var tempVal = top.Ext.getCmp("operationNameStr").getValue();
+ if(tempVal == ""){
+ showResult("手术名称不能为空!");
return false;
}
- top.Ext.getCmp("treeItemData").setValue("["+treeData+"]");
+ var count = useTousseStore.getCount();
+ var items = new Array();
+ var count = useTousseStore.getCount();
+ for(var i = 0 ; i < count ; i++){
+ var record = useTousseStore.getAt(i);
+ items.push({
+ itemId : record.get("itemId"),
+ tousseDefinitionId : record.get("tousseDefinitionId"),
+ name : record.get("name"),
+ amount : record.get("amount")
+ });
+ }
- var b = this;
- top.Ext.MessageBox.confirm("请确认","是否提交"+textName+"信息?",function(btn) {
- if(btn=='yes') {
- b.disable();
- submitForm(form,window,actionMethodName,function(window, action){
- if(isOrgUnitWin){
- root.reload();
- }else{
- reloadGrid();
- }
- if(action.result.saveSuccess){
- showResult("保存成功!");
- window.close();
- }else{
- showResult(textName+"【"+action.result.nameIsExist+"】已存在!");
- b.enable();
- }
- });
+ var data = {
+ orgUnitCoding : currentClickNode.attributes.keyId,
+ orgUnitName : currentClickNode.attributes.text,
+ operationName : tempVal,
+ operationNameId : id,
+ items : items
+ };
+
+ formObj.form.submit({
+ url : WWWROOT + '/disinfectsystem/basedatamanager/operationOrgAction!saveOperationName.do',
+ method : 'POST',
+ waitMsg : '正在保存数据,请稍候',
+ waitTitle : '提交表单',
+ params : {data : JSON.stringify(data)},
+ success : function(form, action) {
+ var success = action.result.success;
+ if(success){
+ reloadGrid();
+ showResult(action.result.message);
+ formWindow.close();
+ }else{
+ showResult(action.result.message);
+ }
+ },
+ failure : function(form, action) {
+ showResult(action.result.msg);
}
});
}
},{
+ id : 'cancleBtn',
text : '取消',
handler : function() {
- window.close();
+ formWindow.close();
}
}]
});
-
- var window = new top.Ext.Window( {
- id : 'orgunitForOperationApplicationWin',
- layout : 'border',
- title : '批量录入'+textName+'信息',
- width : 510,
- height : 425,
+
+ formWindow = new top.Ext.Window( {
+ id : 'deviceMaintenanceWin',
+ layout : 'fit',
+ title : '手术名称信息',
+ width : 670,
+ modal : true,
+ autoHeight : true,
border : false,
plain : true,
- modal :true,
- items : [{
- region:'center',
- width : 200,
- layout :'fit',
- items:[form]
- }]
+ items : [formObj]
});
+ formWindow.show();
- dataTree.on("beforeclick",function(clickNode){
- if(isClickDel()){//删除
- deleteGiveBackColumnTreeItem(clickNode);
- }
- setClickType('');
- });
- window.show();
+ if(id != ""){
+ Ext.Ajax.request({
+ url:WWWROOT+"/disinfectsystem/basedatamanager/operationOrgAction!loadOperationName.do",
+ params:{id : id},
+ success:function(result){
+ if(result != null){
+ var operationNameJson = JSON.parse(result.responseText);
+ top.Ext.getCmp("operationNameStr").setValue(operationNameJson.operationName);
+ var tousseItems = operationNameJson.tousseItems;
+ for(var i = 0 ;i < tousseItems.length ; i++){
+ var record = new goodsRecord({
+ itemId : tousseItems[i].itemId,
+ tousseDefinitionId : tousseItems[i].tousseDefinitionId,
+ name : tousseItems[i].name,
+ amount : tousseItems[i].amount
+ });
+ useTousseStore.add(record);
+ }
+ }
+ },
+ failure:function(){
+ showResult("加载失败,请联系管理员!");
+ }
+ });
+ }
}
-function showWin(id, tempOperationNameForEdit){
+function addOperationOrg(){
+
+ var departJsonStore = new Ext.data.Store({
+ proxy : new Ext.data.HttpProxy({
+ url : WWWROOT + '/disinfectSystem/baseData/supplyRoomConfigAction!getAllOrgUnitName.do',
+ method : 'POST'
+ }),
+ reader : new Ext.data.JsonReader({
+ root : 'data'
+ },[
+ {name : 'id',mapping : 'id'},
+ {name : 'name',mapping : 'name'}
+ ]
+ )
+ });
+
var form = new top.Ext.form.FormPanel({
id : 'operationNameWinForm',
frame : true,
@@ -369,41 +377,53 @@
autoHeight : true,
labelWidth: 75,
items: [{
- xtype:'hidden',
- id:'currentSelectOrgUnitCoding',
- name:'currentSelectOrgUnitCoding'
- },{
- xtype:'hidden',
- id:'operationNameId',
- name:'operationNameId',
- value:id
- },{
- xtype:'textfield',
- fieldLabel: '手术名称',
- width : 250,
- id: 'operationNameStr',
- name: 'operationNameStr',
- value:tempOperationNameForEdit,
- allowBlank: false
- }],
+ xtype : 'combo',
+ id : 'templateName',
+ name : 'templateName',
+ queryParam : 'spell',
+ minChars : 0,
+ fieldLabel: '科室名称',
+ valueField : 'id',
+ displayField : 'name',
+ store : departJsonStore,
+ forceSelection : true,
+ lazyInit : true,
+ triggerAction : 'all',
+ hideTrigger : true,
+ typeAhead : false,
+ allowBlank : true,
+ width : 320,
+ anchor : '97%'
+ }],
buttonAlign :'center',
buttons : [{
text : '保存',
id :'saveBtn',
handler : function(){
- var tempVal = top.Ext.getCmp("operationNameStr").getValue();
- if(tempVal==""){
- showResult("手术名称不能为空!");
+ var orgUnitCoding = top.Ext.getCmp("templateName").getValue();
+ var orgUnitName = top.Ext.getCmp("templateName").getRawValue();
+ if(orgUnitName == ""){
+ showResult("科室名称不能为空!");
return false;
}
- top.Ext.getCmp("currentSelectOrgUnitCoding").setValue(currentClickNode.attributes.keyId);
- submitForm(form,window,"updateOperationName",function(window, action){
- reloadGrid();
- if(action.result.saveSuccess){
- showResult("修改成功!");
- window.close();
- }else{
- showResult("修改失败,手术名称【"+action.result.nameIsExist+"】已存在!");
+ form.form.submit({
+ url : WWWROOT + '/disinfectsystem/basedatamanager/operationOrgAction!saveOperationOrg.do',
+ method : 'POST',
+ waitMsg : '正在保存数据,请稍候',
+ waitTitle : '提交表单',
+ params : {orgUnitCoding : orgUnitCoding , orgUnitName : orgUnitName},
+ success : function(form, action) {
+ var success = action.result.success;
+ if(success){
+ root.reload();
+ showResult(action.result.message);
+ window.close();
+ }else{
+ showResult(action.result.message);
+ }
+ },
+ failure : function(form, action) {
+ showResult(action.result.msg);
}
});
}
@@ -417,7 +437,7 @@
var window = new top.Ext.Window( {
id : 'operationNameWindow',
layout : 'border',
- title : '手术名称修改',
+ title : '添加录入科室',
width : 410,
height : 100,
border : false,
@@ -565,7 +585,8 @@
//********* 2、ForgonGrid ***********
function gotoPage(v, p, record){
///userForm.mhtml
- return "" + v + "";
+ var id = record.get("id");
+ return "" + v + "";
}
@@ -597,7 +618,7 @@
tooltip:'录入科室',
iconCls:'btn_ext_add',
hidden :false,
- handler:function(){openTreePanalWin(true);}
+ handler:function(){addOperationOrg();}
}, '-',{
text:'添加'+entityName,
tooltip:'添加'+entityName,
@@ -608,15 +629,9 @@
showResult("请先在左边视图选中需要添加手术名称所在的科室!");
return false;
}
- openTreePanalWin(false);
+ setOperationUseTousse("");
}
}, '-', {
- text:'修改'+entityName,
- tooltip:'修改'+entityName,
- iconCls:'btn_ext_refresh',
- hidden :false,
- handler:function (){editOperationName();}
- }, '-', {
text:'删除'+entityName,
tooltip:'删除选择'+entityName,
iconCls:'btn_remove',