main_tree_col.js 36 KB

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