瀏覽代碼

指标计算 no.1 up

laiguoran 7 年之前
父節點
當前提交
290953d965
共有 4 個文件被更改,包括 94 次插入92 次删除
  1. 35 0
      app/controller/lib_controller.js
  2. 49 9
      app/public/js/lib_detail.js
  3. 1 0
      app/router.js
  4. 9 83
      app/view/lib/detail.ejs

+ 35 - 0
app/controller/lib_controller.js

@@ -305,6 +305,41 @@ module.exports = app => {
             }
             ctx.body = responseData;
         }
+
+
+        /**
+         * 获取指标和参数信息
+        *
+         * @param {Object} ctx -egg全局变量
+         * @return {void}
+         */
+        async getNodeAndIndex(ctx) {
+            const responseData = {
+                err: 0,
+                msg: '',
+                data: {},
+            };
+            const data = JSON.parse(ctx.request.body.data);
+            try {
+                if (data.lib_id === undefined || data.node_id === undefined || data.bills_id === undefined) {
+                    throw '提交信息错误';
+                }
+                //取指标编号列表
+                responseData.data.indexList = await ctx.service.tenderIndex.getAllDataByCondition({
+                    where: {lib_id: data.lib_id, node_id: data.node_id}
+                });
+                responseData.data.paramList = await ctx.service.tenderParam.getAllDataByCondition({
+                    where: {lib_id: data.lib_id, node_id: data.node_id}
+                });
+            } catch (err) {
+                console.log(err);
+                responseData.err = 1;
+                responseData.msg = err.toString();
+            }
+
+            ctx.body = responseData;
+        }
+
     }
 
     return LibController;

+ 49 - 9
app/public/js/lib_detail.js

