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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
| /**
| * 代码生成器
| * @author weidy@2020-07-30
| */
| layui.define(['layer','element','form','table','util'],function(exports){
| var Class = function(){
| this.MODELNAME = "platform/objectService/OsCodeGenerator";
| this.moduleKey = "OsCodeGenerator";
| this.id='OsCodeGenerator';
| this.sourceData={};
| this.columns = [];
| this.backPath = configData.compatibility?path:configData.objectServicePath;
| this.url={
| controller:'codeGenSchemaController/',
| dataGrid:'gridSchema',
| referBtmType:'btmTypeController/referDataGrid',
| add:'addSchema',
| edit:'editSchema',
| preview:'previewCodeFile',
| downloadFile:'downloadCodeFile',
| productCodeFile:'productCodeFile',
| getObjectByOid:'getObjectByOid',
| getBtmTypeByOid:'btmTypeController/getBtmTypeByOid'
| };
| this.buttonIconMap = {
| SEARCH:'layui-icon-refresh-2',
| SENIORSEARCH:'layui-icon-query',
| ADD:'layui-icon-add-1',
| EDIT:'layui-icon-edit',
| DELETE:'layui-icon-delete'
| };
| this.panelTypeCombox = [{
| "key":"tree",
| "value":"树形"
| },{
| "key":"table",
| "value":"表格"
| },{
| "key":"table_tree",
| "value":"树表"
| },{
| "key":"form",
| "value":"表单"
| }];
| this.getContent=function(){
| var that = this;
| var html = "";
| html = [
| '<div class="layui-layout-border">',
| '<div class="layui-north" style="height:35px;overflow-x: hidden; background-color: white">',
| '<label style="margin-left:50px;width:200px;">扫描包的路径:</label><input type="text" style="width:500px;height:25px;" name="packName" id="',that.id,'_pack" value="" />',
| '</div>',
| '<div class="layui-center">',
| that.getToolbarHtml(),
| '<table id="table_', that.id , '" lay-filter="',that.id , '" style="overflow-x:auto;"></table>',
| '<div id="toolbar_column_',that.id ,'" style="display:none;"></div>',
| '</div>',
| '</div>'
| ].join("");
| return html;
| };
| this.getToolbarHtml =function(){
| var that = this;
| var html = [
| '<div layui-filter="toolbar_button_',that.id,'" class="layui-btn-container">',
| '<a class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_SCAN"><i class="layui-icon layui-icon-search"></i>扫描包</a>',
| '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_ADDBYBTMTYPE"><i class="layui-icon layui-icon-add-1"></i>添加</button>',
| '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_refresh"><i class="layui-icon layui-icon-refresh"></i>刷新</button>',
| '</div>',
| ].join("");
| return html;
| };
| this.init=function(){
| var that = this;
| $webUtil.copyConfig(that,that.moduleKey);
| var table = layui.table;
| that.checkColumns();
| that.firstGridLoad = false;
| table.render({
| elem: '#table_' + that.id,
| id: 'table_' + that.id,
| url: that.url.controller + that.url.dataGrid,
| backPath:that.backPath,
| page: {
| limit: 20,
| page: 1
| },
| selectMode:table.selectMode.muti,
| cols: [that.columns],
| done:function(res,cur,total){
| if(!that.fristMainLoad ){
| table.on('tool(' + that.id + ')',function(obj){
| var data = obj.data;//当前选择行的数据
| var layEvent = obj.event;//点的是什么按钮
| if(layEvent == 'CONFIG'){
| that.editSchema(data.oid,data.id,data.name);
| }else if(layEvent == 'PRODUCT'){
| that.productCodeFile(data.oid);
| }else if(layEvent == 'PREVIEW'){
| that.previewCodeFile(data.oid,data.name);
| }else{
| that.downloadCodeFile(data.oid);
| }
| });
| }
| that.fristMainLoad = true;
| },
| });
| $webUtil.createSearchHtml({
| id:'业务类型英文名称',
| name:'业务类型中文名称'
| },$("[layui-filter='toolbar_button_" + that.id + "']"),'table_' + that.id);
| $webUtil.bindDefultButtonLisenter(that, that.id);
| document.getElementById("toolbar_column_" + that.id).innerHTML =
| '<a class="layui-btn layui-btn-intable" lay-event="CONFIG">配置</a>' +
| '<a class="layui-btn layui-btn-intable" lay-event="PRODUCT">生成</a>' +
| '<a class="layui-btn layui-btn-intable" lay-event="PREVIEW">预览</a>' +
| '<a class="layui-btn layui-btn-intable" lay-event="DOWNLOAD">下载</a>' ;
| };
| this.checkColumns = function(){
| var that = this;
| var table = layui.table;
| if(that.columns==null || that.columns.length==0){
| that.columns = [table.getIndexColumn(),{
| field:'id',
| title:'业务类型英文',
| width:130
| },{
| field:'name',
| title:'业务类型中文',
| width:150
| },{
| field:'description',
| title:'描述',
| width:150
| },{
| field:'author',
| title:'作者',
| width:100
| },{
| field:'lastProductDate',
| title:'最后生成时间',
| width:135,
| templet:function(d){
| return $webUtil.formateDateTimeNoSecond(d.lastProductDate);
| }
| },{
| field:'options',
| title:'操作',
| width:200,
| toolbar: '#toolbar_column_' + that.id
| }];
| }
| };
| this.refresh = function(){
| var that = this;
| layui.table.reload("table_" + that.id);
| };
| this.SCAN = function () {
| var that = this;
|
| var packName = $("#" + that.id + "_pack").val();
| if($webUtil.isNull(packName)){
| $webUtil.showErrorMsg("请您先输入包名");
| return false;
| }
| $webUtil.post('scanAnnotationController/scanAnnotation',{packName:packName},function (result) {
| if(result.success){
| $webUtil.showMsgFromResult(result,"扫描注解成功,请等待一会检查一下业务类型的数据库表是否创建完成");
| }else{
| $webUtil.showErrorMsg(result.msg);
| }
| },function (err,xhr){
| $webUtil.showErrorMsg("链接服务出错");
| },that.backPath);
| };
| this.ADDBYBTMTYPE = function(){
| var that = this;
| var filter = "btmtype_" + that.id;
| var auditedHistory =$webUtil.dialog({
| title: '从业务类型中选择添加的方案',
| btn:['下一步(配置方案)','取消'],
| content: '<div layui-filter="toolbar_button_' + filter + '" class="layui-btn-container" style="margin-left:10px;margin-top:10px;"></div><table id="dialog_table' + filter + '" lay-filter="' + filter + '" class="layui-table"></table>',
| fullScreen:true,
| resize: false,
| success: function (layero) {
| var table = layui.table;
| that.checkBtmTypeColumns();//主列表中列。
| table.render({
| elem: '#dialog_table' + filter,
| id: 'dialog_table' + filter,
| backPath:that.backPath,
| url:that.url.referBtmType,
| selectMode:table.selectMode.single,
| cols: [that.btmTypeColumns],
| page:{
| limit:25,
| page:1
| }
| });
| $webUtil.createSearchHtml({
| id:'业务类型英文名称',
| name:'业务类型中文名称'
| },$("[layui-filter='toolbar_button_" + filter + "']"),'dialog_table' + filter);
| },
| yes:function(){
| var table = layui.table;
| var oid = $webUtil.getOidFromGrid('dialog_table' + filter,true,true);
| if(!oid){
| return false;
| }
| $webUtil.get(that.url.getBtmTypeByOid,{oid:oid},function(result){
| if(result.success){
| layer.close(auditedHistory);
| var btmType = result.obj;
| var defaultValueByBtm ={
| pkBtmType:btmType.oid,
| id:btmType.id,
| name:btmType.name
| };
| if($webUtil.isNotNull(btmType.implClass) && btmType.implClass.indexOf(".") > -1){
| //com.vci.xx.model.yyy的方式
| var package = btmType.implClass.substring(0,btmType.implClass.lastIndexOf("."));
| defaultValueByBtm['doPackage'] = package;
| if($webUtil.endWith(package,".model")){
| defaultValueByBtm['voPackage'] = package.replace(".model",".pagemodel");
| defaultValueByBtm['dtoPackage'] = package.replace(".model",".dto");
| defaultValueByBtm['controllerPackage'] = package.replace(".model",".controller");
| defaultValueByBtm['servicePackage'] = package.replace(".model",".service");
| defaultValueByBtm['mapperPackage'] = package.replace(".model",".mapper");
| var className = btmType.implClass.substring(btmType.implClass.lastIndexOf(".") + 1);
| if($webUtil.endWith(className,"DO")){
| className = className.substring(0,className.length-2);
| }
| defaultValueByBtm['controllerRequestMap'] = "/" + className.substring(0,1).toLowerCase() + className.substring(1) + "Controller";
| }
| }
| //看看有没有自参照的类型
| if(btmType.attributes){
| layui.each(btmType.attributes,function(_index,attribute){
| if(attribute.referBtmTypeId && attribute.referBtmTypeId.toUpperCase() == btmType.id.toUpperCase()){
| defaultValueByBtm.westLayoutPanelType = 'tree';
| defaultValueByBtm.westNextRegionParam = '{' + attribute.id + ':that.currentItemAttributes.oid}';
| return true;
| }
| })
| }
| //是不是平台通用的生命周期
| if(btmType.lifeCycleFlag && btmType.lifeCycleId && btmType.lifeCycleId == 'frameworkDataLc'){
| defaultValueByBtm.centerButtons = '{ADD:"添加",EDIT:"修改",DEL:"删除",ADVQUERY:"查询",refresh:"刷新",DISABLE:"停用",ENABLE:"启用"}';
| }
| if(("doPackage" in defaultValueByBtm)
| && defaultValueByBtm['doPackage'] == 'com.vci.frameworkcore.model'){
| if(defaultValueByBtm.centerButtons){
| defaultValueByBtm.centerButtons = defaultValueByBtm.centerButtons.replace("}",',EXPORT:"导出",IMPORT:"导入"}');
| }else{
| defaultValueByBtm.centerButtons = '{ADD:"添加",EDIT:"修改",DEL:"删除",ADVQUERY:"查询",refresh:"刷新",EXPORT:"导出",IMPORT:"导入"}';
| }
| }
| that.editSchema(null,result.obj.id,result.obj.name,defaultValueByBtm);
| }else{
| $webUtil.showErrorMsg(result.msg);
| }
| },function(xhr,error){
| $webUtil.showErrorMsg("获取业务类型的属性信息出错了,可能是服务没有启动");
| },that.backPath);
|
| },
| btn2:function(layero){
| that.refresh();
| layer.close(auditedHistory);
| }
| });
| };
| this.checkBtmTypeColumns = function(){
| var that = this;
| var table = layui.table;
| if(that.btmTypeColumns==null || that.btmTypeColumns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列
| that.btmTypeColumns = [table.getIndexColumn(),table.getCheckColumn(),{
| field:'id',
| title:'业务类型英文',
| width:130
| },{
| field:'name',
| title:'业务类型中文',
| width:150
| },{
| field:'description',
| title:'描述',
| width:150
| },{
| field:'tableName',
| title:'数据库表',
| width:140
| },{
| field:'revisionRuleId',
| title:'版本规则',
| width:130,
| templet:function(d){
| if(!d.revisionFlag){
| return '不控制版本';
| }else{
| return d.revisionRuleId + ' ' + d.revisionRuleName;
| }
| }
| },{
| field:'lifeCycleFlag',
| title:'生命周期',
| width:200,
| templet:function(d){
| if(!d.lifeCycleFlag){
| return '不控制生命周期';
| }else{
| return d.lifeCycleId + ' ' + d.lifeCycleName;
| }
| }
| },{
| field:'secretFlag',
| title:'控制密级',
| width:80,
| templet:function(d){
| return $webUtil.formateBoolean(d.secretFlag);
| }
| },{
| field:'viewFlag',
| title:'是否为视图',
| width:90,
| templet:function(d){
| return $webUtil.formateBoolean(d.viewFlag);
| }
| },{
| field:'versionRule',
| title:'版次规则',
| width:110
| }];
| }
| };
| this.editSchema = function(schemaOid,btmTypeId,btmTypeName,defaultValueByBtm){
| var that = this;
| var isEdit = true;
| if(defaultValueByBtm && $webUtil.isNotNull(defaultValueByBtm.pkBtmType)){
| //说明是新增
| isEdit = false;
| }
| var form = layui.form;
| var filter = that.id + "_addOrSchema" ;
| var addOrEditIndex = $webUtil.dialog({
| targetObject:that,
| title: isEdit?'配置生成方案':'新增代码生成方案',
| btn: ['保存', '取消'],
| content: '<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
| resizing: function (layero) {
| form.doResize(filter);
| },
| fullScreen:true,
| success: function (layero) {
| form.addItems(filter,that.getFormItems(),
| function () {
| if(!isEdit) {
| form.setValues(defaultValueByBtm,filter);
| }else {
| form.load(filter,{
| url: that.url.controller + that.url.getObjectByOid,
| backPath:that.backPath,
| method:'get',
| params:{
| oid:schemaOid
| }
| });
| }
| }
| , {}
| , {
| defaultColumnOneRow: 2,
| labelWidth:180
| });
| },
| yes:function(layero){
| if(form.validata(filter)){
| var submitValues = form.getValues(filter,true);
| if(submitValues['backPath'] == "configData."){
| $webUtil.showErrorMsg("界面后台路径没有输入值");
| return false;
| }
| var useLayoutRegion = [];
| for(var key in submitValues){
| if($webUtil.startWith(key,'useLayoutRegion')){
| useLayoutRegion.push(key.replace("useLayoutRegion","").replace("[","").replace("]",""));
| delete submitValues[key];
| }
| }
| submitValues['useLayoutRegion'] = useLayoutRegion.join((","));
| submitValues['genDOFlag'] = 'true';
| submitValues['genVOFlag'] = 'true';
| submitValues['genDTOFlag'] = 'true';
| $webUtil.ajax(isEdit?'PUT':'POST',that.url.controller + (isEdit?that.url.edit:that.url.add),submitValues,function (result) {
| if(result.success){
| $webUtil.showMsgFromResult(result,(isEdit?"配置方案成功":"添加方案成功"));
| that.refresh();
| layer.close(addOrEditIndex);
| }else{
| $webUtil.showErrorMsg(result.msg);
| }
| },function (xhr,error) {
| $webUtil.showErrorMsg("保存代码生成方案出错,可能是服务没有启动");
| },that.backPath);
| }
| }
| });
| };
| this.getFormItems = function(){
| var that = this;
| return [{
| field: 'id',
| text: '业务类型编号',
| required:true,
| readOnly:true
| },{
| field: 'name',
| text: '业务类型名称',
| required:true
| },{
| field: 'description',
| text: '方案描述'
| },{
| field:'author',
| text:'作者',
| required:true
| },{
| field:'fileEncode',
| text:'文件字符集',
| defaultValue:'UTF-8'
| },{
| field:'domemo',
| type:'label',
| isNewRow:true,
| text:'数据库实体文件包名,一般业务类型生成时已经包含了;显示对象是指后台返回给前端的对象;数据传输对象是后台用来接收前端传递的数据的对象;必须有中心区',
| labelWidth:1000
| },{
| field:'doPackage',
| text:'数据库实体包',
| isNewRow:true,
| inputWidth:860
| },{
| field:'voPackage',
| text:'显示对象路径',
| required:true,
| isNewRow:true,
| inputWidth:860
| },{
| field:'dtoPackage',
| text:'数据传输对象路径',
| required:true,
| isNewRow:true,
| inputWidth:860
| },{
| field:'controllerPackage',
| text:'controller的包名',
| required:true,
| isNewRow:true,
| inputWidth:860
| },{
| field:'controllerRequestMap',
| text:'controller的请求地址',
| required:true,
| useAllWidth:true,
| inputWidth:860
| },{
| field:'servicePackage',
| text:'服务包名',
| required:true,
| useAllWidth:true,
| inputWidth:860
| },{
| field:'mapperPackage',
| text:'数据库操作包名',
| required:true,
| useAllWidth:true,
| inputWidth:860
| },{
| field:'mapperXmlPackage',
| text:'mybatis的xml位置',
| required:true,
| defaultValue:'mybatis'
| },{
| field:'jsPackage',
| text:'界面的路径(到js名)',
| required:true,
| inputWidth:450
| },{
| field:'centerLayoutPanelType',
| type:'combox',
| comboxKey:'codeGenPanelType1',
| text:'中心使用的面板',
| required:true,
| defaultValue:'table',
| data:[{key:'table_tree',value:'树表'},{key:'table',value:'表格'},{key:'form',value:'表单'}]
| },{
| field:'backPath',
| text:'界面上的backPath',
| defaultValue:'configData.',
| inputWidth:450
| },{
| field:'centerQueryConfig',
| text:'中心查询条件',
| useAllWidth:true ,
| defaultValue:'{id:"编号",name:"名称"}',
| inputWidth:860
| },{
| field:'centerButtons',
| text:'中心按钮',
| useAllWidth:true ,
| defaultValue:'{ADD:"添加",EDIT:"修改",DEL:"删除",ADVQUERY:"查询",refresh:"刷新"}',
| inputWidth:860
| },{
| field:'westLayoutPanelType',
| type:'combox',
| comboxKey:'codeGenPanelType',
| text:'西区使用的面板',
| isNewRow:true,
| defaultValue:'tree',
| data:[{key:"tree",value:'树形'}]
| },{
| field:'useLayoutRegion',
| type:'combox',
| comboxKey:'useLayoutRegion',
| text:'是否使用西区',
| data:[{key:"west",value:'西区'}],
| isCheckbox:true,
| required:true,
| inputWidth:450
| },{
| field:'westQueryConfig',
| text:'西区查询条件',
| useAllWidth:true ,
| inputWidth:860
| },{
| field:'westNextRegionParam',
| text:'西区传递到下一区域参数',
| useAllWidth:true ,
| inputWidth:860
| },{
| field:'westButtons',
| text:'西区按钮',
| useAllWidth:true,
| inputWidth:860
| }];
| };
| this.productCodeFile = function(oid){
| var that = this;
| if(!oid){
| return false;
| }
| $webUtil.post(that.url.controller + that.url.productCodeFile,{oid:oid},function(result){
| if(result.success){
| $webUtil.showMsgFromResult(result,"生成代码成功");
| that.refresh();
| }else{
| $webUtil.showErrorMsg(result.msg);
| }
| },function(xhr,error){
| $webUtil.showErrorMsg("生成代码失败,可能是服务器没有启动");
| },that.backPath);
| };
| this.previewCodeFile = function(oid,text){
| var that = this;
| if(!oid){
| return false;
| }
| portal.showTabByMenu(that.id + oid,{
| id:that.id + oid,
| text:'查看代码[' + text + "]",
| url:'USEJS:platform/objectService/OsCodePreview?oid=' + oid
| });
| };
| this.downloadCodeFile = function(oid){
| var that = this;
| var iframeId = MD5(oid + $webUtil.getSystemVar($webUtil.systemValueKey.userOid));
| $webUtil.fileDownload(that.backPath + that.url.controller + that.url.downloadFile + "?" + TOKEN_KEY + "=" + $webUtil.getToken() + "&downloadUUID=" + iframeId + "&oid=" + oid);
| };
| };
| var cs = new Class();
| exports(cs.MODELNAME,cs);
| });
|
|