project_glj_view.js 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881
  1. /**
  2. * Created by zhang on 2018/3/13.
  3. */
  4. let projectGljObject={
  5. showTag:'ration',//mixRatio/machine
  6. showMixRatioMark:'',
  7. displayType:filterType.ALL,
  8. mixRatioType: [gljType.CONCRETE, gljType.MORTAR, gljType.MIX_RATIO,gljType.MAIN_MATERIAL],
  9. machineType: [gljType.GENERAL_MACHINE],
  10. projectGljSetting:{},
  11. projectGljSpread:null,
  12. projectGljSheet:null,
  13. materialTreeSheet:null,
  14. projectGljSheetData:[],
  15. mixRatioSetting:{},
  16. infoPriceSetting:{
  17. header:[
  18. {headerName: "材料名称", headerWidth: 320, dataCode: "name", dataType: "String"},
  19. {headerName: "规格型号", headerWidth: 200, dataCode: "specs", hAlign: "left", dataType: "String"},
  20. {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
  21. {headerName: "含税市场价", headerWidth: 100, dataCode: "taxPrice", hAlign: "right", dataType: "Number",validator:"number"},
  22. {headerName: "不含税市场价", headerWidth: 100, dataCode: "noTaxPrice", hAlign: "right", dataType: "Number",validator:"number"}//,decimalField:"glj.unitPrice"
  23. ],
  24. view: {
  25. lockColumns: [0,1,2,3,4]//,
  26. //colHeaderHeight:30
  27. }
  28. },
  29. relatedRationSetting:{
  30. header:[
  31. {headerName: "编码", headerWidth: 100, dataCode: "code", dataType: "String"},
  32. {headerName: "名称", headerWidth: 180, dataCode: "name", dataType: "String"},
  33. {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
  34. {headerName: "工程量", headerWidth: 65, dataCode: "quantity", dataType: "Number", hAlign: "right",decimalField: "ration.quantity"},
  35. {headerName: "单价", headerWidth: 65, dataCode: "feesIndex.common.unitFee", dataType: "Number", hAlign: "right",decimalField: "ration.unitPrice"}
  36. ],
  37. view: {
  38. lockColumns: [0,1,2,3,4]//,
  39. //colHeaderHeight:30
  40. }
  41. },
  42. materialTreeSetting:{
  43. "emptyRows":0,
  44. "headRows":1,
  45. "headRowHeight":[21],
  46. "defaultRowHeight": 21,
  47. "treeCol": 0,
  48. "cols":[]
  49. },
  50. materialSetting:{
  51. header:[
  52. {headerName: "编码", headerWidth: 200, dataCode: "code", dataType: "String"},
  53. {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String"},
  54. {headerName: "规格型号", headerWidth: 160, dataCode: "specs", hAlign: "left", dataType: "String"},
  55. {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
  56. {headerName: "定额价", headerWidth: 70, dataCode: "basePrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:'glj.unitPrice'
  57. {headerName: "市场价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
  58. {headerName: "总消耗量", headerWidth: 70, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
  59. {headerName: "三材系数", headerWidth: 70, dataCode: "materialCoe", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:'material'
  60. {headerName: "三材量", headerWidth: 100, dataCode: "materialQuantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
  61. {headerName: "三材类别", headerWidth: 70, dataCode: "materialType", hAlign: "center", dataType: "String",cellType:'comboBox',editorValueType:true,options:materialComboMap}
  62. ],
  63. view: {
  64. lockColumns: [0,1,2,3,6,8]
  65. }
  66. },
  67. mixRatioSpread:null,
  68. mixRatioSheet:null,
  69. mixRatioData:[],
  70. subList:[],//定额工料机,添加组成物时临时保存组成物信息的位置
  71. usedTenderList:[],
  72. usedUnitPriceInfo:null,
  73. displayTypeMap:[
  74. {ID:'LABOUR',text:'人工'},
  75. {ID:'GENERAL_MATERIAL',text:'材料'},
  76. {ID:'GENERAL_MACHINE',text:'机械'},
  77. {ID:'MAIN_MATERIAL',text:'主材'},
  78. {ID:'EQUIPMENT',text:'设备'}
  79. ],
  80. initInfoPriceSpread:function(){
  81. if(this.infoPriceSpread) return this.infoPriceSpread.refresh();
  82. this.infoPriceSpread = SheetDataHelper.createNewSpread($("#info_price_sheet")[0]);
  83. sheetCommonObj.spreadDefaultStyle(this.infoPriceSpread);
  84. this.infoPriceSheet = this.infoPriceSpread .getSheet(0);
  85. this.initSheet(this.infoPriceSheet,this.infoPriceSetting);
  86. this.infoPriceSheet.bind(GC.Spread.Sheets.Events.TopRowChanged, _.debounce(this.onInfoTopRowChanged, 100));
  87. this.infoPriceSheet.bind(GC.Spread.Sheets.Events.CellDoubleClick, this.onInfoPriceDoubleClick);
  88. this.infoPriceSheet.name('infoPriceSheet');
  89. this.infoPriceSheet.setRowCount(0);
  90. this.getInfoPriceOptions();
  91. if(projectReadOnly){
  92. disableSpread(this.infoPriceSpread);
  93. }else{
  94. this.initInfoPriceRightClick();
  95. }
  96. },
  97. initSpreads:function(){
  98. if(this.projectGljSpread==null) this.initProjectGljSpread();
  99. //if(materialAdjustObj.spread == null) materialAdjustObj.initSpread();
  100. if(configMaterialObj.configSpread == null) configMaterialObj.initSpread();
  101. },
  102. initProjectGljSpread:function () {
  103. if(!this.projectGljSpread){
  104. this.projectGljSpread = SheetDataHelper.createNewSpread($("#project_glj_sheet")[0],2);
  105. sheetCommonObj.spreadDefaultStyle(this.projectGljSpread);
  106. }
  107. this.projectGljSpread.bind(GC.Spread.Sheets.Events.RangeChanged, this.onProjectGljRangeChange);
  108. this.initProjectGljSheet();
  109. this.initMaterialTreeSheet();
  110. disableRightMenu("project_glj_sheet",this.projectGljSpread,this.rightClickCallback);
  111. //打开别人分享的项目,只读
  112. if(projectReadOnly){
  113. //锁定逻辑走disabledSpread里的
  114. if(this.projectGljSetting.view.lockColumns){
  115. this.projectGljSetting.view.lockColumns = null;
  116. }
  117. disableSpread(this.projectGljSpread);
  118. }
  119. },
  120. initProjectGljSheet:function () {
  121. this.projectGljSheet = this.projectGljSpread .getSheet(0);
  122. this.initSheet(this.projectGljSheet,this.projectGljSetting);
  123. this.projectGljSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onProjectGljSelectionChange);
  124. this.projectGljSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onProjectGljEditStarting);
  125. this.projectGljSheet.name('projectGljSheet');
  126. //this.projectGljSheet.setRowHeight(0, 36, 1);
  127. this.projectGljSheet.options.frozenlineColor = '#ababab';
  128. this.projectGljSheet.frozenColumnCount(this.projectGljSetting.frozenCols);
  129. },
  130. initMixRatio:function () {
  131. let me = projectGljObject;
  132. if(me.mixRatioSpread==null){
  133. me.initMixRatioSpread();
  134. if(!projectReadOnly){
  135. me.initRightClick();
  136. }
  137. }
  138. },
  139. initMixRatioSpread:function () {
  140. this.mixRatioSpread = SheetDataHelper.createNewSpread($("#mix_ratio_sheet")[0],2);
  141. sheetCommonObj.spreadDefaultStyle(this.mixRatioSpread);
  142. this.mixRatioSheet = this.mixRatioSpread .getSheet(0);
  143. this.initSheet(this.mixRatioSheet,this.mixRatioSetting);
  144. this.mixRatioSheet.name('mixRatioSheet');
  145. this.mixRatioSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onMixRatioRangeChange);
  146. this.initRelatedRationSheet();
  147. if(projectReadOnly){
  148. if(this.mixRatioSetting.view.lockColumns){
  149. this.mixRatioSetting.view.lockColumns = null;
  150. }
  151. disableSpread(this.mixRatioSpread);
  152. }
  153. },
  154. initRelatedRationSheet:function(){
  155. this.relatedRationSheet = this.mixRatioSpread.getSheet(1);
  156. sheetCommonObj.initSheet(this.relatedRationSheet, this.relatedRationSetting, 30);
  157. this.relatedRationSheet.name('relatedRation');
  158. this.relatedRationSheet.bind(GC.Spread.Sheets.Events.CellDoubleClick, this.onRelatedRationDoubleClick);
  159. //this.mixRatioSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onMixRatioRangeChange);
  160. },
  161. initMaterialTreeSheet:function () {
  162. this.materialTreeSheet = this.projectGljSpread.getSheet(1);
  163. this.materialTreeSetting = this.createMaterialTreeSheetSetting();
  164. this.materialTree = cacheTree.createNew(this);
  165. this.materialTreeController = TREE_SHEET_CONTROLLER.createNew(this.materialTree, this.materialTreeSheet, this.materialTreeSetting);
  166. this.materialTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, this.onSelectionChange);
  167. this.materialTreeSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onProjectGljEditStarting);
  168. this.materialTreeSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onProjectGLJValueChange);
  169. this.materialTreeSheet.name('materialTreeSheet');
  170. if(projectReadOnly && this.materialSetting.view.lockColumns){
  171. if(this.materialSetting.view.lockColumns){
  172. this.materialSetting.view.lockColumns = null;
  173. }
  174. }
  175. },
  176. createMaterialTreeSheetSetting:function () {
  177. return sheetCommonObj.transferToTreeSetting(this.materialSetting,this.materialTreeSetting);
  178. },
  179. unitPriceFileInit:function() {
  180. let me = this;
  181. let projectGLJ = projectObj.project.projectGLJ;
  182. let data = projectGLJ.datas;
  183. me.usedTenderList = data.usedTenderList !== undefined ? data.usedTenderList : [];
  184. me.usedUnitPriceInfo = data.constData.usedUnitPriceInfo !== undefined ?
  185. data.constData.usedUnitPriceInfo : {};
  186. $("#current-name").text(me.usedUnitPriceInfo.name);
  187. let usedCount = me.usedTenderList.length <= 0 ? 1 : me.usedTenderList.length;
  188. $("#used-project-count").text(usedCount);
  189. $("#editUnitFile").attr("href",`/unitPrice/index/${me.usedUnitPriceInfo.id}`)
  190. },
  191. getUsedTenderInfo:function() {
  192. return "人材机单价的变化,将自动影响以下单位工程造价:<br>"+projectGljObject.usedTenderList.join("<br>");
  193. },
  194. // 获取选中人材机,添加组成物时,分页查询语句的扩展
  195. getQueryExtForMixRatio: function () {
  196. const extend = {};
  197. if (!this.selectedProjectGLJ) {
  198. return extend;
  199. }
  200. if (this.selectedProjectGLJ.type === gljType.MAIN_MATERIAL) {//对于主材,只显示没有组成物并且除了自已的主材
  201. extend['component.0'] = {$exists: false};
  202. extend.gljType = gljType.MAIN_MATERIAL;
  203. } else if (_.includes(gljUtil.hasCompMaterial, this.selectedProjectGLJ.type)) {//混凝土、砂浆、配合比
  204. extend.gljType = gljType.GENERAL_MATERIAL;
  205. } else if (_.includes(gljUtil.hasCompMachine, this.selectedProjectGLJ.type)) {//me.selectedProjectGLJ.type == gljType.GENERAL_MACHINE//机械中有组成物的类型
  206. extend.gljType = {$in: gljUtil.machineComposition};
  207. }
  208. return extend;
  209. },
  210. filterLibGLJForMixRatio:function () {
  211. let me = this;
  212. if(me.selectedProjectGLJ){
  213. let showTypes = [];
  214. if(me.selectedProjectGLJ.type == gljType.MAIN_MATERIAL){//对于主材,只显示没有组成物并且除了自已的主材
  215. showTypes = [gljType.MAIN_MATERIAL];
  216. }else if(_.includes(gljUtil.hasCompMaterial,me.selectedProjectGLJ.type)){//混凝土、砂浆、配合比
  217. showTypes = [gljType.GENERAL_MATERIAL];
  218. }else if(_.includes(gljUtil.hasCompMachine,me.selectedProjectGLJ.type)){//me.selectedProjectGLJ.type == gljType.GENERAL_MACHINE//机械中有组成物的类型
  219. showTypes = gljUtil.machineComposition;
  220. }
  221. gljOprObj.gljLibSheetData = _.filter(gljOprObj.gljLibSheetData, function (item) {
  222. if(me.selectedProjectGLJ.type == gljType.MAIN_MATERIAL){
  223. let p_index = gljOprObj.getIndex(me.selectedProjectGLJ,gljKeyArray);
  224. let i_index = gljOprObj.getIndex(item,gljLibKeyArray);
  225. return item.gljType == gljType.MAIN_MATERIAL &&item.component.length == 0 && p_index!=i_index
  226. }else {
  227. return _.includes(showTypes,item.gljType);
  228. }
  229. });
  230. }
  231. },
  232. addMixRatio:async function () {
  233. let me = this, projectGLJ = projectObj.project.projectGLJ;
  234. let tdatas = me.mixRatioData;
  235. if(me.subList.length > 0) tdatas = me.subList;
  236. for(let mix of tdatas){
  237. let m_key = gljOprObj.getIndex(mix, gljKeyArray);
  238. let t_index = gljOprObj.GLJSelection.indexOf(m_key);
  239. t_index != -1?gljOprObj.GLJSelection.splice(t_index,1):'';
  240. }
  241. await me.addMixRatioFromLib(gljOprObj.GLJSelection,()=>{
  242. me.showMixRatioData();//这里添加的组成物的消耗量默认都是0,所以对父工料机的价格不会有影响,不用触发计算
  243. projectGLJ.loadData(function () {
  244. me.showProjectGljData();
  245. gljOprObj.showRationGLJSheetData();
  246. me.onUnitFileChange(me.selectedProjectGLJ);
  247. });
  248. });
  249. },
  250. addMixRatioFromLib:async function(selections,callback){
  251. let gljList = [],allGLJ = gljOprObj.AllRecode;
  252. let url = "/glj/add-ratio";
  253. let result = null;
  254. if(selections.length == 0) {
  255. return;
  256. }
  257. try {
  258. for(let glj of allGLJ){
  259. let i_key = gljUtil.getIndex(glj,gljLibKeyArray);
  260. if(_.includes(selections,i_key)){
  261. let pglj = {
  262. glj_id: glj.ID,
  263. name: glj.name,
  264. code: glj.code,
  265. original_code: glj.code,
  266. unit: glj.unit,
  267. specs: glj.specs,
  268. base_price: glj.basePrice,
  269. market_price: glj.basePrice,
  270. shortName: glj.shortName,
  271. type: glj.gljType,
  272. model:glj.model,
  273. adjCoe: glj.adjCoe,
  274. from:'std',
  275. repositoryId:glj.repositoryId,
  276. materialType:glj.materialType,
  277. materialCoe:glj.materialCoe,
  278. grossWeightCoe:glj.grossWeightCoe,
  279. purchaseStorageRate:glj.purchaseStorageRate,
  280. offSiteTransportLossRate:glj.offSiteTransportLossRate,
  281. handlingLossRate:glj.handlingLossRate
  282. };
  283. if(typeof projectObj !== 'undefined') pglj.project_id = projectObj.project.ID();
  284. if (glj.hasOwnProperty("compilationId")) {
  285. pglj.from = "cpt";
  286. if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改名称、规格、型号等保存到补充工料机库的
  287. pglj.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
  288. }
  289. }
  290. gljList.push(pglj);
  291. }
  292. }
  293. gljList = _.sortByAll(gljList, ['type', 'code']);
  294. if(gljList.length == 0) return;
  295. let parentInfo ={};
  296. if(typeof unitPriceObj !== 'undefined'){
  297. url = "/unitPrice/addMixRatio";
  298. pdata = unitPriceObj.getSelectedUnitPrice();
  299. parentInfo = {
  300. unit_price_file_id:pdata.unit_price_file_id,
  301. connect_key:gljUtil.getIndex(pdata)
  302. };
  303. }else{
  304. parentInfo = {
  305. unit_price_file_id:projectObj.project.property.unitPriceFile.id,
  306. connect_key:gljOprObj.getIndex(projectGljObject.selectedProjectGLJ,gljKeyArray)
  307. };
  308. }
  309. $.bootstrapLoading.start();
  310. result= await ajaxPost(url,{gljList:gljList,parentInfo:parentInfo})
  311. if(callback) callback(result);
  312. } catch (error) {
  313. alert(error);
  314. console.log(error);
  315. }
  316. $.bootstrapLoading.end();
  317. return result;
  318. },
  319. showMixRatioData:function () {
  320. let me = this,gljId = null,gljType = null;
  321. if(!$('#mixRatio-nav').hasClass('active')) return;
  322. me.mixRatioSpread.setActiveSheetIndex(0);
  323. if(!me.projectGljSpread) return;
  324. let sheet = me.projectGljSpread.getActiveSheet();
  325. let oldSel = me.mixRatioSheet.getSelections()[0];
  326. if(sheet.name() == 'projectGljSheet'){//projectGljSheet/materialSheet 工料机汇总和三材汇总表
  327. let sel = me.projectGljSheet.getSelections()[0];
  328. let srow = sel.row == -1||sel.row == ""?0:sel.row;
  329. if(me.projectGljSheetData.length>srow){
  330. gljId = me.projectGljSheetData[srow].id;
  331. gljType = me.projectGljSheetData[srow].type;
  332. }
  333. }else if(sheet.name() == 'materialTreeSheet'){
  334. if(this.materialTree.selected){
  335. gljId = this.materialTree.selected.data.id;
  336. gljType = this.materialTree.selected.data.type;
  337. }
  338. }
  339. if(compositionTypes.indexOf(gljType)==-1){//如果不是有组成物的类型,工料机id设置为空,组成物表设置为空
  340. gljId = null
  341. }
  342. projectObj.project.projectGLJ.getRatioData(gljId,function (data) {
  343. if(gljId !== projectObj.project.projectGLJ.getRatioId){//两个id不一致说明不是最新的请求,不用往下执行。
  344. return;
  345. }
  346. let ratioList =[];
  347. for(let glj of data){
  348. ratioList.push(me.getMixRatioSheetData(glj)) ;
  349. }
  350. ratioList = gljUtil.sortRationGLJ(ratioList);
  351. me.mixRatioData = ratioList;
  352. me.mixRatioSheet.setRowCount(0);
  353. sheetCommonObj.showData(me.mixRatioSheet, me.mixRatioSetting,me.mixRatioData);
  354. me.mixRatioSheet.setRowCount(me.mixRatioData.length);
  355. me.mixRatioSheet.setSelection(oldSel.row==-1?0:oldSel.row,oldSel.col,oldSel.rowCount,oldSel.colCount);
  356. })
  357. },
  358. showRelatedRationDatas:function(){
  359. let me = this;
  360. if(!$('#ration-nav').hasClass('active')) return;
  361. me.mixRatioSpread.setActiveSheetIndex(1);
  362. let projectGLJData = me.getProjectGLJSelected();
  363. let rationIDMap = {};
  364. let rations = [];
  365. if(projectGLJData){
  366. for(let rg of projectObj.project.ration_glj.datas){
  367. if(rg.projectGLJID == projectGLJData.id) rationIDMap[rg.rationID] = true;
  368. }
  369. for(let r of projectObj.project.Ration.datas){
  370. if(rationIDMap[r.ID] || (r.type == rationType.gljRation && r.projectGLJID== projectGLJData.id)){
  371. rations.push(r);
  372. }
  373. }
  374. }
  375. this.relatedRationSheetData = rations;
  376. sheetCommonObj.showData(me.relatedRationSheet, me.relatedRationSetting,rations);
  377. me.relatedRationSheet.setRowCount(rations.length);
  378. },
  379. showInforPriceData:function(datas){
  380. let me = this;
  381. me.infoPriceData = datas;
  382. sheetCommonObj.showData(me.infoPriceSheet, me.infoPriceSetting,datas);
  383. me.infoPriceSheet.setRowCount(datas.length);
  384. },
  385. getMixRatioSheetData:function (glj) {
  386. let data ={
  387. id:glj.id,
  388. mix_ratio_id:glj.ratio_data.id,
  389. code:glj.code,
  390. name:glj.name,
  391. specs:glj.specs,
  392. unit:glj.unit,
  393. type:glj.type,
  394. short_name:projectObj.project.projectGLJ.getShortNameByID(glj.type),
  395. consumption:glj.ratio_data.consumption,
  396. unit_price:glj.unit_price,
  397. connect_key:glj.ratio_data.connect_key
  398. };
  399. gljOprObj.setGLJPrice(data,glj);
  400. return data;
  401. },
  402. onProjectGljEditStarting:function (sender, args) {
  403. let me = projectGljObject;
  404. let row = args.row;
  405. let col = args.col;
  406. if(me.projectGljEditChecking(row,col)==false){
  407. args.cancel = true;
  408. }
  409. },
  410. projectGljEditChecking:function (row,col,isPaste=false) {//return false表示不能编辑
  411. let me = projectGljObject;
  412. let data = null, setting=null;
  413. let sheet = me.projectGljSpread.getActiveSheet();
  414. if(sheet.name() == 'projectGljSheet'){
  415. if(row>=me.projectGljSheetData.length) return false;
  416. data = me.projectGljSheetData[row];
  417. setting = me.projectGljSetting;
  418. }else if(sheet.name() == 'materialTreeSheet'){
  419. data = me.materialTree.selected.data;
  420. setting = me.materialSetting;
  421. let notEditId= ['GC','GJ','MC','SN','SZ'];
  422. if(notEditId.indexOf(data.id)!= -1){
  423. return false;
  424. }
  425. }
  426. let dataCode = setting.header[col].dataCode;
  427. let lockColumns = setting.view.lockColumns;
  428. if(lockColumns.indexOf(col)!= -1) return false;
  429. if(isPaste == false &&(dataCode=='is_adjust_price'||dataCode=='is_evaluate'||dataCode=='is_main_material'||dataCode == 'is_eval_material'||dataCode=='no_tax_eqp')){//除了粘贴,拖动填充等操作,其它的都不能编辑
  430. return false;
  431. }
  432. if(dataCode=='basePrice'||dataCode=='marketPrice'||dataCode=='supply'){//有组成物时,市场单价、定额价、供货方式不能修改
  433. if (data.ratio_data && data.ratio_data.length > 0) return false;
  434. if(dataCode=='basePrice'&&data.is_add!=1) return false;//如果不是新增,定额价不可修改。
  435. }
  436. if(dataCode == 'supply_quantity' && data.supply != 1) return false;// 如果为部分甲供则甲供数量需要可编辑,其它的都不能编辑
  437. if(dataCode == 'materialCoe') {//三材类别为空时,三材系数应只读,不允许输入。
  438. if (data.materialType == undefined || data.materialType == null || data.materialType == '') return false;
  439. }
  440. if(dataCode == 'taxRate') {
  441. //普通材料、商品混凝土、商品砂浆、机械组成物、主材、设备才能编辑
  442. if(!_.includes([gljType.GENERAL_MATERIAL,gljType.COMMERCIAL_CONCRETE,gljType.COMMERCIAL_MORTAR,gljType.MACHINE_COMPOSITION,gljType.MAIN_MATERIAL,gljType.EQUIPMENT],data.type)){
  443. return false
  444. }
  445. }
  446. return true;
  447. },
  448. onSelectionChange:function (){
  449. let me = projectGljObject;
  450. me.showMixRatioData();
  451. me.materialTreeSheet.repaint();
  452. },
  453. onRelatedRationDoubleClick:function (sender,args) {
  454. let me = projectGljObject;
  455. let record = me.relatedRationSheetData[args.row];
  456. $("#tab_zaojiashu").click();
  457. locateObject.locateNode(record.ID);
  458. },
  459. onInfoPriceDoubleClick:function name(sender,args) {
  460. projectGljObject.preApplyInfoPrice(args.row);
  461. },
  462. onProjectGljSelectionChange:function (sender, args) {
  463. let me = projectGljObject;
  464. let newSel = args.newSelections[0];
  465. let oldSel = args.oldSelections?args.oldSelections[0]:{};
  466. me.projectGljSheet.suspendPaint();
  467. me.projectGljSheet.suspendEvent();
  468. if(newSel.row != oldSel.row){
  469. let style = gljOprObj.getSelStyle(true,{});
  470. me.projectGljSheet.setStyle(newSel.row, -1, style);
  471. let orow = oldSel.row==''||oldSel.row==-1?0:oldSel.row;
  472. if(me.projectGljSheetData[orow]){
  473. style = gljOprObj.getSelStyle(false,{},me.projectGljSheetData[orow].bgColour);
  474. }else{
  475. style.backColor = "White";
  476. }
  477. me.projectGljSheet.setStyle(orow, -1, style);
  478. me.projectGljRowChang();
  479. }else{
  480. me.projectGljSheet.repaint();
  481. }
  482. me.projectGljSheet.resumeEvent();
  483. me.projectGljSheet.resumePaint();
  484. },
  485. projectGljRowChang:function(row){
  486. let me = projectGljObject;
  487. let sel = me.mixRatioSheet.getSelections()[0];
  488. sel.row = -1;
  489. sel.col = 0;
  490. sel.rowCount = 1;
  491. sel.colCount = 1;
  492. me.showMixRatioData();
  493. me.showRelatedRationDatas();
  494. },
  495. rightClickCallback:function (row) {
  496. let me = projectGljObject;
  497. let sheet = me.projectGljSpread.getActiveSheet();
  498. if(sheet.name() == 'projectGljSheet'){
  499. me.projectGljRowChang(row);
  500. }else if(sheet.name() == 'materialTreeSheet'){
  501. me.materialTreeController.setTreeSelected(me.materialTreeController.tree.items[row]);
  502. }
  503. },
  504. onProjectGljRangeChange:function (sender,info) {
  505. let me = projectGljObject;
  506. let changeInfo=[];
  507. let canChange = true;
  508. if(info.action == GC.Spread.Sheets.RangeChangedAction.clear){
  509. if(me.projectGljEditChecking(info.row,info.col) == false){
  510. canChange = false;
  511. }else {
  512. info.newValue = null;
  513. me.onProjectGLJValueChange(sender,info);
  514. return ;
  515. }
  516. }
  517. for(let c of info.changedCells){
  518. let value= info.sheet.getCell(c.row, c.col).text();
  519. changeInfo.push({row:c.row,col:c.col,value:value});
  520. if(me.projectGljEditChecking(c.row,c.col,true)==false){//如果不能编辑
  521. canChange = false;
  522. break;
  523. }
  524. if (!me.checkData(c.col,me.projectGljSetting,value)) {
  525. alert('输入的数据类型不对,请重新输入!');
  526. canChange = false;
  527. break;
  528. }
  529. }
  530. if(canChange == false){//恢复原来的值
  531. info.sheetName =="materialTreeSheet"?me.showMaterialTreeData():me.showProjectGljData();
  532. }else if(info.sheetName =="projectGljSheet"){
  533. me.batchUpdateProjectGLJ(changeInfo,info.sheetName);
  534. }
  535. },
  536. onMixRatioRangeChange:function (sender,info){
  537. let me = projectGljObject;
  538. let canChange = true;
  539. let changeInfo=[];
  540. /* if (info.action == GC.Spread.Sheets.RangeChangedAction.clear) {
  541. info.newValue = 0;
  542. me.onMixRatioValueChange(sender,info);
  543. info.sheet.getCell(info.row, info.col).text(0);
  544. return ;
  545. } */
  546. for(let c of info.changedCells){
  547. let value = info.sheet.getCell(c.row, c.col).text();
  548. if(_.isEmpty(value)) value = 0;
  549. if (!me.checkData(c.col,me.mixRatioSetting,value)) {
  550. alert('输入的数据类型不对,请重新输入!');
  551. canChange = false;
  552. break;
  553. }else {
  554. changeInfo.push({row:c.row,col:c.col,value:value});
  555. }
  556. }
  557. if(canChange == false) me.showMixRatioData(); //数据类型不对
  558. if(changeInfo.length > 0) me.batchUpdateConsumption(changeInfo);
  559. },
  560. batchUpdateProjectGLJ:function(changeInfo,sheetName){
  561. let projectGLJ = projectObj.project.projectGLJ;
  562. let me = projectGljObject;
  563. let propertyCells=[],priceCells=[];
  564. let setting = sheetName =="materialTreeSheet"?me.materialSetting:me.projectGljSetting;
  565. for(let c of changeInfo){
  566. c.dataCode = setting.header[c.col].dataCode;
  567. if(c.dataCode == 'basePrice'||c.dataCode=='marketPrice'){
  568. priceCells.push(c);
  569. }else {
  570. propertyCells.push(c);
  571. }
  572. }
  573. me.batchUpdateGLJProperty(propertyCells,sheetName,function () {
  574. //价格属于单价文件表,如果与项目工料机的其它属性一起的话计算起来会比较复杂,同时出现价格与其它属性一起更新的情况也会比较少;
  575. projectGLJ.batchUpdatePrice(priceCells,sheetName);
  576. //me.refreshBySheetName(sheetName); 2020-07-27 改在projectGLJ里统一刷新了
  577. //gljOprObj.refreshView();
  578. });
  579. },
  580. refreshBySheetName:function (sheetName) {
  581. let me = projectGljObject;
  582. if(sheetName =="projectGljSheet"){
  583. me.showProjectGljData();
  584. }else if(sheetName =="materialTreeSheet"){
  585. me.showMaterialTreeData();
  586. }
  587. },
  588. batchUpdateGLJProperty:function (changeInfo,sheetName,callback) {
  589. let me = projectGljObject,updateMap = {};
  590. let projectGLJ = projectObj.project.projectGLJ;
  591. for(let c of changeInfo){
  592. if(c.dataCode == 'is_evaluate') continue; //暂估,暂时跳过
  593. let recode = sheetName =="materialTreeSheet"?me.materialTree.items[c.row].data:me.projectGljSheetData[c.row];
  594. if(recode[c.dataCode] == c.value){
  595. continue;
  596. }
  597. me.getUpdateData(recode.id,c.value,c.dataCode,recode.quantity,updateMap);
  598. }
  599. if(_.isEmpty(updateMap)){
  600. callback?callback():'';
  601. return;
  602. }
  603. projectGLJ.batchUpdateGLJProperty(updateMap,callback);
  604. },
  605. getUpdateData :function (id,value,dataCode,quantity,updateMap) {
  606. let me = projectGljObject;
  607. let supplyMap = {"自行采购":0,"部分甲供":1,"完全甲供":2,"甲定乙供":3};
  608. let materialMap = {"钢材":1,"钢筋":2,"木材":3,"水泥":4,"商品砼":5,"商品砂浆":6};
  609. let data = updateMap[id]?updateMap[id]:{};
  610. //供货方式 和三材类型 粘贴和填充过来的数据,要做对应转换,因为这里value只是中文文本,并不是实际的值
  611. // 如果是供货方式则需要处理数据
  612. if (dataCode === 'supply') {
  613. if(supplyMap[value]!==undefined||supplyMap[value]!==null){
  614. value = supplyMap[value];
  615. }
  616. data.supply_quantity = me.getSupplyQuantity(value,quantity);
  617. }
  618. if(dataCode === 'supply_quantity'){//修改数量需做4舍5入
  619. value = scMathUtil.roundForObj(value,getDecimal('glj.quantity'));
  620. }
  621. if(dataCode === 'is_evaluate'||dataCode === 'is_adjust_price'||dataCode === 'is_main_material'){
  622. value = value? 1:0;
  623. }
  624. if(dataCode === 'materialType'){//三材类型要做对应转换,因为这里value只是中文文本,并不是实际的值
  625. if(materialMap[value]!==undefined||materialMap[value]!==null){
  626. value = materialMap[value];
  627. }
  628. if(value == null || value==""){//删除三材类别时,清空三材系数
  629. value = null;
  630. data.materialCoe = null;
  631. }
  632. }
  633. if(dataCode == 'materialCoe'){
  634. value = scMathUtil.roundForObj(value,getDecimal("material"));
  635. }
  636. data[dataCode] = value ;
  637. updateMap[id] = data;
  638. },
  639. batchUpdateConsumption:function(changeInfo){
  640. let projectGLJ = projectObj.project.projectGLJ;
  641. let me = projectGljObject;
  642. let updateMap = {},updateData = [],parentBasePrice = 0,parentMarketPrice = 0;
  643. let parentKey = '',unit_price_file_id=null;
  644. for(let c of changeInfo){
  645. let record = me.mixRatioData[c.row];
  646. let value = scMathUtil.roundForObj(c.value,getDecimal("glj.quantity"));
  647. updateMap[record.mix_ratio_id] = {consumption: value,record:record };
  648. updateData.push({type:'mix_ratio',query:{id:record.mix_ratio_id},doc:{consumption:value}});
  649. parentKey = record.connect_key;
  650. unit_price_file_id = record.unit_price.unit_price_file_id;
  651. }
  652. for(let sub of me.mixRatioData){
  653. let marketPrice = scMathUtil.roundForObj(sub.unit_price.market_price,getDecimal("process"));
  654. let basePrice = scMathUtil.roundForObj(sub.unit_price.base_price,getDecimal("process"));
  655. let consumption = updateMap[sub.mix_ratio_id]?updateMap[sub.mix_ratio_id].consumption:scMathUtil.roundForObj(sub.consumption,getDecimal("glj.quantity"));
  656. parentMarketPrice = scMathUtil.roundForObj(marketPrice*consumption + parentMarketPrice,getDecimal("process"));
  657. parentBasePrice = scMathUtil.roundForObj(basePrice*consumption + parentBasePrice,getDecimal("process"));
  658. }
  659. parentBasePrice = scMathUtil.roundForObj(parentBasePrice,getDecimal("glj.unitPrice"));
  660. parentMarketPrice = scMathUtil.roundForObj(parentMarketPrice,getDecimal("glj.unitPrice"));
  661. updateData.push({type:'parent',connect_key:parentKey,base_price:parentBasePrice,market_price:parentMarketPrice,unit_price_file_id:unit_price_file_id});
  662. projectGLJ.batchUpdateConsumption(updateData,updateMap,function () {
  663. //更新人材机汇总表
  664. let parentSheet = me.projectGljSpread.getActiveSheet();//三材汇总表和工料机汇总表
  665. let prow = parentSheet.getActiveRowIndex();//取父机械或组成物的下标
  666. let prowData = parentSheet.name() == 'projectGljSheet'?me.projectGljSheetData[prow]:me.materialTree.items[prow].data;
  667. me.refreshParentData(prow,prowData.id);
  668. me.onUnitFileChange(updateData);
  669. });
  670. },
  671. showProjectGljData:function () {
  672. if(!this.projectGljSpread) return;
  673. let me = this;
  674. this.projectGljSpread.setActiveSheetIndex(0);
  675. let sel = this.projectGljSheet.getSelections()[0];
  676. let oldData = sel.row<this.projectGljSheetData.length?this.projectGljSheetData[sel.row]:"";
  677. let projectGljSheetData = [];
  678. let gljList = projectObj.project.projectGLJ.datas.gljList;
  679. gljList = this.filterProjectGLJ(gljList);
  680. gljList = sortProjectGLJ(gljList);
  681. for(let glj of gljList){
  682. projectGljSheetData.push(this.getSheetDataByGLJ(glj));
  683. }
  684. this.projectGljSheetData = projectGljSheetData;
  685. sheetCommonObj.showData(this.projectGljSheet, this.projectGljSetting,this.projectGljSheetData,null,function(){
  686. me.projectGljSheet.setRowCount(me.projectGljSheetData.length);
  687. sel.row = oldData?_.findIndex(me.projectGljSheetData,{'id':oldData.id}):-1;
  688. me.projectGljSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
  689. });
  690. },
  691. showMaterialTreeData:function () {
  692. this.projectGljSpread.setActiveSheetIndex(1);
  693. let sel = this.materialTreeSheet.getSelections()[0];
  694. let oldNodeID = this.materialTree.selected?this.materialTree.selected.data.id:"";
  695. let gljList = projectObj.project.projectGLJ.datas.gljList;
  696. gljList = _.sortByAll(gljList, [ 'code']);
  697. this.createMaterialTree(gljList);
  698. this.materialTreeController.showTreeData();
  699. let newNode = this.materialTree.getNodeByID(oldNodeID);
  700. sel.row = newNode?newNode.serialNo():-1;
  701. this.materialTreeSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
  702. this.materialTreeController.setTreeSelected(this.materialTree.items[sel.row==-1?0:sel.row]);
  703. },
  704. initSheetViews:function(){
  705. let me = projectGljObject;
  706. /* if(me.displayType == filterType.AMAE){
  707. $('#material_adjust').show();
  708. $('#adjustType').show();
  709. let adjustType = projectObj.project.projectInfo.property.gljAdjustType || 'priceInfo';
  710. $('#adjustType').val(adjustType);
  711. $('#project-glj-main').hide();
  712. $('#config_material').hide();
  713. }else*/
  714. if(me.displayType == filterType.AMAE || me.displayType == filterType.ZGCL || me.displayType == filterType.PBCL){
  715. $('#adjustType').hide();
  716. if(me.displayType == filterType.AMAE){
  717. let adjustType = projectObj.project.projectInfo.property.gljAdjustType || 'priceInfo';
  718. $('#adjustType').val(adjustType);
  719. $('#adjustType').show();
  720. }
  721. configMaterialObj.setNavLinkText(me.displayType);
  722. $('#material_adjust').hide();
  723. $('#project-glj-main').hide();
  724. $('#config_material').show();
  725. } else {
  726. $('#material_adjust').hide();
  727. $('#adjustType').hide();
  728. $('#config_material').hide();
  729. $('#project-glj-main').show();
  730. if(me.displayType == filterType.JGCL || me.displayType == filterType.SCHZ){
  731. $("#projectGljResize").hide();
  732. $("#projectGljBottom").hide();
  733. }else{
  734. $("#projectGljResize").show();
  735. $("#projectGljBottom").show();
  736. }
  737. }
  738. },
  739. refreshViewsData:function(){
  740. let me = projectGljObject;
  741. if(me.displayType == filterType.AMAE) return materialAdjustObj.refreshSheetDatas();
  742. if(me.displayType == filterType.ZGCL || me.displayType == filterType.PBCL) return configMaterialObj.refreshSheetDatas();
  743. me.refreshDataSheet();
  744. },
  745. refreshDataSheet:function (refresh) {//refresh = true 的时候不用更新表头信息
  746. let me = projectGljObject;
  747. if(!refresh){
  748. let quantityCol = _.findIndex(me.projectGljSetting.header,function (header) {
  749. return header.dataCode == 'quantity'|| header.dataCode == 'techQuantity' || header.dataCode =='subdivisionQuantity';
  750. });
  751. if(me.displayType == filterType.FBFX){//分部分项人材机,将“总消耗量”替换显示为“分部分项总消耗量”。
  752. me.projectGljSetting.header[quantityCol].dataCode = 'subdivisionQuantity';
  753. me.projectGljSheet.setValue(0, quantityCol, "分部分项总消耗量", GC.Spread.Sheets.SheetArea.colHeader);
  754. }else if(me.displayType == filterType.TECH) {//措施项目人材机,将“总消耗量”替换显示为“措施项目总消耗量”。
  755. me.projectGljSetting.header[quantityCol].dataCode = 'techQuantity';
  756. me.projectGljSheet.setValue(0, quantityCol, "措施项目总消耗量", GC.Spread.Sheets.SheetArea.colHeader);
  757. }else {
  758. me.projectGljSetting.header[quantityCol].dataCode = 'quantity';
  759. me.projectGljSheet.setValue(0, quantityCol, "总消耗量", GC.Spread.Sheets.SheetArea.colHeader);
  760. }
  761. }
  762. if(me.displayType == filterType.SCHZ){//三材汇总树节点
  763. me.showMaterialTreeData();
  764. }else {
  765. me.showProjectGljData();
  766. me.showMixRatioData();
  767. me.showRelatedRationDatas();
  768. }
  769. },
  770. createMaterialTree:function (gljList) {
  771. let me = projectGljObject;
  772. let q_decimal = getDecimal("glj.quantity");
  773. let GC = {id:'GC',name:materialType[materialTypeMap.GC],code:'GC',unit:'t',ParentID:-1,NextSiblingID:'MC'};
  774. let GJ = {id:'GJ',name:materialType[materialTypeMap.GJ],code:'GJ',unit:'t',ParentID:'GC',NextSiblingID:-1};
  775. let MC = {id:'MC',name:materialType[materialTypeMap.MC],code:'MC',unit:'m3',ParentID:-1,NextSiblingID:'SN'};
  776. let SN = {id:'SN',name:materialType[materialTypeMap.SN],code:'SN',unit:'t',ParentID:-1,NextSiblingID:'ST'};
  777. let ST = {id:'ST',name:materialType[materialTypeMap.ST],code:'SPT',unit:'m3',ParentID:-1,NextSiblingID:'SS'};
  778. let SS= {id:'SS',name:materialType[materialTypeMap.SS],code:'SPJS',unit:'m3',ParentID:-1,NextSiblingID:'-1'};
  779. let rootDatas= [GC,GJ,MC,SN,ST,SS];
  780. let parentMap = {};
  781. let sumMap = {};
  782. this.materialTree.nodes={},this.materialTree.selected = null,this.materialTree.roots = [],this.materialTree.items=[];
  783. for(let r of rootDatas){
  784. let baseNode = null;
  785. if(r.id == 'GJ'){
  786. baseNode = createMaterialNode(r,parentMap['GC'],null);//钢筋的父节点为钢材
  787. }else {
  788. baseNode = createMaterialNode(r,null,null);
  789. }
  790. parentMap[r.id] = baseNode;
  791. }
  792. for(let g of gljList){
  793. if(g.quantity !== 0 && g.quantity !== '0'){
  794. if(g.materialType){
  795. let tem = me.getMaterialSheetDataByGLJ(g);
  796. if(tem.materialQuantity){
  797. sumMap[g.materialType] = sumMap[g.materialType]?sumMap[g.materialType] + tem.materialQuantity:tem.materialQuantity;
  798. tem.materialQuantity = scMathUtil.roundToString(tem.materialQuantity,q_decimal);//转成string
  799. }
  800. if(g.materialType == materialTypeMap.GC){ //钢材的下一节点是钢筋
  801. createMaterialNode(tem,parentMap['GC'],parentMap['GJ']);
  802. }else {
  803. createMaterialNode(tem,parentMap[materialTypeMap[g.materialType]]);
  804. }
  805. }
  806. }
  807. }
  808. for(let mkey in sumMap){
  809. if(mkey == materialTypeMap.GC && sumMap[materialTypeMap.GJ]){//钢材汇总要加上钢筋的总量
  810. parentMap['GC'].data.materialQuantity = scMathUtil.roundToString(sumMap[mkey]+sumMap[materialTypeMap.GJ],q_decimal);
  811. }else {
  812. parentMap[materialTypeMap[mkey]].data.materialQuantity = scMathUtil.roundToString(sumMap[mkey],q_decimal);
  813. }
  814. }
  815. this.materialTree.sortTreeItems();
  816. function createMaterialNode(data,parent,next) {
  817. let newNode = me.materialTree.addNode(parent, next, data.id);
  818. newNode.data = data;
  819. return newNode;
  820. }
  821. },
  822. getMaterialSheetDataByGLJ:function (glj) {
  823. let q_decimal = getDecimal("glj.quantity");
  824. let m_decimal = getDecimal("material");
  825. let p_decimal = getDecimal("glj.unitPrice");
  826. let projectGLJ = projectObj.project.projectGLJ;
  827. let data ={
  828. id:glj.id,
  829. code:glj.code,
  830. name:glj.name,
  831. specs:glj.specs,
  832. unit:glj.unit,
  833. type:glj.type,
  834. short_name:projectGLJ.getShortNameByID(glj.type),
  835. quantity:scMathUtil.roundToString(glj.quantity,q_decimal),
  836. supply:glj.supply,
  837. supply_quantity:glj.supply_quantity,
  838. materialType:glj.materialType,
  839. delivery:glj.delivery,
  840. delivery_address:glj.delivery_address,
  841. is_adjust_price:glj.is_adjust_price,
  842. ratio_data:glj.ratio_data,
  843. is_add:glj.unit_price.is_add,
  844. bgColour:'white'
  845. };
  846. if(glj.materialCoe){
  847. data.materialCoe = scMathUtil.roundForObj(glj.materialCoe,m_decimal);
  848. data.materialQuantity = scMathUtil.roundForObj(glj.materialCoe * glj.quantity,q_decimal);//还要做汇总,汇总完再转成string
  849. }
  850. gljOprObj.setGLJPrice(data,glj);
  851. data.basePrice = scMathUtil.roundToString(data.basePrice,p_decimal);
  852. data.marketPrice = scMathUtil.roundToString(data.marketPrice,p_decimal);
  853. return data;
  854. },
  855. filterProjectGLJ:function (gljList) {
  856. let me = projectGljObject;
  857. if(gljList.length>0){
  858. gljList = _.filter(gljList,function (item) {
  859. return me.displayTypeFilter(item);
  860. });
  861. }
  862. return gljList;
  863. },
  864. displayTypeFilter:function (item) {
  865. let me = this;
  866. if(item.quantity !== 0 && item.quantity !== '0'){//过滤掉消耗量为0的工料机
  867. if(me.displayType == filterType.ALL){//所有工料机
  868. return true;
  869. }else if(filterTypeArray.indexOf(me.displayType) != -1){//人工、材料、机械、主材、设备
  870. let typeString = item.type+"";
  871. return typeString.startsWith(me.displayType);
  872. }else if(me.displayType == filterType.FBFX){//“分部分项总消耗量”≠0的工料机行
  873. return item.subdivisionQuantity !== 0 && item.subdivisionQuantity !== '0';
  874. }else if(me.displayType == filterType.TECH){//筛选“措施项目总消耗量”≠0的工料机行
  875. return item.techQuantity !== 0 && item.techQuantity !== '0';
  876. }else if(me.displayType == filterType.JGCL){//筛选“供货方式”=“完全甲供”或“部分甲供”的工料机行
  877. return item.supply == supplyType.WQJG || item.supply == supplyType.BFJG;
  878. }else if(me.displayType == filterType.ZGCL){//筛选“是否暂估”=“是”的工料机行。
  879. return item.is_evaluate == 1;
  880. }else if(me.displayType == filterType.ZYCL){//筛选“主要材料”=“是”的工料机行。
  881. return item.is_main_material == 1;
  882. }
  883. }
  884. return false;
  885. },
  886. getSheetDataByGLJ:function (glj) {
  887. let projectGLJ = projectObj.project.projectGLJ;
  888. let materialIdList = projectGLJ.datas.constData.materialIdList;
  889. let data ={
  890. id:glj.id,
  891. code:glj.code,
  892. name:glj.name,
  893. specs:glj.specs,
  894. unit:glj.unit,
  895. type:glj.type,
  896. short_name:projectGLJ.getShortNameByID(glj.type),
  897. quantity:glj.quantity,
  898. tenderQuantity:glj.tenderQuantity,
  899. supply:glj.supply,
  900. supply_quantity:glj.supply_quantity,
  901. materialType:glj.materialType,
  902. materialCoe:glj.materialCoe,
  903. delivery:glj.delivery,
  904. delivery_address:glj.delivery_address,
  905. is_adjust_price:glj.is_adjust_price,
  906. ratio_data:glj.ratio_data,
  907. is_add:glj.unit_price.is_add,
  908. bgColour:'white',
  909. techQuantity:glj.techQuantity,
  910. subdivisionQuantity:glj.subdivisionQuantity,
  911. originPlace:glj.originPlace,
  912. vender:glj.vender,
  913. qualityGrace:glj.qualityGrace,
  914. brand:glj.brand,
  915. unitPriceID:glj.unit_price.id,
  916. priceFrom:glj.unit_price.priceFrom,
  917. remark:glj.remark
  918. };
  919. gljOprObj.setGLJPrice(data,glj);
  920. data.is_main_material = glj.is_main_material == 1?1:0;
  921. //供货方式为完全甲供时设置甲供数量为总消耗量
  922. if (data.supply == 2) data.supply_quantity = glj.quantity;
  923. // 只有材料才显示是否暂估
  924. if (materialIdList.indexOf(glj.type) >= 0) data.is_evaluate = glj.is_evaluate;
  925. //是“材料”、“主材”、“设备”时显示评标材料
  926. if (materialIdList.indexOf(glj.type) >= 0||glj.type == gljType.MAIN_MATERIAL || glj.type == gljType.EQUIPMENT) data.is_eval_material = glj.is_eval_material ? glj.is_eval_material : 0;
  927. //类型是“设备”时有效
  928. if(glj.type == gljType.EQUIPMENT) data.no_tax_eqp = glj.no_tax_eqp?glj.no_tax_eqp:0;
  929. if(glj.materialCoe !== null && glj.materialCoe !==undefined){
  930. data.materialCoe = scMathUtil.roundForObj(glj.materialCoe,getDecimal("material"));
  931. }
  932. //bgColour
  933. if(data.basePrice == data.marketPrice){//如果定额价等于市场价时,改底色。 优先度低于有组成物时的底色
  934. data.bgColour = "#C4CAFB";
  935. }
  936. if (gljUtil.notEditType.indexOf(glj.type) >= 0) {
  937. if (data.ratio_data && data.ratio_data.length > 0){//有组成物时
  938. //设置底色
  939. data.bgColour = "#E0E0E0";
  940. }
  941. }
  942. return data;
  943. },
  944. refreshProjectGljRow:function (row) {
  945. let me = projectGljObject;
  946. let rowData = me.projectGljSheetData[row];
  947. let glj = projectObj.project.projectGLJ.getByID(rowData.id);
  948. let newRow = null;
  949. if(glj){
  950. newRow = me.getSheetDataByGLJ(glj);
  951. }
  952. if(me.displayTypeFilter(newRow) == true){
  953. me.projectGljSheetData[row] = newRow;
  954. sheetCommonObj.showRowData(this.projectGljSheet, this.projectGljSetting,row,this.projectGljSheetData);
  955. }else {
  956. me.projectGljSheetData.splice(row,1);
  957. me.projectGljSheet.deleteRows(row,1);
  958. me.showMixRatioData();
  959. me.showRelatedRationDatas();
  960. }
  961. //me.projectGljSheetData[row] = me.getSheetDataByGLJ(glj);
  962. },
  963. initSheet: function (sheet,setting) {
  964. var me = this;
  965. sheetCommonObj.initSheet(sheet, setting, 30);
  966. sheet.bind(GC.Spread.Sheets.Events.ValueChanged, me.onSheetValueChange);
  967. },
  968. onSheetValueChange:function (e,info) {
  969. let me = projectGljObject;
  970. if(info.sheetName=='projectGljSheet'){
  971. me.onProjectGLJValueChange(e,info);
  972. }else if(info.sheetName == 'mixRatioSheet'){
  973. me.onMixRatioValueChange(e,info);
  974. }
  975. },
  976. onMixRatioValueChange:function (e,info){
  977. let composition = projectObj.project.composition;
  978. let me = projectGljObject,row = info.row, col = info.col;
  979. let dataCode = me.mixRatioSetting.header[col].dataCode;
  980. let recode = me.mixRatioData[row];
  981. let value = info.newValue;
  982. let parentSheet = me.projectGljSpread.getActiveSheet();//三材汇总表和工料机汇总表
  983. if (!me.checkData(col,me.mixRatioSetting,value)) {
  984. alert('输入的数据类型不对,请重新输入!');
  985. me.mixRatioSheet.setValue(row, col, info.oldValue);
  986. return false;
  987. }
  988. value = scMathUtil.roundToString(value,getDecimal("glj.quantity"));
  989. me.batchUpdateConsumption([{row:row,col:col,value}]);
  990. },
  991. refreshParentData:function (row,pid,sid) {
  992. let me = this;
  993. let sheet = me.projectGljSpread.getActiveSheet();
  994. let parantData = null;
  995. if(sheet.name() == 'projectGljSheet'){
  996. me.showProjectGljData();// me.refreshProjectGljRow(row) 这里原来是分开刷新的,现在整个统一刷新,先留着
  997. //parantData = _.find(); //me.projectGljSheetData[row];
  998. }else {
  999. me.showMaterialTreeData();
  1000. //parantData = me.materialTree.items[row].data;
  1001. }
  1002. let pglj = _.find(projectObj.project.projectGLJ.datas.gljList,{'id':pid});
  1003. parantData = pglj?me.getSheetDataByGLJ(pglj):null;
  1004. //projectObj.project.projectGLJ.datas.gljList
  1005. // 更新组成物缓存
  1006. projectObj.project.composition.loadData();
  1007. me.updateParentNodes(pid,parantData.marketPrice,sid);
  1008. },
  1009. updateParentNodes:function(pid,marketPrice,sid){
  1010. //先查找使用了父项目工料机的定额工料机
  1011. let updateNodes=[];
  1012. let ration_gljs = _.filter(projectObj.project.ration_glj.datas,{'projectGLJID':pid});
  1013. for(let rg of ration_gljs){
  1014. let node = projectObj.project.mainTree.getNodeByID(rg.rationID);
  1015. if(node){
  1016. updateNodes.push(node);
  1017. }
  1018. }
  1019. //或者是使用了父项目工料机的工料机类型的定额
  1020. let rations = _.filter(projectObj.project.Ration.datas,{'type':3,'projectGLJID':pid});
  1021. for(let r of rations){
  1022. let r_node = projectObj.project.mainTree.getNodeByID(r.ID);
  1023. if(r_node){
  1024. r_node.data.marketUnitFee = marketPrice;//parentMarketPrice;//这里用显示的价格
  1025. updateNodes.push(r_node);
  1026. }
  1027. }
  1028. if(sid){
  1029. let subRations = calcTools.getRationsByProjectGLJ(sid);
  1030. updateNodes = updateNodes.concat(subRations);
  1031. }
  1032. if(updateNodes.length>0){
  1033. projectObj.project.calcProgram.calcNodesAndSave(updateNodes,async function () {
  1034. projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots);
  1035. installationFeeObj.calcInstallationFee();//计算安装增加费
  1036. await OVER_HEIGHT.reCalcOverHeightFee();
  1037. await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(updateNodes);
  1038. });
  1039. }
  1040. gljOprObj.refreshView();
  1041. },
  1042. onUnitFileChange:function (data) {
  1043. projectObj.project.markUpdateProject({projectID:projectObj.project.ID(),'unitFileID':socketObject.getUnitFileRoomID()},"unitFile",function(){
  1044. //socket.emit('unitFileChangeNotify', JSON.stringify(data));
  1045. socket.emit('unitFileChangeNotify', {projectID:projectObj.project.ID(),userID:userID,'unitFileID':socketObject.getUnitFileRoomID()});
  1046. });
  1047. },
  1048. deleteMixRatio:function (row) {
  1049. let me = this, deleteRecode = me.mixRatioData[row];
  1050. let consumption = deleteRecode.consumption;
  1051. let [parentMarketPrice, parentBasePrice] = me.getCompositionSumPrice('delete', row);
  1052. let parentSheet = me.projectGljSpread.getActiveSheet();//三材汇总表和工料机汇总表
  1053. let prow= parentSheet.getActiveRowIndex();//取父机械或组成物的下标
  1054. let prowData = parentSheet.name() == 'projectGljSheet'?me.projectGljSheetData[prow]:me.materialTree.items[prow].data;
  1055. let updateData = {id: deleteRecode.mix_ratio_id, field: 'mix_ratio.consumption' , value: 0, market_price: parentMarketPrice, base_price: parentBasePrice};
  1056. projectObj.project.composition.deleteComposition(updateData,deleteRecode,prowData.id,function () {
  1057. _.remove(me.mixRatioData,{"mix_ratio_id":deleteRecode.mix_ratio_id});
  1058. me.refreshParentData(prow,prowData.id);
  1059. me.mixRatioSheet.deleteRows(row,1);
  1060. me.onUnitFileChange(deleteRecode);
  1061. });
  1062. },
  1063. getCompositionSumPrice : function(scene, affectRow, newValue = 0) {
  1064. let me = this;
  1065. let parentMarketPrice = 0;
  1066. let parentBasePrice = 0;
  1067. for(let i = 0;i < me.mixRatioData.length;i++){
  1068. let ratio = me.mixRatioData[i];
  1069. let marketPrice = ratio.unit_price.market_price;
  1070. let basePrice = ratio.unit_price.base_price;
  1071. // 如果是删除则忽略即将被删除的行数据
  1072. if (scene === 'delete' && affectRow === i) {
  1073. continue;
  1074. }
  1075. let consumption = i === affectRow ? newValue : ratio.consumption;
  1076. parentMarketPrice += operationWithRound(consumption,marketPrice,"glj.unitPrice","*");
  1077. parentBasePrice += operationWithRound(consumption,basePrice,"glj.unitPrice","*");
  1078. }
  1079. parentMarketPrice = parentMarketPrice.toDecimal(getDecimal("glj.unitPrice"));
  1080. parentBasePrice = parentBasePrice.toDecimal(getDecimal("glj.unitPrice"));
  1081. return [parentMarketPrice, parentBasePrice];
  1082. },
  1083. onProjectGLJValueChange:function (e,info) {//me.projectGljSetting
  1084. let projectGLJ = projectObj.project.projectGLJ;
  1085. let me = projectGljObject,row = info.row, col = info.col;
  1086. let setting = info.sheetName =="materialTreeSheet"?me.materialSetting:me.projectGljSetting;
  1087. let dataCode = setting.header[col].dataCode;
  1088. let recode = info.sheetName =="materialTreeSheet"?me.materialTree.selected.data:me.projectGljSheetData[row];
  1089. let value = info.newValue;
  1090. if(info.newValue === undefined ){
  1091. return;
  1092. }
  1093. if (value&&!me.checkData(col,setting,value)) {
  1094. alert('输入的数据类型不对,请重新输入!');
  1095. info.sheetName =="materialTreeSheet"?me.materialTreeController.refreshTreeNode([me.materialTree.selected]):me.refreshProjectGljRow(row);
  1096. return ;
  1097. }
  1098. let callback=function (impactList) {
  1099. info.sheet.suspendPaint();
  1100. info.sheet.suspendEvent();
  1101. if(info.sheetName =="materialTreeSheet"){
  1102. me.showMaterialTreeData();
  1103. }else {
  1104. me.refreshProjectGljRow(row);
  1105. for(let g of impactList){
  1106. me.refreshProjectGljRowByID(g.id,row);
  1107. }
  1108. }
  1109. info.sheet.resumeEvent();
  1110. info.sheet.resumePaint();
  1111. if (dataCode === 'supply' || dataCode === 'supply_quantity'){ // basePrice、marketPrice 有自己的计算代码,无需走这里重复计算
  1112. let rations = calcTools.getRationsByProjectGLJ(recode.id);
  1113. projectObj.project.calcProgram.calcNodesAndSave(rations, function () {
  1114. projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots);
  1115. });
  1116. }
  1117. };
  1118. if(dataCode=='basePrice'||dataCode=='marketPrice'){//修改市场价和修改定额价时需要重新记算很多受影响的树节点,现在改成与定字额工料机那里调相同的方法。
  1119. let editField = dataCode === 'basePrice'?"base_price":"market_price";
  1120. projectObj.project.projectGLJ.updatePrice(recode,editField,value,'pg',null,callback);
  1121. }else {
  1122. let extend = {};
  1123. // 如果是供货方式则需要处理数据
  1124. if (dataCode === 'supply') {
  1125. extend.supply_quantity = me.getSupplyQuantity(value, recode.quantity);
  1126. }
  1127. if(dataCode === 'supply_quantity'){//修改数量需做4舍5入
  1128. value= scMathUtil.roundForObj(value,getDecimal('glj.quantity'));
  1129. }
  1130. if(dataCode === 'is_evaluate'||dataCode === 'is_adjust_price'||dataCode === 'is_main_material'||dataCode === 'no_tax_eqp'||dataCode == 'is_eval_material'){
  1131. value = value == true?1:0;
  1132. if(dataCode === 'is_evaluate'|| dataCode == 'is_eval_material'){
  1133. configMaterialObj.updateConfigMaterial(dataCode,value,recode);//暂估材料,主要材料等新需求
  1134. return
  1135. }
  1136. }
  1137. if(dataCode === 'materialType' && (value == null || value=="")){//删除三材类别时,清空三材系数
  1138. value = null;
  1139. extend.materialCoe = null;
  1140. }
  1141. if(dataCode == 'materialCoe'){
  1142. value = scMathUtil.roundForObj(value,getDecimal("material"));
  1143. }
  1144. if(dataCode == 'taxRate') value = scMathUtil.roundToString(value,2);
  1145. extend = Object.keys(extend).length > 0 ? JSON.stringify(extend) : '';
  1146. if(recode[dataCode] == value) return;
  1147. let updateData = {id: recode.id, field: dataCode, value: value, extend: extend};
  1148. projectGLJ.pGljUpdate(updateData,callback);
  1149. };
  1150. },
  1151. refreshProjectGljRowByID:function (ID,row) {//row 可以不传,如果row 和 index 相等就不刷新
  1152. let me = this;
  1153. let index = _.findIndex(me.projectGljSheetData, { 'id': ID});
  1154. if(index>=0&&index != row){
  1155. me.refreshProjectGljRow(index);
  1156. }
  1157. },
  1158. getSupplyQuantity : function(supplyType, quantity) {
  1159. // 自行采购和甲定乙供则把甲供数量设置为0,其余情况则设置为当前总消耗量
  1160. let supplyQuantity = supplyType == 0 || supplyType == 3 ? 0 : quantity;
  1161. supplyQuantity = parseFloat(supplyQuantity);
  1162. return supplyQuantity;
  1163. },
  1164. getSupplyQuantityByGlj:function (glj, tender) {
  1165. //{"自行采购":0,"部分甲供":1,"完全甲供":2,"甲定乙供":3};
  1166. let supply_quantity = glj.supply_quantity;
  1167. switch (glj.supply){
  1168. case 0:
  1169. supply_quantity = 0;
  1170. break;
  1171. case 1:
  1172. break;
  1173. case 2:
  1174. supply_quantity = tender ? glj.tenderQuantity : glj.quantity;
  1175. break;
  1176. case 3:
  1177. supply_quantity = 0;
  1178. break;
  1179. }
  1180. return supply_quantity
  1181. },
  1182. checkData : function(col,setting, value) {
  1183. return sheetCommonObj.checkData(col,setting, value);
  1184. },
  1185. getProjectGLJSelected:function () {
  1186. let me = this,data = null;
  1187. let sheet = me.projectGljSpread.getActiveSheet();
  1188. if(sheet.name() == 'projectGljSheet'){//projectGljSheet/materialSheet 工料机汇总和三材汇总表
  1189. let sel = me.projectGljSheet.getSelections()[0];
  1190. let srow = sel.row == -1||sel.row == ""?0:sel.row;
  1191. if(me.projectGljSheetData.length>srow){
  1192. data = me.projectGljSheetData[srow];
  1193. }
  1194. }else if(sheet.name() == 'materialTreeSheet'){
  1195. if(this.materialTree.selected){
  1196. data = this.materialTree.selected.data;
  1197. }
  1198. }
  1199. return data;
  1200. },
  1201. initInfoPriceRightClick:function(){
  1202. let me = this;
  1203. $.contextMenu({
  1204. selector: '#info_price_sheet',
  1205. build: function ($trigger, e) {
  1206. me.rightClickTarget = SheetDataHelper.safeRightClickSelection($trigger, e, me.infoPriceSpread);
  1207. return me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.viewport ||
  1208. me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
  1209. },
  1210. items: {
  1211. "apply": {
  1212. name: "确认套用(或双快速套用)",
  1213. icon: 'fa-sign-in',
  1214. disabled: function () {
  1215. return me.rightClickTarget.row === undefined;
  1216. },
  1217. callback: function (key, opt) {
  1218. let row = me.rightClickTarget.row;
  1219. me.preApplyInfoPrice(row);
  1220. }
  1221. }
  1222. }
  1223. });
  1224. },
  1225. initRightClick : function() {
  1226. let activeSheet = this.mixRatioSheet;
  1227. let me = this;
  1228. $.contextMenu({
  1229. selector: '#mix_ratio_sheet',
  1230. build: function ($trigger, e) {
  1231. me.rightClickTarget = SheetDataHelper.safeRightClickSelection($trigger, e, me.mixRatioSpread);
  1232. return me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.viewport ||
  1233. me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
  1234. },
  1235. items: {
  1236. "deleteMixRatio": {
  1237. name: "删除",
  1238. icon: 'fa-trash-o',
  1239. disabled: function () {
  1240. return me.rightClickTarget.row === undefined;
  1241. },
  1242. callback: function (key, opt) {
  1243. let row = me.rightClickTarget.row;
  1244. me.deleteMixRatio(row);
  1245. },
  1246. visible: function(key, opt){
  1247. if(!$('#mixRatio-nav').hasClass('active')) return false;
  1248. return true;
  1249. }
  1250. },
  1251. "addMixRatio":{
  1252. name: '添加',
  1253. icon: 'fa-sign-in',
  1254. disabled: function () {
  1255. let projectGLJ = projectGljObject.getProjectGLJSelected();
  1256. return !_.includes(compositionTypes,projectGLJ.type);
  1257. },
  1258. callback: function (key, opt) {
  1259. me.selectedProjectGLJ = projectGljObject.getProjectGLJSelected();
  1260. getGLJData('addMix', null, true, null);
  1261. },
  1262. visible: function(key, opt){
  1263. if(!$('#mixRatio-nav').hasClass('active')) return false;
  1264. return true;
  1265. }
  1266. }
  1267. }
  1268. });
  1269. },
  1270. changeFileCallback:function(){
  1271. projectGljObject.unitPriceFileInit();
  1272. projectGljObject.refreshViewsData();
  1273. gljOprObj.refreshView();
  1274. projectObj.project.calcProgram.calcAllNodesAndSave(calcAllType.catAll,function () {
  1275. if(socketObject.roomInfo){
  1276. let data ={
  1277. projectID:projectObj.project.ID(),
  1278. oldRoom:socketObject.roomInfo.unitFile,
  1279. newRoom:socketObject.getUnitFileRoomID(),
  1280. userID:userID,
  1281. name:'unitFile'
  1282. };
  1283. socket.emit('changeNewRoom',data);
  1284. socketObject.roomInfo.unitFile = socketObject.getUnitFileRoomID();
  1285. }
  1286. });
  1287. },
  1288. calcPartASupplyFeeByProjectGLJs: function (projectGLJsArr) {
  1289. for (let pGLJ of projectGLJsArr){
  1290. if (pGLJ.supply == supplyType.BFJG){
  1291. let rations = calcTools.getRationsByProjectGLJ(pGLJ.id);
  1292. projectObj.project.calcProgram.calcNodesAndSave(rations, function () {
  1293. projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots);
  1294. });
  1295. }
  1296. }
  1297. },
  1298. checkUnitFileName:function (name,callback) {
  1299. let projectGLJ = projectObj.project.projectGLJ;
  1300. projectGLJ.checkUnitFileName(name,function (data) {
  1301. if(data){
  1302. $("#save-as-tips").text('已存在同名单价文件').show();
  1303. $('#save-as-confirm').attr("disabled","disabled");
  1304. }else {
  1305. $("#save-as-tips").hide();
  1306. $('#save-as-confirm').removeAttr("disabled");
  1307. if(callback) callback();
  1308. }
  1309. });
  1310. },
  1311. initFilterTypeList:function () {//初始化人材机汇总工料机类型过滤列表
  1312. let htmlString = ' <ul class="nav flex-column">';
  1313. for(let t of this.displayTypeMap){
  1314. htmlString += '<li class="nav-item "><a class="nav-link pl-4" href="javascript:void(0)" id="'+t.ID+'">'+t.text+'</a></li>';
  1315. }
  1316. htmlString += '</ul>';
  1317. $('#ALL').after(htmlString);
  1318. },
  1319. getInfoPriceOptions:async function(){
  1320. let options =await ajaxPost("/infoPrice/getOptions",{});
  1321. this.infoPriceOptions=options;
  1322. this.createSelectOptions($("#info_area"),options.areas,true);
  1323. let years = _.keysIn(options.periodMap);
  1324. this.createSelectOptions($("#info_year"),_.sortBy(years));
  1325. },
  1326. createSelectOptions:function(ele,opts,isArea){
  1327. ele.empty();
  1328. let str = `<option value=""></option>`;
  1329. for(let o of opts){
  1330. if(isArea == true){
  1331. str +=`<option value="${o.ID}">${o.name}</option>`
  1332. }else{
  1333. str +=`<option value="${o}">${o}</option>`
  1334. }
  1335. }
  1336. ele.html(str);
  1337. },
  1338. onInfoTopRowChanged:function(sender, args){
  1339. let me = projectGljObject;
  1340. const bottomRow = args.sheet.getViewportBottomRow(1);
  1341. if(me.infoPriceData >= me.infoPriceTotalSize) return;
  1342. if(me.infoPriceData.length - bottomRow < 20 ){
  1343. if(projectGljObject.infoPriceLastLoadingRow == me.infoPriceData.length){//如果最后一行已经加载过了,就不用再加载了,不然会重复加载
  1344. return;
  1345. }
  1346. console.log(bottomRow);
  1347. me.infoPriceLastLoadingRow = me.infoPriceData.length;
  1348. me.searchInfoPrice(me.infoPriceData[me.infoPriceData.length - 1]._id)
  1349. }
  1350. },
  1351. searchInfoPrice:async function(objectID){
  1352. let year = $('#info_year').val();
  1353. let month = $('#info_month').val();
  1354. let areaID = $('#info_area').val();
  1355. let keyWord = $('#info_search_name').val();
  1356. let me = projectGljObject;
  1357. try {
  1358. if(year !="" && month!="" && areaID!="") {
  1359. let condition = {
  1360. period:year+"-"+month,
  1361. areaID:areaID
  1362. }
  1363. let data ={condition:condition};
  1364. if(keyWord !="") data.keyWord = keyWord;
  1365. if(objectID) data.lastID = objectID;
  1366. let result = await ajaxPost("/infoPrice/getDataByCondition",data);
  1367. if(objectID){//分页查询
  1368. sheetCommonObj.appendData(me.infoPriceSheet, me.infoPriceData.length, 0, me.infoPriceSetting, result.items);
  1369. me.infoPriceData.splice(me.infoPriceData.length, 0, ...result.items);
  1370. }else{
  1371. me.infoPriceTotalSize = result.totalSize;
  1372. me.infoPriceLastLoadingRow = 0;
  1373. me.showInforPriceData(result.items);
  1374. }
  1375. }
  1376. } catch (error) {
  1377. console.log(error)
  1378. }
  1379. },
  1380. preApplyInfoPrice:function (row) {
  1381. let info = this.infoPriceData[row];
  1382. let projectGLJData = this.getProjectGLJSelected();
  1383. if (projectGLJData.ratio_data && projectGLJData.ratio_data.length > 0) return ;
  1384. let marketPrice = this.getInfoMarketPrice(info);
  1385. if(projectGLJData.unit == info.unit){
  1386. this.applyInfoPrice(projectGLJData,marketPrice,1);
  1387. }else if(_.includes(["t","kg"],projectGLJData.unit)&&_.includes(["t","kg"],info.unit)){
  1388. //遇到t和kg之间的转换,默认处理:1t=1000kg,不弹换算窗口
  1389. let coeMap={"t":1,"kg":1000};
  1390. let coe = coeMap[info.unit]/coeMap[projectGLJData.unit];
  1391. this.applyInfoPrice(projectGLJData,marketPrice,coe);
  1392. }else{//弹出单位转换窗口
  1393. $("#infoRow").val(row);
  1394. $("#applyGLJName").text(projectGLJData.name);
  1395. $("#applyGLJUnit").text(projectGLJData.unit);
  1396. $("#infoPriceCoe").val("");
  1397. $("#applyInfoUnit").text(info.unit);
  1398. $("#infoPriceCoeDiv").modal('show')
  1399. }
  1400. },
  1401. applyInfoPrice:function (projectGLJData,price,coe) {
  1402. let priceFrom= me.getPriceFrom();
  1403. projectObj.project.projectGLJ.updatePrice(projectGLJData,"market_price",price*coe,'pg',{"priceFrom":priceFrom});
  1404. },
  1405. getPriceFrom:function(){
  1406. let area = "";
  1407. for(let o of this.infoPriceOptions.areas){
  1408. if(o.ID == $("#info_area").val()){
  1409. area = o.name;
  1410. break;
  1411. }
  1412. }
  1413. return `${area}信息价(${$("#info_year").val()}${$("#info_month").val()})`;
  1414. },
  1415. getInfoMarketPrice:function (info) {
  1416. let taxType = projectObj.project.property.taxType;//1: 一般计税 2: 简易计税
  1417. return gljUtil.getInfoMarketPrice(info,taxType);
  1418. }
  1419. };
  1420. function getProjectResizeEles() {
  1421. let pojGljResizeEles = {};
  1422. pojGljResizeEles.eleObj = {
  1423. module: 'projectGlj',
  1424. resize: $('#projectGljResize'),
  1425. top: $('#projectGljTop'),
  1426. topSpread: $('#project_glj_sheet'),
  1427. bottom: $('#projectGljBottom'),
  1428. bottomSpread: $('#mix_ratio_sheet')
  1429. };
  1430. pojGljResizeEles.limit = {
  1431. min: 150,
  1432. max: `$(window).height()-$('.header').height()-$('#projectGljToolsBar').height()-150-5`,//5: resize.height()
  1433. notTopSpread: 0,
  1434. notBottomSpread: 0,
  1435. totalHeight: `$(window).height()-$('.header').height()-$('#projectGljToolsBar').height()-5`
  1436. };
  1437. return pojGljResizeEles;
  1438. }
  1439. function getConficMaterialResizeEles() {
  1440. let conficMaterialResizeEles = {};
  1441. conficMaterialResizeEles.eleObj = {
  1442. module: 'conficMaterial',
  1443. resize: $('#configMaterialResize'),
  1444. top: $('#configMaterialTop'),
  1445. topSpread: $('#config_material_sheet'),
  1446. bottom: $('#configMaterialBottom'),
  1447. bottomSpread: $('#related_sheet')
  1448. };
  1449. conficMaterialResizeEles.limit = {
  1450. min: 150,
  1451. max: `$(window).height()-$('.header').height()-$('#projectGljToolsBar').height()-150-5`,//5: resize.height()
  1452. notTopSpread: 0,
  1453. notBottomSpread: 0,
  1454. totalHeight: `$(window).height()-$('.header').height()-$('#projectGljToolsBar').height()-5`,
  1455. bottomNav:`$('#configMaterialBottom ul').height() + $('#filterToolDiv').height()+10`
  1456. };
  1457. return conficMaterialResizeEles;
  1458. }
  1459. function loadProjectGljSize() {
  1460. if($('#project-glj-main').is(':visible')){
  1461. let me = projectGljObject;
  1462. let pojGljResizeEles = getProjectResizeEles();
  1463. if(!$("#projectGljBottom").is(':visible')){
  1464. let total = $(window).height()-$('.header').height()-$('#projectGljToolsBar').height()+3;
  1465. $("#projectGljTop").height(total);
  1466. $("#project_glj_sheet").height(total);
  1467. me.projectGljSpread?me.projectGljSpread.refresh():'';
  1468. }else{
  1469. SlideResize.loadVerticalHeight(pojGljResizeEles.eleObj.module, pojGljResizeEles.eleObj, pojGljResizeEles.limit, function () {
  1470. me.projectGljSpread?me.projectGljSpread.refresh():'';
  1471. me.mixRatioSpread?me.mixRatioSpread.refresh():'';
  1472. //信息价相关
  1473. $('#info_price_sheet').height($("#mix_ratio_sheet").height() - $("#infoToolDiv").height());
  1474. if($('#info_price_sheet').is(':visible')) me.initInfoPriceSpread();
  1475. });
  1476. }
  1477. }else if($('#material_adjust').is(':visible')){
  1478. $('#material_adjust_sheet').height($(window).height()-$('.header').height()-$('#projectGljToolsBar').height()+3);
  1479. if(materialAdjustObj.spread)materialAdjustObj.spread.refresh();
  1480. }else if($('#config_material').is(':visible')){
  1481. let configMaterialResizeEles = getConficMaterialResizeEles();
  1482. SlideResize.loadVerticalHeight(configMaterialResizeEles.eleObj.module, configMaterialResizeEles.eleObj, configMaterialResizeEles.limit, function () {
  1483. configMaterialObj.configSpread? configMaterialObj.configSpread.refresh():'';
  1484. configMaterialObj.relatedSpread? configMaterialObj.relatedSpread.refresh():'';
  1485. /*
  1486. me.mixRatioSpread?me.mixRatioSpread.refresh():'';*/
  1487. });
  1488. }
  1489. }
  1490. //从其他建设项目中复制中,建设项目的文件层次结构名称和顺序
  1491. function getFileHierarchyInfo(treeData){
  1492. let tree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1});
  1493. tree.loadDatas(treeData);
  1494. let items = tree.items;
  1495. let rst = [];
  1496. function getFileHierarchyName(node){
  1497. let nodeName = node.data.name;
  1498. let name = [];
  1499. while (node.parent){
  1500. name.push(node.parent.data.name ? node.parent.data.name : '');
  1501. node = node.parent;
  1502. }
  1503. name = name.reverse();
  1504. name.push(nodeName);
  1505. return name.join('\\');
  1506. }
  1507. for(let node of items){
  1508. if(node.children.length === 0 ){//project
  1509. rst.push({ID: node.data.ID, fileHierarchyName: getFileHierarchyName(node)})
  1510. }
  1511. }
  1512. return rst;
  1513. }
  1514. $(function () {
  1515. let pojGljResizeEles = getProjectResizeEles();
  1516. SlideResize.verticalSlide(pojGljResizeEles.eleObj, pojGljResizeEles.limit, function () {
  1517. projectGljObject.projectGljSpread.refresh();
  1518. projectGljObject.mixRatioSpread?projectGljObject.mixRatioSpread.refresh():'';
  1519. });
  1520. let tr = getConficMaterialResizeEles();
  1521. SlideResize.verticalSlide(tr.eleObj, tr.limit, function(){
  1522. configMaterialObj.configSpread? configMaterialObj.configSpread.refresh():'';
  1523. configMaterialObj.relatedSpread? configMaterialObj.relatedSpread.refresh():'';
  1524. });
  1525. $('#tab_project_glj').on('shown.bs.tab', function (e) {
  1526. sessionStorage.setItem('mainTab', '#tab_project_glj');
  1527. let me = projectGljObject;
  1528. $(e.relatedTarget.hash).removeClass('active');
  1529. if(me.projectGljSpread==null){
  1530. me.initSpreads();
  1531. }
  1532. me.unitPriceFileInit();
  1533. me.initMixRatio();
  1534. me.initSheetViews();
  1535. //projectObj.project.projectGLJ.calcQuantity(); 在工程量有更新的地方调用
  1536. me.refreshViewsData();
  1537. loadProjectGljSize();
  1538. });
  1539. /* $('#ration_link').on('shown.bs.tab', function (e) {
  1540. let me = projectGljObject;
  1541. me.showTag='ration';
  1542. me.showProjectGljData();
  1543. });
  1544. $('#mix_ratio_link').on('shown.bs.tab', function (e) {
  1545. let me = projectGljObject;
  1546. me.showTag='mixRatio';
  1547. me.showProjectGljData();
  1548. me.initMixRatio();
  1549. });
  1550. $('#machine_ratio_link').on('shown.bs.tab', function (e) {
  1551. let me = projectGljObject;
  1552. me.showTag='machine';
  1553. me.showProjectGljData();
  1554. me.initMixRatio();
  1555. });*/
  1556. $('#pop-used-list').tooltip({
  1557. placement: "bottom",
  1558. html: true,
  1559. trigger: "hover | focus",
  1560. title: projectGljObject.getUsedTenderInfo
  1561. }
  1562. );
  1563. // 单价文件切换弹框
  1564. $('#change-unitFile').on('shown.bs.modal', function () {
  1565. let rootProjectID = projectObj.project.projectInfo.property.rootProjectID;
  1566. // 获取切换单价文件相关数据
  1567. $.ajax({
  1568. url: '/glj/get-project-info',
  1569. type: 'post',
  1570. data: {project_id: scUrlUtil.GetQueryString('project'),rootProjectID:rootProjectID},
  1571. dataType: 'json',
  1572. success: function (response) {
  1573. if (response.err === 1) {
  1574. alert('数据传输错误!');
  1575. return false;
  1576. }
  1577. let data = response.data;
  1578. projectGljObject.changeInfo = data;
  1579. $("#current-project-name").text(data.currentProjectName);
  1580. // 本项目中的单价文件
  1581. if (data.self.length > 0) {
  1582. let selfFileHtml = '';
  1583. for (let tmp of data.self) {
  1584. let select = usedUnitPriceInfo === tmp.id ? ' selected="selected"' : '';
  1585. selfFileHtml += '<option' + select + ' value="' + tmp.id + '">' + tmp.name + '</option>';
  1586. }
  1587. $("#self-file").html(selfFileHtml);
  1588. }
  1589. // 其他建设项目数据
  1590. let newDataOther = [];
  1591. if (data.other.length > 0) {
  1592. //转换成按项目管理顺序,名称包含文件夹层次
  1593. let fileHierarchyDatas = getFileHierarchyInfo(data.treeData);
  1594. for(let fileHierarchyData of fileHierarchyDatas){
  1595. let projData = _.find(data.other, {ID: fileHierarchyData.ID});
  1596. if(projData){
  1597. projData.name = fileHierarchyData.fileHierarchyName;
  1598. newDataOther.push(projData);
  1599. }
  1600. }
  1601. data.other = newDataOther;
  1602. let otherProjectHtml = '';
  1603. let otherFileHtml = '';
  1604. for (let tmp of data.other) {
  1605. otherProjectHtml += '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
  1606. otherFileData[tmp.ID] = tmp.unitPriceList;
  1607. if (otherFileHtml !== '') {
  1608. continue;
  1609. }
  1610. for (let unitPrice of tmp.unitPriceList) {
  1611. otherFileHtml += '<option value="' + unitPrice.id + '">' + unitPrice.name + '</option>';
  1612. }
  1613. }
  1614. $("#other-project").html(otherProjectHtml);
  1615. $("#other-file").html(otherFileHtml);
  1616. }
  1617. }
  1618. });
  1619. });
  1620. // 单价文件切换确认
  1621. $("#change-file-confirm").click(function () {
  1622. let type = $("input[name='change-type']:checked").val();
  1623. type = parseInt(type);
  1624. let changeUnitPriceId = 0;
  1625. $('#change-unitFile').modal("hide");
  1626. if (type === 0) {
  1627. // 从本项目中选择
  1628. changeUnitPriceId = $("#self-file").val();
  1629. if(!changeUnitPriceId){
  1630. alert('单价文件不可为空');
  1631. return;
  1632. }
  1633. submitFileChange(changeUnitPriceId,type);
  1634. } else {
  1635. // 从其他项目中复制
  1636. changeUnitPriceId = $("#other-file").val();
  1637. let newName = $("#other-file").children("option:selected").text();
  1638. projectObj.project.projectGLJ.checkUnitFileName(newName,function (need_rename) {
  1639. if(need_rename){
  1640. $("#rename-unitFile").modal({show:true});
  1641. $("#newUnitFileID").val(changeUnitPriceId);
  1642. $("#newUnitFileName").val(newName);
  1643. }else {
  1644. submitFileChange(changeUnitPriceId,type);
  1645. }
  1646. });
  1647. }
  1648. function submitFileChange(changeUnitPriceId,type) {
  1649. let data = {project_id: scUrlUtil.GetQueryString('project'), change_id: changeUnitPriceId, type: type};
  1650. projectObj.project.projectGLJ.changeFile(data,function () {
  1651. projectGljObject.changeFileCallback();
  1652. })
  1653. }
  1654. });
  1655. // 单价文件选项切换
  1656. $("input[name='change-type']").change(function () {
  1657. let type = $(this).val();
  1658. type = parseInt(type);
  1659. $("#change-unitFile .option").hide();
  1660. if (type === 0) {
  1661. $(".option.select").show();
  1662. } else {
  1663. $(".option.copy").show();
  1664. }
  1665. });
  1666. $("#unitFile-save-as").on('shown.bs.modal', function () {
  1667. // 获取当前建设项数据
  1668. $("#save-as-name").val(projectGljObject.usedUnitPriceInfo.name + '副本');
  1669. projectGljObject.checkUnitFileName(projectGljObject.usedUnitPriceInfo.name + '副本');
  1670. });
  1671. // 从其他建设项目中复制 选择建设项目
  1672. $("#other-project").change(function () {
  1673. let projectId = $(this).val();
  1674. if (otherFileData[projectId] === undefined) {
  1675. return false;
  1676. }
  1677. let otherFileHtml = '';
  1678. for (let unitPrice of otherFileData[projectId]) {
  1679. otherFileHtml += '<option value="' + unitPrice.id + '">' + unitPrice.name + '</option>';
  1680. }
  1681. $("#other-file").html(otherFileHtml);
  1682. });
  1683. $('#save-as-name').change(function () {
  1684. projectGljObject.checkUnitFileName(this.value);
  1685. });
  1686. $('#newUnitFileName').change(function () {
  1687. let projectGLJ = projectObj.project.projectGLJ;
  1688. projectGLJ.checkUnitFileName(this.value,function (data) {
  1689. if(data){
  1690. $("#renameError_unitFile").text('已存在同名单价文件').show();
  1691. //$('#renameUnitFileConfirm').attr("disabled","disabled");
  1692. }else {
  1693. $("#renameError_unitFile").hide();
  1694. // $('#renameUnitFileConfirm').removeAttr("disabled");
  1695. }
  1696. });
  1697. });
  1698. $("#renameUnitFileConfirm").click(function () {
  1699. let projectGLJ = projectObj.project.projectGLJ;
  1700. let newName = $('#newUnitFileName').val();
  1701. let changeUnitPriceId = $('#newUnitFileID').val();
  1702. projectGLJ.checkUnitFileName(newName,function (data) {
  1703. if(data){
  1704. $("#renameError_unitFile").text('已存在同名单价文件').show();
  1705. //$('#renameUnitFileConfirm').attr("disabled","disabled");
  1706. }else {
  1707. $("#renameError_unitFile").hide();
  1708. $('#rename-unitFile').modal('hide');
  1709. // $('#renameUnitFileConfirm').removeAttr("disabled");
  1710. let data = {project_id: scUrlUtil.GetQueryString('project'), change_id: changeUnitPriceId, type: 1,newName:newName};
  1711. projectObj.project.projectGLJ.changeFile(data,function () {
  1712. projectGljObject.changeFileCallback();
  1713. })
  1714. }
  1715. });
  1716. });
  1717. // 单价文件另存为操作
  1718. $("#save-as-confirm").click(function () {
  1719. let projectGLJ = projectObj.project.projectGLJ;
  1720. let name = $("#save-as-name").val();
  1721. if (name === '') {
  1722. $("#save-as-tips").text('请填写单价文件名称').show();
  1723. return false;
  1724. }
  1725. let saveData = {name: name, project_id: scUrlUtil.GetQueryString('project')};
  1726. projectGljObject.checkUnitFileName(name,function () {
  1727. projectGLJ.saveAs(saveData,function () {
  1728. projectGljObject.changeFileCallback();
  1729. $("#unitFile-save-as").modal("hide");
  1730. });
  1731. });
  1732. });
  1733. $("#filterType").on("click","ul li a",function(e){
  1734. let children = $('#filterType a');
  1735. for(let c of children){
  1736. $(c).removeClass('active');
  1737. }
  1738. $(this).addClass('active');
  1739. let me = projectGljObject;
  1740. me.displayType = filterType[this.id];
  1741. me.initSheetViews();
  1742. me.refreshViewsData();
  1743. loadProjectGljSize();
  1744. });
  1745. $("#mixRatio-nav").on('shown.bs.tab', function () {
  1746. projectGljObject.mixRatioSpread.refresh();
  1747. projectGljObject.showMixRatioData();
  1748. });
  1749. $("#ration-nav").on('shown.bs.tab', function () {
  1750. projectGljObject.mixRatioSpread.refresh();
  1751. projectGljObject.showRelatedRationDatas();
  1752. });
  1753. $("#info-nav").on('shown.bs.tab', function () {
  1754. $('#info_price_sheet').height($("#mix_ratio_sheet").height() - $("#infoToolDiv").height());
  1755. projectGljObject.initInfoPriceSpread();
  1756. /*
  1757. projectGljObject.showRelatedRationDatas(); */
  1758. });
  1759. $('#info_year').change(function () {
  1760. let periodMap = projectGljObject.infoPriceOptions.periodMap;
  1761. let year = $(this).val();
  1762. let month = $("#info_month").val();
  1763. let options = periodMap[year];
  1764. projectGljObject.createSelectOptions($("#info_month"),periodMap[year]);
  1765. if(month !=""){
  1766. if(_.includes(options,month)){
  1767. $("#info_month").val(month);
  1768. projectGljObject.searchInfoPrice();
  1769. }
  1770. }
  1771. });
  1772. $('#info_month').change(function () {
  1773. projectGljObject.searchInfoPrice();
  1774. });
  1775. $('#info_area').change(function () {
  1776. projectGljObject.searchInfoPrice();
  1777. });
  1778. $('#info_search_name').on('keypress', function (e) {
  1779. if (e.keyCode === 13) {
  1780. projectGljObject.searchInfoPrice();
  1781. }
  1782. });
  1783. $('#info_search_btn').on('click', function (e) {
  1784. projectGljObject.searchInfoPrice();
  1785. });
  1786. $('#infoPriceCoeConfirm').on('click', function (e) {
  1787. let me = projectGljObject;
  1788. let infoPriceCoe = $("#infoPriceCoe").val();
  1789. if(infoPriceCoe==="") return alert("请输入单位转换值!");
  1790. if(!(/^\d+(\.\d+)?$/.test(infoPriceCoe))) return alert("请输入数字!");
  1791. $("#infoPriceCoeDiv").modal('hide');
  1792. let pojectGLJData = me.getProjectGLJSelected();
  1793. let info=me.infoPriceData[parseInt($("#infoRow").val())];
  1794. let marketPrice = me.getInfoMarketPrice(info);
  1795. me.applyInfoPrice(pojectGLJData,marketPrice,parseFloat(infoPriceCoe));
  1796. });
  1797. $('#muti_apply_info').on('click', function (e) {
  1798. let year = $('#info_year').val();
  1799. let month = $('#info_month').val();
  1800. let areaID = $('#info_area').val();
  1801. if(year !="" && month!="" && areaID!=""){
  1802. $("#mutiApplyInfoPriceDiv").modal("show");
  1803. }
  1804. });
  1805. $('#mutiApplyinfoPriceConfirm').on('click', function (e) {
  1806. let typeMap= {};
  1807. let pgljMap = {};
  1808. let year = $('#info_year').val();
  1809. let month = $('#info_month').val();
  1810. let areaID = $('#info_area').val();
  1811. for(let e of $(".info_apply_type")){
  1812. if($(e).prop('checked') == true){
  1813. typeMap[$(e).val()] = true;
  1814. }
  1815. }
  1816. for(let pglj of projectGljObject.projectGljSheetData){
  1817. if(pglj.ratio_data && pglj.ratio_data.length > 0) continue; //有组成物时跳过
  1818. let typeString = pglj.type +"";
  1819. if(typeMap[typeString.charAt(0)]){
  1820. let index = gljUtil.getIndex(pglj,["name","specs","unit"]);
  1821. let obj = {pgljID:pglj.id,unitPriceID:pglj.unitPriceID,fullIndex:gljUtil.getIndex(pglj)};
  1822. pgljMap[index]?pgljMap[index].push(obj):pgljMap[index]=[obj];//考虑到只用三个去匹配会有重复的工料机,所以这里用数组
  1823. }
  1824. }
  1825. if(_.isEmpty(pgljMap)) return;
  1826. let condition = {
  1827. period:year+"-"+month,
  1828. areaID:areaID
  1829. }
  1830. let priceFrom = projectGljObject.getPriceFrom();
  1831. projectObj.project.projectGLJ.mutiApplyInfoPrice(pgljMap,condition,priceFrom);
  1832. });
  1833. });