|
@@ -80,7 +80,7 @@ $(document).ready(() => {
|
|
|
font: '12px 微软雅黑',
|
|
|
readOnly,
|
|
|
getColor: function (sheet, data, row, col, defaultColor) {
|
|
|
- if (!data || data.rela_lid) return defaultColor;
|
|
|
+ if (!data || (data.rela_lid && data.rela_cid)) return defaultColor;
|
|
|
|
|
|
const samePrice = sheet.zh_data.find(x => {
|
|
|
return x.b_code === data.b_code && x.name === data.name && x.unit === data.unit && x.org_price === data.org_price;
|
|
@@ -102,7 +102,10 @@ $(document).ready(() => {
|
|
|
headerFont: '12px 微软雅黑',
|
|
|
font: '12px 微软雅黑',
|
|
|
readOnly: true,
|
|
|
- getColor: function (sheet, data, row, col, defaultColor) {
|
|
|
+ // getColor: function (sheet, data, row, col, defaultColor) {
|
|
|
+ // return data && data.valid ? defaultColor : '#ddd';
|
|
|
+ // },
|
|
|
+ getForeColor: function (sheet, data, row, col, defaultColor) {
|
|
|
return data && data.valid ? defaultColor : '#ddd';
|
|
|
},
|
|
|
};
|
|
@@ -120,8 +123,8 @@ $(document).ready(() => {
|
|
|
headerFont: '12px 微软雅黑',
|
|
|
font: '12px 微软雅黑',
|
|
|
readOnly: true,
|
|
|
- getColor: function (sheet, data, row, col, defaultColor) {
|
|
|
- return data && data.rela ? defaultColor : '#ddd';
|
|
|
+ getForeColor: function (sheet, data, row, col, defaultColor) {
|
|
|
+ return data && data.valid ? defaultColor : '#ddd';
|
|
|
},
|
|
|
};
|
|
|
autoFlashHeight();
|
|
@@ -168,9 +171,6 @@ $(document).ready(() => {
|
|
|
this.data = datas;
|
|
|
this.tree.loadDatas(treeData);
|
|
|
this.resortData();
|
|
|
- for (const d of this.data) {
|
|
|
- this.analysisRelaLid(d);
|
|
|
- }
|
|
|
this.change = changeData;
|
|
|
if (this.data.length > 0) this.refreshRela(this.data[0]);
|
|
|
}
|
|
@@ -178,7 +178,6 @@ $(document).ready(() => {
|
|
|
if (updateData.add) {
|
|
|
for (const a of updateData.add) {
|
|
|
this.data.push(a);
|
|
|
- this.analysisRelaLid(a);
|
|
|
}
|
|
|
}
|
|
|
if (updateData.update) {
|
|
@@ -191,7 +190,6 @@ $(document).ready(() => {
|
|
|
} else {
|
|
|
this.data.push(d);
|
|
|
}
|
|
|
- this.analysisRelaLid(d);
|
|
|
}
|
|
|
}
|
|
|
if (updateData.del) {
|
|
@@ -235,6 +233,7 @@ $(document).ready(() => {
|
|
|
const choose = price.rela_cid.split(',');
|
|
|
for (const c of this.change) {
|
|
|
c.rela = choose.indexOf(c.cid + '') >= 0;
|
|
|
+ c.valid = c.rela;
|
|
|
}
|
|
|
} else {
|
|
|
const invalid = [];
|
|
@@ -243,7 +242,15 @@ $(document).ready(() => {
|
|
|
invalid.push(...cid);
|
|
|
}
|
|
|
for (const c of this.change) {
|
|
|
- c.rela = invalid.indexOf(c.cid + '') < 0;
|
|
|
+ c.rela = invalid.indexOf(c.cid + '') >= 0;
|
|
|
+ if (c.rela) {
|
|
|
+ c.valid = 0;
|
|
|
+ } else {
|
|
|
+ const exist = c.bills.find(x => {
|
|
|
+ return x.code === price.b_code && x.name === price.name && x.unit === price.unit && x.unit_price === price.org_price;
|
|
|
+ });
|
|
|
+ c.valid = exist;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -440,14 +447,21 @@ $(document).ready(() => {
|
|
|
const data = { update: { id: price.id, rela_lid } };
|
|
|
postData(window.location.pathname + '/update', data, function (result) {
|
|
|
revisePrice.loadUpdateData(result);
|
|
|
- SpreadJsObj.reLoadSheetData(priceSheet);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ updateRelaCid: function (price, rela_cid) {
|
|
|
+ const data = { update: { id: price.id, rela_cid } };
|
|
|
+ postData(window.location.pathname + '/update', data, function (result) {
|
|
|
+ revisePrice.loadUpdateData(result);
|
|
|
});
|
|
|
},
|
|
|
selectionChanged: function () {
|
|
|
const price = SpreadJsObj.getSelectObject(priceSheet);
|
|
|
revisePrice.refreshRela(price);
|
|
|
- SpreadJsObj.reloadRowBackColor(priceBwSheet, 0, priceBwSheet.getRowCount());
|
|
|
- SpreadJsObj.reloadRowBackColor(priceChangeSheet, 0, priceChangeSheet.getRowCount());
|
|
|
+ // SpreadJsObj.reloadRowBackColor(priceBwSheet, 0, priceBwSheet.getRowCount());
|
|
|
+ // SpreadJsObj.reloadRowBackColor(priceChangeSheet, 0, priceChangeSheet.getRowCount());
|
|
|
+ SpreadJsObj.reloadRowForeColor(priceBwSheet, 0, priceBwSheet.getRowCount());
|
|
|
+ SpreadJsObj.reloadRowForeColor(priceChangeSheet, 0, priceChangeSheet.getRowCount());
|
|
|
},
|
|
|
};
|
|
|
if (!readOnly) {
|
|
@@ -535,8 +549,7 @@ $(document).ready(() => {
|
|
|
callback: function (key, opt) {
|
|
|
const price = SpreadJsObj.getSelectObject(priceSheet);
|
|
|
const samePrice = revisePrice.getSamePrice(price);
|
|
|
- // todo
|
|
|
- // chooseRelaChange.show(price, samePrice);
|
|
|
+ chooseRelaChange.show(price, samePrice);
|
|
|
},
|
|
|
disabled: function (key, opt) {
|
|
|
const node = SpreadJsObj.getSelectObject(priceSheet);
|
|
@@ -611,6 +624,8 @@ $(document).ready(() => {
|
|
|
autoFlashHeight();
|
|
|
priceSpread.refresh();
|
|
|
ledgerGcl.spread.refresh();
|
|
|
+ priceBwSpread.refresh();
|
|
|
+ priceChangeSpread.refresh();
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -675,11 +690,11 @@ $(document).ready(() => {
|
|
|
this.sheet = this.spread.getActiveSheet();
|
|
|
const spreadSetting = {
|
|
|
cols: [
|
|
|
- {title: '选择', colSpan: '1', rowSpan: '1', field: 'check', hAlign: 1, width: 50, formatter: '@', readOnly: true, cellType: 'checkbox'},
|
|
|
- {title: '项目节编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 150, formatter: '@', readOnly: true, cellType: 'tree'},
|
|
|
- {title: '清单编号', colSpan: '1', rowSpan: '1', field: 'b_code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
|
|
|
- {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 230, formatter: '@', readOnly: true},
|
|
|
- {title: '单位', colSpan: '1', rowSpan: '1', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: true},
|
|
|
+ {title: '选择', colSpan: '1', rowSpan: '1', field: 'check', hAlign: 1, width: 50, formatter: '@', cellType: 'checkbox'},
|
|
|
+ {title: '项目节编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 150, formatter: '@', cellType: 'tree'},
|
|
|
+ {title: '清单编号', colSpan: '1', rowSpan: '1', field: 'b_code', hAlign: 0, width: 80, formatter: '@'},
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 230, formatter: '@'},
|
|
|
+ {title: '单位', colSpan: '1', rowSpan: '1', field: 'unit', hAlign: 1, width: 60, formatter: '@'},
|
|
|
],
|
|
|
headRows: 1,
|
|
|
emptyRows: 0,
|
|
@@ -687,6 +702,7 @@ $(document).ready(() => {
|
|
|
defaultRowHeight: 21,
|
|
|
headerFont: '12px 微软雅黑',
|
|
|
font: '12px 微软雅黑',
|
|
|
+ readOnly: true,
|
|
|
getColor: function (sheet, data, row, col, defaultColor) {
|
|
|
return data && data.invalid ? '#dddddd' : defaultColor;
|
|
|
}
|
|
@@ -807,12 +823,104 @@ $(document).ready(() => {
|
|
|
}
|
|
|
}
|
|
|
const chooseRelaBw = new ChooseRelaBw();
|
|
|
+ class ChooseRelaChange {
|
|
|
+ constructor (){
|
|
|
+ const self = this;
|
|
|
+ $('#choose-rela-change').on('shown.bs.modal', function() {
|
|
|
+ self.initSpread();
|
|
|
+ SpreadJsObj.reloadColData(self.sheet, 0, 1);
|
|
|
+ SpreadJsObj.reloadRowBackColor(self.sheet, 0, self.change.length);
|
|
|
+ });
|
|
|
+ $('#choose-rela-change-ok').click(function() {
|
|
|
+ const choose_cid = [];
|
|
|
+ self.change.forEach(x => {
|
|
|
+ if (x.check) choose_cid.push(x.cid);
|
|
|
+ });
|
|
|
+ priceOprObj.updateRelaCid(self.price, choose_cid.join(','));
|
|
|
+ $('#choose-rela-change').modal('hide');
|
|
|
+ });
|
|
|
+ }
|
|
|
+ initSpread() {
|
|
|
+ if (this.spread) return;
|
|
|
+
|
|
|
+ this.spread = SpreadJsObj.createNewSpread($('#rela-change-spread')[0]);
|
|
|
+ this.sheet = this.spread.getActiveSheet();
|
|
|
+ const spreadSetting = {
|
|
|
+ cols: [
|
|
|
+ {title: '选择', colSpan: '1', rowSpan: '1', field: 'check', hAlign: 1, width: 50, formatter: '@', cellType: 'checkbox'},
|
|
|
+ {title: '变更令', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 150, formatter: '@'},
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 230, formatter: '@'},
|
|
|
+ {title: '单位', colSpan: '1', rowSpan: '1', field: 'unit', hAlign: 1, width: 60, formatter: '@'},
|
|
|
+ ],
|
|
|
+ headRows: 1,
|
|
|
+ emptyRows: 0,
|
|
|
+ headRowHeight: [25],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ readOnly: true,
|
|
|
+ getColor: function (sheet, data, row, col, defaultColor) {
|
|
|
+ return data && data.invalid ? '#dddddd' : defaultColor;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ SpreadJsObj.initSheet(this.sheet, spreadSetting);
|
|
|
+ const self = this;
|
|
|
+ this.spread.bind(spreadNS.Events.ButtonClicked, function (e, info) {
|
|
|
+ const sheet = info.sheet, cellType = sheet.getCellType(info.row, info.col);
|
|
|
+ if (!sheet.zh_setting) return;
|
|
|
+
|
|
|
+ if (cellType instanceof spreadNS.CellTypes.CheckBox) {
|
|
|
+ if (sheet.isEditing()) sheet.endEdit(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ const col = sheet.zh_setting.cols[info.col];
|
|
|
+ if (col.field !== 'check') return;
|
|
|
+
|
|
|
+ const node = SpreadJsObj.getSelectObject(sheet);
|
|
|
+
|
|
|
+ if (!node.check) {
|
|
|
+ if (node.invalid) return;
|
|
|
+ node.check = true;
|
|
|
+ SpreadJsObj.reLoadRowsData(info.sheet, [info.row]);
|
|
|
+ } else {
|
|
|
+ node.check = false;
|
|
|
+ SpreadJsObj.reLoadRowsData(info.sheet, [info.row]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Data, this.change);
|
|
|
+ }
|
|
|
+ loadChange(data) {
|
|
|
+ this.change = data;
|
|
|
+ }
|
|
|
+ show(price, samePrice) {
|
|
|
+ this.price = price;
|
|
|
+ this.choose = price.rela_cid ? price.rela_cid.split(',') : [];
|
|
|
+ this.invalid = [];
|
|
|
+ for (const sp of samePrice) {
|
|
|
+ const cid = sp.rela_cid ? sp.rela_cid.split(',') : [];
|
|
|
+ this.invalid.push(...cid);
|
|
|
+ }
|
|
|
+ for (const c of this.change) {
|
|
|
+ c.check = this.choose.indexOf(c.cid + '') >= 0;
|
|
|
+ c.invalid = this.invalid.indexOf(c.cid + '') >= 0;
|
|
|
+ if (!c.check && c.invalid) {
|
|
|
+ const exist = c.bills.find(x => {
|
|
|
+ return x.code === price.b_code && x.name === price.name && x.unit === price.unit && x.unit_price === price.org_price;
|
|
|
+ });
|
|
|
+ c.invalid = !exist;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $('#choose-rela-change').modal('show');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const chooseRelaChange = new ChooseRelaChange();
|
|
|
|
|
|
postData('load', { filter: 'bills;pos;price;change' }, result => {
|
|
|
revisePrice.loadDatas(result.price, result.bills, result.change);
|
|
|
SpreadJsObj.loadSheetData(priceSheet, SpreadJsObj.DataType.Data, revisePrice.data);
|
|
|
ledgerGcl.loadData(result.bills, result.pos);
|
|
|
chooseRelaBw.loadTree(result.bills);
|
|
|
+ chooseRelaChange.loadChange(result.change);
|
|
|
SpreadJsObj.loadSheetData(priceBwSheet, SpreadJsObj.DataType.Tree, revisePrice.tree);
|
|
|
SpreadJsObj.loadSheetData(priceChangeSheet, SpreadJsObj.DataType.Data, revisePrice.change);
|
|
|
$("[content='#ledgerGcl']").click();
|
|
@@ -825,7 +933,7 @@ $(document).ready(() => {
|
|
|
if (!tab.hasClass('active')) {
|
|
|
$('a', '#side-menu').removeClass('active');
|
|
|
tab.addClass('active');
|
|
|
- $('.tab-content .tab-pane').removeClass('active');
|
|
|
+ $('#right-view .tab-pane').removeClass('active');
|
|
|
tabPanel.addClass('active');
|
|
|
showSideTools(tab.hasClass('active'));
|
|
|
ledgerGcl.spread.refresh();
|
|
@@ -836,5 +944,15 @@ $(document).ready(() => {
|
|
|
showSideTools(tab.hasClass('active'));
|
|
|
}
|
|
|
priceSpread.refresh();
|
|
|
+ priceBwSpread.refresh();
|
|
|
+ priceChangeSpread.refresh();
|
|
|
+ });
|
|
|
+ $('a', '.bcontent-wrap').click(function() {
|
|
|
+ $('[name=priceRela]').removeClass('active');
|
|
|
+ $(this).addClass('active');
|
|
|
+ $('#priceRelaTab').children().removeClass('active');
|
|
|
+ $(this.getAttribute('href')).addClass('active');
|
|
|
+ priceBwSpread.refresh();
|
|
|
+ priceChangeSpread.refresh();
|
|
|
});
|
|
|
});
|