|
@@ -2,6 +2,7 @@
|
|
|
* Created by Mai on 2017/4/17.
|
|
|
*/
|
|
|
$(document).ready(function () {
|
|
|
+ var tempType = 3;
|
|
|
var PostData = function (url, data, successCallback, errorCallback) {
|
|
|
$.ajax({
|
|
|
type:"POST",
|
|
@@ -31,7 +32,7 @@ $(document).ready(function () {
|
|
|
var FormatUpdateData = function (data) {
|
|
|
var updateData = {};
|
|
|
updateData['user_id'] = userID;
|
|
|
- updateData['tempType'] = 1;
|
|
|
+ updateData['tempType'] = tempType;
|
|
|
updateData['updateData'] = data;
|
|
|
return updateData;
|
|
|
};
|
|
@@ -49,6 +50,15 @@ $(document).ready(function () {
|
|
|
showButton(tree.selected && tree.selected.canDownMove(), $('#downMove'));
|
|
|
showButton(tree.selected ? true : false, $('#delete'));
|
|
|
}
|
|
|
+ var RefreshBillsData = function (datas) {
|
|
|
+ datas.forEach(function (data) {
|
|
|
+ bills.forEach(function (billsData) {
|
|
|
+ if (data.data.ID === billsData.ID) {
|
|
|
+ $.extend(true, billsData, data.data);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
var bills;
|
|
|
var tree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1});
|
|
@@ -61,23 +71,10 @@ $(document).ready(function () {
|
|
|
billsSpread.options.scrollbarMaxAlign = true;
|
|
|
controller.bind('refreshBaseActn', RefreshBaseActn);
|
|
|
|
|
|
- /*billsSpread.bind(GC.Spread.Sheets.Events.ValueChanged, function (e, info) {
|
|
|
- var node = controller.tree.findNode(info.sheet.getTag(info.row, info.col));
|
|
|
- var fieldName = controller.setting.cols[info.col].data.field;
|
|
|
- var data = {type: 'update', data: node.data};
|
|
|
- data.data[fieldName] = info.newValue;
|
|
|
- var updateData = FormatUpdateData([data]);
|
|
|
- PostData('/template/bills/updateBillsTemplate', updateData, function (data) {
|
|
|
- node.data[fieldName] = info.newValue;
|
|
|
- }, function () {
|
|
|
- TREE_SHEET_HELPER.refreshTreeNodeData(setting, sheet, [node], false);
|
|
|
- });
|
|
|
- });*/
|
|
|
-
|
|
|
billsSpread.bind(GC.Spread.Sheets.Events.EditEnded, function (sender, info) {
|
|
|
var node = controller.tree.findNode(info.sheet.getTag(info.row, info.col));
|
|
|
var fieldName = controller.setting.cols[info.col].data.field;
|
|
|
- var data = {type: 'update', data: node.data};
|
|
|
+ var data = {type: 'update', data: {ID: node.getID()}};
|
|
|
data.data[fieldName] = info.editingText;
|
|
|
var updateData = FormatUpdateData([data]);
|
|
|
PostData('/template/bills/updateBillsTemplate', updateData, function (data) {
|
|
@@ -88,7 +85,30 @@ $(document).ready(function () {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- PostData('/template/bills/getBillsTemplate', {tempType: 1}, function (data) {
|
|
|
+ billsSpread.bind(GC.Spread.Sheets.Events.ClipboardPasted, function (e, info) {
|
|
|
+ var node, iRow, iCol, curRow, curCol, datas = [], data, fieldName, updateData;
|
|
|
+ for (iRow = 0; iRow < info.cellRange.rowCount; iRow ++) {
|
|
|
+ curRow = info.cellRange.row + iRow;
|
|
|
+ node = controller.tree.findNode(info.sheet.getTag(curRow, 0));
|
|
|
+ if (node) {
|
|
|
+ data = {type: 'update', data: {ID: node.getID()}};
|
|
|
+ for (iCol = 0; iCol < info.cellRange.colCount; iCol++) {
|
|
|
+ curCol = info.cellRange.col + iCol;
|
|
|
+ fieldName = controller.setting.cols[curCol].data.field;
|
|
|
+ data.data[fieldName] = info.sheet.getText(curRow, curCol);
|
|
|
+ }
|
|
|
+ datas.push(data);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ PostData('/template/bills/updateBillsTemplate', FormatUpdateData(datas), function (data) {
|
|
|
+ RefreshBillsData(data);
|
|
|
+ controller.showTreeData();
|
|
|
+ }, function () {
|
|
|
+ controller.showTreeData();
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ PostData('/template/bills/getBillsTemplate', {tempType: tempType}, function (data) {
|
|
|
bills = data;
|
|
|
tree.loadDatas(bills);
|
|
|
controller.showTreeData();
|
|
@@ -107,6 +127,8 @@ $(document).ready(function () {
|
|
|
}
|
|
|
PostData('/template/bills/updateBillsTemplate', updateData, function (data) {
|
|
|
controller.insert();
|
|
|
+ RefreshBillsData(data);
|
|
|
+ controller.showTreeData();
|
|
|
});
|
|
|
});
|
|
|
$('#delete').click(function () {
|
|
@@ -115,6 +137,8 @@ $(document).ready(function () {
|
|
|
updateData = FormatUpdateData(controller.tree.getDeleteData(selected));
|
|
|
PostData('/template/bills/updateBillsTemplate', updateData, function (data) {
|
|
|
controller.delete();
|
|
|
+ RefreshBillsData(data);
|
|
|
+ controller.showTreeData();
|
|
|
});
|
|
|
}
|
|
|
});
|
|
@@ -124,6 +148,8 @@ $(document).ready(function () {
|
|
|
updateData = FormatUpdateData(selected.getUpLevelData());
|
|
|
PostData('/template/bills/updateBillsTemplate', updateData, function (data) {
|
|
|
controller.upLevel();
|
|
|
+ RefreshBillsData(data);
|
|
|
+ controller.showTreeData();
|
|
|
});
|
|
|
}
|
|
|
});
|
|
@@ -133,6 +159,8 @@ $(document).ready(function () {
|
|
|
updateData = FormatUpdateData(selected.getDownLevelData());
|
|
|
PostData('/template/bills/updateBillsTemplate', updateData, function (data) {
|
|
|
controller.downLevel();
|
|
|
+ RefreshBillsData(data);
|
|
|
+ controller.showTreeData();
|
|
|
});
|
|
|
}
|
|
|
});
|
|
@@ -142,6 +170,8 @@ $(document).ready(function () {
|
|
|
updateData = FormatUpdateData(selected.getUpMoveData());
|
|
|
PostData('/template/bills/updateBillsTemplate', updateData, function (data) {
|
|
|
controller.upMove();
|
|
|
+ RefreshBillsData(data);
|
|
|
+ controller.showTreeData();
|
|
|
});
|
|
|
}
|
|
|
});
|
|
@@ -150,7 +180,9 @@ $(document).ready(function () {
|
|
|
if (selected) {
|
|
|
updateData = FormatUpdateData(selected.getDownMoveData());
|
|
|
PostData('/template/bills/updateBillsTemplate', updateData, function (data) {
|
|
|
- controller.downMove()
|
|
|
+ controller.downMove();
|
|
|
+ RefreshBillsData(data);
|
|
|
+ controller.showTreeData();
|
|
|
});
|
|
|
}
|
|
|
});
|