Browse Source

单位和单价小数位数更改

laiguoran 6 years ago
parent
commit
231da50a05

+ 33 - 0
app/const/change.js

@@ -69,4 +69,37 @@ module.exports = {
             value: 2, name: '承包人',
         },
     },
+    // 变更单位
+    units: {
+        m: { unit: 'm' },
+        km: { unit: 'km' },
+        m2: { unit: 'm2' },
+        m3: { unit: 'm3' },
+        dm3: { unit: 'dm3' },
+        kg: { unit: 'kg' },
+        t: { unit: 't' },
+        m3km: { unit: 'm3·km' },
+        zonger: { unit: '总额' },
+        yue: { unit: '月' },
+        xiang: { unit: '项' },
+        chu: { unit: '处' },
+        ge: { unit: '个' },
+        gen: { unit: '根' },
+        ke: { unit: '棵' },
+        kuai: { unit: '块' },
+        tai: { unit: '台' },
+        xitong: { unit: '系统' },
+        meiyishizhuang: { unit: '每一试桩' },
+        qiaochangmi: { unit: '桥长米' },
+        gonglugongli: { unit: '公路公里' },
+        zhu: { unit: '株' },
+        zu: { unit: '组' },
+        zuo: { unit: '座' },
+        yuan: { unit: '元' },
+        gongri: { unit: '工日' },
+        tao: { unit: '套' },
+        taiban: { unit: '台班' },
+        souban: { unit: '艘班' },
+        mu: { unit: '亩' },
+    },
 }

+ 3 - 1
app/controller/change_controller.js

