Index: ssts-web/src/main/webapp/disinfectsystem/routineMonitoring/routineMonitoringQmForm.js =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/routineMonitoring/routineMonitoringQmForm.js (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/routineMonitoring/routineMonitoringQmForm.js (revision 41278) @@ -0,0 +1,827 @@ +var goodsRecord = Ext.data.Record.create([ + { name: 'id' }, + { name: 'name' }, + { name: 'dateTime' } +]); + +var qmInstanceStore = new Ext.data.Store({ + proxy: new Ext.data.MemoryProxy([]), + reader: new Ext.data.JsonReader({ + fields: [{ + name: 'id' + }, { + name: 'name' + }, { + name: 'dateTime' + }] + }) +}); + +function addQMInstance(id, name, dateTime) { + var isExist = false; + for (var i = 0; i < qmInstanceStore.getCount(); i++) { + var record = qmInstanceStore.getAt(i); + if (record.get('id') == id) { + isExist = true; + break; + } + } + if (!isExist) { + var record = new goodsRecord({ + id: id, + name: name, + dateTime: dateTime + }); + qmInstanceStore.add(record); + } else { + showResult(name + ",已添加!"); + } +} + +//返回炉次显示框 质量监测 +function createRoutineMonitoringElementSterNameQW(value) { + return { + columnWidth: .5, + layout: 'form', + labelWidth: 90, + items: [{ + xtype: 'textfield', + fieldLabel: '炉次', + maxLength: '30', + id: 'configItemOptionSterNameQW', + name: 'configItemOptionSterNameQW', + allowBlank: true, + readOnly: true, + value: value, + anchor: '95%' + }] + }; +} +// 返回炉号显示框 质量监测 +function createRoutineMonitoringElementSterFreQW(value) { + return { + columnWidth: .5, + layout: 'form', + labelWidth: 90, + items: [{ + xtype: 'textfield', + fieldLabel: '炉号', + maxLength: '30', + id: 'configItemOptionSterFreQW', + name: 'configItemOptionSterFreQW', + allowBlank: true, + readOnly: true, + value: value, + anchor: '95%' + }] + }; +} + +/** + * 选择监测项下拉框的某个选项时调用(定期监测不合格是添加的质量监测). + * @param formId + */ +function addQualityMonitoringItem(formId) { + Ext.Ajax.request({ + url: WWWROOT + '/disinfectSystem/formDefinitionAction!loadFormDefinition.do', + params: { id: formId }, + success: function (response, options) { + var result = Ext.decode(response.responseText); + if (result.success) { + top.Ext.getCmp('scope2').setValue(result.data.scope); + top.Ext.getCmp('optionAmount2').setValue(''); + var items = new Array(); + //FSSDERMYY-18:隐藏器械包信息 + if (result.data.scope == '无') { + hideQualityMonitoringTousseMsg(); + } else { + showQualityMonitoringTousseMsg(); + } + // 如果显示炉次炉号,添加表单 + if (result.data.showSterilizerNumFrequency == '是') { + items.push(createRoutineMonitoringElementSterNameQW('')); + items.push(createRoutineMonitoringElementSterFreQW('')); + } + for (var i = 0; i < result.data.items.length; i++) { + var item = result.data.items[i]; + if (top.Ext.getCmp('optionAmount2').getValue() == null || top.Ext.getCmp('optionAmount2').getValue() == '') { + top.Ext.getCmp('optionAmount2').setValue(item.id); + } else { + top.Ext.getCmp('optionAmount2').setValue(top.Ext.getCmp('optionAmount2').getValue() + ';' + item.id); + } + var allowBlank = result.data.items[i].requirement == '必填' ? false : true; + items.push(createRoutineMonitoringItemElement(item.type, item.id, item.name, allowBlank, item.optionsJson, null, item.isTriggerItem)); + if (result.data.items[i].type == '多选') { + items.push({ + columnWidth: 1, + xtype: "label", + html: ' ', + anchor: '95%' + }); + } + } + + top.Ext.getCmp('addQualityMonitoringForm').remove('itemsFieldSet2'); + if (items.length > 0) { + top.Ext.getCmp('addQualityMonitoringForm').add({ + id: 'itemsFieldSet2', + xtype: "fieldset", + labelAlign: 'left', + title: "监测项", + layout: 'column', + autoHeight: true, + items: items + }); + } + + top.Ext.getCmp('addQualityMonitoringForm').doLayout(); + if (top.Ext.getCmp('itemsFieldSet2')) { + top.Ext.getCmp('itemsFieldSet2').doLayout(); + } + } + }, + failure: function (response, options) { + showResultQM('系统加载出错,请稍候再试'); + } + }); +} + +/** + * 定期监测失败后添加的质量监测. + * qmInstanceId + */ +function addQualityMonitoring(qmInstanceId) { + var materialDefinitionStore = new Ext.data.Store({ + proxy: new Ext.data.HttpProxy({ + url: WWWROOT + '/disinfectSystem/baseData/materialDefinitionAction!getMaterialDefinitionData.do', + method: 'POST' + }), + reader: new Ext.data.JsonReader({ + totalProperty: 'totalCount', + root: 'data' + }, [ + { name: 'id', mapping: 'id' }, + { name: 'spelling', mapping: 'spelling' }, + { name: 'name', mapping: 'name' }, + { name: 'count', mapping: 'count' } + ]), + listeners: { + beforeload: function (thiz, options) { + thiz.baseParams['tousseDefinitionId'] = top.Ext.getCmp('tousseDefinitionId2').getValue(); + } + } + }); + + var tousseDefinitionStore = new Ext.data.Store({ + proxy: new Ext.data.HttpProxy({ + url: WWWROOT + '/disinfectSystem/baseData/tousseDefinitionAction!getTousseAndDiposableGoodsData.do?type=' + encodeURI('器械包和外来器械包'), + 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' }] + ) + }); + + var formDefinitionStore = new Ext.data.Store({ + proxy: new Ext.data.HttpProxy({ + url: WWWROOT + '/disinfectSystem/qualityMonitoringDefinitionAction!loadLastDeployFormDefinitionGroupByFormName.do', + method: 'POST' + }), + baseParams: { formType: formType_qualityMonitoring }, + reader: new Ext.data.JsonReader({ + root: 'data' + }, [ + { name: 'id' }, + { name: 'name' } + ] + ), + listeners: { + load: function (store, records) { + if (records.length > 0) { + top.Ext.getCmp('formName2').setValue(records[0].data.name); + addQualityMonitoringItem(records[0].data.id, records[0].data.name); + top.Ext.getCmp("formDefinitionId2").setValue(records[0].data.id); + top.Ext.getCmp("name2").setValue(records[0].data.name); + } else { + // 没有找到监测项 + top.Ext.getCmp('formName2').setValue(''); + } + } + } + }); + + var formPanel = new top.Ext.FormPanel({ + id: 'addQualityMonitoringForm', + frame: true, + labelSeparator: ':', + bodyStyle: 'padding:5px 5px 0px 5px', + width: 600, + height: 500, + labelAlign: 'right', + buttonAlign: 'center', + autoScroll: true, + items: [{ + layout: 'column', + xtype: "fieldset", //定义类别为fieldset + title: "基本信息", + autoHeight: true, + items: [{ + xtype: 'hidden', + name: 'id', + id: 'id2' + }, { + xtype: 'hidden', + name: 'tousseInstanceId', + id: 'tousseInstanceId2' + }, { + xtype: 'hidden', + name: 'tousseDefinitionId', + id: 'tousseDefinitionId2' + }, { + xtype: 'hidden', + name: 'formDefinitionId', + id: 'formDefinitionId2' + }, { + xtype: 'hidden', + name: 'barcode', + id: 'barcode2' + }, { + xtype: 'hidden', + name: 'scope', + id: 'scope2' + }, { + xtype: 'hidden', + name: 'type', + id: 'type2', + value: '质量监测' + }, { + xtype: 'hidden', + name: 'name', + id: 'name2', + value: '质量监测' + }, { + xtype: 'hidden', + name: 'optionAmount', + id: 'optionAmount2' + }, { + layout: 'form', + columnWidth: .5, + labelWidth: 90, + items: [{ + xtype: 'combo', + id: 'formName2', + name: 'formName', + queryParam: 'spell', + fieldLabel: '监测项', + minChars: 0, + valueField: 'id', + displayField: 'name', + anchor: '95%', + store: formDefinitionStore, + lazyInit: true, + forceSelection: true, + triggerAction: 'all', + hideTrigger: false, + typeAhead: false, + allowBlank: false, + listeners: { + beforequery: function (queryEvent) { + if (qmInstanceId != "" && qmInstanceId != 0) { + return false; + } + }, + beforeselect: function (combo, record, index) { + if (record.data.name != combo.getValue()) { + if (top.Ext.getCmp('barcode2').getValue()) { + getTousseInstanceNameAndResponsiblePerson(top.Ext.getCmp('tempBarcode2').getValue(), combo.getValue(), null, true, false); + } + } + }, + select: function (combo, record, index) { + top.Ext.getCmp("formDefinitionId2").setValue(combo.getValue()); + top.Ext.getCmp("name2").setValue(combo.getRawValue()); + addQualityMonitoringItem(combo.getValue(), combo.getRawValue()); + } + } + }] + }, { + layout: 'form', + columnWidth: .5, + labelWidth: 90, + items: [{ + xtype: 'datefieldWithMin', + fieldLabel: '抽检时间', + id: 'dateTime2', + name: 'dateTime', + // value : new Date(), + editable: false, + format: 'Y-m-d H:i', + allowBlank: false, + anchor: '95%' + }] + }, { + layout: 'form', + columnWidth: .5, + labelWidth: 90, + items: [{ + xtype: 'textfield', + name: 'tempBarcode', + id: 'tempBarcode2', + fieldLabel: "器械包条码", + listeners: { + specialkey: function (field, e) { + if (e.getKey() == 13) { + getTousseInstanceNameAndResponsiblePerson(field.getValue(), top.Ext.getCmp('formDefinitionId2').getValue(), materialDefinitionStore, true, true); + field.setValue(''); + } + } + }, + anchor: '95%' + }] + }, { + layout: 'form', + columnWidth: .5, + labelWidth: 90, + items: [{ + xtype: 'combo', + id: 'tousseName2', + name: 'tousseName', + fieldLabel: '器械包名称', + queryParam: 'spell', + minChars: 0, + valueField: 'name', + displayField: 'name', + store: tousseDefinitionStore, + forceSelection: true, + lazyInit: true, + triggerAction: 'all', + hideTrigger: true, + typeAhead: false, + anchor: '95%', + listeners: { + select: function (combo, record, index) { + combo.setValue(record.data.name); + top.Ext.getCmp('tousseDefinitionId2').setValue(record.data.id); + //加载责任人 + + }, + blur: function (field) { + if (!top.Ext.getCmp('tousseName2').getRawValue()) { + top.Ext.getCmp('tousseDefinitionId2').setValue(''); + } + //重新加载包内的材料 + materialDefinitionStore.reload(); + } + } + }] + }, { + layout: 'form', + columnWidth: .5, + labelWidth: 90, + items: [{ + xtype: 'combo', + id: 'material2', + name: 'material', + fieldLabel: '抽检器械', + queryParam: 'spell', + minChars: 0, + valueField: 'id', + displayField: 'name', + store: materialDefinitionStore, + forceSelection: true, + lazyInit: true, + triggerAction: 'all', + hideTrigger: true, + typeAhead: false, + anchor: '95%', + listeners: { + select: function (combo, record, index) { + combo.setValue(record.data.name); + } + } + }] + }, { + layout: 'form', + columnWidth: .5, + labelWidth: 90, + items: [{ + xtype: 'numberfield', + allowDecimals: false, + name: 'amount', + id: 'amount2', + fieldLabel: "数量", + anchor: '95%' + }] + }, { + layout: 'form', + columnWidth: .5, + labelWidth: 90, + items: [{ + xtype: 'textfield', + name: 'registerPerson', + id: 'registerPerson2', + fieldLabel: "登记人", + anchor: '95%', + readOnly: true, + value: $Id('userName').value + }] + }, { + layout: 'form', + columnWidth: .5, + labelWidth: 90, + items: [{ + xtype: 'textfield', + name: 'responsiblePerson', + id: 'responsiblePerson2', + fieldLabel: "责任人", + anchor: '95%' + }] + }, { + layout: 'form', + columnWidth: 1, + labelWidth: 90, + items: [{ + xtype: 'textarea', + name: 'remark', + id: 'remark2', + width: 150, + height: 50, + fieldLabel: "备注", + anchor: '97%' + }] + }] + }], + buttons: [{ + id: 'saveBtn2', + text: '保存', + handler: function () { + saveQualityMonitoring(this, materialDefinitionStore); + } + }, { + text: '取消', + id: 'saveAndNewBtn2', + handler: function () { + var qualityMonitoringWin = top.Ext.getCmp("qualityMonitoringWin"); + qualityMonitoringWin.close(); + } + }] + }); + + var qualityMonitoringWin = new top.Ext.Window({ + id: 'qualityMonitoringWin', + layout: 'fit', + title: '质量监测信息', + width: 700, + modal: true, + autoHeight: true, + border: false, + plain: true, + items: [formPanel] + }); + qualityMonitoringWin.show(); + if (qmInstanceId != null && qmInstanceId != '') { + var items = new Array(); + Ext.Ajax.request({ + url: WWWROOT + '/disinfectSystem/qualityMonitoringInstanceAction!loadQualityMonitoringInstance.do', + params: { id: qmInstanceId }, + async: false, + success: function (response, options) { + var result = Ext.decode(response.responseText); + if (result.success) { + top.Ext.getCmp('id2').setValue(qmInstanceId); + top.Ext.getCmp('formName2').setValue(result.data.name); + top.Ext.getCmp('name2').setValue(result.data.name); + top.Ext.getCmp('type2').setValue(result.data.type); + if (result.data.name == "无") { + top.Ext.getCmp("formDefinitionId2").setValue(0); + } else { + top.Ext.getCmp("formDefinitionId2").setValue(result.data.formDefinition.id); + } + top.Ext.getCmp('dateTime2').setValue(Ext.util.Format.date(new Date(result.data.dateTime.time), "Y-m-d H:i")); + loadTousseAndMaterialMsgByQm(result.data.qualityMonitoringGoodsList); + top.Ext.getCmp('scope2').setValue(result.data.scope); + top.Ext.getCmp('tousseName2').setRawValue(result.data.tousseName); + top.Ext.getCmp('responsiblePerson2').setValue(result.data.responsiblePerson); + top.Ext.getCmp('registerPerson2').setValue(result.data.createUserName); + top.Ext.getCmp('remark2').setValue(result.data.remark); + top.Ext.getCmp('optionAmount2').setValue(''); + //FSSDERMYY-18:隐藏器械包信息 + if (result.data.scope == '无') { + hideQualityMonitoringTousseMsg(); + } else { + showQualityMonitoringTousseMsg(); + } + + // 如果显示炉次炉号,添加表单 + if (result.showSterNameAndFre == '是') { + items.push(createRoutineMonitoringElementSterNameQW(result.data.sterilizerName)); + items.push(createRoutineMonitoringElementSterFreQW(result.data.sterilizerFrequency)); + } + for (var i = 0; i < result.data.items.length; i++) { + var item = result.data.items[i].definitionItem; + if (top.Ext.getCmp('optionAmount2').getValue() == null || top.Ext.getCmp('optionAmount2').getValue() == '') { + top.Ext.getCmp('optionAmount2').setValue(item.id); + } else { + top.Ext.getCmp('optionAmount2').setValue(top.Ext.getCmp('optionAmount2').getValue() + ';' + item.id); + } + var allowBlank = item.requirement == '必填' ? false : true; + items.push(createRoutineMonitoringItemElement(item.type, item.id, item.name, allowBlank, item.optionsJson, result.data.items[i].showAnswer, item.isTriggerItem)); + if (item.type == '多选') { + items.push({ + columnWidth: 1, + xtype: "label", + html: ' ', + anchor: '95%' + }); + } + } + + top.Ext.getCmp('addQualityMonitoringForm').remove('itemsFieldSet2'); + if (items.length > 0) { + top.Ext.getCmp('addQualityMonitoringForm').add({ + id: 'itemsFieldSet2', + xtype: "fieldset", + labelWidth: 400, + labelAlign: 'left', + title: "监测项", + layout: 'column', + autoHeight: true, + items: items + }); + } + top.Ext.getCmp('addQualityMonitoringForm').doLayout(); + if (top.Ext.getCmp('itemsFieldSet2')) { + top.Ext.getCmp('itemsFieldSet2').doLayout(); + } + } + }, + failure: function (response, options) { + showResult('系统加载出错,请稍候再试'); + } + }); + } else { + setStartDate(top.Ext, 'yyyy/MM/dd HH:mm', 'dateTime2'); //(设置抽检时间,取服务器时间 cjr) + top.Ext.getCmp('amount2').setValue(1); + formDefinitionStore.load(); + } +} + +//打开质量监测记录,加载包和材料信息 +function loadTousseAndMaterialMsgByQm(routineMonitoringGoodsList) { + if (routineMonitoringGoodsList == null || routineMonitoringGoodsList == '' || routineMonitoringGoodsList.length == 0) { + return; + } + var length = routineMonitoringGoodsList.length; + if (length == 1) { + // 只有包或者材料 + var tousseName = routineMonitoringGoodsList[0].tousseName; + if (isUndefinedOrNullOrEmpty(tousseName)) { + //是材料信息 + var material = routineMonitoringGoodsList[0].material; + var amount = routineMonitoringGoodsList[0].amount; + top.Ext.getCmp('material2').setValue(material); + top.Ext.getCmp('amount2').setValue(amount); + } else { + // 是包信息 + var barcode = routineMonitoringGoodsList[0].barcode; + var tousseInstanceId = routineMonitoringGoodsList[0].tousseInstanceId; + var tousseName = routineMonitoringGoodsList[0].tousseName; + var amount = routineMonitoringGoodsList[0].amount; + top.Ext.getCmp('barcode2').setValue(barcode); + top.Ext.getCmp('tousseInstanceId2').setValue(tousseInstanceId); + if (!isUndefinedOrNullOrEmpty(barcode)) { + tousseName += "(" + barcode + ")"; + } + top.Ext.getCmp('tousseName2').setValue(tousseName); + top.Ext.getCmp('amount2').setValue(amount); + } + } else if (length == 2) { + // 第一个是包,第二个是材料 + var barcode = routineMonitoringGoodsList[0].barcode; + var tousseInstanceId = routineMonitoringGoodsList[0].tousseInstanceId; + var tousseName = routineMonitoringGoodsList[0].tousseName; + var amount = routineMonitoringGoodsList[1].amount; + var material = routineMonitoringGoodsList[1].material; + top.Ext.getCmp('material2').setValue(material); + top.Ext.getCmp('barcode2').setValue(barcode); + top.Ext.getCmp('tousseInstanceId2').setValue(tousseInstanceId); + if (!isUndefinedOrNullOrEmpty(barcode)) { + tousseName += "(" + barcode + ")"; + } + top.Ext.getCmp('tousseName2').setValue(tousseName); + top.Ext.getCmp('amount2').setValue(amount); + } +} + +/** + * 隐藏定期监测的质量监测记录的器械包信息 + */ +function hideQualityMonitoringTousseMsg() { + top.Ext.getCmp('tempBarcode2').setVisible(false); + top.Ext.getCmp('tempBarcode2').getEl().up('.x-form-item').setDisplayed(false); + top.Ext.getCmp('tousseName2').setVisible(false); + top.Ext.getCmp('tousseName2').getEl().up('.x-form-item').setDisplayed(false); + top.Ext.getCmp('material2').setVisible(false); + top.Ext.getCmp('material2').getEl().up('.x-form-item').setDisplayed(false); + top.Ext.getCmp('amount2').setVisible(false); + top.Ext.getCmp('amount2').getEl().up('.x-form-item').setDisplayed(false); +} +/** + * 显示定期监测的质量监测记录的器械包信息 + */ +function showQualityMonitoringTousseMsg() { + top.Ext.getCmp('tempBarcode2').setVisible(true); + top.Ext.getCmp('tempBarcode2').getEl().up('.x-form-item').setDisplayed(true); + top.Ext.getCmp('tousseName2').setVisible(true); + top.Ext.getCmp('tousseName2').getEl().up('.x-form-item').setDisplayed(true); + top.Ext.getCmp('material2').setVisible(true); + top.Ext.getCmp('material2').getEl().up('.x-form-item').setDisplayed(true); + top.Ext.getCmp('amount2').setVisible(true); + top.Ext.getCmp('amount2').getEl().up('.x-form-item').setDisplayed(true); +} + +/** + * 保存质量监测实例(定期监测不合格保存的质量监测). + * @param thiz + * @param materialDefinitionStore + */ +function saveQualityMonitoring(thiz, materialDefinitionStore) { + //监测项元素id集合(用分号分隔) + var optionAmount = top.Ext.getCmp('optionAmount2').getValue(); + if (optionAmount) { + var optionAmountArr = optionAmount.split(';'); + for (var i = 0; i < optionAmountArr.length; i++) { + var itemId = optionAmountArr[i]; + if (top.Ext.getCmp('configItemOption' + itemId).getXType() != 'hidden') { + if (!top.Ext.getCmp('configItemOption' + itemId).isValid()) { + showResultQM("请正确填写表单各值。"); + thiz.enable(); + return false; + } + } else { + if (!top.Ext.getCmp('configItemOption' + itemId).hidden && top.Ext.getCmp('configItemOption' + itemId).getValue() == '#@') { + showResultQM("请正确填写表单各值。"); + thiz.enable(); + return false; + } + } + + //如果是多选,并且必填,需要单独校验 + var extElement = top.Ext.getCmp('hideElement' + itemId); + if (extElement.getXType() == 'fieldset' && !extElement.allowBlank) { + var checkboxArr = extElement.findByType('checkbox'); + var checked = false; + for (var int = 0; int < checkboxArr.length; int++) { + if (checkboxArr[int].checked) { + checked = checkboxArr[int].checked; + continue; + } + } + if (!checked) { + showResultQM(extElement.title + "是必填项"); + thiz.enable(); + return false; + } + } + } + } + + var scope = top.Ext.getCmp('scope2').getValue(); + var material = top.Ext.getCmp('material2').getValue(); + var tousseName = top.Ext.getCmp('tousseName2').getRawValue(); + var barcode = top.Ext.getCmp('barcode2').getValue(); + if ('无' != scope) { + if (!material && !tousseName) { + showResult("请录入抽验器械或器械包名称"); + return false; + } + } + // 获取质量检测记录的id,如果不为空,说明是打开的记录,不再校验包和材料的数量 + var id2 = top.Ext.getCmp('id2').getValue(); + if (isUndefinedOrNullOrEmpty(id2)) { + if (material) { + var amount = top.Ext.getCmp('amount2').getValue(); + if (!amount || amount < 0) { + showResult('输入的“' + material + '”的数量且不能小于1'); + return false; + } + + if (tousseName) { + var isExist = false; + var count = materialDefinitionStore.getCount(); + for (var i = 0; i < count; i++) { + var r = materialDefinitionStore.getAt(i); + if (r.data.name == material) { + isExist = true; + //对比 当前输入材料的数量 与 该器械包中此材料的数量 + var v = r.data.count - amount; + if (v < 0) { + showResult('输入的' + material + '的数量不能大于当前器械包该材料的数量'); + top.Ext.getCmp('amount2').setValue(r.data.count); + return false; + } + } + } + if (!isExist) { + showResult('在当前器械包中找不到找材料“' + material + '”'); + top.Ext.getCmp('material2').setValue(''); + top.Ext.getCmp('amount2').setValue(); + return false; + } + } + } + } + + checkIsUniqueWithBarcodeAndInspectItemAndConvertToJson(thiz, top.Ext.getCmp('id2').getValue(), barcode, top.Ext.getCmp('formDefinitionId2').getValue()); +} + +function checkIsUniqueWithBarcodeAndInspectItemAndConvertToJson(thiz, id, barcode, formDefinitionId) { + if (barcode && formDefinitionId) { + Ext.Ajax.request({ + url: WWWROOT + '/disinfectSystem/qualityMonitoringInstanceAction!checkIsUniqueWithBarcodeAndInspectItem.do', + params: { + id: id, + barcode: barcode, + formDefinitionId: formDefinitionId + }, + success: function (response, options) { + var result = Ext.decode(response.responseText); + if (!result.isUnique) { + showResult("当前器械包所对应的检测项已存在"); + thiz.enable(); + return false; + } + submintQMForm(); + }, + failure: function (response, options) { + showResult('系统加载出错,请稍候再试'); + } + }); + } else { + submintQMForm(); + } +} + +function submintQMForm() { + var material2 = top.Ext.getCmp("material2").getValue(); + var amount2 = top.Ext.getCmp("amount2").getValue(); + var materialInfo = ""; + if (material2 != null && material2 != '') { + materialInfo = material2 + "@" + amount2 + "@" + "" + "@" + 2 + "@" + " " + ";"; + } + var tousseInstanceInfo = ""; + var tousseName = top.Ext.getCmp("tousseName2").getValue(); + var tousseBarcode = top.Ext.getCmp("barcode2").getValue(); + var tousseInstanceId = top.Ext.getCmp("tousseInstanceId2").getValue(); + var tousseAmount = 1; + if (!isUndefinedOrNullOrEmpty(tousseName)) { + if (isUndefinedOrNullOrEmpty(material2)) { + tousseInstanceInfo = tousseBarcode + "@" + tousseInstanceId + "@" + tousseName + "@" + tousseAmount + + "@" + "否" + "@" + "否" + "@" + amount2 + "@" + " " + "@" + "是" + ";"; + } else { + tousseInstanceInfo = tousseBarcode + "@" + tousseInstanceId + "@" + tousseName + "@" + tousseAmount + + "@" + "否" + "@" + "否" + "@" + 1 + "@" + " " + "@" + "是" + ";"; + } + } + var qualityMonitoringWin = top.Ext.getCmp("qualityMonitoringWin"); + + top.Ext.getCmp('addQualityMonitoringForm').form.submit({ + url: WWWROOT + '/disinfectSystem/qualityMonitoringInstanceAction!saveQualityMonitoringInstance.do', + params: { + materialInfo: materialInfo, + tousseInstanceInfo: tousseInstanceInfo + }, + method: 'POST', + waitMsg: '正在保存数据,请稍候', + waitTitle: '提交表单', + success: function (form, action) { + var result = top.Ext.decode(action.response.responseText); + showResult(result.message); + if (result.success) { + var formName = top.Ext.getCmp('formName2').getRawValue(); + var dateTime = top.Ext.getCmp('dateTime2').getRawValue(); + addQMInstance(result.id, formName, dateTime); + qualityMonitoringWin.close(); + if (typeof (grid) != 'undefined' && grid != null) { + grid.getStore().reload(); + } + } + }, + failure: function (form, action) { + if (action.response != null && action.response.responseText != null) { + var result = top.Ext.decode(action.response.responseText); + showResult(result.message); + } else { + alert('failure = ' + action.failureType); + } + qualityMonitoringWin.close(); + } + }); +} \ No newline at end of file Index: ssts-web/src/main/webapp/disinfectsystem/routineMonitoring/routineMonitoringForm.js =================================================================== diff -u -r41264 -r41278 --- ssts-web/src/main/webapp/disinfectsystem/routineMonitoring/routineMonitoringForm.js (.../routineMonitoringForm.js) (revision 41264) +++ ssts-web/src/main/webapp/disinfectsystem/routineMonitoring/routineMonitoringForm.js (.../routineMonitoringForm.js) (revision 41278) @@ -4,11 +4,16 @@ var materialDefinitionStore; var frequencyStore; -var goodsRecord = Ext.data.Record.create([ - { name: 'id' }, - { name: 'name' }, - { name: 'dateTime' } -]); +function removeItem(gridId) { + var gridObj = Ext.getCmp(gridId); + var rows = gridObj.getSelectionModel().getSelections(); + if (rows) { + var store = gridObj.getStore(); + for (var i = 0; i < rows.length; i++) { + store.remove(rows[i]); + } + } +} //返回炉次显示框 function createRoutineMonitoringElementSterFre(value) { @@ -110,6 +115,7 @@ allowBlank: false, anchor: '95%', index: id, + value: value, listeners: { specialkey: function (field, e) { if (e.getKey() == 13) { @@ -124,7 +130,11 @@ showResultQM("登记人需为当前科室用户!"); return } - Ext.getCmp('configItemOption' + field.index).setValue(result.fullName); + var elementObj = Ext.getCmp('configItemOption' + field.index); + if (top.Ext && top.Ext.getCmp('configItemOption' + field.index)) { + elementObj = top.Ext.getCmp('configItemOption' + field.index) + } + elementObj.setValue(result.fullName); } else { showResultQM('找不到该工号对应的人员信息'); } @@ -299,10 +309,14 @@ listeners: { select: function (combo, record, index) { var valueTriggerItemIds = record.get("valueTriggerItemIds"); - var oldTriggerItemIds = Ext.getCmp("triggerItemIds" + id).getValue(); + var elementObj = Ext.getCmp("triggerItemIds" + id); + if (top.Ext && top.Ext.getCmp("triggerItemIds" + id)) { + elementObj = top.Ext.getCmp("triggerItemIds" + id) + } + var oldTriggerItemIds = elementObj.getValue(); triggerItemAction(oldTriggerItemIds, "hide"); triggerItemAction(valueTriggerItemIds, "show"); - Ext.getCmp("triggerItemIds" + id).setValue(valueTriggerItemIds); + elementObj.setValue(valueTriggerItemIds); } } }] @@ -351,6 +365,9 @@ check: function (thiz, checked) { var elementId = thiz.getName().substring(1); var elementObj = Ext.getCmp(elementId); + if (top.Ext && top.Ext.getCmp(elementId)) { + elementObj = top.Ext.getCmp(elementId); + } if (elementObj != undefined && elementObj != null) { var oldElementValue = elementObj.getValue(); var checkedValue = JSON.parse(thiz.getRawValue()); @@ -425,7 +442,15 @@ xtype: 'radio', checked: qualifiedChecked, columnWidth: .5, - inputValue: '合格' + inputValue: '合格', + listeners: { + check: function (thiz, checked) { + if (checked) { + qmInstanceStore.removeAll(); + Ext.getCmp("addRoutineMonitoringGrid").hide(); + } + } + } }] }, { layout: 'form', @@ -437,76 +462,82 @@ xtype: 'radio', checked: unqualifiedChecked, columnWidth: .5, - inputValue: '不合格' + inputValue: '不合格', + listeners: { + check: function (thiz, checked) { + if (checked) { + Ext.getCmp("addRoutineMonitoringGrid").show(); + } + } + } }] }] }] }); -} -/** - * 选择监测项下拉框的某个选项时调用(定期监测不合格是添加的质量监测). - * @param formId - */ -function addRoutineMonitoringItem(formId) { - Ext.Ajax.request({ - url: WWWROOT + '/disinfectSystem/formDefinitionAction!loadFormDefinition.do', - params: { id: formId }, - success: function (response, options) { - var result = Ext.decode(response.responseText); - if (result.success) { - Ext.getCmp('scope2').setValue(result.data.scope); - Ext.getCmp('optionAmount2').setValue(''); - var items = new Array(); - //FSSDERMYY-18:隐藏器械包信息 - if (result.data.scope == '无') { - hideRoutineMonitoringTousseMsg(); - } else { - showRoutineMonitoringTousseMsg(); - } - for (var i = 0; i < result.data.items.length; i++) { - var item = result.data.items[i]; - if (Ext.getCmp('optionAmount2').getValue() == null || Ext.getCmp('optionAmount2').getValue() == '') { - Ext.getCmp('optionAmount2').setValue(item.id); - } else { - Ext.getCmp('optionAmount2').setValue(Ext.getCmp('optionAmount2').getValue() + ';' + item.id); - } - var allowBlank = result.data.items[i].requirement == '必填' ? false : true; - items.push(createRoutineMonitoringItemElement(item.type, item.id, item.name, allowBlank, item.optionsJson, null, item.isTriggerItem)); - if (result.data.items[i].type == '多选') { - items.push({ - columnWidth: 1, - xtype: "label", - html: ' ', - anchor: '95%' - }); - } - } + var cm = new Ext.grid.ColumnModel([{ + id: 'id', + name: 'id', + hidden: true, + dataIndex: 'id' + }, { + id: 'name', + header: "监测项名称", + width: 180, + menuDisabled: true, + dataIndex: 'name' + }, { + id: 'dateTime', + header: "录入时间", + width: 120, + menuDisabled: true, + dataIndex: 'dateTime' + }, { + id: 'deleteItem', + header: '删除', + menuDisabled: true, + dataIndex: 'button', + renderer: function (v, p, record, index) { + var itemid = record.get("id"); + return ""; + } + }]); - Ext.getCmp('addRoutineMonitoringForm').remove('itemsFieldSet2'); - if (items.length > 0) { - Ext.getCmp('addRoutineMonitoringForm').add({ - id: 'itemsFieldSet2', - xtype: "fieldset", - labelAlign: 'left', - title: "监测项", - layout: 'column', - autoHeight: true, - items: items - }); - } - - Ext.getCmp('addRoutineMonitoringForm').doLayout(); - if (Ext.getCmp('itemsFieldSet2')) { - Ext.getCmp('itemsFieldSet2').doLayout(); - } - } - }, - failure: function (response, options) { - showResultQM('系统加载出错,请稍候再试'); + var tbar = [{ + text: '添加质量监测', + handler: function () { + addQualityMonitoring(""); } - }); + }]; + Ext.getCmp('addRoutineMonitoringForm').add({ + id: 'addRoutineMonitoringGrid', + xtype: "fieldset", + labelAlign: 'left', + title: "添加质量监测", + hidden: true, + layout: 'column', + autoHeight: true, + items: [{ + columnWidth: 1, + items: [ + new Ext.grid.GridPanel({ + id: 'qmGridPanel', + store: qmInstanceStore, + cm: cm, + width: 620, + height: 120, + tbar: tbar, + viewConfig: { + forceFit: true + }, + bodyStyle: 'border:1px solid #afd7af', + anchor: '100%', + autoExpandColumn: 'deleteItem' + }) + ] + }] + }); } // 打开定期监测,加载包和材料的信息 @@ -624,82 +655,7 @@ } } -//打开质量监测记录,加载包和材料信息 -function loadTousseAndMaterialMsg(routineMonitoringGoodsList) { - if (routineMonitoringGoodsList == null || routineMonitoringGoodsList == '' || routineMonitoringGoodsList.length == 0) { - return; - } - var length = routineMonitoringGoodsList.length; - if (length == 1) { - // 只有包或者材料 - var tousseName = routineMonitoringGoodsList[0].tousseName; - if (isUndefinedOrNullOrEmpty(tousseName)) { - //是材料信息 - var material = routineMonitoringGoodsList[0].material; - var amount = routineMonitoringGoodsList[0].amount; - Ext.getCmp('material2').setValue(material); - Ext.getCmp('amount2').setValue(amount); - } else { - // 是包信息 - var barcode = routineMonitoringGoodsList[0].barcode; - var tousseInstanceId = routineMonitoringGoodsList[0].tousseInstanceId; - var tousseName = routineMonitoringGoodsList[0].tousseName; - var amount = routineMonitoringGoodsList[0].amount; - Ext.getCmp('barcode2').setValue(barcode); - Ext.getCmp('tousseInstanceId2').setValue(tousseInstanceId); - if (!isUndefinedOrNullOrEmpty(barcode)) { - tousseName += "(" + barcode + ")"; - } - Ext.getCmp('tousseName2').setValue(tousseName); - Ext.getCmp('amount2').setValue(amount); - } - } else if (length == 2) { - // 第一个是包,第二个是材料 - var barcode = routineMonitoringGoodsList[0].barcode; - var tousseInstanceId = routineMonitoringGoodsList[0].tousseInstanceId; - var tousseName = routineMonitoringGoodsList[0].tousseName; - var amount = routineMonitoringGoodsList[1].amount; - var material = routineMonitoringGoodsList[1].material; - Ext.getCmp('material2').setValue(material); - Ext.getCmp('barcode2').setValue(barcode); - Ext.getCmp('tousseInstanceId2').setValue(tousseInstanceId); - if (!isUndefinedOrNullOrEmpty(barcode)) { - tousseName += "(" + barcode + ")"; - } - Ext.getCmp('tousseName2').setValue(tousseName); - Ext.getCmp('amount2').setValue(amount); - } -} - - /** - * 隐藏定期监测的质量监测记录的器械包信息 - */ -function hideRoutineMonitoringTousseMsg() { - Ext.getCmp('tempBarcode2').setVisible(false); - Ext.getCmp('tempBarcode2').getEl().up('.x-form-item').setDisplayed(false); - Ext.getCmp('tousseName2').setVisible(false); - Ext.getCmp('tousseName2').getEl().up('.x-form-item').setDisplayed(false); - Ext.getCmp('material2').setVisible(false); - Ext.getCmp('material2').getEl().up('.x-form-item').setDisplayed(false); - Ext.getCmp('amount2').setVisible(false); - Ext.getCmp('amount2').getEl().up('.x-form-item').setDisplayed(false); -} -/** - * 显示定期监测的质量监测记录的器械包信息 - */ -function showRoutineMonitoringTousseMsg() { - Ext.getCmp('tempBarcode2').setVisible(true); - Ext.getCmp('tempBarcode2').getEl().up('.x-form-item').setDisplayed(true); - Ext.getCmp('tousseName2').setVisible(true); - Ext.getCmp('tousseName2').getEl().up('.x-form-item').setDisplayed(true); - Ext.getCmp('material2').setVisible(true); - Ext.getCmp('material2').getEl().up('.x-form-item').setDisplayed(true); - Ext.getCmp('amount2').setVisible(true); - Ext.getCmp('amount2').getEl().up('.x-form-item').setDisplayed(true); -} - -/** * 选择监测项下拉框的某个选项时调用 */ function addRoutineMonitoringItem(formId) { @@ -883,6 +839,10 @@ id: 'optionAmount' }, { xtype: 'hidden', + name: 'qualityMonitoringItems', + id: 'qualityMonitoringItems' + }, { + xtype: 'hidden', name: 'isRecycle', id: 'isRecycle' }, { @@ -1407,6 +1367,16 @@ if (Ext.getCmp('resultFieldSet')) { Ext.getCmp('resultFieldSet').doLayout(); } + qmInstanceStore.removeAll(); + var monitorings = result.data.qualityMonitorings; + if (monitorings != null && monitorings.length > 0) { + Ext.getCmp("addRoutineMonitoringGrid").show(); + for (var j = 0; j < monitorings.length; j++) { + var qmForRoutine = monitorings[j]; + var tmpDateTime = Ext.util.Format.date(new Date(qmForRoutine.dateTime.time), "Y-m-d H:i"); + addQMInstance(qmForRoutine.id, qmForRoutine.name, tmpDateTime); + } + } //打开已有质量监测记录,器械包条码,器械包名称,重新回收和重新装配都禁用掉,不能再修改 Ext.getCmp('recycle').disable(); Ext.getCmp('repacking').disable(); @@ -1652,6 +1622,15 @@ } function submitForm(thiz, sterilerConfirmObj) { + var qmArray = []; + for (var i = 0; i < qmInstanceStore.getCount(); i++) { + var record = qmInstanceStore.getAt(i); + qmArray.push({ + id: record.get("id") + }); + } + Ext.getCmp('qualityMonitoringItems').setValue(Ext.encode(qmArray)); + var material = Ext.getCmp("material").getValue(); var amount = Ext.getCmp("amount").getValue(); if (isUndefinedOrNullOrEmpty(tousseName)) { @@ -1778,8 +1757,4 @@ } catch (e) { } -} - -function isLoadIframe() { - return true } \ No newline at end of file Index: ssts-web/src/main/webapp/disinfectsystem/routineMonitoring/routineMonitoringForm.jsp =================================================================== diff -u -r41262 -r41278 --- ssts-web/src/main/webapp/disinfectsystem/routineMonitoring/routineMonitoringForm.jsp (.../routineMonitoringForm.jsp) (revision 41262) +++ ssts-web/src/main/webapp/disinfectsystem/routineMonitoring/routineMonitoringForm.jsp (.../routineMonitoringForm.jsp) (revision 41278) @@ -128,6 +128,7 @@ } } +