瀏覽代碼

1. 报表,添加材料调差相关数据
2. 中间计量,附件,删除问题

MaiXinRong 3 年之前
父節點
當前提交
0fd4a24a33

+ 19 - 0
app/lib/ledger.js

@@ -749,6 +749,25 @@ class checkData {
 
             addXmjCheck(topLevel);
         }
+        const xmjPart = {}, xmjIndex = [];
+        for (const x of xmj) {
+            if (!xmjPart[x.code]) {
+                xmjPart[x.code] = [];
+                xmjIndex.push(x.code);
+            }
+            xmjPart[x.code].push(x);
+        }
+        for (const x of xmjIndex) {
+            if (xmjPart[x].length <= 1) continue;
+            for (const xp of xmjPart[x]) {
+                this.checkResult.error.push({
+                    ledger_id: xp.ledger_id,
+                    b_code: xp.b_code,
+                    name: xp.name,
+                    errorType: 'same_code',
+                })
+            }
+        }
         let check = null;
         while (xmj.length > 0) {
             [check, xmj] = this.ctx.helper._.partition(xmj, x => { return x.code === xmj[0].code; });

+ 9 - 5
app/public/js/ledger_check.js

@@ -148,12 +148,16 @@ const ledgerCheckUtil = {
 
             addXmjCheck(topLevel);
         }
-        let check = null;
-        while (xmj.length > 0) {
-            [check, xmj] = _.partition(xmj, x => { return x.code === xmj[0].code; });
-            if (check.length > 1) {
-                error.push(...check);
+        const xmjPart = {}, xmjIndex = [];
+        for (const x of xmj) {
+            if (!xmjPart[x.code]) {
+                xmjPart[x.code] = [];
+                xmjIndex.push(x.code);
             }
+            xmjPart[x.code].push(x);
+        }
+        for (const x of xmjIndex) {
+            if (xmjPart[x].length > 1) error.push(...xmjPart[x]);
         }
         return error;
     },

+ 23 - 2
app/public/js/stage.js

@@ -2021,13 +2021,23 @@ $(document).ready(() => {
 
     // 加载计量单元数据 - 暂时统一加载,如有需要,切换成动态加载并缓存
     postData(window.location.pathname + '/load', { filter: 'ledger;pos;detail;change;tag;cooperation' }, function (result) {
+        result.ledgerData && console.log('ledger: ' + result.ledgerData.length);
+        result.posData && console.log('pos: ' + result.posData.length);
+        result.detailData && console.log('detail: ' + result.detailData.length);
+        result.detailAtt && console.log('detailAtt: ' + result.detailAtt.length);
+        result.changeData && console.log('change: ' + result.changeData.length);
+        result.tags && console.log('tag: ' + result.tags.length);
+        result.cooperation && console.log('cooperation: ' + result.cooperation.length);
         // 加载树结构
+        console.time('loadLedger');
         stageTree.loadDatas(result.ledgerData);
-        // stageTree.loadCurStageData(curStageData);
-        // stageTree.loadPreStageData(preStageData);
+        console.timeEnd('loadLedger');
         checkShowLast(result.ledgerData.length);
+        console.time('calcLedger');
         treeCalc.calculateAll(stageTree);
+        console.timeEnd('calcLedger');
         // 加载解锁相关
+        console.time('loadCooperation');
         if (result.cooperation) {
             stageTree.loadPwd(result.cooperation, 'bills-p-' + userID + '-' + window.location.pathname.split('/')[2], result.cooperationConfirm);
             $('#cooperationCount').html(stageTree.pwd.length || '');
@@ -2035,20 +2045,31 @@ $(document).ready(() => {
             setCooperationSelectHtml();
             reloadCooperationHtml();
         }
+        console.timeEnd('loadCooperation');
+        console.time('loadTag');
         for (const t of result.tags) {
             t.node = stageTree.datas.find(x => {return x.id === t.lid});
         }
         billsTag.loadDatas(result.tags);
+        console.timeEnd('loadTag');
         // 加载部位明细
+        console.time('loadPos');
         stagePos.loadDatas(result.posData);
+        console.timeEnd('loadPos');
         stagePos.calculateAll();
+        console.time('showLedger');
         SpreadJsObj.loadSheetData(slSpread.getActiveSheet(), 'tree', stageTree);
         SpreadJsObj.loadTopAndSelect(slSpread.getActiveSheet(), ckBillsSpread);
+        console.timeEnd('showLedger');
+        console.time('showPos');
         stagePosSpreadObj.loadCurPosData();
         SpreadJsObj.resetTopAndSelect(spSpread.getActiveSheet());
+        console.timeEnd('showPos');
         // 加载中间计量
+        console.time('loadIm');
         stageIm.init(stage, imType, tenderInfo.decimal);
         stageIm.loadData(result.ledgerData, result.posData, result.detailData, result.changeData, result.detailAtt);
+        console.timeEnd('loadIm');
 
         errorList.loadHisErrorData();
         checkList.loadHisCheckData();

+ 21 - 0
app/service/material.js

@@ -68,11 +68,32 @@ module.exports = app => {
             return material;
         }
 
+        async checkMaterial(tid, order) {
+            if (this.ctx.material) return;
+            this.ctx.material = await this.getSelectMaterial(tid, order);
+        }
+
         /**
          * 获取标段下的全部计量期,按倒序
          * @param tenderId
          * @return {Promise<void>}
          */
+        async getSelectMaterial(tenderId, order) {
+            const materials = await this.db.select(this.tableName, {
+                where: { tid: tenderId, order },
+            });
+            if (materials.length > 0 && materials[0].status !== auditConst.status.checked) {
+                const material = materials[0];
+                const curAuditor = await this.ctx.service.materialAudit.getCurAuditor(material.id, material.times);
+                const isActive = curAuditor ? curAuditor.id === this.ctx.session.sessionUser.accountId : material.user_id === this.ctx.session.sessionUser.accountId;
+                if (isActive) {
+                    material.curTimes = material.times;
+                    material.curOrder = curAuditor ? curAuditor.order : 0;
+                }
+            }
+            return materials;
+        }
+
         async getValidMaterials(tenderId) {
             const materials = await this.db.select(this.tableName, {
                 where: { tid: tenderId },

+ 8 - 0
app/service/report.js

@@ -160,6 +160,14 @@ module.exports = app => {
                                 customDefine.gather_select, customSelect ? customSelect.gather_select : null));
                             runnableKey.push(filter);
                             break;
+                        case 'mem_select_material':
+                            runnableRst.push(service.material.getSelectMaterial(params.tender_id, params.material_order));
+                            runnableKey.push(filter);
+                            break;
+                        case 'mem_select_material_audit':
+                            runnableRst.push(service.material.getSelectMaterialAuditors(params.tender_id, params.material_order));
+                            runnableKey.push(filter);
+                            break;
                         case 'mem_material':
                             runnableRst.push(service.reportMemory.getMaterial(params.tender_id, params.material_order, memFieldKeys[filter]));
                             runnableKey.push(filter);

+ 19 - 0
app/service/report_memory.js

@@ -921,6 +921,25 @@ module.exports = app => {
             }
         }
 
+        async getSelectMaterialAuditors(tid, material_order, fields) {
+            this.material = await this.ctx.service.material.checkMaterial(tid, material_order);
+            const auditors = await this.ctx.service.materialAudit.getFinalAuditGroup(this.material.id, this.ctx.material.curTimes);
+            const user = await this.ctx.service.projectAccount.getDataById(this.ctx.material.user_id);
+            const result = [{
+                aid: user.id,
+                name: user.name,
+                company: user.company,
+                role: user.role,
+                mobile: user.mobile,
+                telephone: user.telephone,
+                sign_path: user.sign_path,
+                opinion: user.opinion,
+                end_time: auditors && auditors.length > 0 ? auditors[0].begin_time : null,
+                sort: 0,
+            }, ...auditors];
+            return result;
+        }
+
         async getMaterial(tender_id, material_order, fields) {
             return await this.ctx.service.material.getValidMaterials(tender_id);
         }

+ 1 - 5
app/service/stage_detail_att.js

@@ -130,11 +130,7 @@ module.exports = app => {
             detailAtt.attachment.splice(index, 1);
             await this.db.update(this.tableName, { id: detailAtt.id, attachment: JSON.stringify(detailAtt.attachment) });
 
-            // if (fs.existsSync(path.join(this.ctx.app.baseDir, att.filepath))) {
-            //     await fs.unlinkSync(path.join(this.ctx.app.baseDir, att.filepath));
-            // }
-            await this.ctx.app.fujianOss.delete(ctx.app.config.fujianOssFolder + att.filepath);
-
+            await this.ctx.app.fujianOss.delete(this.ctx.app.config.fujianOssFolder + att.filepath);
 
             await this._complete4Output(detailAtt);
             return detailAtt;

+ 45 - 1
builder_report_index_define.js

@@ -1250,6 +1250,48 @@ const gather_deal_bills = {
 };
 
 // 材差
+const select_material = {
+    name: '材料调差-选择期-数据(mem_select_material)',
+    remark: '',
+    id: 71,
+    key: 'mem_select_material',
+    prefix: '材料调差-选择期',
+    cols: [
+        { name: 'id', field: 'id', type: dataType.int },
+        { name: '标段id', field: 'tid', type: dataType.int },
+        { name: '创建者id', field: 'user_id', type: dataType.int },
+        { name: '审批次数', field: 'times', type: dataType.int },
+        { name: '审批状态', field: 'status', type: dataType.int },
+        { name: '期id列表', field: 'stage_id', type: dataType.str },
+        { name: '期order列表', field: 's_order', type: dataType.str },
+        { name: '材料调差期数', field: 'order', type: dataType.int },
+        { name: '本期金额', field: 'm_tp', type: dataType.currency },
+        { name: '截止上期金额', field: 'pre_tp', type: dataType.currency },
+        { name: '税率', field: 'rate', type: dataType.int },
+        { name: '创建时间', field: 'in_time', type: dataType.str },
+
+    ],
+};
+
+const select_material_audit = {
+    name: '材料调差-选择期-审批人 列表(mem_select_material_audit)',
+    remark: '',
+    id: 72,
+    key: 'mem_select_material_audit',
+    prefix: '材料调差-选择期',
+    cols: [
+        { name: '审批人id', field: 'aid', type: dataType.int },
+        { name: '姓名', field: 'name', type: dataType.str },
+        { name: '公司', field: 'company', type: dataType.str },
+        { name: '角色', field: 'role', type: dataType.str },
+        { name: '手机', field: 'mobile', type: dataType.str },
+        { name: '电话', field: 'telephone', type: dataType.str },
+        { name: '审批意见', field: 'opinion', type: dataType.str },
+        { name: '审批时间', field: 'end_time', type: dataType.str },
+        { name: '审批顺序', field: 'sort', type: dataType.str },
+    ],
+};
+
 const material = {
     name: '材料调差-期列表-数据(mem_material)',
     remark: '',
@@ -2031,6 +2073,8 @@ const custom_select = {
         { name: '标段汇总-汇总区间(期)', field: 'gather_select.stage_zone', type: dataType.int },
         // stage_select
         { name: '期汇总-选择期', field: 'stage_select.stages', type: dataType.str},
+        // material_select
+        { name: '材料调差-选择期', field: 'material'}
     ]
 };
 
@@ -2141,7 +2185,7 @@ const defines = [
     stage_im_zl, stage_im_tz, stage_im_tz_bills,
     stage_rela_im, stage_rela_im_bills,
     gather_stage_bills, gather_tender_info, gather_stage_pay, gather_deal_bills,
-    material, materialGl, material_bills, material_pos, material_gl_detail,
+    select_material, select_material_audit, material, materialGl, material_bills, material_pos, material_gl_detail,
     stage_sum_bills, stage_sum_pay, stage_audit, sign_select,
     stage_change, stage_change_bills, stage_change_ledger,
     gcl_gather_bills, gcl_gather_xmj,