Przeglądaj źródła

合同支付,导入材差数据

MaiXinRong 7 godzin temu
rodzic
commit
305d619108

+ 6 - 0
app/controller/tender_controller.js

@@ -1768,6 +1768,12 @@ module.exports = app => {
                         case 'tender_info':
                             responseData.data[f] = ctx.tender.info;
                             break;
+                        case 'materials':
+                            responseData.data[f] = await this.ctx.service.material.getAllDataByCondition({
+                                where: { tid: ctx.tender.id, status: auditConst.material.status.checked },
+                                orders: [['order', 'desc']],
+                            });
+                            break;
                         default:
                             throw '未知数据类型';
                     }

+ 66 - 0
app/public/js/shares/import_material.js

@@ -0,0 +1,66 @@
+const importMaterial = (function(){
+    let importNode, materials, callback;
+    const getMaterialHtml = function() {
+        const html = materials.map(x => {
+            const mh = [];
+            mh.push('<tr>');
+            mh.push(`<td class="text-center"><input type="checkbox" mid="${x.id}"></td>`);
+            mh.push(`<td class="text-center">${x.m_order}</td>`);
+            mh.push(`<td class="text-center">${x.s_order}</td>`);
+            mh.push(`<td class="text-right">${x.info_tp}</td>`);
+            mh.push(`<td class="text-right">${x.info_tax_tp}</td>`);
+            mh.push(`<td class="text-right">${x.index_tp}</td>`);
+            mh.push(`<td class="text-right">${x.index_tax_tp}</td>`);
+            mh.push(`<td class="text-right">${x.sum_tp}</td>`);
+            mh.push(`<td class="text-right">${x.sum_tax_tp}</td>`);
+            mh.push('</tr>');
+            return mh.join('');
+        });
+        return html.join('');
+    };
+    const analysisMaterial = function(data) {
+        materials = data.map(x => {
+            const md = { id: x.id, order: x.order, m_order: `第${x.order}期`, s_order: x.s_order };
+            md.info_tp = x.m_tp || 0;
+            md.info_tax_tp = x.material_tax ? (x.m_tax_tp || x.m_tp || 0) : (x.rate_tp || 0);
+            md.index_tp = x.ex_tp || 0;
+            md.index_tax_tp = x.ex_tax_tp || 0;
+            md.sum_tp = ZhCalc.add(md.info_tp, md.index_tp);
+            md.sum_tax_tp =  ZhCalc.add(md.info_tax_tp, md.index_tax_tp);
+            return md;
+        });
+        $('#import-material-list').html(getMaterialHtml())
+    };
+    const init = async function() {
+        if (materials) return;
+
+        const tenderId = window.location.pathname.split('/')[2];
+        postData(`/tender/${tenderId}/load`, { filter: 'materials' }, function(data) {
+            analysisMaterial(data.materials);
+        });
+        $('#import-material-ok').click(function() {
+            const selects = $('input[mid]:checked');
+            if (selects.length === 0) {
+                toastr.warning('请选择材料调差');
+                return;
+            }
+            const selectId = [];
+            selects.each(function(){ selectId.push(this.getAttribute('mid')); });
+            const tpField = $('input[name=im-type]:checked').val() + ($('#im-data-tax')[0].checked ? '_tax_tp' : '_tp');
+            const tpFieldStr = '{' + $('input[name=im-type]:checked').attr('type-name') + '}' + ($('#im-data-tax')[0].checked ? '{{含税金额}}' : '{{金额}}');
+            const selectMaterials = materials.filter(x => { return selectId.indexOf(x.id + '') >= 0 });
+            const tp = ZhCalc.sum(selectMaterials.map(y => { return y[tpField]; }));
+            const memo = '第{' + selectMaterials.map(y => { return y.order; }).join(',') + `}期材差-${tpFieldStr}`;
+            callback(importNode, tp, memo);
+            $('#import-material').modal('hide');
+        });
+    };
+    const show = async function(setting) {
+        importNode = setting.relaNode;
+        callback = setting.callback;
+        await init();
+        $('input[mid]').attr('checked', false);
+        $('#import-material').modal('show');
+    };
+    return { show }
+})();

+ 25 - 0
app/public/js/stage_pay.js

@@ -962,6 +962,17 @@ $(document).ready(() => {
                 }
             }
         },
