浏览代码

feat: 增加预付款首页附件modal

lanjianrong 5 年之前
父节点
当前提交
c4eef21eb2

+ 4 - 1
app/controller/advance_controller.js

@@ -78,6 +78,7 @@ module.exports = app => {
             }
             // 获取审核人左边列表
             data.auditors = await ctx.service.advanceAudit.getAuditorsWithOwner(ctx.advance.id, ctx.advance.times);
+            // data.fileList = await ctx.service.advanceFile.getAdvanceFiles({ vid: ctx.advance.id });
             // 获取审批流程中右边列表
             const auditHistory = [];
             const times = ctx.advance.status === auditConst.status.checkNo ? ctx.advance.times - 1 : ctx.advance.times;
@@ -87,6 +88,7 @@ module.exports = app => {
                 }
             }
             data.auditHistory = auditHistory;
+            console.log('data.auditHistory', data.auditHistory);
             data.fileList = await ctx.service.advanceFile.getAdvanceFiles({ vid: ctx.advance.id });
             return data;
         }
@@ -105,6 +107,7 @@ module.exports = app => {
                     ctx.advance.auditHistory.push(await ctx.service.advanceAudit.getAuditors(ctx.advance.id, i));
                 }
             }
+            console.log('ctx.advance.auditHistory', ctx.advance.auditHistory);
             // 获取审批流程中左边列表
             ctx.advance.auditors2 = await ctx.service.advanceAudit.getAuditGroupByList(ctx.advance.id, times);
             if (ctx.advance.status === auditConst.status.uncheck || ctx.advance.status === auditConst.status.checkNo) {
@@ -406,7 +409,7 @@ module.exports = app => {
                 try {
                     const fileInfo = await ctx.service.advanceFile.getDataById(id);
                     if (fileInfo !== undefined && fileInfo !== '') {
-                        const fileName = path.join(this.app.baseDir, 'app', fileInfo.filepath);
+                        const fileName = path.join(__dirname, '../', fileInfo.filepath);
                         // 解决中文无法下载问题
                         const userAgent = (ctx.request.header['user-agent'] || '').toLowerCase();
                         let disposition = '';

+ 21 - 0
app/public/js/advance.js

@@ -28,6 +28,27 @@ $(document).ready(function () {
         return false
     })
 
+    $('#advanceList').on('click', `a[href="#file"]`, function() {
+        const { fileList = [] } = advanceList.find(item => item.id === parseInt($(this).data('id')))
+        $('#file-content').empty()
+        let html = `<thead>
+                            <tr>
+                                <th>文件名</th>
+                                <th>上传时间</th>
+                                <th>操作</th>
+                            </tr>
+                        </thead>`
+        fileList.forEach(file => {
+            html+= `<tr>
+                            <td>${file.filename}</td>
+                            <td>${new Date(file.create_time).toLocaleDateString()}</td>
+                            <td>
+                                <a href="/${file.filepath}" target="_blank" title="下载"><i class="fa fa-download"></i></a>
+                            </td>
+                        </tr>`
+        })
+        $('#file-content').append(html)
+    })
     function formatMoney(s, dot = ',') {
         if (!s) return '0.00';
         s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(2) + '';

+ 3 - 3
app/public/js/advance_audit.js

@@ -208,9 +208,9 @@ $(document).ready(function () {
         postData(preUrl + '/update', data)
     }
 
-    $('#file-modal-target').click(function () {
-        $('#file-modal').trigger('click')
-    })
+    // $('#file-modal-target').click(function () {
+    //     $('#file-modal').trigger('click')
+    // })
     $('#file-ok').click(function () {
         const files = Array.from($('#file-modal')[0].files)
         const valiData = files.map(v => {

+ 3 - 2
app/view/advance/index.ejs

@@ -63,8 +63,8 @@
                                 <td class="text-right"><%- ctx.helper.formatMoney(item.cur_amount)%></td>
                                 <td class="text-right"><%- ctx.helper.formatMoney(item.prev_amount)%></td>
                                 <td class="text-right"><%- ctx.helper.formatMoney(item.prev_total_amount)%></td>
-                                <td><a class="btn btn-sm" href="#file" data-toggle="modal" data-target="#file"><i
-                                            class="fa fa-paperclip "></i> 3</a></td>
+                                <td><a class="btn btn-sm" href="#file" data-toggle="modal" data-target="#file" data-id="<%- item.id %>"><i
+                                            class="fa fa-paperclip"></i><%- item.fileList.length %></a></td>
                                 <td>
                                     <% if (item.curAuditor) { %>
                                         <a href="/tender/<%- ctx.tender.id %>/advance/<%- item.id %>/detail" m-order="<%- item.order %>"><%- item.curAuditor.name %><%if (item.curAuditor.role !== '' && item.curAuditor.role !== null) { %>-<%- item.curAuditor.role %><% } %></a>
@@ -94,4 +94,5 @@
 <script>
     const type = parseInt('<%- type %>');
     const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
+    const advanceList = JSON.parse('<%- JSON.stringify(advanceList) %>');
 </script>

+ 2 - 23
app/view/advance/modal.ejs

@@ -8,34 +8,13 @@
             </div>
             <div class="modal-body">
                 <div class="modal-height-500">
-                    <table class="table table-sm table-bordered">
-                        <thead>
-                            <tr>
-                                <th>文件名</th>
-                                <th>上传时间</th>
-                                <th>操作</th>
-                            </tr>
-                        </thead>
-                        <tr>
-                            <td>XXXX.jpg</td>
-                            <td>2018-01-01</td>
-                            <td>
-                                <a href="#" target="_blank" title="下载"><i class="fa fa-download"></i></a>
-                            </td>
-                        </tr>
-                        <tr>
-                            <td>YYYY.jpg</td>
-                            <td>2018-01-01</td>
-                            <td>
-                                <a href="#" target="_blank" title="下载"><i class="fa fa-download"></i></a>
-                            </td>
-                        </tr>
+                    <table class="table table-sm table-bordered" id="file-content">
                     </table>
                 </div>
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
-                <button type="button" class="btn btn-primary">确定</button>
+                <!-- <button type="button" class="btn btn-primary">确定</button> -->
             </div>
         </div>
     </div>

+ 18 - 2
app/view/advance/modal_audit.ejs

@@ -29,8 +29,8 @@
         </div>
         <div class="modal-body">
             <p>大小限制:30MB,支持office等文档格式、图片格式、压缩包格式</p>
-            <p><a href="javascript: void(0);" class="btn btn-primary" id="file-modal-target">选择文件</a></p>
-            <input type="file" id="file-modal" multiple="multiple" style="display: none;">
+            <!-- <p><a href="javascript: void(0);" class="btn btn-primary" id="file-modal-target">选择文件</a></p> -->
+            <input type="file" id="file-modal" multiple="multiple" >
         </div>
         <div class="modal-footer">
             <button id="file-cancel" type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
@@ -854,6 +854,22 @@
 <% } %>
 
 <script>
+    function auditCheck(i) {
+        const inlineRadio1 = $('#inlineRadio1:checked').val()
+        const inlineRadio2 = $('#inlineRadio2:checked').val()
+        const opinion = $('textarea[name="opinion"]').eq(i).val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
+        $('textarea[name="opinion"]').eq(i).val(opinion);
+        if (i === 1) {
+            if (!inlineRadio1 && !inlineRadio2) {
+                if (!$('#warning-text').length) {
+                    $('#reject-process').prepend('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
+                }
+                return false;
+            }
+            if ($('#warning-text').length) $('#warning-text').remove()
+        }
+        return true;
+    }
     $('.sp-location-list').on('shown.bs.modal', function () {
         const height = $(this)[0].scrollHeight;
         const scrollBox = $(this).find('div[class="col-8 modal-height-500"]');