123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- /**
- * Created by Mai on 2017/6/1.
- */
- ProjectController = {
- /* sc: tree_sheet_controller */
- syncDisplayNewNode: function (sc, newNode) {
- TREE_SHEET_HELPER.massOperationSheet(sc.sheet, function () {
- var sels = sc.sheet.getSelections();
- sc.sheet.addRows(newNode.serialNo(), 1);
- TREE_SHEET_HELPER.refreshTreeNodeData(sc.setting, sc.sheet, [newNode], false);
- sc.setTreeSelected(newNode);
- sc.sheet.setSelection(newNode.serialNo(), sels[0].col, 1, 1);
- sc.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
- });
- },
- addBills: function (project, sheetController, std) {
- if (!project || !sheetController) { return null; }
- let target = project.getParentTarget(project.mainTree.selected, 'sourceType', project.Bills.getSourceType());
- let newSource = null, newNode = null;
- let parentID = target ? target.source.getParentID() : project.Bills.tree.setting.rootId;
- let nextSiblingID = target ? target.source.getNextSiblingID() : project.Bills.tree.setting.rootId;
- if (std) {
- let newCode = project.Bills.newFormatCode(std.code);
- newSource = project.Bills.insertStdBills(parentID, nextSiblingID, std, newCode);
- } else {
- newSource = project.Bills.insertBills(parentID, nextSiblingID);
- }
- newNode = project.mainTree.insert(target.getParentID(), target.getNextSiblingID());
- if (newNode) {
- newNode.source = newSource;
- newNode.sourceType = project.Bills.getSourceType();
- newNode.data = newSource.data;
- this.syncDisplayNewNode(sheetController, newNode);
- }
- },
- addRation: function (project, sheetController, std) {
- if (!project || !sheetController) { return; }
- let selected = project.mainTree.selected, newSource = null, newNode = null;
- if (selected === null) { return; }
- if (selected.sourceType === project.Bills.getSourceType() && selected.depth() > 0) {
- if (selected.source.children.length > 0) {
- alert('当前清单已有清单子项,不能套用定额。');
- } else if (false) {
- alert('当前清单已有公式计算,不能套用定额。');
- } else {
- let firstChild = selected.firstChild();
- if (firstChild && firstChild.sourceType === project.VolumePrice.getSourceType()) {
- alert('当前位置已有量价,不能套用定额。');
- } else {
- if (std) {
- newSource = project.Ration.insertStdRation(selected.source.getID(), null, std);
- project.ration_glj.addRationGLJ(newSource,std);
- } else {
- newSource = project.Ration.insertRation(selected.source.getID());
- }
- }
- newNode = project.mainTree.insert(selected.getID(), selected.tree.rootID());
- }
- } else if (selected.sourceType === project.Ration.getSourceType()) {
- if (std) {
- newSource = project.Ration.insertStdRation(selected.source[project.masterField.ration], selected.source, std);
- project.ration_glj.addRationGLJ(newSource,std);
- } else {
- newSource = project.Ration.insertRation(selected.source[project.masterField.ration], selected.source);
- }
- newNode = project.mainTree.insert(selected.getParentID(), selected.getNextSiblingID());
- } else if (selected.sourceType === project.VolumePrice.getSourceType()) {
- alert('当前位置已有量价,不能套用定额。');
- }
- if (newNode) {
- newNode.source = newSource;
- newNode.sourceType = project.Ration.getSourceType();
- newNode.data = newSource;
- this.syncDisplayNewNode(sheetController, newNode);
- }
- },
- addVolumePrice: function (project, sheetController) {
- if (!project || !sheetController) { return null; }
- var selected = project.mainTree.selected;
- var newSource = null, newNode = null;
- if(selected === null) {
- return;
- }
- if (selected.sourceType === project.Bills.getSourceType() && selected.source.children.length === 0) {
- newSource = project.VolumePrice.insertVolumePrice(selected.source.getID());
- newNode = project.mainTree.insert(selected.getID(), selected.tree.rootID());
- } else if (selected.sourceType === project.VolumePrice.getSourceType()) {
- newSource = project.VolumePrice.insertVolumePrice(selected.source[project.masterField.volumePrice], selected.source);
- newNode = project.mainTree.insert(selected.getParentID(), selected.getNextSiblingID());
- }
- if (newNode) {
- newNode.source = newSource;
- newNode.sourceType = project.VolumePrice.getSourceType();
- newNode.data = newSource;
- this.syncDisplayNewNode(sheetController, newNode);
- }
- },
- calculateAll: function (project, sheetController, CalcType) {
- this.project.setCalcFlag(CalcType);
- let calc = new BillsCalcHelper(project);
- calc.calcAll();
- sheetController.showTreeData();
- project.Bills.updateAll();
- calc = null;
- }
- }
|