Explorar o código

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

Tony Kang %!s(int64=3) %!d(string=hai) anos
pai
achega
68db4b10f3

+ 8 - 8
app/lib/sum_load.js

@@ -330,6 +330,7 @@ class gatherStageGclTree extends loadGclBaseTree {
             const relaPos = pos.filter(x => {return x.lid === d.id});
             const baseNode = {
                 id: d.id,
+                is_import: d.is_import,
                 ledger_id: d.ledger_id,
                 ledger_pid: d.ledger_pid,
                 level: d.level,
@@ -339,10 +340,10 @@ class gatherStageGclTree extends loadGclBaseTree {
                 name: d.name,
                 unit: d.unit,
                 unit_price: d.unit_price,
-                org_contract_qty: this.cover ? d.contract_qty || 0 : 0,
-                org_contract_tp: this.cover ? d.contract_tp || 0 : 0,
-                org_qc_qty: d.is_import ? 0 : d.qc_qty || 0,
-                org_qc_tp: d.is_import ? 0 : d.qc_tp || 0,
+                org_contract_qty: d.contract_qty || 0,
+                org_contract_tp: d.contract_tp || 0,
+                org_qc_qty: d.qc_qty || 0,
+                org_qc_tp: d.qc_tp || 0,
                 org_order: d.order,
                 contract_qty: 0,
                 contract_tp: 0,
@@ -386,14 +387,13 @@ class gatherStageGclTree extends loadGclBaseTree {
     getUpdateData() {
         const result = { update: [], errors: [], qc_detail: [] };
         for (const bn of this.baseNodes) {
+            if (!this.cover && !bn.is_import && !bn.contract_qty && !bn.qc_qty && !bn.contract_tp) continue;
+
             if (!bn.is_import && bn.org_qc_qty !== 0 && bn.qc_qty !== 0) {
                 result.errors.push({ b_code: bn.b_code, name: bn.name, unit: bn.unit, qc_qty: bn.qc_qty, ledger_id: bn.ledger_id, type: 'qc-conflict'});
-                if (bn.contract_qty !== bn.org_contract_qty || bn.contract_tp !== bn.org_contract_tp) {
-                    result.update.push({ lid: bn.id, contract_qty: bn.contract_qty, contract_tp: bn.contract_tp, qc_qty: bn.org_qc_qty, qc_tp: bn.org_qc_tp });
-                }
                 continue;
             }
-            if (bn.contract_qty !== bn.org_contract_qty || bn.contract_tp !== bn.org_contract_tp || bn.qc_qty !== bn.org_qc_qty) {
+            if (bn.is_import || this.cover || bn.contract_qty !== bn.org_contract_qty || bn.contract_tp !== bn.org_contract_tp || bn.qc_qty !== bn.org_qc_qty) {
                 let data = { lid: bn.id, contract_qty: bn.contract_qty, contract_tp: bn.contract_tp };
                 if (!bn.is_import && bn.org_qc_qty) {
                     data.qc_qty = bn.org_qc_qty;

+ 15 - 1
app/public/js/change_plan_information.js

@@ -452,11 +452,13 @@ $(document).ready(() => {
                 const sortData = info.sheet.zh_data || [];
                 const range = info.cellRange;
                 const data = [];
+                let haveNew = false;
                 for (let iRow = 0; iRow < range.rowCount; iRow++) {
                     let bPaste = true;
                     const curRow = range.row + iRow;
                     // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
                     const cLData = curRow >= sortData.length ? {unit: ''} : {id: sortData[curRow].id};
+                    haveNew = curRow >= sortData.length ? curRow : false;
                     const hintRow = range.rowCount > 1 ? curRow : '';
                     let sameCol = 0;
                     for (let iCol = 0; iCol < range.colCount; iCol++) {
@@ -524,8 +526,16 @@ $(document).ready(() => {
                 // 更新至服务器
                 postData(preUrl + '/list/save', { type:'paste', updateData: data }, function (result) {
                     changeList = result;
+                    if (haveNew) {
+                        SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
+                    }
                     SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
                     changeSpreadObj.makeSjsFooter();
+                    if (haveNew) {
+                        changeSpreadSheet.setSelection(haveNew, 1, 1, 1);
+                        changeSpreadSheet.getParent().focus();
+                        changeSpreadSheet.showRow(haveNew, spreadNS.VerticalPosition.center);
+                    }
                 }, function () {
                     SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
                     return;
@@ -842,7 +852,11 @@ $(document).ready(() => {
                     }
                     // cLData[colSetting.field] = validText;
                     sortData[curRow][colSetting.field] = validText;
-                    cLData.spamount = validText;
+                    if (colSetting.field === 'ex_memo1' || colSetting.field === 'ex_memo2') {
+                        cLData[colSetting.field] = validText;
+                    } else {
+                        cLData.spamount = validText;
+                    }
                 }
                 if (bPaste) {
                     data.push(cLData);

+ 8 - 8
app/public/js/material_list.js

@@ -427,7 +427,7 @@ $(document).ready(() => {
         const index = gclGatherData.indexOf(select);
         const leafXmjSheet = leafXmjSpread.getActiveSheet();
         const leafXmjSelect = SpreadJsObj.getSelectObject(leafXmjSheet);
-        const gcl = gclGatherData[index].leafXmjs;
+        const gcl = gclGatherData[index].leafXmjs.filter(item => item.gather_qty !== null && item.gather_qty !== undefined);
         // const leafXmjIndex = gcl.indexOf(leafXmjSelect);
         // const xmj = gcl[leafXmjIndex];
         // const data = {
@@ -467,10 +467,10 @@ $(document).ready(() => {
             $('#addgl').modal('hide');
         });
         // postData(window.location.pathname + '/save', {type: 'add', postData: data}, function (result) {
-            // // 添加到materialList里
-            // materialListData = result;
-            // loadMaterialData(index, leafXmjIndex);
-            // $('#addgl').modal('hide');
+        //     // 添加到materialList里
+        //     materialListData = result;
+        //     loadMaterialData(index, leafXmjIndex);
+        //     $('#addgl').modal('hide');
         // });
         $('#materialBills').find('input:disabled').prop('checked', true);
     });
@@ -576,7 +576,7 @@ $(document).ready(() => {
                 const sheet = ledgerSpread.getActiveSheet();
                 const select = SpreadJsObj.getSelectObject(sheet);
                 const index = gclGatherData.indexOf(select);
-                const gcl = gclGatherData[index].leafXmjs;
+                const gcl = gclGatherData[index].leafXmjs.filter(item => item.gather_qty !== null && item.gather_qty !== undefined);
                 const datas = [];
                 for (const xmj of gcl) {
                     const data = {
@@ -674,7 +674,7 @@ $(document).ready(() => {
                     const ledgerSheet = ledgerSpread.getActiveSheet();
                     const ledgerSelect = SpreadJsObj.getSelectObject(ledgerSheet);
                     const index = gclGatherData.indexOf(ledgerSelect);
-                    const gcl = gclGatherData[index].leafXmjs;
+                    const gcl = gclGatherData[index].leafXmjs.filter(item => item.gather_qty !== null && item.gather_qty !== undefined);
                     const datas = [];
                     for (const xmj of gcl) {
                         const data = {
@@ -799,7 +799,7 @@ $(document).ready(() => {
                 const ledgerSheet = ledgerSpread.getActiveSheet();
                 const ledgerSelect = SpreadJsObj.getSelectObject(ledgerSheet);
                 const index = gclGatherData.indexOf(ledgerSelect);
-                const gcl = gclGatherData[index].leafXmjs;
+                const gcl = gclGatherData[index].leafXmjs.filter(item => item.gather_qty !== null && item.gather_qty !== undefined);
                 const datas = [];
                 for (const xmj of gcl) {
                     const data2 = {

+ 6 - 2
app/public/js/setting.js

@@ -452,7 +452,7 @@ function checkUserForm(status) {
             if ($('#add-user input[name="name"]').val() == '') {
                 throw '姓名不能为空';
             }
-            if (_.findIndex(unitList, $('#add-user select[name="company"]').val()) === -1) {
+            if (_.findIndex(unitList, { name: $('#add-user select[name="company"]').val() }) === -1) {
                 throw '请选择单位名称';
             }
             if ($('#add-user input[name="role"]').val() == '') {
@@ -473,7 +473,7 @@ function checkUserForm(status) {
             if ($('#edit-user input[name="name"]').val() == '') {
                 throw '姓名不能为空';
             }
-            if (_.findIndex(unitList, $('#edit-user select[name="company"]').val()) === -1) {
+            if (_.findIndex(unitList, { name: $('#edit-user select[name="company"]').val() }) === -1) {
                 throw '请选择单位名称';
             }
             if ($('#edit-user input[name="role"]').val() == '') {
@@ -502,6 +502,10 @@ function checkUnitForm() {
         if ($('#add-company select[name="type"]').val() == 0) {
             throw '请选择类型';
         }
+        // 检测同名
+        if (_.findIndex(unitList, { name: $('#add-company input[name="name"]').val() }) !== -1) {
+            throw '已存在对应的单位名称';
+        }
     } catch (err) {
         toastr.error(err);
         return false;

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

@@ -3832,7 +3832,7 @@ $(document).ready(() => {
                 b.pos = _.filter(change.detail.curUsedBills, { rela_cbid: b.id });
                 b.cur_qty = 0;
                 for (const p of b.pos) {
-                    b.qty = b.rela_qty;
+                    p.qty = p.rela_qty;
                     const node = stageTree.datas.find(x => { return x.id === p.lid; });
                     p.ledger_id = node.ledger_id;
                     p.f_qty = node.quantity;

+ 40 - 1
app/service/material_list.js

@@ -334,6 +334,7 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 const list = [];
+                const listGcl = [];
                 // const delList = [];
                 // const mb_idList = [];
                 for (const xmj of datas.xmjs) {
@@ -363,15 +364,30 @@ module.exports = app => {
                             is_join: xmj.is_join,
                         };
                         list.push(newLists);
+                        if (this._.findIndex(listGcl, { gcl_id: xmj.gcl_id }) === -1) {
+                            const newListGcl = {
+                                tid: this.ctx.tender.id,
+                                order: this.ctx.material.order,
+                                mid: this.ctx.material.id,
+                                mb_id: mb,
+                                gcl_id: xmj.gcl_id,
+                                quantity: 0,
+                                expr: '',
+                            };
+                            listGcl.push(newListGcl);
+                        }
                     }
                 }
+                // 维护list_gcl表
+
 
                 // 删除工料清单关联
                 // if (delList.length > 0) await transaction.delete(this.tableName, { id: delList });
                 // 新增工料清单关联
                 if (list.length > 0) {
                     const result = await transaction.insert(this.tableName, list);
-                    if (result.affectedRows === 0) {
+                    const result2 = await transaction.insert(this.ctx.service.materialListGcl.tableName, listGcl);
+                    if (result.affectedRows === 0 || result2.affectedRows === 0) {
                         throw '新增工料数据失败';
                     }
                 }
@@ -405,8 +421,13 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 // 判断是否可删
+                const listGcl = [];
                 for (const xmj of datas.xmjs) {
                     await transaction.delete(this.tableName, { tid: this.ctx.tender.id, mid: this.ctx.material.id, mb_id: datas.mb_id, gcl_id: xmj.gcl_id, xmj_id: xmj.xmj_id, mx_id: xmj.mx_id });
+                    if (this._.indexOf(listGcl, xmj.gcl_id) === -1) {
+                        await transaction.delete(this.service.materialListGcl.tableName, { tid: this.ctx.tender.id, mid: this.ctx.material.id, mb_id: datas.mb_id, gcl_id: xmj.gcl_id });
+                        listGcl.push(xmj.gcl_id);
+                    }
                 }
                 // await transaction.delete(this.tableName, { id });
                 await this.calcQuantityByML(transaction, datas.mb_id);
@@ -437,6 +458,8 @@ module.exports = app => {
             try {
                 const mb_id = datas.mb_id;
                 const updateDatas = [];
+                const updateListGcl = [];
+                const listGcl = [];
                 for (const xmj of datas.xmjs) {
                     const udata = {
                         row: {
@@ -453,8 +476,24 @@ module.exports = app => {
                         },
                     };
                     updateDatas.push(udata);
+                    if (this._.indexOf(listGcl, xmj.gcl_id) === -1) {
+                        listGcl.push(xmj.gcl_id);
+                        updateListGcl.push({
+                            row: {
+                                expr: datas.expr,
+                                quantity: datas.quantity,
+                            },
+                            where: {
+                                tid: this.ctx.tender.id,
+                                mid: this.ctx.material.id,
+                                mb_id,
+                                gcl_id: xmj.gcl_id,
+                            },
+                        });
+                    }
                 }
                 if (updateDatas.length > 0) await transaction.updateRows(this.tableName, updateDatas);
+                if (updateListGcl.length > 0) await transaction.updateRows(this.service.materialListGcl.tableName, updateListGcl);
                 await this.calcQuantityByML(transaction, mb_id);
                 await transaction.commit();
                 return await this.getMaterialData(this.ctx.tender.id, this.ctx.material.id);

+ 6 - 0
app/service/report.js

@@ -269,6 +269,12 @@ module.exports = app => {
                     case 'mem_union_data':
                         rst[filter] = [];
                         break;
+                    case 'mem_import_change':
+                        rst[filter] = await service.reportMemory.getImportChangeData(params.tender_id, params.stage_id, memFieldKeys[filter]);
+                        break;
+                    case 'mem_import_change_bills':
+                        rst[filter] = await service.reportMemory.getImportChangeBillsData(params.tender_id, params.stage_id, memFieldKeys[filter]);
+                        break;
                     case 'mem_change':
                         rst[filter] = await service.reportMemory.getChangeData(params.tender_id, params.stage_id, memFieldKeys[filter]);
                         break;

+ 62 - 1
app/service/report_memory.js

@@ -840,6 +840,68 @@ module.exports = app => {
             }
         }
 
+        async _generateImportChange(sid) {
+            if (this.importChange !== null) return;
+            const self = this;
+            try {
+                const ctx = this.ctx;
+                const change = await this.ctx.service.stageImportChange.getImportChange(sid);
+                for (const c of change) {
+                    const types = ctx.helper._.map(c.type.split(','), function (t) {
+                        return self._getChangeConstName(changeConst.type, ctx.helper._.toInteger(t));
+                    });
+                    c.type = types.join(';');
+                    c.class = this._getChangeConstName(changeConst.class, c.class);
+                    c.quality = this._getChangeConstName(changeConst.quality, c.quality);
+                    c.charge = this._getChangeConstName(changeConst.charge, c.charge);
+                }
+
+                change.sort(function (a, b) {
+                    return a.code.localeCompare(b.code);
+                });
+                const changeBills = [];
+                for (const c of change) {
+                    const bills = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid: c.cid } });
+                    for (const b of bills) {
+                        b.o_qty = b.oamount;
+                        b.c_qty = b.camount;
+                        b.s_qty = b.samount ? parseFloat(b.samount) : 0;
+                        b.sp_qty = b.spamount;
+                    }
+
+                    bills.sort(function (a, b) {
+                        return ctx.helper.compareCode(a.code, b.code);
+                    });
+                    changeBills.push(...bills);
+                }
+                this.importChange = {change: change, bills: changeBills};
+            } catch(err) {
+                this.ctx.helper.log(err);
+                throw err;
+                this.importChange = {change: [], bills: []};
+            }
+        }
+
+        async getImportChangeData(tid, sid, fields) {
+            try {
+                await this._generateImportChange(sid);
+                return this.importChange.change;
+            } catch (err) {
+                return [];
+            }
+        }
+
+        async getImportChangeBillsData(tid, sid, fields) {
+            try {
+                await this.ctx.service.tender.checkTender(tid);
+
+                await this._generateImportChange(tid);
+                return this.importChange.bills;
+            } catch (err) {
+                return [];
+            }
+        }
+
         async _generateChangeApply(tid) {
             if (!!this.changeApplyData) return;
             const helper = this.ctx.helper;
@@ -1382,7 +1444,6 @@ module.exports = app => {
                 c.used_ratio = c.used_pt;
                 c.is_import = 0;
             }
-            const importChange = await this.ctx.service.stageImportChange.get
             return this.changeInfo;
         }
 

+ 1 - 1
app/view/material/list.ejs

@@ -55,7 +55,7 @@
                             </li>
                             <li class="ml-auto">
                             <% if (!material.readOnly || material.status === auditConst.status.checked) { %>
-                            <button class="btn btn-sm btn-primary" id="user_all_material">应用调差工料至其他清单明细</button>
+                            <!--<button class="btn btn-sm btn-primary" id="user_all_material">应用调差工料至其他清单明细</button>-->
                             <% } %>
                             </li>
                         </ul>

+ 1 - 1
app/view/setting/user_modal.ejs

@@ -40,7 +40,7 @@
                 <div class="form-group">
                     <label>单位名称<b class="text-danger">*</b></label>
                     <!--<input class="form-control form-control-sm" name="company" value="" type="text">-->
-                    <input value="" name="account_group" type="hidden">
+                    <input value="7" name="account_group" type="hidden">
                     <select class="form-control form-control-sm" name="company">
                         <option>请选择</option>
                         <% for (const u of unitList) { %>

+ 1 - 1
app/view/setting/user_permission_modal.ejs

@@ -39,7 +39,7 @@
                 </div>
                 <div class="form-group">
                     <label>单位名称<b class="text-danger">*</b></label>
-                    <input value="" name="account_group" type="hidden">
+                    <input value="7" name="account_group" type="hidden">
                     <select class="form-control form-control-sm" name="company">
                         <option>请选择</option>
                         <% for (const u of unitList) { %>

+ 1 - 1
app/view/setting/user_unit_modal.ejs

@@ -39,7 +39,7 @@
                 </div>
                 <div class="form-group">
                     <label>单位名称<b class="text-danger">*</b></label>
-                    <input value="" name="account_group" type="hidden">
+                    <input value="7" name="account_group" type="hidden">
                     <select class="form-control form-control-sm" name="company">
                         <option value="0">请选择</option>
                         <% for (const u of unitList) { %>

+ 63 - 1
builder_report_index_define.js

@@ -327,6 +327,64 @@ const change_audit = {
     ],
 };
 
+const import_change = {
+    name: '变更令(mem_import_change)',
+    remark: '',
+    id: 83,
+    key: 'mem_import_change',
+    prefix: '变更令',
+    cols: [
+        { name: '变更令id', field: 'cid', type: dataType.str },
+        { name: '变更令号', field: 'code', type: dataType.str },
+        { name: '批复文号', field: 'w_code', type: dataType.str },
+        { name: '批复编号', field: 'p_code', type: dataType.str },
+        { name: '变更名称', field: 'name', type: dataType.str },
+        { name: '桩号', field: 'peg', type: dataType.str },
+        { name: '原设计图名称', field: 'org_name', type: dataType.str },
+        { name: '原图号', field: 'org_code', type: dataType.str },
+        { name: '变更设计图名称', field: 'new_name', type: dataType.str },
+        { name: '变更图号', field: 'new_code', type: dataType.str },
+        { name: '工程变更理由及内容', field: 'content', type: dataType.str },
+        { name: '工程变更合同依据', field: 'basis', type: dataType.str },
+        { name: '变更工程量数量计算式', field: 'expr', type: dataType.str },
+        { name: '备注', field: 'memo', type: dataType.str },
+        { name: '变更类型', field: 'type', type: dataType.str },
+        { name: '变更类别', field: 'class', type: dataType.int },
+        { name: '变更性质', field: 'quality', type: dataType.int },
+        { name: '变更提出单位', field: 'company', type: dataType.str },
+        { name: '费用承担方', field: 'charge', type: dataType.int },
+        { name: '金额', field: 'total_price', type: dataType.currency },
+        { name: '变更状态发生时间(时间戳)', field: 'cin_time', type: dataType.str },
+        { name: '完成审批时间(时间戳)', field: 'sin_time', type: dataType.str },
+    ],
+};
+const import_change_bills = {
+    name: '变更清单(mem_import_change_bills)',
+    remark: '',
+    id: 84,
+    key: 'mem_import_change_bills',
+    prefix: '变更清单',
+    cols: [
+        { name: '变更令id', field: 'cid', type: dataType.str },
+        { name: '签约清单id或台账id', field: 'lid', type: dataType.str },
+        { name: '清单编号', field: 'code', type: dataType.str },
+        { name: '名称', field: 'name', type: dataType.str },
+        { name: '单位', field: 'unit', type: dataType.str },
+        { name: '单价', field: 'unit_price', type: dataType.currency },
+        { name: '原-数量', field: 'o_qty', type: dataType.currency },
+        { name: '变更-数量', field: 'c_qty', type: dataType.currency },
+        { name: '审批变更后-数量', field: 's_qty', type: dataType.currency },
+        { name: '部位明细', field: 'bwmx', type: dataType.str },
+        { name: '变更详情', field: 'detail', type: dataType.str },
+        { name: '项目节编号', field: 'xmj_code', type: dataType.str },
+        { name: '细目', field: 'xmj_jldy', type: dataType.str },
+        { name: '单位工程', field: 'xmj_dwgc', type: dataType.str },
+        { name: '分部工程', field: 'xmj_fbgc', type: dataType.str },
+        { name: '分项工程', field: 'xmj_fxgc', type: dataType.str },
+        { name: '审批流程中读取数量', field: 'sp_qty', type: dataType.currency },
+    ],
+};
+
 const change_project = {
     name: '变更立项(mem_change_project)',
     remark: '',
@@ -483,6 +541,7 @@ const change_plan = {
         { name: '方案描述', field: 'memo', type: dataType.str },
         { name: '金额', field: 'total_price', type: dataType.currency },
         { name: '小数位数设置JSON', field: 'decimal', type: dataType.int },
+        { name: '计算式', field: 'expr', type: dataType.str },
     ],
 };
 const change_plan_audit = {
@@ -545,6 +604,9 @@ const change_plan_bills = {
         { name: '金额_8', field: 'tp_8', type: dataType.currency },
         { name: '数量_9', field: 'qty_9', type: dataType.currency },
         { name: '金额_9', field: 'tp_9', type: dataType.currency },
+        { name: '新增单价', field: 'new_up', type: dataType.int},
+        { name: 'ex_memo1', field: 'ex_memo1', type: dataType.str},
+        { name: 'ex_memo2', field: 'ex_memo2', type: dataType.str},
     ]
 };
 
@@ -2499,7 +2561,7 @@ const defines = [
     month_progress,
     stage_bills, stage_bills_compare,
     stage_jgcl, stage_bonus, stage_other, stage_safe_prod, stage_temp_land,
-    change, change_bills, change_audit,
+    change, change_bills, change_audit, import_change, import_change_bills,
     change_apply, change_apply_audit, change_apply_bills,
     change_plan, change_plan_audit, change_plan_bills,
     change_project, change_project_audit,