Ver código fonte

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

Tony Kang 2 anos atrás
pai
commit
f47f90fe2d

+ 10 - 3
app/public/js/ledger.js

@@ -140,6 +140,12 @@ $(document).ready(function() {
         },
     });
 
+    const gclGather = $.cs_gclGather({
+        selector: '#gcl-gather',
+        id: 'gcl-gather',
+        relaSheet: ledgerSpread.getActiveSheet(),
+    });
+
     $.subMenu({
         menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
         toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
@@ -176,6 +182,7 @@ $(document).ready(function() {
             if (checkList) {
                 checkList.spread.refresh();
             }
+            if (gclGather) gclGather.spread.refresh();
         }
     });
 
@@ -1070,12 +1077,9 @@ $(document).ready(function() {
     ledgerSpread.bind(spreadNS.Events.SelectionChanged, treeOperationObj.selectionChanged);
     ledgerSpread.bind(spreadNS.Events.TopRowChanged, treeOperationObj.topRowChanged);
 
-    console.log(ledgerSpread.options);
     ledgerSpread.bind(spreadNS.Events.ClipboardChanging, function (e, info) {
         const copyText = SpreadJsObj.getFilterCopyText(info.sheet);
         SpreadJsObj.Clipboard.setCopyData(copyText);
-        info.copyData.text = copyText;
-        info.copyData.html = SpreadJsObj.getFilterCopyHTML(info.sheet);
     });
     if (!ledgerSpreadSetting.readOnly) {
         ledgerSpread.bind(spreadNS.Events.SelectionChanged, function (e, info) {
@@ -2269,6 +2273,7 @@ $(document).ready(function() {
             if (checkList) {
                 checkList.spread.refresh();
             }
+            if (gclGather) gclGather.spread.refresh();
         }
     });
     const stdLibCellDoubleClick = function (e, info) {
@@ -2471,6 +2476,8 @@ $(document).ready(function() {
               const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
               getNodeList(node.id);
               getAllList();
+            } else if (tab.attr('content') === '#gcl-gather') {
+                gclGather.spread.refresh();
             }
         } else { // 收起工具栏
             tab.removeClass('active');

+ 4 - 4
app/public/js/measure_material.js

@@ -266,11 +266,11 @@ $(function () {
         };
         if (lastMaterialListNum === 0) {
             console.log(newMaterialData);
-            // postData(preUrl + '/measure/material/add', newMaterialData, function (result) {
-            //     window.location.href = preUrl + '/measure/material/' + result.order;
-            // }, function () {
+            postData(preUrl + '/measure/material/add', newMaterialData, function (result) {
+                window.location.href = preUrl + '/measure/material/' + result.order;
+            }, function () {
                 _self.attr('disabled', false).text('确认添加');
-            // });
+            });
             return;
         }
         $('#add-qi').modal('hide');

+ 12 - 1
app/public/js/path_tree.js

@@ -146,9 +146,13 @@ class PosData {
     }
 
     resortLedgerPos(ledgerPos) {
+        const sortRule = this.setting.sort || [['porder', 'asc']];
         if (ledgerPos instanceof Array) {
             ledgerPos.sort(function (a, b) {
-                return a.porder - b.porder;
+                for (const sr of sortRule) {
+                    const iSort = sr[1] === 'asc' ? a[sr[0]] - b[sr[0]] : b[sr[0]] - a[sr[0]];
+                    if (iSort) return iSort;
+                }
             })
         }
     }
@@ -162,6 +166,13 @@ class PosData {
             this.setting.calcFun(pos);
         }
     }
+
+    set sort(sort) {
+        this.setting.sort = sort;
+        for (const key in this.ledgerPos) {
+            this.resortLedgerPos(this.ledgerPos[key]);
+        }
+    }
 }
 
 class StagePosData extends PosData {

+ 89 - 0
app/public/js/shares/cs_gcl_gather.js

@@ -0,0 +1,89 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+(function($){
+    $.cs_gclGather = function (setting) {
+        if (!setting.selector) return;
+
+        if (!setting.spreadSetting) {
+            setting.spreadSetting = {
+                cols: [
+                    {title: '清单编号', field: 'b_code', width: 80, formatter: '@'},
+                    {title: '名称', field: 'name', width: 150, formatter: '@'},
+                    {title: '单位', field: 'unit', width: 50, formatter: '@'},
+                    {title: '单价', field: 'unit_price', width: 60, formatter: '@'},
+                    {title: '数量', field: 'quantity', width: 60, },
+                    {title: '数量', field: 'total_price', width: 60, },
+                ],
+                emptyRows: 0,
+                headRows: 1,
+                headRowHeight: [32],
+                defaultRowHeight: 21,
+                headerFont: '12px 微软雅黑',
+                font: '12px 微软雅黑',
+                selectedBackColor: '#fffacd',
+                readOnly: true,
+            };
+        }
+        if (!setting.gatherFields) setting.gatherFields = ['quantity', 'total_price'];
+
+        const resultId = setting.id + '-spread';
+        const obj = $(setting.selector);
+        obj.html(
+            '<div class="sjs-bar">\n' +
+            `    <div class="pb-1 d-flex"><button class="btn btn-primary btn-sm" id="gcl-gather-refresh">汇总</button>\n` +
+            '        <span class="pl-2" id="' + setting.id + '-info"></span>\n' +
+            '    </div>\n' +
+            '</div>' +
+            '<div id="' + resultId + '" class="sjs-sh">\n' +
+            '</div>'
+        );
+        autoFlashHeight();
+
+        const spread = SpreadJsObj.createNewSpread($('#' + resultId)[0]);
+        const sheet = spread.getActiveSheet();
+        const result = [];
+        SpreadJsObj.initSheet(sheet, setting.spreadSetting);
+        SpreadJsObj.loadSheetData(sheet, SpreadJsObj.DataType.Data, result);
+
+        const recursiveGather = function(nodes) {
+            for (const node of nodes) {
+                if (node.children && node.children.length > 0) {
+                    recursiveGather(node.children);
+                } else {
+                    if (!node.b_code) continue;
+                    let gcl = result.find(x => {
+                        return x.b_code === node.b_code && x.name === node.name && x.unit === node.unit && x.unit_price === node.unit_price;
+                    });
+                    if (!gcl) {
+                        gcl = { b_code: node.b_code, name: node.name, unit: node.unit, unit_price: node.unit_price };
+                        result.push(gcl);
+                    }
+                    for (const f of setting.gatherFields) {
+                        gcl[f] = ZhCalc.add(gcl[f], node[f]);
+                    }
+                }
+            }
+        };
+
+        const gather = function (node) {
+            $(`#${setting.id}-info`).html(`${node.code || ''}${node.b_code || ''} ${node.name || ''} - ${moment(new Date()).format('YYYY-MM-DD HH:mm:ss')}`);
+            recursiveGather([node]);
+            SpreadJsObj.reLoadSheetData(sheet);
+        };
+
+        $('#gcl-gather-refresh').click(() => {
+            gather(SpreadJsObj.getSelectObject(setting.relaSheet));
+        });
+
+        return { spread, sheet, gather}
+    };
+
+})(jQuery);

+ 21 - 2
app/public/js/shares/show_level.js

@@ -29,7 +29,7 @@ $.cs_showLevel = function (setting) {
             if (l.type === 'sort') {
                 let count = typeof l.count === 'function' ? l.count() : l.count;
                 count = Math.min(count, 5);
-                for (let i = 1; i <= count; ++i) {
+                for (let i = 1; i <= l.count; ++i) {
                     html.push(`<a class="dropdown-item" name="showLevel" tag="${i}" href="javascript: void(0);">${sortTitle[i-1]}</a>`);
                 }
             } else {
@@ -48,7 +48,26 @@ $.cs_showLevel = function (setting) {
                 closeWaitingView();
             });
         });
+        refreshMenuVisible();
     };
 
-    return { initShowLevel } ;
+    const refreshMenuVisible = function () {
+        const showMenu = function (tag, visible) {
+            if (visible) $(`[tag=${tag}]`).show();
+            if (!visible) $(`[tag=${tag}]`).hide();
+        };
+        for (const l of setting.levels) {
+            if (l.type === 'sort') {
+                let visibleCount = typeof l.visible_count === 'function' ? l.visible_count() : l.visible_count;
+                for (let i = 1; i <= l.count; ++i) {
+                    showMenu(i, i <= visibleCount);
+                }
+            } else {
+                const visible = typeof l.visible === 'function' ? l.visible() : l.visible;
+                showMenu(l.type, visible);
+            }
+        }
+    };
+
+    return { initShowLevel, refreshMenuVisible } ;
 };

+ 6 - 0
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -406,6 +406,7 @@ const SpreadJsObj = {
             SpreadJsObj.selChangedRefreshBackColor(sheet);
         }
         this.endMassOperation(sheet);
+        if (!setting.invalidCopyFilterHiddenRow) this.copyFilterHiddenRow(sheet);
     },
     reLoadSheetHeader: function (sheet) {
         if (sheet.zh_setting) {
@@ -993,6 +994,11 @@ const SpreadJsObj = {
         }
         return result;
     },
+    copyFilterHiddenRow: function (sheet) {
+        sheet.bind(spreadNS.Events.ClipboardChanged, function (e, info) {
+            SpreadJsObj.Clipboard.setSysClipboard(SpreadJsObj.getFilterCopyText(info.sheet));
+        });
+    },
     /**
      * 树表结构,定位至指定的节点
      * @param {GC.Spread.Sheets.Worksheet} sheet - 需要定位的sheet

+ 17 - 0
app/public/js/stage.js

@@ -2198,6 +2198,23 @@ $(document).ready(() => {
                     stagePosSpreadObj.deletePos(spSpread.getActiveSheet());
                 }
             },
+            'sort': {
+                name: '排序',
+                items: {
+                    "addStageReverse": {
+                        name: '按新增期倒序',
+                        icon: 'fa-sort-amount-desc',
+                        callback: function (key, opt) {
+                            stagePos.sort = [['add_stage_order', 'desc'], ['porder', 'asc']];
+                            const spSheet = spSpread.getActiveSheet();
+                            if (spSheet.zh_data) {
+                                spSheet.zh_data.sort((x, y) => { return y.add_stage_order - x.add_stage_order || x.porder - y.porder; });
+                                SpreadJsObj.reLoadSheetData(spSheet);
+                            }
+                        }
+                    }
+                }
+            },
             'merge-peg': {
                 name: '合并起讫桩号',
                 visible: function (key, opt) {

+ 0 - 6
app/public/js/stage_bwtz.js

@@ -90,12 +90,6 @@ $(document).ready(() => {
     xmjSpread.bind(spreadNS.Events.SelectionChanged, function (e, info) {
         unitTreeObj.loadCurUnitData();
     });
-    xmjSpread.bind(spreadNS.Events.ClipboardChanged, function (e, info) {
-        SpreadJsObj.Clipboard.setSysClipboard(SpreadJsObj.getFilterCopyText(info.sheet));
-    });
-    unitSpread.bind(spreadNS.Events.ClipboardChanged, function (e, info) {
-        SpreadJsObj.Clipboard.setSysClipboard(SpreadJsObj.getFilterCopyText(info.sheet));
-    });
     const loadData = function (dataType) {
         postData(window.location.pathname + '/load', {filter: dataType}, function (result) {
             const setting = {

+ 10 - 2
app/public/js/tender_list.js

@@ -287,6 +287,12 @@ function recursiveGetTenderNodeHtml (node, arr, pid) {
         html.push('<a href="javascript: void(0)" id="' + node.id + '">', node.name, '</a>');
     }
     html.push('</td>');
+    // 计量模式
+    html.push('<td style="width: 5%" class="text-center">');
+    if (node.measure_type) {
+        html.push(node.measure_type === measureType.tz.value ? '0号台账' : '工程量清单');
+    }
+    html.push('</td>');
     // 创建人
     html.push('<td style="width: 10%" class="text-center">', node.user_name ? node.user_name : '', '</td>');
     // 创建时间
@@ -322,9 +328,10 @@ function getTenderTreeHtml () {
         const html = [];
         html.push('<table class="table table-hover table-bordered">');
         html.push('<thead style="position: fixed;left:56px;top: 34px;">', '<tr>');
-        html.push('<th class="text-center" style="width: 45%">', '标段名称', tenderListOrder.getOrderButton('name'), '</th>');
+        html.push('<th class="text-center" style="width: 40%">', '标段名称', tenderListOrder.getOrderButton('name'), '</th>');
+        html.push('<th class="text-center" style="width: 10%">', '计量模式', '</th>');
         html.push('<th class="text-center" style="width: 10%">', '创建人', '</th>');
-        html.push('<th class="text-center" style="width: 15%">', '创建时间', tenderListOrder.getOrderButton('create_time'), '</th>');
+        html.push('<th class="text-center" style="width: 10%">', '创建时间', tenderListOrder.getOrderButton('create_time'), '</th>');
         html.push('<th class="text-center" style="width: 10%">', '计量期数', '</th>');
         html.push('<th class="text-center" style="width: 20%">', '审批状态', '</th>');
         html.push('</tr>', '</thead>');
@@ -399,6 +406,7 @@ $(document).ready(() => {
             $('.c-body').html(getTenderTreeHtml());
             localHideList();
             $('#cate-set').modal('hide');
+            tenderTreeShowLevel.refreshMenuVisible();
         });
     });
     // 新增标段

+ 1 - 0
app/public/js/tender_list_info.js

@@ -476,6 +476,7 @@ $(document).ready(() => {
             $('.c-body').html(getTenderTreeHtml());
             localHideList();
             $('#cate-set').modal('hide');
+            tenderTreeShowLevel.refreshMenuVisible();
         });
     });
     // 新增标段

+ 1 - 0
app/public/js/tender_list_manage.js

@@ -412,6 +412,7 @@ $(document).ready(() => {
             $('.c-body').html(getTenderTreeHtml());
             localHideList();
             $('#cate-set').modal('hide');
+            tenderTreeShowLevel.refreshMenuVisible();
         });
     });
 

+ 1 - 0
app/public/js/tender_list_progress.js

@@ -448,6 +448,7 @@ $(document).ready(() => {
             $('.c-body').html(getTenderTreeHtml());
             localHideList();
             $('#cate-set').modal('hide');
+            tenderTreeShowLevel.refreshMenuVisible();
         });
     });
     // 新增标段

+ 16 - 11
app/public/js/tender_showhide.js

@@ -155,6 +155,15 @@ function doTrStatus(node, status, all = '') {
 }
 
 let tenderTreeShowLevel;
+const getChildrenLevel = function (node) {
+    let iLevel = node.level;
+    if (node.children && node.children.length > 0) {
+        for (const c of node.children) {
+            iLevel = Math.max(iLevel, getChildrenLevel(c));
+        }
+    }
+    return iLevel;
+};
 
 $(document).ready(() => {
     // 展开和收起
@@ -211,20 +220,16 @@ $(document).ready(() => {
         selector: '#show-level',
         levels: [
             {
-                type: 'sort', count: function () {
-                    const getChildrenLevel = function (node) {
-                        let iLevel = node.level;
-                        if (node.children && node.children.length > 0) {
-                            for (const c of node.children) {
-                                iLevel = Math.max(iLevel, getChildrenLevel(c));
-                            }
-                        }
-                        return iLevel;
-                    };
+                type: 'sort', count: 5, visible_count: function () {
                     return tenderTree.map(getChildrenLevel).reduce((x, y) => { return Math.max(x, y); }, 0) - 1;
                 }
             },
-            { type: 'last', title: '最底层' },
+            {
+                type: 'last', title: '最底层', visible: function () {
+                    const count = tenderTree.map(getChildrenLevel).reduce((x, y) => { return Math.max(x, y); }, 0) - 1;
+                    return count > 0;
+                }
+            },
         ],
         showLevel: function (tag) {
 

+ 4 - 0
app/service/project_account.js

@@ -153,6 +153,10 @@ module.exports = app => {
                         // throw '该账号已被停用,请联系销售人员';
                         return 2;
                     }
+                    if (accountData.invalid_time) {
+                        const date = this.ctx.moment(accountData.invalid_time, 'YYYY-MM-DD').toDate();
+                        if (date < new Date()) return 2;
+                    }
 
                     projectList = await this.getProjectInfoByAccount(data.account.trim());
                     // permission = accountData.permission;

+ 5 - 0
app/view/ledger/explode.ejs

@@ -275,6 +275,8 @@
                           </div>
                       </div>
                   </div>
+                    <div id="gcl-gather" class="tab-pane tab-select-show">
+                    </div>
                 </div>
             </div>
         </div>
@@ -305,6 +307,9 @@
                 <li class="nav-item">
                     <a class="nav-link" content="#check-list" id="check-list-tab" href="javascript: void(0);" style="display: none;">数据检查</a>
                 </li>
+                <li class="nav-item">
+                    <a class="nav-link" content="#gcl-gather" id="gcl-gather-tab" href="javascript: void(0);">清单汇总</a>
+                </li>
             </ul>
         </div>
     </div>

+ 1 - 0
config/web.js

@@ -152,6 +152,7 @@ const JsFiles = {
                     '/public/js/shares/sjs_setting.js',
                     '/public/js/shares/export_excel.js',
                     '/public/js/shares/cs_tools.js',
+                    '/public/js/shares/cs_gcl_gather.js',
                     '/public/js/shares/merge_peg.js',
                     '/public/js/shares/new_tag.js',
                     '/public/js/zh_calc.js',

+ 3 - 0
sql/update.sql

@@ -54,3 +54,6 @@ CREATE TABLE `zh_material_stage_bills`  (
   INDEX `tid`(`tid`) USING BTREE,
   INDEX `mid`(`mid`) USING BTREE
 ) ENGINE = InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+ALTER TABLE `zh_project_account`
+ADD COLUMN `invalid_time`  varchar(50) NOT NULL DEFAULT '' AFTER `wx_name`;