Service.js 97 KB

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