exportStandardInterface.js 107 KB

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