Service.js 123 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027
  1. import {copy, danxiangdinge_index, danxiangdinge_index_djcs, renameDingE, extractFuzhu, match_target, azfy, xsazfy, tjazfy, addChildren, translate, translate2} from './utils';
  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. this.task={};
  30. }
  31. setToken(token) {
  32. this.token_ = token;
  33. }
  34. ip() {
  35. //return "/api"//return "http://127.0.0.1:8000"
  36. return "http://www.xiaozaotongxue.com/api"
  37. }
  38. clearCache() {//set qufei will clear cache
  39. this.cache = [];
  40. this.footprint= [];
  41. this.memory = [];
  42. this.mem_pointer = -1;
  43. this.cache_djcs = [];
  44. this.memory_djcs = [];
  45. this.mem_pointer_djcs = -1;
  46. this.task={};
  47. }
  48. setQufei(data) {
  49. let result = [];
  50. for(let i = 0; i < data[0]['children'].length; i++) {
  51. let child = data[0]['children'][i];
  52. for(let j = 0; j < child['children'].length; j++) {
  53. let grandchild = child['children'][j];
  54. //console.log(grandchild);
  55. result.push(grandchild);
  56. }
  57. }
  58. this.qufei = result;
  59. }
  60. setJiagongcai(data) {
  61. this.jiagongcai = data;
  62. }
  63. setQufeiEntry(bh) {
  64. this.qufeiEntry = this.qufei.filter(x=>x['key'] == bh)[0];
  65. }
  66. processDjcsmingxi(mingxi) {
  67. this.cache_djcs = copy(mingxi);
  68. for(let i = 0; i < this.cache_djcs.length; i++) {
  69. let zimu = this.cache_djcs[i];
  70. if (!zimu.hasOwnProperty("_children")) {
  71. zimu["_children"] = [];
  72. }
  73. if (!zimu.hasOwnProperty("rcj")) {
  74. zimu["rcj"] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  75. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
  76. }
  77. }
  78. for(let i = 0; i < this.cache_djcs.length; i++) {
  79. let zimu = this.cache_djcs[i];
  80. for(let j = 0; j < zimu["_children"].length; j++) {
  81. let de = zimu["_children"][j];
  82. if (!de.hasOwnProperty("dercj")) {
  83. de["dercj"] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  84. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
  85. }
  86. }
  87. }
  88. this.cache_djcs = this.cache_djcs.map(x=>{
  89. //x["children"] = x["__children"];
  90. x["key"] = x["序号"];
  91. x["_children"] = x["_children"].map(y=>{
  92. if (!y.hasOwnProperty('key')) {
  93. y['key'] = uuidv4();
  94. }
  95. return y;
  96. })
  97. return x;
  98. });
  99. this.memory_djcs = [];
  100. this.memory_djcs.push(copy(this.cache_djcs));
  101. this.mem_pointer_djcs = 0;
  102. }
  103. processQingdanmingxi(mingxi) {
  104. this.cache = copy(mingxi);
  105. for(let i = 0; i < this.cache.length; i++) {
  106. let zimu = this.cache[i];
  107. if (!zimu.hasOwnProperty("__children")) {
  108. zimu["__children"] = [];
  109. }
  110. if (!zimu.hasOwnProperty("rcj")) {
  111. zimu["rcj"] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  112. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
  113. }
  114. }
  115. for(let i = 0; i < this.cache.length; i++) {
  116. let zimu = this.cache[i];
  117. for(let j = 0; j < zimu["__children"].length; j++) {
  118. let de = zimu["__children"][j];
  119. if (!de.hasOwnProperty("dercj")) {
  120. de["dercj"] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  121. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
  122. }
  123. }
  124. }
  125. this.cache = this.cache.map(x=>{
  126. x["_children"] = x["__children"];
  127. x["key"] = x["序号"];
  128. x["_children"] = x["_children"].map(y=>{
  129. if (!y.hasOwnProperty('key')) {
  130. y['key'] = uuidv4();
  131. }
  132. return y;
  133. })
  134. return x;
  135. });
  136. this.memory = [];
  137. this.footprint = [];
  138. this.memory.push(copy(this.cache));
  139. this.mem_pointer = 0;
  140. }
  141. async generateXxj(city, month, navigate) {
  142. const response = await fetch(this.ip().concat( "/xxj/"), {
  143. method : "POST",
  144. headers: {
  145. "Content-type": "application/json",
  146. 'Authorization': `Bearer ${this.token_}`
  147. },
  148. body: JSON.stringify({
  149. city: city,
  150. month: month
  151. })
  152. });
  153. if (!response.ok) {
  154. if (response.status == 401) {
  155. navigate("/editor/signin");
  156. }
  157. } else {
  158. const data_ = await response.json();
  159. return data_;
  160. }
  161. }
  162. async generateLsj(bianma, mingcheng, danwei, navigate) {
  163. const response = await fetch(this.ip().concat( "/lsj/"), {
  164. method : "POST",
  165. headers: {
  166. "Content-type": "application/json",
  167. 'Authorization': `Bearer ${this.token_}`
  168. },
  169. body: JSON.stringify({
  170. bianma: bianma,
  171. mingcheng: mingcheng,
  172. danwei: danwei
  173. })
  174. });
  175. if (!response.ok) {
  176. if (response.status == 401) {
  177. navigate("/editor/signin");
  178. }
  179. } else {
  180. const data_ = await response.json();
  181. return data_;
  182. }
  183. }
  184. async jgfb(bianma, mingcheng, danwei) {
  185. const response = await fetch(this.ip().concat( "/jgfb/"), {
  186. method : "POST",
  187. headers: {
  188. "Content-type": "application/json",
  189. 'Authorization': `Bearer ${this.token_}`
  190. },
  191. body: JSON.stringify(
  192. {
  193. "bianma": bianma,
  194. "mingcheng": mingcheng,
  195. "danwei": danwei
  196. }
  197. )
  198. });
  199. if (!response.ok) {
  200. //const error = await response.json();
  201. console.error('error');
  202. } else {
  203. const data = await response.json();
  204. return data;
  205. }
  206. }
  207. async generateRencaijihuizong2(name, id, navigate) {
  208. const response = await fetch(this.ip().concat( "/rencaijihuizong2/"), {
  209. method : "POST",
  210. headers: {
  211. "Content-type": "application/json",
  212. 'Authorization': `Bearer ${this.token_}`
  213. },
  214. body: JSON.stringify({
  215. name: name,
  216. id: id
  217. })
  218. });
  219. if (!response.ok) {
  220. if (response.status == 401) {
  221. navigate("/editor/signin");
  222. }
  223. } else {
  224. const data_ = await response.json();
  225. const data = data_['rcjhz']
  226. let result = [];
  227. for (let i = 1; i < data.length; i++) {
  228. if(Number(data[i][5])>0.0001){
  229. console.log(data[i][5])
  230. result.push({
  231. 'key': uuidv4(),
  232. 'ID' : data[i][0],
  233. '编码' : data[i][1],
  234. '名称': data[i][2],
  235. '规格型号' : data[i][3],
  236. '单位' : data[i][4],
  237. '数量' : data[i][5],
  238. '单价' : data[i][6],
  239. '合价' : data[i][7],
  240. '产地' : data[i][8],
  241. '供应厂商' : data[i][9],
  242. '人材机类别' : data[i][10],
  243. '主要材料标志' : data[i][11],
  244. '主材标志' : data[i][12],
  245. '设备标志' : data[i][13],
  246. '甲供标志' : data[i][14],
  247. '暂估价标志' : data[i][15]
  248. });
  249. }
  250. }
  251. this.setQufeiEntry(id);
  252. return {'rcjhz': result, 'jxchaifen': data_['jxchaifen']};
  253. }
  254. }
  255. /////////////////////////////////////qingdan//////////////////////////////////////
  256. async generateQingdanmingxi(name, bh, bt) {
  257. if (bt == 'ALL') {
  258. const response = await fetch(this.ip().concat("/qingdanmingxi/"), {
  259. method : "POST",
  260. headers: {
  261. "Content-type": "application/json",
  262. 'Authorization': `Bearer ${this.token_}`
  263. },
  264. body: JSON.stringify(
  265. {
  266. "bh": bh,
  267. "bt": bt,
  268. "name": name
  269. }
  270. )
  271. });
  272. if (!response.ok) {
  273. //const error = await response.json();
  274. console.error('error');
  275. } else {
  276. const data = await response.json();
  277. return data;
  278. }
  279. } else {
  280. if (this.cache.length == 0 || this.cache[0]["biao_id"] != name || this.cache[0]["Dwgcbh"] != bh || this.cache[0]["bt"] != bt) {
  281. const response = await fetch(this.ip().concat("/qingdanmingxi/"), {
  282. method : "POST",
  283. headers: {
  284. "Content-type": "application/json",
  285. 'Authorization': `Bearer ${this.token_}`
  286. },
  287. body: JSON.stringify(
  288. {
  289. "bh": bh,
  290. "bt": bt,
  291. "name": name
  292. }
  293. )
  294. });
  295. if (!response.ok) {
  296. //const error = await response.json();
  297. console.error('error');
  298. } else {
  299. const data = await response.json();
  300. this.processQingdanmingxi(data);
  301. this.setQufeiEntry(bh);
  302. return copy(this.cache);
  303. }
  304. } else {
  305. return copy(this.cache);
  306. }
  307. }
  308. }
  309. async generateQingdanrcj(name, bh, bt, bm) {
  310. if (bt == "Djcs") {
  311. let qd = this.cache_djcs.filter(x=>x["清单编码"] == bm)[0];
  312. return copy(qd["rcj"]);
  313. }
  314. let qd = this.cache.filter(x=>x["清单编码"] == bm)[0];
  315. return copy(qd["rcj"]);
  316. }
  317. async generateDingercj(name, bh, bt, qdbm, debm, danwei, key) {
  318. console.log('generateDingercj');
  319. console.log(debm);
  320. if (bt == 'Djcs') {
  321. let qd = this.cache_djcs.filter(x=>x["清单编码"] == qdbm)[0];
  322. let de = qd["_children"].filter(x=>x["清单编码"]==debm && x['key'] == key)[0];
  323. return [copy(de["dercj"]), de["fuzhuEnable"], de['yuban']];
  324. }
  325. let qd = this.cache.filter(x=>x["清单编码"] == qdbm)[0];
  326. let de = qd["_children"].filter(x=>x["清单编码"]==debm && x['key'] == key)[0];
  327. return [copy(de["dercj"]), de["fuzhuEnable"], de['yuban'], de['rcjbc']];
  328. }
  329. /////////////////////////////end of qingdan////////////////////////////////////
  330. async generateDjcs(name, bh, navigate) {
  331. if (this.cache_djcs.length == 0 || this.cache_djcs[0]["biao_id"] != name || this.cache_djcs[0]["Dwgcbh"] != bh) {
  332. const response = await fetch(this.ip().concat( "/djcs/"), {
  333. method : "POST",
  334. headers: {
  335. "Content-type": "application/json",
  336. 'Authorization': `Bearer ${this.token_}`
  337. },
  338. body: JSON.stringify(
  339. {
  340. "bh": bh,
  341. "name": name
  342. }
  343. )
  344. });
  345. if (!response.ok) {
  346. if (response.status == 401) {
  347. navigate("/editor/signin");
  348. }
  349. } else {
  350. const data = await response.json();
  351. this.processDjcsmingxi(data);
  352. this.setQufeiEntry(bh);
  353. return copy(this.cache_djcs);
  354. }
  355. } else {
  356. return copy(this.cache_djcs);
  357. }
  358. }
  359. async save() {
  360. const response = await fetch(this.ip().concat( "/save/"), {
  361. method : "POST",
  362. headers: {
  363. "Content-type": "application/json",
  364. 'Authorization': `Bearer ${this.token_}`
  365. },
  366. body: JSON.stringify(
  367. {
  368. "name": JSON.stringify(this.cache.filter(x=>this.footprint.includes(x['key'])))
  369. }
  370. )
  371. });
  372. if (!response.ok) {
  373. //const error = await response.json();
  374. console.error('error');
  375. } else {
  376. const data = await response.json();
  377. this.footprint = [];
  378. return data;
  379. }
  380. }
  381. async save_djcs() {
  382. const response = await fetch(this.ip().concat( "/savedjcs/"), {
  383. method : "POST",
  384. headers: {
  385. "Content-type": "application/json",
  386. 'Authorization': `Bearer ${this.token_}`
  387. },
  388. body: JSON.stringify(
  389. {
  390. "name": JSON.stringify(this.cache_djcs)
  391. }
  392. )
  393. });
  394. if (!response.ok) {
  395. //const error = await response.json();
  396. console.error('error');
  397. } else {
  398. const data = await response.json();
  399. return data;
  400. }
  401. }
  402. async rgtz(biao_id, bh, yi, er, san) {
  403. let glf = "";
  404. let lr = "";
  405. let bz = 0;//changgui
  406. if (this.qufeiEntry['备注'].length == 0) {
  407. //changuiqufei
  408. glf = this.qufeiEntry['管理费(%)'] ;
  409. lr = this.qufeiEntry['利润(%)'];
  410. } else {
  411. glf = this.qufeiEntry['管理费(%)'] ;
  412. lr = this.qufeiEntry['利润(%)'];
  413. bz = 1;
  414. }
  415. const response = await fetch(this.ip().concat( "/rgtz/"), {
  416. method : "POST",
  417. headers: {
  418. "Content-type": "application/json",
  419. 'Authorization': `Bearer ${this.token_}`
  420. },
  421. body: JSON.stringify(
  422. {
  423. "biao_id": biao_id,
  424. "bh": bh,
  425. "yi" : yi,
  426. "er" : er,
  427. "san" : san,
  428. "glf": glf,
  429. "lr": lr,
  430. 'bz' : bz
  431. }
  432. )
  433. });
  434. if (!response.ok) {
  435. //const error = await response.json();
  436. console.error('error');
  437. } else {
  438. const data = await response.json();
  439. this.clearCache();
  440. return data;
  441. }
  442. }
  443. async jxtz(biao_id, bh, data) {
  444. let glf = "";
  445. let lr = "";
  446. let bz = 0;//changgui
  447. if (this.qufeiEntry['备注'].length == 0) {
  448. //changuiqufei
  449. glf = this.qufeiEntry['管理费(%)'] ;
  450. lr = this.qufeiEntry['利润(%)'];
  451. } else {
  452. glf = this.qufeiEntry['管理费(%)'] ;
  453. lr = this.qufeiEntry['利润(%)'];
  454. bz = 1;
  455. }
  456. let gong = 0
  457. let chaiyou = 0
  458. let qiyou = 0
  459. let dian = 0
  460. for (let i = 0; i < data.length; i++) {
  461. if( data[i]['名称'].includes('工') ){
  462. gong = data[i]['单价']
  463. }
  464. if( data[i]['名称'].includes('柴')) {
  465. chaiyou = data[i]['单价']
  466. }
  467. if (data[i]['名称'].includes('汽')) {
  468. qiyou = data[i]['单价']
  469. }
  470. if (data[i]['名称'].includes('电')) {
  471. dian = data[i]['单价']
  472. }
  473. }
  474. const response = await fetch(this.ip().concat( "/jxtz/"), {
  475. method : "POST",
  476. headers: {
  477. "Content-type": "application/json",
  478. 'Authorization': `Bearer ${this.token_}`
  479. },
  480. body: JSON.stringify(
  481. {
  482. "biao_id": biao_id,
  483. "bh": bh,
  484. "glf": glf,
  485. "lr": lr,
  486. 'bz' : bz,
  487. 'gong': gong,
  488. 'chaiyou': chaiyou,
  489. 'qiyou': qiyou,
  490. 'dian' : dian
  491. }
  492. )
  493. });
  494. if (!response.ok) {
  495. //const error = await response.json();
  496. console.error('error');
  497. } else {
  498. const data = await response.json();
  499. this.clearCache();
  500. return data;
  501. }
  502. }
  503. async zcfx2(biao_id, bh, prefix) {
  504. const response = await fetch(this.ip().concat( "/zcfx2/"), {
  505. method : "POST",
  506. headers: {
  507. "Content-type": "application/json",
  508. 'Authorization': `Bearer ${this.token_}`
  509. },
  510. body: JSON.stringify(
  511. {
  512. "biao_id": biao_id,
  513. "bh": bh,
  514. "prefix": translate2(prefix)
  515. }
  516. )
  517. });
  518. if (!response.ok) {
  519. //const error = await response.json();
  520. console.error('error');
  521. } else {
  522. const data = await response.json();
  523. return translate(data);
  524. }
  525. }
  526. async zcfx(biao_id, bh) {
  527. const response = await fetch(this.ip().concat( "/zcfx/"), {
  528. method : "POST",
  529. headers: {
  530. "Content-type": "application/json",
  531. 'Authorization': `Bearer ${this.token_}`
  532. },
  533. body: JSON.stringify(
  534. {
  535. "biao_id": biao_id,
  536. "bh": bh,
  537. }
  538. )
  539. });
  540. if (!response.ok) {
  541. //const error = await response.json();
  542. console.error('error');
  543. } else {
  544. const data = await response.json();
  545. return translate(data);
  546. }
  547. }
  548. async tiaojia(biao_id, bh, bm, mingcheng, danwei, jiage) {
  549. let glf = "";
  550. let lr = "";
  551. let bz = 0;//changgui
  552. if (this.qufeiEntry['备注'].length == 0) {
  553. //changuiqufei
  554. glf = this.qufeiEntry['管理费(%)'] ;
  555. lr = this.qufeiEntry['利润(%)'];
  556. } else {
  557. glf = this.qufeiEntry['管理费(%)'] ;
  558. lr = this.qufeiEntry['利润(%)'];
  559. bz = 1;
  560. }
  561. const response = await fetch(this.ip().concat( "/tiaojia/"), {
  562. method : "POST",
  563. headers: {
  564. "Content-type": "application/json",
  565. 'Authorization': `Bearer ${this.token_}`
  566. },
  567. body: JSON.stringify(
  568. {
  569. "biao_id": biao_id,
  570. "bh": bh,
  571. "bm": bm,
  572. "mingcheng": mingcheng,
  573. "danwei" : danwei,
  574. "jiage": jiage,
  575. "glf" : glf,
  576. "lr" : lr,
  577. "bz" : bz
  578. }
  579. )
  580. });
  581. if (!response.ok) {
  582. //const error = await response.json();
  583. console.error('error');
  584. } else {
  585. const data = await response.json();
  586. this.clearCache();
  587. return data;
  588. }
  589. }
  590. ///////////////////////////////////editor_code//////////////////////////////////
  591. summarize_one_djcs(qd) {///根据定额汇总清单
  592. let dict = {};
  593. let left = [];
  594. for(let i = 0; i < qd["_children"].length; i++) {
  595. let de = qd["_children"][i];
  596. let desl = Number(de['数量']);
  597. let dercj = de['dercj'];
  598. for (let j = 1; j < dercj.length; j++) {
  599. let hl = copy(dercj[j]);
  600. if (hl[1] == '00EXP001' && hl[4] == '%') {
  601. left.push(hl);
  602. continue;
  603. }
  604. if (hl[1] == '99EXP007' && hl[4] == '%') {
  605. left.push(hl);
  606. continue;
  607. }
  608. if (hl[1] == '99EXP022' && hl[4] == '%') {
  609. left.push(hl);
  610. continue;
  611. }
  612. if (hl[1] == '31130104' && hl[4] == '%') {
  613. left.push(hl);
  614. continue;
  615. }
  616. hl[10] = desl * Number(hl[10]);
  617. hl[11] = desl * Number(hl[11]);
  618. let a = hl[1];//"人材机编码",
  619. let b = a.concat(hl[2]);//"名称",
  620. let c = b.concat(hl[4]);// "单位"
  621. if (dict.hasOwnProperty(c)) {
  622. dict[c].push(hl);
  623. } else {
  624. dict[c] = [hl];
  625. }
  626. }
  627. }
  628. let result = [];
  629. for(const key in dict) {
  630. let list = dict[key];
  631. let sum = 0;
  632. let danjia = Number(list[0][5]);
  633. for (let i =0 ;i < list.length; i++) {
  634. sum += Number(list[i][10]);
  635. }
  636. let entry = [list[0][0], list[0][1], list[0][2], list[0][3], list[0][4], danjia,
  637. list[0][6], list[0][7], list[0][8], list[0][9], sum, sum * danjia, list[0][12],
  638. list[0][13], list[0][14], list[0][15]
  639. ];
  640. result.push(entry);
  641. }
  642. for (let i = 0; i < left.length; i++) {
  643. result.push(left[i]);
  644. }
  645. let gongri = 0;
  646. for(let i = 0; i < result.length; i++) {
  647. if (result[i][4] == '工日') {
  648. gongri += result[i][10];
  649. }
  650. }
  651. result.sort((a, b) => Number(a[8]) - Number(b[8]));
  652. qd['rcj'] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  653. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]].concat(result);
  654. qd["综合人工工日"] = gongri;
  655. qd['综合单价'] = 0;
  656. qd['合价'] = 0;
  657. qd['人工费'] = 0;
  658. qd['主材费'] = 0;
  659. qd['设备费'] = 0;
  660. qd['辅材费'] = 0;
  661. qd['材料费'] = 0;
  662. qd['机械费'] = 0;
  663. qd['管理费'] = 0;
  664. qd['利润'] = 0;
  665. for(let i = 0; i < qd["_children"].length; i++) {
  666. qd['综合单价'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['综合单价']);
  667. qd['合价'] += Number(qd['_children'][i]['合价']);
  668. qd['人工费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['人工费']);
  669. qd['主材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['主材费']);
  670. qd['设备费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['设备费']);
  671. qd['辅材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['辅材费']);
  672. qd['材料费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['材料费']);
  673. qd['机械费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['机械费']);
  674. qd['管理费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['管理费']);
  675. qd['利润'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['利润']);
  676. }
  677. return qd;
  678. }
  679. summarize_one(qd) {///根据定额汇总清单
  680. qd['综合单价'] = 0;
  681. qd['合价'] = 0;
  682. qd['人工费'] = 0;
  683. qd['主材费'] = 0;
  684. qd['设备费'] = 0;
  685. qd['辅材费'] = 0;
  686. qd['材料费'] = 0;
  687. qd['机械费'] = 0;
  688. qd['管理费'] = 0;
  689. qd['利润'] = 0;
  690. for(let i = 0; i < qd["_children"].length; i++) {
  691. if (qd["_children"][i]['azfytag'].length > 0)continue;
  692. qd['综合单价'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['综合单价']);
  693. qd['合价'] += Number(qd['_children'][i]['合价']);
  694. qd['人工费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['人工费']);
  695. qd['主材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['主材费']);
  696. qd['设备费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['设备费']);
  697. qd['辅材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['辅材费']);
  698. qd['材料费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['材料费']);
  699. qd['机械费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['机械费']);
  700. qd['管理费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['管理费']);
  701. qd['利润'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['利润']);
  702. }
  703. //处理安装费用
  704. //console.log(qd["_children"].length);
  705. for(let i = 0; i < qd["_children"].length; i++) {
  706. //console.log(i);
  707. if (qd["_children"][i]['azfytag'].length > 0){
  708. let tag = qd["_children"][i]['azfytag'];
  709. if (tag[0] == '人工费') {
  710. let current_rgf = qd['人工费'];
  711. let added = Number(current_rgf) * Number(tag[1]) / Number(100);
  712. let added_rgf = added * Number(tag[2]) / Number(100);
  713. let added_clf = added * Number(tag[3]) / Number(100);
  714. let added_jxf = added * Number(tag[4]) / Number(100);
  715. qd["_children"][i]['人工费'] = added_rgf;
  716. qd["_children"][i]['辅材费'] = added_clf;
  717. qd["_children"][i]['材料费'] = added_clf;
  718. qd["_children"][i]['机械费'] = added_jxf;
  719. if (this.qufeiEntry['备注'].length == 0) {
  720. //changuiqufei
  721. qd["_children"][i]['管理费'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  722. qd["_children"][i]['利润'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  723. } else {
  724. qd["_children"][i]['管理费'] = (added_rgf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  725. qd["_children"][i]['利润'] = (added_rgf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  726. }
  727. qd["_children"][i]['综合单价'] = qd["_children"][i]['人工费'] + qd["_children"][i]['材料费'] + qd["_children"][i]['机械费'] + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
  728. qd["_children"][i]['合价'] = qd["_children"][i]['综合单价'] * Number(qd["_children"][i]['数量']) * Number(qd['数量']);
  729. let dercj = qd["_children"][i]['dercj'];
  730. for (let j = 1; j < dercj.length; j++) {
  731. dercj[j][11] = Number(added) * Number(dercj[j][10]) / Number(100);
  732. }
  733. }
  734. if (tag[0] == '人工费+机械费') {
  735. let current_rgf = qd['人工费'] + qd['机械费'];
  736. let added = Number(current_rgf) * Number(tag[1]) / Number(100);
  737. let added_rgf = added * Number(tag[2]) / Number(100);
  738. let added_clf = added * Number(tag[3]) / Number(100);
  739. let added_jxf = added * Number(tag[4]) / Number(100);
  740. qd["_children"][i]['人工费'] = added_rgf;
  741. qd["_children"][i]['辅材费'] = added_clf;
  742. qd["_children"][i]['材料费'] = added_clf;
  743. qd["_children"][i]['机械费'] = added_jxf;
  744. if (this.qufeiEntry['备注'].length == 0) {
  745. //changuiqufei
  746. qd["_children"][i]['管理费'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  747. qd["_children"][i]['利润'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  748. } else {
  749. qd["_children"][i]['管理费'] = (added_rgf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  750. qd["_children"][i]['利润'] = (added_rgf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  751. }
  752. qd["_children"][i]['综合单价'] = qd["_children"][i]['人工费'] + qd["_children"][i]['材料费'] + qd["_children"][i]['机械费'] + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
  753. qd["_children"][i]['合价'] = qd["_children"][i]['综合单价'] * Number(qd["_children"][i]['数量']) * Number(qd["数量"]);
  754. let dercj = qd["_children"][i]['dercj'];
  755. for (let j = 1; j < dercj.length; j++) {
  756. dercj[j][11] = Number(added) * Number(dercj[j][10]) / Number(100);
  757. }
  758. }
  759. }
  760. }
  761. qd['综合单价'] = 0;
  762. qd['合价'] = 0;
  763. qd['人工费'] = 0;
  764. qd['主材费'] = 0;
  765. qd['设备费'] = 0;
  766. qd['辅材费'] = 0;
  767. qd['材料费'] = 0;
  768. qd['机械费'] = 0;
  769. qd['管理费'] = 0;
  770. qd['利润'] = 0;
  771. for(let i = 0; i < qd["_children"].length; i++) {
  772. qd['综合单价'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['综合单价']);
  773. qd['合价'] += Number(qd['_children'][i]['合价']);
  774. qd['人工费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['人工费']);
  775. qd['主材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['主材费']);
  776. qd['设备费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['设备费']);
  777. qd['辅材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['辅材费']);
  778. qd['材料费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['材料费']);
  779. qd['机械费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['机械费']);
  780. qd['管理费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['管理费']);
  781. qd['利润'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['利润']);
  782. }
  783. let dict = {};
  784. let left = [];
  785. for(let i = 0; i < qd["_children"].length; i++) {
  786. let de = qd["_children"][i];
  787. let desl = Number(de['数量']);
  788. let dercj = de['dercj'];
  789. for (let j = 1; j < dercj.length; j++) {
  790. let hl = copy(dercj[j]);
  791. if (hl[1].includes('000FE') && hl[4] == '%') {
  792. left.push(hl);
  793. continue;
  794. }
  795. if (hl[1] == '00EXP001' && hl[4] == '%') {
  796. left.push(hl);
  797. continue;
  798. }
  799. if (hl[1] == '99EXP007' && hl[4] == '%') {
  800. left.push(hl);
  801. continue;
  802. }
  803. if (hl[1] == '99EXP022' && hl[4] == '%') {
  804. left.push(hl);
  805. continue;
  806. }
  807. if (hl[1] == '31130104' && hl[4] == '%') {
  808. left.push(hl);
  809. continue;
  810. }
  811. hl[10] = desl * Number(hl[10]);
  812. hl[11] = desl * Number(hl[11]);
  813. let a = hl[1];//"人材机编码",
  814. let b = a.concat(hl[2]);//"名称",
  815. let c = b.concat(hl[4]);// "单位"
  816. if (dict.hasOwnProperty(c)) {
  817. dict[c].push(hl);
  818. } else {
  819. dict[c] = [hl];
  820. }
  821. }
  822. }
  823. let result = [];
  824. for(const key in dict) {
  825. let list = dict[key];
  826. let sum = 0;
  827. let danjia = Number(list[0][5]);
  828. for (let i =0 ;i < list.length; i++) {
  829. sum += Number(list[i][10]);
  830. }
  831. let entry = [list[0][0], list[0][1], list[0][2], list[0][3], list[0][4], danjia,
  832. list[0][6], list[0][7], list[0][8], list[0][9], sum, sum * danjia, list[0][12],
  833. list[0][13], list[0][14], list[0][15]
  834. ];
  835. result.push(entry);
  836. }
  837. for (let i = 0; i < left.length; i++) {
  838. result.push(left[i]);
  839. }
  840. let gongri = 0;
  841. for(let i = 0; i < result.length; i++) {
  842. if (result[i][4] == '工日') {
  843. gongri += result[i][10];
  844. }
  845. }
  846. result.sort((a, b) => Number(a[8]) - Number(b[8]));
  847. qd['rcj'] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  848. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]].concat(result);
  849. qd["综合人工工日"] = gongri;
  850. return qd;
  851. }
  852. summarize(data) {
  853. return data.map(x=>this.summarize_one(x));
  854. }
  855. summarize_djcs(data) {
  856. return data.map(x=>this.summarize_one_djcs(x));
  857. }
  858. push_op(newData) {
  859. if(this.memory.length == this.mem_pointer + 1) {
  860. this.memory.push(copy(newData));
  861. this.mem_pointer = this.mem_pointer + 1;
  862. } else{
  863. this.memory.splice(this.mem_pointer + 1);
  864. this.memory.push(copy(newData));
  865. this.mem_pointer = this.mem_pointer + 1;
  866. }
  867. }
  868. push_op_djcs(newData) {
  869. if(this.memory_djcs.length == this.mem_pointer_djcs + 1) {
  870. this.memory_djcs.push(copy(newData));
  871. this.mem_pointer_djcs = this.mem_pointer_djcs + 1;
  872. } else{
  873. this.memory_djcs.splice(this.mem_pointer_djcs + 1);
  874. this.memory_djcs.push(copy(newData));
  875. this.mem_pointer_djcs = this.mem_pointer_djcs + 1;
  876. }
  877. }
  878. undo() {
  879. if (this.mem_pointer > 0) {
  880. let newData = this.memory[this.mem_pointer - 1];
  881. this.mem_pointer = this.mem_pointer - 1;
  882. this.cache = copy(newData);
  883. return copy(newData);
  884. }
  885. return copy(this.cache);
  886. }
  887. undo_djcs() {
  888. if (this.mem_pointer_djcs > 0) {
  889. let newData = this.memory_djcs[this.mem_pointer_djcs - 1];
  890. this.mem_pointer_djcs = this.mem_pointer_djcs - 1;
  891. this.cache_djcs = copy(newData);
  892. return copy(newData);
  893. }
  894. return copy(this.cache_djcs);
  895. }
  896. redo() {
  897. if (this.mem_pointer + 1 != this.memory.length) {
  898. let newData = this.memory[this.mem_pointer + 1];
  899. this.mem_pointer = this.mem_pointer + 1;
  900. this.cache = copy(newData);
  901. return copy(newData);
  902. }
  903. return copy(this.cache);
  904. }
  905. redo_djcs() {
  906. if (this.mem_pointer_djcs + 1 != this.memory_djcs.length) {
  907. let newData = this.memory_djcs[this.mem_pointer_djcs + 1];
  908. this.mem_pointer_djcs = this.mem_pointer_djcs + 1;
  909. this.cache_djcs = copy(newData);
  910. return copy(newData);
  911. }
  912. return copy(this.cache_djcs);
  913. }
  914. shanchu_djcs(key) {
  915. if (this.cache_djcs.filter(x=>x['key'] == key).length > 0) {
  916. ///qd
  917. let newData = this.cache_djcs.map(x=>{
  918. if (x["key"] == key) {
  919. let y = copy(x);
  920. y["_children"] = [];
  921. return y;
  922. } else {
  923. return x;
  924. }
  925. });
  926. let summarized = this.summarize_djcs(newData);
  927. this.push_op_djcs(summarized);
  928. /////////////////
  929. this.cache_djcs = copy(summarized);
  930. return copy(this.cache_djcs);
  931. } else {
  932. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key'] == key).length > 0)[0];
  933. let qdbm = qd['清单编码'];
  934. let newData = this.cache_djcs.map(x=>{
  935. if (x["清单编码"] == qdbm) {
  936. let y = copy(x);
  937. let origin = y["_children"];
  938. let trans = origin.filter(z=>z["key"]!=key);
  939. y["_children"] = trans;
  940. return y;
  941. } else {
  942. return x;
  943. }
  944. });
  945. let summarized = this.summarize_djcs(newData);
  946. this.push_op_djcs(summarized);
  947. /////////////////
  948. this.cache_djcs = copy(summarized);
  949. return copy(this.cache_djcs);
  950. }
  951. }
  952. updateFootprint(key) {
  953. if (this.footprint.includes(key)) {
  954. } else {
  955. this.footprint.push(key);
  956. }
  957. }
  958. shanchu(key) {
  959. if (this.cache.filter(x=>x['key'] == key).length > 0) {
  960. this.updateFootprint(key);
  961. ///qd
  962. let newData = this.cache.map(x=>{
  963. if (x["key"] == key) {
  964. let y = copy(x);
  965. y["_children"] = [];
  966. return y;
  967. } else {
  968. return x;
  969. }
  970. });
  971. let summarized = this.summarize(newData);
  972. this.push_op(summarized);
  973. /////////////////
  974. this.cache = copy(summarized);
  975. return copy(this.cache);
  976. } else {
  977. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key'] == key).length > 0)[0];
  978. this.updateFootprint(qd['key']);
  979. let qdbm = qd['清单编码'];
  980. let newData = this.cache.map(x=>{
  981. if (x["清单编码"] == qdbm) {
  982. let y = copy(x);
  983. let origin = y["_children"];
  984. let trans = origin.filter(z=>z["key"]!=key);
  985. y["_children"] = trans;
  986. return y;
  987. } else {
  988. return x;
  989. }
  990. });
  991. let summarized = this.summarize(newData);
  992. this.push_op(summarized);
  993. /////////////////
  994. this.cache = copy(summarized);
  995. return copy(this.cache);
  996. }
  997. }
  998. //有预拌砂浆,没有补充
  999. updateDercj_djcs_(row, data, xuhao, yuban, mode=0/**0->update by view; 1-> config change */) {///change 一条定额 inplace, 汇总一条定额的rcj, xuhao is for rename
  1000. console.log("data updated");
  1001. let data_normal = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1002. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];//正常部分,不包括补充
  1003. //处理附注
  1004. let huan = false;
  1005. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1006. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1007. if (de.hasOwnProperty("rcjdg")) {//新数据
  1008. de['dercj'] = copy(de['rcjdg']);
  1009. if (de.hasOwnProperty('fuzhu')) {//
  1010. for(let j = 1; j < de['rcjdg'].length; j++) {
  1011. let origin = Number(de['rcjdg'][j][10]);
  1012. let bianhao_huan = '';
  1013. let name_huan = '';
  1014. let new_jia = 0;
  1015. for(let i = 0; i < de['fuzhu'].length; i++) {
  1016. let selected = de['fuzhu'][i];//selected is 结构化的处理信息
  1017. let target = selected[0];
  1018. if (match_target(de['rcjdg'][j][1], de['rcjdg'][j][2], target, selected[1])) {
  1019. if (selected[2] == '系数' || selected[2] == '商品砼系数' || selected[2] == '除此机械外') {
  1020. origin = origin * (Number(selected[3]) ** Number(selected[5]));
  1021. } else if (selected[2] == '含量' || selected[2] == '商品砼含量') {
  1022. origin = Number(selected[3]);
  1023. } else if (selected[2] == '调整' || selected[2] == '商品砼调整') {
  1024. origin = origin + Number(selected[3]) * Number(selected[5]);
  1025. } else if (selected[2] == '调比') {
  1026. origin = origin + Number(selected[3]) * Number(selected[5]) / Number(100);
  1027. } else if (selected[2] == '次方') {
  1028. origin = origin * (Number(selected[3]) ** Number(selected[5]));
  1029. } else if (selected[2] == '叠加备注') {
  1030. } else if (selected[2] == '换机械系数') {
  1031. bianhao_huan = selected[4];
  1032. name_huan = this.mapper[bianhao_huan][0];
  1033. new_jia = this.mapper[bianhao_huan][1];
  1034. origin = origin * (Number(selected[3]) ** Number(selected[5]));
  1035. } else if (selected[2] == '换材料系数') {
  1036. bianhao_huan = selected[4];
  1037. name_huan = this.mapper[bianhao_huan][0];
  1038. new_jia = this.mapper[bianhao_huan][1];
  1039. origin = origin * (Number(selected[3]) ** Number(selected[5]));
  1040. } else if (selected[2] == '使用泵送') {
  1041. if (de['rcjdg'][j][2].includes('C20')) {
  1042. bianhao_huan = '80212103';
  1043. name_huan = '(C20泵送商品砼)';
  1044. new_jia = 342;
  1045. }
  1046. if (de['rcjdg'][j][2].includes('C30')) {
  1047. bianhao_huan = '80212105';
  1048. name_huan = '(C30泵送商品砼)';
  1049. new_jia = 362;
  1050. }
  1051. } else if (selected[2] == '使用非泵送') {
  1052. if (de['rcjdg'][j][2].includes('C20')) {
  1053. bianhao_huan = '80212115';
  1054. name_huan = '(C20非泵送商品砼)';
  1055. new_jia = 333;
  1056. }
  1057. if (de['rcjdg'][j][2].includes('C30')) {
  1058. bianhao_huan = '80212117';
  1059. name_huan = '(C30非泵送商品砼)';
  1060. new_jia = 353;
  1061. }
  1062. }
  1063. else {
  1064. throw new Error('无法处理的附注'.concat(selected[2]));
  1065. }
  1066. }
  1067. }
  1068. if (bianhao_huan == '') {
  1069. } else {
  1070. de['dercj'][j][1] = bianhao_huan;//编号
  1071. de['dercj'][j][2] = name_huan;//mc
  1072. de['dercj'][j][5] = new_jia;//jiage
  1073. }
  1074. de['dercj'][j][10] = origin;
  1075. de['dercj'][j][11] = Number(de['dercj'][j][5]) * origin;
  1076. }
  1077. }
  1078. for(let j = 1; j < de['dercj'].length; j++) {
  1079. for (let k = 0; k < data.length; k++) {
  1080. if (data[k][16] == de['dercj'][j][16]) {
  1081. let datak2 = data[k][2];
  1082. if (datak2.includes('(湿拌砂浆)')) {
  1083. datak2 = datak2.replace('(湿拌砂浆)', '');
  1084. }
  1085. if (datak2.includes('(干拌(混)砂浆)')) {
  1086. datak2 = datak2.replace('(干拌(混)砂浆)', '');
  1087. }
  1088. if (de['dercj'][j][2] == datak2) {//名称
  1089. } else {
  1090. huan = true;
  1091. }
  1092. }
  1093. }
  1094. }
  1095. if (mode == 1) {
  1096. data_normal = de['dercj'];
  1097. huan = false;
  1098. } else {
  1099. de['dercj'] = copy(data);
  1100. data_normal = de['dercj'];
  1101. }
  1102. } else {////单项定额没有底稿,老数据没底搞,无法判断换部换,暂时统一认为不换
  1103. //强行改含量
  1104. de['dercj'] = copy(data);
  1105. data_normal = de['dercj'];
  1106. }
  1107. if (yuban.length > 0) {//处理预拌砂浆
  1108. if (yuban.includes('1')) {//与换无关
  1109. for(let i = 1; i < data_normal.length; i++) {
  1110. if (data_normal[i][4]=='工日') {
  1111. data_normal[i][10] = Number(data_normal[i][10]) - 0.45;
  1112. }
  1113. if (data_normal[i][2].includes('搅拌机')) {
  1114. data_normal[i][10] = 0;
  1115. }
  1116. if (data_normal[i][2].includes('砂浆') && !data_normal[i][2].includes('搅拌机')) {
  1117. data_normal[i][2] = data_normal[i][2].concat('(湿拌砂浆)')
  1118. }
  1119. }
  1120. if (mode == 0) {
  1121. data_normal = copy(data);
  1122. } else if (mode == 1) {
  1123. //data_normal = data_normal.filter(x=>x[17]!='true');
  1124. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1125. } else if (mode == 2) {
  1126. let data_normal_2 = copy(data_normal);
  1127. data_normal = data.filter(x=>x[17]!='true');
  1128. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1129. }
  1130. } else if (yuban.includes('2')) {//与换无关
  1131. let added = [];
  1132. for(let i = 1; i < data_normal.length; i++) {
  1133. let origin = 0;
  1134. if (data_normal[i][4]=='工日') {
  1135. data_normal[i][10] = Number(data_normal[i][10]) - 0.3;
  1136. }
  1137. if (data_normal[i][2].includes('搅拌机')) {
  1138. data_normal[i][10] = 0;
  1139. }
  1140. if (data_normal[i][2].includes('砂浆') && !data_normal[i][2].includes('搅拌机')) {
  1141. data_normal[i][2] = data_normal[i][2].concat('(干拌(混)砂浆)');
  1142. origin = Number(data_normal[i][10]);
  1143. data_normal[i][10] = origin * 1.75;
  1144. added.push(['', 'S00001', '水', '', 't', '4.70', '', '', '2', 'false', (origin * 0.29).toString(), ''/**hj */, ''/**zgj */,''/**zycl */,''/**zc */,''/**sb */,'',data_normal[i][17]]);
  1145. added.push(['', 'JD0001', '其他机械费(电)', '', '度', '0.65', '', '', '3', 'false', (origin * 2.15).toString(), ''/**hj */, ''/**zgj */,''/**zycl */,''/**zc */,''/**sb */, '',data_normal[i][17]]);
  1146. }
  1147. }
  1148. data_normal = data_normal.concat(added);
  1149. if (mode == 0) {
  1150. data_normal = copy(data);
  1151. } else if (mode == 1) {
  1152. //data_normal = data_normal.filter(x=>x[17]!='true');
  1153. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1154. } else if (mode == 2) {
  1155. let data_normal_2 = copy(data_normal);
  1156. data_normal = data.filter(x=>x[17]!='true');
  1157. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1158. }
  1159. } else if (yuban.includes('3')) {//与换无关
  1160. let added = [];
  1161. for(let i = 1; i < data_normal.length; i++) {
  1162. let origin = 0;
  1163. if (data_normal[i][4]=='工日') {
  1164. data_normal[i][10] = Number(data_normal[i][10]) - 0.2;
  1165. }
  1166. if (data_normal[i][2].includes('砂浆') && !data_normal[i][2].includes('搅拌机')) {
  1167. data_normal[i][2] = data_normal[i][2].concat('(干拌(混)砂浆)');
  1168. origin = Number(data_normal[i][10]);
  1169. data_normal[i][10] = origin * 1.75;
  1170. added.push(['', 'S00001', '水', '', 't', '4.70', '', '', '2', 'false', (origin * 0.29).toString(), '', '','','','','',data_normal[i][17]]);
  1171. }
  1172. }
  1173. data_normal = data_normal.concat(added);
  1174. if (mode == 0) {
  1175. data_normal = copy(data);
  1176. } else if (mode == 1) {
  1177. //data_normal = data_normal.filter(x=>x[17]!='true');
  1178. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1179. } else if (mode == 2) {
  1180. let data_normal_2 = copy(data_normal);
  1181. data_normal = data.filter(x=>x[17]!='true');
  1182. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1183. }
  1184. } else {
  1185. let data_normal_2 = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1186. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];
  1187. for(let i = 1; i < data_normal.length; i++) {
  1188. let bc = data_normal[i][17];
  1189. let child = addChildren(10, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1190. if (child.length > 0) {
  1191. } else {
  1192. child = addChildren(40, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1193. if (child.length > 0) {
  1194. } else {
  1195. child = addChildren(50, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1196. }
  1197. }
  1198. if (child.length > 0) {//拆分
  1199. for(let j = 0; j < child.length; j++) {
  1200. data_normal_2.push(child[j]);
  1201. if (bc == 'true') {
  1202. for (let k = 0; k < data.length; k++) {
  1203. if (data[k][16] == child[j][16]) {
  1204. let datak2 = data[k][2];
  1205. if (child[j][2] == datak2) {//名称
  1206. } else {
  1207. if (mode > 0) {
  1208. } else {
  1209. huan = true;
  1210. }
  1211. }
  1212. }
  1213. }
  1214. } else if (mode != 1){
  1215. for (let k = 0; k < data.length; k++) {
  1216. if (data[k][16] == child[j][16]) {
  1217. let datak2 = data[k][2];
  1218. if (child[j][2] == datak2) {//名称
  1219. } else {
  1220. huan = true;
  1221. }
  1222. }
  1223. }
  1224. }
  1225. }
  1226. } else {
  1227. data_normal_2.push(data_normal[i]);
  1228. }
  1229. }
  1230. if (mode == 0) {
  1231. data_normal = copy(data);
  1232. } else if (mode == 2) {
  1233. data_normal = data.filter(x=>x[17]!='true');
  1234. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1235. } else if (mode == 1) {
  1236. data_normal = data_normal_2;
  1237. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1238. }
  1239. }
  1240. } else {//没有预拌
  1241. let data_normal_2 = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1242. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];
  1243. for(let i = 1; i < data_normal.length; i++) {
  1244. let bc = data_normal[i][17];
  1245. let child = addChildren(10, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1246. if (child.length > 0) {
  1247. } else {
  1248. child = addChildren(40, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1249. if (child.length > 0) {
  1250. } else {
  1251. child = addChildren(50, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1252. }
  1253. }
  1254. if (child.length > 0) {//拆分
  1255. for(let j = 0; j < child.length; j++) {
  1256. data_normal_2.push(child[j]);
  1257. if (bc == 'true') {
  1258. for (let k = 0; k < data.length; k++) {
  1259. if (data[k][16] == child[j][16]) {
  1260. let datak2 = data[k][2];
  1261. if (child[j][2] == datak2) {//名称
  1262. } else {
  1263. if (mode > 0) {
  1264. } else {
  1265. huan = true;
  1266. }
  1267. }
  1268. }
  1269. }
  1270. } else if (mode != 1){
  1271. for (let k = 0; k < data.length; k++) {
  1272. if (data[k][16] == child[j][16]) {
  1273. let datak2 = data[k][2];
  1274. if (child[j][2] == datak2) {//名称
  1275. } else {
  1276. huan = true;
  1277. }
  1278. }
  1279. }
  1280. }
  1281. }
  1282. } else {
  1283. data_normal_2.push(data_normal[i]);
  1284. }
  1285. }
  1286. if (mode == 0) {
  1287. data_normal = copy(data);
  1288. } else if (mode == 2) {
  1289. data_normal = data.filter(x=>x[17]!='true');
  1290. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1291. } else if (mode == 1) {
  1292. data_normal = data_normal_2;
  1293. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1294. }
  1295. }
  1296. data = copy(data_normal);
  1297. //模拟formula计算每一行的合价
  1298. for(let i = 1; i < data.length; i++) {
  1299. data[i][11] = Number(data[i][10]) * Number(data[i][5]);
  1300. }
  1301. //if (data[0].length > 18)
  1302. //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]]);
  1303. let sum = 0;
  1304. let rgf_sum = 0;
  1305. let jxf_sum = 0;
  1306. let clf_sum = 0;
  1307. let zcf_sum = 0;
  1308. for(let i = 1; i < data.length; i++) {
  1309. if (data[i][1]=='00EXP001' && data[i][4] == '%'){//回程费占人工费
  1310. continue;
  1311. }
  1312. if (data[i][1]=='99EXP007' && data[i][4] == '%'){//回程费占机械费
  1313. continue;
  1314. }
  1315. if (data[i][1]=='99EXP022' && data[i][4] == '%'){//回程费占机械费
  1316. continue;
  1317. }
  1318. if (data[i][1]=='31130104' && data[i][4] == '%'){//回程费占材料费
  1319. continue;
  1320. }
  1321. sum += Number(data[i][11]);//11-> hejia
  1322. if (Number(data[i][8]) == 1) {
  1323. rgf_sum += Number(data[i][11]);
  1324. }
  1325. if (Number(data[i][8]) == 2) {
  1326. clf_sum += Number(data[i][11]);
  1327. if (data[i][14] == 'true') {
  1328. zcf_sum += Number(data[i][11]);
  1329. }
  1330. }
  1331. if (Number(data[i][8]) == 3) {
  1332. jxf_sum += Number(data[i][11]);
  1333. }
  1334. }
  1335. console.log("sum=".concat(sum));
  1336. //处理百分比费用
  1337. for(let i = 1; i < data.length; i++) {
  1338. if (data[i][1]=='00EXP001' && data[i][4] == '%'){//回程费占人工费
  1339. data[i][11] = Number(data[i][10]) * rgf_sum / Number(100);
  1340. }
  1341. if (data[i][1]=='99EXP007' && data[i][4] == '%'){//回程费占机械费
  1342. data[i][11] = Number(data[i][10]) * jxf_sum / Number(100);
  1343. }
  1344. if (data[i][1]=='99EXP022' && data[i][4] == '%'){//回程费占机械费
  1345. data[i][11] = Number(data[i][10]) * jxf_sum / Number(100);
  1346. }
  1347. if (data[i][1]=='31130104' && data[i][4] == '%'){//回程费占材料费
  1348. data[i][11] = Number(data[i][10]) * clf_sum / Number(100);
  1349. }
  1350. }
  1351. sum = 0;
  1352. rgf_sum = 0;
  1353. jxf_sum = 0;
  1354. clf_sum = 0;
  1355. zcf_sum = 0;
  1356. for(let i = 1; i < data.length; i++) {
  1357. sum += Number(data[i][11]);//11-> hejia
  1358. if (Number(data[i][8]) == 1) {
  1359. rgf_sum += Number(data[i][11]);
  1360. }
  1361. if (Number(data[i][8]) == 2) {
  1362. clf_sum += Number(data[i][11]);
  1363. if (data[i][14] == 'true') {
  1364. zcf_sum += Number(data[i][11]);
  1365. }
  1366. }
  1367. if (Number(data[i][8]) == 3) {
  1368. jxf_sum += Number(data[i][11]);
  1369. }
  1370. }
  1371. let shuliang = Number(qd['数量']);
  1372. for(let i = 0; i< qd["_children"].length; i++) {
  1373. if(qd["_children"][i]['key'] == row) {
  1374. let desl = Number(qd["_children"][i]['数量']);
  1375. let oldname = qd["_children"][i]['清单编码'];
  1376. qd["_children"][i]['辅材费'] = clf_sum - zcf_sum;
  1377. qd["_children"][i]['材料费'] = clf_sum;
  1378. qd["_children"][i]['人工费'] = rgf_sum;
  1379. qd["_children"][i]['主材费'] = zcf_sum;
  1380. qd["_children"][i]['设备费'] = 0;
  1381. qd["_children"][i]['机械费'] = jxf_sum;
  1382. if (oldname.startsWith("D")) {//单项清单
  1383. qd["_children"][i]['管理费'] = 0;
  1384. qd["_children"][i]['利润'] = 0;
  1385. } else {
  1386. if (this.qufeiEntry['备注'].length == 0) {
  1387. //changuiqufei
  1388. qd["_children"][i]['管理费'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1389. qd["_children"][i]['利润'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1390. } else {
  1391. qd["_children"][i]['管理费'] = (rgf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1392. qd["_children"][i]['利润'] = (rgf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1393. }
  1394. }
  1395. qd["_children"][i]['综合单价'] = sum + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
  1396. qd["_children"][i]['合价'] = (qd["_children"][i]['综合单价'] * shuliang * desl);
  1397. qd["_children"][i]["dercj"] = this.handleJGC(copy(data));
  1398. qd["_children"][i]['清单编码'] = renameDingE(oldname, xuhao, huan);
  1399. }
  1400. }
  1401. }
  1402. updateDercj_(row, data, xuhao, yuban, rcjbc, mode=0) {///change 一条定额 inplace, 汇总一条定额的rcj, xuhao is for rename, yuban is 预拌砂浆
  1403. console.log("data updated");
  1404. //处理附注
  1405. let huan = false;//换
  1406. let data_normal = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1407. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];//正常部分,不包括补充
  1408. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1409. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1410. if (de.hasOwnProperty("rcjdg")) {//新数据
  1411. de['dercj'] = copy(de['rcjdg']);
  1412. if (de.hasOwnProperty('fuzhu')) {//没强行改过含量
  1413. for(let j = 1; j < de['rcjdg'].length; j++) {
  1414. let origin = Number(de['rcjdg'][j][10]);
  1415. let bianhao_huan = '';
  1416. let name_huan = '';
  1417. let new_jia = 0;
  1418. for(let i = 0; i < de['fuzhu'].length; i++) {
  1419. let selected = de['fuzhu'][i];//selected is 结构化的处理信息
  1420. let target = selected[0];
  1421. if (match_target(de['rcjdg'][j][1], de['rcjdg'][j][2], target, selected[1])) {
  1422. if (selected[2] == '系数' || selected[2] == '商品砼系数' || selected[2] == '除此机械外') {
  1423. origin = origin * (Number(selected[3]) ** Number(selected[5]));
  1424. } else if (selected[2] == '含量' || selected[2] == '商品砼含量') {
  1425. origin = Number(selected[3]);
  1426. } else if (selected[2] == '调整' || selected[2] == '商品砼调整') {
  1427. origin = origin + Number(selected[3]) * Number(selected[5]);
  1428. } else if (selected[2] == '调比') {
  1429. origin = origin + Number(selected[3]) * Number(selected[5]) / Number(100);
  1430. } else if (selected[2] == '次方') {
  1431. origin = origin * (Number(selected[3]) ** Number(selected[5]));
  1432. } else if (selected[2] == '叠加备注') {
  1433. } else if (selected[2] == '换机械系数') {
  1434. bianhao_huan = selected[4];
  1435. name_huan = this.mapper[bianhao_huan][0];
  1436. new_jia = this.mapper[bianhao_huan][1];
  1437. origin = origin * (Number(selected[3]) ** Number(selected[5]));
  1438. } else if (selected[2] == '换材料系数') {
  1439. bianhao_huan = selected[4];
  1440. name_huan = this.mapper[bianhao_huan][0];
  1441. new_jia = this.mapper[bianhao_huan][1];
  1442. origin = origin * (Number(selected[3]) ** Number(selected[5]));
  1443. } else if (selected[2] == '使用泵送') {
  1444. if (de['rcjdg'][j][2].includes('C20')) {
  1445. bianhao_huan = '80212103';
  1446. name_huan = '(C20泵送商品砼)';
  1447. new_jia = 342;
  1448. }
  1449. if (de['rcjdg'][j][2].includes('C30')) {
  1450. bianhao_huan = '80212105';
  1451. name_huan = '(C30泵送商品砼)';
  1452. new_jia = 362;
  1453. }
  1454. } else if (selected[2] == '使用非泵送') {
  1455. if (de['rcjdg'][j][2].includes('C20')) {
  1456. bianhao_huan = '80212115';
  1457. name_huan = '(C20非泵送商品砼)';
  1458. new_jia = 333;
  1459. }
  1460. if (de['rcjdg'][j][2].includes('C30')) {
  1461. bianhao_huan = '80212117';
  1462. name_huan = '(C30非泵送商品砼)';
  1463. new_jia = 353;
  1464. }
  1465. }
  1466. else {
  1467. throw new Error('无法处理的附注'.concat(selected[2]));
  1468. }
  1469. }
  1470. }
  1471. if (bianhao_huan == '') {
  1472. } else {
  1473. de['dercj'][j][1] = bianhao_huan;//编号
  1474. de['dercj'][j][2] = name_huan;//mc
  1475. de['dercj'][j][5] = new_jia;//jiage
  1476. }
  1477. de['dercj'][j][10] = origin;
  1478. de['dercj'][j][11] = Number(de['dercj'][j][5]) * origin;
  1479. }
  1480. }
  1481. //基于底稿判断换
  1482. for(let j = 1; j < de['dercj'].length; j++) {
  1483. for (let k = 0; k < data.length; k++) {
  1484. if (data[k][16] == de['dercj'][j][16]) {
  1485. let datak2 = data[k][2];
  1486. if (datak2.includes('(湿拌砂浆)')) {
  1487. datak2 = datak2.replace('(湿拌砂浆)', '');
  1488. }
  1489. if (datak2.includes('(干拌(混)砂浆)')) {
  1490. datak2 = datak2.replace('(干拌(混)砂浆)', '');
  1491. }
  1492. if (de['dercj'][j][2] == datak2) {//名称
  1493. } else {
  1494. huan = true;
  1495. }
  1496. }
  1497. }
  1498. }
  1499. if (mode == 1) {
  1500. data_normal = de['dercj'];
  1501. huan = false;
  1502. } else {
  1503. data_normal = copy(data.filter(x=>x[17] != 'true'));
  1504. }
  1505. } else {////单项定额没有底稿,老数据没底搞,无法判断换部换,暂时统一认为不换
  1506. //强行改含量
  1507. data_normal = copy(data.filter(x=>x[17] != 'true'));
  1508. //data = de['dercj'];
  1509. }
  1510. //处理补充
  1511. for(let i = 0; i < rcjbc.length; i++) {
  1512. 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']);
  1513. for (let k = 0; k < data.length; k++) {
  1514. if (data[k][16] == rcjbc[i]['id']) {
  1515. let datak2 = data[k][2];
  1516. if (datak2.includes('(湿拌砂浆)')) {
  1517. datak2 = datak2.replace('(湿拌砂浆)', '');
  1518. }
  1519. if (datak2.includes('(干拌(混)砂浆)')) {
  1520. datak2 = datak2.replace('(干拌(混)砂浆)', '');
  1521. }
  1522. if (rcjbc[i]['名称'] == datak2) {//名称
  1523. } else {
  1524. if (mode == 2) {
  1525. } else {
  1526. huan = true;
  1527. }
  1528. }
  1529. }
  1530. }
  1531. }
  1532. if (yuban.length > 0) {//处理预拌砂浆
  1533. if (yuban.includes('1')) {//与换无关
  1534. for(let i = 1; i < data_normal.length; i++) {
  1535. if (data_normal[i][4]=='工日') {
  1536. data_normal[i][10] = Number(data_normal[i][10]) - 0.45;
  1537. }
  1538. if (data_normal[i][2].includes('搅拌机')) {
  1539. data_normal[i][10] = 0;
  1540. }
  1541. if (data_normal[i][2].includes('砂浆') && !data_normal[i][2].includes('搅拌机')) {
  1542. data_normal[i][2] = data_normal[i][2].concat('(湿拌砂浆)')
  1543. }
  1544. }
  1545. if (mode == 0) {
  1546. data_normal = copy(data);
  1547. } else if (mode == 1) {
  1548. //data_normal = data_normal.filter(x=>x[17]!='true');
  1549. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1550. } else if (mode == 2) {
  1551. let data_normal_2 = copy(data_normal);
  1552. data_normal = data.filter(x=>x[17]!='true');
  1553. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1554. }
  1555. } else if (yuban.includes('2')) {//与换无关
  1556. let added = [];
  1557. for(let i = 1; i < data_normal.length; i++) {
  1558. let origin = 0;
  1559. if (data_normal[i][4]=='工日') {
  1560. data_normal[i][10] = Number(data_normal[i][10]) - 0.3;
  1561. }
  1562. if (data_normal[i][2].includes('搅拌机')) {
  1563. data_normal[i][10] = 0;
  1564. }
  1565. if (data_normal[i][2].includes('砂浆') && !data_normal[i][2].includes('搅拌机')) {
  1566. data_normal[i][2] = data_normal[i][2].concat('(干拌(混)砂浆)');
  1567. origin = Number(data_normal[i][10]);
  1568. data_normal[i][10] = origin * 1.75;
  1569. added.push(['', 'S00001', '水', '', 't', '4.70', '', '', '2', 'false', (origin * 0.29).toString(), ''/**hj */, ''/**zgj */,''/**zycl */,''/**zc */,''/**sb */,'',data_normal[i][17]]);
  1570. added.push(['', 'JD0001', '其他机械费(电)', '', '度', '0.65', '', '', '3', 'false', (origin * 2.15).toString(), ''/**hj */, ''/**zgj */,''/**zycl */,''/**zc */,''/**sb */, '',data_normal[i][17]]);
  1571. }
  1572. }
  1573. data_normal = data_normal.concat(added);
  1574. if (mode == 0) {
  1575. data_normal = copy(data);
  1576. } else if (mode == 1) {
  1577. //data_normal = data_normal.filter(x=>x[17]!='true');
  1578. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1579. } else if (mode == 2) {
  1580. let data_normal_2 = copy(data_normal);
  1581. data_normal = data.filter(x=>x[17]!='true');
  1582. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1583. }
  1584. } else if (yuban.includes('3')) {//与换无关
  1585. let added = [];
  1586. for(let i = 1; i < data_normal.length; i++) {
  1587. let origin = 0;
  1588. if (data_normal[i][4]=='工日') {
  1589. data_normal[i][10] = Number(data_normal[i][10]) - 0.2;
  1590. }
  1591. if (data_normal[i][2].includes('砂浆') && !data_normal[i][2].includes('搅拌机')) {
  1592. data_normal[i][2] = data_normal[i][2].concat('(干拌(混)砂浆)');
  1593. origin = Number(data_normal[i][10]);
  1594. data_normal[i][10] = origin * 1.75;
  1595. added.push(['', 'S00001', '水', '', 't', '4.70', '', '', '2', 'false', (origin * 0.29).toString(), '', '','','','','',data_normal[i][17]]);
  1596. }
  1597. }
  1598. data_normal = data_normal.concat(added);
  1599. if (mode == 0) {
  1600. data_normal = copy(data);
  1601. } else if (mode == 1) {
  1602. //data_normal = data_normal.filter(x=>x[17]!='true');
  1603. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1604. } else if (mode == 2) {
  1605. let data_normal_2 = copy(data_normal);
  1606. data_normal = data.filter(x=>x[17]!='true');
  1607. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1608. }
  1609. } else {
  1610. let data_normal_2 = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1611. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];
  1612. for(let i = 1; i < data_normal.length; i++) {
  1613. let bc = data_normal[i][17];
  1614. let child = addChildren(10, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1615. if (child.length > 0) {
  1616. } else {
  1617. child = addChildren(40, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1618. if (child.length > 0) {
  1619. } else {
  1620. child = addChildren(50, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1621. }
  1622. }
  1623. if (child.length > 0) {//拆分
  1624. for(let j = 0; j < child.length; j++) {
  1625. data_normal_2.push(child[j]);
  1626. if (bc == 'true') {
  1627. for (let k = 0; k < data.length; k++) {
  1628. if (data[k][16] == child[j][16]) {
  1629. let datak2 = data[k][2];
  1630. if (child[j][2] == datak2) {//名称
  1631. } else {
  1632. if (mode > 0) {
  1633. } else {
  1634. huan = true;
  1635. }
  1636. }
  1637. }
  1638. }
  1639. } else if (mode != 1){
  1640. for (let k = 0; k < data.length; k++) {
  1641. if (data[k][16] == child[j][16]) {
  1642. let datak2 = data[k][2];
  1643. if (child[j][2] == datak2) {//名称
  1644. } else {
  1645. huan = true;
  1646. }
  1647. }
  1648. }
  1649. }
  1650. }
  1651. } else {
  1652. data_normal_2.push(data_normal[i]);
  1653. }
  1654. }
  1655. if (mode == 0) {
  1656. data_normal = copy(data);
  1657. } else if (mode == 2) {
  1658. data_normal = data.filter(x=>x[17]!='true');
  1659. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1660. } else if (mode == 1) {
  1661. data_normal = data_normal_2;
  1662. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1663. }
  1664. }
  1665. } else {//没有预拌
  1666. let data_normal_2 = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  1667. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];
  1668. for(let i = 1; i < data_normal.length; i++) {
  1669. let bc = data_normal[i][17];
  1670. let child = addChildren(10, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1671. if (child.length > 0) {
  1672. } else {
  1673. child = addChildren(40, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1674. if (child.length > 0) {
  1675. } else {
  1676. child = addChildren(50, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
  1677. }
  1678. }
  1679. if (child.length > 0) {//拆分
  1680. for(let j = 0; j < child.length; j++) {
  1681. data_normal_2.push(child[j]);
  1682. if (bc == 'true') {
  1683. for (let k = 0; k < data.length; k++) {
  1684. if (data[k][16] == child[j][16]) {
  1685. let datak2 = data[k][2];
  1686. if (child[j][2] == datak2) {//名称
  1687. } else {
  1688. if (mode > 0) {
  1689. } else {
  1690. huan = true;
  1691. }
  1692. }
  1693. }
  1694. }
  1695. } else if (mode != 1){
  1696. for (let k = 0; k < data.length; k++) {
  1697. if (data[k][16] == child[j][16]) {
  1698. let datak2 = data[k][2];
  1699. if (child[j][2] == datak2) {//名称
  1700. } else {
  1701. huan = true;
  1702. }
  1703. }
  1704. }
  1705. }
  1706. }
  1707. } else {
  1708. data_normal_2.push(data_normal[i]);
  1709. }
  1710. }
  1711. if (mode == 0) {
  1712. data_normal = copy(data);
  1713. } else if (mode == 2) {
  1714. data_normal = data.filter(x=>x[17]!='true');
  1715. data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
  1716. } else if (mode == 1) {
  1717. data_normal = data_normal_2;
  1718. //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
  1719. }
  1720. }
  1721. data = copy(data_normal);
  1722. //模拟formula计算每一行的合价
  1723. for(let i = 1; i < data.length; i++) {
  1724. data[i][11] = Number(data[i][10]) * Number(data[i][5]);
  1725. }
  1726. let sum = 0;
  1727. let rgf_sum = 0;
  1728. let jxf_sum = 0;
  1729. let clf_sum = 0;
  1730. let zcf_sum = 0;
  1731. for(let i = 1; i < data.length; i++) {
  1732. if (data[i][1].includes('000FE') && data[i][4] == '%')continue;//azfy
  1733. if (data[i][1]=='00EXP001' && data[i][4] == '%'){//回程费占人工费
  1734. continue;
  1735. }
  1736. if (data[i][1]=='99EXP007' && data[i][4] == '%'){//回程费占机械费
  1737. continue;
  1738. }
  1739. if (data[i][1]=='99EXP022' && data[i][4] == '%'){//回程费占机械费
  1740. continue;
  1741. }
  1742. if (data[i][1]=='31130104' && data[i][4] == '%'){//回程费占材料费
  1743. continue;
  1744. }
  1745. sum += Number(data[i][11]);//11-> hejia
  1746. if (Number(data[i][8]) == 1) {
  1747. rgf_sum += Number(data[i][11]);
  1748. }
  1749. if (Number(data[i][8]) == 2) {
  1750. clf_sum += Number(data[i][11]);
  1751. if (data[i][14] == 'true') {
  1752. zcf_sum += Number(data[i][11]);
  1753. }
  1754. }
  1755. if (Number(data[i][8]) == 3) {
  1756. jxf_sum += Number(data[i][11]);
  1757. }
  1758. }
  1759. console.log("sum=".concat(sum));
  1760. //处理百分比费用
  1761. for(let i = 1; i < data.length; i++) {
  1762. if (data[i][1]=='00EXP001' && data[i][4] == '%'){//回程费占人工费
  1763. data[i][11] = Number(data[i][10]) * rgf_sum / Number(100);
  1764. }
  1765. if (data[i][1]=='99EXP007' && data[i][4] == '%'){//回程费占机械费
  1766. data[i][11] = Number(data[i][10]) * jxf_sum / Number(100);
  1767. }
  1768. if (data[i][1]=='99EXP022' && data[i][4] == '%'){//回程费占机械费
  1769. data[i][11] = Number(data[i][10]) * jxf_sum / Number(100);
  1770. }
  1771. if (data[i][1]=='31130104' && data[i][4] == '%'){//回程费占材料费
  1772. data[i][11] = Number(data[i][10]) * clf_sum / Number(100);
  1773. }
  1774. }
  1775. sum = 0;
  1776. rgf_sum = 0;
  1777. jxf_sum = 0;
  1778. clf_sum = 0;
  1779. zcf_sum = 0;
  1780. for(let i = 1; i < data.length; i++) {
  1781. sum += Number(data[i][11]);//11-> hejia
  1782. if (Number(data[i][8]) == 1) {
  1783. rgf_sum += Number(data[i][11]);
  1784. }
  1785. if (Number(data[i][8]) == 2) {
  1786. clf_sum += Number(data[i][11]);
  1787. if (data[i][14] == 'true') {
  1788. zcf_sum += Number(data[i][11]);
  1789. }
  1790. }
  1791. if (Number(data[i][8]) == 3) {
  1792. jxf_sum += Number(data[i][11]);
  1793. }
  1794. }
  1795. let shuliang = Number(qd['数量']);
  1796. for(let i = 0; i< qd["_children"].length; i++) {
  1797. if(qd["_children"][i]['key'] == row) {
  1798. let desl = Number(qd["_children"][i]['数量']);
  1799. let oldname = qd["_children"][i]['清单编码'];
  1800. qd["_children"][i]['辅材费'] = clf_sum - zcf_sum;
  1801. qd["_children"][i]['材料费'] = clf_sum;
  1802. qd["_children"][i]['人工费'] = rgf_sum;
  1803. qd["_children"][i]['主材费'] = zcf_sum;
  1804. qd["_children"][i]['设备费'] = 0;
  1805. qd["_children"][i]['机械费'] = jxf_sum;
  1806. if (oldname.startsWith("D")) {//单项清单
  1807. qd["_children"][i]['管理费'] = 0;
  1808. qd["_children"][i]['利润'] = 0;
  1809. } else {
  1810. if (this.qufeiEntry['备注'].length == 0) {
  1811. //changuiqufei
  1812. qd["_children"][i]['管理费'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1813. qd["_children"][i]['利润'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1814. } else {
  1815. qd["_children"][i]['管理费'] = (rgf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
  1816. qd["_children"][i]['利润'] = (rgf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
  1817. }
  1818. }
  1819. qd["_children"][i]['综合单价'] = sum + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
  1820. qd["_children"][i]['合价'] = (qd["_children"][i]['综合单价'] * shuliang * desl);
  1821. qd["_children"][i]["dercj"] = this.handleJGC(copy(data));
  1822. qd["_children"][i]['清单编码'] = renameDingE(oldname, xuhao, huan);
  1823. }
  1824. }
  1825. }
  1826. updateDercj(row, data) {
  1827. //是否手动设置含量
  1828. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1829. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1830. this.updateFootprint(qd['key']);
  1831. let bm = de['清单编码'];
  1832. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  1833. this.updateDercj_(row, data, alreadyFuzhu, de['yuban'], de['rcjbc']);
  1834. //let qd = this.cache.filter(x=>x["children"].filter(y=>y['key']==row).length > 0)[0];
  1835. let newData = this.cache.map(x=>{
  1836. if (x['key'] == qd['key']) {
  1837. return qd;
  1838. } else {
  1839. return x;
  1840. }
  1841. });
  1842. let summarized = this.summarize(newData);
  1843. this.push_op(summarized);
  1844. /////////////////
  1845. this.cache = copy(summarized);
  1846. return copy(this.cache);
  1847. }
  1848. updateDercj_djcs(row, data) {
  1849. //是否手动设置含量
  1850. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1851. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1852. let bm = de['清单编码'];
  1853. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  1854. this.updateDercj_djcs_(row, data, alreadyFuzhu, []);
  1855. //let qd = this.cache.filter(x=>x["children"].filter(y=>y['key']==row).length > 0)[0];
  1856. let newData = this.cache_djcs.map(x=>{
  1857. if (x['key'] == qd['key']) {
  1858. return qd;
  1859. } else {
  1860. return x;
  1861. }
  1862. });
  1863. let summarized = this.summarize_djcs(newData);
  1864. this.push_op_djcs(summarized);
  1865. /////////////////
  1866. this.cache_djcs = copy(summarized);
  1867. return copy(this.cache_djcs);
  1868. }
  1869. updateBeizhu(row, selected, xuhao) {//xuhao is for rename, selected is 结构化的处理信息
  1870. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1871. if (!qd) return [null, null];
  1872. this.updateFootprint(qd['key']);
  1873. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1874. if (de.hasOwnProperty("rcjdg")) {//底稿
  1875. } else {///老数据不能有底稿,附注功能也不使能
  1876. //de['rcjdg'] = copy(de['dercj']);
  1877. }
  1878. de['fuzhu'] = copy(selected);
  1879. this.updateDercj_(row, de['dercj'], xuhao, de['yuban'], de['rcjbc'], 1);
  1880. let newData = this.cache.map(x=>{
  1881. if (x['key'] == qd['key']) {
  1882. return qd;
  1883. } else {
  1884. return x;
  1885. }
  1886. });
  1887. let summarized = this.summarize(newData);
  1888. this.push_op(summarized);
  1889. /////////////////
  1890. this.cache = copy(summarized);
  1891. return [copy(this.cache), copy(de['dercj'])];
  1892. }
  1893. updateBeizhu_djcs(row, selected, xuhao) {//xuhao is for rename
  1894. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1895. if (!qd) return [null, null];
  1896. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1897. if (de.hasOwnProperty("rcjdg")) {//底稿
  1898. } else {///老数据不能有底稿,附注功能也不使能
  1899. //de['rcjdg'] = copy(de['dercj']);
  1900. }
  1901. de['fuzhu'] = copy(selected);
  1902. this.updateDercj_djcs_(row, de['dercj'], xuhao, [], 1);
  1903. let newData = this.cache_djcs.map(x=>{
  1904. if (x['key'] == qd['key']) {
  1905. return qd;
  1906. } else {
  1907. return x;
  1908. }
  1909. });
  1910. let summarized = this.summarize_djcs(newData);
  1911. this.push_op_djcs(summarized);
  1912. /////////////////
  1913. this.cache_djcs = copy(summarized);
  1914. return [copy(this.cache_djcs), copy(de['dercj'])];
  1915. }
  1916. huan(old_index, new_bianhao, new_name, new_jia, zhuanye, row) {
  1917. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1918. this.updateFootprint(qd['key']);
  1919. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1920. let rcj = copy(de['dercj']);
  1921. rcj[old_index][1] = new_bianhao;
  1922. rcj[old_index][2] = new_name;
  1923. rcj[old_index][5] = new_jia;
  1924. return this.updateDercj(row, rcj);
  1925. }
  1926. updateShuliang(value, row) {
  1927. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1928. this.updateFootprint(qd['key']);
  1929. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1930. let origin = de['数量']
  1931. if (Number(origin) - Number(value) < 0.0001 && Number(origin) - Number(value) > -0.0001) {
  1932. return [false, null];
  1933. }
  1934. console.log("shuliang update");
  1935. de['数量'] = value;
  1936. de['合价'] = Number(qd['数量']) * Number(de['综合单价']) * Number(de['数量']);
  1937. let newData = this.cache.map(x=>{
  1938. if (x['key'] == qd['key']) {
  1939. return qd;
  1940. } else {
  1941. return x;
  1942. }
  1943. });
  1944. let summarized = this.summarize(newData);
  1945. this.push_op(summarized);
  1946. /////////////////
  1947. this.cache = copy(summarized);
  1948. return [true, copy(this.cache)];
  1949. }
  1950. updateDeMingcheng(value, row) {
  1951. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1952. this.updateFootprint(qd['key']);
  1953. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1954. de['名称'] = value;
  1955. let newData = this.cache.map(x=>{
  1956. if (x['key'] == qd['key']) {
  1957. return qd;
  1958. } else {
  1959. return x;
  1960. }
  1961. });
  1962. let summarized = this.summarize(newData);
  1963. this.push_op(summarized);
  1964. /////////////////
  1965. this.cache = copy(summarized);
  1966. return copy(this.cache);
  1967. }
  1968. updateShuliang_djcs(value, row) {
  1969. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  1970. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  1971. let origin = de['数量']
  1972. if (Number(origin) - Number(value) < 0.0001 && Number(origin) - Number(value) > -0.0001) {
  1973. return [false, null];
  1974. }
  1975. console.log("shuliang update");
  1976. de['数量'] = value;
  1977. de['合价'] = Number(qd['数量']) * Number(de['综合单价']) * Number(de['数量']);
  1978. let newData = this.cache_djcs.map(x=>{
  1979. if (x['key'] == qd['key']) {
  1980. return qd;
  1981. } else {
  1982. return x;
  1983. }
  1984. });
  1985. let summarized = this.summarize_djcs(newData);
  1986. this.push_op_djcs(summarized);
  1987. /////////////////
  1988. this.cache_djcs = copy(summarized);
  1989. return [true, copy(this.cache_djcs)];
  1990. }
  1991. azfy_djcs_eligible(selectedRow) {
  1992. if (this.cache_djcs.filter(x=>x['key'] == selectedRow).length > 0) {
  1993. return true;
  1994. } else {
  1995. return false;
  1996. }
  1997. }
  1998. azfy_djcs(row, dinge, selected) {
  1999. let res = JSON.parse(dinge);
  2000. let keys = Object.keys(res['DEBH']);
  2001. let key = keys[0];
  2002. let tips = null;
  2003. if (res['actual_zhuanye'] == 30) {
  2004. tips = azfy(res['DEBH'][key], res['GCLMC'][key]);
  2005. }
  2006. if (res['actual_zhuanye'] == 60) {
  2007. tips = xsazfy(res['DEBH'][key], res['GCLMC'][key]);
  2008. }
  2009. if (res['actual_zhuanye'] == 10) {
  2010. tips = tjazfy(res['DEBH'][key], res['GCLMC'][key]);
  2011. }
  2012. if (tips != null) {
  2013. res['rgde'] = tips['rgde'];
  2014. res['clde'] = tips['clde'];
  2015. res['jxde'] = tips['jxde'];
  2016. res['azfytag'] = tips['azfytag'];
  2017. }
  2018. let qd = this.cache_djcs.filter(x=>x['key'] == row)[0];
  2019. let dercj = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  2020. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];
  2021. for(let i = 0; i < selected.length; i++) {
  2022. let rgf = selected[i]['人工费'];
  2023. let clf = selected[i]['材料费'];
  2024. let jxf = selected[i]['机械费'];
  2025. let sl = selected[i]['数量'];
  2026. if (res['azfytag'][0] == '人工费') {
  2027. let sum = Number(sl) * Number(rgf) * Number(res['azfytag'][1]) / Number(100);
  2028. dercj.push(['', res['rgde'][0]['CLBH'], res['rgde'][0]['CLMC'], '', '元',
  2029. '1', '', '', '1', '', Number(sum) * Number(res['azfytag'][2]) / Number(100), Number(sum) * Number(res['azfytag'][2]) / Number(100),
  2030. '', '', '', '', uuidv4(), '' ]);
  2031. dercj.push(['', res['clde'][0]['CLBH'], res['clde'][0]['CLMC'], '', '元',
  2032. '1', '', '', '2', '', Number(sum) * Number(res['azfytag'][3]) / Number(100), Number(sum) * Number(res['azfytag'][3]) / Number(100),
  2033. '', '', '', '', uuidv4(), '' ]);
  2034. dercj.push(['', res['jxde'][0]['jxbh'], res['jxde'][0]['jxmc'], '', '元',
  2035. '1', '', '', '3', '', Number(sum) * Number(res['azfytag'][4]) / Number(100), Number(sum) * Number(res['azfytag'][4]) / Number(100),
  2036. '', '', '', '', uuidv4(), '' ]);
  2037. } else if (res['azfytag'][0] == '人工费+机械费') {
  2038. let sum = Number(sl) * (Number(jxf) + Number(rgf)) * Number(res['azfytag'][1]) / Number(100);
  2039. dercj.push(['', res['rgde'][0]['CLBH'], res['rgde'][0]['CLMC'], '', '元',
  2040. '1', '', '', '1', '', Number(sum) * Number(res['azfytag'][2]) / Number(100), Number(sum) * Number(res['azfytag'][2]) / Number(100),
  2041. '', '', '', '', uuidv4(), '' ]);
  2042. dercj.push(['', res['clde'][0]['CLBH'], res['clde'][0]['CLMC'], '', '元',
  2043. '1', '', '', '2', '', Number(sum) * Number(res['azfytag'][3]) / Number(100), Number(sum) * Number(res['azfytag'][3]) / Number(100),
  2044. '', '', '', '', uuidv4(), '' ]);
  2045. dercj.push(['', res['jxde'][0]['jxbh'], res['jxde'][0]['jxmc'], '', '元',
  2046. '1', '', '', '3', '', Number(sum) * Number(res['azfytag'][4]) / Number(100), Number(sum) * Number(res['azfytag'][4]) / Number(100),
  2047. '', '', '', '', uuidv4(), '' ]);
  2048. }
  2049. }
  2050. let newKey = uuidv4();
  2051. if (!qd.hasOwnProperty('_children')) {
  2052. qd["_children"] = [];
  2053. }
  2054. qd["_children"].push({
  2055. '操作': '',
  2056. '序号': null,
  2057. '清单编码': res['DEBH'][key],
  2058. '名称': res['GCLMC'][key],
  2059. '项目特征': null,
  2060. '计算规则': tips != null ? tips['sm'] : '',
  2061. '单位': res['DW'][key],
  2062. '数量': '1',
  2063. '综合单价': '0',
  2064. '合价': '0',
  2065. '人工费': '0',
  2066. '主材费': '0',
  2067. '设备费': '0',
  2068. '辅材费': '0',
  2069. '材料费': '0',
  2070. '机械费': '0',
  2071. '管理费': '0',
  2072. '利润': '0',
  2073. '暂估价': null,
  2074. '综合人工工日': null,
  2075. '备注': null,
  2076. "dercj": dercj,
  2077. '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]]),
  2078. 'key' : newKey,
  2079. "fuzhuEnable": false,
  2080. 'yuban': [],
  2081. 'rcjbc': [],
  2082. 'azfytag': []
  2083. });
  2084. this.updateDercj_djcs_(newKey, dercj, [], []);
  2085. let summarized = this.summarize_djcs(this.cache_djcs);
  2086. this.push_op_djcs(copy(summarized));
  2087. this.cache_djcs = copy(summarized);
  2088. return [true, copy(this.cache_djcs), newKey];
  2089. }
  2090. changguidinge_djcs(dingeclick, row) {
  2091. if (this.cache_djcs.filter(x=>x['key'] == row).length > 0) {
  2092. let res =dingeclick;
  2093. let keys = Object.keys(res['DEBH']);
  2094. let key = keys[0];
  2095. //console.log(res);
  2096. let qd = this.cache_djcs.filter(x=>x['key'] == row)[0];
  2097. let dercj = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  2098. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", "key", 'bc']];
  2099. for(let i = 0; i < res['rgde'].length; i++) {
  2100. dercj.push(['', res['rgde'][i]['CLBH'], res['rgde'][i]['CLMC'], '', res['rgde'][i]['JLDW'],
  2101. res['rgde'][i]['YSJG'], '', '', '1', '', res['rgde'][i]['gr'], res['rgde'][i]['gf'],
  2102. '', '', '', '', uuidv4(), "false" ]);
  2103. }
  2104. for(let i = 0; i < res['clde'].length; i++) {
  2105. let hit = false;
  2106. let jg = null;
  2107. let bh = res['clde'][i]['CLBH'];
  2108. for(let j = 0; j < this.jiagongcai.length; j++) {
  2109. if (this.jiagongcai[j]['材料编号'] == bh) {
  2110. hit = true;
  2111. jg = this.jiagongcai[j]['单价'];
  2112. }
  2113. }
  2114. if (hit) {
  2115. dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  2116. jg, '', '', '2', 'true', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  2117. '', '', '', '', uuidv4(), 'false' ]);
  2118. } else {
  2119. /* if (res['clde'][i].hasOwnProperty('children')) {
  2120. let parent = uuidv4();
  2121. let children = [];
  2122. let child_data = res['clde'][i]['children'];
  2123. for(let j = 0; j < child_data.length; j++) {
  2124. let id = uuidv4();
  2125. children.push(id);
  2126. dercj.push(['', child_data[j]['CLBH'], child_data[j]['CLMC'], '', child_data[j]['JLDW'],
  2127. child_data[j]['YSJG'], '', '', '2', 'false', child_data[j]['SL'], child_data[j]['HJ'],
  2128. '', '', '', '', id, 'false','false', [parent], [] ]);
  2129. }
  2130. dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  2131. res['clde'][i]['YSJG'], '', '', '2', 'false', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  2132. '', '', '', '', parent, 'false','true', [], children ]);
  2133. } else {*/
  2134. dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  2135. res['clde'][i]['YSJG'], '', '', '2', 'false', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  2136. '', '', '', '', uuidv4(), 'false' ]);
  2137. }
  2138. }
  2139. for(let i = 0; i < res['jxde'].length; i++) {
  2140. dercj.push(['', res['jxde'][i]['jxbh'], res['jxde'][i]['jxmc'], '', res['jxde'][i]['DW'],
  2141. res['jxde'][i]['tbdj'], '', '', '3', '', res['jxde'][i]['sl'], res['jxde'][i]['hj'],
  2142. '', '', '', '',uuidv4(), 'false' ]);
  2143. }
  2144. let newKey = uuidv4();
  2145. if (!qd.hasOwnProperty('_children')) {
  2146. qd["_children"] = [];
  2147. }
  2148. 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]]);
  2149. qd["_children"].push({
  2150. '操作': '',
  2151. '序号': null,
  2152. '清单编码': res['DEBH'][key],
  2153. '名称': res['GCLMC'][key],
  2154. '项目特征': null,
  2155. '计算规则': null,
  2156. '单位': res['DW'][key],
  2157. '数量': '1',
  2158. '综合单价': '0',
  2159. '合价': '0',
  2160. '人工费': '0',
  2161. '主材费': '0',
  2162. '设备费': '0',
  2163. '辅材费': '0',
  2164. '材料费': '0',
  2165. '机械费': '0',
  2166. '管理费': '0',
  2167. '利润': '0',
  2168. '暂估价': null,
  2169. '综合人工工日': null,
  2170. '备注': null,
  2171. "dercj": newdercj,
  2172. 'rcjdg': dercj,
  2173. 'key' : newKey,
  2174. "fuzhuEnable": true
  2175. });
  2176. this.updateDercj_djcs_(newKey, newdercj, [], [], 1);
  2177. let summarized = this.summarize_djcs(this.cache_djcs);
  2178. this.push_op_djcs(copy(summarized));
  2179. /////////////////
  2180. this.cache_djcs = copy(summarized);
  2181. //return copy(this.cache);
  2182. return [true, copy(this.cache_djcs), newKey];
  2183. } else {
  2184. return [false, null, null];
  2185. }
  2186. }
  2187. handleAI_djcs(result) {
  2188. let keys = Object.keys(result);
  2189. let datakey = null;
  2190. for (let i = 0; i < keys.length; i++) {
  2191. let key = keys[i]
  2192. let hits = this.cache_djcs.filter(x=>x['清单编码']==key);
  2193. let qd = hits[0]
  2194. if (qd == null)continue;
  2195. let r = result[key]
  2196. let rr = r['result']
  2197. let rrr = rr['result'][0]
  2198. //console.log(rrr)
  2199. //console.log(qd)
  2200. datakey = qd['key']
  2201. qd['rcj']=rrr['rcj']
  2202. qd['主材费'] = String(rrr['主材费'])
  2203. qd['人工费'] = String(rrr['人工费'])
  2204. qd['利润'] = String(rrr['利润'])
  2205. qd['合价'] = String(rrr['合价'])
  2206. qd['暂估价'] = String(rrr['暂估价'])
  2207. qd['机械费'] = String(rrr['机械费'])
  2208. qd['材料费'] = String(rrr['材料费'])
  2209. qd['管理费'] = String(rrr['管理费'])
  2210. qd['综合人工工日'] = String(rrr['综合人工工日'])
  2211. qd['综合单价'] = String(rrr['综合单价'])
  2212. qd['设备费'] = String(rrr['设备费'])
  2213. qd['辅材费'] = String(rrr['辅材费'])
  2214. qd['_children'] = rrr['_children']
  2215. }
  2216. this.push_op_djcs(copy(this.cache_djcs));
  2217. return [true, copy(this.cache_djcs), datakey];
  2218. }
  2219. handleAI(result) {
  2220. let keys = Object.keys(result);
  2221. let datakey = null;
  2222. let changed = false;
  2223. for (let i = 0; i < keys.length; i++) {
  2224. let key = keys[i]
  2225. let hits = this.cache.filter(x=>x['清单编码']==key);
  2226. let qd = hits[0]
  2227. if (qd == null)continue;
  2228. changed = true;
  2229. let r = result[key]
  2230. let rr = r['result']
  2231. let rrr = rr['result'][0]
  2232. //console.log(rrr)
  2233. //console.log(qd)
  2234. datakey = qd['key']
  2235. qd['rcj']=rrr['rcj']
  2236. qd['主材费'] = String(rrr['主材费'])
  2237. qd['人工费'] = String(rrr['人工费'])
  2238. qd['利润'] = String(rrr['利润'])
  2239. qd['合价'] = String(rrr['合价'])
  2240. qd['暂估价'] = String(rrr['暂估价'])
  2241. qd['机械费'] = String(rrr['机械费'])
  2242. qd['材料费'] = String(rrr['材料费'])
  2243. qd['管理费'] = String(rrr['管理费'])
  2244. qd['综合人工工日'] = String(rrr['综合人工工日'])
  2245. qd['综合单价'] = String(rrr['综合单价'])
  2246. qd['设备费'] = String(rrr['设备费'])
  2247. qd['辅材费'] = String(rrr['辅材费'])
  2248. qd['_children'] = rrr['_children']
  2249. }
  2250. if (changed) {
  2251. this.push_op(copy(this.cache));
  2252. this.updateFootprint(datakey);
  2253. return [true, copy(this.cache), datakey];
  2254. } else {
  2255. return [false, null, null];
  2256. }
  2257. }
  2258. changguidinge(dingeclick, row) {
  2259. if (this.cache.filter(x=>x['key'] == row).length > 0) {
  2260. this.updateFootprint(row);
  2261. let res = copy(dingeclick);
  2262. let keys = Object.keys(res['DEBH']);
  2263. let key = keys[0];
  2264. let tips = null;
  2265. if (res['actual_zhuanye'] == 30) {
  2266. tips = azfy(res['DEBH'][key], res['GCLMC'][key]);
  2267. }
  2268. if (res['actual_zhuanye'] == 60) {
  2269. tips = xsazfy(res['DEBH'][key], res['GCLMC'][key]);
  2270. }
  2271. if (res['actual_zhuanye'] == 10) {
  2272. tips = tjazfy(res['DEBH'][key], res['GCLMC'][key]);
  2273. }
  2274. if (tips != null) {
  2275. res['rgde'] = tips['rgde'];
  2276. res['clde'] = tips['clde'];
  2277. res['jxde'] = tips['jxde'];
  2278. }
  2279. let qd = this.cache.filter(x=>x['key'] == row)[0];
  2280. let dercj = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  2281. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];
  2282. for(let i = 0; i < res['rgde'].length; i++) {
  2283. dercj.push(['', res['rgde'][i]['CLBH'], res['rgde'][i]['CLMC'], '', res['rgde'][i]['JLDW'],
  2284. res['rgde'][i]['YSJG'], '', '', '1', '', res['rgde'][i]['gr'], res['rgde'][i]['gf'],
  2285. '', '', '', '', uuidv4(), 'false' ]);
  2286. }
  2287. for(let i = 0; i < res['clde'].length; i++) {
  2288. let hit = false;
  2289. let jg = null;
  2290. let bh = res['clde'][i]['CLBH'];
  2291. for(let j = 0; j < this.jiagongcai.length; j++) {
  2292. if (this.jiagongcai[j]['材料编号'] == bh) {
  2293. hit = true;
  2294. jg = this.jiagongcai[j]['单价'];
  2295. }
  2296. }
  2297. if (hit) {
  2298. dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  2299. jg, '', '', '2', 'true', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  2300. '', '', '', '', uuidv4(), 'false' ]);
  2301. } else {
  2302. /*if (res['clde'][i].hasOwnProperty('children') && res['clde'][i]['CLMC'].includes('砂浆')) {
  2303. let parent = uuidv4();
  2304. let children = [];
  2305. let child_data = res['clde'][i]['children'];
  2306. for(let j = 0; j < child_data.length; j++) {
  2307. let id = uuidv4();
  2308. children.push(id);
  2309. dercj.push(['', child_data[j]['CLBH'], child_data[j]['CLMC'], '', child_data[j]['JLDW'],
  2310. child_data[j]['YSJG'], '', '', '2', 'false', child_data[j]['SL'], child_data[j]['HJ'],
  2311. '', '', '', '', id, 'false','false', [parent], [] ]);
  2312. }
  2313. dercj.push(['', res['clde'][i]['CLBH'].toString(), res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  2314. res['clde'][i]['YSJG'], '', '', '2', 'false', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  2315. '', '', '', '', parent, 'false','true', [], children ]);
  2316. } else {*/
  2317. dercj.push(['', res['clde'][i]['CLBH'].toString(), res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
  2318. res['clde'][i]['YSJG'], '', '', '2', 'false', res['clde'][i]['SL'], res['clde'][i]['HJ'],
  2319. '', '', '', '', uuidv4(), 'false' ]);
  2320. }
  2321. }
  2322. for(let i = 0; i < res['jxde'].length; i++) {
  2323. dercj.push(['', res['jxde'][i]['jxbh'], res['jxde'][i]['jxmc'], '', res['jxde'][i]['DW'],
  2324. res['jxde'][i]['tbdj'], '', '', '3', '', res['jxde'][i]['sl'], res['jxde'][i]['hj'],
  2325. '', '', '', '', uuidv4(), 'false']);
  2326. }
  2327. let newKey = uuidv4();
  2328. if (!qd.hasOwnProperty('_children')) {
  2329. qd["_children"] = [];
  2330. }
  2331. 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]]);
  2332. qd["_children"].push({
  2333. '操作': '',
  2334. '序号': null,
  2335. '清单编码': res['DEBH'][key],
  2336. '名称': res['GCLMC'][key],
  2337. '项目特征': null,
  2338. '计算规则': tips != null ? tips['sm'] : '',
  2339. '单位': res['DW'][key],
  2340. '数量': '1',
  2341. '综合单价': '0',
  2342. '合价': '0',
  2343. '人工费': '0',
  2344. '主材费': '0',
  2345. '设备费': '0',
  2346. '辅材费': '0',
  2347. '材料费': '0',
  2348. '机械费': '0',
  2349. '管理费': '0',
  2350. '利润': '0',
  2351. '暂估价': null,
  2352. '综合人工工日': null,
  2353. '备注': null,
  2354. "dercj": newdercj,
  2355. 'rcjdg': (dercj),
  2356. 'key' : newKey,
  2357. "fuzhuEnable": true,
  2358. 'yuban': [],
  2359. 'rcjbc': [],
  2360. 'azfytag': tips != null ? tips['azfytag'] : []
  2361. });
  2362. this.updateDercj_(newKey, dercj, [], [], [], 1);
  2363. let summarized = this.summarize(this.cache);
  2364. this.push_op(copy(summarized));
  2365. /////////////////
  2366. this.cache = copy(summarized);
  2367. //return copy(this.cache);
  2368. return [true, copy(this.cache), newKey];
  2369. } else {
  2370. return [false, null, null];
  2371. }
  2372. }
  2373. danxiangdinge(row) {
  2374. let bh = danxiangdinge_index(this.cache);
  2375. if (this.cache.filter(x=>x['key'] == row).length > 0) {
  2376. this.updateFootprint(row);
  2377. let selected = this.cache.filter(x=>x['key'] == row)[0];
  2378. let danwei = selected["单位"];
  2379. let mingcheng = selected['名称'];
  2380. let children = selected["_children"];
  2381. children.push({
  2382. '操作': '',
  2383. '序号': null,
  2384. '清单编码': bh,
  2385. '名称': mingcheng,
  2386. '项目特征': null,
  2387. '计算规则': null,
  2388. '单位': danwei,
  2389. '数量': '1',
  2390. '综合单价': '',
  2391. '合价': '',
  2392. '人工费': '0',
  2393. '主材费': '0',
  2394. '设备费': '0',
  2395. '辅材费': '',
  2396. '材料费': '',
  2397. '机械费': '0',
  2398. '管理费': '0',
  2399. '利润': '0',
  2400. '暂估价': null,
  2401. '综合人工工日': null,
  2402. '备注': null,
  2403. "dercj": [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  2404. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ],
  2405. ['', bh, mingcheng, '', danwei, '', '', '', '2', '', '1', '', '', '', '', '', uuidv4(), '' ]
  2406. ],
  2407. 'key' : uuidv4(),
  2408. "fuzhuEnable": false,
  2409. 'yuban': [],
  2410. 'rcjbc' : [],
  2411. 'azfytag': []
  2412. });
  2413. let summarized = this.summarize(this.cache);
  2414. this.push_op(summarized);
  2415. this.cache = copy(summarized);
  2416. return [true, copy(this.cache)];
  2417. } else {
  2418. return [false,null];
  2419. }
  2420. }
  2421. danxiangdinge_djcs(row) {
  2422. let bh = danxiangdinge_index_djcs(this.cache_djcs);
  2423. if (this.cache_djcs.filter(x=>x['key'] == row).length > 0) {
  2424. let selected = this.cache_djcs.filter(x=>x['key'] == row)[0];
  2425. let danwei = selected["单位"];
  2426. let mingcheng = selected['名称'];
  2427. let children = selected["_children"];
  2428. children.push({
  2429. '序号': null,
  2430. '清单编码': bh,
  2431. '名称': mingcheng,
  2432. '项目特征': null,
  2433. '计算规则': null,
  2434. '单位': danwei,
  2435. '数量': '1',
  2436. '综合单价': '',
  2437. '合价': '',
  2438. '人工费': '0',
  2439. '主材费': '0',
  2440. '设备费': '0',
  2441. '辅材费': '',
  2442. '材料费': '',
  2443. '机械费': '0',
  2444. '管理费': '0',
  2445. '利润': '0',
  2446. '暂估价': null,
  2447. '综合人工工日': null,
  2448. '备注': null,
  2449. "dercj": [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  2450. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", "key" , "bc" ],
  2451. ['', bh, mingcheng, '', danwei, '', '', '', '2', '', '1', '', '', '', '', '', uuidv4(), "" ]
  2452. ],
  2453. 'key' : uuidv4(),
  2454. "fuzhuEnable": false
  2455. });
  2456. let summarized = this.summarize_djcs(this.cache_djcs);
  2457. this.push_op_djcs(summarized);
  2458. this.cache_djcs = copy(summarized);
  2459. return [true, copy(this.cache_djcs)];
  2460. } else {
  2461. return [false,null];
  2462. }
  2463. }
  2464. handleYuban_djcs(row, selected) {
  2465. let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  2466. if (!qd) return [null, null];
  2467. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  2468. let bm = de['清单编码'];
  2469. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  2470. if (de.hasOwnProperty("rcjdg")) {//底稿
  2471. } else {///老数据不能有底稿,附注功能也不使能,预拌也不能使
  2472. //de['rcjdg'] = copy(de['dercj']);
  2473. }
  2474. de['yuban'] = copy(selected);
  2475. this.updateDercj_djcs_(row, de['dercj'], alreadyFuzhu, selected, 1);
  2476. let newData = this.cache_djcs.map(x=>{
  2477. if (x['key'] == qd['key']) {
  2478. return qd;
  2479. } else {
  2480. return x;
  2481. }
  2482. });
  2483. let summarized = this.summarize_djcs(newData);
  2484. this.push_op_djcs(summarized);
  2485. /////////////////
  2486. this.cache_djcs = copy(summarized);
  2487. return [copy(this.cache_djcs), copy(de['dercj'])];
  2488. }
  2489. handleYuban(row, selected) {
  2490. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  2491. if (!qd) return [null, null];
  2492. this.updateFootprint(qd['key']);
  2493. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  2494. let bm = de['清单编码'];
  2495. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  2496. if (de.hasOwnProperty("rcjdg")) {//底稿
  2497. } else {///老数据不能有底稿,附注功能也不使能,预拌也不能使
  2498. //de['rcjdg'] = copy(de['dercj']);
  2499. }
  2500. de['yuban'] = copy(selected);
  2501. this.updateDercj_(row, de['dercj'], alreadyFuzhu, selected, de['rcjbc'], 1);
  2502. let newData = this.cache.map(x=>{
  2503. if (x['key'] == qd['key']) {
  2504. return qd;
  2505. } else {
  2506. return x;
  2507. }
  2508. });
  2509. let summarized = this.summarize(newData);
  2510. this.push_op(summarized);
  2511. /////////////////
  2512. this.cache = copy(summarized);
  2513. return [copy(this.cache), copy(de['dercj'])];
  2514. }
  2515. handleRcjbc(row, rcjbc) {
  2516. let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
  2517. if (!qd) return [null, null];
  2518. this.updateFootprint(qd['key']);
  2519. let de = qd["_children"].filter(x=>x['key'] == row)[0];
  2520. let bm = de['清单编码'];
  2521. let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
  2522. if (de.hasOwnProperty("rcjdg")) {//底稿
  2523. } else {///老数据不能有底稿,附注功能也不使能,预拌也不能使
  2524. //de['rcjdg'] = copy(de['dercj']);
  2525. }
  2526. de['rcjbc'] = copy(rcjbc);
  2527. this.updateDercj_(row, de['dercj'], alreadyFuzhu, de['yuban'], rcjbc, 2);
  2528. let newData = this.cache.map(x=>{
  2529. if (x['key'] == qd['key']) {
  2530. return qd;
  2531. } else {
  2532. return x;
  2533. }
  2534. });
  2535. let summarized = this.summarize(newData);
  2536. this.push_op(summarized);
  2537. /////////////////
  2538. this.cache = copy(summarized);
  2539. return [copy(this.cache), copy(de['dercj'])];
  2540. }
  2541. handleJGC(input) {
  2542. for (let i = 0;i < input.length; i++) {
  2543. let bh = input[i][1];
  2544. let hit = false;
  2545. let jg = 0;
  2546. for(let j = 0; j < this.jiagongcai.length; j++) {
  2547. if (this.jiagongcai[j]['材料编号'] == bh) {
  2548. hit = true;
  2549. //jg = this.jiagongcai[j]['单价'];
  2550. }
  2551. }
  2552. if (hit) {
  2553. input[i][9] = 'true';
  2554. }
  2555. }
  2556. return input;
  2557. }
  2558. async pushTask(data, maxN, label, navigate) {
  2559. let data2 = copy(data);
  2560. data2['now'] = Date.now();
  2561. const response = await fetch(this.ip().concat( "/pushtask/"), {
  2562. method : "POST",
  2563. headers: {
  2564. "Content-type": "application/json",
  2565. 'Authorization': `Bearer ${this.token_}`
  2566. },
  2567. body: JSON.stringify({
  2568. "bianma": data['清单编码'],
  2569. "mc" : data['名称'],
  2570. "tz" : data['项目特征'],
  2571. "dw" : data['单位'] ,
  2572. "sl" : data['数量'],
  2573. "n" : maxN,
  2574. "label": label
  2575. } )
  2576. });
  2577. if (!response.ok) {
  2578. if (response.status == 401) {
  2579. navigate("/editor/signin");
  2580. }
  2581. }
  2582. else {
  2583. const r = await response.json();
  2584. data2['celery_id']=r['id'];
  2585. this.task[data['清单编码']]=data2;
  2586. return r;
  2587. }
  2588. }
  2589. clearTask() {
  2590. this.task={};
  2591. }
  2592. getTaskResult() {
  2593. return copy(this.task);
  2594. }
  2595. async checkTask() {
  2596. let keys = Object.keys(this.task);
  2597. if (keys.length == 0)return "empty";
  2598. for(let i = 0; i < keys.length; i++){
  2599. let entry = this.task[keys[i]];
  2600. if (entry.hasOwnProperty("result")) {
  2601. if (entry["result"]=='failed') return "failed";
  2602. else continue;
  2603. }else {
  2604. let now = entry['now'];
  2605. let current = Date.now();
  2606. if (current - now > 300000){
  2607. entry['result']="failed";
  2608. return "failed";
  2609. } else {
  2610. const response = await fetch(this.ip().concat( "/checktask/".concat(entry['celery_id'])), {
  2611. method : "GET",
  2612. headers : {
  2613. 'Authorization': `Bearer ${this.token_}`
  2614. }
  2615. });
  2616. if (!response.ok) {
  2617. console.error('error');
  2618. entry['result'] = "failed";
  2619. return "failed";
  2620. } else {
  2621. const data = await response.json();
  2622. console.log(data);
  2623. if (data['status']=='FAILURE') {
  2624. entry['result']='failed';
  2625. return 'failed';
  2626. } else if (data['status']=='SUCCESS') {
  2627. entry['result']=data['result'];
  2628. return "progress";
  2629. } else {
  2630. return "progress";
  2631. }
  2632. }
  2633. }
  2634. }
  2635. }
  2636. return "success";
  2637. }
  2638. }
  2639. export default new Service();