main_tree_col.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /**
  2. * Created by Mai on 2017/7/25.
  3. */
  4. let MainTreeCol = {
  5. getText: {
  6. subType: function (node) {
  7. if (node.sourceType === projectObj.project.Bills.getSourceType()) {
  8. return billText[node.data.type];
  9. // CSL, 2017-11-29
  10. } else if (node.sourceType === projectObj.project.Ration.getSourceType()) {
  11. if (node.data.type == 1 || node.data.type == undefined) // 兼容旧定额
  12. return '定';
  13. else if (node.data.type == 2) { // 量价
  14. return volumePriceMaps[node.data.subType];
  15. }
  16. else if (node.data.type == 3) { // 工料机定额
  17. return projectObj.project.projectGLJ.getShortNameByID(node.data.subType);//工料机名字缩写
  18. }else if(node.data.type == 4){//安装增加费生成的定额
  19. return '安';
  20. }
  21. } else if (node.sourceType === projectObj.project.ration_glj.getSourceType()) {
  22. return projectObj.project.projectGLJ.getShortNameByID(node.data.subType);//工料机名字缩写
  23. }
  24. },
  25. quantity:function (node) {
  26. if(node.sourceType === projectObj.project.ration_glj.getSourceType()){
  27. return gljOprObj.getTotalQuantity(node.data);
  28. }else {
  29. return calcTools.uiNodeQty(node)?calcTools.uiNodeQty(node):null;
  30. }
  31. },
  32. // CSL, 2017-11-28
  33. calcProgramName: function (node) {
  34. let programID = node.data.programID;
  35. if (!programID) return
  36. else return projectObj.project.calcProgram.compiledTemplateMaps[programID];
  37. },
  38. calcBase: function (node) {
  39. if (node.data.calcBase && node.data.calcBase != ""){
  40. return cbParser.toFExpr(node.data.calcBase);
  41. }
  42. },
  43. code: function (node) {
  44. if(!isDef(node)){
  45. return '';
  46. }
  47. let rst = '';
  48. if(node.sourceType === projectObj.project.Ration.getSourceType() && node.data.type === rationType.ration
  49. && isDef(node.data.code) && isDef(node.data.prefix) && node.data.prefix !== ''){
  50. rst = node.data.prefix + node.data.code.replace(new RegExp(node.data.prefix, 'g'), '');
  51. }
  52. else
  53. rst = isDef(node.data.code) ? node.data.code : '';
  54. if (node.data.adjustState && rst != '')
  55. rst = rst + rationPrefix.replace;
  56. return rst;
  57. },
  58. marketPrice:function (node) {
  59. if((node.sourceType === projectObj.project.Ration.getSourceType()&&node.data.type!=rationType.ration)||node.sourceType==projectObj.project.ration_glj.getSourceType()){
  60. if(node.data.marketUnitFee) return calcTools.uiGLJPrice(node.data.marketUnitFee);
  61. }
  62. },
  63. feeRate:function (node) {
  64. if(node.data.feeRateID){
  65. let rate = projectObj.project.FeeRate.getFeeRateByID(node.data.feeRateID);
  66. if (rate) return rate.rate;
  67. }
  68. return node.data.feeRate;
  69. }
  70. },
  71. readOnly: {
  72. // Vincent, 2018-01-09
  73. subType: function (node) {
  74. if (calcTools.isVolumePrice(node)) return false;
  75. if(MainTreeCol.readOnly.bills(node)){
  76. return true;
  77. }
  78. if(MainTreeCol.readOnly.ration(node)){
  79. return true;
  80. }
  81. if(MainTreeCol.readOnly.non_editSubType(node)){
  82. return true;
  83. }else if(gljOprObj.hasComposition(node.data,node.sourceType === ModuleNames.ration)){
  84. return true;
  85. }
  86. return false;
  87. },
  88. calcProgramName: function (node) {
  89. if (node.sourceType === projectObj.project.Ration.getSourceType() ||
  90. (calcTools.isLeafBill(node) && projectObj.project.property.billsCalcMode === leafBillGetFeeType.billsPrice)
  91. ) {
  92. //当打勾估价项目选项后,该定额取费专业只读
  93. if(node.data.evaluationProject == 1){
  94. return true;
  95. }
  96. return false;
  97. }
  98. return true;
  99. },
  100. non_editSubType: function (node) {
  101. return node.data.subType != 201 && node.data.subType != 4 && node.data.subType != 5
  102. },
  103. commonUnitFee: function (node) {
  104. // 09-29 zhang
  105. let Bills =projectObj.project.Bills;
  106. // 当前属于分部分项、施工技术措施项目,综合单价只读。
  107. if(Bills.isFBFX(node)||Bills.isTechMeasure(node)){
  108. return true;
  109. }
  110. // 不属于分部分项、施工技术措施项目的部分,如果不是叶子清单,或有基数计算/定额/量价/人材机 只读
  111. if(!calcTools.isLeafBill(node)||calcTools.isCalcBaseBill(node)||node.children.length > 0){
  112. return true;
  113. }
  114. return false;
  115. //return !(calcTools.isLeafBill(node) && !calcTools.isBill_DXFY(node) && !calcTools.isCalcBaseBill(node) && !calcTools.isInheritFrom(node, [fixedFlag.SUB_ENGINERRING, fixedFlag.MEASURE]));
  116. },
  117. //根据节点、父节点类型判断是否可用计算基数
  118. calcBaseType: function (node) {
  119. function isDef(v) {
  120. return v !== undefined && v !== null;
  121. }
  122. function isFlag(v) {
  123. return this.isDef(v.flagsIndex) && this.isDef(v.flagsIndex.fixed);
  124. }
  125. let calcBase = projectObj.project.calcBase;
  126. let parent = node.parent;
  127. if (isFlag(node.data) && (node.data.flagsIndex.fixed.flag === calcBase.fixedFlag.SUB_ENGINERRING
  128. || node.data.flagsIndex.fixed.flag === calcBase.fixedFlag.CONSTRUCTION_TECH)) {
  129. return true;
  130. }
  131. else if (isFlag(node.data) && node.data.flagsIndex.fixed.flag === calcBase.fixedFlag.CONSTRUCTION_ORGANIZATION) {
  132. return false;
  133. }
  134. else {
  135. if (!parent) {
  136. return false;
  137. }
  138. else {
  139. return this.calcBaseType(parent);
  140. }
  141. }
  142. },
  143. bills: function (node) {
  144. return node.sourceType === projectObj.project.Bills.getSourceType();
  145. },
  146. ration: function (node) {
  147. return calcTools.isRationItem(node);
  148. },
  149. isSubcontract: function (node) {
  150. return !calcTools.isRationCategory(node);
  151. },
  152. glj: function (node) {
  153. return node.sourceType == projectObj.project.ration_glj.getSourceType();
  154. },
  155. volumePrice: function (node) {
  156. return (node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation);
  157. },
  158. non_bills: function (node) {
  159. return node.sourceType !== projectObj.project.Bills.getSourceType();
  160. },
  161. non_ration: function (node) {
  162. return node.sourceType !== projectObj.project.Ration.getSourceType();
  163. },
  164. non_volumePrice: function (node) {
  165. return !(node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation);
  166. },
  167. billsParent: function (node) {
  168. return node.sourceType === projectObj.project.Bills.getSourceType() && node.source.children.length > 0;
  169. },
  170. leafBillsWithDetail: function (node) {
  171. return (!MainTreeCol.readOnly.billsParent(node)) && (node.children.length > 0);
  172. },
  173. forCalcBase: function (node) {
  174. // to do according to billsParentType
  175. return MainTreeCol.readOnly.billsParent(node) || MainTreeCol.readOnly.non_bills(node) || MainTreeCol.readOnly.leafBillsWithDetail(node) || MainTreeCol.readOnly.calcBaseType(node);
  176. },
  177. forUnitFee: function (node) {
  178. return MainTreeCol.readOnly.ration(node) || MainTreeCol.readOnly.billsParent(node) || MainTreeCol.readOnly.leafBillsWithDetail(node);
  179. },
  180. forTotalFee: function (node) {
  181. return MainTreeCol.readOnly.non_bills(node) || MainTreeCol.readOnly.billsParent(node) || (MainTreeCol.readOnly.leafBillsWithDetail(node));
  182. },
  183. forQuantifyDetail: function (node) {
  184. return !(node.sourceType == ModuleNames.ration || !MainTreeCol.readOnly.billsParent(node));
  185. },
  186. forFeeRate: function (node) {
  187. let readOnly = true;
  188. let Bills = projectObj.project.Bills;
  189. //只有当选中节点是清单,并且不属于“分部分项工程”或“技术措施项目”,并且是叶子清单且没有定额/量价/工料机时,费率列才可编辑
  190. if(MainTreeCol.readOnly.bills(node)){
  191. if(!Bills.isFBFX(node)&&!Bills.isTechMeasure(node)&&node.children.length<=0){//不属于“分部分项工程”或“技术措施项目”,并且是叶子清单且没有定额/量价/工料机
  192. readOnly = false;
  193. }
  194. }
  195. return readOnly;
  196. },
  197. forQuantity: function (node) {
  198. if(node.sourceType === projectObj.project.Bills.getSourceType()){
  199. if(node.data.type==billType.DXFY||node.data.type==billType.FB||(node.data.type==billType.BILL&&MainTreeCol.readOnly.billsParent(node))){//大项费用、分部、清单父项行,工程量只读。
  200. return true;
  201. }
  202. }else if(MainTreeCol.readOnly.glj(node)){
  203. return true;
  204. }
  205. return false;
  206. },
  207. forMarketPrice: function (node) {
  208. return MainTreeCol.readOnly.bills(node) ||
  209. (node.sourceType === ModuleNames.ration && node.data.type == rationType.ration) ||
  210. gljOprObj.marketPriceReadOnly(node);
  211. },
  212. forContain:function (node) {
  213. return MainTreeCol.readOnly.non_ration(node)&&!MainTreeCol.readOnly.glj(node);
  214. },
  215. forCode:function (node) {
  216. let Bills = projectObj.project.Bills;
  217. if(MainTreeCol.readOnly.glj(node)|| (node.sourceType === projectObj.project.Ration.getSourceType()&&node.data.type===rationType.gljRation)){//是主材或者设备、或者是工料机类型的定额
  218. return true;
  219. }
  220. if(Bills.isTopThreeNode(node)){//是大项1、2、3项的编号设置为只读
  221. return true;
  222. }
  223. return false;
  224. },
  225. forName:function (node) {
  226. if(projectObj.project.Bills.isTopThreeNode(node)){//是大项1、2、3项的编号设置为只读
  227. return true;
  228. }
  229. return false;
  230. },
  231. forUnit:function (node) {
  232. if(MainTreeCol.readOnly.bills(node)&&(node.data.type==billType.DXFY||node.data.type==billType.FB)){//在大项费用、分部行,计量单位只读。
  233. return true;
  234. }else {
  235. return calcTools.isRationItem(node);
  236. }
  237. },
  238. forContentCharacter: function (node) {
  239. return !MainTreeCol.readOnly.bills(node) || (node.data.type !== billType.BILL && node.data.type !== billType.FX);
  240. },
  241. forRuleText: function (node) {
  242. if(MainTreeCol.readOnly.bills(node)){
  243. if(node.data.type === billType.FX || (node.data.type === billType.BILL && node.source.children.length === 0)){
  244. return false;
  245. }
  246. }
  247. return true;
  248. }
  249. },
  250. cellType: {
  251. unit: function (node,setting) {
  252. let tips = "";
  253. //在这里做要不要显示的判断
  254. if(node.sourceType == ModuleNames.bills &&projectObj.ifItemCharHiden(setting)){//清单、并且项目特征列隐藏的时候悬浮提示
  255. tips = node.data.itemCharacterText?node.data.itemCharacterText:'';
  256. }
  257. if(node.sourceType == ModuleNames.ration && node.data.type == rationType.ration){//定额类型时,显示人材机,工作内容等
  258. //这里的人材机需要进行过滤,在初始化时组装会影响性能,应实时显示
  259. tips = MainTreeCol.getRationUnitTips
  260. }
  261. let dynamicCombo = sheetCommonObj.getTipsCombo(true,tips,setting,node);//sheetCommonObj.getDynamicCombo(true);
  262. dynamicCombo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
  263. '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']).editable(true);
  264. return dynamicCombo;
  265. },
  266. units: function () {
  267. this.unit;
  268. },
  269. feeRate: function () {
  270. return feeRateObject.getFeeRateEditCellType();
  271. },
  272. quantity:function (node) {
  273. if(!MainTreeCol.readOnly.forQuantity(node)){
  274. return quantityEditObj.getQuantityEditCellType();
  275. }
  276. },
  277. calcBase: function () {
  278. return calcBaseView.getCalcBaseCellType('bills');
  279. },
  280. // CSL, 2017-11-28
  281. calcProgramName: function (node) {
  282. if (
  283. node.sourceType === projectObj.project.Ration.getSourceType() ||
  284. (calcTools.isLeafBill(node) && projectObj.project.property.billsCalcMode === leafBillGetFeeType.billsPrice)
  285. ) {
  286. // var names = new GC.Spread.Sheets.CellTypes.ComboBox();
  287. var names = sheetCommonObj.getDynamicCombo();
  288. names.items(projectObj.project.calcProgram.compiledTemplateNames);
  289. return names;
  290. }
  291. },
  292. // Vincent, 2018-01-09
  293. subType: function (node) {
  294. if(node.sourceType!=projectObj.project.Bills.getSourceType()){
  295. let VPType = sheetCommonObj.getDynamicCombo();
  296. if(node.sourceType == projectObj.project.Ration.getSourceType()){//是定额类型
  297. if(node.data.type == rationType.volumePrice){
  298. VPType.itemHeight(5).items(["人工", "材料", "机械", "主材", "设备"])
  299. return VPType;
  300. }else if(node.data.type == rationType.gljRation){
  301. if(!MainTreeCol.readOnly.non_editSubType(node)&&gljOprObj.hasComposition(node.data,true)==false){
  302. VPType.itemHeight(3).items(["材料", "主材", "设备"]);
  303. return VPType;
  304. }
  305. }
  306. }else if(node.sourceType === projectObj.project.ration_glj.getSourceType()){//是工料机类型
  307. if(!MainTreeCol.readOnly.non_editSubType(node)&&gljOprObj.hasComposition(node.data)==false){
  308. VPType.itemHeight(3).items(["材料", "主材", "设备"]);
  309. return VPType;
  310. }
  311. }
  312. }
  313. },
  314. isSubcontract: function (node){
  315. if (calcTools.isRationCategory(node))
  316. return new GC.Spread.Sheets.CellTypes.CheckBox();
  317. },
  318. isEstimate:function (node) {
  319. //只对分项、补项、材料(包括混凝土等)、主材、设备有效
  320. if(MainTreeCol.readOnly.glj(node)||(calcTools.isGljRation(node)&&projectObj.project.projectGLJ.isEstimateType(node.data.subType))||(MainTreeCol.readOnly.bills(node)&&(node.data.type == billType.BX||node.data.type == billType.FX))){
  321. return new GC.Spread.Sheets.CellTypes.CheckBox();
  322. }
  323. },
  324. evaluationProject:function (node) {
  325. if(node.sourceType == ModuleNames.ration){
  326. return new GC.Spread.Sheets.CellTypes.CheckBox();
  327. }
  328. },
  329. commonTotalFee: function () {
  330. return projectObj.getCommonTotalFeeCellType();
  331. }
  332. },
  333. editChecking:function(node){
  334. if(node.sourceType==projectObj.project.Bills.getSourceType()&&projectObj.project.isBillsLocked()&&projectObj.project.withinBillsLocked(node)){
  335. return true;
  336. }
  337. if(gljOprObj.isInstallationNode(node)){//如果是通过安装增加费自动生成的,都是只读类型
  338. return true;
  339. }
  340. return false;
  341. },
  342. setAutoHeight:function (cell,node) {//设置自动行高
  343. cell.wordWrap(MainTreeCol.needAutoFit(node));
  344. },
  345. setAutoFitRow:function (sheet,node) {
  346. if(MainTreeCol.needAutoFit(node)){
  347. sheet.autoFitRow(node.serialNo());
  348. }
  349. },
  350. needAutoFit:function (node) {
  351. let displaySetting = projectObj.project.property.displaySetting;
  352. let billsAutoH = displaySetting && displaySetting.billsAutoHeight?displaySetting.billsAutoHeight:false;
  353. let rationAutoH = displaySetting && displaySetting.rationAutoHeight?displaySetting.rationAutoHeight:false;
  354. if(node.sourceType === projectObj.project.Bills.getSourceType()&&billsAutoH == true){
  355. return true;
  356. }
  357. if(node.sourceType !== projectObj.project.Bills.getSourceType()&& rationAutoH == true){
  358. return true;
  359. }
  360. return false;
  361. },
  362. getEvent: function (eventName) {
  363. let names = eventName.split('.');
  364. let event = this;
  365. for (let name of names) {
  366. if (event[name]) {
  367. event = event[name];
  368. } else {
  369. return null;
  370. }
  371. }
  372. if (event && Object.prototype.toString.apply(event) !== "[object Function]") {
  373. return null;
  374. } else {
  375. return event;
  376. }
  377. },
  378. getNumberFormatter: function (digit, align) { // CSL, 2017-11-30 扩展:小数点是否对齐。
  379. if (align) {
  380. switch (digit) {
  381. case 1:
  382. return '0.0';
  383. case 2:
  384. return '0.00';
  385. case 3:
  386. return '0.000';
  387. case 4:
  388. return '0.0000';
  389. case 5:
  390. return '0.00000';
  391. case 6:
  392. return '0.000000';
  393. default:
  394. return '0';
  395. }
  396. ;
  397. }
  398. else {
  399. switch (digit) {
  400. case 1:
  401. return '0.#';
  402. case 2:
  403. return '0.##';
  404. case 3:
  405. return '0.###';
  406. case 4:
  407. return '0.####';
  408. case 5:
  409. return '0.#####';
  410. case 6:
  411. return '0.######';
  412. default:
  413. return '0';
  414. }
  415. ;
  416. }
  417. },
  418. getRationUnitTips:function (node) {
  419. let tips="";
  420. let ration_glj = projectObj.project.ration_glj;
  421. let gljList = gljOprObj.filterGljByRation(node.data, ration_glj.datas);
  422. for(let glj of gljList){
  423. tips += `${glj.code} ${glj.name}${glj.specs ? '&nbsp;&nbsp;&nbsp;' + glj.specs : ''}&nbsp;&nbsp&nbsp;${glj.unit}&nbsp;&nbsp;&nbsp;${glj.quantity}<br>`;
  424. }
  425. if(node.data.content && node.data.content.toString().trim() !== ''){
  426. tips += `工作内容:<br>`;
  427. tips += `${node.data.content.replace(/\n/g,"<br>")}<br>`;
  428. }
  429. if(node.data.annotation && node.data.annotation.toString().trim() !== ''){
  430. tips += `附注:<br>`;
  431. tips += `${node.data.annotation.replace(/\n/g,"<br>")}<br>`;
  432. }
  433. return tips
  434. }
  435. };
  436. let colSettingObj = {
  437. settingSpread: null,
  438. checkBox: new GC.Spread.Sheets.CellTypes.CheckBox(),
  439. loadSetting: function (sheet, setting) {
  440. sheet.suspendPaint();
  441. sheet.suspendEvent();
  442. sheet.setRowCount(setting.cols.length);
  443. sheet.setColumnCount(setting.headRows, GC.Spread.Sheets.SheetArea.rowHeader);
  444. sheet.setColumnCount(1);
  445. sheet.getRange(-1, 0, -1, 1).cellType(this.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
  446. sheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.colHeader).value('显示');
  447. sheet.setColumnWidth(0, 100);
  448. sheet.setColumnWidth(0, 240, GC.Spread.Sheets.SheetArea.rowHeader);
  449. setting.cols.forEach(function (col, index) {
  450. let i, iCol = 0, cell;
  451. for (i = 0; i < col.head.spanCols.length; i++) {
  452. if (col.head.spanCols[i] !== 0) {
  453. cell = sheet.getCell(index, iCol, GC.Spread.Sheets.SheetArea.rowHeader);
  454. cell.value(col.head.titleNames[i]).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]);
  455. //cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]);
  456. }
  457. if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
  458. sheet.addSpan(index, iCol, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.rowHeader);
  459. }
  460. iCol += col.head.spanRows[i];
  461. };
  462. let colWidth = sheet.getColumnWidth(index, GC.Spread.Sheets.SheetArea.rowHeader);
  463. colWidth = colWidth > col.width ? colWidth : col.width;
  464. //sheet.setColumnWidth(index, colWidth, GC.Spread.Sheets.SheetArea.rowHeader);
  465. cell = sheet.getCell(index, 0).value(col.visible);
  466. sheet.autoFitRow(index);
  467. });
  468. sheet.resumeEvent();
  469. sheet.resumePaint();
  470. },
  471. initSettingSpread: function () {
  472. this.settingSpread = SheetDataHelper.createNewSpread($('#col_setting_spread')[0], {sheetCount: 1});
  473. sheetCommonObj.spreadDefaultStyle(this.settingSpread);
  474. this.settingSpread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.vertical;
  475. this.settingSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, function (sender, args) {
  476. if(args.sheet.isEditing()){
  477. args.sheet.endEdit(true);
  478. }
  479. });
  480. this.loadSetting(this.settingSpread.getActiveSheet(), projectObj.project.projSetting.main_tree_col);
  481. },
  482. dataChanged: function () {
  483. let sheet = this.settingSpread.getActiveSheet();
  484. for(let row = 0; row < sheet.getRowCount(); row++){
  485. let orgData = projectObj.project.projSetting.main_tree_col.cols[row].visible;
  486. let newData = sheet.getValue(row, 0);
  487. if(orgData != newData){
  488. return true;
  489. }
  490. }
  491. return false;
  492. },
  493. updateColSetting: function (skipSetValue = false) {
  494. let mainSheet = projectObj.mainSpread.getActiveSheet();
  495. if(!skipSetValue){
  496. let sheet = this.settingSpread.getActiveSheet();
  497. for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
  498. projectObj.project.projSetting.main_tree_col.cols[iRow].visible = sheet.getValue(iRow, 0);
  499. projectObj.project.projSetting.mainGridSetting.cols[iRow].visible = sheet.getValue(iRow, 0);
  500. }
  501. }
  502. SheetDataHelper.massOperationSheet(mainSheet, function () {
  503. SheetDataHelper.refreshColumnVisible(projectObj.project.projSetting.mainGridSetting, mainSheet);
  504. //左右滚动条到最左边
  505. mainSheet.showColumn(projectObj.project.projSetting.mainGridSetting.frozenCols, GC.Spread.Sheets.HorizontalPosition.left);
  506. });
  507. //refresh nodes to autoFitRow
  508. projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots, true);
  509. if(!skipSetValue){
  510. //列设置将项目特征和工作内容都取消打钩后,更新快速列设置
  511. if(!this.getVisible('itemCharacterText')){
  512. switchTznrHtml(true);
  513. }
  514. if(this.getVisible('itemCharacterText')){
  515. switchTznrHtml(false);
  516. }
  517. }
  518. //别人分享过来的项目,打开时,“显示特征”按钮应有效,不影响数据的修改
  519. if(!projectReadOnly){
  520. projectObj.project.pushNow('editColSetting', projectObj.project.projSetting.moduleName, {
  521. projectID: projectObj.project.ID(),
  522. main_tree_col: projectObj.project.projSetting.main_tree_col
  523. });
  524. }
  525. },
  526. setVisible: function (field, visible) {
  527. let mainTreeCols = projectObj.project.projSetting.main_tree_col.cols;
  528. for(let colSetting of mainTreeCols){
  529. if(colSetting.data.field === field){
  530. colSetting.visible = visible;
  531. break;
  532. }
  533. }
  534. let mainGridCols = projectObj.project.projSetting.mainGridSetting.cols;
  535. for(let colSetting of mainGridCols){
  536. if(colSetting.data.field === field){
  537. colSetting.visible = visible;
  538. break;
  539. }
  540. }
  541. },
  542. getVisible: function(field){
  543. let cols = projectObj.project.projSetting.main_tree_col.cols;
  544. for(let colSetting of cols){
  545. if(colSetting.data.field === field){
  546. return colSetting.visible;
  547. }
  548. }
  549. return false;
  550. },
  551. getColByField: function (field) {
  552. let cols = projectObj.project.projSetting.main_tree_col.cols;
  553. for(let i = 0; i < cols.length; i++){
  554. let colSetting = cols[i];
  555. if(colSetting.data.field === field){
  556. return i;
  557. }
  558. }
  559. return null;
  560. },
  561. getFieldByCol: function (col) {
  562. let cols = projectObj.project.projSetting.main_tree_col.cols;
  563. let colSetting = cols[col];
  564. return colSetting ? colSetting.data.field : null;
  565. }
  566. };
  567. function switchTznrHtml(show) {
  568. if(show){
  569. $('#switchTznr').html('<i class="fa fa-eye" aria-hidden="true"></i> 显示特征');
  570. }
  571. else {
  572. $('#switchTznr').html('<i class="fa fa-eye-slash" aria-hidden="true"></i> 隐藏特征');
  573. }
  574. }
  575. $('#switchTznr').click(function () {
  576. let me = colSettingObj;
  577. let cur = $(this).text();
  578. if(cur.includes('显示特征')){
  579. switchTznrHtml(false);
  580. me.setVisible('itemCharacterText', true);
  581. me.updateColSetting(true);
  582. }
  583. else {
  584. switchTznrHtml(true);
  585. me.setVisible('itemCharacterText', false);
  586. me.updateColSetting(true);
  587. }
  588. let mainSheet = projectObj.mainSpread.getActiveSheet();
  589. mainSheet.showRow(mainSheet.getActiveRowIndex(), GC.Spread.Sheets.VerticalPosition.center);
  590. });
  591. $('#poj-set').on('shown.bs.modal', function (e) {
  592. if (!colSettingObj.settingSpread) {
  593. colSettingObj.initSettingSpread();
  594. if(projectReadOnly){
  595. disableSpread(colSettingObj.settingSpread);
  596. }
  597. }
  598. if($('#tab_display_setting').hasClass('active')){
  599. let sheet = colSettingObj.settingSpread.getActiveSheet();
  600. SheetDataHelper.massOperationSheet(sheet, function () {
  601. for(let row = 0; row < sheet.getRowCount(); row++){
  602. let orgData = projectObj.project.projSetting.main_tree_col.cols[row].visible;
  603. sheet.setValue(row, 0, orgData);
  604. }
  605. });
  606. }
  607. });
  608. $('#poj-set').on('hidden.bs.modal', function (e) {
  609. if (colSettingObj.settingSpread) {
  610. //恢复
  611. let sheet = colSettingObj.settingSpread.getActiveSheet();
  612. SheetDataHelper.massOperationSheet(sheet, function () {
  613. for(let row = 0; row < sheet.getRowCount(); row++){
  614. let orgData = projectObj.project.projSetting.main_tree_col.cols[row].visible;
  615. sheet.setValue(row, 0, orgData);
  616. }
  617. });
  618. }
  619. });
  620. $('#tab_display_setting').on('shown.bs.tab', function () {
  621. if(colSettingObj.settingSpread){
  622. colSettingObj.settingSpread.refresh();
  623. }
  624. });