exportStandardInterface.js 124 KB

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