双重预防项目-国泰新华二开定制版
SZH
2022-08-20 f9f0687195e0fe349185437d22c495d74c8d4a20
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
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改公司信息(文章)')" />
    <th:block th:include="include :: summernote-css" />
    <th:block th:include="include :: layui-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-article-edit" th:object="${article}">
            <input id="articleId" name="articleId" th:field="*{articleId}"  type="hidden">
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">文章标题:</label>
                <div class="col-sm-10">
                    <input id="articleTitle" name="articleTitle" th:field="*{articleTitle}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label is-required">文章类型:</label>
                <div class="col-sm-10">
                    <select name="articleType" class="form-control m-b" th:with="type=${@dict.getType('tr_article_management_type')}"  th:field="*{articleType}" required>
                        <option value="">--请选择--</option>
                        <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-2 control-label">文章内容:</label>
                <div class="col-sm-10">
                    <input id="articleContent" name="articleContent" th:field="*{articleContent}" type="hidden">
                    <div id="editor" class="summernote"></div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">备注信息:</label>
                <div class="col-sm-10">
                    <input id="remark" name="remark" class="form-control" th:field="*{remark}" type="text">
                </div>
            </div>
 
            <div class="form-group">
                <label class="col-sm-2 control-label">所属文件:
                </label>
 
                <div class="col-sm-10" >
                    <button type="button" class="layui-btn layui-btn-normal" id="testList">选择多文件</button>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                </label>
 
                <div class="col-sm-10" >
                    <div class="layui-upload-list">
                        <table class="layui-table">
                            <thead>
                            <tr><th>文件名</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr></thead>
                            <tbody id="demoList" >
                            <tr th:each="file :${fileList}" th:id="${file.attachmentId}">
                                <td>[[${file.originalFileName}]]</td>
                                <td>已上传</td>
                                <td>
                                    <a target="_blank" th:if="${#strings.contains(file.filePath,'.pdf')}" th:href="${serviceDomainName}+${file.filePath}"><button type="button" class="layui-btn layui-btn-xs layui-btn-primary">阅览</button></a>
                                    <a target="_blank" th:if="${!#strings.contains(file.filePath,'.pdf')}" th:href="'https://view.officeapps.live.com/op/view.aspx?src='+${serviceDomainName}+${file.filePath}"><button type="button" class="layui-btn layui-btn-xs layui-btn-primary">阅览</button></a>
                                    <a th:href="${file.filePath}" th:download="${file.originalFileName}"><button type="button" class="layui-btn layui-btn-xs layui-btn-normal" >下载</button></a>
                                    <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" th:onclick="'deleteFile('+${file.attachmentId}+')'">删除</button>
                                </td>
 
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <button type="button" class="layui-btn" id="testListAction">开始上传</button>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: summernote-js" />
    <th:block th:include="include :: layui-js"/>
    <!-- 封装layui上传方法 -->
    <script src="/js/common/fileUpload.js"></script>
    <script type="text/javascript">
        //存放已上传的附件的数组
        var attachmentListArray = new Array();
 
        $(function() {
            fileUpload("#testList","#testListAction","#demoList",attachmentListArray);
        });
 
        var prefix = ctx + "tr/article";
    
        $(function() {
            $('.summernote').summernote({
                placeholder: '请输入文章内容',
                height : 192,
                lang : 'zh-CN',
                followingToolbar: false,
                callbacks: {
                    onImageUpload: function (files) {
                        sendFile(files[0], this);
                    }
                }
            });
            var content = $("#articleContent").val();
            $('#editor').summernote('code', content);
        });
        
        // 上传文件
        function sendFile(file, obj) {
            var data = new FormData();
            data.append("file", file);
            $.ajax({
                type: "POST",
                url: ctx + "common/upload",
                data: data,
                cache: false,
                contentType: false,
                processData: false,
                dataType: 'json',
                success: function(result) {
                    if (result.code == web_status.SUCCESS) {
                        $(obj).summernote('editor.insertImage', result.url, result.fileName);
                    } else {
                        $.modal.alertError(result.msg);
                    }
                },
                error: function(error) {
                    $.modal.alertWarning("图片上传失败。");
                }
            });
        }
        
        $("#form-article-edit").validate({
            focusCleanup: true
        });
        
        function submitHandler() {
            if ($.validate.form()) {
                var sHTML = $('.summernote').summernote('code');
                $("#articleContent").val(sHTML);
 
                var data = $('#form-article-edit').serializeArray();
                data.push({"name": "ownedFile", "value": JSON.stringify(attachmentListArray)});
 
                $.operate.save(prefix + "/edit", data);
            }
        }
    </script>
</body>
</html>