@@ -279,6 +279,7 @@ module.exports = app => {
                     auditList,
                     changeList,
                     tpUnit: ctx.tender.info.decimal.tp,
+                    upUnit: ctx.tender.info.decimal.up,
                 };
                 // 根据auditStatus状态获取的不同的数据
                 if (auditStatus === 1 || auditStatus === 2) {
@@ -291,7 +292,8 @@ module.exports = app => {
                     renderData.pos = pos;
 
                     renderData.dealBillList = dealBillList;
-                    renderData.changeUnits = ctx.tender.info.precision;
+                    renderData.changeUnits = changeConst.units;
+                    renderData.precision = ctx.tender.info.precision;
                     renderData.accountGroup = accountGroup;
                     // 获取所有项目参与者
                     const accountList = await ctx.service.projectAccount.getAllDataByCondition({

+ 1 - 1
app/extend/helper.js

@@ -181,7 +181,7 @@ module.exports = {
 
     // 根据单位获取小数位数
     findDecimal(unit) {
-        let value = 2;
+        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) {

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

@@ -18,30 +18,32 @@ $(document).ready(() => {
     let listHtml = '';
     let list_index = 1;
     for (const gcl of gclGatherData) {
-        const quantity = gcl.quantity !== undefined ? gcl.quantity : 0;
+        const unit = gcl.unit !== undefined && gcl.unit !== null ? gcl.unit : '';
+        const quantity = gcl.quantity !== null && gcl.quantity !== undefined ? (unit !== '' ? roundnum(gcl.quantity, findDecimal(gcl.unit)) : gcl.quantity) : 0;
         const unit_price = gcl.unit_price !== null && gcl.unit_price !== undefined ? gcl.unit_price : 0;
         listHtml += '<tr data-lid="' + list_index + '" data-gcl="' + (list_index-1) + '" data-index="' + list_index + '" data-detail="">' +
             '<td>' + list_index + '</td>' +
             '<td>' + gcl.b_code + '</td>' +
             '<td>' + gcl.name + '</td>' +
-            '<td>' + gcl.unit + '</td>' +
-            '<td>' + roundnum(unit_price, totalPriceUnit) + '</td>' +
-            '<td>' + roundnum(quantity, findDecimal(gcl.unit)) + '</td>' +
+            '<td>' + unit + '</td>' +
+            '<td>' + roundnum(unit_price, unitPriceUnit) + '</td>' +
+            '<td>' + quantity + '</td>' +
             // '<td>' + roundnum(parseFloat(gcl.unit_price).mul(parseFloat(gcl.quantity)), totalPriceUnit) + '</td>' +
             '</tr>';
         list_index++;
     }
     // 再加载签约清单
     for (const db of dealBillList) {
-        const quantity = db.quantity !== undefined ? db.quantity : 0;
+        const unit = db.unit !== undefined && db.unit !== null ? db.unit : '';
+        const quantity = db.quantity !== null && db.quantity !== undefined ? (unit !== '' ? roundnum(db.quantity, findDecimal(db.unit)) : db.quantity) : 0;
         const unit_price = db.unit_price !== null && db.unit_price !== undefined ? db.unit_price : 0;
         listHtml += '<tr data-lid="' + db.id + '" data-index="' + list_index + '" data-detail="">' +
             '<td>' + list_index + '</td>' +
             '<td>' + db.code + '</td>' +
             '<td>' + db.name + '</td>' +
-            '<td>' + db.unit + '</td>' +
-            '<td>' + roundnum(unit_price, totalPriceUnit) + '</td>' +
-            '<td>' + roundnum(quantity, findDecimal(db.unit)) + '</td>' +
+            '<td>' + unit + '</td>' +
+            '<td>' + roundnum(unit_price, unitPriceUnit) + '</td>' +
+            '<td>' + quantity + '</td>' +
             // '<td>' + roundnum(parseFloat(db.unit_price).mul(parseFloat(db.quantity)), totalPriceUnit) + '</td>' +
             '</tr>';
         list_index++;
@@ -297,7 +299,7 @@ $(document).ready(() => {
             $('#code-list input:checked').each(function () {
                 const tr = $(this).parents('tr');
                 const length = tr.children('td').length;
-                const detail = length === 4 ? tr.children('td').eq(0).text() + '_' + tr.children('td').eq(2).text() : '0';
+                const detail = length === 5 ? tr.children('td').eq(0).text() + '_' + tr.children('td').eq(2).text() : '0';
                 const quantity = tr.attr('quantity');
                 const de_qu = detail + ';' + quantity;
                 data_detail.push(de_qu);
@@ -312,7 +314,7 @@ $(document).ready(() => {
                 $('#code-list input:checked').each(function () {
                     const tr = $(this).parents('tr');
                     const length = tr.children('td').length;
-                    const detail = length === 4 ? tr.children('td').eq(0).text() + '_' + tr.children('td').eq(2).text() : '0';
+                    const detail = length === 5 ? tr.children('td').eq(0).text() + '_' + tr.children('td').eq(2).text() : '0';
                     const quantity = tr.attr('quantity');
                     const de_qu = detail + ';' + quantity;
                     data_detail.push(de_qu);
@@ -470,6 +472,8 @@ function getAuditList() {
 function maketablelist(status){
     // 金额位数
     const decimal = totalPriceUnit;
+    // 单价位数
+    const updecimal = unitPriceUnit;
 
     let html = '';
 
@@ -523,7 +527,7 @@ function maketablelist(status){
             '<td data-site="1">'+ name +'</td>' +
             '<td data-site="2"><input class="form-control input-sm" type="text" placeholder="变更详情" value="' + detail + '"></td>' +
             '<td data-site="3">'+ unit +'</td>' +
-            '<td data-site="4">'+ roundnum(price, decimal) +'</td>' +
+            '<td data-site="4">'+ roundnum(price, updecimal) +'</td>' +
             '<td data-site="5">'+ roundnum(oamount, numdecimal) +'</td>' +
             '<td data-site="6">'+ roundnum(parseFloat(price).mul(parseFloat(oamount)),decimal) +'</td>' +
             '<td data-site="7"><input class="form-control input-sm" type="text" onkeyup="RegNum(this,event,'+ numdecimal +')" placeholder="请输入变更数量" value="'+ (scnum != '-' ? roundnum(scnum, numdecimal) : '') +'"></td>' +
@@ -537,7 +541,7 @@ function maketablelist(status){
     let radionWhiteList = $('#change-whitelist').val() !== '' ? $('#change-whitelist').val().split('^_^') : [];
     //判断是否添加空白清单
     if(status == 'addwhite'){
-        let trlist = ['','',changeUnits.t.unit,makedecimalzero(decimal),makedecimalzero(changeUnits.t.value),makedecimalzero(changeUnits.t.value),'',0];
+        let trlist = ['','',changeUnits.m.unit,makedecimalzero(decimal),makedecimalzero(findDecimal(changeUnits.m.unit)),makedecimalzero(findDecimal(changeUnits.m.unit)),'',0];
         radionWhiteList.push(trlist.join(';'));
     }
 
@@ -570,7 +574,7 @@ function maketablelist(status){
             '<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="'+ detail +'" placeholder="变更详情"></td>' +
             '<td data-site="3"><select class="form-control input-sm">'+ optionlist +'</select></td>' +
-            '<td data-site="4"><input class="form-control input-sm" type="text" onkeyup="RegNum(this,event,'+ decimal +')" value="'+ roundnum(price, decimal) +'" placeholder="请输入单价"></td>' +
+            '<td data-site="4"><input class="form-control input-sm" type="text" onkeyup="RegNum(this,event,'+ updecimal +')" value="'+ roundnum(price, updecimal) +'" placeholder="请输入单价"></td>' +
             '<td data-site="5"><input class="form-control input-sm" type="text" onkeyup="RegNum(this,event,'+ numdecimal +')" value="'+ roundnum(oamount, numdecimal) +'" placeholder="请输入数量"></td>' +
             '<td data-site="6">'+ ototal +'</td>' +
             '<td data-site="7"><input class="form-control input-sm" type="text" onkeyup="RegNum(this,event,'+ numdecimal +')" value="'+ roundnum(scnum, numdecimal) +'" placeholder="请输入变更数量"></td>' +
@@ -621,7 +625,8 @@ function totalamount(decimal){
 
 // 找出单位对应的小数位数值
 function findDecimal(unit) {
-    let value = 2;
+    let value = precision.other.value;
+    const changeUnits = precision;
     for (const d in changeUnits) {
         if (changeUnits[d].unit !== undefined && changeUnits[d].unit === unit) {
             value = changeUnits[d].value;

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

@@ -460,7 +460,7 @@
                                 <% } %>
                             </select>
                         </td>
-                        <td data-site="4"><input class="form-control form-control-sm" placeholder="单价" onkeyup="RegNum(this,event,tpUnit)" type="text" value="<%= ctx.helper.roundNum(cl.unit_price, tpUnit) %>"></td>
+                        <td data-site="4"><input class="form-control form-control-sm" placeholder="单价" onkeyup="RegNum(this,event,upUnit)" type="text" value="<%= ctx.helper.roundNum(cl.unit_price, upUnit) %>"></td>
                         <td data-site="5"><input class="form-control form-control-sm" placeholder="数量" onkeyup="RegNum(this,event,<%= ctx.helper.findDecimal(cl.unit) %>)" type="text" value="<%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %>"></td>
                         <td data-site="6"><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
                         <td data-site="7"><input class="form-control form-control-sm" placeholder="变更数量" onkeyup="RegNum(this,event,<%= ctx.helper.findDecimal(cl.unit) %>)" type="text" value="<%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %>"></td>
@@ -509,7 +509,7 @@
                             <td><%= cl.name %></td>
                             <td><%= cl.detail %></td>
                             <td><%= cl.unit %></td>
-                            <td><%= ctx.helper.roundNum(cl.unit_price, tpUnit) %></td>
+                            <td><%= ctx.helper.roundNum(cl.unit_price, upUnit) %></td>
                             <td><%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %></td>
                             <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
                             <td><%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %></td>
@@ -567,7 +567,7 @@
                             <td><%= cl.name %></td>
                             <td><%= cl.detail %></td>
                             <td><%= cl.unit %></td>
-                            <td><%= ctx.helper.roundNum(cl.unit_price, tpUnit) %></td>
+                            <td><%= ctx.helper.roundNum(cl.unit_price, upUnit) %></td>
                             <td><%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %></td>
                             <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
                             <td><%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %></td>
@@ -633,7 +633,7 @@
                             <td><%= cl.name %></td>
                             <td><%= cl.detail %></td>
                             <td><%= cl.unit %></td>
-                            <td data-site="4"><%= ctx.helper.roundNum(cl.unit_price, tpUnit) %></td>
+                            <td data-site="4"><%= ctx.helper.roundNum(cl.unit_price, upUnit) %></td>
                             <td><%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %></td>
                             <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
                             <td><%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %></td>
@@ -729,6 +729,7 @@
     })
     let table = '';
     const totalPriceUnit = '<%- tpUnit %>';
+    const unitPriceUnit = '<%- upUnit %>';
 </script>
 <script src="/public/js/datatable/jquery.dataTables.min.js"></script>
 <script src="/public/js/datatable/dataTables.bootstrap4.min.js"></script>
@@ -739,6 +740,7 @@
 <script>
     const whiteList = JSON.parse('<%- JSON.stringify(whiteList) %>');
     const changeUnits = JSON.parse('<%- JSON.stringify(changeUnits) %>');
+    const precision = JSON.parse('<%- JSON.stringify(precision) %>');
     const accountList = JSON.parse('<%- JSON.stringify(accountList) %>');
     const billsTable = {
         columnDefs: [