shandong_common.js 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518
  1. // INTERFACE_EXPORT =,必须这么写,这样才能在导出时动态加载脚本后,覆盖前端代码
  2. // 参考广东中山导出接口
  3. INTERFACE_EXPORT = (() => {
  4. "use strict";
  5. const feeRateMap = {
  6. 冬季施工增加费: "DJSGZJFFL",
  7. 冬季施工: "DJSGZJFFL",
  8. 雨季施工增加费: "YUJSGZJFFL",
  9. 雨季施工: "YUJSGZJFFL",
  10. 夜间施工增加费: "YEJSGZJFFL",
  11. 夜间施工: "YEJSGZJFFL",
  12. 高原地区施工增加费: "GYDQSGZJFFL",
  13. 高原施工: "GYDQSGZJFFL",
  14. 风沙地区施工增加费: "FSDQSGZJFFL",
  15. 风沙施工: "FSDQSGZJFFL",
  16. 沿海地区施工增加费: "YHDQSGZJFFL",
  17. 沿海施工: "YHDQSGZJFFL",
  18. 行车干扰施工增加费: "XCGRGCSGZJFFL",
  19. 行车干扰: "XCGRGCSGZJFFL",
  20. 工地转移费: "GDZYFFL",
  21. '工地转移(km)': "GDZYFFL",
  22. 施工辅助费: "SGFZFFL",
  23. 施工辅助: "SGFZFFL",
  24. 基本费用: "JBFYFL",
  25. 主副食运费补贴: "ZFSYFBTFL",
  26. '综合里程(km)': "ZFSYFBTFL",
  27. 职工探亲路费: "ZGTQLFFL",
  28. 职工探亲: "ZGTQLFFL",
  29. 职工取暖补贴: "ZGQNBTFL",
  30. 职工取暖: "ZGQNBTFL",
  31. 财务费用: "CWFYFL",
  32. 养老保险费: "YANGLBXFFL",
  33. 失业保险费: "SYBXFFL",
  34. 医疗保险费: "YILBXFFL",
  35. 工伤保险费: "GSBXFL",
  36. 养老保险: "YANGLBXFFL",
  37. 失业保险: "SYBXFFL",
  38. 医疗保险: "YILBXFFL",
  39. 工伤保险: "GSBXFL",
  40. 住房公积金: "ZFGJJFL",
  41. 规费: "GFZHFL",
  42. 利润: "LRL",
  43. 税金: "SL",
  44. 土方: "TF",
  45. 石方: "SF",
  46. 运输: "YS",
  47. 路面: "LM",
  48. "路面(不计雨)": "LM",
  49. 隧道: "SD",
  50. 构造物I: "GZW1",
  51. "构造物I(不计冬)": "GZW1",
  52. "构造物I(不计雨)": "GZW1",
  53. 构造物II: "GZW2",
  54. "构造物III(桥梁)": "GZW3",
  55. "构造物III(除桥以外)": "GZW3",
  56. "构造物III(除桥以外不计雨夜)": "GZW3",
  57. 技术复杂大桥: "JSFZDQ",
  58. "钢材及钢结构(桥梁)": "GJG",
  59. "钢材及钢结构(除桥以外)": "GJG",
  60. "钢材及钢结构(除桥以外不计夜)": "GJG",
  61. };
  62. //计算程序有,这里没有:施工机械使用费\施工机械人工费\定额人工费\定额材料费\定额施工机械使用费
  63. const itemFeeMap = {
  64. 'marketLabour': 'RGF',
  65. 'marketMaterial': 'CLF',
  66. 'marketMachine':'JXSYF',
  67. 'marketEquipment': 'SBGZF',
  68. 'direct': 'DEZJF',
  69. 'equipment': 'DESBF',
  70. 'marketDirect': 'ZJF',
  71. 'measure': 'CSF',
  72. 'measure1': 'CSF1',
  73. 'measure2': 'CSF2',
  74. 'manage': 'QYGLF',
  75. 'force': 'GF',
  76. 'profit': 'LR',
  77. 'tax': 'SJ',
  78. 'common': 'JAF',
  79. 'rationCommon': 'DEJAF'
  80. };
  81. const feeLibNoMap = {
  82. 'eba0e7c0-cfe6-11ea-ba15-739be477d1fe': 'GYSFL-000000-2018-86',
  83. '451d3180-e02e-11ea-8056-1514dfc2f39e': 'GYSFL-340000-2019-210',
  84. '32923ff0-e912-11ea-8b20-d93bc370e960': 'GYSFL-440000-2019-544'
  85. };
  86. const FixedCostMap = {
  87. //折旧费、检修费、维护费、安拆辅助费
  88. '折旧费': 1,
  89. '检修费': 1,
  90. '维护费': 1,
  91. '安拆辅助费':1
  92. }
  93. const RoadGradeMap = {
  94. "高速公路": "0",
  95. "一级公路": "1",
  96. "二级公路": "2",
  97. "三级公路": "3",
  98. "四级公路": "4",
  99. "等外公路": "5",
  100. "独立桥梁": "6",
  101. "独立隧道": "7"
  102. }
  103. const sectionNameMap = {
  104. "清单 第100章 总则": true,
  105. "清单 第200章 路基": true,
  106. "清单 第300章 路面": true,
  107. "清单 第400章 桥梁、涵洞": true,
  108. "清单 第500章 隧道": true,
  109. "清单 第600章 安全设施及预埋管线": true,
  110. "清单 第700章 绿化及环境保护设施": true,
  111. // "清单 第800章 机电工程": true,
  112. // "清单 第900章 附属区房建工程":true
  113. }
  114. const ListCodeMap = {
  115. "第100章至700章清单":"1",
  116. "清单 第100章 总则": "一",
  117. "清单 第200章 路基": "二",
  118. "清单 第300章 路面": "三",
  119. "清单 第400章 桥梁、涵洞": "四",
  120. "清单 第500章 隧道": "五",
  121. "清单 第600章 安全设施及预埋管线": "六",
  122. "清单 第700章 绿化及环境保护设施": "七",
  123. // "清单 第800章 机电工程": "八",
  124. // "清单 第900章 附属区房建工程": "九",
  125. "已包含在清单合计中的材料、工程设备、专业工程暂估价合计": "10",
  126. "清单合计减去材料、工程设备、专业工程暂估价合计": "11",
  127. "计日工合计": "12",
  128. "劳务": "12.1",
  129. "材料": "12.2",
  130. "机械": "12.3",
  131. "暂列金额(不含计日工总额)": "13",
  132. "投标报价": "14"
  133. }
  134. const ratioCodeMap = {
  135. "01ZJF":"0",
  136. "02JXF":"1",
  137. "03WHF":"2",
  138. "04ACFZF":"3"
  139. }
  140. function getBasePrice(projectGLJID, tenderProject) {
  141. let glj = _.find(tenderProject.projectGLJ.datas.gljList, {
  142. id: projectGLJID
  143. })
  144. return glj ? gljUtil.getBasePrice(glj, null, null, null, decimalObj, false, _, scMathUtil) : 0;
  145. }
  146. function getFeeRate(programID, fieldName, tenderProject) {
  147. let rate = 0;
  148. let template = tenderProject.calcProgram.compiledTemplates;
  149. if (template[programID]) {
  150. let item = _.find(template[programID].calcItems, {
  151. fieldName: fieldName
  152. })
  153. if (item) rate = item.feeRate;
  154. }
  155. return rate
  156. }
  157. function billNameChecking(bNode,projectName,fixedFlag) {
  158. let data = bNode.data;
  159. let fail = null;
  160. let pass = true;
  161. if (data.flagsIndex && data.flagsIndex.fixed) {
  162. let flag = data.flagsIndex.fixed.flag;
  163. switch (flag) {
  164. case fixedFlag.ONE_SEVEN_BILLS:
  165. pass = data.name == "第100章至700章清单" || data.name == "第100章至700章清单合计";
  166. break;
  167. case fixedFlag.PROVISIONAL_TOTAL:
  168. pass = data.name == "已包含在清单合计中的材料、工程设备、专业工程暂估价合计";
  169. break;
  170. case fixedFlag.BILLS_TOTAL_WT_PROV:
  171. pass = data.name == "清单合计减去材料、工程设备、专业工程暂估价合计";
  172. break;
  173. case fixedFlag.DAYWORK_LABOR:
  174. pass = data.name == "计日工合计";
  175. break;
  176. /* case fixedFlag.LABOUR_SERVICE:
  177. pass = data.name == "劳务";
  178. break;
  179. case fixedFlag.MATERIAL:
  180. pass = data.name == "材料";
  181. break;
  182. case fixedFlag.CONSTRUCTION_MACHINE:
  183. pass = data.name == "机械";
  184. break; */
  185. case fixedFlag.PROVISIONAL:
  186. pass = data.name == "暂列金额(不含计日工总额)";
  187. break;
  188. case fixedFlag.TOTAL_COST:
  189. pass = data.name == "投标报价";
  190. break;
  191. case fixedFlag.ONE_HUNDRED_BILLS:
  192. pass = data.name == "清单 第100章 总则";
  193. break;
  194. }
  195. } else {
  196. if (bNode.parent) {
  197. const pdata = bNode.parent.data;
  198. if (pdata.flagsIndex && pdata.flagsIndex.fixed && pdata.flagsIndex.fixed.flag == fixedFlag.ONE_SEVEN_BILLS) {
  199. if (!sectionNameMap[data.name]) pass = false
  200. }
  201. }
  202. }
  203. if(pass == false)fail = { hint: `清单:"${data.name?data.name:""}",名字不符合规范!`, type: projectName }
  204. return fail;
  205. }
  206. /**
  207. *
  208. * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理
  209. * @param {Number} exportKind - 导出类型,招标、投标、控制价
  210. * @param {Object} projectData - 项目表数据:{ 建设项目Data, children: [单位工程...] }
  211. * @param {Object} tenderDetailMap - 单位工程ID与getData接口数据(projectObj.project的结构)的映射。
  212. * @return {Promise<Array>} - 返回的数据结构必须按照规定:[{ data, exportKind, fileName }],参考web\building_saas\standard_interface\index.js中的注释说明
  213. */
  214. async function entry(areaKey, exportKind, projectData, tenderDetailMap) {
  215. const {
  216. CONFIG: {
  217. TYPE
  218. },
  219. UTIL,
  220. Element
  221. } = INTERFACE_EXPORT_BASE;
  222. const {
  223. EXPORT_KIND: {
  224. BID_INVITATION,
  225. BID_SUBMISSION,
  226. CONTROL
  227. },
  228. fixedFlag,
  229. } = window.commonConstants;
  230. let cprjType = {
  231. 1: "GCLQD", // 招标
  232. 2: "TBBJ", // 投标
  233. 3: "ZBKZJ", // 控制价
  234. };
  235. const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  236. const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  237. const isControl = exportKind === CONTROL; // 是否是控制价
  238. function emptyElement(name) {
  239. this.name = name;
  240. this.attrs = [];
  241. this.children = [];
  242. }
  243. // 建设项目根节点信息
  244. function CprjInfo(projectName) {
  245. const attrs = [{
  246. name: "CprjName",
  247. value: projectName,
  248. },
  249. {
  250. name: "CprjType",
  251. value: cprjType[exportKind],
  252. },
  253. ];
  254. Element.call(this, "CprjInfo", attrs);
  255. }
  256. // 项目基本信息
  257. function SystemInfo(projectData) {
  258. let baseInfo = _.find(projectData.property.basicInformation, {
  259. dispName: "基本信息",
  260. });
  261. //“招标工程量清单”、“招标控制价”时,输出该字段,为导出该文件的当前时间
  262. let makeData = {
  263. value : UTIL.getNowFormatTime(true)
  264. }
  265. //投标的时候取基本信息的makeData字段
  266. if(isBidSubmission) makeData = _.find(baseInfo.items, { "key": "makeDate" });
  267. // 取编制软件序列号所属单位。读取项目属性-建设项目基本信息的“投标单位”字段。该字段需要模板中新增。等确定后再修改
  268. // let softwareNumHolder = _.find(baseInfo.items, { "key": "bidderName" });
  269. let softwareNumHolder = userCompany; // userCompany是在main界面上已经有现成的(类似userAccount, userID)
  270. let hardID = UTIL.generateHardwareId();
  271. let [cpuId, diskId, macId] = hardID.split(";");
  272. // const orgScretInfoStr = `SoftwareName=纵横公路工程造价管理软件,SoftwareVer=V${VERSION},SoftwareCompany=珠海纵横创新软件有限公司,SoftwareNumber=${userID},HardNumber=${diskId},MacAddress=${macId},SoftwareNumberHolder=${softwareNumHolder}`
  273. const orgScretInfoStr = `SoftwareName=纵横公路工程造价管理软件,SoftwareVer=V${VERSION},SoftwareCompany=珠海纵横创新软件有限公司,SoftwareNumber=${window.btoa(userID)},HardNumber=${window.btoa(diskId)},MacAddress=${window.btoa(macId)},SoftwareNumberHolder=${softwareNumHolder}`
  274. let scretInfo = sm3Digest(orgScretInfoStr);
  275. const attrs = [{
  276. name: "Name",
  277. value: "公路工程造价数据标准",
  278. },
  279. {
  280. name: "Version",
  281. value: "1.0",
  282. },
  283. {
  284. name: "SoftwareName",
  285. value: "纵横公路工程造价管理软件",
  286. },
  287. {
  288. name: "SoftwareVer",
  289. value: "V" + VERSION,
  290. },
  291. {
  292. name: "SoftwareCompany",
  293. value: "珠海纵横创新软件有限公司",
  294. },
  295. {
  296. name: "MakeDate",
  297. value: makeData?makeData.value:"",
  298. },
  299. {
  300. name: "SoftwareNumber",
  301. value: window.btoa(userID),
  302. },
  303. {
  304. name: "HardNumber",
  305. value: window.btoa(diskId),
  306. },
  307. {
  308. name: "MacAddress",
  309. value: window.btoa(macId),
  310. },
  311. {
  312. name: "SoftwareNumberHolder",
  313. value: softwareNumHolder,
  314. },
  315. {
  316. name: "SecretInfo",
  317. value: scretInfo,
  318. },
  319. ];
  320. Element.call(this, "SystemInfo", attrs);
  321. }
  322. //造价依据
  323. function CostBasis() {
  324. // ItemStandardNo="GYSFX-000000-2018-86"
  325. const attrs = [{
  326. name: "MakeRuleNo",
  327. value: "GYSBB-000000-2018-86",
  328. },
  329. {
  330. name: "MakeRuleName",
  331. value: "公路工程建设项目概算预算编制办法",
  332. },
  333. {
  334. name: "ItemStandardNo",
  335. value: "GYSFX-000000-2018-86",
  336. },
  337. ];
  338. Element.call(this, "CostBasis", attrs);
  339. //定额库信息
  340. //to do 改成实际的值
  341. function NormLib() {
  342. const attrs = [{
  343. name: "NormLibNo",
  344. value: "YSDE-000000-2018-86",
  345. },
  346. {
  347. name: "NormLibName",
  348. value: "部颁公路工程预算定额(2018)",
  349. },
  350. {
  351. name: "Type",
  352. value: "ZDEK",
  353. },
  354. ];
  355. Element.call(this, "NormLib", attrs);
  356. }
  357. this.children.push(new NormLib());
  358. }
  359. function Rate(tenderProject, feeRateInfo, seirNo) {
  360. //RateNo="1" Name="纵横软件测试版本" RateLibNo="GYSFL-000000-2018-86"
  361. const attrs = [{
  362. name: "RateNo",
  363. value: seirNo,
  364. },
  365. {
  366. name: "Name",
  367. value: feeRateInfo.name,
  368. },
  369. {
  370. name: "RateLibNo",
  371. value: feeLibNoMap[feeRateInfo.libID],
  372. },
  373. ];
  374. Element.call(this, "Rate", attrs);
  375. let RateParams = new emptyElement("RateParams");
  376. let subRates = projectObj.project.FeeRate.getAllSubRates(feeRateInfo.rates);
  377. for (let s of subRates) {
  378. let sname = s.name.replace("(%)", "");
  379. sname = sname.replace("(%)", "");
  380. if (feeRateMap[sname]) {
  381. let value = "";
  382. if (s.editable) {
  383. let sel = _.find(s.optionList, {
  384. selected: true,
  385. });
  386. if (sel) {
  387. value = sel.name;
  388. } else if (gljUtil.isDef(s.value)) {
  389. value = s.value;
  390. }
  391. } else {
  392. value = _.findIndex(s.optionList, {
  393. selected: true,
  394. });
  395. if (value == -1) value = 0;
  396. }
  397. /* if (sname == '利润') tenderProject.ProfitRate = value;
  398. if (sname == '税金') tenderProject.TaxRate = value; */
  399. RateParams.children.push(new RateParam(feeRateMap[sname], value));
  400. }
  401. }
  402. this.children.push(RateParams);
  403. function RateParam(RateTypeNo, RateParamNo) {
  404. //<RateParam RateTypeNo="DJSGZJFFL" RateParamNo="0" Ratio="100"/>
  405. const attrs = [{
  406. name: "RateTypeNo",
  407. value: RateTypeNo,
  408. },
  409. {
  410. name: "RateParamNo",
  411. value: RateParamNo,
  412. },
  413. {
  414. name: "Ratio",
  415. value: "100",
  416. },
  417. ];
  418. Element.call(this, "RateParam", attrs);
  419. }
  420. let RateValues = new emptyElement("RateValues");
  421. function RateValue(CostTypeNo, RateTypeNo, value) {
  422. const attrs = [{
  423. name: "CostTypeNo",
  424. value: CostTypeNo,
  425. },
  426. {
  427. name: "RateTypeNo",
  428. value: RateTypeNo,
  429. },
  430. {
  431. name: "RateValue",
  432. value: value,
  433. },
  434. ];
  435. Element.call(this, "RateValue", attrs);
  436. }
  437. let prefix = "";
  438. for (let r of feeRateInfo.rates) {
  439. if (!r.ParentID && feeRateMap[r.name]) prefix = feeRateMap[r.name];
  440. if (feeRateMap[r.name] && r.ParentID) {
  441. RateValues.children.push(new RateValue(prefix, feeRateMap[r.name], r.rate));
  442. }
  443. }
  444. this.children.push(RateValues);
  445. }
  446. function Pract(tpdata, seriNo) {
  447. let pgljData = tpdata.projectGLJ.datas;
  448. let decimalObj = tpdata.property.decimal;
  449. const attrs = [{
  450. name: "PractNo",
  451. value: seriNo,
  452. },
  453. {
  454. name: "Name",
  455. value: pgljData.constData.usedUnitPriceInfo.name,
  456. },
  457. ];
  458. Element.call(this, "Pract", attrs);
  459. let Param = {
  460. name: "Param",
  461. attrs: [{
  462. name: "TaxLibNo",
  463. value: "CCSBZ-440000-2019-544",
  464. },
  465. {
  466. name: "AuxRate",
  467. value: pgljData.constData.assistProductionFeeRate,
  468. },
  469. ],
  470. children: [],
  471. };
  472. if (isBidSubmission || isControl) { //导出到招标文件中,不输出这一部分。
  473. let elecDatas = electrovalenceObj.getElectrovalenceDatas(null, pgljData.com_electrovalence, pgljData.gljList);
  474. electrovalenceObj.calcPertElectrovalenceMarketPrice(elecDatas);
  475. for (let e of elecDatas) {
  476. let Electro = {
  477. name: "Electro",
  478. attrs: [{
  479. name: "Code",
  480. value: e.code,
  481. },
  482. {
  483. name: "Price",
  484. value: e.electPrice,
  485. },
  486. {
  487. name: "Ratio",
  488. value: e.coe,
  489. },
  490. ],
  491. children: [],
  492. };
  493. Param.children.push(Electro);
  494. }
  495. }
  496. this.children.push(Param);
  497. function Mp(g) {
  498. const attrs = [{
  499. name: "Code",
  500. value: g.code,
  501. },
  502. {
  503. name: "PractName",
  504. value: g.name,
  505. },
  506. {
  507. name: "Spec",
  508. value: g.specs,
  509. },
  510. {
  511. name: "Unit",
  512. value: g.unit,
  513. },
  514. {
  515. name: "BudgetPrice",
  516. value: g.priceInfo.tenderPrice,
  517. },
  518. {
  519. name: "NormPrice",
  520. value: g.priceInfo.basePrice,
  521. },
  522. {
  523. name: "IsAdd",
  524. value: g.unit_price.is_add,
  525. },
  526. ];
  527. Element.call(this, "Mp", attrs);
  528. }
  529. function Material(g) {
  530. const attrs = [{
  531. name: "Code",
  532. value: g.code,
  533. },
  534. {
  535. name: "PractName",
  536. value: g.name,
  537. },
  538. {
  539. name: "Spec",
  540. value: g.specs,
  541. },
  542. {
  543. name: "Unit",
  544. value: g.unit,
  545. },
  546. {
  547. name: "BudgetPrice",
  548. value: g.priceInfo.tenderPrice,
  549. },
  550. {
  551. name: "NormPrice",
  552. value: g.priceInfo.basePrice,
  553. },
  554. {
  555. name: "IsAdd",
  556. value: g.unit_price.is_add,
  557. },
  558. {
  559. name: "OrgPrice",
  560. value: g.unit_price.originalPrice ? g.unit_price.originalPrice : 0,
  561. },
  562. {
  563. name: "TransFee",
  564. value: g.unit_price.unitFreight ? g.unit_price.unitFreight : 0,
  565. },
  566. {
  567. name: "GwRate",
  568. value: g.unit_price.grossWeightCoe_n ? g.unit_price.grossWeightCoe_n : 0,
  569. },
  570. {
  571. name: "OffSiteLf",
  572. value: g.unit_price.offSiteTransportLossRate_n ? g.unit_price.offSiteTransportLossRate_n : 0,
  573. },
  574. {
  575. name: "OnSiteLf",
  576. value: 0,
  577. },
  578. {
  579. name: "LoadLf",
  580. value: g.unit_price.handlingLossRate_n ? g.unit_price.handlingLossRate_n : 0,
  581. },
  582. {
  583. name: "StoreRate",
  584. value: g.unit_price.purchaseStorageRate_n ? g.unit_price.purchaseStorageRate_n : 0,
  585. },
  586. {
  587. name: "PackageRecycleFee",
  588. value: g.unit_price.packageRecoverValue ? g.unit_price.packageRecoverValue : 0,
  589. },
  590. ];
  591. Element.call(this, "Material", attrs);
  592. // if (g.unit_price.calcMaterial == 1) { //有材料计算
  593. // let index = gljUtil.getIndex(g);
  594. // let orList = [];
  595. // for (let o of pgljData.originalList) {
  596. // if (o.connect_key == index) orList.push(new OrgPrices(o));
  597. // }
  598. // if (orList.length > 0) this.children = orList;
  599. // }
  600. function CostStructure(r) {
  601. //待获取
  602. this.name = "CostStructure";
  603. this.attrs = [];
  604. this.children = [];
  605. }
  606. function Consume(r, o) {
  607. this.name = "Consume";
  608. this.attrs = [];
  609. this.children = [];
  610. for (let g of o.ration_gljs) {
  611. if (g.rationID == r.ID) {
  612. let r_quantity = scMathUtil.roundForObj(r.quantity, tpdata.property.decimal.ration.quantity);
  613. this.children.push(new ConsumeItem(g, r_quantity));
  614. }
  615. }
  616. }
  617. function ConsumeItem(g, ration_quantity) {
  618. const attrs = [{
  619. name: "Code", //待获取
  620. value: g.code,
  621. },
  622. {
  623. name: "Consumption",
  624. value: scMathUtil.roundForObj(ration_quantity * parseFloat(g.quantity), tpdata.property.decimal.glj.quantity),
  625. },
  626. ];
  627. Element.call(this, "ConsumeItem", attrs);
  628. }
  629. function Norm(r, o) {
  630. const attrs = [{
  631. name: "NormLibNo", //待获取
  632. value: "",
  633. },
  634. {
  635. name: "DisplayCode",
  636. value: r.code,
  637. },
  638. {
  639. name: "Name",
  640. value: r.name,
  641. },
  642. {
  643. name: "Unit",
  644. value: r.unit,
  645. },
  646. {
  647. name: "Num",
  648. value: r.quantity,
  649. },
  650. {
  651. name: "CostTypeNo",
  652. value: "", //待获取
  653. },
  654. {
  655. name: "FabricationCost", //待获取
  656. value: "",
  657. },
  658. {
  659. name: "AdjustStatus",
  660. value: "",
  661. },
  662. ];
  663. Element.call(this, "Norm", attrs);
  664. this.children.push(new CostStructure(r));
  665. this.children.push(new Consume(r, o));
  666. }
  667. function SelfCollect(o) {
  668. const attrs = [{
  669. name: "OtherCost",
  670. value: 0,
  671. }, ];
  672. Element.call(this, "SelfCollect", attrs);
  673. for (let r of o.rations) {
  674. this.children.push(new Norm(r, o));
  675. }
  676. }
  677. function OrgPrices(o) {
  678. const attrs = [{
  679. name: "OrgPricevalue",
  680. value: o.supplyPrice,
  681. },
  682. {
  683. name: "Ratio",
  684. value: o.coe,
  685. },
  686. ];
  687. Element.call(this, "OrgPrices", attrs);
  688. if (!o.rations) return;
  689. this.children.push(new SelfCollect(o));
  690. }
  691. }
  692. function Mech(g,gljKeyMap) {
  693. const attrs = [{
  694. name: "Code",
  695. value: g.code,
  696. },
  697. {
  698. name: "PractName",
  699. value: g.name,
  700. },
  701. {
  702. name: "Spec",
  703. value: g.specs,
  704. },
  705. {
  706. name: "Unit",
  707. value: g.unit,
  708. },
  709. {
  710. name: "BudgetPrice",
  711. value: g.priceInfo.tenderPrice,
  712. },
  713. {
  714. name: "NormPrice",
  715. value: g.priceInfo.basePrice,
  716. },
  717. {
  718. name: "IsAdd",
  719. value: g.unit_price.is_add,
  720. },
  721. ];
  722. Element.call(this, "Mech", attrs);
  723. let FixedCostItems = [];
  724. let fcsum = 0;
  725. let VariableCostItems = [];
  726. let vcsum = 0;
  727. if (g.ratio_data && g.ratio_data.length > 0) {
  728. for (let ratio of g.ratio_data) {
  729. let rIndex = gljUtil.getIndex(ratio);
  730. let rglj = gljKeyMap[rIndex];
  731. let ts = scMathUtil.roundForObj(parseFloat(ratio.consumption) * rglj.priceInfo.tenderPrice, decimalObj.glj.unitPrice);
  732. if (FixedCostMap[ratio.name]) {
  733. FixedCostItems.push(new FixedCostItem(ratio));
  734. fcsum = scMathUtil.roundForObj(fcsum + ts, decimalObj.glj.unitPrice);
  735. } else {
  736. VariableCostItems.push(new VariableCostItem(ratio));
  737. vcsum = scMathUtil.roundForObj(vcsum + ts, decimalObj.glj.unitPrice);
  738. }
  739. }
  740. }
  741. if (FixedCostItems.length > 0) {
  742. let fc = new FixedCost(fcsum);
  743. fc.children = FixedCostItems;
  744. this.children.push(fc);
  745. }
  746. if (VariableCostItems.length > 0) {
  747. let vc = new VariableCost(vcsum);
  748. vc.children = VariableCostItems;
  749. this.children.push(vc);
  750. }
  751. function VariableCost(sum) {
  752. const attrs = [{
  753. name: "VariableCostSum",
  754. value: sum,
  755. }];
  756. Element.call(this, "VariableCost", attrs);
  757. }
  758. function VariableCostItem(item) {
  759. const attrs = [{
  760. name: "VariableCostNo",
  761. value: item.code,
  762. },{
  763. name: "Consumption",
  764. value: item.consumption,
  765. }]
  766. Element.call(this, "VariableCostItem", attrs);
  767. }
  768. function FixedCost(sum) {
  769. const attrs = [{
  770. name: "FixedCostSum",
  771. value: sum,
  772. }, {
  773. name: "FixedRate",
  774. value: 1,
  775. }];
  776. Element.call(this, "FixedCost", attrs);
  777. }
  778. function FixedCostItem(item) {
  779. const attrs = [{
  780. name: "FixedCostNo",
  781. value: ratioCodeMap[item.code],
  782. },{
  783. name: "Sum",
  784. value: item.consumption,
  785. }]
  786. Element.call(this, "FixedCostItem", attrs);
  787. }
  788. }
  789. let Mps = new emptyElement("Mps");
  790. let Materials = new emptyElement("Materials");
  791. let Mechs = new emptyElement("Mechs");
  792. let gljKeyMap = {};
  793. let temMechs = [];
  794. if (isBidSubmission || isControl) { //导出到招标文件中,不输出这一部分。
  795. for (let g of pgljData.gljList) {
  796. if (!g.quantity) {
  797. continue;
  798. }
  799. let type = g.type + "";
  800. gljKeyMap[gljUtil.getIndex(g)] = g;
  801. type = type.charAt(0);
  802. if (type == "1") {
  803. Mps.children.push(new Mp(g));
  804. } else if (type == "2" || type == 5) {
  805. Materials.children.push(new Material(g));
  806. } else if (type == "3") {
  807. temMechs.push(g);
  808. }
  809. }
  810. for (let t of temMechs) {
  811. Mechs.children.push(new Mech(t,gljKeyMap));
  812. }
  813. }
  814. this.children.push(Mps);
  815. this.children.push(Materials);
  816. this.children.push(Mechs);
  817. }
  818. function EprjInfo(tenderProject) {
  819. let bills = tenderProject.Bills.datas;
  820. let feature = tenderProject.property.projectFeature ? tenderProject.property.projectFeature : [];
  821. let totalItem = null;
  822. let proItem = null; //暂列金额项
  823. let safeItem = null;
  824. let oneToSevenItem = null;
  825. for (let b of bills) {
  826. if (b.flagsIndex && b.flagsIndex.fixed && b.flagsIndex.fixed.flag == fixedFlag.TOTAL_COST) totalItem = b;
  827. if (b.flagsIndex && b.flagsIndex.fixed && b.flagsIndex.fixed.flag == fixedFlag.PROVISIONAL) proItem = b;
  828. if (b.flagsIndex && b.flagsIndex.fixed && b.flagsIndex.fixed.flag == fixedFlag.ONE_SEVEN_BILLS) oneToSevenItem = b;
  829. if(b.code == "102-3" && b.name=="安全生产费") safeItem = b;
  830. }
  831. const attrs = [{
  832. name: "Name",
  833. value: tenderProject.projectInfo.name,
  834. },
  835. {
  836. name: "Sums",
  837. value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
  838. },
  839. ];
  840. //输出控制价、投标文件时,取调价后的标段总造价。
  841. //输出招标文件时,取0
  842. if (isBidInvitation) attrs[1].value = 0;
  843. Element.call(this, "EprjInfo", attrs);
  844. this.children.push(new SummaryOfCost(totalItem, proItem,safeItem,oneToSevenItem,feature));
  845. this.children.push(new MakeInfo(tenderProject));
  846. this.children.push(new Params(tenderProject));
  847. this.children.push(new getBillsItems(tenderProject));
  848. this.children.push(new getIndexs(tenderProject));
  849. let bidEvaluationMainMaterials = getBidEvaluationMainMaterial(tenderProject);
  850. if(bidEvaluationMainMaterials.length > 0) this.children.push(...bidEvaluationMainMaterials);
  851. //山东接口还需要增加几个表的数据(就是把原报表的显示数据转到投标文件里)
  852. // 1. 投标报价汇总表
  853. this.children.push(new quoteSummary(tenderProject));
  854. // 2. 计日工表
  855. let spdw = sporadicWork(tenderProject);
  856. if (spdw) {
  857. this.children.push(spdw);
  858. }
  859. // 3. 材料暂估价表
  860. let estMaterialRpt = materialEstimate(tenderProject);
  861. if (estMaterialRpt) {
  862. this.children.push(estMaterialRpt);
  863. }
  864. // 4. 工程设备暂估价表
  865. let estMachineRpt = getMachineTempEst(tenderProject);
  866. if (estMachineRpt) {
  867. this.children.push(estMachineRpt);
  868. }
  869. // 5. 专业工程暂估价表
  870. let estSpecPrjRpt = getSpecPrjEst(tenderProject);
  871. if (estSpecPrjRpt) {
  872. this.children.push(estSpecPrjRpt);
  873. }
  874. // 6. 工程量清单单价分析表
  875. let billAnalyzeRpt = getBillsAnalyze(tenderProject);
  876. if (billAnalyzeRpt) {
  877. this.children.push(billAnalyzeRpt);
  878. }
  879. }
  880. function _getBidGljCode(tenderProject, orgGlj) {
  881. let rst = orgGlj.code;
  882. if (tenderProject.bid_evaluation_list && tenderProject.bid_evaluation_list.datas) {
  883. for (let bGlj of tenderProject.bid_evaluation_list.datas) {
  884. if (bGlj.projectGLJID === orgGlj.id) {
  885. rst = bGlj.seq;
  886. break;
  887. }
  888. }
  889. }
  890. return rst;
  891. }
  892. function _getFee(bill, key = 'common', valueKey = 'tenderTotalFee') {
  893. let rstSum = 0;
  894. if (bill) {
  895. let dtlB = (bill.data) ? bill.data : bill;
  896. if (dtlB.fees) {
  897. for (let fee of dtlB.fees) {
  898. if (fee.fieldName === key) {
  899. rstSum = fee[valueKey];
  900. break;
  901. }
  902. }
  903. }
  904. }
  905. return rstSum;
  906. };
  907. function _getNumValueByExportKind(orgSum) {
  908. let rst = orgSum;
  909. // const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  910. // const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  911. // const isControl = exportKind === CONTROL; // 是否是控制价
  912. //根据导出类型(上面3个),输出实际合计或price
  913. if (isBidInvitation) {
  914. rst = 0;
  915. }
  916. return rst;
  917. }
  918. function _getStrValueByExportKind(orgStr) {
  919. let rst = orgStr;
  920. // const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  921. // const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  922. // const isControl = exportKind === CONTROL; // 是否是控制价
  923. //根据导出类型(上面3个),输出实际合计或price
  924. if (isBidInvitation) {
  925. rst = '';
  926. }
  927. return rst;
  928. }
  929. function quoteSummary(tenderProject) {
  930. let quoteSummaryItem = new emptyElement('QuoteSummary');
  931. // let attrs = [];
  932. //1. 取固定清单,
  933. // 1.1 100~700章总清单(flags有属性为19的那个) -> topNode100To700
  934. // 1.2 已包含在清单合计中的材料、工程设备、专业工程暂估价合计 标记:20
  935. // 1.3 清单合计减去材料、工程设备、专业工程暂估价|合计 标记:21
  936. // 1.4 计日工合计 标记:22
  937. // 1.5 暂列金额(不含计日工总额) 标记:26
  938. // 1.6 投标报价 标记:9
  939. let topNode100To700, nodeZXZDJ, nodeQDKCZXZDJ, nodeJRG, nodeZLJE, nodeTBBJ;
  940. let chapterNodes = [];
  941. tenderProject.Bills.datas.forEach((bill)=> {
  942. if (bill.flags && bill.flags.length > 0) {
  943. for (let flag of bill.flags) {
  944. switch(flag.flag) {
  945. case 19 :
  946. topNode100To700 = bill;
  947. break;
  948. case 20 :
  949. nodeZXZDJ = bill;
  950. break;
  951. case 21 :
  952. nodeQDKCZXZDJ = bill;
  953. break;
  954. case 22 :
  955. nodeJRG = bill;
  956. break;
  957. case 26 :
  958. nodeZLJE = bill;
  959. break;
  960. case 9 :
  961. nodeTBBJ = bill;
  962. break;
  963. default :
  964. break;
  965. }
  966. }
  967. }
  968. });
  969. //2. 然后获取topNode100To700下的所有次一级清单(100章...700章)
  970. if (topNode100To700) {
  971. for (let rootBill of tenderProject.Bills.tree.roots) {
  972. // 100~700章总清单在top级别(山东养护)
  973. if (rootBill.data.ID === topNode100To700.ID) {
  974. rootBill.children.forEach((subBill)=> {
  975. if (subBill.data.name.includes('00章')) {
  976. chapterNodes.push(subBill);
  977. }
  978. });
  979. break;
  980. }
  981. }
  982. }
  983. //3. 拼凑数据
  984. let nodeAttrs = [];
  985. if (topNode100To700) {
  986. let order = 1;
  987. //读取投标报价汇总表信息。1.ItemNo 序号。2.ChapterNo 章次。 3.Name 科目名称。 4.Sum 金额。
  988. chapterNodes.forEach((cnode)=> {
  989. let chapterIdx = cnode.data.name.indexOf("00章");
  990. nodeAttrs.push({ItemNo: order, ChapterNo: cnode.data.name.substr(chapterIdx - 1, 3), Name: cnode.data.name, Sum: _getFee(cnode)});
  991. order++;
  992. });
  993. nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: '第100章至700章清单合计', Sum: _getFee(topNode100To700)});
  994. order++;
  995. if (nodeZXZDJ) {
  996. nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: '已包含在清单合计中的材料、工程设备、专业工程暂估价合计', Sum: _getFee(nodeZXZDJ)});
  997. order++;
  998. }
  999. if (nodeQDKCZXZDJ) {
  1000. nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: `清单合计减去材料、工程设备、专业工程暂估价合计(即${order - 2}-${order - 1})=${order}`, Sum: _getFee(nodeQDKCZXZDJ)});
  1001. order++;
  1002. }
  1003. if (nodeJRG) {
  1004. nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: `计日工合计`, Sum: _getFee(nodeJRG)});
  1005. order++;
  1006. }
  1007. if (nodeZLJE) {
  1008. nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: `暂列金额(不含计日工总额)`, Sum: _getFee(nodeZLJE)});
  1009. order++;
  1010. }
  1011. if (nodeTBBJ) {
  1012. nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: `投标报价(${chapterNodes.length + 1} + ${order - 2}+${order - 1})=${order}`, Sum: _getFee(nodeTBBJ)});
  1013. order++;
  1014. }
  1015. }
  1016. function _Item(item) {
  1017. const attrs = [
  1018. { name: 'ItemNo',
  1019. value: item.ItemNo
  1020. },
  1021. { name: 'ChapterNo',
  1022. value: item.ChapterNo
  1023. },
  1024. { name: 'Name',
  1025. value: item.Name
  1026. },
  1027. { name: 'Sum',
  1028. value: _getNumValueByExportKind(item.Sum)
  1029. // value: 0 // 所有清单的金额都是0
  1030. }
  1031. ];
  1032. let rst = new emptyElement('Item');
  1033. rst.attrs.push(...attrs);
  1034. return rst;
  1035. }
  1036. for (let attr of nodeAttrs) {
  1037. quoteSummaryItem.children.push(_Item(attr));
  1038. }
  1039. return quoteSummaryItem;
  1040. }
  1041. function sporadicWork(tenderProject) {
  1042. //计日工表,含:劳务、材料、施工机械、计日工汇总
  1043. let hasSporadicWork = false;
  1044. let sporadicWorkItem = new Element('SporadicWork');
  1045. let nodeLabour, nodeMaterial, nodeMachine;
  1046. //首先收集过滤计日工相关清单
  1047. tenderProject.Bills.datas.forEach((bill)=> {
  1048. if (bill.flags && bill.flags.length > 0) {
  1049. for (let flag of bill.flags) {
  1050. switch(flag.flag) {
  1051. case 23 :
  1052. nodeLabour = bill;
  1053. break;
  1054. case 24 :
  1055. nodeMaterial = bill;
  1056. break;
  1057. case 25 :
  1058. nodeMachine = bill;
  1059. break;
  1060. default :
  1061. break;
  1062. }
  1063. }
  1064. }
  1065. });
  1066. const _buildWorkNodeItem = function(orgNode, subNodes, parentKey, childKey) {
  1067. let parentNode = new Element(parentKey);
  1068. sporadicWorkItem.children.push(parentNode);
  1069. const pSumAttrs = [
  1070. {
  1071. name: 'Sum',
  1072. value: _getNumValueByExportKind(_getFee(orgNode))
  1073. // value: 0
  1074. }
  1075. ];
  1076. // Element.call(this, parentKey, pSumAttrs);
  1077. parentNode.attrs.push(...pSumAttrs);
  1078. subNodes.forEach((node)=> {
  1079. let childNode = new Element(childKey);
  1080. parentNode.children.push(childNode);
  1081. const attrs = [
  1082. { name: 'ItemNo',
  1083. value: node.code
  1084. }, {
  1085. name: 'Name',
  1086. value: node.name
  1087. }, {
  1088. name: 'Unit',
  1089. value: node.unit
  1090. }, {
  1091. name: 'Num',
  1092. value: node.quantity
  1093. }, {
  1094. name: 'Price',
  1095. value: _getNumValueByExportKind(_getFee(node, 'common', 'tenderUnitFee'))
  1096. // value: 0
  1097. }, {
  1098. name: 'Sum',
  1099. value: _getNumValueByExportKind(_getFee(node))
  1100. // value: 0
  1101. }
  1102. ];
  1103. childNode.attrs.push(...attrs);
  1104. });
  1105. };
  1106. //1. 判断劳务
  1107. if (nodeLabour) {
  1108. let subNodes = [];
  1109. tenderProject.Bills.datas.forEach((bill)=> {
  1110. if (bill.ParentID === nodeLabour.ID) {
  1111. subNodes.push(bill);
  1112. }
  1113. });
  1114. if (subNodes.length > 0) {
  1115. hasSporadicWork = true;
  1116. //创建劳务Mps节点及劳务Mps下Mp子节点
  1117. _buildWorkNodeItem(nodeLabour, subNodes, 'Mps', 'Mp');
  1118. }
  1119. }
  1120. //2. 判断材料
  1121. if (nodeMaterial) {
  1122. let subNodes = [];
  1123. tenderProject.Bills.datas.forEach((bill)=> {
  1124. if (bill.ParentID === nodeMaterial.ID) {
  1125. subNodes.push(bill);
  1126. }
  1127. });
  1128. if (subNodes.length > 0) {
  1129. hasSporadicWork = true;
  1130. //创建材料Materials节点及劳务Materials下Material子节点
  1131. _buildWorkNodeItem(nodeMaterial, subNodes, 'Materials', 'Material');
  1132. }
  1133. }
  1134. //3. 判断施工机械
  1135. if (nodeMachine) {
  1136. let subNodes = [];
  1137. tenderProject.Bills.datas.forEach((bill)=> {
  1138. if (bill.ParentID === nodeMachine.ID) {
  1139. subNodes.push(bill);
  1140. }
  1141. });
  1142. if (subNodes.length > 0) {
  1143. hasSporadicWork = true;
  1144. //创建施工机械Meehs节点及劳务Meehs下Meeh子节点
  1145. _buildWorkNodeItem(nodeMachine, subNodes, 'Mechs', 'Mech');
  1146. }
  1147. }
  1148. //4. 判断计日工汇总
  1149. if (hasSporadicWork) {
  1150. let summaryNode = new Element('Summary');
  1151. sporadicWorkItem.children.push(summaryNode);
  1152. const pSumAttrs = [
  1153. {
  1154. name: 'Sum',
  1155. // value: _getFee(nodeLabour) + _getFee(nodeMaterial) + _getFee(nodeMachine)
  1156. value: _getNumValueByExportKind(_getFee(nodeLabour) + _getFee(nodeMaterial) + _getFee(nodeMachine))
  1157. }
  1158. ];
  1159. summaryNode.attrs = pSumAttrs;
  1160. //把劳务、材料、施工机械
  1161. function _workItem(node, name, remark='') {
  1162. let childNode = new Element('Item');
  1163. summaryNode.children.push(childNode);
  1164. const attrs = [
  1165. {
  1166. name: "Name",
  1167. value: name,
  1168. },
  1169. {
  1170. name: "Sum",
  1171. value: _getNumValueByExportKind(_getFee(node)),
  1172. },
  1173. {
  1174. name: "Remark",
  1175. value: remark,
  1176. }
  1177. ]
  1178. childNode.attrs.push(...attrs);
  1179. }
  1180. _workItem(nodeLabour, '劳务');
  1181. _workItem(nodeMaterial, '材料');
  1182. _workItem(nodeMachine, '机械');
  1183. }
  1184. //返回
  1185. if (hasSporadicWork) {
  1186. return sporadicWorkItem;
  1187. } else {
  1188. return null;
  1189. }
  1190. }
  1191. function materialEstimate(tenderProject) {
  1192. let mEstNode = new emptyElement('MaterialEstimate');
  1193. let items = [];
  1194. let billItems = [];
  1195. let itemNo = 1;
  1196. //材料暂估价明细
  1197. tenderProject.Bills.datas.forEach((bill)=> {
  1198. if (bill.specialProvisional === '材料暂估') {
  1199. billItems.push(bill);
  1200. }
  1201. });
  1202. if (billItems.length > 0) {
  1203. billItems.forEach((bill)=> {
  1204. let mEstItemNode = new emptyElement('Item');
  1205. mEstNode.children.push(mEstItemNode);
  1206. let attrs = [
  1207. {name: 'ItemNo', value: itemNo},
  1208. {name: 'Code', value: bill.code},
  1209. {name: 'Number', value: bill.code},
  1210. {name: 'Name', value: bill.name},
  1211. {name: 'Unit', value: bill.unit},
  1212. {name: 'Num', value: bill.quantity},
  1213. {name: 'Price', value: _getNumValueByExportKind(_getFee(bill, 'common', 'tenderUnitFee'))},
  1214. {name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), 0)), type:TYPE.DECIMAL},
  1215. // {name: 'Price', value: 0},
  1216. // {name: 'Sum', value: 0},
  1217. {name: 'Remark', value: (bill.remark) ? glj.remark : ''}
  1218. ];
  1219. itemNo++;
  1220. mEstItemNode.attrs.push(...attrs);
  1221. });
  1222. }
  1223. tenderProject.projectGLJ.datas.gljList.forEach((glj)=> {
  1224. if (glj.is_evaluate && glj.type !== 5 && glj.type !== 301) {
  1225. items.push(glj);
  1226. }
  1227. });
  1228. if (items.length > 0) {
  1229. items.forEach((glj)=> {
  1230. let mEstItemNode = new emptyElement('Item');
  1231. mEstNode.children.push(mEstItemNode);
  1232. let attrs = [
  1233. {name: 'ItemNo', value: itemNo},
  1234. {name: 'Code', value: _getBidGljCode(tenderProject, glj)},
  1235. {name: 'Number', value: glj.code},
  1236. {name: 'Name', value: glj.name},
  1237. {name: 'Unit', value: glj.unit},
  1238. {name: 'Num', value: glj.tenderQuantity},
  1239. // {name: 'Price', value: _getNumValueByExportKind(glj.unit_price.market_price)},
  1240. {name: 'Price', value: glj.unit_price.market_price}, //暂估材料输出price,不需判断导出类型
  1241. {name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(glj.tenderQuantity * glj.unit_price.market_price, 0)), type:TYPE.DECIMAL},
  1242. // {name: 'Price', value: 0},
  1243. // {name: 'Sum', value: 0},
  1244. {name: 'Remark', value: (glj.remark) ? glj.remark : ''}
  1245. ];
  1246. itemNo++;
  1247. mEstItemNode.attrs.push(...attrs);
  1248. });
  1249. }
  1250. if (billItems.length > 0 || items.length > 0) {
  1251. return mEstNode;
  1252. } else {
  1253. return null;
  1254. }
  1255. }
  1256. function getMachineTempEst(tenderProject) {
  1257. let mEstNode = new emptyElement('PrjDeviceEstimate');
  1258. let items = [];
  1259. let billItems = [];
  1260. let itemNo = 1;
  1261. //工程设备明细
  1262. tenderProject.Bills.datas.forEach((bill)=> {
  1263. console.log(`bill.specialProvisional: ${bill.specialProvisional}`);
  1264. if (bill.specialProvisional === '工程设备') {
  1265. billItems.push(bill);
  1266. }
  1267. });
  1268. if (billItems.length > 0) {
  1269. billItems.forEach((bill)=> {
  1270. let mEstItemNode = new emptyElement('Item');
  1271. mEstNode.children.push(mEstItemNode);
  1272. let attrs = [
  1273. {name: 'ItemNo', value: itemNo},
  1274. {name: 'Code', value: bill.code},
  1275. {name: 'Number', value: bill.code},
  1276. {name: 'Name', value: bill.name},
  1277. {name: 'Unit', value: bill.unit},
  1278. {name: 'Num', value: bill.quantity},
  1279. {name: 'Price', value: _getNumValueByExportKind(_getFee(bill, 'common', 'tenderUnitFee'))},
  1280. {name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), 0)), type:TYPE.DECIMAL},
  1281. // {name: 'Price', value: 0},
  1282. // {name: 'Sum', value: 0},
  1283. {name: 'Remark', value: (bill.remark) ? glj.remark : ''}
  1284. ];
  1285. itemNo++;
  1286. mEstItemNode.attrs.push(...attrs);
  1287. });
  1288. }
  1289. tenderProject.projectGLJ.datas.gljList.forEach((glj)=> {
  1290. if (glj.is_evaluate && glj.type === 5) {
  1291. items.push(glj);
  1292. }
  1293. });
  1294. if (items.length > 0) {
  1295. items.forEach((glj, sno)=> {
  1296. let mEstItemNode = new emptyElement('Item');
  1297. mEstNode.children.push(mEstItemNode);
  1298. let attrs = [
  1299. {name: 'ItemNo', value: itemNo},
  1300. {name: 'Code', value: _getBidGljCode(tenderProject, glj)},
  1301. {name: 'Number', value: glj.code},
  1302. {name: 'Name', value: glj.name},
  1303. {name: 'Unit', value: glj.unit},
  1304. {name: 'Num', value: glj.tenderQuantity},
  1305. // {name: 'Price', value: _getNumValueByExportKind(glj.unit_price.market_price)},
  1306. {name: 'Price', value: glj.unit_price.market_price}, // 暂估设备直接输出price
  1307. {name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(glj.tenderQuantity * glj.unit_price.market_price, 0)), type:TYPE.DECIMAL},
  1308. // {name: 'Price', value: 0},
  1309. // {name: 'Sum', value: 0},
  1310. {name: 'Remark', value: (glj.remark) ? glj.remark : ''}
  1311. ];
  1312. itemNo++;
  1313. mEstItemNode.attrs.push(...attrs);
  1314. });
  1315. }
  1316. if (billItems.length > 0 || items.length > 0) {
  1317. return mEstNode;
  1318. } else {
  1319. return null;
  1320. }
  1321. }
  1322. function getSpecPrjEst(tenderProject) {
  1323. let mEstNode = new emptyElement('SpecPrjEstimate');
  1324. let sum = 0;
  1325. let items = [];
  1326. //专业工程暂估明细
  1327. tenderProject.Bills.datas.forEach((bill)=> {
  1328. if (bill.specialProvisional === '专业工程') {
  1329. items.push(bill);
  1330. }
  1331. });
  1332. if (items.length > 0) {
  1333. items.forEach((bill, sno)=> {
  1334. let mEstItemNode = new emptyElement('Item');
  1335. mEstNode.children.push(mEstItemNode);
  1336. let ttl = _getFee(bill);
  1337. sum += ttl;
  1338. let attrs = [
  1339. {name: 'ItemNo', value: sno + 1},
  1340. {name: 'Code', value: bill.code},
  1341. {name: 'Number', value: bill.code},
  1342. {name: 'Name', value: bill.name},
  1343. {name: 'Content', value: bill.jobContent.toString()},
  1344. // {name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(ttl, 0)), type:TYPE.DECIMAL},
  1345. {name: 'Sum', value: ttl, type:TYPE.DECIMAL},
  1346. // {name: 'Sum', value: 0, type:TYPE.DECIMAL},
  1347. ];
  1348. mEstItemNode.attrs.push(...attrs);
  1349. });
  1350. mEstNode.attrs.push({name: 'Sum', value: sum});
  1351. return mEstNode;
  1352. } else {
  1353. return null;
  1354. }
  1355. }
  1356. function getBillsAnalyze(tenderProject) {
  1357. // 本函数是尽量复刻【5.5表】工程量清单单价分析表的‘综合’计算式脚本的相关逻辑,具体细节根据实际环境有所调整(前端环境已有不少现成的结构及数据,能少跑不少逻辑)
  1358. let djfxbNode = new emptyElement('ListUnitPriceAnalysis');
  1359. let decimalObj = tenderProject.property.decimal;
  1360. // 工程量清单单价分析(100~700章 清单下所有定额工料机的综合)
  1361. let topNode100To700;
  1362. let sno = 1;
  1363. const prefix = '_';
  1364. let filterMtlTypes = [202, 203, 204, 301];
  1365. for (let bill of tenderProject.Bills.datas) {
  1366. if (bill.flags && bill.flags.length > 0) {
  1367. for (let flag of bill.flags) {
  1368. if (flag.flag === 19) {
  1369. for (let rootBill of tenderProject.Bills.tree.roots) {
  1370. if (rootBill.data.ID === bill.ID) {
  1371. topNode100To700 = rootBill;
  1372. break;
  1373. }
  1374. }
  1375. break;
  1376. }
  1377. }
  1378. }
  1379. }
  1380. const cacheObj = {};
  1381. const proKeysArr = [];
  1382. const addedGljCodeCache = {};
  1383. //说明:根据实际情况,用户会直接在清单下加工料机,此工料机属于定额层次,那么算工程量的时候要加上这个(沟通后这种几率很小,暂时返回0,如有再补上)
  1384. const _getAdhocGljQty = function(billsId, rationCode, rstType = 1) {
  1385. let rst = 0;
  1386. // for (let nbidx = 0; nbidx < newRBillsIdArr.length; nbidx++) {
  1387. // if (newRBillsIdArr[nbidx] === billsId && newRCodeArr[nbidx] === rationCode) {
  1388. // rst = (rstType === 1) ? newRQtyArr[nbidx] : newTtlArr[nbidx];
  1389. // break;
  1390. // }
  1391. // }
  1392. return rst;
  1393. };
  1394. const _getCacheObjInitialedItem = function(bill = null, glj = null) {
  1395. let rst = {
  1396. code: (bill) ? bill.code : ((glj) ? glj.code : ''),
  1397. name: (bill) ? bill.name : ((glj) ? glj.name : ''),
  1398. quantity: (bill) ? bill.quantity : 1,
  1399. labourConsume: 0,
  1400. labourUnitPrice: 0,
  1401. labourTotalPrice: 0,
  1402. mainMaterialFee: 0,
  1403. auxiliaryMaterialFee: 0,
  1404. materialUnitFee: (bill) ? _getFee(bill, 'marketMaterial', 'unitFee') : 0,
  1405. machineFee: (bill) ? _getFee(bill, 'marketMachine') : 0,
  1406. otherFee: (bill) ? _getFee(bill, 'measure') : 0, //措施费
  1407. managementFee: (bill) ? (_getFee(bill, 'manage') + _getFee(bill, 'force')) : 0, //管理+规费
  1408. taxFee: (bill) ? _getFee(bill, 'tax') : 0,
  1409. profitFee: (bill) ? _getFee(bill, 'profit') : 0,
  1410. unitPrice: (bill) ? _getFee(bill, 'common', 'unitFee') : 0,
  1411. items: []
  1412. };
  1413. return rst;
  1414. };
  1415. const _getPrjGLJ = function(gljID) {
  1416. let rst = null;
  1417. for (let glj of tenderProject.projectGLJ.datas.gljList) {
  1418. if (glj.id === gljID) {
  1419. rst = glj;
  1420. break;
  1421. }
  1422. }
  1423. return rst;
  1424. };
  1425. const _getRation = function(rationId) {
  1426. let rst = null;
  1427. for (let ration of tenderProject.Ration.datas) {
  1428. if (ration.ID === rationId) {
  1429. rst = ration;
  1430. break;
  1431. }
  1432. }
  1433. return rst;
  1434. };
  1435. const _createNode = function(billIdKey, bill) {
  1436. if (cacheObj[billIdKey]) {
  1437. //1. 叶子清单,先创建清单Item
  1438. let bQtn = 1;
  1439. if (bill.data.hasOwnProperty('quantity')) {
  1440. bQtn = parseFloat(bill.data.quantity);
  1441. if (isNaN(bQtn)) bQtn = 1;
  1442. }
  1443. let billMainMaterialTtl = cacheObj[billIdKey].mainMaterialFee/bQtn;
  1444. let billAuxiliaryMaterialTtl = cacheObj[billIdKey].auxiliaryMaterialFee/bQtn;
  1445. // scMathUtil.roundForObj(cacheObj[billIdKey].labourConsume / bQtn, decimalObj.glj.unitPrice)
  1446. let leafBillAttrs = [
  1447. {name: 'ItemNo', value: sno},
  1448. {name: 'Code', value: cacheObj[billIdKey].code},
  1449. {name: 'Name', value: cacheObj[billIdKey].name},
  1450. {name: 'LaborWorkDays', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourConsume / bQtn, decimalObj.glj.quantity))},
  1451. {name: 'LaborUnitPrice', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourUnitPrice, decimalObj.glj.unitPrice))},
  1452. {name: 'LaborUnitTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourTotalPrice / bQtn, decimalObj.glj.unitPrice))},
  1453. {name: 'MainMaterialConsume', value: 0},
  1454. {name: 'MainMaterialUnit', value: ''},
  1455. {name: 'MainMaterialUnitPrice', value: 0},
  1456. {name: 'MainMaterialTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(billMainMaterialTtl, decimalObj.glj.unitPrice))},
  1457. {name: 'AuxiliaryMaterialFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(billAuxiliaryMaterialTtl, decimalObj.glj.unitPrice))},
  1458. {name: 'MaterialSum', value: _getNumValueByExportKind(scMathUtil.roundForObj(billMainMaterialTtl + billAuxiliaryMaterialTtl, decimalObj.glj.unitPrice))},
  1459. {name: 'MachUsageFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].machineFee/bQtn, decimalObj.glj.unitPrice))},
  1460. {name: 'OtherFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].otherFee/bQtn, decimalObj.glj.unitPrice))},
  1461. {name: 'ManageFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].managementFee/bQtn, decimalObj.glj.unitPrice))},
  1462. {name: 'Tax', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].taxFee/bQtn, decimalObj.glj.unitPrice))},
  1463. {name: 'Profit', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].profitFee/bQtn, decimalObj.glj.unitPrice))},
  1464. {name: 'Price', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill, 'common', 'tenderUnitFee'), decimalObj.glj.unitPrice))},
  1465. ];
  1466. sno++;
  1467. let leafItemNode = new emptyElement('Item');
  1468. djfxbNode.children.push(leafItemNode);
  1469. // leafItemNode.attrs.push(...leafBillAttrs);
  1470. leafItemNode.attrs = leafBillAttrs;
  1471. //2. 清单下工料机
  1472. cacheObj[billIdKey].items.forEach((gljItem)=> {
  1473. let showQty = gljItem.mainMaterialConsume/bQtn;
  1474. showQty = Math.round(showQty * 1000000) / 1000000;
  1475. let gljAttrs = [
  1476. {name: 'ItemNo', value: sno},
  1477. {name: 'Code', value: gljItem.code},
  1478. {name: 'Name', value: gljItem.name},
  1479. {name: 'LaborWorkDays', value: 0},
  1480. {name: 'LaborUnitPrice', value: 0},
  1481. {name: 'LaborUnitTotal', value: 0},
  1482. // {name: 'MainMaterialConsume', value: scMathUtil.roundForObj(showQty, decimalObj.glj.quantity)},
  1483. {name: 'MainMaterialConsume', value: _getNumValueByExportKind(scMathUtil.roundForObj(showQty, decimalObj.glj.quantity))},
  1484. // {name: 'MainMaterialUnit', value: gljItem.mainMaterialUnit},
  1485. {name: 'MainMaterialUnit', value: _getStrValueByExportKind(gljItem.mainMaterialUnit)},
  1486. {name: 'MainMaterialUnitPrice', value: _getNumValueByExportKind(scMathUtil.roundForObj(gljItem.mainMaterialUnitPrice, decimalObj.glj.unitPrice))},
  1487. {name: 'MainMaterialTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(showQty * gljItem.mainMaterialUnitPrice, decimalObj.glj.unitPrice))},
  1488. {name: 'AuxiliaryMaterialFee', value: 0},
  1489. {name: 'MaterialSum', value: 0},
  1490. {name: 'MachUsageFee', value: 0},
  1491. {name: 'OtherFee', value: 0},
  1492. {name: 'ManageFee', value: 0},
  1493. {name: 'Tax', value: 0},
  1494. {name: 'Profit', value: 0},
  1495. // {name: 'Price', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), decimalObj.glj.unitPrice))},
  1496. {name: 'Price', value: 0},
  1497. ];
  1498. sno++;
  1499. let gljItemNode = new emptyElement('Item');
  1500. djfxbNode.children.push(gljItemNode);
  1501. // gljItemNode.attrs.push(...gljAttrs);
  1502. gljItemNode.attrs = gljAttrs;
  1503. });
  1504. }
  1505. };
  1506. const _getAllGlj = function(parentBill) {
  1507. if (parentBill.children.length > 0) {
  1508. parentBill.children.forEach((subBill)=> {
  1509. _getAllGlj(subBill);
  1510. });
  1511. } else {
  1512. let billIdKey = prefix + parentBill.data.ID;
  1513. if (!cacheObj.hasOwnProperty(billIdKey)) {
  1514. cacheObj[billIdKey] = _getCacheObjInitialedItem(parentBill.data);
  1515. addedGljCodeCache[billIdKey] = [];
  1516. proKeysArr.push(billIdKey);
  1517. }
  1518. tenderProject.ration_glj.datas.forEach((rglj)=> {
  1519. if (rglj.billsItemID === parentBill.data.ID) {
  1520. let gljQty = parseFloat(rglj.quantity);
  1521. if (isNaN(gljQty)) gljQty = 0;
  1522. let ration = _getRation(rglj.rationID);
  1523. let gljRationQty = 0;
  1524. if (ration) gljRationQty = parseFloat(ration.quantity);
  1525. if (isNaN(gljRationQty)) gljRationQty = 0;
  1526. let gljCns = gljQty * gljRationQty;
  1527. let prjGlj = _getPrjGLJ(rglj.projectGLJID);
  1528. let gljUnitPrice = parseFloat(prjGlj.unit_price.market_price);
  1529. let gljTotalPrice = gljCns * gljUnitPrice;
  1530. let gljCode = rglj.code;
  1531. if (rglj.type === 1) {
  1532. //人工
  1533. cacheObj[billIdKey].labourConsume = cacheObj[billIdKey].labourConsume + gljCns;
  1534. cacheObj[billIdKey].labourUnitPrice = gljUnitPrice;
  1535. cacheObj[billIdKey].labourTotalPrice = cacheObj[billIdKey].labourTotalPrice + gljTotalPrice;
  1536. } else if (filterMtlTypes.indexOf(rglj.type) < 0) {
  1537. if (!addedGljCodeCache[billIdKey].includes(gljCode)) {
  1538. addedGljCodeCache[billIdKey].push(gljCode);
  1539. }
  1540. if (prjGlj.is_main_material) {
  1541. let dtlObj = {};
  1542. dtlObj.code = gljCode;
  1543. dtlObj.name = rglj.name;
  1544. dtlObj.specs = rglj.specs;
  1545. //
  1546. let adhocGljQty = _getAdhocGljQty(parentBill.data.ID, dtlObj.code);
  1547. let adhocGljTtl = adhocGljQty * gljUnitPrice;
  1548. dtlObj.mainMaterialConsume = gljCns + adhocGljQty; //考虑清单单独加工料机的情况,需要补上消耗量
  1549. dtlObj.mainMaterialUnitPrice = gljUnitPrice;
  1550. dtlObj.mainMaterialTotalPrice = gljTotalPrice;
  1551. dtlObj.mainMaterialUnit = rglj.unit;
  1552. let isAdd = 0;
  1553. for (let i = 0; i < cacheObj[billIdKey].items.length; i++) {
  1554. //先比较对象中是否已存在同一条工料机,存在,则累加汇总消耗量和金额;否则添加。
  1555. if (dtlObj.code === cacheObj[billIdKey].items[i].code && dtlObj.name === cacheObj[billIdKey].items[i].name && dtlObj.mainMaterialUnit === cacheObj[billIdKey].items[i].mainMaterialUnit && dtlObj.specs === cacheObj[billIdKey].items[i].specs) {
  1556. cacheObj[billIdKey].items[i].mainMaterialConsume = cacheObj[billIdKey].items[i].mainMaterialConsume + gljCns;
  1557. cacheObj[billIdKey].items[i].mainMaterialTotalPrice = cacheObj[billIdKey].items[i].mainMaterialTotalPrice + gljTotalPrice;
  1558. isAdd = 1;
  1559. break;
  1560. }
  1561. }
  1562. if (isAdd === 0) {
  1563. cacheObj[billIdKey].items.push(dtlObj);
  1564. }
  1565. cacheObj[billIdKey].mainMaterialFee = cacheObj[billIdKey].mainMaterialFee + gljTotalPrice + adhocGljTtl;
  1566. } else {
  1567. cacheObj[billIdKey].auxiliaryMaterialFee = cacheObj[billIdKey].auxiliaryMaterialFee + gljTotalPrice;
  1568. }
  1569. }
  1570. }
  1571. });
  1572. // 整理完后,开始创建XML节点(这里与参考脚本逻辑不一样了,直接开始创建)
  1573. _createNode(billIdKey, parentBill);
  1574. }
  1575. };
  1576. if (topNode100To700) {
  1577. topNode100To700.children.forEach((topChapterBill)=> {
  1578. _getAllGlj(topChapterBill);
  1579. });
  1580. }
  1581. //...
  1582. return djfxbNode;
  1583. }
  1584. function getBidEvaluationMainMaterial(tenderProject) {
  1585. let bidMaterials = [];
  1586. let i = 1;
  1587. for (let b of tenderProject.bidMaterialData) {
  1588. bidMaterials.push(new BidEvaluationMainMaterial(b, i));
  1589. i++
  1590. }
  1591. return bidMaterials;
  1592. function BidEvaluationMainMaterial(b, index) {
  1593. const attrs = [{
  1594. name: "Code",
  1595. value: b.seq,
  1596. },
  1597. {
  1598. name: "Number",
  1599. value: b.code
  1600. },
  1601. {
  1602. name: "Name",
  1603. value: b.name
  1604. },
  1605. {
  1606. name: "Specification",
  1607. value: b.specs
  1608. },
  1609. {
  1610. name: "Unit",
  1611. value: b.unit
  1612. },
  1613. {
  1614. name: "Price",
  1615. value: _getNumValueByExportKind(b.marketPrice || '0'),
  1616. type: TYPE.DECIMAL
  1617. },
  1618. {
  1619. name: "LimitedPrice",
  1620. value: _getNumValueByExportKind(b.marketPrice || '0'),
  1621. type: TYPE.DECIMAL
  1622. },
  1623. {
  1624. name: "Quantity",
  1625. value: b.quantity,
  1626. type: TYPE.DECIMAL
  1627. },
  1628. {
  1629. name: "Total",
  1630. value: 0
  1631. },
  1632. {
  1633. name: "Remark",
  1634. value: b.remark
  1635. }
  1636. ];
  1637. if (isBidSubmission || isControl) {
  1638. attrs[7].value = b.quantity;
  1639. attrs[8].value = b.totalPrice;
  1640. }
  1641. Element.call(this, "BidEvaluationMainMaterial", attrs);
  1642. }
  1643. }
  1644. function getIndexs(tenderProject) {
  1645. let Indexs = new emptyElement('Indexs');
  1646. let feature = tenderProject.property.projectFeature ? tenderProject.property.projectFeature : [];
  1647. for (let f of feature) {
  1648. if (f.code) Indexs.children.push(new IndexItem(f))
  1649. }
  1650. return Indexs;
  1651. function IndexItem(fea) {
  1652. const attrs = [{
  1653. name: "Code",
  1654. value: fea.code,
  1655. },
  1656. {
  1657. name: "Name",
  1658. value: fea.dispName,
  1659. },
  1660. {
  1661. name: "Unit",
  1662. value: fea.unit,
  1663. },
  1664. {
  1665. name: "Value",
  1666. value: fea.value,
  1667. },
  1668. {
  1669. name: "Remark",
  1670. value: fea.remark,
  1671. }
  1672. ]
  1673. Element.call(this, "IndexItem", attrs);
  1674. }
  1675. }
  1676. function getBillsItems(tenderProject) {
  1677. let items = new emptyElement("Items");
  1678. let rootNodes = tenderProject.mainTree.roots;
  1679. for (let r of rootNodes) {
  1680. setItem(r, -1, items.children);
  1681. }
  1682. return items;
  1683. function setItem(bNode, level, list) {
  1684. if (bNode.sourceType == ModuleNames.ration) return;
  1685. let item = new bill(bNode, level);
  1686. if (bNode.children && bNode.children.length > 0) {
  1687. level += 1;
  1688. for (let c of bNode.children) {
  1689. setItem(c, level, item.children);
  1690. }
  1691. }
  1692. list.push(item);
  1693. function getCalcType(node) {
  1694. /*
  1695. 判断是否父项:
  1696. 是父项,则取1;
  1697. 是叶子项,则判断其下有无套定额/量价/工料机:
  1698. 有则取1;
  1699. 无则判断有无基数计算:
  1700. 有则取2;
  1701. 无则取3 */
  1702. if (node.children && node.children.length > 0) {
  1703. return 1; //是父项,则取1, 有套定额/量价/工料机,也取1
  1704. } else {
  1705. return node.data.calcBase && node.data.calcBase != "" ? 2 : 3
  1706. }
  1707. }
  1708. function getItemType(node) {
  1709. let Bills = projectObj.project.Bills;
  1710. //是100~900章部分、或是计日工部分,叶子清单输出1,父项输出0;
  1711. if (Bills.isBelongOneToSeven(node)||Bills.isBelongDayWork(node)) {
  1712. if (node.children && node.children.length > 0) {
  1713. return node.children[0].sourceType == ModuleNames.ration ? 1 : 0
  1714. }
  1715. return 1 //叶子清单输出1
  1716. } else {
  1717. return 0;
  1718. /* //非100~900章部分,
  1719. // 是暂列金额,判断暂列金额的金额等于0,则输出为0;暂列金额的金额不等于0,则输出为1;
  1720. if (node.data.name && node.data.name.indexOf("暂列金额") != -1) {
  1721. let sum = node.data.feesIndex && node.data.feesIndex.common ? node.data.feesIndex.common.tenderTotalFee : "";
  1722. return gljUtil.isNotEmpty(sum) ? 1 : 0
  1723. } else { //非暂列金额,则判断清单的工程量是否等于0,等于0,则输出0;不等于0,则输出1
  1724. return gljUtil.isNotEmpty(node.data.quantity) ? 1 : 0
  1725. } */
  1726. }
  1727. }
  1728. function bill(bNode, level) {
  1729. let data = bNode.data;
  1730. let CostKind = 3;
  1731. if (data.name && data.name.indexOf("安全生产费") != -1) CostKind = 1;
  1732. if (data.name && data.name.indexOf("暂列金额") != -1) CostKind = 2;
  1733. //1 = 工程量×综合单价;2 = 计算基数×费率;3 = 工程量×单价。
  1734. let CalcType = getCalcType(bNode);
  1735. //取暂估价类型。读取造价书界面的专项暂定列。0=材料暂估价,1=工程设备暂估价,2=专业工程暂估价,没有选的输出为空。
  1736. let ProvisionalType = "";
  1737. if (data.specialProvisional == "材料暂估") ProvisionalType = 0;
  1738. if (data.specialProvisional == "工程设备") ProvisionalType = 1;
  1739. if (data.specialProvisional == "专业工程") ProvisionalType = 2;
  1740. //MpRatio
  1741. let MpRatio = "";
  1742. let MaterialRatio = "";
  1743. let MechRatio = "";
  1744. if (data.quantityCoe) {
  1745. if (data.quantityCoe["labour"]) MpRatio = data.quantityCoe["labour"];
  1746. if (data.quantityCoe["material"]) MaterialRatio = data.quantityCoe["material"];
  1747. if (data.quantityCoe["machine"]) MechRatio = data.quantityCoe["machine"];
  1748. }
  1749. let fail = billNameChecking(bNode,tenderProject.projectInfo.name,fixedFlag)
  1750. //fail: { hint: '错误提示', type: '提示所属(基本就是单位工程名称)' }
  1751. let ListCode = "";
  1752. if (ListCodeMap[data.name]) ListCode = ListCodeMap[data.name];
  1753. if (data.code && data.code != "") ListCode = data.code;
  1754. let qtyFormula = data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "";
  1755. //data.calcBase //data.calcBase ? cbParser.toFExpr(data.calcBase, tenderProject.mainTree.items) : "",
  1756. if (!data.name.includes('暂列金额') && isBidInvitation) {
  1757. if (data.hasOwnProperty('calcBase')) {
  1758. let chkNaN = parseFloat(data.calcBase);
  1759. if (isNaN(chkNaN)) {
  1760. qtyFormula = data.calcBase;
  1761. } else {
  1762. qtyFormula = '';
  1763. }
  1764. } else {
  1765. qtyFormula = '';
  1766. }
  1767. //判断公式(calcBase)是否为正常的计算公式(即非直接输入数量),
  1768. }
  1769. const attrs = [{
  1770. name: "ListCode",
  1771. value: ListCode,
  1772. },
  1773. {
  1774. name: "ListName",
  1775. value: data.name,
  1776. fail:fail
  1777. },
  1778. {
  1779. name: "Unit",
  1780. value: data.unit,
  1781. },
  1782. {
  1783. name: "Num",
  1784. value: data.quantity,
  1785. type: TYPE.DECIMAL,
  1786. toFix:3
  1787. },
  1788. {
  1789. name: "QtyFormula",
  1790. value: qtyFormula,
  1791. type: TYPE.DECIMAL,
  1792. toFix:2
  1793. },
  1794. {
  1795. name: "Price",
  1796. value: 0,//data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderUnitFee : "",
  1797. type: TYPE.DECIMAL,
  1798. toFix:2
  1799. },
  1800. {
  1801. name: "Rate",
  1802. value: 100,
  1803. },
  1804. {
  1805. name: "Sum",
  1806. value: 0,//data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "",
  1807. type: TYPE.DECIMAL,
  1808. toFix:2
  1809. },
  1810. {
  1811. name: "ChapterKind",
  1812. value: level > 3 ? 3 : level,
  1813. },
  1814. {
  1815. name: "CostKind",
  1816. value: CostKind,
  1817. },
  1818. {
  1819. name: "CalcType",
  1820. value: CalcType,
  1821. },
  1822. {
  1823. name: "ProvisionalType",
  1824. value: ProvisionalType,
  1825. mustHasValue:true
  1826. },
  1827. {
  1828. name: "MeterRules",
  1829. value: "",
  1830. },
  1831. {
  1832. name: "Content",
  1833. value: data.jobContentText,
  1834. },
  1835. {
  1836. name: "Remarks",
  1837. value: data.remark,
  1838. },
  1839. /* {
  1840. name: "MpRatio",
  1841. value: MpRatio,
  1842. },
  1843. {
  1844. name: "MaterialRatio",
  1845. value: MaterialRatio,
  1846. },
  1847. {
  1848. name: "MechRatio",
  1849. value: MechRatio,
  1850. },
  1851. {
  1852. name: "AdjustedPrice",
  1853. value: data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderUnitFee : "",
  1854. },
  1855. {
  1856. name: "AdjustedSums",
  1857. value: data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "",
  1858. }, */
  1859. {
  1860. name: "ItemType",
  1861. value: getItemType(bNode),
  1862. },
  1863. /* {
  1864. name: "FomulaCode",
  1865. value: ""
  1866. }, */
  1867. ];
  1868. //投标、招标控制价时。取单价。
  1869. //招标时,如果是“安全生产费”或“暂列金额”,取单价,否则取0。
  1870. if (isBidSubmission || isControl || CostKind==1 ||CostKind==2 || ProvisionalType === 2) {
  1871. attrs[5].value = data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderUnitFee : "";
  1872. attrs[7].value = data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "";
  1873. //暂列金额 数量为0的时候,单价输出0
  1874. if( CostKind==2 && !gljUtil.isNotEmpty(data.quantity)) attrs[5].value = 0
  1875. }
  1876. Element.call(this, "Item", attrs);
  1877. let cc = CostComposition(bNode);
  1878. if (cc) this.children.push(cc);
  1879. this.children.push(CostStructure(data))
  1880. function CostComposition(bNode) {
  1881. // if (isBidInvitation) return null;
  1882. // 山东逻辑:如果清单下有计算基数,则需要输出
  1883. let bSet = true;
  1884. if (bNode.data.hasOwnProperty('calcBase')) {
  1885. let chkNaN = parseFloat(bNode.data.calcBase);
  1886. if (!isNaN(chkNaN)) {
  1887. bSet = false;
  1888. }
  1889. } else {
  1890. bSet = false;
  1891. }
  1892. if (!bSet) return null;
  1893. let CostComposition = new emptyElement('CostComposition');
  1894. let Norms = [];
  1895. let Costs = [];
  1896. if (bNode.children && bNode.children.length > 0 && bNode.children[0].sourceType == ModuleNames.ration) {
  1897. for (let r of bNode.children) {
  1898. if (r.data.type == rationType.ration) {
  1899. if(isEmptyRation(r.data)) continue;//定额空行不输出到接口文件中。
  1900. Norms.push(new Ration(r.data));
  1901. } else {
  1902. Costs.push(new Cost(r.data));
  1903. }
  1904. }
  1905. }
  1906. if (Norms.length > 0) CostComposition.children.push(...Norms);
  1907. if (Costs.length > 0) CostComposition.children.push(...Costs);
  1908. if (bNode.data.calcBase) CostComposition.children.push(new Formula(bNode.data));
  1909. return CostComposition.children.length > 0 ? CostComposition : null;
  1910. //定额空行不输出到接口文件中。 //定额空行的判断是:定额编码、定额名称、定额单位、定额单位、定额工程量为零或为空时
  1911. function isEmptyRation(ration){
  1912. return !gljUtil.isNotEmpty(ration.code)&&!gljUtil.isNotEmpty(ration.name)&&!gljUtil.isNotEmpty(ration.unit)&&(!gljUtil.isNotEmpty(ration.quantity)||ration.quantity == 0)
  1913. }
  1914. function Formula(bills) {
  1915. const attrs = [{
  1916. name: "Name",
  1917. value: bills.name
  1918. },
  1919. {
  1920. name: "Formulas",
  1921. value: bills.calcBase
  1922. },
  1923. {
  1924. name: "Ratio",
  1925. value: 1
  1926. },
  1927. {
  1928. name: "Sum",
  1929. // value: bills.feesIndex && bills.feesIndex.common ? bills.feesIndex.common.tenderTotalFee : "",
  1930. value: _getNumValueByExportKind(bills.feesIndex && bills.feesIndex.common ? bills.feesIndex.common.tenderTotalFee : ""),
  1931. type:TYPE.DECIMAL
  1932. },
  1933. {
  1934. name: "Remarks",
  1935. value: bills.remark
  1936. }
  1937. ]
  1938. Element.call(this, "Formula", attrs);
  1939. // 1.Name
  1940. // 名称/描述。取清单的名称。
  1941. // 2.Formulas
  1942. // 计算式。读取计算基数的文本。
  1943. // 取基数计算窗口内容,基数直接转换为金额?参考标准文档的 7.11 及 7.12 节。
  1944. // 7.11是定额的费用,7.12是清单累进基数,主要是估概预算中用到,清单里的不同,所以中山的接口直接输出基数文本。
  1945. // 3.Ratio
  1946. // 系数。输出为1,非必填。
  1947. // 4.Sum
  1948. // 取金额。
  1949. // 5.Remarks
  1950. }
  1951. function Cost(item) {
  1952. let BasePrice = 0;
  1953. if (item.type == rationType.volumePrice) { // 当插入的是量价时,基价读取单价列。
  1954. BasePrice = item.feesIndex && item.feesIndex.common ? item.feesIndex.common.tenderUnitFee : 0
  1955. } else {
  1956. BasePrice = getBasePrice(item.projectGLJID, tenderProject)
  1957. }
  1958. let calcMap = tenderProject.calcProgram.compiledTemplateMaps
  1959. let CostTypeNo = '';
  1960. if (feeRateMap[calcMap[item.programID]]) CostTypeNo = feeRateMap[calcMap[item.programID]];
  1961. const attrs = [{
  1962. name: "Code",
  1963. value: item.code,
  1964. }, {
  1965. name: 'Name',
  1966. value: item.name
  1967. }, {
  1968. name: 'Spec',
  1969. value: item.specs
  1970. }, {
  1971. name: 'Unit',
  1972. value: item.unit
  1973. }, {
  1974. name: 'Num',
  1975. value: item.tenderQuantity
  1976. }, {
  1977. name: 'BasePrice',
  1978. value: BasePrice
  1979. }, {
  1980. name: 'Price',
  1981. value: item.feesIndex && item.feesIndex.common ? item.feesIndex.common.tenderUnitFee : 0
  1982. }, {
  1983. name: 'IsEquipment',
  1984. value: item.subType == gljType.EQUIPMENT ? 1 : 0
  1985. }, {
  1986. name: 'CostTypeNo',
  1987. value: CostTypeNo
  1988. }, {
  1989. name: 'ProfitRate',
  1990. value: getFeeRate(item.programID, 'profit', tenderProject)
  1991. },
  1992. {
  1993. name: 'TaxRate',
  1994. value: getFeeRate(item.programID, 'tax', tenderProject)
  1995. },
  1996. {
  1997. name: 'MpRatio',
  1998. value: item.subType == gljType.LABOUR ? 100 : 0
  1999. },
  2000. {
  2001. name: 'MaterialRatio',
  2002. value: item.subType == gljType.GENERAL_MATERIAL ? 100 : 0
  2003. },
  2004. {
  2005. name: 'MechRatio',
  2006. value: item.subType == gljType.GENERAL_MACHINE ? 100 : 0
  2007. }
  2008. ]
  2009. Element.call(this, "Cost", attrs);
  2010. this.children.push(CostStructure(item));
  2011. }
  2012. function Ration(ration) {
  2013. let calcMap = tenderProject.calcProgram.compiledTemplateMaps
  2014. let CostTypeNo = '';
  2015. if (feeRateMap[calcMap[ration.programID]]) CostTypeNo = feeRateMap[calcMap[ration.programID]];
  2016. const attrs = [{
  2017. name: "NormLibNo",
  2018. value: 'YSDE-000000-2018-86',
  2019. }, {
  2020. name: 'DisplayCode',
  2021. value: ration.code
  2022. }, {
  2023. name: 'Name',
  2024. value: ration.name
  2025. }, {
  2026. name: 'Unit',
  2027. value: ration.unit
  2028. }, {
  2029. name: 'Num',
  2030. value: ration.tenderQuantity
  2031. },
  2032. {
  2033. name: 'CostTypeNo',
  2034. value: CostTypeNo
  2035. },
  2036. {
  2037. name: 'ProfitRate',
  2038. value: getFeeRate(ration.programID, 'profit', tenderProject) //tenderProject.ProfitRate
  2039. },
  2040. {
  2041. name: 'TaxRate',
  2042. value: getFeeRate(ration.programID, 'tax', tenderProject) //tenderProject.TaxRate
  2043. },
  2044. {
  2045. name: 'FabricationCost',
  2046. value: ration.feesIndex && ration.feesIndex.common ? ration.feesIndex.common.tenderTotalFee : 0
  2047. },
  2048. {
  2049. name: 'AdjustStatus',
  2050. value: ration.adjustState
  2051. }
  2052. ]
  2053. Element.call(this, "Norm", attrs);
  2054. this.children.push(CostStructure(ration));
  2055. this.children.push(Consume(ration));
  2056. }
  2057. }
  2058. function Consume(ration) {
  2059. let consume = new emptyElement('Consume');
  2060. for (let rg of ration.rationGLJList) {
  2061. consume.children.push(new ConsumeItem(rg));
  2062. }
  2063. return consume;
  2064. function ConsumeItem(rg) {
  2065. const attrs = [{
  2066. name: "Code",
  2067. value: rg.code,
  2068. }, {
  2069. name: "Consumption",
  2070. value: rg.tenderQuantity
  2071. }];
  2072. Element.call(this, "ConsumeItem", attrs);
  2073. }
  2074. }
  2075. function CostStructure(item) {
  2076. let CostStructure = new emptyElement('CostStructure');
  2077. for (let f of cpFeeTypes) {
  2078. if(itemFeeMap[f.type]) CostStructure.children.push(new CostItem(item,f.type))
  2079. }
  2080. if (CostStructure.children.length == 0) CostStructure.children.push(new CostItem({},""))
  2081. function CostItem(item,type) {
  2082. const attrs = [{
  2083. name: "ItemNo",
  2084. value: itemFeeMap[type],
  2085. }, {
  2086. name: 'Sum',
  2087. value: 0 //fee.tenderTotalFee
  2088. }]
  2089. if ((isBidSubmission || isControl) && item.feesIndex && item.feesIndex[type]) attrs[1].value = item.feesIndex[type].tenderTotalFee;
  2090. Element.call(this, "CostItem", attrs);
  2091. }
  2092. return CostStructure;
  2093. }
  2094. }
  2095. }
  2096. }
  2097. function Params(tenderProject) {
  2098. let feature = tenderProject.property.projectFeature ? tenderProject.property.projectFeature : [];
  2099. let featrueMap = {};
  2100. let baseMap = {};
  2101. for (let f of feature) {
  2102. featrueMap[f.key] = f;
  2103. }
  2104. let baseInfo = _.find(tenderProject.property.basicInformation, {
  2105. dispName: "基本信息",
  2106. });
  2107. for (let i of baseInfo.items) {
  2108. let key = i.key;
  2109. //if (i.dispName == "编制日期") key = "编制时间";
  2110. baseMap[key] = i;
  2111. }
  2112. let BuildType = "";
  2113. if (baseMap["natureConstruction"].value == "新建") BuildType = 0;
  2114. if (baseMap["natureConstruction"].value == "改扩建") BuildType = 1;
  2115. let Terrain = "";
  2116. if (baseMap["terrainCategory"].value == "平原微丘") Terrain = 0;
  2117. if (baseMap["terrainCategory"].value == "山岭重丘") Terrain = 1;
  2118. let DesignSpeed = featrueMap["designSpeed"].value;
  2119. let Structure = "";
  2120. if (featrueMap["pavementStructure"].value == "沥青路面") Structure = 0;
  2121. if (featrueMap["pavementStructure"].value == "水泥混凝土路面") Structure = 1;
  2122. if (featrueMap["pavementStructure"].value == "其他类型路面") Structure = 2;
  2123. let RoadGrade = "";
  2124. if (RoadGradeMap[baseMap["roadGrade"].value]) RoadGrade = RoadGradeMap[baseMap["roadGrade"].value];
  2125. const attrs = [{
  2126. name: "PrjArea",
  2127. value: baseMap["location"] ? baseMap["location"].value : ""
  2128. },
  2129. {
  2130. name: "StartPileNo",
  2131. value: baseMap["startChainages"] ? baseMap["startChainages"].value : "",
  2132. mustHasValue: true
  2133. },
  2134. {
  2135. name: "EndPileNo",
  2136. value: baseMap["endChainages"] ? baseMap["endChainages"].value : "",
  2137. mustHasValue: true
  2138. },
  2139. {
  2140. name: "BuildType",
  2141. value: BuildType,
  2142. },
  2143. {
  2144. name: "Terrain",
  2145. value: Terrain,
  2146. mustHasValue: true
  2147. },
  2148. {
  2149. name: "RoadGrade",
  2150. value: RoadGrade,
  2151. mustHasValue: true
  2152. },
  2153. {
  2154. name: "DesignSpeed",
  2155. value: DesignSpeed,
  2156. mustHasValue: true
  2157. },
  2158. {
  2159. name: "Structure",
  2160. value: Structure,
  2161. mustHasValue: true
  2162. },
  2163. {
  2164. name: "SubgradeWidth",
  2165. value: featrueMap["subgradeWidth"] ? featrueMap["subgradeWidth"].value : "",
  2166. mustHasValue: true
  2167. },
  2168. {
  2169. name: "RoadLength",
  2170. value: featrueMap["roadLength"] ? featrueMap["roadLength"].value : "",
  2171. mustHasValue: true
  2172. },
  2173. {
  2174. name: "BridgeLength",
  2175. value: featrueMap["bridgeLength"] ? featrueMap["bridgeLength"].value : "",
  2176. mustHasValue: true
  2177. },
  2178. {
  2179. name: "TunnelLength",
  2180. value: featrueMap["tunnelLength"] ? featrueMap["tunnelLength"].value : "",
  2181. mustHasValue: true
  2182. },
  2183. {
  2184. name: "BriTunRate",
  2185. value: featrueMap["briTunRate"] ? featrueMap["briTunRate"].value : "",
  2186. mustHasValue: true
  2187. },
  2188. {
  2189. name: "InterchangeNum",
  2190. value: featrueMap["interchangeNum"] ? featrueMap["interchangeNum"].value : "",
  2191. mustHasValue: true
  2192. },
  2193. {
  2194. name: "StubLengths",
  2195. value: featrueMap["stubLengths"] ? featrueMap["stubLengths"].value : "",
  2196. mustHasValue: true
  2197. },
  2198. {
  2199. name: "LaneLength",
  2200. value: featrueMap["laneLength"] ? featrueMap["laneLength"].value : "",
  2201. mustHasValue: true
  2202. },
  2203. ];
  2204. Element.call(this, "Params", attrs);
  2205. }
  2206. function SummaryOfCost(totalItem, proItem,safeItem,oneToSevenItem,feature) {
  2207. let attrs = [{
  2208. name: "TenderSumLimit",
  2209. value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
  2210. type: TYPE.DECIMAL,
  2211. toFix:2,
  2212. },
  2213. {
  2214. name: "BidTotal",
  2215. value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
  2216. type: TYPE.DECIMAL,
  2217. toFix:2,
  2218. },
  2219. {
  2220. name: "BillTotal",
  2221. value: oneToSevenItem.feesIndex && oneToSevenItem.feesIndex.common && oneToSevenItem.feesIndex.common.tenderTotalFee ? oneToSevenItem.feesIndex.common.tenderTotalFee : 0,
  2222. type: TYPE.DECIMAL,
  2223. toFix:2,
  2224. },
  2225. {
  2226. name: "CostForHSE",
  2227. value: safeItem && safeItem.feesIndex && safeItem.feesIndex.common && safeItem.feesIndex.common.tenderTotalFee ? safeItem.feesIndex.common.tenderTotalFee : 0,
  2228. type: TYPE.DECIMAL,
  2229. toFix:2,
  2230. },
  2231. {
  2232. name: "ProvisionalSums",
  2233. value: proItem.feesIndex && proItem.feesIndex.common && proItem.feesIndex.common.tenderTotalFee ? proItem.feesIndex.common.tenderTotalFee : 0,
  2234. type: TYPE.DECIMAL,
  2235. toFix:2,
  2236. },
  2237. {
  2238. name: "Appraisal",
  2239. // value: totalItem.feesIndex && totalItem.feesIndex.estimate && totalItem.feesIndex.estimate.tenderTotalFee ? totalItem.feesIndex.estimate.tenderTotalFee : 0,
  2240. value: 0,
  2241. type: TYPE.DECIMAL,
  2242. toFix:2,
  2243. },
  2244. ];
  2245. if (isBidInvitation) {
  2246. attrs.splice(0, 3) //招标
  2247. }
  2248. //if (isControl) attrs.splice(1, 5); //控制价
  2249. if (isBidSubmission) { //投标文件时,读工程特征中的 招标控制价 值
  2250. let tenderSumLimit = _.find(feature, { "key": "tenderSumLimit" });
  2251. if(tenderSumLimit) attrs[0].value = tenderSumLimit.value
  2252. }
  2253. Element.call(this, "SummaryOfCost", attrs);
  2254. }
  2255. function MakeInfo(tenderProject) {
  2256. let property = tenderProject.property;
  2257. let baseMap = {};
  2258. let baseInfo = _.find(property.basicInformation, {
  2259. dispName: "基本信息",
  2260. });
  2261. for (let i of baseInfo.items) {
  2262. let key = i.key;
  2263. //if (i.dispName == "编制日期") key = "编制时间";
  2264. baseMap[key] = i;
  2265. }
  2266. //mustHasValue
  2267. const attrs = [{
  2268. name: "ValuationModel",
  2269. value: property.taxType,
  2270. },
  2271. {
  2272. name: "Manage",
  2273. value: baseMap["constructingUnit"] ? baseMap["constructingUnit"].value : "",
  2274. },
  2275. {
  2276. name: "Designer",
  2277. value: baseMap["designUnit"] ? baseMap["designUnit"].value : "",
  2278. mustHasValue:true
  2279. },
  2280. {
  2281. name: "Compile",
  2282. value: baseMap["compileUnit"] ? baseMap["compileUnit"].value : "",
  2283. },
  2284. {
  2285. name: "CompileApprover",
  2286. value: baseMap["compileApprover"] ? baseMap["compileApprover"].value : "",
  2287. },
  2288. {
  2289. name: "CompileCertNo",
  2290. value: baseMap["compileCertNo"] ? baseMap["compileCertNo"].value : "",
  2291. mustHasValue:true
  2292. },
  2293. {
  2294. name: "CompileDate",
  2295. value: baseMap["compileDate"] && baseMap["compileDate"].value != "" ? baseMap["compileDate"].value + "T00:00:00" : "",
  2296. mustHasValue:true
  2297. },
  2298. {
  2299. name: "Review",
  2300. value: baseMap["reviewUnit"] ? baseMap["reviewUnit"].value : "",
  2301. mustHasValue:true
  2302. },
  2303. {
  2304. name: "ReviewApprover",
  2305. value: baseMap["reviewApprover"] ? baseMap["reviewApprover"].value : "",
  2306. mustHasValue:true
  2307. },
  2308. {
  2309. name: "ReviewCertNo",
  2310. value: baseMap["reviewCertNo"] ? baseMap["reviewCertNo"].value : "",
  2311. mustHasValue:true
  2312. },
  2313. {
  2314. name: "ReviewDate",
  2315. value: baseMap["reviewDate"] && baseMap["reviewDate"].value != "" ? baseMap["reviewDate"].value + "T00:00:00" : "",
  2316. mustHasValue:true
  2317. },
  2318. {
  2319. name: "Examine",
  2320. value: baseMap["examineUnit"] ? baseMap["examineUnit"].value : "",
  2321. mustHasValue:true
  2322. },
  2323. {
  2324. name: "ExamineApprover",
  2325. value: baseMap["examineApprover"] ? baseMap["examineApprover"].value : "",
  2326. mustHasValue:true
  2327. },
  2328. {
  2329. name: "ExamineCertNo",
  2330. value: baseMap["examineCertNo"] ? baseMap["examineCertNo"].value : "",
  2331. mustHasValue:true
  2332. },
  2333. {
  2334. name: "ExamineDate",
  2335. value: baseMap["examineDate"] && baseMap["examineDate"].value != "" ? baseMap["examineDate"].value + "T00:00:00" : "",
  2336. mustHasValue:true
  2337. },
  2338. {
  2339. name: "CompileExplain",
  2340. value: baseMap["compileExplain"] ? baseMap["compileExplain"].value : "",
  2341. mustHasValue:true
  2342. },
  2343. {
  2344. name: "ExamineExplain",
  2345. value: baseMap["examineExplain"] ? baseMap["examineExplain"].value : "",
  2346. mustHasValue:true
  2347. },
  2348. {
  2349. name: "ProjectExplain",
  2350. value: baseMap["projectExplain"] ? baseMap["projectExplain"].value : "",
  2351. mustHasValue:true
  2352. },
  2353. {
  2354. name: "Bidder",
  2355. // value: baseMap["bidderCompany"] ? baseMap["bidderCompany"].value : "",
  2356. value: baseMap["bidderName"] ? baseMap["bidderName"].value : "",
  2357. mustHasValue:true
  2358. },
  2359. ];
  2360. if (isBidInvitation) { //招标文件,则以下的8、12~18则不输出
  2361. attrs.splice(11, 7);
  2362. attrs.splice(7, 1);
  2363. }
  2364. Element.call(this, "MakeInfo", attrs);
  2365. }
  2366. let data = new CprjInfo(projectData.name);
  2367. data.children.push(new SystemInfo(projectData));
  2368. data.children.push(new CostBasis());
  2369. let seriNo = 1;
  2370. let Rates = [];
  2371. let Practs = [];
  2372. let EprjInfos = [];
  2373. for (let c of projectData.children) {
  2374. let tenderProject = tenderDetailMap[c.ID];
  2375. let feeRataDatas = tenderProject.FeeRate.datas;
  2376. Rates.push(new Rate(tenderProject, feeRataDatas, seriNo));
  2377. Practs.push(new Pract(tenderProject, seriNo));
  2378. EprjInfos.push(new EprjInfo(tenderProject));
  2379. seriNo++;
  2380. }
  2381. data.children.push(...Rates,...Practs,...EprjInfos);
  2382. return [{
  2383. data: data,
  2384. exportKind: exportKind,
  2385. fileName: projectData.name + INTERFACE_CONFIG[areaKey]["fileSuffix"][exportKind],
  2386. }, ];
  2387. }
  2388. // 山东需求,要有密文校验信息(SM3算法,在界面上已导入sm3对象)
  2389. /**
  2390. * SM3加密主函数
  2391. * @param msg
  2392. * @returns
  2393. */
  2394. function sm3Digest(msg){
  2395. let hashHex = sm3(msg);
  2396. // return hashHex;
  2397. return hashHex.toUpperCase();
  2398. }
  2399. return {
  2400. entry,
  2401. };
  2402. })();