Jelajahi Sumber

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

TonyKang 3 tahun lalu
induk
melakukan
08d6254b6a

+ 5 - 0
app/controller/material_controller.js

@@ -125,6 +125,11 @@ module.exports = app => {
                 if (data.s_order === '') {
                     throw '没有选中计量期';
                 }
+                // 调差期是否存在审批或待上报,存在则无法重复添加
+                const doingMaterial = await ctx.service.material.getDataByCondition({ tid: ctx.tender.id, status: [auditConst.status.uncheck, auditConst.status.checking, auditConst.status.checkNo] });
+                if (doingMaterial) {
+                    throw '存在待上报或审批中的调差期,请勿重复生成';
+                }
                 const newMaterial = await ctx.service.material.addMaterial(ctx.tender.id, data);
                 if (!newMaterial) {
                     throw '新增材料调差期失败,请重试';

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

@@ -244,7 +244,7 @@ $(function () {
             $(this).removeAttr('disabled');
             return false;
         }
-        $(this).text('添加中,请稍后...');
+        $(this).text('正在生成新一期数据中,请勿刷新本页!...');
         $(this).parents('form').submit();
     })
 });

+ 1 - 1
app/public/js/shares/cs_tools.js

@@ -686,7 +686,7 @@ const showSelectTab = function(select, spread, afterShow) {
             tagHtml.push('<div class="pull-right edit-tag-btn">');
             const lid = tag.node ? tag.node.ledger_id : -1;
             tagHtml.push(`<a class="mr-1" name="bills-tag-locate" href="javascript: void(0);" lid="${lid}"><i class="fa fa-crosshairs"></i> 定位</a>`);
-            if (tag.uid === userID) tagHtml.push(`<a href="javascript: void(0);" name="bills-tag-edit" tag-id="${tag.id}"><i class="fa fa-edit"></i> 编辑</a>`);
+            if (tag.uid === userID && !setting.readOnly) tagHtml.push(`<a href="javascript: void(0);" name="bills-tag-edit" tag-id="${tag.id}"><i class="fa fa-edit"></i> 编辑</a>`);
             tagHtml.push('</div>');
             tagHtml.push('<div class="card-body p-2">', '<p class="card-text">', tag.comment, '</p>', '</div>');
             tagHtml.push('</div>');

+ 23 - 6
app/public/js/sr_detail.js

@@ -328,6 +328,7 @@ $(document).ready(() => {
         selector: '#bills-tag',
         relaSpread: slSpread,
         updateUrl: window.location.pathname + '/tag',
+        readOnly: true,
         afterModify: function (nodes) {
             SpreadJsObj.repaintNodesRowHeader(slSpread.getActiveSheet(), nodes);
         },
@@ -844,7 +845,7 @@ $(document).ready(() => {
                 const curIndex = parseInt($('#im-locate-info')[0].innerText.split('/')[0]);
                 const select = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
                 if (select && select.source) {
-                    const targetIndex = math.max(curIndex-1, 1);
+                    const targetIndex = Math.max(curIndex-1, 1);
                     SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), select.source[targetIndex-1].id, true);
                     stagePosSpreadObj.loadCurPosData();
                     $('#im-locate-info')[0].innerText = targetIndex + '/' + select.source.length;
@@ -854,7 +855,7 @@ $(document).ready(() => {
                 const curIndex = parseInt($('#im-locate-info')[0].innerText.split('/')[0]);
                 const select = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
                 if (select && select.source) {
-                    const targetIndex = math.min(curIndex+1, select.source.length);
+                    const targetIndex = Math.min(curIndex+1, select.source.length);
                     SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), select.source[targetIndex-1].id, true);
                     stagePosSpreadObj.loadCurPosData();
                     $('#im-locate-info')[0].innerText = targetIndex + '/' + select.source.length;
@@ -1135,7 +1136,7 @@ $(document).ready(() => {
     // 批量下载
     $('#bach-download').click(function() {
         const fileIds = [];
-        const type = $(this).prop('type');
+        const type = $(this).attr('type');
         let node = ''
         if (type === 'curr') {
             node = '#nodelist-table .check-file:checked'
@@ -1148,9 +1149,25 @@ $(document).ready(() => {
         });
 
         if (fileIds.length) {
-            const url = `/tender/${relaTender.id}/measure/stage/${relaStage.order}/download/compresse-file?fileIds=${JSON.stringify(fileIds)}`;
-            $('#zipDown').attr('href', url);
-            $("#zipDown")[0].click();
+            if (fileIds.length > 10) {
+              return toastr.warning(`最大允许10个文件(当前${fileIds.length}个)`)
+            }
+            toastr.success('正在进行压缩文件...', '', { timeOut: 0, extendedTimeOut: 0})
+            $(this).attr('disabled', "true")
+            const btn = $(this)
+            postCompressFile(`/tender/${relaTender.id}/measure/stage/${relaStage.order}/download/compresse-file`, {fileIds}, function(result) {
+              toastr.clear()
+              toastr.success('压缩文件成功')
+              btn.removeAttr('disabled')
+              const href = window.URL.createObjectURL(result)
+              $('#zipDown').attr('href', href);
+              $('#zipDown').attr('download', `${relaTender.name}-计量台账-第${relaStage.order}期-附件.zip`);
+              $("#zipDown")[0].click();
+            }, () => {
+              btn.removeAttr('disabled')
+              toastr.clear()
+              toastr.error('批量下载失败')
+            });
         }
     });
 

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

@@ -2962,7 +2962,7 @@ $(document).ready(() => {
                 const curIndex = parseInt($('#im-locate-info')[0].innerText.split('/')[0]);
                 const select = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
                 if (select && select.source) {
-                    const targetIndex = math.max(curIndex-1, 1);
+                    const targetIndex = Math.max(curIndex-1, 1);
                     SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), select.source[targetIndex-1].id, true);
                     stagePosSpreadObj.loadCurPosData();
                     $('#im-locate-info')[0].innerText = targetIndex + '/' + select.source.length;
@@ -2972,7 +2972,7 @@ $(document).ready(() => {
                 const curIndex = parseInt($('#im-locate-info')[0].innerText.split('/')[0]);
                 const select = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
                 if (select && select.source) {
-                    const targetIndex = math.min(curIndex+1, select.source.length);
+                    const targetIndex = Math.min(curIndex+1, select.source.length);
                     SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), select.source[targetIndex-1].id, true);
                     stagePosSpreadObj.loadCurPosData();
                     $('#im-locate-info')[0].innerText = targetIndex + '/' + select.source.length;
@@ -4415,7 +4415,7 @@ function makeShouFang() {
 // 生成收方单列表
 function getShouFangList(currPageNum = 1) {
     // 每页最多几个附件
-    const pageCount = 15;
+    const pageCount = 20;
     // 附件总数
     const total = sfData.length;
     // 总页数
@@ -4449,9 +4449,9 @@ function makeReportData(sfid) {
     const ledger_code = sfInfo.name.split(' / ')[0];
     const pos_name = sfInfo.name.split(' / ')[1] ? sfInfo.name.split(' / ')[1] : '';
     const replace_key_params = {
-        'KEY_标段名称': tender.name,
+        'KEY_标段名称': tenderInfo.deal_info.buildName,
         'KEY_总承包单位': tenderInfo.construction_unit.contract1.company,
-        'KEY_合同段': tenderInfo.deal_info.dealCode,
+        'KEY_合同段': tenderInfo.deal_info.dealName,
         'KEY_监理单位': tenderInfo.construction_unit.supervision1.company,
         'KEY_编号': '',
         'KEY_设计工程数量': 0,

+ 31 - 12
app/service/stage.js

@@ -512,18 +512,18 @@ module.exports = app => {
             try {
                 const stageInfo = await this.getDataById(id);
                 // 通知发送 - 第三方更新
-                if (this.ctx.session.sessionProject.custom && syncApiConst.notice_type.indexOf(this.ctx.session.sessionProject.customType) !== -1) {
-                    const base_data = {
-                        tid: this.ctx.tender.id,
-                        sid: id,
-                        op: 'delete',
-                    };
-                    await this.ctx.helper.syncNoticeSend(this.ctx.session.sessionProject.customType, JSON.stringify(base_data));
-                    // 是否还存在其他期
-                    base_data.op = stageInfo.order === 1 ? 'delete' : 'update';
-                    base_data.sid = -1;
-                    await this.ctx.helper.syncNoticeSend(this.ctx.session.sessionProject.customType, JSON.stringify(base_data));
-                }
+                // if (this.ctx.session.sessionProject.custom && syncApiConst.notice_type.indexOf(this.ctx.session.sessionProject.customType) !== -1) {
+                //     const base_data = {
+                //         tid: this.ctx.tender.id,
+                //         sid: id,
+                //         op: 'delete',
+                //     };
+                //     await this.ctx.helper.syncNoticeSend(this.ctx.session.sessionProject.customType, JSON.stringify(base_data));
+                //     // 是否还存在其他期
+                //     base_data.op = stageInfo.order === 1 ? 'delete' : 'update';
+                //     base_data.sid = -1;
+                //     await this.ctx.helper.syncNoticeSend(this.ctx.session.sessionProject.customType, JSON.stringify(base_data));
+                // }
                 await transaction.delete(this.tableName, { id });
                 await transaction.delete(this.ctx.service.pos.tableName, { add_stage: id });
                 await transaction.delete(this.ctx.service.stageAudit.tableName, { sid: id });
@@ -580,6 +580,25 @@ module.exports = app => {
                 await transaction.delete(this.ctx.service.scheduleStage.tableName, { tid: stageInfo.tid, order: stageInfo.order });
                 // 重算进度计量总金额
                 await this.ctx.service.scheduleStage.calcStageSjTp(transaction, stageInfo.tid);
+                // 删除收方单及附件
+                const shoufangAttList = await this.ctx.service.stageShoufangAtt.getAllDataByCondition({ where: { sid: id } });
+                if (shoufangAttList.length !== 0) {
+                    for (const att of shoufangAttList) {
+                        if (fs.existsSync(path.join(this.app.baseDir, att.filepath))) {
+                            await fs.unlinkSync(path.join(this.app.baseDir, att.filepath));
+                        }
+                    }
+                }
+                await transaction.delete(this.ctx.service.stageShoufangAtt.tableName, { sid: id });
+                const shoufangList = await this.ctx.service.stageShoufang.getAllDataByCondition({ where: { sid: id } });
+                if (shoufangList.length !== 0) {
+                    for (const att of shoufangList) {
+                        if (fs.existsSync(path.join(this.app.baseDir, 'app/' + att.qrcode))) {
+                            await fs.unlinkSync(path.join(this.app.baseDir, 'app/' + att.qrcode));
+                        }
+                    }
+                }
+                await transaction.delete(this.ctx.service.stageShoufang.tableName, { sid: id });
                 // 记录删除日志
                 await this.ctx.service.projectLog.addProjectLog(transaction, projectLogConst.type.stage, projectLogConst.status.delete, '第' + stageInfo.order + '期');
                 await transaction.commit();

+ 5 - 3
app/service/stage_rela.js

@@ -49,8 +49,10 @@ class srCache {
                 l.contract_tp = this.ctx.helper.mul(l.unit_price, l.contract_qty, decimal.tp);
                 l.qc_tp = this.ctx.helper.mul(l.unit_price, l.qc_qty, decimal.tp);
             }
+            l.gather_qty = this.ctx.helper.add(l.contract_qty, l.qc_qty);
             l.gather_tp = this.ctx.helper.add(l.contract_tp, l.qc_tp);
-            l.pre_gather_tp = this.ctx.helper.add(l.pre_contract_qty, l.pre_contract_tp);
+            l.pre_gather_qty = this.ctx.helper.add(l.pre_contract_qty, l.pre_contract_qty);
+            l.pre_gather_tp = this.ctx.helper.add(l.pre_contract_tp, l.pre_contract_tp);
             l.end_contract_qty = this.ctx.helper.add(l.pre_contract_qty, l.contract_qty);
             l.end_contract_tp = this.ctx.helper.add(l.pre_contract_tp, l.contract_tp);
             l.end_qc_qty = this.ctx.helper.add(l.pre_qc_qty, l.qc_qty);
@@ -170,7 +172,7 @@ class srCache {
                 this.stagePos.push({
                     tid: this.ctx.tender.id, sid: this.ctx.stage.id, sorder: this.ctx.stage.order,
                     rela_tid: this.stage.tid, rela_sid: this.stage.id, rela_sorder: this.stage.order,
-                    pid: t.pid, lid: t.id,
+                    pid: t.id, lid: t.id,
                     contract_qty: t.contract_qty, contract_expr: t.contract_expr, qc_qty: t.qc_qty, postil: t.postil,
                 });
             }
@@ -178,7 +180,7 @@ class srCache {
                 this.stagePosFinal.push({
                     tid: this.ctx.tender.id, sid: this.ctx.stage.id, sorder: this.ctx.stage.order,
                     rela_tid: this.stage.tid, rela_sid: this.stage.id, rela_sorder: this.stage.order,
-                    pid: t.pid, lid: t.lid,
+                    pid: t.id, lid: t.lid,
                     contract_qty: t.end_contract_qty, qc_qty: t.end_qc_qty
                 })
             }

+ 2 - 2
app/service/stage_shoufang.js

@@ -65,8 +65,8 @@ module.exports = app => {
                     }
                 }
                 // 删除二维码
-                if (fs.existsSync(path.join(this.app.baseDir, sfInfo.qrcode))) {
-                    await fs.unlinkSync(path.join(this.app.baseDir, sfInfo.qrcode));
+                if (fs.existsSync(path.join(this.app.baseDir, 'app/' + sfInfo.qrcode))) {
+                    await fs.unlinkSync(path.join(this.app.baseDir, 'app/' + sfInfo.qrcode));
                 }
                 await transaction.delete(this.ctx.service.stageShoufangAtt.tableName, { sfid });
                 await transaction.delete(this.tableName, { id: sfid });

+ 2 - 1
app/view/stage/index.ejs

@@ -561,7 +561,7 @@
                             <!--所有附件 翻页-->
                             <span id="shoufang-showPage" class="ml-auto"><a href="javascript:void(0);" class="shoufang-page-select ml-3" content="pre"><i class="fa fa-chevron-left"></i></a> <span id="shoufang-currentPage">1</span>/<span id="shoufang-totalPage">10</span> <a href="javascript:void(0);" class="shoufang-page-select mr-3" content="next"><i class="fa fa-chevron-right"></i></a></span>
                         </div>
-                        <div class="sjs-height-3" style="overflow:auto; overflow-x:hidden;">
+                        <div class="sjs-height-6" style="overflow:auto; overflow-x:hidden;">
                             <table class="table table-sm table-bordered table-hover" style="word-break:break-all; table-layout: fixed">
                                 <tr><th>清单 / 计量单元</th><th width="40">附件</th><th width="100">收方单</th></tr>
                                 <tbody id="shoufang-table" class="list-table">
@@ -634,6 +634,7 @@
     }
     const tender = JSON.parse(unescape('<%- escape(JSON.stringify(tender)) %>'));
     const tenderInfo = JSON.parse(unescape('<%- escape(JSON.stringify(ctx.tender.info)) %>'));
+    console.log(tenderInfo);
     const thousandth = <%- ctx.tender.info.display.thousandth %>;
     const measureType = JSON.parse('<%- JSON.stringify(measureType) %>');
     const stage = JSON.parse(unescape('<%- escape(JSON.stringify(ctx.stage)) %>'));

+ 2 - 1
app/view/stage_rela/detail.ejs

@@ -247,7 +247,7 @@
                                     <a class="nav-link" data-toggle="tab" href="#syfujian" role="tab" fujian-content="syfujian">所有附件</a>
                                 </li>
                                 <li class="nav-item ml-auto pt-1">
-                                    <a href="javascript:void(0);" id="bach-download" class="btn btn-sm btn-primary" type="curr">批量下载</a>
+                                    <button id="bach-download" class="btn btn-sm btn-primary" type="curr">批量下载</button>
                                     <!--所有附件 翻页-->
                                     <span id="showPage" style="display: none"><a href="javascript:void(0);" class="page-select ml-3" content="pre"><i class="fa fa-chevron-left"></i></a> <span id="currentPage">1</span>/<span id="totalPage">10</span> <a href="javascript:void(0);" class="page-select mr-3" content="next"><i class="fa fa-chevron-right"></i></a></span>
                                 </li>
@@ -410,6 +410,7 @@
     const thirdParty = JSON.parse('<%- JSON.stringify(thirdParty) %>');
     const measureType = JSON.parse('<%- JSON.stringify(measureType) %>');
     const imType = JSON.parse('<%- JSON.stringify(imType) %>');
+    const cur_uid = parseInt('<%- ctx.session.sessionUser.accountId %>');
 </script>
 <style>
 

+ 21 - 0
app/view/stage_rela/detail_modal.ejs

@@ -0,0 +1,21 @@
+<!--草图预览-->
+<div class="modal fade" id="imgview" data-backdrop="static">
+    <div class="modal-dialog modal-lgx" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">查看草图</h5>
+            </div>
+            <div class="modal-body">
+                <img src="" id="view-calc-img">
+                <div class="mt-2">
+                    <textarea id="view-calc-remark" class="form-control form-control-sm" placeholder="草图备注" rows="3">
+                    </textarea>
+                </div>
+            </div>
+
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+            </div>
+        </div>
+    </div>
+</div>