+        importMaterial: function(node, tp, memo) {
+            const select = SpreadJsObj.getSelectObject(paySheet);
+            const data = { type: 'stage', updateData: { pid: select.pid, tp, postil: memo } };
+            postData(window.location.pathname + '/save', data, function (result) {
+                loadUpdateDealPays(result);
+                SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
+                paySpreadObj.loadExprToInput();
+            }, function () {
+                SpreadJsObj.reLoadRowData(info.sheet, info.row);
+            });
+        }
     };
     paySpreadObj.refreshActn();
     paySpread.bind(spreadNS.Events.SelectionChanged, paySpreadObj.selectionChanged);
@@ -1227,6 +1238,20 @@ $(document).ready(() => {
                         SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
                     });
                 }
+            },
+            'importMaterial': {
+                name: '导入材差数据',
+                visible: function(key, opt) {
+                    const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
+                    return !payBase.isSpecial(select) && !readOnly;
+                },
+                callback: function(key, opt) {
+                    const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
+                    importMaterial.show({
+                        relaNode: select,
+                        callback: paySpreadObj.importMaterial,
+                    })
+                },
             }
         }
     });

+ 48 - 0
app/view/shares/import_material_modal.ejs

@@ -0,0 +1,48 @@
+<div class="modal fade" id="import-material" data-backdrop="static">
+    <div class="modal-dialog modal-xl" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">导入材差数据</h5>
+            </div>
+            <div class="modal-body">
+                <div class="" id="im-type">
+                    <div class="form-row align-items-center mb-2">
+                        <div class="col-auto"><span class="form-check-label">导入数据:</span></div>
+                        <div class="col-auto">
+                            <div class="form-check form-check-inline">
+                                <input class="form-check-input" type="radio" id="im-type-info" value="info" type-name="信息价调差" name="im-type" checked="">
+                                <label class="form-check-label" for="im-type-info">信息价调差</label>
+                            </div>
+                            <div class="form-check form-check-inline">
+                                <input class="form-check-input" type="radio" id="im-type-index" value="index" type-name="指数法调差" name="im-type">
+                                <label class="form-check-label" for="im-type-index">指数法调差</label>
+                            </div>
+                            <div class="form-check form-check-inline">
+                                <input class="form-check-input" type="radio" id="im-type-sum" value="sum" type-name="合计" name="im-type">
+                                <label class="form-check-label" for="im-type-sum">合计</label>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="form-row align-items-center mb-2">
+                        <div class="col-auto"><span class="form-check-label">数据类型:</span></div>
+                        <div class="form-check form-check-inline ml-2">
+                            <input class="form-check-input" type="checkbox" id="im-data-tax">
+                            <label class="form-check-label" for="im-data-tax">含税价</label>
+                        </div>
+                    </div>
+                </div>
+                <div class="modal-height-500 scroll-y">
+                    <table class="table table-sm table-bordered table-hover" style="word-break:break-all; table-layout: fixed">
+                        <tr class="text-center"><th rowspan="2">选择</th><th rowspan="2">期数</th><th rowspan="2">关联计量</th><th colspan="2">信息价调差</th><th colspan="2">指数法调差</th><th colspan="2">合计</th></tr>
+                        <tr class="text-center"><th>价差费用</th><th>含税价</th><th>价差费用</th><th>含税价</th><th>价差费用</th><th>含税价</th></tr>
+                        <tbody id="import-material-list" class="list-table"></tbody>
+                    </table>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">取消</button>
+                <button type="button" class="btn btn-primary btn-sm" id="import-material-ok">确定</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 1 - 0
app/view/stage/pay_modal.ejs

@@ -125,4 +125,5 @@
         </div>
     </div>
 </div>
+<% include ../shares/import_material_modal.ejs %>
 <% include ./audit_modal.ejs %>

+ 1 - 0
config/web.js

@@ -459,6 +459,7 @@ const JsFiles = {
                     '/public/js/spreadjs_rela/spreadjs_zh.js',
                     '/public/js/shares/sjs_setting.js',
                     '/public/js/shares/cs_tools.js',
+                    '/public/js/shares/import_material.js',
                     '/public/js/stage_pay.js',
                     '/public/js/stage_audit.js',
                 ],