提交 | 用户 | 时间
|
71e81e
|
1 |
layui.use(['layer', 'ax', 'form', 'laydate', 'element', 'table', 'jquery'], function () { |
懒 |
2 |
var $ = layui.$; |
|
3 |
var $ax = layui.ax; |
|
4 |
var layer = layui.layer; |
|
5 |
var form = layui.form; |
|
6 |
var laydate = layui.laydate; |
|
7 |
var element = layui.element; |
|
8 |
var table = layui.table; |
|
9 |
var jquery = layui.jquery; |
|
10 |
|
|
11 |
var Code = { |
|
12 |
tableNames: "", |
|
13 |
dbId: "", |
|
14 |
tables: {}, |
|
15 |
jumpTypeBounceSet: new Set() |
|
16 |
}; |
|
17 |
|
|
18 |
$('#code_gen').click(function () { |
|
19 |
window.location.href = Feng.ctxPath + "/gen"; |
|
20 |
}); |
|
21 |
|
|
22 |
$('#db_config').click(function () { |
|
23 |
window.location.href = Feng.ctxPath + "/db"; |
|
24 |
}); |
|
25 |
|
|
26 |
$('#add_db').click(function () { |
|
27 |
window.location.href = Feng.ctxPath + "/db/add"; |
|
28 |
}); |
|
29 |
|
|
30 |
table.render({ |
|
31 |
elem: '#dbTableList' |
|
32 |
, url: Feng.ctxPath + '/databaseInfo/tableList' |
|
33 |
, page: false |
|
34 |
, cols: [[ |
|
35 |
{type: 'checkbox'} |
|
36 |
, {field: 'tableName', title: '表的名称'} |
|
37 |
, {field: 'tableComment', title: '表的名称注释'} |
|
38 |
, {field: 'jumpType', title: '跳转是否弹窗', templet: '#switchTpl', unresize: true} |
|
39 |
, {toolbar: '#tableBar', title: '操作'} |
|
40 |
]] |
|
41 |
}); |
|
42 |
|
|
43 |
//监听跳转类型操作 |
|
44 |
form.on('switch(jumpTypeFilter)', function (obj) { |
|
45 |
obj.elem.checked ? Code.jumpTypeBounceSet.add(obj.elem.value) : Code.jumpTypeBounceSet.delete(obj.elem.value); |
|
46 |
layer.tips(obj.elem.checked ? '新增修改页面弹框展示' : '新增修改页面页面跳转展示', obj.othis); |
|
47 |
}); |
|
48 |
|
|
49 |
table.on('checkbox(dbTableList)', function (obj) { |
|
50 |
var checkStatus = table.checkStatus('dbTableList'); |
|
51 |
var tableNames = ""; |
|
52 |
for (var tableItem in checkStatus.data) { |
|
53 |
tableNames += "CAT" + checkStatus.data[tableItem].tableName; |
|
54 |
} |
|
55 |
Code.tableNames = tableNames; |
|
56 |
|
|
57 |
//选中行后,显示对应的操作按钮 |
|
58 |
if (obj.type === "all") { |
|
59 |
if (obj.checked) { |
|
60 |
$("a[name='con-btn']").removeClass("layui-hide"); |
|
61 |
$("a[name='param-box']").removeClass("layui-hide"); |
|
62 |
$("div[name='jumpTypeDiv']").removeClass("layui-hide"); |
|
63 |
} else { |
|
64 |
$("a[name='con-btn']").addClass("layui-hide"); |
|
65 |
$("a[name='param-box']").addClass("layui-hide"); |
|
66 |
$("div[name='jumpTypeDiv']").addClass("layui-hide"); |
|
67 |
} |
|
68 |
} else { |
|
69 |
if (obj.checked) { |
|
70 |
$("#" + obj.data.tableName + "_opt").removeClass("layui-hide"); |
|
71 |
$("#" + obj.data.tableName + "_pbt").removeClass("layui-hide"); |
|
72 |
$("#" + obj.data.tableName + "_jt").removeClass("layui-hide"); |
|
73 |
|
|
74 |
} else { |
|
75 |
$("#" + obj.data.tableName + "_opt").addClass("layui-hide"); |
|
76 |
$("#" + obj.data.tableName + "_pbt").addClass("layui-hide"); |
|
77 |
$("#" + obj.data.tableName + "_jt").addClass("layui-hide"); |
|
78 |
} |
|
79 |
} |
|
80 |
}); |
|
81 |
|
|
82 |
table.on('tool(dbTableList)', function (obj) { |
|
83 |
var data = obj.data; |
|
84 |
var layEvent = obj.event; |
|
85 |
|
|
86 |
if (layEvent === 'conditionEdit') { |
|
87 |
top.layer.open({ |
|
88 |
type: 2, |
|
89 |
title: '选择字段', |
|
90 |
area: ['900px', '600px'], |
|
91 |
content: Feng.ctxPath + '/tableFields?dbId=' + Code.dbId + "&tableName=" + data.tableName |
|
92 |
}); |
|
93 |
} |
|
94 |
}); |
|
95 |
|
|
96 |
form.on('select(dataSourceId)', function (data) { |
|
97 |
var dbId = data.value; |
|
98 |
Code.dbId = dbId; |
|
99 |
table.reload("dbTableList", {where: {dbId: dbId}}); |
|
100 |
}); |
|
101 |
|
|
102 |
|
|
103 |
$('#execute').on('click', function () { |
|
104 |
|
|
105 |
let author = $("#author").val(); |
|
106 |
let proPackage = $("#proPackage").val(); |
|
107 |
let removePrefix = $("#removePrefix").val(); |
|
108 |
let dataSourceId = $("#dataSourceId").val(); |
|
109 |
let modularName = $("#modularName").val(); |
|
110 |
let version = $("input[name='version']:checked").val(); |
|
111 |
let genLocation = $("input[name='genLocation']:checked").val(); |
|
112 |
let swagger = $("input[name='swagger']:checked").val(); |
|
113 |
let remote = $("input[name='remote']:checked").val(); |
|
114 |
let set = Code.jumpTypeBounceSet; |
|
115 |
let jumpTypeStr = ''; |
|
116 |
for (let s of set) { |
|
117 |
jumpTypeStr += 'CAT' + s; |
|
118 |
} |
|
119 |
|
|
120 |
var tempWindow = window.open('_blank'); |
|
121 |
tempWindow.location = Feng.ctxPath + "/execute?dataSourceId=" + dataSourceId + "&author=" |
|
122 |
+ author + "&proPackage=" + proPackage + "&removePrefix=" + removePrefix + "&tables=" + Code.tableNames + "&modularName=" + modularName |
|
123 |
+ "&version=" + version + "&swagger=" + swagger + "&remote=" + remote + '&jumpTypeStr=' + jumpTypeStr + '&genLocation=' + genLocation; |
|
124 |
}); |
|
125 |
|
|
126 |
//初始化单体选择 |
|
127 |
var activeSingleSelect = function () { |
|
128 |
$("#microDiv").hide(); |
|
129 |
}; |
|
130 |
|
|
131 |
//初始化微服务选择 |
|
132 |
var activeMicroSelect = function () { |
|
133 |
$("#microDiv").show(); |
|
134 |
}; |
|
135 |
|
|
136 |
//监听如果选择微服务版本,则显示是否开启swagger |
|
137 |
form.on('radio(versionChecked)', function (data) { |
|
138 |
if (data.value === "single") { |
|
139 |
activeSingleSelect(); |
|
140 |
} else { |
|
141 |
activeMicroSelect(); |
|
142 |
} |
|
143 |
}); |
|
144 |
|
|
145 |
//默认激活单体 |
|
146 |
activeSingleSelect(); |
|
147 |
|
|
148 |
}); |