|
@@ -15,12 +15,12 @@ var rationOprObj = {
|
|
|
currentSectionId: -1,
|
|
|
setting: {
|
|
|
header:[
|
|
|
- {headerName:"编码",headerWidth:120,data:"code"},
|
|
|
- {headerName:"名称",headerWidth:300,data:"name"},
|
|
|
- {headerName:"单位",headerWidth:120,data:"unit"},
|
|
|
- {headerName:"基价",headerWidth:120,data:"basePrice"},
|
|
|
- {headerName:"显示名称(以%s表示参数)",headerWidth:350,data:"caption"},
|
|
|
- {headerName:"取费专业",headerWidth:120,data:"feeType"}
|
|
|
+ {headerName:"编码",headerWidth:120,dataCode:"code"},
|
|
|
+ {headerName:"名称",headerWidth:300,dataCode:"name"},
|
|
|
+ {headerName:"单位",headerWidth:120,dataCode:"unit"},
|
|
|
+ {headerName:"基价",headerWidth:120,dataCode:"basePrice"},
|
|
|
+ {headerName:"显示名称(以%s表示参数)",headerWidth:350,dataCode:"caption"},
|
|
|
+ {headerName:"取费专业",headerWidth:120,dataCode:"feeType"}
|
|
|
],
|
|
|
view:{
|
|
|
comboBox:[
|
|
@@ -33,7 +33,7 @@ var rationOprObj = {
|
|
|
},
|
|
|
buildSheet: function(container) {
|
|
|
var me = this;
|
|
|
- me.workBook = sheetCommonObj.buildSheet(container, me.setting);
|
|
|
+ me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
|
|
|
me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
|
me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
|
|
|
},
|
|
@@ -58,11 +58,16 @@ var rationOprObj = {
|
|
|
itemObj = {};
|
|
|
}
|
|
|
} else if (info.pasteData.text[i] === "\t" || info.pasteData.text[i] === "\r") {
|
|
|
- itemObj[me.setting.header[propId].data] = info.pasteData.text.slice(preStrIdx, i);
|
|
|
+ itemObj[me.setting.header[propId].dataCode] = info.pasteData.text.slice(preStrIdx, i);
|
|
|
propId++;
|
|
|
preStrIdx = i + 1;
|
|
|
+ //if the last copied-cell were empty, should check whether the end of text
|
|
|
+ if (i == info.pasteData.text.length - 1) {
|
|
|
+ itemObj[me.setting.header[propId].dataCode] = info.pasteData.text.slice(preStrIdx);
|
|
|
+ rst.push(itemObj);
|
|
|
+ }
|
|
|
} else if (i == info.pasteData.text.length - 1) {
|
|
|
- itemObj[me.setting.header[propId].data] = info.pasteData.text.slice(preStrIdx);
|
|
|
+ itemObj[me.setting.header[propId].dataCode] = info.pasteData.text.slice(preStrIdx);
|
|
|
rst.push(itemObj);
|
|
|
}
|
|
|
}
|
|
@@ -73,17 +78,56 @@ var rationOprObj = {
|
|
|
if (cacheSection) {
|
|
|
var hasCacheItem = false;
|
|
|
for (var j = 0; j < cacheSection.length; j++) {
|
|
|
- if (cacheSection[j][me.setting.header[0].data] == items[i][me.setting.header[0].data]) {
|
|
|
+ if (cacheSection[j][me.setting.header[0].dataCode] == items[i][me.setting.header[0].dataCode]) {
|
|
|
hasCacheItem = true;
|
|
|
+ items[i]["ID"] = cacheSection[j]["ID"];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (hasCacheItem) addArr.push(items[i])
|
|
|
- else updateArr.push(items[i])
|
|
|
+ if (!hasCacheItem) {
|
|
|
+ addArr.push(items[i]);
|
|
|
+ } else {
|
|
|
+ updateArr.push(items[i]);
|
|
|
+ }
|
|
|
} else {
|
|
|
addArr.push(items[i])
|
|
|
}
|
|
|
};
|
|
|
+ if (updateArr.length > 0 || addArr.length > 0) {
|
|
|
+ $.ajax({
|
|
|
+ type:"POST",
|
|
|
+ url:"api/mixUpdateRationItems",
|
|
|
+ data:{"sectionID": me.currentSectionId, "updateItems": JSON.stringify(updateArr), "addItems": JSON.stringify(addArr)},
|
|
|
+ dataType:"json",
|
|
|
+ cache:false,
|
|
|
+ timeout:5000,
|
|
|
+ success:function(result){
|
|
|
+ if (result.err) {
|
|
|
+ alert(err);
|
|
|
+ me.getRationItems(me.currentSectionId);
|
|
|
+ } else {
|
|
|
+ if (!(me.currentRations["_SEC_ID_" + me.currentSectionId])) {
|
|
|
+ me.currentRations["_SEC_ID_" + me.currentSectionId] = [];
|
|
|
+ cacheSection = me.currentRations["_SEC_ID_" + me.currentSectionId];
|
|
|
+ }
|
|
|
+ if (addArr.length > 0) {
|
|
|
+ me.currentRations["_SEC_ID_" + me.currentSectionId] = cacheSection.concat(addArr);
|
|
|
+ cacheSection = me.currentRations["_SEC_ID_" + me.currentSectionId];
|
|
|
+ }
|
|
|
+ for (var i = 0; i < updateArr.length; i++) {
|
|
|
+ for (var j = 0; j < cacheSection.length; j++) {
|
|
|
+ if (cacheSection[j][me.setting.header[0].dataCode] == updateArr[i][me.setting.header[0].dataCode]) {
|
|
|
+ cacheSection[j] = updateArr[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ me.showRationItems(me.currentSectionId);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error:function(){
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
getRationItems: function(sectionID){
|
|
|
if (sectionID != -1) {
|
|
@@ -106,7 +150,8 @@ var rationOprObj = {
|
|
|
}
|
|
|
|
|
|
},
|
|
|
- error:function(){
|
|
|
+ error:function(err){
|
|
|
+ alert(err);
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -116,10 +161,12 @@ var rationOprObj = {
|
|
|
var me = rationOprObj;
|
|
|
if (me.workBook) {
|
|
|
if (me.currentRations && me.currentRations["_SEC_ID_" + sectionID] && me.currentRations["_SEC_ID_" + sectionID].length > 0) {
|
|
|
- //
|
|
|
+ var cacheSection = me.currentRations["_SEC_ID_" + sectionID];
|
|
|
+ sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
|
|
|
+ sheetCommonObj.showData(me.workBook.getSheet(0), me.setting, cacheSection);
|
|
|
} else {
|
|
|
//清除ration数据及工料机数据
|
|
|
- sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, 3);
|
|
|
+ sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
|
|
|
}
|
|
|
}
|
|
|
}
|