|
@@ -7,11 +7,27 @@ let labourCoeView = {
|
|
|
spread: null,
|
|
|
sheet: null,
|
|
|
|
|
|
- buildSheet: function (){
|
|
|
+ init(){
|
|
|
let me = this;
|
|
|
|
|
|
- me.datas = projectObj.project.LabourCoe.datas !== null ? projectObj.project.LabourCoe.datas.coes : [];
|
|
|
+ function getStdLabourCoeFilesHtml(stdLabourCoeLibs) {
|
|
|
+ let result = '<option value="">请选择人工系数标准库</option>';
|
|
|
+ if (stdLabourCoeLibs.length <= 0) {
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ for (let lib of stdLabourCoeLibs){
|
|
|
+ result += '<option value="'+ lib.id +'">'+ lib.name +'</option>';
|
|
|
+ };
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ let stdLCHtml = getStdLabourCoeFilesHtml(projectInfoObj.projectInfo.engineeringInfo.artificial_lib);
|
|
|
+ $("#std_labour_coe_files").html(stdLCHtml);
|
|
|
+ },
|
|
|
|
|
|
+ buildSheet: function (){
|
|
|
+ let me = this;
|
|
|
if (me.spread) {
|
|
|
me.spread.destroy();
|
|
|
me.spread = null;
|
|
@@ -36,8 +52,9 @@ let labourCoeView = {
|
|
|
sheet.resumePaint();
|
|
|
},
|
|
|
|
|
|
- loadData(){ // 树结构转换二维表显示,行列转换
|
|
|
+ loadData(datas){ // 树结构转换二维表显示,行列转换
|
|
|
let me = this;
|
|
|
+ me.datas = datas;
|
|
|
let libArr = [];
|
|
|
for (let v of me.datas) {if (!v.ParentID) libArr.push(v);};
|
|
|
|
|
@@ -54,7 +71,7 @@ let labourCoeView = {
|
|
|
me.sheet.setRowCount(row, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
me.sheet.setText(0, 0, "定额工种", GC.Spread.Sheets.SheetArea.colHeader);
|
|
|
me.sheet.options.isProtected = true;
|
|
|
- me.sheet.getRange(-1, 1, -1, libArr.length + 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
|
|
|
+ me.sheet.getRange(-1, 1, -1, libArr.length + 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
|
|
|
|
|
|
// 列名称
|
|
|
for (let c = 0; c <= libArr.length - 1; c++) {
|
|
@@ -74,31 +91,12 @@ let labourCoeView = {
|
|
|
};
|
|
|
},
|
|
|
|
|
|
- init(){
|
|
|
- let me = this;
|
|
|
-
|
|
|
- function getStdLabourCoeFilesHtml(stdLabourCoeLibs) {
|
|
|
- let result = '<option value="">请选择人工系数标准库</option>';
|
|
|
- if (stdLabourCoeLibs.length <= 0) {
|
|
|
- return result;
|
|
|
- };
|
|
|
-
|
|
|
- for (let lib of stdLabourCoeLibs){
|
|
|
- result += '<option value="'+ lib.id +'">'+ lib.name +'</option>';
|
|
|
- };
|
|
|
-
|
|
|
- return result;
|
|
|
- };
|
|
|
-
|
|
|
- let stdLCHtml = getStdLabourCoeFilesHtml(projectInfoObj.projectInfo.engineeringInfo.artificial_lib);
|
|
|
- $("#std_labour_coe_files").html(stdLCHtml);
|
|
|
- },
|
|
|
-
|
|
|
showData(){
|
|
|
let me = this;
|
|
|
+ let datas = projectObj.project.LabourCoe.datas !== null ? projectObj.project.LabourCoe.datas.coes : [];
|
|
|
me.init();
|
|
|
me.buildSheet();
|
|
|
- me.loadData();
|
|
|
+ me.loadData(datas);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -106,4 +104,34 @@ $(document).ready(function(){
|
|
|
$("#tab_poj-settings-6").on('shown.bs.tab', function (e) {
|
|
|
labourCoeView.showData();
|
|
|
});
|
|
|
+
|
|
|
+ $("#std_labour_coe_files").change(function() {
|
|
|
+ // 取标准库数据过来显示。
|
|
|
+ let libID = $(this).val();
|
|
|
+ if (libID == ''){
|
|
|
+ labourCoeView.loadData([]);
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ type:"POST",
|
|
|
+ url: '/labourCoe/getStdLabourCoe',
|
|
|
+ data: {"ID": libID},
|
|
|
+ dataType: 'json',
|
|
|
+ cache: false,
|
|
|
+ timeout: 50000,
|
|
|
+ success: function(result){
|
|
|
+ if (result.error === 0) {
|
|
|
+ labourCoeView.buildSheet();
|
|
|
+ labourCoeView.loadData(result.data.coes);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ alert('error: ' + result.message);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function(jqXHR, textStatus, errorThrown){
|
|
|
+ alert('error ' + textStatus + " " + errorThrown);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|