exportStandardInterface.js 122 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Zhong
  6. * @date 2019/3/15
  7. * @version
  8. */
  9. /*
  10. * 数据标准接口
  11. * 导出符合标准接口要求的xml
  12. * */
  13. const XMLStandard = (function () {
  14. //费用类别:固定行ID对应
  15. const FEE_TYPE = {
  16. [fixedFlag.SUB_ENGINERRING]: '1100',
  17. [fixedFlag.MEASURE]: '1200',
  18. [fixedFlag.CONSTRUCTION_ORGANIZATION]: '120201',
  19. [fixedFlag.ORGANIZATION]: '120201',
  20. [fixedFlag.SAFETY_CONSTRUCTION]: '1204',
  21. [fixedFlag.PROJECT_COMPLETE_ARCH_FEE]: '10041',
  22. [fixedFlag.HOUSE_QUALITY_ACCEPT_FEE]: '1206',
  23. [fixedFlag.OTHER]: '1300',
  24. [fixedFlag.CHARGE]: '800',
  25. [fixedFlag.TAX]: '900',
  26. [fixedFlag.ADDED_VALUE_TAX]: '9001',
  27. [fixedFlag.ADDITIONAL_TAX]: '9002',
  28. [fixedFlag.ENVIRONMENTAL_PROTECTION_TAX]: '9003',
  29. [fixedFlag.ENGINEERINGCOST]: '1',
  30. 0: '1800', //其他未定义的大项费用
  31. };
  32. //文件类型
  33. const FILE_KIND_TEXT = {
  34. '1': '投标',
  35. '2': '招标',
  36. '3': '控制价'
  37. };
  38. //固定类别-基数映射
  39. const FlagCalcBaseMap = {
  40. [fixedFlag.SUB_ENGINERRING]: 'FBFXHJ',
  41. [fixedFlag.MEASURE]: 'CSXMHJ',
  42. [fixedFlag.CONSTRUCTION_TECH]: 'JSCSF',
  43. [fixedFlag.CONSTRUCTION_ORGANIZATION]: 'ZZCSF',
  44. [fixedFlag.Other]: 'QTXMHJ',
  45. [fixedFlag.CHARGE]: 'GF',
  46. [fixedFlag.TAX]: 'SJ',
  47. [fixedFlag.PROVISIONAL]: 'ZLJE',
  48. [fixedFlag.ENGINEERING_ESITIMATE]: 'ZYZGJ',
  49. [fixedFlag.DAYWORK]: 'JRG',
  50. [fixedFlag.TURN_KEY_CONTRACT]: 'ZCBFWF',
  51. [fixedFlag.CLAIM_VISA]: 'SPQZ',
  52. '{分部分项工程费}': fixedFlag.SUB_ENGINERRING,
  53. '{措施项目费}': fixedFlag.MEASURE,
  54. '{组织措施项目费}': fixedFlag.CONSTRUCTION_ORGANIZATION,
  55. '{技术措施项目费}': fixedFlag.CONSTRUCTION_TECH,
  56. '{安全文明施工专项费}': fixedFlag.SAFETY_CONSTRUCTION,
  57. '{其他项目费}': fixedFlag.OTHER,
  58. '{规费}': fixedFlag.CHARGE,
  59. '{税金}': fixedFlag.TAX,
  60. '{增值税}': fixedFlag.ADDED_VALUE_TAX,
  61. };
  62. //计算基础表达式映射
  63. const CalcBaseMap = {
  64. '{分部分项工程费}': 'FBFXHJ',
  65. '{措施项目费}': 'CSXMHJ',
  66. '{组织措施项目费}': 'ZZCSF',
  67. '{其他项目费}': 'QTXMHJ',
  68. '{规费}': 'GF',
  69. '{税金}': 'SJ',
  70. '{分部分项定额人工费}': 'RGF',
  71. '{分部分项定额材料费}': 'CLF',
  72. '{分部分项定额施工机具使用费}': 'JXF',
  73. '{分部分项主材费}': 'ZCF',
  74. '{分部分项人工工日}': 'GR',
  75. '{技术措施项目费}': 'JSCSF',
  76. '{技术措施项目定额人工费}': 'JSCS_RGF',
  77. '{技术措施项目定额材料费}': 'JSCS_CLF',
  78. '{技术措施项目定额施工机具使用费}': 'JSCS_JXF',
  79. '{技术措施项目主材费}': 'JSCS_ZCF',
  80. '{技术措施项目人工工日}': 'JSCS_GR',
  81. '{建筑面积}': 'JZMJ',
  82. '{人材机价差}': 'RCJJC',
  83. '{人工价差}': 'RGJC',
  84. '{材料价差}': 'CLJC',
  85. '{施工机具使用费价差}': 'JXJC',
  86. '{甲供人工费}': 'JGRGF',
  87. '{甲供材料费}': 'JGCLF',
  88. '{甲供施工机具使用费}': 'JGJXF',
  89. '{甲供主材费}': 'JGZCF',
  90. '{甲供设备费}': 'JGSBF',
  91. '{分包费}': 'FBF',
  92. '{分包定额人工费}': 'FBRGF',
  93. '{分包定额材料费}': 'FBCLF',
  94. '{分包定额机械费}': 'FBJXF',
  95. '{分包主材费}': 'FBZCF',
  96. '{分包设备费}': 'FBSBF',
  97. '{分包人工工日}': 'FBGR'
  98. };
  99. //计算基础说明映射
  100. const CalcStateMap = {
  101. 'FBFXHJ': '分部分项工程费',
  102. 'CSXMHJ': '措施项目费',
  103. 'ZZCSF': '组织措施项目费',
  104. 'QTXMHJ': '其他项目费',
  105. 'GF': '规费',
  106. 'SJ': '税金',
  107. 'RGF': '分部分项定额人工费',
  108. 'CLF': '分部分项定额材料费',
  109. 'JXF': '分部分项定额施工机具使用费',
  110. 'ZCF': '分部分项主材费',
  111. 'GR': '分部分项人工工日',
  112. 'JSCSF': '技术措施项目费',
  113. 'JSCS_RGF': '技术措施项目定额人工费',
  114. 'JSCS_CLF': '技术措施项目定额材料费',
  115. 'JSCS_JXF': '技术措施项目定额施工机具使用费',
  116. 'JSCS_ZCF': '技术措施项目主材费',
  117. 'JSCS_GR': '技术措施项目人工工日',
  118. 'JZMJ': '建筑面积',
  119. 'RCJJC': '人材机价差',
  120. 'RGJC': '人工价差',
  121. 'CLJC': '材料价差',
  122. 'JXJC': '施工机具使用费价差',
  123. 'JGRGF': '甲供人工费',
  124. 'JGCLF': '甲供材料费',
  125. 'JGJXF': '甲供施工机具使用费',
  126. 'JGZCF': '甲供主材费',
  127. 'JGSBF': '甲供设备费',
  128. 'FBF': '分包费',
  129. 'FBRGF': '分包定额人工费',
  130. 'FBCLF': '分包定额材料费',
  131. 'FBJXF': '分包定额机械费',
  132. 'FBZCF': '分包主材费',
  133. 'FBSBF': '分包设备费',
  134. 'FBGR': '分包人工工日',
  135. };
  136. // 通用设置和工具
  137. let _base = XML_EXPORT_BASE,
  138. _config = _base.CONFIG,
  139. _util = _base.UTIL,
  140. _cache = _base.CACHE;
  141. /*
  142. * 提取数据入口
  143. * @param {String}userID 用户ID
  144. * {Number}exportKind 导出类型(投标1、招标2、控制价3
  145. * {Object}projectData 项目数据(项目自身的数据、建设、单项、单位的数据(projects表的数据),不包含详细的清单定额等数据)
  146. * @return {Array} [{data: Object, exportKind: Number, fileName: String}]
  147. * */
  148. async function entry(userID, exportKind, projectData) {
  149. let _failList = _cache.getItem('failList');
  150. //建设项目定义
  151. //source:来源数据
  152. function Project(source) {
  153. let attrs = [
  154. {name: '项目编号', value: _util.getValueByKey(source.basicInformation, 'projNum'), required: true, minLen: 1, maxLen: 255,
  155. whiteSpace: _config.WHITE_SPACE.COLLAPSE},
  156. {name: '项目名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
  157. {name: '建设单位', value: _util.getValueByKey(source.basicInformation, 'constructionUnit'), required: true},
  158. {name: '标准版本号', value: '3.2.2', required: true},
  159. {name: '标准名称', value: '重庆造价软件数据交换标准(清单计价)', required: true,},
  160. {name: '文件类型', value: source.fileKind, required: true, enumeration: ['招标', '投标', '控制价', '结算', '其他']},
  161. {name: '计税方法', value: source.taxType, required: true, enumeration: ['营业税', '一般计税法', '简易计税法']},
  162. ];
  163. //唯一约束
  164. this.constraints = {
  165. engCode: [], //单项工程编号
  166. tenderCode: [], //单位工程编号
  167. billsCode: [], //清单项目项目编码(修改成了建设项目下唯一)
  168. };
  169. XML_EXPORT_BASE.Element.call(this, '标段', attrs);
  170. }
  171. //项目信息定义
  172. function ProjectInfo(source) {
  173. let attrs = [
  174. {name: '工程规模', value: _util.getValueByKey(source.basicInformation, 'projectScale'), required: true},
  175. {name: '工程所在地', value: _util.getValueByKey(source.basicInformation, 'projLocation'), required: true},
  176. {name: '工程地址', value: _util.getValueByKey(source.basicInformation, 'projAddress'), required: true},
  177. {name: '施工单位', value: _util.getValueByKey(source.basicInformation, 'buildingUnit')},
  178. {name: '编制单位', value: _util.getValueByKey(source.basicInformation, 'establishUnit'), required: true},
  179. {name: '审核单位', value: _util.getValueByKey(source.basicInformation, 'auditUnit')},
  180. {name: '编制人', value: _util.getValueByKey(source.basicInformation, 'establishUnitAuthor'), required: true},
  181. {name: '审核人', value: _util.getValueByKey(source.basicInformation, 'auditUnitAuditor')},
  182. {name: '开工日期', value: _util.getValueByKey(source.basicInformation, 'commencementDate'), type: _config.TYPE.DATE},
  183. {name: '竣工日期', value: _util.getValueByKey(source.basicInformation, 'completionDate'), type: _config.TYPE.DATE},
  184. {name: '编制日期', value: _util.getValueByKey(source.basicInformation, 'establishDate'), type: _config.TYPE.DATE, required: true},
  185. {name: '审核日期', value: _util.getValueByKey(source.basicInformation, 'auditDate'), type: _config.TYPE.DATE},
  186. {name: '材料价格期', value: _util.getValueByKey(source.basicInformation, 'materialPricePeriod'), required: true},
  187. {name: '合同价类型', value: _util.getValueByKey(source.basicInformation, 'contractPriceType')},
  188. ];
  189. XML_EXPORT_BASE.Element.call(this, '项目信息', attrs);
  190. }
  191. //招标信息定义
  192. function BiddingInfo(source) {
  193. //控制总价: 如果文件类型是“控制价”,则导出建设项目的工程造价;如果是“招标”、“投标”,则取0
  194. let attrs = [
  195. {name: '招标代理机构', value: _util.getValueByKey(source.basicInformation, 'agency')},
  196. {name: '造价工程师', value: _util.getValueByKey(source.basicInformation, 'tenderCostEngineer'), required: true},
  197. {name: '造价工程师注册证号', value: _util.getValueByKey(source.basicInformation, 'tenderingRegistrationCertificateNumber'), required: true},
  198. {name: '招标工期', value: _util.getValueByKey(source.basicInformation, 'tenderingPeriod'), required: true, type: _config.TYPE.INT},
  199. {name: '控制总价', value: exportKind === _config.EXPORT_KIND.Control ? source.summaryInfo.engineeringCost : '0',
  200. required: true, type: _config.TYPE.NUM2},
  201. ];
  202. XML_EXPORT_BASE.Element.call(this, '招标信息', attrs);
  203. }
  204. //投标信息定义
  205. function BidInfo(source) {
  206. let attrs = [
  207. {name: '投标人', value: _util.getValueByKey(source.basicInformation, 'bidder'), required: true},
  208. {name: '造价工程师', value: _util.getValueByKey(source.basicInformation, 'bidCostEngineer'), required: true},
  209. {name: '造价工程师注册证号', value: _util.getValueByKey(source.basicInformation, 'bidRegistrationCertificateNumber'), required: true},
  210. {name: '项目经理', value: _util.getValueByKey(source.basicInformation, 'projectManager')},
  211. {name: '投标工期', value: _util.getValueByKey(source.basicInformation, 'bidPeriod')},
  212. {name: '投标保证金', value: _util.getValueByKey(source.basicInformation, 'biddingMargin'), type: _config.TYPE.NUM2},
  213. {name: '质量承诺', value: _util.getValueByKey(source.basicInformation, 'qualityCommitment')},
  214. {name: '担保类型', value: _util.getValueByKey(source.basicInformation, 'guaranteeType'), enumeration: ['支票', '现金', '电汇', '汇票']},
  215. {name: '投标总价', value: source.summaryInfo.engineeringCost, required: true, type: _config.TYPE.NUM2},
  216. ];
  217. XML_EXPORT_BASE.Element.call(this, '投标信息', attrs);
  218. }
  219. //编制说明定义
  220. function CompilationIllustration(source) {
  221. let attrs = [
  222. {name: '内容', value: source.compilationIllustration, required: true},
  223. ];
  224. XML_EXPORT_BASE.Element.call(this, '编制说明', attrs);
  225. }
  226. //系统信息定义
  227. function SystemInfo(source) {
  228. let attrs = [
  229. {name: 'ID1', value: source.softInfo, required: true},
  230. {name: 'ID2', value: '', required: true},
  231. {name: '生成时间', value: source.generatedTime, type: _config.TYPE.DATE_TIME, required: true},
  232. ];
  233. XML_EXPORT_BASE.Element.call(this, '系统信息', attrs);
  234. }
  235. //费用构成定义
  236. function FeeFrom(summaryInfo) {
  237. let attrs = [
  238. {name: '工程费合计', value: exportKind === _config.EXPORT_KIND.Tender ? summaryInfo.engineeringCost : '0', required: true, type: _config.TYPE.NUM2},
  239. {name: '分部分项清单合计', value: exportKind === _config.EXPORT_KIND.Tender ? summaryInfo.subEngineering : '0', required: true, type: _config.TYPE.NUM2},
  240. {name: '措施项目清单合计', value: exportKind === _config.EXPORT_KIND.Tender ? summaryInfo.measure : '0', required: true, type: _config.TYPE.NUM2},
  241. {name: '安全文明施工专项费', value: exportKind === _config.EXPORT_KIND.Tender ? summaryInfo.safetyConstruction : '0', required: true, type: _config.TYPE.NUM2},
  242. {name: '其他项目清单合计', value: exportKind === _config.EXPORT_KIND.Tender ? summaryInfo.other : '0', required: true, type: _config.TYPE.NUM2},
  243. {name: '暂列金额合计', value: exportKind === _config.EXPORT_KIND.Tender ? summaryInfo.provisional : '0', type: _config.TYPE.NUM2},
  244. {name: '材料暂估价合计', value: exportKind === _config.EXPORT_KIND.Tender ? summaryInfo.materialProvisional : '0', type: _config.TYPE.NUM2},
  245. {name: '专业工程暂估价合计', value: exportKind === _config.EXPORT_KIND.Tender ? summaryInfo.engineeringEstimate : '0', type: _config.TYPE.NUM2},
  246. {name: '计日工合计', value: exportKind === _config.EXPORT_KIND.Tender ? summaryInfo.daywork : '0', type: _config.TYPE.NUM2},
  247. {name: '总承包服务费合计', value: exportKind === _config.EXPORT_KIND.Tender ? summaryInfo.turnKeyContract : '0', type: _config.TYPE.NUM2},
  248. {name: '签证索赔合计', value: exportKind === _config.EXPORT_KIND.Tender ? summaryInfo.claimVisa : '0', type: _config.TYPE.NUM2},
  249. {name: '规费', value: exportKind === _config.EXPORT_KIND.Tender ? summaryInfo.charge : '0', required: true, type: _config.TYPE.NUM2},
  250. {name: '税金', value: exportKind === _config.EXPORT_KIND.Tender ? summaryInfo.tax : '0', required: true, type: _config.TYPE.NUM2},
  251. ];
  252. XML_EXPORT_BASE.Element.call(this, '费用构成', attrs);
  253. }
  254. //单项工程定义
  255. function Engineering(source) {
  256. let attrs = [
  257. {name: '编号', value: '', required: true, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
  258. {name: '名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
  259. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? source.summaryInfo.engineeringCost : '0', type: _config.TYPE.NUM2},
  260. ];
  261. XML_EXPORT_BASE.Element.call(this, '单项工程', attrs);
  262. }
  263. //单位工程定义
  264. function Tender(source) {
  265. const TAX = {
  266. '1': '一般计税',
  267. '2': '简易计税',
  268. };
  269. let attrs = [
  270. {name: '编号', value: '', required: true, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
  271. {name: '名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
  272. {name: '专业', value: source.engineeringName, required: true, enumeration: [
  273. '土建工程', '装饰工程', '安装工程', '市政工程', '园林绿化工程',
  274. '仿古建筑工程', '房修工程', '轨道工程', '构筑物工程', '机械(爆破)土石方',
  275. '围墙工程', '幕墙工程', '市政安装工程', '城市轨道交通安装', '人工土石方',
  276. '房屋安装修缮工程', '房屋修缮单拆除'
  277. ]},
  278. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender
  279. ? source.summaryInfo.engineeringCost
  280. : '0', type: _config.TYPE.NUM2},
  281. {name: '定额库编码', value: source.defaultRationLibCode, enumeration: [
  282. 'CQ18TJ', 'CQ18ZS', 'CQ18AZ', 'CQ18SZ', 'CQ18YL', 'CQ18FG', 'CQ18GD', 'CQ18FS',
  283. 'CQ18LS', 'CQ18GZW', 'CQ18BP', 'CQ18ZP'
  284. ]},
  285. {name: '计税方法', value: TAX[source.taxType], required: true, enumeration: ['营业税', '一般计税', '简易计税']},
  286. ];
  287. this.constraints = {
  288. billsCode: [], //清单项目项目编码
  289. formulaMeasureNo: [], //公式计算措施项序号
  290. gljCode: [], //人材机代码
  291. provisionalDetailCode: [], //暂列金额明细编号
  292. engEstimateDetailCode: [], //专业工程暂估明细
  293. turnKeyContractCode: [], //总承包服务费费用项编号
  294. labourDayWorkCode: [], //人工计日工项目编号
  295. materialDayWorkCode: [], //材料计日工项目编号
  296. machineDayWorkCode: [], //机械计日工项目编号
  297. otherItemNo: [], //其他列项序号
  298. feeItemNo: [], //费用项序号
  299. mainBillsCode: [], //主要清单明细项目编码 (标准文件中constraint中没有定义此唯一性,但是主要清单明细的备注那里说明了,这里处理一下)
  300. appraisalDetailCode: [], //评审材料明细代码唯一(标准文件中constraint中没有定义此唯一性,但是评审材料明细的备注里说明了)
  301. };
  302. XML_EXPORT_BASE.Element.call(this, '单位工程', attrs);
  303. }
  304. //工程特征定义
  305. function EngFeature(source) {
  306. let attrs = [
  307. {name: '建筑分类', value: source.feature.buildingClass, required: true},
  308. {name: '工程分类', value: source.feature.projClass, required: true},
  309. {name: '建设规模', value: source.feature.projectScale, required: true},
  310. {name: '工程类别', value: _util.getValueByKey(source.basicInformation, 'projectCategory'), required: true} //取建设项目的工程类别
  311. ];
  312. XML_EXPORT_BASE.Element.call(this, '工程特征', attrs);
  313. }
  314. //特征项定义
  315. function FeatureItem(feature) {
  316. let attrs = [
  317. {name: '编码', value: feature.code},
  318. {name: '名称', value: feature.dispName, required: true},
  319. {name: '内容', value: feature.value, required: true},
  320. ];
  321. XML_EXPORT_BASE.Element.call(this, '特征项', attrs);
  322. }
  323. //工程信息-信息项定义
  324. function InfoItem(info) {
  325. let attrs = [
  326. {name: '编码', value: info.code, required: true},
  327. {name: '内容', value: info.value, required: true},
  328. ];
  329. XML_EXPORT_BASE.Element.call(this, '信息项', attrs);
  330. }
  331. //单位工程费汇总定义
  332. function TenderFeeSummary() {
  333. XML_EXPORT_BASE.Element.call(this, '单位工程费汇总', []);
  334. }
  335. //计价程序费用行定义
  336. function FeeRow(source) {
  337. let attrs = [
  338. {name: '序号', value: source.code},
  339. {name: '行代号', value: source.rowCode, required: true},
  340. {name: '项目名称', value: source.name, required: true},
  341. {name: '计算基础表达式', value: source.calcBase, required: true},
  342. {name: '计算基础说明', value: source.calcBaseState},
  343. {name: '费率', value: exportKind === _config.EXPORT_KIND.Tender ? source.feeRate : '100'},
  344. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.totalFee') : '0', type: _config.TYPE.NUM2},
  345. {name: '其中暂估价', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'estimate.totalFee') : '0', type: _config.TYPE.NUM2},
  346. {name: '费用类别', value: source.feeType, type: _config.TYPE.INT, required: true,
  347. enumeration: ['1100', '1200', '1204', '1300', '800', '900', '1800', '1'],
  348. failHint: `第${source.row}行清单-“费用类别”`
  349. },
  350. {name: '备注', value: source.remark},
  351. ];
  352. XML_EXPORT_BASE.Element.call(this, '计价程序费用行', attrs);
  353. }
  354. //分部分项清单
  355. function FBFXBills() {
  356. XML_EXPORT_BASE.Element.call(this, '分部分项清单', []);
  357. }
  358. //清单分部定义
  359. function FBBills(source) {
  360. let attrs = [
  361. {name: '编号', value: source.code, required: true, maxLen: 20,
  362. failHint: `第${source.row}行清单分部-“编码”`},
  363. {name: '名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE,
  364. failHint: `第${source.row}行清单分部-“名称”`},
  365. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.totalFee') : '0', required: true, type: _config.TYPE.NUM2},
  366. {name: '其中暂估价', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'estimate.totalFee') : '0', required: true},
  367. {name: '备注', value: source.remark}
  368. ];
  369. XML_EXPORT_BASE.Element.call(this, '清单分部', attrs);
  370. }
  371. //清单项目定义
  372. function FXbills(source) {
  373. let attrs = [
  374. {name: '项目编码', value: source.code, required: true, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE,
  375. failHint: `第${source.row}行清单-“编码”`},
  376. {name: '项目名称', value: source.name, required: true, minLen: 1, maxLen: 500, whiteSpace: _config.WHITE_SPACE.COLLAPSE,
  377. failHint: `第${source.row}行清单-“名称”`},
  378. {name: '单位', value: source.unit, required: true, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE,
  379. failHint: `第${source.row}行清单-“单位”`},
  380. {name: '工程量', value: source.quantity, required: true, type: _config.TYPE.DECIMAL,
  381. failHint: `第${source.row}行清单-“工程量”`},
  382. {name: '综合单价', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.unitFee') : '0', required: true,
  383. type: _config.TYPE.DECIMAL},
  384. {name: '综合合价', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.totalFee') : '0', required: true,
  385. type: _config.TYPE.NUM2},
  386. {name: '其中暂估价', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'estimate.totalFee') : '0', required: true,
  387. type: _config.TYPE.NUM2},
  388. {name: '主要清单标志', value: !!source.mainBills, type: _config.TYPE.BOOL,
  389. failHint: `第${source.row}行清单-“主要清单标志”`},
  390. {name: '暂估清单标志', value: !!source.isEstimate, type: _config.TYPE.BOOL,
  391. failHint: `第${source.row}行清单-“暂估清单标志”`},
  392. {name: '最高限价', value: source.maxPrice, type: _config.TYPE.NUM2,
  393. failHint: `第${source.row}行清单-“最高限价”`},
  394. {name: '备注', value: source.remark},
  395. ];
  396. XML_EXPORT_BASE.Element.call(this, '清单项目', attrs);
  397. }
  398. //项目特征定义
  399. function ItemCharacter() {
  400. XML_EXPORT_BASE.Element.call(this, '项目特征', []);
  401. }
  402. //特征定义
  403. function Feature(source) {
  404. let attrs = [
  405. {name: '特征名称', value: source.name, required: true},
  406. {name: '特征描述', value: source.value, required: true},
  407. ];
  408. XML_EXPORT_BASE.Element.call(this, '特征', attrs);
  409. }
  410. //工程内容定义
  411. function JobContent() {
  412. XML_EXPORT_BASE.Element.call(this, '工程内容', []);
  413. }
  414. //内容定义
  415. function Content(content) {
  416. let attrs = [
  417. {name: '内容', value: content, required: true}
  418. ];
  419. XML_EXPORT_BASE.Element.call(this, '内容', attrs);
  420. }
  421. //组价内容定义
  422. function PriceContent() {
  423. XML_EXPORT_BASE.Element.call(this, '组价内容', []);
  424. }
  425. //定额子目定义
  426. function Ration(source) {
  427. let attrs = [
  428. {name: '定额编号', value: source.viewCode, required: true, minLen: 1, maxLen: 80, whiteSpace: _config.WHITE_SPACE.COLLAPSE,
  429. failHint: `第${source.row}行定额-“编码”`},
  430. {name: '项目名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE,
  431. failHint: `第${source.row}行定额-“名称”`},
  432. {name: '单位', value: source.unit, required: true, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE,
  433. failHint: `第${source.row}行定额-“单位”`},
  434. {name: '定额库编码', value: source.libCode, required: true},
  435. {name: '原始定额编号', value: source.code, minLen: 1, maxLen: 80, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
  436. {name: '子目类型', value: source.subType, required: true, type: _config.TYPE.INT, enumeration: ['0', '1', '2', '3', '4', '5', '6']},
  437. {name: '工程量', value: source.quantity, required: true, type: _config.TYPE.DECIMAL,
  438. failHint: `第${source.row}行定额-“工程量”`},
  439. {name: '工程量计算式', value: source.quantityEXP},
  440. {name: '定额单价', value: _util.getFee(source.fees, 'rationUnitPrice.unitFee'), required: true, type: _config.TYPE.DECIMAL},
  441. {name: '定额合价', value: _util.getFee(source.fees, 'rationUnitPrice.totalFee'), required: true, type: _config.TYPE.NUM2},
  442. {name: '综合单价', value: _util.getFee(source.fees, 'common.unitFee'), required: true, type: _config.TYPE.DECIMAL},
  443. {name: '综合合价', value: _util.getFee(source.fees, 'common.totalFee'), required: true, type: _config.TYPE.NUM2},
  444. {name: '单价构成文件ID', value: source.programID, required: true, type: _config.TYPE.INT},
  445. {name: '分包标志', value: !!source.isSubcontract, type: _config.TYPE.BOOL,
  446. failHint: `第${source.row}行定额-“分包标志”`},
  447. {name: '备注', value: source.remark}
  448. ];
  449. XML_EXPORT_BASE.Element.call(this, '定额子目', attrs);
  450. }
  451. //工料分析定义
  452. function GljAnalyze() {
  453. XML_EXPORT_BASE.Element.call(this, '工料分析', []);
  454. }
  455. //人材机含量定义
  456. function GljContent(source) {
  457. let attrs = [
  458. {name: '人材机代码', value: source.code, required: true, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
  459. {name: '消耗量', value: source.quantity, required: true, type: _config.TYPE.DECIMAL},
  460. {name: '数量', value: source.totalQuantity, required: true, type: _config.TYPE.DECIMAL},
  461. {name: '数量计算方式', value: 1, required: true, type: _config.TYPE.INT, enumeration: ['1', '2']},
  462. ];
  463. XML_EXPORT_BASE.Element.call(this, '人材机含量', attrs);
  464. }
  465. //费用组成
  466. function FeeContent(source) {
  467. let attrs = [
  468. {name: '基价人工费单价', value: _util.getFee(source.fees, 'labour.unitFee'), type: _config.TYPE.DECIMAL, required: true},
  469. {name: '基价人工费合价', value: _util.getFee(source.fees, 'labour.totalFee'), type: _config.TYPE.NUM2, required: true},
  470. {name: '定额人工基价调整单价', value: 0, type: _config.TYPE.DECIMAL}, //调整价目前只有08有,默认设置成0
  471. {name: '定额人工基价调整合价', value: 0, type: _config.TYPE.NUM2},
  472. {name: '基价材料费单价', value: _util.getFee(source.fees, 'material.unitFee'), type: _config.TYPE.DECIMAL, required: true},
  473. {name: '基价材料费合价', value: _util.getFee(source.fees, 'material.totalFee'), type: _config.TYPE.NUM2, required: true},
  474. {name: '基价机械费单价', value: _util.getFee(source.fees, 'machine.unitFee'), type: _config.TYPE.DECIMAL, required: true},
  475. {name: '基价机械费合价', value: _util.getFee(source.fees, 'machine.totalFee'), type: _config.TYPE.NUM2, required: true},
  476. {name: '定额机上人工基价调整单价', value: 0, type: _config.TYPE.DECIMAL, required: true},
  477. {name: '定额机上人工基价调整合价', value: 0, type: _config.TYPE.NUM2, required: true},
  478. {name: '未计价材料单价', value: _util.getFee(source.fees, 'unratedMaterial.unitFee'), type: _config.TYPE.DECIMAL, required: true},
  479. {name: '未计价材料合价', value: _util.getFee(source.fees, 'unratedMaterial.totalFee'), type: _config.TYPE.NUM2, required: true},
  480. {name: '人材机价差单价', value: scMathUtil.roundForObj(_util.getFee(source.fees, 'labourDiff.unitFee') +
  481. _util.getFee(source.fees, 'materialDiff.unitFee') + _util.getFee(source.fees, 'machineDiff.unitFee'), 2),
  482. type: _config.TYPE.DECIMAL, required: true}, //人材机价差通过人工、材料、机械价差相加得出
  483. {name: '人材机价差合价', value: scMathUtil.roundForObj(_util.getFee(source.fees, 'labourDiff.totalFee') +
  484. _util.getFee(source.fees, 'materialDiff.totalFee') + _util.getFee(source.fees, 'machineDiff.totalFee'), 2),
  485. type: _config.TYPE.NUM2, required: true},
  486. {name: '暂估材料单价', value: _util.getFee(source.fees, 'estimate.unitFee'), type: _config.TYPE.DECIMAL, required: true},
  487. {name: '暂估材料合价', value: _util.getFee(source.fees, 'estimate.totalFee'), type: _config.TYPE.NUM2, required: true},
  488. {name: '管理费单价', value: _util.getFee(source.fees, 'manage.unitFee'), type: _config.TYPE.DECIMAL, required: true},
  489. {name: '管理费合价', value: _util.getFee(source.fees, 'manage.totalFee'), type: _config.TYPE.NUM2, required: true},
  490. {name: '利润单价', value: _util.getFee(source.fees, 'profit.unitFee'), type: _config.TYPE.DECIMAL, required: true},
  491. {name: '利润合价', value: _util.getFee(source.fees, 'profit.totalFee'), type: _config.TYPE.NUM2, required: true},
  492. {name: '风险单价', value: scMathUtil.roundForObj(_util.getFee(source.fees, 'risk.unitFee') + _util.getFee(source.fees, 'otherRisk.unitFee'), 2),
  493. type: _config.TYPE.DECIMAL, required: true}, //一般风险费单价+其他风险费单价
  494. {name: '风险合价', value: scMathUtil.roundForObj(_util.getFee(source.fees, 'risk.totalFee') + _util.getFee(source.fees, 'otherRisk.totalFee'), 2),
  495. type: _config.TYPE.NUM2, required: true},
  496. {name: '一般风险单价', value: _util.getFee(source.fees, 'risk.unitFee'), type: _config.TYPE.DECIMAL, required: true},
  497. {name: '一般风险合价', value: _util.getFee(source.fees, 'risk.totalFee'), type: _config.TYPE.NUM2, required: true},
  498. {name: '其他风险单价', value: _util.getFee(source.fees, 'otherRisk.unitFee'), type: _config.TYPE.DECIMAL, required: true},
  499. {name: '其他风险合价', value: _util.getFee(source.fees, 'otherRisk.totalFee'), type: _config.TYPE.NUM2, required: true},
  500. ];
  501. XML_EXPORT_BASE.Element.call(this, '费用组成', attrs);
  502. }
  503. //措施项目清单定义
  504. function CSXMBills(source) {
  505. let attrs = [
  506. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.totalFee') : '0',
  507. type: _config.TYPE.NUM2, required: true},
  508. {name: '其中暂估价', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'estimate.totalFee') : '0',
  509. type: _config.TYPE.NUM2, required: true},
  510. ];
  511. XML_EXPORT_BASE.Element.call(this, '措施项目清单', attrs);
  512. }
  513. //组织措施清单定义
  514. function ZZCSBills(source) {
  515. let attrs = [
  516. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.totalFee') : '0',
  517. type: _config.TYPE.NUM2, required: true},
  518. ];
  519. XML_EXPORT_BASE.Element.call(this, '组织措施清单', attrs);
  520. }
  521. //组织措施分类定义
  522. function ZZCSClass(source) {
  523. let attrs = [
  524. {name: '编码', value: source.code, maxLen: 20, required: true,
  525. failHint: `第${source.row}行组织措施清单-“编码”`},
  526. {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  527. failHint: `第${source.row}行组织措施清单-“名称”`},
  528. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.totalFee') : '0',
  529. type: _config.TYPE.NUM2, required: true},
  530. {name: '备注', value: source.remark}
  531. ];
  532. XML_EXPORT_BASE.Element.call(this, '组织措施分类', attrs);
  533. }
  534. //公式计算措施项
  535. function FormulaCalcMeasure(source) {
  536. let attrs = [
  537. {name: '序号', value: source.code, minLen: 1, maxLen:20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  538. failHint: `第${source.row}行清单-“编码”`},
  539. {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  540. failHint: `第${source.row}行清单-“名称”`},
  541. {name: '计算基础表达式', value: source.calcBase, required: true},
  542. {name: '计算基础说明', value: source.calcBaseState},
  543. {name: '费率', value: exportKind === _config.EXPORT_KIND.Tender ? source.feeRate : '0', required: true},
  544. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.totalFee') : '0', required: true},
  545. {name: '暂估价标志', value: !!source.isEstimate, type: _config.TYPE.BOOL},
  546. {name: '备注', value: source.remark},
  547. {name: '费用类别', value: source.feeType, enumeration: ['120201', '1204', '10041', '1206'], required: true,
  548. enumerationHint: ['组织措施费', '安全文明施工专项费', '建设工程竣工档案编制费', '住宅工程质量分户验收费'],
  549. failHint: `第${source.row}行清单-“固定费用类别”`},
  550. ];
  551. XML_EXPORT_BASE.Element.call(this, '公式计算措施项', attrs);
  552. }
  553. //技术措施清单定义
  554. function JSCSBills(source) {
  555. let attrs = [
  556. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.totalFee') : '0',
  557. type: _config.TYPE.NUM2, required: true},
  558. {name: '其中暂估价', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'estimate.totalFee') : '0',
  559. type: _config.TYPE.NUM2, required: true},
  560. ];
  561. XML_EXPORT_BASE.Element.call(this, '技术措施清单', attrs);
  562. }
  563. //技术措施分类
  564. function JSCSClass(source) {
  565. let attrs = [
  566. {name: '编号', value: source.code},
  567. {name: '名称', value: source.name, required: true},
  568. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.totalFee') : '0',
  569. type: _config.TYPE.NUM2, required: true},
  570. {name: '其中暂估价', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'estimate.totalFee') : '0',
  571. type: _config.TYPE.DECIMAL, required: true},
  572. ];
  573. XML_EXPORT_BASE.Element.call(this, '技术措施分类', attrs);
  574. }
  575. //其他项目清单定义
  576. function OtherBills() {
  577. XML_EXPORT_BASE.Element.call(this, '其他项目清单', []);
  578. }
  579. //暂列金额定义
  580. function Provisional(source) {
  581. let attrs = [
  582. {name: '金额', value: _util.getFee(source.fees, 'common.totalFee'), type: _config.TYPE.NUM2}
  583. ];
  584. XML_EXPORT_BASE.Element.call(this, '暂列金额', attrs);
  585. }
  586. //暂列金额明细定义
  587. function ProvisionalDetail(source) {
  588. let attrs = [
  589. {name: '编号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  590. failHint: `第${source.row}行暂列金额清单-“编码”`},
  591. {name: '项目名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  592. failHint: `第${source.row}行暂列金额清单-“名称”`},
  593. {name: '计量单位', value: source.unit, maxLen: 20, required: true,
  594. failHint: `第${source.row}行暂列金额清单-“单位”`},
  595. {name: '金额', value: _util.getFee(source.fees, 'common.totalFee'),
  596. type: _config.TYPE.NUM2, required: true},
  597. {name: '备注', value: source.remark, required: true}
  598. ];
  599. XML_EXPORT_BASE.Element.call(this, '暂列金额明细', attrs);
  600. }
  601. //专业工程暂估价定义
  602. function EngEstimate(source) {
  603. let attrs = [
  604. {name: '金额', value: _util.getFee(source.fees, 'common.totalFee')}
  605. ];
  606. XML_EXPORT_BASE.Element.call(this, '专业工程暂估价', attrs);
  607. }
  608. //专业工程暂估明细定义
  609. function EngEstimateDetail(source) {
  610. let attrs = [
  611. {name: '编号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  612. failHint: `第${source.row}行专业工程暂估清单-“编码”`},
  613. {name: '工程名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  614. failHint: `第${source.row}行专业工程暂估清单-“名称”`},
  615. {name: '工程内容', value: source.engineeringContent, maxLen: 2000, required: true,
  616. failHint: `第${source.row}行专业工程暂估清单-“工程内容”`},
  617. {name: '金额', value: _util.getFee(source.fees, 'common.totalFee'),
  618. type: _config.TYPE.NUM2, required: true},
  619. {name: '备注', value: source.remark, required: true}
  620. ];
  621. XML_EXPORT_BASE.Element.call(this, '专业工程暂估明细', attrs);
  622. }
  623. //计日工定义
  624. function DayWork(source) {
  625. let attrs = [
  626. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.totalFee') : '0'}
  627. ];
  628. XML_EXPORT_BASE.Element.call(this, '计日工', attrs);
  629. }
  630. //人工定义
  631. function Labour() {
  632. XML_EXPORT_BASE.Element.call(this, '人工', []);
  633. }
  634. //材料定义
  635. function Material() {
  636. XML_EXPORT_BASE.Element.call(this, '材料', []);
  637. }
  638. //施工机械定义
  639. function Machine() {
  640. XML_EXPORT_BASE.Element.call(this, '施工机械', []);
  641. }
  642. //计日工项目定义
  643. function DayWorkItem(source) {
  644. let attrs = [
  645. {name: '编号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  646. failHint: `第${source.row}行计日工清单-“编码”`},
  647. {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  648. failHint: `第${source.row}行计日工清单-“名称”`},
  649. {name: '单位', value: source.unit, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  650. failHint: `第${source.row}行计日工清单-“单位”`},
  651. {name: '数量', value: source.quantity, type: _config.TYPE.DECIMAL, required: true},
  652. {name: '综合单价', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.unitFee') : '0',
  653. type: _config.TYPE.DECIMAL, required: true},
  654. {name: '综合合价', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.totalFee') : '0',
  655. type: _config.TYPE.NUM2, required: true},
  656. {name: '备注', value: source.remark}
  657. ];
  658. XML_EXPORT_BASE.Element.call(this, '计日工项目', attrs);
  659. }
  660. //总承包服务费定义
  661. function TurnKeyContract(source) {
  662. let attrs = [
  663. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.totalFee') : '0', type: _config.TYPE.NUM2}
  664. ];
  665. XML_EXPORT_BASE.Element.call(this, '总承包服务费', attrs);
  666. }
  667. //总承包服务费分类定义
  668. function TurnKeyContractClass(source) {
  669. let attrs = [
  670. {name:'编号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE,
  671. failHint: `第${source.row}行承包服务费清单-“编码”`},
  672. {name:'名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  673. failHint: `第${source.row}行承包服务费清单-“名称”`},
  674. {name:'备注', value: source.remark}
  675. ];
  676. XML_EXPORT_BASE.Element.call(this, '总承包服务费分类', attrs);
  677. }
  678. //总承包服务费费用项定义
  679. function TurnKeyContractItem(source) {
  680. let attrs = [
  681. {name: '编号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  682. failHint: `第${source.row}行承包服务费清单-“编码”`},
  683. {name: '工程名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  684. failHint: `第${source.row}行承包服务费清单-“名称”`},
  685. {name: '计算基础', value: exportKind === _config.EXPORT_KIND.Tender ? source.calcBaseValue : '', type: _config.TYPE.DECIMAL, required: true},
  686. {name: '服务内容', value: source.serviceContent, maxLen: 255, required: true,
  687. failHint: `第${source.row}行承包服务费清单-“服务内容”`},
  688. {name: '费率', value: exportKind === _config.EXPORT_KIND.Tender ? source.feeRate : '0', type: _config.TYPE.DECIMAL, required: true},
  689. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.totalFee') : '0', type: _config.TYPE.NUM2, required: true},
  690. {name: '备注', value: source.remark}
  691. ];
  692. XML_EXPORT_BASE.Element.call(this, '总承包服务费费用项', attrs);
  693. }
  694. //签证索赔计价汇总费用项
  695. function ClaimVisaFeeItem(source) {
  696. let attrs = [
  697. {name: '编号', value: source.code, required: true},
  698. {name: '项目名称', value: source.name, required: true},
  699. {name: '计量单位', value: source.unit, required: true},
  700. {name: '数量', value: source.quantity, type: _config.TYPE.DECIMAL, required: true},
  701. {name: '单价', value: _util.getFee(source.fees, 'common.unitFee'),
  702. type: _config.TYPE.DECIMAL, required: true},
  703. {name: '合价', value: _util.getFee(source.fees, 'common.totalFee'),
  704. type: _config.TYPE.NUM2, required: true},
  705. {name: '依据', value: source.claimVisa, required: true},
  706. ];
  707. XML_EXPORT_BASE.Element.call(this, '签证索赔计价汇总费用项', attrs);
  708. }
  709. //其他定义
  710. function Other(source) {
  711. let attrs = [
  712. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? source.commonTotalFee : '0', type: _config.TYPE.NUM2}
  713. ];
  714. XML_EXPORT_BASE.Element.call(this, '其他', attrs);
  715. }
  716. //其他列项定义
  717. function OtherItem(source) {
  718. let attrs = [
  719. {name: '序号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  720. failHint: `第${source.row}行清单-“编码”`},
  721. {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  722. failHint: `第${source.row}行清单-“名称”`},
  723. {name: '计算基础', value: exportKind === _config.EXPORT_KIND.Tender ? source.calcBase : '', maxLen: 255,
  724. failHint: `第${source.row}行清单-“计算基础”`},
  725. {name: '费率', value: exportKind === _config.EXPORT_KIND.Tender ? source.feeRate : '100', type: _config.TYPE.DECIMAL},
  726. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? source.commonTotalFee : '0', type: _config.TYPE.NUM2, required: true},
  727. {name: '不计入合价标志', value: source.notSummray, type: _config.TYPE.BOOL},
  728. {name: '招标人标志', value: false, type: _config.TYPE.BOOL},
  729. {name: '备注', value: source.remark, maxLen: 255}
  730. ];
  731. XML_EXPORT_BASE.Element.call(this, '其他列项', attrs);
  732. }
  733. //规费和税金清单定义
  734. function ChargeTaxBills() {
  735. XML_EXPORT_BASE.Element.call(this, '规费和税金清单', []);
  736. }
  737. //费用项定义
  738. function FeeItem(source) {
  739. let attrs = [
  740. {name: '序号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  741. failHint: `第${source.row}行清单-“编号”`},
  742. {name: '行代号', value: source.rowCode, maxLen: 20, required: true},
  743. {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  744. failHint: `第${source.row}行清单-“名称”`},
  745. {name: '计算基础表达式', value: source.calcBase, maxLen: 255, required: true,
  746. failHint: `第${source.row}行清单-“计算基础表达式”`},
  747. {name: '计算基础说明', value: source.calcBaseState, maxLen: 255},
  748. {name: '费率', value: exportKind === _config.EXPORT_KIND.Tender ? source.feeRate : '0', type: _config.TYPE.DECIMAL, required: true},
  749. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(source.fees, 'common.totalFee') : '0', type: _config.TYPE.NUM2, required: true},
  750. {name: '费用类别', value: source.feeType, enumeration: ['800', '900', '9001', '9002', '9003'], required: true,
  751. enumerationHint: ['规费', '税金', '增值税', '附加税', '环境保护税'],
  752. failHint: `第${source.row}行清单-“固定费用类别”`},
  753. {name: '备注', value: source.remark, maxLen: 255}
  754. ];
  755. XML_EXPORT_BASE.Element.call(this, '费用项', attrs);
  756. }
  757. //承包人材料差额法表
  758. function DifferentiaGlj() {
  759. XML_EXPORT_BASE.Element.call(this, '承包人材料差额法表', []);
  760. }
  761. //承包人材料差额法明细
  762. //如果是“控制价”、“招标”,则不导出;
  763. //如果是“投标”,且采用了信息价差额法,则导出;如果采用了指数法,则导出,但数量、风险系数、基准单价、投标单价,都取0。
  764. function DifferentiaGljDetail(adjustType, source) {
  765. let attrs = [
  766. {name: '关联材料号', value: getGljCode(source.id), minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  767. {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  768. {name: '规格', value: source.specs, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
  769. {name: '单位', value: source.unit, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  770. {name: '数量', value: adjustType === _config.ADJUST_TYPE.info ? source.quantity : '0', type: _config.TYPE.DECIMAL, required: true},
  771. {name: '风险系数', value: adjustType === _config.ADJUST_TYPE.info ? source.riskCoe : '0', type: _config.TYPE.DECIMAL, require: true},
  772. {name: '基准单价', value: source.standardPrice, type: _config.TYPE.DECIMAL, require: true},
  773. {name: '投标单价', value: adjustType === _config.ADJUST_TYPE.info ? source.marketPrice : '0', type: _config.TYPE.DECIMAL},
  774. {name: '确认单价', value: '0', type: _config.TYPE.DECIMAL},
  775. {name: '备注', value: source.remark, maxLen: 255,
  776. failHint: `承包人材料${source.code}-“备注”`},
  777. ];
  778. XML_EXPORT_BASE.Element.call(this, '承包人材料差额法明细', attrs);
  779. }
  780. //承包人材料指数法表
  781. function ExponentialGlj(fixedWeight) {
  782. let attrs = [
  783. {name: '定值权重A', value: fixedWeight, required: true, type: _config.TYPE.DECIMAL}
  784. ];
  785. XML_EXPORT_BASE.Element.call(this, '承包人材料指数法表', attrs);
  786. }
  787. //承包人材料指数法明细
  788. //如果是“控制价”、“招标”,则不导出;
  789. //如果是“投标”,且采用了指数法,则导出;如果采用了信息价差额法,则导出,但定值权重A取1,变值权重B、基本价格指数、现行价格指数取0。
  790. function ExponentialGljDetail(adjustType, source) {
  791. let attrs = [
  792. {name: '关联材料号', value: getGljCode(source.id), minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  793. {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  794. {name: '规格', value: source.specs, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
  795. {name: '变值权重B', value: adjustType === _config.ADJUST_TYPE.coe ? source.varWeight : '0', type: _config.TYPE.DECIMAL, required: true},
  796. {name: '基本价格指数', value: adjustType === _config.ADJUST_TYPE.coe ? source.FO : '0', type: _config.TYPE.DECIMAL, require: true},
  797. {name: '现行价格指数', value: adjustType === _config.ADJUST_TYPE.coe ? source.FI : '0', type: _config.TYPE.DECIMAL, require: true},
  798. {name: '备注', value: source.remark, maxLen: 255,
  799. failHint: `承包人材料${source.code}-“备注”`},
  800. ];
  801. XML_EXPORT_BASE.Element.call(this, '承包人材料指数法明细', attrs);
  802. }
  803. //人材机汇总定义
  804. function GljSummary() {
  805. XML_EXPORT_BASE.Element.call(this, '人材机汇总', []);
  806. }
  807. //人材机定义
  808. function Glj(source) {
  809. let attrs = [
  810. {name: '代码', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  811. failHint: `人材机${source.orgCode}-“编码”`},
  812. {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  813. failHint: `人材机${source.orgCode}-“名称”`},
  814. {name: '规格', value: source.specs, maxLen: 255,
  815. failHint: `人材机${source.orgCode}-“规格”`},
  816. {name: '单位', value: source.unit, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true,
  817. failHint: `人材机${source.orgCode}-“单位”`},
  818. {name: '原始代码', value: source.orgCode, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
  819. {name: '费用类别', value: source.feeType, enumeration: ['1', '2', '3', '4'], required: true},
  820. {name: '配比类别', value: source.ratioType, type: _config.TYPE.INT},
  821. {name: '主要材料类别', value: source.mainMaterialType, type: _config.TYPE.INT},
  822. {name: '主要材料单位系数', value: source.materialCoe, type: _config.TYPE.DECIMAL},
  823. {name: '材料耗用类型', value: 0, type: _config.TYPE.INT, required: true},
  824. {name: '供应方式', value: source.supply, type: _config.TYPE.INT, enumeration: ['1', '2']},
  825. {name: '暂估材料标志', value: source.is_evaluate, type: _config.TYPE.BOOL},
  826. {name: '不计税设备标志', value: source.no_tax_eqp, type: _config.TYPE.BOOL, required: true},
  827. {name: '单价不从明细汇总标志', value: source.notFromDetail, type: _config.TYPE.BOOL},
  828. {name: '定额价', value: source.basePrice, type: _config.TYPE.DECIMAL, required: true},
  829. {name: '定额价调整', value: source.adjPrice, type: _config.TYPE.DECIMAL, required: true},
  830. {name: '市场价', value: source.marketPrice, type: _config.TYPE.DECIMAL, required: true},
  831. {name: '数量', value: source.quantity, type: _config.TYPE.DECIMAL, required: true},
  832. {name: '产地', value: source.originPlace, maxLen: 255,
  833. failHint: `人材机${source.orgCode}-“产地”`},
  834. {name: '厂家', value: source.vender, maxLen: 255,
  835. failHint: `人材机${source.orgCode}-“厂家”`},
  836. {name: '质量等级', value: source.qualityGrace, maxLen: 255,
  837. failHint: `人材机${source.orgCode}-“质量等级”`},
  838. {name: '品牌', value: source.brand, maxLen: 255,
  839. failHint: `人材机${source.orgCode}-“品牌”`},
  840. {name: '备注', value: source.remark, maxLen: 255,
  841. failHint: `人材机${source.orgCode}-“备注”`},
  842. ];
  843. XML_EXPORT_BASE.Element.call(this, '人材机', attrs);
  844. }
  845. //人材机配比定义
  846. function GljRatio(source) {
  847. let attrs = [
  848. {name: '明细材料代码', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  849. {name: '数量', value: source.quantity, type: _config.TYPE.DECIMAL, required: true}
  850. ];
  851. XML_EXPORT_BASE.Element.call(this, '人材机配比', attrs);
  852. }
  853. //评标材料表定义
  854. function EvalBidMaterial() {
  855. XML_EXPORT_BASE.Element.call(this, '评标材料表', []);
  856. }
  857. //暂估价材料表定义
  858. function EvalEstimateMaterial() {
  859. XML_EXPORT_BASE.Element.call(this, '暂估价材料表', []);
  860. }
  861. //材料明细定义
  862. function MaterialDetail(source) {
  863. let attrs = [
  864. {name: '序号', value: source.serialNo, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  865. {name: '关联材料号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
  866. {name: '材料名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  867. {name: '规格型号', value: source.specs, maxLen: 255},
  868. {name: '计量单位', value: source.unit, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  869. {name: '数量', value: source.quantity, type: _config.TYPE.DECIMAL},
  870. {name: '单价', value: source.marketPrice, type: _config.TYPE.DECIMAL},
  871. {name: '合价', value: source.totalPrice, type: _config.TYPE.NUM2},
  872. {name: '产地', value: source.originPlace, maxLen: 255},
  873. {name: '厂家', value: source.vender, maxLen: 255},
  874. {name: '品牌', value: source.brand, maxLen: 255},
  875. {name: '质量等级', value: source.qualityGrace, maxLen: 255},
  876. {name: '备注', value: source.remark, maxLen: 255},
  877. ];
  878. XML_EXPORT_BASE.Element.call(this, '材料明细', attrs);
  879. }
  880. //清单综合单价计算程序定义
  881. function CalcProgram() {
  882. XML_EXPORT_BASE.Element.call(this, '清单综合单价计算程序', []);
  883. }
  884. //综合单价计算程序文件定义
  885. function CalcProgramFile(source) {
  886. let attrs = [
  887. {name: 'ID', value: source.ID, type: _config.TYPE.INT, required: true},
  888. {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true}
  889. ];
  890. XML_EXPORT_BASE.Element.call(this, '综合单价计算程序文件', attrs);
  891. }
  892. //综合单价计算程序费用项定义
  893. function CalcProgramFeeItem(source) {
  894. let attrs = [
  895. {name: '序号', value: source.serialNo, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE},
  896. {name: '行代号', value: source.rowCode, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  897. {name: '项目名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  898. {name: '计算基础表达式', value: source.calcBase, maxLen: 255, required: true},
  899. {name: '计算基础说明', value: source.statement, maxLen: 255},
  900. {name: '费率', value: source.feeRate, type: _config.TYPE.DECIMAL},
  901. {name: '费用类别', value: source.feeType, type: _config.TYPE.INT, required: true},
  902. {name: '备注', value: source.remark, maxLen: 255},
  903. ];
  904. XML_EXPORT_BASE.Element.call(this, '综合单价计算程序费用项', attrs);
  905. }
  906. //主要清单汇总定义
  907. function MainBillsSummary() {
  908. XML_EXPORT_BASE.Element.call(this, '主要清单汇总', []);
  909. }
  910. //主要清单明细定义
  911. function MainBillsItem(source) {
  912. let attrs = [
  913. {name: '项目编码', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  914. {name: '项目名称', value: source.name, minLen: 1, maxLen: 500, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  915. {name: '单位', value: source.unit, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  916. {name: '工程量', value: source.quantity, type: _config.TYPE.DECIMAL, required: true},
  917. {name: '综合单价', value: _util.getFee(source.fees, 'common.unitFee'), type: _config.TYPE.DECIMAL, required: true},
  918. {name: '综合合价', value: _util.getFee(source.fees, 'common.totalFee'), type: _config.TYPE.NUM2, required: true},
  919. {name: '其中暂估价', value: _util.getFee(source.fees, 'estimate.totalFee'), type: _config.TYPE.DECIMAL},
  920. {name: '备注', value: source.remark, maxLen: 255},
  921. ];
  922. XML_EXPORT_BASE.Element.call(this, '主要清单明细', attrs);
  923. }
  924. //评审材料汇总定义
  925. function AppraisalSummary(){
  926. XML_EXPORT_BASE.Element.call(this, '评审材料汇总', []);
  927. }
  928. //评审材料明细定义
  929. function AppraisalDetail(source) {
  930. let attrs = [
  931. {name: '代码', value: source.code, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  932. {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  933. {name: '规格', value: source.specs, maxLen: 255},
  934. {name: '单位', value: source.unit, minLen: 1, maxLen: 20, whiteSpace: _config.WHITE_SPACE.COLLAPSE, required: true},
  935. {name: '市场价', value: source.marketPrice, type: _config.TYPE.DECIMAL, required: true}
  936. ];
  937. XML_EXPORT_BASE.Element.call(this, '评审材料明细', attrs);
  938. }
  939. //目前的数据
  940. let curProjectEle = null, //建设项目节点
  941. curTenderEle = null; //单位工程节点
  942. // 获取需要导出的项目数据
  943. //@param {Number}tenderID(当前界面的单位工程ID,后台根据这个单位工程,去找其建设项目下所有数据)
  944. //@return {Object}(eleObj)
  945. async function loadProject(projectData) {
  946. // 标记自检提示的开始(一次性多出多个文件类型,会导出多次)
  947. _failList.push(_config.HINT_START);
  948. console.log(projectData);
  949. //标段
  950. let project = new Project({
  951. basicInformation: projectData.property.basicInformation,
  952. name: projectData.name,
  953. fileKind: FILE_KIND_TEXT[exportKind],
  954. taxType: projectData.property.taxType ? _config.TAX_TYPE[projectData.property.taxType] : ''
  955. });
  956. curProjectEle = project;
  957. //项目信息
  958. let projectInfo = new ProjectInfo({basicInformation: projectData.property.basicInformation});
  959. project.children.push(projectInfo);
  960. //招标信息
  961. let biddingInfo = new BiddingInfo({basicInformation: projectData.property.basicInformation, summaryInfo: projectData.summaryInfo[projectData.ID]});
  962. projectInfo.children.push(biddingInfo);
  963. //投标信息 导出类型为投标时,才导出
  964. if (exportKind === _config.EXPORT_KIND.Tender) {
  965. let bidInfo = new BidInfo({basicInformation: projectData.property.basicInformation, summaryInfo: projectData.summaryInfo[projectData.ID]});
  966. projectInfo.children.push(bidInfo);
  967. }
  968. //编制说明
  969. let compilationIll = new CompilationIllustration({compilationIllustration: projectData.property.compilationIllustration});
  970. project.children.push(compilationIll);
  971. //系统信息
  972. let generatedTime = moment(Date.now()).format('YYYY-MM-DDTHH:mm:ss'),
  973. sysInfoSource = {softInfo: projectData.softInfo, generatedTime},
  974. sysInfo = new SystemInfo(sysInfoSource);
  975. project.children.push(sysInfo);
  976. //费用构成
  977. let feeForm = new FeeFrom(projectData.summaryInfo[projectData.ID]);
  978. project.children.push(feeForm);
  979. //主要清单汇总 主要清单明细在loadTender中设置
  980. let mainBillsSummaryEle = new MainBillsSummary();
  981. project.children.unshift(mainBillsSummaryEle); //必须要排在loadTender前,这样才能添加到明细数据
  982. //评审材料汇总 评审材料明细在loadTender中设置
  983. let appraisalSummary = new AppraisalSummary();
  984. project.children.unshift(appraisalSummary);
  985. //单项工程
  986. for (let eng of projectData.children) {
  987. let engElement = await loadEngineering(projectData.summaryInfo, eng);
  988. project.children.push(engElement);
  989. }
  990. //主要清单汇总、评审材料汇总 排在后面
  991. project.children = [...project.children.slice(2), mainBillsSummaryEle, appraisalSummary];
  992. return [{
  993. data: project,
  994. exportKind: exportKind,
  995. fileName: `重庆标准交换数据(${FILE_KIND_TEXT[exportKind]}).QTF`
  996. }];
  997. }
  998. //单位工程内的人材机ID: 用于代码映射关系 //单位工程级别,C+数组下标 <==> gljID
  999. let tenderGljs = [];
  1000. //获取人材机代码,eg: C0, C1....
  1001. function getGljCode(gljID) {
  1002. let idx = tenderGljs.findIndex(ID => ID === gljID);
  1003. if (~idx) {
  1004. return `C${idx}`;
  1005. }
  1006. tenderGljs.push(gljID);
  1007. return `C${tenderGljs.length - 1}`;
  1008. }
  1009. /*
  1010. * 加载单项工程数据
  1011. * @param {Object}summaryInfo(项目汇总信息映射) {Object}engData(单项工程数据)
  1012. * */
  1013. async function loadEngineering(summaryInfo, engData) {
  1014. let source = {summaryInfo: summaryInfo[engData.ID], name: engData.name};
  1015. let engineering = new Engineering(source);
  1016. //费用构成
  1017. let feeForm = new FeeFrom(summaryInfo[engData.ID]);
  1018. engineering.children.push(feeForm);
  1019. //分批次获取单位工程
  1020. let tenderDetailMap = _cache.getItem('tenderDetailMap');
  1021. for (let tenderData of engData.children) {
  1022. //需要请求项目详细数据的时候,间隔一段时间再初始单位工程数据,减少服务器压力
  1023. if (!tenderDetailMap[tenderData.ID]) {
  1024. await _util.setTimeoutSync(() => {}, _config.TIMEOUT_TIME);
  1025. }
  1026. //方便用户看错误来自哪个单位工程
  1027. _failList.push(`<span style="font-weight: bold">单位工程“${tenderData.name}”下:</span>`);
  1028. let orgLen = _failList.length;
  1029. let tender = await loadTender(summaryInfo, tenderData);
  1030. if (_failList.length === orgLen) { //只有上方的提示,说明该单位工程没有报错
  1031. _failList.pop();
  1032. }
  1033. tenderGljs = []; //清空单位工程内所有的人材机(ID)
  1034. engineering.children.push(tender);
  1035. }
  1036. return engineering;
  1037. }
  1038. /*
  1039. * 加载单位工程数据
  1040. * @param {Object}summaryInfo(项目汇总信息映射) {Object}tenderData(单位工程数据)
  1041. * @return {Object}
  1042. * */
  1043. async function loadTender(summaryInfo, tenderData) {
  1044. //获取单位工程详细数据
  1045. let tenderDetail = await _util.getTenderDetail(tenderData.ID, userID);
  1046. //设置定额库编码
  1047. tenderDetail.rationLibMap = {};
  1048. let defaultLib = null;
  1049. if (tenderDetail.projectInfo.engineeringInfo && Array.isArray(tenderDetail.projectInfo.engineeringInfo.ration_lib)) {
  1050. defaultLib = tenderDetail.projectInfo.engineeringInfo.ration_lib.find(data => data.isDefault);
  1051. for (let lib of tenderDetail.projectInfo.engineeringInfo.ration_lib) {
  1052. tenderDetail.rationLibMap[lib.id] = lib;
  1053. }
  1054. }
  1055. //初始化项目人材机代号(人材机生成的代号要由排序后的项目人材机从C0开始生成),定额下的人材机含量提前使用到了这个代码,所以需要先初始化
  1056. let allGljs = gljUtil.sortRationGLJ(tenderDetail.projectGLJ.datas.gljList); //人材机汇总排序
  1057. tenderGljs = allGljs.map(glj => glj.id);
  1058. //单位工程
  1059. let tenderSource = {
  1060. name: tenderData.name,
  1061. engineeringName: tenderData.property.engineeringName,
  1062. summaryInfo: summaryInfo[tenderData.ID],
  1063. defaultRationLibCode: defaultLib.libCode,
  1064. taxType: tenderData.property.taxType
  1065. };
  1066. let tender = curTenderEle = new Tender(tenderSource);
  1067. //工程特征
  1068. let featureObj = _util.arrayToObj(tenderData.property.projectFeature);
  1069. let engFeature = new EngFeature({feature:featureObj, basicInformation: tenderDetail.projectInfo.property.basicInformation});
  1070. tender.children.push(engFeature);
  1071. //特征项:每一项工程特征
  1072. for (let data of tenderData.property.projectFeature) {
  1073. let featureItem = new FeatureItem(data);
  1074. engFeature.children.push(featureItem);
  1075. }
  1076. //工程信息 : 筛选设置了编码的基本信息数据
  1077. let constructInfo = new XML_EXPORT_BASE.Element('工程信息', []);
  1078. tenderDetail.projectInfo.property.basicInformation.forEach(pItem => {
  1079. pItem.items.forEach(info => {
  1080. if (info.code) {
  1081. constructInfo.children.push(new InfoItem(info));
  1082. }
  1083. });
  1084. });
  1085. if (constructInfo.children.length) {
  1086. tender.children.push(constructInfo)
  1087. }
  1088. //单位工程费汇总
  1089. tender.children.push(loadDXFY(tenderDetail));
  1090. //分部分项清单
  1091. tender.children.push(loadFBFX(tenderDetail));
  1092. //措施项目清单
  1093. tender.children.push(loadCSXM(tenderDetail));
  1094. //其他项目清单
  1095. let other = loadOtherBills(tenderDetail);
  1096. if (other) {
  1097. tender.children.push(other);
  1098. }
  1099. //规费和税金清单
  1100. let chargeTax = loadChargeTax(tenderDetail);
  1101. tender.children.push(chargeTax);
  1102. //建设项目下评审材料汇总设置评审材料明细
  1103. let curAppraisalSummary = curProjectEle.children.find(ele => ele.name === '评审材料汇总');
  1104. //人材机汇总相关
  1105. let gljSumarryInfo = loadGlj(curAppraisalSummary, tenderDetail);
  1106. if (gljSumarryInfo) {
  1107. //投标导出承包人材料相关
  1108. if (exportKind === _config.EXPORT_KIND.Tender) {
  1109. let adjustType = tenderData.property.gljAdjustType || _config.ADJUST_TYPE.info;
  1110. //承包人材料差额法表
  1111. let diffGljs = materialAdjustObj.getPirceInfoDatas(tenderDetail.projectGLJ.datas.gljList);
  1112. if (diffGljs.length) {
  1113. let diffP = new DifferentiaGlj();
  1114. diffGljs.forEach(data => diffP.children.push(new DifferentiaGljDetail(adjustType, data)));
  1115. tender.children.push(diffP);
  1116. }
  1117. //承包人材料指数法表
  1118. let engineeringCostNode = tenderDetail.Bills.tree.roots.find(node => node.getFlag() === fixedFlag.ENGINEERINGCOST);
  1119. if (engineeringCostNode) {
  1120. let ecTotalFee = _util.getFee(engineeringCostNode.data.fees, 'common.totalFee');
  1121. let exponentialGljs = materialAdjustObj.getPriceCoeDatas(tenderDetail.projectGLJ.datas.gljList, ecTotalFee);
  1122. if (exponentialGljs.length) {
  1123. // 变值权重B累加
  1124. let totalVarWeight = exponentialGljs.reduce((acc, cur) => acc += cur.varWeight || 0, 0);
  1125. // 如果采用指数法,定值权重A = 1 - 变值权重B累加。如果不是指数法,取1
  1126. let fixedWeight = adjustType === _config.ADJUST_TYPE.coe ? 1 - totalVarWeight : '1';
  1127. let exP = new ExponentialGlj(fixedWeight);
  1128. exponentialGljs.forEach(data => {
  1129. exP.children.push(new ExponentialGljDetail(adjustType, data));
  1130. });
  1131. tender.children.push(exP);
  1132. }
  1133. }
  1134. }
  1135. let {gljSummary, evalBidMaterial, evalEstimateMaterial} = gljSumarryInfo;
  1136. //投标导出人材机汇总
  1137. if (exportKind === _config.EXPORT_KIND.Tender) {
  1138. tender.children.push(gljSummary);
  1139. }
  1140. //评标材料表
  1141. if (evalBidMaterial && evalBidMaterial.children.length) {
  1142. tender.children.push(evalBidMaterial);
  1143. }
  1144. //暂估价材料表
  1145. if (evalEstimateMaterial && evalEstimateMaterial.children.length) {
  1146. tender.children.push(evalEstimateMaterial);
  1147. }
  1148. }
  1149. //清单综合单价计算程序
  1150. let calcProgram = loadCalcProgram(tenderDetail);
  1151. if (calcProgram) {
  1152. tender.children.push(calcProgram);
  1153. }
  1154. //给建设项目下主要清单汇总设置主要清单明细
  1155. let curMainBillsSummary = curProjectEle.children.find(ele => ele.name === '主要清单汇总');
  1156. if (curMainBillsSummary) {
  1157. loadMainBillsItems(curMainBillsSummary, tenderDetail);
  1158. }
  1159. return tender;
  1160. }
  1161. /*
  1162. * 加载计算程序费用行
  1163. * @param {Object}detail(单位工程的详细数据,清单定额等等)
  1164. * @return {Object}
  1165. * */
  1166. function loadDXFY(detail) {
  1167. //单位工程费汇总
  1168. let tenderFeeSummary = new TenderFeeSummary();
  1169. //计价程序费用行,筛选大项费用
  1170. let feeNodes = detail.Bills.tree.roots;
  1171. for (let node of feeNodes) {
  1172. let mainTreeNode = detail.mainTree.getNodeByID(node.data.ID),
  1173. serialNo = mainTreeNode ? mainTreeNode.serialNo() + 1 : 1;
  1174. let flag = node.getFlag() || 0;
  1175. let source = {
  1176. row: serialNo,
  1177. code: node.data.code,
  1178. rowCode: `F${serialNo}`,
  1179. name: node.data.name,
  1180. calcBase: _util.transformCalcBase(detail, node, {CalcBaseMap, FlagCalcBaseMap}),
  1181. feeRate: _util.hasValue(node.data.feeRate) ? node.data.feeRate : 100,
  1182. fees: node.data.fees,
  1183. feeType: FEE_TYPE[flag] || FEE_TYPE['0'],
  1184. remark: node.data.remark
  1185. };
  1186. source.calcBaseState = _util.transformCalcBaseState(detail, source.calcBase, CalcStateMap);
  1187. let feeRow = new FeeRow(source);
  1188. tenderFeeSummary.children.push(feeRow);
  1189. }
  1190. return tenderFeeSummary;
  1191. }
  1192. /*
  1193. * 加载清单项目
  1194. * @param {Object}node(清单树节点) {Object}detail
  1195. * */
  1196. function loadBills(node, detail) {// allRation, allRationGlj, decimal,
  1197. let allRation = detail.Ration.datas,
  1198. allRationGlj = detail.ration_glj.datas,
  1199. decimal = detail.projectInfo.property.decimal;
  1200. // 处理最高限价,输出最高限价时,若最高限价为空,则取综合单价,否则取最高限价
  1201. let maxPrice = 0;
  1202. if (exportKind === _config.EXPORT_KIND.Control && node.data.outPutMaxPrice) {
  1203. maxPrice = _util.isDef(node.data.maxPrice)
  1204. ? node.data.maxPrice
  1205. : _util.getFee(node.data.fees, 'common.unitFee')
  1206. }
  1207. let source = {
  1208. row: detail.mainTree.nodes[detail.mainTree.prefix + node.data.ID].serialNo() + 1,
  1209. code: node.data.code,
  1210. name: node.data.name,
  1211. unit: node.data.unit,
  1212. quantity: node.data.quantity,
  1213. fees: node.data.fees,
  1214. mainBills: node.data.mainBills,
  1215. maxPrice: maxPrice,
  1216. isEstimate: node.data.isEstimate,
  1217. remark: node.data.remark
  1218. };
  1219. let bills = new FXbills(source);
  1220. //清单项目项目编码要在建设项目中唯一
  1221. _util.checkUnique(curProjectEle.constraints.billsCode, source.code, `第${source.row}行`,`清单项目编码${source.code}`);
  1222. //加载特征及内容
  1223. function loadFeatureContent() {
  1224. let job = [],
  1225. feature = [];
  1226. let jobText = node.data.jobContentText || '';
  1227. let featureText = node.data.itemCharacterText || '';
  1228. let jobSplit = jobText.split(/[\r,\n]/g),
  1229. featureSplit = featureText.split(/[\r,\n]/g);
  1230. //将特征和内容分类,通过[项目特征][工作内容]区分。若没有,则不区分:工作内容列全部数据为工作内容,项目特征列全部数据为项目特征
  1231. //@param {Array}data(splitdata) {String}field(job、feature)
  1232. function classifyData(data, field) {
  1233. let rst = {
  1234. job: [],
  1235. feature: []
  1236. };
  1237. let featureIndex = data.findIndex(x => x === '[项目特征]');
  1238. if (featureIndex < 0) {
  1239. rst[field] = data;
  1240. return rst;
  1241. }
  1242. let jobIndex = data.findIndex(x => x === '[工作内容]');
  1243. if (jobIndex < 0) { //有[项目特征],没有[工作内容],则其数据全为项目特征数据
  1244. rst.feature = data;
  1245. return rst;
  1246. }
  1247. //有[项目特征],有[工作内容],进行数据分类
  1248. rst.feature = data.slice(featureIndex, jobIndex);
  1249. rst.job = data.slice(jobIndex);
  1250. return rst;
  1251. }
  1252. let classifiedJob = classifyData(jobSplit, 'job');
  1253. job = job.concat(classifiedJob.job);
  1254. feature = feature.concat(classifiedJob.feature);
  1255. let classifiedFeature = classifyData(featureSplit, 'feature');
  1256. job = job.concat(classifiedFeature.job);
  1257. feature = feature.concat(classifiedFeature.feature);
  1258. job = job.filter(x => x && !['[项目特征]', '[工作内容]'].includes(x));
  1259. feature = feature.filter(x => x && !['[项目特征]', '[工作内容]'].includes(x));
  1260. //创建项目特征节点
  1261. if (feature.length > 0) {
  1262. let itemChac = new ItemCharacter();
  1263. let reg = /(.{0,}):(.{0,})/;
  1264. for (let f of feature) {
  1265. let source = {name: '', value: ''};
  1266. let execRst = reg.exec(f);
  1267. if (execRst) {
  1268. source.name = execRst[1].replace(/^\d+\.{1}/, '').trim(); //去除开头(1.)序号,首位空格
  1269. source.value = execRst[2].trim();
  1270. }
  1271. let featureEle = new Feature(source);
  1272. //let featureEle = new Feature({name: f.trim(), value: ''});
  1273. itemChac.children.push(featureEle);
  1274. }
  1275. bills.children.push(itemChac);
  1276. }
  1277. //创建工作内容节点
  1278. if (job.length > 0) {
  1279. let jobContent = new JobContent();
  1280. for (let j of job) {
  1281. let data = j.replace(/^\d+\.{1}/, '').trim();
  1282. let content = new Content(data);
  1283. //let content = new Content(j.trim());
  1284. jobContent.children.push(content);
  1285. }
  1286. bills.children.push(jobContent);
  1287. }
  1288. }
  1289. loadFeatureContent();
  1290. //解析工程量计算式
  1291. function parseQuantityExp(rationData) {
  1292. if (rationData.quantityEXP === 'QDL') { //取清单工程量
  1293. return node.data.quantity;
  1294. } else if (rationData.quantityEXP === 'GCLMXHJ') { //从明细汇总成数值
  1295. let referDetail = detail.quantity_detail.datas.filter(data => data.rationID === rationData.ID && data.isSummation);
  1296. if (referDetail.length === 0) {
  1297. return '';
  1298. }
  1299. let rst = 0;
  1300. for (let d of referDetail) {
  1301. rst = scMathUtil.roundForObj(rst + d.result, detail.projectInfo.property.decimal.process);
  1302. }
  1303. return scMathUtil.roundForObj(rst, detail.projectInfo.property.decimal.ration.quantity);
  1304. } else {
  1305. return rationData.quantityEXP;
  1306. }
  1307. }
  1308. /*
  1309. * 加载定额子目
  1310. * @param {Array}rationData(清单项目下定额数据) {Array}rationGljData(定额的人材机数据) {Object}decimal(项目小数位数)
  1311. * @return {Object}
  1312. * */
  1313. function loadRation(rationData, rationGljData) {
  1314. let viewCode = rationData.code;
  1315. if (rationData.prefix) {
  1316. viewCode = rationData.prefix + viewCode;
  1317. }
  1318. if (rationData.adjustState) {
  1319. viewCode += '换';
  1320. }
  1321. //子目类型 补充定额为“1”,标准定额无换算为“0”,标准定额有换算为“2”,安装费用,即自动生成的安装子目,为“3”,子目级人材机,即量价、与定额同级的人材机 其他待完善……
  1322. let subType;
  1323. if (rationData.type === rationType.ration && rationData.from === 'cpt') {
  1324. subType = '1';
  1325. } else if (rationData.type === rationType.ration && !rationData.adjustState) {
  1326. subType = '0';
  1327. } else if (rationData.type === rationType.ration && rationData.adjustState) {
  1328. subType = '2';
  1329. } else if (rationData.type === rationType.install) {
  1330. subType = '3';
  1331. } else if (rationData.type === rationType.volumePrice) {
  1332. subType = '6';
  1333. }
  1334. let rNode = detail.mainTree.nodes[detail.mainTree.prefix + rationData.ID];
  1335. let rationSource = {
  1336. row: rNode ? rNode.serialNo() + 1 : -1,
  1337. viewCode: viewCode,
  1338. name: rationData.name,
  1339. unit: rationData.unit,
  1340. libCode: '',
  1341. code: rationData.code,
  1342. subType: subType,
  1343. quantity: rationData.quantity,
  1344. quantityEXP: parseQuantityExp(rationData),
  1345. fees: rationData.fees,
  1346. isSubcontract: rationData.isSubcontract,
  1347. programID: rationData.programID,
  1348. remark: rationData.remark
  1349. };
  1350. if (rationData.from === 'std' && _util.isDef(rationData.libID)) { //来自标准库,设置定额库编码
  1351. rationSource.libCode = detail.rationLibMap[rationData.libID].libCode;
  1352. }
  1353. let ration = new Ration(rationSource);
  1354. //创建工料分析
  1355. let gljAnalyze = new GljAnalyze();
  1356. ration.children.push(gljAnalyze);
  1357. //定额人材机排序
  1358. rationGljData = gljUtil.sortRationGLJ(rationGljData);
  1359. for (let rGlj of rationGljData) {
  1360. let gljSource = {
  1361. //code: rGlj.code,
  1362. code: getGljCode(rGlj.projectGLJID),
  1363. quantity: rGlj.quantity,
  1364. totalQuantity: gljUtil.getTotalQuantity(rGlj, rationData, decimal.glj.quantity, decimal.ration.quantity)
  1365. };
  1366. let gljContent = new GljContent(gljSource);
  1367. gljAnalyze.children.push(gljContent);
  1368. }
  1369. //创建费用组成
  1370. let feeContent = new FeeContent({fees: rationData.fees});
  1371. ration.children.push(feeContent);
  1372. return ration;
  1373. }
  1374. //投标加载组价内容、费用组成
  1375. if (exportKind === _config.EXPORT_KIND.Tender) {
  1376. let rationData = allRation.filter(x => x.billsItemID === node.data.ID);
  1377. if (rationData.length > 0) {
  1378. let priceContent = new PriceContent();
  1379. bills.children.push(priceContent);
  1380. //加载定额子目
  1381. rationData.sort((x, y) => x.serialNo - y.serialNo); //定额排序
  1382. for (let rData of rationData) {
  1383. let rationGlj = allRationGlj.filter(x => x.rationID === rData.ID);
  1384. priceContent.children.push(loadRation(rData, rationGlj));
  1385. }
  1386. }
  1387. //清单费用组成
  1388. let feeContent = new FeeContent({fees: node.data.fees});
  1389. bills.children.push(feeContent);
  1390. }
  1391. return bills;
  1392. }
  1393. /*
  1394. * 加载分部分项清单
  1395. * @param {Object}detail
  1396. * @return {Object || NULL}
  1397. * */
  1398. function loadFBFX(detail) {
  1399. let fbfxBills = new FBFXBills();
  1400. let subEngNode = detail.Bills.tree.roots.find((node) => node.getFlag() === fixedFlag.SUB_ENGINERRING);
  1401. if (!subEngNode) {
  1402. _failList.push('不存在分部分项清单');
  1403. return fbfxBills;
  1404. }
  1405. //是否有清单分类,分部分项下,清单分类和清单项目不可同层存在,如果有了清单分类,则提示其他清单项目:
  1406. //清单xx行应是清单分类,其下必须有清单项目
  1407. let hasBillsClass = subEngNode.children && subEngNode.children.some(node => node.children && node.children.length);
  1408. for (let node of subEngNode.children) {
  1409. if (node.data.type === billType.FB) {
  1410. //创建清单分部节点
  1411. let fbSource = {
  1412. row: detail.mainTree.nodes[detail.mainTree.prefix + node.data.ID].serialNo() + 1,
  1413. code: node.data.code,
  1414. name: node.data.name,
  1415. fees: node.data.fees,
  1416. remark: node.data.remark
  1417. };
  1418. if (node.children.length === 0) {
  1419. _failList.push(`第${fbSource.row}行清单分部下至少要有一条清单项目。`);
  1420. }
  1421. let fbBills = new FBBills(fbSource);
  1422. fbfxBills.children.push(fbBills);
  1423. //创建清单项目节点
  1424. for (let subNode of node.children) {
  1425. //detail.mainTree.nodes[detail.mainTree.prefix + node.data.ID].serialNo() + 1,
  1426. let fx = loadBills(subNode, detail);
  1427. fbBills.children.push(fx);
  1428. }
  1429. } else {
  1430. //第一层有了分部,不能有分项
  1431. if (hasBillsClass) {
  1432. let row = detail.mainTree.nodes[detail.mainTree.prefix + node.data.ID].serialNo() + 1;
  1433. _failList.push(`第${row}行清单应是清单分部,其下必须有清单项目。<span style="color: red">(错误清单结构)</span>`);
  1434. }
  1435. let fxBills = loadBills(node, detail);
  1436. fbfxBills.children.push(fxBills);
  1437. }
  1438. }
  1439. return fbfxBills;
  1440. }
  1441. /*
  1442. * 加载措施项目清单
  1443. * @param {Object}detail
  1444. * @return {Object}
  1445. * */
  1446. function loadCSXM(detail) {
  1447. let measureNode = detail.Bills.tree.roots.find((node) => node.getFlag() === fixedFlag.MEASURE);
  1448. if (!measureNode) {
  1449. _failList.push('不存在措施项目清单');
  1450. return new XML_EXPORT_BASE.Element('措施项目清单', []);
  1451. }
  1452. let csxmBills = new CSXMBills({fees: measureNode.data.fees});
  1453. //加载组织措施清单
  1454. let zzcsNode = detail.Bills.tree.items.find(node => node.getFlag() === fixedFlag.CONSTRUCTION_ORGANIZATION);
  1455. if (zzcsNode) {
  1456. let zzcsBills = new ZZCSBills({fees: zzcsNode.data.fees});
  1457. csxmBills.children.push(zzcsBills);
  1458. loadZZCS(zzcsBills, zzcsNode.children);
  1459. }
  1460. //加载技术措施清单
  1461. let jscsNode = detail.Bills.tree.items.find(node => node.getFlag() === fixedFlag.CONSTRUCTION_TECH);
  1462. let maxDepth = 2; //技术措施清单最多深度是2层:技术措施分类-清单项目
  1463. if (jscsNode) {
  1464. let jscsBills = new JSCSBills({fees: jscsNode.data.fees});
  1465. csxmBills.children.push(jscsBills);
  1466. let isValidDepth = _util.validDepth(maxDepth, jscsNode);
  1467. if (!isValidDepth) {
  1468. _failList.push('技术措施清单子项超过两层');
  1469. } else {
  1470. loadJSCS(jscsBills, jscsNode.children);
  1471. }
  1472. }
  1473. return csxmBills;
  1474. function loadZZCS(parent, nodes) {
  1475. let hasBillsClass = nodes && nodes.some(node => node.children && node.children.length);
  1476. //组织措施分类和公式计算措施项不能出现在同层中
  1477. for (let node of nodes) {
  1478. if (node.children.length > 0) { //组织措施分类
  1479. let classSource = {
  1480. row: detail.mainTree.nodes[detail.mainTree.prefix + node.data.ID].serialNo() + 1,
  1481. code: node.data.code,
  1482. name: node.data.name,
  1483. fees: node.data.fees,
  1484. remark: node.data.remark
  1485. };
  1486. let zzcsClass = new ZZCSClass(classSource);
  1487. parent.children.push(zzcsClass);
  1488. loadZZCS(zzcsClass, node.children);
  1489. } else { //公式计算措施项
  1490. let source = {
  1491. row: detail.mainTree.nodes[detail.mainTree.prefix + node.data.ID].serialNo() + 1,
  1492. code: node.data.code,
  1493. name: node.data.name,
  1494. calcBase: _util.transformCalcBase(detail, node, {CalcBaseMap, FlagCalcBaseMap}),
  1495. feeRate: _util.hasValue(node.data.feeRate) ? node.data.feeRate : 100,
  1496. fees: node.data.fees,
  1497. remark: node.data.remark,
  1498. feeType: FEE_TYPE[node.getFlag()] || FEE_TYPE['0']
  1499. };
  1500. source.calcBaseState = _util.transformCalcBaseState(detail, source.calcBase, CalcStateMap);
  1501. if (hasBillsClass) {
  1502. _failList.push(`第${source.row}行清单应是清单分类,其下必须有清单项目。<span style="color: red">(错误清单结构)</span>`);
  1503. }
  1504. let formula = new FormulaCalcMeasure(source);
  1505. parent.children.push(formula);
  1506. }
  1507. }
  1508. if (parent instanceof ZZCSClass) { //组织措施分类下的只能有一个组织措施分类
  1509. let filters = parent.children.filter(data => data instanceof ZZCSClass);
  1510. if (filters.length) {
  1511. _failList.push('组织措施分类下只能有一个组织措施分类');
  1512. }
  1513. }
  1514. }
  1515. function loadJSCS(parent, nodes) {
  1516. let hasBillsClass = nodes && nodes.some(node => node.children && node.children.length);
  1517. for (let node of nodes) {
  1518. if (node.children.length > 0) { //技术措施分类
  1519. let classSource = {
  1520. code: node.data.code,
  1521. name: node.data.name,
  1522. fees: node.data.fees
  1523. };
  1524. let jscsClass = new JSCSClass(classSource);
  1525. parent.children.push(jscsClass);
  1526. loadJSCS(jscsClass, node.children);
  1527. } else { //清单项目
  1528. if (hasBillsClass) {
  1529. let row = detail.mainTree.nodes[detail.mainTree.prefix + node.data.ID].serialNo() + 1;
  1530. _failList.push(`第${row}行清单应是清单分类,其下必须有清单项目。<span style="color: red">(错误清单结构)</span>`);
  1531. }
  1532. parent.children.push(loadBills(node, detail));
  1533. }
  1534. }
  1535. }
  1536. }
  1537. /*
  1538. * 加载其他项目清单,要出现此节点,需要遵循标准条件(至少含有一条相关明细)
  1539. * @param {Object}detail
  1540. * @return {Object || Null}
  1541. * */
  1542. function loadOtherBills(detail) {
  1543. //其他项目清单元素
  1544. let otherEle = new OtherBills();
  1545. let otherNode = detail.Bills.tree.roots.find(node => node.getFlag() === fixedFlag.OTHER);
  1546. if (otherNode.children.length === 0) {
  1547. return otherEle;
  1548. }
  1549. //添加暂列金额元素
  1550. let provisionalNode = detail.Bills.tree.items.find(node => node.getFlag() === fixedFlag.PROVISIONAL);
  1551. if (provisionalNode && provisionalNode.children.length > 0) {
  1552. otherEle.children.push(loadProvisional(provisionalNode));
  1553. }
  1554. //添加专业工程暂估价元素
  1555. let engEstimateNode = detail.Bills.tree.items.find(node => node.getFlag() === fixedFlag.ENGINEERING_ESITIMATE);
  1556. if (engEstimateNode && engEstimateNode.children.length > 0) {
  1557. otherEle.children.push(loadEngEstimate(engEstimateNode));
  1558. }
  1559. //添加计日工元素
  1560. let dayWorkNode = detail.Bills.tree.items.find(node => node.getFlag() === fixedFlag.DAYWORK);
  1561. let dayWorkEle = new DayWork({fees: dayWorkNode.data.fees});
  1562. if (dayWorkNode && dayWorkNode.children.length > 0) {
  1563. //要显示计日工元素,人工、材料、施工机械,最少有一条含有子项(计日工项目)
  1564. let filterNodes = dayWorkNode.children.filter(node => [fixedFlag.LABOUR, fixedFlag.MATERIAL, fixedFlag.MACHINE].includes(node.getFlag()));
  1565. for (let fNode of filterNodes) {
  1566. let ele,
  1567. constraints;
  1568. let flag = fNode.getFlag();
  1569. if (flag === fixedFlag.LABOUR) {
  1570. ele = new Labour();
  1571. constraints = curTenderEle.constraints.labourDayWorkCode;
  1572. } else if (flag === fixedFlag.MATERIAL) {
  1573. ele = new Material();
  1574. constraints = curTenderEle.constraints.materialDayWorkCode;
  1575. } else if (flag === fixedFlag.MACHINE) {
  1576. ele = new Machine();
  1577. constraints = curTenderEle.constraints.machineDayWorkCode;
  1578. }
  1579. if (fNode.children.length > 0) {
  1580. let isValidDepth = _util.validDepth(1, fNode);
  1581. if (!isValidDepth) {
  1582. _failList.push(`计日工${ele.name}子项超过一层`);
  1583. } else {
  1584. for (let itemNode of fNode.children) {
  1585. ele.children.push(loadDayWorkItem(itemNode, constraints, `${ele.name}计日工项目编号`));
  1586. }
  1587. dayWorkEle.children.push(ele);
  1588. }
  1589. }
  1590. }
  1591. //如果计日工下有计日工项目,则显示计日工元素
  1592. if (dayWorkEle.children.length > 0) {
  1593. otherEle.children.push(dayWorkEle);
  1594. }
  1595. }
  1596. //添加总承包服务费元素
  1597. let tkcNode = detail.Bills.tree.items.find(node => node.getFlag() === fixedFlag.TURN_KEY_CONTRACT);
  1598. if (tkcNode && tkcNode.children.length > 0) { //必须要有子项才显示总承包服务费元素
  1599. let isValidDepth = _util.validDepth(2, tkcNode); //最多2层子项:总承包服务费分类-总承包服务费费用项
  1600. if (!isValidDepth) {
  1601. _failList.push('总承包服务费子项超过两层');
  1602. } else {
  1603. let tkcEle = new TurnKeyContract({fees: tkcNode.data.fees});
  1604. otherEle.children.push(tkcEle);
  1605. loadService(tkcEle, tkcNode.children);
  1606. }
  1607. }
  1608. //添加索赔计价汇总元素
  1609. let claimNode = detail.Bills.tree.items.find(node => node.getFlag() === fixedFlag.CLAIM);
  1610. if (claimNode && claimNode.children.length > 0) { //必须要有子项才能显示索赔计价汇总元素
  1611. let claimEle = new XML_EXPORT_BASE.Element('索赔计价汇总', [
  1612. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(claimNode.data.fees, 'common.totalFee') : '0'}]);
  1613. for (let n of claimNode.children) {
  1614. claimEle.children.push(new ClaimVisaFeeItem(n.data));
  1615. }
  1616. otherEle.children.push(claimEle);
  1617. }
  1618. //添加现场签证计价汇总元素
  1619. let visaNode = detail.Bills.tree.items.find(node => node.getFlag() === fixedFlag.VISA);
  1620. if (visaNode && visaNode.children.length > 0) { //必须要有子项才能显示现场签证计价汇总元素
  1621. let visaEle = new XML_EXPORT_BASE.Element('现场签证计价汇总', [
  1622. {name: '金额', value: exportKind === _config.EXPORT_KIND.Tender ? _util.getFee(visaNode.data.fees, 'common.totalFee') : '0'}
  1623. ]);
  1624. for (let n of visaNode.children) {
  1625. visaEle.children.push(new ClaimVisaFeeItem(n.data));
  1626. }
  1627. otherEle.children.push(visaEle);
  1628. }
  1629. //添加其他元素
  1630. let posetriy = otherNode.getPosterity();
  1631. let subOtherEle = loadOthers(posetriy);
  1632. if (subOtherEle) {
  1633. otherEle.children.push(subOtherEle);
  1634. }
  1635. // 不需要有子节点,也可以输出显示
  1636. return otherEle;
  1637. //加载暂列金额
  1638. function loadProvisional(node) {
  1639. let provisionalEle = new Provisional({fees: node.data.fees});
  1640. //暂列金额最多只有一层子节点
  1641. let isValidDepth = _util.validDepth(1, node);
  1642. if (!isValidDepth) {
  1643. _failList.push('暂列金额子项超过一层');
  1644. } else { //加载暂列金额明细
  1645. for (let n of node.children) {
  1646. let pDetailSource = {
  1647. row: detail.mainTree.nodes[detail.mainTree.prefix + n.data.ID].serialNo() + 1,
  1648. code: n.data.code,
  1649. name: n.data.name,
  1650. unit: n.data.unit,
  1651. fees: n.data.fees,
  1652. remark: n.data.remark
  1653. },
  1654. pDetailEle = new ProvisionalDetail(pDetailSource);
  1655. //暂列金额明细编号在单位工程中唯一
  1656. _util.checkUnique(curTenderEle.constraints.provisionalDetailCode, pDetailSource.code,
  1657. `第${pDetailSource.row}行`, `暂列金额明细编码${pDetailSource.code}`);
  1658. provisionalEle.children.push(pDetailEle);
  1659. }
  1660. }
  1661. return provisionalEle;
  1662. }
  1663. //加载专业工程暂估价
  1664. function loadEngEstimate(node) {
  1665. let engEstimateEle = new EngEstimate({fees: node.data.fees});
  1666. //专业工程暂估价最多只有一层子节点
  1667. let isValidDepth = _util.validDepth(1, node);
  1668. if (!isValidDepth) {
  1669. _failList.push('专业工程暂估价子项超过一层');
  1670. } else { //加载专业工程暂估明细
  1671. for (let n of node.children) {
  1672. let eDetailSource = {
  1673. row: detail.mainTree.nodes[detail.mainTree.prefix + n.data.ID].serialNo() + 1,
  1674. code: n.data.code,
  1675. name: n.data.name,
  1676. engineeringContent: n.data.engineeringContent,
  1677. fees: n.data.fees,
  1678. remark: n.data.remark
  1679. },
  1680. eDetailEle = new EngEstimateDetail(eDetailSource);
  1681. //暂列金额明细编号在单位工程中唯一
  1682. _util.checkUnique(curTenderEle.constraints.engEstimateDetailCode, eDetailSource.code,
  1683. `第${eDetailSource.row}行`, `专业工程暂估明细编码${eDetailSource.code}`);
  1684. engEstimateEle.children.push(eDetailEle);
  1685. }
  1686. }
  1687. return engEstimateEle;
  1688. }
  1689. //加载计日工项目
  1690. function loadDayWorkItem(node, constraints, hint) {
  1691. let source = {
  1692. row: detail.mainTree.nodes[detail.mainTree.prefix + node.data.ID].serialNo() + 1,
  1693. code: node.data.code,
  1694. name: node.data.name,
  1695. unit: node.data.unit,
  1696. quantity: node.data.quantity,
  1697. fees: node.data.fees,
  1698. remark: node.data.remark
  1699. };
  1700. _util.checkUnique(constraints, source.code, `第${source.row}行`, `计日工项目编码${source.code}`);
  1701. return new DayWorkItem(source);
  1702. }
  1703. //加载服务费项
  1704. function loadService(parent, nodes) {
  1705. let hasBillsClass = nodes && nodes.some(node => node.children && node.children.length);
  1706. for (let node of nodes) {
  1707. if (node.children.length > 0) { //总承包服务费分类
  1708. let classSource = {
  1709. row: detail.mainTree.nodes[detail.mainTree.prefix + node.data.ID].serialNo() + 1,
  1710. code: node.data.code,
  1711. name: node.data.name,
  1712. remark: node.data.remark
  1713. };
  1714. let tkcClass = new TurnKeyContractClass(classSource);
  1715. parent.children.push(tkcClass);
  1716. loadService(tkcClass, node.children);
  1717. } else { //总承包服务费费用项
  1718. let source = {
  1719. row: detail.mainTree.nodes[detail.mainTree.prefix + node.data.ID].serialNo() + 1,
  1720. code: node.data.code,
  1721. name: node.data.name,
  1722. serviceContent: node.data.serviceContent,
  1723. calcBaseValue: node.data.calcBaseValue,
  1724. feeRate: _util.hasValue(node.data.feeRate) ? node.data.feeRate : 100,
  1725. fees: node.data.fees,
  1726. remark: node.data.remark
  1727. };
  1728. if (hasBillsClass) {
  1729. _failList.push(`第${source.row}行清单应是清单分类,其下必须有清单项目。<span style="color: red">(错误清单结构)</span>`);
  1730. }
  1731. parent.children.push(new TurnKeyContractItem(source));
  1732. }
  1733. }
  1734. }
  1735. //加载其他列项,不符合上述情况的,其他所有清单子项
  1736. function loadOthers(nodes) {
  1737. //排除项
  1738. let exclusionFlags = [
  1739. fixedFlag.PROVISIONAL,
  1740. fixedFlag.MATERIAL_PROVISIONAL, // 材料(工程设备)暂估价 不导出
  1741. fixedFlag.ENGINEERING_ESITIMATE,
  1742. fixedFlag.LABOUR,
  1743. fixedFlag.MATERIAL,
  1744. fixedFlag.MACHINE,
  1745. fixedFlag.TURN_KEY_CONTRACT,
  1746. fixedFlag.CLAIM,
  1747. fixedFlag.VISA
  1748. ];
  1749. //生成其他列项
  1750. let otherItems = [],
  1751. summaryFee = 0;
  1752. for (let node of nodes) {
  1753. let belongFlag = node.belongToFlag();
  1754. if (node.children.length > 0 || (belongFlag && exclusionFlags.includes(belongFlag))) {
  1755. continue;
  1756. }
  1757. //汇总其他列项金额
  1758. let totalFee = _util.getFee(node.data.fees, 'common.totalFee');
  1759. summaryFee = scMathUtil.roundForObj(summaryFee + totalFee, detail.projectInfo.property.decimal.bills.totalPrice);
  1760. let otherItemSource = {
  1761. row: detail.mainTree.nodes[detail.mainTree.prefix + node.data.ID].serialNo() + 1,
  1762. code: node.data.code,
  1763. name: node.data.name,
  1764. calcBase: _util.transformCalcBase(detail, node, {CalcBaseMap, FlagCalcBaseMap}),
  1765. feeRate: _util.hasValue(node.data.feeRate) ? node.data.feeRate : 100,
  1766. commonTotalFee: totalFee,
  1767. notSummary: belongFlag && belongFlag === fixedFlag.MATERIAL_PROVISIONAL, //不计入合价,只有材料(工程设备)暂估价固定节点
  1768. remark: node.data.remark
  1769. };
  1770. let otherItemEle = new OtherItem(otherItemSource);
  1771. otherItems.push(otherItemEle);
  1772. _util.checkUnique(curTenderEle.constraints.otherItemNo, otherItemSource.code,
  1773. `第${otherItemSource.row}行`, `清单编码${otherItemSource.code}`);
  1774. }
  1775. let otherEle = new Other({commonTotalFee: summaryFee});
  1776. for (let ele of otherItems) {
  1777. otherEle.children.push(ele);
  1778. }
  1779. return otherEle.children.length > 0 ? otherEle : null; //有其他列项才能显示其他元素
  1780. }
  1781. }
  1782. /*
  1783. * 加载规费和税金清单,固定显示:规费、规费子项、税金、增值税、附加税、环境保护税这几个清单
  1784. * @param {Object}detail
  1785. * @return {Object}
  1786. * */
  1787. function loadChargeTax(detail) {
  1788. let chargeTaxEle = new ChargeTaxBills();
  1789. let filterFlags = [
  1790. fixedFlag.CHARGE,
  1791. fixedFlag.TAX,
  1792. fixedFlag.ADDED_VALUE_TAX,
  1793. fixedFlag.ADDITIONAL_TAX,
  1794. fixedFlag.ENVIRONMENTAL_PROTECTION_TAX
  1795. ];
  1796. let filterNodes = detail.Bills.tree.items.filter(node => filterFlags.includes(node.getFlag()));
  1797. // 规费子项
  1798. let chargeNode = filterNodes.find(node => node.getFlag() === fixedFlag.CHARGE);
  1799. if (chargeNode) {
  1800. filterNodes.splice(filterNodes.indexOf(chargeNode) + 1, 0, ...chargeNode.children);
  1801. }
  1802. for (let node of filterNodes) {
  1803. let mainTreeNode = detail.mainTree.getNodeByID(node.data.ID),
  1804. serialNo = mainTreeNode ? mainTreeNode.serialNo() + 1 : 1;
  1805. // 规费和规费子项费用类别相同
  1806. let feeType = node === chargeNode || node.parent === chargeNode
  1807. ? FEE_TYPE[chargeNode.getFlag()]
  1808. : FEE_TYPE[node.getFlag()] || FEE_TYPE['0'];
  1809. let source = {
  1810. row: detail.mainTree.nodes[detail.mainTree.prefix + node.data.ID].serialNo() + 1,
  1811. code: node.data.code,
  1812. rowCode: `F${serialNo}`,
  1813. name: node.data.name,
  1814. calcBase: _util.transformCalcBase(detail, node, {CalcBaseMap, FlagCalcBaseMap}),
  1815. feeRate: _util.hasValue(node.data.feeRate) ? node.data.feeRate : 100,
  1816. fees: node.data.fees,
  1817. feeType: feeType,
  1818. remark: node.data.remark
  1819. };
  1820. source.calcBaseState = _util.transformCalcBaseState(detail, source.calcBase, CalcStateMap);
  1821. //序号唯一
  1822. _util.checkUnique(curTenderEle.constraints.feeItemNo, source.code,
  1823. `第${source.row}行`, `清单编码${source.code}`);
  1824. chargeTaxEle.children.push(new FeeItem(source));
  1825. }
  1826. return chargeTaxEle;
  1827. }
  1828. /*
  1829. * 加载主要清单明细
  1830. * @param {Obejct}parent(设置到的父项:主要清单汇总元素) {Object}detail
  1831. * @return {void}
  1832. * */
  1833. function loadMainBillsItems(parent, detail) {
  1834. let mainBills = detail.Bills.datas.filter(data => {
  1835. let billsNode = detail.Bills.tree.nodes[`${detail.Bills.tree.prefix}${data.ID}`];
  1836. return data.mainBills && billsNode && billsNode.children.length === 0;
  1837. });
  1838. for (let bills of mainBills) {
  1839. let source = {
  1840. code: bills.code,
  1841. name: bills.name,
  1842. unit: bills.unit,
  1843. quantity: bills.quantity,
  1844. fees: bills.fees,
  1845. remark: bills.remark
  1846. };
  1847. let mainBillsItemEle = new MainBillsItem(source);
  1848. //主要清单明细项目编码唯一
  1849. _util.checkUnique(curTenderEle.constraints.mainBillsCode, source.code, '主要清单明细项目编码');
  1850. parent.children.push(mainBillsItemEle);
  1851. }
  1852. }
  1853. /*
  1854. * 加载人材机汇总相关:人材机汇总、评标、暂估
  1855. * @param {Object}appraisalSummary(建设项目下的评审材料汇总) {Object}detail
  1856. * @return {Object}
  1857. * */
  1858. function loadGlj(appraisalSummary, detail) {
  1859. let gljList = detail.projectGLJ.datas.gljList;
  1860. let evalBidSeq = 1, //评标序号
  1861. evalEstSeq = 1; //暂估序号
  1862. if (gljList.length > 0) {
  1863. //创建人材机汇总节点
  1864. let gljSummary = new GljSummary();
  1865. //创建评标材料表节点
  1866. let evalBidMaterial = new EvalBidMaterial();
  1867. //创建暂估价材料表节点
  1868. let evalEstimateMaterial = new EvalEstimateMaterial();
  1869. //人材机节点
  1870. let allGljs = gljUtil.sortRationGLJ(gljList); //人材机汇总排序
  1871. //计算总消耗量
  1872. gljUtil.calcProjectGLJQuantity(detail.projectGLJ.datas,
  1873. detail.ration_glj.datas, detail.Ration.datas, detail.Bills.datas, detail.projectInfo.property.decimal.glj.quantity, _, scMathUtil);
  1874. //类型-配比类别映射
  1875. let ratioMapping = {
  1876. '202': '1', //为“混凝土”时,取“1”;
  1877. '205': '2', //为“商品混凝土”时,取“2”;
  1878. '203': '3', //为“砂浆”时,取“3”;
  1879. '206': '4', //为“商品砂浆”时,取“4”;
  1880. '204': '5' //为“配合比”时,取“5”
  1881. };
  1882. //三材类别-主要材料类别映射 三材类型:钢材1、钢筋2、木材3、水泥4、商品砼5、商品砂浆6
  1883. let mainMaterialMapping = {
  1884. '1': '100', //为“钢材”、“钢筋”时,取“100”;
  1885. '2': '100',
  1886. '4': '200', //为“水泥”时,取“200”;
  1887. '3': '300', //为“木材”时,取“300”;
  1888. '5': '400', //为“商品砼”、商品砂浆”时,取“400”。
  1889. '6': '400'
  1890. };
  1891. for (let glj of allGljs) {
  1892. let price = gljUtil.getGLJPrice(glj, detail.projectGLJ.datas,
  1893. detail.projectInfo.property.calcOptions, detail.labourCoe.datas, detail.projectInfo.property.decimal, false, _, scMathUtil);
  1894. //调整价
  1895. /*let adjPrice = gljUtil.getAdjustPrice(glj, detail.projectGLJ.datas,
  1896. detail.projectInfo.property.calcOptions, detail.labourCoe.datas, detail.projectInfo.property.decimal, false, _, scMathUtil);*/
  1897. let adjPrice = 0;
  1898. //获取人材机费用类别: 1=人工费 2=材料费 3=机械费 4=未计价费
  1899. let feeType = String(glj.type)[0];
  1900. if (feeType && !['1', '2', '3'].includes(feeType)) {
  1901. feeType = '4';
  1902. }
  1903. let gljSource = {
  1904. //code: glj.code,
  1905. code: getGljCode(glj.id),
  1906. name: glj.name,
  1907. specs: glj.specs,
  1908. unit: glj.unit,
  1909. orgCode: glj.code, //不取原始编码了,直接取编码
  1910. feeType: feeType,
  1911. ratioType: ratioMapping[glj.type],
  1912. mainMaterialType: mainMaterialMapping[glj.materialType],
  1913. materialCoe: glj.materialCoe,
  1914. supply: glj.supply === 2 ? 2 : 1, //供货方式为“完全甲供”,取“2”;否则取“1”。
  1915. is_evaluate: !!glj.is_evaluate,
  1916. no_tax_eqp: !!glj.no_tax_eqp,
  1917. notFromDetail: !glj.ratio_data.length, //单价不从明细汇总标志,如果有配比组成,取“false”;否则取“true”。
  1918. basePrice: price.basePrice,
  1919. adjPrice: adjPrice,
  1920. marketPrice: price.marketPrice,
  1921. quantity: glj.quantity,
  1922. originPlace: glj.originPlace,
  1923. vender: glj.vender,
  1924. qualityGrace: glj.qualityGrace,
  1925. brand: glj.brand,
  1926. remark: glj.remark
  1927. };
  1928. let gljEle = new Glj(gljSource);
  1929. //人材机代码唯一
  1930. _util.checkUnique(curTenderEle.constraints.gljCode, gljSource.code, '人材机代码', gljSource.orgCode);
  1931. //人材机配比
  1932. let connectKey = gljUtil.getIndex(glj, gljKeyArray),
  1933. ratioData = detail.projectGLJ.datas.mixRatioMap[connectKey];
  1934. if (ratioData && Array.isArray(ratioData)) {
  1935. for (let ratio of ratioData) {
  1936. let pGLJ = detail.projectGLJ.datas.gljList.find(d => d.original_code === ratio.code);
  1937. if (pGLJ) {
  1938. let gljRatio = new GljRatio({code: getGljCode(pGLJ.id), quantity: ratio.consumption});
  1939. gljEle.children.push(gljRatio);
  1940. }
  1941. }
  1942. }
  1943. gljSummary.children.push(gljEle);
  1944. gljSource.totalPrice = scMathUtil.roundForObj(gljSource.quantity * gljSource.marketPrice,
  1945. detail.projectInfo.property.decimal.bills.totalPrice);
  1946. //评标和暂估材料表下的材料明细中的人材机代码,要求单位工程内唯一,由于人材机汇总也有这个限制,所以这里不再处理
  1947. if (glj.is_eval_material) { //评标
  1948. gljSource.serialNo = evalBidSeq++;
  1949. evalBidMaterial.children.push(new MaterialDetail(gljSource));
  1950. //给建设项目下的评审材料汇总设置明细数据,这里需要检测代码(编号)唯一性,因为是汇总所有单位工程的,要求所有单位工程内评审材料代码唯一
  1951. appraisalSummary.children.push(new AppraisalDetail(gljSource));
  1952. _util.checkUnique(curTenderEle.constraints.appraisalDetailCode, gljSource.code, '评审材料明细代码', gljSource.orgCode);
  1953. }
  1954. if (glj.is_evaluate) { //暂估
  1955. gljSource.serialNo = evalEstSeq++;
  1956. evalEstimateMaterial.children.push(new MaterialDetail(gljSource));
  1957. }
  1958. }
  1959. return {gljSummary, evalBidMaterial, evalEstimateMaterial};
  1960. }
  1961. }
  1962. /*
  1963. * 加载清单综合单价计算程序
  1964. * */
  1965. function loadCalcProgram(detail) {
  1966. let calcProgram = detail.calcProgram;
  1967. if (!calcProgram) {
  1968. return null;
  1969. }
  1970. let calcProramTemplates = calcProgram.templates;
  1971. if (!Array.isArray(calcProramTemplates) || calcProramTemplates.length === 0) {
  1972. return null;
  1973. }
  1974. //创建清单综合单价计算程序
  1975. let calcProgramEle = new CalcProgram();
  1976. //创建综合单价计算程序文件
  1977. for (let calcFile of calcProramTemplates) {
  1978. let calcFileEle = new CalcProgramFile({ID: calcFile.ID, name: calcFile.name});
  1979. //创建计算程序费用项
  1980. for (let calcItem of calcFile.calcItems) {
  1981. let idx = calcFile.calcItems.indexOf(calcItem);
  1982. //如果是有[]的基数则转换为其简称,如“[定额人工费]”对应的检查是"RGF"
  1983. let calcBase = calcItem.dispExpr.replace(/\[[\u4e00-\u9fa5]+\]/g, str => rationBaseShort[str] ? rationBaseShort[str] : '');
  1984. let feeType = calcProgram.feeTypes.find(data => data.type === calcItem.fieldName);
  1985. feeType = feeType ? feeType.code : '1800';
  1986. let source = {
  1987. serialNo: idx + 1,
  1988. rowCode: `F${idx + 1}`,
  1989. name: calcItem.name,
  1990. calcBase: calcBase,
  1991. statement: calcItem.statement,
  1992. feeRate: _util.hasValue(calcItem.feeRate) ? calcItem.feeRate : 100,
  1993. feeType: feeType,
  1994. remark: calcItem.memo
  1995. };
  1996. let calcItemEle = new CalcProgramFeeItem(source);
  1997. calcFileEle.children.push(calcItemEle);
  1998. }
  1999. if (calcFileEle.children.length > 0) { //计算程序文件必须有费用项
  2000. calcProgramEle.children.push(calcFileEle);
  2001. }
  2002. }
  2003. return calcProgramEle.children.length > 0 ? calcProgramEle : null;
  2004. }
  2005. // 返回提取的数据
  2006. return await loadProject(projectData);
  2007. }
  2008. /*
  2009. * 重置工程编号,因为每一个费用定额,导出的结构都不相同,重置工程编号的逻辑需要各自定义
  2010. * @param {Array}codes 工程编号
  2011. * {Array}extractData 提取的数据
  2012. * @return {void}
  2013. * */
  2014. function resetContentCode(codes, extractData) {
  2015. // 提取到的数据全是以建设项目为根元素的数据,每份数据都要重置编号
  2016. extractData.forEach(obj => {
  2017. let idx = 0;
  2018. // 从建设项目元素中筛选出单项工程元素
  2019. let engs = _util.getElementFromSrc(obj.data, '单项工程');
  2020. engs.forEach(eng => {
  2021. // 从属性中找到编号项
  2022. let codeItem = eng.attrs.find(attr => attr.name === '编号');
  2023. codeItem.value = codes[idx++];
  2024. // 从单项工程元素中筛选出单位工程元素
  2025. let tenders = _util.getElementFromSrc(eng, '单位工程');
  2026. tenders.forEach(tender => {
  2027. let codeItem = tender.attrs.find(attr => attr.name === '编号');
  2028. codeItem.value = codes[idx++];
  2029. });
  2030. });
  2031. });
  2032. }
  2033. /*
  2034. * 导出文件的结构逻辑,每个费用定额导出的最终文件结构要求可能不同,需要各自定义
  2035. * 重庆18费用定额,只有一个文件的时候直接导出qtf文件,文件数大于1时,导出zip压缩包
  2036. * @param {Array}fileData 文件数据
  2037. * @return {void}
  2038. * */
  2039. async function saveAsFile(fileData) {
  2040. if (fileData.length === 1) {
  2041. saveAs(fileData[0].blob, fileData[0].fileName);
  2042. } else if (fileData.length > 1) { //导出压缩包
  2043. let zip = new JSZip();
  2044. for (let file of fileData) {
  2045. zip.file(file.fileName, file.blob, {binary: true});
  2046. }
  2047. let zipFile = await zip.generateAsync({type: 'blob'});
  2048. saveAs(zipFile, '重庆标准交换数据.zip');
  2049. }
  2050. }
  2051. return {
  2052. entry,
  2053. resetContentCode,
  2054. saveAsFile
  2055. };
  2056. })();