| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 | 
							- /**
 
-  * Created by CSL on 2017-05-18.
 
-  */
 
- //modiyied by zhong on 2017/9/21
 
- var pageObj = {
 
-     libID: null,
 
-     gljLibID: null,
 
-     initPage: function (){
 
-         $("#drirect-dinge").click(function(){
 
-             $(this).attr('href', "/complementaryRation/ration" + "?repository=" + getQueryString("repository"))
 
-         });
 
-         $("#gongliao").click(function(){
 
-             $(this).attr('href', "/complementaryRation/glj" + "?repository=" + getQueryString("repository"))
 
-         });
 
-         var libID = getQueryString("repository");
 
-         var libName = storageUtil.getSessionCache("RationGrp","repositoryID_" + libID);
 
-         if (libName) {
 
-             var html = $("#rationname")[0].outerHTML;
 
-             html = html.replace("XXX定额库", libName);
 
-             $("#rationname")[0].outerHTML = html;
 
-         };
 
-         this.gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + libID);
 
-         this.libID = libID;
 
-         coeOprObj.buildSheet($('#mainSpread')[0]);
 
-         gljAdjOprObj.buildSheet($('#contentSpread')[0]);
 
-         coeOprObj.getCoeList();
 
-         gljAdjOprObj.getGljItemsOcc();
 
-     },
 
-     showData: function(sheet, setting, data) {
 
-         let me = pageObj, ch = GC.Spread.Sheets.SheetArea.viewport;
 
-         sheet.suspendPaint();
 
-         sheet.suspendEvent();
 
-         sheet.clear(0, 0, sheet.getRowCount(), sheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
 
-         sheet.setRowCount(data.length + 3);
 
-         for (let col = 0; col < setting.header.length; col++) {
 
-             var hAlign = "left", vAlign = "center";
 
-             if (setting.header[col].hAlign) {
 
-                 hAlign = setting.header[col].hAlign;
 
-             } else if (setting.header[col].dataType !== "String"){
 
-                 hAlign = "right";
 
-             }
 
-             if(setting.header[col].readOnly){
 
-                 sheet.getRange(-1, col, -1, 1).locked(true);
 
-             }
 
-             else{
 
-                 sheet.getRange(-1, col, -1, 1).locked(false);
 
-             }
 
-             vAlign = setting.header[col].vAlign?setting.header[col].vAlign:vAlign;
 
-             sheetCommonObj.setAreaAlign(sheet.getRange(-1, col, -1, 1), hAlign, vAlign);
 
-             if (setting.header[col].formatter) {
 
-                 sheet.setFormatter(-1, col, setting.header[col].formatter, GC.Spread.Sheets.SheetArea.viewport);
 
-             }
 
-             for (let row = 0; row < data.length; row++) {
 
-                 let val = data[row][setting.header[col].dataCode];
 
-                 sheet.setValue(row, col, val, ch);
 
-             }
 
-         }
 
-         sheet.resumeEvent();
 
-         sheet.resumePaint();
 
-     }
 
- };
 
- let coeOprObj = {
 
-     workBook: null,
 
-     workSheet: null,
 
-     currentCoeList: [],
 
-     currentCoe: null,
 
-     currentMaxNo: null,
 
-     setting: {
 
-         header: [
 
-             {headerName:"编号", headerWidth:60, dataCode:"serialNo", dataType: "String", hAlign: "center", vAlign: "center", readOnly: false},
 
-             {headerName:"名称", headerWidth:280, dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center", readOnly: false},
 
-             {headerName:"内容", headerWidth:250, dataCode:"content", dataType: "String", hAlign: "left", vAlign: "center", readOnly: false},
 
-         ]
 
-     },
 
-     buildSheet: function (container) {
 
-         let me = coeOprObj;
 
-         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
 
-         me.workSheet = me.workBook.getSheet(0);
 
-         me.workSheet.options.isProtected = true;
 
-         me.workSheet.bind(GC.Spread.Sheets.Events.SelectionChanged, me.onSelectionChanged);
 
-         me.workSheet.bind(GC.Spread.Sheets.Events.EditStarting, me.onEditStarting);
 
-         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
 
-     },
 
-     onSelectionChanged: function (sender, info) {
 
-         let me = coeOprObj, that = gljAdjOprObj;
 
-         if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
 
-             let row = info.newSelections[0].row;
 
-             if(row < me.currentCoeList.length){
 
-                 me.currentCoe = me.currentCoeList[row];
 
-                 that.currentGljAdjList = me.currentCoe.coes;
 
-                 that.buildDynamicComboBox(that.workSheet);
 
-             }
 
-             else{
 
-                 me.currentCoe = null;
 
-                 that.currentGljAdjList = [];
 
-                 that.buildBaseCell(that.workSheet);
 
-             }
 
-             //refresh & show coes
 
-             sheetCommonObj.cleanSheet(that.workSheet, that.setting, -1);
 
-             me.workBook.focus(true);
 
-             that.show(that.currentGljAdjList);
 
-         }
 
-     },
 
-     onEditStarting: function (sender, args) {
 
-         args.cancel = true;
 
-     },
 
-     onClipboardPasting: function (sender, info) {
 
-         info.cancel = true;
 
-     },
 
-     isInt: function (num) {
 
-         return !isNaN(num) && num % 1 === 0;
 
-     },
 
-     sortCoeList: function (coeList) {
 
-         coeList.sort(function (a, b) {
 
-             let rst = 0;
 
-             if(a.serialNo > b.serialNo) rst = 1;
 
-             else if(a.serialNo < b.serialNo) rst = -1;
 
-             return rst;
 
-         });
 
-     },
 
-     getCoeList: function () {
 
-         let me = coeOprObj;
 
-         CommonAjax.post('api/getCoeList', {libID: pageObj.libID}, function (rstData) {
 
-             me.currentCoeList = rstData;
 
-             me.sortCoeList(me.currentCoeList);
 
-             me.currentMaxNo =  me.currentCoeList.length > 0 ? me.currentCoeList[me.currentCoeList.length - 1].serialNo : 0;
 
-             pageObj.showData(me.workSheet, me.setting, me.currentCoeList);
 
-             me.workSheet.clearSelection();
 
-         });
 
-     }
 
- };
 
