Ver código fonte

防止多次点击

laiguoran 5 anos atrás
pai
commit
352e8b5c05

+ 6 - 0
app/controller/material_controller.js

@@ -218,8 +218,14 @@ module.exports = app => {
             try {
                 await this._getMaterialAuditViewData(ctx);
                 const renderData = await this._getDefaultRenderData(ctx);
+                // 根据期判断需要获取的工料信息值
                 // 取所有工料表
                 renderData.materialBillsData = await ctx.service.materialBills.getAllDataByCondition({ where: { tid: ctx.tender.id } });
+                // 取截取上期的调差金额
+                for (const mindex in renderData.materialBillsData) {
+                    const pre_tp = renderData.materialBillsData[mindex].pre_tp !== null ? renderData.materialBillsData[mindex].pre_tp.split(',')[ctx.material.order - 1] : null;
+                    renderData.materialBillsData[mindex].pre_tp = pre_tp;
+                }
                 // 取所有已被调用的工料清单表
                 renderData.materialListData = await ctx.service.materialList.getAllDataByCondition({ where: { tid: ctx.tender.id } });
                 renderData.materialType = JSON.stringify(materialConst);

+ 41 - 8
app/public/js/material.js

@@ -28,15 +28,16 @@ $(document).ready(() => {
             {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
             {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 180, formatter: '@', readOnly: 'readOnly.isEdit'},
             {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
-            {title: '规格', colSpan: '1', rowSpan: '2', field: 'spec', hAlign: 0, width: 230, formatter: '@', readOnly: 'readOnly.isEdit'},
+            {title: '规格', colSpan: '1', rowSpan: '2', field: 'spec', hAlign: 0, width: 180, formatter: '@', readOnly: 'readOnly.isEdit'},
             {title: '工料分类', colSpan: '1', rowSpan: '2', field: 'm_type', hAlign: 0, width: 60, readOnly: 'readOnly.isEdit', cellType: 'customizeCombo', comboItems: materialType.m_type, cellTypeKey: 2},
-            {title: '本期应耗数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 100, type: 'Number', readOnly: 'readOnly.isEdit'},
+            {title: '本期应耗数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 100, type: 'Number', readOnly: true},
             {title: '基准价', colSpan: '1', rowSpan: '2', field: 'basic_price', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit'},
             {title: '基准时间', colSpan: '1', rowSpan: '2', field: 'basic_times', hAlign: 0, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
             {title: '本期信息价|单价', colSpan: '3|1', rowSpan: '1|1', field: 'msg_tp', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit'},
             {title: '|时间', colSpan: '|1', rowSpan: '|1', field: 'msg_times', hAlign: 0, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
             {title: '|价差', colSpan: '1', rowSpan: '1|1', field: 'msg_spread', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.msg_spread'},
-            {title: '本期材料调差|风险幅度(%)', colSpan: '3|1', rowSpan: '1|1', field: 'm_risk', hAlign: 2, width: 100, type: 'Number', readOnly: 'readOnly.isEdit'},
+            {title: '本期材料调差|上涨幅度(%)', colSpan: '4|1', rowSpan: '1|1', field: 'm_up_risk', hAlign: 2, width: 100, type: 'Number', readOnly: 'readOnly.isEdit'},
+            {title: '|下跌幅度(%)', colSpan: '|1', rowSpan: '|1', field: 'm_down_risk', hAlign: 2, width: 100, type: 'Number', readOnly: 'readOnly.isEdit'},
             {title: '|有效价差', colSpan: '|1', rowSpan: '|1', field: 'm_spread', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.m_spread'},
             {title: '|调整金额', colSpan: '|1', rowSpan: '1|1', field: 'm_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.m_tp'},
             {title: '截止上期调差金额', colSpan: '1', rowSpan: '2', field: 'pre_tp', hAlign: 2, width: 120, type: 'Number', readOnly: true},
@@ -62,15 +63,15 @@ $(document).ready(() => {
     const materialCol = {
         getValue: {
             msg_spread: function (data) {
-                return ZhCalc.sub(data.msg_tp, data.basic_price);
+                return ZhCalc.round(ZhCalc.sub(data.msg_tp, data.basic_price), 2);
             },
             m_spread : function (data) {
-                const cor = ZhCalc.mul(data.basic_price, ZhCalc.div(data.m_risk, 100));
                 const msg_spread = materialCol.getValue.msg_spread(data);
-                return Math.abs(msg_spread) > Math.abs(cor) ? (msg_spread > 0 ? ZhCalc.sub(msg_spread, cor) : ZhCalc.add(msg_spread, cor)) : 0;
+                const cor = msg_spread >= 0 ? ZhCalc.mul(data.basic_price, ZhCalc.div(data.m_up_risk, 100)) : ZhCalc.mul(data.basic_price, ZhCalc.div(data.m_down_risk, 100));
+                return Math.abs(msg_spread) > Math.abs(cor) ? (msg_spread > 0 ? ZhCalc.round(ZhCalc.sub(msg_spread, cor), 2) : ZhCalc.round(ZhCalc.add(msg_spread, cor), 2)) : 0;
             },
             m_tp: function (data) {
-                return ZhCalc.mul(materialCol.getValue.m_spread(data), data.quantity);
+                return ZhCalc.round(ZhCalc.mul(materialCol.getValue.m_spread(data), data.quantity), 2);
             }
         },
         readOnly: {
@@ -151,6 +152,12 @@ $(document).ready(() => {
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         return;
                     }
+                    const num = parseFloat(validText);
+                    if (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num)) {
+                        toastr.error('请输入大于0并且小于3位小数的浮点数');
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
                 }
                 if (col.field === 'msg_tp') {
                     if (isNaN(validText)) {
@@ -158,14 +165,40 @@ $(document).ready(() => {
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         return;
                     }
+                    const num = parseFloat(validText);
+                    if (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num)) {
+                        toastr.error('请输入大于0并且小于3位小数的浮点数');
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
                 }
-                if (col.field === 'm_risk') {
+                if (col.field === 'm_up_risk') {
                     // 只能输入正整数
                     if (isNaN(validText)) {
                         toastr.error('不能输入其它非数字类型字符');
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         return;
                     }
+                    const num = parseFloat(validText);
+                    if (num < 0 || num > 100 || !/^\d+$/.test(num)) {
+                        toastr.error('只能输入0-100的正整数');
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
+                }
+                if (col.field === 'm_down_risk') {
+                    // 只能输入正整数
+                    if (isNaN(validText)) {
+                        toastr.error('不能输入其它非数字类型字符');
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
+                    const num = parseFloat(validText);
+                    if (num < 0 || num > 100 || !/^\d+$/.test(num)) {
+                        toastr.error('只能输入0-100的正整数');
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
                 }
 
                 select[col.field] = validText;

+ 1 - 0
app/public/js/measure_stage.js

@@ -82,5 +82,6 @@ $('a[data-target="#sp-list" ]').on('click', function () {
 
 function checkValidForm() {
     $('#add-stage-btn').attr('disabled', true);
+    $('#hide-all').show();
     return true;
 }

+ 2 - 0
app/public/js/tender_list.js

@@ -417,6 +417,7 @@ $(document).ready(() => {
             }
             data.category.push(cate);
         }
+        $('#hide-all').show();
         postData('/list/add', data, function (result) {
             tenders.push(result);
             initTenderTree();
@@ -424,6 +425,7 @@ $(document).ready(() => {
             bindTenderUrl();
             $('#add-bd').modal('hide');
             $('[name=name]', '#add-bd').val('');
+            $('#hide-all').hide();
         });
     });
 });

+ 10 - 2
app/view/material/info.ejs

@@ -33,14 +33,22 @@
                             <div class="input-group-prepend">
                                 <span class="input-group-text" id="basic-addon1">增税税率</span>
                             </div>
-                            <select class="form-control col-1"><option>9%</option><option>10%</option><option>11%</option></select>
+                            <select class="form-control col-1" id="changeRate">
+                                <% if (ctx.material.readOnly) { %>
+                                <option value="9" <% if(ctx.material.rate === 9) { %>selected<% } %>>9%</option>
+                                <option value="10" <% if(ctx.material.rate === 10) { %>selected<% } %>>10%</option>
+                                <option value="11" <% if(ctx.material.rate === 11) { %>selected<% } %>>11%</option>
+                                <% } else { %>
+                                <option value="<%= ctx.material.rate %>" selected><%= ctx.material.rate %>%</option>
+                                <% } %>
+                            </select>
                         </div>
                     </div>
                     <div class="sp-wrap">
                         <div class="col-4 p-0">
                             <table class="table table-sm table-bordered">
                                 <tr><th></th><th>本期金额</th><th>截止本期金额</th></tr>
-                                <tr><td>材料价差费用</td><td></td><td></td></tr>
+                                <tr><td>材料价差费用</td><td><%= ctx.material.m_tp %></td><td><%= ctx.material.pre_tp %></td></tr>
                                 <tr><td>材料价差费用(含税)</td><td></td><td></td></tr>
                             </table>
                         </div>