guangdong_2018_export.js 144 KB

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