Service.js 98 KB

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