多单位版国产化地质资料管理系统
zhai
2025-12-18 3c6f6c1e3016e38146a4c46be6e7b625c35591f2
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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
 
<!DOCTYPE>
<html>
<head>
    <base href="<%=basePath%>">
    <meta name="viewport" charset="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>业务表信息</title>
 
    <link rel="stylesheet" href="static/plugins/jquery-steps/css/main.css" type="text/css">
    <link rel="stylesheet" href="static/plugins/jquery-steps/css/jquery.steps.css" type="text/css">
    <link href="static/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css">
    <link href="static/plugins/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="static/styles/initialize.css" type="text/css">
    <link rel="stylesheet" href="static/styles/common.css" type="text/css">
 
    <script type="text/javascript" src="static/plugins/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="static/plugins/jquery-easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="static/plugins/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="static/scripts/easyuiExtend.js"></script>
    <script type="text/javascript" src="static/scripts/jquery-extend.js"></script>
    <script type="text/javascript" src="static/plugins/layer/layer.js"></script>
    <script type="text/javascript" src="static/plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <script type="text/javascript" src="static/plugins/jquery-easyui-edatagrid/jquery.edatagrid.js"></script>
    <!-- 弹窗加载组件 -->
    <script type="text/javascript" src="static/plugins/layer/layer.js"></script>
    <script type="text/javascript" src="static/plugins/spinjs/spin.js"></script>
    <script type="text/javascript" src="static/plugins/spinjs/jquery.spin.js"></script>
    <script type="text/javascript" src="static/plugins/jquery.blockUI.js"></script>
    <script type="text/javascript" src="static/plugins/ace/src-noconflict/ace.js"></script>
    <!-- wcp组件 -->
    <script type="text/javascript" src="static/wcp/scripts/wcp.js"></script>
    <script type="text/javascript" src="static/wcp/scripts/libs/wcp.layer.js"></script>
    <script type="text/javascript" src="static/wcp/scripts/libs/wcp.blockUI.js"></script>
    <script type="text/javascript" src="static/wcp/scripts/libs/wcp.spin.js"></script>
    <script type="text/javascript" src="static/wcp/scripts/libs/wcp.jquery.js"></script>
 
    <!--[if lt IE 9]>
    <script type="text/javascript" src="static/plugins/json2.js"></script>
    <![endif]-->
    <script type="text/javascript" src="static/wcp/scripts/libs/wcp.infoPicker.js"></script>
 
 
    <style>
        .combobox-group {
            clear: both;
        }
 
        .content {
            height: 530px !important;
        }
    </style>
 
