浏览代码

调差税功能更新

laiguoran 3 年之前
父节点
当前提交
a4d79986cd

+ 1 - 1
app/controller/material_controller.js

@@ -975,7 +975,7 @@ module.exports = app => {
                         if (ctx.material.readOnly) {
                             throw '无权操作';
                         }
-                        await ctx.service.material.changeRate(data.rate);
+                        await ctx.service.material.changeExponentRate(data.rate);
                         break;
                     case 'paste':
                         [ex_tp, ex_expr] = await ctx.service.materialExponent.saveDatas(data.updateData);

+ 59 - 13
app/public/js/material.js

@@ -78,7 +78,7 @@ function resetTpTable() {
         $('#tax_rate_set').find('td').eq(1).text(ZhCalc.round(m_tax_tp, materialDecimal.tp));
         $('#tax_rate_set').find('td').eq(2).text(ZhCalc.round(ZhCalc.add(m_tax_pre_tp, m_tax_tp), materialDecimal.tp));
     } else {
-        const rate = $('#changeRate').val();
+        const rate = $('#rateInput').val();
         const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), materialDecimal.tp);
         const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), materialDecimal.tp);
         $('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
@@ -1063,19 +1063,65 @@ $(document).ready(() => {
                 },
             }
         });
-        $('#changeRate').change(function () {
-            const rate = parseInt($(this).val());
-            postData(window.location.pathname + '/save', { type:'rate', rate: rate }, function (result) {
-                const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), materialDecimal.tp);
-                const exbqhs = ZhCalc.round(ZhCalc.mul(ex_tp, 1+rate/100), materialDecimal.tp);
-                const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), materialDecimal.tp);
-                const exjzbqhs = ZhCalc.round(ZhCalc.add(ex_pre_tp_hs, exbqhs), materialDecimal.tp);
-                $('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
-                $('#rate_set').find('td').eq(2).text(jzbqhs !== 0 ? jzbqhs : '');
-                $('#rate_set').find('td').eq(3).text(exbqhs !== 0 ? exbqhs : '');
-                $('#rate_set').find('td').eq(4).text(exjzbqhs !== 0 ? exjzbqhs : '');
-            });
+        $('.changeRate').click(function () {
+            $('#rateInput').val(parseInt($(this).data('value')));
+            $('#rateInput').siblings('.dropdown-menu').hide();
+        });
+        $('#rateInput').click(function () {
+            $(this).siblings('.dropdown-menu').show();
+        })
+        // 回车提交
+        $('#rateInput').on('keypress', function () {
+            if(window.event.keyCode === 13) {
+                $(this).blur();
+            }
+        });
+        $('#rateInput').blur(function () {
+            const _self = $(this);
+            setTimeout(function () {
+                let rate = parseFloat(_self.val());
+                if (_.isNaN(rate)) {
+                    toastr.error('请输入0-100之前的整数值');
+                    $('#rateInput').val(materialRate);
+                    return;
+                }
+                rate = _.round(rate);
+                if(rate < 0 || rate > 100) {
+                    toastr.error('请输入0-100之前的整数值');
+                    $('#rateInput').val(materialRate);
+                    return;
+                }
+                $('#rateInput').siblings('.dropdown-menu').hide();
+                console.log(rate, materialRate);
+                if (rate !== materialRate) {
+                    postData(window.location.pathname + '/save', { type:'rate', rate: rate }, function (result) {
+                        const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), materialDecimal.tp);
+                        // const exbqhs = ZhCalc.round(ZhCalc.mul(ex_tp, 1+rate/100), materialDecimal.tp);
+                        const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), materialDecimal.tp);
+                        // const exjzbqhs = ZhCalc.round(ZhCalc.add(ex_pre_tp_hs, exbqhs), materialDecimal.tp);
+                        $('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
+                        $('#rate_set').find('td').eq(2).text(jzbqhs !== 0 ? jzbqhs : '');
+                        // $('#rate_set').find('td').eq(3).text(exbqhs !== 0 ? exbqhs : '');
+                        // $('#rate_set').find('td').eq(4).text(exjzbqhs !== 0 ? exjzbqhs : '');
+                        materialRate = rate;
+                        $('#rateInput').val(rate);
+                    });
+                }
+            }, 500);
         });
