Forráskód Böngészése

1. 树结构速度优化
2. 树结构上一次优化产生的bug
3. 界面调整等

MaiXinRong 6 éve
szülő
commit
b2c708724b

+ 12 - 12
app/const/spread.js

@@ -10,15 +10,15 @@
 
 const ledgerSpread = {
     cols: [
-        {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 150, cellType: 'tree'},
-        {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 80},
-        {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 230},
-        {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 50},
+        {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 150, formatter: '@', cellType: 'tree'},
+        {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 80, formatter: '@'},
+        {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 230, formatter: '@'},
+        {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 50, formatter: '@'},
         {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number'},
         {title: '数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 60, type: 'Number'},
         {title: '金额', colSpan: '1', rowSpan: '2', field: 'total_price', hAlign: 2, width: 60, type: 'Number'},
-        {title: '图(册)号', colSpan: '1', rowSpan: '2', field: 'drawingCode', hAlign: 0, width: 80},
-        {title: '备注', colSpan: '1', rowSpan: '2', field: 'memo', hAlign: 0, width: 100}
+        {title: '图(册)号', colSpan: '1', rowSpan: '2', field: 'drawingCode', hAlign: 0, width: 80, formatter: '@'},
+        {title: '备注', colSpan: '1', rowSpan: '2', field: 'memo', hAlign: 0, width: 100, formatter: '@'}
     ],
     emptyRows: 3,
     headRows: 2,
@@ -28,10 +28,10 @@ const ledgerSpread = {
 
 const measureSpread = {
     cols: [
-        {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 150, readOnly: true, cellType: 'tree'},
-        {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 80, readOnly: true},
-        {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 230, readOnly: true},
-        {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, readOnly: true},
+        {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 150, formatter: '@', readOnly: true, cellType: 'tree'},
+        {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
+        {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 230, formatter: '@', readOnly: true},
+        {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: true},
         {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
         {title: '0号台账合同|数量', colSpan: '2|1', rowSpan: '1|1', field: 'quantity', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
         {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
@@ -41,8 +41,8 @@ const measureSpread = {
         {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'qc_totalprice', hAlign: 2, width: 60, type: 'Number'},
         {title: '本次完成计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'gather_quantity', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
         {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'gather_totalprice', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
-        {title: '图(册)号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, readOnly: true},
-        {title: '备注', colSpan: '1', rowSpan: '2', field: 'memo', hAlign: 0, width: 100, readOnly: true},
+        {title: '图(册)号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
+        {title: '备注', colSpan: '1', rowSpan: '2', field: 'memo', hAlign: 0, width: 100, formatter: '@', readOnly: true},
     ],
     emptyRows: 3,
     headRows: 2,

+ 32 - 26
app/controller/ledger_controller.js

@@ -39,34 +39,40 @@ module.exports = app => {
          * @return {void}
          */
         async explode(ctx) {
-            const tenderId = ctx.session.sessionUser.tenderId;
-            const tenderList = ctx.tenderList;
-            const tenderData = ctx.tenderData;
+            try {
+                const tenderId = ctx.session.sessionUser.tenderId;
+                const tenderList = ctx.tenderList;
+                const tenderData = ctx.tenderData;
 
-            if (!tenderData.ledger_status) {
-                tenderData.ledger_status = auditConst.status.uncheck;
-            }
-            if (!tenderData.ledger_times) {
-                tenderData.ledger_times = 1;
+                if (!tenderData.ledger_status) {
+                    tenderData.ledger_status = auditConst.status.uncheck;
+                }
+                if (!tenderData.ledger_times) {
+                    tenderData.ledger_times = 1;
+                }
+                const curAuditor = await ctx.service.ledgerAudit.getCurAuditor(tenderId, tenderData.ledger_times);
+                const times = tenderData.ledger_status === auditConst.status.checkNo ? tenderData.ledger_times - 1 : tenderData.ledger_times;
+                const auditors = await ctx.service.ledgerAudit.getAuditors(tenderId, times);
+                const content = auditors.length > 0 ? await ctx.service.ledgerAuditContent.getAllDataByCondition({
+                    where: {tender_id: tenderId, times: times, audit_id: auditors[0].audit_id}
+                }) : null;
+                const ledgerData = await ctx.service.ledger.getDataByTenderId(tenderId, 4);
+                console.log(ledgerData.length);
+                const renderData = {
+                    tenderData,
+                    auditConst,
+                    auditors,
+                    curAuditor,
+                    content,
+                    ledger: JSON.stringify(ledgerData),
+                    ledgerSpreadSetting: JSON.stringify(spreadConst.ledgerSpread),
+                    tenderList,
+                };
+                await this.layout('ledger/explode.ejs', renderData, 'ledger/explode_modal.ejs');
+            } catch (err) {
+                console.log(err);
+                await this.layout('/dashboard');
             }
-            const curAuditor = await ctx.service.ledgerAudit.getCurAuditor(tenderId, tenderData.ledger_times);
-            const times = tenderData.ledger_status === auditConst.status.checkNo ? tenderData.ledger_times - 1 : tenderData.ledger_times;
-            const auditors = await ctx.service.ledgerAudit.getAuditors(tenderId, times);
-            const content = await ctx.service.ledgerAuditContent.getAllDataByCondition({
-                where: {tender_id: tenderId, times: times, audit_id: auditors[0].audit_id}
-            });
-            const ledgerData = await ctx.service.ledger.getDataByTenderId(tenderId, 4);
-            const renderData = {
-                tenderData,
-                auditConst,
-                auditors,
-                curAuditor,
-                content,
-                ledger: JSON.stringify(ledgerData),
-                ledgerSpreadSetting: JSON.stringify(spreadConst.ledgerSpread),
-                tenderList,
-            };
-            await this.layout('ledger/explode.ejs', renderData, 'ledger/explode_modal.ejs');
         }
 
         /**

+ 33 - 0
app/middleware/gzip.js

@@ -0,0 +1,33 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+const isJSON = require('koa-is-json');
+const zlib = require('zlib');
+
+module.exports = options => {
+    return async function gzip(ctx, next) {
+        await next();
+
+        // 后续中间件执行完成后将响应体转换成 gzip
+        let body = ctx.body;
+        if (!body) return;
+
+        // 支持 options.threshold
+        if (options.threshold && ctx.length < options.threshold) return;
+
+        if (isJSON(body)) body = JSON.stringify(body);
+
+        // 设置 gzip body,修正响应头
+        const stream = zlib.createGzip();
+        stream.end(body);
+        ctx.body = stream;
+        ctx.set('Content-Encoding', 'gzip');
+    };
+};

+ 1 - 0
app/middleware/tender_select.js

@@ -46,6 +46,7 @@ module.exports = options => {
                 yield next;
             }
         } catch (err) {
+            console.log(err);
             this.redirect(this.menuList.dashboard.url);
         }
     };

+ 39 - 24
app/public/js/ledger.js

@@ -124,9 +124,9 @@ $(document).ready(function() {
                 // 处理展开
                 if (data.expand) {
                     for (const e of data.expand) {
-                        const children = tree.getChildren(e);
-                        for (const child of children) {
-                            sheet.setRowVisible(tree.nodes.indexOf(child), child.visible);
+                        const posterity = tree.getPosterity(e);
+                        for (const p of posterity) {
+                            sheet.setRowVisible(tree.nodes.indexOf(p), p.visible);
                         }
                     }
                 }
@@ -586,12 +586,15 @@ $(document).ready(function() {
                     keys: ['id', 'list_id', 'chapter_id'],
                 }, {
                     cols: [
-                        {title: '项目节编号', field: 'code', width: 120, readOnly: true, cellType: 'tree'},
-                        {title: '名称', field: 'name', width: 230, readOnly: true},
-                        {title: '单位', field: 'unit', width: 50, readOnly: true}
+                        {title: '项目节编号', field: 'code', width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
+                        {title: '名称', field: 'name', width: 230, formatter: '@', readOnly: true},
+                        {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true}
                     ],
                     treeCol: 0,
-                    emptyRows: 0
+                    emptyRows: 0,
+                    headRows: 1,
+                    headRowHeight: [40],
+                    defaultRowHeight: 21,
                 });
                 stdChapter.loadLib(1);
             } else if (tab.attr('content') === '#std-bills' && !stdBills) {
@@ -604,24 +607,30 @@ $(document).ready(function() {
                     keys: ['id', 'list_id', 'bill_id']
                 }, {
                     cols: [
-                        {title: '清单编号', field: 'code', width: 120, readOnly: true, cellType: 'tree'},
-                        {title: '名称', field: 'name', width: 230, readOnly: true},
-                        {title: '单位', field: 'unit', width: 50, readOnly: true}
+                        {title: '清单编号', field: 'code', width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
+                        {title: '名称', field: 'name', width: 230, formatter: '@', readOnly: true},
+                        {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true}
                     ],
                     treeCol: 0,
-                    emptyRows: 0
+                    emptyRows: 0,
+                    headRows: 1,
+                    headRowHeight: [40],
+                    defaultRowHeight: 21,
                 });
                 stdBills.loadLib(1);
             } else if (tab.attr('content') === '#deal-bills' && !dealBills) {
                 dealBills = new DealBills($('#deal-bills-spread')[0], {
                     cols: [
-                        {title: '清单编号', field: 'code', width: 120, readOnly: true},
-                        {title: '名称', field: 'name', width: 230, readOnly: true},
-                        {title: '单位', field: 'unit', width: 50, readOnly: true},
+                        {title: '清单编号', field: 'code', width: 120, formatter: '@', readOnly: true},
+                        {title: '名称', field: 'name', width: 230, formatter: '@', readOnly: true},
+                        {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true},
                         {title: '单价', field: 'unit_price', width: 50, readOnly: true},
                         {title: '数量', field: 'quantity', width: 50, readOnly: true},
                     ],
                     emptyRows: 0,
+                    headRows: 1,
+                    headRowHeight: [40],
+                    defaultRowHeight: 21,
                 });
                 dealBills.loadData();
             }
@@ -664,7 +673,7 @@ $(document).ready(function() {
                     treeOperationObj.refreshOperationValid(mainSheet, mainSheet.getSelections());
                 });
             });
-            this.pathTree = createNewPathTree(this.treeSetting);
+            this.pathTree = createNewPathTree('active', this.treeSetting);
         }
         loadLib (listId) {
             const self = this;
@@ -709,24 +718,28 @@ $(document).ready(function() {
 
             this.xmSpreadSetting = {
                 cols: [
-                    {title: '部位', field: 'bw', width: 80, readOnly: true},
-                    {title: '图册号', field: 'drawingCode', width: 60, readOnly: true},
+                    {title: '部位', field: 'bw', width: 80, formatter: '@', readOnly: true},
+                    {title: '图册号', field: 'drawingCode', formatter: '@', width: 60, readOnly: true},
                     {title: '数量1', field: 'bills1', width: 50, readOnly: true},
                     {title: '数量2', field: 'bills2', width: 50, readOnly: true},
                 ],
                 emptyRows: 6,
+                headRows: 1,
+                headRowHeight: [40],
             };
             this.xmSpread = SpreadJsObj.createNewSpread($('.batch-l-t')[0]);
 
             this.gclSpreadSetting = {
                 cols: [
-                    {title: '编号', field: 'code', width: 80, readOnly: true},
-                    {title: '名称', field: 'name', width: 120, readOnly: true},
-                    {title: '单位', field: 'unit', width: 50, readOnly: true},
+                    {title: '编号', field: 'code', width: 80, formatter: '@', readOnly: true},
+                    {title: '名称', field: 'name', width: 120, formatter: '@', readOnly: true},
+                    {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true},
                     {title: '单价', field: 'unit_price', width: 50, readOnly: true},
-                    {title: '图册号', field: 'name', width: 60, readOnly: true},
+                    {title: '图册号', field: 'name', width: 60, formatter: '@', readOnly: true},
                 ],
                 emptyRows: 2,
+                headRows: 1,
+                headRowHeight: [40],
             };
             this.gclSpread = SpreadJsObj.createNewSpread($('.batch-l-b')[0]);
 
@@ -734,12 +747,14 @@ $(document).ready(function() {
 
             this.dealSpreadSetting = {
                 cols: [
-                    {title: '清单编号', field: 'code', width: 80, readOnly: true},
-                    {title: '名称', field: 'name', width: 120, readOnly: true},
-                    {title: '单位', field: 'unit', width: 50, readOnly: true},
+                    {title: '清单编号', field: 'code', width: 80, formatter: '@', readOnly: true},
+                    {title: '名称', field: 'name', width: 120, formatter: '@', readOnly: true},
+                    {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true},
                     {title: '单价', field: 'unit_price', width: 50, readOnly: true},
                 ],
                 emptyRows: 0,
+                headRows: 1,
+                headRowHeight: [40],
             };
             this.dealSpread = SpreadJsObj.createNewSpread($('.batch-r')[0]);
             SpreadJsObj.initSheet(this.dealSpread.getActiveSheet(), this.dealSpreadSetting);

+ 57 - 17
app/public/js/path_tree.js

@@ -29,12 +29,15 @@ const createNewPathTree = function (type, setting) {
         /**
          * 树结构根据显示排序
          */
-        sortTreeNode () {
+        sortTreeNode (isResort) {
             const self = this;
             const addSortNodes = function (nodes) {
+                if (!nodes) { return }
                 for (let i = 0; i < nodes.length; i++) {
                     self.nodes.push(nodes[i]);
-                    nodes[i].children = self.getChildren(nodes[i]);
+                    if (!isResort) {
+                        nodes[i].children = self.getChildren(nodes[i]);
+                    }
                     addSortNodes(nodes[i].children);
                 }
             };
@@ -135,7 +138,10 @@ const createNewPathTree = function (type, setting) {
          * @private
          */
         _refreshChildrenVisible (node) {
-            const children = node.children;//this.getChildren(node);
+            if (!node.children) {
+                node.children = this.getChildren(node);
+            }
+            const children = node.children;
             for (const child of children) {
                 child.visible = node.expanded && node.visible;
                 this._refreshChildrenVisible(child);
@@ -326,7 +332,7 @@ const createNewPathTree = function (type, setting) {
                 const children = this.getChildren(node);
                 node.expanded = children.length > 0 && children[0].visible;
             }
-            this.sortTreeNode();
+            this.sortTreeNode(true);
             return loadedData;
         };
         /**
@@ -336,13 +342,17 @@ const createNewPathTree = function (type, setting) {
          * @privateA
          */
         _loadData (datas) {
-            const loadedData = [];
+            const loadedData = [], resortData = [];
             for (const data of datas) {
                 let node = this.getItems(data[this.setting.id]);
                 if (node) {
+                    const parent = this.getItems(node[this.setting.pid]);
                     for (const prop in node) {
-                        if (data[prop] !== undefined) {
+                        if (data[prop] !== undefined && data[prop] !== node[prop]) {
                             node[prop] = data[prop];
+                            if (parent && resortData.indexOf(parent) === -1) {
+                                resortData.push(parent);
+                            }
                         }
                     }
                     loadedData.push(node);
@@ -354,12 +364,22 @@ const createNewPathTree = function (type, setting) {
                     node.expanded = false;
                     node.visible = true;
                     loadedData.push(node);
+                    if (resortData.indexOf(node) === -1) {
+                        resortData.push(node);
+                    }
+                    const parent = this.getItems(node[this.setting.pid]);
+                    if (parent && resortData.indexOf(parent) === -1) {
+                        resortData.push(parent);
+                    }
                 }
             }
-            this.sortTreeNode();
+            for (const node of resortData) {
+                node.children = this.getChildren(node);
+            }
+            this.sortTreeNode(true);
             for (const node of loadedData) {
                 const children = node.children;
-                if (!node.expanded && children.length > 0) {
+                if (!node.expanded && children && children.length > 0) {
                     node.expanded = true;
                     this._refreshChildrenVisible(node);
                 }
@@ -382,7 +402,9 @@ const createNewPathTree = function (type, setting) {
                     delete this.items[itemsPre + node[this.setting.id]];
                     if (node[this.setting.pid] !== this.setting.rootId) {
                         const parent = this.getItems(node[this.setting.pid]);
-                        removeArrayData(parent.children, node);
+                        if (parent) {
+                            removeArrayData(parent.children, node);
+                        }
                     }
                     removeArrayData(this.datas, node);
                     removeArrayData(this.nodes, node);
@@ -396,7 +418,8 @@ const createNewPathTree = function (type, setting) {
          * @private
          */
         _loadExpandData (datas) {
-            const loadedData = [], existData = [], expandData = [];
+            console.log(datas);
+            const loadedData = [], existData = [], expandData = [], resortData = [];
             for (const data of datas) {
                 let node = this.getItems(data[this.setting.id]);
                 if (node) {
@@ -409,24 +432,40 @@ const createNewPathTree = function (type, setting) {
                     node.expanded = false;
                     node.visible = true;
                     loadedData.push(node);
+
+                    if (resortData.indexOf(node) === -1) {
+                        resortData.push(node);
+                    }
+                    const parent = this.getItems(node[this.setting.pid]);
+                    if (parent && resortData.indexOf(parent) === -1) {
+                        resortData.push(parent);
+                    }
                 }
             }
-            this.sortTreeNode();
+            //this.sortTreeNode();
+            for (const node of resortData) {
+                node.children = this.getChildren(node);
+            }
+            this.sortTreeNode(true);
             for (const node of loadedData) {
-                const children = node.children();
+                const children = node.children;
                 if (!node.expanded && children.length > 0) {
                     node.expaned = true;
                     this._refreshChildrenVisible(node);
                 }
             }
             for (const node of existData) {
-                const children = node.children();
-                if (!node.expanded && children.length > 0) {
-                    node.expanded = children.length > 0;
-                    this._refreshChildrenVisible(node);
-                    expandData.push(node);
+                const parent = this.getItems(node[this.setting.pid]);
+                if (expandData.indexOf(parent) === -1) {
+                    expandData.push(parent);
+                    const children = parent.children;
+                    if (!parent.expanded && children.length > 0) {
+                        parent.expanded = true;
+                        this._refreshChildrenVisible(parent);
+                    }
                 }
             }
+            console.log(expandData);
             return [loadedData, expandData];
         };
 
@@ -536,6 +575,7 @@ const createNewPathTree = function (type, setting) {
             data.id = node[self.setting.id];
             postData(url, data, function (datas) {
                 const result = {};
+                console.log(datas);
                 if (datas.update) {
                     result.update = self._updateData(datas.update);
                 }

+ 13 - 8
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -162,7 +162,8 @@ const SpreadJsObj = {
             }
             for (let iCol = 0; iCol < sheet.zh_setting.cols.length; iCol++) {
                 const col = sheet.zh_setting.cols[iCol];
-                const title = col.title.split('|'), colSpan = col.colSpan.split('|'), rowSpan = col.rowSpan.split('|');
+                const title = col.title.split('|');
+                const colSpan = col.colSpan ? col.colSpan.split('|'): ['1'], rowSpan = col.rowSpan ? col.rowSpan.split('|'): ['1'];
                 for (let i = 0; i < title.length; i++) {
                     const cell = sheet.getCell(i, iCol, spreadNS.SheetArea.colHeader);
                     cell.text(title[i]);
@@ -233,6 +234,9 @@ const SpreadJsObj = {
                     }
                     sheet.getRange(-1, j, -1, 1).cellType(sheet.extendCellType.tip);
                 }
+                if (col.formatter) {
+                    sheet.getRange(-1, j, -1, 1).format(col.formatter);
+                }
             });
             this.endMassOperation(sheet);
         } catch (err) {
@@ -263,6 +267,9 @@ const SpreadJsObj = {
                     } else {
                         cell.locked(col.readOnly || sheet.zh_setting.readOnly || false).vAlign(1).hAlign(col.hAlign);
                     }
+                    if (col.formatter) {
+                        cell.formatter(col.formatter);
+                    }
                 });
             };
             // 设置列单元格格式
@@ -311,6 +318,9 @@ const SpreadJsObj = {
                         cell.locked(col.readOnly || sheet.zh_setting.readOnly || false).vAlign(1).hAlign(col.hAlign);
                     }
                     // 设置单元格格式
+                    if (col.formatter) {
+                        cell.formatter(col.formatter);
+                    }
                     if (col.cellType) {
                         if (col.cellType === 'tree') {
                             if (!sheet.extendCellType.tree) {
@@ -613,7 +623,8 @@ const SpreadJsObj = {
 
                 // 点击展开节点时,如果已加载子项,则展开,反之这加载子项,展开
                 if (Math.abs(hitinfo.x - centerX) < halfBoxLength && Math.abs(hitinfo.y - centerY) < halfBoxLength) {
-                    if (!node.expanded && !node.is_leaf && tree.getChildren(node).length === 0 && tree.loadChildren) {
+                    const children = tree.getChildren(node);
+                    if (!node.expanded && !node.is_leaf && children.length === 0 && tree.loadChildren) {
                         tree.loadChildren(node, function () {
                             node.expanded = true;
                             const children = tree.getChildren(node);
@@ -621,19 +632,13 @@ const SpreadJsObj = {
                             SpreadJsObj.reLoadRowData(hitinfo.sheet, hitinfo.row + 1, children.length);
                         });
                     } else {
-                        const time = new Date();
                         tree.setExpanded(node, !node.expanded);
-                        console.log(node.code + ':calc');
-                        console.log(new Date() - time);
 
                         SpreadJsObj.massOperationSheet(hitinfo.sheet, function () {
                             const posterity = tree.getPosterity(node);
-                            const time = new Date();
                             for (const child of posterity) {
                                 hitinfo.sheet.setRowVisible(tree.nodes.indexOf(child), child.visible, hitinfo.sheetArea);
                             }
-                            console.log(node.code + ':refreshView');
-                            console.log(new Date() - time);
                         });
                         hitinfo.sheet.repaint();
                     }

+ 1 - 1
app/service/project_account.js

@@ -40,7 +40,7 @@ module.exports = app => {
                     rule = {
                         account: { type: 'string', required: true, min: 2 },
                         project_password: { type: 'string', required: true, min: 4 },
-                        project: { type: 'string', required: true, min: 13 },
+                        project: { type: 'string', required: true, min: 5 },
                     };
                     break;
                 case 'ssoLogin':

+ 11 - 3
app/view/stage/modal.ejs

@@ -8,11 +8,15 @@
             <div class="modal-body">
                 <div class="form-group">
                     <label>期</label>
-                    <input class="form-control" value="第 <%- stages.length + 1 %> 期" type="text" name="stageName">
+                    <input class="form-control" value="第 4 期" type="text" readonly="" name="stageName">
                 </div>
                 <div class="form-group">
-                    <label>计量月份</label>
-                    <input class="form-control" type="month" name="stageTime">
+                    <label>计量年月</label>
+                    <input class="datepicker-here form-control" placeholder="点击选择年月" data-view="months" data-min-view="months" data-date-format="yyyy-MM" data-language="zh" type="text" name="stageTime">
+                </div>
+                <div class="form-group">
+                    <label>开始-截止日期</label>
+                    <input class="datepicker-here form-control" placeholder="点击选择时间" data-range="true" data-multiple-dates-separator=" ~ " data-language="zh" type="text" name="rangeTime">
                 </div>
             </div>
             <div class="modal-footer">
@@ -27,9 +31,13 @@
     $(document).ready(() => {
         $('input[type=month]').val(moment().format('YYYY-MM'));
         $('#addOk').click(function () {
+            const rangeTime = $('input[name=rangeTime]');
+
             const data = {
                 name: $('input[name=stageName]').val(),
                 time: $('input[name=stageTime]').val(),
+                begin_time: rangeTime.val().split(' ~ '),
+                be_time: $('input[name=rangeTime]').val(),
             };
             postData('/stage/add', data, function (rst) {
                 window.location.href = '/stage/' + rst.order + '/measure';

+ 6 - 1
config/config.default.js

@@ -14,7 +14,7 @@ module.exports = appInfo => {
             // 用户名
             user: 'root',
             // 密码
-            password: 'root',
+            password: 'smartcost',
             // 数据库名
             database: 'calculation',
         },
@@ -108,5 +108,10 @@ module.exports = appInfo => {
     // 是否压缩替换前端js
     config.min = false;
 
+    // 压缩设置
+    config.gzip = {
+        threshold: 1024,
+    };
+
     return config;
 };

+ 3 - 1
package.json

@@ -14,6 +14,7 @@
     "egg-view": "^1.1.2",
     "egg-view-ejs": "^1.1.0",
     "gt3-sdk": "^2.0.0",
+    "koa-is-json": "^1.0.0",
     "moment": "^2.20.1",
     "node-uuid": "^1.4.8",
     "node-xlsx": "^0.12.0",
@@ -21,7 +22,8 @@
     "ueditor": "^1.2.3",
     "uglify-es": "^3.3.9",
     "uglify-js": "^3.3.27",
-    "xmlreader": "^0.2.3"
+    "xmlreader": "^0.2.3",
+    "zlib": "^1.0.5"
   },
   "devDependencies": {
     "autod": "^2.9.0",