123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- /**
- * 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, parentID, nextSiblingID;
- if (target) {
- console.log(target.depth());
- parentID = target.depth() === 0 ? target.source.getID() : target.source.getParentID();
- nextSiblingID = target.depth() === 0 ? project.Bills.tree.setting.rootId : target.source.getNextSiblingID();
- if (std) {
- let newCode = project.Bills.newFormatCode(std.code);
- newSource = project.Bills.insertStdBills(parentID, nextSiblingID, std, newCode);
- } else {
- newSource = project.Bills.insertBills(parentID, nextSiblingID);
- }
- if (target.depth() === 0) {
- newNode = project.mainTree.insert(target.getID(), project.mainTree.rootID())
- } else {
- newNode = project.mainTree.insert(target.getParentID(), target.getNextSiblingID());
- }
- } else {
- alert('不可添加清单');
- }
- if (newNode) {
- newNode.source = newSource;
- newNode.sourceType = project.Bills.getSourceType();
- newNode.data = newSource.data;
- this.syncDisplayNewNode(sheetController, newNode);
- }
- },
- addRation: function (project, sheetController, rationType, 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 {
- 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(),null, rationType);
- }
- 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, rationType);
- }
- newNode = project.mainTree.insert(selected.getParentID(), selected.getNextSiblingID());
- };
- if (newNode) {
- newNode.source = newSource;
- newNode.sourceType = project.Ration.getSourceType();
- newNode.data = newSource;
- this.syncDisplayNewNode(sheetController, newNode);
- }
- },
- replaceRation: 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.Ration.getSourceType()) {
- project.Ration.replaceRation(selected.source, std);
- project.ration_glj.addRationGLJ(selected.source, std);
- sheetController.refreshTreeNode([selected], false);
- } else {
- alert('当前焦点行不是定额,无法替换。');
- }
- }
- /* 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.Ration.getSourceType() || 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;
- }*/
- }
|