exportStandardInterface.js 134 KB

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