exportStandardInterface.js 124 KB

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