Explorar o código

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

Tony Kang hai 5 meses
pai
achega
be32451ddd

+ 3 - 2
app/const/spread.js

@@ -189,7 +189,7 @@ const BaseSetCol = {
         { key: 'unit', name: '单位', fixed: ['alias'], bills: 1, pos: 0 },
         { key: 'unit_price', name: '单价', fixed: ['alias'], bills: 1, pos: 0 },
         { key: 'deal_calc', name: '签约', fixed: [], bills: 1, pos: 0 },
-        { key: 'tz_calc', name: '台账', fixed: [], bills: 1, pos: 0},
+        { key: 'tz_calc', name: '台账', fixed: [], bills: 1, pos: 1},
         { key: 'real_qty', name: '现场实际数量', fixed: ['valid', 'alias'], bills: 0, pos: 1},
         { key: 'estimate_qty', name: '预计变更数量', fixed: ['valid', 'alias'], bills: 0, pos: 1},
         { key: 'cur_calc', name: '本期计量', fixed: ['alias'], bills: 1, pos: 1, },
@@ -285,7 +285,7 @@ const glSpreadTemplate = {
         { key: 'unit', valid: 1 },
         { key: 'unit_price', valid: 1 },
         { key: 'deal_calc', valid: 1, },
-        { key: 'tz_calc', valid: 1 },
+        { key: 'tz_calc', valid: 1, pos_valid: 0 },
         { key: 'real_qty', valid: 1 },
         { key: 'estimate_qty', valid: 1 },
         { key: 'cur_calc', valid: 1 },
@@ -752,6 +752,7 @@ const BaseSpreadColSetting = {
             position: [{title: '位置', colSpan: '1', rowSpan: '2', field: 'position', hAlign: 0, width: 60, formatter: '@'}],
             real_qty: [{title: '现场实际数量', colSpan: '1', rowSpan: '2', field: 'real_qty', hAlign: 2, width: 60, type: 'Number'}],
             estimate_qty: [{title: '预计变更数量', colSpan: '1', rowSpan: '2', field: 'estimate_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true}],
+            tz_calc: [{title: '台账数量', colSpan: '1', rowSpan: '2', field: 'sgfh_qty', hAlign: 2, width: 60, formatter: '@', type: 'Number', aliasFormat: '{%s}数量'}],
             cur_calc: [
                 {title: '本期计量|合同', colSpan: '4|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
                 {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 80, type: 'Number'},

+ 1 - 2
app/controller/pay_controller.js

@@ -31,13 +31,12 @@ module.exports = app => {
                 const phasePays = await this.ctx.service.phasePay.getAllPhasePay(ctx.tender.id, 'DESC');
                 const relaStage = [];
                 for (const p of phasePays) {
-                    // todo 加载当前审批人
                     if (p.audit_status !== audit.common.status.checked) await this.ctx.service.phasePay.loadUser(p);
                     relaStage.push(...p.rela_stage);
                 }
                 const stages = await this.ctx.service.stage.getAllDataByCondition({ where: { tid: ctx.tender.id }, orders: [['order', 'AEC']] });
                 const validStages = stages.filter(s => {
-                    return !relaStage.find(r => { return s.id === r.id; });
+                    return !relaStage.find(r => { return s.id === r.stage_id; });
                 });
                 this.ctx.service.phasePay.calculatePhasePay(phasePays);
                 const renderData = {

+ 33 - 9
app/public/js/project_spread.js

@@ -2,15 +2,15 @@ $(document).ready(() => {
     autoFlashHeight();
     const colSpread = SpreadJsObj.createNewSpread($('#spread-col')[0]);
     const colSheet = colSpread.getActiveSheet();
-    const validData = function(data, col) {
-        return data && data[col.field] ? '√' : '';
+    const canCheck = function(data, col) {
+        return data && data[col.relaField];
     };
     const colSpreadSetting = {
         cols: [
             { title: 'key', colSpan: '1', rowSpan: '2', field: 'key', hAlign: 0, width: 0, visible: false, formatter: '@', readOnly: true, },
             { title: '可显示列', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 200, formatter: '@', readOnly: true, },
-            { title: '项目节\n清单', colSpan: '1', rowSpan: '2', field: 'bills', hAlign: 1, width: 80, readOnly: true, getValue: validData },
-            { title: '计量单元', colSpan: '1', rowSpan: '2', field: 'pos', hAlign: 1, width: 80, readOnly: true, getValue: validData },
+            { title: '项目节\n清单', colSpan: '1', rowSpan: '2', field: 'bills_valid', hAlign: 1, width: 80, readOnly: true, cellType: 'signalCheckbox', show: canCheck, relaField: 'bills', },
+            { title: '计量单元', colSpan: '1', rowSpan: '2', field: 'pos_valid', hAlign: 1, width: 80, readOnly: true, cellType: 'signalCheckbox', show: canCheck, relaField: 'pos', },
             { title: '配置项|是否显示', colSpan: '2|1', rowSpan: '1|1', field: 'valid', hAlign: 1, width: 60, cellType: 'checkbox', readOnly: true },
             { title: '|别名', colSpan: '|1', rowSpan: '1|1', field: 'alias', hAlign: 0, width: 120, formatter: '@',  },
         ],
@@ -23,7 +23,10 @@ $(document).ready(() => {
         getColor: function (sheet, data, row, col, defaultColor) {
             if (!data) return defaultColor;
             switch (col.field) {
+                case 'bills_valid':
+                case 'pos_valid':
                 case 'valid':
+                    return data.fixed.indexOf('valid') >= 0 ? '#eeeeee' : defaultColor;
                 case 'alias':
                     return data.fixed.indexOf(col.field) >= 0 ? '#eeeeee' : defaultColor;
                 default:
@@ -37,7 +40,10 @@ $(document).ready(() => {
         const data = [];
         colSet.forEach(x => {
             const baseCol = BaseSetCol.find(b => { return x.key === b.key });
-            data.push({ ...x, ...baseCol });
+            const colData = { ...x, ...baseCol };
+            if (colData.bills && colData.bills_valid === undefined) colData.bills_valid = colData.valid;
+            if (colData.pos && colData.pos_valid === undefined) colData.pos_valid = colData.valid;
+            data.push(colData);
         });
         BaseSetCol.forEach(x => {
             const col = colSet.find(c => { return c.key === x.key });
@@ -165,10 +171,19 @@ $(document).ready(() => {
             if (!info.sheet.zh_setting) return;
 
             const col = info.sheet.zh_setting.cols[info.col];
-            if (col.field !== 'valid') return;
+            if (col.field.indexOf('valid') < 0) return;
 
             const node = SpreadJsObj.getSelectObject(info.sheet);
-            if (node.fixed.indexOf('valid') < 0) node.valid = !node.valid;
+            if (node.fixed.indexOf('valid') >= 0) return;
+            if (col.field === 'valid') {
+                node.valid = !node.valid;
+                node.bills_valid = node.valid && node.bills;
+                node.pos_valid = node.valid && node.pos;
+            } else {
+                node[col.field] = !node[col.field];
+                if (node.bills_valid || node.pos_valid) node.valid = 1;
+                if (!node.bills_valid && !node.pos_valid) node.valid = 0;
+            }
             SpreadJsObj.reLoadRowData(info.sheet, info.row);
         },
     };
@@ -184,7 +199,7 @@ $(document).ready(() => {
     });
 
     const getCurrentColSet = function() {
-        const cols = { key: 0, name: 1, valid: 4, alias: 5};
+        const cols = { key: 0, name: 1, bills_valid: 2, pos_valid: 3, valid: 4, alias: 5};
         const rowCount = colSheet.getRowCount();
         const result = [];
         for (let iRow = 0; iRow < rowCount; iRow++) {
@@ -192,14 +207,24 @@ $(document).ready(() => {
             const baseCol = BaseSetCol.find(x => { return x.key === keyName; });
             if (!baseCol) continue;
 
+            console.log(baseCol);
             const valid = colSheet.getText(iRow, cols.valid);
             const colSet = { key: keyName, valid: valid === '1' || valid === 'TRUE' ? 1 : 0 };
+            if (baseCol.bills) {
+                const bills_valid = colSheet.getText(iRow, cols.bills_valid);
+                colSet.bills_valid = bills_valid === '1' || bills_valid === 'TRUE' ? 1 : 0;
+            }
+            if (baseCol.pos) {
+                const pos_valid = colSheet.getText(iRow, cols.pos_valid);
+                colSet.pos_valid = pos_valid === '1' || pos_valid === 'TRUE' ? 1 : 0;
+            }
             if (baseCol.fixed.indexOf('alias') < 0) {
                 const alias = colSheet.getText(iRow, cols.alias);
                 if (alias) colSet.alias = alias;
             }
             result.push(colSet);
         }
+        console.log(result);
         return result;
     };
     let previewSpreadSetting, previewBillsSpread, previewPosSpread;
@@ -228,7 +253,6 @@ $(document).ready(() => {
     $('#spread-preview').click(() => {
         const data = { sType, colSet: getCurrentColSet() };
         postData('/setting/spread/preview', data, function(result) {
-            console.log(result);
             previewSpreadSetting = result;
             $('#preview-spread').modal('show');
         })

+ 1 - 1
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -2841,7 +2841,7 @@ const SpreadJsObj = {
                 if (col.show && Object.prototype.toString.apply(col.show) === "[object Function]") {
                     const sortData = SpreadJsObj.getSortData(sheet);
                     const data = sortData ? sortData[iRow] : null;
-                    return data ? col.show(data) : false;
+                    return data ? col.show(data, col) : false;
                 } else {
                     return col.show !== undefined && col.show !== null ? col.show : true ;
                 }

+ 2 - 0
app/service/project_spread.js

@@ -46,6 +46,8 @@ module.exports = app => {
             const spreadSetting = JSON.parse(JSON.stringify(emptyBase));
             for (const col of colSet) {
                 if (!col.valid) continue;
+                const typeValid = spreadType + '_valid';
+                if (col[typeValid] !== undefined && !col[typeValid]) continue;
                 const dc = BaseSetCol.find(x => { return x.key === col.key; });
                 if (!dc || !dc[spreadType]) continue;
                 const orgBaseCols = BaseSpreadColSetting[col.key];

+ 2 - 0
app/view/phase_pay/index.ejs

@@ -6,9 +6,11 @@
             <h2>
                 合同支付列表
             </h2>
+            <% if (ctx.session.sessionUser.accountId === ctx.tender.data.user_id && (phasePays.length === 0 || phasePays[0].audit_status === auditConst.status.checked)) { %>
             <div class="ml-auto">
                 <a href="#add-qi" data-toggle="modal" data-target="#add-qi" class="btn btn-primary btn-sm">开始新一期</a>
             </div>
+            <% } %>
         </div>
     </div>
     <div class="content-wrap">

+ 2 - 2
app/view/phase_pay/sub_menu_list.ejs

@@ -1,4 +1,4 @@
 <nav-menu title="返回" url="/tender/<%= ctx.tender.id %>/pay" tclass="text-primary" ml="1" icon="fa-chevron-left"></nav-menu>
-<nav-menu title="支付明细" url="/tender/<%= ctx.tender.id %>/pay/<%= ctx.phasePay.order + '/detail'%>" ml="3" active="<%= (ctx.url.indexOf('detail') >= 0 ? 1 : -1) %>"></nav-menu>
-<nav-menu title="输出报表" url="/tender/<%= ctx.tender.id %>/pay/<%= ctx.phasePay.order + '/report'%>" ml="3" active="<%= (ctx.url.indexOf('report') >= 0 ? 1 : -1) %>"></nav-menu>
+<nav-menu title="支付明细" url="/tender/<%= ctx.tender.id %>/pay/<%= ctx.phasePay.phase_order + '/detail'%>" ml="3" active="<%= (ctx.url.indexOf('detail') >= 0 ? 1 : -1) %>"></nav-menu>
+<nav-menu title="输出报表" url="/tender/<%= ctx.tender.id %>/pay/<%= ctx.phasePay.phase_order + '/report'%>" ml="3" active="<%= (ctx.url.indexOf('report') >= 0 ? 1 : -1) %>"></nav-menu>
 <% include ./audit_btn.ejs %>

+ 30 - 1
db_script/project_spread.js

@@ -137,4 +137,33 @@ const doComplete = async function(projectCode) {
     BaseUtil.closePool();
 };
 
-doComplete(process.argv[3]);
+// doComplete(process.argv[3]);
+// 更新所有工程量清单
+
+const updateProjectSpread = async function (project) {
+    const projectSpread = await querySql('Select * From zh_project_spread WHERE pid = ?', [project.id]);
+    for (const spread of projectSpread) {
+        if (!spread.gcl_stage_set) continue;
+
+        const gcl_stage_set = JSON.parse(spread.gcl_stage_set);
+        const tz_calc = gcl_stage_set.find(x => { return x.key === 'tz_calc'});
+        if (!tz_calc) continue;
+        tz_calc.pos_valid = 0;
+        await querySql(`UPDATE zh_project_spread SET gcl_stage_set = ? WHERE id = ?`, [JSON.stringify(gcl_stage_set), spread.id]);
+    }
+};
+const doComplete2 = async function (projectCode) {
+    try {
+        const whereSql = projectCode ? ` WHERE code = "${projectCode}"` : '';
+        const project = await querySql(`Select * From zh_project ${whereSql}`);
+        for (const p of project) {
+            console.log(`Update Project ${p.code}(${p.id}):`);
+            await updateProjectSpread(p);
+        }
+    } catch (err) {
+        console.log(err);
+    }
+    BaseUtil.closePool();
+};
+doComplete2(process.argv[3]);
+