瀏覽代碼

feat: 计量台账审核弹窗改版

lanjianrong 4 年之前
父節點
當前提交
abca7008ab

+ 10 - 5
app/controller/stage_controller.js

@@ -60,13 +60,17 @@ module.exports = app => {
                 },
             };
             if ((ctx.stage.status === auditConst.status.uncheck || ctx.stage.status === auditConst.status.checkNo) && ctx.session.sessionUser.accountId === ctx.stage.user_id) {
-                data.accountGroup = accountGroup;
+                // data.accountGroup = accountGroup;
                 // 获取所有项目参与者
                 const accountList = await ctx.service.projectAccount.getAllDataByCondition({
                     where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group'],
+                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
                 });
                 data.accountList = accountList;
+                data.accountGroup = accountGroup.map((item, idx) => {
+                    const groupList = accountList.filter(item => item.account_group === idx);
+                    return { groupName: item, groupList };
+                });
             }
             data.tenderMenu.back.children[0].url = '/tender/' + ctx.tender.id + '/measure/stage';
 
@@ -139,13 +143,13 @@ module.exports = app => {
 
             ctx.stage.user = await ctx.service.projectAccount.getAccountInfoById(ctx.stage.user_id);
             ctx.stage.auditHistory = [];
-            if (ctx.stage.times > 1) {
-                for (let i = 1; i < ctx.stage.times; i++) {
+            if (times >= 1) {
+                for (let i = 1; i <= times; i++) {
                     ctx.stage.auditHistory.push(await ctx.service.stageAudit.getAuditors(ctx.stage.id, i));
                 }
             }
             // 获取审批流程中左边列表
-            ctx.stage.auditors2 = await ctx.service.stageAudit.getAuditGroupByList(ctx.stage.id, times);
+            ctx.stage.auditors2 = await ctx.service.stageAudit.getAuditGroupByListWithOwner(ctx.stage.id, times);
             if (ctx.stage.status === auditConst.status.uncheck || ctx.stage.status === auditConst.status.checkNo) {
                 ctx.stage.auditorList = await ctx.service.stageAudit.getAuditors(ctx.stage.id, ctx.stage.times);
             }
@@ -176,6 +180,7 @@ module.exports = app => {
                 renderData.whiteList = this.ctx.app.config.multipart.whitelist;
                 renderData.imType = tenderConst.imType;
                 renderData.curAuditor = ctx.stage.curAuditor;
+                renderData.auditConst = auditConst;
                 // 获取附件列表
                 const attData = await ctx.service.stageAtt.getDataByTenderIdAndStageId(ctx.tender.id, ctx.params.order);
                 for (const index in attData) {

+ 1 - 34
app/public/js/material_audit.js

@@ -17,27 +17,6 @@ $(document).ready(function () {
         return _.take(path, 6).join('/');
     }
 
-    // 搜索审批人
-    // $('#searchAccount').click(() => {
-    //     const data = {
-    //         keyword: $('#searchName').val(),
-    //     };
-    //     postData('/search/user', data, (data) => {
-    //         const resultDiv = $('#searchResult');
-    //         if (data) {
-    //             $('h5>span', resultDiv).text(data.name);
-    //             $('#addAuditor').attr('auditorId', data.id);
-    //             $('h6', resultDiv).text(data.role);
-    //             $('p', resultDiv).text(data.company);
-    //             resultDiv.show();
-    //         } else {
-    //             toast('未查询到该审核人', 'info');
-    //             resultDiv.hide();
-    //         }
-    //     }, () => {
-    //         $('#searchResult').hide();
-    //     });
-    // });
     $('#gr-search').bind('input propertychange', function(e) {
         oldSearchVal = e.target.value
         timer && clearTimeout(timer)
@@ -114,20 +93,8 @@ $(document).ready(function () {
         return false
     })
 
-    // 审批人分组选择
-    // $('#account_group').change(function () {
-    //     let account_html = '<option value="0">选择审批人</option>';
-    //     for (const account of accountList) {
-    //         if (parseInt($(this).val()) === 0 || parseInt($(this).val()) === account.account_group) {
-    //             const role = account.role !== '' ? '(' + account.role + ')' : '';
-    //             const company = account.company !== '' ? ' -' + account.company : '';
-    //             account_html += '<option value="' + account.id + '">' + account.name + role + company + '</option>';
-    //         }
-    //     }
-    //     $('#account_list').html(account_html);
-    // });
     // 添加到审批流程中
-    $('body').on('change', '#account_list', function () {
+    $('dl').on('click', 'dd', function () {
         let id = $(this).val();
         id = parseInt(id);
         if (id !== 0) {

+ 123 - 52
app/public/js/stage_audit.js

@@ -9,48 +9,110 @@
  */
 
 $(document).ready(function () {
+    let timer = null
+    let oldSearchVal = null
     // 获取审核相关url
     function getUrlPre () {
         const path = window.location.pathname.split('/');
         return _.take(path, 6).join('/');
     }
 
-    // 搜索审批人
-    $('#searchAccount').click(() => {
-        const data = {
-            keyword: $('#searchName').val(),
-        };
-        postData('/search/user', data, (data) => {
-            const resultDiv = $('#searchResult');
-            if (data) {
-                $('h5>span', resultDiv).text(data.name);
-                $('#addAuditor').attr('auditorId', data.id);
-                $('h6', resultDiv).text(data.role);
-                $('p', resultDiv).text(data.company);
-                resultDiv.show();
+    $('#gr-search').bind('input propertychange', function(e) {
+        oldSearchVal = e.target.value
+        timer && clearTimeout(timer)
+        timer = setTimeout(() => {
+            const newVal = $('#gr-search').val()
+            let html = ''
+            if (newVal && newVal === oldSearchVal) {
+                accountList.filter(item => item && cur_uid !== item.id && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
+                    html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
+                        <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
+                                class="ml-auto">${item.mobile || ''}</span></p>
+                        <span class="text-muted">${item.role || ''}</span>
+                    </dd>`
+                })
+                $('.book-list').empty()
+                $('.book-list').append(html)
             } else {
-                toastr.info('未查询到该审核人');
-                resultDiv.hide();
+                if (!$('.acc-btn').length) {
+                    accountGroup.forEach((group, idx) => {
+                        if (!group) return
+                        html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
+                        </a> ${group.groupName}</dt>
+                        <div class="dd-content" data-toggleid="${idx}">`
+                        group.groupList.forEach(item => {
+                            if (item.id !== cur_uid) {
+                                html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
+                                    <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
+                                            class="ml-auto">${item.mobile || ''}</span></p>
+                                    <span class="text-muted">${item.role || ''}</span>
+                                </dd>`
+                            }
+                        });
+                        html += '</div>'
+                    })
+                    $('.book-list').empty()
+                    $('.book-list').append(html)
+                }
             }
-        }, () => {
-            $('#searchResult').hide();
-        });
-    });
+        }, 400);
+    })
+
+    // 添加审批流程按钮逻辑
+    $('.book-list').on('click', '.acc-btn', function () {
+        const idx = $(this).attr('data-groupid')
+        const type = $(this).attr('data-type')
+        if (type === 'hide') {
+            $(this).parent().parent().find(`div[data-toggleid="${idx}"]`).show(() => {
+                $(this).children().removeClass('fa-plus-square').addClass('fa-minus-square-o')
+                $(this).attr('data-type', 'show')
+
+            })
+        } else {
+            $(this).parent().parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
+                $(this).children().removeClass('fa-minus-square-o').addClass('fa-plus-square')
+                $(this).attr('data-type', 'hide')
+            })
+        }
+        return false
+    })
+
+    // 搜索审批人
+    // $('#searchAccount').click(() => {
+    //     const data = {
+    //         keyword: $('#searchName').val(),
+    //     };
+    //     postData('/search/user', data, (data) => {
+    //         const resultDiv = $('#searchResult');
+    //         if (data) {
+    //             $('h5>span', resultDiv).text(data.name);
+    //             $('#addAuditor').attr('auditorId', data.id);
+    //             $('h6', resultDiv).text(data.role);
+    //             $('p', resultDiv).text(data.company);
+    //             resultDiv.show();
+    //         } else {
+    //             toastr.info('未查询到该审核人');
+    //             resultDiv.hide();
+    //         }
+    //     }, () => {
+    //         $('#searchResult').hide();
+    //     });
+    // });
     // 添加审批人
-    $('#addAuditor').click(() => {
-        postData(getUrlPre() + '/audit/add', { auditorId: $('#addAuditor').attr('auditorId') }, (data) => {
-            const html = [];
-            html.push('<li class="list-group-item" auditorId="'+ data.aid +'"><a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
-            html.push('<span>');
-            html.push(data.order + ' ');
-            html.push(data.name + ' ');
-            html.push('</span>');
-            html.push('<small class="text-muted">');
-            html.push(data.role);
-            html.push('</small></li>');
-            $('#auditors').append(html.join(''));
-        });
-    });
+    // $('#addAuditor').click(() => {
+    //     postData(getUrlPre() + '/audit/add', { auditorId: $('#addAuditor').attr('auditorId') }, (data) => {
+    //         const html = [];
+    //         html.push('<li class="list-group-item" auditorId="'+ data.aid +'"><a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
+    //         html.push('<span>');
+    //         html.push(data.order + ' ');
+    //         html.push(data.name + ' ');
+    //         html.push('</span>');
+    //         html.push('<small class="text-muted">');
+    //         html.push(data.role);
+    //         html.push('</small></li>');
+    //         $('#auditors').append(html.join(''));
+    //     });
+    // });
     // 审批人分组选择
     $('#account_group').change(function () {
         let account_html = '<option value="0">选择审批人</option>';
@@ -64,9 +126,8 @@ $(document).ready(function () {
         $('#account_list').html(account_html);
     });
     // 添加到审批流程中
-    $('body').on('change', '#account_list', function () {
-        let id = $(this).val();
-        id = parseInt(id);
+    $('dl').on('click', 'dd', function () {
+        const id = parseInt($(this).data('id'));
         if (id !== 0) {
             postData(getUrlPre() + '/audit/add', { auditorId: id }, (data) => {
                 const html = [];
@@ -142,14 +203,14 @@ $(document).ready(function () {
     });
     // 退回选择修改审批人流程
     $('#hideSp').click(function () {
-        $('#sp-list2').modal('hide');
+        $('#sp-list').modal('hide');
     });
     $('a[f-target]').click(function () {
         $($(this).attr('f-target')).modal('show');
     });
 
     // 多层modal关闭后的滚动bug修复
-    $('#sp-list2').on('hidden.bs.modal', function (e) {
+    $('#sp-list').on('hidden.bs.modal', function (e) {
         $(document.body).addClass('modal-open');
     });
 
@@ -198,20 +259,30 @@ function checkAuditorFrom () {
     return true;
 }
 // texterea换行
-function auditCheck(i) {
-    const inlineRadio1 = $('#inlineRadio1:checked').val()
-    const inlineRadio2 = $('#inlineRadio2:checked').val()
-    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;
-}
+// function auditCheck(i) {
+//     debugger
+//     const inlineRadio1 = $('#inlineRadio1:checked').val()
+//     const inlineRadio2 = $('#inlineRadio2:checked').val()
+//     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()
+//     }
+//     $(this).parent().parent().modal('hide');
+//         const data = {
+//             opinion: $('[name=opinion]', this).val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' '),
+//             checkType: parseInt($('[name=checkType]:checked', this).val()),
+//         };
+//         debugger
+//         postData(this.action, data, function () {
+//             window.location.reload();
+//         })
+//         return false
+// }
 
 /**
  * 获取成功后的操作

+ 21 - 20
app/view/advance/modal_audit.ejs

@@ -594,29 +594,30 @@
                                                         <label>审批意见<b class="text-danger">*</b></label>
                                                         <textarea class="form-control form-control-sm"
                                                             name="opinion">不同意</textarea>
+                                                            <% if (ctx.advance.curAuditor.audit_id === auditor.audit_id) { %>
+                                                                <div id="reject-process" class="alert alert-warning"
+                                                                    style="margin-top: 15px;">
+                                                                    <div class="form-check form-check-inline">
+                                                                        <input class="form-check-input" type="radio" name="checkType"
+                                                                            id="inlineRadio1" value="<%- auditConst.status.checkNo %>">
+                                                                        <label class="form-check-label" for="inlineRadio1">退回原报
+                                                                            <%- ctx.advance.user.name %></label>
+                                                                    </div>
+                                                                    <% if (auditor.order > 1 && auditor.audit_id !== auditors[0].audit_id) { %>
+                                                                    <div class="form-check form-check-inline">
+                                                                        <input class="form-check-input" type="radio" name="checkType"
+                                                                            id="inlineRadio2"
+                                                                            value="<%- auditConst.status.checkNoPre %>">
+                                                                        <label class="form-check-label" for="inlineRadio2">退回上一审批人
+                                                                            <%- auditors[index-1].name %></label>
+                                                                    </div>
+                                                                    <% } %>
+                                                                </div>
+                                                                <% } %>
                                                         <% } else { %>
                                                         <p style="margin: 0;"><%- auditor.opinion %></p>
                                                         <% } %>
-                                                        <% if (ctx.advance.curAuditor.audit_id === auditor.audit_id) { %>
-                                                        <div id="reject-process" class="alert alert-warning"
-                                                            style="margin-top: 15px;">
-                                                            <div class="form-check form-check-inline">
-                                                                <input class="form-check-input" type="radio" name="checkType"
-                                                                    id="inlineRadio1" value="<%- auditConst.status.checkNo %>">
-                                                                <label class="form-check-label" for="inlineRadio1">退回原报
-                                                                    <%- ctx.advance.user.name %></label>
-                                                            </div>
-                                                            <% if (auditor.order > 1 && auditor.audit_id !== auditors[0].audit_id) { %>
-                                                            <div class="form-check form-check-inline">
-                                                                <input class="form-check-input" type="radio" name="checkType"
-                                                                    id="inlineRadio2"
-                                                                    value="<%- auditConst.status.checkNoPre %>">
-                                                                <label class="form-check-label" for="inlineRadio2">退回上一审批人
-                                                                    <%- auditors[index-1].name %></label>
-                                                            </div>
-                                                            <% } %>
-                                                        </div>
-                                                        <% } %>
+
                                                     </div>
 
                                                     <% } %>

+ 22 - 21
app/view/material/audit_modal.ejs

@@ -247,7 +247,7 @@
         </div>
     </div>
 </div>
-<% if (ctx.material.status === auditConst.status.checking) { %>
+<% if (ctx.material.status === auditConst.status.checking || ctx.material.status === auditConst.status.checkNoPre) { %>
     <% if (ctx.material.curAuditor && ctx.material.curAuditor.aid === ctx.session.sessionUser.accountId) { %>
         <!--审批通过-->
         <div class="modal fade sp-location-list" id="sp-done" data-backdrop="static">
@@ -623,29 +623,30 @@
                                                         <label>审批意见<b class="text-danger">*</b></label>
                                                         <textarea class="form-control form-control-sm"
                                                             name="opinion">不同意</textarea>
-                                                        <% } else { %>
-                                                        <p style="margin: 0;"><%- auditor.opinion %></p>
-                                                        <% } %>
-                                                        <% if (ctx.material.curAuditor.aid === auditor.aid) { %>
-                                                        <div id="reject-process" class="alert alert-warning"
-                                                            style="margin-top: 15px;">
-                                                            <div class="form-check form-check-inline">
-                                                                <input class="form-check-input" type="radio" name="checkType"
-                                                                    id="inlineRadio1" value="<%- auditConst.status.checkNo %>">
-                                                                <label class="form-check-label" for="inlineRadio1">退回原报
-                                                                    <%- ctx.material.user.name %></label>
-                                                            </div>
-                                                            <% if (auditor.order > 1 && auditor.aid !== auditors[0].aid) { %>
-                                                            <div class="form-check form-check-inline">
-                                                                <input class="form-check-input" type="radio" name="checkType"
-                                                                    id="inlineRadio2"
-                                                                    value="<%- auditConst.status.checkNoPre %>">
-                                                                <label class="form-check-label" for="inlineRadio2">退回上一审批人
-                                                                    <%- auditors[index-1].name %></label>
+                                                            <% if (ctx.material.curAuditor.aid === auditor.aid ) { %>
+                                                            <div id="reject-process" class="alert alert-warning"
+                                                                style="margin-top: 15px;">
+                                                                <div class="form-check form-check-inline">
+                                                                    <input class="form-check-input" type="radio" name="checkType"
+                                                                        id="inlineRadio1" value="<%- auditConst.status.checkNo %>">
+                                                                    <label class="form-check-label" for="inlineRadio1">退回原报
+                                                                        <%- ctx.material.user.name %></label>
+                                                                </div>
+                                                                <% if (auditor.order > 1 && auditor.aid !== auditors[0].aid) { %>
+                                                                <div class="form-check form-check-inline">
+                                                                    <input class="form-check-input" type="radio" name="checkType"
+                                                                        id="inlineRadio2"
+                                                                        value="<%- auditConst.status.checkNoPre %>">
+                                                                    <label class="form-check-label" for="inlineRadio2">退回上一审批人
+                                                                        <%- auditors[index-1].name %></label>
+                                                                </div>
+                                                                <% } %>
                                                             </div>
                                                             <% } %>
-                                                        </div>
+                                                        <% } else { %>
+                                                        <p style="margin: 0;"><%- auditor.opinion %></p>
                                                         <% } %>
+
                                                     </div>
 
                                                     <% } %>

+ 12 - 2
app/view/stage/audit_btn.ejs

@@ -11,9 +11,9 @@
     <% } else if (ctx.stage.status === auditConst.status.checked) { %>
         <a href="#sp-list" data-toggle="modal" data-target="#sp-list" class="btn btn-outline-secondary btn-sm btn-block">审批完成</a>
     <% } else if (ctx.stage.status === auditConst.status.checkNo) { %>
-        <a href="#sp-list" data-toggle="modal" data-target="#sp-list" class="btn btn-outline-warning btn-sm btn-block text-muted">审批退回</a>
+        <a href="#sp-list"  data-type="hide" data-toggle="modal" data-target="#sp-list" class="btn btn-outline-warning btn-sm btn-block text-muted sp-list-btn">审批退回</a>
         <% if (ctx.session.sessionUser.accountId === ctx.stage.user_id) { %>
-            <a id="sp-list2-btn" href="javascript: void(0);" data-toggle="modal" data-target="#sp-list2" class="btn btn-primary btn-sm btn-block">重新上报</a>
+            <a href="#sp-list" data-type="show" data-toggle="modal" data-target="#sp-list"  class="btn btn-primary btn-sm btn-block sp-list-btn">重新上报</a>
         <% } %>
     <% } else if (ctx.stage.status === auditConst.status.checkNoPre) { %>
         <a href="#sp-list" data-toggle="modal" data-target="#sp-list" class="btn btn-outline-warning btn-sm btn-block text-muted">审批退回</a>
@@ -29,3 +29,13 @@
         <a href="#del-qi" data-toggle="modal" data-target="#del-qi" class="btn btn-outline-danger btn-sm btn-block mt-5">删除本期</a>
     <% } %>
 </div>
+<script>
+    $('.sp-list-btn').click(function () {
+        const type = $(this).data('type')
+        if (type === 'hide') {
+            $('.sp-list-item').hide()
+        } else {
+            $('.sp-list-item').show()
+        }
+    });
+</script>

File diff suppressed because it is too large
+ 850 - 1562
app/view/stage/audit_modal.ejs