main_tree_col.js 31 KB

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