puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
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
@layout("/common/_container.html"){
<style>
    .newWidth, .single-line{
        max-width:350px !important;display: initial !important;
    }
</style>
<input id = "id" style="display: none;" value="${info.id}"/>
<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-content">
                <div class="row row-lg">
                    <div class="col-sm-12">
                        <div class="tabs-container">
                            <ul class="nav nav-tabs">
                                <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">编辑常见问题</a></li>
                            </ul>
                            <div class="tab-content">
                                <div id="tab-1" class="tab-pane active">
                                    <div class="panel-body">
 
                                        <label  class="label1" for="questionTitle">*问题标题:</label>
                                        <input class="textarea" value="${info.content}" type="text" id="questionTitle" placeholder="请输入问题标题">
                                        <div>
                                            <label for="editor_1">*答复内容:</label>
                                            <textarea id="editor_1"  type="text/plain" style="width:1200px;height:400px;">${info.answer}</textarea>
                                        </div>
 
                                        <label for="sort">*排   序:</label>
                                        <input type="text" id="sort" value="${info.sort}" placeholder="请输入排序"><span>&nbsp;&nbsp;&nbsp;数字越大,权重越大</span>
                                        <div class="row btn-group-m-t">
                                            <div class="col-sm-10 col-sm-offset-5">
                                                <#button btnCss="info" name="保存" id="ensure" icon="fa-check" clickFun="edit();" />
                                                <#button btnCss="info" name="关闭" id="close" icon="fa-check" clickFun="closeD();" />
                                            </div>
                                        </div>
                                    </div>
                                </div>
 
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
 
    /**
     * 关闭此对话框
     */
    function closeD(){
        console.log("关闭");
        parent.layer.close(window.parent.TQuestion.layerIndex);
    }
    const data1 = {
        id:null,
        content:"",
        sort:null,
        answer:""
    }
    var editor_1 = null;
    $(function () {
        //初始化编辑器
        editor_1 = UE.getEditor('editor_1');
 
    });
 
 
    function edit(){
        const input1 = document.getElementById('questionTitle');
        const value1 = input1.value;
        const input2 = document.getElementById('sort');
        const value2 = input2.value;
        const input3 = document.getElementById('id');
        const value3 = input3.value;
 
        if (editor_1.getContent() == ""){
            Feng.error("答复内容不能为空!");
            return;
        }if (value1 == ""){
            Feng.error("问题标题不能为空!");
            return;
        }if (value2 == ""){
            Feng.error("排序不能为空!");
            return;
        }
        data1.id = value3;
        data1.content = value1;
        data1.sort =  value2;
        data1.answer =editor_1.getContent();
        console.log(data1);
        submitData(data1);
    }
    function submitData(data) {
        $.ajax({
            url: Feng.ctxPath + "/tQuestion/editQuestion",
            type: "POST",
            contentType: "application/json", // 设置请求头的 Content-Type
            data: JSON.stringify(data), // 将数据转换为 JSON 字符串
            success: function(response) {
                window.parent.TQuestion.table.refresh();
                closeD();
                Feng.success("修改成功!");
            },
            error: function(xhr, status, error) {
                var errorMessage = xhr.responseText ? xhr.responseText : "修改失败!";
                Feng.error(errorMessage);
            }
        });
    }
 
</script>
@}