exportStdInterface_gd18.js 96 KB

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