main_tree_col.js 30 KB

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