Service.js 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382
  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. console.log('match fuzhu')
  1006. if (selected[2] == '系数' || selected[2] == '商品砼系数' || selected[2] == '除此机械外') {
  1007. origin = origin * (Number(selected[3]) ** Number(selected[5]));
  1008. } else if (selected[2] == '含量' || selected[2] == '商品砼含量') {
  1009. origin = Number(selected[3]);
  1010. } else if (selected[2] == '调整' || selected[2] == '商品砼调整') {
  1011. origin = origin + Number(selected[3]) * Number(selected[5]);
  1012. } else if (selected[2] == '调比') {
  1013. origin = origin + Number(selected[3]) * Number(selected[5]) / Number(100);
  1014. } else if (selected[2] == '次方') {
  1015. origin = origin * (Number(selected[3]) ** Number(selected[5]));
  1016. } else if (selected[2] == '叠加备注') {
  1017. } else if (selected[2] == '换机械系数') {
  1018. bianhao_huan = selected[4];
  1019. name_huan = this.mapper[bianhao_huan][0];
  1020. new_jia = this.mapper[bianhao_huan][1];
  1021. origin = origin * (Number(selected[3]) ** Number(selected[5]));
  1022. } else if (selected[2] == '换材料系数') {
  1023. bianhao_huan = selected[4];
  1024. name_huan = this.mapper[bianhao_huan][0];
  1025. new_jia = this.mapper[bianhao_huan][1];
  1026. origin = origin * (Number(selected[3]) ** Number(selected[5]));
  1027. } else if (selected[2] == '使用泵送') {
  1028. if (de['rcjdg'][j][2].includes('C20')) {
  1029. bianhao_huan = '80212103';
  1030. name_huan = '(C20泵送商品砼)';
  1031. new_jia = 342;
  1032. }
  1033. if (de['rcjdg'][j][2].includes('C30')) {
  1034. bianhao_huan = '80212105';
  1035. name_huan = '(C30泵送商品砼)';
  1036. new_jia = 362;
  1037. }
  1038. } else if (selected[2] == '使用非泵送') {
  1039. if (de['rcjdg'][j][2].includes('C20')) {
  1040. bianhao_huan = '80212115';
  1041. name_huan = '(C20非泵送商品砼)';
  1042. new_jia = 333;
  1043. }
  1044. if (de['rcjdg'][j][2].includes('C30')) {
  1045. bianhao_huan = '80212117';
  1046. name_huan = '(C30非泵送商品砼)';
  1047. new_jia = 353;
  1048. }
  1049. }
  1050. else {
  1051. throw new Error('无法处理的附注'.concat(selected[2]));
  1052. }
  1053. }
  1054. }
  1055. if (bianhao_huan == '') {
  1056. } else {
  1057. de['dercj'][j][1] = bianhao_huan;//编号
  1058. de['dercj'][j][2] = name_huan;//mc
  1059. de['dercj'][j][5] = new_jia;//jiage
  1060. }
  1061. de['dercj'][j][10] = origin;
  1062. de['dercj'][j][11] = Number(de['dercj'][j][5]) * origin;
  1063. }
  1064. }
  1065. //基于底稿判断换
  1066. for(let j = 1; j < de['dercj'].length; j++) {
  1067. for (let k = 0; k < data.length; k++) {
  1068. if (data[k][16] == de['dercj'][j][16]) {
  1069. let datak2 = data[k][2];
  1070. if (datak2.includes('(湿拌砂浆)')) {
  1071. datak2 = datak2.replace('(湿拌砂浆)', '');
  1072. }
  1073. if (datak2.includes('(干拌(混)砂浆)')) {
  1074. datak2 = datak2.replace('(干拌(混)砂浆)', '');
  1075. }
  1076. if (de['dercj'][j][2] == datak2) {//名称
  1077. } else {
  1078. huan = true;
  1079. }
  1080. }
  1081. }
  1082. }
  1083. if (mode == 1) {
  1084. data_normal = de['dercj'];
  1085. huan = false;
  1086. } else {
  1087. data_normal = copy(data.filter(x=>x[17] != 'true'));
  1088. }
  1089. } else {////单项定额没有底稿,老数据没底搞,无法判断换部换,暂时统一认为不换
  1090. //强行改含量
  1091. data_normal = copy(data.filter(x=>x[17] != 'true'));
  1092. //data = de['dercj'];
  1093. }
  1094. //处理补充
  1095. for(let i = 0; i < rcjbc.length; i++) {
  1096. 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']);
  1097. for (let k = 0; k < data.length; k++) {
  1098. if (data[k][16] == rcjbc[i]['id']) {
  1099. let datak2 = data[k][2];
  1100. if (datak2.includes('(湿拌砂浆)')) {
  1101. datak2 = datak2.replace('(湿拌砂浆)', '');
  1102. }
  1103. if (datak2.includes('(干拌(混)砂浆)')) {
  1104. datak2 = datak2.replace('(干拌(混)砂浆)', '');
  1105. }
  1106. if (rcjbc[i]['名称'] == datak2) {//名称
  1107. } else {
  1108. if (mode == 2) {
  1109. } else {
  1110. huan = true;
  1111. }
  1112. }
  1113. }
  1114. }
  1115. }
  1116. if (yuban.length > 0) {//处理预拌砂浆
  1117. if (yuban.includes('1')) {//与换无关
  1118. for(let i = 1; i < data_normal.length; i++) {
  1119. if (data_normal[i][4]=='工日') {
  1120. data_normal[i][10] = Number(data_normal[i][10]) - 0.45;
  1121. }
  1122. if (data_normal[i][2].includes('搅拌机')) {
  1123. data_normal[i][10] = 0;
  1124. }
  1125. if (data_normal[i][2].includes('砂浆') && !data_normal[i][2].includes('搅拌机')) {
  1126. data_normal[i][2] = data_normal[i][2].concat('(湿拌砂浆)')
  1127. }
  1128. }
  1129. if (mode == 0) {
  1130. data_normal = copy(data);
  1131. } else if (mode == 1) {
  1132. //data_normal = data_normal.filter(x=>x[17]!='true');
  1133. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1134. } else if (mode == 2) {
  1135. let data_normal_2 = copy(data_normal);
  1136. data_normal = data.filter(x=>x[17]!='true');
  1137. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1138. }
  1139. } else if (yuban.includes('2')) {//与换无关
  1140. let added = [];
  1141. for(let i = 1; i < data_normal.length; i++) {
  1142. let origin = 0;
  1143. if (data_normal[i][4]=='工日') {
  1144. data_normal[i][10] = Number(data_normal[i][10]) - 0.3;
  1145. }
  1146. if (data_normal[i][2].includes('搅拌机')) {
  1147. data_normal[i][10] = 0;
  1148. }
  1149. if (data_normal[i][2].includes('砂浆') && !data_normal[i][2].includes('搅拌机')) {
  1150. data_normal[i][2] = data_normal[i][2].concat('(干拌(混)砂浆)');
  1151. origin = Number(data_normal[i][10]);
  1152. data_normal[i][10] = origin * 1.75;
  1153. added.push(['', 'S00001', '水', '', 't', '4.70', '', '', '2', 'false', (origin * 0.29).toString(), ''/**hj */, ''/**zgj */,''/**zycl */,''/**zc */,''/**sb */,'',data_normal[i][17]]);
  1154. added.push(['', 'JD0001', '其他机械费(电)', '', '度', '0.65', '', '', '3', 'false', (origin * 2.15).toString(), ''/**hj */, ''/**zgj */,''/**zycl */,''/**zc */,''/**sb */, '',data_normal[i][17]]);
  1155. }
  1156. }
  1157. data_normal = data_normal.concat(added);
  1158. if (mode == 0) {
  1159. data_normal = copy(data);
  1160. } else if (mode == 1) {
  1161. //data_normal = data_normal.filter(x=>x[17]!='true');
  1162. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1163. } else if (mode == 2) {
  1164. let data_normal_2 = copy(data_normal);
  1165. data_normal = data.filter(x=>x[17]!='true');
  1166. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1167. }
  1168. } else if (yuban.includes('3')) {//与换无关
  1169. let added = [];
  1170. for(let i = 1; i < data_normal.length; i++) {
  1171. let origin = 0;
  1172. if (data_normal[i][4]=='工日') {
  1173. data_normal[i][10] = Number(data_normal[i][10]) - 0.2;
  1174. }
  1175. if (data_normal[i][2].includes('砂浆') && !data_normal[i][2].includes('搅拌机')) {
  1176. data_normal[i][2] = data_normal[i][2].concat('(干拌(混)砂浆)');
  1177. origin = Number(data_normal[i][10]);
  1178. data_normal[i][10] = origin * 1.75;
  1179. added.push(['', 'S00001', '水', '', 't', '4.70', '', '', '2', 'false', (origin * 0.29).toString(), '', '','','','','',data_normal[i][17]]);
  1180. }
  1181. }
  1182. data_normal = data_normal.concat(added);
  1183. if (mode == 0) {
  1184. data_normal = copy(data);
  1185. } else if (mode == 1) {
  1186. //data_normal = data_normal.filter(x=>x[17]!='true');
  1187. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1188. } else if (mode == 2) {
  1189. let data_normal_2 = copy(data_normal);
  1190. data_normal = data.filter(x=>x[17]!='true');
  1191. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1192. }
  1193. } else {
  1194. let data_normal_2 = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1195. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];
  1196. for(let i = 1; i < data_normal.length; i++) {
  1197. let bc = data_normal[i][17];
  1198. let child = addChildren(10, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1199. if (child.length > 0) {
  1200. } else {
  1201. child = addChildren(40, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1202. if (child.length > 0) {
  1203. } else {
  1204. child = addChildren(50, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1205. }
  1206. }
  1207. if (child.length > 0) {//拆分
  1208. for(let j = 0; j < child.length; j++) {
  1209. data_normal_2.push(child[j]);
  1210. if (bc == 'true') {
  1211. for (let k = 0; k < data.length; k++) {
  1212. if (data[k][16] == child[j][16]) {
  1213. let datak2 = data[k][2];
  1214. if (child[j][2] == datak2) {//名称
  1215. } else {
  1216. if (mode > 0) {
  1217. } else {
  1218. huan = true;
  1219. }
  1220. }
  1221. }
  1222. }
  1223. } else if (mode != 1){
  1224. for (let k = 0; k < data.length; k++) {
  1225. if (data[k][16] == child[j][16]) {
  1226. let datak2 = data[k][2];
  1227. if (child[j][2] == datak2) {//名称
  1228. } else {
  1229. huan = true;
  1230. }
  1231. }
  1232. }
  1233. }
  1234. }
  1235. } else {
  1236. data_normal_2.push(data_normal[i]);
  1237. }
  1238. }
  1239. if (mode == 0) {
  1240. data_normal = copy(data);
  1241. } else if (mode == 2) {
  1242. data_normal = data.filter(x=>x[17]!='true');
  1243. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1244. } else if (mode == 1) {
  1245. data_normal = data_normal_2;
  1246. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1247. }
  1248. }
  1249. } else {//没有预拌
  1250. let data_normal_2 = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1251. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];
  1252. for(let i = 1; i < data_normal.length; i++) {
  1253. let bc = data_normal[i][17];
  1254. let child = addChildren(10, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1255. if (child.length > 0) {
  1256. } else {
  1257. child = addChildren(40, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1258. if (child.length > 0) {
  1259. } else {
  1260. child = addChildren(50, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1261. }
  1262. }
  1263. if (child.length > 0) {//拆分
  1264. for(let j = 0; j < child.length; j++) {
  1265. data_normal_2.push(child[j]);
  1266. if (bc == 'true') {
  1267. for (let k = 0; k < data.length; k++) {
  1268. if (data[k][16] == child[j][16]) {
  1269. let datak2 = data[k][2];
  1270. if (child[j][2] == datak2) {//名称
  1271. } else {
  1272. if (mode > 0) {
  1273. } else {
  1274. huan = true;
  1275. }
  1276. }
  1277. }
  1278. }
  1279. } else if (mode != 1){
  1280. for (let k = 0; k < data.length; k++) {
  1281. if (data[k][16] == child[j][16]) {
  1282. let datak2 = data[k][2];
  1283. if (child[j][2] == datak2) {//名称
  1284. } else {
  1285. huan = true;
  1286. }
  1287. }
  1288. }
  1289. }
  1290. }
  1291. } else {
  1292. data_normal_2.push(data_normal[i]);
  1293. }
  1294. }
  1295. if (mode == 0) {
  1296. data_normal = copy(data);
  1297. } else if (mode == 2) {
  1298. data_normal = data.filter(x=>x[17]!='true');
  1299. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1300. } else if (mode == 1) {
  1301. data_normal = data_normal_2;
  1302. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1303. }
  1304. }
  1305. data = copy(data_normal);
  1306. //模拟formula计算每一行的合价
  1307. for(let i = 1; i < data.length; i++) {
  1308. data[i][11] = Number(data[i][10]) * Number(data[i][5]);
  1309. }
  1310. let sum = 0;
  1311. let rgf_sum = 0;
  1312. let jxf_sum = 0;
  1313. let clf_sum = 0;
  1314. let zcf_sum = 0;
  1315. for(let i = 1; i < data.length; i++) {
  1316. console.log(data[i][1]);
  1317. if (data[i][1].includes('000FE') && data[i][4] == '%')continue;//azfy
  1318. if (data[i][1]=='00EXP001' && data[i][4] == '%'){//回程费占人工费
  1319. continue;
  1320. }
  1321. if (data[i][1]=='99EXP007' && data[i][4] == '%'){//回程费占机械费
  1322. continue;
  1323. }
  1324. if (data[i][1]=='99EXP022' && data[i][4] == '%'){//回程费占机械费
  1325. continue;
  1326. }
  1327. if (data[i][1]=='31130104' && data[i][4] == '%'){//回程费占材料费
  1328. continue;
  1329. }
  1330. sum += Number(data[i][11]);//11-> hejia
  1331. if (Number(data[i][8]) == 1) {
  1332. rgf_sum += Number(data[i][11]);
  1333. }
  1334. if (Number(data[i][8]) == 2) {
  1335. clf_sum += Number(data[i][11]);
  1336. if (data[i][14] == 'true') {
  1337. zcf_sum += Number(data[i][11]);
  1338. }
  1339. }
  1340. if (Number(data[i][8]) == 3) {
  1341. jxf_sum += Number(data[i][11]);
  1342. }
  1343. }
  1344. console.log("sum=".concat(sum));
  1345. //处理百分比费用
  1346. for(let i = 1; i < data.length; i++) {
  1347. if (data[i][1]=='00EXP001' && data[i][4] == '%'){//回程费占人工费
  1348. data[i][11] = Number(data[i][10]) * rgf_sum / Number(100);
  1349. }
  1350. if (data[i][1]=='99EXP007' && data[i][4] == '%'){//回程费占机械费
  1351. data[i][11] = Number(data[i][10]) * jxf_sum / Number(100);
  1352. }
  1353. if (data[i][1]=='99EXP022' && data[i][4] == '%'){//回程费占机械费
  1354. data[i][11] = Number(data[i][10]) * jxf_sum / Number(100);
  1355. }
  1356. if (data[i][1]=='31130104' && data[i][4] == '%'){//回程费占材料费
  1357. data[i][11] = Number(data[i][10]) * clf_sum / Number(100);
  1358. }
  1359. }
  1360. sum = 0;
  1361. rgf_sum = 0;
  1362. jxf_sum = 0;
  1363. clf_sum = 0;
  1364. zcf_sum = 0;
  1365. for(let i = 1; i < data.length; i++) {
  1366. sum += Number(data[i][11]);//11-> hejia
  1367. if (Number(data[i][8]) == 1) {
  1368. rgf_sum += Number(data[i][11]);
  1369. }
  1370. if (Number(data[i][8]) == 2) {
  1371. clf_sum += Number(data[i][11]);
  1372. if (data[i][14] == 'true') {
  1373. zcf_sum += Number(data[i][11]);
  1374. }
  1375. }
  1376. if (Number(data[i][8]) == 3) {
  1377. jxf_sum += Number(data[i][11]);
  1378. }
  1379. }
  1380. let shuliang = Number(qd['数量']);
  1381. for(let i = 0; i< qd["_children"].length; i++) {
  1382. if(qd["_children"][i]['key'] == row) {
  1383. let desl = Number(qd["_children"][i]['数量']);
  1384. let oldname = qd["_children"][i]['清单编码'];
  1385. qd["_children"][i]['辅材费'] = clf_sum - zcf_sum;
  1386. qd["_children"][i]['材料费'] = clf_sum;
  1387. qd["_children"][i]['人工费'] = rgf_sum;
  1388. qd["_children"][i]['主材费'] = zcf_sum;
  1389. qd["_children"][i]['设备费'] = 0;
  1390. qd["_children"][i]['机械费'] = jxf_sum;
  1391. if (oldname.startsWith("D")) {//单项清单
  1392. qd["_children"][i]['管理费'] = 0;
  1393. qd["_children"][i]['利润'] = 0;
  1394. } else {
  1395. if (this.qufeiEntry['备注'].length == 0) {
  1396. //changuiqufei
  1397. qd["_children"][i]['管理费'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1398. qd["_children"][i]['利润'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1399. } else {
  1400. qd["_children"][i]['管理费'] = (rgf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1401. qd["_children"][i]['利润'] = (rgf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1402. }
  1403. }
  1404. qd["_children"][i]['综合单价'] = sum + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
  1405. qd["_children"][i]['合价'] = (qd["_children"][i]['综合单价'] * shuliang * desl);
  1406. qd["_children"][i]["dercj"] = this.handleJGC(copy(data));
  1407. qd["_children"][i]['清单编码'] = renameDingE(oldname, xuhao, huan);
  1408. }
  1409. }
  1410. }
  1411. updateDercj(row, data) {
  1412. //是否手动设置含量
  1413. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1414. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1415. this.updateFootprint(qd['key']);
  1416. let bm = de['清单编码'];
  1417. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  1418. this.updateDercj_(row, data, alreadyFuzhu, de['yuban'], de['rcjbc']);
  1419. //let qd = this.cache.filter(x=>x["children"].filter(y=>y['key']==row).length > 0)[0];
  1420. let newData = this.cache.map(x=>{
  1421. if (x['key'] == qd['key']) {
  1422. return qd;
  1423. } else {
  1424. return x;
  1425. }
  1426. });
  1427. let summarized = this.summarize(newData);
  1428. this.push_op(summarized);
  1429. /////////////////
  1430. this.cache = copy(summarized);
  1431. return copy(this.cache);
  1432. }
  1433. updateDercj_djcs(row, data) {
  1434. //是否手动设置含量
  1435. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1436. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1437. let bm = de['清单编码'];
  1438. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  1439. this.updateDercj_djcs_(row, data, alreadyFuzhu);
  1440. //let qd = this.cache.filter(x=>x["children"].filter(y=>y['key']==row).length > 0)[0];
  1441. let newData = this.cache_djcs.map(x=>{
  1442. if (x['key'] == qd['key']) {
  1443. return qd;
  1444. } else {
  1445. return x;
  1446. }
  1447. });
  1448. let summarized = this.summarize_djcs(newData);
  1449. this.push_op_djcs(summarized);
  1450. /////////////////
  1451. this.cache_djcs = copy(summarized);
  1452. return copy(this.cache_djcs);
  1453. }
  1454. //xuhao=['1*1','3*1']
  1455. updateBeizhu(row, selected, xuhao) {//xuhao is for rename, selected is 结构化的处理信息
  1456. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1457. if (!qd) return [null, null];
  1458. this.updateFootprint(qd['key']);
  1459. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1460. if (de.hasOwnProperty("rcjdg")) {//底稿
  1461. } else {///老数据不能有底稿,附注功能也不使能
  1462. //de['rcjdg'] = copy(de['dercj']);
  1463. }
  1464. de['fuzhu'] = copy(selected);
  1465. this.updateDercj_(row, de['dercj'], xuhao, de['yuban'], de['rcjbc'], 1);
  1466. let newData = this.cache.map(x=>{
  1467. if (x['key'] == qd['key']) {
  1468. return qd;
  1469. } else {
  1470. return x;
  1471. }
  1472. });
  1473. let summarized = this.summarize(newData);
  1474. this.push_op(summarized);
  1475. /////////////////
  1476. this.cache = copy(summarized);
  1477. return [copy(this.cache), copy(de['dercj'])];
  1478. }
  1479. updateBeizhu_djcs(row, selected, xuhao) {//xuhao is for rename
  1480. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1481. if (!qd) return [null, null];
  1482. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1483. if (de.hasOwnProperty("rcjdg")) {//底稿
  1484. } else {///老数据不能有底稿,附注功能也不使能
  1485. //de['rcjdg'] = copy(de['dercj']);
  1486. }
  1487. de['fuzhu'] = copy(selected);
  1488. this.updateDercj_djcs_(row, de['dercj'], xuhao, 1);
  1489. let newData = this.cache_djcs.map(x=>{
  1490. if (x['key'] == qd['key']) {
  1491. return qd;
  1492. } else {
  1493. return x;
  1494. }
  1495. });
  1496. let summarized = this.summarize_djcs(newData);
  1497. this.push_op_djcs(summarized);
  1498. /////////////////
  1499. this.cache_djcs = copy(summarized);
  1500. return [copy(this.cache_djcs), copy(de['dercj'])];
  1501. }
  1502. huan(old_index, new_bianhao, new_name, new_jia, zhuanye, row) {
  1503. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1504. this.updateFootprint(qd['key']);
  1505. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1506. let rcj = copy(de['dercj']);
  1507. rcj[old_index][1] = new_bianhao;
  1508. rcj[old_index][2] = new_name;
  1509. rcj[old_index][5] = new_jia;
  1510. return this.updateDercj(row, rcj);
  1511. }
  1512. updateShuliang(value, row) {
  1513. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1514. this.updateFootprint(qd['key']);
  1515. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1516. let origin = de['数量']
  1517. if (Number(origin) - Number(value) < 0.0001 && Number(origin) - Number(value) > -0.0001) {
  1518. return [false, copy(this.cache)];
  1519. }
  1520. console.log("shuliang update");
  1521. de['数量'] = value;
  1522. de['合价'] = Number(qd['数量']) * Number(de['综合单价']) * Number(de['数量']);
  1523. let newData = this.cache.map(x=>{
  1524. if (x['key'] == qd['key']) {
  1525. return qd;
  1526. } else {
  1527. return x;
  1528. }
  1529. });
  1530. let summarized = this.summarize(newData);
  1531. this.push_op(summarized);
  1532. /////////////////
  1533. this.cache = copy(summarized);
  1534. return [true, copy(this.cache)];
  1535. }
  1536. updateDeMingcheng(value, row) {
  1537. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1538. this.updateFootprint(qd['key']);
  1539. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1540. de['名称'] = value;
  1541. let newData = this.cache.map(x=>{
  1542. if (x['key'] == qd['key']) {
  1543. return qd;
  1544. } else {
  1545. return x;
  1546. }
  1547. });
  1548. let summarized = this.summarize(newData);
  1549. this.push_op(summarized);
  1550. /////////////////
  1551. this.cache = copy(summarized);
  1552. return copy(this.cache);
  1553. }
  1554. updateShuliang_djcs(value, row) {
  1555. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1556. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1557. let origin = de['数量']
  1558. if (Number(origin) - Number(value) < 0.0001 && Number(origin) - Number(value) > -0.0001) {
  1559. return [false, null];
  1560. }
  1561. console.log("shuliang update");
  1562. de['数量'] = value;
  1563. de['合价'] = Number(qd['数量']) * Number(de['综合单价']) * Number(de['数量']);
  1564. let newData = this.cache_djcs.map(x=>{
  1565. if (x['key'] == qd['key']) {
  1566. return qd;
  1567. } else {
  1568. return x;
  1569. }
  1570. });
  1571. let summarized = this.summarize_djcs(newData);
  1572. this.push_op_djcs(summarized);
  1573. /////////////////
  1574. this.cache_djcs = copy(summarized);
  1575. return [true, copy(this.cache_djcs)];
  1576. }
  1577. azfy_djcs_eligible(selectedRow) {
  1578. if (this.cache_djcs.filter(x=>x['key'] == selectedRow).length > 0) {
  1579. return true;
  1580. } else {
  1581. return false;
  1582. }
  1583. }
  1584. azfy_djcs(row, dinge, selected) {
  1585. let res = JSON.parse(dinge);
  1586. let keys = Object.keys(res['DEBH']);
  1587. let key = keys[0];
  1588. let tips = null;
  1589. if (res['actual_zhuanye'] == 30) {
  1590. tips = azfy(res['DEBH'][key], res['GCLMC'][key]);
  1591. }
  1592. if (res['actual_zhuanye'] == 60) {
  1593. tips = xsazfy(res['DEBH'][key], res['GCLMC'][key]);
  1594. }
  1595. if (res['actual_zhuanye'] == 10) {
  1596. tips = tjazfy(res['DEBH'][key], res['GCLMC'][key]);
  1597. }
  1598. if (tips != null) {
  1599. res['rgde'] = tips['rgde'];
  1600. res['clde'] = tips['clde'];
  1601. res['jxde'] = tips['jxde'];
  1602. res['azfytag'] = tips['azfytag'];
  1603. }
  1604. let qd = this.cache_djcs.filter(x=>x['key'] == row)[0];
  1605. let dercj = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1606. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];
  1607. for(let i = 0; i < selected.length; i++) {
  1608. let rgf = selected[i]['人工费'];
  1609. let clf = selected[i]['材料费'];
  1610. let jxf = selected[i]['机械费'];
  1611. let sl = selected[i]['数量'];
  1612. if (res['azfytag'][0] == '人工费') {
  1613. let sum = Number(sl) * Number(rgf) * Number(res['azfytag'][1]) / Number(100);
  1614. dercj.push(['', res['rgde'][0]['CLBH'], res['rgde'][0]['CLMC'], '', '元',
  1615. '1', '', '', '1', '', Number(sum) * Number(res['azfytag'][2]) / Number(100), Number(sum) * Number(res['azfytag'][2]) / Number(100),
  1616. '', '', '', '', uuidv4(), '' ]);
  1617. dercj.push(['', res['clde'][0]['CLBH'], res['clde'][0]['CLMC'], '', '元',
  1618. '1', '', '', '2', '', Number(sum) * Number(res['azfytag'][3]) / Number(100), Number(sum) * Number(res['azfytag'][3]) / Number(100),
  1619. '', '', '', '', uuidv4(), '' ]);
  1620. dercj.push(['', res['jxde'][0]['jxbh'], res['jxde'][0]['jxmc'], '', '元',
  1621. '1', '', '', '3', '', Number(sum) * Number(res['azfytag'][4]) / Number(100), Number(sum) * Number(res['azfytag'][4]) / Number(100),
  1622. '', '', '', '', uuidv4(), '' ]);
  1623. } else if (res['azfytag'][0] == '人工费+机械费') {
  1624. let sum = Number(sl) * (Number(jxf) + Number(rgf)) * Number(res['azfytag'][1]) / Number(100);
  1625. dercj.push(['', res['rgde'][0]['CLBH'], res['rgde'][0]['CLMC'], '', '元',
  1626. '1', '', '', '1', '', Number(sum) * Number(res['azfytag'][2]) / Number(100), Number(sum) * Number(res['azfytag'][2]) / Number(100),
  1627. '', '', '', '', uuidv4(), '' ]);
  1628. dercj.push(['', res['clde'][0]['CLBH'], res['clde'][0]['CLMC'], '', '元',
  1629. '1', '', '', '2', '', Number(sum) * Number(res['azfytag'][3]) / Number(100), Number(sum) * Number(res['azfytag'][3]) / Number(100),
  1630. '', '', '', '', uuidv4(), '' ]);
  1631. dercj.push(['', res['jxde'][0]['jxbh'], res['jxde'][0]['jxmc'], '', '元',
  1632. '1', '', '', '3', '', Number(sum) * Number(res['azfytag'][4]) / Number(100), Number(sum) * Number(res['azfytag'][4]) / Number(100),
  1633. '', '', '', '', uuidv4(), '' ]);
  1634. }
  1635. }
  1636. let newKey = uuidv4();
  1637. if (!qd.hasOwnProperty('_children')) {
  1638. qd["_children"] = [];
  1639. }
  1640. qd["_children"].push({
  1641. '操作': '',
  1642. '序号': null,
  1643. '清单编码': res['DEBH'][key],
  1644. '名称': res['GCLMC'][key],
  1645. '项目特征': null,
  1646. '计算规则': tips != null ? tips['sm'] : '',
  1647. '单位': res['DW'][key],
  1648. '数量': '1',
  1649. '综合单价': '0',
  1650. '合价': '0',
  1651. '人工费': '0',
  1652. '主材费': '0',
  1653. '设备费': '0',
  1654. '辅材费': '0',
  1655. '材料费': '0',
  1656. '机械费': '0',
  1657. '管理费': '0',
  1658. '利润': '0',
  1659. '暂估价': null,
  1660. '综合人工工日': null,
  1661. '备注': null,
  1662. "dercj": dercj,
  1663. '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]]),
  1664. 'key' : newKey,
  1665. "fuzhuEnable": false,
  1666. 'yuban': [],
  1667. 'rcjbc': [],
  1668. 'azfytag': []
  1669. });
  1670. this.updateDercj_djcs_(newKey, dercj, []);
  1671. let summarized = this.summarize_djcs(this.cache_djcs);
  1672. this.push_op_djcs(copy(summarized));
  1673. this.cache_djcs = copy(summarized);
  1674. return [true, copy(this.cache_djcs), newKey];
  1675. }
  1676. changguidinge_djcs(dingeclick, row) {
  1677. if (this.cache_djcs.filter(x=>x['key'] == row).length > 0) {
  1678. let res =dingeclick;
  1679. let keys = Object.keys(res['DEBH']);
  1680. let key = keys[0];
  1681. //console.log(res);
  1682. let qd = this.cache_djcs.filter(x=>x['key'] == row)[0];
  1683. let dercj = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1684. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", "key", 'bc']];
  1685. for(let i = 0; i < res['rgde'].length; i++) {
  1686. dercj.push(['', res['rgde'][i]['CLBH'], res['rgde'][i]['CLMC'], '', res['rgde'][i]['JLDW'],
  1687. res['rgde'][i]['YSJG'], '', '', '1', '', res['rgde'][i]['gr'], res['rgde'][i]['gf'],
  1688. '', '', '', '', uuidv4(), "false" ]);
  1689. }
  1690. for(let i = 0; i < res['clde'].length; i++) {
  1691. let hit = false;
  1692. let jg = null;
  1693. let bh = res['clde'][i]['CLBH'];
  1694. for(let j = 0; j < this.jiagongcai.length; j++) {
  1695. if (this.jiagongcai[j]['材料编号'] == bh) {
  1696. hit = true;
  1697. jg = this.jiagongcai[j]['单价'];
  1698. }
  1699. }
  1700. if (hit) {
  1701. dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  1702. jg, '', '', '2', 'true', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  1703. '', '', '', '', uuidv4(), 'false' ]);
  1704. } else {
  1705. /* if (res['clde'][i].hasOwnProperty('children')) {
  1706. let parent = uuidv4();
  1707. let children = [];
  1708. let child_data = res['clde'][i]['children'];
  1709. for(let j = 0; j < child_data.length; j++) {
  1710. let id = uuidv4();
  1711. children.push(id);
  1712. dercj.push(['', child_data[j]['CLBH'], child_data[j]['CLMC'], '', child_data[j]['JLDW'],
  1713. child_data[j]['YSJG'], '', '', '2', 'false', child_data[j]['SL'], child_data[j]['HJ'],
  1714. '', '', '', '', id, 'false','false', [parent], [] ]);
  1715. }
  1716. dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  1717. res['clde'][i]['YSJG'], '', '', '2', 'false', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  1718. '', '', '', '', parent, 'false','true', [], children ]);
  1719. } else {*/
  1720. dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  1721. res['clde'][i]['YSJG'], '', '', '2', 'false', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  1722. '', '', '', '', uuidv4(), 'false' ]);
  1723. }
  1724. }
  1725. for(let i = 0; i < res['jxde'].length; i++) {
  1726. dercj.push(['', res['jxde'][i]['jxbh'], res['jxde'][i]['jxmc'], '', res['jxde'][i]['DW'],
  1727. res['jxde'][i]['tbdj'], '', '', '3', '', res['jxde'][i]['sl'], res['jxde'][i]['hj'],
  1728. '', '', '', '',uuidv4(), 'false' ]);
  1729. }
  1730. let newKey = uuidv4();
  1731. if (!qd.hasOwnProperty('_children')) {
  1732. qd["_children"] = [];
  1733. }
  1734. 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]]);
  1735. qd["_children"].push({
  1736. '操作': '',
  1737. '序号': null,
  1738. '清单编码': res['DEBH'][key],
  1739. '名称': res['GCLMC'][key],
  1740. '项目特征': null,
  1741. '计算规则': null,
  1742. '单位': res['DW'][key],
  1743. '数量': '1',
  1744. '综合单价': '0',
  1745. '合价': '0',
  1746. '人工费': '0',
  1747. '主材费': '0',
  1748. '设备费': '0',
  1749. '辅材费': '0',
  1750. '材料费': '0',
  1751. '机械费': '0',
  1752. '管理费': '0',
  1753. '利润': '0',
  1754. '暂估价': null,
  1755. '综合人工工日': null,
  1756. '备注': null,
  1757. "dercj": newdercj,
  1758. 'rcjdg': dercj,
  1759. 'key' : newKey,
  1760. "fuzhuEnable": true
  1761. });
  1762. this.updateDercj_djcs_(newKey, newdercj, []);
  1763. let summarized = this.summarize_djcs(this.cache_djcs);
  1764. this.push_op_djcs(copy(summarized));
  1765. /////////////////
  1766. this.cache_djcs = copy(summarized);
  1767. //return copy(this.cache);
  1768. return [true, copy(this.cache_djcs), newKey];
  1769. } else {
  1770. return [false, null, null];
  1771. }
  1772. }
  1773. changguidinge(dingeclick, row) {
  1774. if (this.cache.filter(x=>x['key'] == row).length > 0) {
  1775. this.updateFootprint(row);
  1776. let res = copy(dingeclick);
  1777. let keys = Object.keys(res['DEBH']);
  1778. let key = keys[0];
  1779. let tips = null;
  1780. if (res['actual_zhuanye'] == 30) {
  1781. tips = azfy(res['DEBH'][key], res['GCLMC'][key]);
  1782. }
  1783. if (res['actual_zhuanye'] == 60) {
  1784. tips = xsazfy(res['DEBH'][key], res['GCLMC'][key]);
  1785. }
  1786. if (res['actual_zhuanye'] == 10) {
  1787. tips = tjazfy(res['DEBH'][key], res['GCLMC'][key]);
  1788. }
  1789. if (tips != null) {
  1790. res['rgde'] = tips['rgde'];
  1791. res['clde'] = tips['clde'];
  1792. res['jxde'] = tips['jxde'];
  1793. }
  1794. let qd = this.cache.filter(x=>x['key'] == row)[0];
  1795. let dercj = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1796. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];
  1797. for(let i = 0; i < res['rgde'].length; i++) {
  1798. dercj.push(['', res['rgde'][i]['CLBH'], res['rgde'][i]['CLMC'], '', res['rgde'][i]['JLDW'],
  1799. res['rgde'][i]['YSJG'], '', '', '1', '', res['rgde'][i]['gr'], res['rgde'][i]['gf'],
  1800. '', '', '', '', uuidv4(), 'false' ]);
  1801. }
  1802. for(let i = 0; i < res['clde'].length; i++) {
  1803. let hit = false;
  1804. let jg = null;
  1805. let bh = res['clde'][i]['CLBH'];
  1806. for(let j = 0; j < this.jiagongcai.length; j++) {
  1807. if (this.jiagongcai[j]['材料编号'] == bh) {
  1808. hit = true;
  1809. jg = this.jiagongcai[j]['单价'];
  1810. }
  1811. }
  1812. if (hit) {
  1813. dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  1814. jg, '', '', '2', 'true', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  1815. '', '', '', '', uuidv4(), 'false' ]);
  1816. } else {
  1817. /*if (res['clde'][i].hasOwnProperty('children') && res['clde'][i]['CLMC'].includes('砂浆')) {
  1818. let parent = uuidv4();
  1819. let children = [];
  1820. let child_data = res['clde'][i]['children'];
  1821. for(let j = 0; j < child_data.length; j++) {
  1822. let id = uuidv4();
  1823. children.push(id);
  1824. dercj.push(['', child_data[j]['CLBH'], child_data[j]['CLMC'], '', child_data[j]['JLDW'],
  1825. child_data[j]['YSJG'], '', '', '2', 'false', child_data[j]['SL'], child_data[j]['HJ'],
  1826. '', '', '', '', id, 'false','false', [parent], [] ]);
  1827. }
  1828. dercj.push(['', res['clde'][i]['CLBH'].toString(), res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  1829. res['clde'][i]['YSJG'], '', '', '2', 'false', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  1830. '', '', '', '', parent, 'false','true', [], children ]);
  1831. } else {*/
  1832. dercj.push(['', res['clde'][i]['CLBH'].toString(), res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  1833. res['clde'][i]['YSJG'], '', '', '2', 'false', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  1834. '', '', '', '', uuidv4(), 'false' ]);
  1835. }
  1836. }
  1837. for(let i = 0; i < res['jxde'].length; i++) {
  1838. dercj.push(['', res['jxde'][i]['jxbh'], res['jxde'][i]['jxmc'], '', res['jxde'][i]['DW'],
  1839. res['jxde'][i]['tbdj'], '', '', '3', '', res['jxde'][i]['sl'], res['jxde'][i]['hj'],
  1840. '', '', '', '', uuidv4(), 'false']);
  1841. }
  1842. let newKey = uuidv4();
  1843. if (!qd.hasOwnProperty('_children')) {
  1844. qd["_children"] = [];
  1845. }
  1846. 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]]);
  1847. qd["_children"].push({
  1848. '操作': '',
  1849. '序号': null,
  1850. '清单编码': res['DEBH'][key],
  1851. '名称': res['GCLMC'][key],
  1852. '项目特征': null,
  1853. '计算规则': tips != null ? tips['sm'] : '',
  1854. '单位': res['DW'][key],
  1855. '数量': '1',
  1856. '综合单价': '0',
  1857. '合价': '0',
  1858. '人工费': '0',
  1859. '主材费': '0',
  1860. '设备费': '0',
  1861. '辅材费': '0',
  1862. '材料费': '0',
  1863. '机械费': '0',
  1864. '管理费': '0',
  1865. '利润': '0',
  1866. '暂估价': null,
  1867. '综合人工工日': null,
  1868. '备注': null,
  1869. "dercj": newdercj,
  1870. 'rcjdg': (dercj),
  1871. 'key' : newKey,
  1872. "fuzhuEnable": true,
  1873. 'yuban': [],
  1874. 'rcjbc': [],
  1875. 'azfytag': tips != null ? tips['azfytag'] : []
  1876. });
  1877. this.updateDercj_(newKey, dercj, [], [], [], 1);
  1878. let summarized = this.summarize(this.cache);
  1879. this.push_op(copy(summarized));
  1880. /////////////////
  1881. this.cache = copy(summarized);
  1882. //return copy(this.cache);
  1883. return [true, copy(this.cache), newKey];
  1884. } else {
  1885. return [false, null, null];
  1886. }
  1887. }
  1888. danxiangdinge(row, maxN, extra) {
  1889. //let bh = danxiangdinge_index(this.cache);
  1890. let result = (maxN + 1).toString();
  1891. result = result.padStart(5, '0');
  1892. let bh= "D".concat(result);
  1893. if (this.cache.filter(x=>x['key'] == row).length > 0) {
  1894. this.updateFootprint(row);
  1895. let selected = this.cache.filter(x=>x['key'] == row)[0];
  1896. let danwei = selected["单位"];
  1897. let mingcheng = extra;//selected['名称'];
  1898. let children = selected["_children"];
  1899. children.push({
  1900. '操作': '',
  1901. '序号': null,
  1902. '清单编码': bh,
  1903. '名称': mingcheng,
  1904. '项目特征': null,
  1905. '计算规则': null,
  1906. '单位': danwei,
  1907. '数量': '1',
  1908. '综合单价': '',
  1909. '合价': '',
  1910. '人工费': '0',
  1911. '主材费': '0',
  1912. '设备费': '0',
  1913. '辅材费': '',
  1914. '材料费': '',
  1915. '机械费': '0',
  1916. '管理费': '0',
  1917. '利润': '0',
  1918. '暂估价': null,
  1919. '综合人工工日': null,
  1920. '备注': null,
  1921. "dercj": [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1922. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ],
  1923. ['', bh, mingcheng, '', danwei, '', '', '', '2', '', '1', '', '', '', '', '', uuidv4(), '' ]
  1924. ],
  1925. 'key' : uuidv4(),
  1926. "fuzhuEnable": false,
  1927. 'yuban': [],
  1928. 'rcjbc' : [],
  1929. 'azfytag': []
  1930. });
  1931. let summarized = this.summarize(this.cache);
  1932. this.push_op(summarized);
  1933. this.cache = copy(summarized);
  1934. return [true, copy(this.cache)];
  1935. } else {
  1936. return [false,null];
  1937. }
  1938. }
  1939. danxiangdinge_djcs(row) {
  1940. let bh = danxiangdinge_index_djcs(this.cache_djcs);
  1941. if (this.cache_djcs.filter(x=>x['key'] == row).length > 0) {
  1942. let selected = this.cache_djcs.filter(x=>x['key'] == row)[0];
  1943. let danwei = selected["单位"];
  1944. let mingcheng = selected['名称'];
  1945. let children = selected["_children"];
  1946. children.push({
  1947. '序号': null,
  1948. '清单编码': bh,
  1949. '名称': mingcheng,
  1950. '项目特征': null,
  1951. '计算规则': null,
  1952. '单位': danwei,
  1953. '数量': '1',
  1954. '综合单价': '',
  1955. '合价': '',
  1956. '人工费': '0',
  1957. '主材费': '0',
  1958. '设备费': '0',
  1959. '辅材费': '',
  1960. '材料费': '',
  1961. '机械费': '0',
  1962. '管理费': '0',
  1963. '利润': '0',
  1964. '暂估价': null,
  1965. '综合人工工日': null,
  1966. '备注': null,
  1967. "dercj": [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1968. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", "key" , "bc" ],
  1969. ['', bh, mingcheng, '', danwei, '', '', '', '2', '', '1', '', '', '', '', '', uuidv4(), "" ]
  1970. ],
  1971. 'key' : uuidv4(),
  1972. "fuzhuEnable": false
  1973. });
  1974. let summarized = this.summarize_djcs(this.cache_djcs);
  1975. this.push_op_djcs(summarized);
  1976. this.cache_djcs = copy(summarized);
  1977. return [true, copy(this.cache_djcs)];
  1978. } else {
  1979. return [false,null];
  1980. }
  1981. }
  1982. handleYuban(row, selected) {
  1983. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1984. if (!qd) return [null, null];
  1985. this.updateFootprint(qd['key']);
  1986. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1987. let bm = de['清单编码'];
  1988. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  1989. if (de.hasOwnProperty("rcjdg")) {//底稿
  1990. } else {///老数据不能有底稿,附注功能也不使能,预拌也不能使
  1991. //de['rcjdg'] = copy(de['dercj']);
  1992. }
  1993. de['yuban'] = copy(selected);
  1994. this.updateDercj_(row, de['dercj'], alreadyFuzhu, selected, de['rcjbc'], 1);
  1995. let newData = this.cache.map(x=>{
  1996. if (x['key'] == qd['key']) {
  1997. return qd;
  1998. } else {
  1999. return x;
  2000. }
  2001. });
  2002. let summarized = this.summarize(newData);
  2003. this.push_op(summarized);
  2004. /////////////////
  2005. this.cache = copy(summarized);
  2006. return [copy(this.cache), copy(de['dercj'])];
  2007. }
  2008. handleRcjbc(row, rcjbc) {
  2009. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  2010. if (!qd) return [null, null];
  2011. this.updateFootprint(qd['key']);
  2012. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  2013. let bm = de['清单编码'];
  2014. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  2015. if (de.hasOwnProperty("rcjdg")) {//底稿
  2016. } else {///老数据不能有底稿,附注功能也不使能,预拌也不能使
  2017. //de['rcjdg'] = copy(de['dercj']);
  2018. }
  2019. de['rcjbc'] = copy(rcjbc);
  2020. this.updateDercj_(row, de['dercj'], alreadyFuzhu, de['yuban'], rcjbc, 2);
  2021. let newData = this.cache.map(x=>{
  2022. if (x['key'] == qd['key']) {
  2023. return qd;
  2024. } else {
  2025. return x;
  2026. }
  2027. });
  2028. let summarized = this.summarize(newData);
  2029. this.push_op(summarized);
  2030. /////////////////
  2031. this.cache = copy(summarized);
  2032. return [copy(this.cache), copy(de['dercj'])];
  2033. }
  2034. handleJGC(input) {
  2035. for (let i = 0;i < input.length; i++) {
  2036. let bh = input[i][1];
  2037. let hit = false;
  2038. let jg = 0;
  2039. for(let j = 0; j < this.jiagongcai.length; j++) {
  2040. if (this.jiagongcai[j]['材料编号'] == bh) {
  2041. hit = true;
  2042. //jg = this.jiagongcai[j]['单价'];
  2043. }
  2044. }
  2045. if (hit) {
  2046. input[i][9] = 'true';
  2047. }
  2048. }
  2049. return input;
  2050. }
  2051. current(){
  2052. return copy(this.cache)
  2053. }
  2054. }
  2055. export default new Service();