MaiXinRong 5 лет назад
Родитель
Сommit
6cf9555289

+ 3 - 0
app/controller/login_controller.js

@@ -60,6 +60,9 @@ module.exports = app => {
                     throw '该账号已被停用,请联系销售人员';
                 }
 
+                // 调用 rotateCsrfSecret 刷新用户的 CSRF token
+                ctx.rotateCsrfSecret();
+
                 // 判断是否已经有对应用户信息,没有则跳转初始化页面
                 const needBoot = await ctx.service.customer.isNeedBoot(ctx.request.body);
                 const url = needBoot ? '/boot' : '/dashboard';

+ 1 - 1
app/controller/stage_extra_controller.js

@@ -89,7 +89,7 @@ module.exports = app => {
                 const renderData = {
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.stageExtra.bonus)
                 }
-                await this.layout('stage_extra/bonus.ejs', renderData);
+                await this.layout('stage_extra/bonus.ejs', renderData, 'stage_extra/bonus_modal.ejs');
             } catch (err) {
                 ctx.helper.log(err);
             }

+ 72 - 30
app/public/js/se_bonus.js

@@ -14,6 +14,31 @@ const isPre = function (data) {
 $(document).ready(() => {
     autoFlashHeight();
 
+    const fileObj = {
+        generateFilesHtml(data) {
+            const id = data.id, files = data.proof_file;
+            let html = [];
+            if (files !== null && files !== undefined) {
+                for (const [i, f] of files.entries()) {
+                    html.push('<tr>');
+                    html.push('<td style="width: 200px">', f.filename + f.fileext, '</td>');
+                    html.push('<td>', f.username, '</td>');
+                    html.push('<td>', f.in_time, '</td>');
+                    html.push('<td>');
+                    // 下载
+                    html.push('<a href="' + window.location.pathname + '/file/download?id=' + id + '&index=' + i + ' title="下载><i class="fa fa-download "></i></a>');
+                    // 删除
+                    if (!readOnly && uploadPermission && !isPre(data)) {
+                        html.push('<a class="delete-att text-danger" href="javascript:void(0);" data-id ="' + id + '"file-index="' + i + '" title="删除"><i class="fa fa-remove "></i></a>');
+                    }
+                    html.push('</td>');
+                    html.push('</tr>');
+                }
+            }
+            $('#file-list').html(html.join(''));
+        },
+    };
+
     let datepicker;
     const spreadSetting = {
         cols: [
@@ -27,7 +52,17 @@ $(document).ready(() => {
                 },
             },
             {title: '编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 150, formatter: '@', readOnly: isPre, },
-            {title: '依据材料证明', colSpan: '1', rowSpan: '1', field: 'proof', hAlign: 0, width: 180, formatter: '@', readOnly: isPre, },
+            {title: '发文单位', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 150, formatter: '@', readOnly: isPre},
+            {
+                title: '依据材料证明', colSpan: '1', rowSpan: '1', field: 'proof_file', hAlign: 1, width: 80, formatter: '@',
+                readOnly: true, cellType: 'imageBtn', normalImg: '#rela-file-icon', hoverImg: '#rela-file-hover',
+                getValue: function (data) {
+                    return data.proof_file ? data.proof_file.length : 0;
+                },
+                showImage: function (data) {
+                    return data !== undefined && data !== null;
+                },
+            },
             {
                 title: '计量期', colSpan: '1', rowSpan: '1', field: 'sorder', hAlign: 1, width: 100, formatter: '@',
                 getValue: function (data) {
@@ -49,38 +84,45 @@ $(document).ready(() => {
             const setting = hitinfo.sheet.zh_setting;
             if (!setting) return;
             const col = setting.cols[hitinfo.col];
-            if (!col || col.field !== 'real_time') return;
-
-            const pos = SpreadJsObj.getObjPos(hitinfo.sheet.getParent().qo);
-            if (!datepicker) {
-                datepicker = $('.datepicker-here').datepicker({
-                    language: 'zh',
-                    dateFormat: 'yyyy-MM-dd',
-                    autoClose: true,
-                    onSelect: function (formattedDate, date, inst) {
-                        if (!inst.visible) return;
-                        const sels = hitinfo.sheet.getSelections();
-                        if (!sels || !sels[0]) return;
-                        const node = SpreadJsObj.getSelectObject(hitinfo.sheet);
-                        const uData = { update: {id: node.id, real_time: date} };
+            if (!col) return;
 
-                        postData(window.location.pathname + '/update', uData, function (result) {
-                            bonusObj.loadUpdateData(result);
-                            SpreadJsObj.reLoadRowData(hitinfo.sheet, sels[0].row);
-                        }, function () {
-                            SpreadJsObj.reLoadRowData(hitinfo.sheet, sels[0].row);
-                        });
-                    }
-                }).data('datepicker');
+            if (col.field === 'proof_file') {
+                fileObj.generateFilesHtml(data);
+                $('#file').modal('show');
             }
-            const value = hitinfo.sheet.getValue(hitinfo.row, hitinfo.col);
-            if (value) {
-                datepicker.selectDate(value);
-            } else {
-                datepicker.clear();
+
+            if (col.field === 'real_time') {
+                const pos = SpreadJsObj.getObjPos(hitinfo.sheet.getParent().qo);
+                if (!datepicker) {
+                    datepicker = $('.datepicker-here').datepicker({
+                        language: 'zh',
+                        dateFormat: 'yyyy-MM-dd',
+                        autoClose: true,
+                        onSelect: function (formattedDate, date, inst) {
+                            if (!inst.visible) return;
+                            const sels = hitinfo.sheet.getSelections();
+                            if (!sels || !sels[0]) return;
+                            const node = SpreadJsObj.getSelectObject(hitinfo.sheet);
+                            const uData = { update: {id: node.id, real_time: date} };
+
+                            postData(window.location.pathname + '/update', uData, function (result) {
+                                bonusObj.loadUpdateData(result);
+                                SpreadJsObj.reLoadRowData(hitinfo.sheet, sels[0].row);
+                            }, function () {
+                                SpreadJsObj.reLoadRowData(hitinfo.sheet, sels[0].row);
+                            });
+                        }
+                    }).data('datepicker');
+                }
+                const value = hitinfo.sheet.getValue(hitinfo.row, hitinfo.col);
+                if (value) {
+                    datepicker.selectDate(value);
+                } else {
+                    datepicker.clear();
+                }
+                datepicker.show();
+                $('#datepickers-container').css('top', hitinfo.cellRect.y + pos.y).css('left', hitinfo.cellRect.x + pos.x);
             }
-            datepicker.show();
-            $('#datepickers-container').css('top', hitinfo.cellRect.y + pos.y).css('left', hitinfo.cellRect.x + pos.x);
         }
     };
 

+ 3 - 1
app/service/stage_bonus.js

@@ -67,9 +67,10 @@ module.exports = app => {
                 };
                 nd.tp = d.tp ? this.ctx.helper.round(d.to, this.ctx.tender.info.decimal.tp) : 0;
                 nd.code = d.code ? d.code: null;
-                nd.proof = d.proof ? d.proof : null;
+                //nd.proof = d.proof ? d.proof : null;
                 nd.real_time = d.real_time ? d.real_time : null;
                 nd.memo = d.memo ? d.memo : null;
+                nd.doc_co = d.doc_co ? d.doc_co : null;
                 insertData.push(nd);
             }
             await this.db.insert(this.tableName, insertData);
@@ -105,6 +106,7 @@ module.exports = app => {
                 if (d.real_time !== undefined) nd.real_time = new Date(d.real_time);
                 if (d.memo !== undefined) nd.memo = d.memo;
                 if (d.order !== undefined) nd.order = d.order;
+                if (d.doc_co !== undefined) nd.doc_co = d.doc_co;
                 uDatas.push(nd);
                 console.log(nd);
             }

+ 2 - 0
app/view/stage_extra/bonus.ejs

@@ -21,6 +21,8 @@
     </div>
     <div style="display: none">
         <img src="/public/images/ellipsis_horizontal.png" id="ellipsis-icon" />
+        <img src="/public/images/file_clip.png" id="rela-file-icon" />
+        <img src="/public/images/file_clip_hover.png" id="rela-file-hover" />
     </div>
 </div>
 <script>

+ 36 - 0
app/view/stage_extra/bonus_modal.ejs

@@ -0,0 +1,36 @@
+<!--附件-->
+<div class="modal fade" id="file" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">附件</h5>
+            </div>
+            <div class="modal-body">
+                <% if (uploadPermission) { %>
+                <div class="form-group">
+                    <label for="formGroupExampleInput">大小限制:30MB,支持<span data-toggle="tooltip" data-placement="bottom" title="doc,docx,xls,xlsx,ppt,pptx,pdf">office等文档格式</span>、<span data-toggle="tooltip" data-placement="bottom" title="jpg,png,bmp">图片格式</span>、<span data-toggle="tooltip" data-placement="bottom" title="rar,zip">压缩包格式</span></label>
+                    <input type="file" class="" id="upload-file" multiple>
+                </div>
+                <% } %>
+                <div class="modal-height-500" style="overflow:auto;">
+                    <table class="table table-sm table-bordered" style="word-break:break-all; table-layout: fixed">
+                        <thead>
+                        <tr><th width="240">文件名</th><th>上传人</th><th>上传时间</th><th width="40">操作</th></tr>
+                        </thead>
+                        <tbody id="file-list">
+                        <tr>
+                            <td>XXXX.jpg</td><td>张三</td><td>2018-01-01</td><td><a href="#" target="_blank" title="下载"><i class="fa fa-download "></i></a> <a class="text-danger" href="#" target="_blank" title="删除"><i class="fa fa-remove "></i></a></td>
+                        </tr>
+                        <tr>
+                            <td>YYYY.jpg</td><td>李四</td><td>2018-01-01</td><td><a href="#" target="_blank" title="下载"><i class="fa fa-download "></i></a></td>
+                        </tr>
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
+            </div>
+        </div>
+    </div>
+</div>