浏览代码

台账修订,变更清单

MaiXinRong 5 年之前
父节点
当前提交
f46d04e1cf

+ 23 - 0
app/controller/change_controller.js

@@ -746,6 +746,29 @@ module.exports = app => {
                 ctx.redirect(ctx.request.header.referer);
             }
         }
+
+        /**
+         * 获取变更清单
+         * @param ctx
+         * @returns {Promise<void>}
+         */
+        async bills(ctx) {
+            try {
+                const data = JSON.parse(ctx.request.body.data);
+                const responseData = {err: 0, msg: '', data: []};
+                switch (data.type) {
+                    case 'gather':
+                        responseData.data = await ctx.service.changeAuditList.gatherBgBills(ctx.tender.id);
+                        break;
+                    default:
+                        throw '查询的数据不存在';
+                }
+                ctx.body = responseData;
+            } catch (err) {
+                this.log(err);
+                this.ajaxErrorBody(err, '获取变更清单失败');
+            }
+        }
     }
 
     return ChangeController;

+ 14 - 0
app/controller/revise_controller.js

@@ -464,6 +464,17 @@ module.exports = app => {
                 throw '数据错误';
             }
         }
+        async _addBg(revise, data) {
+            if (!data.type || !data.bgBills) throw '数据错误';
+            data.bgBills.unit_price = this.ctx.helper.round(data.bgBills.unit_price, this.ctx.tender.info.decimal.up);
+            if (data.type === 'child') {
+                return await this.ctx.service.reviseBills.addChild(revise.tid, data.id, data.bgBills, revise.id);
+            } else if (data.type === 'next') {
+                return await this.ctx.service.reviseBills.addBillsNode(revise.tid, data.id, data.bgBills, revise.id);
+            } else {
+                throw '数据错误';
+            }
+        }
         async _updatePos(revise, data) {
             await this.checkMeasureType(measureType.tz.value);
             if (!data.posPostType) throw '数据错误';
@@ -517,6 +528,9 @@ module.exports = app => {
                     case 'add-deal':
                         responseData.data = await this._addDeal(revise, data.postData);
                         break;
+                    case 'add-bg':
+                        responseData.data = await this._addDeal(revise, data.postData);
+                        break;
                     case 'add-std':
                         responseData.data = await this._addStd(revise, data.postData);
                         break;

+ 1 - 1
app/public/css/main.css

@@ -103,7 +103,7 @@ input.nospin[type="number"]{-moz-appearance:textfield;}
 	background-color: #ced4da;
 	-webkit-border-radius: 0;
 }
-.sjs-height-1,.sjs-height-2,.sjs-sh-1,.sjs-sh-2,.sjs-sh-3,.sjs-sh-4,.sjs-sh-5{
+.sjs-height-1,.sjs-height-2,.sjs-sh,.sjs-sh-1,.sjs-sh-2,.sjs-sh-3,.sjs-sh-4,.sjs-sh-5{
   overflow: hidden;
 }
 .sjs-height-4,.sjs-height-5,.sjs-height-6,.sjs-option-height{

+ 3 - 0
app/public/js/global.js

@@ -31,6 +31,9 @@ function autoFlashHeight(){
     $(".sjs-sh-3").height($(window).height()-cHeader-sBar3-92+55);
     $(".sjs-sh-4").height($(window).height()-cHeader-sBar4-92+55);
     $(".sjs-sh-5").height($(window).height()-cHeader-sBar5-92+55);
+    for (const sh of $('.sjs-sh')) {
+        $(sh).height($(window).height()-cHeader-getObjHeight($('.sjs-bar', sh.parent))-92+55);
+    }
 };
 $(window).resize(autoFlashHeight);
 /*全局自适应高度结束*/

+ 34 - 10
app/public/js/revise.js

@@ -1345,37 +1345,36 @@ $(document).ready(() => {
     }
     class BgBills {
         constructor (selector, spreadSetting) {
-            const self = this;
             this.loaded = false;
             this.obj = $(selector)[0];
-            this.url = '/tender/' + window.location.pathname.split('/')[2] + '/deal';
             this.spreadSetting = spreadSetting;
             this.spread = SpreadJsObj.createNewSpread(this.obj);
-            SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
+            this.sheet = this.spread.getActiveSheet();
+            SpreadJsObj.initSheet(this.sheet, this.spreadSetting);
             if (!readOnly) {
                 this.spread.bind(spreadNS.Events.CellDoubleClick, function (e, info) {
                     const dealSheet = info.sheet;
                     const mainSheet = billsSheet;
 
-                    const dealBills = SpreadJsObj.getSelectObject(dealSheet);
-                    if (!dealBills) { return; }
+                    const bgBills = SpreadJsObj.getSelectObject(dealSheet);
+                    if (!bgBills) { return; }
                     const mainTree = mainSheet.zh_tree;
                     const mainNode = SpreadJsObj.getSelectObject(mainSheet);
                     if (!mainNode || !mainTree) { return; }
 
                     if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
-                        toastr.warning('非最底层项目下,不应添加节点');
+                        toastr.warning('非最底层项目下,不应添加变更清单');
                         return;
                     }
 
                     postData(window.location.pathname + '/update', {
-                        postType: 'add-deal',
+                        postType: 'add-bg',
                         postData: {
                             id: mainNode.ledger_id,
                             type: mainNode.code ? 'child' : 'next',
                             dealBills: {
-                                b_code: dealBills.code, name: dealBills.name, unit: dealBills.unit,
-                                unit_price: dealBills.unit_price,
+                                b_code: bgBills.code, name: bgBills.name, unit: bgBills.unit,
+                                unit_price: bgBills.unit_price,
                             }
                         },
                     }, function (result) {
@@ -1396,7 +1395,7 @@ $(document).ready(() => {
         loadData () {
             if (this.loaded) return;
             const self = this;
-            postData('/tender/' + window.location.pathname.split('/')[2] +'/get-bg-bills', {}, function (data) {
+            postData('/tender/' + window.location.pathname.split('/')[2] +'/change/bills', {type: 'gather'}, function (data) {
                 self.data = data;
                 SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', data);
                 self.loaded = true;
@@ -1587,6 +1586,22 @@ $(document).ready(() => {
         headerFont: '12px 微软雅黑',
         font: '12px 微软雅黑',
     });
+    const bgBills = new BgBills('#bg-bills-spread', {
+        cols: [
+            {title: '清单编号', field: 'code', hAlign: 0, width: 85, formatter: '@', readOnly: true},
+            {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
+            {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true},
+            {title: '单价', field: 'unit_price', hAlign: 2, width: 50, readOnly: true},
+            {title: '数量', field: 'quantity', hAlign: 2, width: 50, readOnly: true},
+            {title: '金额', field: 'total_price', hAlign: 2, width: 50, readOnly: true},
+        ],
+        emptyRows: 0,
+        headRows: 1,
+        headRowHeight: [32],
+        defaultRowHeight: 21,
+        headerFont: '12px 微软雅黑',
+        font: '12px 微软雅黑',
+    });
 
     $.divResizer({
         select: '#revise-right-spr',
@@ -1604,6 +1619,9 @@ $(document).ready(() => {
             if (dealBills) {
                 dealBills.spread.refresh();
             }
+            if (bgBills) {
+                bgBills.spread.refresh();
+            }
             if (searchLedger) {
                 searchLedger.spread.refresh();
             }
@@ -1636,6 +1654,9 @@ $(document).ready(() => {
             if (dealBills) {
                 dealBills.spread.refresh();
             }
+            if (bgBills) {
+                bgBills.spread.refresh();
+            }
             if (searchLedger) {
                 searchLedger.spread.refresh();
             }
@@ -1804,6 +1825,9 @@ $(document).ready(() => {
             } else if (tab.attr('content') === '#deal-bills') {
                 dealBills.loadData();
                 dealBills.spread.refresh();
+            } else if (tab.attr('content') === '#bg-bills') {
+                bgBills.loadData();
+                bgBills.spread.refresh();
             } else if (tab.attr('content') === '#search' && !searchLedger) {
                 if (!searchLedger) {
                     searchLedger = $.billsSearch({

+ 1 - 0
app/router.js

@@ -209,6 +209,7 @@ module.exports = app => {
     app.get('/change/download/file/:id', sessionAuth, 'changeController.downloadFile');
     app.post('/change/delete/file', sessionAuth, 'changeController.deleteFile');
     app.post('/tender/:id/change/delete', sessionAuth, tenderCheck, 'changeController.delete');
+    app.post('/tender/:id/change/bills', sessionAuth, tenderCheck, 'changeController.bills');
 
     app.post('/change/save', sessionAuth, 'changeController.save');
 

+ 13 - 0
app/service/change_audit_list.js

@@ -22,6 +22,19 @@ module.exports = app => {
             super(ctx);
             this.tableName = 'change_audit_list';
         }
+
+        async gatherBgBills (tid) {
+            const sql = 'SELECT code, name, unit, unit_price, Sum(camount) as quantity' +
+                '  FROM ' + this.tableName +
+                '  WHERE tid = ?' +
+                '  GROUP BY code, name, unit, unit_price';
+            const param = [tid];
+            const result = await this.db.query(sql, param);
+            for (const b of result) {
+                b.total_price = this.ctx.helper.mul(b.unit_price, b.quantity, this.ctx.tender.info.decimal.tp);
+            }
+            return result;
+        }
     }
 
     return ChangeAuditList;

+ 0 - 14
app/view/measure/stage_modal.ejs

@@ -185,20 +185,6 @@
         editPeriod.selectDate(period);
     }
     <% } %>
-    // $('#edit-ok').click(function () {
-    //     const data = {
-    //         order: parseInt($(this).attr('s-order')),
-    //         date: $('input[name=edit-date]').val(),
-    //         period: $('input[name=edit-period]').val(),
-    //     };
-    //     if (data.date === '' || data.period === '') {
-    //         return;
-    //     }
-    //     const tenderId = window.location.pathname.split('/')[2];
-    //     postData('/tender/' + tenderId + '/measure/stage/save', data, function () {
-    //         $('#edit').modal('hide');
-    //     });
-    // });
     $('.datepicker-here').datepicker({
         autoClose: true,
     });

+ 10 - 0
app/view/revise/info.ejs

@@ -161,6 +161,13 @@
                         <div id="deal-bills-spread" class="sjs-sh-5">
                         </div>
                     </div>
+                    <div id="bg-bills" class="tab-pane">
+                        <div class="sjs-bar">
+                            变更清单
+                        </div>
+                        <div id="bg-bills-spread" class="sjs-sh">
+                        </div>
+                    </div>
                 </div>
             </div>
         </div>
@@ -183,6 +190,9 @@
                 <li class="nav-item">
                     <a class="nav-link" content="#deal-bills" href="javascript: void(0);">签约清单</a>
                 </li>
+                <li class="nav-item">
+                    <a class="nav-link" content="#bg-bills" href="javascript: void(0);">变更清单</a>
+                </li>
             </ul>
         </div>
     </div>