MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {}; MWF.xDesktop.requireApp("process.FormDesigner", "Module.$Container", null, false); MWF.xDesktop.requireApp("process.FormDesigner", "Module.$Component", null, false); MWF.xDesktop.requireApp("process.FormDesigner", "Module.Datatable$Data", null, false); MWF.xDesktop.requireApp("process.FormDesigner", "Module.Datatable$Title", null, false); MWF.xDesktop.requireApp("process.FormDesigner", "Module.Table$Td", null, false); MWF.xApplication.process.FormDesigner.Module.Datatable = MWF.FCDatatable = new Class({ Extends: MWF.FC$Component, Implements: [Options, Events], options: { "style": "default", "propertyPath": "../x_component_process_FormDesigner/Module/Datatable/datatable.html" }, initialize: function(form, options){ this.setOptions(options); this.path = "../x_component_process_FormDesigner/Module/Datatable/"; this.cssPath = "../x_component_process_FormDesigner/Module/Datatable/"+this.options.style+"/css.wcss"; this._loadCss(); this.moduleType = "component"; this.moduleName = "datatable"; this.form = form; this.container = null; this.containerNode = null; this.containers = []; this.elements = []; this.selectedMultiTds = []; debugger; }, clearTemplateStyles: function(styles){ debugger; if (styles){ if (styles.styles) this.removeStyles(styles.styles, "styles"); if (styles.tableStyles) this.removeStyles(styles.tableStyles, "tableStyles"); if (styles.titleStyles) this.removeStyles(styles.titleStyles, "titleStyles"); if (styles.contentStyles) this.removeStyles(styles.contentStyles, "contentStyles"); if (styles.actionStyles) this.removeStyles(styles.actionStyles, "actionStyles"); if (styles.editStyles) this.removeStyles(styles.editStyles, "editStyles"); if (styles.amountStyles) this.removeStyles(styles.amountStyles, "amountStyles"); if (styles.sectionAmountStyles) this.removeStyles(styles.sectionAmountStyles, "sectionAmountStyles"); if (styles.itemTitleStyles) this.removeStyles(styles.itemTitleStyles, "itemTitleStyles"); if (styles.properties) this.removeStyles(styles.properties, "properties"); if (styles.importActionStyles) this.removeStyles(styles.importActionStyles, "importActionStyles"); if (styles.exportActionStyles) this.removeStyles(styles.exportActionStyles, "exportActionStyles"); if (styles.sectionKeyStyles) this.removeStyles(styles.sectionKeyStyles, "sectionKeyStyles"); if (styles.sectionKeyStyles) this.removeStyles(styles.sectionKeyStyles, "sectionByStyles"); } }, setTemplateStyles: function(styles){ debugger; if (styles.styles) this.copyStyles(styles.styles, "styles"); if (styles.tableStyles) this.copyStyles(styles.tableStyles, "tableStyles"); if (styles.titleStyles) this.copyStyles(styles.titleStyles, "titleStyles"); if (styles.contentStyles) this.copyStyles(styles.contentStyles, "contentStyles"); if (styles.actionStyles) this.copyStyles(styles.actionStyles, "actionStyles"); if (styles.editStyles) this.copyStyles(styles.editStyles, "editStyles"); if (styles.amountStyles) this.copyStyles(styles.amountStyles, "amountStyles"); if (styles.sectionAmountStyles) this.copyStyles(styles.sectionAmountStyles, "sectionAmountStyles"); if (styles.itemTitleStyles) this.copyStyles(styles.itemTitleStyles, "itemTitleStyles"); if (styles.properties) this.copyStyles(styles.properties, "properties"); if (styles.importActionStyles) this.copyStyles(styles.importActionStyles, "importActionStyles"); if (styles.exportActionStyles) this.copyStyles(styles.exportActionStyles, "exportActionStyles"); if (styles.sectionKeyStyles) this.copyStyles(styles.sectionKeyStyles, "sectionKeyStyles"); if (styles.sectionKeyStyles) this.copyStyles(styles.sectionKeyStyles, "sectionByStyles"); }, setImpExpTableStyles: function(){ //设置导入导出表格样式 if(this.form.templateStyles && this.form.templateStyles.table){ this.json.impExpTableStyles = Object.merge(this.json.impExpTableStyles||{}, this.form.templateStyles.table.styles||{}); this.json.impExpTableTitleStyles = Object.merge(this.json.impExpTableTitleStyles||{}, this.form.templateStyles.table.titleStyles||{}); this.json.impExpTableContentStyles = Object.merge(this.json.impExpTableContentStyles||{}, this.form.templateStyles.table.contentStyles||{}); this.json.impExpTableProperties = Object.merge(this.json.impExpTableProperties||{}, this.form.templateStyles.table.properties||{}); } }, _createMoveNode: function(){ var tableHTML = ""; tableHTML += ""; tableHTML += ""; tableHTML += "
"; this.moveNode = new Element("div", { "html": tableHTML }).inject(this.form.container); // this.moveNode = divNode.getFirst(); // this.moveNode.inject(divNode, "after"); // divNode.destroy(); this.moveNode.setStyles(this.css.moduleNodeMove); this._setTableStyle(); }, _setTableStyle: function(){ var tds = this.moveNode.getElements("td"); tds.setStyles({ "border": "1px dashed #999", "height": "20px" }); var tds = this.moveNode.getElements("th"); tds.setStyles({ "background": "#C3CEEA", "border": "1px dashed #999", "height": "20px" }); }, _getContainers: function(){ var tds = this.node.getElements("td"); this.form.getTemplateData("Datatable$Data", function(data){ tds.each(function(td){ var json = this.form.getDomjson(td); var tdContainer = null; if (!json){ var moduleData = Object.clone(data); tdContainer = new MWF.FCDatatable$Data(this.form); tdContainer.load(moduleData, td, this); }else{ var moduleData = Object.clone(data); Object.merge(moduleData, json); Object.merge(json, moduleData); tdContainer = new MWF.FCDatatable$Data(this.form); tdContainer.load(json, td, this); } this.containers.push(tdContainer); }.bind(this)); }.bind(this), false); }, _getElements: function(){ //this.elements.push(this); var ths = this.node.getElements("th"); this.form.getTemplateData("Datatable$Title", function(data){ ths.each(function(th){ var json = this.form.getDomjson(th); var thElement = null; if (!json){ var moduleData = Object.clone(data); thElement = new MWF.FCDatatable$Title(this.form); thElement.load(moduleData, th, this); }else{ var moduleData = Object.clone(data); Object.merge(moduleData, json); Object.merge(json, moduleData); thElement = new MWF.FCDatatable$Title(this.form); thElement.load(json, th, this); } this.elements.push(thElement); }.bind(this)); }.bind(this), false); }, // _getDroppableNodes: function(){ // var nodes = [this.form.node].concat(this.form.moduleElementNodeList, this.form.moduleContainerNodeList, this.form.moduleComponentNodeList); // this.form.moduleList.each( function(module){ // //数据网格不能往数据模板里拖 // if( module.moduleName === "datatemplate" ){ // var subDoms = this.form.getModuleNodes(module.node); // nodes.erase( module.node ); // subDoms.each(function (dom) { // nodes.erase( dom ); // }) // } // }.bind(this)); // return nodes; // }, _createNode: function(callback){ var module = this; var url = this.path+"datatableCreate.html"; MWF.require("MWF.widget.Dialog", function(){ var size = $(document.body).getSize(); var x = size.x/2-180; var y = size.y/2-130; var dlg = new MWF.DL({ "title": "Create Datatable", "style": "property", "top": y, "left": x-40, "fromTop":size.y/2-65, "fromLeft": size.x/2, "width": 360, "height": 260, "url": url, "lp": MWF.xApplication.process.FormDesigner.LP.propertyTemplate, "buttonList": [ { "text": MWF.APPFD.LP.button.ok, "action": function(){ module._createTableNode(); callback(); this.close(); } } ] }); dlg.show(); }.bind(this)); }, _createTableNode: function(){ var cols = $("MWFNewTableColumn").get("value"); var width = $("MWFNewTableWidth").get("value"); var widthUnitNode = $("MWFNewTableWidthUnit"); var widthUnit = widthUnitNode.options[widthUnitNode.selectedIndex].value; var border = $("MWFNewTableBorder").get("value"); var cellpadding = $("MWFNewTableCellpadding").get("value"); var cellspacing = $("MWFNewTableCellspacing").get("value"); var w = ""; if (widthUnit=="percent"){ w = width+"%"; }else{ w = width+"px"; } this.json.properties.width = w; this.json.properties.border = border; this.json.properties.cellpadding = cellpadding; this.json.properties.cellspacing = cellspacing; var tableHTML = ""; tableHTML += ""; for (var j=0; j