| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715 |
- var headerCount=4;//头部行高,第4行是总计
- var totalRowIndex=headerCount-1;
- var nextDataRowIndex=headerCount;//下条数据所在行
- var bgColor1='rgb(255,238,183)';//市场
- var bgColor2='rgb(214,206,242)';//运营
- var bgColor3='rgb(189,215,238)';//人资
- var bgColor4='rgb(255,201,201)';//采购
- var openPostNumColArray=[];
- var totoalAmountColIndex=4;
- $(function () {
- spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {sheetCount: 1});
- initSpread();
- initStatusBar(spread);
- initStatusBarEvents(spread);
- top.spread=spread;
- });
- function initSpread() {
- spread.suspendPaint();
- var sheet ;
- if (dbJson) {//数据库
- spread.fromJSON(dbJson);
- sheet=spread.getActiveSheet();
- var setting = sheet.tag();
- if(setting){
- if(setting.nextDataRowIndex){
- nextDataRowIndex = setting.nextDataRowIndex;
- }
- if(setting.openPostNumColArray){
- openPostNumColArray= setting.openPostNumColArray;
- }
- }
- addCostomFunction(sheet);
- //解决合并后 维度公式背景色问题
- /* loopAll(sheet,function(row,col){
- var cellTag = sheet.getTag(row,col);
- if(cellTag && cellTag.functionId){
- sheet.getCell(row,col).backColor('yellow');
- }
- });*/
- } else {
- spread.fromJSON(cost_breakdown_header);
- sheet=spread.getActiveSheet();
- sheet.clearSelection();
- var title = sheet.getValue(0,0);
- title= title.replace(/\$periodYear/g,periodYear);
- sheet.setValue(0,0,title);
- sheet.getRange(0,-1).visible(false);//第一行隐藏
- sheet.showColumn(0, GC.Spread.Sheets.HorizontalPosition.left);
- addCostomFunction(sheet);
- setTotalRow(sheet);
- addContractInfo(sheet);
- }
- sheet.frozenRowCount(headerCount);
- sheet.frozenColumnCount(3);
- spread.options.newTabVisible = false;//取消新增sheet按钮
- spread.options.allowExtendPasteRange = true;//扩展粘贴区域
- spread.options.allowCopyPasteExcelStyle = false
- removeMenu(sheet);
- addDimFunctionMenu(spread);
- bindEvent(spread);
- setDefaultLock(sheet);
- spread.resumePaint();
- }
- function bindEvent(spread) {
- spread.bind(GC.Spread.Sheets.Events.ValueChanged, function (e, info) {
- var sheet=info.sheet;
- var row = info.row;
- var col=info.col;
- if(col==totoalAmountColIndex){//金额列被修改 ,同时改变隐藏列
- sheet.setValue(row,col-1,info.newValue);
- }
- });
- spread.bind(GC.Spread.Sheets.Events.RowChanging, function (e, info) {
- //info.propertyName="deleteRows" //删除行
- if(info.propertyName="deleteRows"){
- var deleteRow = info.row;
- var deleteCount = info.count;
- var sheet=info.sheet;
- var sheetTag = sheet.tag();
- var ids = sheetTag.ids;
- for(var i=deleteRow;i<deleteRow+deleteCount;i++) {
- if(nextDataRowIndex>headerCount) nextDataRowIndex--;
- var rowTag = sheet.getTag(i,-1);
- if(!rowTag) continue;
- for(var j=0;j<ids.length;j++){
- if(ids[j]==rowTag.id){
- delete ids[j];
- }
- }
- }
- addSheetTagValue(sheet,{ids:ids,nextDataRowIndex:nextDataRowIndex});
- onDeleteRow(sheet,deleteRow,deleteCount);
- }
- });
- spread.bind(GC.Spread.Sheets.Events.CellClick, function (e, info) {
- var row = info.row;
- var col=info.col;
- var sheet=info.sheet;
- if(row<headerCount) return;
- for(var i=0;i<openPostNumColArray.length;i++){
- var colVar = openPostNumColArray[i];
- var _col = colVar.col;
- if(_col==col){
- if(editAuth!='yunying') break;
- var type=colVar.type;//0自有员工 1外包员工
- var postType= colVar.postType;
- var cellTag=sheet.getTag(row,col);
- var rowTag = sheet.getTag(row,-1);
- if(!cellTag) cellTag={};
- var id = cellTag.postNumId;
- if(!id){
- id= rowTag['postNumId'+type];
- }
- if(!id) id='';
- var entityId= rowTag.id;
- var url="budgetPostNumController.do?goAdd&id="+id+"&entityId="+entityId+"&type="+type+"&postType="+postType+"&periodYear="+periodYear;
- var width='100%';
- var height='100%';
- if(type==0){
- var wbfy=sheet.getValue(row,col-2);if(!wbfy)wbfy=0;
- var wbrs=sheet.getValue(row,col-4);if(!wbrs)wbrs=0;
- var scrs=sheet.getValue(row,col-5);if(!scrs)scrs=0;
- var scfy=sheet.getValue(row,col-6);if(!scfy)scfy=0;
- url+="&wbfy="+wbfy;
- url+="&wbrs="+wbrs;
- url+="&scrs="+scrs;
- url+="&scfy="+scfy;
- }else {
- width='600px';
- height='450px';
- }
- _openDialog(url,'录入岗位人数',function(iframe){
- var form= $('#formobj', iframe.document);
- var flag = true;
- form.find('input[name$=num]').each(function(){
- var v=$(this).val();
- if(v && !/^\d+(\.\d+)?$/.test(v)){
- flag=false;
- return false;
- }
- });
- if(!flag) {
- iframe.tip('请输入数字');
- return false;
- }
- $.ajax({
- type: "POST",
- dataType: "json",
- url: form.attr('action') ,
- data: form.serialize(),
- success: function (result) {
- var newPostNumId =result.attributes.id;
- var descn =result.attributes.descn;
- var totalNum =result.attributes.totalNum;
- addCellTagValue(sheet,row,col,{postNumId:newPostNumId});
- var rowTagVar = 'postNumId'+type;
- var rowTag={};
- rowTag[rowTagVar]=newPostNumId
- addCellTagValue(sheet,row,-1,rowTag);
- sheet.setValue(row,col,descn);
- sheet.setValue(row,col-1,totalNum);
- if(type==0){
- var costPostMaterialSchemeAmount =result.attributes.costPostMaterialSchemeAmount;
- sheet.setValue(row,col+1,costPostMaterialSchemeAmount);
- }
- },
- error : function() {
- alert("异常!");
- }
- });
- },width,height);
- }
- }
- });
- spread.bind(GC.Spread.Sheets.Events.EditEnded, function (e, info) {
- var text = info.editingText;
- var sheet=info.sheet;
- var row = info.row;
- var col=info.col;
- var cellTag = sheet.getTag(row,col);
- if(text.indexOf('=')>0){
- if(cellTag){
- if(cellTag.datatype=='amount'){
- if (!/^(-?\d+)(\.\d+)?$/.test(text)) {
- sheet.clear(row,col,1,1,GC.Spread.Sheets.SheetArea.viewport,GC.Spread.Sheets.StorageType.data);
- }
- }
- }
- }
- });
- spread.bind(GC.Spread.Sheets.Events.ClipboardPasting, function(e, info) {
- var value = info.pasteData.text;
- if(value) {
- var rowValues=value.split('\r\n');
- var r = info.cellRange.row;
- var c = info.cellRange.col;
- var rc = info.cellRange.rowCount;
- var cc = info.cellRange.colCount;
- var sheet = info.sheet;
- for(var i=r;i<r+rc;i++){
- var rowValue = rowValues[i-r];
- var rowValueArr = rowValue.split('\t');
- for(var j=c;j<c+cc;j++) {
- var cellValue =rowValueArr[j-c];
- cellValue=cellValue.trim();
- if(!cellValue){
- continue;
- }
- var cellTag = sheet.getTag(i,j);
- if(cellTag && cellTag.datatype=='amount') {
- cellValue =cellValue.replace(/[^\-\d\.]/g,'');
- if(!isDouble(cellValue)){
- cellValue = null;
- }
- }
- if(!cellValue){
- continue;
- }
- sheet.setValue(i,j,cellValue);
- if(cellTag && cellTag.functionId){
- delete cellTag['functionId'];
- sheet.setTag(i,j,cellTag);
- }
- if(j==totoalAmountColIndex){//金额列被修改 ,同时改变隐藏列
- cellValue =cellValue.replace(/[^\-\d\.]/g,'');
- sheet.setValue(i,j-1,cellValue);
- }
- }
- }
- }
- // sheet.setValue(r, c, value);
- // 停止粘贴事件
- info.cancel();
- })
- addConsistencyEvent(spread,'cost');
- }
- function setTotalRow(sheet) {
- }
- function setDefaultLock(sheet) {
- var option = {
- allowSelectLockedCells: true,
- allowSelectUnlockedCells: true,
- allowFilter: false,
- allowSort: false,
- allowResizeRows: true,
- allowResizeColumns: true,
- allowEditObjects: false,
- allowDragInsertRows: false,
- allowDragInsertColumns: false,
- allowInsertRows: false,
- allowInsertColumns: false,
- allowDeleteRows: true,
- allowDeleteColumns: false
- };
- sheet.options.protectionOptions = option;
- sheet.options.isProtected = true;
- var defaultStyle = sheet.getDefaultStyle(); //默认的样式,
- defaultStyle.locked = true;
- defaultStyle.hAlign=GC.Spread.Sheets.HorizontalAlign.center;
- defaultStyle.vAlign=GC.Spread.Sheets.VerticalAlign.center;
- // defaultStyle.wordWrap=true;
- defaultStyle.showEllipsis=true;
- // defaultStyle.cellType = new TipCellType();
- sheet.setDefaultStyle(defaultStyle);
- var colCount = sheet.getColumnCount();
- var rowCount = sheet.getRowCount();
- for(var i=2;i<colCount;i++){
- var bindInfo = costMeasureBindMap[i];
- if(bindInfo){
- if(editAuth==bindInfo.editAuth || bindInfo.editAuth=='all'){
- sheet.getRange(headerCount,i,rowCount,1).locked(false);
- }else {
- sheet.getRange(headerCount,i,rowCount,1).locked(true);
- }
- if(bindInfo.editAuth){
- sheet.getRange(-1,i).visible(true);
- }
- }
- }
- }
- function removeMenu(){
- for(var i=0;i< spread.contextMenu.menuData.length;i++){
- var menu = spread.contextMenu.menuData[i];
- var text=menu.text;
- if(text=='清除' || text=='插入'|| text=='隐藏'|| text=='显示' ){//去掉过滤、排序
- delete spread.contextMenu.menuData[i];
- }
- }
- }
- function save() {
- var sheet = spread.getActiveSheet();
- var json = spread.toJSON();
- var jsonString = JSON.stringify(json);
- var params = {};
- params.json = jsonString;
- params.id = costEntityId;
- params.saveAuth=editAuth;
- var layerIndex = layer.msg('保存中,请稍候···', {
- time : 3000*1000,
- shade: 0.1});
- $.post('budgetCostBreakdownController.do?doFill', params, function (d) {
- layer.close(layerIndex);
- $.messager.alert("信息", d.msg);
- isSave=true;
- }, 'json');
- }
- function addCostomFunction(sheet){
- }
- function addContractInfo(sheet){
- for(var i=0;i<contractInfo.length;i++){
- var one =contractInfo[i];
- addRow(one,i);
- }
- sheet.autoFitColumn(1);
- }
- function addRow(one,dataIndex){
- var sheet = spread.getActiveSheet();
- sheet.suspendPaint();
- var sheetTag = sheet.tag();
- if(!sheetTag) sheetTag={};
- if(!sheetTag.ids) sheetTag.ids=[];
- var id = one.id;
- if($.inArray(id, sheetTag.ids)!=-1){
- return;
- }
- sheetTag.ids.push(id);
- addSheetTagValue(sheet,{ids:sheetTag.ids});
- var row = nextDataRowIndex++;
- var sheetRowCount = sheet.getRowCount();
- if(row>=sheetRowCount-1){
- sheet.addRows(sheetRowCount-1,1)
- }
- var rowSetting={};//行变量
- var col=0;
- var id = one.id;
- var entityName = one.entityName;
- var contractDate = one.contractDate;
- var contractTotalAmount = one.contractTotalAmount;
- var entityCellInfo = {entityId:id,entityName:entityName};
- var yunyingCostMoneyArrayCol=[];//运营费业务配置
- var shichangCostMoneyArrayCol=[];//市场费业务配置
- var leftBorderThickArray=[];//做边框加重数组
- var costLimitCol;
- var cellStr;
- //序号
- sheet.setFormula(row, col, "row()-"+headerCount);
- sheet.getCell(row,col).backColor(bgColor1);
- col++;
- //名称
- sheet.getCell(row,col).backColor(bgColor1);
- sheet.setValue(row, col, entityName);
- col++;
- //合同起止日期
- sheet.getCell(row,col).backColor(bgColor1);
- sheet.setValue(row, col, contractDate);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- col++;
- //合同金额统计隐藏
- if(dataIndex==0){
- sheet.addColumns(col,1);
- cellStr = getCellStr(sheet,row,col);
- cellStr=cellStr.substring(0,cellStr.lastIndexOf('$'));
- sheet.setFormula(row-1,col+1,"sum("+cellStr+":"+cellStr+")");
- sheet.getRange(-1,col).visible(false);
- }
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- col++;
- //合同额
- sheet.getCell(row,col).backColor(bgColor1);
- sheet.setValue(row, col, contractTotalAmount);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- if(contractTotalAmount){
- var contractTotalAmountArray = contractTotalAmount.split(',');
- var contractTotalAmountNum=0;
- for(var i=0;i<contractTotalAmountArray.length;i++){
- contractTotalAmountNum+=parseFloat(contractTotalAmountArray[i]);
- }
- sheet.setValue(row, col-1, contractTotalAmountNum);
- }else {
- sheet.setValue(row, col-1, 0);
- }
- totoalAmountColIndex=col;
- col++;
- //预算成本上线
- sheet.getCell(row,col).backColor(bgColor1);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- costLimitCol=getCellStr(sheet,row,col);
- col++;
- //添加不同分类
- //办公室,客服,保安,保洁,工程,会务,宿管,其他
- var postTypeArray=["bgs","kf","ba","bj","gc","hw","sg","qt"];
- var fyhjArray=[],ygslhjArray=[],wbygslhjArray=[],wbygfyhjArray=[],zyygslhjArray=[],rywzfyhjArray=[],zyygfyhjArray=[],ygfyhjArray=[];
- for(var i =0;i<postTypeArray.length;i++){
- var postType = postTypeArray[i];
- //费用 录入
- sheet.getCell(row,col).backColor(bgColor1);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- cellStr= getCellStr(sheet,row,col);
- shichangCostMoneyArrayCol.push(cellStr);
- leftBorderThickArray.push(col);
- fyhjArray.push(cellStr);
- col++;
- //员工总数 录入
- sheet.getCell(row,col).backColor(bgColor1);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- cellStr= getCellStr(sheet,row,col);
- ygslhjArray.push(cellStr);
- col++;
- //外包员工数量 隐藏列
- if(dataIndex==0){//添加统计
- sheet.addColumns(col,1);
- cellStr = getCellStr(sheet,row,col);
- cellStr=cellStr.substring(0,cellStr.lastIndexOf('$'));
- sheet.setFormula(row-1,col+1,"SUBTOTAL(109,"+cellStr+":"+cellStr+")");
- sheet.getRange(-1,col).visible(false);
- }
- cellStr= getCellStr(sheet,row,col);
- wbygslhjArray.push(cellStr);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- col++;
- //外包员工数量 弹窗
- // bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,false);
- sheet.getCell(row,col).backColor(bgColor2);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- if(dataIndex==0){
- openPostNumColArray.push({col:col,type:1,postType:postType});
- }
- col++;
- //外包员工费用 录入
- sheet.getCell(row,col).backColor(bgColor2);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- cellStr= getCellStr(sheet,row,col);
- yunyingCostMoneyArrayCol.push(cellStr);
- wbygfyhjArray.push(cellStr);
- col++;
- //自有员工数量 隐藏列
- if(dataIndex==0){//添加统计
- sheet.addColumns(col,1);
- cellStr = getCellStr(sheet,row,col);
- cellStr=cellStr.substring(0,cellStr.lastIndexOf('$'));
- sheet.setFormula(row-1,col+1,"SUBTOTAL(109,"+cellStr+":"+cellStr+")");
- sheet.getRange(-1,col).visible(false);
- }
- cellStr= getCellStr(sheet,row,col);
- zyygslhjArray.push(cellStr);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- col++;
- //自有员工数量 弹窗
- // bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,false);
- sheet.getCell(row,col).backColor(bgColor2);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- if(dataIndex==0) {
- openPostNumColArray.push({col:col,type:0,postType:postType});
- }
- col++;
- //人员物资费用(运营配置)
- sheet.getCell(row,col).backColor(bgColor2);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- cellStr= getCellStr(sheet,row,col);
- yunyingCostMoneyArrayCol.push(cellStr);
- rywzfyhjArray.push(cellStr);
- col++;
- //自有员工费用 计算
- sheet.getCell(row,col).backColor(bgColor3);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- cellStr= getCellStr(sheet,row,col);
- yunyingCostMoneyArrayCol.push(cellStr);
- zyygfyhjArray.push(cellStr);
- col++;
- //物料费用 暂时隐藏
- if(dataIndex==0){
- sheet.getRange(-1,col).visible(false);
- }
- sheet.getCell(row,col).backColor(bgColor4);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- col++;
- }
- //费用合计(市场配置)
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- sheet.getCell(row,col).formula("sum("+fyhjArray.join(',')+")").backColor(bgColor1);
- var shichangheji = getCellStr(sheet,row,col);
- col++;
- //员工总数合计(市场配置)
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- sheet.getCell(row,col).formula("sum("+ygslhjArray.join(',')+")").backColor(bgColor1);
- var shichangrenshu = getCellStr(sheet,row,col);
- col++;
- //市场人均费用预算
- var div =shichangheji+"/"+shichangrenshu;
- var formula= 'IFERROR('+div+',0)'
- sheet.getCell(row,col).formula(formula).formatter('0.00').backColor(bgColor1);
- col++;
- //运营人工费用
- formula = "sum("+wbygfyhjArray.join(',')+','+rywzfyhjArray.join(',')+','+zyygfyhjArray.join(',')+")";
- sheet.getCell(row,col).formula(formula).backColor(bgColor2).formatter('0.00');
- var yunyingfeiyong = getCellStr(sheet,row,col);
- col++;
- //运营人工数量
- var formula = "sum("+wbygslhjArray.join(',')+','+zyygslhjArray.join(',')+")";
- sheet.getCell(row,col).formula(formula).backColor(bgColor2).formatter('0.00');
- var yunyingfeirenshu = getCellStr(sheet,row,col);
- col++;
- //运营人均费用
- div = yunyingfeiyong+"/"+yunyingfeirenshu;
- formula= 'IFERROR('+div+',0)';
- sheet.getCell(row,col).formula(formula).formatter('0.00').backColor(bgColor2);
- col++;
- //物料费用(市场配置)
- sheet.getCell(row,col).backColor(bgColor1);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- shichangCostMoneyArrayCol.push(getCellStr(sheet,row,col));
- leftBorderThickArray.push(col);
- col++;
- //物料费用(采购配置)
- sheet.getCell(row,col).backColor(bgColor4);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- yunyingCostMoneyArrayCol.push(getCellStr(sheet,row,col));
- col++;
- //维保 市场配置
- sheet.getCell(row,col).backColor(bgColor1);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- shichangCostMoneyArrayCol.push(getCellStr(sheet,row,col));
- leftBorderThickArray.push(col);
- col++;
- //维保 采购配置
- sheet.getCell(row,col).backColor(bgColor4);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- yunyingCostMoneyArrayCol.push(getCellStr(sheet,row,col));
- col++;
- //管理费 录入
- sheet.getCell(row,col).backColor(bgColor1);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- yunyingCostMoneyArrayCol.push(getCellStr(sheet,row,col));
- shichangCostMoneyArrayCol.push(getCellStr(sheet,row,col));
- leftBorderThickArray.push(col);
- col++;
- //税金 录入
- sheet.getCell(row,col).backColor(bgColor1);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- yunyingCostMoneyArrayCol.push(getCellStr(sheet,row,col));
- shichangCostMoneyArrayCol.push(getCellStr(sheet,row,col));
- col++;
- //运营费 业务配置 公式
- // sheet.getCell(row,col).backColor(bgColor1);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- sheet.setFormula(row,col,costLimitCol+"-"+yunyingCostMoneyArrayCol.join('-'));
- col++;
- //运营费 市场配置 公式
- // sheet.getCell(row,col).backColor(bgColor1);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- sheet.setFormula(row,col,costLimitCol+"-"+shichangCostMoneyArrayCol.join('-'));
- col++;
- //备注
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- col++;
- if(dataIndex==0){//最后插入隐藏统计列
- sheet.addColumns(col,8);
- sheet.getRange(-1,col,-1,8).visible(false);
- }
- //外包员工数合计(运营配置)
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- sheet.setFormula(row,col,"sum("+wbygslhjArray.join(',')+")");
- col++;
- //外包员工费用合计(运营配置)
- cellStr= getCellStr(sheet,row,col);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- sheet.setFormula(row,col,"sum("+wbygfyhjArray.join(',')+")");
- ygfyhjArray.push(cellStr);
- col++;
- //自有员工数量合计(运营配置)
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- sheet.setFormula(row,col,"sum("+zyygslhjArray.join(',')+")");
- col++;
- //人员物资费用合计(运营配置)
- cellStr= getCellStr(sheet,row,col);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- sheet.setFormula(row,col,"sum("+rywzfyhjArray.join(',')+")");
- ygfyhjArray.push(cellStr);
- col++;
- //自有员工费用合计(人资配置)
- cellStr= getCellStr(sheet,row,col);
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- sheet.setFormula(row,col,"sum("+zyygfyhjArray.join(',')+")");
- ygfyhjArray.push(cellStr);
- col++;
- //员工费用合计(业务配置)
- bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
- sheet.setFormula(row,col,"sum("+ygfyhjArray.join(',')+")");
- col++;
- //边框
- var thinBorder = new GC.Spread.Sheets.LineBorder('black', GC.Spread.Sheets.LineStyle.thin);
- var thickBorder = new GC.Spread.Sheets.LineBorder('black', GC.Spread.Sheets.LineStyle.thick);
- var columnCount = sheet.getColumnCount();
- sheet.getRange(row,-1).setBorder(thinBorder, { left: true, right: true,top:true,bottom:true,inside:true});
- for(var i=0;i<leftBorderThickArray.length;i++) {
- sheet.getCell(row,leftBorderThickArray[i]).borderLeft(thickBorder);
- }
- addSheetTagValue(sheet,{nextDataRowIndex:nextDataRowIndex});
- addSheetTagValue(sheet,{openPostNumColArray:openPostNumColArray});
- rowSetting.id=id;
- addCellTagValue(sheet,row,-1,rowSetting);
- sheet.resumePaint();
- }
- function bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,dataCell){
- if(dataCell){
- setDataCell(sheet,row,col);
- }
- var cellInfo =entityCellInfo;
- var bindInfo = costMeasureBindMap[col];
- var measureId = bindInfo.measureId;
- var measureEntity = costMeasure[measureId];
- cellInfo.measureId=measureId;
- if(measureEntity) {
- cellInfo.measureName=measureEntity.name;
- cellInfo.datatype=measureEntity.datatype;
- cellInfo.showType=measureEntity.showType;
- cellInfo.fractionNum=measureEntity.fractionNum;
- cellInfo.currencySymbol=measureEntity.currencySymbol;
- cellInfo.thousandth=measureEntity.thousandth;
- }else {
- cellInfo.datatype='txt';
- }
- cellInfo.editAuth = bindInfo.editAuth;
- cellInfo.saveAuth = bindInfo.saveAuth;
- cellInfo.findKey = bindInfo.findKey;
- addCellTagValue(sheet,row,col,cellInfo);
- var format = setAmountFormat(sheet,row,col,cellInfo);
- var cell=sheet.getCell(row,col);
- cell.hAlign( GC.Spread.Sheets.HorizontalAlign.right).vAlign(GC.Spread.Sheets.VerticalAlign.center);
- if(dataIndex==0){//修改合计行
- sheet.setFormatter(row-1,col, format);
- setCellAlignRight(sheet,row-1,col);
- }
- }
- function setCellAlignRight(sheet,row,col){
- sheet.getCell(row,col).hAlign( GC.Spread.Sheets.HorizontalAlign.right).vAlign(GC.Spread.Sheets.VerticalAlign.center);
- }
- /*
- function sort(){//不能用 有bug
- var sheet=spread.getActiveSheet();
- var colCount = sheet.getColumnCount();
- sheet.sortRange(headerCount, 0, nextDataRowIndex-headerCount, colCount, true,[
- { index: 1, ascending: false,compareFunction: function (value1, value2) {
- if(!value1) return -1;
- return value1.localeCompare(value2)
- }}
- ]);
- }*/
- function TipCellType() {
- }
- TipCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
- TipCellType.prototype.getHitInfo = function(x, y, cellStyle, cellRect, context) {
- return {
- x: x,
- y: y,
- row: context.row,
- col: context.col,
- cellStyle: cellStyle,
- cellRect: cellRect,
- sheetArea: context.sheetArea
- };
- }
- TipCellType.prototype.processMouseEnter = function(hitinfo) {
- if (!this._toolTipElement) {
- var div = document.createElement("div");
- $(div).css("position", "absolute")
- .css("border", "1px #C0C0C0 solid")
- .css("box-shadow", "1px 2px 5px rgba(0,0,0,0.4)")
- .css("font", "9pt Arial")
- .css("background", "white")
- .css("padding", 5);
- this._toolTipElement = div;
- }
- $(this._toolTipElement).text("Cell [R:" + hitinfo.row + "] : [C:" + hitinfo.col + "]")
- .css("top", hitinfo.y + 15)
- .css("left", hitinfo.x + 15);
- $(this._toolTipElement).hide();
- document.body.insertBefore(this._toolTipElement, null);
- $(this._toolTipElement).show("fast");
- };
- TipCellType.prototype.processMouseLeave = function(hitinfo) {
- if (this._toolTipElement) {
- document.body.removeChild(this._toolTipElement);
- this._toolTipElement = null;
- }
- };
|