budgetCostBreakdown-fill.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. var headerCount=4;//头部行高,第4行是总计
  2. var totalRowIndex=headerCount-1;
  3. var nextDataRowIndex=headerCount;//下条数据所在行
  4. var bgColor1='rgb(255,238,183)';//市场
  5. var bgColor2='rgb(214,206,242)';//运营
  6. var bgColor3='rgb(189,215,238)';//人资
  7. var bgColor4='rgb(255,201,201)';//采购
  8. var openPostNumColArray=[];
  9. var totoalAmountColIndex=4;
  10. $(function () {
  11. spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {sheetCount: 1});
  12. initSpread();
  13. initStatusBar(spread);
  14. initStatusBarEvents(spread);
  15. top.spread=spread;
  16. });
  17. function initSpread() {
  18. spread.suspendPaint();
  19. var sheet ;
  20. if (dbJson) {//数据库
  21. spread.fromJSON(dbJson);
  22. sheet=spread.getActiveSheet();
  23. var setting = sheet.tag();
  24. if(setting){
  25. if(setting.nextDataRowIndex){
  26. nextDataRowIndex = setting.nextDataRowIndex;
  27. }
  28. if(setting.openPostNumColArray){
  29. openPostNumColArray= setting.openPostNumColArray;
  30. }
  31. }
  32. addCostomFunction(sheet);
  33. //解决合并后 维度公式背景色问题
  34. /* loopAll(sheet,function(row,col){
  35. var cellTag = sheet.getTag(row,col);
  36. if(cellTag && cellTag.functionId){
  37. sheet.getCell(row,col).backColor('yellow');
  38. }
  39. });*/
  40. } else {
  41. spread.fromJSON(cost_breakdown_header);
  42. sheet=spread.getActiveSheet();
  43. sheet.clearSelection();
  44. var title = sheet.getValue(0,0);
  45. title= title.replace(/\$periodYear/g,periodYear);
  46. sheet.setValue(0,0,title);
  47. sheet.getRange(0,-1).visible(false);//第一行隐藏
  48. sheet.showColumn(0, GC.Spread.Sheets.HorizontalPosition.left);
  49. addCostomFunction(sheet);
  50. setTotalRow(sheet);
  51. addContractInfo(sheet);
  52. }
  53. sheet.frozenRowCount(headerCount);
  54. sheet.frozenColumnCount(3);
  55. spread.options.newTabVisible = false;//取消新增sheet按钮
  56. spread.options.allowExtendPasteRange = true;//扩展粘贴区域
  57. spread.options.allowCopyPasteExcelStyle = false
  58. removeMenu(sheet);
  59. addDimFunctionMenu(spread);
  60. bindEvent(spread);
  61. setDefaultLock(sheet);
  62. spread.resumePaint();
  63. }
  64. function bindEvent(spread) {
  65. spread.bind(GC.Spread.Sheets.Events.ValueChanged, function (e, info) {
  66. var sheet=info.sheet;
  67. var row = info.row;
  68. var col=info.col;
  69. if(col==totoalAmountColIndex){//金额列被修改 ,同时改变隐藏列
  70. sheet.setValue(row,col-1,info.newValue);
  71. }
  72. });
  73. spread.bind(GC.Spread.Sheets.Events.RowChanging, function (e, info) {
  74. //info.propertyName="deleteRows" //删除行
  75. if(info.propertyName="deleteRows"){
  76. var deleteRow = info.row;
  77. var deleteCount = info.count;
  78. var sheet=info.sheet;
  79. var sheetTag = sheet.tag();
  80. var ids = sheetTag.ids;
  81. for(var i=deleteRow;i<deleteRow+deleteCount;i++) {
  82. if(nextDataRowIndex>headerCount) nextDataRowIndex--;
  83. var rowTag = sheet.getTag(i,-1);
  84. if(!rowTag) continue;
  85. for(var j=0;j<ids.length;j++){
  86. if(ids[j]==rowTag.id){
  87. delete ids[j];
  88. }
  89. }
  90. }
  91. addSheetTagValue(sheet,{ids:ids,nextDataRowIndex:nextDataRowIndex});
  92. onDeleteRow(sheet,deleteRow,deleteCount);
  93. }
  94. });
  95. spread.bind(GC.Spread.Sheets.Events.CellClick, function (e, info) {
  96. var row = info.row;
  97. var col=info.col;
  98. var sheet=info.sheet;
  99. if(row<headerCount) return;
  100. for(var i=0;i<openPostNumColArray.length;i++){
  101. var colVar = openPostNumColArray[i];
  102. var _col = colVar.col;
  103. if(_col==col){
  104. if(editAuth!='yunying') break;
  105. var type=colVar.type;//0自有员工 1外包员工
  106. var postType= colVar.postType;
  107. var cellTag=sheet.getTag(row,col);
  108. var rowTag = sheet.getTag(row,-1);
  109. if(!cellTag) cellTag={};
  110. var id = cellTag.postNumId;
  111. if(!id){
  112. id= rowTag['postNumId'+type];
  113. }
  114. if(!id) id='';
  115. var entityId= rowTag.id;
  116. var url="budgetPostNumController.do?goAdd&id="+id+"&entityId="+entityId+"&type="+type+"&postType="+postType+"&periodYear="+periodYear;
  117. var width='100%';
  118. var height='100%';
  119. if(type==0){
  120. var wbfy=sheet.getValue(row,col-2);if(!wbfy)wbfy=0;
  121. var wbrs=sheet.getValue(row,col-4);if(!wbrs)wbrs=0;
  122. var scrs=sheet.getValue(row,col-5);if(!scrs)scrs=0;
  123. var scfy=sheet.getValue(row,col-6);if(!scfy)scfy=0;
  124. url+="&wbfy="+wbfy;
  125. url+="&wbrs="+wbrs;
  126. url+="&scrs="+scrs;
  127. url+="&scfy="+scfy;
  128. }else {
  129. width='600px';
  130. height='450px';
  131. }
  132. _openDialog(url,'录入岗位人数',function(iframe){
  133. var form= $('#formobj', iframe.document);
  134. var flag = true;
  135. form.find('input[name$=num]').each(function(){
  136. var v=$(this).val();
  137. if(v && !/^\d+(\.\d+)?$/.test(v)){
  138. flag=false;
  139. return false;
  140. }
  141. });
  142. if(!flag) {
  143. iframe.tip('请输入数字');
  144. return false;
  145. }
  146. $.ajax({
  147. type: "POST",
  148. dataType: "json",
  149. url: form.attr('action') ,
  150. data: form.serialize(),
  151. success: function (result) {
  152. var newPostNumId =result.attributes.id;
  153. var descn =result.attributes.descn;
  154. var totalNum =result.attributes.totalNum;
  155. addCellTagValue(sheet,row,col,{postNumId:newPostNumId});
  156. var rowTagVar = 'postNumId'+type;
  157. var rowTag={};
  158. rowTag[rowTagVar]=newPostNumId
  159. addCellTagValue(sheet,row,-1,rowTag);
  160. sheet.setValue(row,col,descn);
  161. sheet.setValue(row,col-1,totalNum);
  162. if(type==0){
  163. var costPostMaterialSchemeAmount =result.attributes.costPostMaterialSchemeAmount;
  164. sheet.setValue(row,col+1,costPostMaterialSchemeAmount);
  165. }
  166. },
  167. error : function() {
  168. alert("异常!");
  169. }
  170. });
  171. },width,height);
  172. }
  173. }
  174. });
  175. spread.bind(GC.Spread.Sheets.Events.EditEnded, function (e, info) {
  176. var text = info.editingText;
  177. var sheet=info.sheet;
  178. var row = info.row;
  179. var col=info.col;
  180. var cellTag = sheet.getTag(row,col);
  181. if(text.indexOf('=')>0){
  182. if(cellTag){
  183. if(cellTag.datatype=='amount'){
  184. if (!/^(-?\d+)(\.\d+)?$/.test(text)) {
  185. sheet.clear(row,col,1,1,GC.Spread.Sheets.SheetArea.viewport,GC.Spread.Sheets.StorageType.data);
  186. }
  187. }
  188. }
  189. }
  190. });
  191. spread.bind(GC.Spread.Sheets.Events.ClipboardPasting, function(e, info) {
  192. var value = info.pasteData.text;
  193. if(value) {
  194. var rowValues=value.split('\r\n');
  195. var r = info.cellRange.row;
  196. var c = info.cellRange.col;
  197. var rc = info.cellRange.rowCount;
  198. var cc = info.cellRange.colCount;
  199. var sheet = info.sheet;
  200. for(var i=r;i<r+rc;i++){
  201. var rowValue = rowValues[i-r];
  202. var rowValueArr = rowValue.split('\t');
  203. for(var j=c;j<c+cc;j++) {
  204. var cellValue =rowValueArr[j-c];
  205. cellValue=cellValue.trim();
  206. if(!cellValue){
  207. continue;
  208. }
  209. var cellTag = sheet.getTag(i,j);
  210. if(cellTag && cellTag.datatype=='amount') {
  211. cellValue =cellValue.replace(/[^\-\d\.]/g,'');
  212. if(!isDouble(cellValue)){
  213. cellValue = null;
  214. }
  215. }
  216. if(!cellValue){
  217. continue;
  218. }
  219. sheet.setValue(i,j,cellValue);
  220. if(cellTag && cellTag.functionId){
  221. delete cellTag['functionId'];
  222. sheet.setTag(i,j,cellTag);
  223. }
  224. if(j==totoalAmountColIndex){//金额列被修改 ,同时改变隐藏列
  225. cellValue =cellValue.replace(/[^\-\d\.]/g,'');
  226. sheet.setValue(i,j-1,cellValue);
  227. }
  228. }
  229. }
  230. }
  231. // sheet.setValue(r, c, value);
  232. // 停止粘贴事件
  233. info.cancel();
  234. })
  235. addConsistencyEvent(spread,'cost');
  236. }
  237. function setTotalRow(sheet) {
  238. }
  239. function setDefaultLock(sheet) {
  240. var option = {
  241. allowSelectLockedCells: true,
  242. allowSelectUnlockedCells: true,
  243. allowFilter: false,
  244. allowSort: false,
  245. allowResizeRows: true,
  246. allowResizeColumns: true,
  247. allowEditObjects: false,
  248. allowDragInsertRows: false,
  249. allowDragInsertColumns: false,
  250. allowInsertRows: false,
  251. allowInsertColumns: false,
  252. allowDeleteRows: true,
  253. allowDeleteColumns: false
  254. };
  255. sheet.options.protectionOptions = option;
  256. sheet.options.isProtected = true;
  257. var defaultStyle = sheet.getDefaultStyle(); //默认的样式,
  258. defaultStyle.locked = true;
  259. defaultStyle.hAlign=GC.Spread.Sheets.HorizontalAlign.center;
  260. defaultStyle.vAlign=GC.Spread.Sheets.VerticalAlign.center;
  261. // defaultStyle.wordWrap=true;
  262. defaultStyle.showEllipsis=true;
  263. // defaultStyle.cellType = new TipCellType();
  264. sheet.setDefaultStyle(defaultStyle);
  265. var colCount = sheet.getColumnCount();
  266. var rowCount = sheet.getRowCount();
  267. for(var i=2;i<colCount;i++){
  268. var bindInfo = costMeasureBindMap[i];
  269. if(bindInfo){
  270. if(editAuth==bindInfo.editAuth || bindInfo.editAuth=='all'){
  271. sheet.getRange(headerCount,i,rowCount,1).locked(false);
  272. }else {
  273. sheet.getRange(headerCount,i,rowCount,1).locked(true);
  274. }
  275. if(bindInfo.editAuth){
  276. sheet.getRange(-1,i).visible(true);
  277. }
  278. }
  279. }
  280. }
  281. function removeMenu(){
  282. for(var i=0;i< spread.contextMenu.menuData.length;i++){
  283. var menu = spread.contextMenu.menuData[i];
  284. var text=menu.text;
  285. if(text=='清除' || text=='插入'|| text=='隐藏'|| text=='显示' ){//去掉过滤、排序
  286. delete spread.contextMenu.menuData[i];
  287. }
  288. }
  289. }
  290. function save() {
  291. var sheet = spread.getActiveSheet();
  292. var json = spread.toJSON();
  293. var jsonString = JSON.stringify(json);
  294. var params = {};
  295. params.json = jsonString;
  296. params.id = costEntityId;
  297. params.saveAuth=editAuth;
  298. var layerIndex = layer.msg('保存中,请稍候···', {
  299. time : 3000*1000,
  300. shade: 0.1});
  301. $.post('budgetCostBreakdownController.do?doFill', params, function (d) {
  302. layer.close(layerIndex);
  303. $.messager.alert("信息", d.msg);
  304. isSave=true;
  305. }, 'json');
  306. }
  307. function addCostomFunction(sheet){
  308. }
  309. function addContractInfo(sheet){
  310. for(var i=0;i<contractInfo.length;i++){
  311. var one =contractInfo[i];
  312. addRow(one,i);
  313. }
  314. sheet.autoFitColumn(1);
  315. }
  316. function addRow(one,dataIndex){
  317. var sheet = spread.getActiveSheet();
  318. sheet.suspendPaint();
  319. var sheetTag = sheet.tag();
  320. if(!sheetTag) sheetTag={};
  321. if(!sheetTag.ids) sheetTag.ids=[];
  322. var id = one.id;
  323. if($.inArray(id, sheetTag.ids)!=-1){
  324. return;
  325. }
  326. sheetTag.ids.push(id);
  327. addSheetTagValue(sheet,{ids:sheetTag.ids});
  328. var row = nextDataRowIndex++;
  329. var sheetRowCount = sheet.getRowCount();
  330. if(row>=sheetRowCount-1){
  331. sheet.addRows(sheetRowCount-1,1)
  332. }
  333. var rowSetting={};//行变量
  334. var col=0;
  335. var id = one.id;
  336. var entityName = one.entityName;
  337. var contractDate = one.contractDate;
  338. var contractTotalAmount = one.contractTotalAmount;
  339. var entityCellInfo = {entityId:id,entityName:entityName};
  340. var yunyingCostMoneyArrayCol=[];//运营费业务配置
  341. var shichangCostMoneyArrayCol=[];//市场费业务配置
  342. var leftBorderThickArray=[];//做边框加重数组
  343. var costLimitCol;
  344. var cellStr;
  345. //序号
  346. sheet.setFormula(row, col, "row()-"+headerCount);
  347. sheet.getCell(row,col).backColor(bgColor1);
  348. col++;
  349. //名称
  350. sheet.getCell(row,col).backColor(bgColor1);
  351. sheet.setValue(row, col, entityName);
  352. col++;
  353. //合同起止日期
  354. sheet.getCell(row,col).backColor(bgColor1);
  355. sheet.setValue(row, col, contractDate);
  356. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  357. col++;
  358. //合同金额统计隐藏
  359. if(dataIndex==0){
  360. sheet.addColumns(col,1);
  361. cellStr = getCellStr(sheet,row,col);
  362. cellStr=cellStr.substring(0,cellStr.lastIndexOf('$'));
  363. sheet.setFormula(row-1,col+1,"sum("+cellStr+":"+cellStr+")");
  364. sheet.getRange(-1,col).visible(false);
  365. }
  366. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  367. col++;
  368. //合同额
  369. sheet.getCell(row,col).backColor(bgColor1);
  370. sheet.setValue(row, col, contractTotalAmount);
  371. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  372. if(contractTotalAmount){
  373. var contractTotalAmountArray = contractTotalAmount.split(',');
  374. var contractTotalAmountNum=0;
  375. for(var i=0;i<contractTotalAmountArray.length;i++){
  376. contractTotalAmountNum+=parseFloat(contractTotalAmountArray[i]);
  377. }
  378. sheet.setValue(row, col-1, contractTotalAmountNum);
  379. }else {
  380. sheet.setValue(row, col-1, 0);
  381. }
  382. totoalAmountColIndex=col;
  383. col++;
  384. //预算成本上线
  385. sheet.getCell(row,col).backColor(bgColor1);
  386. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  387. costLimitCol=getCellStr(sheet,row,col);
  388. col++;
  389. //添加不同分类
  390. //办公室,客服,保安,保洁,工程,会务,宿管,其他
  391. var postTypeArray=["bgs","kf","ba","bj","gc","hw","sg","qt"];
  392. var fyhjArray=[],ygslhjArray=[],wbygslhjArray=[],wbygfyhjArray=[],zyygslhjArray=[],rywzfyhjArray=[],zyygfyhjArray=[],ygfyhjArray=[];
  393. for(var i =0;i<postTypeArray.length;i++){
  394. var postType = postTypeArray[i];
  395. //费用 录入
  396. sheet.getCell(row,col).backColor(bgColor1);
  397. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  398. cellStr= getCellStr(sheet,row,col);
  399. shichangCostMoneyArrayCol.push(cellStr);
  400. leftBorderThickArray.push(col);
  401. fyhjArray.push(cellStr);
  402. col++;
  403. //员工总数 录入
  404. sheet.getCell(row,col).backColor(bgColor1);
  405. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  406. cellStr= getCellStr(sheet,row,col);
  407. ygslhjArray.push(cellStr);
  408. col++;
  409. //外包员工数量 隐藏列
  410. if(dataIndex==0){//添加统计
  411. sheet.addColumns(col,1);
  412. cellStr = getCellStr(sheet,row,col);
  413. cellStr=cellStr.substring(0,cellStr.lastIndexOf('$'));
  414. sheet.setFormula(row-1,col+1,"SUBTOTAL(109,"+cellStr+":"+cellStr+")");
  415. sheet.getRange(-1,col).visible(false);
  416. }
  417. cellStr= getCellStr(sheet,row,col);
  418. wbygslhjArray.push(cellStr);
  419. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  420. col++;
  421. //外包员工数量 弹窗
  422. // bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,false);
  423. sheet.getCell(row,col).backColor(bgColor2);
  424. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  425. if(dataIndex==0){
  426. openPostNumColArray.push({col:col,type:1,postType:postType});
  427. }
  428. col++;
  429. //外包员工费用 录入
  430. sheet.getCell(row,col).backColor(bgColor2);
  431. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  432. cellStr= getCellStr(sheet,row,col);
  433. yunyingCostMoneyArrayCol.push(cellStr);
  434. wbygfyhjArray.push(cellStr);
  435. col++;
  436. //自有员工数量 隐藏列
  437. if(dataIndex==0){//添加统计
  438. sheet.addColumns(col,1);
  439. cellStr = getCellStr(sheet,row,col);
  440. cellStr=cellStr.substring(0,cellStr.lastIndexOf('$'));
  441. sheet.setFormula(row-1,col+1,"SUBTOTAL(109,"+cellStr+":"+cellStr+")");
  442. sheet.getRange(-1,col).visible(false);
  443. }
  444. cellStr= getCellStr(sheet,row,col);
  445. zyygslhjArray.push(cellStr);
  446. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  447. col++;
  448. //自有员工数量 弹窗
  449. // bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,false);
  450. sheet.getCell(row,col).backColor(bgColor2);
  451. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  452. if(dataIndex==0) {
  453. openPostNumColArray.push({col:col,type:0,postType:postType});
  454. }
  455. col++;
  456. //人员物资费用(运营配置)
  457. sheet.getCell(row,col).backColor(bgColor2);
  458. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  459. cellStr= getCellStr(sheet,row,col);
  460. yunyingCostMoneyArrayCol.push(cellStr);
  461. rywzfyhjArray.push(cellStr);
  462. col++;
  463. //自有员工费用 计算
  464. sheet.getCell(row,col).backColor(bgColor3);
  465. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  466. cellStr= getCellStr(sheet,row,col);
  467. yunyingCostMoneyArrayCol.push(cellStr);
  468. zyygfyhjArray.push(cellStr);
  469. col++;
  470. //物料费用 暂时隐藏
  471. if(dataIndex==0){
  472. sheet.getRange(-1,col).visible(false);
  473. }
  474. sheet.getCell(row,col).backColor(bgColor4);
  475. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  476. col++;
  477. }
  478. //费用合计(市场配置)
  479. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  480. sheet.getCell(row,col).formula("sum("+fyhjArray.join(',')+")").backColor(bgColor1);
  481. var shichangheji = getCellStr(sheet,row,col);
  482. col++;
  483. //员工总数合计(市场配置)
  484. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  485. sheet.getCell(row,col).formula("sum("+ygslhjArray.join(',')+")").backColor(bgColor1);
  486. var shichangrenshu = getCellStr(sheet,row,col);
  487. col++;
  488. //市场人均费用预算
  489. var div =shichangheji+"/"+shichangrenshu;
  490. var formula= 'IFERROR('+div+',0)'
  491. sheet.getCell(row,col).formula(formula).formatter('0.00').backColor(bgColor1);
  492. col++;
  493. //运营人工费用
  494. formula = "sum("+wbygfyhjArray.join(',')+','+rywzfyhjArray.join(',')+','+zyygfyhjArray.join(',')+")";
  495. sheet.getCell(row,col).formula(formula).backColor(bgColor2).formatter('0.00');
  496. var yunyingfeiyong = getCellStr(sheet,row,col);
  497. col++;
  498. //运营人工数量
  499. var formula = "sum("+wbygslhjArray.join(',')+','+zyygslhjArray.join(',')+")";
  500. sheet.getCell(row,col).formula(formula).backColor(bgColor2).formatter('0.00');
  501. var yunyingfeirenshu = getCellStr(sheet,row,col);
  502. col++;
  503. //运营人均费用
  504. div = yunyingfeiyong+"/"+yunyingfeirenshu;
  505. formula= 'IFERROR('+div+',0)';
  506. sheet.getCell(row,col).formula(formula).formatter('0.00').backColor(bgColor2);
  507. col++;
  508. //物料费用(市场配置)
  509. sheet.getCell(row,col).backColor(bgColor1);
  510. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  511. shichangCostMoneyArrayCol.push(getCellStr(sheet,row,col));
  512. leftBorderThickArray.push(col);
  513. col++;
  514. //物料费用(采购配置)
  515. sheet.getCell(row,col).backColor(bgColor4);
  516. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  517. yunyingCostMoneyArrayCol.push(getCellStr(sheet,row,col));
  518. col++;
  519. //维保 市场配置
  520. sheet.getCell(row,col).backColor(bgColor1);
  521. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  522. shichangCostMoneyArrayCol.push(getCellStr(sheet,row,col));
  523. leftBorderThickArray.push(col);
  524. col++;
  525. //维保 采购配置
  526. sheet.getCell(row,col).backColor(bgColor4);
  527. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  528. yunyingCostMoneyArrayCol.push(getCellStr(sheet,row,col));
  529. col++;
  530. //管理费 录入
  531. sheet.getCell(row,col).backColor(bgColor1);
  532. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  533. yunyingCostMoneyArrayCol.push(getCellStr(sheet,row,col));
  534. shichangCostMoneyArrayCol.push(getCellStr(sheet,row,col));
  535. leftBorderThickArray.push(col);
  536. col++;
  537. //税金 录入
  538. sheet.getCell(row,col).backColor(bgColor1);
  539. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  540. yunyingCostMoneyArrayCol.push(getCellStr(sheet,row,col));
  541. shichangCostMoneyArrayCol.push(getCellStr(sheet,row,col));
  542. col++;
  543. //运营费 业务配置 公式
  544. // sheet.getCell(row,col).backColor(bgColor1);
  545. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  546. sheet.setFormula(row,col,costLimitCol+"-"+yunyingCostMoneyArrayCol.join('-'));
  547. col++;
  548. //运营费 市场配置 公式
  549. // sheet.getCell(row,col).backColor(bgColor1);
  550. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  551. sheet.setFormula(row,col,costLimitCol+"-"+shichangCostMoneyArrayCol.join('-'));
  552. col++;
  553. //备注
  554. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  555. col++;
  556. if(dataIndex==0){//最后插入隐藏统计列
  557. sheet.addColumns(col,8);
  558. sheet.getRange(-1,col,-1,8).visible(false);
  559. }
  560. //外包员工数合计(运营配置)
  561. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  562. sheet.setFormula(row,col,"sum("+wbygslhjArray.join(',')+")");
  563. col++;
  564. //外包员工费用合计(运营配置)
  565. cellStr= getCellStr(sheet,row,col);
  566. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  567. sheet.setFormula(row,col,"sum("+wbygfyhjArray.join(',')+")");
  568. ygfyhjArray.push(cellStr);
  569. col++;
  570. //自有员工数量合计(运营配置)
  571. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  572. sheet.setFormula(row,col,"sum("+zyygslhjArray.join(',')+")");
  573. col++;
  574. //人员物资费用合计(运营配置)
  575. cellStr= getCellStr(sheet,row,col);
  576. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  577. sheet.setFormula(row,col,"sum("+rywzfyhjArray.join(',')+")");
  578. ygfyhjArray.push(cellStr);
  579. col++;
  580. //自有员工费用合计(人资配置)
  581. cellStr= getCellStr(sheet,row,col);
  582. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  583. sheet.setFormula(row,col,"sum("+zyygfyhjArray.join(',')+")");
  584. ygfyhjArray.push(cellStr);
  585. col++;
  586. //员工费用合计(业务配置)
  587. bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,true);
  588. sheet.setFormula(row,col,"sum("+ygfyhjArray.join(',')+")");
  589. col++;
  590. //边框
  591. var thinBorder = new GC.Spread.Sheets.LineBorder('black', GC.Spread.Sheets.LineStyle.thin);
  592. var thickBorder = new GC.Spread.Sheets.LineBorder('black', GC.Spread.Sheets.LineStyle.thick);
  593. var columnCount = sheet.getColumnCount();
  594. sheet.getRange(row,-1).setBorder(thinBorder, { left: true, right: true,top:true,bottom:true,inside:true});
  595. for(var i=0;i<leftBorderThickArray.length;i++) {
  596. sheet.getCell(row,leftBorderThickArray[i]).borderLeft(thickBorder);
  597. }
  598. addSheetTagValue(sheet,{nextDataRowIndex:nextDataRowIndex});
  599. addSheetTagValue(sheet,{openPostNumColArray:openPostNumColArray});
  600. rowSetting.id=id;
  601. addCellTagValue(sheet,row,-1,rowSetting);
  602. sheet.resumePaint();
  603. }
  604. function bindCellInfo(sheet,row,col,entityCellInfo,dataIndex,dataCell){
  605. if(dataCell){
  606. setDataCell(sheet,row,col);
  607. }
  608. var cellInfo =entityCellInfo;
  609. var bindInfo = costMeasureBindMap[col];
  610. var measureId = bindInfo.measureId;
  611. var measureEntity = costMeasure[measureId];
  612. cellInfo.measureId=measureId;
  613. if(measureEntity) {
  614. cellInfo.measureName=measureEntity.name;
  615. cellInfo.datatype=measureEntity.datatype;
  616. cellInfo.showType=measureEntity.showType;
  617. cellInfo.fractionNum=measureEntity.fractionNum;
  618. cellInfo.currencySymbol=measureEntity.currencySymbol;
  619. cellInfo.thousandth=measureEntity.thousandth;
  620. }else {
  621. cellInfo.datatype='txt';
  622. }
  623. cellInfo.editAuth = bindInfo.editAuth;
  624. cellInfo.saveAuth = bindInfo.saveAuth;
  625. cellInfo.findKey = bindInfo.findKey;
  626. addCellTagValue(sheet,row,col,cellInfo);
  627. var format = setAmountFormat(sheet,row,col,cellInfo);
  628. var cell=sheet.getCell(row,col);
  629. cell.hAlign( GC.Spread.Sheets.HorizontalAlign.right).vAlign(GC.Spread.Sheets.VerticalAlign.center);
  630. if(dataIndex==0){//修改合计行
  631. sheet.setFormatter(row-1,col, format);
  632. setCellAlignRight(sheet,row-1,col);
  633. }
  634. }
  635. function setCellAlignRight(sheet,row,col){
  636. sheet.getCell(row,col).hAlign( GC.Spread.Sheets.HorizontalAlign.right).vAlign(GC.Spread.Sheets.VerticalAlign.center);
  637. }
  638. /*
  639. function sort(){//不能用 有bug
  640. var sheet=spread.getActiveSheet();
  641. var colCount = sheet.getColumnCount();
  642. sheet.sortRange(headerCount, 0, nextDataRowIndex-headerCount, colCount, true,[
  643. { index: 1, ascending: false,compareFunction: function (value1, value2) {
  644. if(!value1) return -1;
  645. return value1.localeCompare(value2)
  646. }}
  647. ]);
  648. }*/
  649. function TipCellType() {
  650. }
  651. TipCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
  652. TipCellType.prototype.getHitInfo = function(x, y, cellStyle, cellRect, context) {
  653. return {
  654. x: x,
  655. y: y,
  656. row: context.row,
  657. col: context.col,
  658. cellStyle: cellStyle,
  659. cellRect: cellRect,
  660. sheetArea: context.sheetArea
  661. };
  662. }
  663. TipCellType.prototype.processMouseEnter = function(hitinfo) {
  664. if (!this._toolTipElement) {
  665. var div = document.createElement("div");
  666. $(div).css("position", "absolute")
  667. .css("border", "1px #C0C0C0 solid")
  668. .css("box-shadow", "1px 2px 5px rgba(0,0,0,0.4)")
  669. .css("font", "9pt Arial")
  670. .css("background", "white")
  671. .css("padding", 5);
  672. this._toolTipElement = div;
  673. }
  674. $(this._toolTipElement).text("Cell [R:" + hitinfo.row + "] : [C:" + hitinfo.col + "]")
  675. .css("top", hitinfo.y + 15)
  676. .css("left", hitinfo.x + 15);
  677. $(this._toolTipElement).hide();
  678. document.body.insertBefore(this._toolTipElement, null);
  679. $(this._toolTipElement).show("fast");
  680. };
  681. TipCellType.prototype.processMouseLeave = function(hitinfo) {
  682. if (this._toolTipElement) {
  683. document.body.removeChild(this._toolTipElement);
  684. this._toolTipElement = null;
  685. }
  686. };