Index: ssts-web/src/main/webapp/disinfectsystem/deviceMaintenance/deviceMaintenanceCostomInsForm.js =================================================================== diff -u -r38391 -r38667 --- ssts-web/src/main/webapp/disinfectsystem/deviceMaintenance/deviceMaintenanceCostomInsForm.js (.../deviceMaintenanceCostomInsForm.js) (revision 38391) +++ ssts-web/src/main/webapp/disinfectsystem/deviceMaintenance/deviceMaintenanceCostomInsForm.js (.../deviceMaintenanceCostomInsForm.js) (revision 38667) @@ -10,6 +10,195 @@ formInstanceWin.close(); } +function downLoadAttachFile(id) { + location.href = WWWROOT + "/disinfectsystem/staffArchives/downloadAttachFile.jsp?id=" + id; +} + +function deleteAttachFile(id) { + if (id != null && id != "") { + top.Ext.MessageBox.confirm("请确认", "是否确定要删除此附件?", function (button, text) { + if ("yes" == button) { + Ext.Ajax.request({ + url: WWWROOT + '/disinfectSystem/baseData/staffArchiveAction!deleteAttachFile.do', + params: { attachId: id }, + success: function (response, options) { + showResult("删除成功"); + fileManageStore.load(); + grid.dwrReload(); + }, + failure: function (response, options) { + showResult("删除失败"); + } + }); + } + }); + } +} + +function deleteOrDownLoad(v, p, record) { + var html = ''; + html += '删除   '; + html += ''; + html += '下载'; + return html; +} + +function uploadFileWindow() { + var id = top.Ext.getCmp('id').getValue(); + var tempObjectID = top.Ext.getCmp('tempObjectID').getValue(); + if (id == '') { + id = tempObjectID; + } + var dialog = new top.Ext.ux.UploadDialog.Dialog({ + title: "上传附件", + url: WWWROOT + '/disinfectSystem/deviceMaintenanceCusInsAction!uploadAttachFile.do?attachType=' + encodeURI("设备维护信息") + '&objectId=' + id, + post_var_name: 'uploadFiles',//这里是自己定义的,默认的名字叫file + width: 450, + height: 300, + minWidth: 450, + minHeight: 300, + draggable: true, + resizable: true, + constraintoviewport: true, + modal: true, + reset_on_hide: false, + allow_close_on_upload: false, //关闭上传窗口是否仍然上传文件 + upload_autostart: false + }); + + + dialog.show(); + dialog.on('uploadsuccess', function (dialog) { + showResult("文件上传成功!"); + fileManageStore.reload(); + dialog.hide(); + }); //定义上传完成回调函数 + dialog.on('uploadfailed', function (dialog) { + showResult("文件上传失败!"); + fileManageStore.reload(); + dialog.hide(); + }); //定义上传完成回调函数 +} + +//BJ309YY-33:添加上传附件 +function uploadAttachFileFun() { + var id = top.Ext.getCmp('id').getValue(); + var tempObjectID = top.Ext.getCmp('tempObjectID').getValue(); + if (id == '') { + id = tempObjectID; + } + fileManageStore = new top.Ext.data.Store({ + proxy: new Ext.data.HttpProxy({ + url: WWWROOT + '/disinfectSystem/baseData/staffArchiveAction!loadStaffArchiveAttach.do?attachType=' + encodeURI("设备维护信息") + '&objectId=' + id, + method: 'POST' + }), + reader: new Ext.data.JsonReader({ + totalProperty: 'totalCount', + root: 'data' + }, [ + { name: 'id', mapping: 'id' }, + { name: 'fileName', mapping: 'fileName' } + ]), + listeners:{ + load:function(store,records) { + var html = ''; + var attachFileIds = ''; + for (var i = 0; i < records.length; i++) { + var items = records[i].data; + if(attachFileIds == ''){ + attachFileIds += items.id; + }else { + attachFileIds += ';' + items.id + } + html += "

" + (i + 1) + ',' + items.fileName + "

"; + } + documentGetElementsByClassName('fileDisplayClass', top.Ext.getCmp('fileDisplay').el.dom)[0].innerHTML = html; + top.Ext.getCmp('attachFileIds').setValue(attachFileIds); + } + } + }); + fileManageStore.load(); + + var cm = new top.Ext.grid.ColumnModel([{ + name: 'id1', + hidden: true, + dataIndex: 'id1' + }, { + menuDisabled: true, + header: "附件名称", + width: 200, + dataIndex: 'fileName' + }, { + id: 'deleteAction', + menuDisabled: true, + header: '删除 | 下载', + width: 100, + renderer: deleteOrDownLoad, + dataIndex: 'button' + }]); + + var tbar = [{ + text: '上传附件', + handler: function () { + uploadFileWindow(); + } + }]; + + var attachFilePanel = new top.Ext.FormPanel({ + id: 'attachFileForm', + frame: true, + labelAlign: 'right', + labelSeparator: ':', + bodyStyle: 'padding:5px 5px 0px 5px', + autoWidth: true, + autoHeight: true, + autoScroll: true, + items: [{ + layout: 'column', + items: [{ + columnWidth: 1, + layout: 'form', + items: [ + new top.Ext.grid.GridPanel({ + id: 'attachFileGrid', + store: fileManageStore, + tbar: tbar, + cm: cm, + height: 240, + frame: false, + autoExpandColumn: 'deleteAction', + bodyStyle: 'border:1px solid #afd7af', + anchor: '100%', + selModel: new top.Ext.grid.RowSelectionModel({ + singleSelect: false + }) + }) + ] + }] + }], + buttons: [{ + id: 'cancleBtn', + text: '取消', + handler: function () { + formWindow.close(); + } + }] + }); + + var formWindow = new top.Ext.Window({ + id: 'fileWin', + layout: 'fit', + title: "上传设备维护附件", + width: 600, + modal: true, + autoHeight: true, + border: false, + plain: true, + items: [attachFilePanel] + }); + formWindow.show(); +} + //触发项事件,用于触发对应的监测细则显示或隐藏 function triggerItemAction(valueTriggerItemIds,action){ if(valueTriggerItemIds != null && valueTriggerItemIds != ""){ @@ -404,6 +593,49 @@ } } top.Ext.getCmp('formDefinitionItemIds').setValue(itemIds); + + if(result.data.uploadAttachFile == '是'){ + var fileHtml = '
'; + fileHtml += ''; + fileHtml += '
'; + fileHtml += '
'; + fileHtml += '
'; + fileHtml += '
'; + + top.Ext.getCmp('addFormInstanceForm').remove('uploadAttachFileSet'); + top.Ext.getCmp('addFormInstanceForm').add({ + id : 'uploadAttachFileSet', + xtype:"fieldset", + labelAlign :'left', + title:"附件", + layout:'column', + autoHeight:true, + collapsible: true, + items:[{ + layout: 'form', + columnWidth: 1, + labelWidth: 90, + id: "fileButton", + items: [{ + name: 'fileDisplay', + id: 'fileDisplay', + width: 150, + fieldLabel: "附件", + anchor: '97%', + html: fileHtml + }, new top.Ext.Button({ + text: '附件管理', + id: 'uploadButton', + style: 'margin: 15px 0px 10px 95px;', + handler: function () { + uploadAttachFileFun(); + } + })] + }] + }); + var tempObjectID = Date.parse(new Date()) / 1000; + top.Ext.getCmp('tempObjectID').setValue(tempObjectID); + } top.Ext.getCmp('addFormInstanceForm').remove('itemsFieldSet'); if(items.length > 0){ @@ -418,6 +650,7 @@ items:items }); } + top.Ext.getCmp('addFormInstanceForm').doLayout(); if(top.Ext.getCmp('itemsFieldSet')){ top.Ext.getCmp('itemsFieldSet').doLayout(); @@ -453,16 +686,7 @@ ] ) }); - - fields : [{ - id : 'itemId', - tousseDefinitionId : 'tousseDefinitionId', - name : 'name', - amount : 'amount' - }] - - var formPanel = new top.Ext.FormPanel({ id : 'addFormInstanceForm', frame : true, @@ -480,6 +704,14 @@ collapsible: true, autoHeight:true, items : [{ + xtype: 'hidden', + name: 'tempObjectID', + id: 'tempObjectID' + },{ + xtype: 'hidden', + name: 'attachFileIds', + id: 'attachFileIds' + },{ xtype : 'hidden', name : 'id', id : 'id' @@ -726,7 +958,72 @@ }); } } + top.Ext.getCmp('formDefinitionItemIds').setValue(itemIds); + + if(result.data.formDefinition.uploadAttachFile == '是'){ + var fileHtml = '
'; + fileHtml += ''; + fileHtml += '
'; + fileHtml += '
'; + fileHtml += '
'; + fileHtml += '
'; + + top.Ext.getCmp('addFormInstanceForm').remove('uploadAttachFileSet'); + top.Ext.getCmp('addFormInstanceForm').add({ + id : 'uploadAttachFileSet', + xtype:"fieldset", + labelAlign :'left', + title:"附件", + layout:'column', + autoHeight:true, + collapsible: true, + items:[{ + layout: 'form', + columnWidth: 1, + labelWidth: 90, + id: "fileButton", + items: [{ + name: 'fileDisplay', + id: 'fileDisplay', + width: 150, + fieldLabel: "附件", + anchor: '97%', + html: fileHtml + }, new top.Ext.Button({ + text: '附件管理', + id: 'uploadButton', + style: 'margin: 15px 0px 10px 95px;', + handler: function () { + uploadAttachFileFun(); + } + })] + }] + }); + + Ext.Ajax.request({ + url: WWWROOT + '/disinfectSystem/baseData/staffArchiveAction!loadStaffArchiveAttach.do', + params: { attachType: '设备维护信息', objectId: id }, + success: function (response, options) { + var res = Ext.decode(response.responseText); + var html = ""; + if (res.success) { + var attachFileIds = ''; + for (var i = 0; i < res.data.length; i++) { + if(attachFileIds == ''){ + attachFileIds += res.data[i].id; + }else { + attachFileIds += ';' + res.data[i].id + } + html += "

" + (i + 1) + ',' + res.data[i].fileName + "

"; + } + documentGetElementsByClassName('fileDisplayClass', top.Ext.getCmp('fileDisplay').el.dom)[0].innerHTML = html; + top.Ext.getCmp("attachFileIds").setValue(attachFileIds); + } + } + }) + } + top.Ext.getCmp('addFormInstanceForm').remove('itemsFieldSet'); if(items.length > 0){ top.Ext.getCmp('addFormInstanceForm').add({ Index: ssts-web/src/main/webapp/disinfectsystem/deviceMaintenance/deviceMaintenanceCostomDefView.js =================================================================== diff -u -r36764 -r38667 --- ssts-web/src/main/webapp/disinfectsystem/deviceMaintenance/deviceMaintenanceCostomDefView.js (.../deviceMaintenanceCostomDefView.js) (revision 36764) +++ ssts-web/src/main/webapp/disinfectsystem/deviceMaintenance/deviceMaintenanceCostomDefView.js (.../deviceMaintenanceCostomDefView.js) (revision 38667) @@ -430,6 +430,27 @@ }] },{ layout : 'form', + columnWidth : .5, + labelWidth : 80, + items : [{ + xtype : 'combo', + fieldLabel : "允许上传附件", + name : "uploadAttachFile", + id : "uploadAttachFile", + valueField:'value', + displayField:'value', + mode:'local', + triggerAction : 'all', + store:new top.Ext.data.SimpleStore({ + fields : ['value'], + data : [['是'],['否']] + }), + editable : false, + value:'否', + anchor : '100%' + }] + },{ + layout : 'form', columnWidth : 1, labelWidth : 80, items : [{