main_tree_col.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  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.isFBFX(node)||Bills.isTechMeasure(node)) return true;
  120. // 不属于分部分项、施工技术措施项目的部分,如果不是叶子清单,或有基数计算/定额/量价/人材机 只读
  121. if(!calcTools.isLeafBill(node)||calcTools.isCalcBaseBill(node)||node.children.length > 0)return true;
  122. }
  123. //当前是定额,综合单价只读。 2018-11-15
  124. if(MainTreeCol.readOnly.ration(node)) return true;
  125. return false;
  126. },
  127. commonTotalFee: function (node) {
  128. // 属于标题清单,只读
  129. if (node.sourceType == ModuleNames.bills &&
  130. calcTools.isTitleBills(node)) {
  131. return true;
  132. }
  133. // 09-29 zhang
  134. let Bills =projectObj.project.Bills;
  135. // 当前属于分部分项、施工技术措施项目,综合单价只读。
  136. if(Bills.isFBFX(node)||Bills.isTechMeasure(node)){
  137. return true;
  138. }
  139. // 不属于分部分项、施工技术措施项目的部分,如果不是叶子清单,或有基数计算/定额/量价/人材机 只读
  140. if(!calcTools.isLeafBill(node)||calcTools.isCalcBaseBill(node)||node.children.length > 0){
  141. return true;
  142. }
  143. return false;
  144. },
  145. //根据节点、父节点类型判断是否可用计算基数
  146. calcBaseType: function (node) {
  147. function isDef(v) {
  148. return v !== undefined && v !== null;
  149. }
  150. function isFlag(v) {
  151. return this.isDef(v.flagsIndex) && this.isDef(v.flagsIndex.fixed);
  152. }
  153. let calcBase = projectObj.project.calcBase;
  154. let parent = node.parent;
  155. if (isFlag(node.data) && (node.data.flagsIndex.fixed.flag === calcBase.fixedFlag.SUB_ENGINERRING
  156. || node.data.flagsIndex.fixed.flag === calcBase.fixedFlag.CONSTRUCTION_TECH)) {
  157. return true;
  158. }
  159. else if (isFlag(node.data) && node.data.flagsIndex.fixed.flag === calcBase.fixedFlag.CONSTRUCTION_ORGANIZATION) {
  160. return false;
  161. }
  162. else {
  163. if (!parent) {
  164. return false;
  165. }
  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)){
  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. if(Bills.isTopThreeNode(node)){//是大项1、2、3项的编号设置为只读
  263. return true;
  264. }
  265. return false;
  266. },
  267. forName:function (node) {
  268. // 属于标题清单,只读
  269. if (node.sourceType == ModuleNames.bills &&
  270. calcTools.isTitleBills(node)) {
  271. return true;
  272. }
  273. if(projectObj.project.Bills.isTopThreeNode(node)){//是大项1、2、3项的编号设置为只读
  274. return true;
  275. }
  276. return false;
  277. },
  278. forUnit:function (node) {
  279. if(MainTreeCol.readOnly.bills(node)&&(node.data.type==billType.DXFY||node.data.type==billType.FB)){//在大项费用、分部行,计量单位只读。
  280. return true;
  281. }else {
  282. return calcTools.isRationItem(node);
  283. }
  284. },
  285. forContentCharacter: function (node, field) {
  286. // 定额工作内容下拉
  287. if (_compilationConfig.dynamicRationWorkContent &&
  288. node.sourceType === projectObj.project.Ration.getSourceType() &&
  289. field === 'jobContentText') {
  290. return false;
  291. }
  292. return !MainTreeCol.readOnly.bills(node) || (node.data.type !== billType.BILL && node.data.type !== billType.FX);
  293. },
  294. forRuleText: function (node) {
  295. if(MainTreeCol.readOnly.bills(node)){
  296. if(node.data.type === billType.FX || (node.data.type === billType.BILL && node.source.children.length === 0)){
  297. return false;
  298. }
  299. }
  300. return true;
  301. },
  302. maxPrice:function (node) {
  303. if($("#fileKind").val() == '1') return true;//对于投标项目只读
  304. return node.data.outPutMaxPrice!==true;
  305. }
  306. },
  307. cellType: {
  308. unit: function (node,setting) {
  309. let tips = "";
  310. //在这里做要不要显示的判断
  311. if(node.sourceType == ModuleNames.bills &&projectObj.ifItemCharHiden(setting)){//清单、并且项目特征列隐藏的时候悬浮提示
  312. tips = node.data.itemCharacterText?node.data.itemCharacterText:'';
  313. }
  314. if(node.sourceType == ModuleNames.ration && node.data.type == rationType.ration){//定额类型时,显示人材机,工作内容等
  315. //这里的人材机需要进行过滤,在初始化时组装会影响性能,应实时显示
  316. tips = MainTreeCol.getRationUnitTips
  317. }
  318. let dynamicCombo = sheetCommonObj.getTipsCombo(true,tips,setting,node);//sheetCommonObj.getDynamicCombo(true);
  319. dynamicCombo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
  320. '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']).editable(true);
  321. return dynamicCombo;
  322. },
  323. units: function () {
  324. this.unit;
  325. },
  326. jobContent: function (node) {
  327. // 定额工作内容下拉
  328. if (_compilationConfig.dynamicRationWorkContent &&
  329. node.sourceType === projectObj.project.Ration.getSourceType()) {
  330. let combo = sheetCommonObj.getDynamicCombo();
  331. combo._maxDropDownItems = 10;
  332. combo.items(contentOprObj.getContentTexts(node.parent));
  333. return combo;
  334. }
  335. },
  336. feeRate: function () {
  337. return feeRateObject.getFeeRateEditCellType();
  338. },
  339. quantity:function (node) {
  340. if(!MainTreeCol.readOnly.forQuantity(node)){
  341. return quantityEditObj.getQuantityEditCellType();
  342. }
  343. },
  344. calcBase: function (node) {
  345. let readOnly = projectReadOnly || !calcBaseView.ifEdit('bills', projectObj.project.mainTree.items.indexOf(node));
  346. return sheetCommonObj.getCusButtonCellType(calcBaseView.onCalcBaseButtonClick,readOnly)
  347. },
  348. // CSL, 2017-11-28
  349. calcProgramName: function (node) {
  350. if (
  351. node.sourceType === projectObj.project.Ration.getSourceType() ||
  352. (calcTools.isLeafBill(node) && projectObj.project.property.billsCalcMode === leafBillGetFeeType.billsPrice)
  353. ) {
  354. // var names = new GC.Spread.Sheets.CellTypes.ComboBox();
  355. var names = sheetCommonObj.getDynamicCombo();
  356. names._maxDropDownItems = 10;
  357. names.items(projectObj.project.calcProgram.compiledTemplateNames);
  358. return names;
  359. }
  360. },
  361. // Vincent, 2018-01-09
  362. subType: function (node) {
  363. if(node.sourceType!=projectObj.project.Bills.getSourceType()){
  364. let VPType = sheetCommonObj.getDynamicCombo();
  365. if(node.sourceType == projectObj.project.Ration.getSourceType()){//是定额类型
  366. if(node.data.type == rationType.volumePrice){
  367. VPType.itemHeight(5).items(["人工", "材料", "机械", "主材", "设备"])
  368. return VPType;
  369. }else if(node.data.type == rationType.gljRation){
  370. if(!MainTreeCol.readOnly.non_editSubType(node)&&gljOprObj.hasComposition(node.data,true)==false){
  371. VPType.itemHeight(3).items(["材料", "主材", "设备"]);
  372. return VPType;
  373. }
  374. }
  375. }else if(node.sourceType === projectObj.project.ration_glj.getSourceType()){//是工料机类型
  376. if(!MainTreeCol.readOnly.non_editSubType(node)&&gljOprObj.hasComposition(node.data)==false){
  377. VPType.itemHeight(3).items(["材料", "主材", "设备"]);
  378. return VPType;
  379. }
  380. }
  381. }
  382. },
  383. isSubcontract: function (node){
  384. if (calcTools.isRationCategory(node))
  385. return new GC.Spread.Sheets.CellTypes.CheckBox();
  386. },
  387. isEstimate:function (node) {
  388. //只对分项、补项、材料(包括混凝土等)、主材、设备有效
  389. 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))){
  390. return new GC.Spread.Sheets.CellTypes.CheckBox();
  391. }
  392. },
  393. evaluationProject:function (node) {
  394. if(node.sourceType == ModuleNames.ration){
  395. return new GC.Spread.Sheets.CellTypes.CheckBox();
  396. }
  397. },
  398. commonTotalFee: function (node) {
  399. let readOnly = projectReadOnly || !calcBaseView.ifEdit('bills', projectObj.project.mainTree.items.indexOf(node));
  400. return sheetCommonObj.getCusButtonCellType(projectObj.onCommonTotalFeeButtonClick,readOnly) //projectObj.getCommonTotalFeeCellType();
  401. },
  402. mainBills:function (node) {
  403. if(MainTreeCol.mainBillsEnable(node)) return sheetCommonObj.getCheckBox(true);
  404. },
  405. outPutMaxPrice:function (node) {
  406. if(MainTreeCol.mainBillsEnable(node) && $("#fileKind").val() != '1') return sheetCommonObj.getCheckBox(true);
  407. }
  408. },
  409. mainBillsEnable:function (node) {
  410. let Bills = projectObj.project.Bills;
  411. //仅“分部分项工程”或“施工技术措施项目”下的分部、分项、补项、清单可编辑
  412. return ((Bills.isFBFX(node)||Bills.isTechMeasure(node))&&node.sourceType == ModuleNames.bills)
  413. },
  414. editChecking:function(node){
  415. if(node.sourceType==projectObj.project.Bills.getSourceType()&&projectObj.project.isBillsLocked()&&projectObj.project.withinBillsLocked(node)){
  416. return true;
  417. }
  418. if(gljOprObj.isInstallationNode(node)){//如果是通过安装增加费自动生成的,都是只读类型
  419. return true;
  420. }
  421. return false;
  422. },
  423. setAutoHeight:function (cell,node) {//设置自动行高
  424. cell.wordWrap(MainTreeCol.needAutoFit(node));
  425. },
  426. setAutoFitRow:function (sheet,node) {
  427. if(MainTreeCol.needAutoFit(node)){
  428. sheet.autoFitRow(node.serialNo());
  429. }
  430. },
  431. needAutoFit:function (node) {
  432. let displaySetting = projectObj.project.property.displaySetting;
  433. let billsAutoH = displaySetting && displaySetting.billsAutoHeight?displaySetting.billsAutoHeight:false;
  434. let rationAutoH = displaySetting && displaySetting.rationAutoHeight?displaySetting.rationAutoHeight:false;
  435. if(node.sourceType === projectObj.project.Bills.getSourceType()&&billsAutoH == true){
  436. return true;
  437. }
  438. if(node.sourceType !== projectObj.project.Bills.getSourceType()&& rationAutoH == true){
  439. return true;
  440. }
  441. return false;
  442. },
  443. getEvent: function (eventName) {
  444. let names = eventName.split('.');
  445. let event = this;
  446. for (let name of names) {
  447. if (event[name]) {
  448. event = event[name];
  449. } else {
  450. return null;
  451. }
  452. }
  453. if (event && Object.prototype.toString.apply(event) !== "[object Function]") {
  454. return null;
  455. } else {
  456. return event;
  457. }
  458. },
  459. getNumberFormatter: function (digit, align) { // CSL, 2017-11-30 扩展:小数点是否对齐。
  460. if (align) {
  461. switch (digit) {
  462. case 1:
  463. return '0.0';
  464. case 2:
  465. return '0.00';
  466. case 3:
  467. return '0.000';
  468. case 4:
  469. return '0.0000';
  470. case 5:
  471. return '0.00000';
  472. case 6:
  473. return '0.000000';
  474. default:
  475. return '0';
  476. }
  477. ;
  478. }
  479. else {
  480. switch (digit) {
  481. case 1:
  482. return '0.#';
  483. case 2:
  484. return '0.##';
  485. case 3:
  486. return '0.###';
  487. case 4:
  488. return '0.####';
  489. case 5:
  490. return '0.#####';
  491. case 6:
  492. return '0.######';
  493. default:
  494. return '0';
  495. };
  496. }
  497. },
  498. getRationUnitTips:function (node) {
  499. let tips="";
  500. let ration_glj = projectObj.project.ration_glj;
  501. let gljList = gljOprObj.filterGljByRation(node.data, ration_glj.datas);
  502. gljList = gljUtil.sortRationGLJ(gljList);
  503. if(node.data.content && node.data.content.toString().trim() !== ''){
  504. tips += `<label class="nomargin font_blue">工作内容:<br>`;
  505. tips += `${node.data.content.replace(/\n/g,"<br>")}</label><br><br>`;
  506. }
  507. for(let glj of gljList){
  508. 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>`;
  509. }
  510. if(node.data.annotation && node.data.annotation.toString().trim() !== ''){
  511. tips +='<br>';
  512. tips += `附注:<br>`;
  513. tips += `${node.data.annotation.replace(/\n/g,"<br>")}<br>`;
  514. }
  515. return tips
  516. }
  517. };
  518. let colSettingObj = {
  519. settingSpread: null,
  520. checkBox: new GC.Spread.Sheets.CellTypes.CheckBox(),
  521. loadSetting: function (sheet, setting) {
  522. sheet.suspendPaint();
  523. sheet.suspendEvent();
  524. sheet.setRowCount(setting.cols.length);
  525. sheet.setColumnCount(setting.headRows, GC.Spread.Sheets.SheetArea.rowHeader);
  526. sheet.setColumnCount(1);
  527. sheet.getRange(-1, 0, -1, 1).cellType(this.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
  528. sheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.colHeader).value('显示');
  529. sheet.setColumnWidth(0, 100);
  530. sheet.setColumnWidth(0, 240, GC.Spread.Sheets.SheetArea.rowHeader);
  531. setting.cols.forEach(function (col, index) {
  532. let i, iCol = 0, cell;
  533. for (i = 0; i < col.head.spanCols.length; i++) {
  534. if (col.head.spanCols[i] !== 0) {
  535. cell = sheet.getCell(index, iCol, GC.Spread.Sheets.SheetArea.rowHeader);
  536. cell.value(col.head.titleNames[i]).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]);
  537. //cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]);
  538. }
  539. if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
  540. sheet.addSpan(index, iCol, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.rowHeader);
  541. }
  542. iCol += col.head.spanRows[i];
  543. };
  544. let colWidth = sheet.getColumnWidth(index, GC.Spread.Sheets.SheetArea.rowHeader);
  545. colWidth = colWidth > col.width ? colWidth : col.width;
  546. //sheet.setColumnWidth(index, colWidth, GC.Spread.Sheets.SheetArea.rowHeader);
  547. cell = sheet.getCell(index, 0).value(col.visible);
  548. sheet.autoFitRow(index);
  549. });
  550. sheet.resumeEvent();
  551. sheet.resumePaint();
  552. },
  553. initSettingSpread: function () {
  554. this.settingSpread = SheetDataHelper.createNewSpread($('#col_setting_spread')[0], {sheetCount: 1});
  555. sheetCommonObj.spreadDefaultStyle(this.settingSpread);
  556. this.settingSpread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.vertical;
  557. this.settingSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, function (sender, args) {
  558. if(args.sheet.isEditing()){
  559. args.sheet.endEdit(true);
  560. }
  561. });
  562. this.loadSetting(this.settingSpread.getActiveSheet(), projectObj.project.projSetting.main_tree_col);
  563. },
  564. dataChanged: function () {
  565. let sheet = this.settingSpread.getActiveSheet();
  566. for(let row = 0; row < sheet.getRowCount(); row++){
  567. let orgData = projectObj.project.projSetting.main_tree_col.cols[row].visible;
  568. let newData = sheet.getValue(row, 0);
  569. if(orgData != newData){
  570. return true;
  571. }
  572. }
  573. return false;
  574. },
  575. updateColSetting: function (skipSetValue = false) {
  576. let mainSheet = projectObj.mainSpread.getActiveSheet();
  577. if(!skipSetValue){
  578. let sheet = this.settingSpread.getActiveSheet();
  579. for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
  580. projectObj.project.projSetting.main_tree_col.cols[iRow].visible = sheet.getValue(iRow, 0);
  581. projectObj.project.projSetting.mainGridSetting.cols[iRow].visible = sheet.getValue(iRow, 0);
  582. }
  583. }
  584. SheetDataHelper.massOperationSheet(mainSheet, function () {
  585. SheetDataHelper.refreshColumnVisible(projectObj.project.projSetting.mainGridSetting, mainSheet);
  586. //左右滚动条到最左边
  587. mainSheet.showColumn(projectObj.project.projSetting.mainGridSetting.frozenCols, GC.Spread.Sheets.HorizontalPosition.left);
  588. });
  589. //refresh nodes to autoFitRow
  590. projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots, true);
  591. if(!skipSetValue){
  592. //列设置将项目特征和工作内容都取消打钩后,更新快速列设置
  593. if(!this.getVisible('itemCharacterText')){
  594. switchTznrHtml(true);
  595. }
  596. if(this.getVisible('itemCharacterText')){
  597. switchTznrHtml(false);
  598. }
  599. }
  600. //别人分享过来的项目,打开时,“显示特征”按钮应有效,不影响数据的修改
  601. if(!projectReadOnly){
  602. projectObj.project.pushNow('editColSetting', projectObj.project.projSetting.moduleName, {
  603. projectID: projectObj.project.ID(),
  604. main_tree_col: projectObj.project.projSetting.main_tree_col
  605. });
  606. }
  607. },
  608. setVisible: function (field, visible) {
  609. let mainTreeCols = projectObj.project.projSetting.main_tree_col.cols;
  610. for(let colSetting of mainTreeCols){
  611. if(colSetting.data.field === field){
  612. colSetting.visible = visible;
  613. break;
  614. }
  615. }
  616. let mainGridCols = projectObj.project.projSetting.mainGridSetting.cols;
  617. for(let colSetting of mainGridCols){
  618. if(colSetting.data.field === field){
  619. colSetting.visible = visible;
  620. break;
  621. }
  622. }
  623. },
  624. getVisible: function(field){
  625. let cols = projectObj.project.projSetting.main_tree_col.cols;
  626. for(let colSetting of cols){
  627. if(colSetting.data.field === field){
  628. return colSetting.visible;
  629. }
  630. }
  631. return false;
  632. },
  633. getColByField: function (field) {
  634. let cols = projectObj.project.projSetting.main_tree_col.cols;
  635. for(let i = 0; i < cols.length; i++){
  636. let colSetting = cols[i];
  637. if(colSetting.data.field === field){
  638. return i;
  639. }
  640. }
  641. return null;
  642. },
  643. getFieldByCol: function (col) {
  644. let cols = projectObj.project.projSetting.main_tree_col.cols;
  645. let colSetting = cols[col];
  646. return colSetting ? colSetting.data.field : null;
  647. }
  648. };
  649. function switchTznrHtml(show) {
  650. if(show){
  651. $('#switchTznr').html('<i class="fa fa-eye" aria-hidden="true"></i> 显示特征');
  652. }
  653. else {
  654. $('#switchTznr').html('<i class="fa fa-eye-slash" aria-hidden="true"></i> 隐藏特征');
  655. }
  656. }
  657. $('#switchTznr').click(function () {
  658. let me = colSettingObj;
  659. let cur = $(this).text();
  660. if(cur.includes('显示特征')){
  661. switchTznrHtml(false);
  662. me.setVisible('itemCharacterText', true);
  663. me.updateColSetting(true);
  664. }
  665. else {
  666. switchTznrHtml(true);
  667. me.setVisible('itemCharacterText', false);
  668. me.updateColSetting(true);
  669. }
  670. let mainSheet = projectObj.mainSpread.getActiveSheet();
  671. mainSheet.showRow(mainSheet.getActiveRowIndex(), GC.Spread.Sheets.VerticalPosition.center);
  672. });
  673. $('#poj-set').on('shown.bs.modal', function (e) {
  674. if (!colSettingObj.settingSpread) {
  675. colSettingObj.initSettingSpread();
  676. if(projectReadOnly){
  677. disableSpread(colSettingObj.settingSpread);
  678. }
  679. }
  680. if($('#tab_display_setting').hasClass('active')){
  681. let sheet = colSettingObj.settingSpread.getActiveSheet();
  682. SheetDataHelper.massOperationSheet(sheet, function () {
  683. for(let row = 0; row < sheet.getRowCount(); row++){
  684. let orgData = projectObj.project.projSetting.main_tree_col.cols[row].visible;
  685. sheet.setValue(row, 0, orgData);
  686. }
  687. });
  688. }
  689. });
  690. $('#poj-set').on('hidden.bs.modal', function (e) {
  691. if (colSettingObj.settingSpread) {
  692. //恢复
  693. let sheet = colSettingObj.settingSpread.getActiveSheet();
  694. SheetDataHelper.massOperationSheet(sheet, function () {
  695. for(let row = 0; row < sheet.getRowCount(); row++){
  696. let orgData = projectObj.project.projSetting.main_tree_col.cols[row].visible;
  697. sheet.setValue(row, 0, orgData);
  698. }
  699. });
  700. }
  701. });
  702. $('#tab_display_setting').on('shown.bs.tab', function () {
  703. if(colSettingObj.settingSpread){
  704. colSettingObj.settingSpread.refresh();
  705. }
  706. });