|
@@ -8,9 +8,7 @@
|
|
|
* @version
|
|
|
*/
|
|
|
|
|
|
-$(document).ready(function () {
|
|
|
- autoFlashHeight();
|
|
|
- // 根据设置整理Spread设置
|
|
|
+function initSpreadSettingWithRoles(compareRoles) {
|
|
|
function setSpreadSettingCols(setting, fieldSufs, Roles) {
|
|
|
function addExtraCols(fieldSuf, Role) {
|
|
|
for (const ec of setting.extraCols) {
|
|
@@ -28,21 +26,35 @@ $(document).ready(function () {
|
|
|
addExtraCols(fieldSufs[index], Roles[index]);
|
|
|
}
|
|
|
}
|
|
|
- setSpreadSettingCols(ledgerSpreadSetting, ['0'], ['原报']);
|
|
|
- setSpreadSettingCols(posSpreadSetting, ['0'], ['原报']);
|
|
|
-
|
|
|
- function calculateStageLedgerData(datas) {
|
|
|
- for (const d of datas) {
|
|
|
- d.gather_qty = ZhCalc.add(d.contract_qty, d.qc_qty);
|
|
|
- d.gather_tp = ZhCalc.add(d.contract_tp, d.qc_tp);
|
|
|
+ const fieldSufs = ['0'], roles = ['原报'], trs = $('tr[auditorId]');
|
|
|
+ for (let r of compareRoles) {
|
|
|
+ if (r > 0) {
|
|
|
+ const tr = trs[r-1];
|
|
|
+ if (tr) {
|
|
|
+ fieldSufs.push(r + '');
|
|
|
+ roles.push(tr.children[0].textContent);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- function calculateStagePosData(datas) {
|
|
|
- for (const d of datas) {
|
|
|
- d.gather_qty = ZhCalc.add(d.contract_qty, d.qc_qty);
|
|
|
- }
|
|
|
+ setSpreadSettingCols(ledgerSpreadSetting, fieldSufs, roles);
|
|
|
+ setSpreadSettingCols(posSpreadSetting, fieldSufs, roles);
|
|
|
+}
|
|
|
+function calculateStageLedgerData(datas) {
|
|
|
+ for (const d of datas) {
|
|
|
+ d.gather_qty = ZhCalc.add(d.contract_qty, d.qc_qty);
|
|
|
+ d.gather_tp = ZhCalc.add(d.contract_tp, d.qc_tp);
|
|
|
}
|
|
|
+}
|
|
|
+function calculateStagePosData(datas) {
|
|
|
+ for (const d of datas) {
|
|
|
+ d.gather_qty = ZhCalc.add(d.contract_qty, d.qc_qty);
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+$(document).ready(function () {
|
|
|
+ autoFlashHeight();
|
|
|
+ // 根据设置整理Spread设置
|
|
|
+ initSpreadSettingWithRoles(scRoles);
|
|
|
// 初始化台账
|
|
|
const ledgerSpread = SpreadJsObj.createNewSpread($('#ledger-spread')[0]);
|
|
|
SpreadJsObj.initSheet(ledgerSpread.getActiveSheet(), ledgerSpreadSetting);
|
|
@@ -72,12 +84,6 @@ $(document).ready(function () {
|
|
|
calcFields: [],
|
|
|
};
|
|
|
const scTree = createNewPathTree('master', scTreeSetting);
|
|
|
- scTree.loadDatas(ledger);
|
|
|
- calculateStageLedgerData(orgStageLedger);
|
|
|
- scTree.loadMinorData(orgStageLedger, '0', ['gather_qty', 'gather_tp'], ['gather_tp']);
|
|
|
- treeCalc.calculateAll(scTree);
|
|
|
- scTree.expandByCalcFields();
|
|
|
- SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, scTree);
|
|
|
// 加载 部位 数据
|
|
|
const scPosSetting = {
|
|
|
id: 'id', ledgerId: 'lid', masterId: 'id', minorId: 'pid',
|
|
@@ -86,11 +92,33 @@ $(document).ready(function () {
|
|
|
pos.gather_qty = ZhCalc.add(pos.contract_qty, pos.qc_qty);
|
|
|
};
|
|
|
const scPos = new MasterPosData(scPosSetting);
|
|
|
- scPos.loadDatas(pos);
|
|
|
- calculateStagePosData(orgStagePos);
|
|
|
- scPos.loadMinorData(orgStagePos, '0', ['gather_qty']);
|
|
|
|
|
|
- // 获取项目节数据
|
|
|
+ postData(window.location.pathname + '/load', {main: true, roles: scRoles}, function (result) {
|
|
|
+ scTree.loadDatas(result.main.ledger);
|
|
|
+ scPos.loadDatas(result.main.pos);
|
|
|
+ for (const aData of result.roles) {
|
|
|
+ calculateStageLedgerData(aData.bills);
|
|
|
+ scTree.loadMinorData(aData.bills, aData.order + '', ['gather_qty', 'gather_tp'], ['gather_tp']);
|
|
|
+ treeCalc.calculateAll(scTree);
|
|
|
+ calculateStagePosData(aData.pos);
|
|
|
+ scPos.loadMinorData(aData.pos, aData.order + '', ['gather_qty']);
|
|
|
+ }
|
|
|
+ scTree.expandByCalcFields();
|
|
|
+ SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, scTree);
|
|
|
+ loadPosData(0);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ // scTree.loadDatas(ledger);
|
|
|
+ // calculateStageLedgerData(orgStageLedger);
|
|
|
+ // scTree.loadMinorData(orgStageLedger, '0', ['gather_qty', 'gather_tp'], ['gather_tp']);
|
|
|
+ // treeCalc.calculateAll(scTree);
|
|
|
+ // scTree.expandByCalcFields();
|
|
|
+ // SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, scTree);
|
|
|
+ // scPos.loadDatas(pos);
|
|
|
+ // calculateStagePosData(orgStagePos);
|
|
|
+ // scPos.loadMinorData(orgStagePos, '0', ['gather_qty']);
|
|
|
+ // 获取部位明细数据
|
|
|
function loadPosData(iRow) {
|
|
|
const node = ledgerSpread.getActiveSheet().zh_tree.nodes[iRow];
|
|
|
if (node) {
|
|
@@ -100,7 +128,6 @@ $(document).ready(function () {
|
|
|
}
|
|
|
SpreadJsObj.resetTopAndSelect(posSpread.getActiveSheet());
|
|
|
}
|
|
|
- loadPosData(0);
|
|
|
// 切换清单行,读取所属项目节数据
|
|
|
ledgerSpread.getActiveSheet().bind(spreadNS.Events.SelectionChanged, function (e, info) {
|
|
|
if (info.newSelections) {
|
|
@@ -127,20 +154,19 @@ $(document).ready(function () {
|
|
|
// 选择比较人
|
|
|
$('#select-qi-ok').click(function () {
|
|
|
function refreshView () {
|
|
|
- const fieldSufs = ['0'], roles = ['原报'], trs = $('tr[auditorId]');
|
|
|
+ const compareRoles = [0];
|
|
|
for (let order = 0, iLength = trs.length; order < iLength; order++) {
|
|
|
const tr = trs[order];
|
|
|
if ($('input', tr)[0].checked) {
|
|
|
- fieldSufs.push((order + 1) + '');
|
|
|
- roles.push(tr.children[0].textContent);
|
|
|
+ compareRoles.push(order + 1);
|
|
|
}
|
|
|
}
|
|
|
- setSpreadSettingCols(ledgerSpreadSetting, fieldSufs, roles);
|
|
|
+ setLocalCache(scCacheKey, compareRoles.join(','));
|
|
|
+ initSpreadSettingWithRoles(compareRoles);
|
|
|
SpreadJsObj.initSheet(ledgerSpread.getActiveSheet(), ledgerSpreadSetting);
|
|
|
treeCalc.calculateAll(scTree);
|
|
|
scTree.expandByCalcFields();
|
|
|
SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, scTree);
|
|
|
- setSpreadSettingCols(posSpreadSetting, fieldSufs, roles);
|
|
|
SpreadJsObj.initSheet(posSpread.getActiveSheet(), posSpreadSetting);
|
|
|
loadPosData(0);
|
|
|
}
|
|
@@ -155,8 +181,8 @@ $(document).ready(function () {
|
|
|
}
|
|
|
}
|
|
|
if (loadData.length > 0) {
|
|
|
- postData(window.location.pathname + '/load', {auditors: loadData}, function (result) {
|
|
|
- for (const aData of result) {
|
|
|
+ postData(window.location.pathname + '/load', {roles: loadData}, function (result) {
|
|
|
+ for (const aData of result.roles) {
|
|
|
calculateStageLedgerData(aData.bills);
|
|
|
scTree.loadMinorData(aData.bills, aData.order + '', ['gather_qty', 'gather_tp'], ['gather_tp']);
|
|
|
treeCalc.calculateAll(scTree);
|