123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663 |
- package com.extUi;
- import java.util.ArrayList;
- import org.apache.log4j.Logger;
- import com.extUi.form.FormImpl;
- import com.extUi.form.Formable;
- import com.extUi.grid.GridImpl;
- import com.extUi.grid.Gridable;
- import com.sysmodel.XFormFactory;
- import com.sysmodel.collectmodel.xmlmodel.able.FormCollection;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.MdpClass;
- import com.sysmodel.datamodel.xmlmodel.able.MdpModule;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- import com.sysmodel.listmodel.xmlmodel.impl.FormListImpl;
- import com.toolkit.file.FileOperate;
- public class ExtUiImp implements ExtUiable{
- private final static Logger log = Logger.getLogger(ExtUiImp.class);
- private static SysModel sysmodel = ModelFactory.getSysmodel();
- private static Gridable Gridable = new GridImpl();
- private static Formable Formable = new FormImpl();
- public String getHtmlPathByModuleCode(String Code) {
- String result = "";
- MdpModule mdpmod = sysmodel.getMdpModuleByCode(Code);
- String fromXmlFolder = sysmodel.getFileLoadFolder();
- fromXmlFolder = fromXmlFolder.replace("WEB-INF", "page");
- String fromPackageName = mdpmod.getPackageName().replaceFirst("com.sinosoft.", "")
- .replace("lz.", "");
- result = fromXmlFolder + fromPackageName.replace(".", "\\");
- // 这段代码替换\到/ 字符串替换
- result = result.replaceAll("\\\\", "/");
- // log.info(result);
- return result;
- }
- public String getResourcePathByModuleCode(String Code) {
- String result = "";
- String temp = getHtmlPathByModuleCode(Code);
- temp = temp.substring(temp.indexOf("page"));
- result = "../";
- while (temp.indexOf("/") != -1) {
- result += "../";
- temp = temp.substring(temp.indexOf("/") + 1);
- };
- // log.info(result);
- return result;
- }
- public StringBuffer getFormJs(String pageid) {
- return Formable.getFormJs(pageid);
- }
- public String getFormHtmlNameById(String pageid) {
- String result = "";
- FormCollection FormCollection = XFormFactory.getXFormModel().getFormCollection(pageid);
- String[] tables = FormCollection.getClassidArry();
- MdpClass mdpClass = null;
- for (int i = 0; i < tables.length; i++) {
- String temp1 = (String) tables[i];
- mdpClass = sysmodel.getMdpClassByClassID(Integer.parseInt(temp1));
- result += mdpClass.getName().replaceFirst(mdpClass.getType() + "_", "");
- }
- result = result.replace("_", "");
- return result + "edit.html";
- }
- public String creatFormHtmlJsFile(String pageid) {
- FormCollection FormCollection = XFormFactory.getXFormModel().getFormCollection(pageid);
- String outputPath = this.getHtmlPathByModuleCode(FormCollection.getType());
- String ResourcePath = this.getResourcePathByModuleCode(FormCollection.getType());
- StringBuffer sb = new StringBuffer();
- sb.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n");
- sb.append(" <html> \n");
- sb.append(" <head>\n");
- sb.append(" <META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n");
- sb.append(" <title>" + FormCollection.getDescription() + FormCollection.getPageid()
- + "</title>\n");
- sb.append(" <script type=\"text/javascript\" src=\"" + ResourcePath
- + "admin/scripts/ext20/adapter/ext/ext-base.js\"></script>\n");
- sb.append(" <script type=\"text/javascript\" src=\"" + ResourcePath
- + "admin/scripts/ext20/ext-all.js\"></script>\n");
- sb.append(" <script type=\"text/javascript\" src=\"" + ResourcePath
- + "js/util.js\"></script>\n");
- sb.append(" <link rel=\"stylesheet\" type=\"text/css\" href=\"" + ResourcePath
- + "admin/scripts/ext20/resources/css/ext-all.css\"></link>\n");
- sb.append(" <link rel=\"stylesheet\" type=\"text/css\" href=\"" + ResourcePath
- + "css/grid/grid-button.css\"></link>\n");
- sb.append(" <script type=\"text/javascript\" src=\"" + ResourcePath
- + "js/getConstant.js\"></script>\n");
- sb.append(" <script type=\"text/javascript\">\n");
- sb.append(" Ext.onReady(function(){\n");
- sb.append(this.getFormJs(pageid));
- sb.append(" fsf.render(document.body);\n");
- sb.append(" });\n");
- sb.append(" </script>\n");
- sb.append(" </head>\n");
- sb.append(" <body>\n");
- sb.append(" </body> \n");
- sb.append("</html>");
- log.info("\n" + sb.toString());
- FileOperate FileOperate = new FileOperate();
- boolean bsuccess = FileOperate.createFile(getFormHtmlNameById(pageid), outputPath,
- sb.toString(), "UTF-8", false);
- sb = new StringBuffer();
- sb.append("【" + FormCollection.getPageid() + "】: 正在生成采集页面“"
- + FormCollection.getDescription() + "” ...<br>");
- sb.append("<font color=\"#FF0000\">");
- sb.append("文件" + bsuccess + "发布到:" + outputPath + "/" + getFormHtmlNameById(pageid));
- sb.append("<br></font>");
- return sb.toString();
- }
- public String creatFormJsFile(String pageid) {
- FormCollection FormCollection = XFormFactory.getXFormModel().getFormCollection(pageid);
- String outputPath = this.getHtmlPathByModuleCode(FormCollection.getType());
- StringBuffer sb = new StringBuffer();
- String jsFileName = getFormHtmlNameById(pageid).replace(".html", ".js");
- sb.append("function getEditForm(Win){\n");
- sb.append(this.getFormJs(pageid));
- sb.append(" return fsf;\n");
- sb.append("}\n");
- FileOperate FileOperate = new FileOperate();
- boolean bsuccess = FileOperate.createFile(jsFileName, outputPath, sb.toString(), "UTF-8",
- false);
- sb = new StringBuffer();
- sb.append("【" + FormCollection.getPageid() + "】: 正在生成采集JS函数“"
- + FormCollection.getDescription() + "” ...<br>");
- sb.append("<font color=\"#FF0000\">");
- sb.append("文件" + bsuccess + "发布到:" + outputPath + "/" + jsFileName);
- sb.append("<br></font>");
- return sb.toString();
- }
- public String creatJsFile(String pageid, String listid) {
- FormCollection formCollection = XFormFactory.getXFormModel().getFormCollection(pageid);
- String outputPath = this.getHtmlPathByModuleCode(formCollection.getType());
- StringBuffer sb = new StringBuffer();
- String jsFileName = getFormHtmlNameById(pageid).replace(".html", ".js");
- MdpModule mdpmod = sysmodel.getMdpModuleByCode(formCollection.getType());
- sb.append("/**\n");
- sb.append(" * @class \n");
- sb.append(" * @author \n");
- sb.append(" * @deprecated ");
- sb.append(mdpmod.getDescription());// 类说明
- sb.append(" \n");
- sb.append(" */\n");
- sb.append("Ext.namespace('" + mdpmod.getPackageName() + "');\n");
- sb.append(mdpmod.getPackageName());
- sb.append(".");
- sb.append(sysmodel.getMdpClassByClassID(Integer.valueOf(formCollection.getClassid()))
- .getName().replace("_", ""));
- sb.append("= function() {\n");
- sb.append("var _this = this;\n");
- sb.append("\n");
- sb.append("// 私有属性\n");
- sb.append("\n");
- sb.append("// 公有属性\n");
- sb.append("_this.listGrid = null;\n");
- sb.append("_this.queryFrom = null;\n");
- sb.append("_this.editFrom = null;\n");
- sb.append("// 私有方法\n");
- sb.append("\n");
- // 生成form表单
- sb.append(this.getFormJs(pageid));
- sb.append("// 公有方法\n");
- sb.append("/**\n");
- sb.append(" * 新增用户 参数-obj 数据对象,json格式\n");
- sb.append(" */\n");
- sb.append("_this.add = function(obj) {\n");
- sb.append("\n");
- sb.append("com.sinosoft.common.utils.Request.add(\n");
- sb.append("'../ws/crud/CRUDService/create', obj, function() {\n");
- sb.append("// 成功后需要执行的动作\n");
- sb.append("\n");
- sb.append("// 刷新列表数据\n");
- sb.append("var ds = _this.listGrid.getStore();\n");
- sb.append("ds.reload();\n");
- sb.append("// 成功后自动关闭 新增表单窗口-调用框架方法\n");
- sb.append("com.sinosoft.common.frameWork.FrameWork.hideWin();\n");
- sb.append("\n");
- sb.append("});\n");
- sb.append("}\n");
- sb.append(" /**\n");
- sb.append(" * 显示详细信息\n");
- sb.append(" */\n");
- sb.append(" _this.showInfo = function() {\n");
- sb.append(" // 获取用户选择的列\n");
- sb.append(" var sm = _this.listGrid.getSelectionModel();\n");
- sb.append(" if (sm.getCount() == 1) {\n");
- sb.append(" // 获取数据id\n");
- sb.append(" var FD_OBJECTID = sm.getSelected().get('FD_OBJECTID"
- + formCollection.getClassid() + "');\n");
- sb.append(" // 构造传给服务的参数,\n");
- sb.append(" var params = {\n");
- sb.append(" objectID : FD_OBJECTID,\n");
- sb.append("classid : '");
- sb.append(formCollection.getClassid());
- sb.append("'\n");
- sb.append(" };\n");
- sb.append(" com.sinosoft.common.utils.Request.query(\n");
- sb.append(" '../ws/crud/CRUDService/getDataById/', params, function(obj) {\n");
- sb.append(" // 成功后需要执行的动作\n");
- sb.append(" var infoWin = new Ext.Window({\n");
- sb.append(" layout : 'fit',\n");
- sb.append(" width : 600,\n");
- sb.append(" draggable : true, // 不允许拖动\n");
- sb.append(" modal : false,\n");
- sb.append(" maximizable : true,\n");
- sb.append(" minimizable : false,\n");
- sb.append(" autoDestroy : true,\n");
- sb.append(" height : 400,\n");
- sb.append(" autoHeight : false,\n");
- sb.append(" autoScroll : true,\n");
- sb.append(" title : '详细信息',\n");
- sb.append(" closable : true,\n");
- sb.append(" closeAction : 'close'\n");
- sb.append(" });\n");
- sb.append(" infoWin.show();\n");
- sb.append(Gridable.getTpl(listid));
- sb.append(" tpl.overwrite(infoWin.body, obj);\n");
- sb.append("});\n");
- sb.append("} else {\n");
- sb.append("// 提示用户删除操作必须选择记录--调用模型框架显示\n");
- sb.append("com.sinosoft.common.frameWork.FrameWork.showMsg('info', '请选择一条记录!');\n");
- sb.append("}\n");
- sb.append("};\n");
- sb.append("/**\n");
- sb.append(" * 修改用户信息 参数-obj 数据对象,josn格式\n");
- sb.append(" */\n");
- sb.append("_this.edit = function(obj) {\n");
- sb.append("\n");
- sb.append("com.sinosoft.common.utils.Request.update(\n");
- sb.append("'../ws/crud/CRUDService/update', obj, function() {\n");
- sb.append("// 成功后需要执行的动作\n");
- sb.append("\n");
- sb.append("// 刷新列表数据\n");
- sb.append("var ds = _this.listGrid.getStore();\n");
- sb.append("ds.reload();\n");
- sb.append("// 成功后自动关闭 新增表单窗口-调用框架方法\n");
- sb.append("com.sinosoft.common.frameWork.FrameWork.hideWin();\n");
- sb.append("});\n");
- sb.append("}\n");
- sb.append("/**\n");
- sb.append(" * 删除用户 参数:无\n");
- sb.append(" */\n");
- sb.append("_this.del = function(button, text) {\n");
- sb.append("\n");
- sb.append("if (button == 'yes') {\n");
- sb.append("// 获取用户选择的列\n");
- sb.append("var sm = _this.listGrid.getSelectionModel();\n");
- sb.append("if (sm.getCount() > 0) {\n");
- sb.append("// 构造需要删除的对象的 FD_OBJECTID 用逗号(,) 分隔\n");
- sb.append("var ids = '';\n");
- sb.append("var selections = sm.getSelections();\n");
- sb.append("for (var i = 0; i < selections.length; i++) {\n");
- sb.append("ids += selections[i].get('FD_OBJECTID" + listid + "') + ',';\n");
- sb.append("}\n");
- sb.append("// 构造传给服务的参数,objectIDs---要删除的对象的id集合,classid--要删除的表的id\n");
- sb.append("\n");
- sb.append("var params = {\n");
- sb.append("objectIDs : ids,\n");
- sb.append("classid : '");
- sb.append(formCollection.getClassid());
- sb.append("'\n");
- sb.append("};\n");
- sb.append("// 调用框架 的删除请求服务\n");
- sb.append("// 参数 url---删除服务的地址,默认为ws/crud/CRUDService/delete/\n");
- sb.append("// 参数params ---传给服务的参数,\n");
- sb.append("// sucFun---删除成功后的回调函数,一般为刷新列表数据,可以添加自己的业务函数\n");
- sb.append("com.sinosoft.common.utils.Request.del(\n");
- sb.append("'../ws/crud/CRUDService/delete/', params,\n");
- sb.append("function() {\n");
- sb.append("// 成功后需要执行的动作\n");
- sb.append("\n");
- sb.append("// 刷新列表数据\n");
- sb.append("var ds = _this.listGrid.getStore();\n");
- sb.append("ds.reload();\n");
- sb.append("\n");
- sb.append("});\n");
- sb.append("}\n");
- sb.append("}\n");
- sb.append("\n");
- sb.append("}\n");
- sb.append("/**\n");
- sb.append(" * 查询函数\n");
- sb.append(" */\n");
- sb.append("_this.query = function() {\n");
- sb.append("// 获取查询条件-根据表单内容构造查询 条件\n");
- sb.append("var params = _this.queryFrom.getForm().getValues();\n");
- sb.append("// 加载数据\n");
- sb.append("var ds = _this.listGrid.getStore();\n");
- sb.append("ds.load({\n");
- sb.append("params : params\n");
- sb.append("});\n");
- sb.append("\n");
- sb.append("}\n");
- sb.append("/**\n");
- sb.append(" * 显示新增表单\n");
- sb.append(" * \n");
- sb.append(" */\n");
- sb.append("_this.showAddPanel = function() {\n");
- sb.append("getEditFrom();\n");
- sb.append("com.sinosoft.common.frameWork.FrameWork.openWin(_this.editFrom, 500,\n");
- sb.append("500, '新增');\n");
- sb.append("\n");
- sb.append("}\n");
- sb.append("/**\n");
- sb.append(" * 显示编辑表单\n");
- sb.append(" */\n");
- sb.append("_this.showEditPanel = function() {\n");
- sb.append("var sm = _this.listGrid.getSelectionModel();\n");
- sb.append("if (sm.getCount() == 1) {\n");
- sb.append("var record = sm.getSelected();\n");
- sb.append("if (_this.editFrom != null) {\n");
- sb.append("getEditFrom();\n");
- sb.append("com.sinosoft.common.frameWork.FrameWork.openWin(_this.editFrom,\n");
- sb.append("500, 500, '修改');\n");
- sb.append("\n");
- sb.append("_this.editFrom.getForm().loadRecord(record);\n");
- sb.append("} else {\n");
- sb.append("getEditFrom();\n");
- sb.append("com.sinosoft.common.frameWork.FrameWork.openWin(_this.editFrom,\n");
- sb.append("500, 500, '修改');\n");
- sb.append("_this.editFrom.getForm().loadRecord(record);\n");
- sb.append("}\n");
- sb.append("\n");
- sb.append("}\n");
- sb.append("\n");
- sb.append("}\n");
- sb.append("/**\n");
- sb.append(" * 显示删除确认框\n");
- sb.append(" */\n");
- sb.append("_this.showDelcon = function(obj) {\n");
- sb.append("// 获取用户选择的列\n");
- sb.append("var sm = _this.listGrid.getSelectionModel();\n");
- sb.append("if (sm.getCount() > 0) {\n");
- sb.append("\n");
- sb.append("Ext.MessageBox.confirm('系统提示', '您确定删除这些数据吗?', _this.del);\n");
- sb.append("} else {\n");
- sb.append("// 提示用户删除操作必须选择记录--调用模型框架显示\n");
- sb.append("com.sinosoft.common.frameWork.FrameWork.showMsg('info',\n");
- sb.append("'请选择要删除的记录!');\n");
- sb.append("}\n");
- sb.append("\n");
- sb.append("}\n");
- sb.append("\n");
- sb.append("\n");
- sb.append(this.getGridJs(listid));
- sb.append("\n");
- sb.append("}\n");
- FileOperate FileOperate = new FileOperate();
- boolean bsuccess = FileOperate.createFile(jsFileName, outputPath, sb.toString(), "UTF-8",
- false);
- sb = new StringBuffer();
- sb.append("【" + formCollection.getPageid() + "】: 正在生成采集JS函数“"
- + formCollection.getDescription() + "” ...<br>");
- sb.append("<font color=\"#FF0000\">");
- sb.append("文件" + bsuccess + "发布到:" + outputPath + "/" + jsFileName);
- sb.append("<br></font>");
- return sb.toString();
- }
- public String getGridHtmlNameById(String listid) {
- String result = "";
- FormListImpl FormList = (FormListImpl) XFormFactory.getXFormModel().getFormList(listid);
- ArrayList<String> tables = FormList.getQueryTables();
- MdpClass mdpClass = null;
- for (int i = 0; i < tables.size(); i++) {
- String temp1 = (String) tables.get(i);
- mdpClass = sysmodel.getMdpClassByClassID(Integer.parseInt(temp1));
- result += mdpClass.getName().replaceFirst(mdpClass.getType() + "_", "");
- }
- result = result.replace("_", "");
- return result + "list.html";
- }
- public StringBuffer getGridJs(String listid) {
- return Gridable.getGridJs(listid);
- }
- public String creatGridHtmlJsFile(String listid) {
- FormListImpl FormList = (FormListImpl) XFormFactory.getXFormModel().getFormList(listid);
- String outputPath = this.getHtmlPathByModuleCode(FormList.getType());
- String ResourcePath = this.getResourcePathByModuleCode(FormList.getType());
- StringBuffer sb = new StringBuffer();
- sb.append("<html xmlns:lxslt=\"http://xml.apache.org/xslt\" \n");
- sb.append(" xmlns:stringutils=\"xalan://org.apache.tools.ant.util.StringUtils\"> \n");
- sb.append(" <head>\n");
- sb.append(" <META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n");
- sb.append(" <title>" + FormList.getDescription() + FormList.getListid() + "</title>\n");
- sb.append(" <script type=\"text/javascript\" src=\"" + ResourcePath
- + "js/ext/adapter/ext/ext-base.js\"></script>\n");
- sb.append(" <script type=\"text/javascript\" src=\"" + ResourcePath
- + "js/ext/ext-all.js\"></script>\n");
- sb.append(" <script type=\"text/javascript\" src=\"" + ResourcePath
- + "js/util.js\"></script>\n");
- if (FormList.getQueryFields().size() > 0) {
- sb.append(" <script type=\"text/javascript\" src=\"" + ResourcePath
- + "js/getConstant.js\"></script>\n");
- }
- sb.append(" <link rel=\"stylesheet\" type=\"text/css\" href=\"" + ResourcePath
- + "js/ext/resources/css/ext-all.css\"></link>\n");
- sb.append(" <link rel=\"stylesheet\" type=\"text/css\" href=\"" + ResourcePath
- + "css/grid/grid-button.css\"></link>\n");
- /**
- * 引入页面的CSS,JS等
- */
- sb.append(FormList.getInclude() + "\n");
- sb.append(this.getGridJs(listid));
- sb.append(" </head>\n");
- sb.append(" <body>\n");
- // 列表显示的div
- sb.append(" <div id=\"Grid" + listid + "\"></div>\n");
- if (FormList.getQueryFields().size() > 0 || FormList.getListAction().size() > 0) {
- sb.append(" <div id=\"qry-window\" class=\"x-hidden\">\n");
- sb.append(" <div class=\"x-window-header\">" + FormList.getListHead().getTitle()
- + "</div>\n");
- sb.append(" <div id=\"content\"></div>\n");
- sb.append(" </div>\n");
- sb.append(" <div id=\"edit-window\" class=\"x-hidden\">\n");
- sb.append(" <div class=\"x-window-header\">" + FormList.getListHead().getTitle()
- + "</div>\n");
- sb.append(" <div id=\"content\"></div>\n");
- sb.append(" </div>\n");
- }
- sb.append(" </body> \n");
- sb.append("</html>");
- log.info("生成文件名称:" + getGridHtmlNameById(listid));
- log.info("生成文件路径:" + outputPath);
- log.info("\n" + sb.toString());
- FileOperate FileOperate = new FileOperate();
- boolean bsuccess = FileOperate.createFile(getGridHtmlNameById(listid), outputPath,
- sb.toString(), "UTF-8", false);
- sb = new StringBuffer();
- sb.append("【" + FormList.getListid() + "】: 正在生成列表“" + FormList.getDescription()
- + "” 页面...<br>");
- sb.append("<font color=\"#FF0000\">");
- sb.append("文件" + bsuccess + "发布到:" + outputPath + "/" + getGridHtmlNameById(listid));
- sb.append("<br></font>");
- return sb.toString();
- }
- public String creatQueryJsFile(String listid) {
- FormListImpl formlist = (FormListImpl) XFormFactory.getXFormModel().getFormList(listid);
- String outputPath = this.getHtmlPathByModuleCode(formlist.getType());
- StringBuffer sb = new StringBuffer();
- String jsFileName = getGridHtmlNameById(listid).replace(".html", ".js");
- MdpModule mdpmod = sysmodel.getMdpModuleByCode(formlist.getType());
- int classid = 0;
- if (formlist.getQueryFields().size() > 0) {
- classid = formlist.getQueryFields().get(0).getClassid();
- }
- sb.append("/**\n");
- sb.append(" * @class \n");
- sb.append(" * @author \n");
- sb.append(" * @deprecated ");
- sb.append(mdpmod.getDescription());// 类说明
- sb.append(" \n");
- sb.append(" */\n");
- sb.append("Ext.namespace('" + mdpmod.getPackageName() + "');\n");
- sb.append(mdpmod.getPackageName());
- sb.append(".");
- sb.append(sysmodel.getMdpClassByClassID(classid).getName().replace("_", ""));
- sb.append("= function() {\n");
- sb.append("var _this = this;\n");
- sb.append("\n");
- sb.append("// 私有属性\n");
- sb.append("\n");
- sb.append("// 公有属性\n");
- sb.append("_this.listGrid = null;\n");
- sb.append("_this.queryFrom = null;\n");
- sb.append("// 私有方法\n");
- sb.append("\n");
- sb.append("// 公有方法\n");
- sb.append("/**\n");
- sb.append(" */\n");
- sb.append(" /**\n");
- sb.append(" * 显示详细信息\n");
- sb.append(" */\n");
- sb.append(" _this.showInfo = function() {\n");
- sb.append(" // 获取用户选择的列\n");
- sb.append(" var sm = _this.listGrid.getSelectionModel();\n");
- sb.append(" if (sm.getCount() == 1) {\n");
- sb.append(" // 获取数据id\n");
- sb.append(" var FD_OBJECTID = sm.getSelected().get('FD_OBJECTID" + classid + "');\n");
- sb.append(" // 构造传给服务的参数,\n");
- sb.append(" var params = {\n");
- sb.append(" objectID : FD_OBJECTID,\n");
- sb.append("classid : '");
- sb.append(classid);
- sb.append("'\n");
- sb.append(" };\n");
- sb.append(" com.sinosoft.common.utils.Request.query(\n");
- sb.append(" '../ws/crud/CRUDService/getDataById/', params, function(obj) {\n");
- sb.append(" // 成功后需要执行的动作\n");
- sb.append(" var infoWin = new Ext.Window({\n");
- sb.append(" layout : 'fit',\n");
- sb.append(" width : 600,\n");
- sb.append(" draggable : true, // 不允许拖动\n");
- sb.append(" modal : false,\n");
- sb.append(" maximizable : true,\n");
- sb.append(" minimizable : false,\n");
- sb.append(" autoDestroy : true,\n");
- sb.append(" height : 400,\n");
- sb.append(" autoHeight : false,\n");
- sb.append(" autoScroll : true,\n");
- sb.append(" title : '详细信息',\n");
- sb.append(" closable : true,\n");
- sb.append(" closeAction : 'close'\n");
- sb.append(" });\n");
- sb.append(" infoWin.show();\n");
- sb.append(Gridable.getTpl(listid));
- sb.append(";\n");
- sb.append(" tpl.overwrite(infoWin.body, obj);\n");
- sb.append("});\n");
- sb.append("};\n");
- sb.append("}\n");
- sb.append("/**\n");
- sb.append(" * 列表导出EXCEL 参数-_this.listGrid 数据对象无\n");
- sb.append(" */\n");
- // 导出EXCEL函数
- sb.append(this.getExcelFunction());
- sb.append("/**\n");
- sb.append(" * 查询函数\n");
- sb.append(" */\n");
- sb.append("_this.query = function() {\n");
- sb.append("// 获取查询条件-根据表单内容构造查询 条件\n");
- sb.append("var params = _this.queryFrom.getForm().getValues();\n");
- sb.append("// 加载数据\n");
- sb.append("var ds = _this.listGrid.getStore();\n");
- sb.append("ds.load({\n");
- sb.append("params : params\n");
- sb.append("});\n");
- sb.append("\n");
- sb.append("}\n");
- sb.append("/**\n");
- sb.append("\n");
- sb.append("\n");
- sb.append(this.getGridForQuery(listid));
- sb.append("\n");
- sb.append("}\n");
- FileOperate FileOperate = new FileOperate();
- boolean bsuccess = FileOperate.createFile(jsFileName, outputPath, sb.toString(), "UTF-8",
- false);
- sb = new StringBuffer();
- sb.append("【" + formlist.getListid() + "】: 正在生成采集JS函数“" + formlist.getDescription()
- + "” ...<br>");
- sb.append("<font color=\"#FF0000\">");
- sb.append("文件" + bsuccess + "发布到:" + outputPath + "/" + jsFileName);
- sb.append("<br></font>");
- return sb.toString();
- }
- private String getExcelFunction() {
- StringBuffer sb = new StringBuffer();
- sb.append("_this.exportExcel = function(grid) {\n");
- sb.append("var ds = new Ext.data.Store({// 这是数据源\n");
- sb.append(" proxy : grid.store.proxy,\n");
- sb.append(" baseParams : grid.store.baseParams,\n");
- sb.append(" reader : grid.store.reader\n");
- sb.append("});\n\n");
- sb.append("var dd = grid.store.baseParams;\n");
- sb.append("ds.load({\n");
- sb.append(" start : 0,\n");
- sb.append(" limit : 2000\n");
- sb.append("});\n");
- sb.append("var vExportContent = grid.getExcelXml(true);\n");
- sb.append("if (Ext.isIE6 || Ext.isIE7 || Ext.isSafari || Ext.isSafari2 || Ext.isSafari3) {\n");
- sb.append("var fd = Ext.get('frmDummy');\n");
- sb.append("if (!fd) {\n");
- sb.append(" fd = Ext.DomHelper.append(Ext.getBody(), {\n");
- sb.append(" tag : 'form',\n");
- sb.append(" method : 'post',\n");
- sb.append(" id : 'frmDummy',\n");
- sb.append(" action : 'toExcel/exportexcel.jsp',\n");
- sb.append(" target : '_blank',\n");
- sb.append(" name : 'frmDummy',\n");
- sb.append(" cls : 'x-hidden',\n");
- sb.append(" cn : [{\n");
- sb.append(" tag : 'input',\n");
- sb.append(" name : 'exportContent',\n");
- sb.append(" id : 'exportContent',\n");
- sb.append(" type : 'hidden'\n");
- sb.append("}]\n");
- sb.append("}, true);\n");
- sb.append("}\n");
- sb.append(" fd.child('#exportContent').set({\n");
- sb.append(" value : vExportContent\n");
- sb.append(" });\n");
- sb.append(" fd.dom.submit();\n");
- sb.append("} else {\n");
- sb.append(" document.location = 'data:application/vnd.ms-excel;base64,'\n");
- sb.append(" + Base64.encode(vExportContent);\n");
- sb.append("}\n");
- sb.append("}\n");
- return sb.toString();
- }
- private StringBuffer getGridForQuery(String listid) {
- return Gridable.getGridJsForQuery(listid);
- }
- }
|