@@ -10,6 +10,7 @@
 
 $(document).ready(function() {
     const billsSpread = SpreadJsObj.createNewSpread($('#bills-spread')[0]);
+    const billsSheet = billsSpread.getActiveSheet();
     const billsTree = createNewPathTree({
         id: 'n_id',
         pid: 'n_pid',
@@ -22,15 +23,15 @@ $(document).ready(function() {
         preUrl: '/lib/detail',
     });
     billsTree.loadDatas(bills);
-    SpreadJsObj.initSheet(billsSpread.getActiveSheet(), {
+    SpreadJsObj.initSheet(billsSheet, {
         cols: [
-            {title: '项目节编号', field: 'code', width: 120, cellType: 'tree', vAlign: 1, readOnly: true,},
-            {title: '清单编号', field: 'b_code', width: 80, vAlign: 1, readOnly: true,},
-            {title: '名称', field: 'name', width: 200, vAlign: 1, readOnly: true,},
-            {title: '单位', field: 'unit', width: 50, vAlign: 1, readOnly: true,},
-            {title: '数量1', field: 'dgn_quantity1', width: 60, type: 'Number', vAlign: 1, readOnly: true,},
-            {title: '数量2', field: 'dgn_quantity2', width: 60, type: 'Number', vAlign: 1, readOnly: true,},
-            {title: '金额', field: 'total_price', width: 60, type: 'Number', vAlign: 1, readOnly: true,},
+            {title: '项目节编号', field: 'code', width: 120, cellType: 'tree', vAlign: 1, readOnly: true},
+            {title: '清单编号', field: 'b_code', width: 80, vAlign: 1, readOnly: true},
+            {title: '名称', field: 'name', width: 200, vAlign: 1, readOnly: true},
+            {title: '单位', field: 'units', width: 50, vAlign: 1, readOnly: true},
+            {title: '数量1', field: 'dgn_quantity1', width: 60, type: 'Number', vAlign: 1, readOnly: true},
+            {title: '数量2', field: 'dgn_quantity2', width: 60, type: 'Number', vAlign: 1, readOnly: true},
+            {title: '金额', field: 'total_price', width: 60, type: 'Number', vAlign: 1, readOnly: true},
         ],
         treeCol: 0,
         emptyRows: 3,
@@ -38,5 +39,44 @@ $(document).ready(function() {
         headRowHeight: [28],
         defaultRowHeight: 30,
     });
-    SpreadJsObj.loadSheetData(billsSpread.getActiveSheet(), 'tree', billsTree);
+    SpreadJsObj.loadSheetData(billsSheet, 'tree', billsTree);
+    billsSheet.selectionPolicy(0);
+    billsSheet.selectionUnit(1);
+    billsSheet.clearSelection();
+    const spreadNS = GC.Spread.Sheets;
+
+    //项目节选中
+    billsSheet.bind(spreadNS.Events.SelectionChanged, function (e, info) {
+        const billsInfo = billsTree.nodes[info.newSelections[0].row];
+        $('#codeName').text(billsInfo.name);
+        $('#indexList').html('');
+        $('#paramList').html('');
+        if(billsInfo.match_node !== null){
+            const postUrl = '/lib/getNodeAndIndex';
+            const postInfo = {
+                lib_id:billsInfo.lib_id,
+                node_id:billsInfo.match_node,
+                bills_id:billsInfo.id
+            };
+            postData(postUrl, postInfo, function (result) {
+                let index_html = '';
+                const index_list = result.indexList;
+                for(let i in index_list) {
+                    index_list[i].unit1 = index_list[i].unit1 !== null ? index_list[i].unit1 : '';
+                    index_list[i].unit2 = index_list[i].unit2 !== null ? index_list[i].unit2 : '';
+                    index_html += '<tr> <td>'+ index_list[i].code +'</td> <td>'+ index_list[i].name +'</td> <td>'+ index_list[i].unit1 +'</td> <td>'+ index_list[i].unit2 +'</td> <td></td> <td>'+ index_list[i].rule +'</td> <td></td> <td></td> </tr>';
+                }
+                $('#indexList').html(index_html);
+
+                let param_html = '';
+                const param_list = result.paramList;
+                for(let i in param_list) {
+                    param_html += '<tr> <td>'+ param_list[i].name +'</th><td>'+ param_list[i].code +'</td><td><input class="form-control form-control-sm" value=""></td> </tr>';
+                }
+                $('#paramList').html(param_html);
+                console.log(param_html);
+                console.log(index_html);
+            });
+        }
+    });
 });

+ 1 - 0
app/router.js

@@ -21,6 +21,7 @@ module.exports = app => {
     app.post('/lib/detail/get-children', sessionAuth, 'libController.getChildren');
     app.get('/lib/global/:id', sessionAuth, 'libController.global');
     app.post('/lib/updateParamValue', sessionAuth, 'libController.updateParamValue');
+    app.post('/lib/getNodeAndIndex', sessionAuth, 'libController.getNodeAndIndex');
     app.post('/lib/delete', sessionAuth, 'libController.delete');
     app.post('/lib/enter', sessionAuth, 'libController.enter');
 

+ 9 - 83
app/view/lib/detail.ejs

@@ -28,6 +28,7 @@
                 <div class="col-7">
                     <div class="sjs-height-3">
                         <table class="table table-bordered table-sm table-hover">
+                            <thead>
                             <tr>
                                 <th>指标编号</th>
                                 <th>项目或费用名称</th>
@@ -37,98 +38,23 @@
                                 <th>指标计算</th>
                                 <th>经济指标</th>
                             </tr>
-                            <tr>
-                                <td>z1-a</td>
-                                <td>临时道路</td>
-                                <td></td>
-                                <td>km</td>
-                                <td></td>
-                                <td>指新建便道与利用原有道路的总长</td>
-                                <td></td>
-                                <td></td>
-                            </tr>
-                            <tr>
-                                <td>z1-a-1</td>
-                                <td>临时道路公路公里造价</td>
-                                <td>元</td>
-                                <td>公路公里</td>
-                                <td></td>
-                                <td>合价/路线总长度</td>
-                                <td>10000/500</td>
-                                <td>20</td>
-                            </tr>
-                            <tr>
-                                <td>z1-a-2</td>
-                                <td>临时道路公里造价</td>
-                                <td>元</td>
-                                <td>km</td>
-                                <td></td>
-                                <td>km指临时道路长度,合价/临时道路长</td>
-                                <td></td>
-                                <td></td>
-                            </tr>
-                            <tr>
-                                <td>z1-a-3</td>
-                                <td>临时道路建筑面积造价</td>
-                                <td>元</td>
-                                <td>m2</td>
-                                <td></td>
-                                <td>合价/(临时道路长度×路基均宽)</td>
-                                <td></td>
-                                <td></td>
-                            </tr>
-                            <tr>
-                                <td>z1-a-4</td>
-                                <td>临时道路造价占比</td>
-                                <td></td>
-                                <td>%</td>
-                                <td></td>
-                                <td>合价/临时工程费用</td>
-                                <td></td>
-                                <td></td>
-                            </tr>
-                            <tr>
-                                <td>z1-a-5</td>
-                                <td>临时道路面积长度比</td>
-                                <td></td>
-                                <td>%</td>
-                                <td></td>
-                                <td>临时道路建筑面积/临时道路长度</td>
-                                <td></td>
-                                <td></td>
-                            </tr>
-                            <tr>
-                                <td>z1-a-6</td>
-                                <td>临时道路路线长度比</td>
-                                <td>km</td>
-                                <td>公路公里</td>
-                                <td></td>
-                                <td>临时道路长度/路线总长度</td>
-                                <td></td>
-                                <td></td>
-                            </tr>
+                            </thead>
+                            <tbody id="indexList">
+                            </tbody>
                         </table>
                     </div>
                     <div class="sjs-bottom-2">
                         <legend class="mt-3">填写参数</legend>
                         <!--本节点参数-->
                         <table class="table table-bordered table-sm table-hover">
-                            <tr><th colspan="4" class="text-center">1-1 项目节 参数</th></tr>
+                            <thead>
+                            <tr><th colspan="4" class="text-center"><span id="codeName"></span> 参数</th></tr>
                             <tr>
                                 <th>参数名称</th><th>绑定分项节点</th><th>参数数值</th>
                             </tr>
-                            <tr>
-                                <td>总造价</th><td></td><td><input class="form-control form-control-sm"></td>
-                            </tr>
-                            <tr>
-                                <td>路线总长度</td><td>1-1-2</td><td><input class="form-control form-control-sm" value="15123"></td>
-                            </tr>
-                            <tr>
-                                <td>路基工程费用</td><td>1-4-1</td><td><input class="form-control form-control-sm" value="50410"></td>
-                            </tr>
-                            <tr>
-                                <td>边沟圬工体积</td><td></td><td><input class="form-control form-control-sm"></td>
-                            </tr>
+                            </thead>
+                            <tbody id="paramList">
+                            </tbody>
                         </table>
                     </div>
                 </div>