Browse Source

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

TonyKang 4 years ago
parent
commit
0643213384

+ 5 - 2
app/controller/revise_controller.js

@@ -921,7 +921,7 @@ module.exports = app => {
             await this.layout('revise/compare.ejs', renderData, 'revise/compare_modal.ejs');
         }
 
-        _loadPreData(curData, preData, field, prefix, relaId) {
+        _loadPreData(curData, preData, field, prefix, relaId, extraFields = []) {
             if (preData.length === 0) return;
             for (const pd of preData) {
                 const cd = curData.find(x => {return x[relaId] === pd[relaId]});
@@ -932,6 +932,9 @@ module.exports = app => {
                 } else {
                     const ncd = {id: pd.id};
                     ncd[relaId] = pd[relaId];
+                    for (const ef of extraFields) {
+                        ncd[ef] = pd[ef];
+                    }
                     for (const f of field) {
                         ncd[prefix + f] = pd[f];
                     }
@@ -966,7 +969,7 @@ module.exports = app => {
             const preStageData = ctx.lastStage.order > 1
                 ? await ctx.service.stagePosFinal.getFinalData(ctx.tender.data, ctx.lastStage.order - 1)
                 : [];
-            this._loadPreData(curStageData, preStageData, ['contract_qty', 'qc_qty'], 'pre_', 'lid');
+            this._loadPreData(curStageData, preStageData, ['contract_qty', 'qc_qty'], 'pre_', 'pid', ['lid']);
             return curStageData;
         }
 

+ 1 - 1
app/controller/stage_controller.js

@@ -341,7 +341,7 @@ module.exports = app => {
 
                 const qtyData = ctx.helper.checkBillsWithPos(ledgerData, posData, ['contract_qty', 'qc_qty']);
                 qtyData.error.forEach(x => { x.errorType = 'qty'; });
-                const tpData = ctx.helper.checkBillsTp(ledgerData, [
+                const tpData = ctx.helper.checkBillsTp(ledgerData.filter(x => {return !x.is_tp}), [
                     { qty: 'contract_qty', tp: 'contract_tp' }, { qty: 'qc_qty', tp: 'qc_tp' },
                 ], this.ctx.tender.info.decimal);
                 tpData.error.forEach(x => { x.errorType = 'tp'; });

+ 23 - 12
app/controller/tender_controller.js

@@ -764,21 +764,32 @@ module.exports = app => {
                 }
             }
             const tenders = await ctx.service.tender.getList('', null, 1);
+            const removeTenders = [];
             for (const tender of tenders) {
-                tender.shenpiInfo = await ctx.service.tenderInfo.getTenderShenpiInfo(tender.id);
-                // 获取所有的固定审批流或固定终审
-                const shenpiauditList = {};
-                for (const shenpi in tender.shenpiInfo) {
-                    if (tender.shenpiInfo[shenpi] === shenpiConst.sp_status.gdspl) {
-                        const shenpiList = await ctx.service.shenpiAudit.getAllDataByCondition({ where: { tid: tender.id, sp_type: shenpiConst.sp_type[shenpi], sp_status: tender.shenpiInfo[shenpi] } });
-                        const shenpiIdList = ctx.helper._.map(shenpiList, 'audit_id');
-                        shenpiauditList[shenpi] = shenpiIdList.length ? shenpiIdList : null;
-                    } else if (tender.shenpiInfo[shenpi] === shenpiConst.sp_status.gdzs) {
-                        const shenpiInfo = await ctx.service.shenpiAudit.getDataByCondition({ tid: tender.id, sp_type: shenpiConst.sp_type[shenpi], sp_status: tender.shenpiInfo[shenpi] });
-                        shenpiauditList[shenpi] = shenpiInfo && shenpiInfo.audit_id ? [shenpiInfo.audit_id] : null;
+                const shenpiInfo = await ctx.service.tenderInfo.getTenderShenpiInfo(tender.id);
+                if (!shenpiInfo) {
+                    removeTenders.push(tender.id);
+                } else {
+                    tender.shenpiInfo = shenpiInfo;
+                    // 获取所有的固定审批流或固定终审
+                    const shenpiauditList = {};
+                    for (const shenpi in tender.shenpiInfo) {
+                        if (tender.shenpiInfo[shenpi] === shenpiConst.sp_status.gdspl) {
+                            const shenpiList = await ctx.service.shenpiAudit.getAllDataByCondition({ where: { tid: tender.id, sp_type: shenpiConst.sp_type[shenpi], sp_status: tender.shenpiInfo[shenpi] } });
+                            const shenpiIdList = ctx.helper._.map(shenpiList, 'audit_id');
+                            shenpiauditList[shenpi] = shenpiIdList.length ? shenpiIdList : null;
+                        } else if (tender.shenpiInfo[shenpi] === shenpiConst.sp_status.gdzs) {
+                            const shenpiInfo = await ctx.service.shenpiAudit.getDataByCondition({ tid: tender.id, sp_type: shenpiConst.sp_type[shenpi], sp_status: tender.shenpiInfo[shenpi] });
+                            shenpiauditList[shenpi] = shenpiInfo && shenpiInfo.audit_id ? [shenpiInfo.audit_id] : null;
+                        }
                     }
+                    tender.shenpiauditList = shenpiauditList;
                 }
-                tender.shenpiauditList = shenpiauditList;
+            }
+            if (removeTenders.length > 0) {
+                ctx.helper._.remove(tenders, function(n) {
+                    return removeTenders.indexOf(n.id) !== -1;
+                });
             }
             const categoryData = await ctx.service.category.getAllCategory(ctx.session.sessionProject.id);
             const renderData = {

+ 3 - 3
app/public/js/change_set.js

@@ -251,7 +251,7 @@ $(document).ready(() => {
             const newVal = $('#gr-search').val()
             let html = ''
             if (newVal && newVal === oldSearchVal) {
-                accountList.filter(item => item && changesUid !== item.id && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
+                accountList.filter(item => item && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
                     html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
                         <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
                                 class="ml-auto">${item.mobile || ''}</span></p>
@@ -268,13 +268,13 @@ $(document).ready(() => {
                         </a> ${group.groupName}</dt>
                         <div class="dd-content" data-toggleid="${idx}">`
                         group.groupList.forEach(item => {
-                            if (item.id !== changesUid) {
+                            // if (item.id !== changesUid) {
                                 html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
                                     <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
                                             class="ml-auto">${item.mobile || ''}</span></p>
                                     <span class="text-muted">${item.role || ''}</span>
                                 </dd>`
-                            }
+                            // }
                         });
                         html += '</div>'
                     })

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

@@ -2127,7 +2127,7 @@ $(document).ready(function() {
             defaultRowHeight: 21,
             headerFont: '12px 微软雅黑',
             font: '12px 微软雅黑',
-            headColWidth: [0],
+            headColWidth: [30],
             selectedBackColor: '#fffacd',
         },
         cellDoubleClick: stdLibCellDoubleClick,
@@ -2158,7 +2158,7 @@ $(document).ready(function() {
             defaultRowHeight: 21,
             headerFont: '12px 微软雅黑',
             font: '12px 微软雅黑',
-            headColWidth: [0],
+            headColWidth: [30],
             selectedBackColor: '#fffacd',
         },
         cellDoubleClick: stdLibCellDoubleClick,
@@ -2206,7 +2206,7 @@ $(document).ready(function() {
                         defaultRowHeight: 21,
                         headerFont: '12px 微软雅黑',
                         font: '12px 微软雅黑',
-                        headColWidth: [0],
+                        headColWidth: [30],
                         selectedBackColor: '#fffacd',
                         readOnly: true,
                     });

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

@@ -173,7 +173,7 @@ $(document).ready(() => {
                     defaultRowHeight: 21,
                     headerFont: '12px 微软雅黑',
                     font: '12px 微软雅黑',
-                    headColWidth: [0],
+                    headColWidth: [30],
                     selectedBackColor: '#fffacd',
                 });
                 dealBills.loadData();

+ 2 - 2
app/public/js/revise.js

@@ -2345,7 +2345,7 @@ $(document).ready(() => {
             defaultRowHeight: 21,
             headerFont: '12px 微软雅黑',
             font: '12px 微软雅黑',
-            headColWidth: [0],
+            headColWidth: [30],
             selectedBackColor: '#fffacd',
         },
         cellDoubleClick: stdLibCellDoubleClick,
@@ -2376,7 +2376,7 @@ $(document).ready(() => {
             defaultRowHeight: 21,
             headerFont: '12px 微软雅黑',
             font: '12px 微软雅黑',
-            headColWidth: [0],
+            headColWidth: [30],
             selectedBackColor: '#fffacd',
         },
         cellDoubleClick: stdLibCellDoubleClick,

+ 2 - 2
app/public/js/revise_compare.js

@@ -83,7 +83,7 @@ $(document).ready(() => {
         calcFields: [
             'org_sgfh_tp', 'org_sjcl_tp', 'org_qtcl_tp', 'org_total_price', 'org_deal_tp',
             'new_sgfh_tp', 'new_sjcl_tp', 'new_qtcl_tp', 'new_total_price', 'new_deal_tp',
-            'contract_tp', 'qc_tp', 'end_contract_tp', 'end_qc_tp'
+            'contract_tp', 'qc_tp', 'pre_contract_tp', 'pre_qc_tp'
         ],
         findNode: function (tree, node, parent) {
             const sameId = tree.datas.find(x => {return x.id === node.id});
@@ -454,7 +454,7 @@ $(document).ready(() => {
                 //pos.end_gather_qty = ZhCalc.add(pos.gather_qty, pos.pre_gather_qty);
             }
             posSpreadObj.loadCurPosData();
-            //$('[data-target=#load-stage]').hide();
+            $('#load-stage-btn').hide();
             $('#load-stage').modal('hide');
         });
     });

+ 2 - 2
app/public/js/shenpi.js

@@ -183,9 +183,9 @@ function getShenpiHtml (this_code) {
         html.push('<tr>');
         html.push('<td>', sp.name, '</td>');
         html.push('<td>');
-        html.push(sp_status_list[sp.status].name);
         const this_status = parseInt($('.' + sp.code + '_div').children('.lc-show').siblings('.form-group').find('input:checked').val());
-        if(this_status != sp_status.sqspr) {
+        html.push(sp_status_list[this_status].name);
+        if(this_status !== sp_status.sqspr) {
             const nameList = [];
             const aid_num = $('.' + sp.code + '_div').children('.lc-show').children('ul').find('.remove-audit').length;
             const aidList = [];

+ 2 - 2
app/service/shenpi_audit.js

@@ -89,7 +89,7 @@ module.exports = app => {
                     if (shenpi_status !== shenpiConst.sp_status.sqspr) {
                         await transaction.delete(this.tableName, { tid: t.id, sp_type: shenpiConst.sp_type[data.code], sp_status: shenpi_status });
                         for (const aid of data.aidList.split(',')) {
-                            if (parseInt(aid) !== t.user_id || (parseInt(aid) === t.user_id && canYB)) {
+                            if (aid && parseInt(aid) !== t.user_id || (parseInt(aid) === t.user_id && canYB)) {
                                 const insertData = {
                                     tid: t.id,
                                     sp_type: shenpiConst.sp_type[data.code],
@@ -129,7 +129,7 @@ module.exports = app => {
                     if (shenpiInfo[code] !== shenpiConst.sp_status.sqspr) {
                         await transaction.delete(this.tableName, { tid: this.ctx.tender.id, sp_type: shenpiConst.sp_type[code], sp_status: shenpiInfo[code] });
                         for (const aid of data.aidList.split(',')) {
-                            if (parseInt(aid) !== this.ctx.tender.data.user_id || (parseInt(aid) === this.ctx.tender.data.user_id && needYB.indexOf(code) !== -1)) {
+                            if (aid && parseInt(aid) !== this.ctx.tender.data.user_id || (parseInt(aid) === this.ctx.tender.data.user_id && needYB.indexOf(code) !== -1)) {
                                 const insertData = {
                                     tid: this.ctx.tender.id,
                                     sp_type: shenpiConst.sp_type[code],

+ 1 - 1
app/service/stage.js

@@ -592,7 +592,7 @@ module.exports = app => {
                         cb.value = this.ctx.helper.add(sumGcl.contract_tp, sumGcl.qc_tp);
                         break;
                     case 'bqyf':
-                        cb.value = this._.sumBy(stage_list, 'yf_tp');
+                        cb.value = this.ctx.helper.roundNum(this._.sumBy(stage_list, 'yf_tp'), 2);
                         break;
                     default:
                         cb.value = 0;

+ 5 - 1
app/service/tender_info.js

@@ -342,7 +342,11 @@ module.exports = app => {
          */
         async getTenderShenpiInfo(tenderId) {
             const info = await this.getDataByCondition({ tid: tenderId });
-            const shenpiInfo = !info.shenpi || info.shenpi === '' ? defaultInfo.shenpi : JSON.parse(info.shenpi);
+            // 还没选择模式的标段不应该可以选择审批流程设置
+            if (!info) {
+                return false;
+            }
+            const shenpiInfo = !info.shenpi || info.shenpi === null || info.shenpi === '' ? defaultInfo.shenpi : JSON.parse(info.shenpi);
             return shenpiInfo;
         }
     }

+ 3 - 1
app/view/revise/compare.ejs

@@ -28,8 +28,10 @@
                 <span class="ml-2"><i class="fa fa-stop text-success-50 border-success-50 bg-success-50"></i> 文字修改</span>
             </div>
             <div class="ml-auto">
+                <% if (ctx.app.config.is_debug) { %>
                 <% if (lastStage) { %>
-                <a class="btn btn-sm btn-primary mr-1" href="#load-stage" data-toggle="modal" data-target="#load-stage">加载计量数据</a>
+                <a class="btn btn-sm btn-primary mr-1" id="load-stage-btn" href="#load-stage" data-toggle="modal" data-target="#load-stage">加载计量数据</a>
+                <% } %>
                 <% } %>
             </div>
         </div>

+ 9 - 0
sql/update.sql

@@ -15,3 +15,12 @@ CHANGE COLUMN `re_upload` `extra_upload` TINYINT(1) NOT NULL DEFAULT '0' COMMENT
 
 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='审批流程人设置表';