Index: ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationView.js =================================================================== diff -u -r36704 -r36804 --- ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationView.js (.../operationReservationView.js) (revision 36704) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationView.js (.../operationReservationView.js) (revision 36804) @@ -26,13 +26,24 @@ //删除grid明细 function deleteItem(tousseDefinitionId) { - var rootNode = top.Ext.getCmp('operationReservationGrid').getRootNode(); - rootNode.eachChild(function (pNode) { - if (pNode.attributes.tousseDefinitionId == tousseDefinitionId) { - pNode.remove(); - return false; + if (top.Ext.getCmp('operationReservationGrid').getRootNode) { + var rootNode = top.Ext.getCmp('operationReservationGrid').getRootNode(); + rootNode.eachChild(function (pNode) { + if (pNode.attributes.tousseDefinitionId == tousseDefinitionId) { + pNode.remove(); + return false; + } + }); + } else { + var gridStore = top.Ext.getCmp('operationReservationGrid').getStore(); + for (var i = 0; i < gridStore.getCount(); i++) { + var record = gridStore.getAt(i); + if (record.data.tousseDefinitionId == tousseDefinitionId) { + gridStore.remove(record); + break; + } } - }); + } } //Ext.form.DateField在IE8下显示不全 Ext.override(top.Ext.menu.Menu, { @@ -41,7 +52,14 @@ } }); +var goodsItemRecord = Ext.data.Record.create([ + { name: 'itemId' }, + { name: 'tousseDefinitionId' }, + { name: 'name' }, + { name: 'amount' } +]); + function saveOrSubmitForm(id, isCommit) { var form = top.Ext.getCmp("materialInvoiceForm"); if (!form.getForm().isValid()) { @@ -53,21 +71,39 @@ showResult('手术名称不能为空!'); return false; } - var rootNode = top.Ext.getCmp('operationReservationGrid').getRootNode(); - if (!rootNode.hasChildNodes()) { - showResult('请添加物品项!'); - return false; - } var jsonArray = new Array(); - rootNode.eachChild(function (pNode) { - var po = pNode.attributes; - jsonArray.push({ - itemId: po.itemId, - tousseDefinitionId: po.tousseDefinitionId, - name: po.name, - amount: po.amount + if (top.Ext.getCmp('operationReservationGrid').getRootNode) { + var rootNode = top.Ext.getCmp('operationReservationGrid').getRootNode(); + if (!rootNode.hasChildNodes()) { + showResult('请添加物品项!'); + return false; + } + rootNode.eachChild(function (pNode) { + var po = pNode.attributes; + jsonArray.push({ + itemId: po.itemId, + tousseDefinitionId: po.tousseDefinitionId, + name: po.name, + amount: po.amount + }); }); - }); + } else { + var store = top.Ext.getCmp('operationReservationGrid').getStore(); + if (store.getCount() <= 0) { + showResult('请添加物品项!'); + return false; + } + var jsonArray = new Array(); + for (var i = 0; i < store.getCount(); i++) { + var record = store.getAt(i); + jsonArray.push({ + itemId: record.data.itemId, + tousseDefinitionId: record.data.tousseDefinitionId, + name: record.data.name, + amount: record.data.amount + }); + } + } var params = { id: id, @@ -146,15 +182,15 @@ } //删除所有节点 -function removeAllTousse(){ +function removeAllTousse() { var rootNode = top.Ext.getCmp('operationReservationGrid').getRootNode(); if (rootNode.childNodes.length > 0) { var deleteNodes = []; rootNode.eachChild(function (pNode) { deleteNodes.push(pNode); }); - if(deleteNodes.length > 0){ - for(var i=0;i 0) { + for (var i = 0; i < deleteNodes.length; i++) { rootNode.removeChild(deleteNodes[i]) } } @@ -171,27 +207,50 @@ showResult("请填写数量!"); return false; } - var rootNode = top.Ext.getCmp('operationReservationGrid').getRootNode(); var isExist = false; - rootNode.eachChild(function (pNode) { - if (pNode.attributes.name == name) { - isExist = true; - return false; + if (top.Ext.getCmp('operationReservationGrid').getRootNode) { + var rootNode = top.Ext.getCmp('operationReservationGrid').getRootNode(); + rootNode.eachChild(function (pNode) { + if (pNode.attributes.name == name) { + isExist = true; + return false; + } + }); + } else { + var store = top.Ext.getCmp('operationReservationGrid').getStore(); + var count = store.getCount(); + for (var i = 0; i < count; i++) { + var record = store.getAt(i); + if (record.get("name") == name) { + isExist = true; + break; + } } - }); + } if (!isExist) { //添加操作 - var parentNode = createTousseNode(true, itemId, tousseDefinitionId, name, amount, goodIndex); - if (tousseStorageInfos && tousseStorageInfos.length > 0) { - for (var i = 0; i < tousseStorageInfos.length; i++) { - var accessStatus = tousseStorageInfos[i].accessStatus; - var barcode = tousseStorageInfos[i].barcode; - var storageName = tousseStorageInfos[i].storageName; - var childNode = createTousseNode(false, itemId, tousseDefinitionId, name, 1, '', accessStatus, barcode, storageName); - parentNode.appendChild(childNode); + if (top.Ext.getCmp('operationReservationGrid').getRootNode) { + var parentNode = createTousseNode(true, itemId, tousseDefinitionId, name, amount, goodIndex); + if (tousseStorageInfos && tousseStorageInfos.length > 0) { + for (var i = 0; i < tousseStorageInfos.length; i++) { + var accessStatus = tousseStorageInfos[i].accessStatus; + var barcode = tousseStorageInfos[i].barcode; + var storageName = tousseStorageInfos[i].storageName; + var childNode = createTousseNode(false, itemId, tousseDefinitionId, name, 1, '', accessStatus, barcode, storageName); + parentNode.appendChild(childNode); + } } + rootNode.appendChild(parentNode); + } else { + var materialInvoiceItem = new goodsItemRecord({ + itemId: itemId, + tousseDefinitionId: tousseDefinitionId, + name: name, + amount: amount + }); + store.add(materialInvoiceItem); } - rootNode.appendChild(parentNode); + top.Ext.getCmp('goodsName').setValue(''); top.Ext.getCmp('amount').setValue(''); top.Ext.getCmp('goodsName').focus(); @@ -379,144 +438,288 @@ } } }); - var gridPanel = new top.Ext.tree.ColumnTree({ - id: 'operationReservationGrid', - rootVisible: false, - autoScroll: true, - bodyStyle: 'border:1px solid #afd7af', - containerScroll: true, - width: (document.body.clientWidth > 700) ? 665 : (document.body.clientWidth - 80), - height: (document.body.clientHeight > 600) ? 350 : (document.body.clientHeight - 300), - columns: [{ - header: '序号', - width: 50, - dataIndex: 'goodIndex' - }, { - header: '物品名称', - width: 170, - dataIndex: 'name' - }, { - header: '数量', - width: 80, - dataIndex: 'amount' - }, { - header: '条码', - width: 80, - dataIndex: 'barcode', - hidden: !sstsConfig.enableWarehousePositionModuleInterfaceWithKardexContainer - }, { - header: '存取状态', - width: 80, - dataIndex: 'accessStatus', - hidden: !sstsConfig.enableWarehousePositionModuleInterfaceWithKardexContainer - }, { - header: '托盘名称', - width: 80, - dataIndex: 'storageName', - hidden: !sstsConfig.enableWarehousePositionModuleInterfaceWithKardexContainer - }, { - header: '删除', - width: 80, - dataIndex: 'deleteButton', - renderer: renderDeleteButton - }], - tbar: [{ - text: '手术名称:' - }, { - xtype: 'combo', - queryParam: 'spell', - minChars: 0, - valueField: 'id', - displayField: 'operationName', - store: operationNameStore, - forceSelection: false, - lazyInit: true, - triggerAction: 'all', - hideTrigger: false, - typeAhead: false, - editable: true, - width: 300, - name: "operation", - id: "operation", - anchor: '98%', - listeners: { - select: function (combo, record, index) { + var gridPanel; + if (sstsConfig.enableOperationReservationShippedToTraysOfKardexContainer && deliverStatus !== '待发货') { + gridPanel = new top.Ext.tree.ColumnTree({ + id: 'operationReservationGrid', + rootVisible: false, + autoScroll: true, + bodyStyle: 'border:1px solid #afd7af', + containerScroll: true, + width: (document.body.clientWidth > 700) ? 665 : (document.body.clientWidth - 80), + height: (document.body.clientHeight > 600) ? 350 : (document.body.clientHeight - 300), + columns: [{ + header: '序号', + width: 50, + dataIndex: 'goodIndex' + }, { + header: '物品名称', + width: 170, + dataIndex: 'name' + }, { + header: '数量', + width: 80, + dataIndex: 'amount' + }, { + header: '条码', + width: 80, + dataIndex: 'barcode' + }, { + header: '存取状态', + width: 80, + dataIndex: 'accessStatus' + }, { + header: '托盘名称', + width: 80, + dataIndex: 'storageName' + }, { + header: '删除', + width: 80, + dataIndex: 'deleteButton', + renderer: renderDeleteButton + }], + tbar: [{ + text: '手术名称:' + }, { + xtype: 'combo', + queryParam: 'spell', + minChars: 0, + valueField: 'id', + displayField: 'operationName', + store: operationNameStore, + forceSelection: false, + lazyInit: true, + triggerAction: 'all', + hideTrigger: false, + typeAhead: false, + editable: true, + width: 300, + name: "operation", + id: "operation", + anchor: '98%', + listeners: { + select: function (combo, record, index) { - top.Ext.getCmp("operationName").setValue(combo.getRawValue()); - removeAllTousse(); - var items = record.get("items"); - if (items != null) { - for (var i = 0; i < items.length; i++) { - addItems("", items[i].tousseDefinitionId, items[i].name, items[i].amount, (i + 1)); + top.Ext.getCmp("operationName").setValue(combo.getRawValue()); + removeAllTousse(); + var items = record.get("items"); + if (items != null) { + for (var i = 0; i < items.length; i++) { + addItems("", items[i].tousseDefinitionId, items[i].name, items[i].amount, (i + 1)); + } } } } - } - }], - listeners: { - render: function () { - var tbar = new top.Ext.Toolbar({ - items: [{ - text: '物品名称:' - }, { - xtype: 'combo', - id: 'goodsName', - name: 'goodsName', - queryParam: 'spell', - fieldLabel: '物品名称', - minChars: 0, - valueField: 'id', - displayField: 'displayName', - anchor: '100%', - width: (document.body.clientWidth > 700) ? 300 : 200, - store: tousseAndDiposableGoodsStore, - lazyInit: true, - triggerAction: 'all', - hideTrigger: true, - typeAhead: false, - forceSelection: true, - allowBlank: true - }, { - text: ' 数量:' - }, { - xtype: 'textfield', - maxLength: '16', - id: 'amount', - name: 'amount', - width: 70, - regex: /^\d+$/, - regexText: '只能输入数字', - anchor: '100%', - listeners: { - specialkey: function (field, e) { - if (e.getKey() == Ext.EventObject.ENTER) { - var tousseDefinitionId = top.Ext.getCmp('goodsName').getValue(); - var name = top.Ext.getCmp('goodsName').getRawValue() - var amount = top.Ext.getCmp('amount').getValue(); - addItems("", tousseDefinitionId, name, amount); + }], + listeners: { + render: function () { + var tbar = new top.Ext.Toolbar({ + items: [{ + text: '物品名称:' + }, { + xtype: 'combo', + id: 'goodsName', + name: 'goodsName', + queryParam: 'spell', + fieldLabel: '物品名称', + minChars: 0, + valueField: 'id', + displayField: 'displayName', + anchor: '100%', + width: (document.body.clientWidth > 700) ? 300 : 200, + store: tousseAndDiposableGoodsStore, + lazyInit: true, + triggerAction: 'all', + hideTrigger: true, + typeAhead: false, + forceSelection: true, + allowBlank: true + }, { + text: ' 数量:' + }, { + xtype: 'textfield', + maxLength: '16', + id: 'amount', + name: 'amount', + width: 70, + regex: /^\d+$/, + regexText: '只能输入数字', + anchor: '100%', + listeners: { + specialkey: function (field, e) { + if (e.getKey() == Ext.EventObject.ENTER) { + var tousseDefinitionId = top.Ext.getCmp('goodsName').getValue(); + var name = top.Ext.getCmp('goodsName').getRawValue() + var amount = top.Ext.getCmp('amount').getValue(); + addItems("", tousseDefinitionId, name, amount); + } } } + }, { + text: '添加', + iconCls: 'btn_ext_add', + handler: function () { + var tousseDefinitionId = top.Ext.getCmp('goodsName').getValue(); + var name = top.Ext.getCmp('goodsName').getRawValue() + var amount = top.Ext.getCmp('amount').getValue(); + addItems("", tousseDefinitionId, name, amount); + } } - }, { - text: '添加', - iconCls: 'btn_ext_add', - handler: function () { - var tousseDefinitionId = top.Ext.getCmp('goodsName').getValue(); - var name = top.Ext.getCmp('goodsName').getRawValue() - var amount = top.Ext.getCmp('amount').getValue(); - addItems("", tousseDefinitionId, name, amount); + ] + }); + tbar.render(top.Ext.getCmp('operationReservationGrid').tbar); + } + }, + root: new top.Ext.tree.AsyncTreeNode({ + text: '器械包' + }) + }); + } else { + gridPanel = new top.Ext.grid.EditorGridPanel({ + id: 'operationReservationGrid', + bodyStyle: 'border:1px solid #afd7af', + frame: false, + viewConfig: { + forceFit: true + }, + store: new Ext.data.Store({ + proxy: new Ext.data.HttpProxy({ + url: WWWROOT + '/disinfectSystem/materialInvoiceAction!getMaterialInvoiceItemsByMaterialInvoiceId.do', + method: 'POST' + }), + reader: new Ext.data.JsonReader({ + fields: [ + { name: 'id' }, + { name: 'materialDefinitionId' }, + { name: 'materialName' }, + { name: 'userecordId' }, + { name: 'userecordName' }, + { name: 'userecordDepartCoding' }, + { name: 'amount' }, + { name: 'deleteButton' } + ] + }) + }), + cm: new Ext.grid.ColumnModel([new Ext.grid.RowNumberer({ header: "序号", width: 40 }), + { header: "itemId", dataIndex: 'itemId', hidden: true }, + { header: "tousseDefinitionId", dataIndex: 'tousseDefinitionId', hidden: true }, + { header: "物品名称", dataIndex: 'name', width: 170, menuDisabled: true }, + { + header: " 数量", dataIndex: 'amount', width: 80, menuDisabled: true, + editor: new Ext.form.TextField({ + regex: /^\d+$/, + regexText: '只能输入数字', + allowBlank: false + }) + }, + { header: "删除", width: 80, menuDisabled: true, dataIndex: 'deleteButton', id: 'expandColumn', renderer: renderDeleteButton } + ]), + width: (document.body.clientWidth > 700) ? 665 : (document.body.clientWidth - 80), + height: (document.body.clientHeight > 600) ? 350 : (document.body.clientHeight - 300), + autoExpandColumn: 'expandColumn', + clicksToEdit: 1,// 设置点击几次才可编辑 + selModel: new top.Ext.grid.RowSelectionModel({ + singleSelect: false + }), + tbar: [{ + text: '手术名称:' + }, { + xtype: 'combo', + queryParam: 'spell', + minChars: 0, + valueField: 'id', + displayField: 'operationName', + store: operationNameStore, + forceSelection: false, + lazyInit: true, + triggerAction: 'all', + hideTrigger: false, + typeAhead: false, + editable: true, + width: 300, + name: "operation", + id: "operation", + anchor: '98%', + listeners: { + select: function (combo, record, index) { + + top.Ext.getCmp("operationName").setValue(combo.getRawValue()); + var store = top.Ext.getCmp('operationReservationGrid').getStore(); + store.removeAll(); + + var items = record.get("items"); + if (items != null) { + for (var i = 0; i < items.length; i++) { + addItems("", items[i].tousseDefinitionId, items[i].name, items[i].amount); + } } } - ] - }); - tbar.render(top.Ext.getCmp('operationReservationGrid').tbar); + } } - }, - root: new top.Ext.tree.AsyncTreeNode({ - text: '器械包' + ], + listeners: { + render: function () { + var tbar = new top.Ext.Toolbar({ + items: [{ + text: '物品名称:' + }, { + xtype: 'combo', + id: 'goodsName', + name: 'goodsName', + queryParam: 'spell', + fieldLabel: '物品名称', + minChars: 0, + valueField: 'id', + displayField: 'displayName', + anchor: '100%', + width: (document.body.clientWidth > 700) ? 300 : 200, + store: tousseAndDiposableGoodsStore, + lazyInit: true, + triggerAction: 'all', + hideTrigger: true, + typeAhead: false, + forceSelection: true, + allowBlank: true + }, { + text: ' 数量:' + }, { + xtype: 'textfield', + maxLength: '16', + id: 'amount', + name: 'amount', + width: 70, + regex: /^\d+$/, + regexText: '只能输入数字', + anchor: '100%', + listeners: { + specialkey: function (field, e) { + if (e.getKey() == Ext.EventObject.ENTER) { + var tousseDefinitionId = top.Ext.getCmp('goodsName').getValue(); + var name = top.Ext.getCmp('goodsName').getRawValue() + var amount = top.Ext.getCmp('amount').getValue(); + addItems("", tousseDefinitionId, name, amount); + } + } + } + }, { + text: '添加', + iconCls: 'btn_ext_add', + handler: function () { + var tousseDefinitionId = top.Ext.getCmp('goodsName').getValue(); + var name = top.Ext.getCmp('goodsName').getRawValue() + var amount = top.Ext.getCmp('amount').getValue(); + addItems("", tousseDefinitionId, name, amount); + } + } + ] + }); + tbar.render(top.Ext.getCmp('operationReservationGrid').tbar); + } + } }) - }); + } + var form = new top.Ext.FormPanel({ id: 'materialInvoiceForm', frame: true, @@ -794,10 +997,10 @@ layout: 'form', columnWidth: .33, items: [{ - xtype:'hidden', - id:'storageLocationAddr', - name:'storageLocationAddr' - },{ + xtype: 'hidden', + id: 'storageLocationAddr', + name: 'storageLocationAddr' + }, { xtype: 'combo', id: 'storageLocationAddrName', name: 'storageLocationAddrName', @@ -815,10 +1018,10 @@ fields: ['queryMode', 'queryValue'], data: [['一号开口', 'S01-1'], ['二号开口', 'S01-2'], ['三号开口', 'S01-3']] }), - listeners:{ - select:function(combo, record, index){ - top.Ext.getCmp('storageLocationAddr').setValue(record.data.queryValue); - } + listeners: { + select: function (combo, record, index) { + top.Ext.getCmp('storageLocationAddr').setValue(record.data.queryValue); + } } }] }, {