main_tree_col.js 39 KB

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