main_tree_col.js 26 KB

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