Selaa lähdekoodia

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

Tony Kang 2 vuotta sitten
vanhempi
commit
2da988f30c

+ 18 - 1
app/controller/payment_controller.js

@@ -508,7 +508,10 @@ module.exports = app => {
             // 获取报表表单列表
             if (ctx.payment.auditPermission.view_all || ctx.tender.uid === ctx.session.sessionUser.accountId || formProcess) {
                 const rptProject = await ctx.service.rptTreeNode.getDataByCondition({ pid: ctx.session.sessionProject.id, name: '01.支付审批报表' });
-                const rptProjectList = rptProject && rptProject.items ? JSON.parse(rptProject.items) : [];
+                const rptProjectList = [];
+                const newRptList = rptProject && rptProject.items ? JSON.parse(rptProject.items) : [];
+                ctx.rptListNum = 0;
+                await this.getNewRptProjectList(ctx, newRptList, rptProjectList, 1);
                 const tenderRptList = await ctx.service.paymentTenderRpt.getProcessList(ctx.tender.id);
                 if (tenderRptList === -1) {
                     throw '未配置审批模块,请联系管理员处理';
@@ -517,6 +520,20 @@ module.exports = app => {
             }
             return await ctx.service.paymentTenderRpt.getList(ctx.tender.id, ctx.session.sessionUser.accountId);
         }
+        // 循环获取到到rptProject
+        async getNewRptProjectList(ctx, newRptList, rptProjectList, level = 1) {
+            if (newRptList.length > 0) {
+                for (const r of newRptList) {
+                    r.level = level;
+                    r.index = ctx.rptListNum;
+                    ctx.rptListNum = ctx.rptListNum + 1;
+                    rptProjectList.push(r);
+                    if (r.items && r.items.length > 0) {
+                        await this.getNewRptProjectList(ctx, r.items, rptProjectList, level + 1);
+                    }
+                }
+            }
+        }
 
         async process(ctx) {
             try {

+ 4 - 2
app/lib/rm/material.js

@@ -325,16 +325,18 @@ class ReportMemoryMaterial {
                     return m.gcl_id === x.org_gcl_id && m.xmj_id === x.id && (x.mx_id && x.mx_id !== x.id  ? x.mx_id === m.mx_id : true);
                 });
                 x.is_join = !mnj;
-                if (mnj) continue;
                 const list = materialGl.filter(gl => {
                     return gl.gcl_id === x.org_gcl_id && gl.xmj_id === x.id && (x.mx_id && x.mx_id !== x.id ? x.mx_id === gl.mx_id : true);
                 });
+                list.forEach(l => { l.gather_gcl_id = x.gcl_id});
+
+                if (mnj) continue;
                 for (const l of list) {
-                    x.gather_gcl_id = x.gcl_id;
                     x.jiacha = helper.add(x.jiacha, helper.mul(helper.mul(x.gather_qty, l.quantity), l.m_spread));
                 }
                 x.jiacha = helper.round(x.jiacha, decimal.tp);
                 g.jiacha = helper.add(g.jiacha, x.jiacha);
+                g.jiacha_qty = helper.add(g.jiacha_qty, x.gather_qty);
             }
         }
         return [gatherUtil.gclList, gatherUtil.leafXmjs];

+ 10 - 2
app/lib/rpt_data_analysis.js

@@ -1914,7 +1914,8 @@ const masterCross = {
             masterKey: 'id', subKey: 'gather_gcl_id', gatherKey: 'mb_id',
             prefix: 's_',
             fields: ['code', 'name', 'units'],
-            gatherFields: ['quantity'],
+            quoteFields: ['quantity'],
+            gatherFields: [],
         },
         target: 'master_converse'
     },