+        // $('#changeRate').change(function () {
+        //     const rate = parseInt($(this).val());
+        //     postData(window.location.pathname + '/save', { type:'rate', rate: rate }, function (result) {
+        //         const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), materialDecimal.tp);
+        //         const exbqhs = ZhCalc.round(ZhCalc.mul(ex_tp, 1+rate/100), materialDecimal.tp);
+        //         const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), materialDecimal.tp);
+        //         const exjzbqhs = ZhCalc.round(ZhCalc.add(ex_pre_tp_hs, exbqhs), materialDecimal.tp);
+        //         $('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
+        //         $('#rate_set').find('td').eq(2).text(jzbqhs !== 0 ? jzbqhs : '');
+        //         $('#rate_set').find('td').eq(3).text(exbqhs !== 0 ? exbqhs : '');
+        //         $('#rate_set').find('td').eq(4).text(exjzbqhs !== 0 ? exjzbqhs : '');
+        //     });
+        // });
 
         $('#expr_select button').on('click', function () {
             const code = $(this).text();

+ 62 - 15
app/public/js/material_exponent.js

@@ -13,7 +13,7 @@ function getPasteHint (str, row = '') {
     return returnObj;
 }
 function resetExTpTable() {
-    const rate = $('#changeRate').val();
+    const rate = $('#rateInput').val();
     const bqhs = ZhCalc.round(ZhCalc.mul(ex_tp, 1+rate/100), materialDecimal.tp);
     const jzbqhs = ZhCalc.round(ZhCalc.add(ex_pre_tp_hs, bqhs), materialDecimal.tp);
     $('#tp_set').find('td').eq(3).text(ZhCalc.round(ex_tp, materialDecimal.tp));
@@ -523,22 +523,69 @@ $(document).ready(() => {
             });
         });
 
-
-        $('#changeRate').change(function () {
-            const rate = parseInt($(this).val());
-            postData(window.location.pathname + '/save', { type:'rate', rate: rate }, function (result) {
-                const exbqhs = ZhCalc.round(ZhCalc.mul(ex_tp, 1+rate/100), materialDecimal.tp);
-                const exjzbqhs = ZhCalc.round(ZhCalc.add(ex_pre_tp_hs, exbqhs), materialDecimal.tp);
-                if (!materialTax) {
-                    const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), materialDecimal.tp);
-                    const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), materialDecimal.tp);
-                    $('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
-                    $('#rate_set').find('td').eq(2).text(jzbqhs !== 0 ? jzbqhs : '');
+        $('.changeRate').click(function () {
+            $('#rateInput').val(parseInt($(this).data('value')));
+            $('#rateInput').siblings('.dropdown-menu').hide();
+        });
+        $('#rateInput').click(function () {
+            $(this).siblings('.dropdown-menu').show();
+        })
+        // 回车提交
+        $('#rateInput').on('keypress', function () {
+            if(window.event.keyCode === 13) {
+                $(this).blur();
+            }
+        });
+        $('#rateInput').blur(function () {
+            const _self = $(this);
+            setTimeout(function () {
+                let rate = parseFloat(_self.val());
+                if (_.isNaN(rate)) {
+                    toastr.error('请输入0-100之前的整数值');
+                    $('#rateInput').val(materialRate);
+                    return;
                 }
-                $('#rate_set').find('td').eq(3).text(exbqhs !== 0 ? exbqhs : '');
-                $('#rate_set').find('td').eq(4).text(exjzbqhs !== 0 ? exjzbqhs : '');
-            });
+                rate = _.round(rate);
+                if(rate < 0 || rate > 100) {
+                    toastr.error('请输入0-100之前的整数值');
+                    $('#rateInput').val(materialRate);
+                    return;
+                }
+                $('#rateInput').siblings('.dropdown-menu').hide();
+                console.log(rate, materialRate);
+                if (rate !== materialRate) {
+                    postData(window.location.pathname + '/save', { type:'rate', rate: rate }, function (result) {
+                        const exbqhs = ZhCalc.round(ZhCalc.mul(ex_tp, 1+rate/100), materialDecimal.tp);
+                        const exjzbqhs = ZhCalc.round(ZhCalc.add(ex_pre_tp_hs, exbqhs), materialDecimal.tp);
+                        // if (!materialTax) {
+                        //     const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), materialDecimal.tp);
+                        //     const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), materialDecimal.tp);
+                        //     $('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
+                        //     $('#rate_set').find('td').eq(2).text(jzbqhs !== 0 ? jzbqhs : '');
+                        // }
+                        $('#rate_set').find('td').eq(3).text(exbqhs !== 0 ? exbqhs : '');
+                        $('#rate_set').find('td').eq(4).text(exjzbqhs !== 0 ? exjzbqhs : '');
+                        materialRate = rate;
+                        $('#rateInput').val(rate);
+                    });
+                }
+            }, 500);
         });
+        // $('#changeRate').change(function () {
+        //     const rate = parseInt($(this).val());
+        //     postData(window.location.pathname + '/save', { type:'rate', rate: rate }, function (result) {
+        //         const exbqhs = ZhCalc.round(ZhCalc.mul(ex_tp, 1+rate/100), materialDecimal.tp);
+        //         const exjzbqhs = ZhCalc.round(ZhCalc.add(ex_pre_tp_hs, exbqhs), materialDecimal.tp);
+        //         if (!materialTax) {
+        //             const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), materialDecimal.tp);
+        //             const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), materialDecimal.tp);
+        //             $('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
+        //             $('#rate_set').find('td').eq(2).text(jzbqhs !== 0 ? jzbqhs : '');
+        //         }
+        //         $('#rate_set').find('td').eq(3).text(exbqhs !== 0 ? exbqhs : '');
+        //         $('#rate_set').find('td').eq(4).text(exjzbqhs !== 0 ? exjzbqhs : '');
+        //     });
+        // });
     }
 
     $.divResizer({

+ 14 - 0
app/service/material.js

@@ -154,6 +154,7 @@ module.exports = app => {
             try {
                 if (preMaterial) {
                     newMaterial.rate = preMaterial.rate;
+                    newMaterial.exponent_rate = preMaterial.exponent_rate;
                     newMaterial.pre_tp = this.ctx.helper.add(preMaterial.m_tp, preMaterial.pre_tp);
                     newMaterial.ex_pre_tp = this.ctx.helper.add(preMaterial.ex_tp, preMaterial.ex_pre_tp);
                     newMaterial.m_tax_pre_tp = preMaterial.material_tax ? this.ctx.helper.add(preMaterial.m_tax_tp, preMaterial.m_tax_pre_tp) : preMaterial.m_tax_pre_tp;
@@ -311,6 +312,19 @@ module.exports = app => {
         }
 
         /**
+         * 修改增税税率
+         * @param {int} rate 税率
+         * @return {Promise<*>}
+         */
+        async changeExponentRate(rate) {
+            const updateData = {
+                id: this.ctx.material.id,
+                exponent_rate: rate,
+            };
+            return await this.db.update(this.tableName, updateData);
+        }
+
+        /**
          * 修改调差基数
          * @param {int} rate 税率
          * @return {Promise<*>}

+ 28 - 19
app/view/material/exponent.ejs

@@ -43,15 +43,23 @@
                             <div class="input-group-prepend">
                                 <span class="input-group-text" id="basic-addon1">增值税税率</span>
                             </div>
-                            <select class="form-control form-control-sm col-1" id="changeRate">
-                                <% if (!material.readOnly) { %>
-                                    <option value="9" <% if(material.rate === 9) { %>selected<% } %>>9%</option>
-                                    <option value="10" <% if(material.rate === 10) { %>selected<% } %>>10%</option>
-                                    <option value="11" <% if(material.rate === 11) { %>selected<% } %>>11%</option>
-                                <% } else { %>
-                                    <option value="<%= material.rate %>" selected><%= material.rate %>%</option>
-                                <% } %>
-                            </select>
+                            <input id="rateInput" class="form-control form-control-sm col-1" <% if (material.readOnly) { %>disabled<% } %> type="number" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" min="0" step="1" max="100" value="<%- material.exponent_rate %>">
+                            <% if (!material.readOnly) { %>
+                                <div class="dropdown-menu">
+                                    <a class="dropdown-item changeRate" href="javascript:void(0);" data-value="9">9%</a>
+                                    <a class="dropdown-item changeRate" href="javascript:void(0);" data-value="10">10%</a>
+                                    <a class="dropdown-item changeRate" href="javascript:void(0);" data-value="11">11%</a>
+                                </div>
+                            <% } %>
+                            <!--<select class="form-control form-control-sm col-1" id="changeRate">-->
+                                <!--<% if (!material.readOnly) { %>-->
+                                    <!--<option value="9" <% if(material.exponent_rate === 9) { %>selected<% } %>>9%</option>-->
+                                    <!--<option value="10" <% if(material.exponent_rate === 10) { %>selected<% } %>>10%</option>-->
+                                    <!--<option value="11" <% if(material.exponent_rate === 11) { %>selected<% } %>>11%</option>-->
+                                <!--<% } else { %>-->
+                                    <!--<option value="<%= material.exponent_rate %>" selected><%= material.exponent_rate %>%</option>-->
+                                <!--<% } %>-->
+                            <!--</select>-->
                         </div>
                     </div>
                     <% if (!material.material_tax && !old_had_tax) { %>
@@ -72,8 +80,8 @@
                                     <tr id="rate_set"><td>材料价差费用(含建筑税)</td>
                                         <td class="text-center"><%= material.m_tp !== null ? ctx.helper.round(ctx.helper.mul(material.m_tp, 1+material.rate/100), material.decimal.tp) : null %></td>
                                         <td class="text-center"><%= material.m_tp !== null || pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.m_tp, 1+material.rate/100), material.decimal.tp)), material.decimal.tp) : null %></td>
-                                        <td class="text-center"><%= material.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.rate/100), material.decimal.tp) : null %></td>
-                                        <td class="text-center"><%= material.ex_tp !== null || ex_pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(ex_pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.rate/100), material.decimal.tp)), material.decimal.tp) : null %></td>
+                                        <td class="text-center"><%= material.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.exponent_rate/100), material.decimal.tp) : null %></td>
+                                        <td class="text-center"><%= material.ex_tp !== null || ex_pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(ex_pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.exponent_rate/100), material.decimal.tp)), material.decimal.tp) : null %></td>
                                     </tr>
                                 </table>
                             </div>
@@ -93,17 +101,17 @@
                                         <td class="text-center"><%= material.ex_tp !== null ? ctx.helper.round(material.ex_tp, material.decimal.tp) : null %></td>
                                         <td class="text-center"><%= material.ex_tp !== null || material.ex_pre_tp !== null ? ctx.helper.round(ctx.helper.add(material.ex_pre_tp, material.ex_tp), material.decimal.tp) : null %></td>
                                     </tr>
-                                    <tr><td>材料价差费用(含材料税)</td>
-                                        <td class="text-center"><%= material.material_tax ? (material.m_tax_tp !== null ? material.m_tax_tp : null) : '-' %></td>
-                                        <td class="text-center"><%= material.material_tax ? (material.m_tax_tp !== null || material.m_tax_pre_tp !== null ? ctx.helper.round(ctx.helper.add(material.m_tax_pre_tp, material.m_tax_tp), material.decimal.tp) : null) : material.m_tax_pre_tp %></td>
-                                        <td class="text-center">-</td>
-                                        <td class="text-center">-</td>
-                                    </tr>
+                                    <!--<tr><td>材料价差费用(含材料税)</td>-->
+                                        <!--<td class="text-center"><%= material.material_tax ? (material.m_tax_tp !== null ? material.m_tax_tp : null) : '-' %></td>-->
+                                        <!--<td class="text-center"><%= material.material_tax ? (material.m_tax_tp !== null || material.m_tax_pre_tp !== null ? ctx.helper.round(ctx.helper.add(material.m_tax_pre_tp, material.m_tax_tp), material.decimal.tp) : null) : material.m_tax_pre_tp %></td>-->
+                                        <!--<td class="text-center">-</td>-->
+                                        <!--<td class="text-center">-</td>-->
+                                    <!--</tr>-->
                                     <tr id="rate_set"><td>材料价差费用(含建筑税)</td>
                                         <td class="text-center"><%= !material.material_tax ? (material.m_tp !== null ? ctx.helper.round(ctx.helper.mul(material.m_tp, 1+material.rate/100), material.decimal.tp) : null) : '-' %></td>
                                         <td class="text-center"><%= !material.material_tax ? (material.m_tp !== null || pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.m_tp, 1+material.rate/100), material.decimal.tp)), material.decimal.tp) : null) : pre_tp_hs !== null ? pre_tp_hs : '-' %></td>
-                                        <td class="text-center"><%= material.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.rate/100), material.decimal.tp) : null %></td>
-                                        <td class="text-center"><%= material.ex_tp !== null || ex_pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(ex_pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.rate/100), material.decimal.tp)), material.decimal.tp) : null %></td>
+                                        <td class="text-center"><%= material.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.exponent_rate/100), material.decimal.tp) : null %></td>
+                                        <td class="text-center"><%= material.ex_tp !== null || ex_pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(ex_pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.exponent_rate/100), material.decimal.tp)), material.decimal.tp) : null %></td>
                                     </tr>
                                 </table>
                             </div>
@@ -164,5 +172,6 @@
     const materialType = JSON.parse('<%- JSON.stringify(materialType) %>');
     const ex_calc = JSON.parse('<%- JSON.stringify(ex_calc) %>');
     let ex_expr = '<%- material.ex_expr %>';
+    let materialRate = parseInt('<%- material.exponent_rate %>');
     let materialExponentData = JSON.parse(unescape('<%- escape(JSON.stringify(materialExponentData)) %>'));
 </script>

+ 2 - 2
app/view/material/index.ejs

@@ -59,10 +59,10 @@
                             <% if (openMaterialTax) { %><td class="text-right"><% if (m.material_tax) { %><% if (m.m_tax_tp) { %><%- m.m_tax_tp %><% } else { %><%- m.m_tp %><% } %><% } %></td><% } %>
                             <% if ((openMaterialTax && !allMaterialTax) || !openMaterialTax) { %><td class="text-right"><% if (!m.material_tax) { %><%= m.m_tp !== null ? ctx.helper.round(ctx.helper.mul(m.m_tp, 1+m.rate/100), m.decimal.tp) : null %><% } %></td><% } %>
                             <td class="text-right"><%= m.ex_tp !== null ? ctx.helper.round(m.ex_tp, m.decimal.tp) : null %></td>
-                            <td class="text-right"><%= m.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(m.ex_tp, 1+m.rate/100), m.decimal.tp) : null %></td>
+                            <td class="text-right"><%= m.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(m.ex_tp, 1+m.exponent_rate/100), m.decimal.tp) : null %></td>
                             <td class="text-right"><%= ctx.helper.add(ctx.helper.round(m.ex_tp, m.decimal.tp), ctx.helper.round(m.m_tp, m.decimal.tp)) %></td>
                             <% if (openMaterialTax) { %><td class="text-right"><% if (m.material_tax) { %><% if (m.m_tax_tp) { %><%- m.m_tax_tp %><% } else { %><%- m.m_tp %><% } %><% } %></td><% } %>
-                            <td class="text-right"><% if (m.material_tax) { %><%= m.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(m.ex_tp, 1+m.rate/100), m.decimal.tp) : null %><% } else { %><%= ctx.helper.add(ctx.helper.round(ctx.helper.mul(m.ex_tp, 1+m.rate/100), m.decimal.tp), ctx.helper.round(ctx.helper.mul(m.m_tp, 1+m.rate/100), m.decimal.tp)) %><% } %></td>
+                            <td class="text-right"><% if (m.material_tax) { %><%= m.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(m.ex_tp, 1+m.exponent_rate/100), m.decimal.tp) : null %><% } else { %><%= ctx.helper.add(ctx.helper.round(ctx.helper.mul(m.ex_tp, 1+m.exponent_rate/100), m.decimal.tp), ctx.helper.round(ctx.helper.mul(m.m_tp, 1+m.rate/100), m.decimal.tp)) %><% } %></td>
                             <td class="<%- auditConst.auditProgressClass[m.status] %>">
                                 <% if (m.curAuditor) { %>
                                     <a href="#sp-list" data-toggle="modal" data-target="#sp-list" m-order="<%- m.order %>"><%- m.curAuditor.name %><%if (m.curAuditor.role !== '' && m.curAuditor.role !== null) { %>-<%- m.curAuditor.role %><% } %></a>

+ 22 - 13
app/view/material/info.ejs

@@ -56,15 +56,23 @@
                             <div class="input-group-prepend">
                                 <span class="input-group-text" id="basic-addon1">建筑增值税</span>
                             </div>
-                            <select class="form-control form-control-sm col-1" id="changeRate" <% if (material.material_tax) { %>disabled<% } %>>
-                                <% if (!material.readOnly) { %>
-                                    <option value="9" <% if(material.rate === 9) { %>selected<% } %>>9%</option>
-                                    <option value="10" <% if(material.rate === 10) { %>selected<% } %>>10%</option>
-                                    <option value="11" <% if(material.rate === 11) { %>selected<% } %>>11%</option>
-                                <% } else { %>
-                                    <option value="<%= material.rate %>" selected><%= material.rate %>%</option>
-                                <% } %>
-                            </select>
+                            <input id="rateInput" class="form-control form-control-sm col-1" <% if (material.material_tax || material.readOnly) { %>disabled<% } %> type="number" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" min="0" step="1" max="100" value="<%- material.rate %>">
+                            <% if (!material.readOnly || !material.material_tax) { %>
+                            <div class="dropdown-menu">
+                                <a class="dropdown-item changeRate" href="javascript:void(0);" data-value="9">9%</a>
+                                <a class="dropdown-item changeRate" href="javascript:void(0);" data-value="10">10%</a>
+                                <a class="dropdown-item changeRate" href="javascript:void(0);" data-value="11">11%</a>
+                            </div>
+                            <% } %>
+                            <!--<select class="form-control form-control-sm col-1" id="changeRate" <% if (material.material_tax) { %>disabled<% } %>>-->
+                                <!--<% if (!material.readOnly) { %>-->
+                                    <!--<option value="9" <% if(material.rate === 9) { %>selected<% } %>>9%</option>-->
+                                    <!--<option value="10" <% if(material.rate === 10) { %>selected<% } %>>10%</option>-->
+                                    <!--<option value="11" <% if(material.rate === 11) { %>selected<% } %>>11%</option>-->
+                                <!--<% } else { %>-->
+                                    <!--<option value="<%= material.rate %>" selected><%= material.rate %>%</option>-->
+                                <!--<% } %>-->
+                            <!--</select>-->
                         </div>
                     </div>
                     <% if (!material.material_tax && !old_had_tax) { %>
@@ -85,8 +93,8 @@
                                 <tr id="rate_set"><td>材料价差费用(含建筑税)</td>
                                     <td class="text-center"><%= material.m_tp !== null ? ctx.helper.round(ctx.helper.mul(material.m_tp, 1+material.rate/100), material.decimal.tp) : null %></td>
                                     <td class="text-center"><%= material.m_tp !== null || pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.m_tp, 1+material.rate/100), material.decimal.tp)), material.decimal.tp) : null %></td>
-                                    <td class="text-center"><%= material.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.rate/100), material.decimal.tp) : null %></td>
-                                    <td class="text-center"><%= material.ex_tp !== null || ex_pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(ex_pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.rate/100), material.decimal.tp)), material.decimal.tp) : null %></td>
+                                    <td class="text-center"><%= material.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.exponent_rate/100), material.decimal.tp) : null %></td>
+                                    <td class="text-center"><%= material.ex_tp !== null || ex_pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(ex_pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.exponent_rate/100), material.decimal.tp)), material.decimal.tp) : null %></td>
                                 </tr>
                             </table>
                         </div>
@@ -115,8 +123,8 @@
                                 <tr id="rate_set"><td>材料价差费用(含建筑税)</td>
                                     <td class="text-center"><%= !material.material_tax ? (material.m_tp !== null ? ctx.helper.round(ctx.helper.mul(material.m_tp, 1+material.rate/100), material.decimal.tp) : null) : '-' %></td>
                                     <td class="text-center"><%= !material.material_tax ? (material.m_tp !== null || pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.m_tp, 1+material.rate/100), material.decimal.tp)), material.decimal.tp) : null) : pre_tp_hs !== null ? pre_tp_hs : '-' %></td>
-                                    <td class="text-center"><%= material.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.rate/100), material.decimal.tp) : null %></td>
-                                    <td class="text-center"><%= material.ex_tp !== null || ex_pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(ex_pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.rate/100), material.decimal.tp)), material.decimal.tp) : null %></td>
+                                    <td class="text-center"><%= material.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.exponent_rate/100), material.decimal.tp) : null %></td>
+                                    <td class="text-center"><%= material.ex_tp !== null || ex_pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(ex_pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.exponent_rate/100), material.decimal.tp)), material.decimal.tp) : null %></td>
                                 </tr>
                             </table>
                         </div>
@@ -166,6 +174,7 @@
     const readOnly = <%- material.readOnly %>;
     const materialID = <%- material.id %>;
     const materialTax = <%- material.material_tax %>;
+    let materialRate = parseInt('<%- material.rate %>');
     const materialDecimal = JSON.parse(unescape('<%- escape(JSON.stringify(material.decimal)) %>'));
     let m_tp = <%= material.m_tp !== null ? material.m_tp : 0 %>;
     let ex_tp = <%= material.ex_tp !== null ? material.ex_tp : 0 %>;

+ 5 - 1
sql/update.sql

@@ -1,4 +1,8 @@
 ALTER TABLE `zh_material_list_gcl` ADD `old_quantity` DECIMAL(30,8) NULL DEFAULT NULL COMMENT '数量,用于复原数据' AFTER `expr`,
 ADD `old_expr` VARCHAR(255) NULL DEFAULT NULL COMMENT '公式,用于复原数据' AFTER `old_quantity`;
 
-UPDATE `zh_material_list_gcl` SET `old_quantity`=`quantity`,`old_expr`=`expr`
+UPDATE `zh_material_list_gcl` SET `old_quantity`=`quantity`,`old_expr`=`expr`;
+
+ALTER TABLE `zh_material` ADD `exponent_rate` TINYINT(3) NULL DEFAULT '0' COMMENT '材料税税率' AFTER `rate`;
+
+UPDATE `zh_material` SET `exponent_rate`=`rate`;