main_tree_col.js 35 KB

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