main_tree_col.js 39 KB

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