/**
|
* 初始化
|
*/
|
var Code = {
|
ztreeInstance: null,
|
tableName: "",
|
tableComment: "",
|
submitData: {},
|
switchs: {}
|
};
|
|
/**
|
* 选择table的事件
|
*/
|
Code.selectTable = function (tableName, tableComment) {
|
|
SelectList.clearSelect("templateList");
|
Code.switchs = {};
|
|
if (SelectList.singelSelect("tableList", "tableName", tableName) == true) {
|
Code.tableName = tableName;
|
Code.tableComment = tableComment;
|
// // 自动生成前缀
|
// $("#ignoreTabelPrefix").val(tableName.split("_")[0] + "_");
|
Code.setTableName(tableName, tableComment);
|
|
// 选中所有模板项
|
Code.selectedTemplateAll();
|
} else {
|
Code.tableName = "";
|
Code.tableComment = "";
|
}
|
};
|
/**
|
* 选中所有模板项
|
*/
|
Code.selectedTemplateAll = function() {
|
SelectList.mutiSelect("templateList", "key", "controllerSwitch");
|
Code.switchs['controllerSwitch'] = true;
|
SelectList.mutiSelect("templateList", "key", "entitySwitch");
|
Code.switchs['entitySwitch'] = true;
|
SelectList.mutiSelect("templateList", "key", "serviceSwitch");
|
Code.switchs['serviceSwitch'] = true;
|
SelectList.mutiSelect("templateList", "key", "daoSwitch");
|
Code.switchs['daoSwitch'] = true;
|
SelectList.mutiSelect("templateList", "key", "indexPageSwitch");
|
Code.switchs['indexPageSwitch'] = true;
|
SelectList.mutiSelect("templateList", "key", "addPageSwitch");
|
Code.switchs['addPageSwitch'] = true;
|
SelectList.mutiSelect("templateList", "key", "editPageSwitch");
|
Code.switchs['editPageSwitch'] = true;
|
SelectList.mutiSelect("templateList", "key", "jsSwitch");
|
Code.switchs['jsSwitch'] = true;
|
SelectList.mutiSelect("templateList", "key", "infoJsSwitch");
|
Code.switchs['infoJsSwitch'] = true;
|
SelectList.mutiSelect("templateList", "key", "sqlSwitch");
|
Code.switchs['sqlSwitch'] = true;
|
};
|
|
/**
|
* 选择模板的事件
|
*/
|
Code.selectTemplate = function (templateKey) {
|
if (Code.tableName != "") {
|
if (SelectList.mutiSelect("templateList", "key", templateKey) == true) {
|
Code.switchs[templateKey] = true;
|
} else {
|
Code.switchs[templateKey] = false;
|
}
|
} else {
|
Feng.info("请先选择表");
|
}
|
};
|
|
/**
|
* 点击生成
|
*/
|
Code.generate = function () {
|
Code.submitData = {};
|
Code.submitData.tableName = Code.tableName;
|
Code.submitData.bizName = Code.bizName;
|
this.set('projectPath').set('author').set('projectPackage').set('corePackage').set('ignoreTabelPrefix').set('dbName').set('bizName').set('moduleName').set('parentMenuName');
|
var baseAjax = Feng.baseAjax("/code/generate", "生成代码");
|
|
for (var item in Code.switchs) {
|
Code.submitData[item] = Code.switchs[item];
|
}
|
|
baseAjax.setData(Code.submitData);
|
baseAjax.start();
|
};
|
|
/**
|
* 设置表名称,业务名称
|
*/
|
Code.setTableName = function (tableName, tableComment) {
|
var preSize = $("#ignoreTabelPrefix").val().length;
|
$("#tableName").val(tableName);
|
$("#bizName").val(tableComment);
|
$("#className").val(Feng.underLineToCamel(tableName.substring(preSize)));
|
};
|
|
/**
|
* 点击父级编号input框时
|
*/
|
Code.onClickDept = function (e, treeId, treeNode) {
|
$("#parentMenuName").attr("value", Code.ztreeInstance.getSelectedVal());
|
};
|
|
/**
|
* 显示父级菜单选择的树
|
*/
|
Code.showMenuSelectTree = function () {
|
Feng.showInputTree("parentMenuName", "pcodeTreeDiv", 15, 34);
|
};
|
|
$(function () {
|
var ztree = new $ZTree("pcodeTree", "/menu/selectMenuTreeList");
|
ztree.bindOnClick(Code.onClickDept);
|
ztree.init();
|
Code.ztreeInstance = ztree;
|
$("#pcodeTree").css('width',$("#parentMenuName").css('width'));
|
});
|
|
Code.set = function (key, value) {
|
Code.submitData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
|
return this;
|
};
|