guangdong_2018_export.js 124 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702
  1. /**
  2. *
  3. *
  4. * @author Zhong
  5. * @date 2019/6/24
  6. * @version
  7. */
  8. /*
  9. * 广东建设工程政府投资项目造价数据标准3.0
  10. * */
  11. const XMLStandard = (function () {
  12. // 广东18的导出文件中,需要把建设项目和单位工程文件分开
  13. // 数据类别,辨别提取的数据,哪份是以建设项目为根元素,哪份以单位工程为根元素
  14. const DATA_TYPE = {
  15. PROJECT: 1,
  16. TENDER: 2,
  17. };
  18. // 精度
  19. const Decimal = {
  20. // 工料机消耗量、含量、用量类小数精度
  21. GLJ: 4,
  22. // 工程量、数量类小数精度
  23. QUANTITY: 3,
  24. // 金额、合价、费用类小数精度
  25. FEE: 2,
  26. // 费率、指数、比例(%)类小数精度
  27. RATE: 3,
  28. };
  29. // 建设性质
  30. const ConstructionType = {
  31. '新建': '1',
  32. '扩建': '2',
  33. '改建': '3',
  34. '修缮': '4',
  35. '修复': '5',
  36. '维护保养': '6',
  37. '其他': '9',
  38. };
  39. // 造价类型
  40. const CostType = {
  41. '投资估算': '1',
  42. '设计概算': '2',
  43. '施工图预算': '3',
  44. '招标工程量清单': '4',
  45. '招标控制价(最高投标限价)': '5',
  46. '投标报价': '6',
  47. '签约合同价': '7',
  48. '竣工结算价': '8',
  49. };
  50. // 软件中的文件类型与造假类型映射
  51. const FileKind = {
  52. '1': '6', // 投标
  53. '2': '4', // 招标
  54. '3': '5', // 控制价
  55. };
  56. // 计价模式
  57. const ValuationModel = {
  58. BILL: '1', // 清单计价
  59. RATION: '2', // 定额计价
  60. };
  61. // 地区类别
  62. const AreaKind = {
  63. '一类地区': '1',
  64. '二类地区': '2',
  65. '三类地区': '3',
  66. '四类地区': '4',
  67. };
  68. // 专业类别
  69. const Specialty = {
  70. '房屋建筑与装饰工程': '1',
  71. '仿古建筑': '2',
  72. '通用安装工程': '3',
  73. '市政工程': '4',
  74. '园林绿化': '5',
  75. '矿山': '6',
  76. '构筑物': '7',
  77. '城市轨道交通工程': '8',
  78. '爆破': '9',
  79. '装饰装修': '10',
  80. '市政交通设施': '11',
  81. '市政养护': '12',
  82. '修缮': '13',
  83. '环卫': '14',
  84. '古建筑': '15',
  85. '节能': '16',
  86. '抗震加固': '17',
  87. '绿色建筑': '18',
  88. '工业建筑': '19',
  89. '地下管廊': '20',
  90. '装配式建筑': '21',
  91. '营造林': '22',
  92. '修复': '23',
  93. '其他': '99',
  94. };
  95. /* // 需要用固定类别关联的费用字典,用固定类别来映射
  96. // 数据节选自标准pdf文件《《建设工程政府投资项目造价数据标准》信息公开版》,附录C-费用名称与费用代号
  97. // 若映射表中没有映射关系,则费用字典取名称首字母
  98. const FlagFeeCodeMap = {
  99. // 分部分项工程
  100. [fixedFlag.SUB_ENGINERRING]: 'QDF',
  101. // 措施项目
  102. [fixedFlag.MEASURE]: 'CSF',
  103. // 其他项目
  104. [fixedFlag.OTHER]: 'QTF',
  105. // 措施项目的子项
  106. [fixedFlag.GREEN_MEASURE_FEE]: 'AQWMSGF', // 绿色施工安全防护措施费
  107. [fixedFlag.OTHER_MEASURE_FEE]: 'QTCSF', // 其他措施费
  108. // 其他项目的子项
  109. [fixedFlag.PROVISIONAL]: 'ZLF', // 暂列金额
  110. [fixedFlag.ESTIMATE]: 'ZGJ', // 暂估价
  111. [fixedFlag.MATERIAL_PROVISIONAL]: 'ZGC', // 材料(工程设备)暂估价
  112. [fixedFlag.ENGINEERING_ESITIMATE]: 'ZGGC', // 专业工程暂估价
  113. [fixedFlag.DAYWORK]: 'LXF', // 计日工
  114. [fixedFlag.TURN_KEY_CONTRACT]: 'ZCBFWF', // 总承包服务费
  115. [fixedFlag.BUDGET_INCLUDE_WORK_FEE]: 'YSBGF', // 预算包干费
  116. [fixedFlag.PROJECT_HIGH_QUALITY_FEE]: 'GCYZF', // 工程优质费
  117. [fixedFlag.BUDGET_ESTIMATE_DIFF]: 'GSFDC', // 概算幅度差
  118. [fixedFlag.CLAIM]: 'SPFY', // 索赔费用
  119. [fixedFlag.VISA]: 'XCQZFY', // 现场签证
  120. [fixedFlag.OTHER_FEE]: 'QTFY', // 其他费用
  121. // 税金
  122. [fixedFlag.TAX]: 'SJ',
  123. // 工程造价
  124. [fixedFlag.ENGINEERINGCOST]: 'ZZJ',
  125. }; */
  126. // 需要用计算基数关联的费用字典
  127. /* const FormulaFeeCodeMap = {
  128. '{分部分项工程费}': 'QDF',
  129. '{分部分项人工费}': 'QRG',
  130. '{分部分项材料费}': 'QCL',
  131. '{分部分项施工机具费}': 'QJX',
  132. '{分部分项主材费}': 'QZCF',
  133. '{分部分项设备费}': 'QSBF',
  134. '{分部分项人工工日}': 'FBFXRGGR', // 标准没有,自增
  135. '{建筑面积}': 'JZMZ', // 自增
  136. '{措施项目费}': 'CSF',
  137. '{其他项目费}': 'QTF',
  138. '{甲供人工费}': 'JGRGF', // 自增
  139. '{甲供材料费}': 'JGC',
  140. '{甲供施工机具费}': 'JGSGJJF', // 自增
  141. '{甲定人工费}': 'JDRGF', // 自增
  142. '{甲定材料费}': 'JDCLF', // 自增
  143. '{甲定施工机具费}': 'JDSGJJF', // 自增
  144. '{甲定主材费}': 'JDZCF', // 自增
  145. '{甲定设备费}': 'JDSBF', // 自增
  146. '{暂估材料费(从子目汇总)}': 'ZGCLFCZMHZ', // 自增
  147. '{税金}': 'SJ',
  148. }; */
  149. // 费用字典占用列表,普通清单根据首字母获取费用字典时,与下列占用费用字典重复时,需要加上_序号后缀
  150. const feeCodeList = [
  151. 'QDF', 'QRG', 'QCL', 'QJX', 'ZCSB', 'QZCF', 'QSBF', 'QGL', 'QLR', 'QZGJ', 'CSF', 'AQWMSGF', 'AXSJSCSXMF',
  152. 'QTCSF', 'LSSGCSF', 'SGYCWRFZF', 'YGSMGLF', 'DXJXSBJCCJAC', 'GGCSF', 'CSRG', 'CSCL', 'CSJX', 'CSZCSB',
  153. 'CSZCF', 'CSSBF', 'CSGL', 'CSLR', 'CSZGJ', 'QTF', 'ZGJ', 'ZGC', 'ZLF', 'ZGGC', 'ZCBFWF', 'LXF', 'CLBGF',
  154. 'YSBGF', 'SPFY', 'XCQZFY', 'DLF', 'QTFY', 'YLJ', 'GF', 'SJ', 'ZZJ', 'ZJF', 'RGF', 'JXRG', 'CLF', 'JXF',
  155. 'ZCF', 'SBF', 'ZZCSB', 'JC', 'RGJC', 'CLJC', 'JXJC', 'JGC', 'GLF', 'LR', 'DJ', 'HJ', 'YNZTYSYPFFY',
  156. 'JZYWSHBXF', 'GCFY', 'JZAZGCF', 'SBJGQJGZF', 'GCJSQTFY', 'YBF', 'CLGZF', 'JSQDKLX', 'PDLDZJ'
  157. ];
  158. // 计算程序名称-计算基数映射
  159. const CalculationQtyMap = {
  160. '直接费': 'RGF+CLF+JXF+ZCF+SBF+GLF',
  161. '人工费': 'RGF',
  162. '材料费': 'CLF',
  163. '施工机具费': 'JXF',
  164. '主材费': 'ZCF',
  165. '设备费': 'SBF',
  166. '管理费': 'GLF',
  167. '利润': 'LR',
  168. '综合单价': 'RGF+CLF+JXF+ZCF+SBF+GLF+LR',
  169. };
  170. // 计算程序名称-费用代号映射
  171. const CalculationCodeMap = {
  172. '直接费': 'DEZJF',
  173. '人工费': 'RGF',
  174. '材料费': 'CLF',
  175. '施工机具费': 'JXF',
  176. '主材费': 'ZCF',
  177. '设备费': 'SBF',
  178. '管理费': 'GLF',
  179. '利润': 'LR',
  180. '综合单价': 'DJ',
  181. }
  182. // 章节类型
  183. const ChapterKind = {
  184. '章': '1',
  185. '节': '2',
  186. '细目': '3',
  187. '其他': '4',
  188. };
  189. // 汇总类型
  190. const SummrayKind = {
  191. YES: '1', // 汇总
  192. NO: '2', // 不汇总
  193. };
  194. // 工程量计算累加与汇总类型映射
  195. const SummationKindMap = {
  196. '0': SummrayKind.NO,
  197. '1': SummrayKind.YES,
  198. }
  199. // 清单子目类型
  200. const BillsKind = {
  201. FBFX: '1', // 分部分项子目
  202. '模板及支架': '2',
  203. '脚手架': '3',
  204. '现场围挡': '4',
  205. '防尘降噪绿色施工防护': '5',
  206. MEASURE: '6', // 其他措施子目
  207. };
  208. // 取费类型
  209. const CalcKind = {
  210. '地上工程': '1',
  211. '地下明(盖)挖工程': '2',
  212. '地下暗挖工程': '3',
  213. '盾构工程': '4',
  214. '轨道工程': '5',
  215. '通信工程': '6',
  216. '信号工程': '7',
  217. '供电工程': '8',
  218. '智能与控制系统工程': '9',
  219. '机电工程': '10',
  220. '其他': '15',
  221. };
  222. // 费用归属
  223. const CostKind = {
  224. '建筑工程费': '1',
  225. '安装工程费': '2',
  226. '其他': '3',
  227. };
  228. // 计算方式
  229. const CalcType = {
  230. 'quantityMulTotalUnitPrice': '1', // 工程量×综合单价
  231. 'formulaAddFeeRate': '2', // 计算基数×费率
  232. 'quantityMulUnitPrice': '3', // 工程量×单价
  233. };
  234. // 降效类型 建筑装饰工程定额超高降效费用计算标记
  235. const EfficiencyKind = {
  236. BASE_REDUCTION: '1', // 降效基础定额
  237. NOT_BASE_REDUCTION: '2', // 非降效定额
  238. MARKET_PRICE_REDUCTION: '3', // 按市场价计算降效费用定额
  239. RATION_PRICE_REDUCTION: '4', // 按定额价计算降效费用定额
  240. };
  241. // 子目增加费类型 安装工程定额子目增加费的费用计算标记
  242. const IncFeeKind = {
  243. SUB_BASE: '1', // 子目增加费基础定额
  244. NOT_SUB_BASE: '2', // 非子目增加费定额
  245. SUB_CALC: '3', // 子目增加费用计算定额
  246. };
  247. // 工料机类型
  248. const GLJKind = {
  249. };
  250. // 供料方式
  251. const Provider = {
  252. [commonConstants.supplyType.ZXCG]: '1',
  253. [commonConstants.supplyType.BFJG]: '2',
  254. [commonConstants.supplyType.WQJG]: '3',
  255. }
  256. // 通用设置和工具
  257. const _base = XML_EXPORT_BASE;
  258. const _config = _base.CONFIG;
  259. const _type = _config.TYPE;
  260. const _util = _base.UTIL;
  261. const _cache = _base.CACHE;
  262. // 项目汇总字段
  263. const summaryObj = {
  264. // 取固定清单的综合合价进行汇总
  265. feeFields: [
  266. { k: fixedFlag.ENGINEERINGCOST, v: 'engineeringCost' },
  267. { k: fixedFlag.SUB_ENGINERRING, v: 'subEngineering' },
  268. { k: fixedFlag.MEASURE, v: 'measure' },
  269. { k: fixedFlag.GREEN_MEASURE_FEE, v: 'greenMeasureFee' },
  270. { k: fixedFlag.OTHER_MEASURE_FEE, v: 'otherPreliminaries' },
  271. { k: fixedFlag.OTHER, v: 'other' },
  272. { k: fixedFlag.PROVISIONAL, v: 'provisional' },
  273. { k: fixedFlag.MATERIAL_PROVISIONAL, v: 'materialProvisional' },
  274. { k: fixedFlag.ENGINEERING_ESITIMATE, v: 'engineeringEstimate' },
  275. { k: fixedFlag.DAYWORK, v: 'daywork' },
  276. { k: fixedFlag.TURN_KEY_CONTRACT, v: 'turnKeyContract' },
  277. { k: fixedFlag.CLAIM, v: 'claim' },
  278. { k: fixedFlag.VISA, v: 'visa' },
  279. { k: fixedFlag.TAX, v: 'tax' }
  280. ],
  281. // 取工程造价的一些费用进行汇总,k为汇总到summaryInfo的字段,v为取的工程造价费用字段
  282. engineeringCostFields: [
  283. { k: 'labour', v: 'labour' },
  284. { k: 'material', v: 'material' },
  285. { k: 'equipment', v: 'equipment' },
  286. { k: 'mainMaterial', v: 'mainMaterial' },
  287. { k: 'machine', v: 'machine' },
  288. { k: 'overhead', v: 'manage' },
  289. { k: 'profit', v: 'profit' },
  290. ]
  291. };
  292. // 获取工程类型:枚举单位工程的工程专业+费用标准,用“;”分隔
  293. function getProjectType(projectData, enumerable) {
  294. // 工程类型 工程专业+费用标准
  295. if (!enumerable) {
  296. const engineeringName = projectData.property.engineeringName.replace('工程', '');
  297. const feeStandardName = projectData.property.feeStandardName;
  298. return `${engineeringName}${feeStandardName}`;
  299. }
  300. return projectData.children.reduce((acc, eng) => {
  301. const tenderProjectTypeArr = eng.children.reduce((acc, tender) => {
  302. const engineeringName = tender.property.engineeringName.replace('工程', '');
  303. const feeStandardName = tender.property.feeStandardName;
  304. acc.push(`${engineeringName}${feeStandardName}`);
  305. return acc;
  306. }, []);
  307. acc.push(...tenderProjectTypeArr);
  308. return acc;
  309. }, []).join(';');
  310. }
  311. // 清单名称首字母包含的清单ID eg: 'AABC': ['ID1', 'ID2']
  312. const firstLetterMap = {};
  313. // 对已被占用的费用字典进行占位处理
  314. feeCodeList.forEach(feeCode => firstLetterMap[feeCode] = [null]);
  315. /**
  316. * 获取费用字典
  317. * @param {Object} bills - 清单数据,清单获取费用字典时用
  318. * @param {String} formula - 文本内容,非ID引用基数获取费用字典时用 eg: {分部分项工程费}
  319. * @return {String}
  320. */
  321. function getFeeCode(bills, formula) {
  322. let feeCode;
  323. // 清单获取费用字典,如果根据固定类别找不到对应的费用字典,才用名称首字母获取
  324. if (bills) {
  325. const flag = bills.flagsIndex && bills.flagsIndex.fixed ? bills.flagsIndex.fixed.flag : null;
  326. feeCode = FlagFeeCodeMap[flag];
  327. if (feeCode) {
  328. return feeCode;
  329. }
  330. const name = bills.name || '';
  331. // 出现重名,应以“费用代号_顺序号”规则,顺序号为自然数,从 1 开始(整个建设项目)
  332. const tempFeeCode = pinyinUtil.getFirstLetter(name);
  333. const sameFeeCodes = firstLetterMap[tempFeeCode] ? firstLetterMap[tempFeeCode] : firstLetterMap[tempFeeCode] = [];
  334. feeCode = sameFeeCodes.includes(bills.ID)
  335. ? `${tempFeeCode}${sameFeeCodes.indexOf(bills.ID) === 0 ? '' : '_' + sameFeeCodes.indexOf(bills.ID)}`
  336. : sameFeeCodes.length
  337. ? `${tempFeeCode}_${sameFeeCodes.length}`
  338. : tempFeeCode;
  339. if (!sameFeeCodes.includes(bills.ID)) {
  340. sameFeeCodes.push(bills.ID);
  341. }
  342. return feeCode;
  343. } else { // 非ID引用基数获取费用字典
  344. return FormulaFeeCodeMap[formula] || '';
  345. }
  346. }
  347. // 获取转换后的计算基数
  348. // 1.有子项,则取固定清单对应基数
  349. // 2.无子项,有基数,转换为费用字典
  350. function getQtyFormula(node) {
  351. let expr = node.data.calcBase || '';
  352. if (node.children.length) {
  353. return FlagFeeCodeMap[node.getFlag()] || '';
  354. }
  355. if (expr) {
  356. const normalBase = _util.getNormalBase(expr);
  357. const idBase = _util.getIDBase(expr);
  358. //普通基数转费用字典
  359. normalBase.forEach(base => {
  360. const feeCode = getFeeCode(null, base);
  361. if (/[\(\)]/.test(base)) {
  362. // 将()进行处理不然会被当成组
  363. base = base.replace(/[\(\)]/g, function(matched) {
  364. return matched === '(' ? '\\(' : '\\)'
  365. });
  366. }
  367. expr = expr.replace(new RegExp(base, 'g'), feeCode);
  368. });
  369. //id引用转换为费用字典
  370. idBase.forEach(base => {
  371. const id = base.match(/[^@]+/)[0];
  372. const theNode = node.tree.getNodeByID(id);
  373. const feeCode = getFeeCode(theNode.data);
  374. expr = expr.replace(new RegExp(base, 'g'), feeCode);
  375. });
  376. return expr;
  377. }
  378. }
  379. // 获取计算计算说明
  380. function getCalBasis(node) {
  381. let expr = node.data.calcBase || '';
  382. expr = expr.replace(new RegExp('{', 'g'), '');
  383. expr = expr.replace(new RegExp('}', 'g'), '');
  384. return expr;
  385. }
  386. // 获取定额册 取定额编号开头字母后面、-前面的数字,没有则取0
  387. // 如: A2-1-1 则册为2
  388. function getVolume(code) {
  389. if (!code) {
  390. return '0';
  391. }
  392. const reg = /^[A-Za-z](\d+)(?=-)/;
  393. const rst = reg.exec(code);
  394. return rst ? rst[1] : '0';
  395. }
  396. // 获取定额章 取定额编号第一个-和第二个-之间的数字
  397. // 如: A1-2-3 则章为2
  398. function getChapter(code) {
  399. if (!code) {
  400. return '0';
  401. }
  402. const reg = /^[A-Za-z]\d+-(\d+)(?=-)/;
  403. const rst = reg.exec(code);
  404. return rst ? rst[1] : '0';
  405. }
  406. // 获取人材机类型
  407. function getGLJKind(type) {
  408. // 标准中的定义: 1=人工;2=材料;3=机械;4=主材;5=设备;6=配合比(砂浆、混凝土);7=机械(具)台班;8=定额材料;15=其他。
  409. // 处理人材机类型:2=除了配合比、砂浆、混凝土的材料; 3=除了机械台班的机械
  410. type = +type;
  411. switch (type) {
  412. case 202:
  413. case 203:
  414. case 204:
  415. return '6'; // 配合比、砂浆、混凝土
  416. case 301:
  417. return '7'; // 机械台班
  418. case 6:
  419. case 7:
  420. case 8:
  421. return '15'; // 管理费、利润、一般风险费
  422. }
  423. const rootTypeReg = /\d/;
  424. const rootType = rootTypeReg.exec(type)[0];
  425. return ['1', '2', '3', '4', '5', '6'].includes(rootType) ? rootType : '15';
  426. }
  427. /*
  428. * 提取数据入口
  429. * @param {String}userID 用户ID
  430. * {Number}exportKind 导出类型(投标1、招标2、控制价3)
  431. * {Object}projectData 项目数据(项目自身的数据、建设、单项、单位的数据(projects表的数据),不包含详细的清单定额等数据)
  432. * @return {Array} [{data: Object, exportKind: Number, fileName: String}]
  433. * */
  434. async function entry(userID, exportKind, projectData) {
  435. // name为导出的xml节点属性名称 dName为可能需要显示给用户属性时使用的名称,比如自检提示的时候用,这里只有required为true时需要设置dNam
  436. // 错误列表
  437. const _failList = _cache.getItem('failList');
  438. // 建设项目
  439. function ConstructionProject(projectData, summaryInfo) {
  440. const basicInformation = projectData.property.basicInformation;
  441. const attrs = [
  442. // 项目编号
  443. {
  444. name: 'Number', dName: '项目编号', required: true,
  445. value: _util.getValueByKey(basicInformation, 'projNum')
  446. },
  447. // 项目名称
  448. {
  449. name: 'Name', dName: '项目名称', required: true,
  450. value: projectData.name
  451. },
  452. // 工程类别
  453. {
  454. name: 'ProjectCategory', dName: '工程类别', required: true,
  455. value: _util.getValueByKey(basicInformation, 'projectCategory')
  456. },
  457. // 工程类型
  458. {
  459. name: 'ProjectType', dName: '工程类型', required: true,
  460. value: getProjectType(projectData, true)
  461. },
  462. // 建设性质
  463. {
  464. name: 'ConstructionType', type: _type.INT, enumeration: Object.values(ConstructionType), enumerationHint: Object.keys(ConstructionType),
  465. value: ConstructionType[_util.getValueByKey(basicInformation, 'constructionType')]
  466. },
  467. // 文件类型
  468. {
  469. name: 'FileKind', dName: '文件类型', type: _type.INT, required: true,
  470. value: FileKind[exportKind]
  471. },
  472. // 计价模式
  473. {
  474. name: 'ValuationModel', dName: '计价模式', type: _type.INT, required: true,
  475. value: ValuationModel.BILL
  476. },
  477. // 计税模式
  478. {
  479. name: 'TaxModel', dName: '计税模式', type: _type.INT, required: true,
  480. value: projectData.property.taxType
  481. },
  482. // 地区类别
  483. {
  484. name: 'AreaKind', dName: '地区类别', type: _type.INT, required: true, enumeration: Object.values(AreaKind), enumerationHint: Object.keys(AreaKind),
  485. value: AreaKind[_util.getValueByKey(basicInformation, 'regionalCategories')]
  486. },
  487. // 工程地点
  488. {
  489. name: 'ProjectSite',
  490. value: _util.getValueByKey(basicInformation, 'projLocation')
  491. },
  492. // 建设单位
  493. {
  494. name: 'BulidUnit', dName: '建设单位', required: true,
  495. value: _util.getValueByKey(basicInformation, 'constructingUnits')
  496. },
  497. // 建设单位法定代表人或其授权人
  498. {
  499. name: 'BulidAuthorizer',
  500. value: _util.getValueByKey(basicInformation, 'constructingUnitsPerson')
  501. },
  502. // 数据交换标准名称
  503. {
  504. name: 'StandardName', required: true,
  505. value: '建设工程政府投资项目造价数据标准'
  506. },
  507. // 数据交换标准编号
  508. {
  509. name: 'StandardNumber', required: true,
  510. value: 'DBJ/T XX-XX-2018'
  511. },
  512. // 建设(编制)范围
  513. {
  514. name: 'RangeOfCompilation',
  515. value: _util.getValueByKey(basicInformation, 'rangeOfCompilation')
  516. },
  517. // 建设规模
  518. {
  519. name: 'Scale', dName: '工程规模', type: _type.DECIMAL, required: true,
  520. value: _util.getValueByKey(basicInformation, 'scale')
  521. },
  522. // 建设规模单位
  523. {
  524. name: 'Unit', dName: '建设规模单位', required: true,
  525. value: _util.getValueByKey(basicInformation, 'unit')
  526. },
  527. // 技术经济指标(元) 取单方造价
  528. {
  529. name: 'TechnicalAndEconomicIndex', type: _type.DECIMAL,
  530. value: summaryInfo.perCost
  531. },
  532. // 总说明 编制说明
  533. {
  534. name: 'Explains',
  535. value: projectData.property.compilationIllustrationProject
  536. }
  537. ];
  538. //唯一约束
  539. this.constraints = {
  540. billsCode: [], //清单项目项目编码(xsd中没体现,通过跟pm沟通得知)
  541. };
  542. _base.Element.call(this, 'ConstructionProject', attrs, '建设项目');
  543. }
  544. // 系统信息
  545. function SystemInfo({ ID1, ID2, makeDate }) {
  546. const attrs = [
  547. // 编制软件信息
  548. { name: 'ID1', value: ID1 },
  549. // 编制机器硬件信息,不输出
  550. { name: 'ID2', value: ID2 },
  551. // 文件生成时间
  552. { name: 'MakeDate', dName: '文件生成时间', type: _type.DATE_TIME, required: true, value: makeDate }
  553. ];
  554. _base.Element.call(this, 'SystemInfo', attrs, '系统信息');
  555. }
  556. // 工程信息
  557. function ConstructionInfo() {
  558. _base.Element.call(this, 'ConstructionInfo', []);
  559. }
  560. // 费用精度
  561. function Option() {
  562. const attrs = [
  563. // 工料机消耗量、含量、用量类小数精度
  564. { name: 'ResPrecision', type: _type.INT, required: true, value: Decimal.GLJ },
  565. // 工程量、数量类小数精度
  566. { name: 'QuantityPrecision', type: _type.INT, required: true, value: Decimal.QUANTITY },
  567. // 金额、合价、费用类小数精度
  568. { name: 'CostPrecision', type: _type.INT, required: true, value: Decimal.FEE },
  569. // 费率、指数、比例(%)类小数精度
  570. { name: 'RatePrecision', type: _type.INT, required: true, value: Decimal.RATE }
  571. ];
  572. _base.Element.call(this, 'Option', attrs, '费用精度');
  573. }
  574. // 估(概、预、结)算信息
  575. // 有内容的属性才输出
  576. function ProjectInfo(basicInformation, summaryInfo) {
  577. const attrs = [
  578. // 设计单位
  579. { name: 'Designer', mustHasValue: true, value: _util.getValueByKey(basicInformation, 'designUnits') },
  580. // 承包单位
  581. { name: 'Contractor', mustHasValue: true, value: _util.getValueByKey(basicInformation, 'constructionUnits') },
  582. // 编制单位
  583. {
  584. name: 'CompileCompany', dName: '编制单位', required: true,
  585. value: _util.getValueByKey(basicInformation, 'establishUnit') || '无'
  586. },
  587. // 编制时间,投标文件取bidCompileDate。招标、控制价文件取tenderCompileDate
  588. {
  589. name: 'CompileDate', dName: '编制时间', required: true,
  590. value: exportKind === _config.EXPORT_KIND.Tender
  591. ? _util.getValueByKey(basicInformation, 'bidCompileDate')
  592. : _util.getValueByKey(basicInformation, 'tenderCompileDate')
  593. },
  594. // 编制单位法定代表人或其授权人
  595. { name: 'Authorizer', mustHasValue: true, value: _util.getValueByKey(basicInformation, 'authorizer') },
  596. // 工程总价(元)
  597. {
  598. name: 'Total', dName: '工程总价', type: _type.DECIMAL, required: true,
  599. value: summaryInfo.engineeringCost
  600. }
  601. ];
  602. _base.Element.call(this, 'ProjectInfo', attrs, '建设项目基本信息');
  603. }
  604. // 招标信息 工程量清单、招标控制价时输出
  605. // 有内容的属性才输出
  606. function TendereeInfo(basicInformation, summaryInfo) {
  607. const attrs = [
  608. // 招标人
  609. {
  610. name: 'TendereeName', dName: '招标人', required: true,
  611. value: _util.getValueByKey(basicInformation, 'tendereeName')
  612. },
  613. // 招标单位法定代表人或其授权人
  614. {
  615. name: 'TenderAuthorizer', mustHasValue: true,
  616. value: _util.getValueByKey(basicInformation, 'tenderAuthorizer')
  617. },
  618. // 招标单位编制人
  619. {
  620. name: 'TenderCompiler', mustHasValue: true,
  621. value: _util.getValueByKey(basicInformation, 'tenderCompiler')
  622. },
  623. // 招标单位编制人资格证书编号
  624. {
  625. name: 'TenderCompilerCertNo', mustHasValue: true,
  626. value: _util.getValueByKey(basicInformation, 'tenderCompilerCertNo')
  627. },
  628. // 招标单位编制时间
  629. {
  630. name: 'TenderCompileDate', mustHasValue: true,
  631. value: _util.getValueByKey(basicInformation, 'tenderCompileDate')
  632. },
  633. // 招标单位审核人
  634. {
  635. name: 'TenderExaminer', mustHasValue: true,
  636. value: _util.getValueByKey(basicInformation, 'tenderExaminer')
  637. },
  638. // 招标单位审核人资格证书编号
  639. {
  640. name: 'TenderExaminerCertNo', mustHasValue: true,
  641. value: _util.getValueByKey(basicInformation, 'tenderExaminerCertNo')
  642. },
  643. // 招标单位审核时间
  644. {
  645. name: 'TenderExamineDate', mustHasValue: true,
  646. value: _util.getValueByKey(basicInformation, 'tenderExamineDate')
  647. },
  648. // 招标单位审定人
  649. {
  650. name: 'TenderApprover', mustHasValue: true,
  651. value: _util.getValueByKey(basicInformation, 'tenderApprover')
  652. },
  653. // 招标单位审定人资格证书编号
  654. {
  655. name: 'TenderApproverCertNo', mustHasValue: true,
  656. value: _util.getValueByKey(basicInformation, 'tenderApproverCertNo')
  657. },
  658. // 招标单位审定时间
  659. {
  660. name: 'TenderApproveDate', mustHasValue: true,
  661. value: _util.getValueByKey(basicInformation, 'tenderApproveDate')
  662. },
  663. // 招标代理 不得为空,如无招标代理,则应填写“无”。
  664. {
  665. name: 'Proxy', dName: '招标代理',
  666. value: _util.getValueByKey(basicInformation, 'proxy') || '无', required: true
  667. },
  668. // 招标代理资质证书编号
  669. {
  670. name: 'ProxyCertNo', mustHasValue: true,
  671. value: _util.getValueByKey(basicInformation, 'proxyCertNo')
  672. },
  673. // 招标代理法定代表人或其授权人
  674. {
  675. name: 'ProxyAuthorizer', mustHasValue: true,
  676. value: _util.getValueByKey(basicInformation, 'proxyAuthorizer')
  677. },
  678. // 招标代理编制人员
  679. {
  680. name: 'ProxyCompiler', mustHasValue: true,
  681. value: _util.getValueByKey(basicInformation, 'proxyCompiler')
  682. },
  683. // 招标代理编制人员资格证书编号
  684. {
  685. name: 'ProxyCompilerCertNo', mustHasValue: true,
  686. value: _util.getValueByKey(basicInformation, 'proxyCompilerCertNo')
  687. },
  688. // 招标代理编制时间
  689. {
  690. name: 'ProxyCompileDate', mustHasValue: true,
  691. value: _util.getValueByKey(basicInformation, 'proxyCompileDate')
  692. },
  693. // 招标代理审核人
  694. {
  695. name: 'ProxyExaminer', mustHasValue: true,
  696. value: _util.getValueByKey(basicInformation, 'proxyExaminer')
  697. },
  698. // 招标代理审核人资格证书编号
  699. {
  700. name: 'ProxyExaminerCertNo', mustHasValue: true,
  701. value: _util.getValueByKey(basicInformation, 'proxyExaminerCertNo')
  702. },
  703. // 招标代理审核时间
  704. {
  705. name: 'ProxyExamineDate', mustHasValue: true,
  706. value: _util.getValueByKey(basicInformation, 'proxyExamineDate')
  707. },
  708. // 招标代理审定人
  709. {
  710. name: 'ProxyApprover', mustHasValue: true,
  711. value: _util.getValueByKey(basicInformation, 'proxyApprover')
  712. },
  713. // 招标代理审定人资格证书编号
  714. {
  715. name: 'ProxyApproverCertNo', mustHasValue: true,
  716. value: _util.getValueByKey(basicInformation, 'proxyApproverCertNo')
  717. },
  718. // 招标代理审定时间
  719. {
  720. name: 'ProxyApproveDate', mustHasValue: true,
  721. value: _util.getValueByKey(basicInformation, 'proxyApproveDate')
  722. },
  723. // 造价咨询 、Consultant(造价咨询):不得为空,如无则应填写“无”。
  724. {
  725. name: 'Consultant', dName: '造价咨询', required: true,
  726. value: _util.getValueByKey(basicInformation, 'consultant') || '无'
  727. },
  728. // 造价咨询资质证书编号
  729. {
  730. name: 'ConsultantCertNo', mustHasValue: true,
  731. value: _util.getValueByKey(basicInformation, 'consultantCertNo')
  732. },
  733. // 造价咨询法定代表人或其授权人
  734. {
  735. name: 'ConsultantAuthorizer', mustHasValue: true,
  736. value: _util.getValueByKey(basicInformation, 'consultantAuthorizer')
  737. },
  738. // 造价咨询编制人
  739. {
  740. name: 'ConsultantCompiler', mustHasValue: true,
  741. value: _util.getValueByKey(basicInformation, 'consultantCompiler')
  742. },
  743. // 造价咨询编制人资格证书
  744. {
  745. name: 'ConsultantCompilerCertNo', mustHasValue: true,
  746. value: _util.getValueByKey(basicInformation, 'consultantCompilerCertNo')
  747. },
  748. // 造价咨询编制时间
  749. {
  750. name: 'ConsultantCompileDate', mustHasValue: true,
  751. value: _util.getValueByKey(basicInformation, 'consultantCompileDate')
  752. },
  753. // 造价咨询审核人
  754. {
  755. name: 'ConsultantExaminer', mustHasValue: true,
  756. value: _util.getValueByKey(basicInformation, 'consultantExaminer')
  757. },
  758. // 造价咨询审核人资格证书编号
  759. {
  760. name: 'ConsultantExaminerCertNo', mustHasValue: true,
  761. value: _util.getValueByKey(basicInformation, 'consultantExaminerCertNo')
  762. },
  763. // 造价咨询审核时间
  764. {
  765. name: 'ConsultantExamineDate', mustHasValue: true,
  766. value: _util.getValueByKey(basicInformation, 'consultantExamineDate')
  767. },
  768. // 造价咨询审定人
  769. {
  770. name: 'ConsultantApprover', mustHasValue: true,
  771. value: _util.getValueByKey(basicInformation, 'consultantApprover')
  772. },
  773. // 造价咨询审定人资格证书编号
  774. {
  775. name: 'ConsultantApproverCertNo', mustHasValue: true,
  776. value: _util.getValueByKey(basicInformation, 'consultantApproverCertNo')
  777. },
  778. // 造价咨询审定时间
  779. {
  780. name: 'ConsultantApproveDate', mustHasValue: true,
  781. value: _util.getValueByKey(basicInformation, 'consultantApproveDate')
  782. },
  783. // 招标控制价(元)
  784. {
  785. name: 'TenderSumLimit', dName: '招标控制价', type: _type.DECIMAL, required: true,
  786. value: summaryInfo.engineeringCost
  787. }
  788. ];
  789. _base.Element.call(this, 'TendereeInfo', attrs, '招标信息');
  790. }
  791. // 投标信息
  792. function BidderInfo(basicInformation, summaryInfo) {
  793. const attrs = [
  794. // 投标人
  795. {
  796. name: 'BidName', dName: '投标人', required: true,
  797. value: _util.getValueByKey(basicInformation, 'bidName') || '无'
  798. },
  799. // 投标单位法定代表人或其授权人
  800. {
  801. name: 'BidAuthorizer', mustHasValue: true,
  802. value: _util.getValueByKey(basicInformation, 'bidAuthorizer')
  803. },
  804. // 投标总价(元)
  805. {
  806. name: 'BidTotal', dName: '投标总价', type: _type.DECIMAL, required: true,
  807. value: summaryInfo.engineeringCost
  808. },
  809. // 投标单位编制人
  810. {
  811. name: 'BidCompiler', mustHasValue: true,
  812. value: _util.getValueByKey(basicInformation, 'bidCompiler')
  813. },
  814. // 投标单位编制人资格证书编号
  815. {
  816. name: 'BidCompilerCertNo', mustHasValue: true,
  817. value: _util.getValueByKey(basicInformation, 'bidCompilerCertNo')
  818. },
  819. // 投标单位编制时间
  820. {
  821. name: 'BidCompileDate', mustHasValue: true,
  822. value: _util.getValueByKey(basicInformation, 'bidCompileDate')
  823. },
  824. // 投标单位审核人
  825. {
  826. name: 'BidExaminer', mustHasValue: true,
  827. value: _util.getValueByKey(basicInformation, 'bidExaminer')
  828. },
  829. // 投标单位审核人资格证书编号
  830. {
  831. name: 'BidExaminerCertNo', mustHasValue: true,
  832. value: _util.getValueByKey(basicInformation, 'bidExaminerCertNo')
  833. },
  834. // 投标单位审核时间
  835. {
  836. name: 'BidExamineDate', mustHasValue: true,
  837. value: _util.getValueByKey(basicInformation, 'bidExamineDate')
  838. },
  839. // 投标单位审定人
  840. {
  841. name: 'BidApprover', mustHasValue: true,
  842. value: _util.getValueByKey(basicInformation, 'bidApprover')
  843. },
  844. // 投标单位审定人资格证书
  845. {
  846. name: 'BidApproverCertNo', mustHasValue: true,
  847. value: _util.getValueByKey(basicInformation, 'bidApproverCertNo')
  848. },
  849. // 投标单位审定时间
  850. {
  851. name: 'BidApproveDate', mustHasValue: true,
  852. value: _util.getValueByKey(basicInformation, 'bidApproveDate')
  853. }
  854. ];
  855. _base.Element.call(this, 'BidderInfo', attrs, '投标信息');
  856. }
  857. // 费用汇总
  858. function SummaryOfCost(summaryInfo) {
  859. const attrs = [
  860. // 工程造价(元)
  861. {
  862. name: 'Total', type: _type.DECIMAL,
  863. value: summaryInfo.engineeringCost
  864. },
  865. // 分部分项工程费
  866. {
  867. name: 'DivisionalAndElementalWorks', type: _type.DECIMAL,
  868. value: summaryInfo.subEngineering
  869. },
  870. // 措施项目费
  871. {
  872. name: 'Preliminaries', type: _type.DECIMAL,
  873. value: summaryInfo.measure
  874. },
  875. // 绿色施工安全防护措施费
  876. {
  877. name: 'CostForHSE', type: _type.DECIMAL,
  878. value: summaryInfo.greenMeasureFee
  879. },
  880. // 其他措施费
  881. {
  882. name: 'OtherPreliminaries', type: _type.DECIMAL,
  883. value: summaryInfo.otherPreliminaries
  884. },
  885. // 其他项目费
  886. {
  887. name: 'SundryCosts', type: _type.DECIMAL,
  888. value: summaryInfo.other
  889. },
  890. // 暂列金额
  891. {
  892. name: 'ProvisionalSums', type: _type.DECIMAL,
  893. value: summaryInfo.provisional
  894. },
  895. // 暂估价材料
  896. {
  897. name: 'ProvisionalMaterial', type: _type.DECIMAL,
  898. value: summaryInfo.materialProvisional
  899. },
  900. // 专业工程暂估价
  901. {
  902. name: 'SpecialtyProvisionalPrice', type: _type.DECIMAL,
  903. value: summaryInfo.engineeringEstimate
  904. },
  905. // 计日工费用
  906. {
  907. name: 'DayWorkRate', type: _type.DECIMAL,
  908. value: summaryInfo.daywork
  909. },
  910. // 总承包服务费
  911. {
  912. name: 'MainContractorAttendance', type: _type.DECIMAL,
  913. value: summaryInfo.turnKeyContract
  914. },
  915. // 索赔费用
  916. {
  917. name: 'ClaimForLossAndExpenses', type: _type.DECIMAL,
  918. value: summaryInfo.claim
  919. },
  920. // 现场签证费用
  921. {
  922. name: 'SiteInstruction', type: _type.DECIMAL,
  923. value: summaryInfo.visa
  924. },
  925. // 规费
  926. {
  927. name: 'StatutoryFees', type: _type.DECIMAL,
  928. value: '0'
  929. },
  930. // 税金
  931. {
  932. name: 'Tax', type: _type.DECIMAL,
  933. value: summaryInfo.tax
  934. },
  935. // 人工费
  936. {
  937. name: 'Labor', type: _type.DECIMAL,
  938. value: summaryInfo.labour
  939. },
  940. // 材料费
  941. {
  942. name: 'Material', type: _type.DECIMAL,
  943. value: summaryInfo.material
  944. },
  945. // 设备费
  946. {
  947. name: 'Equipment', type: _type.DECIMAL,
  948. value: summaryInfo.equipment
  949. },
  950. // 主材设备费
  951. {
  952. name: 'MainMaterialEquipment', type: _type.DECIMAL,
  953. value: scMathUtil.roundForObj(summaryInfo.mainMaterial + summaryInfo.equipment, Decimal.FEE)
  954. },
  955. // 主材费
  956. {
  957. name: 'MainMaterial', type: _type.DECIMAL,
  958. value: summaryInfo.mainMaterial
  959. },
  960. // 机械费
  961. {
  962. name: 'Machine', type: _type.DECIMAL,
  963. value: summaryInfo.machine
  964. },
  965. // 管理费
  966. {
  967. name: 'Overhead', type: _type.DECIMAL,
  968. value: summaryInfo.overhead
  969. },
  970. // 利润
  971. {
  972. name: 'Profit', type: _type.DECIMAL,
  973. value: summaryInfo.profit
  974. },
  975. ];
  976. _base.Element.call(this, 'SummaryOfCost', attrs, '费用汇总');
  977. }
  978. // 建筑安装工程费
  979. function ProjectInstallationWorkCost(projectData, summaryInfo) {
  980. const basicInformation = projectData.property.basicInformation;
  981. const attrs = [
  982. // 工程编号
  983. {
  984. name: 'Number',
  985. value: _util.getValueByKey(basicInformation, 'projNum')
  986. },
  987. // 工程名称
  988. {
  989. name: 'Name', dName: '工程名称', required: true,
  990. value: projectData.name
  991. },
  992. // 金额 (元)
  993. {
  994. name: 'Total', type: _type.DECIMAL,
  995. value: summaryInfo.engineeringCost
  996. },
  997. // 建设规模
  998. {
  999. name: 'Scale', dName: '建设规模', type: _type.DECIMAL, required: true,
  1000. value: _util.getValueByKey(basicInformation, 'scale')
  1001. },
  1002. // 建设规模单位
  1003. {
  1004. name: 'Unit', dName: '建设规模单位', required: true,
  1005. value: _util.getValueByKey(basicInformation, 'unit')
  1006. },
  1007. // 占总投资比例(%)
  1008. {
  1009. name: 'Ratios', type: _type.DECIMAL,
  1010. value: '0.00'
  1011. },
  1012. ];
  1013. _base.Element.call(this, 'ProjectInstallationWorkCost', attrs, '建筑安装工程费');
  1014. }
  1015. // 单项工程
  1016. function SectionalWorks({ name, total, rate }) {
  1017. const attrs = [
  1018. // 工程编号
  1019. {
  1020. name: 'Number',
  1021. value: ''
  1022. },
  1023. // 工程名称
  1024. {
  1025. name: 'Name', dName: '工程名称', required: true,
  1026. value: name
  1027. },
  1028. // 金额
  1029. {
  1030. name: 'Total', type: _type.DECIMAL,
  1031. value: total
  1032. },
  1033. // 建设规模 单项工程没有填写的地方,输出“0”
  1034. {
  1035. name: 'Scale', dName: '建设规模', type: _type.DECIMAL, required: true,
  1036. value: '0'
  1037. },
  1038. // 建设规模单位 单项工程没有填写的地方,输出和"m2"
  1039. {
  1040. name: 'Unit', dName: '建设规模单位', required: true,
  1041. value: 'm2'
  1042. },
  1043. // 占总投资比例(%)
  1044. {
  1045. name: 'Ratios', type: _type.DECIMAL,
  1046. value: rate
  1047. },
  1048. // 费用代号
  1049. {
  1050. name: 'Code', type: _type.DECIMAL,
  1051. value: ''
  1052. },
  1053. ];
  1054. _base.Element.call(this, 'SectionalWorks', attrs, '单项工程');
  1055. }
  1056. // 单位工程
  1057. function UnitWorks(projectData, tenderData, defaultRationLibName, summaryInfo) {
  1058. const basicInformation = projectData.property.basicInformation;
  1059. const projectFeature = tenderData.property.projectFeature;
  1060. const attrs = [
  1061. // 工程编号
  1062. {
  1063. name: 'Number', dName: '工程编号', required: true,
  1064. value: ''
  1065. },
  1066. // 工程名称
  1067. {
  1068. name: 'Name', dName: '工程名称', required: true,
  1069. value: tenderData.name
  1070. },
  1071. // 标段 取建设项目名称
  1072. {
  1073. name: 'Segment',
  1074. value: projectData.name
  1075. },
  1076. // 工程类别
  1077. {
  1078. name: 'ProjectCategory', dName: '工程类别', required: true,
  1079. value: _util.getValueByKey(basicInformation, 'projectCategory')
  1080. },
  1081. // 工程类型
  1082. {
  1083. name: 'ProjectType', dName: '工程类型', required: true,
  1084. value: getProjectType(tenderData, false)
  1085. },
  1086. // 计价模式
  1087. {
  1088. name: 'ValuationModel', dName: '计价模式', type: _type.INT, required: true,
  1089. value: ValuationModel.BILL
  1090. },
  1091. // 计税模式
  1092. {
  1093. name: 'TaxModel', dName: '计税模式', type: _type.INT, required: true,
  1094. value: tenderData.property.taxType
  1095. },
  1096. // 地区类别 取建设项目-基本信息-地区类别
  1097. {
  1098. name: 'AreaKind', dName: '地区类别', type: _type.INT, required: true, enumeration: Object.values(AreaKind), enumerationHint: Object.keys(AreaKind),
  1099. value: AreaKind[_util.getValueByKey(basicInformation, 'regionalCategories')]
  1100. },
  1101. // 金额
  1102. {
  1103. name: 'Total', type: _type.DECIMAL,
  1104. value: summaryInfo.engineeringCost
  1105. },
  1106. // 专业类别
  1107. {
  1108. name: 'Specialty', type: _type.INT,
  1109. value: Specialty[tenderData.property.engineeringName]
  1110. },
  1111. // 工程用途
  1112. {
  1113. name: 'Purposes',
  1114. value: ''
  1115. },
  1116. //建设(编制)范围
  1117. {
  1118. name: 'RangeOfCompilation',
  1119. value: ''
  1120. },
  1121. // 建设规模 取单位工程-工程特征-建设规模
  1122. {
  1123. name: 'Scale', dName: '建设规模', type: _type.DECIMAL, required: true,
  1124. value: _util.getValueByKey(projectFeature, 'buildScale')
  1125. },
  1126. // 建设规模单位 暂取'm2'
  1127. {
  1128. name: 'Unit', dName: '建设规模单位', required: true,
  1129. value: 'm2'
  1130. },
  1131. // 占总投资比例(%)
  1132. {
  1133. name: 'Ratios', type: _type.DECIMAL,
  1134. value: summaryInfo.rate
  1135. },
  1136. // 清单数据库,没有则填写 “无”
  1137. {
  1138. name: 'BillDataBase', dName: '清单数据库', required: true,
  1139. value: '工程量清单规范(2013广东)',
  1140. },
  1141. {
  1142. // 定额数据库,默认的定额库名称,没有则填写 “无”
  1143. name: 'NormDataBase', dName: '定额数据库', required: true,
  1144. value: defaultRationLibName || '无'
  1145. },
  1146. // 人工材料设备价格文件,没有则填写 “无”
  1147. {
  1148. name: 'ResInfoPricingFile', dName: '人工材料设备价格文件', required: true,
  1149. value: '无'
  1150. },
  1151. // 总说明
  1152. {
  1153. name: 'Explains',
  1154. value: tenderData.property.compilationIllustration
  1155. },
  1156. // 导出XML文件名,工程编号+工程名称.xml, 暂时取“名称.xml”,用户设置完工程编号后修改此值
  1157. {
  1158. name: 'FileName',
  1159. value: `${tenderData.name}.xml`
  1160. },
  1161. // 备注
  1162. {
  1163. name: 'Remark',
  1164. value: ''
  1165. },
  1166. ];
  1167. _base.Element.call(this, 'UnitWorks', attrs, '单位工程');
  1168. }
  1169. // 工程特征信息 AttrInfo, 补充信息AddiInfo
  1170. function Info(eleName) {
  1171. _base.Element.call(this, eleName, []);
  1172. }
  1173. // 工程特征信息明细 AttrInfoItem, 补充信息明细AddiInfoItem
  1174. function InfoItem(eleName, attr) {
  1175. const attrs = [
  1176. {
  1177. name: 'Name', dName: '工程名称', required: true,
  1178. value: attr.dispName,
  1179. },
  1180. { name: 'Value', value: attr.value },
  1181. ];
  1182. if (attr.code) {
  1183. attrs.push({ name: 'Code', value: attr.code });
  1184. }
  1185. if (attr.remark) {
  1186. attrs.push({ name: 'Remark', value: attr.remark });
  1187. }
  1188. _base.Element.call(this, eleName, attrs, '工程特征');
  1189. }
  1190. // 单位工程费用汇总
  1191. function UnitWorksSummary() {
  1192. _base.Element.call(this, 'UnitWorksSummary', []);
  1193. }
  1194. // 单位工程费用汇总标题
  1195. function UnitWorksSummaryGroup(bills) {
  1196. const attrs = [
  1197. // 费用编号
  1198. { name: 'Number', value: bills.code },
  1199. // 费用名称
  1200. {
  1201. name: 'Name', dName: '名称', required: true,
  1202. value: bills.name
  1203. },
  1204. // 单位
  1205. { name: 'Unit', value: bills.unit },
  1206. // 工程量
  1207. {
  1208. name: 'Quantity', type: _type.DECIMAL,
  1209. value: bills.quantity
  1210. },
  1211. // 金额
  1212. {
  1213. name: 'Total', type: _type.DECIMAL,
  1214. value: _util.getFee(bills.fees, 'common.totalFee')
  1215. },
  1216. // 技术经济指标(元) 取综合单价
  1217. {
  1218. name: 'TechnicalAndEconomicIndex', type: _type.DECIMAL,
  1219. value: _util.getFee(bills.fees, 'common.unitFee')
  1220. },
  1221. //章节类型
  1222. {
  1223. name: 'ChapterKind', dName: '章节类型', type: _type.INT, required: true,
  1224. value: '4'
  1225. },
  1226. // 费用代号
  1227. {
  1228. name: 'Code', dName: '费用代号', required: true,
  1229. value: getFeeCode(bills)
  1230. },
  1231. // 汇总类型
  1232. {
  1233. name: 'Kind', dName: '汇总类型', type: _type.INT, required: true,
  1234. value: '1'
  1235. },
  1236. // 备注
  1237. { name: 'Remark', value: bills.remark }
  1238. ];
  1239. _base.Element.call(this, 'UnitWorksSummaryGroup', attrs, '单位工程费用汇总标题');
  1240. }
  1241. // 单位工程费汇总明细
  1242. function UnitWorksSummaryItem(node) {
  1243. const bills = node.data;
  1244. const attrs = [
  1245. { name: 'Number', value: bills.code },
  1246. {
  1247. name: 'Name', dName: '名称', required: true,
  1248. value: bills.name
  1249. },
  1250. { name: 'Unit', value: bills.unit },
  1251. {
  1252. name: 'Quantity', type: _type.DECIMAL,
  1253. value: bills.quantity
  1254. },
  1255. // 计算基数:可由费用代号、数字、四则运算符号、小括号组成
  1256. {
  1257. name: 'QtyFormula', type: _type.DECIMAL,
  1258. value: getQtyFormula(node)
  1259. },
  1260. // 费率
  1261. {
  1262. name: 'Rate', type: _type.DECIMAL,
  1263. value: commonUtil.isDef(bills.feeRate) ? bills.feeRate : '100'
  1264. },
  1265. {
  1266. name: 'Total', type: _type.DECIMAL,
  1267. value: _util.getFee(bills.fees, 'common.totalFee')
  1268. },
  1269. // 技术经济指标(元)
  1270. {
  1271. name: 'TechnicalAndEconomicIndex', type: _type.DECIMAL,
  1272. value: _util.getFee(bills.fees, 'common.unitFee')
  1273. },
  1274. //章节类型
  1275. {
  1276. name: 'ChapterKind', dName: '章节类型', type: _type.INT, required: true,
  1277. value: '4'
  1278. },
  1279. // 费用代号
  1280. {
  1281. name: 'Code', dName: '费用代号', required: true,
  1282. value: getFeeCode(bills)
  1283. },
  1284. // 汇总类型
  1285. {
  1286. name: 'Kind', dName: '汇总类型', type: _type.INT, required: true,
  1287. value: '1'
  1288. },
  1289. // 备注
  1290. { name: 'Remark', value: bills.remark }
  1291. ];
  1292. _base.Element.call(this, 'UnitWorksSummaryItem', attrs, '单位工程费用汇总明细');
  1293. }
  1294. // 分部分项工程
  1295. function DivisionalAndElementalWorks() {
  1296. _base.Element.call(this, 'DivisionalAndElementalWorks', []);
  1297. }
  1298. // 措施项目
  1299. function Preliminaries() {
  1300. _base.Element.call(this, 'Preliminaries', []);
  1301. }
  1302. // 合计费用
  1303. function SummaryOfBasicCost(items, bills) {
  1304. // 省略了一些
  1305. const mainMaterial = _util.getFee(bills.fees, 'mainMaterial.totalFee');
  1306. const equipment = _util.getFee(bills.fees, 'equipment.totalFee');
  1307. const mainMaterialEquipment = scMathUtil.roundForObj(mainMaterial + equipment, Decimal.FEE); // 主材设备费 = 主材 + 设备 (设备不输出)
  1308. const attrs = [
  1309. // 人工费
  1310. {
  1311. name: 'Labor', type: _type.DECIMAL,
  1312. value: _util.getFee(bills.fees, 'labour.totalFee')
  1313. },
  1314. // 材料费
  1315. {
  1316. name: 'Material', type: _type.DECIMAL,
  1317. value: _util.getFee(bills.fees, 'material.totalFee')
  1318. },
  1319. // 主材费
  1320. {
  1321. name: 'MainMaterial', type: _type.DECIMAL,
  1322. value: mainMaterial
  1323. },
  1324. // 主材设备费
  1325. {
  1326. name: 'MainMaterialEquipment', type: _type.DECIMAL,
  1327. value: mainMaterialEquipment
  1328. },
  1329. // 暂估价
  1330. {
  1331. name: 'Appraisal', type: _type.DECIMAL,
  1332. value: _util.getFeeByFlag(items, fixedFlag.ESTIMATE, 'common.totalFee')
  1333. },
  1334. // 机械费
  1335. {
  1336. name: 'Machine', type: _type.DECIMAL,
  1337. value: _util.getFee(bills.fees, 'machine.totalFee')
  1338. },
  1339. // 管理费
  1340. {
  1341. name: 'Overhead', type: _type.DECIMAL,
  1342. value: _util.getFee(bills.fees, 'manage.totalFee')
  1343. },
  1344. // 利润
  1345. {
  1346. name: 'Profit', type: _type.DECIMAL,
  1347. value: _util.getFee(bills.fees, 'profit.totalFee')
  1348. },
  1349. // 分部分项工程费
  1350. {
  1351. name: 'DivisionalAndElementalWorks', type: _type.DECIMAL,
  1352. value: _util.getFeeByFlag(items, fixedFlag.SUB_ENGINERRING, 'common.totalFee')
  1353. },
  1354. // 措施项目费
  1355. {
  1356. name: 'Preliminaries', type: _type.DECIMAL,
  1357. value: _util.getFeeByFlag(items, fixedFlag.MEASURE, 'common.totalFee')
  1358. },
  1359. // 绿色施工安全防护措施费
  1360. {
  1361. name: 'CostForHSE', type: _type.DECIMAL,
  1362. value: _util.getFeeByFlag(items, fixedFlag.GREEN_MEASURE_FEE, 'common.totalFee')
  1363. },
  1364. // 其他项目费
  1365. {
  1366. name: 'SundryCosts', type: _type.DECIMAL,
  1367. value: _util.getFeeByFlag(items, fixedFlag.OTHER_MEASURE_FEE, 'common.totalFee')
  1368. },
  1369. // 暂列金额
  1370. {
  1371. name: 'ProvisionalSums', type: _type.DECIMAL,
  1372. value: _util.getFeeByFlag(items, fixedFlag.PROVISIONAL, 'common.totalFee')
  1373. },
  1374. // 规费
  1375. {
  1376. name: 'StatutoryFees', type: _type.DECIMAL,
  1377. value: '0'
  1378. },
  1379. // 税金
  1380. {
  1381. name: 'Tax', type: _type.DECIMAL,
  1382. value: _util.getFeeByFlag(items, fixedFlag.TAX, 'common.totalFee')
  1383. },
  1384. ];
  1385. _base.Element.call(this, 'SummaryOfBasicCost', attrs);
  1386. }
  1387. // 分部工程
  1388. function DivisionalWorks(bills) {
  1389. const attrs = [
  1390. // 编码
  1391. { name: 'Number', value: bills.code },
  1392. // 名称
  1393. {
  1394. name: 'Name', dName: '名称', required: true,
  1395. value: bills.name
  1396. },
  1397. // 特征
  1398. { name: 'Attr', value: '' },
  1399. // 单位
  1400. { name: 'Unit', value: bills.unit },
  1401. // 工程量
  1402. {
  1403. name: 'Quantity', type: _type.DECIMAL,
  1404. value: bills.quantity
  1405. },
  1406. // 综合合价
  1407. {
  1408. name: 'Total', type: _type.DECIMAL,
  1409. value: _util.getFee(bills.fees, 'common.totalFee')
  1410. },
  1411. // 综合单价
  1412. {
  1413. name: 'TechnicalAndEconomicIndex', type: _type.DECIMAL,
  1414. value: _util.getFee(bills.fees, 'common.unitFee')
  1415. },
  1416. // 章节类型
  1417. {
  1418. name: 'ChapterKind', dName: '章节类型', type: _type.INT, required: true,
  1419. value: '4'
  1420. },
  1421. // 费用字典,拼音首字母
  1422. { name: 'Code', value: getFeeCode(bills) },
  1423. // 备注
  1424. { name: 'Remark', value: bills.remark }
  1425. ];
  1426. _base.Element.call(this, 'DivisionalWorks', attrs, '分部工程');
  1427. }
  1428. // 清单项目
  1429. function WorkElement(node, kind, specialty) {
  1430. const bills = node.data;
  1431. const attrs = [
  1432. // 项目编码
  1433. { name: 'Number', dName: '项目编码', required: true, value: bills.code || '' },
  1434. // 项目名称
  1435. { name: 'Name', dName: '项目名称', required: true, value: bills.name },
  1436. // 项目特征
  1437. { name: 'Attr', value: bills.itemCharacterText },
  1438. // 工作内容
  1439. { name: 'WorkContent', value: bills.jocContentText },
  1440. // 计量单位
  1441. { name: 'Unit', dName: '计量单位', required: true, value: bills.unit },
  1442. // 工程量
  1443. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1444. // 计算基数
  1445. { name: 'QtyFormula', type: _type.DECIMAL, value: getQtyFormula(node) },
  1446. // 单价(元)
  1447. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1448. // 设备单价(元)指清单项目所采用设备的综合单价
  1449. { name: 'EquipmentPrice', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'equipment.unitFee') },
  1450. // 最低限价(元)
  1451. //{ name: 'PriceLow', type: _type.DECIMAL, value: 'todo' },
  1452. // 最高限价(元)
  1453. { name: 'PriceHigh', type: _type.DECIMAL, value: bills.maxPrice },
  1454. // 费率(%)
  1455. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1456. // 合价(元)
  1457. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1458. // 主要清单
  1459. { name: 'Major', type: _type.BOOL, value: !!bills.mainBills },
  1460. // 子目类型
  1461. { name: 'Kind', dName: '子目类型', type: _type.INT, required: true, value: kind },
  1462. // 取费类型
  1463. { name: 'CalculationKind', dName: '取费类型', type: _type.INT, required: true, value: '1' },
  1464. // 费用归属
  1465. { name: 'CostKind', dName: '费用归属', type: _type.INT, required: true, value: '1' },
  1466. // 计算方式
  1467. { name: 'CalcType', dName: '计算方式', type: _type.INT, required: true, value: '1' },
  1468. // 专业类型
  1469. { name: 'Specialty', type: _type.INT, value: specialty },
  1470. // 清单标识
  1471. { name: 'ListingIdentity', value: 'GB50500-2013 1 GD' },
  1472. // 费用代号
  1473. { name: 'Code', value: getFeeCode(bills) },
  1474. // 备注
  1475. { name: 'Remark', value: bills.remark }
  1476. ];
  1477. _base.Element.call(this, 'WorkElement', attrs, '清单');
  1478. }
  1479. // 工程量计算表
  1480. function ExpressElement(quantityDetail) {
  1481. const attrs = [
  1482. // 序号
  1483. { name: 'OrderNumber', dName: '序号', required: true, value: quantityDetail.name },
  1484. // 工程量计算式
  1485. { name: 'Express', dName: '工程量计算式', required: true, value: quantityDetail.regex },
  1486. // 工程量
  1487. { name: 'Quantity', dName: '工程量', required: true, value: quantityDetail.result },
  1488. // 汇总类型
  1489. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummationKindMap[quantityDetail.isSummation] },
  1490. ];
  1491. _base.Element.call(this, 'ExpressElement', attrs, '工程量计算表');
  1492. }
  1493. // 工序内容
  1494. function WorkContent(contentText, fee) {
  1495. const attrs = [
  1496. // 定额工作内容
  1497. { name: 'Name', dName: '定额工作内容', required: true, value: contentText },
  1498. // 取此工作内容下定额子目/量价/定额同级人材机的综合合价之和
  1499. { name: 'Total', type: _type.DECIMAL, value: fee },
  1500. { name: 'Remark', value: '' }
  1501. ];
  1502. _base.Element.call(this, 'WorkContent', attrs, '工序内容');
  1503. }
  1504. // 定额子目
  1505. function Norm(ration, libCode, kind, specialty) {
  1506. const attrs = [
  1507. // 定额编码
  1508. { name: 'Number', dName: '定额编码', required: true, value: ration.code },
  1509. { name: 'Name', dName: '定额名称', required: true, value: ration.name },
  1510. { name: 'Unit', dName: '计量单位', required: true, value: ration.unit },
  1511. { name: 'Quantity', type: _type.DECIMAL, value: ration.quantity },
  1512. // 单价
  1513. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(ration.fees, 'common.unitFee') },
  1514. // 合价
  1515. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(ration.fees, 'common.totalFee') },
  1516. // 是否定额
  1517. { name: 'IsNorm', dName: '是否定额', type: _type.Bool, required: true, value: 'true' },
  1518. // 子目类型
  1519. { name: 'Kind', dName: '子目类型', type: _type.INT, required: true, value: kind },
  1520. // 取费类型
  1521. { name: 'CalculationKind', dName: '取费类型', type: _type.INT, required: true, value: '1' },
  1522. // 费用归属
  1523. { name: 'CostKind', dName: '费用归属', type: _type.INT, required: true, value: '1' },
  1524. // 降效类型
  1525. {
  1526. name: 'EfficiencyKind', type: _type.INT,
  1527. value: ration.type === rationType.overHeight ? EfficiencyKind.BASE_REDUCTION : EfficiencyKind.NOT_BASE_REDUCTION
  1528. },
  1529. // 子目增加费类型itemIncrease
  1530. {
  1531. name: 'IncFeeKind', type: _type.INT,
  1532. value: ration.type === rationType.overHeight ? IncFeeKind.SUB_BASE : IncFeeKind.NOT_SUB_BASE
  1533. },
  1534. // 换算说明
  1535. { name: 'Conversion', value: ration.adjustState },
  1536. // 专业类别
  1537. { name: 'Specialty', type: _type.INT, value: specialty },
  1538. //定额标识(定额库编码)
  1539. { name: 'NormIdentity', value: libCode },
  1540. // 册 定额书没有分册填写0,有分册的按册号填写
  1541. { name: 'Volume', type: _type.INT, value: getVolume(ration.code) },
  1542. // 章
  1543. { name: 'Chapter', type: _type.INT, value: getChapter(ration.code) },
  1544. { name: 'Remark', value: ration.remark }
  1545. ];
  1546. _base.Element.call(this, 'Norm', attrs, '定额子目');
  1547. }
  1548. // 子目管理费
  1549. function ManageFees(calcTemplate) {
  1550. const calcItems = (calcTemplate || {}).calcItems;
  1551. const manageItem = (calcItems || []).find(item => item.name === '管理费');
  1552. const fee1 = manageItem ? manageItem.unitFee : '0';
  1553. const rate = manageItem && commonUtil.isDef(manageItem.feeRate) ? manageItem.feeRate : '100';
  1554. const attrs = [
  1555. // 一类地区管理费 输出定额计算程序的管理费单价
  1556. { name: 'Fee1', dName: '一类地区管理费', type: _type.DECIMAL, required: true, value: fee1 },
  1557. // 二类地区管理费
  1558. { name: 'Fee2', dName: '二类地区管理费', type: _type.DECIMAL, required: true, value: '0' },
  1559. // 三类地区管理费
  1560. { name: 'Fee3', dName: '三类地区管理费', type: _type.DECIMAL, required: true, value: '0' },
  1561. // 四类地区管理费
  1562. { name: 'Fee4', dName: '四类地区管理费', type: _type.DECIMAL, required: true, value: '0' },
  1563. // 管理费换算比例
  1564. { name: 'Rate', dName: '管理费换算比例', type: _type.DECIMAL, required: true, value: rate },
  1565. ];
  1566. _base.Element.call(this, 'ManageFees', attrs, '子目管理费');
  1567. }
  1568. // 工料机含量明细
  1569. function LabourMaterialsEquipmentsMachinesElement(glj, quantity) {
  1570. const attrs = [
  1571. // 工料机编码
  1572. { name: 'Number', value: glj.code },
  1573. // 消耗量
  1574. { name: 'Quantity', type: _type.DECIMAL, value: quantity },
  1575. // 不计价材料
  1576. { name: 'NOCost', typ: _type.BOOL, value: 'false' },
  1577. // 备注
  1578. { name: 'Remark', value: '' }
  1579. ];
  1580. _base.Element.call(this, 'LabourMaterialsEquipmentsMachinesElement', attrs);
  1581. }
  1582. //子目单价计算
  1583. function UnitPriceCalculationOfItem(calcItem) {
  1584. const feeRate = commonUtil.isDef(calcItem.feeRate) ? calcItem.feeRate : '100';
  1585. const attrs = [
  1586. // 费用名称
  1587. { name: 'Name', dName: '费用名称', required: true, value: calcItem.name },
  1588. // 计算基数
  1589. { name: 'QtyFormula', value: CalculationQtyMap[calcItem.name] },
  1590. // 费率
  1591. { name: 'Rate', type: _type.DECIMAL, value: feeRate },
  1592. // 金额
  1593. { name: 'Total', type: _type.DECIMAL, value: calcItem.totalFee },
  1594. // 费用代号
  1595. { name: 'Code', value: CalculationCodeMap[calcItem.name] },
  1596. // 备注
  1597. { name: 'Remark', value: '' },
  1598. ];
  1599. _base.Element.call(this, 'UnitPriceCalculationOfItem', attrs, '子目单价计算');
  1600. }
  1601. // 其他项目
  1602. function Sundry() {
  1603. _base.Element.call(this, 'Sundry', []);
  1604. }
  1605. // 其他项目汇总子目
  1606. function SundryItem(eleName, bills) {
  1607. const attrs = [
  1608. // 名称
  1609. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1610. // 金额
  1611. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1612. // 费用代号
  1613. { name: 'Code', dName: '费用代号', required: true, value: getFeeCode(bills) },
  1614. // 备注
  1615. { name: 'Remark', value: bills.remark }
  1616. ];
  1617. _base.Element.call(this, eleName, attrs, '其他项目汇总项');
  1618. }
  1619. // 其他项目费标题
  1620. function SundryCostsGroup(node) {
  1621. const bills = node.data;
  1622. const attrs = [
  1623. // 名称
  1624. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1625. // 金额
  1626. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1627. // 费用代号
  1628. { name: 'Code', dName: '费用代号', required: true, value: getFeeCode(bills) },
  1629. // 汇总类型
  1630. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1631. // 备注
  1632. { name: 'Remark', value: bills.remark }
  1633. ];
  1634. _base.Element.call(this, 'SundryCostsGroup', attrs, '其他项目费标题');
  1635. }
  1636. // 其他项目费明细
  1637. function SundryCostsItem(node) {
  1638. const bills = node.data;
  1639. if (bills.name === '材料暂估价') {
  1640. debugger;
  1641. }
  1642. const attrs = [
  1643. // 名称
  1644. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1645. // 单位
  1646. { name: 'Unit', value: bills.unit },
  1647. // 工程量
  1648. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1649. // 计算基数
  1650. { name: 'QtyFormula', value: getQtyFormula(node) },
  1651. // 单价
  1652. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1653. // 费率
  1654. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1655. // 金额
  1656. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1657. // 费用代号
  1658. { name: 'Code', dName: '费用代号', required: true, value: getFeeCode(bills) },
  1659. // 汇总类型
  1660. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1661. // 备注
  1662. { name: 'Remark', value: bills.remark }
  1663. ];
  1664. _base.Element.call(this, 'SundryCostsItem', attrs, '其他项目费明细');
  1665. }
  1666. // 暂列金额标题
  1667. function ProvisionalSumsGroup(node) {
  1668. const bills = node.data;
  1669. const attrs = [
  1670. // 名称
  1671. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1672. // 金额
  1673. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1674. // 汇总类型
  1675. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1676. // 备注
  1677. { name: 'Remark', value: bills.remark }
  1678. ];
  1679. _base.Element.call(this, 'ProvisionalSumsGroup', attrs, '暂列金额标题');
  1680. }
  1681. // 暂列金额明细
  1682. function ProvisionalSumsItem(node) {
  1683. const bills = node.data;
  1684. const attrs = [
  1685. // 名称
  1686. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1687. // 单位
  1688. { name: 'Unit', value: bills.unit },
  1689. // 工程量
  1690. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1691. // 计算基数
  1692. { name: 'QtyFormula', value: getQtyFormula(node) },
  1693. // 单价
  1694. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1695. // 费率
  1696. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1697. // 金额
  1698. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1699. // 汇总类型
  1700. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1701. // 备注
  1702. { name: 'Remark', value: bills.remark }
  1703. ];
  1704. _base.Element.call(this, 'ProvisionalSumsItem', attrs, '暂列金额明细');
  1705. }
  1706. // 材料设备暂估价明细
  1707. // 读取单位工程-其他项目费的材料暂估价的组成数据,业务上这个清单是使用清单基数计算得来,所以此部分读取整个单位工程下打勾暂估的材料
  1708. function ProvisionalMaterialEquipmentItem(glj, price) {
  1709. const attrs = [
  1710. // 编码
  1711. { name: 'Number', value: glj.code },
  1712. // 名称
  1713. { name: 'Name', dName: '名称', required: true, value: glj.name },
  1714. // 型号规格
  1715. { name: 'Specification', value: glj.specs },
  1716. // 单位
  1717. { name: 'Unit', dName: '单位', required: true, value: bills.unit },
  1718. // 工程量(总消耗量)
  1719. { name: 'Quantity', type: _type.DECIMAL, value: glj.quantity },
  1720. // 单价 取市场价
  1721. { name: 'Price', type: _type.DECIMAL, value: price.marketPrice },
  1722. // 金额 round(总消耗量*市场价,2)
  1723. { name: 'Total', type: _type.DECIMAL, value: scMathUtil.roundForObj(price.quantity * price.marketPrice, 2) },
  1724. // 备注
  1725. { name: 'Remark', value: glj.remark }
  1726. ];
  1727. _base.Element.call(this, 'ProvisionalMaterialEquipmentItem', attrs, '材料设备暂估价明细');
  1728. }
  1729. // 专业工程暂估价标题
  1730. function SpecialtyProvisionalPriceGroup(node) {
  1731. const bills = node.data;
  1732. const attrs = [
  1733. // 名称
  1734. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1735. // 工程内容
  1736. { name: 'Content', value: bills.engineeringContent },
  1737. // 金额
  1738. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1739. // 汇总类型
  1740. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1741. // 备注
  1742. { name: 'Remark', value: bills.remark }
  1743. ];
  1744. _base.Element.call(this, 'SpecialtyProvisionalPriceGroup', attrs, '专业工程暂估价标题');
  1745. }
  1746. // 专业工程暂估价明细
  1747. function SpecialtyProvisionalPriceItem(node) {
  1748. const bills = node.data;
  1749. const attrs = [
  1750. // 名称
  1751. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1752. // 工程内容
  1753. { name: 'Content', value: bills.engineeringContent },
  1754. // 单位
  1755. { name: 'Unit', value: bills.unit },
  1756. // 工程量
  1757. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1758. // 计算基数
  1759. { name: 'QtyFormula', value: getQtyFormula(node) },
  1760. // 单价
  1761. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1762. // 费率
  1763. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1764. // 金额
  1765. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1766. // 汇总类型
  1767. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1768. // 备注
  1769. { name: 'Remark', value: bills.remark }
  1770. ];
  1771. _base.Element.call(this, 'SpecialtyProvisionalPriceItem', attrs, '专业工程暂估价明细');
  1772. }
  1773. // 计日工标题
  1774. function DayWorkRateGroup(node) {
  1775. const bills = node.data;
  1776. const attrs = [
  1777. // 名称
  1778. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1779. // 金额
  1780. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1781. // 费用代号
  1782. { name: 'Code', value: getFeeCode(bills) },
  1783. // 备注
  1784. { name: 'Remark', value: bills.remark }
  1785. ];
  1786. _base.Element.call(this, 'DayWorkRateGroup', attrs, '计日工标题');
  1787. }
  1788. // 计日工明细
  1789. function DayWorkRateItem(node) {
  1790. const bills = node.data;
  1791. const attrs = [
  1792. // 编码
  1793. { name: 'Number', value: bills.code },
  1794. // 名称
  1795. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1796. // 型号规格
  1797. { name: 'Specification', value: '' },
  1798. // 单位
  1799. { name: 'Unit', dName: '单位', required: true, value: bills.unit },
  1800. // 工程量
  1801. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1802. // 单价
  1803. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1804. // 金额
  1805. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1806. // 备注
  1807. { name: 'Remark', value: bills.remark }
  1808. ];
  1809. _base.Element.call(this, 'DayWorkRateItem', attrs, '计日工明细');
  1810. }
  1811. // 总承包服务费标题
  1812. function MainContractorAttendanceGroup(node) {
  1813. const bills = node.data;
  1814. const attrs = [
  1815. // 名称
  1816. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1817. // 金额
  1818. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1819. // 汇总类型
  1820. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1821. // 备注
  1822. { name: 'Remark', value: bills.remark }
  1823. ];
  1824. _base.Element.call(this, 'MainContractorAttendanceGroup', attrs, '总承包服务费标题');
  1825. }
  1826. // 总承包服务费明细
  1827. function MainContractorAttendanceItem(node) {
  1828. const bills = node.data;
  1829. const attrs = [
  1830. // 名称
  1831. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1832. // 项目价值
  1833. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1834. // 服务内容
  1835. { name: 'Content', value: bills.serviceContent },
  1836. // 计算基数
  1837. { name: 'QtyFormula', value: getQtyFormula(node) },
  1838. // 费率
  1839. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1840. // 金额
  1841. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1842. // 汇总类型
  1843. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1844. // 备注
  1845. { name: 'Remark', value: bills.remark }
  1846. ];
  1847. _base.Element.call(this, 'MainContractorAttendanceItem', attrs, '总承包服务费明细');
  1848. }
  1849. // 索赔、签证费用标题
  1850. function ClaimVisaCostGroup(eleName, node) {
  1851. const bills = node.data;
  1852. const attrs = [
  1853. // 名称
  1854. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1855. // 金额
  1856. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1857. // 汇总类型
  1858. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1859. // 备注
  1860. { name: 'Remark', value: bills.remark }
  1861. ];
  1862. _base.Element.call(this, eleName, attrs, '索赔、签证费用标题');
  1863. }
  1864. // 索赔费用明细
  1865. function ClaimVisaCostItem(eleName, node) {
  1866. const bills = node.data;
  1867. const attrs = [
  1868. // 名称
  1869. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1870. // 单位
  1871. { name: 'Unit', value: bills.unit },
  1872. // 数量
  1873. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1874. // 计算基数
  1875. { name: 'QtyFormula', value: getQtyFormula(node) },
  1876. // 单价
  1877. { name: 'Price', value: _util.getFee(bills.fees, 'common.unitFee') },
  1878. // 费率
  1879. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1880. // 金额
  1881. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1882. // 依据
  1883. { name: 'Reason', value: '' },
  1884. // 汇总类型
  1885. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1886. // 备注
  1887. { name: 'Remark', value: bills.remark }
  1888. ];
  1889. _base.Element.call(this, eleName, attrs, '索赔费用明细');
  1890. }
  1891. // 规费
  1892. function StatutoryFees() {
  1893. const attrs = [
  1894. { name: 'Name', dName: '名称', required: true, value: '规费' },
  1895. { name: 'Code', dName: '费用代号', required: true, value: 'GF' }
  1896. ];
  1897. _base.Element.call(this, 'StatutoryFees', attrs, '规费');
  1898. }
  1899. // 税金
  1900. function Tax(eleName, node) {
  1901. const bills = node.data;
  1902. const attrs = [
  1903. // 名称
  1904. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1905. // 计算基数说明
  1906. { name: 'CalBasis', value: getCalBasis(node) },
  1907. // 计算基数
  1908. { name: 'QtyFormula', value: getQtyFormula(node) },
  1909. // 费率
  1910. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1911. // 金额
  1912. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1913. // 费用代号
  1914. { name: 'Code', value: getFeeCode(bills) },
  1915. // 备注
  1916. { name: 'Remark', value: bills.remark }
  1917. ];
  1918. _base.Element.call(this, eleName, attrs, '税金');
  1919. }
  1920. // 人材机汇总
  1921. function LabourMaterialsEquipmentsMachinesSummary(glj, price, infoData, coeData) {
  1922. const attrs = [
  1923. // 编码
  1924. { name: 'Number', dName: '编码', required: true, value: glj.code },
  1925. // 名称
  1926. { name: 'Name', dName: '名称', required: true, value: glj.name },
  1927. // 规格型号
  1928. { name: 'Specification', value: glj.specs },
  1929. // 单位
  1930. { name: 'Unit', dName: '单位', required: true, value: glj.unit },
  1931. // 数量(总消耗量)
  1932. { name: 'Quantity', type: _type.DECIMAL, value: glj.quantity },
  1933. // 风险系数 从承包人主要材料设备-造价信息差额调整法读取,取不到则输出"0"
  1934. { name: 'ProviderExp', type: _type.DECIMAL, value: infoData && infoData.riskCoe || '0' },
  1935. // 基准单价 从承包人主要材料设备-造价信息差额调整法读取,取不到则输出"0"
  1936. { name: 'ProviderBase', type: _type.DECIMAL, value: infoData && infoData.standardPrice || '0' },
  1937. // 除税定额价(定额价)
  1938. { name: 'NoTaxOrgPrice', type: _type.DECIMAL, value: price.basePrice },
  1939. // 除税编制价(市场价)
  1940. { name: 'NoTaxPrice', type: _type.DECIMAL, value: price.marketPrice },
  1941. // 含税定额价 不存在这个字段,输出"0"
  1942. { name: 'TaxOrgPrice', type: _type.DECIMAL, value: '0' },
  1943. // 含税编制价 暂时取市场价
  1944. { name: 'TaxPrice', type: _type.DECIMAL, value: price.marketPrice },
  1945. // 引进部分
  1946. { name: 'ForeignCurrency', type: _type.DECIMAL, value: '0' },
  1947. // 折合人民币
  1948. { name: 'ConvertedIntoRMB', type: _type.DECIMAL, value: '0' },
  1949. // 除税定额价合价 取Round(定额价*总消耗量,2)
  1950. { name: 'NoTaxOrgTotal', type: _type.DECIMAL, value: scMathUtil.roundForObj(price.basePrice * glj.quantity, 2) },
  1951. // 除税编制价合价(元) 取Round(不含税市场价*总消耗量,2)
  1952. { name: 'NoTaxTotal', type: _type.DECIMAL, value: scMathUtil.roundForObj(price.marketPrice * glj.quantity, 2) },
  1953. // 含税定额价合价
  1954. { name: 'TaxOrgTotal', type: _type.DECIMAL, value: '0' },
  1955. // 含税编制价合价 取Round(含税市场价*总消耗量,2) (暂时用市场价)
  1956. { name: 'TaxTotal', type: _type.DECIMAL, value: scMathUtil.roundForObj(price.marketPrice * glj.quantity, 2) },
  1957. // 变值权重 从承包人主要材料设备-价格指数调整法读取,取不到则输出“0”
  1958. { name: 'Weight', type: _type.DECIMAL, value: coeData && coeData.varWeight || '0' },
  1959. // 基本价格指数 从承包人主要材料设备-价格指数调整法读取,取不到则输出“0”
  1960. { name: 'BasicPrice', type: _type.DECIMAL, value: coeData && coeData.FO || '0' },
  1961. // 现行价格指数 从承包人主要材料设备-价格指数调整法读取,取不到则输出“0”
  1962. { name: 'CurrentPrice', type: _type.DECIMAL, value: coeData && coeData.FI || '0' },
  1963. // 工料机类型
  1964. { name: 'Kind', type: _type.INT, value: getGLJKind(glj.type) },
  1965. // 工料机归属
  1966. { name: 'Class', value: '' },
  1967. // 扩展属性
  1968. { name: 'ExtKind', type: _type.INT, value: 1 },
  1969. // 商品砼 如果工料机类型是“商品混凝土”、“商品砂浆”、“商品配合比”(软件中没有),则取“true”;否则取“false”
  1970. { name: 'Concrete', type: _type.BOOL, value: [205, 206].includes(glj.type) },
  1971. // 主要材料
  1972. { name: 'MainMaterial', type: _type.BOOL, value: !!glj.is_main_material },
  1973. // 是否暂估价材料
  1974. { name: 'ProvisionalMaterial', type: _type.BOOL, value: !!glj.is_evaluate },
  1975. // 供料方式
  1976. { name: 'Provider', type: _type.INT, value: Provider[glj.supply] },
  1977. // 价格来源
  1978. { name: 'PriceSource', value: '' },
  1979. // 交货方式
  1980. { name: 'Delivery', value: glj.delivery },
  1981. // 送达地点
  1982. { name: 'Location', value: glj.delivery_address },
  1983. // 产地
  1984. { name: 'ProducingArea', value: glj.originPlace },
  1985. // 供应商
  1986. { name: 'Supplier', value: glj.vender },
  1987. // 质量要求
  1988. { name: 'Character', value: glj.qualityGrace },
  1989. // 备注
  1990. { name: 'Remark', value: glj.remark }
  1991. ];
  1992. _base.Element.call(this, 'LabourMaterialsEquipmentsMachinesSummary', attrs, '人材机汇总');
  1993. }
  1994. // 评标主要材料
  1995. function BidEvaluationMainMaterial(glj) {
  1996. const attrs = [
  1997. // 序号
  1998. { name: 'Code', dName: '序号', required: true, value: glj.seq },
  1999. // 编码
  2000. { name: 'Number', value: glj.code },
  2001. // 名称
  2002. { name: 'Name', dName: '名称', required: true, value: glj.name },
  2003. // 规格型号
  2004. { name: 'Specification', value: glj.specs },
  2005. // 单位
  2006. { name: 'Unit', dName: '单位', required: true, value: glj.unit },
  2007. // 市场价
  2008. { name: 'Price', type: _type.DECIMAL, value: glj.marketPrice },
  2009. // 最高限价
  2010. { name: 'LimitedPrice', type: _type.DECIMAL, value: '0' },
  2011. // 总消耗量
  2012. { name: 'Quantity', type: _type.DECIMAL, value: glj.quantity },
  2013. // 金额 Round(市场价*总消耗量,2)
  2014. { name: 'Total', type: _type.DECIMAL, value: scMathUtil.roundForObj(glj.marketPrice * glj.quantity, 2) },
  2015. // 交货方式
  2016. { name: 'Delivery', type: _type.DECIMAL, value: glj.delivery },
  2017. // 送达地点
  2018. { name: 'DeliPlace', value: glj.delivery_address },
  2019. // 产地
  2020. { name: 'ProducingArea', value: glj.originPlace },
  2021. // 供应商
  2022. { name: 'Supplier', value: glj.vender },
  2023. // 质量要求
  2024. { name: 'Character', value: glj.qualityGrace },
  2025. // 备注
  2026. { name: 'Remark', value: glj.remark }
  2027. ];
  2028. _base.Element.call(this, 'BidEvaluationMainMaterial', attrs, '评标主要材料');
  2029. }
  2030. // 建设项目节点
  2031. let constructionProjectEle = null;
  2032. /*
  2033. * 加载数据,分两种数据类型
  2034. * 1.建设项目
  2035. * 2.建设项目下单位工程
  2036. * @param {Object}项目数据
  2037. * @return {Array}
  2038. * */
  2039. async function loadData(projectData) {
  2040. // 标记自检提示的开始(一次性多出多个文件类型,会导出多次)
  2041. _failList.push(_config.HINT_START);
  2042. // 提取出的数据
  2043. const extractData = [];
  2044. // 建设项目部分
  2045. constructionProjectEle = await loadConstructionProject(projectData);
  2046. extractData.push({
  2047. data: constructionProjectEle,
  2048. dataType: DATA_TYPE.PROJECT,
  2049. exportKind,
  2050. fileName: 'Project.xml'
  2051. });
  2052. // 单位工程部分
  2053. // 提取出单位工程级别的项目数据
  2054. const tenderData = projectData.children.reduce((acc, cur) => {
  2055. if (Array.isArray(cur.children)) {
  2056. acc.push(...cur.children)
  2057. }
  2058. return acc;
  2059. }, []);
  2060. // 获取单位工程详细结构
  2061. const isPlainTender = false;
  2062. const tenders = await loadTenders(projectData.summaryInfo, tenderData, isPlainTender);
  2063. tenders.forEach(tender => {
  2064. // 单位工程文件名为@_单位工程编码_单位工程名称.xml
  2065. // 因为单位工程编码后续用户可能会改变,这里暂时将fileName设置成单位工程名称
  2066. const name = tender.attrs.find(attr => attr.name === 'Name');
  2067. extractData.push({
  2068. data: tender,
  2069. dataType: DATA_TYPE.TENDER,
  2070. exportKind,
  2071. fileName: name
  2072. });
  2073. });
  2074. return extractData;
  2075. }
  2076. /*
  2077. * 加载建设项目
  2078. * @param {Object}项目数据
  2079. * @return {Array}
  2080. * */
  2081. async function loadConstructionProject(projectData) {
  2082. const summaryInfo = projectData.summaryInfo[projectData.ID];
  2083. // 建设项目
  2084. const constructionProject = new ConstructionProject(projectData, summaryInfo);
  2085. // 系统信息
  2086. const systemInfo = new SystemInfo({
  2087. // 软件相关信息进行base64编码
  2088. ID1: Base64.encode(projectData.softInfo),
  2089. ID2: _util.generateHardwareId(),
  2090. makeDate: moment(Date.now()).format('YYYY-MM-DDTHH:mm:ss'),
  2091. });
  2092. // 工程信息
  2093. const constructionInfo = loadConstructionInfo(projectData);
  2094. // 费用汇总
  2095. const summaryCost = new SummaryOfCost(summaryInfo);
  2096. // 建筑安装工程费
  2097. const projectInstall = new ProjectInstallationWorkCost(projectData, summaryInfo);
  2098. // 单项工程
  2099. const sectionalWorks = await loadEngineering(projectData.summaryInfo, projectData.children);
  2100. projectInstall.children.push(...sectionalWorks);
  2101. constructionProject.children.push(
  2102. systemInfo,
  2103. constructionInfo,
  2104. summaryCost,
  2105. projectInstall
  2106. );
  2107. return constructionProject;
  2108. }
  2109. // 加载工程信息相关元素
  2110. function loadConstructionInfo(projectData) {
  2111. const basicInformation = projectData.property.basicInformation;
  2112. const summaryInfo = projectData.summaryInfo[projectData.ID];
  2113. // 工程信息
  2114. const constructionInfo = new ConstructionInfo();
  2115. // 费用精度
  2116. const option = new Option();
  2117. // 估(概、预、结)算信息
  2118. const projectInfo = new ProjectInfo(basicInformation, summaryInfo);
  2119. let exportInfo;
  2120. if (exportKind === _config.EXPORT_KIND.Tender) {
  2121. // 投标文件输出招标、投标信息
  2122. exportInfo = [
  2123. new TendereeInfo(basicInformation, summaryInfo),
  2124. new BidderInfo(basicInformation, summaryInfo)
  2125. ];
  2126. } else {
  2127. // 招标或控制价文件只输出招标信息
  2128. exportInfo = [new TendereeInfo(basicInformation, summaryInfo)];
  2129. }
  2130. constructionInfo.children.push(option, projectInfo, ...exportInfo);
  2131. return constructionInfo;
  2132. }
  2133. /*
  2134. * 加载所有单项工程元素
  2135. * @param {Object}summaryInfoMap 总的汇总价格映射表(与项目ID映射)
  2136. * {Array}engineeringData 所有单项工程项目数据
  2137. * @return {Array}
  2138. * */
  2139. async function loadEngineering(summaryInfoMap, engineeringData) {
  2140. const isPlainTender = true;
  2141. const sectionalWorks = [];
  2142. for (const engData of engineeringData) {
  2143. const summaryInfo = summaryInfoMap[engData.ID];
  2144. // 单项工程
  2145. const sectionalWork = new SectionalWorks({
  2146. name: engData.name,
  2147. total: summaryInfo.engineeringCost,
  2148. rate: summaryInfo.rate,
  2149. });
  2150. // 费用汇总
  2151. const summaryCost = new SummaryOfCost(summaryInfo);
  2152. // 简单结构的单位工程
  2153. const tenders = await loadTenders(summaryInfoMap, engData.children, isPlainTender);
  2154. sectionalWork.children.push(summaryCost, ...tenders);
  2155. sectionalWorks.push(sectionalWork);
  2156. }
  2157. return sectionalWorks;
  2158. }
  2159. /*
  2160. * 加载所有单位工程元素
  2161. * @param {Object}summaryInfoMap 总的汇总价格映射表(与项目ID映射)
  2162. * {Array}tenderData 所有单项工程项目数据
  2163. * {Boolean}isPlain 是否简单结构(简单结构只含有UnitWorks,其下不含子元素)
  2164. * @return {Array}
  2165. * */
  2166. let tenderDetail = null;
  2167. async function loadTenders(summaryInfoMap, tenderData, isPlain) {
  2168. const unitWorks = [];
  2169. for (const tData of tenderData) {
  2170. // 需要请求项目详细数据的时候,间隔一段时间再初始单位工程数据,减少服务器压力
  2171. const tenderDetailMap = _cache.getItem('tenderDetailMap');
  2172. if (!tenderDetailMap[tData.ID]) {
  2173. await _util.setTimeoutSync(() => { }, _config.TIMEOUT_TIME);
  2174. }
  2175. // 获取单位工程详细数据
  2176. debugger;
  2177. tenderDetail = await _util.getTenderDetail(tData.ID, userID);
  2178. // 先计算人材机总消耗量,以供后面需要
  2179. gljUtil.calcProjectGLJQuantity(tenderDetail.projectGLJ.datas,
  2180. tenderDetail.ration_glj.datas, tenderDetail.Ration.datas, tenderDetail.Bills.datas, Decimal.GLJ, _, scMathUtil);
  2181. const summaryInfo = summaryInfoMap[tData.ID];
  2182. const defaultRationLib = tenderDetail.projectInfo.engineeringInfo.ration_lib.find(lib => lib.isDefault);
  2183. const defaultRationLibName = defaultRationLib.name;
  2184. // 单位工程
  2185. const unitWork = new UnitWorks(projectData, tData, defaultRationLibName, summaryInfo);
  2186. // 简单结构,不需要继续添加子元素
  2187. if (isPlain) {
  2188. unitWorks.push(unitWork);
  2189. continue;
  2190. }
  2191. // 不是简单结构,继续添加各种子元素
  2192. // 方便用户看错误来自哪个单位工程
  2193. _failList.push(`<span style="font-weight: bold">单位工程“${tData.name}”下:</span>`);
  2194. const orgLen = _failList.length;
  2195. // 工程特征信息
  2196. const attrInfo = loadAttrInfo(tData.property.projectFeature);
  2197. // 基本信息
  2198. const addiInfo = loadAddiInfo(projectData.property.basicInformation);
  2199. // 费用汇总
  2200. const summaryOfCost = new SummaryOfCost(summaryInfo);
  2201. /* // 获取单位工程详细数据
  2202. tenderDetail = await _util.getTenderDetail(tData.ID, userID);
  2203. // 先计算人材机总消耗量,以供后面需要
  2204. gljUtil.calcProjectGLJQuantity(tenderDetail.projectGLJ.datas,
  2205. tenderDetail.ration_glj.datas, tenderDetail.Ration.datas, tenderDetail.Bills.datas, Decimal.GLJ, _, scMathUtil); */
  2206. // 单位工程费用汇总
  2207. const unitWorksSummary = loadUnitWorksSummary(tenderDetail);
  2208. // 分部分项工程
  2209. const divisionalElements = loadDivisionalAndElementalWorks();
  2210. // 措施项目
  2211. const preliminaries = loadPreliminaries();
  2212. // 其他项目
  2213. const sundry = loadSundry();
  2214. // 规费
  2215. const statutoryFees = new StatutoryFees();
  2216. // 税金
  2217. const tax = loadTax();
  2218. // 人材机汇总
  2219. const gljSummary = loadGLJSummary();
  2220. // 评标材料
  2221. const bidEvaluations = loadBidEvaluation();
  2222. // 人材机汇总和评标材料需要汇总到建设项目
  2223. const projectInstallationWorkCost = constructionProjectEle.children.find(ele => ele.name === 'ProjectInstallationWorkCost');
  2224. projectInstallationWorkCost.children.push(...gljSummary, ...bidEvaluations);
  2225. unitWork.children.push(
  2226. attrInfo,
  2227. addiInfo,
  2228. summaryOfCost,
  2229. unitWorksSummary,
  2230. divisionalElements,
  2231. preliminaries,
  2232. sundry,
  2233. statutoryFees,
  2234. tax,
  2235. ...gljSummary,
  2236. ...bidEvaluations
  2237. );
  2238. // 只有方便用户看错误来自哪个单位工程的提示,说明该单位工程没有报错
  2239. if (_failList.length === orgLen) {
  2240. _failList.pop();
  2241. }
  2242. unitWorks.push(unitWork);
  2243. }
  2244. return unitWorks;
  2245. }
  2246. // 加载工程特征信息
  2247. // attrList 单位工程的工程特征,来自property.projectFeature
  2248. function loadAttrInfo(attrList) {
  2249. const attrInfo = new Info('AttrInfo');
  2250. // 有值的才输出
  2251. attrInfo.children = attrList
  2252. .filter(attr => commonUtil.isDef(attr.value))
  2253. .map(attr => new InfoItem('AttrInfoItem', attr));
  2254. return attrInfo;
  2255. }
  2256. // 加载补充信息(基本信息所有条目)
  2257. function loadAddiInfo(infoList) {
  2258. const addiInfo = new Info('AddiInfo');
  2259. addiInfo.children = infoList.map(rootInfoItem => {
  2260. const rootInfo = new InfoItem('AddiInfoItem', rootInfoItem);
  2261. rootInfo.children = rootInfoItem.items.map(infoItem => new InfoItem('AddiInfoItem', infoItem));
  2262. return rootInfo;
  2263. });
  2264. return addiInfo;
  2265. }
  2266. // 加载单位工程费用汇总
  2267. // tenderDetail 单位工程详细数据
  2268. function loadUnitWorksSummary() {
  2269. const unitWorksSummary = new UnitWorksSummary();
  2270. // 读取单位工程中的固定类别为“分部分项工程”、“措施项目”、“其他项目”的大项费用
  2271. // 分部分项
  2272. const fbfx = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.SUB_ENGINERRING);
  2273. const fbfxGroup = new UnitWorksSummaryGroup(fbfx.data);
  2274. // 分部分项工程的子项,取项目名称的首字母拼接
  2275. const fbfxChildren = fbfx.children.map(node => new UnitWorksSummaryItem(node));
  2276. fbfxGroup.children.push(...fbfxChildren);
  2277. // 措施项目
  2278. const csxm = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.MEASURE);
  2279. const csxmGroup = new UnitWorksSummaryGroup(csxm.data);
  2280. // 措施项目的子项,“绿色施工安全防护措施费”、“其他措施费”
  2281. const csxmChildren = csxm.getPosterity()
  2282. .filter(node => [fixedFlag.GREEN_MEASURE_FEE, fixedFlag.OTHER_MEASURE_FEE].includes(node.getFlag()))
  2283. .map(node => new UnitWorksSummaryItem(node));
  2284. csxmGroup.children.push(...csxmChildren);
  2285. // 其他项目
  2286. const other = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.OTHER);
  2287. const otherGroup = new UnitWorksSummaryGroup(other.data);
  2288. // 其他项目子项,暂列金额;暂估价;材料(工程设备)暂估价;专业工程暂估价;计日工;总承包服务费;预算包干费;工程优质费;概算幅度差;索赔费用;现场签证费用;其他费用
  2289. const otherChildrenFlags = [
  2290. fixedFlag.PROVISIONAL,
  2291. fixedFlag.ESTIMATE,
  2292. fixedFlag.MATERIAL_PROVISIONAL,
  2293. fixedFlag.ENGINEERING_ESITIMATE,
  2294. fixedFlag.DAYWORK,
  2295. fixedFlag.TURN_KEY_CONTRACT,
  2296. fixedFlag.BUDGET_INCLUDE_WORK_FEE,
  2297. fixedFlag.PROJECT_HIGH_QUALITY_FEE,
  2298. fixedFlag.BUDGET_ESTIMATE_DIFF,
  2299. fixedFlag.CLAIM,
  2300. fixedFlag.VISA,
  2301. fixedFlag.OTHER_FEE
  2302. ];
  2303. const otherChildren = other.getPosterity()
  2304. .filter(node => otherChildrenFlags.includes(node.getFlag()))
  2305. .map(node => new UnitWorksSummaryItem(node));
  2306. otherGroup.children.push(...otherChildren);
  2307. // 除固定类别为“分部分项工程”、“措施项目”、“其他项目”以外的大项费用,通常无子项,所以显示到Item中。(即使造价书有子项,也显示到Item中,不再列出其子项数据)
  2308. const flags = [fixedFlag.SUB_ENGINERRING, fixedFlag.MEASURE, fixedFlag.OTEHER];
  2309. const otherRoots = tenderDetail.mainTree.roots
  2310. .filter(node => !flags.includes(node.getFlag()))
  2311. .map(node => new UnitWorksSummaryItem(node));
  2312. unitWorksSummary.children.push(fbfxGroup, csxmGroup, otherGroup, ...otherRoots);
  2313. return unitWorksSummary;
  2314. }
  2315. // 加载分部分项工程
  2316. function loadDivisionalAndElementalWorks() {
  2317. const division = new DivisionalAndElementalWorks();
  2318. const subEngineering = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.SUB_ENGINERRING);
  2319. // 合计费用
  2320. const summaryCost = new SummaryOfBasicCost(tenderDetail.mainTree.items, subEngineering.data);
  2321. // 分部、分项
  2322. const fbfx = loadFBFX(subEngineering.children, BillsKind.FBFX);
  2323. division.children.push(summaryCost, ...fbfx);
  2324. return division;
  2325. }
  2326. // 加载措施项目
  2327. function loadPreliminaries() {
  2328. const preliminaries = new Preliminaries();
  2329. const measure = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.MEASURE);
  2330. // 合计费用
  2331. const summaryCost = new SummaryOfBasicCost(tenderDetail.mainTree.items, measure.data);
  2332. // 分部、分项
  2333. const fbfx = loadFBFX(measure.children, BillsKind.MEASURE);
  2334. preliminaries.children.push(summaryCost, ...fbfx);
  2335. return preliminaries;
  2336. }
  2337. // 加载分部分项清单,这部分是分部分项工程和措施项目共用的
  2338. function loadFBFX(nodes, kind) {
  2339. return nodes.map(node => {
  2340. let ele;
  2341. // 有子清单的是分部
  2342. if (node.source.children.length) {
  2343. ele = new DivisionalWorks(node.data);
  2344. const summaryCost = new SummaryOfBasicCost(tenderDetail.mainTree.items, node.data);
  2345. // 递归获取子元素
  2346. ele.children = [summaryCost, ...loadFBFX(node.children)];
  2347. } else { // 无子清单的是分项
  2348. ele = loadBills(node, kind);
  2349. }
  2350. return ele;
  2351. });
  2352. }
  2353. // 加载清单
  2354. function loadBills(node, kind) {
  2355. const specialty = Specialty[tenderDetail.projectInfo.property.engineeringName]; // 工程专业
  2356. const workElement = new WorkElement(node, kind, specialty);
  2357. // 合计费用
  2358. const summaryCost = new SummaryOfBasicCost(tenderDetail.mainTree.items, node.data);
  2359. workElement.children.push(summaryCost);
  2360. // 工程量计算表
  2361. const expressElement = loadQuantityExpressions(tenderDetail.quantity_detail.datas, true, node.data.ID);
  2362. workElement.children.push(...expressElement);
  2363. // 相同工作内容的定额进行分组
  2364. const workMap = _.groupBy(node.children, node => node.data.jobContentText || '');
  2365. const workContents = Object
  2366. .entries(workMap)
  2367. .map(([contentText, rationNodes]) => {
  2368. const workContent = new WorkContent(contentText, _util.getAggregateFee(rationNodes));
  2369. workContent.children = rationNodes.map(node => loadRation(node, kind, specialty));
  2370. return workContent;
  2371. });
  2372. workElement.children.push(...workContents);
  2373. return workElement
  2374. }
  2375. // 加载工程量计算表
  2376. function loadQuantityExpressions(quantityDetails, isBills, ID) {
  2377. if (quantityDetails.length) {
  2378. return [];
  2379. }
  2380. quantityDetails.sort((a, b) => a.seq - b.seq);
  2381. const key = isBills ? 'billID' : 'rationID';
  2382. return quantityDetails
  2383. .filter(quantityDetail => quantityDetail[key] === ID)
  2384. .map(quantityDetail => new ExpressElement(quantityDetail));
  2385. }
  2386. // 获取定额的定额库编码
  2387. function getLibCode(ration, rationLibs) {
  2388. const theLib = rationLibs.find(lib => lib.id === ration.libID);
  2389. return theLib ? theLib.libCode : '';
  2390. }
  2391. // 加载定额
  2392. function loadRation(node, kind, specialty) {
  2393. // 定额
  2394. const libCode = getLibCode(node.data, tenderDetail.projectInfo.engineeringInfo.ration_lib);
  2395. const norm = new Norm(node.data, libCode, kind, specialty);
  2396. // 工程量计算表
  2397. const expressElement = loadQuantityExpressions(tenderDetail.quantity_detail.datas, false, node.data.ID);
  2398. if (expressElement.length) {
  2399. norm.children.push(...expressElement);
  2400. }
  2401. // 触发计算程序计算,否则定额calcTemplate数据必为空
  2402. calcProgramObj.refreshCalcProgram(node, 4);
  2403. // 子目管理费
  2404. const manageFees = new ManageFees(node.data.calcTemplate);
  2405. norm.children.push(manageFees);
  2406. // 定额人材机含量明细
  2407. let rationGLJs = tenderDetail.ration_glj.datas.filter(rGLJ => rGLJ.rationID === node.data.ID);
  2408. rationGLJs = gljUtil.sortRationGLJ(rationGLJs); // 定额人材机排序
  2409. const rationGLJElements = rationGLJs
  2410. .filter(rGLJ => {
  2411. // 总消耗量为0的,不输出
  2412. const totalQuantity = gljUtil.getTotalQuantity(rGLJ, node.data, Decimal.GLJ, Decimal.QUANTITY);
  2413. const parsedTotalQuantity = parseFloat(totalQuantity);
  2414. return parsedTotalQuantity;
  2415. })
  2416. .map(rGLJ => {
  2417. const totalQuantity = gljUtil.getTotalQuantity(rGLJ, node.data, Decimal.GLJ, Decimal.QUANTITY);
  2418. return new LabourMaterialsEquipmentsMachinesElement(rGLJ, totalQuantity)
  2419. });
  2420. norm.children.push(...rationGLJElements);
  2421. // 子目单价计算(定额计算程序)
  2422. if (node.data.calcTemplate) {
  2423. const unitPriceCalculationOfItems = node.data.calcTemplate.calcItems.map(item => new UnitPriceCalculationOfItem(item));
  2424. norm.children.push(...unitPriceCalculationOfItems);
  2425. }
  2426. return norm;
  2427. }
  2428. // 递归加载标题和子目
  2429. function loadGroupAndItems(nodes, groupFactory, itemFactory) {
  2430. return nodes.map(node => {
  2431. let ele;
  2432. // 有子清单的是标题
  2433. if (node.source.children.length) {
  2434. ele = groupFactory(node);
  2435. // 递归获取子元素
  2436. ele.children = loadGroupAndItems(node.children, groupFactory, itemFactory);
  2437. } else { // 无子清单的是分项
  2438. ele = itemFactory(node);
  2439. }
  2440. return ele;
  2441. });
  2442. }
  2443. // 加载其他项目
  2444. function loadSundry() {
  2445. // 加载材料设备暂估价明细
  2446. // 业务上这个清单是使用清单基数计算得来,所以此部分读取整个单位工程下打勾暂估的材料。is_evaluate = 1
  2447. function loadProvisionalMaterialDetail(gljList) {
  2448. return gljList
  2449. .filter(glj => glj.is_evaluate)
  2450. .map(glj => {
  2451. const price = gljUtil.getGLJPrice(glj, tenderDetail.projectGLJ.datas, // 价格信息
  2452. tenderDetail.projectInfo.property.calcOptions, tenderDetail.labourCoe.datas, tenderDetail.projectInfo.property.decimal, false, _, scMathUtil);
  2453. return new ProvisionalMaterialEquipmentItem(glj, price);
  2454. });
  2455. }
  2456. const sundry = new Sundry();
  2457. // 其他项目费
  2458. debugger;
  2459. const other = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.OTHER);
  2460. const sundryCosts = new SundryItem('SundryCosts', other.data);
  2461. sundryCosts.children = loadGroupAndItems(
  2462. other.children,
  2463. (node) => new SundryCostsGroup(node),
  2464. (node) => new SundryCostsItem(node)
  2465. );
  2466. // 暂列金额
  2467. const provisional = tenderDetail.mainTree.items.find(node => node.getFlag() === fixedFlag.PROVISIONAL);
  2468. const provisionalSums = new SundryItem('ProvisionalSums', provisional.data);
  2469. provisionalSums.children = loadGroupAndItems(
  2470. provisional.children,
  2471. (node) => new ProvisionalSumsGroup(node),
  2472. (node) => new ProvisionalSumsItem(node)
  2473. );
  2474. // 材料设备暂估价
  2475. const provisionalMaterial = tenderDetail.mainTree.items.find(node => node.getFlag() === fixedFlag.MATERIAL_PROVISIONAL);
  2476. const provisionalMaterialEle = new SundryItem('ProvisionalMaterialEquipment', provisionalMaterial.data);
  2477. provisionalMaterialEle.children = loadProvisionalMaterialDetail(tenderDetail.projectGLJ.datas.gljList);
  2478. // 专业工程暂估价
  2479. const specialtyProvisionalNode = tenderDetail.mainTree.items.find(node => node.getFlag() === fixedFlag.ENGINEERING_ESITIMATE);
  2480. const specialtyProvisional = new SundryItem('SpecialtyProvisionalPrice', specialtyProvisionalNode.data);
  2481. specialtyProvisional.children = loadGroupAndItems(
  2482. specialtyProvisionalNode.children,
  2483. (node) => new SpecialtyProvisionalPriceGroup(node),
  2484. (node) => new SpecialtyProvisionalPriceItem(node)
  2485. );
  2486. // 计日工
  2487. const daywork = tenderDetail.mainTree.items.find(node => node.getFlag() === fixedFlag.DAYWORK);
  2488. const dayworkRate = new SundryItem('DayWorkRate', daywork.data);
  2489. // 计日工最多只能有两层子项
  2490. const isValidDepth = _util.validDepth(2, daywork);
  2491. if (!isValidDepth) {
  2492. _failList.push('计日工子项超过两层')
  2493. } else {
  2494. dayworkRate.children = loadGroupAndItems(
  2495. daywork.children,
  2496. (node) => new DayWorkRateGroup(node),
  2497. (node) => new DayWorkRateItem(node)
  2498. );
  2499. }
  2500. // 总承包服务费
  2501. const turnKeyContract = tenderDetail.mainTree.items.find(node => node.getFlag() === fixedFlag.TURN_KEY_CONTRACT);
  2502. const mainContractorAttendance = new SundryItem('MainContractorAttendance', turnKeyContract.data);
  2503. mainContractorAttendance.children = loadGroupAndItems(
  2504. turnKeyContract.children,
  2505. (node) => new MainContractorAttendanceGroup(node),
  2506. (node) => new MainContractorAttendanceItem(node)
  2507. );
  2508. // 索赔费用
  2509. const claim = tenderDetail.mainTree.items.find(node => node.getFlag() === fixedFlag.CLAIM);
  2510. const claimsCost = new SundryItem('ClaimsCost', claim.data);
  2511. claimsCost.children = loadGroupAndItems(
  2512. claim.children,
  2513. (node) => new ClaimVisaCostGroup('ClaimsCostGroup', node),
  2514. (node) => new ClaimVisaCostItem('ClaimsCostItem', node)
  2515. );
  2516. // 签证费用
  2517. const visa = tenderDetail.mainTree.items.find(node => node.getFlag() === fixedFlag.VISA);
  2518. const siteInstructionCost = new SundryItem('SiteInstructionCost', visa.data);
  2519. siteInstructionCost.children = loadGroupAndItems(
  2520. visa.children,
  2521. (node) => new ClaimVisaCostGroup('SiteInstructionCostGroup', node),
  2522. (node) => new ClaimVisaCostItem('SiteInstructionCostItem', node)
  2523. );
  2524. sundry.children.push(sundryCosts, provisionalSums, provisionalMaterialEle, specialtyProvisional, dayworkRate, mainContractorAttendance, claimsCost, siteInstructionCost);
  2525. return sundry;
  2526. }
  2527. // 加载税金
  2528. function loadTax() {
  2529. const tax = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.TAX);
  2530. const taxEle = new Tax('Tax', tax);
  2531. // 加载税金子项,若无税金子项,税金本身也作为子项
  2532. const taxChildren = tax.source.children.length ? tax.source.children : [tax];
  2533. taxEle.children = taxChildren.map(taxItem => new Tax('TaxItem', taxItem));
  2534. return taxEle;
  2535. }
  2536. // 加载人材机汇总
  2537. function loadGLJSummary() {
  2538. // 所有人材机
  2539. const gljList = gljUtil.sortRationGLJ(tenderDetail.projectGLJ.datas.gljList); // 汇总排序
  2540. const contractorList = tenderDetail.contractor_list.datas;
  2541. const decimalObj = tenderDetail.projectInfo.property.decimal;
  2542. // 总承包人造价信息差额调整法数据
  2543. const infoDatas = materialAdjustObj.getPirceInfoDatas(gljList, contractorList, decimalObj)
  2544. // 总承包人价格指数调整法数据
  2545. const engineeringCostNode = tenderDetail.Bills.tree.roots.find(node => node.getFlag() === fixedFlag.ENGINEERINGCOST);
  2546. const ecTotalFee = _util.getFee(engineeringCostNode.data.fees, 'common.totalFee');
  2547. const coeDatas = materialAdjustObj.getPriceCoeDatas(gljList, contractorList, ecTotalFee, decimalObj);
  2548. return gljList.map(glj => {
  2549. // 人材机
  2550. const price = gljUtil.getGLJPrice(glj, tenderDetail.projectGLJ.datas, // 价格信息
  2551. tenderDetail.projectInfo.property.calcOptions, tenderDetail.labourCoe.datas, tenderDetail.projectInfo.property.decimal, false, _, scMathUtil);
  2552. // 人材机对应的造价信息差额数据
  2553. const infoData = infoDatas.find(item => item.projectGLJID === glj.id);
  2554. // 人材机对应的价格指数数据
  2555. const coeData = coeDatas.find(item => item.projectGLJID === glj.id);
  2556. const gljEle = new LabourMaterialsEquipmentsMachinesSummary(glj, price, infoData, coeData);
  2557. // 人材机组成物
  2558. const connectKey = gljUtil.getIndex(glj, gljKeyArray);
  2559. const ratios = tenderDetail.projectGLJ.datas.mixRatioMap[connectKey] || [];
  2560. gljEle.children = ratios.map(ratio => new LabourMaterialsEquipmentsMachinesElement(ratio, ratio.consumption));
  2561. return gljEle;
  2562. });
  2563. }
  2564. // 加载评标材料
  2565. function loadBidEvaluation() {
  2566. const gljList = tenderDetail.projectGLJ.datas.gljList;
  2567. const bidEvaluationSrc = tenderDetail.bid_evaluation_list.datas;
  2568. const decimalObj = tenderDetail.projectInfo.property.decimal;
  2569. const bidEvaluationList = configMaterialObj.getBidMaterialDatas(gljList, bidEvaluationSrc, decimalObj);
  2570. return bidEvaluationList.map(glj => {
  2571. const projectGLJ = gljList.find(pGLJ => pGLJ.id === glj.projectGLJID);
  2572. if (projectGLJ) {
  2573. glj.delivery = projectGLJ.delivery;
  2574. glj.delivery_address = projectGLJ.delivery_address;
  2575. glj.originPlace = projectGLJ.originPlace;
  2576. glj.vender = projectGLJ.vender;
  2577. glj.qualityGrace = projectGLJ.qualityGrace;
  2578. }
  2579. return new BidEvaluationMainMaterial(glj);
  2580. });
  2581. }
  2582. // 返回提取的数据
  2583. return await loadData(projectData);
  2584. }
  2585. /*
  2586. * 重置工程编号,广东18 3.0的接口,导出时的文件会用到这个编号
  2587. * 因此重置工程编号后,还需要重置文件名数据
  2588. * @param {Array}codes 工程编号
  2589. * {Array}extractData 提取的数据
  2590. * @return {void}
  2591. * */
  2592. function resetContentCode(codes, extractData) {
  2593. // 提取到的数据分两种类型:
  2594. // 1.根元素为建设项目:需要修改建设项目下的单位工程元素的编码和文件名
  2595. // 2.根元素为单位工程:需要修改单位工程的编码和文件名
  2596. // 获取建设项目数据下的单位工程元素
  2597. const extractProject = extractData.find(data => data.dataType === DATA_TYPE.PROJECT);
  2598. const extractTenders = extractData.filter(data => data.dataType === DATA_TYPE.TENDER)
  2599. // 建设项目元素下建筑安装工程费元素
  2600. const projectInstallations = _util.getElementFromSrc(extractProject.data, 'ProjectInstallationWorkCost');
  2601. // 建筑安装工程费元素下单项工程元素
  2602. const sectionalWorks = projectInstallations.reduce((acc, cur) => {
  2603. const sections = _util.getElementFromSrc(cur, 'SectionalWorks');
  2604. acc.push(...sections);
  2605. return acc;
  2606. }, []);
  2607. let idx = 0;
  2608. // 单项工程
  2609. sectionalWorks.forEach(sectionalWork => {
  2610. _util.setAttr(sectionalWork, 'Number', codes[idx++]);
  2611. });
  2612. // 建筑安装工程费元素下单位工程元素, 顺序与提取的单位工程文件(extractTenders)是一一对应的
  2613. const unitWorks = sectionalWorks.reduce((acc, cur) => {
  2614. const tenders = _util.getElementFromSrc(cur, 'UnitWorks');
  2615. acc.push(...tenders);
  2616. return acc;
  2617. }, []);
  2618. unitWorks.forEach((unitWork, index) => {
  2619. // 更改编号
  2620. const code = codes[idx++];
  2621. _util.setAttr(unitWork, 'Number', code);
  2622. // 更改文件名:@_单位工程编码_单位工程名称.xml
  2623. const name = _util.getAttr(unitWork, 'Name');
  2624. const fileName = `@_${code}_${name}.xml`;
  2625. _util.setAttr(unitWork, 'FileName', fileName);
  2626. // 更改提取的单位工程详细文件的导出名称、单位工程节点编号、文件名
  2627. const extractTender = extractTenders[index];
  2628. extractTender.fileName = fileName;
  2629. const extractUnitWork = extractTender.data;
  2630. _util.setAttr(extractUnitWork, 'Number', code);
  2631. _util.setAttr(extractUnitWork, 'FileName', fileName);
  2632. });
  2633. }
  2634. /*
  2635. * 导出文件的结构逻辑,每个费用定额导出的最终文件结构要求可能不同,需要各自定义
  2636. * 广东18费用定额,由建设项目文件和若干个单位工程文件组成。存储成 XML 文件时,
  2637. * 建设项目文件应与单位工程文件分开,然后用ZIP算法技术压缩成一个后缀名为COS文件。
  2638. * 同一类型(投标、招标、控制价)的文件被包含在一个cos文件中,有多个类型的文件则多个cos文件一个个导出
  2639. * @param {Array}fileData 文件数据
  2640. * @return {void}
  2641. * */
  2642. async function saveAsFile(fileData) {
  2643. // 根据导出类型分组
  2644. const groupedData = _.groupBy(fileData, 'exportKind');
  2645. for (const exportKind in groupedData) {
  2646. const files = groupedData[exportKind];
  2647. const zip = new JSZip();
  2648. for (const file of files) {
  2649. zip.file(file.fileName, file.blob, { binary: true });
  2650. }
  2651. const zipFile = await zip.generateAsync({ type: 'blob' });
  2652. const exportKindName = _config.EXPORT_KIND_NAME[exportKind];
  2653. saveAs(zipFile, `广东标准交换数据(${exportKindName}).COS`);
  2654. }
  2655. }
  2656. return {
  2657. summaryObj,
  2658. entry,
  2659. resetContentCode,
  2660. saveAsFile
  2661. };
  2662. })();