</head>
<body>
<div class="wizard clearfix" role="application" id="steps-uid-0">
    <div class="steps clearfix">
        <ul role="tablist">
            <li id="steps-uid-0-t-0" role="tab" class="first current">
                <a>
                    <span class="number">1.</span>
                    业务表信息
                </a>
            </li>
            <li id="steps-uid-0-t-1" role="tab" class="disabled last">
                <a>
                    <span class="number">2.</span>
                    业务表字段设计
                </a>
            </li>
        </ul>
    </div>
    <div class="content clearfix">
 
        <h3 id="steps-uid-0-h-0" tabindex="-1" class="title current">业务表信息</h3>
        <fieldset id="steps-uid-0-p-0" role="tabpanel" class="body current" style="padding:10px 20px;">
            <form id="tablefrom" action="">
 
                <div class="currentmargin" style="width:300px;">
                    <input type="hidden" id="tableId" name="tableId" value="${table.tableId }"/>
                    <input type="hidden" id="enableSetMainTable" name="enableSetMainTable"
                           value="${table.enableSetMainTable }"/>
                    <input id="txt_tableName" name="tableName" value="${table.tableName }" label="业务表名称:"
                           class="easyui-textbox easyui-validatebox" labelPosition="top" labelWidth="100px"
                           style="width:250px;height:60px" data-options="required:true,validType:['regTable']">
                </div>
 
                <div class="currentmargin" style="width:300px;">
                    <input class="easyui-textbox" name="displayName" value="${table.displayName }" label="显示名称:"
                           labelPosition="top" style="width:250px;height:60px"
                           data-options="required:true,validType:'displayName'">
                </div>
                <div class="currentmargin" style="width:300px;">
                    <input type="hidden" name="moduleId" value="${table.moduleId }" id="txt_ModuleId"
                           class="easyui-textbox">
                    <input id="txt_ModuleName" name="moduleName" value="${table.moduleName }" class="easyui-textbox"
                           label="所属模块:" labelPosition="top" style="width:250px;height:60px"
                           data-options="required:true,editable:false,buttonText:'选择模块',prompt:'',onClickButton:function(){selectModule();}"/>
                </div>
                <div class="currentmargin" style="width:300px;">
                    <input type="hidden" id="notCreated" name="notCreated" value="${table.notCreated}"/>
                    <input id="notCreatedText" class="easyui-switchbutton" label="不创建实体表:" labelPosition="top"
                           labelWidth="250px"
                           data-options="readonly:${table.tableId>0 },onText:'是',offText:'否',onChange:setEnableValue"/>
                </div>
                <div class="currentmargin">
 
                    <input id="keyword" name="keyword" value="${table.keyword }" class="easyui-textbox"
                           label="日志记录关键字:" labelPosition="top" style="width:60%;height:60px"
                           data-options="required:false,editable:true,buttonText:'选择字段',prompt:'',onClickButton:function(){selectColumn();}"/>
                </div>
                <div class="currentmargin">
                    <input class="easyui-textbox" name="tableDescription" value="${table.tableDescription }"
                           label="业务表说明:" labelPosition="top" multiline="true" style="width:60%;height:100px">
                </div>
            </form>
        </fieldset>
        <h3 id="steps-uid-0-h-1" tabindex="-1" class="title">业务表字段设计</h3>
        <fieldset id="steps-uid-0-p-1" role="tabpanel" class="body" style="width:100%; display: none;">
 
            <table id="tb_TableFields" singleselect="true" idfield="columnId" style="width: auto; height: 100%"
                   toolbar="#toolbar">
                <thead>
                <tr>
                    <th field="columnName" width="150" align="left"
                        editor="{type:'validatebox',options:{required:true,validType:'regTable'}}">字段名
                    </th>
                    <th field="displayName" width="120" align="left"
                        editor="{type:'validatebox',options:{required:true}}">显示名称
                    </th>
                    <th field="dataType" width="120" align="center" formatter="dataTypeFormatter"
                        editor="{type:'combobox',options:{valueField:'csmc',textField:'csmc',data:dataTypeList,required:true,validType:'dataType',multiple:false,onChange:function(newValue,oldValue){ setDataSize(this,newValue,oldValue);}}}">
                        数据类型
                    </th>
                    <th field="dataSize" width="80" align="center"
                        editor="{type:'validatebox',options:{validType:'decimalPoint'}}">数据长度
                    </th>
                    <th field="decimalPoint" width="50" align="center"
                        editor="{type:'validatebox',options:{validType:'decimalPoint'}}">小数点
                    </th>
                    <th field="isPrimary" width="60" align="center" editor="{type:'checkbox',options:{on:'是',off:'否'}}">
                        主键
                    </th>
                    <th field="isNotNull" width="60" align="center" editor="{type:'checkbox',options:{on:'是',off:'否'}}">
                        为空
                    </th>
                    <th field="isIdentity" width="100" align="center" editor="{type:'combobox',options:{valueField:'csmc',textField:'csmc',
                            data:uniqueList,multiple:false,editable:false,panelHeight:'auto'}}">自增长
                    </th>
                    <th field="isUnique" width="60" align="center" editor="{type:'checkbox',options:{on:'是',off:'否'}}">
                        唯一
                    </th>
                    <th field="isNotForQuery" width="100" align="center" editor="{type:'checkbox',options:{on:'是',off:'否'}}">
                        禁用于查询
                    </th>
                    <th field="forbidBatchUpdate" width="100" align="center" editor="{type:'checkbox',options:{on:'是',off:'否'}}">
                        禁用于批量修改
                    </th>
 
                    <th field="customTag" width="100" align="center" editor="text">
                        自定义标记
                    </th>
                    <th field="defaultValue" width="100" align="center" editor="text">默认值</th>
                    <th field="columnDescription" width="220" align="left" editor="text">字段说明</th>
                </tr>
                </thead>
            </table>
            <div id="toolbar" style="height: auto">
                <div style="margin-left:2px;">
                    <!-- <a onclick="$('#tb_TableFields').edatagrid('addRow');" class="pt-btn pt-btn-success">
                        <i class="fa fa-plus"></i>添加字段
                    </a> -->
                    <a onclick="addRow();" class="pt-btn pt-btn-success">
                        <i class="fa fa-plus"></i>
                        添加字段
                    </a>
                    <a onclick="selectSystemColumn();" class="pt-btn pt-btn-purple">
                        <i class="fa fa-plus"></i>
                        添加系统字段
                    </a>
                    <a onclick="$('#tb_TableFields').edatagrid('saveRow');" class="pt-btn pt-btn-info">
                        <i class="fa fa-save"></i>
                        确认修改
                    </a>
                    <a onclick="$('#tb_TableFields').edatagrid('cancelRow');" class="pt-btn pt-btn-warning">
                        <i class="fa fa-scissors"></i>
                        取消修改
                    </a>
                    <a onclick="$('#tb_TableFields').edatagrid('destroyRow');" class="pt-btn pt-btn-danger">
                        <i class="fa fa-trash-o"></i>
                        删除字段
                    </a>
                </div>
            </div>
        </fieldset>
 
    </div>
 
    <div class="pt-form-btn" style="bottom: 0">
        <div class="form-group">
            <button id="prev" class="pt-btn" role="menuitem">上一步</button>
            <button id="next" class="pt-btn pt-btn-primary" role="menuitem">下一步</button>
            <shiro:hasPermission name="SYS_CONFIG.MODULE.OPERATION.CONFIG.TABLE.SAVE">
                <button id="btnSave" class="pt-btn pt-btn-primary">保存</button>
            </shiro:hasPermission>
            <button id="btnClose" class="pt-btn pt-btn-default">关闭</button>
            <input type="hidden" id="deleteFields">
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="static/scripts/ResizeScroll.js"></script>
<script>
    //字段名是否需要大写
    var isNeedUpper = ${isNeedUpper};
 
    //窗口参数,用于弹窗传递
    var params = {
        callBack: null
    };
 
    var next = null;
    var deleteFields = [];
 
    var uniqueList = [
        {
            "csid": "0",
            "csmc": "否",
            "selected": "true"
        },
        {
            "csid": "1",
            "csmc": "默认(自增长)"
        },
        {
            "csid": "2",
            "csmc": "分布式唯一ID"
        }
    ];
    var dataTypeList = [
        {
            csid: 1,
            csmc: 'int'
        },
        {
            csid: 2,
            csmc: 'varchar'
        },
        {
            csid: 3,
            csmc: 'nvarchar'
        },
        {
            csid: 4,
            csmc: 'datetime'
        },
        {
            csid: 5,
            csmc: 'binary'
        },
        {
            csid: 6,
            csmc: 'float'
        },
        {
            csid: 7,
            csmc: 'decimal'
        },
        {
            csid: 8,
            csmc: 'bit'
        },
        {
            csid: 9,
            csmc: 'text'
        },
        {
            csid: 10,
            csmc: 'tinyint'
        },
        {
            csid: 11,
            csmc: 'bigint'
        },
    ];
    var usedTableName = "${table.tableName}";
    $(function () {
 
        //表名称定义初始值
        var tableId = $("#tableId").val();
        if (tableId == null || tableId == "") {
            var defaultPre = "bus_";
            if (isNeedUpper) {
                defaultPre = defaultPre.toUpperCase();
            }
            $("#txt_tableName").textbox("setValue", defaultPre);
        }
        var moduleName = "${moduleName}";
        var moduleId = "${moduleId}";
        if (moduleId != null && moduleId != "") {
            $("#txt_ModuleId").textbox("setValue", moduleId);
        }
        if (moduleName != null && moduleName != "") {
            $("#txt_ModuleName").textbox("setValue", moduleName);
        }
 
        $("#next").click(function () {
            var valid = $("#txt_tableName").validatebox("isValid");
            if (valid) {
                //上一步下一步按钮
                $("#prev").addClass("pt-btn-primary");
                $(this).removeClass("pt-btn-primary");
                $(this).addClass("disabled");
                //内容
                $("#steps-uid-0-p-1").show();
                $("#steps-uid-0-p-0").hide();
                //导航条
                $("#steps-uid-0-t-1").addClass("current").removeClass("disabled");
                $("#steps-uid-0-t-0").addClass("disabled").removeClass("current");
                $("#steps-uid-0-t-0").removeClass("error");
            } else {
                $("#steps-uid-0-t-0").addClass("error");
            }
 
            //上一步,下一步不刷新表单内容
            if (next != 1) {
                $('#tb_TableFields').edatagrid({
                    rownumbers: true,
                    pagination: false,
                    fitColumns: true,
                    method: "get",
                    url: "config/table/selectColumnList?tableId=" + "${table.tableId }",
                    saveUrl: "",
                    updateUrl: "",
                    destroyUrl: "",
                    onBeginEdit: function (index, row) {
                        var editors = $('#tb_TableFields').datagrid('getEditors', index);
                        //获取行编辑器第一个对象
                        editors[5].target[0].onclick = function () {
                            changePrimary(this, editors);
                        }
 
                        changePrimary(editors[5].target[0], editors);
                    },
                    onBeforeSave: function (rowIndex) {
                        var Editrow = $('#tb_TableFields').datagrid('getEditor', {
                            index: rowIndex,
                            field: 'columnName'
                        });
                        var newColumnName = Editrow.target[0].value;
                        var oldColumnName = Editrow.oldHtml;
                        var rows = $('#tb_TableFields').datagrid("getRows");
                        for (var i = 0; i < rows.length; i++) {
                            if (rows[i].ColumnName != oldColumnName && rows[i].ColumnName == newColumnName) {
                                layer.alert("字段名必须唯一,请勿重复");
                                // alert("字段名必须唯一,请勿重复");
                                return false;
                            }
                        }
                    },
                    onDestroy: function (index, row) {
                        if (row.columnId > 0) {
                            deleteFields.push(row.columnId);
                        }
                    }
                });
            }
 
        });
 
        $("#prev").click(function () {
            var valid = true;
            next = 1;
            if (valid) {
                //上一步下一步按钮
                $("#next").addClass("pt-btn-primary");
                $(this).removeClass("pt-btn-primary");
                //内容
                $("#steps-uid-0-p-1").hide();
                $("#steps-uid-0-p-0").show();
                //导航条
                $("#steps-uid-0-t-1").addClass("disabled").removeClass("current");
                $("#steps-uid-0-t-0").addClass("current").removeClass("disabled");
            }
        });
 
        $("#finish").click(function () {
            var valid = $("#txt_tableName").validatebox("isValid");
        });
 
        initEnableCheck();
 
        //绑定按钮事件
        $("#btnSave").click(saveTable);
 
 
        $("#btnClose").click(function () {
            closeWindow();
        });
 
    });
 
    //初始化选择项
    function initEnableCheck() {
        if ("${table.notCreated}" == "true") {
            $('#notCreatedText').switchbutton("check");
        } else {
            $('#notCreatedText').switchbutton("uncheck");
        }
    }
 
    function addRow() {
        var rows = $("#tb_TableFields").datagrid("getRows");
        var index = rows.length;
        $('#tb_TableFields').edatagrid('addRow', {
            index: index,
            row: {
                "columnName": "",
                "displayName": "",
                "columnType": 0,
                "dataType": "",
                "dataSize": "",
                "decimalPoint": "",
                "isPrimary": "",
                "isNotNull": "是",
                "isIdentity": "否",
                "isUnique": "",
                "customTag": "",
                "defaultValue": "",
                "columnDescription": ""
            }
        });
    }
 
    function saveTable() {
        //验证表单信息
        var isValid = $('#tablefrom').form('validate');
        if (!isValid) {
            wcp.notify.warn('表单验证有误,请检查表单输入项!');
            return false;
        }
 
        var obj = $("#tablefrom").serializeObject();
        var tableColumn = $('#tb_TableFields').datagrid("getRows");
        //判断是否有字段
        if (tableColumn.length == 0) {
            layer.alert("请添加字段再提交!");
            return false;
        }
        var map = {};
        var systemMap = {};
        var isPrimary = 0;
        //判断是否点击保存
        for (i = 0; i < tableColumn.length; i++) {
            if (tableColumn[i].hasOwnProperty('isNewRecord')) {
                var isNewRecord = tableColumn[i].isNewRecord;
                if (isNewRecord) {
                    layer.alert("请先确认字段!");
                    return false;
                }
                //删除isNewRecord属性
                delete tableColumn[i].isNewRecord;
            }
            var columnName = tableColumn[i].columnName.toLowerCase();
            if (tableColumn[i].isPrimary == "是") {
                isPrimary = 1;
            }
 
            if (typeof map[columnName] != "undefined") {
                layer.alert("字段名必须唯一,请勿重复!");
                return false;
            }
            map[columnName] = columnName;
            if (columnName == "create_user_id"
                || columnName == "create_user_name"
                || columnName == "create_time"
                || columnName == "modify_time"
                || columnName == "create_dept_id"
                || columnName == "create_dept_name") {
                systemMap[columnName] = columnName;
            }
 
        }
 
        var userId = systemMap["create_user_id"];
        var userName = systemMap["create_user_name"];
        var createTime = systemMap["create_time"];
        var modifyTime = systemMap["modify_time"];
        var deptId = systemMap["create_dept_id"];
        var deptName = systemMap["create_dept_name"];
 
        var notCreated = "";
        try {
            notCreated = $("#notCreated").textbox("getValue");
        } catch (e) {
            notCreated = $("#notCreated").val();
        }
 
 
        if (notCreated == "false") {
            if (typeof userId == "undefined" || typeof userName == "undefined" || typeof createTime == "undefined" || typeof modifyTime == "undefined"
                || typeof deptId == "undefined" || typeof deptName == "undefined") {
                layer.alert("请添加必填系统字段!");
                return false;
            }
        }
 
        if (isPrimary == 0) {
            layer.alert("请设置一个主键!");
            return false;
        }
 
        //var deleteFields = $("#deleteFields").val();
        wcp.ui.setBusy("body", wcp.ajax({
            url: "config/table/saveTab?usedTableName=" + usedTableName,
            data: JSON.stringify({
                table: obj,
                columnList: tableColumn,
                deleteFields: deleteFields
            }),
        }).done(function (result) {
            //判断是否需要执行回调函数
            if (params.callBack) {
                params.callBack();
            }
            closeWindow();
            top.wcp.notify.success("保存成功!");
        }));
    }
 
    function closeWindow() {
        var index = top.layer.getFrameIndex(window.name); //获取窗口索引
        top.layer.close(index);
    }
 
    function setDataSize(obj, newValue, oldValue) {
        switch (newValue) {
            case "binary":
                $(obj).closest('[field="dataType"]').next('[field="dataSize"]').find("input[type=text]").val("8");
                $(obj).closest('[field="dataType"]').nextAll('[field="decimalPoint"]').find("input[type=text]").val("0");
                break;
            case "bit":
                $(obj).closest('[field="dataType"]').next('[field="dataSize"]').find("input[type=text]").val("1");
                $(obj).closest('[field="dataType"]').nextAll('[field="decimalPoint"]').find("input[type=text]").val("0");
                break;
            case "decimal":
                $(obj).closest('[field="dataType"]').next('[field="dataSize"]').find("input[type=text]").val("18");
                $(obj).closest('[field="dataType"]').nextAll('[field="decimalPoint"]').find("input[type=text]").val("2");
                break;
            case "int":
                $(obj).closest('[field="dataType"]').next('[field="dataSize"]').find("input[type=text]").val("4");
                $(obj).closest('[field="dataType"]').nextAll('[field="decimalPoint"]').find("input[type=text]").val("0");
                break;
            case "float":
                $(obj).closest('[field="dataType"]').next('[field="dataSize"]').find("input[type=text]").val("4");
                $(obj).closest('[field="dataType"]').nextAll('[field="decimalPoint"]').find("input[type=text]").val("0");
                break;
            case "datetime":
                $(obj).closest('[field="dataType"]').next('[field="dataSize"]').find("input[type=text]").val("0");
                $(obj).closest('[field="dataType"]').nextAll('[field="decimalPoint"]').find("input[type=text]").val("0");
                break;
            case "tinyint":
                $(obj).closest('[field="dataType"]').next('[field="dataSize"]').find("input[type=text]").val("1");
                $(obj).closest('[field="dataType"]').nextAll('[field="decimalPoint"]').find("input[type=text]").val("0");
                break;
            case "bigint":
                $(obj).closest('[field="dataType"]').next('[field="dataSize"]').find("input[type=text]").val("20");
                $(obj).closest('[field="dataType"]').nextAll('[field="decimalPoint"]').find("input[type=text]").val("0");
                break;
            case "varchar":
                $(obj).closest('[field="dataType"]').next('[field="dataSize"]').find("input[type=text]").val("50");
                $(obj).closest('[field="dataType"]').nextAll('[field="decimalPoint"]').find("input[type=text]").val("0");
                break;
            case "nvarchar":
                $(obj).closest('[field="dataType"]').next('[field="dataSize"]').find("input[type=text]").val("100");
                $(obj).closest('[field="dataType"]').nextAll('[field="decimalPoint"]').find("input[type=text]").val("0");
                break;
            case "text":
                $(obj).closest('[field="dataType"]').next('[field="dataSize"]').find("input[type=text]").val("0");
                $(obj).closest('[field="dataType"]').nextAll('[field="decimalPoint"]').find("input[type=text]").val("0");
                break;
            case "ntext":
                $(obj).closest('[field="dataType"]').next('[field="DataSize"]').find("input[type=text]").val("16");
                $(obj).closest('[field="dataType"]').nextAll('[field="decimalPoint"]').find("input[type=text]").val("0");
                break;
        }
 
        if (oldValue == "decimal") {
            $(obj).closest('[field="dataType"]').nextAll('[field="decimalPoint"]').find("input[type=text]").val("0");
        }
    }
 
    function dataTypeFormatter(value) {
        for (var i = 0; i < dataTypeList.length; i++) {
            if (dataTypeList[i].csid == value)
                return dataTypeList[i].csmc;
        }
        return value;
    }
 
    function changePrimary(obj, editors) {
        if (obj.checked) {
            $(editors[6].target[0]).prop("checked", false);
            $(editors[6].target[0]).prop("disabled", true);
            $(editors[8].target[0]).prop("checked", false);
            $(editors[8].target[0]).prop("disabled", true);
            $(editors[7].target[0]).combobox("setValue", "分布式唯一ID");
            $(editors[7].target[0]).combobox("setText", "分布式唯一ID");
        } else {
            $(editors[6].target[0]).prop("checked", true);
            $(editors[6].target[0]).prop("disabled", false);
            $(editors[8].target[0]).prop("disabled", false);
            $(editors[7].target[0]).combobox("setValue", "否");
            $(editors[7].target[0]).combobox("setText", "否");
 
        }
    }
 
    //选择模块
    function selectModule() {
        wcp.picker.selectModule({
            title: "请选择模块",
            multiSelect: false,
            idElement: "txt_ModuleId",
            nameElement: "txt_ModuleName",
            layerOpener: window
        });
    }
 
    function editTable() {
        var url = "config/table/selectColumn";
        top.layer.open({
            title: "选择字段",
            type: 2,
            area: ["550px", "400px"],
            fixed: false,
            maxmin: true,
            content: url,
            success: function (layero, index) {
                var body = window.top.layer.getChildFrame('body', index);
                var iframeWin = window.top[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象
 
                //将回调函数传给子页面
                iframeWin.params.callBack = refreshData;
            }
        });
 
        //window.event ? window.event.returnValue == false : e.preventDefault();
    }
 
    function selectSystemColumn() {
        var url = "config/table/selectSystemColumns";
        var title = "系统字段";
        top.layer.open({
            title: title,
            type: 2,
            area: ["800px", "500px"],
            fixed: false,
            content: url,
            success: function (layero, index) {
                var body = window.top.layer.getChildFrame('body', index);
                var iframeWin = window.top[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象
                //将回调函数传给子页面
                iframeWin.params.callBack = addSystemColumn;
            }
        });
    }
 
    function addSystemColumn(columnData) {
        var rows = $("#tb_TableFields").datagrid("getRows");
        var rowsIndex = rows.length;
        var map = {};
        $.each(rows, function (index, value) {
            map[value.columnName] = value.columnName;
        });
        $.each(columnData, function (index, value) {
            var column = map[value.columnName];
            if (typeof column != "undefined") {
                layer.alert(column + ":系统字段已存在!");
                return false;
            }
 
            var columnName = value.columnName;
            if (isNeedUpper) {
                columnName = columnName.toUpperCase();
            }
 
            $('#tb_TableFields').edatagrid('addRow', {
                index: rowsIndex,
                row: {
                    columnName: columnName,
                    displayName: value.displayName,
                    columnType: 1,
                    dataType: value.dataType,
                    dataSize: value.dataSize,
                    decimalPoint: value.decimalPoint,
                    isPrimary: value.isPrimary,
                    isNotNull: value.isNotNull,
                    isIdentity: value.isIdentity,
                    isUnique: value.isUnique,
                    isNotForQuery: value.isNotForQuery,
                    forbidBatchUpdate: value.forbidBatchUpdate,
                    customTag: value.customTag,
                    defaultValue: value.defaultValue,
                    columnDescription: value.columnDescription
                }
            });
            rowsIndex++;
        });
        $('#tb_TableFields').edatagrid('saveRow');
 
    }
 
    //刷新表格数据
    function refreshData() {
        $('#dg_table').datagrid('reload');
        //清除已经选择的数据
        $('#dg_table').datagrid('clearSelections');
        $('#dg_table').datagrid('clearChecked');
    }
 
    //设置隐藏域值
    function setEnableValue(checked) {
        $('#' + this.id.replace("Text", "")).val(checked);
    }
 
    //选择字段
    function selectColumn() {
 
        var _tableId = "${table.tableId}";
        if (_tableId == undefined || _tableId == '' || _tableId == 0) {
            layer.alert("请先保存业务表!");
            return;
        }
        wcp.picker.selectTableColumn({
            title: "请选择字段",
            tableId: _tableId,
            multiSelect: true,
            layerOpener: window
        }, function (rows) {
            var _separator = "-";
            var selectedColumns = "";
            $.each(rows, function (index, value) {
                selectedColumns += '\${' + value.columnName + '}' + _separator;
            });
 
            selectedColumns = selectedColumns.substr(0, selectedColumns.length - 1);
 
 
            $('#keyword').textbox("setValue", selectedColumns);
 
        });
    }
 
</script>
 
</html>