- let gljAdjOprObj = {
 
-     workBook: null,
 
-     workSheet: null,
 
-     currentGljAdjList: [],
 
-     gljList: [],//只含编号和名称的总工料机列表
 
-     setting: {
 
-         header: [
 
-             {headerName:"调整类型", headerWidth:100, dataCode:"coeType", dataType: "String", hAlign: "center", vAlign: "center", readOnly: false},
 
-             {headerName:"工料机编码", headerWidth:100, dataCode:"gljCode", dataType: "String", formatter: '@', hAlign: "center", vAlign: "center", readOnly: false},
 
-             {headerName:"名称", headerWidth:100, dataCode:"gljName", dataType: "String", hAlign: "center", vAlign: "center", readOnly: true},
 
-             {headerName:"操作符", headerWidth:60, dataCode:"operator", dataType: "String", hAlign: "center", vAlign: "center", readOnly: false},
 
-             {headerName:"数量", headerWidth:80, dataCode:"amount", dataType: "String", hAlign: "center", vAlign: "center" , readOnly: false},
 
-         ],
 
-         comboItems: {
 
-             //调整类型下拉菜单
 
-             coeType: ['定额子目', '人工类', '材料类', '机械类', '主材类', '设备类', '单个工料机'],
 
-             //操作符下拉菜单
 
-             operator: ['+', '-', '*', '/', '=']
 
-         }
 
-     },
 
-     buildSheet: function (container) {
 
-         let me = gljAdjOprObj;
 
-         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 3);
 
-         me.workSheet = me.workBook.getSheet(0);
 
-         me.workSheet.options.isProtected = true;
 
-         me.workSheet.clearSelection();
 
-         me.workSheet.bind(GC.Spread.Sheets.Events.EditStarting, me.onEditStart);
 
-         me.workSheet.bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
 
-         me.workSheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
 
-     },
 
-     buildBaseCell: function (sheet) {
 
-         let me = gljAdjOprObj;
 
-         sheet.suspendPaint();
 
-         sheet.suspendEvent();
 
-         let baseCell = GC.Spread.Sheets.CellTypes.Base();
 
-         sheet.getCell(-1, 0).cellType(baseCell);
 
-         sheet.getCell(-1, 3).cellType(baseCell);
 
-         sheet.resumePaint();
 
-         sheet.resumeEvent();
 
-     },
 
-     buildDynamicComboBox: function (sheet) {
 
-         let me = gljAdjOprObj;
 
-         sheet.suspendPaint();
 
-         sheet.suspendEvent();
 
-         let dynamicCombo = sheetCommonObj.getDynamicCombo();
 
-         dynamicCombo.items(me.setting.comboItems.coeType);
 
-         let dynamicOprCombo = sheetCommonObj.getDynamicCombo();
 
-         dynamicOprCombo.items(me.setting.comboItems.operator);
 
-         sheet.getCell(-1, 0).cellType(dynamicCombo);
 
-         sheet.getCell(-1, 3).cellType(dynamicOprCombo);
 
-         sheet.resumePaint();
 
-         sheet.resumeEvent();
 
-     },
 
-     onEnterCell: function (sender, args) {
 
-         args.sheet.repaint();
 
-     },
 
-     onEditStart: function (sender, args) {
 
-         let me = gljAdjOprObj;
 
-         args.cancel = true;
 
-     },
 
-     onClipboardPasting: function (sender, info) {
 
-         info.cancel = true;
 
-     },
 
-     show: function (coes) {
 
-         let me = gljAdjOprObj;
 
-         pageObj.showData(me.workSheet, me.setting, coes)
 
-     },
 
-     getGljItemsOcc: function () {
 
-         let me = gljAdjOprObj;
 
-         CommonAjax.post('api/getGljItemsOccupied', {gljLibId: pageObj.gljLibID, occupation: '-_id code name'}, function (rstData) {
 
-             me.gljList = rstData;
 
-         });
 
-     }
 
- };
 
 
  |