shandong_common.js 94 KB

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