Service.js 88 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516
  1. import {copy, danxiangdinge_index, danxiangdinge_index_djcs, renameDingE, extractFuzhu, match_target, azfy} from './utils';
  2. import { v4 as uuidv4 } from 'uuid';
  3. class Service{
  4. constructor() {
  5. this.footprint = [];
  6. this.cache = [];
  7. this.memory = [];
  8. this.mem_pointer = -1;
  9. this.cache_djcs = [];
  10. this.memory_djcs = [];
  11. this.mem_pointer_djcs = -1;
  12. this.qufei = [];
  13. this.qufeiEntry = null;
  14. }
  15. ip() {
  16. //return "/api"//return "http://127.0.0.1:8000"
  17. return "http://192.168.31.48:1313/api"
  18. }
  19. clearCache() {//set qufei will clear cache
  20. this.cache = [];
  21. this.footprint= [];
  22. this.memory = [];
  23. this.mem_pointer = -1;
  24. this.cache_djcs = [];
  25. this.memory_djcs = [];
  26. this.mem_pointer_djcs = -1;
  27. }
  28. setQufei(data) {
  29. let result = [];
  30. for(let i = 0; i < data[0]['children'].length; i++) {
  31. let child = data[0]['children'][i];
  32. for(let j = 0; j < child['children'].length; j++) {
  33. let grandchild = child['children'][j];
  34. //console.log(grandchild);
  35. result.push(grandchild);
  36. }
  37. }
  38. this.qufei = result;
  39. }
  40. setQufeiEntry(bh) {
  41. this.qufeiEntry = this.qufei.filter(x=>x['key'] == bh)[0];
  42. }
  43. processDjcsmingxi(mingxi) {
  44. this.cache_djcs = copy(mingxi);
  45. for(let i = 0; i < this.cache_djcs.length; i++) {
  46. let zimu = this.cache_djcs[i];
  47. if (!zimu.hasOwnProperty("_children")) {
  48. zimu["_children"] = [];
  49. }
  50. if (!zimu.hasOwnProperty("rcj")) {
  51. zimu["rcj"] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  52. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
  53. }
  54. }
  55. for(let i = 0; i < this.cache_djcs.length; i++) {
  56. let zimu = this.cache_djcs[i];
  57. for(let j = 0; j < zimu["_children"].length; j++) {
  58. let de = zimu["_children"][j];
  59. if (!de.hasOwnProperty("dercj")) {
  60. de["dercj"] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  61. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
  62. }
  63. }
  64. }
  65. this.cache_djcs = this.cache_djcs.map(x=>{
  66. //x["children"] = x["__children"];
  67. x["key"] = x["序号"];
  68. x["_children"] = x["_children"].map(y=>{
  69. if (!y.hasOwnProperty('key')) {
  70. y['key'] = uuidv4();
  71. }
  72. return y;
  73. })
  74. return x;
  75. });
  76. this.memory_djcs = [];
  77. this.memory_djcs.push(copy(this.cache_djcs));
  78. this.mem_pointer_djcs = 0;
  79. }
  80. processQingdanmingxi(mingxi) {
  81. this.cache = copy(mingxi);
  82. for(let i = 0; i < this.cache.length; i++) {
  83. let zimu = this.cache[i];
  84. if (!zimu.hasOwnProperty("__children")) {
  85. zimu["__children"] = [];
  86. }
  87. if (!zimu.hasOwnProperty("rcj")) {
  88. zimu["rcj"] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  89. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
  90. }
  91. }
  92. for(let i = 0; i < this.cache.length; i++) {
  93. let zimu = this.cache[i];
  94. for(let j = 0; j < zimu["__children"].length; j++) {
  95. let de = zimu["__children"][j];
  96. if (!de.hasOwnProperty("dercj")) {
  97. de["dercj"] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  98. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
  99. }
  100. }
  101. }
  102. this.cache = this.cache.map(x=>{
  103. x["_children"] = x["__children"];
  104. x["key"] = x["序号"];
  105. x["_children"] = x["_children"].map(y=>{
  106. if (!y.hasOwnProperty('key')) {
  107. y['key'] = uuidv4();
  108. }
  109. return y;
  110. })
  111. return x;
  112. });
  113. this.memory = [];
  114. this.footprint = [];
  115. this.memory.push(copy(this.cache));
  116. this.mem_pointer = 0;
  117. }
  118. async generateOutline(name) {
  119. const response = await fetch(this.ip().concat( "/outline"), {
  120. method : "POST",
  121. headers: {
  122. "Content-type": "application/json"
  123. },
  124. body : JSON.stringify({
  125. "name": name
  126. })
  127. });
  128. if (!response.ok) {
  129. //const error = await response.json();
  130. console.error('error');
  131. } else {
  132. const data = await response.json();
  133. return data;
  134. }
  135. }
  136. async uploadFile(fd) {
  137. const response = await fetch(this.ip().concat( "/upload/"), {
  138. method : "POST",
  139. body : fd
  140. });
  141. if (!response.ok) {
  142. //const error = await response.json();
  143. console.error('error');
  144. } else {
  145. const data = await response.json();
  146. return data;
  147. }
  148. }
  149. async generateQufei(name) {
  150. const response = await fetch(this.ip().concat("/qufei/"), {
  151. method : "POST",
  152. headers: {
  153. "Content-type": "application/json"
  154. },
  155. body : JSON.stringify({
  156. "name": name
  157. })
  158. });
  159. if (!response.ok) {
  160. //const error = await response.json();
  161. console.error('error');
  162. } else {
  163. const data = await response.json();
  164. return data;
  165. }
  166. }
  167. async generateOutline2(name) {
  168. const response = await fetch(this.ip().concat( "/outline2"), {
  169. method : "POST",
  170. headers: {
  171. "Content-type": "application/json"
  172. },
  173. body : JSON.stringify({
  174. "name": name
  175. })
  176. });
  177. if (!response.ok) {
  178. //const error = await response.json();
  179. console.error('error');
  180. } else {
  181. const data = await response.json();
  182. return data;
  183. }
  184. }
  185. async generateDetail(name) {
  186. const response = await fetch(this.ip().concat("/detail"), {
  187. method : "POST",
  188. headers: {
  189. "Content-type": "application/json"
  190. },
  191. body : JSON.stringify({
  192. "name": name
  193. })
  194. });
  195. if (!response.ok) {
  196. //const error = await response.json();
  197. console.error('error');
  198. } else {
  199. const data = await response.json();
  200. return data;
  201. }
  202. }
  203. async generateDetail2(name) {
  204. const response = await fetch(this.ip().concat("/detail2"), {
  205. method : "POST",
  206. headers: {
  207. "Content-type": "application/json"
  208. },
  209. body : JSON.stringify({
  210. "name": name
  211. })
  212. });
  213. if (!response.ok) {
  214. //const error = await response.json();
  215. console.error('error');
  216. } else {
  217. const data = await response.json();
  218. return data;
  219. }
  220. }
  221. async generateBaojiahuizong(name, id) {
  222. const response = await fetch(this.ip().concat( "/baojiahuizong/"), {
  223. method : "POST",
  224. headers: {
  225. "Content-type": "application/json"
  226. },
  227. body: JSON.stringify({
  228. name: name,
  229. id : id
  230. })
  231. });
  232. if (!response.ok) {
  233. //const error = await response.json();
  234. console.error('error');
  235. } else {
  236. const data = await response.json();
  237. return data;
  238. }
  239. }
  240. async generateBaojiahuizong2(name, id) {
  241. const response = await fetch(this.ip().concat( "/baojiahuizong2/"), {
  242. method : "POST",
  243. headers: {
  244. "Content-type": "application/json"
  245. },
  246. body: JSON.stringify({
  247. name: name,
  248. id : id
  249. })
  250. });
  251. if (!response.ok) {
  252. //const error = await response.json();
  253. console.error('error');
  254. } else {
  255. const data = await response.json();
  256. return data;
  257. }
  258. }
  259. async generateGuifeishuijin(name, id) {
  260. const response = await fetch(this.ip().concat( "/guifeishuijin/"), {
  261. method : "POST",
  262. headers: {
  263. "Content-type": "application/json"
  264. },
  265. body: JSON.stringify({
  266. name: name,
  267. id: id
  268. })
  269. });
  270. if (!response.ok) {
  271. //const error = await response.json();
  272. console.error('error');
  273. } else {
  274. const data = await response.json();
  275. return data;
  276. }
  277. }
  278. async generateGuifeishuijin2(name, id) {
  279. const response = await fetch(this.ip().concat( "/guifeishuijin2/"), {
  280. method : "POST",
  281. headers: {
  282. "Content-type": "application/json"
  283. },
  284. body: JSON.stringify({
  285. name: name,
  286. id: id
  287. })
  288. });
  289. if (!response.ok) {
  290. //const error = await response.json();
  291. console.error('error');
  292. } else {
  293. const data = await response.json();
  294. return data;
  295. }
  296. }
  297. async generateQitaxiangmu(name, id) {
  298. const response = await fetch(this.ip().concat( "/qitaxiangmu/"), {
  299. method : "POST",
  300. headers: {
  301. "Content-type": "application/json"
  302. },
  303. body: JSON.stringify({
  304. name: name,
  305. id : id
  306. })
  307. });
  308. if (!response.ok) {
  309. //const error = await response.json();
  310. console.error('error');
  311. } else {
  312. const data = await response.json();
  313. return data;
  314. }
  315. }
  316. async generateQitaxiangmu2(name, id) {
  317. const response = await fetch(this.ip().concat( "/qitaxiangmu2/"), {
  318. method : "POST",
  319. headers: {
  320. "Content-type": "application/json"
  321. },
  322. body: JSON.stringify({
  323. name: name,
  324. id : id
  325. })
  326. });
  327. if (!response.ok) {
  328. //const error = await response.json();
  329. console.error('error');
  330. } else {
  331. const data = await response.json();
  332. return data;
  333. }
  334. }
  335. async generateZygczgj(name, id) {
  336. const response = await fetch(this.ip().concat( "/zygczgj/"), {
  337. method : "POST",
  338. headers: {
  339. "Content-type": "application/json"
  340. },
  341. body: JSON.stringify({
  342. name: name,
  343. id : id
  344. })
  345. });
  346. if (!response.ok) {
  347. //const error = await response.json();
  348. console.error('error');
  349. } else {
  350. const data = await response.json();
  351. return data;
  352. }
  353. }
  354. async generateZongchengbaofuwufei(name, id) {
  355. const response = await fetch(this.ip().concat( "/zongchengbaofuwufei/"), {
  356. method : "POST",
  357. headers: {
  358. "Content-type": "application/json"
  359. },
  360. body: JSON.stringify({
  361. name: name,
  362. id: id
  363. })
  364. });
  365. if (!response.ok) {
  366. //const error = await response.json();
  367. console.error('error');
  368. } else {
  369. const data = await response.json();
  370. return data;
  371. }
  372. }
  373. async generateZongchengbaofuwufei2(name, id) {
  374. const response = await fetch(this.ip().concat( "/zongchengbaofuwufei2/"), {
  375. method : "POST",
  376. headers: {
  377. "Content-type": "application/json"
  378. },
  379. body: JSON.stringify({
  380. name: name,
  381. id: id
  382. })
  383. });
  384. if (!response.ok) {
  385. //const error = await response.json();
  386. console.error('error');
  387. } else {
  388. const data = await response.json();
  389. return data;
  390. }
  391. }
  392. async generateFabaorengongyingcailiao(name, id) {
  393. const response = await fetch(this.ip().concat( "/fabaorengongyingcailiao/"), {
  394. method : "POST",
  395. headers: {
  396. "Content-type": "application/json"
  397. },
  398. body: JSON.stringify({
  399. name: name,
  400. id : id
  401. })
  402. });
  403. if (!response.ok) {
  404. //const error = await response.json();
  405. console.error('error');
  406. } else {
  407. const data = await response.json();
  408. return data;
  409. }
  410. }
  411. async generateFabaorengongyingcailiao2(name, id) {
  412. const response = await fetch(this.ip().concat( "/fabaorengongyingcailiao2/"), {
  413. method : "POST",
  414. headers: {
  415. "Content-type": "application/json"
  416. },
  417. body: JSON.stringify({
  418. name: name,
  419. id : id
  420. })
  421. });
  422. if (!response.ok) {
  423. //const error = await response.json();
  424. console.error('error');
  425. } else {
  426. const data = await response.json();
  427. return data;
  428. }
  429. }
  430. async generateRencaijihuizong(name, id) {
  431. const response = await fetch(this.ip().concat( "/rencaijihuizong/"), {
  432. method : "POST",
  433. headers: {
  434. "Content-type": "application/json"
  435. },
  436. body: JSON.stringify({
  437. name: name,
  438. id: id
  439. })
  440. });
  441. if (!response.ok) {
  442. //const error = await response.json();
  443. console.error('error');
  444. } else {
  445. const data = await response.json();
  446. return data;
  447. }
  448. }
  449. async generateRencaijihuizong2(name, id) {
  450. const response = await fetch(this.ip().concat( "/rencaijihuizong2/"), {
  451. method : "POST",
  452. headers: {
  453. "Content-type": "application/json"
  454. },
  455. body: JSON.stringify({
  456. name: name,
  457. id: id
  458. })
  459. });
  460. if (!response.ok) {
  461. //const error = await response.json();
  462. console.error('error');
  463. } else {
  464. const data = await response.json();
  465. let result = [];
  466. for (let i = 1; i < data.length; i++) {
  467. result.push({
  468. 'key': uuidv4(),
  469. 'ID' : data[i][0],
  470. '编码' : data[i][1],
  471. '名称': data[i][2],
  472. '规格型号' : data[i][3],
  473. '单位' : data[i][4],
  474. '数量' : data[i][5],
  475. '单价' : data[i][6],
  476. '合价' : data[i][7],
  477. '产地' : data[i][8],
  478. '供应厂商' : data[i][9],
  479. '人材机类别' : data[i][10],
  480. '主要材料标志' : data[i][11],
  481. '主材标志' : data[i][12],
  482. '设备标志' : data[i][13],
  483. '甲供标志' : data[i][14],
  484. '暂估价标志' : data[i][15]
  485. });
  486. }
  487. this.setQufeiEntry(id);
  488. return result;
  489. }
  490. }
  491. async generateJirigong(name, id) {
  492. const response = await fetch(this.ip().concat("/jirigong/"), {
  493. method : "POST",
  494. headers: {
  495. "Content-type": "application/json"
  496. },
  497. body: JSON.stringify({
  498. name: name,
  499. id: id
  500. })
  501. });
  502. if (!response.ok) {
  503. //const error = await response.json();
  504. console.error('error');
  505. } else {
  506. const data = await response.json();
  507. return data;
  508. }
  509. }
  510. async generateJirigong2(name, id) {
  511. const response = await fetch(this.ip().concat("/jirigong2/"), {
  512. method : "POST",
  513. headers: {
  514. "Content-type": "application/json"
  515. },
  516. body: JSON.stringify({
  517. name: name,
  518. id: id
  519. })
  520. });
  521. if (!response.ok) {
  522. //const error = await response.json();
  523. console.error('error');
  524. } else {
  525. const data = await response.json();
  526. return data;
  527. }
  528. }
  529. async generateZanliejine(name, id) {
  530. const response = await fetch(this.ip().concat( "/zanliejine/"), {
  531. method : "POST",
  532. headers: {
  533. "Content-type": "application/json"
  534. },
  535. body: JSON.stringify({
  536. name: name,
  537. id: id
  538. })
  539. });
  540. if (!response.ok) {
  541. //const error = await response.json();
  542. console.error('error');
  543. } else {
  544. const data = await response.json();
  545. return data;
  546. }
  547. }
  548. async generateZanliejine2(name, id) {
  549. const response = await fetch(this.ip().concat( "/zanliejine2/"), {
  550. method : "POST",
  551. headers: {
  552. "Content-type": "application/json"
  553. },
  554. body: JSON.stringify({
  555. name: name,
  556. id: id
  557. })
  558. });
  559. if (!response.ok) {
  560. //const error = await response.json();
  561. console.error('error');
  562. } else {
  563. const data = await response.json();
  564. return data;
  565. }
  566. }
  567. async generateQingdanxiangmu(name, id) {
  568. const response = await fetch(this.ip().concat( "/qingdanxiangmu/"), {
  569. method : "POST",
  570. headers: {
  571. "Content-type": "application/json"
  572. },
  573. body: JSON.stringify({
  574. name: name,
  575. id: id
  576. })
  577. });
  578. if (!response.ok) {
  579. //const error = await response.json();
  580. console.error('error');
  581. } else {
  582. const data = await response.json();
  583. return data;
  584. }
  585. }
  586. async generateQingdanxiangmu2(name, id) {
  587. const response = await fetch(this.ip().concat( "/qingdanxiangmu2/"), {
  588. method : "POST",
  589. headers: {
  590. "Content-type": "application/json"
  591. },
  592. body: JSON.stringify({
  593. name: name,
  594. id: id
  595. })
  596. });
  597. if (!response.ok) {
  598. //const error = await response.json();
  599. console.error('error');
  600. } else {
  601. const data = await response.json();
  602. return data;
  603. }
  604. }
  605. async searchDe(zhuanye, text) {
  606. const response = await fetch(this.ip().concat( "/searchde/"), {
  607. method : "POST",
  608. headers: {
  609. "Content-type": "application/json"
  610. },
  611. body: JSON.stringify({
  612. zhuanye: zhuanye,
  613. text: text
  614. })
  615. });
  616. if (!response.ok) {
  617. //const error = await response.json();
  618. console.error('error');
  619. } else {
  620. const data = await response.json();
  621. return data;
  622. }
  623. }
  624. /////////////////////////////////////qingdan//////////////////////////////////////
  625. async generateQingdanmingxi(name, bh, bt) {
  626. if (this.cache.length == 0 || this.cache[0]["biao_id"] != name || this.cache[0]["Dwgcbh"] != bh ||
  627. this.cache[0]["bt"] != bt) {
  628. const response = await fetch(this.ip().concat("/qingdanmingxi/"), {
  629. method : "POST",
  630. headers: {
  631. "Content-type": "application/json"
  632. },
  633. body: JSON.stringify(
  634. {
  635. "bh": bh,
  636. "bt": bt,
  637. "name": name
  638. }
  639. )
  640. });
  641. if (!response.ok) {
  642. //const error = await response.json();
  643. console.error('error');
  644. } else {
  645. const data = await response.json();
  646. this.processQingdanmingxi(data);
  647. this.setQufeiEntry(bh);
  648. return copy(this.cache);
  649. }
  650. } else {
  651. return copy(this.cache);
  652. }
  653. }
  654. async generateQingdanrcj(name, bh, bt, bm) {
  655. if (bt == "Djcs") {
  656. let qd = this.cache_djcs.filter(x=>x["清单编码"] == bm)[0];
  657. return copy(qd["rcj"]);
  658. }
  659. let qd = this.cache.filter(x=>x["清单编码"] == bm)[0];
  660. return copy(qd["rcj"]);
  661. }
  662. async generateDingercj(name, bh, bt, qdbm, debm, danwei) {
  663. console.log('generateDingercj');
  664. console.log(debm);
  665. if (bt == 'Djcs') {
  666. let qd = this.cache_djcs.filter(x=>x["清单编码"] == qdbm)[0];
  667. let de = qd["_children"].filter(x=>x["清单编码"]==debm)[0];
  668. return [copy(de["dercj"]), de["fuzhuEnable"]];
  669. }
  670. let qd = this.cache.filter(x=>x["清单编码"] == qdbm)[0];
  671. let de = qd["_children"].filter(x=>x["清单编码"]==debm)[0];
  672. return [copy(de["dercj"]), de["fuzhuEnable"], de['yuban'], de['rcjbc']];
  673. }
  674. /////////////////////////////end of qingdan////////////////////////////////////
  675. async generateQingdanTuijian(name, bh, bt, bm) {
  676. const response = await fetch(this.ip().concat( "/qingdantuijian/"), {
  677. method : "POST",
  678. headers: {
  679. "Content-type": "application/json"
  680. },
  681. body: JSON.stringify(
  682. {
  683. "bh": bh,
  684. "bt": bt,
  685. "bm": bm,
  686. "name": name
  687. }
  688. )
  689. });
  690. if (!response.ok) {
  691. //const error = await response.json();
  692. console.error('error');
  693. } else {
  694. const data = await response.json();
  695. return data;
  696. }
  697. }
  698. async generateZjcs(name, bh) {
  699. const response = await fetch(this.ip().concat( "/zjcs/"), {
  700. method : "POST",
  701. headers: {
  702. "Content-type": "application/json"
  703. },
  704. body: JSON.stringify(
  705. {
  706. "bh": bh,
  707. "name": name
  708. }
  709. )
  710. });
  711. if (!response.ok) {
  712. //const error = await response.json();
  713. console.error('error');
  714. } else {
  715. const data = await response.json();
  716. return data;
  717. }
  718. }
  719. async generateDjcs(name, bh) {
  720. if (this.cache_djcs.length == 0 || this.cache_djcs[0]["biao_id"] != name || this.cache_djcs[0]["Dwgcbh"] != bh) {
  721. const response = await fetch(this.ip().concat( "/djcs/"), {
  722. method : "POST",
  723. headers: {
  724. "Content-type": "application/json"
  725. },
  726. body: JSON.stringify(
  727. {
  728. "bh": bh,
  729. "name": name
  730. }
  731. )
  732. });
  733. if (!response.ok) {
  734. //const error = await response.json();
  735. console.error('error');
  736. } else {
  737. const data = await response.json();
  738. this.processDjcsmingxi(data);
  739. this.setQufeiEntry(bh);
  740. return copy(this.cache_djcs);
  741. }
  742. } else {
  743. return copy(this.cache_djcs);
  744. }
  745. }
  746. async generateFiles() {
  747. const response = await fetch(this.ip().concat( "/files/"), {
  748. method : "POST",
  749. headers: {
  750. "Content-type": "application/json"
  751. }
  752. });
  753. if (!response.ok) {
  754. //const error = await response.json();
  755. console.error('error');
  756. } else {
  757. const data = await response.json();
  758. return data;
  759. }
  760. }
  761. async generateFiles2() {
  762. const response = await fetch(this.ip().concat( "/files2/"), {
  763. method : "POST",
  764. headers: {
  765. "Content-type": "application/json"
  766. }
  767. });
  768. if (!response.ok) {
  769. //const error = await response.json();
  770. console.error('error');
  771. } else {
  772. const data = await response.json();
  773. return data;
  774. }
  775. }
  776. async deleteFiles(id) {
  777. const response = await fetch(this.ip().concat( "/deleteFile/"), {
  778. method : "POST",
  779. headers: {
  780. "Content-type": "application/json"
  781. },
  782. body: JSON.stringify(
  783. {
  784. "name": id,
  785. }
  786. )
  787. });
  788. if (!response.ok) {
  789. //const error = await response.json();
  790. console.error('error');
  791. } else {
  792. const data = await response.json();
  793. return data;
  794. }
  795. }
  796. async generatePeibiXilie(id) {
  797. const response = await fetch(this.ip().concat( "/pbxl/"), {
  798. method : "POST",
  799. headers: {
  800. "Content-type": "application/json"
  801. },
  802. body: JSON.stringify(
  803. {
  804. "name": id
  805. }
  806. )
  807. });
  808. if (!response.ok) {
  809. //const error = await response.json();
  810. console.error('error');
  811. } else {
  812. const data = await response.json();
  813. return data;
  814. }
  815. }
  816. async generatePeibishu(zhuanye) {
  817. const response = await fetch(this.ip().concat( "/pbs/"), {
  818. method : "POST",
  819. headers: {
  820. "Content-type": "application/json"
  821. },
  822. body: JSON.stringify(
  823. {
  824. "value": zhuanye
  825. }
  826. )
  827. });
  828. if (!response.ok) {
  829. //const error = await response.json();
  830. console.error('error');
  831. } else {
  832. const data = await response.json();
  833. return data;
  834. }
  835. }
  836. async generateDingeshu(value) {
  837. const response = await fetch(this.ip().concat( "/des/"), {
  838. method : "POST",
  839. headers: {
  840. "Content-type": "application/json"
  841. },
  842. body: JSON.stringify(
  843. {
  844. "value": value
  845. }
  846. )
  847. });
  848. if (!response.ok) {
  849. //const error = await response.json();
  850. console.error('error');
  851. } else {
  852. const data = await response.json();
  853. return data;
  854. }
  855. }
  856. async generateDingeXilie(value, id) {//定额书的一个栏目的所有具体定额
  857. const response = await fetch(this.ip().concat("/dexilie/"), {
  858. method : "POST",
  859. headers: {
  860. "Content-type": "application/json"
  861. },
  862. body: JSON.stringify(
  863. {
  864. "value": value,
  865. "id": id
  866. }
  867. )
  868. });
  869. if (!response.ok) {
  870. //const error = await response.json();
  871. console.error('error');
  872. } else {
  873. const data = await response.json();
  874. return data;
  875. }
  876. }
  877. async generateSingleDingeXilie(zhuanye, debh) {//清单页面展示用
  878. const response = await fetch(this.ip().concat( "/singledexilie/"), {
  879. method : "POST",
  880. headers: {
  881. "Content-type": "application/json"
  882. },
  883. body: JSON.stringify(
  884. {
  885. "debh": debh,
  886. "zhuanye": zhuanye
  887. }
  888. )
  889. });
  890. if (!response.ok) {
  891. //const error = await response.json();
  892. console.error('error');
  893. } else {
  894. const data = await response.json();
  895. return data;
  896. }
  897. }
  898. async save() {
  899. const response = await fetch(this.ip().concat( "/save/"), {
  900. method : "POST",
  901. headers: {
  902. "Content-type": "application/json"
  903. },
  904. body: JSON.stringify(
  905. {
  906. "name": JSON.stringify(this.cache.filter(x=>this.footprint.includes(x['key'])))
  907. }
  908. )
  909. });
  910. if (!response.ok) {
  911. //const error = await response.json();
  912. console.error('error');
  913. } else {
  914. const data = await response.json();
  915. this.footprint = [];
  916. return data;
  917. }
  918. }
  919. async save_djcs() {
  920. const response = await fetch(this.ip().concat( "/savedjcs/"), {
  921. method : "POST",
  922. headers: {
  923. "Content-type": "application/json"
  924. },
  925. body: JSON.stringify(
  926. {
  927. "name": JSON.stringify(this.cache_djcs)
  928. }
  929. )
  930. });
  931. if (!response.ok) {
  932. //const error = await response.json();
  933. console.error('error');
  934. } else {
  935. const data = await response.json();
  936. return data;
  937. }
  938. }
  939. async applyFL(id, data) {
  940. const response = await fetch(this.ip().concat( "/applyFL/"), {
  941. method : "POST",
  942. headers: {
  943. "Content-type": "application/json"
  944. },
  945. body: JSON.stringify(
  946. {
  947. "id": id,
  948. "name": JSON.stringify(data)
  949. }
  950. )
  951. });
  952. if (!response.ok) {
  953. //const error = await response.json();
  954. console.error('error');
  955. } else {
  956. const data = await response.json();
  957. return data;
  958. }
  959. }
  960. async download(id) {
  961. const response = await fetch(this.ip().concat( "/download/").concat(id.toString()));
  962. if (!response.ok) {
  963. //const error = await response.json();
  964. console.error('error');
  965. } else {
  966. const data = await response.blob();
  967. return data;
  968. }
  969. }
  970. async tiaojia(biao_id, bh, bm, mingcheng, danwei, jiage) {
  971. let glf = "";
  972. let lr = "";
  973. let bz = 0;//changgui
  974. if (this.qufeiEntry['备注'].length == 0) {
  975. //changuiqufei
  976. glf = this.qufeiEntry['管理费(%)'] ;
  977. lr = this.qufeiEntry['利润(%)'];
  978. } else {
  979. glf = this.qufeiEntry['管理费(%)'] ;
  980. lr = this.qufeiEntry['利润(%)'];
  981. bz = 1;
  982. }
  983. const response = await fetch(this.ip().concat( "/tiaojia/"), {
  984. method : "POST",
  985. headers: {
  986. "Content-type": "application/json"
  987. },
  988. body: JSON.stringify(
  989. {
  990. "biao_id": biao_id,
  991. "bh": bh,
  992. "bm": bm,
  993. "mingcheng": mingcheng,
  994. "danwei" : danwei,
  995. "jiage": jiage,
  996. "glf" : glf,
  997. "lr" : lr,
  998. "bz" : bz
  999. }
  1000. )
  1001. });
  1002. if (!response.ok) {
  1003. //const error = await response.json();
  1004. console.error('error');
  1005. } else {
  1006. const data = await response.json();
  1007. this.clearCache();
  1008. return data;
  1009. }
  1010. }
  1011. async updateZjcs(biao_id, bh, row) {
  1012. const response = await fetch(this.ip().concat( "/updatezjcs/"), {
  1013. method : "POST",
  1014. headers: {
  1015. "Content-type": "application/json"
  1016. },
  1017. body: JSON.stringify(
  1018. {
  1019. "biao_id": biao_id,
  1020. "bh": bh,
  1021. 'mc': row['名称'].toString(),
  1022. 'fl': row['费率'].toString()
  1023. }
  1024. )
  1025. });
  1026. if (!response.ok) {
  1027. //const error = await response.json();
  1028. console.error('error');
  1029. } else {
  1030. const data = await response.json();
  1031. return data;
  1032. }
  1033. }
  1034. async cankao() { //参考费率
  1035. const response = await fetch(this.ip().concat( "/cankao/"), {
  1036. method : "POST",
  1037. headers: {
  1038. "Content-type": "application/json"
  1039. },
  1040. body: JSON.stringify(
  1041. {
  1042. }
  1043. )
  1044. });
  1045. if (!response.ok) {
  1046. //const error = await response.json();
  1047. console.error('error');
  1048. } else {
  1049. const data = await response.json();
  1050. return data;
  1051. }
  1052. }
  1053. ///////////////////////////////////editor//////////////////////////////////
  1054. summarize_one_djcs(qd) {///根据定额汇总清单
  1055. let dict = {};
  1056. for(let i = 0; i < qd["_children"].length; i++) {
  1057. let de = qd["_children"][i];
  1058. let desl = Number(de['数量']);
  1059. let dercj = de['dercj'];
  1060. for (let j = 1; j < dercj.length; j++) {
  1061. let hl = copy(dercj[j]);
  1062. hl[10] = desl * Number(hl[10]);
  1063. hl[11] = desl * Number(hl[11]);
  1064. let a = hl[1];//"人材机编码",
  1065. let b = a.concat(hl[2]);//"名称",
  1066. let c = b.concat(hl[4]);// "单位"
  1067. if (dict.hasOwnProperty(c)) {
  1068. dict[c].push(hl);
  1069. } else {
  1070. dict[c] = [hl];
  1071. }
  1072. }
  1073. }
  1074. let result = [];
  1075. for(const key in dict) {
  1076. let list = dict[key];
  1077. let sum = 0;
  1078. let danjia = Number(list[0][5]);
  1079. for (let i =0 ;i < list.length; i++) {
  1080. sum += Number(list[i][10]);
  1081. }
  1082. let entry = [list[0][0], list[0][1], list[0][2], list[0][3], list[0][4], danjia,
  1083. list[0][6], list[0][7], list[0][8], list[0][9], sum, sum * danjia, list[0][12],
  1084. list[0][13], list[0][14], list[0][15]
  1085. ];
  1086. result.push(entry);
  1087. }
  1088. let gongri = 0;
  1089. for(let i = 0; i < result.length; i++) {
  1090. if (result[i][4] == '工日') {
  1091. gongri += result[i][10];
  1092. }
  1093. }
  1094. result.sort((a, b) => Number(a[8]) - Number(b[8]));
  1095. qd['rcj'] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1096. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]].concat(result);
  1097. qd["综合人工工日"] = gongri;
  1098. qd['综合单价'] = 0;
  1099. qd['合价'] = 0;
  1100. qd['人工费'] = 0;
  1101. qd['主材费'] = 0;
  1102. qd['设备费'] = 0;
  1103. qd['辅材费'] = 0;
  1104. qd['材料费'] = 0;
  1105. qd['机械费'] = 0;
  1106. qd['管理费'] = 0;
  1107. qd['利润'] = 0;
  1108. for(let i = 0; i < qd["_children"].length; i++) {
  1109. qd['综合单价'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['综合单价']);
  1110. qd['合价'] += Number(qd['_children'][i]['合价']);
  1111. qd['人工费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['人工费']);
  1112. qd['主材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['主材费']);
  1113. qd['设备费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['设备费']);
  1114. qd['辅材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['辅材费']);
  1115. qd['材料费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['材料费']);
  1116. qd['机械费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['机械费']);
  1117. qd['管理费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['管理费']);
  1118. qd['利润'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['利润']);
  1119. }
  1120. return qd;
  1121. }
  1122. summarize_one(qd) {///根据定额汇总清单
  1123. qd['综合单价'] = 0;
  1124. qd['合价'] = 0;
  1125. qd['人工费'] = 0;
  1126. qd['主材费'] = 0;
  1127. qd['设备费'] = 0;
  1128. qd['辅材费'] = 0;
  1129. qd['材料费'] = 0;
  1130. qd['机械费'] = 0;
  1131. qd['管理费'] = 0;
  1132. qd['利润'] = 0;
  1133. for(let i = 0; i < qd["_children"].length; i++) {
  1134. if (qd["_children"][i]['azfytag'].length > 0)continue;
  1135. qd['综合单价'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['综合单价']);
  1136. qd['合价'] += Number(qd['_children'][i]['合价']);
  1137. qd['人工费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['人工费']);
  1138. qd['主材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['主材费']);
  1139. qd['设备费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['设备费']);
  1140. qd['辅材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['辅材费']);
  1141. qd['材料费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['材料费']);
  1142. qd['机械费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['机械费']);
  1143. qd['管理费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['管理费']);
  1144. qd['利润'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['利润']);
  1145. }
  1146. //处理安装费用
  1147. console.log(qd["_children"].length);
  1148. for(let i = 0; i < qd["_children"].length; i++) {
  1149. console.log(i);
  1150. if (qd["_children"][i]['azfytag'].length > 0){
  1151. let tag = qd["_children"][i]['azfytag'];
  1152. if (tag[0] == '人工费') {
  1153. let current_rgf = qd['人工费'];
  1154. let added = Number(current_rgf) * Number(tag[1]) / Number(100);
  1155. let added_rgf = added * Number(tag[2]) / Number(100);
  1156. let added_clf = added * Number(tag[3]) / Number(100);
  1157. let added_jxf = added * Number(tag[4]) / Number(100);
  1158. qd["_children"][i]['人工费'] = added_rgf;
  1159. qd["_children"][i]['辅材费'] = added_clf;
  1160. qd["_children"][i]['材料费'] = added_clf;
  1161. qd["_children"][i]['机械费'] = added_jxf;
  1162. if (this.qufeiEntry['备注'].length == 0) {
  1163. //changuiqufei
  1164. qd["_children"][i]['管理费'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1165. qd["_children"][i]['利润'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1166. } else {
  1167. qd["_children"][i]['管理费'] = (added_rgf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1168. qd["_children"][i]['利润'] = (added_rgf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1169. }
  1170. qd["_children"][i]['综合单价'] = qd["_children"][i]['人工费'] + qd["_children"][i]['材料费'] + qd["_children"][i]['机械费'] + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
  1171. qd["_children"][i]['合价'] = qd["_children"][i]['综合单价'] * Number(qd["_children"][i]['数量']) * Number(qd['数量']);
  1172. let dercj = qd["_children"][i]['dercj'];
  1173. for (let j = 1; j < dercj.length; j++) {
  1174. dercj[j][11] = Number(qd['_children'][i]['综合单价']) * Number(dercj[j][10]) / Number(100);
  1175. }
  1176. }
  1177. if (tag[0] == '人工费+机械费') {
  1178. let current_rgf = qd['人工费'] + qd['机械费'];
  1179. let added = Number(current_rgf) * Number(tag[1]) / Number(100);
  1180. let added_rgf = added * Number(tag[2]) / Number(100);
  1181. let added_clf = added * Number(tag[3]) / Number(100);
  1182. let added_jxf = added * Number(tag[4]) / Number(100);
  1183. qd["_children"][i]['人工费'] = added_rgf;
  1184. qd["_children"][i]['辅材费'] = added_clf;
  1185. qd["_children"][i]['材料费'] = added_clf;
  1186. qd["_children"][i]['机械费'] = added_jxf;
  1187. if (this.qufeiEntry['备注'].length == 0) {
  1188. //changuiqufei
  1189. qd["_children"][i]['管理费'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1190. qd["_children"][i]['利润'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1191. } else {
  1192. qd["_children"][i]['管理费'] = (added_rgf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1193. qd["_children"][i]['利润'] = (added_rgf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1194. }
  1195. qd["_children"][i]['综合单价'] = qd["_children"][i]['人工费'] + qd["_children"][i]['材料费'] + qd["_children"][i]['机械费'] + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
  1196. qd["_children"][i]['合价'] = qd["_children"][i]['综合单价'] * Number(qd["_children"][i]['数量']) * Number(qd["数量"]);
  1197. let dercj = qd["_children"][i]['dercj'];
  1198. for (let j = 1; j < dercj.length; j++) {
  1199. dercj[j][11] = Number(qd['_children'][i]['综合单价']) * Number(dercj[j][10]) / Number(100);
  1200. }
  1201. }
  1202. }
  1203. }
  1204. qd['综合单价'] = 0;
  1205. qd['合价'] = 0;
  1206. qd['人工费'] = 0;
  1207. qd['主材费'] = 0;
  1208. qd['设备费'] = 0;
  1209. qd['辅材费'] = 0;
  1210. qd['材料费'] = 0;
  1211. qd['机械费'] = 0;
  1212. qd['管理费'] = 0;
  1213. qd['利润'] = 0;
  1214. for(let i = 0; i < qd["_children"].length; i++) {
  1215. qd['综合单价'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['综合单价']);
  1216. qd['合价'] += Number(qd['_children'][i]['合价']);
  1217. qd['人工费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['人工费']);
  1218. qd['主材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['主材费']);
  1219. qd['设备费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['设备费']);
  1220. qd['辅材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['辅材费']);
  1221. qd['材料费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['材料费']);
  1222. qd['机械费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['机械费']);
  1223. qd['管理费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['管理费']);
  1224. qd['利润'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['利润']);
  1225. }
  1226. let dict = {};
  1227. let left = [];
  1228. for(let i = 0; i < qd["_children"].length; i++) {
  1229. let de = qd["_children"][i];
  1230. let desl = Number(de['数量']);
  1231. let dercj = de['dercj'];
  1232. for (let j = 1; j < dercj.length; j++) {
  1233. let hl = copy(dercj[j]);
  1234. if (hl[1].includes('000FE')) {
  1235. left.push(hl);
  1236. continue;
  1237. }
  1238. hl[10] = desl * Number(hl[10]);
  1239. hl[11] = desl * Number(hl[11]);
  1240. let a = hl[1];//"人材机编码",
  1241. let b = a.concat(hl[2]);//"名称",
  1242. let c = b.concat(hl[4]);// "单位"
  1243. if (dict.hasOwnProperty(c)) {
  1244. dict[c].push(hl);
  1245. } else {
  1246. dict[c] = [hl];
  1247. }
  1248. }
  1249. }
  1250. let result = [];
  1251. for(const key in dict) {
  1252. let list = dict[key];
  1253. let sum = 0;
  1254. let danjia = Number(list[0][5]);
  1255. for (let i =0 ;i < list.length; i++) {
  1256. sum += Number(list[i][10]);
  1257. }
  1258. let entry = [list[0][0], list[0][1], list[0][2], list[0][3], list[0][4], danjia,
  1259. list[0][6], list[0][7], list[0][8], list[0][9], sum, sum * danjia, list[0][12],
  1260. list[0][13], list[0][14], list[0][15]
  1261. ];
  1262. result.push(entry);
  1263. }
  1264. for (let i = 0; i < left.length; i++) {
  1265. result.push(left[i]);
  1266. }
  1267. let gongri = 0;
  1268. for(let i = 0; i < result.length; i++) {
  1269. if (result[i][4] == '工日') {
  1270. gongri += result[i][10];
  1271. }
  1272. }
  1273. result.sort((a, b) => Number(a[8]) - Number(b[8]));
  1274. qd['rcj'] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1275. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]].concat(result);
  1276. qd["综合人工工日"] = gongri;
  1277. return qd;
  1278. }
  1279. summarize(data) {
  1280. return data.map(x=>this.summarize_one(x));
  1281. }
  1282. summarize_djcs(data) {
  1283. return data.map(x=>this.summarize_one_djcs(x));
  1284. }
  1285. push_op(newData) {
  1286. if(this.memory.length == this.mem_pointer + 1) {
  1287. this.memory.push(copy(newData));
  1288. this.mem_pointer = this.mem_pointer + 1;
  1289. } else{
  1290. this.memory.splice(this.mem_pointer + 1);
  1291. this.memory.push(copy(newData));
  1292. this.mem_pointer = this.mem_pointer + 1;
  1293. }
  1294. }
  1295. push_op_djcs(newData) {
  1296. if(this.memory_djcs.length == this.mem_pointer_djcs + 1) {
  1297. this.memory_djcs.push(copy(newData));
  1298. this.mem_pointer_djcs = this.mem_pointer_djcs + 1;
  1299. } else{
  1300. this.memory_djcs.splice(this.mem_pointer_djcs + 1);
  1301. this.memory_djcs.push(copy(newData));
  1302. this.mem_pointer_djcs = this.mem_pointer_djcs + 1;
  1303. }
  1304. }
  1305. undo() {
  1306. if (this.mem_pointer > 0) {
  1307. let newData = this.memory[this.mem_pointer - 1];
  1308. this.mem_pointer = this.mem_pointer - 1;
  1309. this.cache = copy(newData);
  1310. return copy(newData);
  1311. }
  1312. return copy(this.cache);
  1313. }
  1314. undo_djcs() {
  1315. if (this.mem_pointer_djcs > 0) {
  1316. let newData = this.memory_djcs[this.mem_pointer_djcs - 1];
  1317. this.mem_pointer_djcs = this.mem_pointer_djcs - 1;
  1318. this.cache_djcs = copy(newData);
  1319. return copy(newData);
  1320. }
  1321. return copy(this.cache_djcs);
  1322. }
  1323. redo() {
  1324. if (this.mem_pointer + 1 != this.memory.length) {
  1325. let newData = this.memory[this.mem_pointer + 1];
  1326. this.mem_pointer = this.mem_pointer + 1;
  1327. this.cache = copy(newData);
  1328. return copy(newData);
  1329. }
  1330. return copy(this.cache);
  1331. }
  1332. redo_djcs() {
  1333. if (this.mem_pointer_djcs + 1 != this.memory_djcs.length) {
  1334. let newData = this.memory_djcs[this.mem_pointer_djcs + 1];
  1335. this.mem_pointer_djcs = this.mem_pointer_djcs + 1;
  1336. this.cache_djcs = copy(newData);
  1337. return copy(newData);
  1338. }
  1339. return copy(this.cache_djcs);
  1340. }
  1341. shanchu_djcs(key) {
  1342. if (this.cache_djcs.filter(x=>x['key'] == key).length > 0) {
  1343. ///qd
  1344. let newData = this.cache_djcs.map(x=>{
  1345. if (x["key"] == key) {
  1346. let y = copy(x);
  1347. y["_children"] = [];
  1348. return y;
  1349. } else {
  1350. return x;
  1351. }
  1352. });
  1353. let summarized = this.summarize_djcs(newData);
  1354. this.push_op_djcs(summarized);
  1355. /////////////////
  1356. this.cache_djcs = copy(summarized);
  1357. return copy(this.cache_djcs);
  1358. } else {
  1359. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key'] == key).length > 0)[0];
  1360. let qdbm = qd['清单编码'];
  1361. let newData = this.cache_djcs.map(x=>{
  1362. if (x["清单编码"] == qdbm) {
  1363. let y = copy(x);
  1364. let origin = y["_children"];
  1365. let trans = origin.filter(z=>z["key"]!=key);
  1366. y["_children"] = trans;
  1367. return y;
  1368. } else {
  1369. return x;
  1370. }
  1371. });
  1372. let summarized = this.summarize_djcs(newData);
  1373. this.push_op_djcs(summarized);
  1374. /////////////////
  1375. this.cache_djcs = copy(summarized);
  1376. return copy(this.cache_djcs);
  1377. }
  1378. }
  1379. updateFootprint(key) {
  1380. if (this.footprint.includes(key)) {
  1381. } else {
  1382. this.footprint.push(key);
  1383. }
  1384. }
  1385. shanchu(key) {
  1386. if (this.cache.filter(x=>x['key'] == key).length > 0) {
  1387. this.updateFootprint(key);
  1388. ///qd
  1389. let newData = this.cache.map(x=>{
  1390. if (x["key"] == key) {
  1391. let y = copy(x);
  1392. y["_children"] = [];
  1393. return y;
  1394. } else {
  1395. return x;
  1396. }
  1397. });
  1398. let summarized = this.summarize(newData);
  1399. this.push_op(summarized);
  1400. /////////////////
  1401. this.cache = copy(summarized);
  1402. return copy(this.cache);
  1403. } else {
  1404. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key'] == key).length > 0)[0];
  1405. this.updateFootprint(qd['key']);
  1406. let qdbm = qd['清单编码'];
  1407. let newData = this.cache.map(x=>{
  1408. if (x["清单编码"] == qdbm) {
  1409. let y = copy(x);
  1410. let origin = y["_children"];
  1411. let trans = origin.filter(z=>z["key"]!=key);
  1412. y["_children"] = trans;
  1413. return y;
  1414. } else {
  1415. return x;
  1416. }
  1417. });
  1418. let summarized = this.summarize(newData);
  1419. this.push_op(summarized);
  1420. /////////////////
  1421. this.cache = copy(summarized);
  1422. return copy(this.cache);
  1423. }
  1424. }
  1425. updateDercj_djcs_(row, data, xuhao) {///change 一条定额 inplace, 汇总一条定额的rcj, xuhao is for rename
  1426. console.log("data updated");
  1427. //处理附注
  1428. let huan = false;//换
  1429. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1430. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1431. if (de.hasOwnProperty("rcjdg")) {//新数据
  1432. for (let i = 1; i < de['rcjdg'].length; i++) {
  1433. de['rcjdg'][i][5] = data[i][5];//更新单价
  1434. /****ToDo 更新其他字段 */
  1435. if (de['rcjdg'][i][2] == data[i][2]) {//更新名称
  1436. } else {
  1437. huan = true;
  1438. }
  1439. }
  1440. if (de['fuzhuEnable'] && de.hasOwnProperty('fuzhu')) {//没强行改过含量
  1441. for(let j = 1; j < de['rcjdg'].length; j++) {
  1442. let origin = Number(de['rcjdg'][j][10]);
  1443. for(let i = 0; i < de['fuzhu'].length; i++) {
  1444. let selected = de['fuzhu'][i];
  1445. let target = selected[0];
  1446. if (match_target(de['rcjdg'][j][1], target)) {
  1447. if (selected[2] == '系数') {
  1448. origin = origin * Number(selected[3]);
  1449. } else if (selected[2] == '含量') {
  1450. origin = Number(selected[3]);
  1451. } else if (selected[2] == '调整') {
  1452. origin = origin + Number(selected[3]);
  1453. } else {
  1454. throw new Error('无法处理的附注'.concat(selected[2]));
  1455. }
  1456. }
  1457. }
  1458. de['dercj'][j][2] = data[j][2];//名称
  1459. de['dercj'][j][1] = data[j][1];//编号
  1460. de['dercj'][j][5] = de['rcjdg'][j][5];//单价
  1461. de['dercj'][j][10] = origin;
  1462. de['dercj'][j][11] = Number(de['dercj'][j][5]) * origin;
  1463. }
  1464. } else if (de['fuzhuEnable'] && !de.hasOwnProperty('fuzhu')) {
  1465. for(let j = 1; j < de['rcjdg'].length; j++) {
  1466. let origin = Number(de['rcjdg'][j][10]);
  1467. de['dercj'][j][2] = data[j][2];//名称
  1468. de['dercj'][j][1] = data[j][1];//编号
  1469. de['dercj'][j][5] = de['rcjdg'][j][5];
  1470. de['dercj'][j][10] = origin;
  1471. de['dercj'][j][11] = Number(de['dercj'][j][5]) * origin;
  1472. }
  1473. }
  1474. else {
  1475. //强行改含量
  1476. de['dercj'] = copy(data);
  1477. }
  1478. data = de['dercj'];
  1479. } else {////单项定额没有底稿,老数据没底搞,无法判断换部换,暂时统一认为不换
  1480. //强行改含量
  1481. de['dercj'] = copy(data);
  1482. data = de['dercj'];
  1483. }
  1484. //模拟formula计算每一行的合价
  1485. for(let i = 1; i < data.length; i++) {
  1486. data[i][11] = Number(data[i][10]) * Number(data[i][5]);
  1487. }
  1488. let sum = 0;
  1489. let rgf_sum = 0;
  1490. let jxf_sum = 0;
  1491. let clf_sum = 0;
  1492. let zcf_sum = 0;
  1493. for(let i = 1; i < data.length; i++) {
  1494. sum += Number(data[i][11]);//11-> hejia
  1495. if (Number(data[i][8]) == 1) {
  1496. rgf_sum += Number(data[i][11]);
  1497. }
  1498. if (Number(data[i][8]) == 2) {
  1499. clf_sum += Number(data[i][11]);
  1500. if (data[i][14] == 'true') {
  1501. zcf_sum += Number(data[i][11]);
  1502. }
  1503. }
  1504. if (Number(data[i][8]) == 3) {
  1505. jxf_sum += Number(data[i][11]);
  1506. }
  1507. }
  1508. console.log("sum=".concat(sum));
  1509. //处理百分比费用
  1510. for(let i = 1; i < data.length; i++) {
  1511. if (data[i][1]=='00EXP001'){//回程费占人工费
  1512. data[i][11] = Number(data[i][10]) * rgf_sum / Number(100);
  1513. }
  1514. if (data[i][1]=='99EXP007'){//回程费占机械费
  1515. data[i][11] = Number(data[i][10]) * jxf_sum / Number(100);
  1516. }
  1517. if (data[i][1]=='31130104'){//回程费占材料费
  1518. data[i][11] = Number(data[i][10]) * clf_sum / Number(100);
  1519. }
  1520. }
  1521. sum = 0;
  1522. rgf_sum = 0;
  1523. jxf_sum = 0;
  1524. clf_sum = 0;
  1525. zcf_sum = 0;
  1526. for(let i = 1; i < data.length; i++) {
  1527. sum += Number(data[i][11]);//11-> hejia
  1528. if (Number(data[i][8]) == 1) {
  1529. rgf_sum += Number(data[i][11]);
  1530. }
  1531. if (Number(data[i][8]) == 2) {
  1532. clf_sum += Number(data[i][11]);
  1533. if (data[i][14] == 'true') {
  1534. zcf_sum += Number(data[i][11]);
  1535. }
  1536. }
  1537. if (Number(data[i][8]) == 3) {
  1538. jxf_sum += Number(data[i][11]);
  1539. }
  1540. }
  1541. let shuliang = Number(qd['数量']);
  1542. for(let i = 0; i< qd["_children"].length; i++) {
  1543. if(qd["_children"][i]['key'] == row) {
  1544. let desl = Number(qd["_children"][i]['数量']);
  1545. let oldname = qd["_children"][i]['清单编码'];
  1546. qd["_children"][i]['辅材费'] = clf_sum - zcf_sum;
  1547. qd["_children"][i]['材料费'] = clf_sum;
  1548. qd["_children"][i]['人工费'] = rgf_sum;
  1549. qd["_children"][i]['主材费'] = zcf_sum;
  1550. qd["_children"][i]['设备费'] = 0;
  1551. qd["_children"][i]['机械费'] = jxf_sum;
  1552. if (oldname.startsWith("D")) {//单项清单
  1553. qd["_children"][i]['管理费'] = 0;
  1554. qd["_children"][i]['利润'] = 0;
  1555. } else {
  1556. if (this.qufeiEntry['备注'].length == 0) {
  1557. //changuiqufei
  1558. qd["_children"][i]['管理费'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1559. qd["_children"][i]['利润'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1560. } else {
  1561. qd["_children"][i]['管理费'] = (rgf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1562. qd["_children"][i]['利润'] = (rgf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1563. }
  1564. }
  1565. qd["_children"][i]['综合单价'] = sum + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
  1566. qd["_children"][i]['合价'] = (qd["_children"][i]['综合单价'] * shuliang * desl);
  1567. qd["_children"][i]["dercj"] = copy(data);
  1568. qd["_children"][i]['清单编码'] = renameDingE(oldname, xuhao, huan);
  1569. }
  1570. }
  1571. }
  1572. updateDercj_(row, data, xuhao, yuban, rcjbc) {///change 一条定额 inplace, 汇总一条定额的rcj, xuhao is for rename, yuban is 预拌砂浆
  1573. console.log("data updated");
  1574. //处理附注
  1575. let huan = false;//换
  1576. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1577. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1578. if (de.hasOwnProperty("rcjdg")) {//新数据
  1579. for (let i = 1; i < de['rcjdg'].length; i++) {
  1580. de['rcjdg'][i][5] = data[i][5];//更新单价,底稿的单价不是很需要同步(在人才机汇总修改价格)
  1581. /****ToDo 更新其他字段 */
  1582. if (de['rcjdg'][i][2] == data[i][2]) {//更新名称
  1583. } else {
  1584. huan = true;
  1585. }
  1586. }
  1587. if (de['fuzhuEnable'] && de.hasOwnProperty('fuzhu')) {//没强行改过含量
  1588. for(let j = 1; j < de['rcjdg'].length; j++) {
  1589. let origin = Number(de['rcjdg'][j][10]);
  1590. for(let i = 0; i < de['fuzhu'].length; i++) {
  1591. let selected = de['fuzhu'][i];
  1592. let target = selected[0];
  1593. if (match_target(de['rcjdg'][j][1], target)) {
  1594. if (selected[2] == '系数') {
  1595. origin = origin * Number(selected[3]);
  1596. } else if (selected[2] == '含量') {
  1597. origin = Number(selected[3]);
  1598. } else if (selected[2] == '调整') {
  1599. origin = origin + Number(selected[3]);
  1600. } else {
  1601. throw new Error('无法处理的附注'.concat(selected[2]));
  1602. }
  1603. }
  1604. }
  1605. de['dercj'][j][2] = data[j][2];//名称
  1606. de['dercj'][j][1] = data[j][1];//编号
  1607. de['dercj'][j][5] = de['rcjdg'][j][5];//单价
  1608. de['dercj'][j][10] = origin;
  1609. de['dercj'][j][11] = Number(de['dercj'][j][5]) * origin;
  1610. }
  1611. } else if (de['fuzhuEnable'] && !de.hasOwnProperty('fuzhu')) {
  1612. for(let j = 1; j < de['rcjdg'].length; j++) {
  1613. let origin = Number(de['rcjdg'][j][10]);
  1614. de['dercj'][j][2] = data[j][2];//名称
  1615. de['dercj'][j][1] = data[j][1];//编号
  1616. de['dercj'][j][5] = de['rcjdg'][j][5];
  1617. de['dercj'][j][10] = origin;
  1618. de['dercj'][j][11] = Number(de['dercj'][j][5]) * origin;
  1619. }
  1620. }
  1621. else {
  1622. //强行改含量
  1623. de['dercj'] = copy(data);
  1624. }
  1625. data = de['dercj'];
  1626. if (de['fuzhuEnable']) {
  1627. data = data.filter(x=>x[1] != 'S00001' && x[1] != 'JD0001');
  1628. for (let i = 1; i < data.length; i++) {
  1629. if (data[i][2].includes('(湿拌砂浆)')) {
  1630. let index = data[i][2].indexOf("(湿拌砂浆)");
  1631. data[i][2] = data[i][2].substring(0, index);
  1632. }
  1633. if (data[i][2].includes('(干拌(混)砂浆)')) {
  1634. let index = data[i][2].indexOf("(干拌(混)砂浆)");
  1635. data[i][2] = data[i][2].substring(0, index);
  1636. }
  1637. }
  1638. de['dercj'] = copy(data);
  1639. }
  1640. } else {////单项定额没有底稿,老数据没底搞,无法判断换部换,暂时统一认为不换
  1641. //强行改含量
  1642. de['dercj'] = copy(data);
  1643. data = de['dercj'];
  1644. }
  1645. if (de.hasOwnProperty("rcjdg") && de['fuzhuEnable'] && yuban.length > 0) {//没强行改过含量
  1646. if (yuban.includes('1')) {
  1647. for(let i = 1; i < data.length; i++) {
  1648. if (data[i][4]=='工日') {
  1649. data[i][10] = Number(data[i][10]) - 0.45;
  1650. }
  1651. if (data[i][2].includes('搅拌机')) {
  1652. data[i][10] = 0;
  1653. }
  1654. if (data[i][2].includes('砂浆') && !data[i][2].includes('搅拌机')) {
  1655. data[i][2] = data[i][2].concat('(湿拌砂浆)')
  1656. }
  1657. }
  1658. } else if (yuban.includes('2')) {
  1659. let origin = 0;
  1660. for(let i = 1; i < data.length; i++) {
  1661. if (data[i][4]=='工日') {
  1662. data[i][10] = Number(data[i][10]) - 0.3;
  1663. }
  1664. if (data[i][2].includes('搅拌机')) {
  1665. data[i][10] = 0;
  1666. }
  1667. if (data[i][2].includes('砂浆') && !data[i][2].includes('搅拌机')) {
  1668. data[i][2] = data[i][2].concat('(干拌(混)砂浆)');
  1669. origin = Number(data[i][10]);
  1670. data[i][10] = origin * 1.75;
  1671. }
  1672. }
  1673. data.push(['', 'S00001', '水', '', 't', '4.70', '', '', '2', 'false', (origin * 0.29).toString(), '', '','','','']);
  1674. data.push(['', 'JD0001', '其他机械费(电)', '', '度', '0.65', '', '', '3', 'false', (origin * 2.15).toString(), '', '','','','']);
  1675. } else if (yuban.includes('3')) {
  1676. let origin = 0;
  1677. for(let i = 1; i < data.length; i++) {
  1678. if (data[i][4]=='工日') {
  1679. data[i][10] = Number(data[i][10]) - 0.2;
  1680. }
  1681. if (data[i][2].includes('砂浆') && !data[i][2].includes('搅拌机')) {
  1682. data[i][2] = data[i][2].concat('(干拌(混)砂浆)');
  1683. origin = Number(data[i][10]);
  1684. data[i][10] = origin * 1.75;
  1685. }
  1686. }
  1687. data.push(['', 'S00001', '水', '', 't', '4.70', '', '', '2', 'false', (origin * 0.29).toString(), '', '','','','']);
  1688. }
  1689. de['dercj'] = copy(data);
  1690. }
  1691. de['dercj'] = de['dercj'].filter(x=>x[1] != '410000F')//补充
  1692. for(let i = 0; i < rcjbc.length; i++) {
  1693. de['dercj'].push(['', rcjbc[i]['人材机编码'], rcjbc[i]['名称'], rcjbc[i]['规格型号'], rcjbc[i]['单位'], rcjbc[i]['单价'], rcjbc[i]['产地'], rcjbc[i]['供应厂商'], rcjbc[i]['人材机类别'], rcjbc[i]['甲供标志'], rcjbc[i]['含量'], '', rcjbc[i]['暂估价标志'],rcjbc[i]['主要材料标志'],rcjbc[i]['主材标志'],rcjbc[i]['设备标志']]);
  1694. }
  1695. data = copy(de['dercj']);
  1696. //模拟formula计算每一行的合价
  1697. for(let i = 1; i < data.length; i++) {
  1698. data[i][11] = Number(data[i][10]) * Number(data[i][5]);
  1699. }
  1700. let sum = 0;
  1701. let rgf_sum = 0;
  1702. let jxf_sum = 0;
  1703. let clf_sum = 0;
  1704. let zcf_sum = 0;
  1705. for(let i = 1; i < data.length; i++) {
  1706. if (data[i][1].includes('000FE') && data[i][4] == '%')continue;
  1707. sum += Number(data[i][11]);//11-> hejia
  1708. if (Number(data[i][8]) == 1) {
  1709. rgf_sum += Number(data[i][11]);
  1710. }
  1711. if (Number(data[i][8]) == 2) {
  1712. clf_sum += Number(data[i][11]);
  1713. if (data[i][14] == 'true') {
  1714. zcf_sum += Number(data[i][11]);
  1715. }
  1716. }
  1717. if (Number(data[i][8]) == 3) {
  1718. jxf_sum += Number(data[i][11]);
  1719. }
  1720. }
  1721. console.log("sum=".concat(sum));
  1722. let shuliang = Number(qd['数量']);
  1723. for(let i = 0; i< qd["_children"].length; i++) {
  1724. if(qd["_children"][i]['key'] == row) {
  1725. let desl = Number(qd["_children"][i]['数量']);
  1726. let oldname = qd["_children"][i]['清单编码'];
  1727. qd["_children"][i]['辅材费'] = clf_sum - zcf_sum;
  1728. qd["_children"][i]['材料费'] = clf_sum;
  1729. qd["_children"][i]['人工费'] = rgf_sum;
  1730. qd["_children"][i]['主材费'] = zcf_sum;
  1731. qd["_children"][i]['设备费'] = 0;
  1732. qd["_children"][i]['机械费'] = jxf_sum;
  1733. if (oldname.startsWith("D")) {//单项清单
  1734. qd["_children"][i]['管理费'] = 0;
  1735. qd["_children"][i]['利润'] = 0;
  1736. } else {
  1737. if (this.qufeiEntry['备注'].length == 0) {
  1738. //changuiqufei
  1739. qd["_children"][i]['管理费'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1740. qd["_children"][i]['利润'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1741. } else {
  1742. qd["_children"][i]['管理费'] = (rgf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1743. qd["_children"][i]['利润'] = (rgf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1744. }
  1745. }
  1746. qd["_children"][i]['综合单价'] = sum + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
  1747. qd["_children"][i]['合价'] = (qd["_children"][i]['综合单价'] * shuliang * desl);
  1748. qd["_children"][i]["dercj"] = copy(data);
  1749. qd["_children"][i]['清单编码'] = renameDingE(oldname, xuhao, huan);
  1750. }
  1751. }
  1752. }
  1753. updateDercj(row, data) {
  1754. //是否手动设置含量
  1755. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1756. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1757. this.updateFootprint(qd['key']);
  1758. let bm = de['清单编码'];
  1759. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  1760. let origin = de['dercj'];
  1761. let change = false;
  1762. for(let i = 1; i < data.length; i++) {
  1763. let before = origin[i][10];//含量
  1764. let after = data[i][10];
  1765. if (Number(before) - Number(after) < 0.0001 && Number(before) - Number(after) > -0.0001) {
  1766. //no change
  1767. } else {
  1768. change = true;
  1769. break;
  1770. }
  1771. }
  1772. if (change) {
  1773. de['fuzhuEnable'] = false;
  1774. }
  1775. this.updateDercj_(row, data, alreadyFuzhu, de['yuban'], de['rcjbc']);
  1776. //let qd = this.cache.filter(x=>x["children"].filter(y=>y['key']==row).length > 0)[0];
  1777. let newData = this.cache.map(x=>{
  1778. if (x['key'] == qd['key']) {
  1779. return qd;
  1780. } else {
  1781. return x;
  1782. }
  1783. });
  1784. let summarized = this.summarize(newData);
  1785. this.push_op(summarized);
  1786. /////////////////
  1787. this.cache = copy(summarized);
  1788. return copy(this.cache);
  1789. }
  1790. updateDercj_djcs(row, data) {
  1791. //是否手动设置含量
  1792. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1793. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1794. let bm = de['清单编码'];
  1795. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  1796. let origin = de['dercj'];
  1797. let change = false;
  1798. for(let i = 1; i < data.length; i++) {
  1799. let before = origin[i][10];
  1800. let after = data[i][10];
  1801. if (Number(before) - Number(after) < 0.0001 && Number(before) - Number(after) > -0.0001) {
  1802. //no change
  1803. } else {
  1804. change = true;
  1805. break;
  1806. }
  1807. }
  1808. if (change) {
  1809. de['fuzhuEnable'] = false;
  1810. }
  1811. this.updateDercj_djcs_(row, data, alreadyFuzhu);
  1812. //let qd = this.cache.filter(x=>x["children"].filter(y=>y['key']==row).length > 0)[0];
  1813. let newData = this.cache_djcs.map(x=>{
  1814. if (x['key'] == qd['key']) {
  1815. return qd;
  1816. } else {
  1817. return x;
  1818. }
  1819. });
  1820. let summarized = this.summarize_djcs(newData);
  1821. this.push_op_djcs(summarized);
  1822. /////////////////
  1823. this.cache_djcs = copy(summarized);
  1824. return copy(this.cache_djcs);
  1825. }
  1826. updateBeizhu(row, selected, xuhao) {//xuhao is for rename
  1827. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1828. if (!qd) return [null, null];
  1829. this.updateFootprint(qd['key']);
  1830. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1831. if (de.hasOwnProperty("rcjdg")) {//底稿
  1832. } else {///老数据不能有底稿,附注功能也不使能
  1833. //de['rcjdg'] = copy(de['dercj']);
  1834. }
  1835. de['fuzhu'] = copy(selected);
  1836. this.updateDercj_(row, de['dercj'], xuhao, de['yuban'], de['rcjbc']);
  1837. let newData = this.cache.map(x=>{
  1838. if (x['key'] == qd['key']) {
  1839. return qd;
  1840. } else {
  1841. return x;
  1842. }
  1843. });
  1844. let summarized = this.summarize(newData);
  1845. this.push_op(summarized);
  1846. /////////////////
  1847. this.cache = copy(summarized);
  1848. return [copy(this.cache), copy(de['dercj'])];
  1849. }
  1850. updateBeizhu_djcs(row, selected, xuhao) {//xuhao is for rename
  1851. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1852. if (!qd) return [null, null];
  1853. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1854. if (de.hasOwnProperty("rcjdg")) {//底稿
  1855. } else {///老数据不能有底稿,附注功能也不使能
  1856. //de['rcjdg'] = copy(de['dercj']);
  1857. }
  1858. de['fuzhu'] = copy(selected);
  1859. this.updateDercj_djcs_(row, de['dercj'], xuhao);
  1860. let newData = this.cache_djcs.map(x=>{
  1861. if (x['key'] == qd['key']) {
  1862. return qd;
  1863. } else {
  1864. return x;
  1865. }
  1866. });
  1867. let summarized = this.summarize_djcs(newData);
  1868. this.push_op_djcs(summarized);
  1869. /////////////////
  1870. this.cache_djcs = copy(summarized);
  1871. return [copy(this.cache_djcs), copy(de['dercj'])];
  1872. }
  1873. huan(old_index, new_bianhao, new_name, new_jia, row) {
  1874. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1875. this.updateFootprint(qd['key']);
  1876. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1877. let rcj = copy(de['dercj']);
  1878. rcj[old_index][1] = new_bianhao;
  1879. rcj[old_index][2] = new_name;
  1880. rcj[old_index][5] = new_jia;
  1881. return this.updateDercj(row, rcj);
  1882. }
  1883. updateShuliang(value, row) {
  1884. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1885. this.updateFootprint(qd['key']);
  1886. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1887. let origin = de['数量']
  1888. if (Number(origin) - Number(value) < 0.0001 && Number(origin) - Number(value) > -0.0001) {
  1889. return [false, null];
  1890. }
  1891. console.log("shuliang update");
  1892. de['数量'] = value;
  1893. de['合价'] = Number(qd['数量']) * Number(de['综合单价']) * Number(de['数量']);
  1894. let newData = this.cache.map(x=>{
  1895. if (x['key'] == qd['key']) {
  1896. return qd;
  1897. } else {
  1898. return x;
  1899. }
  1900. });
  1901. let summarized = this.summarize(newData);
  1902. this.push_op(summarized);
  1903. /////////////////
  1904. this.cache = copy(summarized);
  1905. return [true, copy(this.cache)];
  1906. }
  1907. updateDeMingcheng(value, row) {
  1908. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1909. this.updateFootprint(qd['key']);
  1910. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1911. de['名称'] = value;
  1912. let newData = this.cache.map(x=>{
  1913. if (x['key'] == qd['key']) {
  1914. return qd;
  1915. } else {
  1916. return x;
  1917. }
  1918. });
  1919. let summarized = this.summarize(newData);
  1920. this.push_op(summarized);
  1921. /////////////////
  1922. this.cache = copy(summarized);
  1923. return copy(this.cache);
  1924. }
  1925. updateShuliang_djcs(value, row) {
  1926. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1927. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1928. let origin = de['数量']
  1929. if (Number(origin) - Number(value) < 0.0001 && Number(origin) - Number(value) > -0.0001) {
  1930. return [false, null];
  1931. }
  1932. console.log("shuliang update");
  1933. de['数量'] = value;
  1934. de['合价'] = Number(qd['数量']) * Number(de['综合单价']) * Number(de['数量']);
  1935. let newData = this.cache_djcs.map(x=>{
  1936. if (x['key'] == qd['key']) {
  1937. return qd;
  1938. } else {
  1939. return x;
  1940. }
  1941. });
  1942. let summarized = this.summarize_djcs(newData);
  1943. this.push_op_djcs(summarized);
  1944. /////////////////
  1945. this.cache_djcs = copy(summarized);
  1946. return [true, copy(this.cache_djcs)];
  1947. }
  1948. changguidinge_djcs(dingeclick, row) {
  1949. if (this.cache_djcs.filter(x=>x['key'] == row).length > 0) {
  1950. let res =dingeclick;
  1951. let keys = Object.keys(res['DEBH']);
  1952. let key = keys[0];
  1953. //console.log(res);
  1954. let qd = this.cache_djcs.filter(x=>x['key'] == row)[0];
  1955. let dercj = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1956. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
  1957. for(let i = 0; i < res['rgde'].length; i++) {
  1958. dercj.push(['', res['rgde'][i]['CLBH'], res['rgde'][i]['CLMC'], '', res['rgde'][i]['JLDW'],
  1959. res['rgde'][i]['YSJG'], '', '', '1', '', res['rgde'][i]['gr'], res['rgde'][i]['gf'],
  1960. '', '', '', '' ]);
  1961. }
  1962. for(let i = 0; i < res['clde'].length; i++) {
  1963. dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  1964. res['clde'][i]['YSJG'], '', '', '2', '', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  1965. '', '', '', '' ]);
  1966. }
  1967. for(let i = 0; i < res['jxde'].length; i++) {
  1968. dercj.push(['', res['jxde'][i]['jxbh'], res['jxde'][i]['jxmc'], '', res['jxde'][i]['DW'],
  1969. res['jxde'][i]['tbdj'], '', '', '3', '', res['jxde'][i]['sl'], res['jxde'][i]['hj'],
  1970. '', '', '', '' ]);
  1971. }
  1972. let newKey = uuidv4();
  1973. qd["_children"].push({
  1974. '操作': '',
  1975. '序号': null,
  1976. '清单编码': res['DEBH'][key],
  1977. '名称': res['GCLMC'][key],
  1978. '项目特征': null,
  1979. '计算规则': null,
  1980. '单位': res['DW'][key],
  1981. '数量': '1',
  1982. '综合单价': '0',
  1983. '合价': '0',
  1984. '人工费': '0',
  1985. '主材费': '0',
  1986. '设备费': '0',
  1987. '辅材费': '0',
  1988. '材料费': '0',
  1989. '机械费': '0',
  1990. '管理费': '0',
  1991. '利润': '0',
  1992. '暂估价': null,
  1993. '综合人工工日': null,
  1994. '备注': null,
  1995. "dercj": dercj,
  1996. 'rcjdg': copy(dercj),
  1997. 'key' : newKey,
  1998. "fuzhuEnable": true
  1999. });
  2000. this.updateDercj_djcs_(newKey, dercj, []);
  2001. let summarized = this.summarize_djcs(this.cache_djcs);
  2002. this.push_op_djcs(copy(summarized));
  2003. /////////////////
  2004. this.cache_djcs = copy(summarized);
  2005. //return copy(this.cache);
  2006. return [true, copy(this.cache_djcs), newKey];
  2007. } else {
  2008. return [false, null, null];
  2009. }
  2010. }
  2011. changguidinge(dingeclick, row) {
  2012. if (this.cache.filter(x=>x['key'] == row).length > 0) {
  2013. this.updateFootprint(row);
  2014. let res = copy(dingeclick);
  2015. let keys = Object.keys(res['DEBH']);
  2016. let key = keys[0];
  2017. let tips = azfy(res['DEBH'][key], res['GCLMC'][key]);
  2018. if (tips != null) {
  2019. res['rgde'] = tips['rgde'];
  2020. res['clde'] = tips['clde'];
  2021. res['jxde'] = tips['jxde'];
  2022. }
  2023. let qd = this.cache.filter(x=>x['key'] == row)[0];
  2024. let dercj = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  2025. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
  2026. for(let i = 0; i < res['rgde'].length; i++) {
  2027. dercj.push(['', res['rgde'][i]['CLBH'], res['rgde'][i]['CLMC'], '', res['rgde'][i]['JLDW'],
  2028. res['rgde'][i]['YSJG'], '', '', '1', '', res['rgde'][i]['gr'], res['rgde'][i]['gf'],
  2029. '', '', '', '' ]);
  2030. }
  2031. for(let i = 0; i < res['clde'].length; i++) {
  2032. dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  2033. res['clde'][i]['YSJG'], '', '', '2', '', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  2034. '', '', '', '' ]);
  2035. }
  2036. for(let i = 0; i < res['jxde'].length; i++) {
  2037. dercj.push(['', res['jxde'][i]['jxbh'], res['jxde'][i]['jxmc'], '', res['jxde'][i]['DW'],
  2038. res['jxde'][i]['tbdj'], '', '', '3', '', res['jxde'][i]['sl'], res['jxde'][i]['hj'],
  2039. '', '', '', '' ]);
  2040. }
  2041. let newKey = uuidv4();
  2042. qd["_children"].push({
  2043. '操作': '',
  2044. '序号': null,
  2045. '清单编码': res['DEBH'][key],
  2046. '名称': res['GCLMC'][key],
  2047. '项目特征': null,
  2048. '计算规则': tips != null ? tips['sm'] : '',
  2049. '单位': res['DW'][key],
  2050. '数量': '1',
  2051. '综合单价': '0',
  2052. '合价': '0',
  2053. '人工费': '0',
  2054. '主材费': '0',
  2055. '设备费': '0',
  2056. '辅材费': '0',
  2057. '材料费': '0',
  2058. '机械费': '0',
  2059. '管理费': '0',
  2060. '利润': '0',
  2061. '暂估价': null,
  2062. '综合人工工日': null,
  2063. '备注': null,
  2064. "dercj": dercj,
  2065. 'rcjdg': copy(dercj),
  2066. 'key' : newKey,
  2067. "fuzhuEnable": true,
  2068. 'yuban': [],
  2069. 'rcjbc': [],
  2070. 'azfytag': tips != null ? tips['azfytag'] : []
  2071. });
  2072. this.updateDercj_(newKey, dercj, [], [], []);
  2073. let summarized = this.summarize(this.cache);
  2074. this.push_op(copy(summarized));
  2075. /////////////////
  2076. this.cache = copy(summarized);
  2077. //return copy(this.cache);
  2078. return [true, copy(this.cache), newKey];
  2079. } else {
  2080. return [false, null, null];
  2081. }
  2082. }
  2083. danxiangdinge(row) {
  2084. let bh = danxiangdinge_index(this.cache);
  2085. if (this.cache.filter(x=>x['key'] == row).length > 0) {
  2086. this.updateFootprint(row);
  2087. let selected = this.cache.filter(x=>x['key'] == row)[0];
  2088. let danwei = selected["单位"];
  2089. let mingcheng = selected['名称'];
  2090. let children = selected["_children"];
  2091. children.push({
  2092. '操作': '',
  2093. '序号': null,
  2094. '清单编码': bh,
  2095. '名称': mingcheng,
  2096. '项目特征': null,
  2097. '计算规则': null,
  2098. '单位': danwei,
  2099. '数量': '1',
  2100. '综合单价': '',
  2101. '合价': '',
  2102. '人工费': '0',
  2103. '主材费': '0',
  2104. '设备费': '0',
  2105. '辅材费': '',
  2106. '材料费': '',
  2107. '机械费': '0',
  2108. '管理费': '0',
  2109. '利润': '0',
  2110. '暂估价': null,
  2111. '综合人工工日': null,
  2112. '备注': null,
  2113. "dercj": [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  2114. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ],
  2115. ['', bh, mingcheng, '', danwei, '', '', '', '2', '', '1', '', '', '', '', '' ]
  2116. ],
  2117. 'key' : uuidv4(),
  2118. "fuzhuEnable": false,
  2119. 'yuban': [],
  2120. 'rcjbc' : [],
  2121. 'azfytag': []
  2122. });
  2123. let summarized = this.summarize(this.cache);
  2124. this.push_op(summarized);
  2125. this.cache = copy(summarized);
  2126. return [true, copy(this.cache)];
  2127. } else {
  2128. return [false,null];
  2129. }
  2130. }
  2131. danxiangdinge_djcs(row) {
  2132. let bh = danxiangdinge_index_djcs(this.cache_djcs);
  2133. if (this.cache_djcs.filter(x=>x['key'] == row).length > 0) {
  2134. let selected = this.cache_djcs.filter(x=>x['key'] == row)[0];
  2135. let danwei = selected["单位"];
  2136. let mingcheng = selected['名称'];
  2137. let children = selected["_children"];
  2138. children.push({
  2139. '序号': null,
  2140. '清单编码': bh,
  2141. '名称': mingcheng,
  2142. '项目特征': null,
  2143. '计算规则': null,
  2144. '单位': danwei,
  2145. '数量': '1',
  2146. '综合单价': '',
  2147. '合价': '',
  2148. '人工费': '0',
  2149. '主材费': '0',
  2150. '设备费': '0',
  2151. '辅材费': '',
  2152. '材料费': '',
  2153. '机械费': '0',
  2154. '管理费': '0',
  2155. '利润': '0',
  2156. '暂估价': null,
  2157. '综合人工工日': null,
  2158. '备注': null,
  2159. "dercj": [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  2160. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ],
  2161. ['', bh, mingcheng, '', danwei, '', '', '', '2', '', '1', '', '', '', '', '' ]
  2162. ],
  2163. 'key' : uuidv4(),
  2164. "fuzhuEnable": false
  2165. });
  2166. let summarized = this.summarize_djcs(this.cache_djcs);
  2167. this.push_op_djcs(summarized);
  2168. this.cache_djcs = copy(summarized);
  2169. return [true, copy(this.cache_djcs)];
  2170. } else {
  2171. return [false,null];
  2172. }
  2173. }
  2174. handleYuban(row, selected) {
  2175. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  2176. if (!qd) return [null, null];
  2177. this.updateFootprint(qd['key']);
  2178. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  2179. let bm = de['清单编码'];
  2180. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  2181. if (de.hasOwnProperty("rcjdg")) {//底稿
  2182. } else {///老数据不能有底稿,附注功能也不使能,预拌也不能使
  2183. //de['rcjdg'] = copy(de['dercj']);
  2184. }
  2185. de['yuban'] = copy(selected);
  2186. this.updateDercj_(row, de['dercj'], alreadyFuzhu, selected, de['rcjbc']);
  2187. let newData = this.cache.map(x=>{
  2188. if (x['key'] == qd['key']) {
  2189. return qd;
  2190. } else {
  2191. return x;
  2192. }
  2193. });
  2194. let summarized = this.summarize(newData);
  2195. this.push_op(summarized);
  2196. /////////////////
  2197. this.cache = copy(summarized);
  2198. return [copy(this.cache), copy(de['dercj'])];
  2199. }
  2200. handleRcjbc(row, rcjbc) {
  2201. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  2202. if (!qd) return [null, null];
  2203. this.updateFootprint(qd['key']);
  2204. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  2205. let bm = de['清单编码'];
  2206. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  2207. if (de.hasOwnProperty("rcjdg")) {//底稿
  2208. } else {///老数据不能有底稿,附注功能也不使能,预拌也不能使
  2209. //de['rcjdg'] = copy(de['dercj']);
  2210. }
  2211. de['rcjbc'] = copy(rcjbc);
  2212. this.updateDercj_(row, de['dercj'], alreadyFuzhu, de['yuban'], rcjbc);
  2213. let newData = this.cache.map(x=>{
  2214. if (x['key'] == qd['key']) {
  2215. return qd;
  2216. } else {
  2217. return x;
  2218. }
  2219. });
  2220. let summarized = this.summarize(newData);
  2221. this.push_op(summarized);
  2222. /////////////////
  2223. this.cache = copy(summarized);
  2224. return [copy(this.cache), copy(de['dercj'])];
  2225. }
  2226. }
  2227. export default new Service();