puzhibing
2023-10-08 22199bbdda579861736420fe26c2873ab0f5d21c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/**
 * 初始化
 */
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;
};