@@ -1937,14 +1938,21 @@ const masterCross = {
             for (const f of options.main.fields) {
                 temp[options.main.prefix + f] = m[f];
             }
-            const rela = subTable.filter(x => { return x[options.sub.subKey] === m[options.masterKey]; });
+            const rela = subTable.filter(x => { return x[options.sub.subKey] === m[options.sub.masterKey]; });
             for (const cd of converseData) {
                 const nd = JSON.parse(JSON.stringify(temp));
+                nd.quote = false;
                 for (const prop in cd) {
                     nd[options.sub.prefix + prop] = cd[prop];
                 }
                 rela.forEach(x => {
                     if (x[options.sub.gatherKey] !== cd[options.sub.gatherKey]) return;
+                    if (!nd.quote) {
+                        for (const f of options.sub.quoteFields) {
+                            nd[options.sub.prefix + f] = x[f];
+                        }
+                        nd.quote = true;
+                    }
                     for (const f of options.sub.gatherFields) {
                         nd[options.sub.prefix + f] = ctx.helper.add(nd[options.sub.prefix + f], x[f]);
                     }

+ 37 - 1
app/public/js/payment_process.js

@@ -3,8 +3,12 @@ $(function () {
 
     // 全选报表
     $('#select_all_rpt_checkbox').click(function () {
-        $('#rpt_table input[name="rptId[]"]').prop('checked', true);
         $(this).prop('checked', false);
+        $('#rpt_table input[name="rptId[]"]').each(function () {
+            if (parseInt($(this).val()) !== -1) {
+                $(this).prop('checked', true);
+            }
+        });
     });
 
     $('#add_rpt_btn').click(function () {
@@ -350,5 +354,37 @@ $(function () {
             '                                        </span>\n' +
             '                                        </li>';
         return html;
+    };
+
+    $('#add-rpt').on('show.bs.modal', function () {
+        $('#rpt-table').find('input:checked:not(:disabled)').prop('checked', false);
+        $('#rpt-table').find('input:not(:disabled)').each(function () {
+            if (_.findIndex(tenderRptList, { rpt_id: parseInt($(this).val()) }) !== -1) {
+                $(this).prop('checked', true);
+            }
+        });
+    });
+
+    $('#rpt_table input').on('click', function () {
+        if ($(this).is(':checked') && parseInt($(this).val()) === -1) {
+            $(this).prop('checked', false);
+            const index = $("#rpt_table input").index(this);
+            console.log(rptProjectList[index]);
+            // 循环选中当前子项值
+            checkedRptProjectList(rptProjectList[index].items);
+        }
+    });
+
+    function checkedRptProjectList(items) {
+        if (items && items.length > 0) {
+            for (const item of items) {
+                if (item.ID !== -1 && item.items === null) {
+                    console.log(item);
+                    $('#rpt_table input').eq(item.index).prop('checked', true);
+                } else {
+                    checkedRptProjectList(item.items);
+                }
+            }
+        }
     }
 });

+ 2 - 0
app/view/payment/process.ejs

@@ -141,4 +141,6 @@
     const accountList = JSON.parse(unescape('<%- escape(JSON.stringify(accountList)) %>'));
     const cur_uid = parseInt('<%- ctx.tender.uid %>');
     let tenderRptList = JSON.parse(unescape('<%- escape(JSON.stringify(tenderRptList)) %>'));
+    const rptProjectList = JSON.parse(unescape('<%- escape(JSON.stringify(rptProjectList)) %>'));
+    console.log(rptProjectList);
 </script>

+ 6 - 4
app/view/payment/process_modal.ejs

@@ -4,7 +4,7 @@
             <div class="modal-header">
                 <h5 class="modal-title">添加表单</h5>
             </div>
-            <div class="modal-body">
+            <div class="modal-body" style="max-height:800px;overflow: auto">
                 <table id="rpt-table" class="table table-bordered">
                     <thead>
                     <tr>
@@ -15,9 +15,11 @@
                     <tbody id="rpt_table">
                     <% for (const rpt of rptProjectList) { %>
                     <tr>
-                        <td class="text-center"><input type="checkbox" name="rptId[]" data-name="<%- rpt.name %>" value="<%- rpt.ID %>"
-                                                       <% if (ctx.helper._.findIndex(tenderRptList, { rpt_id: rpt.ID }) !== -1) { %>checked<% } %> <% if (rpt.had_rpt) { %>disabled<% } %>></td>
-                        <td><%- rpt.name %></td>
+                        <td class="text-center">
+                            <input type="checkbox" name="rptId[]" data-name="<%- rpt.name %>" value="<%- rpt.ID %>"
+                                                       <% if (ctx.helper._.findIndex(tenderRptList, { rpt_id: rpt.ID }) !== -1) { %>checked<% } %> <% if (rpt.had_rpt) { %>disabled<% } %>>
+                        </td>
+                        <td class="in-<%- rpt.level %>"><% if (rpt.items && rpt.items.length > 0) { %><i class="fa fa-folder-o"></i> <% } %><%- rpt.name %></td>
                     </tr>
                     <% } %>
                     </tbody>