|
@@ -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');
|
|
|
})
|