Prechádzať zdrojové kódy

列显示,项目节清单与计量单元单独控制显示

MaiXinRong 5 mesiacov pred
rodič
commit
b72c2704c7

+ 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'},

+ 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];