linzhijie
2021-03-11 c33914ba0a98c823c4b4d7da21cdd476906c9924
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
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('请选择题目')"/>
    <style>
        .changeColor {
            background-color: #337dff !important;
            color: #fffefa !important;
        }
    </style>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <input type="hidden" name="questionTemplateId" th:value="${questionTemplateId}"/>
                    <ul>
                        <li>
                            <p>题干:</p>
                            <input type="text" name="infoTextContentId"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;[[#{basis.search}]]</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;[[#{basis.reset}]]</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
            <div class="col-sm-offset-5 col-sm-10">
                <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i
                        class="fa fa-check"></i>save
                </button>&nbsp;
                <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i
                        class="fa fa-reply-all"></i>close
                </button>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('exam:question:edit')}]];
    var removeFlag = [[${@permission.hasPermi('exam:question:remove')}]];
    var prefix = ctx + "exam/question";
    var $parent = $.operate.parentHtml();
    $(function () {
        var questionTemplateId = [[${questionTemplateId}]];
        var langType = [[${langType}]];
        var options = {
            url: prefix + "/listForProductAddQuestion",
            queryParams: function () {
                var temp = {
                    questionTemplateId: questionTemplateId,
                    langType: langType
                };
 
                return temp;
            },
            modalName: [[#{menu.exam.question.view}]],
            columns: [{
                checkbox: true,
                //formatter:stateFormatter
            },
                {
                    field: 'id',
                    title: [[#{jsp.exam.product.titleCode}]]
                },
                {
                    field: 'title',
                    title: [[#{jsp.exam.product.questionStem}]]
                },
                {
                    field: 'levelName',
                    title: [[#{menu.exam.level.view}]]
                },
                {
                    field: 'permanentId',
                    title: [[#{jsp.exam.question.questionNumberPermanent}]]
                },
            ],
            onLoadSuccess: function (data) {
                //打开的时候选中
                $.btTable.bootstrapTable('uncheckAll');
                var $thisContent = $parent.$('#headline');;
                var $checkedValues = $thisContent.find('[name="questionId"]');
                var checkby = {};
                checkby['field'] = 'id';
                checkby['values'] = [];
                $($checkedValues).each(function (i) {
                    checkby['values'].push(parseInt($(this).val()));
                });
                $.btTable.bootstrapTable('checkBy', checkby);
            }
        };
        $.table.init(options);
    });
 
    function stateFormatter(value, row, index) {
        // var $thisContent = $parent.$('[add-question-edit="true"]').parents('#headline');
        var $thisContent = $parent.$('#headline');
        var $checkedValues = $thisContent.find('[name="questionId"]');
        var flag = true;
        row['checked'] = false;
        $($checkedValues).each(function (i) {
            if (row.id == parseInt($(this).val())) {
                row.checked = true;
                flag = false;
            }
        });
 
        if (!flag) {
            return {
                disabled: true,//设置是否可用
                checked: true//设置选中
            };
        }
        return value;
    }
 
    // add-question
    function submitHandler() {
        var $tableSelect = $.btTable.bootstrapTable('getSelections');
        $parent.$('#headline').empty();
 
        $.each($tableSelect, function (index, obj) {
            if (!obj.checked) {// if do not checked
                // 清空后再添加
                var $hiddenTitle = $parent.$('#hiddenTitle').clone();
                $hiddenTitle.removeAttrs('id');
                $hiddenTitle.removeAttrs('hidden');
                $hiddenTitle.find('[name="segmentationName"]').val(obj.title);
                $hiddenTitle.find('[name="permanentId"]').val(obj.permanentId);
                $hiddenTitle.find('[name="questionId"]').val(obj.id);
                $parent.$('#headline').append($hiddenTitle);
 
            }
        });
 
        var $title = $parent.$('#headline').find('.headline-index-seq');
        var $description = $parent.$('#headline').find('.segment-discription-seq');
        $title.each(function (i) {
            $(this).text([[#{jsp.exam.product.question}]] + (i + 1) + " -");
            $description.eq(i).text([[#{jsp.exam.product.question}]] + (i + 1) + [[#{jsp.exam.product.description}]] + " -");
        });
 
        $.modal.closeTab();
    }
</script>
</body>
</html>