|
@@ -2,30 +2,83 @@
|
|
|
* Created by Tony on 2017/4/28.
|
|
|
*/
|
|
|
var rationGLJOprObj = {
|
|
|
- sheet: null,
|
|
|
+ workBook: null,
|
|
|
+ cache: {},
|
|
|
setting: {
|
|
|
header:[
|
|
|
- {headerName:"编码",headerWidth:160},
|
|
|
- {headerName:"名称",headerWidth:400},
|
|
|
- {headerName:"单位",headerWidth:160},
|
|
|
- {headerName:"单位基价",headerWidth:160, dataType: "Number", precision: 2},
|
|
|
- {headerName:"定额消耗",headerWidth:160, dataType: "Number", precision: 3},
|
|
|
- {headerName:"类型",headerWidth:160},
|
|
|
- {headerName:"操作",headerWidth:130}
|
|
|
+ {headerName:"编码",headerWidth:160,dataCode:"code", dataType: "String", formatter: "@"},
|
|
|
+ {headerName:"名称",headerWidth:400,dataCode:"name", dataType: "String"},
|
|
|
+ {headerName:"单位",headerWidth:160,dataCode:"unit", dataType: "String"},
|
|
|
+ {headerName:"单位基价",headerWidth:160, dataCode:"basePrice", dataType: "Number", precision: 2},
|
|
|
+ {headerName:"定额消耗",headerWidth:160, dataCode:"consumeAmt", dataType: "Number", precision: 3},
|
|
|
+ {headerName:"类型",headerWidth:160,dataCode:"gljDistType", dataType: "String"},
|
|
|
+ {headerName:"操作",headerWidth:130,dataCode:"code", dataType: "String"}
|
|
|
],
|
|
|
view:{
|
|
|
comboBox:[],
|
|
|
- lockedCells:[
|
|
|
- {row:-1,col:1,rowCount:-1, colCount:1},
|
|
|
- {row:-1,col:2,rowCount:-1, colCount:1},
|
|
|
- {row:-1,col:3,rowCount:-1, colCount:1},
|
|
|
- {row:-1,col:5,rowCount:-1, colCount:1},
|
|
|
- {row:-1,col:6,rowCount:-1, colCount:1}
|
|
|
- ]
|
|
|
+ lockColumns:[1,2,3,5,6]
|
|
|
}
|
|
|
},
|
|
|
buildSheet: function(container) {
|
|
|
var me = this;
|
|
|
- me.sheet = sheetCommonObj.buildSheet(container, me.setting, 30);
|
|
|
+ me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
|
|
|
+ },
|
|
|
+ createRationGljDisplayItem: function(rItem, repGlj) {
|
|
|
+ var rst = {};
|
|
|
+ rst.gljId = rItem.gljId;
|
|
|
+ rst.consumeAmt = rItem.consumeAmt;
|
|
|
+ rst.code = repGlj.code;
|
|
|
+ rst.name = repGlj.name;
|
|
|
+ rst.specs = repGlj.specs;
|
|
|
+ rst.unit = repGlj.unit;
|
|
|
+ rst.basePrice = repGlj.basePrice;
|
|
|
+ rst.gljDistType = repGlj.gljDistType;
|
|
|
+ return rst;
|
|
|
+ },
|
|
|
+ getGljItems: function(rationItem) {
|
|
|
+ var me = this, rationID = rationItem.ID, rationGljList = rationItem.rationGljList;
|
|
|
+ if (me.cache["_GLJ_" + rationID]) {
|
|
|
+ me.showGljItems(rationID);
|
|
|
+ sheetCommonObj.lockCells(me.workBook.getSheet(0), me.setting);
|
|
|
+ } else {
|
|
|
+ var gljIds = [];
|
|
|
+ for (var i = 0; i < rationGljList.length; i++) {
|
|
|
+ gljIds.push(rationGljList[i].gljId);
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ type:"POST",
|
|
|
+ url:"api/getGljItemsByIds",
|
|
|
+ data:{"gljIds": JSON.stringify(gljIds)},
|
|
|
+ dataType:"json",
|
|
|
+ cache:false,
|
|
|
+ timeout:5000,
|
|
|
+ success:function(result){
|
|
|
+ sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
|
|
|
+ if (result) {
|
|
|
+ var cacheArr = [];
|
|
|
+ for (var i = 0; i < result.data.length; i++) {
|
|
|
+ for (var j = 0; j < rationGljList.length; j++) {
|
|
|
+ if (rationGljList[j].gljId == result.data[i].ID) {
|
|
|
+ cacheArr.push(me.createRationGljDisplayItem(rationGljList[j], result.data[i]));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ me.cache["_GLJ_" + rationID] = cacheArr;
|
|
|
+ me.showGljItems(rationID);
|
|
|
+ }
|
|
|
+ sheetCommonObj.lockCells(me.workBook.getSheet(0), me.setting);
|
|
|
+ },
|
|
|
+ error:function(err){
|
|
|
+ alert(err);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ showGljItems: function(rationID) {
|
|
|
+ var me = this;
|
|
|
+ if (me.cache["_GLJ_" + rationID]) {
|
|
|
+ sheetCommonObj.showData(me.workBook.getSheet(0), me.setting, me.cache["_GLJ_" + rationID]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|