|
|
@@ -60,8 +60,10 @@ let pageOprObj = {
|
|
|
//repositoryGljObj.getRationGljIds(gljLibId);
|
|
|
repositoryGljObj.getGljDistType(function () {
|
|
|
repositoryGljObj.currentRepositoryId = me.stdGljLibId;
|
|
|
- repositoryGljObj.getGljItems(me.stdGljLibId, function () {
|
|
|
- gljClassTreeObj.getGljClassTree(stdGljLibId);
|
|
|
+ gljClassTreeObj.getGljClassTree(stdGljLibId, function () {
|
|
|
+ repositoryGljObj.getGljItems(me.stdGljLibId, function () {
|
|
|
+ gljClassTreeObj.initSelection(gljClassTreeObj.tree.selected);
|
|
|
+ });
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
@@ -70,6 +72,10 @@ let pageOprObj = {
|
|
|
let repositoryGljObj = {
|
|
|
treeObj : null,
|
|
|
workBook: null,
|
|
|
+ // 是否获取了完整的人材机数据
|
|
|
+ // 第一次打开页面只加载补充人材机和标准人材机的编码
|
|
|
+ // 第一次打开选择组成物的窗口才加载标准人材机剩余数据
|
|
|
+ pullCompleteData: false,
|
|
|
gljCurTypeId: -1,
|
|
|
currentRepositoryId: -1,
|
|
|
currentCache: null,
|
|
|
@@ -179,8 +185,19 @@ let repositoryGljObj = {
|
|
|
});
|
|
|
},
|
|
|
getGljItems: function(stdGljLibId, callback) {
|
|
|
- let me = this;
|
|
|
- CommonAjax.post('complementartGlj/api/getGljItems', {stdGljLibId: stdGljLibId}, function (rstData) {
|
|
|
+ let me = this,
|
|
|
+ // 一开始获取的标准人材机只包含code,提升打开页面速度
|
|
|
+ projection = {
|
|
|
+ _id: 0,
|
|
|
+ ID: 1,
|
|
|
+ code: 1,
|
|
|
+ unit: 1,
|
|
|
+ name: 1,
|
|
|
+ priceProperty: 1,
|
|
|
+ basePrice: 1
|
|
|
+ };
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ CommonAjax.post('/complementartGlj/api/getGljItems', {stdGljLibId, projection}, function (rstData) {
|
|
|
me.stdGljList = rstData.stdGljs;
|
|
|
//兼容多单价情况
|
|
|
for(let sGlj of me.stdGljList){
|
|
|
@@ -188,14 +205,44 @@ let repositoryGljObj = {
|
|
|
sGlj.basePrice = sGlj.priceProperty.price1;
|
|
|
}
|
|
|
}
|
|
|
- me.complementaryGljList = rstData.complementaryGljs;
|
|
|
- me.workBook.getSheet(0).setRowCount(me.stdGljList.length);
|
|
|
me.sortGlj(me.stdGljList);
|
|
|
me.setProp('isStd', true, me.stdGljList);
|
|
|
+ me.complementaryGljList = rstData.complementaryGljs;
|
|
|
me.sortGlj(me.complementaryGljList);
|
|
|
if(callback){
|
|
|
callback();
|
|
|
}
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ }, function () {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 获取标准人材机数据
|
|
|
+ getStdItems: function (stdGljLibId, callback) {
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ let me = this;
|
|
|
+ let projection = {
|
|
|
+ _id: 0,
|
|
|
+ ID: 1,
|
|
|
+ specs: 1,
|
|
|
+ gljType: 1,
|
|
|
+ shortName: 1,
|
|
|
+ gljClass: 1
|
|
|
+ };
|
|
|
+ CommonAjax.post('/complementartGlj/api/getStdItems', {stdGljLibId, projection}, function (data) {
|
|
|
+ me.pullCompleteData = true;
|
|
|
+ // 更新标准人材机数据
|
|
|
+ let IDMapping = {};
|
|
|
+ for (let glj of data) {
|
|
|
+ IDMapping[glj.ID] = glj;
|
|
|
+ }
|
|
|
+ for (let glj of me.stdGljList) {
|
|
|
+ Object.assign(glj, IDMapping[glj.ID]);
|
|
|
+ }
|
|
|
+ callback();
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ }, function () {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
});
|
|
|
},
|
|
|
showGljItems: function(data, type) {
|
|
|
@@ -283,32 +330,23 @@ let repositoryGljObj = {
|
|
|
},
|
|
|
|
|
|
getCurrentComponent: function (gljComponent) {
|
|
|
- let me = repositoryGljObj, rst = [];
|
|
|
- for(let i = 0; i < gljComponent.length; i++){
|
|
|
- let obj = {};
|
|
|
- for(let j = 0; j < me.complementaryGljList.length; j++){
|
|
|
- if(gljComponent[i].ID == me.complementaryGljList[j].ID){
|
|
|
- obj.isStd = false;
|
|
|
- obj.ID = me.complementaryGljList[j].ID;
|
|
|
- obj.code = me.complementaryGljList[j].code;
|
|
|
- obj.name = me.complementaryGljList[j].name;
|
|
|
- obj.unit = me.complementaryGljList[j].unit;
|
|
|
- obj.basePrice = me.complementaryGljList[j].basePrice;
|
|
|
- obj.consumeAmt = gljComponent[i].consumeAmt;
|
|
|
- rst.push(obj);
|
|
|
- }
|
|
|
- }
|
|
|
- for(let j = 0; j < me.stdGljList.length; j++){
|
|
|
- if(gljComponent[i].ID == me.stdGljList[j].ID){
|
|
|
- obj.isStd = true;
|
|
|
- obj.ID = me.stdGljList[j].ID;
|
|
|
- obj.code = me.stdGljList[j].code;
|
|
|
- obj.name = me.stdGljList[j].name;
|
|
|
- obj.unit = me.stdGljList[j].unit;
|
|
|
- obj.basePrice = me.stdGljList[j].basePrice;
|
|
|
- obj.consumeAmt = gljComponent[i].consumeAmt;
|
|
|
- rst.push(obj);
|
|
|
- }
|
|
|
+ let me = repositoryGljObj,
|
|
|
+ rst = [];
|
|
|
+ for(let thisGlj of gljComponent){
|
|
|
+ let toFindGljList = thisGlj.isStd
|
|
|
+ ? me.stdGljList
|
|
|
+ : me.complementaryGljList;
|
|
|
+ let matchGlj = toFindGljList.find(glj => glj.ID === thisGlj.ID);
|
|
|
+ if (matchGlj) {
|
|
|
+ rst.push({
|
|
|
+ isStd: thisGlj.isStd ? true : false,
|
|
|
+ ID: matchGlj.ID,
|
|
|
+ code: matchGlj.code,
|
|
|
+ name: matchGlj.name,
|
|
|
+ unit: matchGlj.unit,
|
|
|
+ basePrice: matchGlj.basePrice,
|
|
|
+ consumeAmt: thisGlj.consumeAmt
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
rst.sort(function (a, b) {
|