guangdong_2018_export.js 140 KB

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