소스 검색

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

Tony Kang 3 주 전
부모
커밋
07c1b4ea1c

+ 1 - 0
app/controller/quality_controller.js

@@ -138,6 +138,7 @@ module.exports = app => {
             const pos = await this.ctx.service.pos.getAllDataByCondition({
                 where: condition,
                 columns: ['id', 'tid', 'lid', 'name'],
+                orders: [['porder', 'ASC']],
             });
             // const quality = spec && spec.loadStatus ? await this.ctx.service.quality.getAllDataByCondition({
             //     where: { tid: this.ctx.tender.id, rela_type: 'pos' },

+ 3 - 0
app/controller/sub_proj_setting_controller.js

@@ -249,6 +249,8 @@ module.exports = app => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { id: item.id, name: item.name, groupList };
                 }).filter(x => { return x.groupList.length > 0; });
+
+                const subProjects = await this.ctx.service.subProject.getAllDataByCondition({ where: { project_id: this.ctx.session.sessionProject.id, is_folder: 0, is_delete: 0 }});
                 const renderData = {
                     pageInfo,
                     accountGroup,
@@ -260,6 +262,7 @@ module.exports = app => {
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.setting.sp_permission),
                     permissionBlock: ctx.service.subProjPermission.PermissionBlock,
                     accountList,
+                    subProjects,
                 };
                 await this.layout('sp_setting/user.ejs', renderData, 'sp_setting/user_modal.ejs');
             } catch (error) {

+ 1 - 1
app/lib/bills_pos_convert.js

@@ -61,7 +61,7 @@ class BillsPosConvert {
     _loadPosData(pos) {
         this.bpcPos.loadDatas(pos);
     }
-    loadData (ledger, pos, change) {
+    loadData(ledger, pos, change) {
         this._loadLedgerData(ledger);
         this._loadPosData(pos);
         this.bpcChange = change;

+ 52 - 3
app/lib/stage_im.js

@@ -811,6 +811,8 @@ class StageIm {
                 lxid: leafXmj.id,
                 code: leafXmj.code,
                 name: leafXmj.name,
+                contract_expr: [],
+                qc_expr: [],
             };
             im.leafXmjs.push(lx);
         }
@@ -818,6 +820,8 @@ class StageIm {
         lx.contract_jl = this.ctx.helper.add(lx.contract_jl, node.contract_qty);
         lx.qc_jl = this.ctx.helper.add(lx.qc_jl, node.qc_qty);
         lx.qc_minus_jl = this.ctx.helper.add(lx.qc_minus_jl, node.qc_minus_qty);
+        lx.contract_expr.push(node.contract_expr);
+        lx.qc_expr.push(node.qc_qty)
         this._generateZlPosData(node, lx);
     }
     _generateZlChangeData(node, im) {
@@ -966,13 +970,35 @@ class StageIm {
                     im.end_tp = this.ctx.helper.mul(im.end_jl, im.unit_price, tp_decimal);
                     im.end_contract_tp = this.ctx.helper.mul(im.end_contract_jl, im.unit_price, tp_decimal);
                     im.end_qc_tp = this.ctx.helper.mul(im.end_qc_jl, im.unit_price, tp_decimal);
-                    im.calc_memo = '本期计量:' + (this.ctx.helper.checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit;
                     this.ImData.push(im);
                     for (const c of this.changes) {
                         if (c.lid === p.id && c.pid === pp.id && c.qty && c.qty !== 0) {
                             im.changes.push(c);
                         }
                     }
+                    const calc_memo = [];
+                    calc_memo.push('本期计量:' + (this.ctx.helper.checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit);
+                    const contract_expr = pp.contract_expr ? pp.contract_qty + '=' + pp.contract_expr : (pp.contract_qty || 0);
+                    let qc_expr = '', minus_qc_expr = '';
+                    im.changes.forEach(x => {
+                        if (x.no_value) {
+                            if (minus_qc_expr) {
+                                minus_qc_expr = minus_qc_expr + (x.qty > 0 ? '+' + x.qty : x.qty);
+                            } else {
+                                minus_qc_expr = minus_qc_expr + x.qty;
+                            }
+                        } else {
+                            if (qc_expr) {
+                                qc_expr = qc_expr + (x.qty > 0 ? '+' + x.qty : x.qty);
+                            } else {
+                                qc_expr = qc_expr + x.qty;
+                            }
+                        }
+                    });
+                    qc_expr = qc_expr ? pp.qc_qty + '=' + qc_expr : (pp.qc_qty || 0);
+                    minus_qc_expr = minus_qc_expr ? pp.qc_minus_qty + '=' + minus_qc_expr : (pp.qc_minus_qty || 0);
+                    calc_memo.push(`其中合同计量:${contract_expr};变更计量:${qc_expr};变更不计价:${minus_qc_expr}`);
+                    im.calc_memo = calc_memo.join('\n');
                 }
             } else {
                 if (this.ctx.helper.checkZero(p.gather_qty) && this.ctx.helper.checkZero(p.gather_tp) && this.ctx.helper.checkZero(p.qc_minus_qty)) { continue; }
@@ -996,14 +1022,37 @@ class StageIm {
                     position: '',
                     lIndex: this.billsTree.getNodeSerialNo(node),
                 };
-                im.calc_memo = '本期计量:' + (this.ctx.helper.checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit;
                 this.ImData.push(im);
                 for (const c of this.changes) {
                     if (c.lid === p.id && c.pid == -1 && c.qty && c.qty !== 0) {
                         im.changes.push(c);
                     }
                 }
-                this.import_changes.forEach(x => { if (x.lid === p.id) im.changes.push(x) });
+                this.import_changes.forEach(x => { if (x.lid === p.id && x.rela_qty) im.changes.push(x)});
+                const calc_memo = [];
+                calc_memo.push('本期计量:' + (this.ctx.helper.checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit);
+                const contract_expr = p.contract_expr ? p.contract_qty + '=' + p.contract_expr : (p.contract_qty || 0);
+                let qc_expr = '', minus_qc_expr = '';
+                im.changes.forEach(x => {
+                    const prefix = x.rela_no_value === undefined ? '' : 'rela_';
+                    if (x[prefix + 'no_value']) {
+                        if (minus_qc_expr) {
+                            minus_qc_expr = minus_qc_expr + (x[prefix + 'qty'] > 0 ? '+' + x[prefix + 'qty'] : x[prefix + 'qty']);
+                        } else {
+                            minus_qc_expr = minus_qc_expr + x[prefix + 'qty'];
+                        }
+                    } else {
+                        if (qc_expr) {
+                            qc_expr = qc_expr + (x[prefix + 'qty'] > 0 ? '+' + x[prefix + 'qty'] : x[prefix + 'qty']);
+                        } else {
+                            qc_expr = qc_expr + x[prefix + 'qty'];
+                        }
+                    }
+                });
+                qc_expr = qc_expr ? p.qc_qty + '=' + qc_expr : (p.qc_qty || 0);
+                minus_qc_expr = minus_qc_expr ? p.qc_minus_qty + '=' + minus_qc_expr : (p.qc_minus_qty || 0);
+                calc_memo.push(`其中合同计量:${contract_expr};变更计量:${qc_expr};变更不计价:${minus_qc_expr}`);
+                im.calc_memo = calc_memo.join('\n');
             }
         }
     }

+ 4 - 0
app/public/js/global.js

@@ -39,6 +39,10 @@ function autoFlashHeight(){
     for (const sh of $('.sjs-sh')) {
         $(sh).height($(window).height()-cHeader-getObjHeight($('.sjs-bar', sh.parentNode))-getObjHeight($('.sjs-bottom', sh.parentNode))-92+55);
     }
+    for (const sh of $('.sjs-quality')) {
+        // 16为.sjs-quality-nav的margin
+        $(sh).height($(window).height()-$('.panel-title').height()-getObjHeight($('.sjs-quality-nav'))-16-getObjHeight($('.sjs-bar', sh.parentNode)));
+    }
     /*工程变更添加清单高度*/
     $(".sjs-biangeng-height").height($(window).height()/3.3);
     // 大于高度时隐藏nav文字

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

@@ -43,7 +43,7 @@ $(document).ready(() => {
                 if (!parent) return;
                 const cur = parent.children ? parent.children.find(x => { return x.name === node.name }) : null;
                 if (!cur) {
-                    xmjTree.addNode({ id: node.id, tender_id: node.tid, rela_id: parent.id, code: '', name: node.name, rela_type: 'pos', rela_name: node.name, pid: [node.id]}, parent);
+                    xmjTree.addNode({ id: node.id, tender_id: node.tid, rela_id: parent.id, code: '', code: parent.code + '-' + (parent.children.length + 1), name: node.name, rela_type: 'pos', rela_name: node.name, pid: [node.id]}, parent);
                 } else {
                     cur.pid.push(node.id);
                 }

+ 5 - 1
app/public/js/quality_rule.js

@@ -563,7 +563,7 @@ $(() => {
                     if (!parent) return;
                     const cur = parent.children ? parent.children.find(x => { return x.name === node.name }) : null;
                     if (!cur) {
-                        xmjTree.addNode({ id: node.id, tender_id: node.tid, rela_id: parent.id, code: '', name: node.name, rela_type: 'type', rela_name: node.name, pid: [node.id]}, parent);
+                        xmjTree.addNode({ id: node.id, tender_id: node.tid, rela_id: parent.id, code: parent.code + '-' + (parent.children.length + 1), name: node.name, rela_type: type, rela_name: node.name, pid: [node.id]}, parent);
                     } else {
                         cur.pid.push(node.id);
                     }
@@ -573,6 +573,10 @@ $(() => {
             for (const node of ledgerTree.children) {
                 recursiveLoad(node);
             }
+            for (const node of ledgerTree.nodes) {
+                if (!node.children || node.children.length === 0 || node.rela_type !== 'xmj' || node.children[0].rela_type !== 'pos') continue;
+
+            }
             xmjTree.sortTreeNode(false);
 
             const items = getSelectGroup();

+ 45 - 1
app/public/js/sp_setting_permission.js

@@ -248,5 +248,49 @@ $(document).ready(() => {
         postData(`/sp/${spid}/setting/user/permission/update`, { update: updateData }, function() {
             window.location.reload();
         })
-    })
+    });
+
+    $('#copy-user-batch').on('show.bs.modal', function() {
+        $('#cub-sp-all')[0].checked = false;
+        for (const c of $('[name=cub-sp-check]')) {
+            c.checked = false;
+        }
+        $('#cub-user-all')[0].checked = false;
+        for (const c of $('[name=cub-user-check]')) {
+            c.checked = false;
+        }
+    });
+    $('#cub-sp-all').click(function() {
+        for (const c of $('[name=cub-sp-check]')) {
+            c.checked = this.checked;
+        }
+    });
+    $('#cub-user-all').click(function() {
+        for (const c of $('[name=cub-user-check]')) {
+            c.checked = this.checked;
+        }
+    });
+    $('#copy-user-batch-ok').click(function() {
+        const spCheck = $('[name=cub-sp-check]:checked');
+        if (spCheck.length === 0) {
+            toastr.warning('未选择项目');
+            return;
+        }
+        const userCheck = $('[name=cub-user-check]:checked');
+        if (userCheck.length === 0) {
+            toastr.warning('未选择账号');
+            return;
+        }
+        const copyData = { spid: [], uid: [] };
+        for (const sp of spCheck) {
+            copyData.spid.push(sp.getAttribute('spid'));
+        }
+        for (const u of userCheck) {
+            copyData.uid.push(parseInt(u.getAttribute('uid')));
+        }
+        postData(`/sp/${spid}/setting/user/permission/update`, { copy: copyData }, function(result) {
+            toastr.success('设置成功');
+            $('#copy-user-batch').modal('hide');
+        });
+    });
 });

+ 13 - 8
app/public/js/stage_im.js

@@ -937,7 +937,9 @@ const stageIm = (function () {
                             }
                         }
                     });
-                    calc_memo.push(`其中合同计量:${contract_expr};变更计量:${qc_expr || '0'};变更不计价:${minus_qc_expr || '0'}`);
+                    qc_expr = qc_expr ? pp.qc_qty + '=' + qc_expr : (pp.qc_qty || 0);
+                    minus_qc_expr = minus_qc_expr ? pp.qc_minus_qty + '=' + minus_qc_expr : (pp.qc_minus_qty || 0);
+                    calc_memo.push(`其中合同计量:${contract_expr};变更计量:${qc_expr};变更不计价:${minus_qc_expr}`);
                     im.calc_memo =  calc_memo.join('\n');
                 }
             } else {
@@ -965,27 +967,30 @@ const stageIm = (function () {
                         im.changes.push(c);
                     }
                 }
-                importChanges.forEach(x => { if (x.lid === p.id && x.qty) im.changes.push(x); });
+                importChanges.forEach(x => { if (x.lid === p.id && x.rela_qty) im.changes.push(x); });
                 const calc_memo = [];
                 calc_memo.push('本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit);
                 const contract_expr = p.contract_expr ? p.contract_qty + '=' + p.contract_expr : (p.contract_qty || 0);
                 let qc_expr = '', minus_qc_expr = '';
                 im.changes.forEach(x => {
-                    if (x.no_value) {
+                    const prefix = x.rela_no_value === undefined ? '' : 'rela_';
+                    if (x[prefix + 'no_value']) {
                         if (minus_qc_expr) {
-                            minus_qc_expr = minus_qc_expr + (x.qty > 0 ? '+' + x.qty : x.qty);
+                            minus_qc_expr = minus_qc_expr + (x[prefix + 'qty'] > 0 ? '+' + x[prefix + 'qty'] : x[prefix + 'qty']);
                         } else {
-                            minus_qc_expr = minus_qc_expr + x.qty;
+                            minus_qc_expr = minus_qc_expr + x[prefix + 'qty'];
                         }
                     } else {
                         if (qc_expr) {
-                            qc_expr = qc_expr + (x.qty > 0 ? '+' + x.qty : x.qty);
+                            qc_expr = qc_expr + (x[prefix + 'qty'] > 0 ? '+' + x[prefix + 'qty'] : x[prefix + 'qty']);
                         } else {
-                            qc_expr = qc_expr + x.qty;
+                            qc_expr = qc_expr + x[prefix + 'qty'];
                         }
                     }
                 });
-                calc_memo.push(`其中合同计量:${contract_expr};变更计量:${qc_expr || '0'};变更不计价:${minus_qc_expr || '0'}`);
+                qc_expr = qc_expr ? p.qc_qty + '=' + qc_expr : (p.qc_qty || 0);
+                minus_qc_expr = minus_qc_expr ? p.qc_minus_qty + '=' + minus_qc_expr : (p.qc_minus_qty || 0);
+                calc_memo.push(`其中合同计量:${contract_expr};变更计量:${qc_expr};变更不计价:${minus_qc_expr}`);
                 im.calc_memo = calc_memo.join('\n');
             }
         }

+ 1 - 1
app/service/stage_bills.js

@@ -189,7 +189,7 @@ module.exports = app => {
                 end_contract_qty = this.ctx.helper.add(end_contract_qty, preStageBills.contract_qty);
             }
             const end_contract_tp = this.ctx.helper.mul(end_contract_qty, bills.unit_price, decimal.tp);
-            return activeQty === end_contract_qty ? this.ctx.helper.sub(end_contract_tp, preStageBills.contract_tp) : this.ctx.helper.mul(stageBills.contract_qty, bills.unit_price, info.decimal.tp);
+            return activeQty === end_contract_qty ? this.ctx.helper.sub(end_contract_tp, preStageBills.contract_tp) : this.ctx.helper.mul(stageBills.contract_qty, bills.unit_price, decimal.tp);
         }
         async calcContractTp(info, stage, bills, stageBills) {
             const correct = this.ctx.subProject.page_show.correctCalcContractTp;

+ 21 - 0
app/service/sub_proj_permission.js

@@ -341,11 +341,32 @@ module.exports = app => {
             return updateData;
         }
 
+        async _copyUserPermission(copyData) {
+            const copyPermission = await this.getAllDataByCondition({ where: { spid: this.ctx.subProject.id, uid: copyData.uid }});
+            if (copyPermission.length === 0) throw '选择的用户不存在';
+
+            const insertData = [];
+            for (const spid of copyData.spid) {
+                const exist = await this.getAllDataByCondition({ columns: ['uid'], where: { spid } });
+                copyPermission.forEach(cp => {
+                    if (exist.find(x => { return x.uid === cp.uid; })) return;
+
+                    const idata = { id: this.uuid.v4(), spid, pid: cp.pid, uid: cp.uid };
+                    for (const prop in cp) {
+                        if (prop.indexOf('_permission') > 1) idata[prop] = cp[prop];
+                    }
+                    insertData.push(idata);
+                });
+            }
+            await this.db.insert(this.tableName, insertData);
+        }
+
         async updatePermission(subProject, data) {
             const result = {};
             if (data.add) result.add = await this._addUser(subProject, data.add);
             if (data.del) result.del = await this._delUser(subProject, data.del);
             if (data.update) result.update = await this._updateUserPermission(data.update);
+            if (data.copy) await this._copyUserPermission(data.copy);
             return result;
         }