| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155 |
- 'use strict';
- /**
- *
- *
- * @author Zhong
- * @date 2019/3/15
- * @version
- */
- /*
- * 数据标准接口
- * 导出符合标准接口要求的xml
- * */
- const XMLStandard = (function () {
- //属性类型
- const TYPE = {
- DATE: 1, //日期类型YYYY-MM-DD
- DATE_TIME: 2, //日期类型YYY-MM-DDTHH:mm:ss
- INT: 3, //整数类型
- DECIMAL: 4, //数值类型,不限制小数位数
- NUM2: 5, //数值类型2:最多两位小数
- BOOL: 6 //布尔型
- };
- const WHITE_SPACE = {
- COLLAPSE: 1 //移除所有空白字符(换行、回车、空格以及制表符会被替换为空格,开头和结尾的空格会被移除,而多个连续的空格会被缩减为一个单一的空格)
- };
- //费用类别:固定行ID对应
- const FEE_TYPE = {
- [fixedFlag.SUB_ENGINERRING]: '1100',
- [fixedFlag.MEASURE]: '1200',
- [fixedFlag.CONSTRUCTION_ORGANIZATION]: '120201',
- [fixedFlag.ORGANIZATION]: '120201',
- [fixedFlag.SAFETY_CONSTRUCTION]: '1204',
- [fixedFlag.PROJECT_COMPLETE_ARCH_FEE]: '10041',
- [fixedFlag.HOUSE_QUALITY_ACCEPT_FEE]: '1206',
- [fixedFlag.OTHER]: '1300',
- [fixedFlag.CHARGE]: '800',
- [fixedFlag.TAX]: '900',
- [fixedFlag.ADDED_VALUE_TAX]: '9001',
- [fixedFlag.ADDITIONAL_TAX]: '9002',
- [fixedFlag.ENVIRONMENTAL_PROTECTION_TAX]: '9003',
- [fixedFlag.ENGINEERINGCOST]: '1',
- 0: '1800', //其他未定义的大项费用
- };
- //文件类型
- const FILE_KIND = {
- '1': '投标',
- '2': '招标',
- '3': '控制价'
- };
- //计税方法
- const TAX_TYPE = {
- '1': '一般计税法',
- '2': '简易计税法',
- };
- //固定类别-基数映射
- const FlagCalcBaseMap = {
- [fixedFlag.SUB_ENGINERRING]: 'FBFXHJ',
- [fixedFlag.MEASURE]: 'CSXMHJ',
- [fixedFlag.CONSTRUCTION_TECH]: 'JSCSF',
- [fixedFlag.CONSTRUCTION_ORGANIZATION]: 'ZZCSF',
- [fixedFlag.Other]: 'QTXMHJ',
- [fixedFlag.CHARGE]: 'GF',
- [fixedFlag.TAX]: 'SJ',
- [fixedFlag.PROVISIONAL]: 'ZLJE',
- [fixedFlag.ENGINEERING_ESITIMATE]: 'ZYZGJ',
- [fixedFlag.DAYWORK]: 'JRG',
- [fixedFlag.TURN_KEY_CONTRACT]: 'ZCBFWF',
- [fixedFlag.CLAIM_VISA]: 'SPQZ',
- '{分部分项工程费}': fixedFlag.SUB_ENGINERRING,
- '{措施项目费}': fixedFlag.MEASURE,
- '{组织措施项目费}': fixedFlag.CONSTRUCTION_ORGANIZATION,
- '{技术措施项目费}': fixedFlag.CONSTRUCTION_TECH,
- '{安全文明施工专项费}': fixedFlag.SAFETY_CONSTRUCTION,
- '{其他项目费}': fixedFlag.OTHER,
- '{规费}': fixedFlag.CHARGE,
- '{税金}': fixedFlag.TAX,
- '{增值税}': fixedFlag.ADDED_VALUE_TAX,
- };
- //计算基础表达式映射
- const CalcBaseMap = {
- '{分部分项工程费}': 'FBFXHJ',
- '{措施项目费}': 'CSXMHJ',
- '{组织措施项目费}': 'ZZCSF',
- '{其他项目费}': 'QTXMHJ',
- '{规费}': 'GF',
- '{税金}': 'SJ',
- '{分部分项定额人工费}': 'RGF',
- '{分部分项定额材料费}': 'CLF',
- '{分部分项定额施工机具使用费}': 'JXF',
- '{分部分项主材费}': 'ZCF',
- '{分部分项人工工日}': 'GR',
- '{技术措施项目费}': 'JSCSF',
- '{技术措施项目定额人工费}': 'JSCS_RGF',
- '{技术措施项目定额材料费}': 'JSCS_CLF',
- '{技术措施项目定额施工机具使用费}': 'JSCS_JXF',
- '{技术措施项目主材费}': 'JSCS_ZCF',
- '{技术措施项目人工工日}': 'JSCS_GR',
- '{建筑面积}': 'JZMJ',
- '{人材机价差}': 'RCJJC',
- '{人工价差}': 'RGJC',
- '{材料价差}': 'CLJC',
- '{施工机具使用费价差}': 'JXJC',
- '{甲供人工费}': 'JGRGF',
- '{甲供材料费}': 'JGCLF',
- '{甲供施工机具使用费}': 'JGJXF',
- '{甲供主材费}': 'JGZCF',
- '{甲供设备费}': 'JGSBF',
- '{分包费}': 'FBF',
- '{分包定额人工费}': 'FBRGF',
- '{分包定额材料费}': 'FBCLF',
- '{分包定额机械费}': 'FBJXF',
- '{分包主材费}': 'FBZCF',
- '{分包设备费}': 'FBSBF',
- '{分包人工工日}': 'FBGR'
- };
- //加载数据间隔,减少服务器压力
- const TIMEOUT_TIME = 500;
- function isDef(v) {
- return typeof v !== 'undefined' && v !== null;
- }
- //导出粒度
- const GRANULARITY = {
- PROJECT: 1, //导出建设项目
- ENGINEERING: 2, //导出单项工程
- TENDER: 3 //导出单位工程
- };
- //导出的文件类型选项
- const ExportKind = {
- Tender: 1, //投标
- Bid: 2, //招标
- Control: 3 //控制价
- };
- return function (userID, granularity, exportKind) {
- //默认导出建设项目
- if (!granularity || ![1, 2, 3].includes(granularity)) {
- granularity = GRANULARITY.PROJECT;
- }
- this.granularity = granularity;
- //默认导出投标文件
- if (!exportKind || ![1, 2, 3].includes(exportKind)) {
- exportKind = ExportKind.Tender;
- }
- this.exportKind = exportKind;
- /*
- * 检查
- * 创建节点时检查节点的数据
- * 1.长度限制minLen,maxLen
- * 2.值的限制,固定范围:enumeration
- * @param {Array}datas(需要检查的属性数据)
- * @return {Object} failHints没通过的属性提示 filterAttrs过滤后的属性数据(失败提示在属性是必须的时候才提示,如果该属性失败了,但是是非必要属性,那么该属性不显示)
- * */
- function check(datas) {
- let rst = {failHints: [], filterAttrs: []};
- 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])))/;
- for (let data of datas) {
- data.value = typeof data.value === 'undefined' || data.value === null ? '' : data.value.toString();
- if (data.whiteSpace && data.whiteSpace === WHITE_SPACE.COLLAPSE) { //处理空格相关
- data.value = data.value.replace(/[\r,\n,\t]/g, ' ');
- data.value = data.value.trim();
- data.value = data.value.replace(/\s{1,}/g, ' ');
- }
- if (!data.value && !data.minLen && !data.enumeration) { //值为空,且没有限制最小字符数,且没有限制值,则不需判断
- rst.filterAttrs.push(data);
- continue;
- }
- let isFail = false,
- tempFail = '';
- if (data.minLen && data.value.length < data.minLen){
- isFail = true;
- tempFail = `“${data.name}”字符数不可小于${data.minLen}个`;
- } else if (data.maxLen && data.value.length > data.maxLen) {
- isFail = true;
- tempFail = `“${data.name}”字符数不可大于${data.maxLen}个`;
- } else if (data.enumeration && !data.enumeration.includes(data.value)) {
- isFail = true;
- tempFail = `“${data.name}”只能从“${data.enumeration.join(';')}”中选择`;
- } else if (data.type && data.type === TYPE.DATE && !dateReg.test(data.value)) {
- isFail = true;
- tempFail = `“${data.name}”日期格式必须是YYYY-MM-DD`;
- } else if (data.type && data.type === TYPE.INT && !Number.isInteger(parseFloat(data.value))) {
- isFail = true;
- tempFail = `“${data.name}”必须为整数`;
- } else if (data.type && data.type === TYPE.DECIMAL && isNaN(parseFloat(data.value))) {
- isFail = true;
- tempFail = `“${data.name}”必须为数值`;
- } else if (data.type && data.type === TYPE.NUM2) {
- let v = parseFloat(data.value);
- if (isNaN(v)) {
- isFail = true;
- tempFail = `“${data.name}”必须为数值`;
- rst.failHints.push(`“${data.name}”必须为数值`);
- } else if (!data.value.length || (data.value.split('.').length > 1 && data.value.split('.')[1].length > 2)){
- isFail = true;
- }
- } else if (data.type && data.type === TYPE.BOOL && !['true', 'false'].includes(data.value.toString())) {
- isFail = true;
- tempFail = `“${data.name}”必须为true或false`;
- }
- if (!isFail || data.required) {
- rst.filterAttrs.push(data);
- }
- if (isFail && data.required && tempFail) {
- rst.failHints.push(tempFail);
- }
- }
- return rst;
- }
- //从fees数组中获取相关费用
- function getFee(fees, feeFields) {
- if (!Array.isArray(fees)) {
- return 0;
- }
- let fields = feeFields.split('.');
- let fee = fees.find(data => data.fieldName === fields[0]);
- if (!fee) {
- return 0;
- }
- return fee[fields[1]] || 0;
- }
- //根据字段获取基本信息、工程特征
- function getValueByKey(data, key) {
- for (let d of data) {
- if (d.key === key) {
- return d.value;
- }
- if (d.items && d.items.length > 0) {
- let findData = d.items.find(x => x.key === key);
- if (findData) {
- return findData.value;
- }
- }
- }
- return '';
- }
- //造成导出失败
- let failList = [];
- /*
- * 定义不设置一个Node方法统一进入的原因:模板化比较直观,不分开定义节点的话,调用传参也很麻烦而且不直观。
- * 一个节点对应一个构造方法,方便调整配置、方便其他版本开发、接手的人看起来更直观
- * @param {String}name(节点名) {Array}attrs(节点属性数据)
- * @return {void}
- * */
- function element(name, attrs) {
- this.name = name;
- let checkData = check(attrs);
- this.fail = checkData.failHints;
- this.attrs = checkData.filterAttrs;
- this.children = [];
- for (let fail of this.fail) {
- failList.push(`${name}-${fail}`);
- }
- }
- //建设项目定义
- //source:来源数据
- function Project(source) {
- let attrs = [
- {name: '项目编号', value: getValueByKey(source.basicInformation, 'projNum'), required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '项目名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '建设单位', value: getValueByKey(source.basicInformation, 'constructionUnit'), required: true},
- {name: '标准版本号', value: '3.2.2', required: true},
- {name: '标准名称', value: '重庆造价软件数据交换标准(清单计价)', required: true,},
- {name: '文件类型', value: source.fileKind, required: true, enumeration: ['招标', '投标', '控制价', '结算', '其他']},
- {name: '计税方法', value: source.taxType, required: true, enumeration: ['营业税', '一般计税法', '简易计税法']},
- ];
- //唯一约束
- this.constraints = {
- engCode: [], //单项工程编号
- tenderCode: [], //单位工程编号
- };
- element.call(this, '标段', attrs);
- }
- //项目信息定义
- function ProjectInfo(source) {
- let attrs = [
- {name: '工程规模', value: getValueByKey(source.basicInformation, 'projectScale'), required: true},
- {name: '工程所在地', value: getValueByKey(source.basicInformation, 'projLocation'), required: true},
- {name: '工程地址', value: getValueByKey(source.basicInformation, 'projAddress'), required: true},
- {name: '施工单位', value: getValueByKey(source.basicInformation, 'buildingUnit')},
- {name: '编制单位', value: getValueByKey(source.basicInformation, 'establishmentUnit'), required: true},
- {name: '审核单位', value: getValueByKey(source.basicInformation, 'auditUnit')},
- {name: '编制人', value: getValueByKey(source.basicInformation, 'buildingUnitAuthor'), required: true},
- {name: '审核人', value: getValueByKey(source.basicInformation, 'auditUnitAuditor')},
- {name: '开工日期', value: getValueByKey(source.basicInformation, 'commencementDate'), type: TYPE.DATE},
- {name: '竣工日期', value: getValueByKey(source.basicInformation, 'completionDate'), type: TYPE.DATE},
- {name: '编制日期', value: getValueByKey(source.basicInformation, 'establishDate'), type: TYPE.DATE, required: true},
- {name: '审核日期', value: getValueByKey(source.basicInformation, 'auditDate'), type: TYPE.DATE},
- {name: '材料价格期', value: getValueByKey(source.basicInformation, 'materialPricePeriod'), required: true},
- {name: '合同价类型', value: getValueByKey(source.basicInformation, 'contractPriceType')},
- ];
- element.call(this, '项目信息', attrs);
- }
- //招标信息定义
- function BiddingInfo(source) {
- //控制总价: 如果文件类型是“控制价”,则导出建设项目的工程造价;如果是“招标”、“投标”,则取0
- console.log(exportKind);
- let attrs = [
- {name: '招标代理机构', value: getValueByKey(source.basicInformation, 'agency')},
- {name: '造价工程师', value: getValueByKey(source.basicInformation, 'tenderCostEngineer'), required: true},
- {name: '造价工程师注册证号', value: getValueByKey(source.basicInformation, 'tenderCostEngineerNo'), required: true},
- {name: '招标工期', value: getValueByKey(source.basicInformation, 'tenderPeriod'), required: true, type: TYPE.INT},
- {name: '控制总价', value: exportKind === ExportKind.Control ? source.summaryInfo.engineeringCost : '0', required: true, type: TYPE.NUM2},
- ];
- element.call(this, '招标信息', attrs);
- }
- //投标信息定义
- function BidInfo(source) {
- let attrs = [
- {name: '投标人', value: getValueByKey(source.basicInformation, 'bidder'), required: true},
- {name: '造价工程师', value: getValueByKey(source.basicInformation, 'bidCostEngineer'), required: true},
- {name: '造价工程师注册证号', value: getValueByKey(source.basicInformation, 'bidCostEngineerNo'), required: true},
- {name: '项目经理', value: getValueByKey(source.basicInformation, 'projectManager')},
- {name: '投标工期', value: getValueByKey(source.basicInformation, 'biddingPeriod')},
- {name: '投标保证金', value: getValueByKey(source.basicInformation, 'biddingMargin'), type: TYPE.NUM2},
- {name: '质量承诺', value: getValueByKey(source.basicInformation, 'qualityCommitment')},
- {name: '担保类型', value: getValueByKey(source.basicInformation, 'guaranteeType'), enumeration: ['支票', '现金', '电汇', '汇票']},
- {name: '投标总价', value: source.summaryInfo.engineeringCost, required: true, type: TYPE.NUM2},
- ];
- element.call(this, '投标信息', attrs);
- }
- //编制说明定义
- function CompilationIllustration(source) {
- let attrs = [
- {name: '内容', value: source.compilationIllustration, required: true},
- ];
- element.call(this, '编制说明', attrs);
- }
- //系统信息定义
- function SystemInfo(source) {
- let attrs = [
- {name: 'ID1', value: source.softInfo, required: true},
- {name: 'ID2', value: '', required: true},
- {name: '生成时间', value: source.generatedTime, type: TYPE.DATE_TIME, required: true},
- ];
- element.call(this, '系统信息', attrs);
- }
- //费用构成定义
- function FeeFrom(summaryInfo) {
- let attrs = [
- {name: '工程费合计', value: summaryInfo.engineeringCost, required: true, type: TYPE.NUM2},
- {name: '分部分项清单合计', value: summaryInfo.subEngineering, required: true, type: TYPE.NUM2},
- {name: '措施项目清单合计', value: summaryInfo.measure, required: true, type: TYPE.NUM2},
- {name: '安全文明施工专项费', value: summaryInfo.safetyConstruction, required: true, type: TYPE.NUM2},
- {name: '其他项目清单合计', value: summaryInfo.other, required: true, type: TYPE.NUM2},
- {name: '暂列金额合计', value: summaryInfo.provisional, type: TYPE.NUM2},
- {name: '材料暂估价合计', value: summaryInfo.materialProvisional, type: TYPE.NUM2},
- {name: '专业工程暂估价合计', value: summaryInfo.engineeringEstimate, type: TYPE.NUM2},
- {name: '计日工合计', value: summaryInfo.daywork, type: TYPE.NUM2},
- {name: '总承包服务费合计', value: summaryInfo.turnKeyContract, type: TYPE.NUM2},
- {name: '签证索赔合计', value: summaryInfo.claimVisa, type: TYPE.NUM2},
- {name: '规费', value: summaryInfo.charge, required: true, type: TYPE.NUM2},
- {name: '税金', value: summaryInfo.tax, required: true, type: TYPE.NUM2},
- ];
- element.call(this, '费用构成', attrs);
- }
- //单项工程定义
- function Engineering(source) {
- let attrs = [
- {name: '编号', value: source.code, required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '金额', value: exportKind === FILE_KIND.tender ? source.summaryInfo.engineeringCost : '0', type: TYPE.NUM2},
- ];
- element.call(this, '单项工程', attrs);
- }
- //单位工程定义
- function Tender(source) {
- const TAX = {
- '1': '一般计税',
- '2': '简易计税',
- };
- let attrs = [
- {name: '编号', value: source.code, required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '专业', value: source.engineeringName, required: true, enumeration: [
- '土建工程', '装饰工程', '安装工程', '市政工程', '园林绿化工程',
- '仿古建筑工程', '房修工程', '轨道工程', '构筑物工程', '机械(爆破)土石方',
- '围墙工程', '幕墙工程', '市政安装工程', '城市轨道交通安装', '人工土石方',
- '房屋安装修缮工程', '房屋修缮单拆除'
- ]},
- {name: '金额', value: exportKind === FILE_KIND.tender
- ? source.summaryInfo.engineeringCost
- : '0', type: TYPE.NUM2},
- {name: '定额库编码', value: source.defaultRationLibCode, enumeration: [
- 'CQ18TJ', 'CQ18ZS', 'CQ18AZ', 'CQ18SZ', 'CQ18YL', 'CQ18FG', 'CQ18GD', 'CQ18FS',
- 'CQ18LS', 'CQ18GZW', 'CQ18BP', 'CQ18ZP'
- ]},
- {name: '计税方法', value: TAX[source.taxType], required: true, enumeration: ['营业税', '一般计税', '简易计税']},
- ];
- this.constraints = {
- billsCode: [], //清单项目项目编码
- formulaMeasureNo: [], //公式计算措施项序号
- gljCode: [], //人材机代码
- provisionalDetailCode: [], //暂列金额明细编号
- engEstimateDetailCode: [], //专业工程暂估明细
- turnKeyContractCode: [], //总承包服务费费用项编号
- labourDayWorkCode: [], //人工计日工项目编号
- materialDayWorkCode: [], //材料计日工项目编号
- machineDayWorkCode: [], //机械计日工项目编号
- otherItemNo: [], //其他列项序号
- feeItemNo: [], //费用项序号
- mainBillsCode: [], //主要清单明细项目编码 (标准文件中constraint中没有定义此唯一性,但是主要清单明细的备注那里说明了,这里处理一下)
- appraisalDetailCode: [], //评审材料明细代码唯一(标准文件中constraint中没有定义此唯一性,但是评审材料明细的备注里说明了)
- };
- element.call(this, '单位工程', attrs);
- }
- //工程特征定义
- function EngFeature(source) {
- let attrs = [
- {name: '建筑分类', value: source.feature.buildingClass, required: true},
- {name: '工程分类', value: source.feature.projClass, required: true},
- {name: '建设规模', value: source.feature.projectScale, required: true},
- {name: '工程类别', value: getValueByKey(source.basicInformation, 'projectCategory'), required: true} //取建设项目的工程类别
- ];
- element.call(this, '工程特征', attrs);
- }
- //特征项定义
- function FeatureItem(feature) {
- let attrs = [
- {name: '编码', value: feature.code || ''},
- {name: '名称', value: feature.dispName, required: true},
- {name: '内容', value: feature.value, required: true},
- ];
- element.call(this, '特征项', attrs);
- }
- //单位工程费汇总定义
- function TenderFeeSummary() {
- element.call(this, '单位工程费汇总', []);
- }
- //计价程序费用行定义
- function FeeRow(source) {
- let attrs = [
- {name: '序号', value: source.code},
- {name: '行代号', value: source.rowCode, required: true},
- {name: '项目名称', value: source.name, required: true},
- {name: '计算基础表达式', value: source.calcBase, required: true},
- {name: '计算基础说明', value: source.calcBase},
- {name: '费率', value: source.feeRate},
- {name: '金额', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2},
- {name: '其中暂估价', value: getFee(source.fees, 'estimate.totalFee'), type: TYPE.NUM2},
- {name: '费用类别', value: source.feeType, type: TYPE.INT, required: true,
- enumeration: ['1100', '1200', '1204', '1300', '800', '900', '1800', '1']},
- {name: '备注', value: source.remark},
- ];
- element.call(this, '计价程序费用行', attrs);
- }
- //分部分项清单
- function FBFXBills() {
- element.call(this, '分部分项清单', []);
- }
- //清单分部定义
- function FBBills(source) {
- let attrs = [
- {name: '编号', value: source.code, required: true, maxLen: 20},
- {name: '名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '金额', value: getFee(source.fees, 'common.totalFee'), required: true, type: TYPE.NUM2},
- {name: '其中暂估价', value: getFee(source.fees, 'estimate.totalFee'), required: true},
- {name: '备注', value: source.remark}
- ];
- element.call(this, '清单分部', attrs);
- }
- //清单项目定义
- function FXbills(source) {
- let attrs = [
- {name: '项目编码', value: source.code, required: true, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '项目名称', value: source.name, required: true, minLen: 1, maxLen: 500, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '单位', value: source.unit, required: true, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '工程量', value: source.quantity, required: true, type: TYPE.DECIMAL},
- {name: '综合单价', value: getFee(source.fees, 'common.unitFee'), required: true, type: TYPE.DECIMAL},
- {name: '综合合价', value: getFee(source.fees, 'common.totalFee'), required: true, type: TYPE.NUM2},
- {name: '其中暂估价', value: getFee(source.fees, 'estimate.totalFee'), required: true, type: TYPE.NUM2},
- {name: '主要清单标志', value: !!source.mainBills, type: TYPE.BOOL},
- {name: '暂估清单标志', value: !!source.isEstimate, type: TYPE.BOOL},
- {name: '备注', value: source.remark},
- ];
- element.call(this, '清单项目', attrs);
- }
- //项目特征定义
- function ItemCharacter() {
- element.call(this, '项目特征', []);
- }
- //特征定义
- function Feature(source) {
- let attrs = [
- {name: '特征名称', value: source.name, required: true},
- {name: '特征描述', value: source.value, required: true},
- ];
- element.call(this, '特征', attrs);
- }
- //工程内容定义
- function JobContent() {
- element.call(this, '工程内容', []);
- }
- //内容定义
- function Content(content) {
- let attrs = [
- {name: '内容', value: content, required: true}
- ];
- element.call(this, '内容', attrs);
- }
- //组价内容定义
- function PriceContent() {
- element.call(this, '组价内容', []);
- }
- //定额子目定义
- function Ration(source) {
- let attrs = [
- {name: '定额编号', value: source.viewCode, required: true, minLen: 1, maxLen: 80, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '项目名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '单位', value: source.unit, required: true, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '定额库编码', value: source.libCode, required: true},
- {name: '原始定额编号', value: source.code, minLen: 1, maxLen: 80, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '子目类型', value: source.subType, required: true, type: TYPE.INT, enumeration: ['0', '1', '2', '3', '4', '5', '6']},
- {name: '工程量', value: source.quantity, required: true, type: TYPE.DECIMAL},
- {name: '工程量计算式', value: source.quantityEXP},
- {name: '定额单价', value: getFee(source.fees, 'rationUnitPrice.unitFee'), required: true, type: TYPE.DECIMAL},
- {name: '定额合价', value: getFee(source.fees, 'rationUnitPrice.totalFee'), required: true, type: TYPE.NUM2},
- {name: '综合单价', value: getFee(source.fees, 'common.unitFee'), required: true, type: TYPE.DECIMAL},
- {name: '综合合价', value: getFee(source.fees, 'common.totalFee'), required: true, type: TYPE.NUM2},
- {name: '单价构成文件ID', value: source.programID, required: true, type: TYPE.INT},
- {name: '分包标志', value: !!source.isSubcontract, type: TYPE.BOOL},
- {name: '备注', value: source.remark}
- ];
- element.call(this, '定额子目', attrs);
- }
- //工料分析定义
- function GljAnalyze() {
- element.call(this, '工料分析', []);
- }
- //人材机含量定义
- function GljContent(source) {
- let attrs = [
- {name: '人材机代码', value: source.code, required: true, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '消耗量', value: source.quantity, required: true, type: TYPE.DECIMAL},
- {name: '总消耗量', value: source.totalQuantity, required: true, type: TYPE.DECIMAL},
- {name: '数量计算方式', value: 1, required: true, type: TYPE.INT, enumeration: ['1', '2']},
- ];
- element.call(this, '人材机含量', attrs);
- }
- //费用组成
- function FeeContent(source) {
- let attrs = [
- {name: '基价人工费单价', value: getFee(source.fees, 'labour.unitFee'), type: TYPE.DECIMAL, required: true},
- {name: '基价人工费合价', value: getFee(source.fees, 'labour.totalFee'), type: TYPE.NUM2, required: true},
- {name: '定额人工基价调整单价', value: 0, type: TYPE.DECIMAL}, //调整价目前只有08有,默认设置成0
- {name: '定额人工基价调整合价', value: 0, type: TYPE.NUM2},
- {name: '基价材料费单价', value: getFee(source.fees, 'material.unitFee'), type: TYPE.DECIMAL, required: true},
- {name: '基价材料费合价', value: getFee(source.fees, 'material.totalFee'), type: TYPE.NUM2, required: true},
- {name: '基价机械费单价', value: getFee(source.fees, 'machine.unitFee'), type: TYPE.DECIMAL, required: true},
- {name: '基价机械费合价', value: getFee(source.fees, 'machine.totalFee'), type: TYPE.NUM2, required: true},
- {name: '定额机上人工基价调整单价', value: 0, type: TYPE.DECIMAL, required: true},
- {name: '定额机上人工基价调整合价', value: 0, type: TYPE.NUM2, required: true},
- {name: '未计材料单价', value: getFee(source.fees, 'unratedMaterial.unitFee'), type: TYPE.DECIMAL, required: true},
- {name: '未计材料合价', value: getFee(source.fees, 'unratedMaterial.totalFee'), type: TYPE.NUM2, required: true},
- {name: '人材机价差单价', value: getFee(source.fees, 'gljDiff.unitFee'), type: TYPE.DECIMAL, required: true}, //人材机价差通过人工、材料、机械价差相加得出
- {name: '人材机价差合价', value: getFee(source.fees, 'gljDiff.totalFee'), type: TYPE.NUM2, required: true},
- {name: '暂估材料单价', value: getFee(source.fees, 'estimate.unitFee'), type: TYPE.DECIMAL, required: true},
- {name: '暂估材料合价', value: getFee(source.fees, 'estimate.totalFee'), type: TYPE.NUM2, required: true},
- {name: '管理费单价', value: getFee(source.fees, 'manage.unitFee'), type: TYPE.DECIMAL, required: true},
- {name: '管理费合价', value: getFee(source.fees, 'manage.totalFee'), type: TYPE.NUM2, required: true},
- {name: '利润单价', value: getFee(source.fees, 'profit.unitFee'), type: TYPE.DECIMAL, required: true},
- {name: '利润合价', value: getFee(source.fees, 'profit.totalFee'), type: TYPE.NUM2, required: true},
- {name: '风险单价', value: getFee(source.fees, 'risk.unitFee'), type: TYPE.DECIMAL, required: true}, //重庆08叫风险费 重庆18叫一般风险费
- {name: '风险合价', value: getFee(source.fees, 'risk.totalFee'), type: TYPE.NUM2, required: true},
- {name: '一般风险单价', value: getFee(source.fees, 'risk.unitFee'), type: TYPE.DECIMAL, required: true},
- {name: '一般风险合价', value: getFee(source.fees, 'risk.totalFee'), type: TYPE.NUM2, required: true},
- {name: '其他风险单价', value: getFee(source.fees, 'otherRisk.unitFee'), type: TYPE.DECIMAL, required: true},
- {name: '其他风险合价', value: getFee(source.fees, 'otherRisk.totalFee'), type: TYPE.NUM2, required: true},
- ];
- element.call(this, '费用组成', attrs);
- }
- //措施项目清单定义
- function CSXMBills(source) {
- let attrs = [
- {name: '金额', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2, required: true},
- {name: '其中暂估价', value: getFee(source.fees, 'estimate.totalFee'), type: TYPE.NUM2, required: true},
- ];
- element.call(this, '措施项目清单', attrs);
- }
- //组织措施清单定义
- function ZZCSBills(source) {
- let attrs = [
- {name: '金额', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2, required: true},
- ];
- element.call(this, '组织措施清单', attrs);
- }
- //组织措施分类定义
- function ZZCSClass(source) {
- let attrs = [
- {name: '编码', value: source.code, maxLen: 20, required: true},
- {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '金额', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2, required: true},
- {name: '备注', value: source.remark}
- ];
- element.call(this, '组织措施分类', attrs);
- }
- //公式计算措施项
- function FormulaCalcMeasure(source) {
- let attrs = [
- {name: '序号', value: source.code, minLen: 1, maxLen:20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '计算基础表达式', value: source.calcBase, required: true},
- {name: '计算基础说明', value: source.calcBase},
- {name: '费率', value: source.feeRate, required: true},
- {name: '金额', value: getFee(source.fees, 'common.totalFee'), required: true},
- {name: '暂估价标志', value: !!source.isEstimate, type: TYPE.BOOL},
- {name: '备注', value: source.remark},
- {name: '费用类别', value: source.feeType, enumeration: ['120201', '1204', '10041', '1206'], required: true},
- ];
- element.call(this, '公式计算措施项', attrs);
- }
- //技术措施清单定义
- function JSCSBills(source) {
- let attrs = [
- {name: '金额', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2, required: true},
- {name: '其中暂估价', value: getFee(source.fees, 'estimate.totalFee'), type: TYPE.NUM2, required: true},
- ];
- element.call(this, '技术措施清单', attrs);
- }
- //技术措施分类
- function JSCSClass(source) {
- let attrs = [
- {name: '编号', value: source.code},
- {name: '名称', value: source.name, required: true},
- {name: '金额', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2, required: true},
- {name: '其中暂估价', value: getFee(source.fees, 'estimate.totalFee'), type: TYPE.DECIMAL, required: true},
- ];
- element.call(this, '技术措施分类', attrs);
- }
- //其他项目清单定义
- function OtherBills() {
- element.call(this, '其他项目清单', []);
- }
- //暂列金额定义
- function Provisional(source) {
- let attrs = [
- {name: '金额', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2}
- ];
- element.call(this, '暂列金额', attrs);
- }
- //暂列金额明细定义
- function ProvisionalDetail(source) {
- let attrs = [
- {name: '编号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '项目名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '计量单位', value: source.unit, maxLen: 20, required: true},
- {name: '金额', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2, required: true},
- {name: '备注', value: source.remark, required: true}
- ];
- element.call(this, '暂列金额明细', attrs);
- }
- //专业工程暂估价定义
- function EngEstimate(source) {
- let attrs = [
- {name: '金额', value: getFee(source.fees, 'common.totalFee')}
- ];
- element.call(this, '专业工程暂估价', attrs);
- }
- //专业工程暂估明细定义
- function EngEstimateDetail(source) {
- let attrs = [
- {name: '编号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '工程名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '工程内容', value: source.engineeringContent, maxLen: 2000, required: true},
- {name: '金额', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2, required: true},
- {name: '备注', value: source.remark, required: true}
- ];
- element.call(this, '专业工程暂估明细', attrs);
- }
- //计日工定义
- function DayWork(source) {
- let attrs = [
- {name: '金额', value: getFee(source.fees, 'common.totalFee')}
- ];
- element.call(this, '计日工', attrs);
- }
- //人工定义
- function Labour() {
- element.call(this, '人工', []);
- }
- //材料定义
- function Material() {
- element.call(this, '材料', []);
- }
- //施工机械定义
- function Machine() {
- element.call(this, '施工机械', []);
- }
- //计日工项目定义
- function DayWorkItem(source) {
- let attrs = [
- {name: '编号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '单位', value: source.unit, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '数量', value: source.quantity, type: TYPE.DECIMAL, required: true},
- {name: '综合单价', value: source.quantity, type: TYPE.DECIMAL, required: true},
- {name: '综合合价', value: source.quantity, type: TYPE.NUM2, required: true},
- {name: '备注', value: source.remark}
- ];
- element.call(this, '计日工项目', attrs);
- }
- //总承包服务费定义
- function TurnKeyContract(source) {
- let attrs = [
- {name: '金额', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2}
- ];
- element.call(this, '总承包服务费', attrs);
- }
- //总承包服务费分类定义
- function TurnKeyContractClass(source) {
- let attrs = [
- {name:'编号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name:'名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name:'备注', value: source.remark}
- ];
- element.call(this, '总承包服务费分类', attrs);
- }
- //总承包服务费费用项定义
- function TurnKeyContractItem(source) {
- let attrs = [
- {name: '编号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '工程名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '计算基础', value: source.calcBaseValue, type: TYPE.DECIMAL, required: true},
- {name: '服务内容', value: source.serviceContent, maxLen: 255, required: true},
- {name: '费率', value: source.feeRate, type: TYPE.DECIMAL, required: true},
- {name: '金额', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2, required: true},
- {name: '备注', value: source.remark}
- ];
- element.call(this, '总承包服务费费用项', attrs);
- }
- //签证索赔计价汇总费用项
- function ClaimVisaFeeItem(source) {
- let attrs = [
- {name: '编号', value: source.code, required: true},
- {name: '项目名称', value: source.name, required: true},
- {name: '计量单位', value: source.unit, required: true},
- {name: '数量', value: source.quantity, type: TYPE.DECIMAL, required: true},
- {name: '单价', value: getFee(source.fees, 'common.unitFee'), type: TYPE.DECIMAL, required: true},
- {name: '合价', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2, required: true},
- {name: '依据', value: source.claimVisa, required: true},
- ];
- element.call(this, '签证索赔计价汇总费用项', attrs);
- }
- //其他定义
- function Other(source) {
- let attrs = [
- {name: '金额', value: source.commonTotalFee, type: TYPE.NUM2}
- ];
- element.call(this, '其他', attrs);
- }
- //其他列项定义
- function OtherItem(source) {
- let attrs = [
- {name: '序号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '计算基础', value: source.calcBase, maxLen: 255},
- {name: '费率', value: source.feeRate, type: TYPE.DECIMAL},
- {name: '金额', value: source.commonTotalFee, type: TYPE.NUM2, required: true},
- {name: '不计入合价标志', value: source.notSummray, type: TYPE.BOOL},
- {name: '招标人标志', value: false, type: TYPE.BOOL},
- {name: '备注', value: source.remark, maxLen: 255}
- ];
- element.call(this, '其他列项', attrs);
- }
- //规费和税金清单定义
- function ChargeTaxBills() {
- element.call(this, '规费和税金清单', []);
- }
- //费用项定义
- function FeeItem(source) {
- let attrs = [
- {name: '序号', value: source.code, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '行代号', value: source.rowCode, maxLen: 20, required: true},
- {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '计算基础表达式', value: source.calcBase, maxLen: 255, required: true},
- {name: '计算基础说明', value: source.calcBase, maxLen: 255},
- {name: '费率', value: source.feeRate, type: TYPE.DECIMAL, required: true},
- {name: '金额', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2, required: true},
- {name: '费用类别', value: source.feeType, enumeration: ['800', '900', '9001', '9002', '9003'], required: true},
- {name: '备注', value: source.remark, maxLen: 255}
- ];
- element.call(this, '费用项', attrs);
- }
- //人材机汇总定义
- function GljSummary() {
- element.call(this, '人材机汇总', []);
- }
- //人材机定义
- function Glj(source) {
- let attrs = [
- {name: '代码', value: source.code, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '规格', value: source.specs, maxLen: 255},
- {name: '单位', value: source.unit, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '原始代码', value: source.orgCode, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '费用类别', value: source.feeType, enumeration: ['1', '2', '3', '4'], required: true},
- {name: '配比类别', value: source.ratioType, type: TYPE.INT},
- {name: '主要材料类别', value: source.mainMaterialType, type: TYPE.INT},
- {name: '主要材料单位系数', value: source.materialCoe, type: TYPE.DECIMAL},
- {name: '材料耗用类型', value: 0, type: TYPE.INT, required: true},
- {name: '供应方式', value: source.supply, type: TYPE.INT, enumeration: ['1', '2']},
- {name: '暂估材料标志', value: source.is_evaluate, type: TYPE.BOOL},
- {name: '不计税设备标志', value: source.no_tax_eqp, type: TYPE.BOOL, required: true},
- {name: '单价不从明细汇总标志', value: source.notFromDetail, type: TYPE.BOOL},
- {name: '定额价', value: source.basePrice, type: TYPE.DECIMAL, required: true},
- {name: '定额价调整', value: source.adjPrice, type: TYPE.DECIMAL, required: true},
- {name: '市场价', value: source.marketPrice, type: TYPE.DECIMAL, required: true},
- {name: '数量', value: source.quantity, type: TYPE.DECIMAL, required: true},
- {name: '产地', value: source.originPlace, maxLen: 255},
- {name: '厂家', value: source.vender, maxLen: 255},
- {name: '质量等级', value: source.qualityGrace, maxLen: 255},
- {name: '品牌', value: source.brand, maxLen: 255},
- {name: '备注', value: source.remark, maxLen: 255},
- ];
- element.call(this, '人材机', attrs);
- }
- //人材机配比定义
- function GljRatio(source) {
- let attrs = [
- {name: '明细材料代码', value: source.code, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '数量', value: source.quantity, type: TYPE.DECIMAL, required: true}
- ];
- element.call(this, '人材机配比', attrs);
- }
- //评标材料表定义
- function EvalBidMaterial() {
- element.call(this, '评标材料表', []);
- }
- //暂估价材料表定义
- function EvalEstimateMaterial() {
- element.call(this, '暂估价材料表', []);
- }
- //材料明细定义
- function MaterialDetail(source) {
- let attrs = [
- {name: '序号', value: source.serialNo, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '关联材料号', value: source.orgCode, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '材料名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '规格型号', value: source.specs, maxLen: 255},
- {name: '计量单位', value: source.unit, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '数量', value: source.quantity, type: TYPE.DECIMAL},
- {name: '单价', value: source.marketPrice, type: TYPE.DECIMAL},
- {name: '合价', value: source.totalPrice, type: TYPE.NUM2},
- {name: '产地', value: source.originPlace, maxLen: 255},
- {name: '厂家', value: source.vender, maxLen: 255},
- {name: '品牌', value: source.brand, maxLen: 255},
- {name: '质量等级', value: source.qualityGrace, maxLen: 255},
- {name: '备注', value: source.remark, maxLen: 255},
- ];
- element.call(this, '材料明细', attrs);
- }
- //清单综合单价计算程序定义
- function CalcProgram() {
- element.call(this, '清单综合单价计算程序', []);
- }
- //综合单价计算程序文件定义
- function CalcProgramFile(source) {
- let attrs = [
- {name: 'ID', value: source.ID, type: TYPE.INT, required: true},
- {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE, required: true}
- ];
- element.call(this, '综合单价计算程序文件', attrs);
- }
- //综合单价计算程序费用项定义
- function CalcProgramFeeItem(source) {
- let attrs = [
- {name: '序号', value: source.serialNo, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE},
- {name: '行代号', value: source.rowCode, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '项目名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '计算基础表达式', value: source.calcBase, maxLen: 255, required: true},
- {name: '计算基础说明', value: source.statement, maxLen: 255},
- {name: '费率', value: source.feeRate, type: TYPE.DECIMAL},
- {name: '费用类别', value: source.feeType, type: TYPE.INT, required: true},
- {name: '备注', value: source.remark, maxLen: 255},
- ];
- element.call(this, '综合单价计算程序费用项', attrs);
- }
- //主要清单汇总定义
- function MainBillsSummary() {
- element.call(this, '主要清单汇总', []);
- }
- //主要清单明细定义
- function MainBillsItem(source) {
- let attrs = [
- {name: '项目编码', value: source.code, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '项目名称', value: source.name, minLen: 1, maxLen: 500, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '单位', value: source.unit, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '工程量', value: source.quantity, type: TYPE.DECIMAL, required: true},
- {name: '综合单价', value: getFee(source.fees, 'common.unitFee'), type: TYPE.DECIMAL, required: true},
- {name: '综合合价', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2, required: true},
- {name: '其中暂估价', value: getFee(source.fees, 'estimate.totalFee'), type: TYPE.DECIMAL},
- {name: '备注', value: source.remark, maxLen: 255},
- ];
- element.call(this, '主要清单明细', attrs);
- }
- //评审材料汇总定义
- function AppraisalSummary(){
- element.call(this, '评审材料汇总', []);
- }
- //评审材料明细定义
- function AppraisalDetail(source) {
- let attrs = [
- {name: '代码', value: source.orgCode, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '名称', value: source.name, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '规格', value: source.specs, maxLen: 255},
- {name: '单位', value: source.unit, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE, required: true},
- {name: '市场价', value: source.marketPrice, type: TYPE.DECIMAL, required: true}
- ];
- element.call(this, '评审材料明细', attrs);
- }
- function setTimeoutSync(handle, time) {
- return new Promise(function(resolve, reject) {
- setTimeout(function () {
- if (handle && typeof handle === 'function') {
- handle();
- }
- resolve();
- }, time);
- });
- }
- this.failList = failList;
- //目前的数据
- let curPMData = {project: null, engineering: null, tender: null}, //项目管理项目数据
- curProjectEle = null, //建设项目节点
- curTenderEle = null; //单位工程节点
- //记录拉取的单位工程项目详细数据,导出的时候,可能会导出多个文件,只有导出第一个文件的时候需要请求数据
- let tenderDetailMap = {}; //ID映射 ID: data
- //自增编码
- let incrementData = {
- projectCode: 1, //项目编号,单项工程、单位工程编号自动生成
- };
- function getIncreamentData(field) {
- if (!incrementData[field]) {
- incrementData[field] = 1;
- }
- return incrementData[field]++;
- }
- //数组打平成对象
- function arrayToObj(arr) {
- let rst = {};
- for (let data of arr) {
- rst[data.key] = data.value;
- }
- return rst;
- }
- //获取节点固定ID
- function getNodeFlag(node) {
- if (!node || !node.data || !node.data.flags || !node.data.flags[0] || ! node.data.flags[0].flag) {
- return 0;
- }
- return node.data.flags[0].flag;
- }
- //获取节点所属固定ID
- function belongToFlag(node) {
- while (node) {
- if (node.data && node.data.flags && node.data.flags[0] && node.data.flags[0].flag) {
- return node.data.flags[0].flag;
- }
- node = node.parent;
- }
- return null;
- }
- //获取节点后代节点
- function getPosterity(node) {
- let posterity = [];
- getNodes(node.children);
- return posterity;
- function getNodes(nodes) {
- for (let node of nodes) {
- posterity.push(node);
- if (node.children.length > 0){
- getNodes(node.children);
- }
- }
- }
- }
- //检测层数
- //@param {Number}maxDepth(最大深度) {Object}node(需要检测的清单树节点)
- //@return {Boolean}
- function validDepth(maxDepth, node) {
- let nodeDepth = node.depth();
- let allNodes = getPosterity(node);
- //检测相对深度
- for (let n of allNodes) {
- let relativeDepth = n.depth() - nodeDepth;
- if (relativeDepth > maxDepth) {
- return false;
- }
- }
- return true;
- }
- //检测唯一性
- //@param {Object}constraints(约束池) {All}data(检测的数据) {String}hint(提示已存在的内容)
- //@return {void}
- function checkUnique(constraints, data, hint) {
- if (constraints.includes(data)) {
- failList.push(`${hint}“${data}”已存在`);
- } else if (data) {
- constraints.push(data);
- }
- }
- //根据数据的NextSiblingID进行排序,返回排序后的数组
- function sortByNext(datas) {
- let target = [],
- temp = {};
- for (let data of datas) {
- temp[data.ID] = {me: data, next: null, prev: null};
- }
- for (let data of datas) {
- let next = temp[data.NextSiblingID] || null;
- temp[data.ID].next = next;
- if (next) {
- next.prev = temp[data.ID];
- }
- }
- let first = null;
- for (let data of datas) {
- let me = temp[data.ID];
- if (!me.prev) {
- first = me;
- }
- }
- if (!first) {
- return datas;
- }
- while (first) {
- target.push(first.me);
- first = first.next;
- }
- return target;
- }
- //转换基数表达式
- //1.有子项,则取固定清单对应基数
- //2.无子项,有基数,a.优先转换为行代号(不可自身) b.不能转换为行代号则找对应字典
- //3.基数中有无法转换的,设为金额
- function transformCalcBase(tenderDetail, node) {
- let expr = node.data.calcBase || '';
- if (node.children.length) {
- let flag = getNodeFlag(node);
- return FlagCalcBaseMap[flag] || '';
- }
- if (expr) {
- let illegal = false;
- let normalBase = getNormalBase(expr),
- idBase = getIDBase(expr);
- //普通基数转基数字典
- normalBase.forEach(base => {
- let replaceStr = CalcBaseMap[base];
- //转换成行代号的优先级比较高,进行清单匹配
- let flag = FlagCalcBaseMap[base];
- if (flag) {
- let flagNode = tenderDetail.mainTree.items.find(mNode => getNodeFlag(mNode) === flag);
- //匹配到了 普通基数转换成行引用
- if (flagNode) {
- replaceStr = flagNode.serialNo() + 1;
- }
- }
- //存在无法处理的基数
- if (!replaceStr) {
- illegal = true;
- return;
- }
- expr = expr.replace(new RegExp(base, 'g'), replaceStr);
- });
- //id引用转行代号引用
- idBase.forEach(base => {
- let id = base.match(/[^@]+/)[0];
- let theNode = tenderDetail.mainTree.getNodeByID(id),
- rowCode = theNode ? `F${theNode.serialNo() + 1}` : '';
- if (!rowCode) {
- illegal = true;
- return;
- }
- expr = expr.replace(new RegExp(base, 'g'), rowCode);
- });
- //不合法 返回金额
- if (illegal) {
- return getFee(node.data.fees, 'common.totalFee');
- }
- return expr;
- }
- //获取普通基数: {xxx}
- function getNormalBase(str) {
- let reg = /{.+?}/g,
- matchs = str.match(reg);
- return matchs || [];
- }
- //获取id引用基数: @xxx-xxx-xx
- function getIDBase(str) {
- let reg = /@.{36}/g,
- matchs = str.match(reg);
- return matchs || [];
- }
- }
- //获取需要导出的项目数据
- //@param {Number}tenderID(当前界面的单位工程ID,后台根据这个单位工程,去找其建设项目下所有数据)
- //@return {Object}(eleObj)
- async function loadProject(tenderID) {
- //拉取标段数据:建设项目、单项工程、单位工程数据
- let projectData = curPMData.project;
- if (!projectData) { //没有数据,需要拉取
- projectData = curPMData.project = await ajaxPost('/pm/api/getProjectByGranularity', {user_id: userID, tenderID: tenderID, granularity: granularity});
- }
- if (!projectData) {
- throw '获取项目数据错误';
- }
- //单项工程、单位工程按照树结构数据进行排序
- projectData.children = sortByNext(projectData.children);
- for (let engData of projectData.children) {
- engData.children = sortByNext(engData.children);
- }
- //标段
- let project = new Project({
- basicInformation: projectData.property.basicInformation,
- name: projectData.name,
- fileKind: FILE_KIND[exportKind],
- taxType: projectData.property.taxType ? TAX_TYPE[projectData.property.taxType] : ''
- });
- curProjectEle = project;
- //项目信息
- let projectInfo = new ProjectInfo({basicInformation: projectData.property.basicInformation});
- project.children.push(projectInfo);
- //招标信息
- let biddingInfo = new BiddingInfo({basicInformation: projectData.property.basicInformation, summaryInfo: projectData.summaryInfo[projectData.ID]});
- projectInfo.children.push(biddingInfo);
- //投标信息 导出类型为投标时,才导出
- if (exportKind === ExportKind.Tender) {
- let bidInfo = new BidInfo({basicInformation: projectData.property.basicInformation, summaryInfo: projectData.summaryInfo[projectData.ID]});
- projectInfo.children.push(bidInfo);
- }
- //编制说明
- let compilationIll = new CompilationIllustration({compilationIllustration: projectData.property.compilationIllustration});
- project.children.push(compilationIll);
- //系统信息
- let generatedTime = moment(Date.now()).format('YYYY-MM-DDTHH:mm:ss'),
- sysInfoSource = {softInfo: projectData.softInfo, generatedTime},
- sysInfo = new SystemInfo(sysInfoSource);
- project.children.push(sysInfo);
- //费用构成
- let feeForm = new FeeFrom(projectData.summaryInfo[projectData.ID]);
- project.children.push(feeForm);
- //主要清单汇总 主要清单明细在loadTender中设置
- let mainBillsSummaryEle = new MainBillsSummary();
- project.children.unshift(mainBillsSummaryEle); //必须要排在loadTender前,这样才能添加到明细数据
- //评审材料汇总 评审材料明细在loadTender中设置
- let appraisalSummary = new AppraisalSummary();
- project.children.unshift(appraisalSummary);
- //单项工程
- for (let eng of projectData.children) {
- curPMData.engineering = eng;
- let engElement = await loadEngineering(projectData.summaryInfo, eng);
- project.children.push(engElement);
- }
- //主要清单汇总、评审材料汇总 排在后面
- project.children = [...project.children.slice(2), mainBillsSummaryEle, appraisalSummary];
- return project;
- }
- //单位工程内的人材机ID: 用于代码映射关系 //单位工程级别,C+数组下标 <==> gljID
- let tenderGljs = [];
- //获取人材机代码,eg: C0, C1....
- function getGljCode(gljID) {
- let idx = tenderGljs.findIndex(ID => ID === gljID);
- if (~idx) {
- return `C${idx}`;
- }
- tenderGljs.push(gljID);
- return `C${tenderGljs.length - 1}`;
- }
- /*
- * 加载单项工程数据
- * @param {Object}summaryInfo(项目汇总信息映射) {Object}engData(单项工程数据)
- * */
- async function loadEngineering(summaryInfo, engData) {
- let source = {summaryInfo: summaryInfo[engData.ID], name: engData.name, code: getIncreamentData('projectCode')};
- let engineering = new Engineering(source);
- //单项工程编号要唯一
- checkUnique(curProjectEle.constraints.engCode, source.code, '单项工程编号');
- //费用构成
- /*let feeForm = new FeeFrom(summaryInfo[engData.ID]);
- engineering.children.push(feeForm);*/
- //分批次获取单位工程
- for (let tenderData of engData.children) {
- curPMData.tender = tenderData;
- //需要请求项目详细数据的时候,间隔一段时间再初始单位工程数据,减少服务器压力
- if (!tenderDetailMap[tenderData.ID]) {
- await setTimeoutSync(() => {},TIMEOUT_TIME);
- }
- let tender = await loadTender(summaryInfo, tenderData);
- tenderGljs = []; //清空单位工程内所有的人材机(ID)
- engineering.children.push(tender);
- }
- return engineering;
- }
- /*
- * 加载单位工程数据
- * @param {Object}summaryInfo(项目汇总信息映射) {Object}tenderData(单位工程数据)
- * @return {Object}
- * */
- async function loadTender(summaryInfo, tenderData) {
- //获取单位工程详细数据
- let tenderDetail = tenderDetailMap[tenderData.ID];
- if (!tenderDetail) {
- tenderDetail = PROJECT.createNew(tenderData.ID, userID);
- await tenderDetail.loadDataSync();
- tenderDetailMap[tenderData.ID] = tenderDetail;
- }
- //设置定额库编码
- tenderDetail.rationLibMap = {};
- let defaultLib = null;
- if (tenderDetail.projectInfo.engineeringInfo && Array.isArray(tenderDetail.projectInfo.engineeringInfo.ration_lib)) {
- defaultLib = tenderDetail.projectInfo.engineeringInfo.ration_lib.find(data => data.isDefault);
- for (let lib of tenderDetail.projectInfo.engineeringInfo.ration_lib) {
- tenderDetail.rationLibMap[lib.id] = lib;
- }
- }
- //初始化项目人材机代号(人材机生成的代号要由排序后的项目人材机从C0开始生成),定额下的人材机含量提前使用到了这个代码,所以需要先初始化
- let allGljs = gljUtil.sortRationGLJ(tenderDetail.projectGLJ.datas.gljList); //人材机汇总排序
- tenderGljs = allGljs.map(glj => glj.glj_id);
- //单位工程
- let tenderSource = {
- code: getIncreamentData('projectCode'),
- name: tenderData.name,
- engineeringName: tenderData.property.engineeringName,
- summaryInfo: summaryInfo[tenderData.ID],
- defaultRationLibCode: defaultLib.libCode,
- taxType: tenderData.property.taxType
- };
- let tender = curTenderEle = new Tender(tenderSource);
- //单位工程编号要唯一
- checkUnique(curProjectEle.constraints.tenderCode, tenderSource.code, '单位工程编号');
- //工程特征
- let featureObj = arrayToObj(tenderData.property.projectFeature);
- let engFeature = new EngFeature({feature:featureObj, basicInformation: curPMData.project.property.basicInformation});
- tender.children.push(engFeature);
- //特征项:每一项工程特征
- for (let data of tenderData.property.projectFeature) {
- let featureItem = new FeatureItem(data);
- engFeature.children.push(featureItem);
- }
- //单位工程费汇总
- tender.children.push(loadDXFY(tenderDetail));
- //分部分项清单
- tender.children.push(loadFBFX(tenderDetail));
- //措施项目清单
- tender.children.push(loadCSXM(tenderDetail));
- //其他项目清单
- let other = loadOtherBills(tenderDetail);
- if (other) {
- tender.children.push(other);
- }
- //规费和税金清单
- let chargeTax = loadChargeTax(tenderDetail);
- tender.children.push(chargeTax);
- //建设项目下评审材料汇总设置评审材料明细
- let curAppraisalSummary = curProjectEle.children.find(ele => ele.name === '评审材料汇总');
- //人材机汇总
- let gljSumarryInfo = loadGlj(curAppraisalSummary, tenderDetail);
- if (gljSumarryInfo) {
- let {gljSummary, evalBidMaterial, evalEstimateMaterial} = gljSumarryInfo;
- tender.children.push(gljSummary);
- //评标材料表
- if (evalBidMaterial && evalBidMaterial.children.length) {
- tender.children.push(evalBidMaterial);
- }
- //暂估价材料表
- if (evalEstimateMaterial && evalEstimateMaterial.children.length) {
- tender.children.push(evalEstimateMaterial);
- }
- }
- //清单综合单价计算程序
- let calcProgram = loadCalcProgram(tenderDetail);
- if (calcProgram) {
- tender.children.push(calcProgram);
- }
- //给建设项目下主要清单汇总设置主要清单明细
- let curMainBillsSummary = curProjectEle.children.find(ele => ele.name === '主要清单汇总');
- if (curMainBillsSummary) {
- loadMainBillsItems(curMainBillsSummary, tenderDetail);
- }
- return tender;
- }
- /*
- * 加载计算程序费用行
- * @param {Object}detail(单位工程的详细数据,清单定额等等)
- * @return {Object}
- * */
- function loadDXFY(detail) {
- //单位工程费汇总
- let tenderFeeSummary = new TenderFeeSummary();
- //计价程序费用行,筛选大项费用
- let feeNodes = detail.Bills.tree.roots;
- for (let node of feeNodes) {
- let mainTreeNode = detail.mainTree.getNodeByID(node.data.ID),
- serialNo = mainTreeNode ? mainTreeNode.serialNo() + 1 : 1;
- let flag = getNodeFlag(node) || 0;
- let source = {
- code: node.data.code,
- rowCode: `F${serialNo}`,
- name: node.data.name,
- calcBase: transformCalcBase(detail, node),
- feeRate: node.data.feeRate ? node.data.feeRate : 100,
- fees: node.data.fees,
- feeType: FEE_TYPE[flag] || FEE_TYPE['0'],
- remark: node.data.remark
- };
- let feeRow = new FeeRow(source);
- tenderFeeSummary.children.push(feeRow);
- }
- return tenderFeeSummary;
- }
- /*
- * 加载清单项目
- * @param {Object}node(清单树节点) {Object}detail
- * */
- function loadBills(node, detail) {// allRation, allRationGlj, decimal,
- let allRation = detail.Ration.datas,
- allRationGlj = detail.ration_glj.datas,
- decimal = detail.projectInfo.property.decimal;
- let source = {
- code: node.data.code,
- name: node.data.name,
- unit: node.data.unit,
- quantity: node.data.quantity,
- fees: node.data.fees,
- mainBills: node.data.mainBills,
- isEstimate: node.data.isEstimate,
- remark: node.data.remark
- };
- let bills = new FXbills(source);
- //清单项目项目编码要在单位工程中唯一
- checkUnique(curTenderEle.constraints.billsCode, source.code, '清单项目项目编号');
- //加载特征及内容
- function loadFeatureContent() {
- let job = [],
- feature = [];
- let jobText = node.data.jobContentText || '';
- let featureText = node.data.itemCharacterText || '';
- let jobSplit = jobText.split(/[\r,\n]/g),
- featureSplit = featureText.split(/[\r,\n]/g);
- //将特征和内容分类,通过[项目特征][工作内容]区分。若没有,则不区分:工作内容列全部数据为工作内容,项目特征列全部数据为项目特征
- //@param {Array}data(splitdata) {String}field(job、feature)
- function classifyData(data, field) {
- let rst = {
- job: [],
- feature: []
- };
- let featureIndex = data.findIndex(x => x === '[项目特征]');
- if (featureIndex < 0) {
- rst[field] = data;
- return rst;
- }
- let jobIndex = data.findIndex(x => x === '[工作内容]');
- if (jobIndex < 0) { //有[项目特征],没有[工作内容],则其数据全为项目特征数据
- rst.feature = data;
- return rst;
- }
- //有[项目特征],有[工作内容],进行数据分类
- rst.feature = data.slice(featureIndex, jobIndex);
- rst.job = data.slice(jobIndex);
- return rst;
- }
- let classifiedJob = classifyData(jobSplit, 'job');
- job = job.concat(classifiedJob.job);
- feature = feature.concat(classifiedJob.feature);
- let classifiedFeature = classifyData(featureSplit, 'feature');
- job = job.concat(classifiedFeature.job);
- feature = feature.concat(classifiedFeature.feature);
- job = job.filter(x => x && !['[项目特征]', '[工作内容]'].includes(x));
- feature = feature.filter(x => x && !['[项目特征]', '[工作内容]'].includes(x));
- //创建项目特征节点
- if (feature.length > 0) {
- let itemChac = new ItemCharacter();
- //let reg = /(.{0,}):(.{0,})/;
- for (let f of feature) {
- /*let source = {name: '', value: ''};
- let execRst = reg.exec(f);
- if (execRst) {
- source.name = execRst[1].replace(/^\d+\.{1}/, '').trim(); //去除开头(1.)序号,首位空格
- source.value = execRst[2].trim();
- }
- let featureEle = new Feature(source);*/
- let featureEle = new Feature({name: f.trim(), value: ''});
- itemChac.children.push(featureEle);
- }
- bills.children.push(itemChac);
- }
- //创建工作内容节点
- if (job.length > 0) {
- let jobContent = new JobContent();
- for (let j of job) {
- /*let data = j.replace(/^\d+\.{1}/, '').trim();
- let content = new Content(data);*/
- let content = new Content(j.trim());
- jobContent.children.push(content);
- }
- bills.children.push(jobContent);
- }
- }
- loadFeatureContent();
- //解析工程量计算式
- function parseQuantityExp(rationData) {
- if (rationData.quantityEXP === 'QDL') { //取清单工程量
- return node.data.quantity;
- } else if (rationData.quantityEXP === 'GCLMXHJ') { //从明细汇总成数值
- let referDetail = detail.quantity_detail.datas.filter(data => data.rationID === rationData.ID && data.isSummation);
- if (referDetail.length === 0) {
- return '';
- }
- let rst = 0;
- for (let d of referDetail) {
- rst = scMathUtil.roundForObj(rst + d.result, detail.projectInfo.property.decimal.process);
- }
- return scMathUtil.roundForObj(rst, detail.projectInfo.property.decimal.ration.quantity);
- } else {
- return rationData.quantityEXP;
- }
- }
- /*
- * 加载定额子目
- * @param {Array}rationData(清单项目下定额数据) {Array}rationGljData(定额的人材机数据) {Object}decimal(项目小数位数)
- * @return {Object}
- * */
- function loadRation(rationData, rationGljData) {
- let viewCode = rationData.code;
- if (rationData.prefix) {
- viewCode = rationData.prefix + viewCode;
- }
- if (rationData.adjustState) {
- viewCode += '换';
- }
- //子目类型 补充定额为“1”,标准定额无换算为“0”,标准定额有换算为“2”,安装费用,即自动生成的安装子目,为“3”,子目级人材机,即量价、与定额同级的人材机 其他待完善……
- let subType;
- if (rationData.type === rationType.ration && rationData.from === 'cpt') {
- subType = '1';
- } else if (rationData.type === rationType.ration && !rationData.adjustState) {
- subType = '0';
- } else if (rationData.type === rationType.ration && rationData.adjustState) {
- subType = '2';
- } else if (rationData.type === rationType.install) {
- subType = '3';
- } else if (rationData.type === rationType.volumePrice) {
- subType = '6';
- }
- let rationSource = {
- viewCode: viewCode,
- name: rationData.name,
- unit: rationData.unit,
- libCode: '',
- code: rationData.code,
- subType: subType,
- quantity: rationData.quantity,
- quantityEXP: parseQuantityExp(rationData),
- fees: rationData.fees,
- isSubcontract: rationData.isSubcontract,
- programID: rationData.programID,
- remark: rationData.remark
- };
- if (rationData.from === 'std' && isDef(rationData.libID)) { //来自标准库,设置定额库编码
- rationSource.libCode = detail.rationLibMap[rationData.libID].libCode;
- }
- let ration = new Ration(rationSource);
- //创建工料分析
- let gljAnalyze = new GljAnalyze();
- ration.children.push(gljAnalyze);
- //定额人材机排序
- rationGljData = gljUtil.sortRationGLJ(rationGljData);
- for (let rGlj of rationGljData) {
- let gljSource = {
- //code: rGlj.code,
- code: getGljCode(rGlj.GLJID),
- quantity: rGlj.quantity,
- totalQuantity: gljUtil.getTotalQuantity(rGlj, rationData, decimal.glj.quantity, decimal.ration.quantity)
- };
- let gljContent = new GljContent(gljSource);
- gljAnalyze.children.push(gljContent);
- }
- //创建费用组成
- let feeContent = new FeeContent({fees: rationData.fees});
- ration.children.push(feeContent);
- return ration;
- }
- //加载组价内容
- let rationData = allRation.filter(x => x.billsItemID === node.data.ID);
- if (rationData.length > 0) {
- let priceContent = new PriceContent();
- bills.children.push(priceContent);
- //加载定额子目
- rationData.sort((x, y) => x.serialNo - y.serialNo); //定额排序
- for (let rData of rationData) {
- let rationGlj = allRationGlj.filter(x => x.rationID === rData.ID);
- priceContent.children.push(loadRation(rData, rationGlj));
- }
- }
- return bills;
- }
- /*
- * 加载分部分项清单
- * @param {Object}detail
- * @return {Object || NULL}
- * */
- function loadFBFX(detail) {
- let fbfxBills = new FBFXBills();
- let subEngNode = detail.Bills.tree.roots.find((node) => getNodeFlag(node) === fixedFlag.SUB_ENGINERRING);
- if (!subEngNode) {
- failList.push('不存在分部分项清单');
- return fbfxBills;
- }
- for (let node of subEngNode.children) {
- if (node.data.type === billType.FB) {
- if (node.children.length === 0) {
- failList.push('清单分部下至少要有一条清单项目');
- }
- //创建清单分部节点
- let fbSource = {
- code: node.data.code,
- name: node.data.name,
- fees: node.data.fees,
- remark: node.data.remark
- };
- let fbBills = new FBBills(fbSource);
- fbfxBills.children.push(fbBills);
- //创建清单项目节点
- for (let subNode of node.children) {
- let fx = loadBills(subNode, detail);
- fbBills.children.push(fx);
- }
- } else {
- let fxBills = loadBills(node, detail);
- fbfxBills.children.push(fxBills);
- }
- }
- return fbfxBills;
- }
- /*
- * 加载措施项目清单
- * @param {Object}detail
- * @return {Object}
- * */
- function loadCSXM(detail) {
- let measureNode = detail.Bills.tree.roots.find((node) => getNodeFlag(node) === fixedFlag.MEASURE);
- if (!measureNode) {
- failList.push('不存在措施项目清单');
- return new element('措施项目清单', []);
- }
- let csxmBills = new CSXMBills({fees: measureNode.data.fees});
- //加载组织措施清单
- let zzcsNode = detail.Bills.tree.items.find(node => getNodeFlag(node) === fixedFlag.CONSTRUCTION_ORGANIZATION);
- if (zzcsNode) {
- let zzcsBills = new ZZCSBills({fees: zzcsNode.data.fees});
- csxmBills.children.push(zzcsBills);
- loadZZCS(zzcsBills, zzcsNode.children);
- }
- //加载技术措施清单
- let jscsNode = detail.Bills.tree.items.find(node => getNodeFlag(node) === fixedFlag.CONSTRUCTION_TECH);
- let maxDepth = 2; //技术措施清单最多深度是2层:技术措施分类-清单项目
- if (jscsNode) {
- let jscsBills = new JSCSBills({fees: jscsNode.data.fees});
- csxmBills.children.push(jscsBills);
- let isValidDepth = validDepth(maxDepth, jscsNode);
- if (!isValidDepth) {
- failList.push('技术措施清单子项超过两层');
- } else {
- loadJSCS(jscsBills, jscsNode.children);
- }
- }
- return csxmBills;
- function loadZZCS(parent, nodes) {
- for (let node of nodes) {
- if (node.children.length > 0) { //组织措施分类
- let classSource = {
- code: node.data.code,
- name: node.data.name,
- fees: node.data.fees,
- remark: node.data.remark
- };
- let zzcsClass = new ZZCSClass(classSource);
- parent.children.push(zzcsClass);
- loadZZCS(zzcsClass, node.children);
- } else { //公式计算措施项
- let source = {
- code: node.data.code,
- name: node.data.name,
- calcBase: node.data.calcBase,
- feeRate: node.data.feeRate ? node.data.feeRate : 100,
- fees: node.data.fees,
- remark: node.data.remark,
- feeType: FEE_TYPE[getNodeFlag(node)] || FEE_TYPE['0']
- };
- /*if (source.feeType === '1800') {
- debugger;
- }*/
- let formula = new FormulaCalcMeasure(source);
- parent.children.push(formula);
- }
- }
- if (parent instanceof ZZCSClass) { //组织措施分类下的只能有一个组织措施分类
- let filters = parent.children.filter(data => data instanceof ZZCSClass);
- if (filters.length) {
- failList.push('组织措施分类下只能有一个组织措施分类');
- }
- }
- }
- function loadJSCS(parent, nodes) {
- for (let node of nodes) {
- if (node.children.length > 0) { //技术措施分类
- let classSource = {
- code: node.data.code,
- name: node.data.name,
- fees: node.data.fees
- };
- let jscsClass = new JSCSClass(classSource);
- parent.children.push(jscsClass);
- loadJSCS(jscsClass, node.children);
- } else { //清单项目
- parent.children.push(loadBills(node, detail));
- }
- }
- }
- }
- /*
- * 加载其他项目清单,要出现此节点,需要遵循标准条件(至少含有一条相关明细)
- * @param {Object}detail
- * @return {Object || Null}
- * */
- function loadOtherBills(detail) {
- let otherNode = detail.Bills.tree.roots.find(node => getNodeFlag(node) === fixedFlag.OTHER);
- if (otherNode.children.length === 0) {
- return null;
- }
- //其他项目清单元素
- let otherEle = new OtherBills();
- //添加暂列金额元素
- let provisionalNode = detail.Bills.tree.items.find(node => getNodeFlag(node) === fixedFlag.PROVISIONAL);
- if (provisionalNode && provisionalNode.children.length > 0) {
- otherEle.children.push(loadProvisional(provisionalNode));
- }
- //添加专业工程暂估价元素
- let engEstimateNode = detail.Bills.tree.items.find(node => getNodeFlag(node) === fixedFlag.ENGINEERING_ESITIMATE);
- if (engEstimateNode && engEstimateNode.children.length > 0) {
- otherEle.children.push(loadEngEstimate(engEstimateNode));
- }
- //添加计日工元素
- let dayWorkNode = detail.Bills.tree.items.find(node => getNodeFlag(node) === fixedFlag.DAYWORK);
- let dayWorkEle = new DayWork({fees: dayWorkNode.data.fees});
- if (dayWorkNode && dayWorkNode.children.length > 0) {
- //要显示计日工元素,人工、材料、施工机械,最少有一条含有子项(计日工项目)
- let filterNodes = dayWorkNode.children.filter(node => [fixedFlag.LABOUR, fixedFlag.MATERIAL, fixedFlag.MACHINE].includes(getNodeFlag(node)));
- for (let fNode of filterNodes) {
- let ele,
- constraints;
- let flag = getNodeFlag(fNode);
- if (flag === fixedFlag.LABOUR) {
- ele = new Labour();
- constraints = curTenderEle.constraints.labourDayWorkCode;
- } else if (flag === fixedFlag.MATERIAL) {
- ele = new Material();
- constraints = curTenderEle.constraints.materialDayWorkCode;
- } else if (flag === fixedFlag.MACHINE) {
- ele = new Machine();
- constraints = curTenderEle.constraints.machineDayWorkCode;
- }
- if (fNode.children.length > 0) {
- let isValidDepth = validDepth(1, fNode);
- if (!isValidDepth) {
- failList.push(`计日工${ele.name}子项超过一层`);
- } else {
- for (let itemNode of fNode.children) {
- ele.children.push(loadDayWorkItem(itemNode, constraints, `${ele.name}计日工项目编号`));
- }
- dayWorkEle.children.push(ele);
- }
- }
- }
- //如果计日工下有计日工项目,则显示计日工元素
- if (dayWorkEle.children.length > 0) {
- otherEle.children.push(dayWorkEle);
- }
- }
- //添加总承包服务费元素
- let tkcNode = detail.Bills.tree.items.find(node => getNodeFlag(node) === fixedFlag.TURN_KEY_CONTRACT);
- if (tkcNode && tkcNode.children.length > 0) { //必须要有子项才显示总承包服务费元素
- let isValidDepth = validDepth(2, tkcNode); //最多2层子项:总承包服务费分类-总承包服务费费用项
- if (!isValidDepth) {
- failList.push('总承包服务费子项超过两层');
- } else {
- let tkcEle = new TurnKeyContract({fees: tkcNode.data.fees});
- otherEle.children.push(tkcEle);
- loadService(tkcEle, tkcNode.children);
- }
- }
- //添加索赔计价汇总元素
- let claimNode = detail.Bills.tree.items.find(node => getNodeFlag(node) === fixedFlag.CLAIM);
- if (claimNode && claimNode.children.length > 0) { //必须要有子项才能显示索赔计价汇总元素
- let claimEle = new element('索赔计价汇总', []);
- for (let n of claimNode.children) {
- claimEle.children.push(new ClaimVisaFeeItem(n.data));
- }
- otherEle.children.push(claimEle);
- }
- //添加现场签证计价汇总元素
- let visaNode = detail.Bills.tree.items.find(node => getNodeFlag(node) === fixedFlag.VISA);
- if (visaNode && visaNode.children.length > 0) { //必须要有子项才能显示现场签证计价汇总元素
- let visaEle = new element('现场签证计价汇总', []);
- for (let n of visaNode.children) {
- visaEle.children.push(new ClaimVisaFeeItem(n.data));
- }
- otherEle.children.push(visaEle);
- }
- //添加其他元素
- let posetriy = getPosterity(otherNode);
- let subOtherEle = loadOthers(posetriy);
- if (subOtherEle) {
- otherEle.children.push(subOtherEle);
- }
- //必须有有效子项,才能显示其他项目清单元素
- return otherEle.children.length > 0 ? otherEle : null;
- //加载暂列金额
- function loadProvisional(node) {
- let provisionalEle = new Provisional({fees: node.data.fees});
- //暂列金额最多只有一层子节点
- let isValidDepth = validDepth(1, node);
- if (!isValidDepth) {
- failList.push('暂列金额子项超过一层');
- } else { //加载暂列金额明细
- for (let n of node.children) {
- let pDetailSource = {
- code: n.data.code,
- name: n.data.name,
- unit: n.data.unit,
- fees: n.data.fees,
- remark: n.data.remark
- },
- pDetailEle = new ProvisionalDetail(pDetailSource);
- //暂列金额明细编号在单位工程中唯一
- checkUnique(curTenderEle.constraints.provisionalDetailCode, pDetailSource.code, '暂列金额明细编号');
- provisionalEle.children.push(pDetailEle);
- }
- }
- return provisionalEle;
- }
- //加载专业工程暂估价
- function loadEngEstimate(node) {
- let engEstimateEle = new EngEstimate({fees: node.data.fees});
- //专业工程暂估价最多只有一层子节点
- let isValidDepth = validDepth(1, node);
- if (!isValidDepth) {
- failList.push('专业工程暂估价子项超过一层');
- } else { //加载专业工程暂估明细
- for (let n of node.children) {
- let eDetailSource = {
- code: n.data.code,
- name: n.data.name,
- engineeringContent: n.data.engineeringContent,
- fees: n.data.fees,
- remark: n.data.remark
- },
- eDetailEle = new EngEstimateDetail(eDetailSource);
- //暂列金额明细编号在单位工程中唯一
- checkUnique(curTenderEle.constraints.engEstimateDetailCode, eDetailSource.code, '专业工程暂估明细编号');
- engEstimateEle.children.push(eDetailEle);
- }
- }
- return engEstimateEle;
- }
- //加载计日工项目
- function loadDayWorkItem(node, constraints, hint) {
- let source = {
- code: node.data.code,
- name: node.data.name,
- unit: node.data.unit,
- quantity: node.data.quantity,
- fees: node.data.fees,
- remark: node.data.remark
- };
- checkUnique(constraints, source.code, hint);
- return new DayWorkItem(source);
- }
- //加载服务费项
- function loadService(parent, nodes) {
- for (let node of nodes) {
- if (node.children.length > 0) { //总承包服务费分类
- let classSource = {
- code: node.data.code,
- name: node.data.name,
- remark: node.data.remark
- };
- let tkcClass = new TurnKeyContractClass(classSource);
- parent.children.push(tkcClass);
- loadService(tkcClass, node.children);
- } else { //总承包服务费费用项
- let source = {
- code: node.data.code,
- name: node.data.name,
- serviceContent: node.data.serviceContent,
- calcBaseValue: node.data.calcBaseValue,
- feeRate: node.data.feeRate ? node.data.feeRate : 100,
- fees: node.data.fees,
- remark: node.data.remark
- };
- parent.children.push(new TurnKeyContractItem(source));
- }
- }
- }
- //加载其他列项,不符合上述情况的,其他所有清单子项
- function loadOthers(nodes) {
- //排除项
- let exclusionFlags = [
- fixedFlag.PROVISIONAL,
- fixedFlag.ENGINEERING_ESITIMATE,
- fixedFlag.LABOUR,
- fixedFlag.MATERIAL,
- fixedFlag.MACHINE,
- fixedFlag.TURN_KEY_CONTRACT,
- fixedFlag.CLAIM,
- fixedFlag.VISA
- ];
- //生成其他列项
- let otherItems = [],
- summaryFee = 0;
- for (let node of nodes) {
- let belongFlag = belongToFlag(node);
- if (node.children.length > 0 || (belongFlag && exclusionFlags.includes(belongFlag))) {
- continue;
- }
- //汇总其他列项金额
- let totalFee = getFee(node.data.fees, 'common.totalFee');
- summaryFee = scMathUtil.roundForObj(summaryFee + totalFee, curPMData.tender.property.decimal.bills.totalPrice);
- let otherItemEle = new OtherItem({
- code: node.data.code,
- name: node.data.name,
- calcBase: node.data.calcBase,
- feeRate: node.data.feeRate ? node.data.feeRate : 100,
- commonTotalFee: totalFee,
- notSummary: belongFlag && belongFlag === fixedFlag.MATERIAL_PROVISIONAL, //不计入合价,只有材料(工程设备)暂估价固定节点
- remark: node.data.remark
- });
- otherItems.push(otherItemEle);
- checkUnique(curTenderEle.constraints.otherItemNo, node.data.code, '其他列项编号');
- }
- let otherEle = new Other({commonTotalFee: summaryFee});
- for (let ele of otherItems) {
- otherEle.children.push(ele);
- }
- return otherEle.children.length > 0 ? otherEle : null; //有其他列项才能显示其他元素
- }
- }
- /*
- * 加载规费和税金清单,固定显示:规费、税金、增值税、附加税、环境保护税这几个清单
- * @param {Object}detail
- * @return {Object}
- * */
- function loadChargeTax(detail) {
- let chargeTaxEle = new ChargeTaxBills();
- let filterFlags = [
- fixedFlag.CHARGE,
- fixedFlag.TAX,
- fixedFlag.ADDED_VALUE_TAX,
- fixedFlag.ADDITIONAL_TAX,
- fixedFlag.ENVIRONMENTAL_PROTECTION_TAX
- ];
- let fitlerNodes = detail.Bills.tree.items.filter(node => filterFlags.includes(getNodeFlag(node)));
- for (let node of fitlerNodes) {
- let mainTreeNode = detail.mainTree.getNodeByID(node.data.ID),
- serialNo = mainTreeNode ? mainTreeNode.serialNo() + 1 : 1;
- let source = {
- code: node.data.code,
- rowCode: `F${serialNo}`,
- name: node.data.name,
- calcBase: node.data.calcBase,
- feeRate: node.data.feeRate ? node.data.feeRate : 100,
- fees: node.data.fees,
- feeType: FEE_TYPE[getNodeFlag(node)] || FEE_TYPE['0'],
- remark: node.data.remark
- };
- //序号唯一
- checkUnique(curTenderEle.constraints.feeItemNo, source.code, '规费和税金费用项编号');
- chargeTaxEle.children.push(new FeeItem(source));
- }
- return chargeTaxEle;
- }
- /*
- * 加载主要清单明细
- * @param {Obejct}parent(设置到的父项:主要清单汇总元素) {Object}detail
- * @return {void}
- * */
- function loadMainBillsItems(parent, detail) {
- let mainBills = detail.Bills.datas.filter(data => {
- let billsNode = detail.Bills.tree.nodes[`${detail.Bills.tree.prefix}${data.ID}`];
- return data.mainBills && billsNode && billsNode.children.length === 0;
- });
- for (let bills of mainBills) {
- let source = {
- code: bills.code,
- name: bills.name,
- unit: bills.unit,
- quantity: bills.quantity,
- fees: bills.fees,
- remark: bills.remark
- };
- let mainBillsItemEle = new MainBillsItem(source);
- //主要清单明细项目编码唯一
- checkUnique(curTenderEle.constraints.mainBillsCode, source.code, '主要清单明细项目编码');
- parent.children.push(mainBillsItemEle);
- }
- }
- /*
- * 加载人材机汇总相关:人材机汇总、评标、暂估
- * @param {Object}appraisalSummary(建设项目下的评审材料汇总) {Object}detail
- * @return {Object}
- * */
- function loadGlj(appraisalSummary, detail) {
- let gljList = detail.projectGLJ.datas.gljList;
- let evalBidSeq = 1, //评标序号
- evalEstSeq = 1; //暂估序号
- if (gljList.length > 0) {
- //创建人材机汇总节点
- let gljSummary = new GljSummary();
- //创建评标材料表节点
- let evalBidMaterial = new EvalBidMaterial();
- //创建暂估价材料表节点
- let evalEstimateMaterial = new EvalEstimateMaterial();
- //人材机节点
- let allGljs = gljUtil.sortRationGLJ(gljList); //人材机汇总排序
- //计算总消耗量
- gljUtil.calcProjectGLJQuantity(detail.projectGLJ.datas,
- detail.ration_glj.datas, detail.Ration.datas, detail.Bills.datas, curPMData.tender.property.decimal.glj.quantity, _, scMathUtil);
- //类型-配比类别映射
- let ratioMapping = {
- '202': '1', //为“混凝土”时,取“1”;
- '205': '2', //为“商品混凝土”时,取“2”;
- '203': '3', //为“砂浆”时,取“3”;
- '206': '4', //为“商品砂浆”时,取“4”;
- '204': '5' //为“配合比”时,取“5”
- };
- //三材类别-主要材料类别映射 三材类型:钢材1、钢筋2、木材3、水泥4、商品砼5、商品砂浆6
- let mainMaterialMapping = {
- '1': '100', //为“钢材”、“钢筋”时,取“100”;
- '2': '100',
- '4': '200', //为“水泥”时,取“200”;
- '3': '300', //为“木材”时,取“300”;
- '5': '400', //为“商品砼”、商品砂浆”时,取“400”。
- '6': '400'
- };
- for (let glj of allGljs) {
- //gljUtil.getAdjustPrice(glj,proGLJ.datas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
- let price = gljUtil.getGLJPrice(glj, detail.projectGLJ.datas,
- curPMData.tender.property.calcOptions, detail.labourCoe.datas, curPMData.tender.property.decimal, false, _, scMathUtil);
- //调整价
- let adjPrice = gljUtil.getAdjustPrice(glj, detail.projectGLJ.datas,
- curPMData.tender.property.calcOptions, detail.labourCoe.datas, curPMData.tender.property.decimal, false, _, scMathUtil);
- //获取人材机费用类别: 1=人工费 2=材料费 3=机械费 4=未计价费
- let feeType = glj.type.toString()[0];
- if (feeType && !['1', '2', '3'].includes(feeType)) {
- feeType = '4';
- }
- let gljSource = {
- //code: glj.code,
- code: getGljCode(glj.glj_id),
- name: glj.name,
- specs: glj.specs,
- unit: glj.unit,
- orgCode: glj.code, //不取原始编码了,直接取编码
- feeType: feeType,
- ratioType: ratioMapping[glj.type],
- mainMaterialType: mainMaterialMapping[glj.materialType],
- materialCoe: glj.materialCoe,
- supply: glj.supply === 2 ? 2 : 1, //供货方式为“完全甲供”,取“2”;否则取“1”。
- is_evaluate: !!glj.is_evaluate,
- no_tax_eqp: !!glj.no_tax_eqp,
- notFromDetail: !glj.ratio_data.length, //单价不从明细汇总标志,如果有配比组成,取“false”;否则取“true”。
- basePrice: price.basePrice,
- adjPrice: adjPrice,
- marketPrice: price.marketPrice,
- quantity: glj.quantity,
- originPlace: glj.originPlace,
- vender: glj.vender,
- qualityGrace: glj.qualityGrace,
- brand: glj.brand,
- remark: glj.remark
- };
- let gljEle = new Glj(gljSource);
- //人材机代码唯一
- checkUnique(curTenderEle.constraints.gljCode, gljSource.code, '人材机代码');
- //人材机配比
- let connectKey = gljUtil.getIndex(glj, gljKeyArray),
- ratioData = detail.projectGLJ.datas.mixRatioMap[connectKey];
- if (ratioData && Array.isArray(ratioData)) {
- for (let ratio of ratioData) {
- let gljRatio = new GljRatio({code: getGljCode(ratio.glj_id), quantity: ratio.consumption});
- gljEle.children.push(gljRatio);
- }
- }
- gljSummary.children.push(gljEle);
- gljSource.totalPrice = scMathUtil.roundForObj(gljSource.quantity * gljSource.marketPrice,
- detail.projectInfo.property.decimal.bills.totalPrice);
- //评标和暂估材料表下的材料明细中的人材机代码,要求单位工程内唯一,由于人材机汇总也有这个限制,所以这里不再处理
- if (glj.is_eval_material) { //评标
- gljSource.serialNo = evalBidSeq++;
- evalBidMaterial.children.push(new MaterialDetail(gljSource));
- //给建设项目下的评审材料汇总设置明细数据,这里需要检测代码(编号)唯一性,因为是汇总所有单位工程的,要求所有单位工程内评审材料代码唯一
- appraisalSummary.children.push(new AppraisalDetail(gljSource));
- checkUnique(curTenderEle.constraints.appraisalDetailCode, gljSource.code, '评审材料明细代码');
- }
- if (glj.is_evaluate) { //暂估
- gljSource.serialNo = evalEstSeq++;
- evalEstimateMaterial.children.push(new MaterialDetail(gljSource));
- }
- }
- return {gljSummary, evalBidMaterial, evalEstimateMaterial};
- }
- }
- /*
- * 加载清单综合单价计算程序
- * */
- function loadCalcProgram(detail) {
- let calcProgram = detail.calcProgram;
- if (!calcProgram) {
- return null;
- }
- let calcProramTemplates = calcProgram.templates;
- if (!Array.isArray(calcProramTemplates) || calcProramTemplates.length === 0) {
- return null;
- }
- //创建清单综合单价计算程序
- let calcProgramEle = new CalcProgram();
- //创建综合单价计算程序文件
- for (let calcFile of calcProramTemplates) {
- let calcFileEle = new CalcProgramFile({ID: calcFile.ID, name: calcFile.name});
- //创建计算程序费用项
- for (let calcItem of calcFile.calcItems) {
- let idx = calcFile.calcItems.indexOf(calcItem);
- //如果是有[]的基数则转换为其简称,如“[定额人工费]”对应的检查是"RGF"
- let calcBase = calcItem.dispExpr.replace(/\[[\u4e00-\u9fa5]+\]/g, str => rationBaseShort[str] ? rationBaseShort[str] : '');
- let feeType = calcProgram.feeTypes.find(data => data.type === calcItem.fieldName);
- if (feeType) {
- feeType = feeType.code;
- }
- let source = {
- serialNo: idx + 1,
- rowCode: `F${idx + 1}`,
- name: calcItem.name,
- calcBase: calcBase,
- statement: calcItem.statement,
- feeRate: calcItem.feeRate ? calcItem.feeRate : 100,
- feeType: feeType,
- remark: calcItem.memo
- };
- let calcItemEle = new CalcProgramFeeItem(source);
- calcFileEle.children.push(calcItemEle);
- }
- if (calcFileEle.children.length > 0) { //计算程序文件必须有费用项
- calcProgramEle.children.push(calcFileEle);
- }
- }
- return calcProgramEle.children.length > 0 ? calcProgramEle : null;
- }
- //开始标签
- function startTag(ele) {
- let rst = `<${ele.name}`;
- for (let attr of ele.attrs) {
- rst += ` ${attr.name}="${attr.value}"`;
- }
- rst += ele.children.length > 0 ? '>' : '/>';
- return rst;
- }
- //结束标签
- function endTag(ele) {
- return `</${ele.name}>`;
- }
- //拼接成xml字符串
- function toXMLStr(eles) {
- let rst = '';
- for (let ele of eles) {
- rst += startTag(ele);
- if (ele.children.length > 0) {
- rst += toXMLStr(ele.children);
- rst += endTag(ele);
- }
- }
- return rst;
- }
- //格式化xml字符串
- function formatXml(text) {
- //去掉多余的空格
- text = '\n' + text.replace(/>\s*?</g, ">\n<");
- //调整格式
- let rgx = /\n(<(([^\?]).+?)(?:\s|\s*?>|\s*?(\/)>)(?:.*?(?:(?:(\/)>)|(?:<(\/)\2>)))?)/mg;
- let nodeStack = [];
- let output = text.replace(rgx, function($0, all, name, isBegin, isCloseFull1, isCloseFull2, isFull1, isFull2){
- let isClosed = (isCloseFull1 === '/') || (isCloseFull2 === '/' ) || (isFull1 === '/') || (isFull2 === '/');
- let prefix = '';
- if (isBegin === '!') {
- prefix = getPrefix(nodeStack.length);
- } else {
- if (isBegin !== '/') {
- prefix = getPrefix(nodeStack.length);
- if (!isClosed) {
- nodeStack.push(name);
- }
- } else {
- nodeStack.pop();
- prefix = getPrefix(nodeStack.length);
- }
- }
- let ret = '\n' + prefix + all;
- return ret;
- });
- let outputText = output.substring(1);
- return outputText;
- function getPrefix(prefixIndex) {
- let span = ' ';
- let output = [];
- for (let i = 0 ; i < prefixIndex; ++i) {
- output.push(span);
- }
- return output.join('');
- }
- }
- /*
- * 导出数据
- * @param {Number}tenderID(当前界面的单位工程ID,后台根据这个单位工程,根据导出粒度去找其建设项目下相关数据)
- * @param {Number}curExportKind(导出的文件类型:1-投标 2-招标 3-控制价)
- * @return {void}
- * */
- this.toXml = async function (tenderID, curExportKind) {
- if (curExportKind) {
- this.exportKind = exportKind = parseInt(curExportKind);
- }
- let eleData = await loadProject(tenderID);
- this.datas = eleData;
- if (!eleData) {
- return;
- }
- //转换成xml字符串
- let xmlStr = toXMLStr([eleData]);
- //加上xml声明
- xmlStr = `<?xml version="1.0" encoding="utf-8"?>${xmlStr}`;
- //格式化
- xmlStr = formatXml(xmlStr);
- let blob = new Blob([xmlStr], {type: 'text/plain;charset=utf-8'});
- return blob;
- saveAs(blob, '重庆标准交换数据.QTF');
- }
- }
- })();
|