|
@@ -79,25 +79,100 @@ $(document).ready(() => {
|
|
headerFont: '12px 微软雅黑',
|
|
headerFont: '12px 微软雅黑',
|
|
font: '12px 微软雅黑',
|
|
font: '12px 微软雅黑',
|
|
readOnly,
|
|
readOnly,
|
|
|
|
+ getColor: function (sheet, data, row, col, 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;
|
|
|
|
+ });
|
|
|
|
+ return samePrice ? '#f5deb3' : defaultColor;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ const priceBwSpreadSetting = {
|
|
|
|
+ cols: [
|
|
|
|
+ {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,
|
|
|
|
+ headRowHeight: [25],
|
|
|
|
+ defaultRowHeight: 21,
|
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
|
+ font: '12px 微软雅黑',
|
|
|
|
+ readOnly: true,
|
|
|
|
+ // 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';
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+ sjsSettingObj.setFxTreeStyle(priceBwSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
|
|
|
|
+ const priceChangeSpreadSetting = {
|
|
|
|
+ cols: [
|
|
|
|
+ {title: '变更令', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 80, formatter: '@'},
|
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 230, formatter: '@'},
|
|
|
|
+ {title: '批复文号', colSpan: '1', rowSpan: '1', field: 'w_code', hAlign: 1, width: 80, formatter: '@'},
|
|
|
|
+ ],
|
|
|
|
+ headRows: 1,
|
|
|
|
+ emptyRows: 0,
|
|
|
|
+ headRowHeight: [25],
|
|
|
|
+ defaultRowHeight: 21,
|
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
|
+ font: '12px 微软雅黑',
|
|
|
|
+ readOnly: true,
|
|
|
|
+ getForeColor: function (sheet, data, row, col, defaultColor) {
|
|
|
|
+ return data && data.valid ? defaultColor : '#ddd';
|
|
|
|
+ },
|
|
};
|
|
};
|
|
autoFlashHeight();
|
|
autoFlashHeight();
|
|
|
|
+ const bcontent = $(".bcontent-wrap").length > 0 ? $(".bcontent-wrap").height() : 0;
|
|
|
|
+ $(".sp-wrap").height(bcontent-30);
|
|
const priceSpread = SpreadJsObj.createNewSpread($('#price-spread')[0]);
|
|
const priceSpread = SpreadJsObj.createNewSpread($('#price-spread')[0]);
|
|
const priceSheet = priceSpread.getActiveSheet();
|
|
const priceSheet = priceSpread.getActiveSheet();
|
|
|
|
+ const priceBwSpread = SpreadJsObj.createNewSpread($('#price-bw-spread')[0]);
|
|
|
|
+ const priceBwSheet = priceBwSpread.getActiveSheet();
|
|
|
|
+ const priceChangeSpread = SpreadJsObj.createNewSpread($('#price-change-spread')[0]);
|
|
|
|
+ const priceChangeSheet = priceChangeSpread.getActiveSheet();
|
|
|
|
|
|
SpreadJsObj.initSheet(priceSheet, priceSpreadSetting);
|
|
SpreadJsObj.initSheet(priceSheet, priceSpreadSetting);
|
|
|
|
+ SpreadJsObj.initSheet(priceBwSheet, priceBwSpreadSetting);
|
|
|
|
+ SpreadJsObj.initSheet(priceChangeSheet, priceChangeSpreadSetting);
|
|
|
|
|
|
class RevisePrice {
|
|
class RevisePrice {
|
|
constructor () {
|
|
constructor () {
|
|
this.data = [];
|
|
this.data = [];
|
|
|
|
+ this.tree = createNewPathTree('filter', {
|
|
|
|
+ id: 'ledger_id',
|
|
|
|
+ pid: 'ledger_pid',
|
|
|
|
+ order: 'order',
|
|
|
|
+ level: 'level',
|
|
|
|
+ rootId: -1,
|
|
|
|
+ fullPath: 'full_path',
|
|
|
|
+ keys: ['id', 'tender_id', 'ledger_id'],
|
|
|
|
+ });
|
|
}
|
|
}
|
|
resortData() {
|
|
resortData() {
|
|
this.data.sort(function (a, b) {
|
|
this.data.sort(function (a, b) {
|
|
return a.order - b.order;
|
|
return a.order - b.order;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- loadDatas(datas) {
|
|
|
|
|
|
+ analysisRelaLid(price) {
|
|
|
|
+ const tree = this.tree;
|
|
|
|
+ const rela_lid = price.rela_lid ? price.rela_lid.split(',') : [];
|
|
|
|
+ price.rela_hint = rela_lid.map(x => {
|
|
|
|
+ const node = tree.getItems(parseInt(x));
|
|
|
|
+ return node ? node.code || node.name : '';
|
|
|
|
+ }).join(',');
|
|
|
|
+ }
|
|
|
|
+ loadDatas(datas, treeData, changeData) {
|
|
this.data = datas;
|
|
this.data = datas;
|
|
|
|
+ this.tree.loadDatas(treeData);
|
|
this.resortData();
|
|
this.resortData();
|
|
|
|
+ this.change = changeData;
|
|
|
|
+ if (this.data.length > 0) this.refreshRela(this.data[0]);
|
|
}
|
|
}
|
|
loadUpdateData(updateData) {
|
|
loadUpdateData(updateData) {
|
|
if (updateData.add) {
|
|
if (updateData.add) {
|
|
@@ -124,12 +199,72 @@ $(document).ready(() => {
|
|
}
|
|
}
|
|
this.resortData();
|
|
this.resortData();
|
|
}
|
|
}
|
|
|
|
+ getSamePrice(price) {
|
|
|
|
+ return this.data.filter(x => {
|
|
|
|
+ if (x.id === price.id) return false;
|
|
|
|
+ return x.b_code === price.b_code && x.name === price.name && x.unit === price.unit && x.org_price === price.org_price;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ refreshTreeRela(price, samePrice) {
|
|
|
|
+ if (price.rela_lid) {
|
|
|
|
+ const choose = price.rela_lid.split(',');
|
|
|
|
+ for (const node of this.tree.nodes) {
|
|
|
|
+ node.rela = choose.indexOf(node.ledger_id + '') >= 0;
|
|
|
|
+ }
|
|
|
|
+ for (const node of this.tree.nodes) {
|
|
|
|
+ node.valid = node.rela || this.tree.checkParent(node, 'rela') || this.tree.checkChildren(node, 'rela');
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ const invalid = [];
|
|
|
|
+ for (const sp of samePrice) {
|
|
|
|
+ const lid = sp.rela_lid ? sp.rela_lid.split(',') : [];
|
|
|
|
+ invalid.push(...lid);
|
|
|
|
+ }
|
|
|
|
+ for (const node of this.tree.nodes) {
|
|
|
|
+ node.rela = invalid.indexOf(node.ledger_id + '') >= 0;
|
|
|
|
+ }
|
|
|
|
+ for (const node of this.tree.nodes) {
|
|
|
|
+ node.valid = !(node.rela || this.tree.checkParent(node, 'rela'));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ refreshChangeRela(price, samePrice) {
|
|
|
|
+ if (price.rela_cid) {
|
|
|
|
+ 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 = [];
|
|
|
|
+ for (const sp of samePrice) {
|
|
|
|
+ const cid = sp.rela_cid ? sp.rela_cid.split(',') : [];
|
|
|
|
+ invalid.push(...cid);
|
|
|
|
+ }
|
|
|
|
+ for (const c of this.change) {
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ refreshRela(price) {
|
|
|
|
+ const samePrice = this.getSamePrice(price);
|
|
|
|
+ this.refreshTreeRela(price, samePrice);
|
|
|
|
+ this.refreshChangeRela(price, samePrice);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
const revisePrice = new RevisePrice();
|
|
const revisePrice = new RevisePrice();
|
|
const priceOprObj = {
|
|
const priceOprObj = {
|
|
addRevisePrice(data) {
|
|
addRevisePrice(data) {
|
|
const op = revisePrice.data.find(x => {
|
|
const op = revisePrice.data.find(x => {
|
|
- return x.b_code === data.b_code && x.name === x.name && x.unit === x.unit && checkZero(ZhCalc.sub(x.org_price, data.unit_price));
|
|
|
|
|
|
+ return x.b_code === data.b_code && x.name === x.name && x.unit === x.unit && checkZero(ZhCalc.sub(x.org_price, data.unit_price)) && (!x.rela_lid || !x.rela_cid);
|
|
});
|
|
});
|
|
if (op) {
|
|
if (op) {
|
|
toastr.warning('已存在该单价调整');
|
|
toastr.warning('已存在该单价调整');
|
|
@@ -307,7 +442,27 @@ $(document).ready(() => {
|
|
SpreadJsObj.reLoadRowsData(priceSheet, [sels[0].row, sels[0].row + 1]);
|
|
SpreadJsObj.reLoadRowsData(priceSheet, [sels[0].row, sels[0].row + 1]);
|
|
priceSheet.setSelection(sels[0].row + 1, sels[0].col, sels[0].rowCount, sels[0].colCount);
|
|
priceSheet.setSelection(sels[0].row + 1, sels[0].col, sels[0].rowCount, sels[0].colCount);
|
|
});
|
|
});
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ updateRelaLid: function (price, rela_lid) {
|
|
|
|
+ const data = { update: { id: price.id, rela_lid } };
|
|
|
|
+ postData(window.location.pathname + '/update', data, function (result) {
|
|
|
|
+ revisePrice.loadUpdateData(result);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ 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.reloadRowForeColor(priceBwSheet, 0, priceBwSheet.getRowCount());
|
|
|
|
+ SpreadJsObj.reloadRowForeColor(priceChangeSheet, 0, priceChangeSheet.getRowCount());
|
|
|
|
+ },
|
|
};
|
|
};
|
|
if (!readOnly) {
|
|
if (!readOnly) {
|
|
priceSheet.bind(spreadNS.Events.EditEnded, priceOprObj.editEnded);
|
|
priceSheet.bind(spreadNS.Events.EditEnded, priceOprObj.editEnded);
|
|
@@ -334,7 +489,7 @@ $(document).ready(() => {
|
|
return !readOnly;
|
|
return !readOnly;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- sprDel: '------------',
|
|
|
|
|
|
+ sprDel: '----',
|
|
upMove: {
|
|
upMove: {
|
|
name: '上移',
|
|
name: '上移',
|
|
icon: 'fa-arrow-up',
|
|
icon: 'fa-arrow-up',
|
|
@@ -370,10 +525,44 @@ $(document).ready(() => {
|
|
visible: function (key, opt) {
|
|
visible: function (key, opt) {
|
|
return !readOnly;
|
|
return !readOnly;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ sprMove: '----',
|
|
|
|
+ chooseRelaBw: {
|
|
|
|
+ name: '选择应用部位',
|
|
|
|
+ icon: 'fa-tags',
|
|
|
|
+ callback: function (key, opt) {
|
|
|
|
+ const price = SpreadJsObj.getSelectObject(priceSheet);
|
|
|
|
+ const samePrice = revisePrice.getSamePrice(price);
|
|
|
|
+ chooseRelaBw.show(price, samePrice);
|
|
|
|
+ },
|
|
|
|
+ disabled: function (key, opt) {
|
|
|
|
+ const node = SpreadJsObj.getSelectObject(priceSheet);
|
|
|
|
+ return !node;
|
|
|
|
+ },
|
|
|
|
+ visible: function (key, opt) {
|
|
|
|
+ return !readOnly;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ chooseRelaChange: {
|
|
|
|
+ name: '选择应用变更令',
|
|
|
|
+ icon: 'fa-tags',
|
|
|
|
+ callback: function (key, opt) {
|
|
|
|
+ const price = SpreadJsObj.getSelectObject(priceSheet);
|
|
|
|
+ const samePrice = revisePrice.getSamePrice(price);
|
|
|
|
+ chooseRelaChange.show(price, samePrice);
|
|
|
|
+ },
|
|
|
|
+ disabled: function (key, opt) {
|
|
|
|
+ const node = SpreadJsObj.getSelectObject(priceSheet);
|
|
|
|
+ return !node;
|
|
|
|
+ },
|
|
|
|
+ visible: function (key, opt) {
|
|
|
|
+ return !readOnly;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
},
|
|
},
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+ priceSpread.bind(spreadNS.Events.SelectionChanged, priceOprObj.selectionChanged);
|
|
|
|
|
|
class LedgerGcl {
|
|
class LedgerGcl {
|
|
constructor(setting) {
|
|
constructor(setting) {
|
|
@@ -435,6 +624,8 @@ $(document).ready(() => {
|
|
autoFlashHeight();
|
|
autoFlashHeight();
|
|
priceSpread.refresh();
|
|
priceSpread.refresh();
|
|
ledgerGcl.spread.refresh();
|
|
ledgerGcl.spread.refresh();
|
|
|
|
+ priceBwSpread.refresh();
|
|
|
|
+ priceChangeSpread.refresh();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -442,22 +633,296 @@ $(document).ready(() => {
|
|
select: '#revise-right-spr',
|
|
select: '#revise-right-spr',
|
|
callback: function () {
|
|
callback: function () {
|
|
priceSpread.refresh();
|
|
priceSpread.refresh();
|
|
|
|
+ priceBwSpread.refresh();
|
|
|
|
+ priceChangeSpread.refresh();
|
|
ledgerGcl.spread.refresh();
|
|
ledgerGcl.spread.refresh();
|
|
|
|
+ ledgerGcl.xmjSpread.refresh();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
$.divResizer({
|
|
$.divResizer({
|
|
select: '#gcl-spr',
|
|
select: '#gcl-spr',
|
|
callback: function () {
|
|
callback: function () {
|
|
- priceSpread.refresh();
|
|
|
|
ledgerGcl.spread.refresh();
|
|
ledgerGcl.spread.refresh();
|
|
ledgerGcl.xmjSpread.refresh();
|
|
ledgerGcl.xmjSpread.refresh();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ $.divResizer({
|
|
|
|
+ select: '#price-resize',
|
|
|
|
+ callback: function () {
|
|
|
|
+ priceSpread.refresh();
|
|
|
|
+ let bcontent = $(".bcontent-wrap").length > 0 ? $(".bcontent-wrap").height() : 0;
|
|
|
|
+ $(".sp-wrap").height(bcontent-30);
|
|
|
|
+ priceBwSpread.refresh();
|
|
|
|
+ priceChangeSpread.refresh();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ class ChooseRelaBw {
|
|
|
|
+ constructor() {
|
|
|
|
+ const self = this;
|
|
|
|
+ this.tree = createNewPathTree('base', {
|
|
|
|
+ id: 'ledger_id',
|
|
|
|
+ pid: 'ledger_pid',
|
|
|
|
+ order: 'order',
|
|
|
|
+ level: 'level',
|
|
|
|
+ rootId: -1,
|
|
|
|
+ fullPath: 'full_path',
|
|
|
|
+ keys: ['id', 'tender_id', 'ledger_id'],
|
|
|
|
+ });
|
|
|
|
+ $('#choose-rela-bw').on('shown.bs.modal', function() {
|
|
|
|
+ self.initSpread();
|
|
|
|
+ SpreadJsObj.reloadColData(self.sheet, 0, 1);
|
|
|
|
+ SpreadJsObj.reloadRowBackColor(self.sheet, 0, self.tree.nodes.length);
|
|
|
|
+ });
|
|
|
|
+ $('#choose-rela-bw-ok').click(function() {
|
|
|
|
+ const choose_lid = [];
|
|
|
|
+ self.tree.nodes.forEach(x => {
|
|
|
|
+ if (x.check) choose_lid.push(x.ledger_id);
|
|
|
|
+ });
|
|
|
|
+ priceOprObj.updateRelaLid(self.price, choose_lid.join(','));
|
|
|
|
+ $('#choose-rela-bw').modal('hide');
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ initSpread() {
|
|
|
|
+ if (this.spread) return;
|
|
|
|
+
|
|
|
|
+ this.spread = SpreadJsObj.createNewSpread($('#rela-bw-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: '@', 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,
|
|
|
|
+ headRowHeight: [25],
|
|
|
|
+ defaultRowHeight: 21,
|
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
|
+ font: '12px 微软雅黑',
|
|
|
|
+ readOnly: true,
|
|
|
|
+ getColor: function (sheet, data, row, col, defaultColor) {
|
|
|
|
+ return data && data.invalid ? '#dddddd' : defaultColor;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ sjsSettingObj.setFxTreeStyle(spreadSetting, sjsSettingObj.FxTreeStyle.jz);
|
|
|
|
+ SpreadJsObj.initSheet(this.sheet, spreadSetting);
|
|
|
|
+ const self = this;
|
|
|
|
+ this.spread.bind(spreadNS.Events.ButtonClicked, function (e, info) {
|
|
|
|
+ function checkInvalid(node) {
|
|
|
|
+ if (node.invalid) return 1;
|
|
|
|
+ if (self.tree.checkParent(node, 'invalid')) return 2;
|
|
|
|
+ if (self.tree.checkChildren(node, 'invalid')) return 3;
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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 tree = sheet.zh_tree;
|
|
|
|
+ const node = SpreadJsObj.getSelectObject(sheet);
|
|
|
|
+ if (node.b_code) {
|
|
|
|
+ toastr.warning('请选择部位');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!node.check) {
|
|
|
|
+ const invalid = checkInvalid(node);
|
|
|
|
+ const invalidHint = ['该部位已被选择,请勿重复选择', '该部位的父项已被选择,请勿选择', '该部位的子项已被选择,请勿在其子项中选择'];
|
|
|
|
+ if (invalid) {
|
|
|
|
+ toastr.warning(invalidHint[invalid-1]);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (self.tree.checkParent(node)) {
|
|
|
|
+ const rect = info.sheet.getCellRect(info.row, info.col);
|
|
|
|
+ self.chooseConfirmPopover({
|
|
|
|
+ x: rect.x + rect.width / 2 + 25,
|
|
|
|
+ y: rect.y + rect.height / 2 + 3,
|
|
|
|
+ }, '父项已勾选,继续将取消父项勾选。', function () {
|
|
|
|
+ node.check = true;
|
|
|
|
+ const parents = tree.getFullPathNodes(tree.getParent(node).full_path);
|
|
|
|
+ const rows = [tree.nodes.indexOf(node)];
|
|
|
|
+ for (const p of parents) {
|
|
|
|
+ if (p.check) {
|
|
|
|
+ p.check = false;
|
|
|
|
+ rows.push(tree.nodes.indexOf(p));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ SpreadJsObj.reLoadRowsData(info.sheet, rows);
|
|
|
|
+ });
|
|
|
|
+ } else if (self.tree.checkChildren(node)) {
|
|
|
|
+ const rect = info.sheet.getCellRect(info.row, info.col);
|
|
|
|
+ self.chooseConfirmPopover({
|
|
|
|
+ x: rect.x + rect.width / 2 + 25,
|
|
|
|
+ y: rect.y + rect.height / 2 + 3,
|
|
|
|
+ }, '子项已勾选,继续将取消子项勾选。', function () {
|
|
|
|
+ node.check = true;
|
|
|
|
+ const posterity = tree.getPosterity(node);
|
|
|
|
+ const rows = [tree.nodes.indexOf(node)];
|
|
|
|
+ for (const p of posterity) {
|
|
|
|
+ if (p.check) {
|
|
|
|
+ rows.push(tree.nodes.indexOf(p));
|
|
|
|
+ p.check = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ SpreadJsObj.reLoadRowsData(info.sheet, rows);
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ 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.Tree, this.tree);
|
|
|
|
+ }
|
|
|
|
+ reBind(obj, eventName, fun) {
|
|
|
|
+ obj.unbind(eventName);
|
|
|
|
+ obj.bind(eventName, fun);
|
|
|
|
+ }
|
|
|
|
+ chooseConfirmPopover(pos, hint, okCallback) {
|
|
|
|
+ const confirmObj = $('#choose-confirm'), hintObj = $('#choose-confirm-hint');
|
|
|
|
+ const okObj = $('#choose-confirm-ok'), cancelObj = $('#choose-confirm-cancel');
|
|
|
|
+ this.reBind(cancelObj, 'click', function () {
|
|
|
|
+ confirmObj.hide();
|
|
|
|
+ });
|
|
|
|
+ this.reBind(okObj, 'click', function () {
|
|
|
|
+ okCallback();
|
|
|
|
+ confirmObj.hide();
|
|
|
|
+ });
|
|
|
|
+ hintObj.text(hint);
|
|
|
|
+ confirmObj.css("top", pos.y).css("left", pos.x).show();
|
|
|
|
+ }
|
|
|
|
+ loadTree(data) {
|
|
|
|
+ this.tree.loadDatas(data);
|
|
|
|
+ }
|
|
|
|
+ show(price, samePrice){
|
|
|
|
+ this.price = price;
|
|
|
|
+ this.choose = price.rela_lid ? price.rela_lid.split(',') : [];
|
|
|
|
+ this.invalid = [];
|
|
|
|
+ for (const sp of samePrice) {
|
|
|
|
+ const lid = sp.rela_lid ? sp.rela_lid.split(',') : [];
|
|
|
|
+ this.invalid.push(...lid);
|
|
|
|
+ }
|
|
|
|
+ for (const node of this.tree.nodes) {
|
|
|
|
+ node.check = this.choose.indexOf(node.ledger_id + '') >= 0;
|
|
|
|
+ node.invalid = this.invalid.indexOf(node.ledger_id + '') >= 0;
|
|
|
|
+ }
|
|
|
|
+ $('#choose-rela-bw').modal('show');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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;
|
|
|
|
|
|
- postData('load', { filter: 'bills;pos;price' }, result => {
|
|
|
|
- revisePrice.loadDatas(result.price);
|
|
|
|
|
|
+ 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);
|
|
SpreadJsObj.loadSheetData(priceSheet, SpreadJsObj.DataType.Data, revisePrice.data);
|
|
ledgerGcl.loadData(result.bills, result.pos);
|
|
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();
|
|
$("[content='#ledgerGcl']").click();
|
|
});
|
|
});
|
|
|
|
|
|
@@ -468,7 +933,7 @@ $(document).ready(() => {
|
|
if (!tab.hasClass('active')) {
|
|
if (!tab.hasClass('active')) {
|
|
$('a', '#side-menu').removeClass('active');
|
|
$('a', '#side-menu').removeClass('active');
|
|
tab.addClass('active');
|
|
tab.addClass('active');
|
|
- $('.tab-content .tab-pane').removeClass('active');
|
|
|
|
|
|
+ $('#right-view .tab-pane').removeClass('active');
|
|
tabPanel.addClass('active');
|
|
tabPanel.addClass('active');
|
|
showSideTools(tab.hasClass('active'));
|
|
showSideTools(tab.hasClass('active'));
|
|
ledgerGcl.spread.refresh();
|
|
ledgerGcl.spread.refresh();
|
|
@@ -479,5 +944,15 @@ $(document).ready(() => {
|
|
showSideTools(tab.hasClass('active'));
|
|
showSideTools(tab.hasClass('active'));
|
|
}
|
|
}
|
|
priceSpread.refresh();
|
|
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();
|
|
});
|
|
});
|
|
});
|
|
});
|