Service.js 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532
  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. let left = [];
  1057. for(let i = 0; i < qd["_children"].length; i++) {
  1058. let de = qd["_children"][i];
  1059. let desl = Number(de['数量']);
  1060. let dercj = de['dercj'];
  1061. for (let j = 1; j < dercj.length; j++) {
  1062. let hl = copy(dercj[j]);
  1063. if (hl[1] == '00EXP001' && hl[4] == '%') {
  1064. left.push(hl);
  1065. continue;
  1066. }
  1067. if (hl[1] == '99EXP007' && hl[4] == '%') {
  1068. left.push(hl);
  1069. continue;
  1070. }
  1071. if (hl[1] == '31130104' && hl[4] == '%') {
  1072. left.push(hl);
  1073. continue;
  1074. }
  1075. hl[10] = desl * Number(hl[10]);
  1076. hl[11] = desl * Number(hl[11]);
  1077. let a = hl[1];//"人材机编码",
  1078. let b = a.concat(hl[2]);//"名称",
  1079. let c = b.concat(hl[4]);// "单位"
  1080. if (dict.hasOwnProperty(c)) {
  1081. dict[c].push(hl);
  1082. } else {
  1083. dict[c] = [hl];
  1084. }
  1085. }
  1086. }
  1087. let result = [];
  1088. for(const key in dict) {
  1089. let list = dict[key];
  1090. let sum = 0;
  1091. let danjia = Number(list[0][5]);
  1092. for (let i =0 ;i < list.length; i++) {
  1093. sum += Number(list[i][10]);
  1094. }
  1095. let entry = [list[0][0], list[0][1], list[0][2], list[0][3], list[0][4], danjia,
  1096. list[0][6], list[0][7], list[0][8], list[0][9], sum, sum * danjia, list[0][12],
  1097. list[0][13], list[0][14], list[0][15]
  1098. ];
  1099. result.push(entry);
  1100. }
  1101. for (let i = 0; i < left.length; i++) {
  1102. result.push(left[i]);
  1103. }
  1104. let gongri = 0;
  1105. for(let i = 0; i < result.length; i++) {
  1106. if (result[i][4] == '工日') {
  1107. gongri += result[i][10];
  1108. }
  1109. }
  1110. result.sort((a, b) => Number(a[8]) - Number(b[8]));
  1111. qd['rcj'] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1112. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]].concat(result);
  1113. qd["综合人工工日"] = gongri;
  1114. qd['综合单价'] = 0;
  1115. qd['合价'] = 0;
  1116. qd['人工费'] = 0;
  1117. qd['主材费'] = 0;
  1118. qd['设备费'] = 0;
  1119. qd['辅材费'] = 0;
  1120. qd['材料费'] = 0;
  1121. qd['机械费'] = 0;
  1122. qd['管理费'] = 0;
  1123. qd['利润'] = 0;
  1124. for(let i = 0; i < qd["_children"].length; i++) {
  1125. qd['综合单价'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['综合单价']);
  1126. qd['合价'] += Number(qd['_children'][i]['合价']);
  1127. qd['人工费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['人工费']);
  1128. qd['主材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['主材费']);
  1129. qd['设备费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['设备费']);
  1130. qd['辅材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['辅材费']);
  1131. qd['材料费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['材料费']);
  1132. qd['机械费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['机械费']);
  1133. qd['管理费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['管理费']);
  1134. qd['利润'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['利润']);
  1135. }
  1136. return qd;
  1137. }
  1138. summarize_one(qd) {///根据定额汇总清单
  1139. qd['综合单价'] = 0;
  1140. qd['合价'] = 0;
  1141. qd['人工费'] = 0;
  1142. qd['主材费'] = 0;
  1143. qd['设备费'] = 0;
  1144. qd['辅材费'] = 0;
  1145. qd['材料费'] = 0;
  1146. qd['机械费'] = 0;
  1147. qd['管理费'] = 0;
  1148. qd['利润'] = 0;
  1149. for(let i = 0; i < qd["_children"].length; i++) {
  1150. if (qd["_children"][i]['azfytag'].length > 0)continue;
  1151. qd['综合单价'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['综合单价']);
  1152. qd['合价'] += Number(qd['_children'][i]['合价']);
  1153. qd['人工费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['人工费']);
  1154. qd['主材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['主材费']);
  1155. qd['设备费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['设备费']);
  1156. qd['辅材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['辅材费']);
  1157. qd['材料费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['材料费']);
  1158. qd['机械费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['机械费']);
  1159. qd['管理费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['管理费']);
  1160. qd['利润'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['利润']);
  1161. }
  1162. //处理安装费用
  1163. console.log(qd["_children"].length);
  1164. for(let i = 0; i < qd["_children"].length; i++) {
  1165. console.log(i);
  1166. if (qd["_children"][i]['azfytag'].length > 0){
  1167. let tag = qd["_children"][i]['azfytag'];
  1168. if (tag[0] == '人工费') {
  1169. let current_rgf = qd['人工费'];
  1170. let added = Number(current_rgf) * Number(tag[1]) / Number(100);
  1171. let added_rgf = added * Number(tag[2]) / Number(100);
  1172. let added_clf = added * Number(tag[3]) / Number(100);
  1173. let added_jxf = added * Number(tag[4]) / Number(100);
  1174. qd["_children"][i]['人工费'] = added_rgf;
  1175. qd["_children"][i]['辅材费'] = added_clf;
  1176. qd["_children"][i]['材料费'] = added_clf;
  1177. qd["_children"][i]['机械费'] = added_jxf;
  1178. if (this.qufeiEntry['备注'].length == 0) {
  1179. //changuiqufei
  1180. qd["_children"][i]['管理费'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1181. qd["_children"][i]['利润'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1182. } else {
  1183. qd["_children"][i]['管理费'] = (added_rgf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1184. qd["_children"][i]['利润'] = (added_rgf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1185. }
  1186. qd["_children"][i]['综合单价'] = qd["_children"][i]['人工费'] + qd["_children"][i]['材料费'] + qd["_children"][i]['机械费'] + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
  1187. qd["_children"][i]['合价'] = qd["_children"][i]['综合单价'] * Number(qd["_children"][i]['数量']) * Number(qd['数量']);
  1188. let dercj = qd["_children"][i]['dercj'];
  1189. for (let j = 1; j < dercj.length; j++) {
  1190. dercj[j][11] = Number(qd['_children'][i]['综合单价']) * Number(dercj[j][10]) / Number(100);
  1191. }
  1192. }
  1193. if (tag[0] == '人工费+机械费') {
  1194. let current_rgf = qd['人工费'] + qd['机械费'];
  1195. let added = Number(current_rgf) * Number(tag[1]) / Number(100);
  1196. let added_rgf = added * Number(tag[2]) / Number(100);
  1197. let added_clf = added * Number(tag[3]) / Number(100);
  1198. let added_jxf = added * Number(tag[4]) / Number(100);
  1199. qd["_children"][i]['人工费'] = added_rgf;
  1200. qd["_children"][i]['辅材费'] = added_clf;
  1201. qd["_children"][i]['材料费'] = added_clf;
  1202. qd["_children"][i]['机械费'] = added_jxf;
  1203. if (this.qufeiEntry['备注'].length == 0) {
  1204. //changuiqufei
  1205. qd["_children"][i]['管理费'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1206. qd["_children"][i]['利润'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1207. } else {
  1208. qd["_children"][i]['管理费'] = (added_rgf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1209. qd["_children"][i]['利润'] = (added_rgf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1210. }
  1211. qd["_children"][i]['综合单价'] = qd["_children"][i]['人工费'] + qd["_children"][i]['材料费'] + qd["_children"][i]['机械费'] + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
  1212. qd["_children"][i]['合价'] = qd["_children"][i]['综合单价'] * Number(qd["_children"][i]['数量']) * Number(qd["数量"]);
  1213. let dercj = qd["_children"][i]['dercj'];
  1214. for (let j = 1; j < dercj.length; j++) {
  1215. dercj[j][11] = Number(qd['_children'][i]['综合单价']) * Number(dercj[j][10]) / Number(100);
  1216. }
  1217. }
  1218. }
  1219. }
  1220. qd['综合单价'] = 0;
  1221. qd['合价'] = 0;
  1222. qd['人工费'] = 0;
  1223. qd['主材费'] = 0;
  1224. qd['设备费'] = 0;
  1225. qd['辅材费'] = 0;
  1226. qd['材料费'] = 0;
  1227. qd['机械费'] = 0;
  1228. qd['管理费'] = 0;
  1229. qd['利润'] = 0;
  1230. for(let i = 0; i < qd["_children"].length; i++) {
  1231. qd['综合单价'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['综合单价']);
  1232. qd['合价'] += Number(qd['_children'][i]['合价']);
  1233. qd['人工费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['人工费']);
  1234. qd['主材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['主材费']);
  1235. qd['设备费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['设备费']);
  1236. qd['辅材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['辅材费']);
  1237. qd['材料费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['材料费']);
  1238. qd['机械费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['机械费']);
  1239. qd['管理费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['管理费']);
  1240. qd['利润'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['利润']);
  1241. }
  1242. let dict = {};
  1243. let left = [];
  1244. for(let i = 0; i < qd["_children"].length; i++) {
  1245. let de = qd["_children"][i];
  1246. let desl = Number(de['数量']);
  1247. let dercj = de['dercj'];
  1248. for (let j = 1; j < dercj.length; j++) {
  1249. let hl = copy(dercj[j]);
  1250. if (hl[1].includes('000FE') && hl[4] == '%') {
  1251. left.push(hl);
  1252. continue;
  1253. }
  1254. hl[10] = desl * Number(hl[10]);
  1255. hl[11] = desl * Number(hl[11]);
  1256. let a = hl[1];//"人材机编码",
  1257. let b = a.concat(hl[2]);//"名称",
  1258. let c = b.concat(hl[4]);// "单位"
  1259. if (dict.hasOwnProperty(c)) {
  1260. dict[c].push(hl);
  1261. } else {
  1262. dict[c] = [hl];
  1263. }
  1264. }
  1265. }
  1266. let result = [];
  1267. for(const key in dict) {
  1268. let list = dict[key];
  1269. let sum = 0;
  1270. let danjia = Number(list[0][5]);
  1271. for (let i =0 ;i < list.length; i++) {
  1272. sum += Number(list[i][10]);
  1273. }
  1274. let entry = [list[0][0], list[0][1], list[0][2], list[0][3], list[0][4], danjia,
  1275. list[0][6], list[0][7], list[0][8], list[0][9], sum, sum * danjia, list[0][12],
  1276. list[0][13], list[0][14], list[0][15]
  1277. ];
  1278. result.push(entry);
  1279. }
  1280. for (let i = 0; i < left.length; i++) {
  1281. result.push(left[i]);
  1282. }
  1283. let gongri = 0;
  1284. for(let i = 0; i < result.length; i++) {
  1285. if (result[i][4] == '工日') {
  1286. gongri += result[i][10];
  1287. }
  1288. }
  1289. result.sort((a, b) => Number(a[8]) - Number(b[8]));
  1290. qd['rcj'] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1291. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]].concat(result);
  1292. qd["综合人工工日"] = gongri;
  1293. return qd;
  1294. }
  1295. summarize(data) {
  1296. return data.map(x=>this.summarize_one(x));
  1297. }
  1298. summarize_djcs(data) {
  1299. return data.map(x=>this.summarize_one_djcs(x));
  1300. }
  1301. push_op(newData) {
  1302. if(this.memory.length == this.mem_pointer + 1) {
  1303. this.memory.push(copy(newData));
  1304. this.mem_pointer = this.mem_pointer + 1;
  1305. } else{
  1306. this.memory.splice(this.mem_pointer + 1);
  1307. this.memory.push(copy(newData));
  1308. this.mem_pointer = this.mem_pointer + 1;
  1309. }
  1310. }
  1311. push_op_djcs(newData) {
  1312. if(this.memory_djcs.length == this.mem_pointer_djcs + 1) {
  1313. this.memory_djcs.push(copy(newData));
  1314. this.mem_pointer_djcs = this.mem_pointer_djcs + 1;
  1315. } else{
  1316. this.memory_djcs.splice(this.mem_pointer_djcs + 1);
  1317. this.memory_djcs.push(copy(newData));
  1318. this.mem_pointer_djcs = this.mem_pointer_djcs + 1;
  1319. }
  1320. }
  1321. undo() {
  1322. if (this.mem_pointer > 0) {
  1323. let newData = this.memory[this.mem_pointer - 1];
  1324. this.mem_pointer = this.mem_pointer - 1;
  1325. this.cache = copy(newData);
  1326. return copy(newData);
  1327. }
  1328. return copy(this.cache);
  1329. }
  1330. undo_djcs() {
  1331. if (this.mem_pointer_djcs > 0) {
  1332. let newData = this.memory_djcs[this.mem_pointer_djcs - 1];
  1333. this.mem_pointer_djcs = this.mem_pointer_djcs - 1;
  1334. this.cache_djcs = copy(newData);
  1335. return copy(newData);
  1336. }
  1337. return copy(this.cache_djcs);
  1338. }
  1339. redo() {
  1340. if (this.mem_pointer + 1 != this.memory.length) {
  1341. let newData = this.memory[this.mem_pointer + 1];
  1342. this.mem_pointer = this.mem_pointer + 1;
  1343. this.cache = copy(newData);
  1344. return copy(newData);
  1345. }
  1346. return copy(this.cache);
  1347. }
  1348. redo_djcs() {
  1349. if (this.mem_pointer_djcs + 1 != this.memory_djcs.length) {
  1350. let newData = this.memory_djcs[this.mem_pointer_djcs + 1];
  1351. this.mem_pointer_djcs = this.mem_pointer_djcs + 1;
  1352. this.cache_djcs = copy(newData);
  1353. return copy(newData);
  1354. }
  1355. return copy(this.cache_djcs);
  1356. }
  1357. shanchu_djcs(key) {
  1358. if (this.cache_djcs.filter(x=>x['key'] == key).length > 0) {
  1359. ///qd
  1360. let newData = this.cache_djcs.map(x=>{
  1361. if (x["key"] == key) {
  1362. let y = copy(x);
  1363. y["_children"] = [];
  1364. return y;
  1365. } else {
  1366. return x;
  1367. }
  1368. });
  1369. let summarized = this.summarize_djcs(newData);
  1370. this.push_op_djcs(summarized);
  1371. /////////////////
  1372. this.cache_djcs = copy(summarized);
  1373. return copy(this.cache_djcs);
  1374. } else {
  1375. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key'] == key).length > 0)[0];
  1376. let qdbm = qd['清单编码'];
  1377. let newData = this.cache_djcs.map(x=>{
  1378. if (x["清单编码"] == qdbm) {
  1379. let y = copy(x);
  1380. let origin = y["_children"];
  1381. let trans = origin.filter(z=>z["key"]!=key);
  1382. y["_children"] = trans;
  1383. return y;
  1384. } else {
  1385. return x;
  1386. }
  1387. });
  1388. let summarized = this.summarize_djcs(newData);
  1389. this.push_op_djcs(summarized);
  1390. /////////////////
  1391. this.cache_djcs = copy(summarized);
  1392. return copy(this.cache_djcs);
  1393. }
  1394. }
  1395. updateFootprint(key) {
  1396. if (this.footprint.includes(key)) {
  1397. } else {
  1398. this.footprint.push(key);
  1399. }
  1400. }
  1401. shanchu(key) {
  1402. if (this.cache.filter(x=>x['key'] == key).length > 0) {
  1403. this.updateFootprint(key);
  1404. ///qd
  1405. let newData = this.cache.map(x=>{
  1406. if (x["key"] == key) {
  1407. let y = copy(x);
  1408. y["_children"] = [];
  1409. return y;
  1410. } else {
  1411. return x;
  1412. }
  1413. });
  1414. let summarized = this.summarize(newData);
  1415. this.push_op(summarized);
  1416. /////////////////
  1417. this.cache = copy(summarized);
  1418. return copy(this.cache);
  1419. } else {
  1420. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key'] == key).length > 0)[0];
  1421. this.updateFootprint(qd['key']);
  1422. let qdbm = qd['清单编码'];
  1423. let newData = this.cache.map(x=>{
  1424. if (x["清单编码"] == qdbm) {
  1425. let y = copy(x);
  1426. let origin = y["_children"];
  1427. let trans = origin.filter(z=>z["key"]!=key);
  1428. y["_children"] = trans;
  1429. return y;
  1430. } else {
  1431. return x;
  1432. }
  1433. });
  1434. let summarized = this.summarize(newData);
  1435. this.push_op(summarized);
  1436. /////////////////
  1437. this.cache = copy(summarized);
  1438. return copy(this.cache);
  1439. }
  1440. }
  1441. updateDercj_djcs_(row, data, xuhao) {///change 一条定额 inplace, 汇总一条定额的rcj, xuhao is for rename
  1442. console.log("data updated");
  1443. //处理附注
  1444. let huan = false;//换
  1445. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1446. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1447. if (de.hasOwnProperty("rcjdg")) {//新数据
  1448. for (let i = 1; i < de['rcjdg'].length; i++) {
  1449. de['rcjdg'][i][5] = data[i][5];//更新单价
  1450. /****ToDo 更新其他字段 */
  1451. if (de['rcjdg'][i][2] == data[i][2]) {//更新名称
  1452. } else {
  1453. huan = true;
  1454. }
  1455. }
  1456. if (de['fuzhuEnable'] && de.hasOwnProperty('fuzhu')) {//没强行改过含量
  1457. for(let j = 1; j < de['rcjdg'].length; j++) {
  1458. let origin = Number(de['rcjdg'][j][10]);
  1459. for(let i = 0; i < de['fuzhu'].length; i++) {
  1460. let selected = de['fuzhu'][i];
  1461. let target = selected[0];
  1462. if (match_target(de['rcjdg'][j][1], target)) {
  1463. if (selected[2] == '系数') {
  1464. origin = origin * Number(selected[3]);
  1465. } else if (selected[2] == '含量') {
  1466. origin = Number(selected[3]);
  1467. } else if (selected[2] == '调整') {
  1468. origin = origin + Number(selected[3]);
  1469. } else {
  1470. throw new Error('无法处理的附注'.concat(selected[2]));
  1471. }
  1472. }
  1473. }
  1474. de['dercj'][j][2] = data[j][2];//名称
  1475. de['dercj'][j][1] = data[j][1];//编号
  1476. de['dercj'][j][5] = de['rcjdg'][j][5];//单价
  1477. de['dercj'][j][10] = origin;
  1478. de['dercj'][j][11] = Number(de['dercj'][j][5]) * origin;
  1479. }
  1480. } else if (de['fuzhuEnable'] && !de.hasOwnProperty('fuzhu')) {
  1481. for(let j = 1; j < de['rcjdg'].length; j++) {
  1482. let origin = Number(de['rcjdg'][j][10]);
  1483. de['dercj'][j][2] = data[j][2];//名称
  1484. de['dercj'][j][1] = data[j][1];//编号
  1485. de['dercj'][j][5] = de['rcjdg'][j][5];
  1486. de['dercj'][j][10] = origin;
  1487. de['dercj'][j][11] = Number(de['dercj'][j][5]) * origin;
  1488. }
  1489. }
  1490. else {
  1491. //强行改含量
  1492. de['dercj'] = copy(data);
  1493. }
  1494. data = de['dercj'];
  1495. } else {////单项定额没有底稿,老数据没底搞,无法判断换部换,暂时统一认为不换
  1496. //强行改含量
  1497. de['dercj'] = copy(data);
  1498. data = de['dercj'];
  1499. }
  1500. //模拟formula计算每一行的合价
  1501. for(let i = 1; i < data.length; i++) {
  1502. data[i][11] = Number(data[i][10]) * Number(data[i][5]);
  1503. }
  1504. let sum = 0;
  1505. let rgf_sum = 0;
  1506. let jxf_sum = 0;
  1507. let clf_sum = 0;
  1508. let zcf_sum = 0;
  1509. for(let i = 1; i < data.length; i++) {
  1510. sum += Number(data[i][11]);//11-> hejia
  1511. if (Number(data[i][8]) == 1) {
  1512. rgf_sum += Number(data[i][11]);
  1513. }
  1514. if (Number(data[i][8]) == 2) {
  1515. clf_sum += Number(data[i][11]);
  1516. if (data[i][14] == 'true') {
  1517. zcf_sum += Number(data[i][11]);
  1518. }
  1519. }
  1520. if (Number(data[i][8]) == 3) {
  1521. jxf_sum += Number(data[i][11]);
  1522. }
  1523. }
  1524. console.log("sum=".concat(sum));
  1525. //处理百分比费用
  1526. for(let i = 1; i < data.length; i++) {
  1527. if (data[i][1]=='00EXP001' && data[i][4] == '%'){//回程费占人工费
  1528. data[i][11] = Number(data[i][10]) * rgf_sum / Number(100);
  1529. }
  1530. if (data[i][1]=='99EXP007' && data[i][4] == '%'){//回程费占机械费
  1531. data[i][11] = Number(data[i][10]) * jxf_sum / Number(100);
  1532. }
  1533. if (data[i][1]=='31130104' && data[i][4] == '%'){//回程费占材料费
  1534. data[i][11] = Number(data[i][10]) * clf_sum / Number(100);
  1535. }
  1536. }
  1537. sum = 0;
  1538. rgf_sum = 0;
  1539. jxf_sum = 0;
  1540. clf_sum = 0;
  1541. zcf_sum = 0;
  1542. for(let i = 1; i < data.length; i++) {
  1543. sum += Number(data[i][11]);//11-> hejia
  1544. if (Number(data[i][8]) == 1) {
  1545. rgf_sum += Number(data[i][11]);
  1546. }
  1547. if (Number(data[i][8]) == 2) {
  1548. clf_sum += Number(data[i][11]);
  1549. if (data[i][14] == 'true') {
  1550. zcf_sum += Number(data[i][11]);
  1551. }
  1552. }
  1553. if (Number(data[i][8]) == 3) {
  1554. jxf_sum += Number(data[i][11]);
  1555. }
  1556. }
  1557. let shuliang = Number(qd['数量']);
  1558. for(let i = 0; i< qd["_children"].length; i++) {
  1559. if(qd["_children"][i]['key'] == row) {
  1560. let desl = Number(qd["_children"][i]['数量']);
  1561. let oldname = qd["_children"][i]['清单编码'];
  1562. qd["_children"][i]['辅材费'] = clf_sum - zcf_sum;
  1563. qd["_children"][i]['材料费'] = clf_sum;
  1564. qd["_children"][i]['人工费'] = rgf_sum;
  1565. qd["_children"][i]['主材费'] = zcf_sum;
  1566. qd["_children"][i]['设备费'] = 0;
  1567. qd["_children"][i]['机械费'] = jxf_sum;
  1568. if (oldname.startsWith("D")) {//单项清单
  1569. qd["_children"][i]['管理费'] = 0;
  1570. qd["_children"][i]['利润'] = 0;
  1571. } else {
  1572. if (this.qufeiEntry['备注'].length == 0) {
  1573. //changuiqufei
  1574. qd["_children"][i]['管理费'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1575. qd["_children"][i]['利润'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1576. } else {
  1577. qd["_children"][i]['管理费'] = (rgf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1578. qd["_children"][i]['利润'] = (rgf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1579. }
  1580. }
  1581. qd["_children"][i]['综合单价'] = sum + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
  1582. qd["_children"][i]['合价'] = (qd["_children"][i]['综合单价'] * shuliang * desl);
  1583. qd["_children"][i]["dercj"] = copy(data);
  1584. qd["_children"][i]['清单编码'] = renameDingE(oldname, xuhao, huan);
  1585. }
  1586. }
  1587. }
  1588. updateDercj_(row, data, xuhao, yuban, rcjbc) {///change 一条定额 inplace, 汇总一条定额的rcj, xuhao is for rename, yuban is 预拌砂浆
  1589. console.log("data updated");
  1590. //处理附注
  1591. let huan = false;//换
  1592. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1593. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1594. if (de.hasOwnProperty("rcjdg")) {//新数据
  1595. for (let i = 1; i < de['rcjdg'].length; i++) {
  1596. de['rcjdg'][i][5] = data[i][5];//更新单价,底稿的单价不是很需要同步(在人才机汇总修改价格)
  1597. /****ToDo 更新其他字段 */
  1598. if (de['rcjdg'][i][2] == data[i][2]) {//更新名称
  1599. } else {
  1600. huan = true;
  1601. }
  1602. }
  1603. if (de['fuzhuEnable'] && de.hasOwnProperty('fuzhu')) {//没强行改过含量
  1604. for(let j = 1; j < de['rcjdg'].length; j++) {
  1605. let origin = Number(de['rcjdg'][j][10]);
  1606. for(let i = 0; i < de['fuzhu'].length; i++) {
  1607. let selected = de['fuzhu'][i];
  1608. let target = selected[0];
  1609. if (match_target(de['rcjdg'][j][1], target)) {
  1610. if (selected[2] == '系数') {
  1611. origin = origin * Number(selected[3]);
  1612. } else if (selected[2] == '含量') {
  1613. origin = Number(selected[3]);
  1614. } else if (selected[2] == '调整') {
  1615. origin = origin + Number(selected[3]);
  1616. } else {
  1617. throw new Error('无法处理的附注'.concat(selected[2]));
  1618. }
  1619. }
  1620. }
  1621. de['dercj'][j][2] = data[j][2];//名称
  1622. de['dercj'][j][1] = data[j][1];//编号
  1623. de['dercj'][j][5] = de['rcjdg'][j][5];//单价
  1624. de['dercj'][j][10] = origin;
  1625. de['dercj'][j][11] = Number(de['dercj'][j][5]) * origin;
  1626. }
  1627. } else if (de['fuzhuEnable'] && !de.hasOwnProperty('fuzhu')) {
  1628. for(let j = 1; j < de['rcjdg'].length; j++) {
  1629. let origin = Number(de['rcjdg'][j][10]);
  1630. de['dercj'][j][2] = data[j][2];//名称
  1631. de['dercj'][j][1] = data[j][1];//编号
  1632. de['dercj'][j][5] = de['rcjdg'][j][5];
  1633. de['dercj'][j][10] = origin;
  1634. de['dercj'][j][11] = Number(de['dercj'][j][5]) * origin;
  1635. }
  1636. }
  1637. else {
  1638. //强行改含量
  1639. de['dercj'] = copy(data);
  1640. }
  1641. data = de['dercj'];
  1642. if (de['fuzhuEnable']) {
  1643. data = data.filter(x=>x[1] != 'S00001' && x[1] != 'JD0001');
  1644. for (let i = 1; i < data.length; i++) {
  1645. if (data[i][2].includes('(湿拌砂浆)')) {
  1646. let index = data[i][2].indexOf("(湿拌砂浆)");
  1647. data[i][2] = data[i][2].substring(0, index);
  1648. }
  1649. if (data[i][2].includes('(干拌(混)砂浆)')) {
  1650. let index = data[i][2].indexOf("(干拌(混)砂浆)");
  1651. data[i][2] = data[i][2].substring(0, index);
  1652. }
  1653. }
  1654. de['dercj'] = copy(data);
  1655. }
  1656. } else {////单项定额没有底稿,老数据没底搞,无法判断换部换,暂时统一认为不换
  1657. //强行改含量
  1658. de['dercj'] = copy(data);
  1659. data = de['dercj'];
  1660. }
  1661. if (de.hasOwnProperty("rcjdg") && de['fuzhuEnable'] && yuban.length > 0) {//没强行改过含量
  1662. if (yuban.includes('1')) {
  1663. for(let i = 1; i < data.length; i++) {
  1664. if (data[i][4]=='工日') {
  1665. data[i][10] = Number(data[i][10]) - 0.45;
  1666. }
  1667. if (data[i][2].includes('搅拌机')) {
  1668. data[i][10] = 0;
  1669. }
  1670. if (data[i][2].includes('砂浆') && !data[i][2].includes('搅拌机')) {
  1671. data[i][2] = data[i][2].concat('(湿拌砂浆)')
  1672. }
  1673. }
  1674. } else if (yuban.includes('2')) {
  1675. let origin = 0;
  1676. for(let i = 1; i < data.length; i++) {
  1677. if (data[i][4]=='工日') {
  1678. data[i][10] = Number(data[i][10]) - 0.3;
  1679. }
  1680. if (data[i][2].includes('搅拌机')) {
  1681. data[i][10] = 0;
  1682. }
  1683. if (data[i][2].includes('砂浆') && !data[i][2].includes('搅拌机')) {
  1684. data[i][2] = data[i][2].concat('(干拌(混)砂浆)');
  1685. origin = Number(data[i][10]);
  1686. data[i][10] = origin * 1.75;
  1687. }
  1688. }
  1689. data.push(['', 'S00001', '水', '', 't', '4.70', '', '', '2', 'false', (origin * 0.29).toString(), '', '','','','']);
  1690. data.push(['', 'JD0001', '其他机械费(电)', '', '度', '0.65', '', '', '3', 'false', (origin * 2.15).toString(), '', '','','','']);
  1691. } else if (yuban.includes('3')) {
  1692. let origin = 0;
  1693. for(let i = 1; i < data.length; i++) {
  1694. if (data[i][4]=='工日') {
  1695. data[i][10] = Number(data[i][10]) - 0.2;
  1696. }
  1697. if (data[i][2].includes('砂浆') && !data[i][2].includes('搅拌机')) {
  1698. data[i][2] = data[i][2].concat('(干拌(混)砂浆)');
  1699. origin = Number(data[i][10]);
  1700. data[i][10] = origin * 1.75;
  1701. }
  1702. }
  1703. data.push(['', 'S00001', '水', '', 't', '4.70', '', '', '2', 'false', (origin * 0.29).toString(), '', '','','','']);
  1704. }
  1705. de['dercj'] = copy(data);
  1706. }
  1707. de['dercj'] = de['dercj'].filter(x=>x[1] != '410000F')//补充
  1708. for(let i = 0; i < rcjbc.length; i++) {
  1709. 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]['设备标志']]);
  1710. }
  1711. data = copy(de['dercj']);
  1712. //模拟formula计算每一行的合价
  1713. for(let i = 1; i < data.length; i++) {
  1714. data[i][11] = Number(data[i][10]) * Number(data[i][5]);
  1715. }
  1716. let sum = 0;
  1717. let rgf_sum = 0;
  1718. let jxf_sum = 0;
  1719. let clf_sum = 0;
  1720. let zcf_sum = 0;
  1721. for(let i = 1; i < data.length; i++) {
  1722. if (data[i][1].includes('000FE') && data[i][4] == '%')continue;
  1723. sum += Number(data[i][11]);//11-> hejia
  1724. if (Number(data[i][8]) == 1) {
  1725. rgf_sum += Number(data[i][11]);
  1726. }
  1727. if (Number(data[i][8]) == 2) {
  1728. clf_sum += Number(data[i][11]);
  1729. if (data[i][14] == 'true') {
  1730. zcf_sum += Number(data[i][11]);
  1731. }
  1732. }
  1733. if (Number(data[i][8]) == 3) {
  1734. jxf_sum += Number(data[i][11]);
  1735. }
  1736. }
  1737. console.log("sum=".concat(sum));
  1738. let shuliang = Number(qd['数量']);
  1739. for(let i = 0; i< qd["_children"].length; i++) {
  1740. if(qd["_children"][i]['key'] == row) {
  1741. let desl = Number(qd["_children"][i]['数量']);
  1742. let oldname = qd["_children"][i]['清单编码'];
  1743. qd["_children"][i]['辅材费'] = clf_sum - zcf_sum;
  1744. qd["_children"][i]['材料费'] = clf_sum;
  1745. qd["_children"][i]['人工费'] = rgf_sum;
  1746. qd["_children"][i]['主材费'] = zcf_sum;
  1747. qd["_children"][i]['设备费'] = 0;
  1748. qd["_children"][i]['机械费'] = jxf_sum;
  1749. if (oldname.startsWith("D")) {//单项清单
  1750. qd["_children"][i]['管理费'] = 0;
  1751. qd["_children"][i]['利润'] = 0;
  1752. } else {
  1753. if (this.qufeiEntry['备注'].length == 0) {
  1754. //changuiqufei
  1755. qd["_children"][i]['管理费'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1756. qd["_children"][i]['利润'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1757. } else {
  1758. qd["_children"][i]['管理费'] = (rgf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1759. qd["_children"][i]['利润'] = (rgf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1760. }
  1761. }
  1762. qd["_children"][i]['综合单价'] = sum + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
  1763. qd["_children"][i]['合价'] = (qd["_children"][i]['综合单价'] * shuliang * desl);
  1764. qd["_children"][i]["dercj"] = copy(data);
  1765. qd["_children"][i]['清单编码'] = renameDingE(oldname, xuhao, huan);
  1766. }
  1767. }
  1768. }
  1769. updateDercj(row, data) {
  1770. //是否手动设置含量
  1771. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1772. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1773. this.updateFootprint(qd['key']);
  1774. let bm = de['清单编码'];
  1775. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  1776. let origin = de['dercj'];
  1777. let change = false;
  1778. for(let i = 1; i < data.length; i++) {
  1779. let before = origin[i][10];//含量
  1780. let after = data[i][10];
  1781. if (Number(before) - Number(after) < 0.0001 && Number(before) - Number(after) > -0.0001) {
  1782. //no change
  1783. } else {
  1784. change = true;
  1785. break;
  1786. }
  1787. }
  1788. if (change) {
  1789. de['fuzhuEnable'] = false;
  1790. }
  1791. this.updateDercj_(row, data, alreadyFuzhu, de['yuban'], de['rcjbc']);
  1792. //let qd = this.cache.filter(x=>x["children"].filter(y=>y['key']==row).length > 0)[0];
  1793. let newData = this.cache.map(x=>{
  1794. if (x['key'] == qd['key']) {
  1795. return qd;
  1796. } else {
  1797. return x;
  1798. }
  1799. });
  1800. let summarized = this.summarize(newData);
  1801. this.push_op(summarized);
  1802. /////////////////
  1803. this.cache = copy(summarized);
  1804. return copy(this.cache);
  1805. }
  1806. updateDercj_djcs(row, data) {
  1807. //是否手动设置含量
  1808. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1809. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1810. let bm = de['清单编码'];
  1811. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  1812. let origin = de['dercj'];
  1813. let change = false;
  1814. for(let i = 1; i < data.length; i++) {
  1815. let before = origin[i][10];
  1816. let after = data[i][10];
  1817. if (Number(before) - Number(after) < 0.0001 && Number(before) - Number(after) > -0.0001) {
  1818. //no change
  1819. } else {
  1820. change = true;
  1821. break;
  1822. }
  1823. }
  1824. if (change) {
  1825. de['fuzhuEnable'] = false;
  1826. }
  1827. this.updateDercj_djcs_(row, data, alreadyFuzhu);
  1828. //let qd = this.cache.filter(x=>x["children"].filter(y=>y['key']==row).length > 0)[0];
  1829. let newData = this.cache_djcs.map(x=>{
  1830. if (x['key'] == qd['key']) {
  1831. return qd;
  1832. } else {
  1833. return x;
  1834. }
  1835. });
  1836. let summarized = this.summarize_djcs(newData);
  1837. this.push_op_djcs(summarized);
  1838. /////////////////
  1839. this.cache_djcs = copy(summarized);
  1840. return copy(this.cache_djcs);
  1841. }
  1842. updateBeizhu(row, selected, xuhao) {//xuhao is for rename
  1843. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1844. if (!qd) return [null, null];
  1845. this.updateFootprint(qd['key']);
  1846. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1847. if (de.hasOwnProperty("rcjdg")) {//底稿
  1848. } else {///老数据不能有底稿,附注功能也不使能
  1849. //de['rcjdg'] = copy(de['dercj']);
  1850. }
  1851. de['fuzhu'] = copy(selected);
  1852. this.updateDercj_(row, de['dercj'], xuhao, de['yuban'], de['rcjbc']);
  1853. let newData = this.cache.map(x=>{
  1854. if (x['key'] == qd['key']) {
  1855. return qd;
  1856. } else {
  1857. return x;
  1858. }
  1859. });
  1860. let summarized = this.summarize(newData);
  1861. this.push_op(summarized);
  1862. /////////////////
  1863. this.cache = copy(summarized);
  1864. return [copy(this.cache), copy(de['dercj'])];
  1865. }
  1866. updateBeizhu_djcs(row, selected, xuhao) {//xuhao is for rename
  1867. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1868. if (!qd) return [null, null];
  1869. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1870. if (de.hasOwnProperty("rcjdg")) {//底稿
  1871. } else {///老数据不能有底稿,附注功能也不使能
  1872. //de['rcjdg'] = copy(de['dercj']);
  1873. }
  1874. de['fuzhu'] = copy(selected);
  1875. this.updateDercj_djcs_(row, de['dercj'], xuhao);
  1876. let newData = this.cache_djcs.map(x=>{
  1877. if (x['key'] == qd['key']) {
  1878. return qd;
  1879. } else {
  1880. return x;
  1881. }
  1882. });
  1883. let summarized = this.summarize_djcs(newData);
  1884. this.push_op_djcs(summarized);
  1885. /////////////////
  1886. this.cache_djcs = copy(summarized);
  1887. return [copy(this.cache_djcs), copy(de['dercj'])];
  1888. }
  1889. huan(old_index, new_bianhao, new_name, new_jia, row) {
  1890. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1891. this.updateFootprint(qd['key']);
  1892. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1893. let rcj = copy(de['dercj']);
  1894. rcj[old_index][1] = new_bianhao;
  1895. rcj[old_index][2] = new_name;
  1896. rcj[old_index][5] = new_jia;
  1897. return this.updateDercj(row, rcj);
  1898. }
  1899. updateShuliang(value, row) {
  1900. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1901. this.updateFootprint(qd['key']);
  1902. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1903. let origin = de['数量']
  1904. if (Number(origin) - Number(value) < 0.0001 && Number(origin) - Number(value) > -0.0001) {
  1905. return [false, null];
  1906. }
  1907. console.log("shuliang update");
  1908. de['数量'] = value;
  1909. de['合价'] = Number(qd['数量']) * Number(de['综合单价']) * Number(de['数量']);
  1910. let newData = this.cache.map(x=>{
  1911. if (x['key'] == qd['key']) {
  1912. return qd;
  1913. } else {
  1914. return x;
  1915. }
  1916. });
  1917. let summarized = this.summarize(newData);
  1918. this.push_op(summarized);
  1919. /////////////////
  1920. this.cache = copy(summarized);
  1921. return [true, copy(this.cache)];
  1922. }
  1923. updateDeMingcheng(value, row) {
  1924. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1925. this.updateFootprint(qd['key']);
  1926. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1927. de['名称'] = value;
  1928. let newData = this.cache.map(x=>{
  1929. if (x['key'] == qd['key']) {
  1930. return qd;
  1931. } else {
  1932. return x;
  1933. }
  1934. });
  1935. let summarized = this.summarize(newData);
  1936. this.push_op(summarized);
  1937. /////////////////
  1938. this.cache = copy(summarized);
  1939. return copy(this.cache);
  1940. }
  1941. updateShuliang_djcs(value, row) {
  1942. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1943. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1944. let origin = de['数量']
  1945. if (Number(origin) - Number(value) < 0.0001 && Number(origin) - Number(value) > -0.0001) {
  1946. return [false, null];
  1947. }
  1948. console.log("shuliang update");
  1949. de['数量'] = value;
  1950. de['合价'] = Number(qd['数量']) * Number(de['综合单价']) * Number(de['数量']);
  1951. let newData = this.cache_djcs.map(x=>{
  1952. if (x['key'] == qd['key']) {
  1953. return qd;
  1954. } else {
  1955. return x;
  1956. }
  1957. });
  1958. let summarized = this.summarize_djcs(newData);
  1959. this.push_op_djcs(summarized);
  1960. /////////////////
  1961. this.cache_djcs = copy(summarized);
  1962. return [true, copy(this.cache_djcs)];
  1963. }
  1964. changguidinge_djcs(dingeclick, row) {
  1965. if (this.cache_djcs.filter(x=>x['key'] == row).length > 0) {
  1966. let res =dingeclick;
  1967. let keys = Object.keys(res['DEBH']);
  1968. let key = keys[0];
  1969. //console.log(res);
  1970. let qd = this.cache_djcs.filter(x=>x['key'] == row)[0];
  1971. let dercj = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1972. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
  1973. for(let i = 0; i < res['rgde'].length; i++) {
  1974. dercj.push(['', res['rgde'][i]['CLBH'], res['rgde'][i]['CLMC'], '', res['rgde'][i]['JLDW'],
  1975. res['rgde'][i]['YSJG'], '', '', '1', '', res['rgde'][i]['gr'], res['rgde'][i]['gf'],
  1976. '', '', '', '' ]);
  1977. }
  1978. for(let i = 0; i < res['clde'].length; i++) {
  1979. dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  1980. res['clde'][i]['YSJG'], '', '', '2', '', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  1981. '', '', '', '' ]);
  1982. }
  1983. for(let i = 0; i < res['jxde'].length; i++) {
  1984. dercj.push(['', res['jxde'][i]['jxbh'], res['jxde'][i]['jxmc'], '', res['jxde'][i]['DW'],
  1985. res['jxde'][i]['tbdj'], '', '', '3', '', res['jxde'][i]['sl'], res['jxde'][i]['hj'],
  1986. '', '', '', '' ]);
  1987. }
  1988. let newKey = uuidv4();
  1989. qd["_children"].push({
  1990. '操作': '',
  1991. '序号': null,
  1992. '清单编码': res['DEBH'][key],
  1993. '名称': res['GCLMC'][key],
  1994. '项目特征': null,
  1995. '计算规则': null,
  1996. '单位': res['DW'][key],
  1997. '数量': '1',
  1998. '综合单价': '0',
  1999. '合价': '0',
  2000. '人工费': '0',
  2001. '主材费': '0',
  2002. '设备费': '0',
  2003. '辅材费': '0',
  2004. '材料费': '0',
  2005. '机械费': '0',
  2006. '管理费': '0',
  2007. '利润': '0',
  2008. '暂估价': null,
  2009. '综合人工工日': null,
  2010. '备注': null,
  2011. "dercj": dercj,
  2012. 'rcjdg': copy(dercj),
  2013. 'key' : newKey,
  2014. "fuzhuEnable": true
  2015. });
  2016. this.updateDercj_djcs_(newKey, dercj, []);
  2017. let summarized = this.summarize_djcs(this.cache_djcs);
  2018. this.push_op_djcs(copy(summarized));
  2019. /////////////////
  2020. this.cache_djcs = copy(summarized);
  2021. //return copy(this.cache);
  2022. return [true, copy(this.cache_djcs), newKey];
  2023. } else {
  2024. return [false, null, null];
  2025. }
  2026. }
  2027. changguidinge(dingeclick, row) {
  2028. if (this.cache.filter(x=>x['key'] == row).length > 0) {
  2029. this.updateFootprint(row);
  2030. let res = copy(dingeclick);
  2031. let keys = Object.keys(res['DEBH']);
  2032. let key = keys[0];
  2033. let tips = azfy(res['DEBH'][key], res['GCLMC'][key]);
  2034. if (tips != null) {
  2035. res['rgde'] = tips['rgde'];
  2036. res['clde'] = tips['clde'];
  2037. res['jxde'] = tips['jxde'];
  2038. }
  2039. let qd = this.cache.filter(x=>x['key'] == row)[0];
  2040. let dercj = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  2041. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
  2042. for(let i = 0; i < res['rgde'].length; i++) {
  2043. dercj.push(['', res['rgde'][i]['CLBH'], res['rgde'][i]['CLMC'], '', res['rgde'][i]['JLDW'],
  2044. res['rgde'][i]['YSJG'], '', '', '1', '', res['rgde'][i]['gr'], res['rgde'][i]['gf'],
  2045. '', '', '', '' ]);
  2046. }
  2047. for(let i = 0; i < res['clde'].length; i++) {
  2048. dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  2049. res['clde'][i]['YSJG'], '', '', '2', '', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  2050. '', '', '', '' ]);
  2051. }
  2052. for(let i = 0; i < res['jxde'].length; i++) {
  2053. dercj.push(['', res['jxde'][i]['jxbh'], res['jxde'][i]['jxmc'], '', res['jxde'][i]['DW'],
  2054. res['jxde'][i]['tbdj'], '', '', '3', '', res['jxde'][i]['sl'], res['jxde'][i]['hj'],
  2055. '', '', '', '' ]);
  2056. }
  2057. let newKey = uuidv4();
  2058. qd["_children"].push({
  2059. '操作': '',
  2060. '序号': null,
  2061. '清单编码': res['DEBH'][key],
  2062. '名称': res['GCLMC'][key],
  2063. '项目特征': null,
  2064. '计算规则': tips != null ? tips['sm'] : '',
  2065. '单位': res['DW'][key],
  2066. '数量': '1',
  2067. '综合单价': '0',
  2068. '合价': '0',
  2069. '人工费': '0',
  2070. '主材费': '0',
  2071. '设备费': '0',
  2072. '辅材费': '0',
  2073. '材料费': '0',
  2074. '机械费': '0',
  2075. '管理费': '0',
  2076. '利润': '0',
  2077. '暂估价': null,
  2078. '综合人工工日': null,
  2079. '备注': null,
  2080. "dercj": dercj,
  2081. 'rcjdg': copy(dercj),
  2082. 'key' : newKey,
  2083. "fuzhuEnable": true,
  2084. 'yuban': [],
  2085. 'rcjbc': [],
  2086. 'azfytag': tips != null ? tips['azfytag'] : []
  2087. });
  2088. this.updateDercj_(newKey, dercj, [], [], []);
  2089. let summarized = this.summarize(this.cache);
  2090. this.push_op(copy(summarized));
  2091. /////////////////
  2092. this.cache = copy(summarized);
  2093. //return copy(this.cache);
  2094. return [true, copy(this.cache), newKey];
  2095. } else {
  2096. return [false, null, null];
  2097. }
  2098. }
  2099. danxiangdinge(row) {
  2100. let bh = danxiangdinge_index(this.cache);
  2101. if (this.cache.filter(x=>x['key'] == row).length > 0) {
  2102. this.updateFootprint(row);
  2103. let selected = this.cache.filter(x=>x['key'] == row)[0];
  2104. let danwei = selected["单位"];
  2105. let mingcheng = selected['名称'];
  2106. let children = selected["_children"];
  2107. children.push({
  2108. '操作': '',
  2109. '序号': null,
  2110. '清单编码': bh,
  2111. '名称': mingcheng,
  2112. '项目特征': null,
  2113. '计算规则': null,
  2114. '单位': danwei,
  2115. '数量': '1',
  2116. '综合单价': '',
  2117. '合价': '',
  2118. '人工费': '0',
  2119. '主材费': '0',
  2120. '设备费': '0',
  2121. '辅材费': '',
  2122. '材料费': '',
  2123. '机械费': '0',
  2124. '管理费': '0',
  2125. '利润': '0',
  2126. '暂估价': null,
  2127. '综合人工工日': null,
  2128. '备注': null,
  2129. "dercj": [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  2130. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ],
  2131. ['', bh, mingcheng, '', danwei, '', '', '', '2', '', '1', '', '', '', '', '' ]
  2132. ],
  2133. 'key' : uuidv4(),
  2134. "fuzhuEnable": false,
  2135. 'yuban': [],
  2136. 'rcjbc' : [],
  2137. 'azfytag': []
  2138. });
  2139. let summarized = this.summarize(this.cache);
  2140. this.push_op(summarized);
  2141. this.cache = copy(summarized);
  2142. return [true, copy(this.cache)];
  2143. } else {
  2144. return [false,null];
  2145. }
  2146. }
  2147. danxiangdinge_djcs(row) {
  2148. let bh = danxiangdinge_index_djcs(this.cache_djcs);
  2149. if (this.cache_djcs.filter(x=>x['key'] == row).length > 0) {
  2150. let selected = this.cache_djcs.filter(x=>x['key'] == row)[0];
  2151. let danwei = selected["单位"];
  2152. let mingcheng = selected['名称'];
  2153. let children = selected["_children"];
  2154. children.push({
  2155. '序号': null,
  2156. '清单编码': bh,
  2157. '名称': mingcheng,
  2158. '项目特征': null,
  2159. '计算规则': null,
  2160. '单位': danwei,
  2161. '数量': '1',
  2162. '综合单价': '',
  2163. '合价': '',
  2164. '人工费': '0',
  2165. '主材费': '0',
  2166. '设备费': '0',
  2167. '辅材费': '',
  2168. '材料费': '',
  2169. '机械费': '0',
  2170. '管理费': '0',
  2171. '利润': '0',
  2172. '暂估价': null,
  2173. '综合人工工日': null,
  2174. '备注': null,
  2175. "dercj": [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  2176. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ],
  2177. ['', bh, mingcheng, '', danwei, '', '', '', '2', '', '1', '', '', '', '', '' ]
  2178. ],
  2179. 'key' : uuidv4(),
  2180. "fuzhuEnable": false
  2181. });
  2182. let summarized = this.summarize_djcs(this.cache_djcs);
  2183. this.push_op_djcs(summarized);
  2184. this.cache_djcs = copy(summarized);
  2185. return [true, copy(this.cache_djcs)];
  2186. } else {
  2187. return [false,null];
  2188. }
  2189. }
  2190. handleYuban(row, selected) {
  2191. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  2192. if (!qd) return [null, null];
  2193. this.updateFootprint(qd['key']);
  2194. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  2195. let bm = de['清单编码'];
  2196. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  2197. if (de.hasOwnProperty("rcjdg")) {//底稿
  2198. } else {///老数据不能有底稿,附注功能也不使能,预拌也不能使
  2199. //de['rcjdg'] = copy(de['dercj']);
  2200. }
  2201. de['yuban'] = copy(selected);
  2202. this.updateDercj_(row, de['dercj'], alreadyFuzhu, selected, de['rcjbc']);
  2203. let newData = this.cache.map(x=>{
  2204. if (x['key'] == qd['key']) {
  2205. return qd;
  2206. } else {
  2207. return x;
  2208. }
  2209. });
  2210. let summarized = this.summarize(newData);
  2211. this.push_op(summarized);
  2212. /////////////////
  2213. this.cache = copy(summarized);
  2214. return [copy(this.cache), copy(de['dercj'])];
  2215. }
  2216. handleRcjbc(row, rcjbc) {
  2217. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  2218. if (!qd) return [null, null];
  2219. this.updateFootprint(qd['key']);
  2220. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  2221. let bm = de['清单编码'];
  2222. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  2223. if (de.hasOwnProperty("rcjdg")) {//底稿
  2224. } else {///老数据不能有底稿,附注功能也不使能,预拌也不能使
  2225. //de['rcjdg'] = copy(de['dercj']);
  2226. }
  2227. de['rcjbc'] = copy(rcjbc);
  2228. this.updateDercj_(row, de['dercj'], alreadyFuzhu, de['yuban'], rcjbc);
  2229. let newData = this.cache.map(x=>{
  2230. if (x['key'] == qd['key']) {
  2231. return qd;
  2232. } else {
  2233. return x;
  2234. }
  2235. });
  2236. let summarized = this.summarize(newData);
  2237. this.push_op(summarized);
  2238. /////////////////
  2239. this.cache = copy(summarized);
  2240. return [copy(this.cache), copy(de['dercj'])];
  2241. }
  2242. }
  2243. export default new Service();