exportStandardInterface.js 104 KB

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