exportStandardInterface.js 103 KB

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