linzhijie
2021-04-12 c632636e2f5b4188b430f5efc9d9f68c8dbe3d6d
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
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增人口学变量定义')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-demographyParam-add">
        <input type="hidden" id="langCodes" name="langCodes">
        <div class="form-group">
            <label class="col-sm-3 control-label">[[#{jsp.exam.demographyParam.businessuser}]]ID:</label>
            <div class="col-sm-8">
                <input name="userId" class="form-control" type="number" required th:value="${sysUser.userId}" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">[[#{jsp.exam.demographyParam.demographicname}]]:</label>
            <div class="col-sm-8">
                <input name="paramCode" id="paramCode" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">[[#{jsp.exam.demographyParam.variablestate}]]:</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('param_status_type')}">
                    <input type="radio" th:id="${dict.dictCode}" name="paramStatus"
                           th:value="${dict.dictValue}" th:checked="${dict.default}">
                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">[[#{jsp.exam.demographyParam.controltype}]]:</label>
            <div class="col-sm-8">
                <select name="types" class="form-control m-b"
                        th:with="type=${@dict.getType('param_types')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                            th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">[[#{jsp.exam.demographyParam.dictionarytype}]]:</label>
            <div class="col-sm-8">
                <div class='input-group'>
                    <input name="dicttype" id="dicttype" class="form-control" type="text">
                    <span class='input-group-addon input-sm' onclick='selectDictTree()'><i class='fa fa-search'></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">[[#{jsp.exam.demographyParam.isrequired}]]:</label>
            <div class="col-sm-8">
                <label class='check-box'><input th:type="checkbox" id="isRequired" name="isRequired" th:value="1"></label>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">[[#{jsp.exam.demographyParam.isSelect}]]:</label>
            <div class="col-sm-8">
                <label class='check-box'><input th:type="checkbox" id="flag" name="flag"></label>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">[[#{jsp.exam.demographyParam.sort}]]:</label>
            <div class="col-sm-8">
                <input name="sort" class="form-control" type="number">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">[[#{jsp.multilingual.version}]]:</label>
            <div class="col-sm-3">
                <select name="langType" id="langType" class="form-control m-b"
                        th:with="type=${@dict.getType('lang_type')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                            th:value="${dict.dictValue}"></option>
                </select>
            </div>
            <div class="col-sm-4">
                <input name="paramName" id="paramName" class="form-control" type="text">
            </div>
            <div class="col-sm-2">
                <a class="btn btn-success" onclick="insertRow()">
                    <i class="fa fa-plus"></i> [[#{jsp.add.language}]]
                </a>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" data-mobile-responsive="true"></table>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">
    var prefix = ctx + "exam/demographyParam"
    $("#form-demographyParam-add").validate({
        focusCleanup: true
    });
 
 
    $(function() {
        var options = {
            url: prefix + "/addListCodes",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pagination: false,
            uniqueId: "langType",
            height: 400,
            columns: [
            {
                field : 'langType',
                title : '[[#{jsp.exam.demographyParam.languagetype}]]'
            },
            {
                field : 'langCode',
                title : '[[#{jsp.demographic.name}]]'
            }
            ,
            {
                title: '[[#{basis.operate}]]',
                align: 'center',
                formatter: function(value, row, index) {
                    var actions = [];
                    actions.push('<a class="btn btn-danger" onclick="removeRowByUniqueId(\'' + row.langType + '\')"><i class="fa fa-remove"></i>[[#{basis.del}]]</a>');
                    return actions.join('');
                }
            }
            ]
        };
        $.table.init(options);
    });
 
    /*[[#{basis.add}]]表格行 */
    function insertRow(){
        var langCode = $("#paramName").val();
        var langType = $("#langType").val();
 
        if (langCode=='') {
            $.modal.alertWarning('[[#{basis.pleaseentermultilingualinformation}]]');
            return;
        }
 
        if (checkDuplicate(langType)) {
            $.modal.alertWarning('[[#{basis.cclntadd}]]');
            return;
        }
 
        $.btTable.bootstrapTable('insertRow', {
            index: 0, // 你想插入到哪,0表示第一行
            row: {
                langType: langType,
                langCode: langCode,
            }
        })
    }
 
    function checkDuplicate(langType) {
        var data = $.btTable.bootstrapTable('getData');
        var sdata = JSON.stringify(data);
        var jsonArr = JSON.parse(sdata);
        var check = false;
        $.each(jsonArr,function(index,value){
            if (langType==value.langType) {
                check = true;
            }
        });
        return check;
    }
 
    /* 删除行ID值为1的数据 */
    function removeRowByUniqueId(id){
        $.btTable.bootstrapTable('removeByUniqueId', id);
    }
 
    function submitHandler() {
        if ($.validate.form()) {
            var sdata = getData();
            var jsonArr = JSON.parse(sdata);
            if (jsonArr.length == 0) {
                $.modal.alertWarning('[[#{basis.pleaseentermultilingualinformation}]]');
                return;
            }
            $("#langCodes").val(sdata);
            $.operate.save(prefix + "/add", $('#form-demographyParam-add').serialize());
        }
    }
 
    /* 查询表格所有数据值 */
    function getData(){
        var data = $.btTable.bootstrapTable('getData');
        return JSON.stringify(data);
    }
 
    // 选择字典处理函数
    function selectDictTree() {
        var dictType = 'sys_user_sex';
        var url = ctx + "system/dict/selectDictTree/" + 10 + "/" + dictType + "/demography";
        var options = {
            title: '[[#{jsp.exam.demographyParam.dictionarytype}]]',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }
 
    function doSubmit(index, layero){
        var body = layer.getChildFrame('body', index);
        var dictType = body.find('#dictType').val();
        layer.close(index);
        $("#dicttype").val(dictType);
    }
</script>
</body>
</html>