shandong_common.js 100 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822
  1. // INTERFACE_EXPORT =,必须这么写,这样才能在导出时动态加载脚本后,覆盖前端代码
  2. // 参考广东中山导出接口
  3. INTERFACE_EXPORT = (() => {
  4. "use strict";
  5. const feeRateMap = {
  6. 冬季施工增加费: "DJSGZJFFL",
  7. 冬季施工: "DJSGZJFFL",
  8. 雨季施工增加费: "YUJSGZJFFL",
  9. 雨季施工: "YUJSGZJFFL",
  10. 夜间施工增加费: "YEJSGZJFFL",
  11. 夜间施工: "YEJSGZJFFL",
  12. 高原地区施工增加费: "GYDQSGZJFFL",
  13. 高原施工: "GYDQSGZJFFL",
  14. 风沙地区施工增加费: "FSDQSGZJFFL",
  15. 风沙施工: "FSDQSGZJFFL",
  16. 沿海地区施工增加费: "YHDQSGZJFFL",
  17. 沿海施工: "YHDQSGZJFFL",
  18. 行车干扰施工增加费: "XCGRGCSGZJFFL",
  19. 行车干扰: "XCGRGCSGZJFFL",
  20. 工地转移费: "GDZYFFL",
  21. '工地转移(km)': "GDZYFFL",
  22. 施工辅助费: "SGFZFFL",
  23. 施工辅助: "SGFZFFL",
  24. 基本费用: "JBFYFL",
  25. 主副食运费补贴: "ZFSYFBTFL",
  26. '综合里程(km)': "ZFSYFBTFL",
  27. 职工探亲路费: "ZGTQLFFL",
  28. 职工探亲: "ZGTQLFFL",
  29. 职工取暖补贴: "ZGQNBTFL",
  30. 职工取暖: "ZGQNBTFL",
  31. 财务费用: "CWFYFL",
  32. 养老保险费: "YANGLBXFFL",
  33. 失业保险费: "SYBXFFL",
  34. 医疗保险费: "YILBXFFL",
  35. 工伤保险费: "GSBXFL",
  36. 养老保险: "YANGLBXFFL",
  37. 失业保险: "SYBXFFL",
  38. 医疗保险: "YILBXFFL",
  39. 工伤保险: "GSBXFL",
  40. 住房公积金: "ZFGJJFL",
  41. 规费: "GFZHFL",
  42. 利润: "LRL",
  43. 税金: "SL",
  44. 土方: "TF",
  45. 石方: "SF",
  46. 运输: "YS",
  47. 路面: "LM",
  48. "路面(不计雨)": "LM",
  49. 隧道: "SD",
  50. 构造物I: "GZW1",
  51. "构造物I(不计冬)": "GZW1",
  52. "构造物I(不计雨)": "GZW1",
  53. 构造物II: "GZW2",
  54. "构造物III(桥梁)": "GZW3",
  55. "构造物III(除桥以外)": "GZW3",
  56. "构造物III(除桥以外不计雨夜)": "GZW3",
  57. 技术复杂大桥: "JSFZDQ",
  58. "钢材及钢结构(桥梁)": "GJG",
  59. "钢材及钢结构(除桥以外)": "GJG",
  60. "钢材及钢结构(除桥以外不计夜)": "GJG",
  61. };
  62. //计算程序有,这里没有:施工机械使用费\施工机械人工费\定额人工费\定额材料费\定额施工机械使用费
  63. const itemFeeMap = {
  64. 'marketLabour': 'RGF',
  65. 'marketMaterial': 'CLF',
  66. 'marketMachine': 'JXSYF',
  67. 'marketEquipment': 'SBGZF',
  68. 'direct': 'DEZJF',
  69. 'equipment': 'DESBF',
  70. 'marketDirect': 'ZJF',
  71. 'measure': 'CSF',
  72. 'measure1': 'CSF1',
  73. 'measure2': 'CSF2',
  74. 'manage': 'QYGLF',
  75. 'force': 'GF',
  76. 'profit': 'LR',
  77. 'tax': 'SJ',
  78. 'common': 'JAF',
  79. 'rationCommon': 'DEJAF'
  80. };
  81. const feeLibNoMap = {
  82. 'eba0e7c0-cfe6-11ea-ba15-739be477d1fe': 'GYSFL-000000-2018-86',
  83. '451d3180-e02e-11ea-8056-1514dfc2f39e': 'GYSFL-340000-2019-210',
  84. '32923ff0-e912-11ea-8b20-d93bc370e960': 'GYSFL-440000-2019-544'
  85. };
  86. const FixedCostMap = {
  87. //折旧费、检修费、维护费、安拆辅助费
  88. '折旧费': 1,
  89. '检修费': 1,
  90. '维护费': 1,
  91. '安拆辅助费': 1
  92. }
  93. const RoadGradeMap = {
  94. "高速公路": "0",
  95. "一级公路": "1",
  96. "二级公路": "2",
  97. "三级公路": "3",
  98. "四级公路": "4",
  99. "等外公路": "5",
  100. "独立桥梁": "6",
  101. "独立隧道": "7"
  102. }
  103. const sectionNameMap = {
  104. "清单第100章总则": true,
  105. "清单第200章路基": true,
  106. "清单第300章路面": true,
  107. "清单第400章桥梁、涵洞": true,
  108. "清单第500章隧道": true,
  109. "清单第600章安全设施及预埋管线": true,
  110. "清单第700章绿化及环境保护设施": true,
  111. // "清单 第800章 机电工程": true,
  112. // "清单 第900章 附属区房建工程":true
  113. }
  114. const ListCodeMap = {
  115. "第100章至700章清单": "1",
  116. // "清单 第100章 总则": "一",
  117. // "清单 第200章 路基": "二",
  118. // "清单 第300章 路面": "三",
  119. // "清单 第400章 桥梁、涵洞": "四",
  120. // "清单 第500章 隧道": "五",
  121. // "清单 第600章 安全设施及预埋管线": "六",
  122. // "清单 第700章 绿化及环境保护设施": "七",
  123. // "清单 第800章 机电工程": "八",
  124. // "清单 第900章 附属区房建工程": "九",
  125. "清单第100章总则": "100",
  126. "清单第200章路基": "200",
  127. "清单第300章路面": "300",
  128. "清单第400章桥梁、涵洞": "400",
  129. "清单第500章隧道": "500",
  130. "清单第600章安全设施及预埋管线": "600",
  131. "清单第700章绿化及环境保护设施": "700",
  132. "已包含在清单合计中的材料、工程设备、专业工程暂估价合计": "13",
  133. "清单合计减去材料、工程设备、专业工程暂估价合计": "14",
  134. "计日工合计": "15",
  135. "劳务": "15.1",
  136. "材料": "15.2",
  137. "机械": "15.3",
  138. "暂列金额(不含计日工总额)": "16",
  139. "投标报价": "17"
  140. }
  141. const ratioCodeMap = {
  142. "01ZJF": "0",
  143. "02JXF": "1",
  144. "03WHF": "2",
  145. "04ACFZF": "3"
  146. }
  147. const reg1 = new RegExp('\n', 'g'), reg2 = new RegExp('\r', 'g')
  148. , reg3 = new RegExp(' ', 'g'), reg4 = new RegExp('\t', 'g')
  149. , reg5 = new RegExp('(', 'g'), reg6 = new RegExp(')', 'g')
  150. , regRt1 = new RegExp('\n\r', 'g'), regRt2 = new RegExp('\r\n', 'g')
  151. ;
  152. function getBasePrice(projectGLJID, tenderProject) {
  153. let glj = _.find(tenderProject.projectGLJ.datas.gljList, {
  154. id: projectGLJID
  155. })
  156. return glj ? gljUtil.getBasePrice(glj, null, null, null, decimalObj, false, _, scMathUtil) : 0;
  157. }
  158. function getFeeRate(programID, fieldName, tenderProject) {
  159. let rate = 0;
  160. let template = tenderProject.calcProgram.compiledTemplates;
  161. if (template[programID]) {
  162. let item = _.find(template[programID].calcItems, {
  163. fieldName: fieldName
  164. })
  165. if (item) rate = item.feeRate;
  166. }
  167. return rate;
  168. }
  169. function _billStrFilter(billStr) {
  170. let rst = billStr;
  171. if (typeof billStr === 'string') {
  172. rst = billStr.replace(reg1, '').replace(reg2, '').replace(reg3, '').replace(reg4, '').replace(reg5, '(').replace(reg6, ')');
  173. }
  174. return rst;
  175. }
  176. function _chkAdhocChapterBillCode(billStr) {
  177. let rst = false;
  178. rst = (typeof billStr === 'string' &&
  179. (billStr.indexOf('800章') >= 0 || billStr.indexOf('900章') >= 0 || billStr.indexOf('1000章') >= 0 || billStr.indexOf('1100章') >= 0 || billStr.indexOf('1200章') >= 0)
  180. )
  181. return rst;
  182. }
  183. function _extractAdhocChapter(billStr) {
  184. let rst = '';
  185. if (typeof billStr === 'string') {
  186. if (billStr.indexOf('800章') >= 0) {
  187. rst = '800';
  188. } else if (billStr.indexOf('900章') >= 0) {
  189. rst = '900';
  190. } else if (billStr.indexOf('1000章') >= 0) {
  191. rst = '1000';
  192. } else if (billStr.indexOf('1100章') >= 0) {
  193. rst = '1100';
  194. } else if (billStr.indexOf('1200章') >= 0) {
  195. rst = '1200';
  196. }
  197. }
  198. return rst;
  199. }
  200. function billNameChecking(bNode, projectName, fixedFlag) {
  201. let data = bNode.data;
  202. let fail = null;
  203. let pass = true;
  204. if (data.flagsIndex && data.flagsIndex.fixed) {
  205. let flag = data.flagsIndex.fixed.flag;
  206. switch (flag) {
  207. case fixedFlag.ONE_SEVEN_BILLS:
  208. // pass = data.name == "第100章至700章清单" || data.name == "第100章至700章清单合计";
  209. pass = typeof data.name === 'string' && data.name.includes('第100章至');
  210. break;
  211. case fixedFlag.PROVISIONAL_TOTAL:
  212. pass = data.name == "已包含在清单合计中的材料、工程设备、专业工程暂估价合计";
  213. break;
  214. case fixedFlag.BILLS_TOTAL_WT_PROV:
  215. pass = data.name == "清单合计减去材料、工程设备、专业工程暂估价合计";
  216. break;
  217. case fixedFlag.DAYWORK_LABOR:
  218. pass = data.name == "计日工合计";
  219. break;
  220. /* case fixedFlag.LABOUR_SERVICE:
  221. pass = data.name == "劳务";
  222. break;
  223. case fixedFlag.MATERIAL:
  224. pass = data.name == "材料";
  225. break;
  226. case fixedFlag.CONSTRUCTION_MACHINE:
  227. pass = data.name == "机械";
  228. break; */
  229. case fixedFlag.PROVISIONAL:
  230. pass = data.name == "暂列金额(不含计日工总额)";
  231. break;
  232. case fixedFlag.TOTAL_COST:
  233. pass = data.name == "投标报价";
  234. break;
  235. case fixedFlag.ONE_HUNDRED_BILLS:
  236. // pass = data.name == "清单 第100章 总则";
  237. pass = _billStrFilter(data.name) == "清单第100章总则";
  238. break;
  239. }
  240. } else {
  241. if (bNode.parent) {
  242. const pdata = bNode.parent.data;
  243. if (pdata.flagsIndex && pdata.flagsIndex.fixed && pdata.flagsIndex.fixed.flag == fixedFlag.ONE_SEVEN_BILLS) {
  244. if (!sectionNameMap[_billStrFilter(data.name)]) {
  245. pass = _chkAdhocChapterBillCode(data.name);
  246. }
  247. }
  248. }
  249. }
  250. // if(pass == false)fail = { hint: `清单:"${data.name?data.name:""}",名字不符合规范!`, type: projectName } // 不检测了,有问题不管,2022-12-28与潘林QQ中立贴为证
  251. return fail;
  252. }
  253. /**
  254. *
  255. * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理
  256. * @param {Number} exportKind - 导出类型,招标、投标、控制价
  257. * @param {Object} projectData - 项目表数据:{ 建设项目Data, children: [单位工程...] }
  258. * @param {Object} tenderDetailMap - 单位工程ID与getData接口数据(projectObj.project的结构)的映射。
  259. * @return {Promise<Array>} - 返回的数据结构必须按照规定:[{ data, exportKind, fileName }],参考web\building_saas\standard_interface\index.js中的注释说明
  260. */
  261. async function entry(areaKey, exportKind, projectData, tenderDetailMap) {
  262. const {
  263. CONFIG: {
  264. TYPE
  265. },
  266. UTIL,
  267. Element
  268. } = INTERFACE_EXPORT_BASE;
  269. const {
  270. isGLYun
  271. } = window.commonUtil;
  272. const {
  273. EXPORT_KIND: {
  274. BID_INVITATION,
  275. BID_SUBMISSION,
  276. CONTROL
  277. },
  278. fixedFlag,
  279. } = window.commonConstants;
  280. let cprjType = {
  281. 1: "GCLQD", // 招标
  282. 2: "TBBJ", // 投标
  283. 3: "ZBKZJ", // 控制价
  284. }; // 默认是公路云的
  285. if (!isGLYun()) {
  286. // 养护云
  287. cprjType[1] = 'YHGCLQD';
  288. cprjType[2] = 'YHTBBJ';
  289. cprjType[3] = 'YHZBKZJ';
  290. }
  291. const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  292. const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  293. const isControl = exportKind === CONTROL; // 是否是控制价
  294. function emptyElement(name) {
  295. this.name = name;
  296. this.attrs = [];
  297. this.children = [];
  298. }
  299. // 建设项目根节点信息
  300. function CprjInfo(projectName) {
  301. const attrs = [{
  302. name: "CprjName",
  303. value: projectName,
  304. },
  305. {
  306. name: "CprjType",
  307. value: cprjType[exportKind],
  308. },
  309. ];
  310. Element.call(this, "CprjInfo", attrs);
  311. }
  312. // 项目基本信息
  313. function SystemInfo(projectData) {
  314. let baseInfo = _.find(projectData.property.basicInformation, {
  315. dispName: "基本信息",
  316. });
  317. //“招标工程量清单”、“招标控制价”时,输出该字段,为导出该文件的当前时间
  318. let makeData = {
  319. value: UTIL.getNowFormatTime(true)
  320. }
  321. //投标的时候取基本信息的makeData字段
  322. // if (isBidSubmission) makeData = _.find(baseInfo.items, { "key": "makeDate" });
  323. // 山东需求调整,取当前时间
  324. // 取编制软件序列号所属单位。读取项目属性-建设项目基本信息的“投标单位”字段。该字段需要模板中新增。等确定后再修改
  325. // let softwareNumHolder = _.find(baseInfo.items, { "key": "bidderName" });
  326. let softwareNumHolder = userCompany; // userCompany是在main界面上已经有现成的(类似userAccount, userID)
  327. let hardID = UTIL.generateHardwareId();
  328. let [cpuId, diskId, macId] = hardID.split(";");
  329. // const orgScretInfoStr = `SoftwareName=纵横公路工程造价管理软件,SoftwareVer=V${VERSION},SoftwareCompany=珠海纵横创新软件有限公司,SoftwareNumber=${userID},HardNumber=${diskId},MacAddress=${macId},SoftwareNumberHolder=${softwareNumHolder}`
  330. const orgScretInfoStr = `SoftwareName=纵横公路工程造价管理软件,SoftwareVer=V${VERSION},SoftwareCompany=珠海纵横创新软件有限公司,SoftwareNumber=${window.btoa(userID)},HardNumber=${window.btoa(diskId)},MacAddress=${window.btoa(macId)},SoftwareNumberHolder=${softwareNumHolder}`
  331. let scretInfo = sm3Digest(orgScretInfoStr);
  332. const attrs = [{
  333. name: "Name",
  334. value: "公路工程造价数据标准",
  335. },
  336. {
  337. name: "Version",
  338. value: "1.0",
  339. },
  340. {
  341. name: "SoftwareName",
  342. value: "纵横公路工程造价管理软件",
  343. },
  344. {
  345. name: "SoftwareVer",
  346. value: "V" + VERSION,
  347. },
  348. {
  349. name: "SoftwareCompany",
  350. value: "珠海纵横创新软件有限公司",
  351. },
  352. {
  353. name: "MakeDate",
  354. value: makeData ? makeData.value : "",
  355. },
  356. {
  357. name: "SoftwareNumber",
  358. value: window.btoa(userID),
  359. },
  360. {
  361. name: "HardNumber",
  362. value: window.btoa(diskId),
  363. },
  364. {
  365. name: "MacAddress",
  366. value: window.btoa(macId),
  367. },
  368. {
  369. name: "SoftwareNumberHolder",
  370. value: softwareNumHolder,
  371. },
  372. {
  373. name: "SecretInfo",
  374. value: scretInfo,
  375. },
  376. ];
  377. Element.call(this, "SystemInfo", attrs);
  378. }
  379. //造价依据
  380. function CostBasis() {
  381. // ItemStandardNo="GYSFX-000000-2018-86"
  382. const attrs = [{
  383. name: "MakeRuleNo",
  384. value: "GYSBB-000000-2018-86",
  385. },
  386. {
  387. name: "MakeRuleName",
  388. value: "公路工程建设项目概算预算编制办法",
  389. },
  390. {
  391. name: "ItemStandardNo",
  392. value: "GYSFX-000000-2018-86",
  393. },
  394. ];
  395. Element.call(this, "CostBasis", attrs);
  396. //定额库信息
  397. //to do 改成实际的值
  398. function NormLib() {
  399. const attrs = [{
  400. name: "NormLibNo",
  401. value: "YSDE-000000-2018-86",
  402. },
  403. {
  404. name: "NormLibName",
  405. value: "部颁公路工程预算定额(2018)",
  406. },
  407. {
  408. name: "Type",
  409. value: "ZDEK",
  410. },
  411. ];
  412. Element.call(this, "NormLib", attrs);
  413. }
  414. this.children.push(new NormLib());
  415. }
  416. function Rate(tenderProject, feeRateInfo, seirNo) {
  417. //RateNo="1" Name="纵横软件测试版本" RateLibNo="GYSFL-000000-2018-86"
  418. const attrs = [{
  419. name: "RateNo",
  420. value: seirNo,
  421. },
  422. {
  423. name: "Name",
  424. value: feeRateInfo.name,
  425. },
  426. {
  427. name: "RateLibNo",
  428. value: feeLibNoMap[feeRateInfo.libID],
  429. },
  430. ];
  431. Element.call(this, "Rate", attrs);
  432. let RateParams = new emptyElement("RateParams");
  433. let subRates = projectObj.project.FeeRate.getAllSubRates(feeRateInfo.rates);
  434. for (let s of subRates) {
  435. let sname = s.name.replace("(%)", "");
  436. sname = sname.replace("(%)", "");
  437. if (feeRateMap[sname]) {
  438. let value = "";
  439. if (s.editable) {
  440. let sel = _.find(s.optionList, {
  441. selected: true,
  442. });
  443. if (sel) {
  444. value = sel.name;
  445. } else if (gljUtil.isDef(s.value)) {
  446. value = s.value;
  447. }
  448. } else {
  449. value = _.findIndex(s.optionList, {
  450. selected: true,
  451. });
  452. if (value == -1) value = 0;
  453. }
  454. /* if (sname == '利润') tenderProject.ProfitRate = value;
  455. if (sname == '税金') tenderProject.TaxRate = value; */
  456. RateParams.children.push(new RateParam(feeRateMap[sname], value));
  457. }
  458. }
  459. this.children.push(RateParams);
  460. function RateParam(RateTypeNo, RateParamNo) {
  461. //<RateParam RateTypeNo="DJSGZJFFL" RateParamNo="0" Ratio="100"/>
  462. const attrs = [{
  463. name: "RateTypeNo",
  464. value: RateTypeNo,
  465. },
  466. {
  467. name: "RateParamNo",
  468. value: RateParamNo,
  469. },
  470. {
  471. name: "Ratio",
  472. value: "100",
  473. },
  474. ];
  475. Element.call(this, "RateParam", attrs);
  476. }
  477. let RateValues = new emptyElement("RateValues");
  478. function RateValue(CostTypeNo, RateTypeNo, value) {
  479. const attrs = [{
  480. name: "CostTypeNo",
  481. value: CostTypeNo,
  482. },
  483. {
  484. name: "RateTypeNo",
  485. value: RateTypeNo,
  486. },
  487. {
  488. name: "RateValue",
  489. value: value,
  490. },
  491. ];
  492. Element.call(this, "RateValue", attrs);
  493. }
  494. let prefix = "";
  495. for (let r of feeRateInfo.rates) {
  496. if (!r.ParentID && feeRateMap[r.name]) prefix = feeRateMap[r.name];
  497. if (feeRateMap[r.name] && r.ParentID) {
  498. RateValues.children.push(new RateValue(prefix, feeRateMap[r.name], r.rate));
  499. }
  500. }
  501. this.children.push(RateValues);
  502. }
  503. function Pract(tpdata, seriNo) {
  504. let pgljData = tpdata.projectGLJ.datas;
  505. let decimalObj = tpdata.property.decimal;
  506. const attrs = [{
  507. name: "PractNo",
  508. value: seriNo,
  509. },
  510. {
  511. name: "Name",
  512. value: pgljData.constData.usedUnitPriceInfo.name,
  513. },
  514. ];
  515. Element.call(this, "Pract", attrs);
  516. let Param = {
  517. name: "Param",
  518. attrs: [{
  519. name: "TaxLibNo",
  520. value: "CCSBZ-440000-2019-544",
  521. },
  522. {
  523. name: "AuxRate",
  524. value: pgljData.constData.assistProductionFeeRate,
  525. },
  526. ],
  527. children: [],
  528. };
  529. if (isBidSubmission || isControl) { //导出到招标文件中,不输出这一部分。
  530. let elecDatas = electrovalenceObj.getElectrovalenceDatas(null, pgljData.com_electrovalence, pgljData.gljList);
  531. electrovalenceObj.calcPertElectrovalenceMarketPrice(elecDatas);
  532. for (let e of elecDatas) {
  533. let Electro = {
  534. name: "Electro",
  535. attrs: [{
  536. name: "Code",
  537. value: e.code,
  538. },
  539. {
  540. name: "Price",
  541. value: e.electPrice,
  542. },
  543. {
  544. name: "Ratio",
  545. value: e.coe,
  546. },
  547. ],
  548. children: [],
  549. };
  550. Param.children.push(Electro);
  551. }
  552. }
  553. this.children.push(Param);
  554. function Mp(g) {
  555. const attrs = [{
  556. name: "Code",
  557. value: g.code,
  558. },
  559. {
  560. name: "PractName",
  561. value: g.name,
  562. },
  563. {
  564. name: "Spec",
  565. value: g.specs,
  566. },
  567. {
  568. name: "Unit",
  569. value: g.unit,
  570. },
  571. {
  572. name: "BudgetPrice",
  573. value: g.priceInfo.tenderPrice,
  574. },
  575. {
  576. name: "NormPrice",
  577. value: g.priceInfo.basePrice,
  578. },
  579. {
  580. name: "IsAdd",
  581. value: g.unit_price.is_add,
  582. },
  583. ];
  584. Element.call(this, "Mp", attrs);
  585. }
  586. function Material(g) {
  587. const attrs = [{
  588. name: "Code",
  589. value: g.code,
  590. },
  591. {
  592. name: "PractName",
  593. value: g.name,
  594. },
  595. {
  596. name: "Spec",
  597. value: g.specs,
  598. },
  599. {
  600. name: "Unit",
  601. value: g.unit,
  602. },
  603. {
  604. name: "BudgetPrice",
  605. value: g.priceInfo.tenderPrice,
  606. },
  607. {
  608. name: "NormPrice",
  609. value: g.priceInfo.basePrice,
  610. },
  611. {
  612. name: "IsAdd",
  613. value: g.unit_price.is_add,
  614. },
  615. {
  616. name: "OrgPrice",
  617. value: g.unit_price.originalPrice ? g.unit_price.originalPrice : 0,
  618. },
  619. {
  620. name: "TransFee",
  621. value: g.unit_price.unitFreight ? g.unit_price.unitFreight : 0,
  622. },
  623. {
  624. name: "GwRate",
  625. value: g.unit_price.grossWeightCoe_n ? g.unit_price.grossWeightCoe_n : 0,
  626. },
  627. {
  628. name: "OffSiteLf",
  629. value: g.unit_price.offSiteTransportLossRate_n ? g.unit_price.offSiteTransportLossRate_n : 0,
  630. },
  631. {
  632. name: "OnSiteLf",
  633. value: 0,
  634. },
  635. {
  636. name: "LoadLf",
  637. value: g.unit_price.handlingLossRate_n ? g.unit_price.handlingLossRate_n : 0,
  638. },
  639. {
  640. name: "StoreRate",
  641. value: g.unit_price.purchaseStorageRate_n ? g.unit_price.purchaseStorageRate_n : 0,
  642. },
  643. {
  644. name: "PackageRecycleFee",
  645. value: g.unit_price.packageRecoverValue ? g.unit_price.packageRecoverValue : 0,
  646. },
  647. ];
  648. Element.call(this, "Material", attrs);
  649. // if (g.unit_price.calcMaterial == 1) { //有材料计算
  650. // let index = gljUtil.getIndex(g);
  651. // let orList = [];
  652. // for (let o of pgljData.originalList) {
  653. // if (o.connect_key == index) orList.push(new OrgPrices(o));
  654. // }
  655. // if (orList.length > 0) this.children = orList;
  656. // }
  657. function CostStructure(r) {
  658. //待获取
  659. this.name = "CostStructure";
  660. this.attrs = [];
  661. this.children = [];
  662. }
  663. function Consume(r, o) {
  664. this.name = "Consume";
  665. this.attrs = [];
  666. this.children = [];
  667. for (let g of o.ration_gljs) {
  668. if (g.rationID == r.ID) {
  669. let r_quantity = scMathUtil.roundForObj(r.quantity, tpdata.property.decimal.ration.quantity);
  670. this.children.push(new ConsumeItem(g, r_quantity));
  671. }
  672. }
  673. }
  674. function ConsumeItem(g, ration_quantity) {
  675. const attrs = [{
  676. name: "Code", //待获取
  677. value: g.code,
  678. },
  679. {
  680. name: "Consumption",
  681. value: scMathUtil.roundForObj(ration_quantity * parseFloat(g.quantity), tpdata.property.decimal.glj.quantity),
  682. },
  683. ];
  684. Element.call(this, "ConsumeItem", attrs);
  685. }
  686. function Norm(r, o) {
  687. const attrs = [{
  688. name: "NormLibNo", //待获取
  689. value: "",
  690. },
  691. {
  692. name: "DisplayCode",
  693. value: r.code,
  694. },
  695. {
  696. name: "Name",
  697. value: r.name,
  698. },
  699. {
  700. name: "Unit",
  701. value: r.unit,
  702. },
  703. {
  704. name: "Num",
  705. value: r.quantity,
  706. },
  707. {
  708. name: "CostTypeNo",
  709. value: "", //待获取
  710. },
  711. {
  712. name: "FabricationCost", //待获取
  713. value: "",
  714. },
  715. {
  716. name: "AdjustStatus",
  717. value: "",
  718. },
  719. ];
  720. Element.call(this, "Norm", attrs);
  721. this.children.push(new CostStructure(r));
  722. this.children.push(new Consume(r, o));
  723. }
  724. function SelfCollect(o) {
  725. const attrs = [{
  726. name: "OtherCost",
  727. value: 0,
  728. },];
  729. Element.call(this, "SelfCollect", attrs);
  730. for (let r of o.rations) {
  731. this.children.push(new Norm(r, o));
  732. }
  733. }
  734. function OrgPrices(o) {
  735. const attrs = [{
  736. name: "OrgPricevalue",
  737. value: o.supplyPrice,
  738. },
  739. {
  740. name: "Ratio",
  741. value: o.coe,
  742. },
  743. ];
  744. Element.call(this, "OrgPrices", attrs);
  745. if (!o.rations) return;
  746. this.children.push(new SelfCollect(o));
  747. }
  748. }
  749. function Mech(g, gljKeyMap) {
  750. const attrs = [{
  751. name: "Code",
  752. value: g.code,
  753. },
  754. {
  755. name: "PractName",
  756. value: g.name,
  757. },
  758. {
  759. name: "Spec",
  760. value: g.specs,
  761. },
  762. {
  763. name: "Unit",
  764. value: g.unit,
  765. },
  766. {
  767. name: "BudgetPrice",
  768. value: g.priceInfo.tenderPrice,
  769. },
  770. {
  771. name: "NormPrice",
  772. value: g.priceInfo.basePrice,
  773. },
  774. {
  775. name: "IsAdd",
  776. value: g.unit_price.is_add,
  777. },
  778. ];
  779. Element.call(this, "Mech", attrs);
  780. let FixedCostItems = [];
  781. let fcsum = 0;
  782. let VariableCostItems = [];
  783. let vcsum = 0;
  784. if (g.ratio_data && g.ratio_data.length > 0) {
  785. for (let ratio of g.ratio_data) {
  786. let rIndex = gljUtil.getIndex(ratio);
  787. let rglj = gljKeyMap[rIndex];
  788. let ts = scMathUtil.roundForObj(parseFloat(ratio.consumption) * rglj.priceInfo.tenderPrice, decimalObj.glj.unitPrice);
  789. if (FixedCostMap[ratio.name]) {
  790. FixedCostItems.push(new FixedCostItem(ratio));
  791. fcsum = scMathUtil.roundForObj(fcsum + ts, decimalObj.glj.unitPrice);
  792. } else {
  793. VariableCostItems.push(new VariableCostItem(ratio));
  794. vcsum = scMathUtil.roundForObj(vcsum + ts, decimalObj.glj.unitPrice);
  795. }
  796. }
  797. }
  798. if (FixedCostItems.length > 0) {
  799. let fc = new FixedCost(fcsum);
  800. fc.children = FixedCostItems;
  801. this.children.push(fc);
  802. }
  803. if (VariableCostItems.length > 0) {
  804. let vc = new VariableCost(vcsum);
  805. vc.children = VariableCostItems;
  806. this.children.push(vc);
  807. }
  808. function VariableCost(sum) {
  809. const attrs = [{
  810. name: "VariableCostSum",
  811. value: sum,
  812. }];
  813. Element.call(this, "VariableCost", attrs);
  814. }
  815. function VariableCostItem(item) {
  816. const attrs = [{
  817. name: "VariableCostNo",
  818. value: item.code,
  819. }, {
  820. name: "Consumption",
  821. value: item.consumption,
  822. }]
  823. Element.call(this, "VariableCostItem", attrs);
  824. }
  825. function FixedCost(sum) {
  826. const attrs = [{
  827. name: "FixedCostSum",
  828. value: sum,
  829. }, {
  830. name: "FixedRate",
  831. value: 1,
  832. }];
  833. Element.call(this, "FixedCost", attrs);
  834. }
  835. function FixedCostItem(item) {
  836. const attrs = [{
  837. name: "FixedCostNo",
  838. value: ratioCodeMap[item.code],
  839. }, {
  840. name: "Sum",
  841. value: item.consumption,
  842. }]
  843. Element.call(this, "FixedCostItem", attrs);
  844. }
  845. }
  846. let Mps = new emptyElement("Mps");
  847. let Materials = new emptyElement("Materials");
  848. let Mechs = new emptyElement("Mechs");
  849. let gljKeyMap = {};
  850. let temMechs = [];
  851. if (isBidSubmission || isControl) { //导出到招标文件中,不输出这一部分。
  852. for (let g of pgljData.gljList) {
  853. if (!g.quantity) {
  854. continue;
  855. }
  856. let type = g.type + "";
  857. gljKeyMap[gljUtil.getIndex(g)] = g;
  858. type = type.charAt(0);
  859. if (type == "1") {
  860. Mps.children.push(new Mp(g));
  861. } else if (type == "2" || type == 5) {
  862. Materials.children.push(new Material(g));
  863. } else if (type == "3") {
  864. temMechs.push(g);
  865. }
  866. }
  867. for (let t of temMechs) {
  868. Mechs.children.push(new Mech(t, gljKeyMap));
  869. }
  870. }
  871. this.children.push(Mps);
  872. this.children.push(Materials);
  873. this.children.push(Mechs);
  874. }
  875. function EprjInfo(tenderProject) {
  876. let bills = tenderProject.Bills.datas;
  877. let feature = tenderProject.property.projectFeature ? tenderProject.property.projectFeature : [];
  878. let totalItem = null;
  879. let proItem = null; //暂列金额项
  880. let safeItem = null;
  881. let oneToSevenItem = null;
  882. for (let b of bills) {
  883. if (b.flagsIndex && b.flagsIndex.fixed && b.flagsIndex.fixed.flag == fixedFlag.TOTAL_COST) totalItem = b;
  884. if (b.flagsIndex && b.flagsIndex.fixed && b.flagsIndex.fixed.flag == fixedFlag.PROVISIONAL) proItem = b;
  885. if (b.flagsIndex && b.flagsIndex.fixed && b.flagsIndex.fixed.flag == fixedFlag.ONE_SEVEN_BILLS) oneToSevenItem = b;
  886. if (b.code == "102-3" && b.name == "安全生产费") safeItem = b;
  887. }
  888. const attrs = [{
  889. name: "Name",
  890. value: tenderProject.projectInfo.name,
  891. },
  892. {
  893. name: "Sums",
  894. value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
  895. },
  896. ];
  897. //输出控制价、投标文件时,取调价后的标段总造价。
  898. //输出招标文件时,取0
  899. if (isBidInvitation) attrs[1].value = 0;
  900. Element.call(this, "EprjInfo", attrs);
  901. this.children.push(new SummaryOfCost(totalItem, proItem, safeItem, oneToSevenItem, feature));
  902. this.children.push(new MakeInfo(tenderProject));
  903. this.children.push(new Params(tenderProject));
  904. const cacheForFormula = _preCodeingForBills(tenderProject);
  905. this.children.push(new getBillsItems(tenderProject, cacheForFormula));
  906. this.children.push(new getIndexs(tenderProject));
  907. let bidEvaluationMainMaterials = getBidEvaluationMainMaterial(tenderProject);
  908. if (bidEvaluationMainMaterials.length > 0) this.children.push(...bidEvaluationMainMaterials);
  909. //山东接口还需要增加几个表的数据(就是把原报表的显示数据转到投标文件里)
  910. // 1. 投标报价汇总表
  911. this.children.push(new quoteSummary(tenderProject));
  912. // 2. 计日工表
  913. let spdw = sporadicWork(tenderProject);
  914. if (spdw) {
  915. this.children.push(spdw);
  916. }
  917. // 3. 材料暂估价表
  918. let estMaterialRpt = materialEstimate(tenderProject);
  919. if (estMaterialRpt) {
  920. this.children.push(estMaterialRpt);
  921. }
  922. // 4. 工程设备暂估价表
  923. let estMachineRpt = getMachineTempEst(tenderProject);
  924. if (estMachineRpt) {
  925. this.children.push(estMachineRpt);
  926. }
  927. // 5. 专业工程暂估价表
  928. let estSpecPrjRpt = getSpecPrjEst(tenderProject);
  929. if (estSpecPrjRpt) {
  930. this.children.push(estSpecPrjRpt);
  931. }
  932. // 6. 工程量清单单价分析表
  933. let billAnalyzeRpt = getBillsAnalyze(tenderProject);
  934. if (billAnalyzeRpt) {
  935. this.children.push(billAnalyzeRpt);
  936. }
  937. }
  938. function _getBidGljCode(tenderProject, orgGlj) {
  939. let rst = orgGlj.code;
  940. if (tenderProject.bid_evaluation_list && tenderProject.bid_evaluation_list.datas) {
  941. for (let bGlj of tenderProject.bid_evaluation_list.datas) {
  942. if (bGlj.projectGLJID === orgGlj.id) {
  943. rst = bGlj.seq;
  944. break;
  945. }
  946. }
  947. }
  948. return rst;
  949. }
  950. function _getFee(bill, key = 'common', valueKey = 'tenderTotalFee') {
  951. let rstSum = 0;
  952. if (bill) {
  953. let dtlB = (bill.data) ? bill.data : bill;
  954. if (dtlB.fees) {
  955. for (let fee of dtlB.fees) {
  956. if (fee.fieldName === key) {
  957. rstSum = fee[valueKey];
  958. break;
  959. }
  960. }
  961. }
  962. }
  963. return rstSum;
  964. };
  965. function _getNumValueByExportKind(orgSum) {
  966. let rst = orgSum;
  967. // const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  968. // const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  969. // const isControl = exportKind === CONTROL; // 是否是控制价
  970. //根据导出类型(上面3个),输出实际合计或price
  971. if (isBidInvitation) {
  972. rst = 0;
  973. }
  974. return rst;
  975. }
  976. function _getStrValueByExportKind(orgStr) {
  977. let rst = orgStr;
  978. // const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  979. // const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  980. // const isControl = exportKind === CONTROL; // 是否是控制价
  981. //根据导出类型(上面3个),输出实际合计或price
  982. if (isBidInvitation) {
  983. rst = '';
  984. }
  985. return rst;
  986. }
  987. function _getFixedSum(tenderProject) {
  988. let rst = 0;
  989. tenderProject.Bills.datas.forEach((bill) => {
  990. if (bill.specialProvisional == "固定费用") {
  991. let bVal = _getFee(bill);
  992. rst += bVal;
  993. }
  994. });
  995. return rst;
  996. }
  997. function quoteSummary(tenderProject) {
  998. let quoteSummaryItem = new emptyElement('QuoteSummary');
  999. // let attrs = [];
  1000. //1. 取固定清单,
  1001. // 1.1 100~700章总清单(flags有属性为19的那个) -> topNode100To700
  1002. // 1.2 已包含在清单合计中的材料、工程设备、专业工程暂估价合计 标记:20
  1003. // 1.3 清单合计减去材料、工程设备、专业工程暂估价|合计 标记:21
  1004. // 1.4 计日工合计 标记:22
  1005. // 1.5 暂列金额(不含计日工总额) 标记:26
  1006. // 1.6 投标报价 标记:9
  1007. let topNode100To700, nodeZXZDJ, nodeQDKCZXZDJ, nodeJRG, nodeZLJE, nodeTBBJ, newAddedBill;
  1008. let chapterNodes = [];
  1009. let fixedSum = _getFixedSum(tenderProject); //山东有固定费用,此费用不参与到此项中去
  1010. let nextBillID = '';
  1011. tenderProject.Bills.datas.forEach((bill) => {
  1012. if (bill.flags && bill.flags.length > 0) {
  1013. for (let flag of bill.flags) {
  1014. switch (flag.flag) {
  1015. case 19:
  1016. topNode100To700 = bill;
  1017. break;
  1018. case 20:
  1019. nodeZXZDJ = bill;
  1020. break;
  1021. case 21:
  1022. nodeQDKCZXZDJ = bill;
  1023. break;
  1024. case 22:
  1025. nodeJRG = bill;
  1026. break;
  1027. case 26:
  1028. nodeZLJE = bill;
  1029. nextBillID = bill.NextSiblingID
  1030. break;
  1031. case 9:
  1032. nodeTBBJ = bill;
  1033. break;
  1034. case 44:
  1035. newAddedBill = bill;
  1036. break;
  1037. default:
  1038. break;
  1039. }
  1040. }
  1041. }
  1042. });
  1043. tenderProject.Bills.datas.forEach((bill) => {
  1044. if (bill.type === 1 && bill.ID === nextBillID && nodeTBBJ && nodeTBBJ.ID !== nextBillID) {
  1045. newAddedBill = bill;
  1046. }
  1047. });
  1048. //2. 然后获取topNode100To700下的所有次一级清单(100章...700章)
  1049. if (topNode100To700) {
  1050. for (let rootBill of tenderProject.Bills.tree.roots) {
  1051. // 100~700章总清单在top级别(山东养护)
  1052. if (rootBill.data.ID === topNode100To700.ID) {
  1053. rootBill.children.forEach((subBill) => {
  1054. if (subBill.data.name.includes('00章')) {
  1055. chapterNodes.push(subBill);
  1056. }
  1057. });
  1058. break;
  1059. }
  1060. }
  1061. }
  1062. //3. 拼凑数据
  1063. let nodeAttrs = [];
  1064. if (topNode100To700) {
  1065. let order = 1;
  1066. //读取投标报价汇总表信息。1.ItemNo 序号。2.ChapterNo 章次。 3.Name 科目名称。 4.Sum 金额。
  1067. chapterNodes.forEach((cnode) => {
  1068. let chapterIdx = cnode.data.name.indexOf("00章");
  1069. nodeAttrs.push({ ItemNo: order, ChapterNo: cnode.data.name.substr(chapterIdx - 1, 3), Name: cnode.data.name, Sum: _getFee(cnode) });
  1070. order++;
  1071. });
  1072. // nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: '第100章至700章清单合计', Sum: _getFee(topNode100To700) });
  1073. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: topNode100To700.name, Sum: _getFee(topNode100To700) });
  1074. order++;
  1075. if (nodeZXZDJ) {
  1076. // nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: '已包含在清单合计中的材料、工程设备、专业工程暂估价合计', Sum: _getFee(nodeZXZDJ) - fixedSum});
  1077. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: '已包含在清单合计中的材料、工程设备、专业工程暂估价合计', Sum: _getFee(nodeZXZDJ) }); // 又不需要fixedSum了
  1078. order++;
  1079. }
  1080. if (nodeQDKCZXZDJ) {
  1081. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: `清单合计减去材料、工程设备、专业工程暂估价合计(即${order - 2}-${order - 1})=${order}`, Sum: _getFee(nodeQDKCZXZDJ) });
  1082. order++;
  1083. }
  1084. if (nodeJRG) {
  1085. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: `计日工合计`, Sum: _getFee(nodeJRG) });
  1086. order++;
  1087. }
  1088. if (nodeZLJE) {
  1089. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: `暂列金额(不含计日工总额)`, Sum: _getFee(nodeZLJE) });
  1090. order++;
  1091. }
  1092. if (newAddedBill) {
  1093. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: newAddedBill.name, Sum: _getFee(newAddedBill) });
  1094. order++;
  1095. }
  1096. if (nodeTBBJ) {
  1097. let nameStr = `投标报价(${chapterNodes.length + 1}+${order - 2}+${order - 1})=${order}`;
  1098. if (newAddedBill && nodeTBBJ.calcBase && nodeTBBJ.calcBase.includes(newAddedBill.ID)) {
  1099. nameStr = `投标报价(${chapterNodes.length + 1}+${order - 3}+${order - 2}+${order - 1})=${order}`;
  1100. }
  1101. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: nameStr, Sum: _getFee(nodeTBBJ) });
  1102. order++;
  1103. }
  1104. }
  1105. function _Item(item) {
  1106. const attrs = [
  1107. {
  1108. name: 'ItemNo',
  1109. value: item.ItemNo
  1110. },
  1111. {
  1112. name: 'ChapterNo',
  1113. value: item.ChapterNo
  1114. },
  1115. {
  1116. name: 'Name',
  1117. value: item.Name
  1118. },
  1119. {
  1120. name: 'Sum',
  1121. value: scMathUtil.roundForObj(_getNumValueByExportKind(item.Sum), tenderProject.property.decimal.bills.totalPrice)
  1122. // value: 0 // 所有清单的金额都是0
  1123. }
  1124. ];
  1125. let rst = new emptyElement('Item');
  1126. rst.attrs.push(...attrs);
  1127. return rst;
  1128. }
  1129. for (let attr of nodeAttrs) {
  1130. quoteSummaryItem.children.push(_Item(attr));
  1131. }
  1132. return quoteSummaryItem;
  1133. }
  1134. function sporadicWork(tenderProject) {
  1135. //计日工表,含:劳务、材料、施工机械、计日工汇总
  1136. let hasSporadicWork = false;
  1137. let sporadicWorkItem = new Element('SporadicWork');
  1138. let nodeLabour, nodeMaterial, nodeMachine;
  1139. //首先收集过滤计日工相关清单
  1140. tenderProject.Bills.datas.forEach((bill) => {
  1141. if (bill.flags && bill.flags.length > 0) {
  1142. for (let flag of bill.flags) {
  1143. switch (flag.flag) {
  1144. case 23:
  1145. nodeLabour = bill;
  1146. break;
  1147. case 24:
  1148. nodeMaterial = bill;
  1149. break;
  1150. case 25:
  1151. nodeMachine = bill;
  1152. break;
  1153. default:
  1154. break;
  1155. }
  1156. }
  1157. }
  1158. });
  1159. const _buildWorkNodeItem = function (orgNode, subNodes, parentKey, childKey) {
  1160. let parentNode = new Element(parentKey);
  1161. sporadicWorkItem.children.push(parentNode);
  1162. const pSumAttrs = [
  1163. {
  1164. name: 'Sum',
  1165. value: _getNumValueByExportKind(_getFee(orgNode))
  1166. // value: 0
  1167. }
  1168. ];
  1169. // Element.call(this, parentKey, pSumAttrs);
  1170. parentNode.attrs.push(...pSumAttrs);
  1171. subNodes.forEach((node, index) => {
  1172. let childNode = new Element(childKey);
  1173. parentNode.children.push(childNode);
  1174. const attrs = [
  1175. {
  1176. name: 'ItemNo',
  1177. value: (node.code) ? node.code : `${index + 1}`
  1178. }, {
  1179. name: 'Name',
  1180. value: node.name
  1181. }, {
  1182. name: 'Unit',
  1183. value: node.unit
  1184. }, {
  1185. name: 'Num',
  1186. value: node.quantity
  1187. }, {
  1188. name: 'Price',
  1189. value: _getNumValueByExportKind(_getFee(node, 'common', 'tenderUnitFee'))
  1190. // value: 0
  1191. }, {
  1192. name: 'Sum',
  1193. value: _getNumValueByExportKind(_getFee(node))
  1194. // value: 0
  1195. }
  1196. ];
  1197. childNode.attrs.push(...attrs);
  1198. });
  1199. };
  1200. //1. 判断劳务
  1201. if (nodeLabour) {
  1202. let subNodes = [];
  1203. tenderProject.Bills.datas.forEach((bill) => {
  1204. if (bill.ParentID === nodeLabour.ID) {
  1205. subNodes.push(bill);
  1206. }
  1207. });
  1208. if (subNodes.length > 0) {
  1209. hasSporadicWork = true;
  1210. //创建劳务Mps节点及劳务Mps下Mp子节点
  1211. _buildWorkNodeItem(nodeLabour, subNodes, 'Mps', 'Mp');
  1212. }
  1213. }
  1214. //2. 判断材料
  1215. if (nodeMaterial) {
  1216. let subNodes = [];
  1217. tenderProject.Bills.datas.forEach((bill) => {
  1218. if (bill.ParentID === nodeMaterial.ID) {
  1219. subNodes.push(bill);
  1220. }
  1221. });
  1222. if (subNodes.length > 0) {
  1223. hasSporadicWork = true;
  1224. //创建材料Materials节点及劳务Materials下Material子节点
  1225. _buildWorkNodeItem(nodeMaterial, subNodes, 'Materials', 'Material');
  1226. }
  1227. }
  1228. //3. 判断施工机械
  1229. if (nodeMachine) {
  1230. let subNodes = [];
  1231. tenderProject.Bills.datas.forEach((bill) => {
  1232. if (bill.ParentID === nodeMachine.ID) {
  1233. subNodes.push(bill);
  1234. }
  1235. });
  1236. if (subNodes.length > 0) {
  1237. hasSporadicWork = true;
  1238. //创建施工机械Meehs节点及劳务Meehs下Meeh子节点
  1239. _buildWorkNodeItem(nodeMachine, subNodes, 'Mechs', 'Mech');
  1240. }
  1241. }
  1242. //4. 判断计日工汇总
  1243. if (hasSporadicWork) {
  1244. let summaryNode = new Element('Summary');
  1245. sporadicWorkItem.children.push(summaryNode);
  1246. const pSumAttrs = [
  1247. {
  1248. name: 'Sum',
  1249. // value: _getFee(nodeLabour) + _getFee(nodeMaterial) + _getFee(nodeMachine)
  1250. value: _getNumValueByExportKind(_getFee(nodeLabour) + _getFee(nodeMaterial) + _getFee(nodeMachine))
  1251. }
  1252. ];
  1253. summaryNode.attrs = pSumAttrs;
  1254. //把劳务、材料、施工机械
  1255. function _workItem(node, name, remark = '') {
  1256. let childNode = new Element('Item');
  1257. summaryNode.children.push(childNode);
  1258. const attrs = [
  1259. {
  1260. name: "Name",
  1261. value: name,
  1262. },
  1263. {
  1264. name: "Sum",
  1265. value: _getNumValueByExportKind(_getFee(node)),
  1266. },
  1267. {
  1268. name: "Remark",
  1269. value: remark,
  1270. }
  1271. ]
  1272. childNode.attrs.push(...attrs);
  1273. }
  1274. _workItem(nodeLabour, '劳务');
  1275. _workItem(nodeMaterial, '材料');
  1276. _workItem(nodeMachine, '机械');
  1277. }
  1278. //返回
  1279. if (hasSporadicWork) {
  1280. return sporadicWorkItem;
  1281. } else {
  1282. return null;
  1283. }
  1284. }
  1285. function materialEstimate(tenderProject) {
  1286. let mEstNode = new emptyElement('MaterialEstimate');
  1287. let items = [];
  1288. let billItems = [];
  1289. let itemNo = 1;
  1290. //材料暂估价明细
  1291. tenderProject.Bills.datas.forEach((bill) => {
  1292. if (bill.specialProvisional === '材料暂估') {
  1293. billItems.push(bill);
  1294. }
  1295. });
  1296. if (billItems.length > 0) {
  1297. billItems.forEach((bill) => {
  1298. let mEstItemNode = new emptyElement('Item');
  1299. mEstNode.children.push(mEstItemNode);
  1300. let attrs = [
  1301. { name: 'ItemNo', value: itemNo },
  1302. { name: 'Code', value: bill.code },
  1303. { name: 'Number', value: bill.code },
  1304. { name: 'Name', value: bill.name },
  1305. { name: 'Unit', value: bill.unit },
  1306. { name: 'Num', value: bill.quantity },
  1307. { name: 'Price', value: _getNumValueByExportKind(_getFee(bill, 'common', 'tenderUnitFee')) },
  1308. { name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), 0)), type: TYPE.DECIMAL },
  1309. // {name: 'Price', value: 0},
  1310. // {name: 'Sum', value: 0},
  1311. { name: 'Remark', value: (bill.remark) ? bill.remark : '' }
  1312. ];
  1313. itemNo++;
  1314. mEstItemNode.attrs.push(...attrs);
  1315. });
  1316. }
  1317. tenderProject.projectGLJ.datas.gljList.forEach((glj) => {
  1318. if (glj.is_evaluate && glj.type !== 5 && glj.type !== 301) {
  1319. items.push(glj);
  1320. }
  1321. });
  1322. if (items.length > 0) {
  1323. items.forEach((glj) => {
  1324. let mEstItemNode = new emptyElement('Item');
  1325. mEstNode.children.push(mEstItemNode);
  1326. let gljName = glj.name;
  1327. if (tenderProject.evaluate_list.datas && tenderProject.evaluate_list.datas.length > 0) {
  1328. for (let relGlj of tenderProject.evaluate_list.datas) {
  1329. if (relGlj.projectGLJID == glj.id) {
  1330. gljName = relGlj.name;
  1331. break;
  1332. }
  1333. }
  1334. }
  1335. let attrs = [
  1336. { name: 'ItemNo', value: itemNo },
  1337. { name: 'Code', value: _getBidGljCode(tenderProject, glj) },
  1338. { name: 'Number', value: glj.code },
  1339. { name: 'Name', value: gljName },
  1340. { name: 'Unit', value: glj.unit },
  1341. { name: 'Num', value: glj.tenderQuantity },
  1342. // {name: 'Price', value: _getNumValueByExportKind(glj.unit_price.market_price)},
  1343. { name: 'Price', value: glj.unit_price.market_price }, //暂估材料输出price,不需判断导出类型
  1344. { name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(glj.tenderQuantity * glj.unit_price.market_price, 0)), type: TYPE.DECIMAL },
  1345. // {name: 'Price', value: 0},
  1346. // {name: 'Sum', value: 0},
  1347. { name: 'Remark', value: (glj.remark) ? glj.remark : '' }
  1348. ];
  1349. itemNo++;
  1350. mEstItemNode.attrs.push(...attrs);
  1351. });
  1352. }
  1353. if (billItems.length > 0 || items.length > 0) {
  1354. return mEstNode;
  1355. } else {
  1356. return null;
  1357. }
  1358. }
  1359. function getMachineTempEst(tenderProject) {
  1360. let mEstNode = new emptyElement('PrjDeviceEstimate');
  1361. let items = [];
  1362. let billItems = [];
  1363. let itemNo = 1;
  1364. //工程设备明细
  1365. tenderProject.Bills.datas.forEach((bill) => {
  1366. console.log(`bill.specialProvisional: ${bill.specialProvisional}`);
  1367. if (bill.specialProvisional === '工程设备') {
  1368. billItems.push(bill);
  1369. }
  1370. });
  1371. if (billItems.length > 0) {
  1372. billItems.forEach((bill) => {
  1373. let mEstItemNode = new emptyElement('Item');
  1374. mEstNode.children.push(mEstItemNode);
  1375. let attrs = [
  1376. { name: 'ItemNo', value: itemNo },
  1377. { name: 'Code', value: bill.code },
  1378. { name: 'Number', value: bill.code },
  1379. { name: 'Name', value: bill.name },
  1380. { name: 'Unit', value: bill.unit },
  1381. { name: 'Num', value: bill.quantity },
  1382. { name: 'Price', value: _getNumValueByExportKind(_getFee(bill, 'common', 'tenderUnitFee')) },
  1383. { name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), 0)), type: TYPE.DECIMAL },
  1384. // {name: 'Price', value: 0},
  1385. // {name: 'Sum', value: 0},
  1386. { name: 'Remark', value: (bill.remark) ? glj.remark : '' }
  1387. ];
  1388. itemNo++;
  1389. mEstItemNode.attrs.push(...attrs);
  1390. });
  1391. }
  1392. tenderProject.projectGLJ.datas.gljList.forEach((glj) => {
  1393. if (glj.is_evaluate && glj.type === 5) {
  1394. items.push(glj);
  1395. }
  1396. });
  1397. if (items.length > 0) {
  1398. items.forEach((glj, sno) => {
  1399. let mEstItemNode = new emptyElement('Item');
  1400. mEstNode.children.push(mEstItemNode);
  1401. let attrs = [
  1402. { name: 'ItemNo', value: itemNo },
  1403. { name: 'Code', value: _getBidGljCode(tenderProject, glj) },
  1404. { name: 'Number', value: glj.code },
  1405. { name: 'Name', value: glj.name },
  1406. { name: 'Unit', value: glj.unit },
  1407. { name: 'Num', value: glj.tenderQuantity },
  1408. // {name: 'Price', value: _getNumValueByExportKind(glj.unit_price.market_price)},
  1409. { name: 'Price', value: glj.unit_price.market_price }, // 暂估设备直接输出price
  1410. { name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(glj.tenderQuantity * glj.unit_price.market_price, 0)), type: TYPE.DECIMAL },
  1411. // {name: 'Price', value: 0},
  1412. // {name: 'Sum', value: 0},
  1413. { name: 'Remark', value: (glj.remark) ? glj.remark : '' }
  1414. ];
  1415. itemNo++;
  1416. mEstItemNode.attrs.push(...attrs);
  1417. });
  1418. }
  1419. if (billItems.length > 0 || items.length > 0) {
  1420. return mEstNode;
  1421. } else {
  1422. return null;
  1423. }
  1424. }
  1425. function getSpecPrjEst(tenderProject) {
  1426. let mEstNode = new emptyElement('SpecPrjEstimate');
  1427. let sum = 0;
  1428. let items = [];
  1429. //专业工程暂估明细
  1430. tenderProject.Bills.datas.forEach((bill) => {
  1431. if (bill.specialProvisional === '专业工程') {
  1432. items.push(bill);
  1433. }
  1434. });
  1435. if (items.length > 0) {
  1436. items.forEach((bill, sno) => {
  1437. let mEstItemNode = new emptyElement('Item');
  1438. mEstNode.children.push(mEstItemNode);
  1439. let ttl = _getFee(bill);
  1440. sum += ttl;
  1441. let jobContent = '';
  1442. if (bill.jobContent && bill.jobContent.length > 0) {
  1443. jobContent = bill.jobContent.toString();
  1444. } else {
  1445. jobContent = (bill.jobContentText) ? bill.jobContentText : '';
  1446. }
  1447. jobContent = jobContent.replace(regRt1, '&#xA;').replace(regRt2, '&#xA;').replace(reg1, '&#xA;').replace(reg2, '&#xA;'); // 转成XML的换行转义符
  1448. let attrs = [
  1449. { name: 'ItemNo', value: sno + 1 },
  1450. { name: 'Code', value: bill.code },
  1451. { name: 'Number', value: bill.code },
  1452. { name: 'Name', value: bill.name },
  1453. { name: 'Content', value: jobContent },
  1454. // {name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(ttl, 0)), type:TYPE.DECIMAL},
  1455. { name: 'Sum', value: ttl, type: TYPE.DECIMAL },
  1456. // {name: 'Sum', value: 0, type:TYPE.DECIMAL},
  1457. ];
  1458. mEstItemNode.attrs.push(...attrs);
  1459. });
  1460. mEstNode.attrs.push({ name: 'Sum', value: sum });
  1461. return mEstNode;
  1462. } else {
  1463. return null;
  1464. }
  1465. }
  1466. function getBillsAnalyze(tenderProject) {
  1467. if (isBidInvitation) return null; // 招标不输出此部分
  1468. // 本函数是尽量复刻【5.5表】工程量清单单价分析表的‘综合’计算式脚本的相关逻辑,具体细节根据实际环境有所调整(前端环境已有不少现成的结构及数据,能少跑不少逻辑)
  1469. let djfxbNode = new emptyElement('ListUnitPriceAnalysis');
  1470. let decimalObj = tenderProject.property.decimal;
  1471. // 工程量清单单价分析(100~700章 清单下所有定额工料机的综合)
  1472. let topNode100To700;
  1473. let sno = 1;
  1474. const prefix = '_';
  1475. let filterMtlTypes = [202, 203, 204, 301];
  1476. for (let bill of tenderProject.Bills.datas) {
  1477. if (bill.flags && bill.flags.length > 0) {
  1478. for (let flag of bill.flags) {
  1479. if (flag.flag === 19) {
  1480. for (let rootBill of tenderProject.Bills.tree.roots) {
  1481. if (rootBill.data.ID === bill.ID) {
  1482. topNode100To700 = rootBill;
  1483. break;
  1484. }
  1485. }
  1486. break;
  1487. }
  1488. }
  1489. }
  1490. }
  1491. const cacheObj = {};
  1492. const proKeysArr = [];
  1493. const addedGljCodeCache = {};
  1494. //说明:根据实际情况,用户会直接在清单下加工料机,此工料机属于定额层次,那么算工程量的时候要加上这个(沟通后这种几率很小,暂时返回0,如有再补上)
  1495. const _getAdhocGljQty = function (billsId, rationCode, rstType = 1) {
  1496. let rst = 0;
  1497. // for (let nbidx = 0; nbidx < newRBillsIdArr.length; nbidx++) {
  1498. // if (newRBillsIdArr[nbidx] === billsId && newRCodeArr[nbidx] === rationCode) {
  1499. // rst = (rstType === 1) ? newRQtyArr[nbidx] : newTtlArr[nbidx];
  1500. // break;
  1501. // }
  1502. // }
  1503. return rst;
  1504. };
  1505. const _getCacheObjInitialedItem = function (bill = null, glj = null) {
  1506. let rst = {
  1507. code: (bill) ? bill.code : ((glj) ? glj.code : ''),
  1508. name: (bill) ? bill.name : ((glj) ? glj.name : ''),
  1509. quantity: (bill) ? bill.quantity : 1,
  1510. labourConsume: 0,
  1511. labourUnitPrice: 0,
  1512. labourTotalPrice: 0,
  1513. mainMaterialFee: 0,
  1514. auxiliaryMaterialFee: 0,
  1515. materialUnitFee: (bill) ? _getFee(bill, 'marketMaterial', 'unitFee') : 0,
  1516. machineFee: (bill) ? _getFee(bill, 'marketMachine') : 0,
  1517. otherFee: (bill) ? _getFee(bill, 'measure') : 0, //措施费
  1518. managementFee: (bill) ? (_getFee(bill, 'manage') + _getFee(bill, 'force')) : 0, //管理+规费
  1519. taxFee: (bill) ? _getFee(bill, 'tax') : 0,
  1520. profitFee: (bill) ? _getFee(bill, 'profit') : 0,
  1521. unitPrice: (bill) ? _getFee(bill, 'common', 'unitFee') : 0,
  1522. items: []
  1523. };
  1524. return rst;
  1525. };
  1526. const _getPrjGLJ = function (gljID) {
  1527. let rst = null;
  1528. for (let glj of tenderProject.projectGLJ.datas.gljList) {
  1529. if (glj.id === gljID) {
  1530. rst = glj;
  1531. break;
  1532. }
  1533. }
  1534. return rst;
  1535. };
  1536. const _getRation = function (rationId) {
  1537. let rst = null;
  1538. for (let ration of tenderProject.Ration.datas) {
  1539. if (ration.ID === rationId) {
  1540. rst = ration;
  1541. break;
  1542. }
  1543. }
  1544. return rst;
  1545. };
  1546. const _createNode = function (billIdKey, bill) {
  1547. if (cacheObj[billIdKey]) {
  1548. //1. 叶子清单,先创建清单Item
  1549. let bQtn = 1;
  1550. if (bill.data.hasOwnProperty('quantity')) {
  1551. bQtn = parseFloat(bill.data.quantity);
  1552. if (isNaN(bQtn)) bQtn = 1;
  1553. }
  1554. let billMainMaterialTtl = cacheObj[billIdKey].mainMaterialFee / bQtn;
  1555. let billAuxiliaryMaterialTtl = cacheObj[billIdKey].auxiliaryMaterialFee / bQtn;
  1556. // scMathUtil.roundForObj(cacheObj[billIdKey].labourConsume / bQtn, decimalObj.glj.unitPrice)
  1557. let leafBillAttrs = [
  1558. { name: 'ItemNo', value: sno },
  1559. { name: 'Code', value: cacheObj[billIdKey].code },
  1560. { name: 'Name', value: cacheObj[billIdKey].name },
  1561. { name: 'LaborWorkDays', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourConsume / bQtn, decimalObj.glj.quantity)) },
  1562. { name: 'LaborUnitPrice', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourUnitPrice, decimalObj.glj.unitPrice)) },
  1563. { name: 'LaborUnitTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourTotalPrice / bQtn, decimalObj.glj.unitPrice)) },
  1564. { name: 'MainMaterialConsume', value: 0 },
  1565. { name: 'MainMaterialUnit', value: '' },
  1566. { name: 'MainMaterialUnitPrice', value: 0 },
  1567. { name: 'MainMaterialTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(billMainMaterialTtl, decimalObj.glj.unitPrice)) },
  1568. { name: 'AuxiliaryMaterialFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(billAuxiliaryMaterialTtl, decimalObj.glj.unitPrice)) },
  1569. { name: 'MaterialSum', value: _getNumValueByExportKind(scMathUtil.roundForObj(billMainMaterialTtl + billAuxiliaryMaterialTtl, decimalObj.glj.unitPrice)) },
  1570. { name: 'MachUsageFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].machineFee / bQtn, decimalObj.glj.unitPrice)) },
  1571. { name: 'OtherFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].otherFee / bQtn, decimalObj.glj.unitPrice)) },
  1572. { name: 'ManageFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].managementFee / bQtn, decimalObj.glj.unitPrice)) },
  1573. { name: 'Tax', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].taxFee / bQtn, decimalObj.glj.unitPrice)) },
  1574. { name: 'Profit', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].profitFee / bQtn, decimalObj.glj.unitPrice)) },
  1575. { name: 'Price', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill, 'common', 'tenderUnitFee'), decimalObj.glj.unitPrice)) },
  1576. ];
  1577. sno++;
  1578. let leafItemNode = new emptyElement('Item');
  1579. djfxbNode.children.push(leafItemNode);
  1580. // leafItemNode.attrs.push(...leafBillAttrs);
  1581. leafItemNode.attrs = leafBillAttrs;
  1582. //2. 清单下工料机
  1583. cacheObj[billIdKey].items.forEach((gljItem) => {
  1584. let showQty = gljItem.mainMaterialConsume / bQtn;
  1585. showQty = Math.round(showQty * 1000000) / 1000000;
  1586. let gljAttrs = [
  1587. { name: 'ItemNo', value: sno },
  1588. { name: 'Code', value: gljItem.code },
  1589. { name: 'Name', value: gljItem.name },
  1590. { name: 'LaborWorkDays', value: 0 },
  1591. { name: 'LaborUnitPrice', value: 0 },
  1592. { name: 'LaborUnitTotal', value: 0 },
  1593. // {name: 'MainMaterialConsume', value: scMathUtil.roundForObj(showQty, decimalObj.glj.quantity)},
  1594. { name: 'MainMaterialConsume', value: _getNumValueByExportKind(scMathUtil.roundForObj(showQty, decimalObj.glj.quantity)) },
  1595. // {name: 'MainMaterialUnit', value: gljItem.mainMaterialUnit},
  1596. { name: 'MainMaterialUnit', value: _getStrValueByExportKind(gljItem.mainMaterialUnit) },
  1597. { name: 'MainMaterialUnitPrice', value: _getNumValueByExportKind(scMathUtil.roundForObj(gljItem.mainMaterialUnitPrice, decimalObj.glj.unitPrice)) },
  1598. { name: 'MainMaterialTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(showQty * gljItem.mainMaterialUnitPrice, decimalObj.glj.unitPrice)) },
  1599. { name: 'AuxiliaryMaterialFee', value: 0 },
  1600. { name: 'MaterialSum', value: 0 },
  1601. { name: 'MachUsageFee', value: 0 },
  1602. { name: 'OtherFee', value: 0 },
  1603. { name: 'ManageFee', value: 0 },
  1604. { name: 'Tax', value: 0 },
  1605. { name: 'Profit', value: 0 },
  1606. // {name: 'Price', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), decimalObj.glj.unitPrice))},
  1607. { name: 'Price', value: 0 },
  1608. ];
  1609. sno++;
  1610. let gljItemNode = new emptyElement('Item');
  1611. djfxbNode.children.push(gljItemNode);
  1612. // gljItemNode.attrs.push(...gljAttrs);
  1613. gljItemNode.attrs = gljAttrs;
  1614. });
  1615. }
  1616. };
  1617. const _getAllGlj = function (parentBill) {
  1618. if (parentBill.data.name === '挖除水泥混凝土路面(平面交叉)') {
  1619. debugger;
  1620. }
  1621. if (parentBill.children.length > 0) {
  1622. parentBill.children.forEach((subBill) => {
  1623. _getAllGlj(subBill);
  1624. });
  1625. } else {
  1626. let billIdKey = prefix + parentBill.data.ID;
  1627. if (!cacheObj.hasOwnProperty(billIdKey)) {
  1628. cacheObj[billIdKey] = _getCacheObjInitialedItem(parentBill.data);
  1629. addedGljCodeCache[billIdKey] = [];
  1630. proKeysArr.push(billIdKey);
  1631. }
  1632. tenderProject.ration_glj.datas.forEach((rglj) => {
  1633. if (rglj.billsItemID === parentBill.data.ID) {
  1634. let ration = _getRation(rglj.rationID);
  1635. if (ration) {
  1636. // 计算消耗量,否则定额人材机消耗量取值会不正确
  1637. gljOprObj.getTotalQuantity(rglj, ration);
  1638. }
  1639. let gljQty = parseFloat(rglj.tenderQuantity || rglj.quantity);
  1640. if (isNaN(gljQty)) gljQty = 0;
  1641. let gljRationQty = 0;
  1642. if (ration) gljRationQty = parseFloat(ration.tenderQuantity || ration.quantity);
  1643. if (isNaN(gljRationQty)) gljRationQty = 0;
  1644. let gljCns = gljQty * gljRationQty;
  1645. let prjGlj = _getPrjGLJ(rglj.projectGLJID);
  1646. let gljUnitPrice = parseFloat(prjGlj.unit_price.market_price);
  1647. let gljTotalPrice = gljCns * gljUnitPrice;
  1648. let gljCode = rglj.code;
  1649. if (rglj.type === 1) {
  1650. //人工
  1651. cacheObj[billIdKey].labourConsume = cacheObj[billIdKey].labourConsume + gljCns;
  1652. cacheObj[billIdKey].labourUnitPrice = gljUnitPrice;
  1653. cacheObj[billIdKey].labourTotalPrice = cacheObj[billIdKey].labourTotalPrice + gljTotalPrice;
  1654. } else if (filterMtlTypes.indexOf(rglj.type) < 0) {
  1655. if (!addedGljCodeCache[billIdKey].includes(gljCode)) {
  1656. addedGljCodeCache[billIdKey].push(gljCode);
  1657. }
  1658. if (prjGlj.is_main_material) {
  1659. let dtlObj = {};
  1660. dtlObj.code = gljCode;
  1661. dtlObj.name = rglj.name;
  1662. dtlObj.specs = rglj.specs;
  1663. //
  1664. let adhocGljQty = _getAdhocGljQty(parentBill.data.ID, dtlObj.code);
  1665. let adhocGljTtl = adhocGljQty * gljUnitPrice;
  1666. dtlObj.mainMaterialConsume = gljCns + adhocGljQty; //考虑清单单独加工料机的情况,需要补上消耗量
  1667. dtlObj.mainMaterialUnitPrice = gljUnitPrice;
  1668. dtlObj.mainMaterialTotalPrice = gljTotalPrice;
  1669. dtlObj.mainMaterialUnit = rglj.unit;
  1670. let isAdd = 0;
  1671. for (let i = 0; i < cacheObj[billIdKey].items.length; i++) {
  1672. //先比较对象中是否已存在同一条工料机,存在,则累加汇总消耗量和金额;否则添加。
  1673. if (dtlObj.code === cacheObj[billIdKey].items[i].code && dtlObj.name === cacheObj[billIdKey].items[i].name && dtlObj.mainMaterialUnit === cacheObj[billIdKey].items[i].mainMaterialUnit && dtlObj.specs === cacheObj[billIdKey].items[i].specs) {
  1674. cacheObj[billIdKey].items[i].mainMaterialConsume = cacheObj[billIdKey].items[i].mainMaterialConsume + gljCns;
  1675. cacheObj[billIdKey].items[i].mainMaterialTotalPrice = cacheObj[billIdKey].items[i].mainMaterialTotalPrice + gljTotalPrice;
  1676. isAdd = 1;
  1677. break;
  1678. }
  1679. }
  1680. if (isAdd === 0) {
  1681. cacheObj[billIdKey].items.push(dtlObj);
  1682. }
  1683. cacheObj[billIdKey].mainMaterialFee = cacheObj[billIdKey].mainMaterialFee + gljTotalPrice + adhocGljTtl;
  1684. } else {
  1685. cacheObj[billIdKey].auxiliaryMaterialFee = cacheObj[billIdKey].auxiliaryMaterialFee + gljTotalPrice;
  1686. }
  1687. }
  1688. }
  1689. });
  1690. // 整理完后,开始创建XML节点(这里与参考脚本逻辑不一样了,直接开始创建)
  1691. _createNode(billIdKey, parentBill);
  1692. }
  1693. };
  1694. if (topNode100To700) {
  1695. topNode100To700.children.forEach((topChapterBill) => {
  1696. _getAllGlj(topChapterBill);
  1697. });
  1698. }
  1699. //...
  1700. return djfxbNode;
  1701. }
  1702. function getBidEvaluationMainMaterial(tenderProject) {
  1703. let bidMaterials = [];
  1704. let i = 1;
  1705. for (let b of tenderProject.bidMaterialData) {
  1706. bidMaterials.push(new BidEvaluationMainMaterial(b, i));
  1707. i++
  1708. }
  1709. return bidMaterials;
  1710. function BidEvaluationMainMaterial(b, index) {
  1711. const attrs = [{
  1712. name: "Code",
  1713. value: b.seq,
  1714. },
  1715. {
  1716. name: "Number",
  1717. value: b.code
  1718. },
  1719. {
  1720. name: "Name",
  1721. value: b.name
  1722. },
  1723. {
  1724. name: "Specification",
  1725. value: b.specs
  1726. },
  1727. {
  1728. name: "Unit",
  1729. value: b.unit
  1730. },
  1731. {
  1732. name: "Price",
  1733. value: _getNumValueByExportKind(b.marketPrice || '0'),
  1734. type: TYPE.DECIMAL
  1735. },
  1736. {
  1737. name: "LimitedPrice",
  1738. value: _getNumValueByExportKind(b.marketPrice || '0'),
  1739. type: TYPE.DECIMAL
  1740. },
  1741. {
  1742. name: "Quantity",
  1743. value: b.quantity,
  1744. type: TYPE.DECIMAL
  1745. },
  1746. {
  1747. name: "Total",
  1748. value: 0
  1749. },
  1750. {
  1751. name: "Remark",
  1752. value: b.remark
  1753. }
  1754. ];
  1755. if (isBidSubmission || isControl) {
  1756. attrs[7].value = b.quantity;
  1757. attrs[8].value = b.totalPrice;
  1758. }
  1759. Element.call(this, "BidEvaluationMainMaterial", attrs);
  1760. }
  1761. }
  1762. function getIndexs(tenderProject) {
  1763. let Indexs = new emptyElement('Indexs');
  1764. let feature = tenderProject.property.projectFeature ? tenderProject.property.projectFeature : [];
  1765. for (let f of feature) {
  1766. if (f.code) Indexs.children.push(new IndexItem(f))
  1767. }
  1768. return Indexs;
  1769. function IndexItem(fea) {
  1770. const attrs = [{
  1771. name: "Code",
  1772. value: fea.code,
  1773. },
  1774. {
  1775. name: "Name",
  1776. value: fea.dispName,
  1777. },
  1778. {
  1779. name: "Unit",
  1780. value: fea.unit,
  1781. },
  1782. {
  1783. name: "Value",
  1784. value: fea.value,
  1785. },
  1786. {
  1787. name: "Remark",
  1788. value: fea.remark,
  1789. }
  1790. ]
  1791. Element.call(this, "IndexItem", attrs);
  1792. }
  1793. }
  1794. function getBillsItems(tenderProject, cacheForFormula) {
  1795. let items = new emptyElement("Items");
  1796. let rootNodes = tenderProject.mainTree.roots;
  1797. for (let r of rootNodes) {
  1798. setItem(r, -1, items.children);
  1799. }
  1800. return items;
  1801. function setItem(bNode, level, list, dftListCodeSeq = -1) {
  1802. const specialChkBillFlag = [fixedFlag.DAYWORK_LABOR, fixedFlag.LABOUR_SERVICE, fixedFlag.MATERIAL, fixedFlag.CONSTRUCTION_MACHINE];
  1803. if (bNode.sourceType == ModuleNames.ration) return;
  1804. // 判断: 1. 招标清单 2. 是否量价,都是的话,return
  1805. if (isBidInvitation && (bNode.data.specialProvisional == "材料暂估" || bNode.data.specialProvisional == "工程设备")) {
  1806. return;
  1807. }
  1808. let item = new bill(bNode, level, dftListCodeSeq);
  1809. if (bNode.children && bNode.children.length > 0) {
  1810. level += 1;
  1811. let dftLCStartSeq = -1;
  1812. if (isFlag(bNode.data) && specialChkBillFlag.includes(bNode.data.flagsIndex.fixed.flag)) {
  1813. dftLCStartSeq = 1;
  1814. }
  1815. for (let c of bNode.children) {
  1816. setItem(c, level, item.children, dftLCStartSeq);
  1817. if (dftLCStartSeq > 0) dftLCStartSeq++;
  1818. }
  1819. }
  1820. list.push(item);
  1821. function getCalcType(node) {
  1822. /*
  1823. 判断是否父项:
  1824. 是父项,则取1;
  1825. 是叶子项,则判断其下有无套定额/量价/工料机:
  1826. 有则取1;
  1827. 无则判断有无基数计算:
  1828. 有则取2;
  1829. 无则取3 */
  1830. if (node.children && node.children.length > 0) {
  1831. return 1; //是父项,则取1, 有套定额/量价/工料机,也取1
  1832. } else {
  1833. return node.data.calcBase && node.data.calcBase != "" ? 2 : 3
  1834. }
  1835. }
  1836. function getItemType(node) {
  1837. let Bills = projectObj.project.Bills;
  1838. //是100~900章部分、或是计日工部分,叶子清单输出1,父项输出0;
  1839. if (Bills.isBelongOneToSeven(node) || Bills.isBelongDayWork(node)) {
  1840. if (node.children && node.children.length > 0) {
  1841. return node.children[0].sourceType == ModuleNames.ration ? 1 : 0
  1842. }
  1843. //山东新需求:清单 第XXX章、计日工、劳务、材料、机械 输出0
  1844. const bNodeName = _billStrFilter(node.data.name);
  1845. if (bNodeName.indexOf('清单第') >= 0 && bNodeName.indexOf('00章') > 0) {
  1846. return 0;
  1847. } else if (isFlag(node.data) && specialChkBillFlag.includes(node.data.flagsIndex.fixed.flag)) {
  1848. return 0;
  1849. }
  1850. return 1 //叶子清单输出1
  1851. } else {
  1852. return 0;
  1853. /* //非100~900章部分,
  1854. // 是暂列金额,判断暂列金额的金额等于0,则输出为0;暂列金额的金额不等于0,则输出为1;
  1855. if (node.data.name && node.data.name.indexOf("暂列金额") != -1) {
  1856. let sum = node.data.feesIndex && node.data.feesIndex.common ? node.data.feesIndex.common.tenderTotalFee : "";
  1857. return gljUtil.isNotEmpty(sum) ? 1 : 0
  1858. } else { //非暂列金额,则判断清单的工程量是否等于0,等于0,则输出0;不等于0,则输出1
  1859. return gljUtil.isNotEmpty(node.data.quantity) ? 1 : 0
  1860. } */
  1861. }
  1862. }
  1863. function bill(bNode, level, dftListCodeSeq = -1) {
  1864. let data = bNode.data;
  1865. let CostKind = 3;
  1866. if (data.name === undefined || data.name === null) data.name = '';
  1867. if (data.name && data.name.indexOf("安全生产费") != -1) CostKind = 1;
  1868. if (data.name && data.name.indexOf("暂列金额") != -1) CostKind = 2;
  1869. //1 = 工程量×综合单价;2 = 计算基数×费率;3 = 工程量×单价。
  1870. let CalcType = getCalcType(bNode);
  1871. //取暂估价类型。读取造价书界面的专项暂定列。0=材料暂估价,1=工程设备暂估价,2=专业工程暂估价,没有选的输出为空。
  1872. let ProvisionalType = "";
  1873. if (data.specialProvisional == "材料暂估") ProvisionalType = 0;
  1874. if (data.specialProvisional == "工程设备") ProvisionalType = 1;
  1875. if (data.specialProvisional == "专业工程") ProvisionalType = 2;
  1876. if (data.specialProvisional == "固定费用") ProvisionalType = 3;
  1877. //MpRatio
  1878. let MpRatio = "";
  1879. let MaterialRatio = "";
  1880. let MechRatio = "";
  1881. if (data.quantityCoe) {
  1882. if (data.quantityCoe["labour"]) MpRatio = data.quantityCoe["labour"];
  1883. if (data.quantityCoe["material"]) MaterialRatio = data.quantityCoe["material"];
  1884. if (data.quantityCoe["machine"]) MechRatio = data.quantityCoe["machine"];
  1885. }
  1886. let fail = billNameChecking(bNode, tenderProject.projectInfo.name, fixedFlag)
  1887. //fail: { hint: '错误提示', type: '提示所属(基本就是单位工程名称)' }
  1888. let ListCode = "";
  1889. // if (ListCodeMap[data.name]) ListCode = ListCodeMap[data.name];
  1890. if (ListCodeMap[_billStrFilter(data.name)]) {
  1891. ListCode = ListCodeMap[_billStrFilter(data.name)];
  1892. } else if (_chkAdhocChapterBillCode(data.name)) {
  1893. ListCode = _extractAdhocChapter(data.name);
  1894. } else if (data.code && data.code != "") {
  1895. ListCode = data.code;
  1896. } else if (dftListCodeSeq > 0) {
  1897. ListCode = `${dftListCodeSeq}`;
  1898. }
  1899. let qtyFormula = data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "";
  1900. //data.calcBase //data.calcBase ? cbParser.toFExpr(data.calcBase, tenderProject.mainTree.items) : "",
  1901. if (!data.name.includes('暂列金额') && isBidInvitation) {
  1902. if (data.hasOwnProperty('calcBase')) {
  1903. let chkNaN = parseFloat(data.calcBase);
  1904. if (isNaN(chkNaN)) {
  1905. qtyFormula = data.calcBase;
  1906. } else {
  1907. qtyFormula = '';
  1908. }
  1909. } else {
  1910. qtyFormula = '';
  1911. }
  1912. //判断公式(calcBase)是否为正常的计算公式(即非直接输入数量),
  1913. }
  1914. let formulaCode = '';
  1915. if (cacheForFormula['_' + data.ID] && cacheForFormula['_' + data.ID].formulaCode) {
  1916. formulaCode = cacheForFormula['_' + data.ID].formulaCode;
  1917. }
  1918. const attrs = [{
  1919. name: "ListCode",
  1920. value: ListCode,
  1921. },
  1922. {
  1923. name: "ListName",
  1924. value: data.name,
  1925. fail: fail
  1926. },
  1927. {
  1928. name: "Unit",
  1929. value: data.unit,
  1930. },
  1931. {
  1932. name: "Num",
  1933. value: data.quantity,
  1934. type: TYPE.DECIMAL,
  1935. toFix: 3
  1936. },
  1937. {
  1938. name: "QtyFormula",
  1939. value: qtyFormula,
  1940. type: TYPE.DECIMAL,
  1941. toFix: 2
  1942. },
  1943. {
  1944. name: "Price",
  1945. value: 0,//data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderUnitFee : "",
  1946. type: TYPE.DECIMAL,
  1947. toFix: 2
  1948. },
  1949. {
  1950. name: "Rate",
  1951. value: 100,
  1952. },
  1953. {
  1954. name: "Sum",
  1955. value: 0,//data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "",
  1956. type: TYPE.DECIMAL,
  1957. toFix: 2
  1958. },
  1959. {
  1960. name: "ChapterKind",
  1961. value: level > 3 ? 3 : level,
  1962. },
  1963. {
  1964. name: "CostKind",
  1965. value: CostKind,
  1966. },
  1967. {
  1968. name: "CalcType",
  1969. value: CalcType,
  1970. },
  1971. {
  1972. name: "ProvisionalType",
  1973. value: ProvisionalType,
  1974. mustHasValue: true
  1975. },
  1976. {
  1977. name: "MeterRules",
  1978. value: "",
  1979. },
  1980. {
  1981. name: "Content",
  1982. value: data.jobContentText,
  1983. },
  1984. {
  1985. name: "Remarks",
  1986. value: data.remark,
  1987. },
  1988. /* {
  1989. name: "MpRatio",
  1990. value: MpRatio,
  1991. },
  1992. {
  1993. name: "MaterialRatio",
  1994. value: MaterialRatio,
  1995. },
  1996. {
  1997. name: "MechRatio",
  1998. value: MechRatio,
  1999. },
  2000. {
  2001. name: "AdjustedPrice",
  2002. value: data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderUnitFee : "",
  2003. },
  2004. {
  2005. name: "AdjustedSums",
  2006. value: data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "",
  2007. }, */
  2008. {
  2009. name: "ItemType",
  2010. value: getItemType(bNode),
  2011. },
  2012. /* {
  2013. name: "FomulaCode",
  2014. value: ""
  2015. }, */
  2016. {
  2017. name: "FormulaCode",
  2018. value: formulaCode,
  2019. },
  2020. ];
  2021. //投标、招标控制价时。取单价。
  2022. //招标时,如果是“安全生产费”或“暂列金额”,取单价,否则取0。
  2023. if (isBidSubmission || isControl || CostKind == 1 || CostKind == 2 || ProvisionalType === 2 || ProvisionalType === 3) {
  2024. attrs[5].value = data.feesIndex && data.feesIndex.common ? scMathUtil.roundForObj(data.feesIndex.common.tenderUnitFee, tenderProject.property.decimal.bills.unitPrice) : "";
  2025. attrs[7].value = data.feesIndex && data.feesIndex.common ? scMathUtil.roundForObj(data.feesIndex.common.tenderTotalFee, tenderProject.property.decimal.bills.totalPrice) : "";
  2026. //暂列金额 数量为0的时候,单价输出0
  2027. if (CostKind == 2 && !gljUtil.isNotEmpty(data.quantity)) attrs[5].value = 0
  2028. }
  2029. let fixedSumVal = _getFixedSum(tenderProject); // 固定费用
  2030. Element.call(this, "Item", attrs);
  2031. let cc = CostComposition(bNode);
  2032. if (cc) this.children.push(cc);
  2033. this.children.push(CostStructure(data, tenderProject.property.decimal.bills.totalPrice))
  2034. function CostComposition(bNode) {
  2035. // 山东逻辑:如果清单下有计算基数,则需要输出(废弃)
  2036. // 新逻辑:
  2037. // 标准接口文档里,写了只有招标清单,才是完全不输出定额相关数据的
  2038. // 当清单有清单基数和费率,那么应该就是没有定额,不输出定额;
  2039. // 清单没有基数和费率,也没有下挂定额,那么也不输出定额相关字段;
  2040. // 清单有下挂定额、量价,那么输出定额相关数据。
  2041. // if (isBidInvitation) return null; // 山东接口又要这个了
  2042. let CostComposition = new emptyElement('CostComposition');
  2043. let Norms = [];
  2044. let Costs = [];
  2045. if (bNode.children && bNode.children.length > 0 && bNode.children[0].sourceType == ModuleNames.ration) {
  2046. for (let r of bNode.children) {
  2047. if (r.data.type == rationType.ration) {
  2048. if (isEmptyRation(r.data) || isBidInvitation) continue; // 招标 或者 定额空行不输出到接口文件中。
  2049. Norms.push(new Ration(r.data));
  2050. } else if (!isBidInvitation) {
  2051. Costs.push(new Cost(r.data));
  2052. }
  2053. }
  2054. }
  2055. if (Norms.length > 0) CostComposition.children.push(...Norms);
  2056. if (Costs.length > 0) CostComposition.children.push(...Costs);
  2057. if (bNode.data.calcBase) CostComposition.children.push(new Formula(bNode.data));
  2058. return CostComposition.children.length > 0 ? CostComposition : null;
  2059. //定额空行不输出到接口文件中。 //定额空行的判断是:定额编码、定额名称、定额单位、定额单位、定额工程量为零或为空时
  2060. function isEmptyRation(ration) {
  2061. return !gljUtil.isNotEmpty(ration.code) && !gljUtil.isNotEmpty(ration.name) && !gljUtil.isNotEmpty(ration.unit) && (!gljUtil.isNotEmpty(ration.quantity) || ration.quantity == 0)
  2062. }
  2063. function Formula(bills) {
  2064. let sumFix = (bills.name === '已包含在清单合计中的材料、工程设备、专业工程暂估价合计') ? fixedSumVal : 0;
  2065. const attrs = [{
  2066. name: "Name",
  2067. value: bills.name
  2068. },
  2069. {
  2070. name: "Formulas",
  2071. value: _getFormulaDispName(cacheForFormula, bills)
  2072. },
  2073. {
  2074. name: "Ratio",
  2075. value: 1
  2076. },
  2077. {
  2078. name: "Sum",
  2079. // value: bills.feesIndex && bills.feesIndex.common ? bills.feesIndex.common.tenderTotalFee : "",
  2080. // value: _getNumValueByExportKind(bills.feesIndex && bills.feesIndex.common ? bills.feesIndex.common.tenderTotalFee : "") - sumFix,
  2081. value: _getNumValueByExportKind(bills.feesIndex && bills.feesIndex.common ? bills.feesIndex.common.tenderTotalFee : ""), // 不用再减一次sumFix
  2082. type: TYPE.DECIMAL
  2083. },
  2084. {
  2085. name: "Remarks",
  2086. value: bills.remark
  2087. }
  2088. ]
  2089. Element.call(this, "Formula", attrs);
  2090. // 1.Name
  2091. // 名称/描述。取清单的名称。
  2092. // 2.Formulas
  2093. // 计算式。读取计算基数的文本。
  2094. // 取基数计算窗口内容,基数直接转换为金额?参考标准文档的 7.11 及 7.12 节。
  2095. // 7.11是定额的费用,7.12是清单累进基数,主要是估概预算中用到,清单里的不同,所以中山的接口直接输出基数文本。
  2096. // 3.Ratio
  2097. // 系数。输出为1,非必填。
  2098. // 4.Sum
  2099. // 取金额。
  2100. // 5.Remarks
  2101. }
  2102. function Cost(item) {
  2103. let BasePrice = 0;
  2104. if (item.type == rationType.volumePrice) { // 当插入的是量价时,基价读取单价列。
  2105. BasePrice = item.feesIndex && item.feesIndex.common ? item.feesIndex.common.tenderUnitFee : 0
  2106. } else {
  2107. BasePrice = getBasePrice(item.projectGLJID, tenderProject)
  2108. }
  2109. let calcMap = tenderProject.calcProgram.compiledTemplateMaps
  2110. let CostTypeNo = '';
  2111. if (feeRateMap[calcMap[item.programID]]) CostTypeNo = feeRateMap[calcMap[item.programID]];
  2112. const attrs = [{
  2113. name: "Code",
  2114. value: item.code,
  2115. }, {
  2116. name: 'Name',
  2117. value: item.name
  2118. }, {
  2119. name: 'Spec',
  2120. value: item.specs
  2121. }, {
  2122. name: 'Unit',
  2123. value: item.unit
  2124. }, {
  2125. name: 'Num',
  2126. value: item.tenderQuantity
  2127. }, {
  2128. name: 'BasePrice',
  2129. value: BasePrice
  2130. }, {
  2131. name: 'Price',
  2132. value: item.feesIndex && item.feesIndex.common ? item.feesIndex.common.tenderUnitFee : 0
  2133. }, {
  2134. name: 'IsEquipment',
  2135. value: item.subType == gljType.EQUIPMENT ? 1 : 0
  2136. }, {
  2137. name: 'CostTypeNo',
  2138. value: CostTypeNo
  2139. }, {
  2140. name: 'ProfitRate',
  2141. value: getFeeRate(item.programID, 'profit', tenderProject)
  2142. },
  2143. {
  2144. name: 'TaxRate',
  2145. value: getFeeRate(item.programID, 'tax', tenderProject)
  2146. },
  2147. {
  2148. name: 'MpRatio',
  2149. value: item.subType == gljType.LABOUR ? 100 : 0
  2150. },
  2151. {
  2152. name: 'MaterialRatio',
  2153. value: item.subType == gljType.GENERAL_MATERIAL ? 100 : 0
  2154. },
  2155. {
  2156. name: 'MechRatio',
  2157. value: item.subType == gljType.GENERAL_MACHINE ? 100 : 0
  2158. }
  2159. ]
  2160. Element.call(this, "Cost", attrs);
  2161. this.children.push(CostStructure(item, tenderProject.property.decimal.ration.totalPrice));
  2162. }
  2163. function Ration(ration) {
  2164. let calcMap = tenderProject.calcProgram.compiledTemplateMaps
  2165. let CostTypeNo = '';
  2166. if (feeRateMap[calcMap[ration.programID]]) CostTypeNo = feeRateMap[calcMap[ration.programID]];
  2167. const attrs = [{
  2168. name: "NormLibNo",
  2169. value: 'YSDE-000000-2018-86',
  2170. }, {
  2171. name: 'DisplayCode',
  2172. value: ration.code
  2173. }, {
  2174. name: 'Name',
  2175. value: ration.name
  2176. }, {
  2177. name: 'Unit',
  2178. value: ration.unit
  2179. }, {
  2180. name: 'Num',
  2181. value: ration.tenderQuantity
  2182. },
  2183. {
  2184. name: 'CostTypeNo',
  2185. value: CostTypeNo
  2186. },
  2187. {
  2188. name: 'ProfitRate',
  2189. value: getFeeRate(ration.programID, 'profit', tenderProject) //tenderProject.ProfitRate
  2190. },
  2191. {
  2192. name: 'TaxRate',
  2193. value: getFeeRate(ration.programID, 'tax', tenderProject) //tenderProject.TaxRate
  2194. },
  2195. {
  2196. name: 'FabricationCost',
  2197. value: ration.feesIndex && ration.feesIndex.common ? ration.feesIndex.common.tenderTotalFee : 0
  2198. },
  2199. {
  2200. name: 'AdjustStatus',
  2201. value: ration.adjustState
  2202. }
  2203. ]
  2204. Element.call(this, "Norm", attrs);
  2205. this.children.push(CostStructure(ration, tenderProject.property.decimal.ration.totalPrice));
  2206. this.children.push(Consume(ration));
  2207. }
  2208. }
  2209. function Consume(ration) {
  2210. let consume = new emptyElement('Consume');
  2211. for (let rg of ration.rationGLJList) {
  2212. consume.children.push(new ConsumeItem(rg));
  2213. }
  2214. return consume;
  2215. function ConsumeItem(rg) {
  2216. const attrs = [{
  2217. name: "Code",
  2218. value: rg.code,
  2219. }, {
  2220. name: "Consumption",
  2221. value: rg.tenderQuantity
  2222. }];
  2223. Element.call(this, "ConsumeItem", attrs);
  2224. }
  2225. }
  2226. function CostStructure(item, decimalNum) {
  2227. let CostStructure = new emptyElement('CostStructure');
  2228. for (let f of cpFeeTypes) {
  2229. if (itemFeeMap[f.type]) CostStructure.children.push(new CostItem(item, f.type))
  2230. }
  2231. if (CostStructure.children.length == 0) CostStructure.children.push(new CostItem({}, ""))
  2232. function CostItem(item, type) {
  2233. const attrs = [{
  2234. name: "ItemNo",
  2235. value: itemFeeMap[type],
  2236. }, {
  2237. name: 'Sum',
  2238. value: 0 //fee.tenderTotalFee
  2239. }]
  2240. if ((isBidSubmission || isControl) && item.feesIndex && item.feesIndex[type]) {
  2241. attrs[1].value = scMathUtil.roundForObj(item.feesIndex[type].tenderTotalFee, decimalNum);
  2242. if ((item.name === '已包含在清单合计中的材料、工程设备、专业工程暂估价合计') && (itemFeeMap[type] === 'JAF')) {
  2243. attrs[1].value = scMathUtil.roundForObj(attrs[1].value - fixedSumVal, decimalNum);
  2244. }
  2245. }
  2246. Element.call(this, "CostItem", attrs);
  2247. }
  2248. return CostStructure;
  2249. }
  2250. }
  2251. }
  2252. }
  2253. function Params(tenderProject) {
  2254. let feature = tenderProject.property.projectFeature ? tenderProject.property.projectFeature : [];
  2255. let featrueMap = {};
  2256. let baseMap = {};
  2257. for (let f of feature) {
  2258. featrueMap[f.key] = f;
  2259. }
  2260. let baseInfo = _.find(tenderProject.property.basicInformation, {
  2261. dispName: "基本信息",
  2262. });
  2263. for (let i of baseInfo.items) {
  2264. let key = i.key;
  2265. //if (i.dispName == "编制日期") key = "编制时间";
  2266. baseMap[key] = i;
  2267. }
  2268. let BuildType = "";
  2269. if (baseMap["natureConstruction"].value == "新建") BuildType = 0;
  2270. if (baseMap["natureConstruction"].value == "改扩建") BuildType = 1;
  2271. let Terrain = "";
  2272. if (baseMap["terrainCategory"].value == "平原微丘") Terrain = 0;
  2273. if (baseMap["terrainCategory"].value == "山岭重丘") Terrain = 1;
  2274. let DesignSpeed = featrueMap["designSpeed"].value;
  2275. let Structure = "";
  2276. if (featrueMap["pavementStructure"].value == "沥青路面") Structure = 0;
  2277. if (featrueMap["pavementStructure"].value == "水泥混凝土路面") Structure = 1;
  2278. if (featrueMap["pavementStructure"].value == "其他类型路面") Structure = 2;
  2279. let RoadGrade = "";
  2280. if (RoadGradeMap[baseMap["roadGrade"].value]) RoadGrade = RoadGradeMap[baseMap["roadGrade"].value];
  2281. const attrs = [{
  2282. name: "PrjArea",
  2283. value: baseMap["location"] ? baseMap["location"].value : ""
  2284. },
  2285. {
  2286. name: "StartPileNo",
  2287. value: baseMap["startChainages"] ? baseMap["startChainages"].value : "",
  2288. mustHasValue: true
  2289. },
  2290. {
  2291. name: "EndPileNo",
  2292. value: baseMap["endChainages"] ? baseMap["endChainages"].value : "",
  2293. mustHasValue: true
  2294. },
  2295. {
  2296. name: "BuildType",
  2297. value: BuildType,
  2298. },
  2299. {
  2300. name: "Terrain",
  2301. value: Terrain,
  2302. mustHasValue: true
  2303. },
  2304. {
  2305. name: "RoadGrade",
  2306. value: RoadGrade,
  2307. mustHasValue: true
  2308. },
  2309. {
  2310. name: "DesignSpeed",
  2311. value: DesignSpeed,
  2312. mustHasValue: true
  2313. },
  2314. {
  2315. name: "Structure",
  2316. value: Structure,
  2317. mustHasValue: true
  2318. },
  2319. {
  2320. name: "SubgradeWidth",
  2321. value: featrueMap["subgradeWidth"] ? featrueMap["subgradeWidth"].value : "",
  2322. mustHasValue: true
  2323. },
  2324. {
  2325. name: "RoadLength",
  2326. value: featrueMap["roadLength"] ? featrueMap["roadLength"].value : "",
  2327. mustHasValue: true
  2328. },
  2329. {
  2330. name: "BridgeLength",
  2331. value: featrueMap["bridgeLength"] ? featrueMap["bridgeLength"].value : "",
  2332. mustHasValue: true
  2333. },
  2334. {
  2335. name: "TunnelLength",
  2336. value: featrueMap["tunnelLength"] ? featrueMap["tunnelLength"].value : "",
  2337. mustHasValue: true
  2338. },
  2339. {
  2340. name: "BriTunRate",
  2341. value: featrueMap["briTunRate"] ? featrueMap["briTunRate"].value : "",
  2342. mustHasValue: true
  2343. },
  2344. {
  2345. name: "InterchangeNum",
  2346. value: featrueMap["interchangeNum"] ? featrueMap["interchangeNum"].value : "",
  2347. mustHasValue: true
  2348. },
  2349. {
  2350. name: "StubLengths",
  2351. value: featrueMap["stubLengths"] ? featrueMap["stubLengths"].value : "",
  2352. mustHasValue: true
  2353. },
  2354. {
  2355. name: "LaneLength",
  2356. value: featrueMap["laneLength"] ? featrueMap["laneLength"].value : "",
  2357. mustHasValue: true
  2358. },
  2359. ];
  2360. Element.call(this, "Params", attrs);
  2361. }
  2362. function SummaryOfCost(totalItem, proItem, safeItem, oneToSevenItem, feature) {
  2363. let attrs = [{
  2364. name: "TenderSumLimit",
  2365. value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
  2366. type: TYPE.DECIMAL,
  2367. toFix: 2,
  2368. },
  2369. {
  2370. name: "BidTotal",
  2371. value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
  2372. type: TYPE.DECIMAL,
  2373. toFix: 2,
  2374. },
  2375. {
  2376. name: "BillTotal",
  2377. value: oneToSevenItem.feesIndex && oneToSevenItem.feesIndex.common && oneToSevenItem.feesIndex.common.tenderTotalFee ? oneToSevenItem.feesIndex.common.tenderTotalFee : 0,
  2378. type: TYPE.DECIMAL,
  2379. toFix: 2,
  2380. },
  2381. {
  2382. name: "CostForHSE",
  2383. value: safeItem && safeItem.feesIndex && safeItem.feesIndex.common && safeItem.feesIndex.common.tenderTotalFee ? safeItem.feesIndex.common.tenderTotalFee : 0,
  2384. type: TYPE.DECIMAL,
  2385. toFix: 2,
  2386. },
  2387. {
  2388. name: "ProvisionalSums",
  2389. value: proItem.feesIndex && proItem.feesIndex.common && proItem.feesIndex.common.tenderTotalFee ? proItem.feesIndex.common.tenderTotalFee : 0,
  2390. type: TYPE.DECIMAL,
  2391. toFix: 2,
  2392. },
  2393. {
  2394. name: "Appraisal",
  2395. // value: totalItem.feesIndex && totalItem.feesIndex.estimate && totalItem.feesIndex.estimate.tenderTotalFee ? totalItem.feesIndex.estimate.tenderTotalFee : 0,
  2396. value: 0,
  2397. type: TYPE.DECIMAL,
  2398. toFix: 2,
  2399. },
  2400. ];
  2401. if (isBidInvitation) {
  2402. attrs.splice(0, 3) //招标
  2403. }
  2404. //if (isControl) attrs.splice(1, 5); //控制价
  2405. if (isBidSubmission) { //投标文件时,读工程特征中的 招标控制价 值
  2406. let tenderSumLimit = _.find(feature, { "key": "tenderSumLimit" });
  2407. if (tenderSumLimit) attrs[0].value = tenderSumLimit.value
  2408. }
  2409. Element.call(this, "SummaryOfCost", attrs);
  2410. }
  2411. function MakeInfo(tenderProject) {
  2412. let property = tenderProject.property;
  2413. let baseMap = {};
  2414. let baseInfo = _.find(property.basicInformation, {
  2415. dispName: "基本信息",
  2416. });
  2417. for (let i of baseInfo.items) {
  2418. let key = i.key;
  2419. //if (i.dispName == "编制日期") key = "编制时间";
  2420. baseMap[key] = i;
  2421. }
  2422. //mustHasValue
  2423. const attrs = [{
  2424. name: "ValuationModel",
  2425. value: property.taxType,
  2426. },
  2427. {
  2428. name: "Manage",
  2429. value: baseMap["constructingUnit"] ? baseMap["constructingUnit"].value : "",
  2430. },
  2431. {
  2432. name: "Designer",
  2433. value: baseMap["designUnit"] ? baseMap["designUnit"].value : "",
  2434. mustHasValue: true
  2435. },
  2436. {
  2437. name: "Compile",
  2438. value: baseMap["compileUnit"] ? baseMap["compileUnit"].value : "",
  2439. },
  2440. {
  2441. name: "CompileApprover",
  2442. value: baseMap["compileApprover"] ? baseMap["compileApprover"].value : "",
  2443. },
  2444. {
  2445. name: "CompileCertNo",
  2446. value: baseMap["compileCertNo"] ? baseMap["compileCertNo"].value : "",
  2447. mustHasValue: true
  2448. },
  2449. {
  2450. name: "CompileDate",
  2451. value: baseMap["compileDate"] && baseMap["compileDate"].value != "" ? baseMap["compileDate"].value + "T00:00:00" : "",
  2452. mustHasValue: true
  2453. },
  2454. {
  2455. name: "Review",
  2456. value: baseMap["reviewUnit"] ? baseMap["reviewUnit"].value : "",
  2457. mustHasValue: true
  2458. },
  2459. {
  2460. name: "ReviewApprover",
  2461. value: baseMap["reviewApprover"] ? baseMap["reviewApprover"].value : "",
  2462. mustHasValue: true
  2463. },
  2464. {
  2465. name: "ReviewCertNo",
  2466. value: baseMap["reviewCertNo"] ? baseMap["reviewCertNo"].value : "",
  2467. mustHasValue: true
  2468. },
  2469. {
  2470. name: "ReviewDate",
  2471. value: baseMap["reviewDate"] && baseMap["reviewDate"].value != "" ? baseMap["reviewDate"].value + "T00:00:00" : "",
  2472. mustHasValue: true
  2473. },
  2474. {
  2475. name: "Examine",
  2476. value: baseMap["examineUnit"] ? baseMap["examineUnit"].value : "",
  2477. mustHasValue: true
  2478. },
  2479. {
  2480. name: "ExamineApprover",
  2481. value: baseMap["examineApprover"] ? baseMap["examineApprover"].value : "",
  2482. mustHasValue: true
  2483. },
  2484. {
  2485. name: "ExamineCertNo",
  2486. value: baseMap["examineCertNo"] ? baseMap["examineCertNo"].value : "",
  2487. mustHasValue: true
  2488. },
  2489. {
  2490. name: "ExamineDate",
  2491. value: baseMap["examineDate"] && baseMap["examineDate"].value != "" ? baseMap["examineDate"].value + "T00:00:00" : "",
  2492. mustHasValue: true
  2493. },
  2494. {
  2495. name: "CompileExplain",
  2496. value: baseMap["compileExplain"] ? baseMap["compileExplain"].value : "",
  2497. mustHasValue: true
  2498. },
  2499. {
  2500. name: "ExamineExplain",
  2501. value: baseMap["examineExplain"] ? baseMap["examineExplain"].value : "",
  2502. mustHasValue: true
  2503. },
  2504. {
  2505. name: "ProjectExplain",
  2506. value: baseMap["projectExplain"] ? baseMap["projectExplain"].value : "",
  2507. mustHasValue: true
  2508. },
  2509. {
  2510. name: "Bidder",
  2511. // value: baseMap["bidderCompany"] ? baseMap["bidderCompany"].value : "",
  2512. value: baseMap["bidderName"] ? baseMap["bidderName"].value : "",
  2513. mustHasValue: true
  2514. },
  2515. ];
  2516. if (isBidInvitation) { //招标文件,则以下的8、12~18则不输出
  2517. attrs.splice(11, 7);
  2518. attrs.splice(7, 1);
  2519. }
  2520. Element.call(this, "MakeInfo", attrs);
  2521. }
  2522. let data = new CprjInfo(projectData.name);
  2523. data.children.push(new SystemInfo(projectData));
  2524. data.children.push(new CostBasis());
  2525. let seriNo = 1;
  2526. let Rates = [];
  2527. let Practs = [];
  2528. let EprjInfos = [];
  2529. for (let c of projectData.children) {
  2530. let tenderProject = tenderDetailMap[c.ID];
  2531. let feeRataDatas = tenderProject.FeeRate.datas;
  2532. Rates.push(new Rate(tenderProject, feeRataDatas, seriNo));
  2533. Practs.push(new Pract(tenderProject, seriNo));
  2534. EprjInfos.push(new EprjInfo(tenderProject));
  2535. seriNo++;
  2536. }
  2537. data.children.push(...Rates, ...Practs, ...EprjInfos);
  2538. return [{
  2539. data: data,
  2540. exportKind: exportKind,
  2541. fileName: projectData.name + INTERFACE_CONFIG[areaKey]["fileSuffix"][exportKind],
  2542. },];
  2543. }
  2544. // 山东需求,要有密文校验信息(SM3算法,在界面上已导入sm3对象)
  2545. /**
  2546. * SM3加密主函数
  2547. * @param msg
  2548. * @returns
  2549. */
  2550. function sm3Digest(msg) {
  2551. let hashHex = sm3(msg);
  2552. // return hashHex;
  2553. return hashHex.toUpperCase();
  2554. }
  2555. function _extractBillCalcRefs(currentBill) {
  2556. const rst = [];
  2557. function _extract(spliter, excluded = true, nextGap) {
  2558. let currentBillCalcBase = currentBill.calcBase;
  2559. let currentIdx = currentBillCalcBase.indexOf(spliter);
  2560. let exCnt = 0;
  2561. if (excluded) exCnt = spliter.length;
  2562. while (currentIdx >= 0) {
  2563. let bId = currentBillCalcBase.substr(currentIdx + excluded, nextGap);
  2564. if (!rst.includes(bId)) {
  2565. rst.push(bId);
  2566. }
  2567. currentBillCalcBase = currentBillCalcBase.substr(currentIdx + excluded + nextGap);
  2568. currentIdx = currentBillCalcBase.indexOf(spliter);
  2569. }
  2570. }
  2571. if (typeof currentBill.calcBase === 'string') {
  2572. //1. 抽取@引用
  2573. _extract('@', true, 36);
  2574. //2. 抽取特殊引用
  2575. // 2.1 {各章清单合计}
  2576. _extract('{各章清单合计}', false, '{各章清单合计}'.length);
  2577. // 2.2 {100章以外清单合计}
  2578. _extract('{100章以外清单合计}', false, '{100章以外清单合计}'.length);
  2579. }
  2580. return rst;
  2581. }
  2582. function _preCodeingForBills(tenderProject) {
  2583. const cacheObj = {};
  2584. function _chkAdhocChapterBill(bill) {
  2585. let rst = false;
  2586. if (typeof bill.name === 'string' && bill.name.includes('00章') && bill.name.includes('清单')) {
  2587. rst = true;
  2588. }
  2589. return rst;
  2590. }
  2591. function _setCache(bNode) {
  2592. cacheObj['_' + bNode.data.ID] = bNode.data;
  2593. if (bNode.children && bNode.children.length > 0) {
  2594. for (let subNode of bNode.children) {
  2595. _setCache(subNode);
  2596. }
  2597. }
  2598. }
  2599. let rootNodes = tenderProject.mainTree.roots;
  2600. for (let rootNode of rootNodes) {
  2601. _setCache(rootNode);
  2602. }
  2603. let cnt = 1;
  2604. let billsForAcc = [];
  2605. for (let bill of tenderProject.Bills.datas) {
  2606. //这一步设置特殊清单(各章清单合计, 100章~1200章)
  2607. cacheObj['_{100章以外清单合计}'] = {};
  2608. if (_billStrFilter(bill.name).includes('第100章至700章清单') || sectionNameMap[_billStrFilter(bill.name)] || _chkAdhocChapterBill(bill)) {
  2609. if (cacheObj['_' + bill.ID]) {
  2610. if (!cacheObj['_' + bill.ID].hasOwnProperty('formulaCode')) {
  2611. cacheObj['_' + bill.ID].formulaCode = `F${cnt}`;
  2612. cnt++;
  2613. }
  2614. }
  2615. // if (_billStrFilter(bill.name).includes('第100章至700章清单')) {
  2616. if (_billStrFilter(bill.name).includes('第100章至') && _billStrFilter(bill.name).includes('00章清单')) {
  2617. cacheObj['_{各章清单合计}'] = {};
  2618. cacheObj['_{各章清单合计}'].formulaCode = `{F${cnt - 1}}`;
  2619. } else if (!_billStrFilter(bill.name).includes('清单第100章')) {
  2620. billsForAcc.push(`F${cnt - 1}`);
  2621. }
  2622. }
  2623. }
  2624. let tmpStr = ''
  2625. for (let idx = 0; idx < billsForAcc.length; idx++) {
  2626. if (idx === 0) {
  2627. tmpStr = '( ' + `{${billsForAcc[idx]}}`;
  2628. } else {
  2629. tmpStr = tmpStr + ` + {${billsForAcc[idx]}}`;
  2630. }
  2631. if (idx === billsForAcc.length - 1) tmpStr = tmpStr + ' )';
  2632. }
  2633. cacheObj['_{100章以外清单合计}'].formulaCode = tmpStr;
  2634. for (let bill of tenderProject.Bills.datas) {
  2635. let billRefs = _extractBillCalcRefs(bill);
  2636. for (let refBillId of billRefs) {
  2637. if (cacheObj['_' + refBillId]) {
  2638. if (!cacheObj['_' + refBillId].hasOwnProperty('formulaCode')) {
  2639. cacheObj['_' + refBillId].formulaCode = `F${cnt}`;
  2640. cnt++;
  2641. }
  2642. }
  2643. }
  2644. }
  2645. return cacheObj;
  2646. }
  2647. function _getFormulaDispName(cacheForFormula, currentBill) {
  2648. let rst = currentBill.calcBase;
  2649. if (typeof currentBill.calcBase === 'string') {
  2650. //1. @引用
  2651. let currentBillCalcBase = currentBill.calcBase;
  2652. let currentIdx = currentBillCalcBase.indexOf('@');
  2653. let bIdArr = [], replaceArr = [];
  2654. while (currentIdx >= 0) {
  2655. let bId = currentBillCalcBase.substr(currentIdx + 1, 36);
  2656. bIdArr.push(bId);
  2657. if (cacheForFormula['_' + bId]) {
  2658. if (cacheForFormula['_' + bId].hasOwnProperty('formulaCode')) {
  2659. replaceArr.push(`{${cacheForFormula['_' + bId].formulaCode}}`);
  2660. } else {
  2661. replaceArr.push(`{无formulaCode错误:${bId}}`);
  2662. }
  2663. } else {
  2664. replaceArr.push(`{引用错误:${bId}}`);
  2665. }
  2666. currentBillCalcBase = currentBillCalcBase.substr(currentIdx + 37);
  2667. currentIdx = currentBillCalcBase.indexOf('@');
  2668. }
  2669. let tempBillCalcBase = currentBill.calcBase;
  2670. for (let idx = 0; idx < bIdArr.length; idx++) {
  2671. tempBillCalcBase = tempBillCalcBase.replace('@' + bIdArr[idx], replaceArr[idx]);
  2672. }
  2673. //2. 特殊引用
  2674. //{各章清单合计} {100章以外清单合计}
  2675. if (tempBillCalcBase.includes('{各章清单合计}')) {
  2676. console.log(`特殊引用清单{各章清单合计}:${currentBill.name}(${currentBill.code} - ${tempBillCalcBase})`);
  2677. tempBillCalcBase = tempBillCalcBase.replace('{各章清单合计}', cacheForFormula['_{各章清单合计}'].formulaCode);
  2678. }
  2679. if (tempBillCalcBase.includes('{100章以外清单合计}')) {
  2680. console.log(`特殊引用清单{100章以外清单合计}:${currentBill.name}(${currentBill.code} - ${tempBillCalcBase})`);
  2681. tempBillCalcBase = tempBillCalcBase.replace('{100章以外清单合计}', cacheForFormula['_{100章以外清单合计}'].formulaCode);
  2682. }
  2683. //
  2684. rst = tempBillCalcBase;
  2685. }
  2686. return rst;
  2687. }
  2688. return {
  2689. entry,
  2690. };
  2691. })();