main_tree_col.js 32 KB

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