|
@@ -9,15 +9,16 @@ var Bills = {
|
|
|
pid: 'ParentID',
|
|
|
nid: 'NextSiblingID',
|
|
|
rootId: -1,
|
|
|
- autoUpdate: false
|
|
|
+ autoUpdate: true
|
|
|
};
|
|
|
|
|
|
// 用户定义private方法
|
|
|
var tools = {
|
|
|
- coverseTreeUpdateData: function (datas) {
|
|
|
+ coverseTreeUpdateData: function (datas, projectID) {
|
|
|
var updateDatas = [];
|
|
|
datas.forEach(function (data) {
|
|
|
var updateData = {};
|
|
|
+ data.data.projectID = projectID;
|
|
|
if (data.type === idTree.updateType.new) {
|
|
|
updateData.updateType = 'ut_create';
|
|
|
updateData.updateData = data.data;
|
|
@@ -108,47 +109,67 @@ var Bills = {
|
|
|
|
|
|
bills.prototype.insertBills = function (parentId, nextSiblingId) {
|
|
|
var insertData = this.tree.getInsertData(parentId, nextSiblingId);
|
|
|
- var that = this;
|
|
|
+ var that = this, newData = null;
|
|
|
insertData.forEach(function (data) {
|
|
|
- data.data.projectID = that.project.ID();
|
|
|
if (data.type === idTree.updateType.new) {
|
|
|
- that.datas.push(data.data);
|
|
|
+ newData = data.data;
|
|
|
}
|
|
|
});
|
|
|
this.project.pushNow('insertBills', [this.getSourceType(), this.project.projCounter()],
|
|
|
- [ tools.coverseTreeUpdateData(insertData), this.getCounterData()]);
|
|
|
+ [ tools.coverseTreeUpdateData(insertData, this.project.ID()), this.getCounterData()]);
|
|
|
//project.pushNow('insertBills', ModuleNames.bills, tools.coverseTreeUpdateData(insertData));
|
|
|
|
|
|
+ this.datas.push(newData);
|
|
|
return this.tree.insert(parentId, nextSiblingId);
|
|
|
};
|
|
|
-
|
|
|
bills.prototype.insertStdBills = function (parentId, nextSiblingId, stdBillsData) {
|
|
|
var insertData = this.tree.getInsertData(parentId, nextSiblingId);
|
|
|
var newData = null, that = this;
|
|
|
insertData.forEach(function (data) {
|
|
|
- data.data.projectID = that.project.ID();
|
|
|
if (data.type === idTree.updateType.new) {
|
|
|
data.data.code = stdBillsData.code;
|
|
|
data.data.name = stdBillsData.name;
|
|
|
data.data.unit = stdBillsData.unit;
|
|
|
- that.datas.push(data.data);
|
|
|
newData = data.data;
|
|
|
}
|
|
|
});
|
|
|
this.project.pushNow('insertStdBills', [this.getSourceType(), this.project.projCounter()],
|
|
|
- [ tools.coverseTreeUpdateData(insertData), this.getCounterData()]);
|
|
|
- //project.pushNow('insertStdBills', ModuleNames.bills, tools.coverseTreeUpdateData(insertData));
|
|
|
+ [ tools.coverseTreeUpdateData(insertData, this.project.ID()), this.getCounterData()]);
|
|
|
|
|
|
+ this.datas.push(newData);
|
|
|
return this.tree.insertByData(newData, parentId, nextSiblingId);
|
|
|
- }
|
|
|
-
|
|
|
+ };
|
|
|
bills.prototype.deleteBills = function (node) {
|
|
|
var deleteData = this.tree.getDeleteData(node);
|
|
|
project.beginUpdate('deleteBills');
|
|
|
- project.push(ModuleNames.bills, tools.coverseTreeUpdateData(deleteData, project.ID()));
|
|
|
+ project.push(ModuleNames.bills, tools.coverseTreeUpdateData(deleteData, this.project.ID()));
|
|
|
project.endUpdate();
|
|
|
|
|
|
return this.tree.delete(node);
|
|
|
+ };
|
|
|
+ bills.prototype.upMoveBills = function (node) {
|
|
|
+ var upMoveData = node.getUpMoveData();
|
|
|
+ project.pushNow('upMoveBills', this.getSourceType(), tools.coverseTreeUpdateData(upMoveData, this.project.ID()));
|
|
|
+
|
|
|
+ return node.upMove();
|
|
|
+ };
|
|
|
+ bills.prototype.downMoveBills = function (node) {
|
|
|
+ var downMoveData = node.getDownMoveData();
|
|
|
+ project.pushNow('downMoveBills', this.getSourceType(), tools.coverseTreeUpdateData(downMoveData, this.project.ID()));
|
|
|
+
|
|
|
+ return node.downMove();
|
|
|
+ };
|
|
|
+ bills.prototype.upLevelBills = function (node) {
|
|
|
+ var upLevelData = node.getUpLevelData();
|
|
|
+ project.pushNow('upLevelBills', this.getSourceType(), tools.coverseTreeUpdateData(upLevelData, this.project.ID()));
|
|
|
+
|
|
|
+ return node.upLevel();
|
|
|
+ };
|
|
|
+ bills.prototype.downLevelBills = function (node) {
|
|
|
+ var downLevelData = node.getDownLevelData();
|
|
|
+ project.pushNow('downLevelBills', [this.getSourceType()], [tools.coverseTreeUpdateData(downLevelData, this.project.ID())]);
|
|
|
+
|
|
|
+ return node.downLevel();
|
|
|
}
|
|
|
|
|
|
return new bills(project);
|