123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604 |
- /**
- * Created by Tony on 2017/4/28.
- */
- $("#gongliao").click(function(){
- $(this).attr('href', "/rationRepository/lmm" + "?repository=" + getQueryString("repository"))
- });
- $("#fuzhu").click(function(){
- $(this).attr('href', "/rationRepository/coeList" + "?repository=" + getQueryString("repository"))
- });
- var rationOprObj = {
- workBook: null,
- currentRations: {},
- currentEditingRation: null,
- currentSectionId: -1,
- activeCell: null,
- rationsCodes: [],
- setting: {
- header:[
- {headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@"},
- {headerName:"名称",headerWidth:280,dataCode:"name", dataType: "String"},
- {headerName:"单位",headerWidth:120,dataCode:"unit", dataType: "String", hAlign: "center"},
- {headerName:"人工费",headerWidth:120,dataCode:"labourPrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
- {headerName:"材料费",headerWidth:120,dataCode:"materialPrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
- {headerName:"机械费",headerWidth:120,dataCode:"machinePrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
- {headerName:"基价",headerWidth:120,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
- {headerName:"显示名称(以%s表示参数)",headerWidth:280,dataCode:"caption", dataType: "String"},
- {headerName:"取费专业",headerWidth:100,dataCode:"feeType", dataType: "Number", hAlign: "center"}
- ],
- view:{
- comboBox:[
- {row:-1,col:2,rowCount:-1,colCount:1}
- ],
- lockedCells:[
- {row:-1,col:3,rowCount:-1, colCount:1}
- ],
- lockColumns: [
- 3, 4, 5, 6
- ]
- }
- },
- buildSheet: function(container) {
- let rationRepId = getQueryString("repository");
- var me = rationOprObj;
- let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationRepId);
- if(!gljLibID || typeof gljLibID === 'undefined' || gljLibID == -1){
- alert("没有引用工料机库!");
- window.location.href = "/rationRepository/main";
- }
- me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
- me.getRationsCodes(rationRepId);
- me.rationDelOpr();
- me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
- me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
- me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
- me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
- me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
- //me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
- me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.CellClick, me.onCellClick);
- },
- onCellClick: function(sender, args) {
- var me = rationOprObj,
- sheetGLJ = rationGLJOprObj.sheet, settingGLJ = rationGLJOprObj.setting,
- sheetCoe = rationCoeOprObj.sheet, settingCoe = rationCoeOprObj.setting,
- sheetAss = rationAssistOprObj.sheet, settingAss = rationAssistOprObj.setting;
- me.activeCell = {row: args.row, col: args.col};
- sheetCommonObj.cleanSheet(sheetGLJ, settingGLJ, -1);
- sheetCommonObj.shieldAllCells(sheetGLJ);
- sheetCommonObj.cleanSheet(sheetCoe, settingCoe, -1);
- sheetCommonObj.shieldAllCells(sheetCoe);
- sheetCommonObj.cleanSheet(sheetAss, settingAss, -1);
- sheetCommonObj.shieldAllCells(sheetAss);
- if(!(args.sheetArea === GC.Spread.Sheets.SheetArea.colHeader || args.sheetArea === GC.Spread.Sheets.SheetArea.corner)){
- var cacheSection = me.getCache();
- if (cacheSection && args.row < cacheSection.length) {
- rationGLJOprObj.getGljItems(cacheSection[args.row], function () {
- me.workBook.focus(true);
- });
- rationCoeOprObj.getCoeItems(cacheSection[args.row], function () {
- me.workBook.focus(true);
- });
- rationAssistOprObj.getAssItems(cacheSection[args.row]);
- }
- };
- me.workBook.focus(true);
- },
- getCache: function() {
- var me = this, rst = me.currentRations["_SEC_ID_" + me.currentSectionId];
- if (!(rst)) {
- me.currentRations["_SEC_ID_" + me.currentSectionId] = [];
- rst = me.currentRations["_SEC_ID_" + me.currentSectionId];
- }
- return rst;
- },
- updateCache: function(addArr, updateArr, removeIds, result) {
- var me = this, cacheSection = me.getCache();
- if (addArr.length > 0) {
- me.currentRations["_SEC_ID_" + me.currentSectionId] = cacheSection.concat(addArr);
- cacheSection = me.currentRations["_SEC_ID_" + me.currentSectionId];
- }
- for (var i = removeIds.length - 1; i >= 0; i--) {
- for (var j = cacheSection.length - 1; j >= 0 ; j--) {
- if (cacheSection[j]["ID"] == removeIds[i]) {
- cacheSection.splice(j,1);
- }
- }
- }
- if (result && result.data.ops && result.data.ops.length > 0) {
- for (var i = 0; i < result.data.ops.length; i++) {
- for (var j = 0; j < cacheSection.length; j++) {
- if (cacheSection[j][me.setting.header[0].dataCode] == result.data.ops[i][me.setting.header[0].dataCode]) {
- cacheSection[j]["ID"] = result.data.ops[i]["ID"];
- cacheSection[j]["rationGljList"] = result.data.ops[i]["rationGljList"];
- }
- }
- }
- }
- for (var i = 0; i < updateArr.length; i++) {
- for (var j = 0; j < cacheSection.length; j++) {
- if (updateArr[i]["ID"] && cacheSection[j]["ID"]) {
- if (cacheSection[j]["ID"] == updateArr[i]["ID"]) {
- cacheSection[j] = updateArr[i];
- }
- } else {
- if (cacheSection[j][me.setting.header[0].dataCode] == updateArr[i][me.setting.header[0].dataCode]) {
- cacheSection[j] = updateArr[i];
- }
- }
- }
- }
- return cacheSection;
- },
- rationDelOpr: function () {
- let me = rationOprObj;
- me.workBook.commandManager().register('rationDelete', function () {
- let rationSheet = me.workBook.getActiveSheet();
- let sels = rationSheet.getSelections(), updateArr = [], removeArr = [], lockCols = me.setting.view.lockColumns;
- let cacheSection = me.getCache();
- if(sels.length > 0){
- for(let sel = 0; sel < sels.length; sel++){
- if(sels[sel].colCount === me.setting.header.length){
- if(cacheSection){
- for(let i = 0; i < sels[sel].rowCount; i++){
- if(sels[sel].row + i < cacheSection.length){
- removeArr.push(cacheSection[sels[sel].row + i].ID);
- me.rationsCodes.splice(me.rationsCodes.indexOf(cacheSection[sels[sel].row + i].code), 1);
- }
- }
- }
- }
- else{
- if(sels[sel].col === 0){
- $('#alertText').text("编号不能为空,修改失败!");
- $('#alertModalBtn').click();
- rationSheet.options.isProtected = true;
- $('#alertModalCls').click(function () {
- rationSheet.options.isProtected = false;
- });
- $('#alertModalCof').click(function () {
- rationSheet.options.isProtected = false;
- })
- }
- else if(sels[sel].col !== 0 && !(sels[sel].col === 3 && sels.col + sels[sel].colCount -1 === 6)){
- if(cacheSection){
- for(let i = sels[sel].row === -1 ? 1 : 0; i < sels[sel].rowCount; i++){
- if(sels[sel].row + i < cacheSection.length){
- for(let col = sels[sel].col; col <= sels[sel].col + sels[sel].colCount - 1; col++){
- if(lockCols.indexOf(col) === -1){
- cacheSection[sels[sel].row + i][me.setting.header[col].dataCode] = '';
- }
- }
- }
- if(cacheSection[sels[sel].row + i] && typeof cacheSection[sels[sel].row + i] !== 'undefined'){
- updateArr.push(cacheSection[sels[sel].row + i]);
- }
- }
- }
- }
- }
- }
- }
- if(updateArr.length > 0 || removeArr.length > 0){
- me.mixUpdate = 1;
- me.mixUpdateRequest(updateArr, [], removeArr);
- }
- });
- me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
- me.workBook.commandManager().setShortcutKey('rationDelete', GC.Spread.Commands.Key.del, false, false, false, false);
- },
- onRangeChanged: function(sender, args) {
- if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
- var me = rationOprObj, updateArr = [], removeArr = [];
- var cacheSection = me.getCache();
- if (cacheSection) {
- for (var i = 0; i < args.rowCount; i++) {
- //var hasUpdate = false, rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row + i),
- var hasUpdate = false, rObj = sheetCommonObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row + i),
- isEmpty = sheetCommonObj.chkIfEmpty(rObj, me.setting);
- for (var j = 0; j < cacheSection.length; j++) {
- if (cacheSection[j][me.setting.header[0].dataCode] == rObj[me.setting.header[0].dataCode]) {
- rObj["ID"] = cacheSection[j]["ID"];
- hasUpdate = true;
- break;
- }
- }
- if(isEmpty){
- if(args.row + i < cacheSection.length){
- rObj.ID = cacheSection[args.row + i].ID;
- removeArr.push(rObj.ID);
- }
- }
- else{
- }
- if (hasUpdate) {
- if (isEmpty) {
- removeArr.push(rObj);
- } else updateArr.push(rObj);
- } else if (isEmpty) {
- if (args.row + i < cacheSection.length) {
- rObj["ID"] = cacheSection[args.row + i]["ID"];
- removeArr.push(rObj["ID"]);
- }
- }
- }
- // me.mixUpdateRequest(updateArr, [], removeArr);
- //removeRationItems
- }
- }
- },
- onEnterCell: function (sender, args) {
- let me = rationOprObj;
- me.cellRowIdx = args.row;
- let isHasData = false;
- if(me.addRationItem){
- for(let i=0; i<me.setting.header.length; i++){
- if(me.addRationItem[me.setting.header[i].dataCode]){
- isHasData = true;
- break;
- }
- }
- }
- if(isHasData){
- if(me.editingRowIdx !== me.cellRowIdx) {
- let focusToCol = !me.addRationItem.code ? 0 : -1;
- // else {
- if(focusToCol !== -1){
- $('#rationAlertBtn').click();
- me.workBook.getSheet(0).options.isProtected = true;
- $('#rationAlertCac').click(function () {
- me.workBook.getSheet(0).options.isProtected = false;
- //me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
- });
- $('#rationAlertCls').click(function () {
- me.workBook.getSheet(0).options.isProtected = false;
- // me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
- });
- $('#rationAlertCof').click(function () {
- me.workBook.getSheet(0).options.isProtected = false;
- me.addRationItem = null;
- for(let col=0; col<me.setting.header.length; col++){
- me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value(me.currentEditingRation[me.setting.header[col].dataCode]);
- }
- //me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, 0);
- });
- }
- // }
- }
- }
- },
- onCellEditStart: function(sender, args) {
- var me = rationOprObj;
- //var rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row);
- var rObj = sheetCommonObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row);
- me.currentEditingRation = rObj;
- var cacheSection = me.getCache();
- if (cacheSection) {
- for (var j = 0; j < cacheSection.length; j++) {
- if (cacheSection[j][me.setting.header[0].dataCode] == rObj[me.setting.header[0].dataCode]) {
- rObj["ID"] = cacheSection[j]["ID"];
- break;
- }
- }
- }
- },
- onCellEditEnd: function(sender, args) {
- //var me = rationOprObj, rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row),
- var me = rationOprObj, rObj = sheetCommonObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row),
- updateArr = [], addArr = [];
- let dataCode = me.setting.header[args.col].dataCode;
- me.editingRowIdx = args.row;
- if (me.currentEditingRation["ID"]) {
- rObj["ID"] = me.currentEditingRation["ID"];
- if(me.currentEditingRation[dataCode] !== rObj[dataCode]){
- me.addRationItem = rObj;
- if(dataCode === 'code'){
- if(me.rationsCodes.indexOf(rObj.code) === -1){
- me.rationsCodes.splice(me.rationsCodes.indexOf(rObj.code), 1);
- me.rationsCodes.push(rObj.code);
- updateArr.push(rObj);
- }
- else{
- alert("编码已存在!");
- args.sheet.setValue(args.row, args.col, me.currentEditingRation[dataCode]);
- }
- }
- else{
- updateArr.push(rObj);
- }
- }
- }
- else if(!me.currentEditingRation["ID"]) {
- if (!sheetCommonObj.chkIfEmpty(rObj, me.setting)) {
- //addArr.push(rObj);
- me.addRationItem = rObj;
- if(rObj.code && rObj.code.toString().trim().length > 0){
- if(me.rationsCodes.indexOf(rObj.code) === -1){
- //jobContent
- if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
- rObj.jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';
- }
- addArr.push(rObj);
- me.rationsCodes.push(rObj.code);
- me.addRationItem = null;
- }
- else{
- alert('编码已存在!');
- me.workBook.getSheet(0).setValue(args.row, args.col, '');
- }
- /*else if(!rObj.code && rObj.code === ''){
- $('#alertModalBtn').click();
- me.workBook.getSheet(0).options.isProtected = true;
- $('#alertModalCls').click(function () {
- me.workBook.getSheet(0).options.isProtected = false;
- me.addRationItem.code = '';
- me.workBook.getSheet(0).setValue(args.row, args.col, '');
- me.workBook.getSheet(0).setActiveCell(args.row, args.col);
- });
- $('#alertModalCof').click(function () {
- me.workBook.getSheet(0).options.isProtected = false;
- me.addRationItem.code = '';
- me.workBook.getSheet(0).setValue(args.row, args.col, '');
- me.workBook.getSheet(0).setActiveCell(args.row, args.col);
- });
- }*/
- }
- else if(rObj.code && rObj.code.toString.trim().length === 0){
- me.workBook.getSheet(0).setValue(args.row, args.col, '');
- }
- }
- }
- if (updateArr.length > 0 || addArr.length > 0) {
- me.currentEditingRation = null;
- me.mixUpdate = 1;
- me.mixUpdateRequest(updateArr, addArr, []);
- }
- },
- onClipboardPasting: function(sender, args) {
- var me = rationOprObj;
- /* if (args.cellRange.colCount != me.setting.header.length) {
- args.cancel = true;
- }*/
- },
- onClipboardPasted: function(e, info) {
- var me = rationOprObj;
- var cacheSection = me.getCache();
- var updateArr = [], addArr = [];
- var items = sheetCommonObj.analyzePasteData(me.setting, info);
- let failPasteArr = [];
- for (var i = 0, rowIdx =info.cellRange.row; i < items.length; i++, rowIdx++) {
- if (cacheSection) {
- if(!me.isValidUnit(items[i], rationUnits)){//无效单位
- items[i].unit = typeof cacheSection[rowIdx].unit !== 'undefined' && !cacheSection[rowIdx] ? cacheSection[rowIdx].unit : '';
- }
- //var hasCacheItem = false;
- if(!cacheSection[rowIdx] && info.cellRange.col === 0 ){
- if(me.rationsCodes.indexOf(items[i].code) === -1){
- //jobConten
- if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
- items[i].jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';
- }
- addArr.push(items[i]);
- me.rationsCodes.push(items[i].code);
- }
- else{
- failPasteArr.push(items[i].code);
- me.workBook.getSheet(0).setValue(rowIdx, 0, '');
- }
- }
- else if(cacheSection[rowIdx]){
- for(let col = 0; col < me.setting.header.length; col++){
- if(!items[i][me.setting.header[col].dataCode] && typeof cacheSection[rowIdx][me.setting.header[col].dataCode] !== 'undefined'){
- items[i][me.setting.header[col].dataCode] = cacheSection[rowIdx][me.setting.header[col].dataCode];
- }
- }
- if(info.cellRange.col === 0){
- if(me.rationsCodes.indexOf(items[i].code) === -1){
- items[i].ID = cacheSection[rowIdx].ID;
- updateArr.push(items[i]);
- }
- else{
- me.workBook.getSheet(0).setValue(rowIdx, 0, cacheSection[rowIdx].code);
- }
- }
- else{
- items[i].ID = cacheSection[rowIdx].ID;
- updateArr.push(items[i]);
- }
- }
- } else {
- if(!me.isValidUnit(items[i], rationUnits)){//无效单位
- items[i].unit = '';
- }
- //add
- if(info.cellRange.col === 0){
- //是否含有已存在的编号
- if(me.rationsCodes.indexOf(items[i].code) === -1){
- //jobConten
- if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
- items[i].jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';
- }
- addArr.push(items[i]);
- }
- else{
- failPasteArr.push(items[i]);
- }
- }
- }
- };
- /* if(failPasteArr.length > 0 && !(updateArr.length > 0 || addArr.length > 0)){
- me.showRationItems(me.currentSectionId);
- }*/
- if (updateArr.length > 0 || addArr.length > 0) {
- me.mixUpdate = 1;
- me.mixUpdateRequest(updateArr, addArr, []);
- }
- },
- isValidUnit: function (rationObj, validUnits) {
- let rst = true;
- if(typeof rationObj.unit !== 'undefined' && rationObj.unit && validUnits.indexOf(rationObj.unit) === -1){//无效
- rst = false;
- }
- return rst;
- },
- getRationsCodes: function (repId) {
- let me = rationOprObj;
- $.ajax({
- type: 'post',
- url: 'api/getRationsCodes',
- data: {data: JSON.stringify({repId: repId})},
- dataType: 'json',
- success: function (result) {
- if(!result.error){
- me.rationsCodes = result.data;
- }
- }
- })
- },
- mixUpdateRequest: function(updateArr, addArr, removeIds) {
- var me = rationOprObj;
- sheetCommonObj.setLockCol(me.workBook.getSheet(0), 0, true);
- $.ajax({
- type:"POST",
- url:"api/mixUpdateRationItems",
- data:{"rationLibId": getQueryString("repository"), "lastOpr": userAccount, "sectionID": me.currentSectionId, "updateItems": JSON.stringify(updateArr), "addItems": JSON.stringify(addArr), "removeIds": JSON.stringify(removeIds)},
- dataType:"json",
- cache:false,
- timeout:5000,
- success:function(result){
- if (result.error) {
- alert(`error`);
- me.getRationItems(me.currentSectionId);
- } else {
- var cacheSection = me.updateCache(addArr, updateArr, removeIds, result);
- cacheSection.sort(function(a, b){
- var rst = 0;
- if (a.code > b.code) rst = 1
- else if (a.code < b.code) rst = -1;
- return rst;
- });
- //jobContent
- if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.PARTIAL){
- jobContentOprObj.currentRationItems = cacheSection;
- jobContentOprObj.buildTablePartial(jobContentOprObj.tablePartial, jobContentOprObj.getGroup(cacheSection));
- }
- me.showRationItems(me.currentSectionId);
- me.mixUpdate = 0;
- // me.workBook.getSheet(0).setActiveCell(me.activeCell.row, me.activeCell.col);
- }
- sheetCommonObj.setLockCol(me.workBook.getSheet(0), 0, false);
- },
- error:function(){
- }
- });
- },
- getRationItems: function(sectionID){
- if (sectionID != -1) {
- var me = rationOprObj;
- me.mixUpdate = 0;
- me.currentSectionId = sectionID;
- if (me.currentRations["_SEC_ID_" + sectionID]) {
- //jobContent--
- jobContentOprObj.currentRationItems = me.currentRations["_SEC_ID_" + sectionID];
- jobContentOprObj.rationJobContentOpr(me.currentRations["_SEC_ID_" + sectionID]);
- //jobContent--
- me.showRationItems(sectionID);
- ///sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
- sheetCommonObj.lockCells(rationGLJOprObj.sheet, rationGLJOprObj.setting);
- sheetCommonObj.lockCells(rationCoeOprObj.sheet, rationCoeOprObj.setting);
- sheetCommonObj.lockCells(me.workBook.getSheet(0), rationOprObj.setting);
- sheetCommonObj.unShieldAllCells(rationAssistOprObj.sheet);
- } else {
- $.ajax({
- type:"POST",
- url:"api/getRationItems",
- data:{"sectionID": sectionID},
- dataType:"json",
- cache:false,
- timeout:1000,
- success:function(result){
- if (result) {
- me.currentRations["_SEC_ID_" + sectionID] = result.data;
- me.sortByCode(me.currentRations["_SEC_ID_" + sectionID]);
- //job--
- jobContentOprObj.currentRationItems = me.currentRations["_SEC_ID_" + sectionID];
- jobContentOprObj.rationJobContentOpr(me.currentRations["_SEC_ID_" + sectionID]);
- //job--
- me.showRationItems(sectionID);
- //sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
- sheetCommonObj.lockCells(me.workBook.getSheet(0), rationOprObj.setting);
- sheetCommonObj.lockCells(rationGLJOprObj.sheet, rationGLJOprObj.setting);
- sheetCommonObj.lockCells(rationCoeOprObj.sheet, rationCoeOprObj.setting);
- sheetCommonObj.unShieldAllCells(rationAssistOprObj.sheet);
- } else {
- sheetCommonObj.shieldAllCells(me.workBook.getSheet(0));
- sheetCommonObj.shieldAllCells(rationGLJOprObj.sheet);
- sheetCommonObj.shieldAllCells(rationCoeOprObj.sheet);
- sheetCommonObj.shieldAllCells(rationAssistOprObj.sheet);
- }
- },
- error:function(err){
- alert(err);
- }
- })
- }
- }
- },
- setCombo: function (sheet, items) {
- sheet.suspendPaint();
- for(let i = 0, len = sheet.getRowCount(); i < len; i++){
- let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
- combo.items(items);
- combo.itemHeight(10);
- sheet.getCell(i, 2).cellType(combo);
- }
- sheet.resumePaint();
- },
- showRationItems: function(sectionID){
- 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.cleanData(me.workBook.getSheet(0), me.setting, -1);
- sheetCommonObj.showData(me.workBook.getSheet(0), me.setting, cacheSection);
- sheetCommonObj.setLockCol(me.workBook.getSheet(0), 4, true);
- //combo
- me.setCombo(me.workBook.getActiveSheet(), rationUnits);
- if(me.mixUpdate === 1){
- rationGLJOprObj.getGljItems(cacheSection[cacheSection.length - 1], function () {
- me.workBook.focus(true);
- });
- }
- } else {
- //清除ration数据及工料机数据
- sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
- }
- }
- },
- sortByCode: function(arr){
- function compare(){
- return function (a, b) {
- let rst = 0;
- if (a.code > b.code) {
- rst = 1;
- }
- else if (a.code < b.code) {
- rst = -1;
- }
- return rst;
- }
- }
- arr.sort(compare());
- }
- }
|