| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378 |
- import {copy, danxiangdinge_index, danxiangdinge_index_djcs, renameDingE, extractFuzhu, match_target, azfy, xsazfy, tjazfy, addChildren} from './utils.js';
- import { v4 as uuidv4 } from 'uuid';
- class Service{
-
- constructor() {
- this.footprint = [];
- this.cache = [];
- //this.token_ = localStorage.getItem('token');
- this.memory = [];
- this.mem_pointer = -1;
- this.cache_djcs = [];
- this.memory_djcs = [];
- this.mem_pointer_djcs = -1;
- this.qufei = [];
- this.qufeiEntry = null;
- this.jiagongcai = [];
- this.mapper={
- '99090513' : ['汽车式起重机 50t', 2838.92],
- '99090509' : ['汽车式起重机 25t', 1174.12],
- '99090111': ['履带式起重机 提升质量50t', 1755.71],
- '99090108': ['履带式起重机 提升质量25t', 904.68],
- '99030306': ['静力压桩机 压力1200kN', 1508.23],
- '99030124': ['轨道式柴油打桩机 冲击质量2.5t', 1143.91],
- '99030106' : ['履带式柴油打桩机 冲击质量7t', 2545.82],
- '10450518' : ['纯铝箔 140×140', 0.35],
- '10450508' : ['纯银箔 93.3×93.3', 4.5],
- '04050101' : ['道碴 40~80mm', 47],
- '04034103' : ['石屑(米砂)', 40]
- };
-
- }
- setToken(token) {
- this.token_ = token;
- }
-
- ip() {
- //return "/api"//return "http://127.0.0.1:8000"
- return "http://www.xiaozaotongxue.com/api"
- }
- clearCache() {//set qufei will clear cache
- this.cache = [];
- this.footprint= [];
- this.memory = [];
- this.mem_pointer = -1;
- this.cache_djcs = [];
- this.memory_djcs = [];
- this.mem_pointer_djcs = -1;
- }
- setQufei(data) {
- let result = [];
- for(let i = 0; i < data[0]['children'].length; i++) {
- let child = data[0]['children'][i];
- for(let j = 0; j < child['children'].length; j++) {
- let grandchild = child['children'][j];
- //console.log(grandchild);
- result.push(grandchild);
- }
- }
- this.qufei = result;
- }
- setJiagongcai(data) {
-
- this.jiagongcai = data;
- }
- setQufeiEntry(bh) {
- this.qufeiEntry = this.qufei.filter(x=>x['key'] == bh)[0];
- }
- processDjcsmingxi(mingxi) {
- this.cache_djcs = copy(mingxi);
- for(let i = 0; i < this.cache_djcs.length; i++) {
- let zimu = this.cache_djcs[i];
- if (!zimu.hasOwnProperty("_children")) {
- zimu["_children"] = [];
- }
- if (!zimu.hasOwnProperty("rcj")) {
- zimu["rcj"] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
- }
- }
- for(let i = 0; i < this.cache_djcs.length; i++) {
- let zimu = this.cache_djcs[i];
- for(let j = 0; j < zimu["_children"].length; j++) {
- let de = zimu["_children"][j];
- if (!de.hasOwnProperty("dercj")) {
- de["dercj"] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
- }
- }
- }
- this.cache_djcs = this.cache_djcs.map(x=>{
- //x["children"] = x["__children"];
- x["key"] = x["序号"];
- x["_children"] = x["_children"].map(y=>{
- if (!y.hasOwnProperty('key')) {
- y['key'] = uuidv4();
- }
- return y;
- })
- return x;
- });
- this.memory_djcs = [];
- this.memory_djcs.push(copy(this.cache_djcs));
- this.mem_pointer_djcs = 0;
- }
- processQingdanmingxi(mingxi) {
- this.cache = copy(mingxi);
- for(let i = 0; i < this.cache.length; i++) {
- let zimu = this.cache[i];
- if (!zimu.hasOwnProperty("__children")) {
- zimu["__children"] = [];
- }
- if (!zimu.hasOwnProperty("rcj")) {
- zimu["rcj"] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
- }
- }
- for(let i = 0; i < this.cache.length; i++) {
- let zimu = this.cache[i];
- for(let j = 0; j < zimu["__children"].length; j++) {
- let de = zimu["__children"][j];
- if (!de.hasOwnProperty("dercj")) {
- de["dercj"] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
- }
- }
- }
- this.cache = this.cache.map(x=>{
- x["_children"] = x["__children"];
- x["key"] = x["序号"];
- x["_children"] = x["_children"].map(y=>{
- if (!y.hasOwnProperty('key')) {
- y['key'] = uuidv4();
- }
- return y;
- })
- return x;
- });
- this.memory = [];
- this.footprint = [];
- this.memory.push(copy(this.cache));
- this.mem_pointer = 0;
- }
-
- async generateRencaijihuizong2(name, id, navigate) {
- const response = await fetch(this.ip().concat( "/rencaijihuizong2/"), {
- method : "POST",
- headers: {
- "Content-type": "application/json",
- 'Authorization': `Bearer ${this.token_}`
- },
- body: JSON.stringify({
- name: name,
- id: id
- })
- });
- if (!response.ok) {
- if (response.status == 401) {
- navigate("/editor/signin");
- }
- } else {
- const data = await response.json();
- let result = [];
- for (let i = 1; i < data.length; i++) {
- result.push({
- 'key': uuidv4(),
- 'ID' : data[i][0],
- '编码' : data[i][1],
- '名称': data[i][2],
- '规格型号' : data[i][3],
- '单位' : data[i][4],
- '数量' : data[i][5],
- '单价' : data[i][6],
- '合价' : data[i][7],
- '产地' : data[i][8],
- '供应厂商' : data[i][9],
- '人材机类别' : data[i][10],
- '主要材料标志' : data[i][11],
- '主材标志' : data[i][12],
- '设备标志' : data[i][13],
- '甲供标志' : data[i][14],
- '暂估价标志' : data[i][15]
- });
- }
- this.setQufeiEntry(id);
- return result;
- }
- }
-
- /////////////////////////////////////qingdan//////////////////////////////////////
- async generateQingdanmingxi(name, bh, bt) {
- if (bt == 'ALL') {
- const response = await fetch(this.ip().concat("/qingdanmingxi/"), {
- method : "POST",
- headers: {
- "Content-type": "application/json",
- 'Authorization': `Bearer ${this.token_}`
- },
- body: JSON.stringify(
- {
- "bh": bh,
- "bt": bt,
- "name": name
- }
- )
- });
- if (!response.ok) {
- //const error = await response.json();
- console.error('error');
- } else {
- const data = await response.json();
-
-
- return data;
- }
- } else {
- if (this.cache.length == 0 || this.cache[0]["biao_id"] != name || this.cache[0]["Dwgcbh"] != bh || this.cache[0]["bt"] != bt) {
- const response = await fetch(this.ip().concat("/qingdanmingxi/"), {
- method : "POST",
- headers: {
- "Content-type": "application/json",
- 'Authorization': `Bearer ${this.token_}`
- },
- body: JSON.stringify(
- {
- "bh": bh,
- "bt": bt,
- "name": name
- }
- )
- });
- if (!response.ok) {
- //const error = await response.json();
- console.error('error');
- } else {
- const data = await response.json();
- this.processQingdanmingxi(data);
- this.setQufeiEntry(bh);
- return copy(this.cache);
- }
- } else {
- return copy(this.cache);
- }
- }
- }
- async generateQingdanrcj(name, bh, bt, bm) {
- if (bt == "Djcs") {
- let qd = this.cache_djcs.filter(x=>x["清单编码"] == bm)[0];
- return copy(qd["rcj"]);
- }
- let qd = this.cache.filter(x=>x["清单编码"] == bm)[0];
- return copy(qd["rcj"]);
-
- }
- async generateDingercj(name, bh, bt, qdbm, debm, danwei, key) {
- console.log('generateDingercj');
- console.log(debm);
- if (bt == 'Djcs') {
- let qd = this.cache_djcs.filter(x=>x["清单编码"] == qdbm)[0];
- let de = qd["_children"].filter(x=>x["清单编码"]==debm && x['key'] == key)[0];
- return [copy(de["dercj"]), de["fuzhuEnable"]];
-
- }
- let qd = this.cache.filter(x=>x["清单编码"] == qdbm)[0];
- let de = qd["_children"].filter(x=>x["清单编码"]==debm && x['key'] == key)[0];
- return [copy(de["dercj"]), de["fuzhuEnable"], de['yuban'], de['rcjbc']];
-
-
-
-
-
- }
- /////////////////////////////end of qingdan////////////////////////////////////
- async generateDjcs(name, bh, navigate) {
- if (this.cache_djcs.length == 0 || this.cache_djcs[0]["biao_id"] != name || this.cache_djcs[0]["Dwgcbh"] != bh) {
- const response = await fetch(this.ip().concat( "/djcs/"), {
- method : "POST",
- headers: {
- "Content-type": "application/json",
- 'Authorization': `Bearer ${this.token_}`
- },
- body: JSON.stringify(
- {
- "bh": bh,
- "name": name
- }
- )
- });
- if (!response.ok) {
- if (response.status == 401) {
- navigate("/editor/signin");
- }
- } else {
- const data = await response.json();
- this.processDjcsmingxi(data);
- this.setQufeiEntry(bh);
- return copy(this.cache_djcs);
- }
- } else {
- return copy(this.cache_djcs);
- }
- }
- async save() {
- const response = await fetch(this.ip().concat( "/save/"), {
- method : "POST",
- headers: {
- "Content-type": "application/json",
- 'Authorization': `Bearer ${this.token_}`
- },
- body: JSON.stringify(
- {
-
- "name": JSON.stringify(this.cache.filter(x=>this.footprint.includes(x['key'])))
- }
- )
- });
- if (!response.ok) {
- //const error = await response.json();
- console.error('error');
- } else {
- const data = await response.json();
- this.footprint = [];
- return data;
- }
- }
- async save_djcs() {
- const response = await fetch(this.ip().concat( "/savedjcs/"), {
- method : "POST",
- headers: {
- "Content-type": "application/json",
- 'Authorization': `Bearer ${this.token_}`
- },
- body: JSON.stringify(
- {
-
- "name": JSON.stringify(this.cache_djcs)
- }
- )
- });
- if (!response.ok) {
- //const error = await response.json();
- console.error('error');
- } else {
- const data = await response.json();
- return data;
- }
- }
- async tiaojia(biao_id, bh, bm, mingcheng, danwei, jiage) {
- let glf = "";
- let lr = "";
- let bz = 0;//changgui
- if (this.qufeiEntry['备注'].length == 0) {
- //changuiqufei
- glf = this.qufeiEntry['管理费(%)'] ;
- lr = this.qufeiEntry['利润(%)'];
- } else {
- glf = this.qufeiEntry['管理费(%)'] ;
- lr = this.qufeiEntry['利润(%)'];
- bz = 1;
- }
- const response = await fetch(this.ip().concat( "/tiaojia/"), {
- method : "POST",
- headers: {
- "Content-type": "application/json",
- 'Authorization': `Bearer ${this.token_}`
- },
- body: JSON.stringify(
- {
- "biao_id": biao_id,
- "bh": bh,
- "bm": bm,
- "mingcheng": mingcheng,
- "danwei" : danwei,
- "jiage": jiage,
- "glf" : glf,
- "lr" : lr,
- "bz" : bz
- }
- )
- });
- if (!response.ok) {
- //const error = await response.json();
- console.error('error');
- } else {
- const data = await response.json();
- this.clearCache();
- return data;
- }
- }
- ///////////////////////////////////editor_code//////////////////////////////////
- summarize_one_djcs(qd) {///根据定额汇总清单
- let dict = {};
- let left = [];
- for(let i = 0; i < qd["_children"].length; i++) {
- let de = qd["_children"][i];
- let desl = Number(de['数量']);
- let dercj = de['dercj'];
- for (let j = 1; j < dercj.length; j++) {
- let hl = copy(dercj[j]);
- if (hl[1] == '00EXP001' && hl[4] == '%') {
- left.push(hl);
- continue;
- }
- if (hl[1] == '99EXP007' && hl[4] == '%') {
- left.push(hl);
- continue;
- }
- if (hl[1] == '99EXP022' && hl[4] == '%') {
- left.push(hl);
- continue;
- }
- if (hl[1] == '31130104' && hl[4] == '%') {
- left.push(hl);
- continue;
- }
- hl[10] = desl * Number(hl[10]);
- hl[11] = desl * Number(hl[11]);
- let a = hl[1];//"人材机编码",
- let b = a.concat(hl[2]);//"名称",
- let c = b.concat(hl[4]);// "单位"
- if (dict.hasOwnProperty(c)) {
- dict[c].push(hl);
- } else {
- dict[c] = [hl];
- }
- }
- }
- let result = [];
- for(const key in dict) {
- let list = dict[key];
- let sum = 0;
- let danjia = Number(list[0][5]);
- for (let i =0 ;i < list.length; i++) {
- sum += Number(list[i][10]);
- }
- let entry = [list[0][0], list[0][1], list[0][2], list[0][3], list[0][4], danjia,
- list[0][6], list[0][7], list[0][8], list[0][9], sum, sum * danjia, list[0][12],
- list[0][13], list[0][14], list[0][15]
- ];
- result.push(entry);
- }
- for (let i = 0; i < left.length; i++) {
- result.push(left[i]);
- }
- let gongri = 0;
- for(let i = 0; i < result.length; i++) {
- if (result[i][4] == '工日') {
- gongri += result[i][10];
- }
- }
- result.sort((a, b) => Number(a[8]) - Number(b[8]));
- qd['rcj'] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]].concat(result);
- qd["综合人工工日"] = gongri;
- qd['综合单价'] = 0;
- qd['合价'] = 0;
- qd['人工费'] = 0;
- qd['主材费'] = 0;
- qd['设备费'] = 0;
- qd['辅材费'] = 0;
- qd['材料费'] = 0;
- qd['机械费'] = 0;
- qd['管理费'] = 0;
- qd['利润'] = 0;
- for(let i = 0; i < qd["_children"].length; i++) {
- qd['综合单价'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['综合单价']);
- qd['合价'] += Number(qd['_children'][i]['合价']);
- qd['人工费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['人工费']);
- qd['主材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['主材费']);
- qd['设备费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['设备费']);
- qd['辅材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['辅材费']);
- qd['材料费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['材料费']);
- qd['机械费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['机械费']);
- qd['管理费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['管理费']);
- qd['利润'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['利润']);
- }
- return qd;
- }
- summarize_one(qd) {///根据定额汇总清单
- qd['综合单价'] = 0;
- qd['合价'] = 0;
- qd['人工费'] = 0;
- qd['主材费'] = 0;
- qd['设备费'] = 0;
- qd['辅材费'] = 0;
- qd['材料费'] = 0;
- qd['机械费'] = 0;
- qd['管理费'] = 0;
- qd['利润'] = 0;
- for(let i = 0; i < qd["_children"].length; i++) {
- if (qd["_children"][i]['azfytag'].length > 0)continue;
- qd['综合单价'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['综合单价']);
- qd['合价'] += Number(qd['_children'][i]['合价']);
- qd['人工费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['人工费']);
- qd['主材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['主材费']);
- qd['设备费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['设备费']);
- qd['辅材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['辅材费']);
- qd['材料费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['材料费']);
- qd['机械费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['机械费']);
- qd['管理费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['管理费']);
- qd['利润'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['利润']);
- }
- //处理安装费用
- //console.log(qd["_children"].length);
- for(let i = 0; i < qd["_children"].length; i++) {
- //console.log(i);
- if (qd["_children"][i]['azfytag'].length > 0){
- let tag = qd["_children"][i]['azfytag'];
- if (tag[0] == '人工费') {
- let current_rgf = qd['人工费'];
- let added = Number(current_rgf) * Number(tag[1]) / Number(100);
- let added_rgf = added * Number(tag[2]) / Number(100);
- let added_clf = added * Number(tag[3]) / Number(100);
- let added_jxf = added * Number(tag[4]) / Number(100);
- qd["_children"][i]['人工费'] = added_rgf;
- qd["_children"][i]['辅材费'] = added_clf;
- qd["_children"][i]['材料费'] = added_clf;
- qd["_children"][i]['机械费'] = added_jxf;
- if (this.qufeiEntry['备注'].length == 0) {
- //changuiqufei
- qd["_children"][i]['管理费'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
- qd["_children"][i]['利润'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
- } else {
- qd["_children"][i]['管理费'] = (added_rgf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
- qd["_children"][i]['利润'] = (added_rgf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
- }
-
- qd["_children"][i]['综合单价'] = qd["_children"][i]['人工费'] + qd["_children"][i]['材料费'] + qd["_children"][i]['机械费'] + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
- qd["_children"][i]['合价'] = qd["_children"][i]['综合单价'] * Number(qd["_children"][i]['数量']) * Number(qd['数量']);
- let dercj = qd["_children"][i]['dercj'];
- for (let j = 1; j < dercj.length; j++) {
- dercj[j][11] = Number(added) * Number(dercj[j][10]) / Number(100);
- }
- }
- if (tag[0] == '人工费+机械费') {
- let current_rgf = qd['人工费'] + qd['机械费'];
- let added = Number(current_rgf) * Number(tag[1]) / Number(100);
- let added_rgf = added * Number(tag[2]) / Number(100);
- let added_clf = added * Number(tag[3]) / Number(100);
- let added_jxf = added * Number(tag[4]) / Number(100);
- qd["_children"][i]['人工费'] = added_rgf;
- qd["_children"][i]['辅材费'] = added_clf;
- qd["_children"][i]['材料费'] = added_clf;
- qd["_children"][i]['机械费'] = added_jxf;
- if (this.qufeiEntry['备注'].length == 0) {
- //changuiqufei
- qd["_children"][i]['管理费'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
- qd["_children"][i]['利润'] = (added_rgf + added_jxf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
- } else {
- qd["_children"][i]['管理费'] = (added_rgf) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
- qd["_children"][i]['利润'] = (added_rgf) * Number(this.qufeiEntry['利润(%)']) / Number(100);
- }
-
- qd["_children"][i]['综合单价'] = qd["_children"][i]['人工费'] + qd["_children"][i]['材料费'] + qd["_children"][i]['机械费'] + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
- qd["_children"][i]['合价'] = qd["_children"][i]['综合单价'] * Number(qd["_children"][i]['数量']) * Number(qd["数量"]);
- let dercj = qd["_children"][i]['dercj'];
- for (let j = 1; j < dercj.length; j++) {
-
- dercj[j][11] = Number(added) * Number(dercj[j][10]) / Number(100);
-
- }
- }
- }
- }
- qd['综合单价'] = 0;
- qd['合价'] = 0;
- qd['人工费'] = 0;
- qd['主材费'] = 0;
- qd['设备费'] = 0;
- qd['辅材费'] = 0;
- qd['材料费'] = 0;
- qd['机械费'] = 0;
- qd['管理费'] = 0;
- qd['利润'] = 0;
- for(let i = 0; i < qd["_children"].length; i++) {
- qd['综合单价'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['综合单价']);
- qd['合价'] += Number(qd['_children'][i]['合价']);
- qd['人工费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['人工费']);
- qd['主材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['主材费']);
- qd['设备费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['设备费']);
- qd['辅材费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['辅材费']);
- qd['材料费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['材料费']);
- qd['机械费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['机械费']);
- qd['管理费'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['管理费']);
- qd['利润'] += Number(qd['_children'][i]['数量']) * Number(qd['_children'][i]['利润']);
- }
- let dict = {};
- let left = [];
- for(let i = 0; i < qd["_children"].length; i++) {
- let de = qd["_children"][i];
- let desl = Number(de['数量']);
- let dercj = de['dercj'];
- for (let j = 1; j < dercj.length; j++) {
- let hl = copy(dercj[j]);
- if (hl[1].includes('000FE') && hl[4] == '%') {
- left.push(hl);
- continue;
- }
- if (hl[1] == '00EXP001' && hl[4] == '%') {
- left.push(hl);
- continue;
- }
- if (hl[1] == '99EXP007' && hl[4] == '%') {
- left.push(hl);
- continue;
- }
- if (hl[1] == '99EXP022' && hl[4] == '%') {
- left.push(hl);
- continue;
- }
- if (hl[1] == '31130104' && hl[4] == '%') {
- left.push(hl);
- continue;
- }
- hl[10] = desl * Number(hl[10]);
- hl[11] = desl * Number(hl[11]);
- let a = hl[1];//"人材机编码",
- let b = a.concat(hl[2]);//"名称",
- let c = b.concat(hl[4]);// "单位"
- if (dict.hasOwnProperty(c)) {
- dict[c].push(hl);
- } else {
- dict[c] = [hl];
- }
- }
- }
- let result = [];
- for(const key in dict) {
- let list = dict[key];
- let sum = 0;
- let danjia = Number(list[0][5]);
- for (let i =0 ;i < list.length; i++) {
- sum += Number(list[i][10]);
- }
- let entry = [list[0][0], list[0][1], list[0][2], list[0][3], list[0][4], danjia,
- list[0][6], list[0][7], list[0][8], list[0][9], sum, sum * danjia, list[0][12],
- list[0][13], list[0][14], list[0][15]
- ];
- result.push(entry);
- }
- for (let i = 0; i < left.length; i++) {
- result.push(left[i]);
- }
- let gongri = 0;
- for(let i = 0; i < result.length; i++) {
- if (result[i][4] == '工日') {
- gongri += result[i][10];
- }
- }
- result.sort((a, b) => Number(a[8]) - Number(b[8]));
- qd['rcj'] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]].concat(result);
- qd["综合人工工日"] = gongri;
- return qd;
- }
- summarize(data) {
- return data.map(x=>this.summarize_one(x));
- }
- summarize_djcs(data) {
- return data.map(x=>this.summarize_one_djcs(x));
- }
- push_op(newData) {
- if(this.memory.length == this.mem_pointer + 1) {
- this.memory.push(copy(newData));
- this.mem_pointer = this.mem_pointer + 1;
- } else{
- this.memory.splice(this.mem_pointer + 1);
- this.memory.push(copy(newData));
- this.mem_pointer = this.mem_pointer + 1;
-
- }
- }
- push_op_djcs(newData) {
- if(this.memory_djcs.length == this.mem_pointer_djcs + 1) {
- this.memory_djcs.push(copy(newData));
- this.mem_pointer_djcs = this.mem_pointer_djcs + 1;
- } else{
- this.memory_djcs.splice(this.mem_pointer_djcs + 1);
- this.memory_djcs.push(copy(newData));
- this.mem_pointer_djcs = this.mem_pointer_djcs + 1;
-
- }
- }
- undo() {
- if (this.mem_pointer > 0) {
-
- let newData = this.memory[this.mem_pointer - 1];
- this.mem_pointer = this.mem_pointer - 1;
- this.cache = copy(newData);
- return copy(newData);
-
- }
- return copy(this.cache);
- }
- undo_djcs() {
- if (this.mem_pointer_djcs > 0) {
-
- let newData = this.memory_djcs[this.mem_pointer_djcs - 1];
- this.mem_pointer_djcs = this.mem_pointer_djcs - 1;
- this.cache_djcs = copy(newData);
- return copy(newData);
-
- }
- return copy(this.cache_djcs);
- }
-
- redo() {
- if (this.mem_pointer + 1 != this.memory.length) {
- let newData = this.memory[this.mem_pointer + 1];
- this.mem_pointer = this.mem_pointer + 1;
- this.cache = copy(newData);
- return copy(newData);
- }
- return copy(this.cache);
- }
- redo_djcs() {
- if (this.mem_pointer_djcs + 1 != this.memory_djcs.length) {
- let newData = this.memory_djcs[this.mem_pointer_djcs + 1];
- this.mem_pointer_djcs = this.mem_pointer_djcs + 1;
- this.cache_djcs = copy(newData);
- return copy(newData);
- }
- return copy(this.cache_djcs);
- }
- shanchu_djcs(key) {
- if (this.cache_djcs.filter(x=>x['key'] == key).length > 0) {
- ///qd
- let newData = this.cache_djcs.map(x=>{
- if (x["key"] == key) {
- let y = copy(x);
-
- y["_children"] = [];
- return y;
- } else {
- return x;
- }
- });
- let summarized = this.summarize_djcs(newData);
- this.push_op_djcs(summarized);
- /////////////////
- this.cache_djcs = copy(summarized);
- return copy(this.cache_djcs);
- } else {
- let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key'] == key).length > 0)[0];
- let qdbm = qd['清单编码'];
- let newData = this.cache_djcs.map(x=>{
- if (x["清单编码"] == qdbm) {
- let y = copy(x);
- let origin = y["_children"];
- let trans = origin.filter(z=>z["key"]!=key);
- y["_children"] = trans;
- return y;
- } else {
- return x;
- }
- });
- let summarized = this.summarize_djcs(newData);
- this.push_op_djcs(summarized);
- /////////////////
- this.cache_djcs = copy(summarized);
- return copy(this.cache_djcs);
- }
-
-
- }
- updateFootprint(key) {
- if (this.footprint.includes(key)) {
- } else {
- this.footprint.push(key);
- }
- }
- shanchu(key) {
- if (this.cache.filter(x=>x['key'] == key).length > 0) {
- this.updateFootprint(key);
- ///qd
- let newData = this.cache.map(x=>{
- if (x["key"] == key) {
- let y = copy(x);
-
- y["_children"] = [];
- return y;
- } else {
- return x;
- }
- });
- let summarized = this.summarize(newData);
- this.push_op(summarized);
- /////////////////
- this.cache = copy(summarized);
- return copy(this.cache);
- } else {
- let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key'] == key).length > 0)[0];
- this.updateFootprint(qd['key']);
- let qdbm = qd['清单编码'];
- let newData = this.cache.map(x=>{
- if (x["清单编码"] == qdbm) {
- let y = copy(x);
- let origin = y["_children"];
- let trans = origin.filter(z=>z["key"]!=key);
- y["_children"] = trans;
- return y;
- } else {
- return x;
- }
- });
- let summarized = this.summarize(newData);
- this.push_op(summarized);
- /////////////////
- this.cache = copy(summarized);
- return copy(this.cache);
- }
-
-
- }
- //没有预拌砂浆,没有补充
- updateDercj_djcs_(row, data, xuhao, mode=0/**0->update by view; 1-> config change */) {///change 一条定额 inplace, 汇总一条定额的rcj, xuhao is for rename
- console.log("data updated");
- //处理附注
- let huan = false;
- let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
- let de = qd["_children"].filter(x=>x['key'] == row)[0];
- if (de.hasOwnProperty("rcjdg")) {//新数据
- de['dercj'] = copy(de['rcjdg']);
- if (de.hasOwnProperty('fuzhu')) {//
-
- for(let j = 1; j < de['rcjdg'].length; j++) {
- let origin = Number(de['rcjdg'][j][10]);
- let bianhao_huan = '';
- let name_huan = '';
- let new_jia = 0;
- for(let i = 0; i < de['fuzhu'].length; i++) {
- let selected = de['fuzhu'][i];//selected is 结构化的处理信息
- let target = selected[0];
-
-
- if (match_target(de['rcjdg'][j][1], de['rcjdg'][j][2], target, selected[1])) {
- if (selected[2] == '系数' || selected[2] == '商品砼系数' || selected[2] == '除此机械外') {
- origin = origin * (Number(selected[3]) ** Number(selected[5]));
- } else if (selected[2] == '含量' || selected[2] == '商品砼含量') {
- origin = Number(selected[3]);
- } else if (selected[2] == '调整' || selected[2] == '商品砼调整') {
- origin = origin + Number(selected[3]) * Number(selected[5]);
- } else if (selected[2] == '调比') {
- origin = origin + Number(selected[3]) * Number(selected[5]) / Number(100);
- } else if (selected[2] == '次方') {
- origin = origin * (Number(selected[3]) ** Number(selected[5]));
- } else if (selected[2] == '叠加备注') {
- } else if (selected[2] == '换机械系数') {
- bianhao_huan = selected[4];
- name_huan = this.mapper[bianhao_huan][0];
- new_jia = this.mapper[bianhao_huan][1];
- origin = origin * (Number(selected[3]) ** Number(selected[5]));
- } else if (selected[2] == '换材料系数') {
- bianhao_huan = selected[4];
- name_huan = this.mapper[bianhao_huan][0];
- new_jia = this.mapper[bianhao_huan][1];
- origin = origin * (Number(selected[3]) ** Number(selected[5]));
- } else if (selected[2] == '使用泵送') {
- if (de['rcjdg'][j][2].includes('C20')) {
- bianhao_huan = '80212103';
- name_huan = '(C20泵送商品砼)';
- new_jia = 342;
- }
- if (de['rcjdg'][j][2].includes('C30')) {
- bianhao_huan = '80212105';
- name_huan = '(C30泵送商品砼)';
- new_jia = 362;
- }
- } else if (selected[2] == '使用非泵送') {
- if (de['rcjdg'][j][2].includes('C20')) {
- bianhao_huan = '80212115';
- name_huan = '(C20非泵送商品砼)';
- new_jia = 333;
- }
- if (de['rcjdg'][j][2].includes('C30')) {
- bianhao_huan = '80212117';
- name_huan = '(C30非泵送商品砼)';
- new_jia = 353;
- }
- }
- else {
- throw new Error('无法处理的附注'.concat(selected[2]));
- }
-
- }
-
- }
-
- if (bianhao_huan == '') {
-
- } else {
- de['dercj'][j][1] = bianhao_huan;//编号
- de['dercj'][j][2] = name_huan;//mc
- de['dercj'][j][5] = new_jia;//jiage
- }
-
- de['dercj'][j][10] = origin;
- de['dercj'][j][11] = Number(de['dercj'][j][5]) * origin;
- }
- }
-
-
- for(let j = 1; j < de['dercj'].length; j++) {
- for (let k = 0; k < data.length; k++) {
- if (data[k][16] == de['dercj'][j][16]) {
- if (de['dercj'][j][2] == data[k][2]) {//名称
-
- } else {
- huan = true;
- }
-
- }
- }
- }
-
- if (mode == 1) {
- data = de['dercj'];
- huan = false;
- } else {
- de['dercj'] = copy(data);
- data = de['dercj'];
- }
-
-
-
- } else {////单项定额没有底稿,老数据没底搞,无法判断换部换,暂时统一认为不换
- //强行改含量
- de['dercj'] = copy(data);
- data = de['dercj'];
- }
- //模拟formula计算每一行的合价
- for(let i = 1; i < data.length; i++) {
- data[i][11] = Number(data[i][10]) * Number(data[i][5]);
- }
- //if (data[0].length > 18)
- //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]]);
-
- let sum = 0;
- let rgf_sum = 0;
- let jxf_sum = 0;
- let clf_sum = 0;
- let zcf_sum = 0;
- for(let i = 1; i < data.length; i++) {
- if (data[i][1]=='00EXP001' && data[i][4] == '%'){//回程费占人工费
- continue;
- }
- if (data[i][1]=='99EXP007' && data[i][4] == '%'){//回程费占机械费
- continue;
- }
- if (data[i][1]=='99EXP022' && data[i][4] == '%'){//回程费占机械费
- continue;
- }
- if (data[i][1]=='31130104' && data[i][4] == '%'){//回程费占材料费
- continue;
- }
- sum += Number(data[i][11]);//11-> hejia
- if (Number(data[i][8]) == 1) {
- rgf_sum += Number(data[i][11]);
- }
- if (Number(data[i][8]) == 2) {
- clf_sum += Number(data[i][11]);
- if (data[i][14] == 'true') {
- zcf_sum += Number(data[i][11]);
- }
- }
- if (Number(data[i][8]) == 3) {
- jxf_sum += Number(data[i][11]);
- }
- }
- console.log("sum=".concat(sum));
- //处理百分比费用
- for(let i = 1; i < data.length; i++) {
- if (data[i][1]=='00EXP001' && data[i][4] == '%'){//回程费占人工费
- data[i][11] = Number(data[i][10]) * rgf_sum / Number(100);
- }
- if (data[i][1]=='99EXP007' && data[i][4] == '%'){//回程费占机械费
- data[i][11] = Number(data[i][10]) * jxf_sum / Number(100);
- }
- if (data[i][1]=='99EXP022' && data[i][4] == '%'){//回程费占机械费
- data[i][11] = Number(data[i][10]) * jxf_sum / Number(100);
- }
- if (data[i][1]=='31130104' && data[i][4] == '%'){//回程费占材料费
- data[i][11] = Number(data[i][10]) * clf_sum / Number(100);
- }
- }
- sum = 0;
- rgf_sum = 0;
- jxf_sum = 0;
- clf_sum = 0;
- zcf_sum = 0;
- for(let i = 1; i < data.length; i++) {
- sum += Number(data[i][11]);//11-> hejia
- if (Number(data[i][8]) == 1) {
- rgf_sum += Number(data[i][11]);
- }
- if (Number(data[i][8]) == 2) {
- clf_sum += Number(data[i][11]);
- if (data[i][14] == 'true') {
- zcf_sum += Number(data[i][11]);
- }
- }
- if (Number(data[i][8]) == 3) {
- jxf_sum += Number(data[i][11]);
- }
- }
-
- let shuliang = Number(qd['数量']);
- for(let i = 0; i< qd["_children"].length; i++) {
- if(qd["_children"][i]['key'] == row) {
- let desl = Number(qd["_children"][i]['数量']);
- let oldname = qd["_children"][i]['清单编码'];
-
- qd["_children"][i]['辅材费'] = clf_sum - zcf_sum;
- qd["_children"][i]['材料费'] = clf_sum;
- qd["_children"][i]['人工费'] = rgf_sum;
- qd["_children"][i]['主材费'] = zcf_sum;
- qd["_children"][i]['设备费'] = 0;
- qd["_children"][i]['机械费'] = jxf_sum;
- if (oldname.startsWith("D")) {//单项清单
- qd["_children"][i]['管理费'] = 0;
- qd["_children"][i]['利润'] = 0;
- } else {
- if (this.qufeiEntry['备注'].length == 0) {
- //changuiqufei
- qd["_children"][i]['管理费'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
- qd["_children"][i]['利润'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
- } else {
- qd["_children"][i]['管理费'] = (rgf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
- qd["_children"][i]['利润'] = (rgf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
- }
- }
- qd["_children"][i]['综合单价'] = sum + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
- qd["_children"][i]['合价'] = (qd["_children"][i]['综合单价'] * shuliang * desl);
-
-
-
- qd["_children"][i]["dercj"] = this.handleJGC(copy(data));
- qd["_children"][i]['清单编码'] = renameDingE(oldname, xuhao, huan);
- }
- }
- }
- updateDercj_(row, data, xuhao, yuban, rcjbc, mode=0) {///change 一条定额 inplace, 汇总一条定额的rcj, xuhao is for rename, yuban is 预拌砂浆
- console.log("data updated");
- //处理附注
- let huan = false;//换
- let data_normal = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];//正常部分,不包括补充
- let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
- let de = qd["_children"].filter(x=>x['key'] == row)[0];
- if (de.hasOwnProperty("rcjdg")) {//新数据
- de['dercj'] = copy(de['rcjdg']);
- if (de.hasOwnProperty('fuzhu')) {//没强行改过含量
- for(let j = 1; j < de['rcjdg'].length; j++) {
- let origin = Number(de['rcjdg'][j][10]);
- let bianhao_huan = '';
- let name_huan = '';
- let new_jia = 0;
- for(let i = 0; i < de['fuzhu'].length; i++) {
- let selected = de['fuzhu'][i];//selected is 结构化的处理信息
- let target = selected[0];
- if (match_target(de['rcjdg'][j][1], de['rcjdg'][j][2], target, selected[1])) {
- if (selected[2] == '系数' || selected[2] == '商品砼系数' || selected[2] == '除此机械外') {
- origin = origin * (Number(selected[3]) ** Number(selected[5]));
- } else if (selected[2] == '含量' || selected[2] == '商品砼含量') {
- origin = Number(selected[3]);
- } else if (selected[2] == '调整' || selected[2] == '商品砼调整') {
- origin = origin + Number(selected[3]) * Number(selected[5]);
- } else if (selected[2] == '调比') {
- origin = origin + Number(selected[3]) * Number(selected[5]) / Number(100);
- } else if (selected[2] == '次方') {
- origin = origin * (Number(selected[3]) ** Number(selected[5]));
- } else if (selected[2] == '叠加备注') {
- } else if (selected[2] == '换机械系数') {
- bianhao_huan = selected[4];
- name_huan = this.mapper[bianhao_huan][0];
- new_jia = this.mapper[bianhao_huan][1];
- origin = origin * (Number(selected[3]) ** Number(selected[5]));
- } else if (selected[2] == '换材料系数') {
- bianhao_huan = selected[4];
- name_huan = this.mapper[bianhao_huan][0];
- new_jia = this.mapper[bianhao_huan][1];
- origin = origin * (Number(selected[3]) ** Number(selected[5]));
- } else if (selected[2] == '使用泵送') {
- if (de['rcjdg'][j][2].includes('C20')) {
- bianhao_huan = '80212103';
- name_huan = '(C20泵送商品砼)';
- new_jia = 342;
- }
- if (de['rcjdg'][j][2].includes('C30')) {
- bianhao_huan = '80212105';
- name_huan = '(C30泵送商品砼)';
- new_jia = 362;
- }
- } else if (selected[2] == '使用非泵送') {
- if (de['rcjdg'][j][2].includes('C20')) {
- bianhao_huan = '80212115';
- name_huan = '(C20非泵送商品砼)';
- new_jia = 333;
- }
- if (de['rcjdg'][j][2].includes('C30')) {
- bianhao_huan = '80212117';
- name_huan = '(C30非泵送商品砼)';
- new_jia = 353;
- }
- }
- else {
- throw new Error('无法处理的附注'.concat(selected[2]));
- }
- }
- }
- if (bianhao_huan == '') {
-
- } else {
- de['dercj'][j][1] = bianhao_huan;//编号
- de['dercj'][j][2] = name_huan;//mc
- de['dercj'][j][5] = new_jia;//jiage
- }
- de['dercj'][j][10] = origin;
- de['dercj'][j][11] = Number(de['dercj'][j][5]) * origin;
- }
- }
- //基于底稿判断换
- for(let j = 1; j < de['dercj'].length; j++) {
- for (let k = 0; k < data.length; k++) {
- if (data[k][16] == de['dercj'][j][16]) {
- let datak2 = data[k][2];
- if (datak2.includes('(湿拌砂浆)')) {
- datak2 = datak2.replace('(湿拌砂浆)', '');
- }
- if (datak2.includes('(干拌(混)砂浆)')) {
- datak2 = datak2.replace('(干拌(混)砂浆)', '');
- }
- if (de['dercj'][j][2] == datak2) {//名称
-
- } else {
- huan = true;
- }
- }
- }
- }
- if (mode == 1) {
- data_normal = de['dercj'];
- huan = false;
- } else {
- data_normal = copy(data.filter(x=>x[17] != 'true'));
- }
- } else {////单项定额没有底稿,老数据没底搞,无法判断换部换,暂时统一认为不换
- //强行改含量
- data_normal = copy(data.filter(x=>x[17] != 'true'));
- //data = de['dercj'];
- }
- //处理补充
- for(let i = 0; i < rcjbc.length; i++) {
- 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']);
- for (let k = 0; k < data.length; k++) {
- if (data[k][16] == rcjbc[i]['id']) {
- let datak2 = data[k][2];
- if (datak2.includes('(湿拌砂浆)')) {
- datak2 = datak2.replace('(湿拌砂浆)', '');
- }
- if (datak2.includes('(干拌(混)砂浆)')) {
- datak2 = datak2.replace('(干拌(混)砂浆)', '');
- }
- if (rcjbc[i]['名称'] == datak2) {//名称
-
- } else {
- if (mode == 2) {
-
- } else {
- huan = true;
- }
- }
- }
- }
- }
- if (yuban.length > 0) {//处理预拌砂浆
- if (yuban.includes('1')) {//与换无关
- for(let i = 1; i < data_normal.length; i++) {
- if (data_normal[i][4]=='工日') {
- data_normal[i][10] = Number(data_normal[i][10]) - 0.45;
- }
- if (data_normal[i][2].includes('搅拌机')) {
- data_normal[i][10] = 0;
- }
- if (data_normal[i][2].includes('砂浆') && !data_normal[i][2].includes('搅拌机')) {
- data_normal[i][2] = data_normal[i][2].concat('(湿拌砂浆)')
- }
- }
- if (mode == 0) {
- data_normal = copy(data);
- } else if (mode == 1) {
- //data_normal = data_normal.filter(x=>x[17]!='true');
- //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
- } else if (mode == 2) {
- let data_normal_2 = copy(data_normal);
- data_normal = data.filter(x=>x[17]!='true');
- data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
- }
- } else if (yuban.includes('2')) {//与换无关
-
- let added = [];
- for(let i = 1; i < data_normal.length; i++) {
- let origin = 0;
- if (data_normal[i][4]=='工日') {
- data_normal[i][10] = Number(data_normal[i][10]) - 0.3;
- }
- if (data_normal[i][2].includes('搅拌机')) {
- data_normal[i][10] = 0;
- }
- if (data_normal[i][2].includes('砂浆') && !data_normal[i][2].includes('搅拌机')) {
- data_normal[i][2] = data_normal[i][2].concat('(干拌(混)砂浆)');
- origin = Number(data_normal[i][10]);
- data_normal[i][10] = origin * 1.75;
- added.push(['', 'S00001', '水', '', 't', '4.70', '', '', '2', 'false', (origin * 0.29).toString(), ''/**hj */, ''/**zgj */,''/**zycl */,''/**zc */,''/**sb */,'',data_normal[i][17]]);
- added.push(['', 'JD0001', '其他机械费(电)', '', '度', '0.65', '', '', '3', 'false', (origin * 2.15).toString(), ''/**hj */, ''/**zgj */,''/**zycl */,''/**zc */,''/**sb */, '',data_normal[i][17]]);
-
- }
- }
- data_normal = data_normal.concat(added);
- if (mode == 0) {
- data_normal = copy(data);
- } else if (mode == 1) {
- //data_normal = data_normal.filter(x=>x[17]!='true');
- //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
- } else if (mode == 2) {
- let data_normal_2 = copy(data_normal);
- data_normal = data.filter(x=>x[17]!='true');
- data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
- }
- } else if (yuban.includes('3')) {//与换无关
- let added = [];
- for(let i = 1; i < data_normal.length; i++) {
- let origin = 0;
- if (data_normal[i][4]=='工日') {
- data_normal[i][10] = Number(data_normal[i][10]) - 0.2;
- }
- if (data_normal[i][2].includes('砂浆') && !data_normal[i][2].includes('搅拌机')) {
- data_normal[i][2] = data_normal[i][2].concat('(干拌(混)砂浆)');
- origin = Number(data_normal[i][10]);
- data_normal[i][10] = origin * 1.75;
- added.push(['', 'S00001', '水', '', 't', '4.70', '', '', '2', 'false', (origin * 0.29).toString(), '', '','','','','',data_normal[i][17]]);
- }
- }
- data_normal = data_normal.concat(added);
- if (mode == 0) {
- data_normal = copy(data);
- } else if (mode == 1) {
- //data_normal = data_normal.filter(x=>x[17]!='true');
- //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
- } else if (mode == 2) {
- let data_normal_2 = copy(data_normal);
- data_normal = data.filter(x=>x[17]!='true');
- data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
- }
- } else {
- let data_normal_2 = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];
- for(let i = 1; i < data_normal.length; i++) {
- let bc = data_normal[i][17];
- let child = addChildren(10, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
- if (child.length > 0) {
- } else {
- child = addChildren(40, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
- if (child.length > 0) {
- } else {
- child = addChildren(50, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
- }
- }
- if (child.length > 0) {//拆分
- for(let j = 0; j < child.length; j++) {
- data_normal_2.push(child[j]);
- if (bc == 'true') {
- for (let k = 0; k < data.length; k++) {
- if (data[k][16] == child[j][16]) {
- let datak2 = data[k][2];
-
- if (child[j][2] == datak2) {//名称
-
- } else {
- if (mode > 0) {
- } else {
- huan = true;
- }
- }
-
- }
- }
- } else if (mode != 1){
- for (let k = 0; k < data.length; k++) {
- if (data[k][16] == child[j][16]) {
- let datak2 = data[k][2];
-
- if (child[j][2] == datak2) {//名称
-
- } else {
- huan = true;
- }
-
- }
- }
- }
- }
- } else {
- data_normal_2.push(data_normal[i]);
- }
- }
- if (mode == 0) {
- data_normal = copy(data);
- } else if (mode == 2) {
- data_normal = data.filter(x=>x[17]!='true');
- data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
- } else if (mode == 1) {
- data_normal = data_normal_2;
- //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
- }
- }
-
- } else {//没有预拌
- let data_normal_2 = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];
- for(let i = 1; i < data_normal.length; i++) {
- let bc = data_normal[i][17];
- let child = addChildren(10, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
- if (child.length > 0) {
- } else {
- child = addChildren(40, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
- if (child.length > 0) {
- } else {
- child = addChildren(50, data_normal[i][1], data_normal[i][10], data_normal[i][17], data_normal[i][16]);
- }
- }
- if (child.length > 0) {//拆分
- for(let j = 0; j < child.length; j++) {
- data_normal_2.push(child[j]);
- if (bc == 'true') {
- for (let k = 0; k < data.length; k++) {
- if (data[k][16] == child[j][16]) {
- let datak2 = data[k][2];
-
- if (child[j][2] == datak2) {//名称
-
- } else {
- if (mode > 0) {
- } else {
- huan = true;
- }
- }
-
- }
- }
- } else if (mode != 1){
- for (let k = 0; k < data.length; k++) {
- if (data[k][16] == child[j][16]) {
- let datak2 = data[k][2];
-
- if (child[j][2] == datak2) {//名称
-
- } else {
- huan = true;
- }
-
- }
- }
- }
- }
- } else {
- data_normal_2.push(data_normal[i]);
- }
- }
- if (mode == 0) {
- data_normal = copy(data);
- } else if (mode == 2) {
- data_normal = data.filter(x=>x[17]!='true');
- data_normal = data_normal.concat(data_normal_2.filter(x=> x[17] == 'true'));
- } else if (mode == 1) {
- data_normal = data_normal_2;
- //data_normal = data_normal.concat(data.filter(x=> x[17] == 'true'));
- }
- }
-
- data = copy(data_normal);
- //模拟formula计算每一行的合价
- for(let i = 1; i < data.length; i++) {
- data[i][11] = Number(data[i][10]) * Number(data[i][5]);
- }
-
-
- let sum = 0;
- let rgf_sum = 0;
- let jxf_sum = 0;
- let clf_sum = 0;
- let zcf_sum = 0;
- for(let i = 1; i < data.length; i++) {
- if (data[i][1].includes('000FE') && data[i][4] == '%')continue;//azfy
- if (data[i][1]=='00EXP001' && data[i][4] == '%'){//回程费占人工费
- continue;
- }
- if (data[i][1]=='99EXP007' && data[i][4] == '%'){//回程费占机械费
- continue;
- }
- if (data[i][1]=='99EXP022' && data[i][4] == '%'){//回程费占机械费
- continue;
- }
- if (data[i][1]=='31130104' && data[i][4] == '%'){//回程费占材料费
- continue;
- }
- sum += Number(data[i][11]);//11-> hejia
- if (Number(data[i][8]) == 1) {
- rgf_sum += Number(data[i][11]);
- }
- if (Number(data[i][8]) == 2) {
- clf_sum += Number(data[i][11]);
- if (data[i][14] == 'true') {
- zcf_sum += Number(data[i][11]);
- }
- }
- if (Number(data[i][8]) == 3) {
- jxf_sum += Number(data[i][11]);
- }
- }
- console.log("sum=".concat(sum));
- //处理百分比费用
- for(let i = 1; i < data.length; i++) {
- if (data[i][1]=='00EXP001' && data[i][4] == '%'){//回程费占人工费
- data[i][11] = Number(data[i][10]) * rgf_sum / Number(100);
- }
- if (data[i][1]=='99EXP007' && data[i][4] == '%'){//回程费占机械费
- data[i][11] = Number(data[i][10]) * jxf_sum / Number(100);
- }
- if (data[i][1]=='99EXP022' && data[i][4] == '%'){//回程费占机械费
- data[i][11] = Number(data[i][10]) * jxf_sum / Number(100);
- }
- if (data[i][1]=='31130104' && data[i][4] == '%'){//回程费占材料费
- data[i][11] = Number(data[i][10]) * clf_sum / Number(100);
- }
- }
- sum = 0;
- rgf_sum = 0;
- jxf_sum = 0;
- clf_sum = 0;
- zcf_sum = 0;
- for(let i = 1; i < data.length; i++) {
- sum += Number(data[i][11]);//11-> hejia
- if (Number(data[i][8]) == 1) {
- rgf_sum += Number(data[i][11]);
- }
- if (Number(data[i][8]) == 2) {
- clf_sum += Number(data[i][11]);
- if (data[i][14] == 'true') {
- zcf_sum += Number(data[i][11]);
- }
- }
- if (Number(data[i][8]) == 3) {
- jxf_sum += Number(data[i][11]);
- }
- }
- let shuliang = Number(qd['数量']);
- for(let i = 0; i< qd["_children"].length; i++) {
- if(qd["_children"][i]['key'] == row) {
- let desl = Number(qd["_children"][i]['数量']);
- let oldname = qd["_children"][i]['清单编码'];
-
- qd["_children"][i]['辅材费'] = clf_sum - zcf_sum;
- qd["_children"][i]['材料费'] = clf_sum;
- qd["_children"][i]['人工费'] = rgf_sum;
- qd["_children"][i]['主材费'] = zcf_sum;
- qd["_children"][i]['设备费'] = 0;
- qd["_children"][i]['机械费'] = jxf_sum;
- if (oldname.startsWith("D")) {//单项清单
- qd["_children"][i]['管理费'] = 0;
- qd["_children"][i]['利润'] = 0;
- } else {
- if (this.qufeiEntry['备注'].length == 0) {
- //changuiqufei
- qd["_children"][i]['管理费'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
- qd["_children"][i]['利润'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
- } else {
- qd["_children"][i]['管理费'] = (rgf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
- qd["_children"][i]['利润'] = (rgf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
- }
- }
- qd["_children"][i]['综合单价'] = sum + qd["_children"][i]['管理费'] + qd["_children"][i]['利润'];
- qd["_children"][i]['合价'] = (qd["_children"][i]['综合单价'] * shuliang * desl);
-
-
-
- qd["_children"][i]["dercj"] = this.handleJGC(copy(data));
- qd["_children"][i]['清单编码'] = renameDingE(oldname, xuhao, huan);
- }
- }
- }
- updateDercj(row, data) {
- //是否手动设置含量
- let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
- let de = qd["_children"].filter(x=>x['key'] == row)[0];
- this.updateFootprint(qd['key']);
- let bm = de['清单编码'];
- let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
-
-
- this.updateDercj_(row, data, alreadyFuzhu, de['yuban'], de['rcjbc']);
- //let qd = this.cache.filter(x=>x["children"].filter(y=>y['key']==row).length > 0)[0];
- let newData = this.cache.map(x=>{
- if (x['key'] == qd['key']) {
- return qd;
- } else {
- return x;
- }
- });
- let summarized = this.summarize(newData);
- this.push_op(summarized);
- /////////////////
- this.cache = copy(summarized);
- return copy(this.cache);
- }
- updateDercj_djcs(row, data) {
- //是否手动设置含量
- let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
- let de = qd["_children"].filter(x=>x['key'] == row)[0];
- let bm = de['清单编码'];
- let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
-
-
- this.updateDercj_djcs_(row, data, alreadyFuzhu);
- //let qd = this.cache.filter(x=>x["children"].filter(y=>y['key']==row).length > 0)[0];
- let newData = this.cache_djcs.map(x=>{
- if (x['key'] == qd['key']) {
- return qd;
- } else {
- return x;
- }
- });
- let summarized = this.summarize_djcs(newData);
- this.push_op_djcs(summarized);
- /////////////////
- this.cache_djcs = copy(summarized);
- return copy(this.cache_djcs);
- }
- updateBeizhu(row, selected, xuhao) {//xuhao is for rename, selected is 结构化的处理信息
- let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
- if (!qd) return [null, null];
- this.updateFootprint(qd['key']);
- let de = qd["_children"].filter(x=>x['key'] == row)[0];
- if (de.hasOwnProperty("rcjdg")) {//底稿
- } else {///老数据不能有底稿,附注功能也不使能
- //de['rcjdg'] = copy(de['dercj']);
- }
- de['fuzhu'] = copy(selected);
- this.updateDercj_(row, de['dercj'], xuhao, de['yuban'], de['rcjbc'], 1);
- let newData = this.cache.map(x=>{
- if (x['key'] == qd['key']) {
- return qd;
- } else {
- return x;
- }
- });
- let summarized = this.summarize(newData);
- this.push_op(summarized);
- /////////////////
- this.cache = copy(summarized);
- return [copy(this.cache), copy(de['dercj'])];
- }
- updateBeizhu_djcs(row, selected, xuhao) {//xuhao is for rename
- let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
- if (!qd) return [null, null];
- let de = qd["_children"].filter(x=>x['key'] == row)[0];
- if (de.hasOwnProperty("rcjdg")) {//底稿
- } else {///老数据不能有底稿,附注功能也不使能
- //de['rcjdg'] = copy(de['dercj']);
- }
- de['fuzhu'] = copy(selected);
- this.updateDercj_djcs_(row, de['dercj'], xuhao, 1);
- let newData = this.cache_djcs.map(x=>{
- if (x['key'] == qd['key']) {
- return qd;
- } else {
- return x;
- }
- });
- let summarized = this.summarize_djcs(newData);
- this.push_op_djcs(summarized);
- /////////////////
- this.cache_djcs = copy(summarized);
- return [copy(this.cache_djcs), copy(de['dercj'])];
- }
- huan(old_index, new_bianhao, new_name, new_jia, zhuanye, row) {
- let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
- this.updateFootprint(qd['key']);
- let de = qd["_children"].filter(x=>x['key'] == row)[0];
- let rcj = copy(de['dercj']);
-
- rcj[old_index][1] = new_bianhao;
- rcj[old_index][2] = new_name;
- rcj[old_index][5] = new_jia;
- return this.updateDercj(row, rcj);
- }
- updateShuliang(value, row) {
- let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
- this.updateFootprint(qd['key']);
- let de = qd["_children"].filter(x=>x['key'] == row)[0];
- let origin = de['数量']
- if (Number(origin) - Number(value) < 0.0001 && Number(origin) - Number(value) > -0.0001) {
- return [false, null];
- }
- console.log("shuliang update");
- de['数量'] = value;
- de['合价'] = Number(qd['数量']) * Number(de['综合单价']) * Number(de['数量']);
- let newData = this.cache.map(x=>{
- if (x['key'] == qd['key']) {
- return qd;
- } else {
- return x;
- }
- });
- let summarized = this.summarize(newData);
- this.push_op(summarized);
- /////////////////
- this.cache = copy(summarized);
- return [true, copy(this.cache)];
- }
- updateDeMingcheng(value, row) {
- let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
- this.updateFootprint(qd['key']);
- let de = qd["_children"].filter(x=>x['key'] == row)[0];
- de['名称'] = value;
- let newData = this.cache.map(x=>{
- if (x['key'] == qd['key']) {
- return qd;
- } else {
- return x;
- }
- });
- let summarized = this.summarize(newData);
- this.push_op(summarized);
- /////////////////
- this.cache = copy(summarized);
- return copy(this.cache);
- }
- updateShuliang_djcs(value, row) {
- let qd = this.cache_djcs.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
- let de = qd["_children"].filter(x=>x['key'] == row)[0];
- let origin = de['数量']
- if (Number(origin) - Number(value) < 0.0001 && Number(origin) - Number(value) > -0.0001) {
- return [false, null];
- }
- console.log("shuliang update");
- de['数量'] = value;
- de['合价'] = Number(qd['数量']) * Number(de['综合单价']) * Number(de['数量']);
- let newData = this.cache_djcs.map(x=>{
- if (x['key'] == qd['key']) {
- return qd;
- } else {
- return x;
- }
- });
- let summarized = this.summarize_djcs(newData);
- this.push_op_djcs(summarized);
- /////////////////
- this.cache_djcs = copy(summarized);
- return [true, copy(this.cache_djcs)];
- }
- azfy_djcs_eligible(selectedRow) {
- if (this.cache_djcs.filter(x=>x['key'] == selectedRow).length > 0) {
- return true;
- } else {
- return false;
- }
- }
- azfy_djcs(row, dinge, selected) {
- let res = JSON.parse(dinge);
- let keys = Object.keys(res['DEBH']);
- let key = keys[0];
- let tips = null;
- if (res['actual_zhuanye'] == 30) {
- tips = azfy(res['DEBH'][key], res['GCLMC'][key]);
- }
- if (res['actual_zhuanye'] == 60) {
- tips = xsazfy(res['DEBH'][key], res['GCLMC'][key]);
- }
- if (res['actual_zhuanye'] == 10) {
- tips = tjazfy(res['DEBH'][key], res['GCLMC'][key]);
- }
- if (tips != null) {
- res['rgde'] = tips['rgde'];
- res['clde'] = tips['clde'];
- res['jxde'] = tips['jxde'];
- res['azfytag'] = tips['azfytag'];
- }
- let qd = this.cache_djcs.filter(x=>x['key'] == row)[0];
- let dercj = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];
- for(let i = 0; i < selected.length; i++) {
- let rgf = selected[i]['人工费'];
- let clf = selected[i]['材料费'];
- let jxf = selected[i]['机械费'];
- let sl = selected[i]['数量'];
- if (res['azfytag'][0] == '人工费') {
- let sum = Number(sl) * Number(rgf) * Number(res['azfytag'][1]) / Number(100);
- dercj.push(['', res['rgde'][0]['CLBH'], res['rgde'][0]['CLMC'], '', '元',
- '1', '', '', '1', '', Number(sum) * Number(res['azfytag'][2]) / Number(100), Number(sum) * Number(res['azfytag'][2]) / Number(100),
- '', '', '', '', uuidv4(), '' ]);
- dercj.push(['', res['clde'][0]['CLBH'], res['clde'][0]['CLMC'], '', '元',
- '1', '', '', '2', '', Number(sum) * Number(res['azfytag'][3]) / Number(100), Number(sum) * Number(res['azfytag'][3]) / Number(100),
- '', '', '', '', uuidv4(), '' ]);
- dercj.push(['', res['jxde'][0]['jxbh'], res['jxde'][0]['jxmc'], '', '元',
- '1', '', '', '3', '', Number(sum) * Number(res['azfytag'][4]) / Number(100), Number(sum) * Number(res['azfytag'][4]) / Number(100),
- '', '', '', '', uuidv4(), '' ]);
- } else if (res['azfytag'][0] == '人工费+机械费') {
- let sum = Number(sl) * (Number(jxf) + Number(rgf)) * Number(res['azfytag'][1]) / Number(100);
- dercj.push(['', res['rgde'][0]['CLBH'], res['rgde'][0]['CLMC'], '', '元',
- '1', '', '', '1', '', Number(sum) * Number(res['azfytag'][2]) / Number(100), Number(sum) * Number(res['azfytag'][2]) / Number(100),
- '', '', '', '', uuidv4(), '' ]);
- dercj.push(['', res['clde'][0]['CLBH'], res['clde'][0]['CLMC'], '', '元',
- '1', '', '', '2', '', Number(sum) * Number(res['azfytag'][3]) / Number(100), Number(sum) * Number(res['azfytag'][3]) / Number(100),
- '', '', '', '', uuidv4(), '' ]);
- dercj.push(['', res['jxde'][0]['jxbh'], res['jxde'][0]['jxmc'], '', '元',
- '1', '', '', '3', '', Number(sum) * Number(res['azfytag'][4]) / Number(100), Number(sum) * Number(res['azfytag'][4]) / Number(100),
- '', '', '', '', uuidv4(), '' ]);
- }
- }
- let newKey = uuidv4();
- if (!qd.hasOwnProperty('_children')) {
- qd["_children"] = [];
- }
- qd["_children"].push({
- '操作': '',
- '序号': null,
- '清单编码': res['DEBH'][key],
- '名称': res['GCLMC'][key],
- '项目特征': null,
- '计算规则': tips != null ? tips['sm'] : '',
- '单位': res['DW'][key],
- '数量': '1',
- '综合单价': '0',
- '合价': '0',
- '人工费': '0',
- '主材费': '0',
- '设备费': '0',
- '辅材费': '0',
- '材料费': '0',
- '机械费': '0',
- '管理费': '0',
- '利润': '0',
- '暂估价': null,
- '综合人工工日': null,
- '备注': null,
- "dercj": dercj,
- '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]]),
- 'key' : newKey,
- "fuzhuEnable": false,
- 'yuban': [],
- 'rcjbc': [],
- 'azfytag': []
-
-
- });
- this.updateDercj_djcs_(newKey, dercj, []);
- let summarized = this.summarize_djcs(this.cache_djcs);
- this.push_op_djcs(copy(summarized));
- this.cache_djcs = copy(summarized);
-
- return [true, copy(this.cache_djcs), newKey];
- }
- changguidinge_djcs(dingeclick, row) {
- if (this.cache_djcs.filter(x=>x['key'] == row).length > 0) {
-
- let res =dingeclick;
- let keys = Object.keys(res['DEBH']);
- let key = keys[0];
- //console.log(res);
- let qd = this.cache_djcs.filter(x=>x['key'] == row)[0];
- let dercj = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", "key", 'bc']];
- for(let i = 0; i < res['rgde'].length; i++) {
- dercj.push(['', res['rgde'][i]['CLBH'], res['rgde'][i]['CLMC'], '', res['rgde'][i]['JLDW'],
- res['rgde'][i]['YSJG'], '', '', '1', '', res['rgde'][i]['gr'], res['rgde'][i]['gf'],
- '', '', '', '', uuidv4(), "false" ]);
- }
- for(let i = 0; i < res['clde'].length; i++) {
- let hit = false;
- let jg = null;
- let bh = res['clde'][i]['CLBH'];
- for(let j = 0; j < this.jiagongcai.length; j++) {
- if (this.jiagongcai[j]['材料编号'] == bh) {
- hit = true;
- jg = this.jiagongcai[j]['单价'];
- }
- }
- if (hit) {
- dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
- jg, '', '', '2', 'true', res['clde'][i]['SL'], res['clde'][i]['HJ'],
- '', '', '', '', uuidv4(), 'false' ]);
- } else {
- /* if (res['clde'][i].hasOwnProperty('children')) {
- let parent = uuidv4();
- let children = [];
- let child_data = res['clde'][i]['children'];
- for(let j = 0; j < child_data.length; j++) {
- let id = uuidv4();
- children.push(id);
- dercj.push(['', child_data[j]['CLBH'], child_data[j]['CLMC'], '', child_data[j]['JLDW'],
- child_data[j]['YSJG'], '', '', '2', 'false', child_data[j]['SL'], child_data[j]['HJ'],
- '', '', '', '', id, 'false','false', [parent], [] ]);
- }
- dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
- res['clde'][i]['YSJG'], '', '', '2', 'false', res['clde'][i]['SL'], res['clde'][i]['HJ'],
- '', '', '', '', parent, 'false','true', [], children ]);
- } else {*/
- dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
- res['clde'][i]['YSJG'], '', '', '2', 'false', res['clde'][i]['SL'], res['clde'][i]['HJ'],
- '', '', '', '', uuidv4(), 'false' ]);
-
- }
-
- }
- for(let i = 0; i < res['jxde'].length; i++) {
- dercj.push(['', res['jxde'][i]['jxbh'], res['jxde'][i]['jxmc'], '', res['jxde'][i]['DW'],
- res['jxde'][i]['tbdj'], '', '', '3', '', res['jxde'][i]['sl'], res['jxde'][i]['hj'],
- '', '', '', '',uuidv4(), 'false' ]);
- }
- let newKey = uuidv4();
- if (!qd.hasOwnProperty('_children')) {
- qd["_children"] = [];
- }
- 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]]);
- qd["_children"].push({
- '操作': '',
- '序号': null,
- '清单编码': res['DEBH'][key],
- '名称': res['GCLMC'][key],
- '项目特征': null,
- '计算规则': null,
- '单位': res['DW'][key],
- '数量': '1',
- '综合单价': '0',
- '合价': '0',
- '人工费': '0',
- '主材费': '0',
- '设备费': '0',
- '辅材费': '0',
- '材料费': '0',
- '机械费': '0',
- '管理费': '0',
- '利润': '0',
- '暂估价': null,
- '综合人工工日': null,
- '备注': null,
- "dercj": newdercj,
- 'rcjdg': dercj,
- 'key' : newKey,
- "fuzhuEnable": true
-
-
- });
- this.updateDercj_djcs_(newKey, newdercj, []);
- let summarized = this.summarize_djcs(this.cache_djcs);
- this.push_op_djcs(copy(summarized));
- /////////////////
- this.cache_djcs = copy(summarized);
- //return copy(this.cache);
-
- return [true, copy(this.cache_djcs), newKey];
- } else {
- return [false, null, null];
- }
- }
- changguidinge(dingeclick, row) {
- if (this.cache.filter(x=>x['key'] == row).length > 0) {
- this.updateFootprint(row);
-
- let res = copy(dingeclick);
- let keys = Object.keys(res['DEBH']);
- let key = keys[0];
- let tips = null;
- if (res['actual_zhuanye'] == 30) {
- tips = azfy(res['DEBH'][key], res['GCLMC'][key]);
- }
-
- if (res['actual_zhuanye'] == 60) {
- tips = xsazfy(res['DEBH'][key], res['GCLMC'][key]);
- }
- if (res['actual_zhuanye'] == 10) {
- tips = tjazfy(res['DEBH'][key], res['GCLMC'][key]);
- }
- if (tips != null) {
- res['rgde'] = tips['rgde'];
- res['clde'] = tips['clde'];
- res['jxde'] = tips['jxde'];
- }
- let qd = this.cache.filter(x=>x['key'] == row)[0];
- let dercj = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ]];
- for(let i = 0; i < res['rgde'].length; i++) {
- dercj.push(['', res['rgde'][i]['CLBH'], res['rgde'][i]['CLMC'], '', res['rgde'][i]['JLDW'],
- res['rgde'][i]['YSJG'], '', '', '1', '', res['rgde'][i]['gr'], res['rgde'][i]['gf'],
- '', '', '', '', uuidv4(), 'false' ]);
- }
- for(let i = 0; i < res['clde'].length; i++) {
- let hit = false;
- let jg = null;
- let bh = res['clde'][i]['CLBH'];
- for(let j = 0; j < this.jiagongcai.length; j++) {
- if (this.jiagongcai[j]['材料编号'] == bh) {
- hit = true;
- jg = this.jiagongcai[j]['单价'];
- }
- }
- if (hit) {
- dercj.push(['', res['clde'][i]['CLBH'], res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
- jg, '', '', '2', 'true', res['clde'][i]['SL'], res['clde'][i]['HJ'],
- '', '', '', '', uuidv4(), 'false' ]);
- } else {
- /*if (res['clde'][i].hasOwnProperty('children') && res['clde'][i]['CLMC'].includes('砂浆')) {
- let parent = uuidv4();
- let children = [];
- let child_data = res['clde'][i]['children'];
- for(let j = 0; j < child_data.length; j++) {
- let id = uuidv4();
- children.push(id);
- dercj.push(['', child_data[j]['CLBH'], child_data[j]['CLMC'], '', child_data[j]['JLDW'],
- child_data[j]['YSJG'], '', '', '2', 'false', child_data[j]['SL'], child_data[j]['HJ'],
- '', '', '', '', id, 'false','false', [parent], [] ]);
- }
- dercj.push(['', res['clde'][i]['CLBH'].toString(), res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
- res['clde'][i]['YSJG'], '', '', '2', 'false', res['clde'][i]['SL'], res['clde'][i]['HJ'],
- '', '', '', '', parent, 'false','true', [], children ]);
- } else {*/
- dercj.push(['', res['clde'][i]['CLBH'].toString(), res['clde'][i]['CLMC'], '', res['clde'][i]['JLDW'],
- res['clde'][i]['YSJG'], '', '', '2', 'false', res['clde'][i]['SL'], res['clde'][i]['HJ'],
- '', '', '', '', uuidv4(), 'false' ]);
-
-
- }
-
- }
- for(let i = 0; i < res['jxde'].length; i++) {
- dercj.push(['', res['jxde'][i]['jxbh'], res['jxde'][i]['jxmc'], '', res['jxde'][i]['DW'],
- res['jxde'][i]['tbdj'], '', '', '3', '', res['jxde'][i]['sl'], res['jxde'][i]['hj'],
- '', '', '', '', uuidv4(), 'false']);
- }
- let newKey = uuidv4();
- if (!qd.hasOwnProperty('_children')) {
- qd["_children"] = [];
- }
- 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]]);
- qd["_children"].push({
- '操作': '',
- '序号': null,
- '清单编码': res['DEBH'][key],
- '名称': res['GCLMC'][key],
- '项目特征': null,
- '计算规则': tips != null ? tips['sm'] : '',
- '单位': res['DW'][key],
- '数量': '1',
- '综合单价': '0',
- '合价': '0',
- '人工费': '0',
- '主材费': '0',
- '设备费': '0',
- '辅材费': '0',
- '材料费': '0',
- '机械费': '0',
- '管理费': '0',
- '利润': '0',
- '暂估价': null,
- '综合人工工日': null,
- '备注': null,
- "dercj": newdercj,
- 'rcjdg': (dercj),
- 'key' : newKey,
- "fuzhuEnable": true,
- 'yuban': [],
- 'rcjbc': [],
- 'azfytag': tips != null ? tips['azfytag'] : []
-
-
- });
- this.updateDercj_(newKey, dercj, [], [], [], 1);
- let summarized = this.summarize(this.cache);
- this.push_op(copy(summarized));
- /////////////////
- this.cache = copy(summarized);
- //return copy(this.cache);
-
- return [true, copy(this.cache), newKey];
- } else {
- return [false, null, null];
- }
- }
- danxiangdinge(row, maxN, extra) {
- //let bh = danxiangdinge_index(this.cache);
- let result = (maxN + 1).toString();
- result = result.padStart(5, '0');
- let bh= "D".concat(result);
-
- if (this.cache.filter(x=>x['key'] == row).length > 0) {
- this.updateFootprint(row);
- let selected = this.cache.filter(x=>x['key'] == row)[0];
- let danwei = selected["单位"];
- let mingcheng = extra;//selected['名称'];
- let children = selected["_children"];
- children.push({
- '操作': '',
- '序号': null,
- '清单编码': bh,
- '名称': mingcheng,
- '项目特征': null,
- '计算规则': null,
- '单位': danwei,
- '数量': '1',
- '综合单价': '',
- '合价': '',
- '人工费': '0',
- '主材费': '0',
- '设备费': '0',
- '辅材费': '',
- '材料费': '',
- '机械费': '0',
- '管理费': '0',
- '利润': '0',
- '暂估价': null,
- '综合人工工日': null,
- '备注': null,
- "dercj": [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", 'key', 'bc' ],
- ['', bh, mingcheng, '', danwei, '', '', '', '2', '', '1', '', '', '', '', '', uuidv4(), '' ]
- ],
- 'key' : uuidv4(),
- "fuzhuEnable": false,
- 'yuban': [],
- 'rcjbc' : [],
- 'azfytag': []
-
- });
- let summarized = this.summarize(this.cache);
- this.push_op(summarized);
- this.cache = copy(summarized);
-
- return [true, copy(this.cache)];
- } else {
- return [false,null];
- }
- }
- danxiangdinge_djcs(row) {
- let bh = danxiangdinge_index_djcs(this.cache_djcs);
-
- if (this.cache_djcs.filter(x=>x['key'] == row).length > 0) {
- let selected = this.cache_djcs.filter(x=>x['key'] == row)[0];
- let danwei = selected["单位"];
- let mingcheng = selected['名称'];
- let children = selected["_children"];
- children.push({
-
- '序号': null,
- '清单编码': bh,
- '名称': mingcheng,
- '项目特征': null,
- '计算规则': null,
- '单位': danwei,
- '数量': '1',
- '综合单价': '',
- '合价': '',
- '人工费': '0',
- '主材费': '0',
- '设备费': '0',
- '辅材费': '',
- '材料费': '',
- '机械费': '0',
- '管理费': '0',
- '利润': '0',
- '暂估价': null,
- '综合人工工日': null,
- '备注': null,
- "dercj": [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志", "key" , "bc" ],
- ['', bh, mingcheng, '', danwei, '', '', '', '2', '', '1', '', '', '', '', '', uuidv4(), "" ]
- ],
- 'key' : uuidv4(),
- "fuzhuEnable": false
-
- });
- let summarized = this.summarize_djcs(this.cache_djcs);
- this.push_op_djcs(summarized);
- this.cache_djcs = copy(summarized);
-
- return [true, copy(this.cache_djcs)];
- } else {
- return [false,null];
- }
- }
- handleYuban(row, selected) {
- let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
- if (!qd) return [null, null];
- this.updateFootprint(qd['key']);
- let de = qd["_children"].filter(x=>x['key'] == row)[0];
- let bm = de['清单编码'];
- let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
- if (de.hasOwnProperty("rcjdg")) {//底稿
- } else {///老数据不能有底稿,附注功能也不使能,预拌也不能使
- //de['rcjdg'] = copy(de['dercj']);
- }
- de['yuban'] = copy(selected);
- this.updateDercj_(row, de['dercj'], alreadyFuzhu, selected, de['rcjbc'], 1);
- let newData = this.cache.map(x=>{
- if (x['key'] == qd['key']) {
- return qd;
- } else {
- return x;
- }
- });
- let summarized = this.summarize(newData);
- this.push_op(summarized);
- /////////////////
- this.cache = copy(summarized);
- return [copy(this.cache), copy(de['dercj'])];
- }
- handleRcjbc(row, rcjbc) {
- let qd = this.cache.filter(x=>x["_children"].filter(y=>y['key']==row).length > 0)[0];
- if (!qd) return [null, null];
- this.updateFootprint(qd['key']);
- let de = qd["_children"].filter(x=>x['key'] == row)[0];
- let bm = de['清单编码'];
- let alreadyFuzhu = extractFuzhu(bm);//[xuhao]
- if (de.hasOwnProperty("rcjdg")) {//底稿
-
- } else {///老数据不能有底稿,附注功能也不使能,预拌也不能使
- //de['rcjdg'] = copy(de['dercj']);
-
- }
- de['rcjbc'] = copy(rcjbc);
- this.updateDercj_(row, de['dercj'], alreadyFuzhu, de['yuban'], rcjbc, 2);
-
- let newData = this.cache.map(x=>{
- if (x['key'] == qd['key']) {
- return qd;
- } else {
- return x;
- }
- });
- let summarized = this.summarize(newData);
- this.push_op(summarized);
- /////////////////
- this.cache = copy(summarized);
- return [copy(this.cache), copy(de['dercj'])];
- }
- handleJGC(input) {
- for (let i = 0;i < input.length; i++) {
- let bh = input[i][1];
- let hit = false;
- let jg = 0;
- for(let j = 0; j < this.jiagongcai.length; j++) {
- if (this.jiagongcai[j]['材料编号'] == bh) {
- hit = true;
- //jg = this.jiagongcai[j]['单价'];
- }
- }
- if (hit) {
- input[i][9] = 'true';
- }
- }
- return input;
- }
-
- }
- export default new Service();
|