chongqing_2018_export.js 133 KB

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