Selaa lähdekoodia

Merge branch 'master' of http://192.168.1.41:3000/maixinrong/Calculation

MaiXinRong 5 vuotta sitten
vanhempi
commit
c7368beb53

+ 18 - 6
app/extend/helper.js

@@ -82,6 +82,9 @@ module.exports = {
      * @return {string} - 结果
      */
     accMul(arg1, arg2) {
+        if (!arg1 || !arg1) {
+            return '';
+        }
         let m = 0;
         const s1 = arg1.toString();
         const s2 = arg2.toString();
@@ -99,6 +102,9 @@ module.exports = {
     },
 
     accAdd(arg1, arg2) {
+        if (!arg1 || !arg1) {
+            return '';
+        }
         let r1;
         let r2;
         try {
@@ -131,6 +137,9 @@ module.exports = {
 
     // 四舍五入或末尾加零,实现类似php的 sprintf("%.".decimal."f", val);
     roundNum(val, decimals) {
+        if (!val) {
+            return '';
+        }
         if (val !== '') {
             val = parseFloat(val);
             if (decimals < 1) {
@@ -183,12 +192,15 @@ module.exports = {
 
     // 根据单位获取小数位数
     findDecimal(unit) {
-        let value = this.ctx.tender.info.precision.other.value;
-        const changeUnits = this.ctx.tender.info.precision;
-        for (const d in changeUnits) {
-            if (changeUnits[d].unit !== undefined && changeUnits[d].unit === unit) {
-                value = changeUnits[d].value;
-                break;
+        let value = 3;
+        if (unit !== '') {
+            value = this.ctx.tender.info.precision.other.value;
+            const changeUnits = this.ctx.tender.info.precision;
+            for (const d in changeUnits) {
+                if (changeUnits[d].unit !== undefined && changeUnits[d].unit === unit) {
+                    value = changeUnits[d].value;
+                    break;
+                }
             }
         }
         return value;

+ 14 - 14
app/public/js/change_set.js

@@ -470,7 +470,7 @@ $(document).ready(() => {
         const code = $.trim(tr.children('td[data-site="0"]').children('input').val()) || $.trim(tr.children('td[data-site="0"]').text());
         const name = $.trim(tr.children('td[data-site="1"]').children('input').val()) || $.trim(tr.children('td[data-site="1"]').text());
         const bwmx = $.trim(tr.children('td[data-site="2"]').children('input').val()) || $.trim(tr.children('td[data-site="2"]').text());
-        const unit = $.trim(tr.children('td[data-site="4"]').children('select').val()) || $.trim(tr.children('td[data-site="4"]').text());
+        const unit = tr.children('td[data-site="4"]').children('select').val() === '' ? tr.children('td[data-site="4"]').children('select').val() : $.trim(tr.children('td[data-site="4"]').children('select').val()) || $.trim(tr.children('td[data-site="4"]').text());
         const price = (tr.children('td[data-site="5"]').children('input').val() != '-' ? tr.children('td[data-site="5"]').children('input').val() : '') || tr.children('td[data-site="5"]').text();
         const oamount = (tr.children('td[data-site="6"]').children('input').val() != '-' ? tr.children('td[data-site="6"]').children('input').val() : '') || tr.children('td[data-site="6"]').text();
         const scnum = tr.children('td[data-site="8"]').children('input').val() != '-' ? tr.children('td[data-site="8"]').children('input').val() : '';
@@ -500,6 +500,7 @@ $(document).ready(() => {
         const name = $.trim(tr.children('td[data-site="1"]').children('input').val());
         const bwmx = $.trim(tr.children('td[data-site="2"]').children('input').val());
         const unit = $(this).val();
+        tr.children('td[data-site="4"]').children('select').val($(this).val());
         const price = tr.children('td[data-site="5"]').children('input').val() != '-' ? tr.children('td[data-site="5"]').children('input').val() : '';
         let oamount = tr.children('td[data-site="6"]').children('input').val() != '-' ? tr.children('td[data-site="6"]').children('input').val() : '';
         let scnum = tr.children('td[data-site="8"]').children('input').val() != '-' ? tr.children('td[data-site="8"]').children('input').val() : '';
@@ -614,12 +615,12 @@ function maketablelist(status){
             '<td data-site="0">'+ code +'</td>' +
             '<td data-site="1">'+ name +'</td>' +
             '<td data-site="2">'+ bwmx +'</td>' +
-            '<td data-site="3"><input class="form-control input-sm" type="text" placeholder="变更详情" value="' + detail + '"></td>' +
+            '<td data-site="3"><input class="form-control form-control-sm" type="text" placeholder="变更详情" value="' + detail + '"></td>' +
             '<td data-site="4">'+ unit +'</td>' +
             '<td data-site="5">'+ roundnum(price, updecimal) +'</td>' +
             '<td data-site="6">'+ roundnum(oamount, numdecimal) +'</td>' +
             '<td data-site="7">'+ roundnum(parseFloat(price).mul(parseFloat(oamount)),decimal) +'</td>' +
-            '<td data-site="8"><input class="form-control input-sm" type="text" onkeyup="RegNum(this,event,'+ numdecimal +')" placeholder="请输入变更数量" value="'+ (scnum != '-' ? roundnum(scnum, numdecimal) : '') +'"></td>' +
+            '<td data-site="8"><input class="form-control form-control-sm" type="text" onkeyup="RegNum(this,event,'+ numdecimal +')" placeholder="请输入变更数量" value="'+ (scnum != '-' ? roundnum(scnum, numdecimal) : '') +'"></td>' +
             '<td data-site="9">'+ sctotal +'</td>'+
             deteletr +'</tr>';
         index ++;
@@ -630,7 +631,7 @@ function maketablelist(status){
     let radionWhiteList = $('#change-whitelist').val() !== '' ? $('#change-whitelist').val().split('^_^') : [];
     //判断是否添加空白清单
     if(status == 'addwhite'){
-        let trlist = ['','','',changeUnits.m.unit,makedecimalzero(decimal),makedecimalzero(findDecimal(changeUnits.m.unit)),makedecimalzero(findDecimal(changeUnits.m.unit)),'',0];
+        let trlist = ['','','','','','','','',0];
         radionWhiteList.push(trlist.join(';'));
     }
 
@@ -646,8 +647,7 @@ function maketablelist(status){
         let detail = radionArray[7];
         let ototal = price != '' && oamount != '' ? roundnum(parseFloat(price).mul(parseFloat(oamount)),decimal) : '';
         let sctotal = price != '' && scnum != '' ? roundnum(parseFloat(price).mul(parseFloat(scnum)),decimal) : '';
-
-        let optionlist = '';
+        let optionlist = '<option></option>';
         for (const j in changeUnits) {
             if (changeUnits[j].unit !== undefined && changeUnits[j].unit === unit) {
                 optionlist += '<option selected="selected">'+ changeUnits[j].unit +'</option>';
@@ -660,15 +660,15 @@ function maketablelist(status){
         let numdecimal = findDecimal(unit);
 
         html += '<tr class="clist" data-lid="' + whiteIndex + '" data-index="' + whiteIndex + '">' +
-            '<td data-site="0"><input class="form-control input-sm" type="text" value="'+ code +'" placeholder="清单编号"></td>' +
-            '<td data-site="1"><input class="form-control input-sm" type="text" value="'+ name +'" placeholder="名称"></td>' +
-            '<td data-site="2"><input class="form-control input-sm" type="text" value="'+ bwmx +'" placeholder="变更部位"></td>' +
-            '<td data-site="3"><input class="form-control input-sm" type="text" value="'+ detail +'" placeholder="变更详情"></td>' +
-            '<td data-site="4"><select class="form-control input-sm">'+ optionlist +'</select></td>' +
-            '<td data-site="5"><input class="form-control input-sm" type="text" onkeyup="RegNum(this,event,'+ updecimal +')" value="'+ roundnum(price, updecimal) +'" placeholder="请输入单价"></td>' +
-            '<td data-site="6"><input class="form-control input-sm" type="text" onkeyup="RegNum(this,event,'+ numdecimal +')" value="'+ roundnum(oamount, numdecimal) +'" placeholder="请输入数量"></td>' +
+            '<td data-site="0"><input class="form-control form-control-sm" type="text" value="'+ code +'" placeholder="清单编号"></td>' +
+            '<td data-site="1"><input class="form-control form-control-sm" type="text" value="'+ name +'" placeholder="名称"></td>' +
+            '<td data-site="2"><input class="form-control form-control-sm" type="text" value="'+ bwmx +'" placeholder="变更部位"></td>' +
+            '<td data-site="3"><input class="form-control form-control-sm" type="text" value="'+ detail +'" placeholder="变更详情"></td>' +
+            '<td data-site="4"><select class="form-control form-control-sm">'+ optionlist +'</select></td>' +
+            '<td data-site="5"><input class="form-control form-control-sm" type="text" onkeyup="RegNum(this,event,'+ updecimal +')" value="'+ roundnum(price, updecimal) +'" placeholder="请输入单价"></td>' +
+            '<td data-site="6"><input class="form-control form-control-sm" type="text" onkeyup="RegNum(this,event,'+ numdecimal +')" value="'+ roundnum(oamount, numdecimal) +'" placeholder="请输入数量"></td>' +
             '<td data-site="7">'+ ototal +'</td>' +
-            '<td data-site="8"><input class="form-control input-sm" type="text" onkeyup="RegNum(this,event,'+ numdecimal +')" value="'+ roundnum(scnum, numdecimal) +'" placeholder="请输入变更数量"></td>' +
+            '<td data-site="8"><input class="form-control form-control-sm" type="text" onkeyup="RegNum(this,event,'+ numdecimal +')" value="'+ roundnum(scnum, numdecimal) +'" placeholder="请输入变更数量"></td>' +
             '<td data-site="9">'+ sctotal +'</td>'+
             deteletr +'</tr>';
         whiteIndex ++;

+ 8 - 1
app/service/change.js

@@ -279,7 +279,7 @@ module.exports = app => {
          * @return {void}
          */
         async save(postData, tenderId) {
-            const tenderInfo  = await this.ctx.service.tenderInfo.getTenderInfo(tenderId);
+            const tenderInfo = await this.ctx.service.tenderInfo.getTenderInfo(tenderId);
             // 初始化事务
             this.transaction = await this.db.beginTransaction();
             let result = false;
@@ -369,6 +369,13 @@ module.exports = app => {
                             detail: clInfo[7],
                             spamount: clInfo[6],
                         };
+                        if (clInfo[3] === '') {
+                            delete clArray.unit_price;
+                            delete clArray.oamount;
+                            delete clArray.camount;
+                            delete clArray.spamount;
+                        }
+                        console.log(clArray);
                         insertCL.push(clArray);
                         total_price = this.ctx.helper.accAdd(total_price,
                             this.ctx.helper.mul(clArray.unit_price, clArray.spamount, tenderInfo.decimal.tp));

+ 7 - 6
app/view/change/info.ejs

@@ -6,8 +6,8 @@
         font-weight: 600;
     }
     .qd-table .input-sm{
-        height:30px;
-        padding:2px;
+        /*height:calc(1.4125rem + 2px);*/
+        /*padding:2px;*/
     }
     .qd-table>tbody>tr>td, .qd-table>tbody>tr>th, .qd-table>tfoot>tr>td, .qd-table>tfoot>tr>th, .qd-table>thead>tr>td, .qd-table>thead>tr>th {
         padding:5px 2px
@@ -18,10 +18,10 @@
         font-size: 0.9rem;
     }
     #list td select{
-        width: 100%;
-        font-size: 0.9rem;
-        vertical-align: middle;
-        line-height: 30px;
+        /*width: 100%;*/
+        /*font-size: 0.9rem;*/
+        /*vertical-align: middle;*/
+        /*line-height: calc(1.4125rem + 2px);*/
     }
     #list td a {
         cursor: pointer;
@@ -454,6 +454,7 @@
                         <td data-site="3"><input class="form-control form-control-sm" placeholder="变更详情" type="text" value="<%= cl.detail %>"></td>
                         <td data-site="4">
                             <select class="form-control form-control-sm input-sm">
+                                <option></option>
                                 <% for (const j in changeUnits) { %>
                                     <% if (changeUnits[j].unit !== undefined && changeUnits[j].unit === cl.unit) { %>
                                 <option selected="selected"><%= changeUnits[j].unit %></option>

+ 3 - 3
app/view/change/info_modal.ejs

@@ -603,12 +603,12 @@
                                                     </div>
                                                     <div class="alert alert-warning">
                                                         <div class="form-check form-check-inline">
-                                                            <input class="form-check-input" type="radio" name="status" id="change-back" value="5" <% if (index === 1) { %>checked<% } %>>
+                                                            <input class="form-check-input" type="radio" name="status" id="change-back" value="5" <% if (a.usite === 1) { %>checked<% } %>>
                                                             <label class="form-check-label" for="change-back">退回上报 <%= auditList3[0].name %></label>
                                                         </div>
-                                                        <% if (index !== 1) { %>
+                                                        <% if (a.usite !== 1) { %>
                                                             <div class="form-check form-check-inline">
-                                                                <input class="form-check-input" type="radio" name="status" id="chagne-backnew" value="6" <% if (index !== 1) { %>checked<% } %>>
+                                                                <input class="form-check-input" type="radio" name="status" id="chagne-backnew" value="6" <% if (a.usite !== 1) { %>checked<% } %>>
                                                                 <label class="form-check-label" for="chagne-backnew">退回上一审批人 <%= auditList2[a.usite-1].name %></label>
                                                                 <input type="hidden" name="audit_last_id" value="<%= auditList2[a.usite-1].id %>">
                                                             </div>