|
@@ -1,6 +1,36 @@
|
|
|
/**
|
|
|
* Created by CSL on 2017-03-23.
|
|
|
*/
|
|
|
+var region = '重庆';
|
|
|
+var projectID = 5;
|
|
|
+var spreadView;
|
|
|
+
|
|
|
+$(document).ready(function () {
|
|
|
+ $("#inlineFormCustomSelect").change(function () {
|
|
|
+ var fileID = $("#inlineFormCustomSelect").val();
|
|
|
+ loadLibFees(fileID);
|
|
|
+ });
|
|
|
+
|
|
|
+ $("#projectFeeFile").click(function () {
|
|
|
+ loadProjectFees(projectID);
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+function loadProjectFees(fileID) {
|
|
|
+ $.ajax({
|
|
|
+ type: "POST",
|
|
|
+ url: '/fees/getProjectFees',
|
|
|
+ data: {"fileID": fileID},
|
|
|
+ success: function (result) {
|
|
|
+ if (result.data) {
|
|
|
+ createSpreadView(result.data[0].fees, true);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function (result) {
|
|
|
+ alert('内部程序错误!');
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
function loadLibFiles(region) {
|
|
|
$('#inlineFormCustomSelect').empty();
|
|
@@ -16,8 +46,6 @@ function loadLibFiles(region) {
|
|
|
result.data[i].fileName + "</option>");
|
|
|
}
|
|
|
$("#inlineFormCustomSelect").get(0).selectedIndex = 0;
|
|
|
- var fileID = $("#inlineFormCustomSelect").val();
|
|
|
- loadLibFees(fileID);
|
|
|
}
|
|
|
},
|
|
|
error: function (result) {
|
|
@@ -33,7 +61,7 @@ function loadLibFees(fileID) {
|
|
|
data: {"fileID": fileID},
|
|
|
success: function (result) {
|
|
|
if (result.data) {
|
|
|
- createSpreadView(result.data[0].fees);
|
|
|
+ createSpreadView(result.data[0].fees, false);
|
|
|
}
|
|
|
},
|
|
|
error: function (result) {
|
|
@@ -42,11 +70,16 @@ function loadLibFees(fileID) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-function createSpreadView(data) {
|
|
|
+function createSpreadView(data, canEdit) {
|
|
|
// 创建前先销毁旧树表。
|
|
|
//$('#divFee').empty(); // 清空不行,浏览器跟踪显示错误数狂飚:TypeError: G is null
|
|
|
- $('#divFee').remove();
|
|
|
- $('#content').append($('<div class="grid" id="divFee"></div>'));
|
|
|
+ //$('#divFee').remove(); // 删除可以,但是太山寨。
|
|
|
+ //$('#content').append($('<div class="grid" id="divFee"></div>'));
|
|
|
+ // 以下找到官方的处理方法,比较面向对象
|
|
|
+ if (spreadView) {
|
|
|
+ spreadView.destroy();
|
|
|
+ spreadView = null;
|
|
|
+ }
|
|
|
|
|
|
var columns = [
|
|
|
{
|
|
@@ -92,7 +125,7 @@ function createSpreadView(data) {
|
|
|
colMinWidth: 80,
|
|
|
colHeaderHeight: 35,
|
|
|
rowHeight: 30,
|
|
|
- allowEditing: true,
|
|
|
+ allowEditing: canEdit,
|
|
|
hierarchy: {
|
|
|
keyField: 'ID',
|
|
|
parentField: 'ParentID',
|
|
@@ -101,12 +134,15 @@ function createSpreadView(data) {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- var dataView = new GC.Spread.Views.DataView(document.getElementById('divFee'),
|
|
|
+ spreadView = new GC.Spread.Views.DataView($('#divFee')[0],
|
|
|
data, columns, new GC.Spread.Views.Plugins.GridLayout(option));
|
|
|
- var opts = dataView.layoutEngine.options;
|
|
|
+ var opts = spreadView.layoutEngine.options;
|
|
|
opts.editMode = 'inline';
|
|
|
opts.editUnit = 'cell';
|
|
|
- opts.selectionUnit = 'cell';
|
|
|
- dataView.invalidate();
|
|
|
+ if (canEdit){ opts.selectionUnit = 'cell'; }
|
|
|
+ else{ opts.selectionUnit = 'row'; }
|
|
|
+ spreadView.invalidate();
|
|
|
document.querySelector('#divFee').focus();
|
|
|
}
|
|
|
+
|
|
|
+
|