guangdong_2018_export.js 141 KB

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