exportStandardInterface.js 131 KB

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