Index: ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationView.js =================================================================== diff -u -r36581 -r36601 --- ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationView.js (.../operationReservationView.js) (revision 36581) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationView.js (.../operationReservationView.js) (revision 36601) @@ -3,6 +3,8 @@ var operationReservationWindow; var lastSelIdArray = []; var saveOrgUnitCode = null; +//是否成功取回托盘 +var sendToSuccess = false; function initQueryValueAndReload() { setQueryValues(); grid.getStore().lastOptions.params['start'] = 0; @@ -18,19 +20,18 @@ } //明细grid删除按钮 function renderDeleteButton(v, p, record, rowIndex) { - return ""; + return ""; } //删除grid明细 function deleteItem(tousseDefinitionId) { - 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; + var rootNode = top.Ext.getCmp('operationReservationGrid').getRootNode(); + rootNode.eachChild(function (pNode) { + if (pNode.attributes.tousseDefinitionId == tousseDefinitionId) { + pNode.remove(); + return false; } - } + }); } //Ext.form.DateField在IE8下显示不全 Ext.override(top.Ext.menu.Menu, { @@ -39,14 +40,7 @@ } }); -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()) { @@ -58,21 +52,21 @@ showResult('手术名称不能为空!'); return false; } - var store = top.Ext.getCmp('operationReservationGrid').getStore(); - if (store.getCount() <= 0) { + var rootNode = top.Ext.getCmp('operationReservationGrid').getRootNode(); + if (!rootNode.hasChildNodes()) { showResult('请添加物品项!'); return false; } var jsonArray = new Array(); - for (var i = 0; i < store.getCount(); i++) { - var record = store.getAt(i); + rootNode.eachChild(function (pNode) { + var po = pNode.attributes; jsonArray.push({ - itemId: record.data.itemId, - tousseDefinitionId: record.data.tousseDefinitionId, - name: record.data.name, - amount: record.data.amount + itemId: po.itemId, + tousseDefinitionId: po.tousseDefinitionId, + name: po.name, + amount: po.amount }); - } + }); var params = { id: id, @@ -115,8 +109,114 @@ } }); } +function createTousseNode(isParentNode, itemId, tousseDefinitionId, name, amount, goodIndex, accessStatus, barcode, storageName) { + var node; + if (isParentNode) { + //创建父节点 + node = new top.Ext.tree.TreeNode({ + id: Ext.id(), + text: goodIndex, + cls: 'master-task', + iconCls: 'no-node-icon', + uiProvider: top.Ext.tree.ColumnNodeUI, + leaf: false, + expanded: true + }); + } else { + //创建子节点 + node = new top.Ext.tree.TreeNode({ + id: Ext.id(), + text: goodIndex, + iconCls: 'no-node-icon', + uiProvider: top.Ext.tree.ColumnNodeUI, + leaf: true, + expanded: true + }); + } + node.attributes.itemId = itemId; + node.attributes.tousseDefinitionId = tousseDefinitionId; + node.attributes.name = name; + node.attributes.amount = amount; + node.attributes.accessStatus = accessStatus; + node.attributes.barcode = barcode; + node.attributes.storageName = storageName; + node.attributes.goodIndex = goodIndex; + return node; +} -function editOperationReservation(id, committedStatus) { +//添加明细 +function addItems(itemId, tousseDefinitionId, name, amount, goodIndex, tousseStorageInfos) { + if (name == null || name == '') { + showResult("请填写物品名称!"); + return false; + } + if (amount == null || amount == '') { + 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 (!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, amount, '', accessStatus, barcode, storageName); + parentNode.appendChild(childNode); + } + } + rootNode.appendChild(parentNode); + top.Ext.getCmp('goodsName').setValue(''); + top.Ext.getCmp('amount').setValue(''); + top.Ext.getCmp('goodsName').focus(); + } else { + showResult(name + ",已添加!"); + } +} + +//刷新tree +function reload(id) { + Ext.Ajax.request({ + url: WWWROOT + "/disinfectsystem/operationReservationAction!loadOperationReservation.do", + params: { id: id }, + success: function (result) { + if (result != null) { + var data = JSON.parse(result.responseText); + if (data.success) { + var rootNode = top.Ext.getCmp('operationReservationGrid').getRootNode(); + rootNode.eachChild(function (pNode) { + pNode.remove(); + }); + var tousseItems = data.items; + for (var i = 0; i < tousseItems.length; i++) { + var itemId = tousseItems[i].itemId || ''; + var tousseDefinitionId = tousseItems[i].tousseDefinitionId || ''; + var name = tousseItems[i].name || ''; + var amount = tousseItems[i].amount || 0; + var tousseStorageInfos = tousseItems[i].tousseStorageInfos || []; + addItems(itemId, tousseDefinitionId, name, amount, (i + 1), tousseStorageInfos); + } + } else { + showResult("该单已不存在!"); + } + } + }, + failure: function () { + showResult("加载失败,请联系管理员!"); + } + }); +} + +function editOperationReservation(id, committedStatus, deliverStatus) { var operationRoomAllowBlank = true; var operationTimeAllowBlank = true; var consoleNameAllowBlank = true; @@ -241,43 +341,167 @@ } } }); - //添加明细 - function addItems(itemId, tousseDefinitionId, name, amount) { - if (name == null || name == '') { - showResult("请填写物品名称!"); - return false; - } - if (amount == null || amount == '') { - showResult("请填写数量!"); - return false; - } - var store = top.Ext.getCmp('operationReservationGrid').getStore(); - var isExist = false; - var count = store.getCount(); - for (var i = 0; i < count; i++) { - var record = store.getAt(i); - if (record.get("name") == name) { - isExist = true; - break; + + //托盘选择 + var storageLocationStore = new Ext.data.Store({ + proxy: new Ext.data.HttpProxy({ + url: WWWROOT + '/disinfectSystem/baseData/storageLocationAction!loadOperationReservationGoodsStorageLocation.do', + method: 'POST' + }), + reader: new Ext.data.JsonReader({ + totalProperty: 'totalCount', + root: 'data' + }, [ + { name: 'id', mapping: 'id' }, + { name: 'name', mapping: 'name' }, + { name: 'barcode', mapping: 'barcode' }, + { name: 'storageLocationCode', mapping: 'storageLocationCode' } + ]), + listeners: { + beforeload: function (thiz) { + thiz.baseParams["invoicePlanId"] = id; } } - if (!isExist) { - //添加操作 - var materialInvoiceItem = new goodsItemRecord({ - itemId: itemId, - tousseDefinitionId: tousseDefinitionId, - name: name, - amount: amount - }); - store.add(materialInvoiceItem); - top.Ext.getCmp('goodsName').setValue(''); - top.Ext.getCmp('amount').setValue(''); - top.Ext.getCmp('goodsName').focus(); - } else { - showResult(name + ",已添加!"); - } - } + }); + 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) { + top.Ext.getCmp("operationName").setValue(combo.getRawValue()); + var rootNode = top.Ext.getCmp('operationReservationGrid').getRootNode(); + rootNode.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, (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); + } + } + } + }, { + 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: '器械包' + }) + }); + var form = new top.Ext.FormPanel({ id: 'materialInvoiceForm', frame: true, @@ -549,6 +773,117 @@ }] }, { columnWidth: 1, + layout: 'column', + hidden: !(!SSTS_OR_Fetch && (deliverStatus == '部分发货' || deliverStatus == '已发货')), + items: [{ + layout: 'form', + columnWidth: .33, + items: [{ + xtype: 'combo', + id: 'storageLocationAddr', + name: 'storageLocationAddr', + valueField: 'queryValue', + displayField: 'queryMode', + width: 180, + fieldLabel: '开口选择', + mode: 'local', + readOnly: true, + editable: false, + triggerAction: 'all', + forceSelection: true, + anchor: '99%', + store: new Ext.data.SimpleStore({ + fields: ['queryMode', 'queryValue'], + data: [['一号开口', 'S01-1'], ['二号开口', 'S01-2'], ['三号开口', 'S01-3']] + }) + }] + }, { + layout: 'form', + columnWidth: .33, + items: [{ + xtype: 'hidden', + id: 'storageLocationId', + name: 'storageLocationId' + }, { + xtype: 'hidden', + id: 'kardexContainerHost', + name: 'kardexContainerHost', + value: '194.1.2.135' + }, { + xtype: 'hidden', + id: 'kardexContainerPort', + name: 'kardexContainerPort', + value: '15008' + }, { + xtype: 'combo', + fieldLabel: '托盘选择', + id: 'storageLocationName', + name: 'storageLocationName', + minChars: 0, + valueField: 'name', + displayField: 'name', + store: storageLocationStore, + triggerAction: 'all', + readOnly: true, + editable: false, + forceSelection: true, + allowBlank: true, + anchor: '99%', + listeners: { + select: function (combo, record, index) { + top.Ext.getCmp('storageLocationId').setValue(record.data.id); + } + } + }] + }, { + layout: 'form', + columnWidth: .33, + items: [{ + xtype: 'button', + text: '取回托盘', + handler: function () { + var storageLocationId = top.Ext.getCmp("storageLocationId").getValue(); + var storageLocationAddr = top.Ext.getCmp("storageLocationAddr").getValue(); + var kardexContainerHost = top.Ext.getCmp("kardexContainerHost").getValue(); + var kardexContainerPort = top.Ext.getCmp("kardexContainerPort").getValue(); + var params = { + storageLocationId: storageLocationId, + addr: storageLocationAddr, + status: '取出', + host: kardexContainerHost, + port: kardexContainerPort + } + if (storageLocationAddr == '') { + showResult('开口不能为空'); + return; + } + if (storageLocationId == '') { + showResult('托盘不能为空'); + return; + } + showResult('已经发送命令给货柜,托盘调度中,请稍候!'); + Ext.Ajax.timeout = 2 * 60 * 1000; + Ext.Ajax.request({ + url: WWWROOT + '/disinfectSystem/baseData/storageRecordAction!sendKardexContainerTCPCommand.do', + async: false, + params: params, + timeout: 2 * 60 * 1000, + success: function (response) { + var result = Ext.decode(response.responseText); + showResult(result.message); + if (result.success) { + sendToSuccess = true; + } + }, + failure: function (response, options) { + showResult(response.responseText); + } + }); + } + }] + }] + }, { + columnWidth: 1, layout: 'form', items: [{ xtype: 'textarea', @@ -561,149 +896,66 @@ anchor: '100%' }] }] - }, 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); + }, gridPanel], + buttons: [{ + text: '取出', + hidden: !(!SSTS_OR_Fetch && (deliverStatus == '部分发货' || deliverStatus == '已发货')), + handler: function () { + var storageLocationId = top.Ext.getCmp('storageLocationId').getValue(); + var storageLocationName = top.Ext.getCmp('storageLocationName').getRawValue(); + if (storageLocationId == '') { + showResult('托盘不能为空'); + return; + } + var rootNode = top.Ext.getCmp('operationReservationGrid').getRootNode(); + var hasStorage = false; + rootNode.eachChild(function (pNode) { + if (pNode.childNodes.length > 0) { + for (var i = 0; i < pNode.childNodes.length; i++) { + if (storageLocationName == pNode.childNodes[i].attributes.storageName) { + hasStorage = true; + break; } } } + }); + if (!hasStorage) { + showResult('所选托盘中不含有当前手术预约单物品,请选择其他托盘!'); + return } - } - ], - 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); - } + if (!sendToSuccess) { + showResult('托盘名称未进行取回托盘操作,请先取回托盘!'); + return + } + top.Ext.MessageBox.confirm("请确认", "是否在" + storageLocationName + "中取出当前手术预约单中的物品?", function (button, text) { + if ("yes" == button) { + Ext.Ajax.timeout = 2 * 60 * 1000; + Ext.Ajax.request({ + url: WWWROOT + '/disinfectSystem/tousseInstanceAction!takeOutOperationReservationTousseInstance.do', + async: false, + params: { + operationReservationId: id, + storageLocationId: storageLocationId + }, + timeout: 2 * 60 * 1000, + success: function (response) { + var result = Ext.decode(response.responseText); + showResult(result.message); + if (result.success) { + top.Ext.getCmp('storageLocationName').setValue(''); + top.Ext.getCmp('storageLocationId').setValue(''); + sendToSuccess = false; + reload(id); } + }, + failure: function (response, options) { + showResult(response.responseText); } - }, { - 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); - } + }); + } + }); } - })], - buttons: [{ + }, { text: '暂存', hidden: (committedStatus == 1 ? true : false), handler: function () { @@ -761,7 +1013,12 @@ top.Ext.getCmp("remark").setValue(data.remark); var tousseItems = data.items; for (var i = 0; i < tousseItems.length; i++) { - addItems(tousseItems[i].itemId, tousseItems[i].tousseDefinitionId, tousseItems[i].name, tousseItems[i].amount); + var itemId = tousseItems[i].itemId || ''; + var tousseDefinitionId = tousseItems[i].tousseDefinitionId || ''; + var name = tousseItems[i].name || ''; + var amount = tousseItems[i].amount || 0; + var tousseStorageInfos = tousseItems[i].tousseStorageInfos || []; + addItems(itemId, tousseDefinitionId, name, amount, (i + 1), tousseStorageInfos); } } else { showResult("该单已不存在!"); @@ -905,13 +1162,13 @@ ); } -function editRecord(id, committedStatus) { +function editRecord(id, committedStatus, deliverStatus) { lastSelIdArray = [id]; - editOperationReservation(id, committedStatus); + editOperationReservation(id, committedStatus, deliverStatus); } function modify(v, data) { - editRecord(data['id'], data['committedStatus']); + editRecord(data['id'], data['committedStatus'], data['deliverStatus']); } Ext.onReady(function () {