exportStandardInterface.js 136 KB

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