Bläddra i källkod

其它流程设置

laiguoran 4 år sedan
förälder
incheckning
ecaea02145

+ 3 - 0
app/controller/tender_controller.js

@@ -852,6 +852,9 @@ module.exports = app => {
                     case 'copy2ot':
                         await ctx.service.shenpiAudit.copyAudit2otherTender(data);
                         break;
+                    case 'copy2os':
+                        await ctx.service.shenpiAudit.copyAudit2otherShenpi(data);
+                        break;
                     default:break;
                 }
                 ctx.body = { err: 0, msg: '' };

+ 91 - 4
app/public/js/shenpi.js

@@ -170,6 +170,45 @@ function getTenderTreeHtml (this_code, this_status, aidList = []) {
         return EmptyTenderHtml.join('');
     }
 }
+
+function getShenpiHtml (this_code) {
+    const html = [];
+    html.push('<table class="table table-hover table-bordered">');
+    html.push('<thead>', '<tr>');
+    html.push('<th>名称</th>');
+    html.push('<th width="100">审批流程</th>');
+    html.push('<th width="40">选择</th>');
+    html.push('</tr>', '</thead>');
+    for (const sp of sp_lc) {
+        html.push('<tr>');
+        html.push('<td>', sp.name, '</td>');
+        html.push('<td>');
+        html.push(sp_status_list[sp.status].name);
+        const this_status = parseInt($('.' + sp.code + '_div').children('.lc-show').siblings('.form-group').find('input:checked').val());
+        if(this_status != sp_status.sqspr) {
+            const nameList = [];
+            const aid_num = $('.' + sp.code + '_div').children('.lc-show').children('ul').find('.remove-audit').length;
+            const aidList = [];
+            for (let i = 0; i < aid_num; i++) {
+                const aid = parseInt($('.' + sp.code + '_div').children('.lc-show').children('ul').find('.remove-audit').eq(i).data('id'));
+                aidList.push(aid);
+            }
+            if(aidList.length > 0) {
+                for (const uid of aidList) {
+                    const user = _.find(accountList, { id: uid });
+                    nameList.push(user.name);
+                }
+            }
+            html.push('<i class="fa fa-question-circle text-primary" data-container="body" data-toggle="tooltip" data-placement="bottom" ' +
+                'data-original-title="'+ (nameList.length > 0 ? nameList.join('-') : '') +'"></i>');
+        }
+        html.push('</td>');
+        html.push('<td>', this_code !== sp.code ? '<input type="checkbox" data-code="'+ sp.code +'">' : '', '</td>');
+        html.push('</tr>');
+    }
+    html.push('</table>');
+    return html.join('');
+}
 $(document).ready(function () {
     let timer = null;
     let oldSearchVal = null;
@@ -438,7 +477,7 @@ $(document).ready(function () {
         setTimeout(function () { $("#tender-list [data-toggle='tooltip']").tooltip(); },800);
     });
 
-    $('#save-other-shenpi').click(function () {
+    $('#save-other-tender').click(function () {
         $(this).attr('disabled', true);
         const num = $('#tender-list input:checked').length;
         if (num < 2) {
@@ -447,10 +486,10 @@ $(document).ready(function () {
         }
         const data = {
             type: 'copy2ot',
-            status: $('#shenpi_status').val(),
+            status: parseInt($('#shenpi_status').val()),
             code: $('#shenpi_code').val(),
         };
-        if(data.code !== shenpi_status.gdspl) {
+        if(data.status !== shenpi_status.gdspl) {
             data.aidList = $('#shenpi_auditors').val();
         }
         // 获取已选中的标段
@@ -468,5 +507,53 @@ $(document).ready(function () {
                 window.location.reload();
             }, 1000)
         })
-    })
+    });
+
+    $('.set-otherShenpi').on('click', function () {
+        const this_code = $(this).data('code');
+        const this_status = parseInt($(this).siblings('.lc-show').siblings('.form-group').find('input:checked').val());
+        const aid_num = $(this).siblings('.lc-show').children('ul').find('.remove-audit').length;
+        const aidList = [];
+        for (let i = 0; i < aid_num; i++) {
+            const aid = parseInt($(this).siblings('.lc-show').children('ul').find('.remove-audit').eq(i).data('id'));
+            aidList.push(aid);
+        }
+        const html = getShenpiHtml(this_code);
+        $('#shenpi-name2').text($(this).data('name'));
+        $('#shenpi_code2').val(this_code);
+        $('#shenpi_status2').val(this_status);
+        $('#shenpi_auditors2').val(aidList.join(','));
+        $('#shenpi-list').html(html);
+        setTimeout(function () { $("#shenpi-list [data-toggle='tooltip']").tooltip(); },800);
+    });
+
+    $('#save-other-shenpi').click(function () {
+        $(this).attr('disabled', true);
+        const num = $('#shenpi-list input:checked').length;
+        if (num < 1) {
+            toastr.warning('请选择需要设置审批同步的流程');
+            return;
+        }
+        const data = {
+            type: 'copy2os',
+            status: parseInt($('#shenpi_status2').val()),
+            code: $('#shenpi_code2').val(),
+        };
+        if(data.status !== shenpi_status.gdspl) {
+            data.aidList = $('#shenpi_auditors2').val();
+        }
+        // 获取已选中的标段
+        const shenpiList = [];
+        for (let i = 0; i < num; i++) {
+            const code = $('#shenpi-list input:checked').eq(i).data('code');
+            shenpiList.push(code);
+        }
+        data.shenpiList = shenpiList.join(',');
+        postData('/tender/' + cur_tenderid + '/shenpi/audit/save', data, function () {
+            toastr.success('设置成功');
+            setTimeout(function () {
+                window.location.reload();
+            }, 1000)
+        })
+    });
 });

+ 49 - 1
app/service/shenpi_audit.js

@@ -89,7 +89,7 @@ module.exports = app => {
                     if (shenpi_status !== shenpiConst.sp_status.sqspr) {
                         await transaction.delete(this.tableName, { tid: t.id, sp_type: shenpiConst.sp_type[data.code], sp_status: shenpi_status });
                         for (const aid of data.aidList.split(',')) {
-                            if (aid !== t.user_id || (aid === t.user_id && canYB)) {
+                            if (parseInt(aid) !== t.user_id || (parseInt(aid) === t.user_id && canYB)) {
                                 const insertData = {
                                     tid: t.id,
                                     sp_type: shenpiConst.sp_type[data.code],
@@ -110,6 +110,54 @@ module.exports = app => {
                 throw err;
             }
         }
+
+        async copyAudit2otherShenpi(data) {
+            const transaction = await this.db.beginTransaction();
+            try {
+                const shenpi_status = parseInt(data.status);
+                // 1.修改当前审批到它的tender_info里
+                // 2.删除相同审批状态的shenpiAudit
+                // 3.添加新的shenpiAudit(还要针对该标段是否为原报进行处理)
+                const insertList = [];
+                const needYB = ['ledger', 'revise', 'change'];
+                const shenpiInfo = await this.ctx.service.tenderInfo.getTenderShenpiInfo(this.ctx.tender.id);
+                for (const code of data.shenpiList.split(',')) {
+                    // 把当前审批状态复制到其他标段里
+                    if (shenpiInfo[code] !== shenpi_status) {
+                        shenpiInfo[code] = shenpi_status;
+                    }
+                    if (shenpiInfo[code] !== shenpiConst.sp_status.sqspr) {
+                        await transaction.delete(this.tableName, { tid: this.ctx.tender.id, sp_type: shenpiConst.sp_type[code], sp_status: shenpiInfo[code] });
+                        for (const aid of data.aidList.split(',')) {
+                            if (parseInt(aid) !== this.ctx.tender.data.user_id || (parseInt(aid) === this.ctx.tender.data.user_id && needYB.indexOf(code) !== -1)) {
+                                const insertData = {
+                                    tid: this.ctx.tender.id,
+                                    sp_type: shenpiConst.sp_type[code],
+                                    sp_status: shenpi_status,
+                                    audit_id: parseInt(aid),
+                                };
+                                insertList.push(insertData);
+                            }
+                        }
+                    }
+                }
+                await transaction.update(this.ctx.service.tenderInfo.tableName,
+                    {
+                        shenpi: JSON.stringify(shenpiInfo),
+                    },
+                    {
+                        where: {
+                            tid: this.ctx.tender.id,
+                        },
+                    });
+                if (insertList.length > 0) await transaction.insert(this.tableName, insertList);
+                await transaction.commit();
+                return true;
+            } catch (err) {
+                await transaction.rollback();
+                throw err;
+            }
+        }
     }
 
     return ShenpiAudit;

+ 3 - 1
app/view/tender/shenpi.ejs

@@ -13,8 +13,9 @@
                     <div class="col-7">
                         <% for (const sp of shenpi.sp_lc) { %>
                             <div class="card mb-3">
-                                <div class="card-body">
+                                <div class="card-body <%- sp.code %>_div">
                                     <a class="pull-right set-otherTender" data-name="<%- sp.name %>" data-code="<%- sp.code %>" href="#batch" data-toggle="modal" data-target="#batch">设置其他标段</a>
+                                    <a class="pull-right set-otherShenpi mr-3" data-name="<%- sp.name %>" data-code="<%- sp.code %>" href="#batch2" data-toggle="modal" data-target="#batch2">设置其他流程</a>
                                     <h5 class="card-title"><%- sp.name %></h5>
                                     <div class="form-group">
                                         <div class="form-group form-check">
@@ -140,6 +141,7 @@
 </div>
 <script src="/public/js/sub_menu.js"></script>
 <script>
+    const sp_lc = JSON.parse('<%- JSON.stringify(shenpi.sp_lc) %>');
     const sp_type = JSON.parse('<%- JSON.stringify(shenpi.sp_type) %>');
     const sp_status = JSON.parse('<%- JSON.stringify(shenpi.sp_status) %>');
     const sp_status_list = JSON.parse('<%- JSON.stringify(shenpi.sp_status_list) %>');

+ 59 - 0
app/view/tender/shenpi_modal.ejs

@@ -15,6 +15,65 @@
                 <input type="hidden" id="shenpi_code" value="">
                 <input type="hidden" id="shenpi_status" value="">
                 <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>
+                <button type="button" class="btn btn-sm btn-primary" id="save-other-tender">确认</button>
+            </div>
+        </div>
+    </div>
+</div>
+<!--设置其他流程-->
+<div class="modal fade" id="batch2" 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">
+                <div class="alert alert-warning">将「<span id="shenpi-name2"></span>」设置至其他流程</div>
+                <div class="modal-height-300" id="shenpi-list">
+                    <table class="table table-hover table-bordered">
+                        <thead>
+                        <th>名称</th>
+                        <th width="100">审批流程</th>
+                        <th width="40">选择</th>
+                        </thead>
+                        <tr>
+                            <td>预付款审批</td>
+                            <td>固定流程<i class="fa fa-question-circle text-primary" data-container="body" data-toggle="tooltip" data-placement="bottom" data-original-title="王五-张三-李四"></i></td>
+                            <td></td>
+                        </tr>
+                        <tr>
+                            <td>台帐审批</td>
+                            <td>固定流程<i class="fa fa-question-circle text-primary" data-container="body" data-toggle="tooltip" data-placement="bottom" data-original-title="王五-张三-李四"></i></td>
+                            <td><input type="checkbox"></td>
+                        </tr>
+                        <tr>
+                            <td>台帐修订</td>
+                            <td>固定流程<i class="fa fa-question-circle text-primary" data-container="body" data-toggle="tooltip" data-placement="bottom" data-original-title="王五-张三-李四"></i></td>
+                            <td><input type="checkbox"></td>
+                        </tr>
+                        <tr>
+                            <td>计量期审批</td>
+                            <td>固定流程<i class="fa fa-question-circle text-primary" data-container="body" data-toggle="tooltip" data-placement="bottom" data-original-title="王五-张三-李四"></i></td>
+                            <td><input type="checkbox"></td>
+                        </tr>
+                        <tr>
+                            <td>工程变更审批</td>
+                            <td>固定流程<i class="fa fa-question-circle text-primary" data-container="body" data-toggle="tooltip" data-placement="bottom" data-original-title="王五-张三-李四"></i></td>
+                            <td><input type="checkbox"></td>
+                        </tr>
+                        <tr>
+                            <td>材料调差审批</td>
+                            <td>固定流程<i class="fa fa-question-circle text-primary" data-container="body" data-toggle="tooltip" data-placement="bottom" data-original-title="王五-张三-李四"></i></td>
+                            <td><input type="checkbox"></td>
+                        </tr>
+                    </table>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <input type="hidden" id="shenpi_auditors2" value="">
+                <input type="hidden" id="shenpi_code2" value="">
+                <input type="hidden" id="shenpi_status2" value="">
+                <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>
                 <button type="button" class="btn btn-sm btn-primary" id="save-other-shenpi">确认</button>
             </div>
         </div>