瀏覽代碼

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

TonyKang 4 年之前
父節點
當前提交
839583e9f9

+ 2 - 0
.gitignore

@@ -12,3 +12,5 @@ app/public/upload/
 package-lock.json
 package-lock.json
 app/public/js/web
 app/public/js/web
 .vscode/
 .vscode/
+/report_temp
+/file

+ 9 - 5
app/controller/tender_controller.js

@@ -33,7 +33,7 @@ module.exports = app => {
             ctx.showTitle = true;
             ctx.showTitle = true;
         }
         }
 
 
-        async _getLedgerAuditInfo (tender) {
+        async _getLedgerAuditInfo(tender) {
             tender.cur_flow = {
             tender.cur_flow = {
                 title: '台账',
                 title: '台账',
                 status: auditConst.ledger.tiStatusString[tender.ledger_status],
                 status: auditConst.ledger.tiStatusString[tender.ledger_status],
@@ -59,7 +59,7 @@ module.exports = app => {
             }
             }
         }
         }
 
 
-        async _getStageAuditInfo (tender, stage) {
+        async _getStageAuditInfo(tender, stage) {
             tender.cur_flow = {
             tender.cur_flow = {
                 title: '第' + stage.order + '期',
                 title: '第' + stage.order + '期',
                 status: auditConst.stage.tiStatusString[stage.status],
                 status: auditConst.stage.tiStatusString[stage.status],
@@ -73,11 +73,11 @@ module.exports = app => {
                     tender.cur_flow.name = user.name;
                     tender.cur_flow.name = user.name;
                 }
                 }
                 if (stage.order > 1) {
                 if (stage.order > 1) {
-                    const preStage = await this.ctx.service.stage.getDataByCondition({ tid: tender.id, order: stage.order - 1});
+                    const preStage = await this.ctx.service.stage.getDataByCondition({ tid: tender.id, order: stage.order - 1 });
                     if (!preStage) return;
                     if (!preStage) return;
 
 
                     const pre = await this.ctx.service.stageAudit.getLastestAuditor(preStage.id, preStage.times, auditConst.stage.status.checked);
                     const pre = await this.ctx.service.stageAudit.getLastestAuditor(preStage.id, preStage.times, auditConst.stage.status.checked);
-                    if (pre) tender.pre_flow = { name: pre.name, time: pre.end_time};
+                    if (pre) tender.pre_flow = { name: pre.name, time: pre.end_time };
                 }
                 }
             } else {
             } else {
                 let cur;
                 let cur;
@@ -120,7 +120,7 @@ module.exports = app => {
 
 
                 for (const t of tenderList) {
                 for (const t of tenderList) {
                     if (t.user_id === this.ctx.session.sessionUser.accountId && (
                     if (t.user_id === this.ctx.session.sessionUser.accountId && (
-                            t.ledger_status === auditConst.ledger.status.checkNo || t.ledger_status === auditConst.ledger.status.uncheck)) {
+                        t.ledger_status === auditConst.ledger.status.checkNo || t.ledger_status === auditConst.ledger.status.uncheck)) {
                         const sum = await this.ctx.service.ledger.addUp({ tender_id: t.id/* , is_leaf: true*/ });
                         const sum = await this.ctx.service.ledger.addUp({ tender_id: t.id/* , is_leaf: true*/ });
                         t.total_price = sum.total_price;
                         t.total_price = sum.total_price;
                         t.deal_tp = sum.deal_tp;
                         t.deal_tp = sum.deal_tp;
@@ -426,7 +426,11 @@ module.exports = app => {
                     p.end_ratio = ctx.helper.mul(ctx.helper.div(p.end_tp, tender.sum, 4), 100);
                     p.end_ratio = ctx.helper.mul(ctx.helper.div(p.end_tp, tender.sum, 4), 100);
                 }
                 }
                 const revise = await ctx.service.ledgerRevise.getLastestRevise(tender.id);
                 const revise = await ctx.service.ledgerRevise.getLastestRevise(tender.id);
+                const tenders = await ctx.service.tender.getList('', null, 1);
+                const categoryData = await ctx.service.category.getAllCategory(ctx.session.sessionProject.id);
                 const renderData = {
                 const renderData = {
+                    tenders,
+                    categoryData,
                     tender,
                     tender,
                     revise,
                     revise,
                     tenderInfo: ctx.tender.info,
                     tenderInfo: ctx.tender.info,

+ 7 - 2
app/lib/analysis_excel.js

@@ -323,9 +323,12 @@ class ImportStd18Tree extends ImportBaseTree {
      * @private
      * @private
      */
      */
     _checkParent(parent, code) {
     _checkParent(parent, code) {
+        if (code === 'LJ0703') console.log(parent.code, code);
+        const codeNumberPart = code.replace(gdXmjPartReg, '');
         if (!parent.code) return false;
         if (!parent.code) return false;
         const numberPart = parent.code.replace(gdXmjPartReg, '');
         const numberPart = parent.code.replace(gdXmjPartReg, '');
-        if (!numberPart) return false;
+        if (code === 'LJ0703') console.log(numberPart, codeNumberPart);
+        if (!numberPart || !codeNumberPart || numberPart.length >= codeNumberPart.length) return false;
         return code.indexOf(numberPart) === 0 ||
         return code.indexOf(numberPart) === 0 ||
             code.indexOf('G' + numberPart) === 0 ||
             code.indexOf('G' + numberPart) === 0 ||
             code.indexOf('GD' + numberPart) === 0;
             code.indexOf('GD' + numberPart) === 0;
@@ -355,7 +358,7 @@ class ImportStd18Tree extends ImportBaseTree {
      */
      */
     findSubXmjParent(code) {
     findSubXmjParent(code) {
         let parent = this.cacheSubXmjNode;
         let parent = this.cacheSubXmjNode;
-        while (parent && parent.code.match(subReg)) {
+        while (parent && parent.is_sub && parent.code.match(subReg)) {
             if (this._checkParent(parent, code)) return parent;
             if (this._checkParent(parent, code)) return parent;
             parent = this.nodes[parent.ledger_pid];
             parent = this.nodes[parent.ledger_pid];
         }
         }
@@ -385,9 +388,11 @@ class ImportStd18Tree extends ImportBaseTree {
         super.defineCacheData(node);
         super.defineCacheData(node);
         if (node.code) {
         if (node.code) {
             if (node.code.match(mainReg)) {
             if (node.code.match(mainReg)) {
+                node.is_main = true;
                 this.cacheMainXmjNode = node;
                 this.cacheMainXmjNode = node;
                 this.cacheSubXmjNode = null;
                 this.cacheSubXmjNode = null;
             } else if (node.code.match(subReg)) {
             } else if (node.code.match(subReg)) {
+                node.is_sub = true;
                 this.cacheSubXmjNode = node;
                 this.cacheSubXmjNode = node;
             }
             }
             if (node.code.match(specCode106.reg)) {
             if (node.code.match(specCode106.reg)) {

+ 7 - 3
app/lib/rpt_data_analysis.js

@@ -299,7 +299,8 @@ const gatherChapter = {
         sum: {
         sum: {
             name: '合计',
             name: '合计',
             order: 4,
             order: 4,
-        }
+        },
+        filter: [{node_type: standard.nodeType.find(function (x) {return x.text === '计日工'}).value}, {field: 'name', part: '计日工'}],
     },
     },
     customSetting1: {
     customSetting1: {
         count: 7,
         count: 7,
@@ -541,8 +542,9 @@ const gatherChapter = {
             this._completeStageSumInfo(otherChapter, sourceData[0]);
             this._completeStageSumInfo(otherChapter, sourceData[0]);
             this._completeStageSumInfo(customChapter, sourceData[0]);
             this._completeStageSumInfo(customChapter, sourceData[0]);
         }
         }
-        const filter = [];
+        const filter = [], defaultFilter = [];
         for (const d of sourceData) {
         for (const d of sourceData) {
+            if (this._checkMatch(this.defaultSetting.filter, d)) defaultFilter.push(d.full_path);
             for (const c of customChapter) {
             for (const c of customChapter) {
                 if (c.match && this._checkMatch(c.match, d)) {
                 if (c.match && this._checkMatch(c.match, d)) {
                     gatherData(c, d);
                     gatherData(c, d);
@@ -562,7 +564,9 @@ const gatherChapter = {
                 }
                 }
             }
             }
             if (d.b_code) {
             if (d.b_code) {
-                const c = this._getGclChapter(gclChapter, d, 'b_code');
+                const c = this._checkFilter(d.full_path, defaultFilter)
+                    ? gclChapter.find(x => {return x.cType === 21})
+                    : this._getGclChapter(gclChapter, d, 'b_code');
                 if (c) {
                 if (c) {
                     gatherData(c, d);
                     gatherData(c, d);
                 }
                 }

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

@@ -489,7 +489,6 @@ const gclGatherModel = (function () {
                 if (c.cType === 11 && (d.b_code)) {
                 if (c.cType === 11 && (d.b_code)) {
                     gatherfields(c, d, fields);
                     gatherfields(c, d, fields);
                 }
                 }
-                if (!checkFilterPath(d)) continue;
                 if (c.cType === 31 && (!d.b_code || d.b_code === '')) {
                 if (c.cType === 31 && (!d.b_code || d.b_code === '')) {
                     gatherfields(c, d, fields);
                     gatherfields(c, d, fields);
                 }
                 }

+ 0 - 1
app/public/js/shares/gcl_gather_compare.js

@@ -325,7 +325,6 @@ const gclCompareModel = (function () {
                 if (c.cType === 11 && (d.b_code)) {
                 if (c.cType === 11 && (d.b_code)) {
                     gatherfields(c, d, ledgerSetting.chapterFields, ledgerSetting.prefix);
                     gatherfields(c, d, ledgerSetting.chapterFields, ledgerSetting.prefix);
                 }
                 }
-                if (!checkFilterPath(d)) continue;
                 if (c.cType === 31 && (!d.b_code || d.b_code === '')) {
                 if (c.cType === 31 && (!d.b_code || d.b_code === '')) {
                     gatherfields(c, d, ledgerSetting.chapterFields, ledgerSetting.prefix);
                     gatherfields(c, d, ledgerSetting.chapterFields, ledgerSetting.prefix);
                 }
                 }

+ 6 - 3
app/public/js/shares/tenders2tree.js

@@ -81,12 +81,15 @@ const Tender2Tree = (function () {
 
 
         for (const t of tenders) {
         for (const t of tenders) {
             const parent = (t.category && levelCategory.length > 0) ? loadCategoryTreeNode(t, levelCategory) : null;
             const parent = (t.category && levelCategory.length > 0) ? loadCategoryTreeNode(t, levelCategory) : null;
-            tenderTree.addNode({
+            const node = {
                 tid: t.id,
                 tid: t.id,
                 name: t.name,
                 name: t.name,
                 phase: t.lastStage ? '第' + t.lastStage.order + '期' : '台账',
                 phase: t.lastStage ? '第' + t.lastStage.order + '期' : '台账',
-                status: t.lastStage ? stageAuditConst.statusString[t.lastStage.status] : ledgerAuditConst.statusString[t.ledger_status]
-            }, parent);
+            };
+            if (ledgerAuditConst && stageAuditConst) {
+                node.status = t.lastStage ? stageAuditConst.statusString[t.lastStage.status] : ledgerAuditConst.statusString[t.ledger_status];
+            }
+            tenderTree.addNode(node, parent);
         }
         }
         tenderTree.sortTreeNode(false);
         tenderTree.sortTreeNode(false);
         return tenderTree;
         return tenderTree;

+ 2 - 3
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -797,12 +797,11 @@ const SpreadJsObj = {
         this.beginMassOperation(sheet);
         this.beginMassOperation(sheet);
         try {
         try {
             for (const col of cols) {
             for (const col of cols) {
-                const iCol = sheet.zh_setting.cols.indexOf(col);
                 // 清空原单元格数据
                 // 清空原单元格数据
-                sheet.clear(-1, iCol, -1, 1, spreadNS.SheetArea.viewport, spreadNS.StorageType.data);
+                sheet.clear(-1, col, -1, 1, spreadNS.SheetArea.viewport, spreadNS.StorageType.data);
 
 
                 for (const [iRow, data] of sortData.entries()) {
                 for (const [iRow, data] of sortData.entries()) {
-                    this._loadCellData(sheet, data, iRow, iCol);
+                    this._loadCellData(sheet, data, iRow, col);
                 }
                 }
             }
             }
             this.endMassOperation(sheet);
             this.endMassOperation(sheet);

+ 1 - 1
app/public/js/stage.js

@@ -3802,6 +3802,6 @@ $(document).ready(() => {
         const sheet = slSpread.getActiveSheet();
         const sheet = slSpread.getActiveSheet();
         const col = sheet.zh_setting.cols.find(x => {return x.field === 'end_gather_percent' || x.field === 'end_correct_percent'});
         const col = sheet.zh_setting.cols.find(x => {return x.field === 'end_gather_percent' || x.field === 'end_correct_percent'});
         col.field = this.checked ? 'end_correct_percent' : 'end_gather_percent';
         col.field = this.checked ? 'end_correct_percent' : 'end_gather_percent';
-        SpreadJsObj.reLoadColsData(sheet, [col]);
+        SpreadJsObj.reLoadColsData(sheet, [sheet.zh_setting.cols.indexOf(col)]);
     })
     })
 });
 });

+ 153 - 0
app/public/js/tender_copy_setting.js

@@ -0,0 +1,153 @@
+'use strict';
+
+/**
+ *
+ * @author LanJianRong
+ * @date 2020/11/13
+ * @version
+ */
+const tenderTree = [];
+let parentId = 0;
+// 查询方法
+function findNode (key, value, arr) {
+    for (const a of arr) {
+        if (a[key] && a[key] === value) {
+            return a;
+        }
+    }
+}
+// 初始化TenderTree数据
+function initTenderTree () {
+    const levelCategory = category.filter(function (c) {
+        return c.level && c.level > 0;
+    });
+    function findCategoryNode(cid, value, array) {
+        for (const a of array) {
+            if (a.cid === cid && a.vid === value) {
+                return a;
+            }
+        }
+    }
+    function getCategoryNode(category, value, parent, i = null) {
+        const array = parent ?  parent.children : tenderTree;
+        let cate = findCategoryNode(category.id, value, array);
+        if (!cate) {
+            const cateValue = findNode('id', value, category.value);
+            if (!cateValue) return null;
+            cate = {
+                cid: category.id,
+                vid: value,
+                name: cateValue.value,
+                children: [],
+                level: i ? i : category.level,
+                sort_id: ++parentId,
+                sort: cateValue.sort,
+            };
+            array.push(cate);
+        }
+        return cate;
+    }
+    function loadTenderCategory (tender) {
+        let tenderCategory = null;
+        for (const [index,lc] of levelCategory.entries()) {
+            const tenderCate = findNode('cid', lc.id, tender.category);
+            if (tenderCate) {
+                tenderCategory = getCategoryNode(lc, tenderCate.value, tenderCategory);
+            } else {
+                if (index === 0 && tender.category) {
+                    for (const [i,c] of tender.category.entries()) {
+                        const cate = findNode('id', c.cid, category);
+                        tenderCategory = getCategoryNode(cate, c.value, tenderCategory, i+1);
+                    }
+                }
+                return tenderCategory;
+            }
+        }
+        return tenderCategory;
+    }
+    function calculateTender(tender) {
+        if (tender.lastStage) {
+            tender.gather_tp = ZhCalc.add(tender.lastStage.contract_tp, tender.lastStage.qc_tp);
+            tender.end_contract_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.contract_tp);
+            tender.end_qc_tp = ZhCalc.add(tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp);
+            tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
+            tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp);
+            tender.yf_tp = ZhCalc.add(tender.lastStage.yf_tp);
+            tender.end_yf_tp = ZhCalc.add(tender.lastStage.pre_yf_tp, tender.yf_tp);
+        }
+    }
+    tenderTree.splice(0, tenderTree.length);
+    for (const t of tenders) {
+        calculateTender(t);
+        t.valid = true;
+        delete t.level;
+        if (t.category && levelCategory.length > 0) {
+            const parent = loadTenderCategory(t);
+            if (parent) {
+                t.level = parent.level + 1;
+                parent.children.push(t);
+            } else {
+                tenderTree.push(t);
+            }
+        } else {
+            tenderTree.push(t);
+        }
+    }
+}
+function recursiveGetTenderNodeHtml (node, arr, pid) {
+    const html = [];
+    html.push('<tr pid="' + pid + '">');
+    // 名称
+    html.push('<td class="in-' + node.level + '">');
+    if (node.cid) {
+        html.push('<i class="fa fa-folder-o"></i> ', node.name);
+    } else {
+        html.push('<span class="text-muted mr-2">');
+        html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
+        html.push('</span>');
+        //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
+        html.push('<a href="javascript: void(0)" id="' + node.id + '">', node.name, '</a>');
+    }
+    html.push('</td>');
+    // 创建人
+    html.push('<td>');
+    if (!node.cid) {
+        html.push('<input data-tid="'+ node.id +'" type="radio">');
+    }
+    html.push('</td>');
+    html.push('</tr>');
+    if (node.children) {
+        for (const c of node.children) {
+            html.push(recursiveGetTenderNodeHtml(c, node.children, node.sort_id));
+        }
+    }
+    return html.join('');
+}
+// 根据TenderTree数据获取Html代码
+function getTenderTreeHtml () {
+    if (tenderTree.length > 0) {
+        const html = [];
+        html.push('<table class="table table-hover table-bordered">');
+        html.push('<thead>', '<tr>');
+        html.push('<th>名称</th>');
+        html.push('<th width="40">选择</th>');
+        html.push('</tr>', '</thead>');
+        parentId = 0;
+        for (const t of tenderTree) {
+            html.push(recursiveGetTenderNodeHtml(t, tenderTree, ''));
+        }
+        html.push('</table>');
+        return html.join('');
+    } else {
+        return EmptyTenderHtml.join('');
+    }
+}
+$(document).ready(function () {
+    initTenderTree()
+    $('#copyBtn').click(() => {
+        console.log('1111')
+        const html = getTenderTreeHtml();
+        $('#copyModalContent').html(html)
+        $('#bd-set-8').modal('show')
+    })
+})

+ 414 - 358
app/service/report_memory.js

@@ -196,69 +196,81 @@ module.exports = app => {
         }
         }
 
 
         async getStageImTzData(tid, sid, fields, readCache = true) {
         async getStageImTzData(tid, sid, fields, readCache = true) {
-            await this.ctx.service.tender.checkTender(tid);
-            await this.ctx.service.stage.checkStage(sid);
-            if (readCache) {
-                const cache = await this._getReportMemoryCache('mem_stage_im_tz', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
-                if (cache) return cache;
-            }
+            try {
+                await this.ctx.service.tender.checkTender(tid);
+                await this.ctx.service.stage.checkStage(sid);
+                if (readCache) {
+                    const cache = await this._getReportMemoryCache('mem_stage_im_tz', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
+                    if (cache) return cache;
+                }
 
 
-            if (!this.stageImData) {
-                this.stageImData = {};
-                try {
-                    await this._generateStageIm(tid, sid);
-                } catch (err) {
-                    if (err.stack) {
-                        this.ctx.logger.error(err);
+                if (!this.stageImData) {
+                    this.stageImData = {};
+                    try {
+                        await this._generateStageIm(tid, sid);
+                    } catch (err) {
+                        if (err.stack) {
+                            this.ctx.logger.error(err);
+                        }
+                        this.stageImData.main = err.stack ? '数据错误' : err;
+                        this.stageImData.bills = this.stageImData.main;
                     }
                     }
-                    this.stageImData.main = err.stack ? '数据错误' : err;
-                    this.stageImData.bills = this.stageImData.main;
                 }
                 }
+                return this.stageImData.main;
+            } catch (err) {
+                return [];
             }
             }
-            return this.stageImData.main;
         }
         }
 
 
         async getStageImTzBillsData(tid, sid, fields, readCache = true) {
         async getStageImTzBillsData(tid, sid, fields, readCache = true) {
-            await this.ctx.service.tender.checkTender(tid);
-            await this.ctx.service.stage.checkStage(sid);
-            if (readCache) {
-                const cache = await this._getReportMemoryCache('mem_stage_im_tz_bills', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
-                if (cache) return cache;
+            try {
+                await this.ctx.service.tender.checkTender(tid);
+                await this.ctx.service.stage.checkStage(sid);
+                if (readCache) {
+                    const cache = await this._getReportMemoryCache('mem_stage_im_tz_bills', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
+                    if (cache) return cache;
+                }
+
+                if (!this.stageImData) {
+                    this.stageImData = {};
+                    try {
+                        await this._generateStageIm(tid, sid);
+                    } catch (err) {
+                        if (err.stack) {
+                            this.ctx.logger.error(err);
+                        }
+                        this.stageImData.main = err.stack ? '数据错误' : err;
+                        this.stageImData.bills = this.stageImData.main;
+                    }
+                }
+                return this.stageImData.bills;
+            } catch (err) {
+                return [];
             }
             }
+        }
+
+        async getStageImZlData(tid, sid, fields, readCache = true) {
+            try {
+                await this.ctx.service.tender.checkTender(tid);
+                await this.ctx.service.stage.checkStage(sid);
+                if (readCache) {
+                    const cache = await this._getReportMemoryCache('mem_stage_im_zl', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
+                    if (cache) return cache;
+                }
 
 
-            if (!this.stageImData) {
                 this.stageImData = {};
                 this.stageImData = {};
                 try {
                 try {
-                    await this._generateStageIm(tid, sid);
+                    await this._generateStageIm(tid, sid, false);
                 } catch (err) {
                 } catch (err) {
                     if (err.stack) {
                     if (err.stack) {
                         this.ctx.logger.error(err);
                         this.ctx.logger.error(err);
                     }
                     }
-                    this.stageImData.main = err.stack ? '数据错误' : err;
-                    this.stageImData.bills = this.stageImData.main;
+                    this.stageImData.main = err.statck ? '数据错误' : err;
                 }
                 }
-            }
-            return this.stageImData.bills;
-        }
-
-        async getStageImZlData(tid, sid, fields, readCache = true) {
-            await this.ctx.service.tender.checkTender(tid);
-            await this.ctx.service.stage.checkStage(sid);
-            if (readCache) {
-                const cache = await this._getReportMemoryCache('mem_stage_im_zl', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
-                if (cache) return cache;
-            }
-
-            this.stageImData = {};
-            try {
-                await this._generateStageIm(tid, sid, false);
+                return this.stageImData.main;
             } catch (err) {
             } catch (err) {
-                if (err.stack) {
-                    this.ctx.logger.error(err);
-                }
-                this.stageImData.main = err.statck ? '数据错误' : err;
+                return [];
             }
             }
-            return this.stageImData.main;
         }
         }
 
 
         async getMonthProgress(tid, fields) {
         async getMonthProgress(tid, fields) {
@@ -343,67 +355,71 @@ module.exports = app => {
         }
         }
 
 
         async getStageBillsData(tid, sid, fields) {
         async getStageBillsData(tid, sid, fields) {
-            await this.ctx.service.tender.checkTender(tid);
-            if (sid) {
-                await this.ctx.service.stage.checkStage(sid);
-            }
+            try {
+                await this.ctx.service.tender.checkTender(tid);
+                if (sid) {
+                    await this.ctx.service.stage.checkStage(sid);
+                }
 
 
-            const billsData = await this.ctx.service.ledger.getData(this.ctx.tender.id);
-            if (this._checkFieldsExist(fields, billsFields.stageDgn)) {
-                const dgnData = await this.ctx.service.stageBillsDgn.getDgnData(this.ctx.tender.id);
-                for (const d of dgnData) {
-                    const l = this.ctx.helper._.find(billsData, {id: d.id});
-                    this.ctx.helper._.assignIn(l, d);
+                const billsData = await this.ctx.service.ledger.getData(this.ctx.tender.id);
+                if (this._checkFieldsExist(fields, billsFields.stageDgn)) {
+                    const dgnData = await this.ctx.service.stageBillsDgn.getDgnData(this.ctx.tender.id);
+                    for (const d of dgnData) {
+                        const l = this.ctx.helper._.find(billsData, {id: d.id});
+                        this.ctx.helper._.assignIn(l, d);
+                    }
                 }
                 }
-            }
-            if (this._checkFieldsExist(fields, billsFields.stage)) {
-                if (this.ctx.stage.readOnly) {
-                    const curStage = await this.ctx.service.stageBills.getAuditorStageData(this.ctx.tender.id,
-                        this.ctx.stage.id, this.ctx.stage.curTimes, this.ctx.stage.curOrder);
-                    this.ctx.helper.assignRelaData(billsData, [
-                        {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid'}
-                    ]);
-                } else {
-                    const curStage = await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id);
+                if (this._checkFieldsExist(fields, billsFields.stage)) {
+                    if (this.ctx.stage.readOnly) {
+                        const curStage = await this.ctx.service.stageBills.getAuditorStageData(this.ctx.tender.id,
+                            this.ctx.stage.id, this.ctx.stage.curTimes, this.ctx.stage.curOrder);
+                        this.ctx.helper.assignRelaData(billsData, [
+                            {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid'}
+                        ]);
+                    } else {
+                        const curStage = await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id);
+                        this.ctx.helper.assignRelaData(billsData, [
+                            {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid'}
+                        ]);
+                    }
+                }
+                if (this._checkFieldsExist(fields, billsFields.stageEnd)) {
+                    const preStage = this.ctx.stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
                     this.ctx.helper.assignRelaData(billsData, [
                     this.ctx.helper.assignRelaData(billsData, [
-                        {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid'}
+                        {data: preStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'pre_', relaId: 'lid'}
                     ]);
                     ]);
                 }
                 }
-            }
-            if (this._checkFieldsExist(fields, billsFields.stageEnd)) {
-                const preStage = this.ctx.stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
-                this.ctx.helper.assignRelaData(billsData, [
-                    {data: preStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'pre_', relaId: 'lid'}
+                this.billsTree.loadDatas(billsData);
+                this.billsTree.calculateAll();
+
+                if (this._checkFieldsExist(fields, billsFields.bgl)) {
+                    await this._calcBillsBgl();
+                }
+
+                if (this._checkFieldsExist(fields, billsFields.leafXmj)) {
+                    this._calcLeafXmjRela();
+                }
+
+                return this.billsTree.getDatas([
+                    'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',
+                    'code', 'b_code', 'name', 'unit', 'unit_price',
+                    'deal_qty', 'deal_tp',
+                    'sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp', 'quantity', 'total_price',
+                    'dgn_qty1', 'dgn_qty2',
+                    'drawing_code', 'memo', 'node_type', 'is_tp',
+                    'contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'gather_qty', 'gather_tp', 'postil',
+                    'pre_contract_qty', 'pre_contract_tp', 'pre_qc_qty', 'pre_qc_tp', 'pre_gather_qty', 'pre_gather_tp',
+                    'end_contract_qty', 'end_contract_tp', 'end_qc_qty', 'end_qc_tp', 'end_gather_qty', 'end_gather_tp',
+                    'final_tp', 'final_ratio',
+                    'qc_bgl_code',
+                    'chapter',
+                    'leaf_xmj_id',
+                    'sgfh_expr', 'sjcl_expr', 'qtcl_expr', 'contract_expr',
+                    'deal_dgn_qty1', 'deal_dgn_qty2', 'c_dgn_qty1', 'c_dgn_qty2',
                 ]);
                 ]);
+            } catch(err) {
+                return []
             }
             }
-            this.billsTree.loadDatas(billsData);
-            this.billsTree.calculateAll();
-
-            if (this._checkFieldsExist(fields, billsFields.bgl)) {
-                await this._calcBillsBgl();
-            }
-
-            if (this._checkFieldsExist(fields, billsFields.leafXmj)) {
-                this._calcLeafXmjRela();
-            }
-
-            return this.billsTree.getDatas([
-                'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',
-                'code', 'b_code', 'name', 'unit', 'unit_price',
-                'deal_qty', 'deal_tp',
-                'sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp', 'quantity', 'total_price',
-                'dgn_qty1', 'dgn_qty2',
-                'drawing_code', 'memo', 'node_type', 'is_tp',
-                'contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'gather_qty', 'gather_tp', 'postil',
-                'pre_contract_qty', 'pre_contract_tp', 'pre_qc_qty', 'pre_qc_tp', 'pre_gather_qty', 'pre_gather_tp',
-                'end_contract_qty', 'end_contract_tp', 'end_qc_qty', 'end_qc_tp', 'end_gather_qty', 'end_gather_tp',
-                'final_tp', 'final_ratio',
-                'qc_bgl_code',
-                'chapter',
-                'leaf_xmj_id',
-                'sgfh_expr', 'sjcl_expr', 'qtcl_expr', 'contract_expr',
-                'deal_dgn_qty1', 'deal_dgn_qty2', 'c_dgn_qty1', 'c_dgn_qty2',
-            ]);
         }
         }
 
 
         async _calcPosBgl() {
         async _calcPosBgl() {
@@ -430,40 +446,44 @@ module.exports = app => {
         }
         }
 
 
         async getStagePosData(tid, sid, fields) {
         async getStagePosData(tid, sid, fields) {
-            await this.ctx.service.tender.checkTender(tid);
-            if (sid) {
-                await this.ctx.service.stage.checkStage(sid);
-            }
+            try {
+                await this.ctx.service.tender.checkTender(tid);
+                if (sid) {
+                    await this.ctx.service.stage.checkStage(sid);
+                }
 
 
-            const posData = await this.ctx.service.pos.getAllDataByCondition({ where: {tid: this.ctx.tender.id }});
-            if (this._checkFieldsExist(fields, posFields.stage)) {
-                if (this.ctx.stage.readOnly) {
-                    const curPosStage = await this.ctx.service.stagePos.getAuditorStageData2(this.ctx.tender.id,
-                        this.ctx.stage.id, this.ctx.stage.curTimes, this.ctx.stage.curOrder);
-                    this.ctx.helper.assignRelaData(posData, [
-                        {data: curPosStage, fields: ['contract_qty', 'qc_qty', 'contract_expr', 'postil'], prefix: '', relaId: 'pid'}
-                    ]);
-                } else {
-                    const curPosStage = await this.ctx.service.stagePos.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id);
+                const posData = await this.ctx.service.pos.getAllDataByCondition({ where: {tid: this.ctx.tender.id }});
+                if (this._checkFieldsExist(fields, posFields.stage)) {
+                    if (this.ctx.stage.readOnly) {
+                        const curPosStage = await this.ctx.service.stagePos.getAuditorStageData2(this.ctx.tender.id,
+                            this.ctx.stage.id, this.ctx.stage.curTimes, this.ctx.stage.curOrder);
+                        this.ctx.helper.assignRelaData(posData, [
+                            {data: curPosStage, fields: ['contract_qty', 'qc_qty', 'contract_expr', 'postil'], prefix: '', relaId: 'pid'}
+                        ]);
+                    } else {
+                        const curPosStage = await this.ctx.service.stagePos.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id);
+                        this.ctx.helper.assignRelaData(posData, [
+                            {data: curPosStage, fields: ['contract_qty', 'qc_qty', 'contract_expr', 'postil'], prefix: '', relaId: 'pid'}
+                        ]);
+                    }
+                }
+                if (this._checkFieldsExist(fields, posFields.stageEnd)) {
+                    const prePosStage = this.ctx.stage.order > 1 ? await this.ctx.service.stagePosFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
                     this.ctx.helper.assignRelaData(posData, [
                     this.ctx.helper.assignRelaData(posData, [
-                        {data: curPosStage, fields: ['contract_qty', 'qc_qty', 'contract_expr', 'postil'], prefix: '', relaId: 'pid'}
+                        {data: prePosStage, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid'}
                     ]);
                     ]);
                 }
                 }
-            }
-            if (this._checkFieldsExist(fields, posFields.stageEnd)) {
-                const prePosStage = this.ctx.stage.order > 1 ? await this.ctx.service.stagePosFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
-                this.ctx.helper.assignRelaData(posData, [
-                    {data: prePosStage, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid'}
-                ]);
-            }
-            this.pos.loadDatas(posData);
-            this.pos.calculateAll();
+                this.pos.loadDatas(posData);
+                this.pos.calculateAll();
 
 
-            if (this._checkFieldsExist(fields, posFields.bgl)) {
-                await this._calcPosBgl();
-            }
+                if (this._checkFieldsExist(fields, posFields.bgl)) {
+                    await this._calcPosBgl();
+                }
 
 
-            return this.pos.getDatas();
+                return this.pos.getDatas();
+            } catch (err) {
+                return [];
+            }
         }
         }
 
 
         _getStageValidRole () {
         _getStageValidRole () {
@@ -492,193 +512,205 @@ module.exports = app => {
         };
         };
 
 
         async getStageBillsCompareData(tid, sid, fields) {
         async getStageBillsCompareData(tid, sid, fields) {
-            await this.ctx.service.tender.checkTender(tid);
-            await this.ctx.service.stage.checkStage(sid);
-            await this._getStageValidRole();
-
-            const stage = this.ctx.stage, helper = this.ctx.helper;
-            const validRole = this.stageValidRole;
-            const billsData = await this.ctx.service.ledger.getData(this.ctx.tender.id);
-            const allStageBills = await this.ctx.service.stageBills.getAllDataByCondition({where: {sid: sid}});
-
-            const stageBillsIndex = {}, timesLen = 100;
-            for (const role of validRole) {
-                const stageBills = this.ctx.helper._.filter(allStageBills, function (x) {
-                    return x.times < stage.curTimes || (x.times === stage.curTimes && x.order <= role.dataOrder);
-                });
-                this.ctx.helper._.pullAll(allStageBills, stageBills);
-                for (const sb of stageBills) {
-                    const key = 'sb-' + sb.lid;
-                    const sbi = stageBillsIndex[key];
-                    if (sbi) {
-                        if ((sbi.times * timesLen + sbi.order) < (sb.times * timesLen + sb.order)) stageBillsIndex[key] = sb;
-                    } else {
-                        stageBillsIndex[key] = sb;
+            try {
+                await this.ctx.service.tender.checkTender(tid);
+                await this.ctx.service.stage.checkStage(sid);
+                await this._getStageValidRole();
+
+                const stage = this.ctx.stage, helper = this.ctx.helper;
+                const validRole = this.stageValidRole;
+                const billsData = await this.ctx.service.ledger.getData(this.ctx.tender.id);
+                const allStageBills = await this.ctx.service.stageBills.getAllDataByCondition({where: {sid: sid}});
+
+                const stageBillsIndex = {}, timesLen = 100;
+                for (const role of validRole) {
+                    const stageBills = this.ctx.helper._.filter(allStageBills, function (x) {
+                        return x.times < stage.curTimes || (x.times === stage.curTimes && x.order <= role.dataOrder);
+                    });
+                    this.ctx.helper._.pullAll(allStageBills, stageBills);
+                    for (const sb of stageBills) {
+                        const key = 'sb-' + sb.lid;
+                        const sbi = stageBillsIndex[key];
+                        if (sbi) {
+                            if ((sbi.times * timesLen + sbi.order) < (sb.times * timesLen + sb.order)) stageBillsIndex[key] = sb;
+                        } else {
+                            stageBillsIndex[key] = sb;
+                        }
                     }
                     }
+                    const filterStageBills = [];
+                    for (const prop in stageBillsIndex) {
+                        filterStageBills.push(stageBillsIndex[prop]);
+                    }
+                    this.ctx.helper.assignRelaData(billsData, [
+                        {data: filterStageBills, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'r' + role.flowOrder + '_', relaId: 'lid'}
+                    ]);
                 }
                 }
-                const filterStageBills = [];
-                for (const prop in stageBillsIndex) {
-                    filterStageBills.push(stageBillsIndex[prop]);
-                }
-                this.ctx.helper.assignRelaData(billsData, [
-                    {data: filterStageBills, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'r' + role.flowOrder + '_', relaId: 'lid'}
-                ]);
-            }
 
 
-            if (this._checkFieldsExist(fields, billsFields.stageEnd)) {
-                const preStage = this.ctx.stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
-                this.ctx.helper.assignRelaData(billsData, [
-                    {data: preStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'pre_', relaId: 'lid'}
-                ]);
-            }
-            this.billsTree.loadDatas(billsData);
+                if (this._checkFieldsExist(fields, billsFields.stageEnd)) {
+                    const preStage = this.ctx.stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
+                    this.ctx.helper.assignRelaData(billsData, [
+                        {data: preStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'pre_', relaId: 'lid'}
+                    ]);
+                }
+                this.billsTree.loadDatas(billsData);
 
 
-            this.billsTree.setting.calcFields = ['deal_tp', 'total_price', 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp'];
-            for (const role of validRole) {
-                const prefix = 'r' + role.flowOrder + '_';
-                this.billsTree.setting.calcFields.push(prefix + 'contract_tp', prefix + 'qc_tp', prefix + 'gather_tp');
-            }
+                this.billsTree.setting.calcFields = ['deal_tp', 'total_price', 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp'];
+                for (const role of validRole) {
+                    const prefix = 'r' + role.flowOrder + '_';
+                    this.billsTree.setting.calcFields.push(prefix + 'contract_tp', prefix + 'qc_tp', prefix + 'gather_tp');
+                }
 
 
-            this.billsTree.calculateAll(function(node) {
-                let prefix = '';
-                if (node.children && node.children.length === 0) {
-                    node.pre_gather_qty = helper.add(node.pre_contract_qty, node.pre_qc_qty);
+                this.billsTree.calculateAll(function(node) {
+                    let prefix = '';
+                    if (node.children && node.children.length === 0) {
+                        node.pre_gather_qty = helper.add(node.pre_contract_qty, node.pre_qc_qty);
+                        for (const role of validRole) {
+                            prefix = 'r' + role.flowOrder + '_';
+                            node[prefix + 'gather_qty'] = helper.add(node[prefix + 'contract_qty'], node[prefix + 'qc_qty']);
+                        }
+                    }
+                    node.pre_gather_tp = helper.add(node.pre_contract_tp, node.pre_qc_tp);
                     for (const role of validRole) {
                     for (const role of validRole) {
                         prefix = 'r' + role.flowOrder + '_';
                         prefix = 'r' + role.flowOrder + '_';
-                        node[prefix + 'gather_qty'] = helper.add(node[prefix + 'contract_qty'], node[prefix + 'qc_qty']);
+                        node[prefix + 'gather_tp'] = helper.add(node[prefix + 'contract_tp'], node[prefix + 'qc_tp']);
                     }
                     }
+                });
+
+                if (this._checkFieldsExist(fields, billsFields.leafXmj)) {
+                    this._calcLeafXmjRela();
                 }
                 }
-                node.pre_gather_tp = helper.add(node.pre_contract_tp, node.pre_qc_tp);
-                for (const role of validRole) {
-                    prefix = 'r' + role.flowOrder + '_';
-                    node[prefix + 'gather_tp'] = helper.add(node[prefix + 'contract_tp'], node[prefix + 'qc_tp']);
-                }
-            });
 
 
-            if (this._checkFieldsExist(fields, billsFields.leafXmj)) {
-                this._calcLeafXmjRela();
-            }
-
-            return this.billsTree.getDefaultDatas();
-            // return this.billsTree.getDatas([
-            //     'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',                 //8
-            //     'code', 'b_code', 'name', 'unit', 'unit_price',                                                         //5
-            //     'deal_qty', 'deal_tp', 'quantity', 'total_price', 'dgn_qty1', 'dgn_qty2',                               //6
-            //     'drawing_code', 'memo', 'node_type', 'is_tp',                                                           //4
-            //     'r0_contract_qty', 'r0_contract_tp', 'r0_qc_qty', 'r0_qc_tp', 'r0_gather_qty', 'r0_gather_tp',          //6
-            //     'r1_contract_qty', 'r1_contract_tp', 'r1_qc_qty', 'r1_qc_tp', 'r1_gather_qty', 'r1_gather_tp',
-            //     'r2_contract_qty', 'r2_contract_tp', 'r2_qc_qty', 'r2_qc_tp', 'r2_gather_qty', 'r2_gather_tp',
-            //     'r3_contract_qty', 'r3_contract_tp', 'r3_qc_qty', 'r3_qc_tp', 'r3_gather_qty', 'r3_gather_tp',
-            //     'r4_contract_qty', 'r4_contract_tp', 'r4_qc_qty', 'r4_qc_tp', 'r4_gather_qty', 'r4_gather_tp',
-            //     'r5_contract_qty', 'r5_contract_tp', 'r5_qc_qty', 'r5_qc_tp', 'r5_gather_qty', 'r5_gather_tp',
-            //     'r6_contract_qty', 'r6_contract_tp', 'r6_qc_qty', 'r6_qc_tp', 'r6_gather_qty', 'r6_gather_tp',
-            //     'r7_contract_qty', 'r7_contract_tp', 'r7_qc_qty', 'r7_qc_tp', 'r7_gather_qty', 'r7_gather_tp',
-            //     'r8_contract_qty', 'r8_contract_tp', 'r8_qc_qty', 'r8_qc_tp', 'r8_gather_qty', 'r8_gather_tp',
-            //     'r9_contract_qty', 'r9_contract_tp', 'r9_qc_qty', 'r9_qc_tp', 'r9_gather_qty', 'r9_gather_tp',
-            //     'r10_contract_qty', 'r10_contract_tp', 'r10_qc_qty', 'r10_qc_tp', 'r10_gather_qty', 'r10_gather_tp',
-            //     'pre_contract_qty', 'pre_contract_tp', 'pre_qc_qty', 'pre_qc_tp', 'pre_gather_qty', 'pre_gather_tp',
-            //     'chapter',                                                                                              //1
-            // ]);
+                return this.billsTree.getDefaultDatas();
+                // return this.billsTree.getDatas([
+                //     'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',                 //8
+                //     'code', 'b_code', 'name', 'unit', 'unit_price',                                                         //5
+                //     'deal_qty', 'deal_tp', 'quantity', 'total_price', 'dgn_qty1', 'dgn_qty2',                               //6
+                //     'drawing_code', 'memo', 'node_type', 'is_tp',                                                           //4
+                //     'r0_contract_qty', 'r0_contract_tp', 'r0_qc_qty', 'r0_qc_tp', 'r0_gather_qty', 'r0_gather_tp',          //6
+                //     'r1_contract_qty', 'r1_contract_tp', 'r1_qc_qty', 'r1_qc_tp', 'r1_gather_qty', 'r1_gather_tp',
+                //     'r2_contract_qty', 'r2_contract_tp', 'r2_qc_qty', 'r2_qc_tp', 'r2_gather_qty', 'r2_gather_tp',
+                //     'r3_contract_qty', 'r3_contract_tp', 'r3_qc_qty', 'r3_qc_tp', 'r3_gather_qty', 'r3_gather_tp',
+                //     'r4_contract_qty', 'r4_contract_tp', 'r4_qc_qty', 'r4_qc_tp', 'r4_gather_qty', 'r4_gather_tp',
+                //     'r5_contract_qty', 'r5_contract_tp', 'r5_qc_qty', 'r5_qc_tp', 'r5_gather_qty', 'r5_gather_tp',
+                //     'r6_contract_qty', 'r6_contract_tp', 'r6_qc_qty', 'r6_qc_tp', 'r6_gather_qty', 'r6_gather_tp',
+                //     'r7_contract_qty', 'r7_contract_tp', 'r7_qc_qty', 'r7_qc_tp', 'r7_gather_qty', 'r7_gather_tp',
+                //     'r8_contract_qty', 'r8_contract_tp', 'r8_qc_qty', 'r8_qc_tp', 'r8_gather_qty', 'r8_gather_tp',
+                //     'r9_contract_qty', 'r9_contract_tp', 'r9_qc_qty', 'r9_qc_tp', 'r9_gather_qty', 'r9_gather_tp',
+                //     'r10_contract_qty', 'r10_contract_tp', 'r10_qc_qty', 'r10_qc_tp', 'r10_gather_qty', 'r10_gather_tp',
+                //     'pre_contract_qty', 'pre_contract_tp', 'pre_qc_qty', 'pre_qc_tp', 'pre_gather_qty', 'pre_gather_tp',
+                //     'chapter',                                                                                              //1
+                // ]);
+            } catch (err) {
+                return [];
+            }
         }
         }
 
 
         async getStagePosCompareData(tid, sid, fields) {
         async getStagePosCompareData(tid, sid, fields) {
-            await this.ctx.service.tender.checkTender(tid);
-            await this.ctx.service.stage.checkStage(sid);
-            await this._getStageValidRole();
-
-            const stage = this.ctx.stage, helper = this.ctx.helper;
-            const validRole = this.stageValidRole;
-
-            const allStagePos = await this.ctx.service.stagePos.getAllDataByCondition({where: {sid: sid}});
-            const posData = await this.ctx.service.pos.getAllDataByCondition({ where: {tid: this.ctx.tender.id }});
-            const prePosStage = this.ctx.stage.order > 1 ? await this.ctx.service.stagePosFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
-            this.ctx.helper.assignRelaData(posData, [
-                {data: prePosStage, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid'}
-            ]);
-            const stagePosIndex = {}, timesLen = 100;
-            for (const role of validRole) {
-                const stagePos = this.ctx.helper._.filter(allStagePos, function (x) {
-                    return x.times < stage.curTimes || (x.times === stage.curTimes && x.order <= role.dataOrder);
-                });
-                this.ctx.helper._.pullAll(allStagePos, stagePos);
-                for (const sp of stagePos) {
-                    const key = 'sp-' + sp.pid;
-                    const spi = stagePosIndex[key];
-                    if (spi) {
-                        if ((spi.times * timesLen + spi.order) < (sp.times * timesLen + sp.order)) stagePosIndex[key] = sp;
-                    } else {
-                        stagePosIndex[key] = sp;
-                    }
-                }
-                const filterStagePos = [];
-                for (const prop in stagePosIndex) {
-                    filterStagePos.push(stagePosIndex[prop]);
-                }
+            try {
+                await this.ctx.service.tender.checkTender(tid);
+                await this.ctx.service.stage.checkStage(sid);
+                await this._getStageValidRole();
+
+                const stage = this.ctx.stage, helper = this.ctx.helper;
+                const validRole = this.stageValidRole;
+
+                const allStagePos = await this.ctx.service.stagePos.getAllDataByCondition({where: {sid: sid}});
+                const posData = await this.ctx.service.pos.getAllDataByCondition({ where: {tid: this.ctx.tender.id }});
+                const prePosStage = this.ctx.stage.order > 1 ? await this.ctx.service.stagePosFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
                 this.ctx.helper.assignRelaData(posData, [
                 this.ctx.helper.assignRelaData(posData, [
-                    {data: filterStagePos, fields: ['contract_qty', 'qc_qty'], prefix: 'r' + role.flowOrder + '_', relaId: 'pid'}
+                    {data: prePosStage, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid'}
                 ]);
                 ]);
-            }
-            this.pos.loadDatas(posData);
-            this.pos.calculateAll(function (p) {
-                p.pre_gather_qty = helper.add(p.pre_contract_qty, p.pre_qc_qty);
+                const stagePosIndex = {}, timesLen = 100;
                 for (const role of validRole) {
                 for (const role of validRole) {
-                    const prefix = 'r' + role.flowOrder + '_';
-                    p[prefix + 'gather_qty'] = helper.add(p[prefix + 'contract_qty'], p[prefix + 'qc_qty']);
+                    const stagePos = this.ctx.helper._.filter(allStagePos, function (x) {
+                        return x.times < stage.curTimes || (x.times === stage.curTimes && x.order <= role.dataOrder);
+                    });
+                    this.ctx.helper._.pullAll(allStagePos, stagePos);
+                    for (const sp of stagePos) {
+                        const key = 'sp-' + sp.pid;
+                        const spi = stagePosIndex[key];
+                        if (spi) {
+                            if ((spi.times * timesLen + spi.order) < (sp.times * timesLen + sp.order)) stagePosIndex[key] = sp;
+                        } else {
+                            stagePosIndex[key] = sp;
+                        }
+                    }
+                    const filterStagePos = [];
+                    for (const prop in stagePosIndex) {
+                        filterStagePos.push(stagePosIndex[prop]);
+                    }
+                    this.ctx.helper.assignRelaData(posData, [
+                        {data: filterStagePos, fields: ['contract_qty', 'qc_qty'], prefix: 'r' + role.flowOrder + '_', relaId: 'pid'}
+                    ]);
                 }
                 }
+                this.pos.loadDatas(posData);
+                this.pos.calculateAll(function (p) {
+                    p.pre_gather_qty = helper.add(p.pre_contract_qty, p.pre_qc_qty);
+                    for (const role of validRole) {
+                        const prefix = 'r' + role.flowOrder + '_';
+                        p[prefix + 'gather_qty'] = helper.add(p[prefix + 'contract_qty'], p[prefix + 'qc_qty']);
+                    }
 
 
-            });
+                });
 
 
-            return this.pos.getDatas();
+                return this.pos.getDatas();
+            } catch (err) {
+                return [];
+            }
         }
         }
 
 
         async getStagePayData(tid, sid, fields) {
         async getStagePayData(tid, sid, fields) {
-            await this.ctx.service.tender.checkTender(tid);
-            await this.ctx.service.stage.checkStage(sid);
-            const stage = this.ctx.stage;
+            try {
+                await this.ctx.service.tender.checkTender(tid);
+                await this.ctx.service.stage.checkStage(sid);
+                const stage = this.ctx.stage;
 
 
-            const dealPay = await this.ctx.service.stagePay.getStagePays(this.ctx.stage);
+                const dealPay = await this.ctx.service.stagePay.getStagePays(this.ctx.stage);
 
 
-            if (!this.ctx.stage.readOnly) {
-                // 计算 本期金额
-                const PayCalculator = require('../lib/pay_calc');
-                const payCalculator = new PayCalculator(this.ctx, this.ctx.stage, this.ctx.tender.info);
-                await payCalculator.calculateAll(dealPay);
-            }
-            if (this._checkFieldsExist(fields, ['start_stage_order']) && this.ctx.stage.status !== audit.stage.status.checked) {
-                for (const dp of dealPay) {
-                    if (!dp.start_stage_order || dp.start_stage_order === this.ctx.stage.order) {
-                        dp.start_stage_order = this.ctx.helper.checkZero(dp.tp) ? null : this.ctx.stage.order;
+                if (!this.ctx.stage.readOnly) {
+                    // 计算 本期金额
+                    const PayCalculator = require('../lib/pay_calc');
+                    const payCalculator = new PayCalculator(this.ctx, this.ctx.stage, this.ctx.tender.info);
+                    await payCalculator.calculateAll(dealPay);
+                }
+                if (this._checkFieldsExist(fields, ['start_stage_order']) && this.ctx.stage.status !== audit.stage.status.checked) {
+                    for (const dp of dealPay) {
+                        if (!dp.start_stage_order || dp.start_stage_order === this.ctx.stage.order) {
+                            dp.start_stage_order = this.ctx.helper.checkZero(dp.tp) ? null : this.ctx.stage.order;
+                        }
                     }
                     }
                 }
                 }
-            }
 
 
-            if (this._checkFieldsExistReg(fields, 'r[0-9]+_tp')) {
-                this._getStageValidRole();
-                const allStagePays = await this.ctx.service.stagePay.getAllDataByCondition({
-                    where: {sid: stage.id, stimes: stage.curTimes}
-                });
+                if (this._checkFieldsExistReg(fields, 'r[0-9]+_tp')) {
+                    this._getStageValidRole();
+                    const allStagePays = await this.ctx.service.stagePay.getAllDataByCondition({
+                        where: {sid: stage.id, stimes: stage.curTimes}
+                    });
 
 
-                for (const [i, role] of this.stageValidRole.entries()) {
-                    if (i < this.stageValidRole.length - 1) {
-                        const stagePays = this.ctx.helper._.filter(allStagePays, function (x) {
-                            return x.stimes === stage.curTimes && x.sorder === role.dataOrder;
-                        });
-                        this.ctx.helper._.pullAll(allStagePays, stagePays);
-
-                        for (const sp of stagePays) {
-                            const dp = dealPay.find(function (x) {return x.pid === sp.pid});
-                            if (dp) {
-                                dp['r' + role.flowOrder + '_tp'] = sp.tp;
+                    for (const [i, role] of this.stageValidRole.entries()) {
+                        if (i < this.stageValidRole.length - 1) {
+                            const stagePays = this.ctx.helper._.filter(allStagePays, function (x) {
+                                return x.stimes === stage.curTimes && x.sorder === role.dataOrder;
+                            });
+                            this.ctx.helper._.pullAll(allStagePays, stagePays);
+
+                            for (const sp of stagePays) {
+                                const dp = dealPay.find(function (x) {return x.pid === sp.pid});
+                                if (dp) {
+                                    dp['r' + role.flowOrder + '_tp'] = sp.tp;
+                                }
+                            }
+                        } else {
+                            for (const dp of dealPay) {
+                                dp['r' + role.flowOrder + '_tp'] = dp.tp;
                             }
                             }
-                        }
-                    } else {
-                        for (const dp of dealPay) {
-                            dp['r' + role.flowOrder + '_tp'] = dp.tp;
                         }
                         }
                     }
                     }
                 }
                 }
+                return dealPay;
+            } catch (err) {
+                return [];
             }
             }
-            return dealPay;
         }
         }
 
 
         _getChangeConstName(define, value) {
         _getChangeConstName(define, value) {
@@ -755,58 +787,78 @@ module.exports = app => {
         }
         }
 
 
         async getChangeData(tid, sid, fields) {
         async getChangeData(tid, sid, fields) {
-            await this.ctx.service.tender.checkTender(tid);
+            try {
+                await this.ctx.service.tender.checkTender(tid);
 
 
-            await this._generateChange(tid);
-            return this.changeData.change;
+                await this._generateChange(tid);
+                return this.changeData.change;
+            } catch (err) {
+                return [];
+            }
         }
         }
 
 
         async getChangeBillsData(tid, sid, fields) {
         async getChangeBillsData(tid, sid, fields) {
-            await this.ctx.service.tender.checkTender(tid);
+            try {
+                await this.ctx.service.tender.checkTender(tid);
 
 
-            await this._generateChange(tid);
-            return this.changeData.bills;
+                await this._generateChange(tid);
+                return this.changeData.bills;
+            } catch (err) {
+                return [];
+            }
         }
         }
 
 
         async getStageJgcl(tid, sid, fields) {
         async getStageJgcl(tid, sid, fields) {
-            await this.ctx.service.tender.checkTender(tid);
-            await this.ctx.service.stage.checkStage(sid);
+            try {
+                await this.ctx.service.tender.checkTender(tid);
+                await this.ctx.service.stage.checkStage(sid);
 
 
-            const data = await this.ctx.service.stageJgcl.getStageData(this.ctx.stage);
-            const preData = await this.ctx.service.stageJgcl.getPreStageData(this.ctx.stage.order);
-            for (const d of data) {
-                const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
-                if (pd) {
-                    d.pre_arrive_qty = pd.arrive_qty;
-                    d.pre_arrive_tp = pd.arrive_tp;
-                    d.pre_deduct_qty = pd.deduct_qty;
-                    d.pre_deduct_tp = pd.deduct_tp;
+                const data = await this.ctx.service.stageJgcl.getStageData(this.ctx.stage);
+                const preData = await this.ctx.service.stageJgcl.getPreStageData(this.ctx.stage.order);
+                for (const d of data) {
+                    const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
+                    if (pd) {
+                        d.pre_arrive_qty = pd.arrive_qty;
+                        d.pre_arrive_tp = pd.arrive_tp;
+                        d.pre_deduct_qty = pd.deduct_qty;
+                        d.pre_deduct_tp = pd.deduct_tp;
+                    }
                 }
                 }
+                return data;
+            } catch (err) {
+                return [];
             }
             }
-            return data;
         }
         }
 
 
         async getStageBonus(tid, sid, fields) {
         async getStageBonus(tid, sid, fields) {
-            await this.ctx.service.tender.checkTender(tid);
-            await this.ctx.service.stage.checkStage(sid);
+            try {
+                await this.ctx.service.tender.checkTender(tid);
+                await this.ctx.service.stage.checkStage(sid);
 
 
-            const data = await this.ctx.service.stageBonus.getEndStageData(this.ctx.stage.order);
-            return data;
+                const data = await this.ctx.service.stageBonus.getEndStageData(this.ctx.stage.order);
+                return data;
+            } catch (err) {
+                return [];
+            }
         }
         }
 
 
         async getStageOther(tid, sid, fields) {
         async getStageOther(tid, sid, fields) {
-            await this.ctx.service.tender.checkTender(tid);
-            await this.ctx.service.stage.checkStage(sid);
+            try {
+                await this.ctx.service.tender.checkTender(tid);
+                await this.ctx.service.stage.checkStage(sid);
 
 
-            const data = await this.ctx.service.stageOther.getStageData(this.ctx.stage);
-            const preData = await this.ctx.service.stageOther.getPreStageData(this.ctx.stage.order);
-            for (const d of data) {
-                const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
-                if (pd) {
-                    d.pre_tp = pd.tp;
+                const data = await this.ctx.service.stageOther.getStageData(this.ctx.stage);
+                const preData = await this.ctx.service.stageOther.getPreStageData(this.ctx.stage.order);
+                for (const d of data) {
+                    const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
+                    if (pd) {
+                        d.pre_tp = pd.tp;
+                    }
                 }
                 }
+                return data;
+            } catch (err) {
+                return [];
             }
             }
-            return data;
         }
         }
 
 
         async getMaterial(tender_id, material_order, memFieldKeys) {
         async getMaterial(tender_id, material_order, memFieldKeys) {
@@ -861,58 +913,62 @@ module.exports = app => {
         }
         }
 
 
         async getSumStageBillsData(tid, sid, fields) {
         async getSumStageBillsData(tid, sid, fields) {
-            await this.ctx.service.tender.checkTender(tid);
+            try {
+                await this.ctx.service.tender.checkTender(tid);
 
 
-            const billsData = await this.ctx.service.ledger.getData(this.ctx.tender.id);
-            const checkStageField = function (stageOrder) {
-                for (const f of fields) {
-                    if (f.indexOf('s' + stageOrder + '_') >= 0) {
-                        return true;
+                const billsData = await this.ctx.service.ledger.getData(this.ctx.tender.id);
+                const checkStageField = function (stageOrder) {
+                    for (const f of fields) {
+                        if (f.indexOf('s' + stageOrder + '_') >= 0) {
+                            return true;
+                        }
                     }
                     }
+                    return false;
+                };
+
+                const calcFields = ['deal_tp', 'total_price'], calcPrefix = [];
+                const stages = this.ctx.service.stage.getValidStages(this.ctx.tender.id);
+                for (const stage of stages) {
+                    if (!checkStageField(stage.order)) return;
+
+                    await this.ctx.service.stage.doCheckStage(stage);
+                    calcFields.push('s' + stage.order + '_contract_tp');
+                    calcFields.push('s' + stage.order + '_qc_tp');
+                    calcFields.push('s' + stage.order + '_gather_tp');
+                    calcFields.push('s' + stage.order + '_');
+
+                    const curStage = stage.readOnly
+                        ? await this.ctx.service.stageBills.getAuditorStageData(this.ctx.tender.id, stage.id, stage.curTimes, stage.curOrder)
+                        : await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, stage.id);
+                    this.ctx.helper.assignRelaData(billsData, [
+                        {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp'], prefix: 's' + stage.order + '_', relaId: 'lid'}
+                    ]);
                 }
                 }
-                return false;
-            };
-
-            const calcFields = ['deal_tp', 'total_price'], calcPrefix = [];
-            const stages = this.ctx.service.stage.getValidStages(this.ctx.tender.id);
-            for (const stage of stages) {
-                if (!checkStageField(stage.order)) return;
-
-                await this.ctx.service.stage.doCheckStage(stage);
-                calcFields.push('s' + stage.order + '_contract_tp');
-                calcFields.push('s' + stage.order + '_qc_tp');
-                calcFields.push('s' + stage.order + '_gather_tp');
-                calcFields.push('s' + stage.order + '_');
-
-                const curStage = stage.readOnly
-                    ? await this.ctx.service.stageBills.getAuditorStageData(this.ctx.tender.id, stage.id, stage.curTimes, stage.curOrder)
-                    : await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, stage.id);
-                this.ctx.helper.assignRelaData(billsData, [
-                    {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp'], prefix: 's' + stage.order + '_', relaId: 'lid'}
-                ]);
-            }
 
 
-            const billsTree = new Ledger.billsTree(this.ctx, {
-                id: 'ledger_id',
-                pid: 'ledger_pid',
-                order: 'order',
-                level: 'level',
-                rootId: -1,
-                keys: ['id', 'tender_id', 'ledger_id'],
-                stageId: 'id',
-                calcFields: calcFields,
-                calc: function (node) {
-                    for (const prefix of calcPrefix) {
-                        if (node.children && node.children.length === 0) {
-                            node[prefix + 'gather_qty'] = self.ctx.helper.add(node[prefix + 'contract_qty'], node[prefix + 'qc_qty']);
+                const billsTree = new Ledger.billsTree(this.ctx, {
+                    id: 'ledger_id',
+                    pid: 'ledger_pid',
+                    order: 'order',
+                    level: 'level',
+                    rootId: -1,
+                    keys: ['id', 'tender_id', 'ledger_id'],
+                    stageId: 'id',
+                    calcFields: calcFields,
+                    calc: function (node) {
+                        for (const prefix of calcPrefix) {
+                            if (node.children && node.children.length === 0) {
+                                node[prefix + 'gather_qty'] = self.ctx.helper.add(node[prefix + 'contract_qty'], node[prefix + 'qc_qty']);
+                            }
+                            node[prefix + 'gather_tp'] = self.ctx.helper.add(node[prefix + 'contract_tp'], node[prefix + 'qc_tp']);
                         }
                         }
-                        node[prefix + 'gather_tp'] = self.ctx.helper.add(node[prefix + 'contract_tp'], node[prefix + 'qc_tp']);
                     }
                     }
-                }
-            });
-            billsTree.loadDatas(billsData);
-            billsTree.calculateAll();
-            return billsTree.getDefaultDatas();
+                });
+                billsTree.loadDatas(billsData);
+                billsTree.calculateAll();
+                return billsTree.getDefaultDatas();
+            } catch (err) {
+                return [];
+            }
         }
         }
     }
     }
 
 

+ 1 - 0
app/service/stage.js

@@ -133,6 +133,7 @@ module.exports = app => {
         async checkStage(sid) {
         async checkStage(sid) {
             if (!this.ctx.stage) {
             if (!this.ctx.stage) {
                 const stage = await this.ctx.service.stage.getDataById(sid);
                 const stage = await this.ctx.service.stage.getDataById(sid);
+                if (!stage) throw '校验的期数据不存在';
                 await this.doCheckStage(stage);
                 await this.doCheckStage(stage);
                 this.ctx.stage = stage;
                 this.ctx.stage = stage;
             }
             }

+ 4 - 0
app/view/tender/detail.ejs

@@ -100,6 +100,8 @@
                                 <a href="#bd-set-5" data-toggle="modal" data-target="#bd-set-5" class="btn btn-sm btn-outline-primary">显示设置</a>
                                 <a href="#bd-set-5" data-toggle="modal" data-target="#bd-set-5" class="btn btn-sm btn-outline-primary">显示设置</a>
                                 <a href="#bd-set-6" data-toggle="modal" data-target="#bd-set-6" class="btn btn-sm btn-outline-primary">章节设置</a>
                                 <a href="#bd-set-6" data-toggle="modal" data-target="#bd-set-6" class="btn btn-sm btn-outline-primary">章节设置</a>
                                 <a href="#bd-set-7" data-toggle="modal" data-target="#bd-set-7" class="btn btn-sm btn-outline-primary">付款账号</a>
                                 <a href="#bd-set-7" data-toggle="modal" data-target="#bd-set-7" class="btn btn-sm btn-outline-primary">付款账号</a>
+                                <i class="mx-2">|</i>
+                                <a href="javascript: void(0);" class="btn btn-sm btn-outline-primary" id="copyBtn">拷贝设置</a>
                                 <% if (ctx.session.sessionUser.is_admin) { %>
                                 <% if (ctx.session.sessionUser.is_admin) { %>
                                 <a href="/tender/<%- tender.id %>/shenpi" class="btn btn-sm btn-outline-primary">审批流程</a>
                                 <a href="/tender/<%- tender.id %>/shenpi" class="btn btn-sm btn-outline-primary">审批流程</a>
                                 <% } %>
                                 <% } %>
@@ -147,6 +149,8 @@
     });
     });
 </script>
 </script>
 <script type="text/javascript">
 <script type="text/javascript">
+    const category = JSON.parse('<%- JSON.stringify(categoryData) %>');
+    const tenders = JSON.parse('<%- JSON.stringify(tenders) %>');
     //4 标段期数计量进度//
     //4 标段期数计量进度//
     var myChart = echarts.init(document.getElementById('chartContainer4'));
     var myChart = echarts.init(document.getElementById('chartContainer4'));
     var option = {
     var option = {

+ 39 - 0
app/view/tender/detail_modal.ejs

@@ -614,6 +614,45 @@
         </div>
         </div>
     </div>
     </div>
 </div>
 </div>
+<!--批量设置-->
+<div class="modal fade" id="bd-set-8" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">从其他标段拷贝设置</h5>
+            </div>
+            <div class="modal-body">
+                <div class="alert alert-warning mb-1">从以下标段拷贝设置</div>
+                <div class=" mb-1">
+                <a class="btn btn-sm btn-light">
+                    <div class="custom-control custom-checkbox">
+                    <input type="checkbox" class="custom-control-input" id="customCheckDisabld" checked="">
+                    <label class="custom-control-label text-primary" for="customCheckDisabld">标段属性</label>
+                    </div>
+                </a>
+                <a class="btn btn-sm btn-light">
+                    <div class="custom-control custom-checkbox">
+                    <input type="checkbox" class="custom-control-input" id="customCheckDisabld2" checked="">
+                    <label class="custom-control-label text-primary" for="customCheckDisabld2">章节设置</label>
+                    </div>
+                </a>
+                <a class="btn btn-sm btn-light">
+                    <div class="custom-control custom-checkbox">
+                    <input type="checkbox" class="custom-control-input" id="customCheckDisabld3" checked="">
+                    <label class="custom-control-label text-primary" for="customCheckDisabld3">付款账号</label>
+                    </div>
+                </a>
+                </div>
+                <div class="modal-height-300" id="copyModalContent">
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>
+                <button type="button" class="btn btn-sm btn-primary">确认</button>
+            </div>
+        </div>
+    </div>
+</div>
 <script>
 <script>
     let property = JSON.parse(unescape('<%- escape(JSON.stringify(tenderInfo)) %>'));
     let property = JSON.parse(unescape('<%- escape(JSON.stringify(tenderInfo)) %>'));
     let ledgerChecked = <%- (tender.ledger_status === audit.ledger.status.checked) && ((lastStage !== undefined && lastStage !== null) || !revise || !revise.valid || revise.status === audit.revise.status.checked) %>;
     let ledgerChecked = <%- (tender.ledger_status === audit.ledger.status.checked) && ((lastStage !== undefined && lastStage !== null) || !revise || !revise.valid || revise.status === audit.revise.status.checked) %>;

+ 3 - 1
config/web.js

@@ -102,6 +102,8 @@ const JsFiles = {
                 mergeFiles: [
                 mergeFiles: [
                     '/public/js/spreadjs_rela/spreadjs_zh.js',
                     '/public/js/spreadjs_rela/spreadjs_zh.js',
                     '/public/js/zh_calc.js',
                     '/public/js/zh_calc.js',
+                    '/public/js/tender_showhide.js',
+                    '/public/js/tender_copy_setting.js',
                     // "/public/js/tender.js",
                     // "/public/js/tender.js",
                 ],
                 ],
                 mergeFile: 'tender',
                 mergeFile: 'tender',
@@ -278,7 +280,7 @@ const JsFiles = {
                     '/public/js/revise_gcl_compare.js',
                     '/public/js/revise_gcl_compare.js',
                 ],
                 ],
                 mergeFile: 'revise_gcl_compare',
                 mergeFile: 'revise_gcl_compare',
-            }
+            },
         },
         },
         stage: {
         stage: {
             // 本期计量台账
             // 本期计量台账

+ 2 - 27
sql/update.sql

@@ -1,29 +1,2 @@
-ALTER TABLE `zh_s2b_proj`
-ADD COLUMN `common_option`  text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '通用配置' AFTER `dagl_option`;
-
-ALTER TABLE `zh_tender_info` ADD `shenpi` VARCHAR(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '审批流程设置' AFTER `pay_account`;
-
-ALTER TABLE `zh_material_file`
-ADD COLUMN `extra_upload` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否是审核完成后上传的,0:否、1:是' AFTER `fileext`;
-
-ALTER TABLE `zh_pos`
-MODIFY COLUMN `gxby_status`  int(4) NULL DEFAULT -1 COMMENT '工序报验-状态' AFTER `real_qty`,
-MODIFY COLUMN `dagl_status`  int(4) NULL DEFAULT -1 COMMENT '档案管理-状态' AFTER `gxby_status`;
-
-ALTER TABLE `zh_stage_attachment`
-CHANGE COLUMN `re_upload` `extra_upload` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '是否为审核通过后再次上传的文件,0为否' ;
-
-ALTER TABLE `zh_change_attachment`
-ADD COLUMN `extra_upload` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否为审核通过后再次上传的文件,0为否' AFTER `in_time`;
-
-CREATE TABLE `zh_shenpi_audit` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `tid` int(11) NOT NULL COMMENT '标段id',
-  `sp_type` tinyint(4) NOT NULL COMMENT '审批流程类型',
-  `sp_status` tinyint(4) NOT NULL COMMENT '所选审批流程状态',
-  `audit_id` int(11) NOT NULL COMMENT '审批人id',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='审批流程人设置表';
-
+ALTER TABLE `zh_tender`
+ADD COLUMN `copy_id` INT(10) NULL COMMENT '被拷贝标段id' AFTER `uuid`;

+ 29 - 0
sql/update20201105.sql

@@ -0,0 +1,29 @@
+ALTER TABLE `zh_s2b_proj`
+ADD COLUMN `common_option`  text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '通用配置' AFTER `dagl_option`;
+
+ALTER TABLE `zh_tender_info` ADD `shenpi` VARCHAR(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '审批流程设置' AFTER `pay_account`;
+
+ALTER TABLE `zh_material_file`
+ADD COLUMN `extra_upload` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否是审核完成后上传的,0:否、1:是' AFTER `fileext`;
+
+ALTER TABLE `zh_pos`
+MODIFY COLUMN `gxby_status`  int(4) NULL DEFAULT -1 COMMENT '工序报验-状态' AFTER `real_qty`,
+MODIFY COLUMN `dagl_status`  int(4) NULL DEFAULT -1 COMMENT '档案管理-状态' AFTER `gxby_status`;
+
+ALTER TABLE `zh_stage_attachment`
+CHANGE COLUMN `re_upload` `extra_upload` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '是否为审核通过后再次上传的文件,0为否' ;
+
+ALTER TABLE `zh_change_attachment`
+ADD COLUMN `extra_upload` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否为审核通过后再次上传的文件,0为否' AFTER `in_time`;
+
+CREATE TABLE `zh_shenpi_audit` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `tid` int(11) NOT NULL COMMENT '标段id',
+  `sp_type` tinyint(4) NOT NULL COMMENT '审批流程类型',
+  `sp_status` tinyint(4) NOT NULL COMMENT '所选审批流程状态',
+  `audit_id` int(11) NOT NULL COMMENT '审批人id',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='审批流程人设置表';
+
+-- 2020/11/4 更新到uat
+-- 2020/11/5 更新到prod