project_glj_view.js 85 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879
  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 || me.displayType == filterType.ZGCL || me.displayType == filterType.PBCL){
  707. $('#adjustType').hide();
  708. if(me.displayType == filterType.AMAE){
  709. let adjustType = projectObj.project.projectInfo.property.gljAdjustType || 'priceInfo';
  710. $('#adjustType').val(adjustType);
  711. $('#adjustType').show();
  712. }
  713. configMaterialObj.setNavLinkText(me.displayType);
  714. $('#material_adjust').hide();
  715. $('#project-glj-main').hide();
  716. $('#config_material').show();
  717. } else {
  718. $('#material_adjust').hide();
  719. $('#adjustType').hide();
  720. $('#config_material').hide();
  721. $('#project-glj-main').show();
  722. if(me.displayType == filterType.JGCL || me.displayType == filterType.SCHZ){
  723. $("#projectGljResize").hide();
  724. $("#projectGljBottom").hide();
  725. }else{
  726. $("#projectGljResize").show();
  727. $("#projectGljBottom").show();
  728. }
  729. }
  730. },
  731. refreshViewsData:function(){
  732. let me = projectGljObject;
  733. if(me.displayType == filterType.AMAE) return materialAdjustObj.refreshSheetDatas();
  734. if(me.displayType == filterType.ZGCL || me.displayType == filterType.PBCL) return configMaterialObj.refreshSheetDatas();
  735. me.refreshDataSheet();
  736. },
  737. refreshDataSheet:function (refresh) {//refresh = true 的时候不用更新表头信息
  738. let me = projectGljObject;
  739. if(!refresh){
  740. let quantityCol = _.findIndex(me.projectGljSetting.header,function (header) {
  741. return header.dataCode == 'quantity'|| header.dataCode == 'techQuantity' || header.dataCode =='subdivisionQuantity';
  742. });
  743. if(me.displayType == filterType.FBFX){//分部分项人材机,将“总消耗量”替换显示为“分部分项总消耗量”。
  744. me.projectGljSetting.header[quantityCol].dataCode = 'subdivisionQuantity';
  745. me.projectGljSheet.setValue(0, quantityCol, "分部分项总消耗量", GC.Spread.Sheets.SheetArea.colHeader);
  746. }else if(me.displayType == filterType.TECH) {//措施项目人材机,将“总消耗量”替换显示为“措施项目总消耗量”。
  747. me.projectGljSetting.header[quantityCol].dataCode = 'techQuantity';
  748. me.projectGljSheet.setValue(0, quantityCol, "措施项目总消耗量", GC.Spread.Sheets.SheetArea.colHeader);
  749. }else {
  750. me.projectGljSetting.header[quantityCol].dataCode = 'quantity';
  751. me.projectGljSheet.setValue(0, quantityCol, "总消耗量", GC.Spread.Sheets.SheetArea.colHeader);
  752. }
  753. }
  754. if(me.displayType == filterType.SCHZ){//三材汇总树节点
  755. me.showMaterialTreeData();
  756. }else {
  757. me.showProjectGljData();
  758. me.showMixRatioData();
  759. me.showRelatedRationDatas();
  760. }
  761. },
  762. createMaterialTree:function (gljList) {
  763. let me = projectGljObject;
  764. let q_decimal = getDecimal("glj.quantity");
  765. let GC = {id:'GC',name:materialType[materialTypeMap.GC],code:'GC',unit:'t',ParentID:-1,NextSiblingID:'MC'};
  766. let GJ = {id:'GJ',name:materialType[materialTypeMap.GJ],code:'GJ',unit:'t',ParentID:'GC',NextSiblingID:-1};
  767. let MC = {id:'MC',name:materialType[materialTypeMap.MC],code:'MC',unit:'m3',ParentID:-1,NextSiblingID:'SN'};
  768. let SN = {id:'SN',name:materialType[materialTypeMap.SN],code:'SN',unit:'t',ParentID:-1,NextSiblingID:'ST'};
  769. let ST = {id:'ST',name:materialType[materialTypeMap.ST],code:'SPT',unit:'m3',ParentID:-1,NextSiblingID:'SS'};
  770. let SS= {id:'SS',name:materialType[materialTypeMap.SS],code:'SPJS',unit:'m3',ParentID:-1,NextSiblingID:'-1'};
  771. let rootDatas= [GC,GJ,MC,SN,ST,SS];
  772. let parentMap = {};
  773. let sumMap = {};
  774. this.materialTree.nodes={},this.materialTree.selected = null,this.materialTree.roots = [],this.materialTree.items=[];
  775. for(let r of rootDatas){
  776. let baseNode = null;
  777. if(r.id == 'GJ'){
  778. baseNode = createMaterialNode(r,parentMap['GC'],null);//钢筋的父节点为钢材
  779. }else {
  780. baseNode = createMaterialNode(r,null,null);
  781. }
  782. parentMap[r.id] = baseNode;
  783. }
  784. for(let g of gljList){
  785. if(g.quantity !== 0 && g.quantity !== '0'){
  786. if(g.materialType){
  787. let tem = me.getMaterialSheetDataByGLJ(g);
  788. if(tem.materialQuantity){
  789. sumMap[g.materialType] = sumMap[g.materialType]?sumMap[g.materialType] + tem.materialQuantity:tem.materialQuantity;
  790. tem.materialQuantity = scMathUtil.roundToString(tem.materialQuantity,q_decimal);//转成string
  791. }
  792. if(g.materialType == materialTypeMap.GC){ //钢材的下一节点是钢筋
  793. createMaterialNode(tem,parentMap['GC'],parentMap['GJ']);
  794. }else {
  795. createMaterialNode(tem,parentMap[materialTypeMap[g.materialType]]);
  796. }
  797. }
  798. }
  799. }
  800. for(let mkey in sumMap){
  801. if(mkey == materialTypeMap.GC && sumMap[materialTypeMap.GJ]){//钢材汇总要加上钢筋的总量
  802. parentMap['GC'].data.materialQuantity = scMathUtil.roundToString(sumMap[mkey]+sumMap[materialTypeMap.GJ],q_decimal);
  803. }else {
  804. parentMap[materialTypeMap[mkey]].data.materialQuantity = scMathUtil.roundToString(sumMap[mkey],q_decimal);
  805. }
  806. }
  807. this.materialTree.sortTreeItems();
  808. function createMaterialNode(data,parent,next) {
  809. let newNode = me.materialTree.addNode(parent, next, data.id);
  810. newNode.data = data;
  811. return newNode;
  812. }
  813. },
  814. getMaterialSheetDataByGLJ:function (glj) {
  815. let q_decimal = getDecimal("glj.quantity");
  816. let m_decimal = getDecimal("material");
  817. let p_decimal = getDecimal("glj.unitPrice");
  818. let projectGLJ = projectObj.project.projectGLJ;
  819. let data ={
  820. id:glj.id,
  821. code:glj.code,
  822. name:glj.name,
  823. specs:glj.specs,
  824. unit:glj.unit,
  825. type:glj.type,
  826. short_name:projectGLJ.getShortNameByID(glj.type),
  827. quantity:scMathUtil.roundToString(glj.quantity,q_decimal),
  828. supply:glj.supply,
  829. supply_quantity:glj.supply_quantity,
  830. materialType:glj.materialType,
  831. delivery:glj.delivery,
  832. delivery_address:glj.delivery_address,
  833. is_adjust_price:glj.is_adjust_price,
  834. ratio_data:glj.ratio_data,
  835. is_add:glj.unit_price.is_add,
  836. bgColour:'white'
  837. };
  838. if(glj.materialCoe){
  839. data.materialCoe = scMathUtil.roundForObj(glj.materialCoe,m_decimal);
  840. data.materialQuantity = scMathUtil.roundForObj(glj.materialCoe * glj.quantity,q_decimal);//还要做汇总,汇总完再转成string
  841. }
  842. gljOprObj.setGLJPrice(data,glj);
  843. data.basePrice = scMathUtil.roundToString(data.basePrice,p_decimal);
  844. data.marketPrice = scMathUtil.roundToString(data.marketPrice,p_decimal);
  845. return data;
  846. },
  847. filterProjectGLJ:function (gljList) {
  848. let me = projectGljObject;
  849. if(gljList.length>0){
  850. gljList = _.filter(gljList,function (item) {
  851. return me.displayTypeFilter(item);
  852. });
  853. }
  854. return gljList;
  855. },
  856. displayTypeFilter:function (item) {
  857. let me = this;
  858. if(item.quantity !== 0 && item.quantity !== '0'){//过滤掉消耗量为0的工料机
  859. if(me.displayType == filterType.ALL){//所有工料机
  860. return true;
  861. }else if(filterTypeArray.indexOf(me.displayType) != -1){//人工、材料、机械、主材、设备
  862. let typeString = item.type+"";
  863. return typeString.startsWith(me.displayType);
  864. }else if(me.displayType == filterType.FBFX){//“分部分项总消耗量”≠0的工料机行
  865. return item.subdivisionQuantity !== 0 && item.subdivisionQuantity !== '0';
  866. }else if(me.displayType == filterType.TECH){//筛选“措施项目总消耗量”≠0的工料机行
  867. return item.techQuantity !== 0 && item.techQuantity !== '0';
  868. }else if(me.displayType == filterType.JGCL){//筛选“供货方式”=“完全甲供”或“部分甲供”的工料机行
  869. return item.supply == supplyType.WQJG || item.supply == supplyType.BFJG;
  870. }else if(me.displayType == filterType.ZGCL){//筛选“是否暂估”=“是”的工料机行。
  871. return item.is_evaluate == 1;
  872. }else if(me.displayType == filterType.ZYCL){//筛选“主要材料”=“是”的工料机行。
  873. return item.is_main_material == 1;
  874. }
  875. }
  876. return false;
  877. },
  878. getSheetDataByGLJ:function (glj) {
  879. let projectGLJ = projectObj.project.projectGLJ;
  880. let materialIdList = projectGLJ.datas.constData.materialIdList;
  881. let data ={
  882. id:glj.id,
  883. code:glj.code,
  884. name:glj.name,
  885. specs:glj.specs,
  886. unit:glj.unit,
  887. type:glj.type,
  888. short_name:projectGLJ.getShortNameByID(glj.type),
  889. quantity:glj.quantity,
  890. tenderQuantity:glj.tenderQuantity,
  891. supply:glj.supply,
  892. supply_quantity:glj.supply_quantity,
  893. materialType:glj.materialType,
  894. materialCoe:glj.materialCoe,
  895. delivery:glj.delivery,
  896. delivery_address:glj.delivery_address,
  897. is_adjust_price:glj.is_adjust_price,
  898. ratio_data:glj.ratio_data,
  899. is_add:glj.unit_price.is_add,
  900. bgColour:'white',
  901. techQuantity:glj.techQuantity,
  902. subdivisionQuantity:glj.subdivisionQuantity,
  903. originPlace:glj.originPlace,
  904. vender:glj.vender,
  905. qualityGrace:glj.qualityGrace,
  906. brand:glj.brand,
  907. unitPriceID:glj.unit_price.id,
  908. priceFrom:glj.unit_price.priceFrom,
  909. remark:glj.remark
  910. };
  911. gljOprObj.setGLJPrice(data,glj);
  912. data.is_main_material = glj.is_main_material == 1?1:0;
  913. //供货方式为完全甲供时设置甲供数量为总消耗量
  914. if (data.supply == 2) data.supply_quantity = glj.quantity;
  915. // 只有材料才显示是否暂估
  916. if (materialIdList.indexOf(glj.type) >= 0) data.is_evaluate = glj.is_evaluate;
  917. //是“材料”、“主材”、“设备”时显示评标材料
  918. 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;
  919. //类型是“设备”时有效
  920. if(glj.type == gljType.EQUIPMENT) data.no_tax_eqp = glj.no_tax_eqp?glj.no_tax_eqp:0;
  921. if(glj.materialCoe !== null && glj.materialCoe !==undefined){
  922. data.materialCoe = scMathUtil.roundForObj(glj.materialCoe,getDecimal("material"));
  923. }
  924. //bgColour
  925. if(data.basePrice == data.marketPrice){//如果定额价等于市场价时,改底色。 优先度低于有组成物时的底色
  926. data.bgColour = "#C4CAFB";
  927. }
  928. if (gljUtil.notEditType.indexOf(glj.type) >= 0) {
  929. if (data.ratio_data && data.ratio_data.length > 0){//有组成物时
  930. //设置底色
  931. data.bgColour = "#E0E0E0";
  932. }
  933. }
  934. return data;
  935. },
  936. refreshProjectGljRow:function (row) {
  937. let me = projectGljObject;
  938. let rowData = me.projectGljSheetData[row];
  939. let glj = projectObj.project.projectGLJ.getByID(rowData.id);
  940. let newRow = null;
  941. if(glj){
  942. newRow = me.getSheetDataByGLJ(glj);
  943. }
  944. if(me.displayTypeFilter(newRow) == true){
  945. me.projectGljSheetData[row] = newRow;
  946. sheetCommonObj.showRowData(this.projectGljSheet, this.projectGljSetting,row,this.projectGljSheetData);
  947. }else {
  948. me.projectGljSheetData.splice(row,1);
  949. me.projectGljSheet.deleteRows(row,1);
  950. me.showMixRatioData();
  951. me.showRelatedRationDatas();
  952. }
  953. //me.projectGljSheetData[row] = me.getSheetDataByGLJ(glj);
  954. },
  955. initSheet: function (sheet,setting) {
  956. var me = this;
  957. sheetCommonObj.initSheet(sheet, setting, 30);
  958. sheet.bind(GC.Spread.Sheets.Events.ValueChanged, me.onSheetValueChange);
  959. },
  960. onSheetValueChange:function (e,info) {
  961. let me = projectGljObject;
  962. if(info.sheetName=='projectGljSheet'){
  963. me.onProjectGLJValueChange(e,info);
  964. }else if(info.sheetName == 'mixRatioSheet'){
  965. me.onMixRatioValueChange(e,info);
  966. }
  967. },
  968. onMixRatioValueChange:function (e,info){
  969. let composition = projectObj.project.composition;
  970. let me = projectGljObject,row = info.row, col = info.col;
  971. let dataCode = me.mixRatioSetting.header[col].dataCode;
  972. let recode = me.mixRatioData[row];
  973. let value = info.newValue;
  974. let parentSheet = me.projectGljSpread.getActiveSheet();//三材汇总表和工料机汇总表
  975. if (!me.checkData(col,me.mixRatioSetting,value)) {
  976. alert('输入的数据类型不对,请重新输入!');
  977. me.mixRatioSheet.setValue(row, col, info.oldValue);
  978. return false;
  979. }
  980. value = scMathUtil.roundToString(value,getDecimal("glj.quantity"));
  981. me.batchUpdateConsumption([{row:row,col:col,value}]);
  982. },
  983. refreshParentData:function (row,pid,sid) {
  984. let me = this;
  985. let sheet = me.projectGljSpread.getActiveSheet();
  986. let parantData = null;
  987. if(sheet.name() == 'projectGljSheet'){
  988. me.showProjectGljData();// me.refreshProjectGljRow(row) 这里原来是分开刷新的,现在整个统一刷新,先留着
  989. //parantData = _.find(); //me.projectGljSheetData[row];
  990. }else {
  991. me.showMaterialTreeData();
  992. //parantData = me.materialTree.items[row].data;
  993. }
  994. let pglj = _.find(projectObj.project.projectGLJ.datas.gljList,{'id':pid});
  995. parantData = pglj?me.getSheetDataByGLJ(pglj):null;
  996. //projectObj.project.projectGLJ.datas.gljList
  997. // 更新组成物缓存
  998. projectObj.project.composition.loadData();
  999. me.updateParentNodes(pid,parantData.marketPrice,sid);
  1000. },
  1001. updateParentNodes:function(pid,marketPrice,sid){
  1002. //先查找使用了父项目工料机的定额工料机
  1003. let updateNodes=[];
  1004. let ration_gljs = _.filter(projectObj.project.ration_glj.datas,{'projectGLJID':pid});
  1005. for(let rg of ration_gljs){
  1006. let node = projectObj.project.mainTree.getNodeByID(rg.rationID);
  1007. if(node){
  1008. updateNodes.push(node);
  1009. }
  1010. }
  1011. //或者是使用了父项目工料机的工料机类型的定额
  1012. let rations = _.filter(projectObj.project.Ration.datas,{'type':3,'projectGLJID':pid});
  1013. for(let r of rations){
  1014. let r_node = projectObj.project.mainTree.getNodeByID(r.ID);
  1015. if(r_node){
  1016. r_node.data.marketUnitFee = marketPrice;//parentMarketPrice;//这里用显示的价格
  1017. updateNodes.push(r_node);
  1018. }
  1019. }
  1020. if(sid){
  1021. let subRations = calcTools.getRationsByProjectGLJ(sid);
  1022. updateNodes = updateNodes.concat(subRations);
  1023. }
  1024. if(updateNodes.length>0){
  1025. projectObj.project.calcProgram.calcNodesAndSave(updateNodes,async function () {
  1026. projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots);
  1027. installationFeeObj.calcInstallationFee();//计算安装增加费
  1028. await OVER_HEIGHT.reCalcOverHeightFee();
  1029. await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(updateNodes);
  1030. });
  1031. }
  1032. gljOprObj.refreshView();
  1033. },
  1034. onUnitFileChange:function (data) {
  1035. projectObj.project.markUpdateProject({projectID:projectObj.project.ID(),'unitFileID':socketObject.getUnitFileRoomID()},"unitFile",function(){
  1036. //socket.emit('unitFileChangeNotify', JSON.stringify(data));
  1037. socket.emit('unitFileChangeNotify', {projectID:projectObj.project.ID(),userID:userID,'unitFileID':socketObject.getUnitFileRoomID()});
  1038. });
  1039. },
  1040. deleteMixRatio:function (row) {
  1041. let me = this, deleteRecode = me.mixRatioData[row];
  1042. let consumption = deleteRecode.consumption;
  1043. let [parentMarketPrice, parentBasePrice] = me.getCompositionSumPrice('delete', row);
  1044. let parentSheet = me.projectGljSpread.getActiveSheet();//三材汇总表和工料机汇总表
  1045. let prow= parentSheet.getActiveRowIndex();//取父机械或组成物的下标
  1046. let prowData = parentSheet.name() == 'projectGljSheet'?me.projectGljSheetData[prow]:me.materialTree.items[prow].data;
  1047. let updateData = {id: deleteRecode.mix_ratio_id, field: 'mix_ratio.consumption' , value: 0, market_price: parentMarketPrice, base_price: parentBasePrice};
  1048. projectObj.project.composition.deleteComposition(updateData,deleteRecode,prowData.id,function () {
  1049. _.remove(me.mixRatioData,{"mix_ratio_id":deleteRecode.mix_ratio_id});
  1050. me.refreshParentData(prow,prowData.id);
  1051. me.mixRatioSheet.deleteRows(row,1);
  1052. me.onUnitFileChange(deleteRecode);
  1053. });
  1054. },
  1055. getCompositionSumPrice : function(scene, affectRow, newValue = 0) {
  1056. let me = this;
  1057. let parentMarketPrice = 0;
  1058. let parentBasePrice = 0;
  1059. for(let i = 0;i < me.mixRatioData.length;i++){
  1060. let ratio = me.mixRatioData[i];
  1061. let marketPrice = ratio.unit_price.market_price;
  1062. let basePrice = ratio.unit_price.base_price;
  1063. // 如果是删除则忽略即将被删除的行数据
  1064. if (scene === 'delete' && affectRow === i) {
  1065. continue;
  1066. }
  1067. let consumption = i === affectRow ? newValue : ratio.consumption;
  1068. parentMarketPrice += operationWithRound(consumption,marketPrice,"glj.unitPrice","*");
  1069. parentBasePrice += operationWithRound(consumption,basePrice,"glj.unitPrice","*");
  1070. }
  1071. parentMarketPrice = parentMarketPrice.toDecimal(getDecimal("glj.unitPrice"));
  1072. parentBasePrice = parentBasePrice.toDecimal(getDecimal("glj.unitPrice"));
  1073. return [parentMarketPrice, parentBasePrice];
  1074. },
  1075. onProjectGLJValueChange:function (e,info) {//me.projectGljSetting
  1076. let projectGLJ = projectObj.project.projectGLJ;
  1077. let me = projectGljObject,row = info.row, col = info.col;
  1078. let setting = info.sheetName =="materialTreeSheet"?me.materialSetting:me.projectGljSetting;
  1079. let dataCode = setting.header[col].dataCode;
  1080. let recode = info.sheetName =="materialTreeSheet"?me.materialTree.selected.data:me.projectGljSheetData[row];
  1081. let value = info.newValue;
  1082. if(info.newValue === undefined ){
  1083. return;
  1084. }
  1085. if (value&&!me.checkData(col,setting,value)) {
  1086. alert('输入的数据类型不对,请重新输入!');
  1087. info.sheetName =="materialTreeSheet"?me.materialTreeController.refreshTreeNode([me.materialTree.selected]):me.refreshProjectGljRow(row);
  1088. return ;
  1089. }
  1090. let callback=function (impactList) {
  1091. info.sheet.suspendPaint();
  1092. info.sheet.suspendEvent();
  1093. if (dataCode === 'is_adjust_price'){
  1094. projectGLJ.calcQuantity();
  1095. };
  1096. if(info.sheetName =="materialTreeSheet"){
  1097. me.showMaterialTreeData();
  1098. }else {
  1099. // me.refreshProjectGljRow(row);
  1100. me.showProjectGljData();
  1101. for(let g of impactList){
  1102. me.refreshProjectGljRowByID(g.id,row);
  1103. }
  1104. }
  1105. info.sheet.resumeEvent();
  1106. info.sheet.resumePaint();
  1107. if (dataCode === 'supply' || dataCode === 'supply_quantity' || dataCode === 'is_adjust_price'){ // basePrice、marketPrice 有自己的计算代码,无需走这里重复计算
  1108. let rations = calcTools.getRationsByProjectGLJ(recode.id);
  1109. projectObj.project.calcProgram.calcNodesAndSave(rations, function () {
  1110. projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots);
  1111. });
  1112. };
  1113. gljOprObj.refreshView();
  1114. };
  1115. if(dataCode=='basePrice'||dataCode=='marketPrice'){//修改市场价和修改定额价时需要重新记算很多受影响的树节点,现在改成与定字额工料机那里调相同的方法。
  1116. let editField = dataCode === 'basePrice'?"base_price":"market_price";
  1117. projectObj.project.projectGLJ.updatePrice(recode,editField,value,'pg',null,callback);
  1118. }else {
  1119. let extend = {};
  1120. // 如果是供货方式则需要处理数据
  1121. if (dataCode === 'supply') {
  1122. extend.supply_quantity = me.getSupplyQuantity(value, recode.quantity);
  1123. }
  1124. if(dataCode === 'supply_quantity'){//修改数量需做4舍5入
  1125. value= scMathUtil.roundForObj(value,getDecimal('glj.quantity'));
  1126. }
  1127. if(dataCode === 'is_evaluate'||dataCode === 'is_adjust_price'||dataCode === 'is_main_material'||dataCode === 'no_tax_eqp'||dataCode == 'is_eval_material'){
  1128. value = value == true?1:0;
  1129. if(dataCode === 'is_evaluate'|| dataCode == 'is_eval_material'){
  1130. configMaterialObj.updateConfigMaterial(dataCode,value,recode);//暂估材料,主要材料等新需求
  1131. return
  1132. }
  1133. }
  1134. if(dataCode === 'materialType' && (value == null || value=="")){//删除三材类别时,清空三材系数
  1135. value = null;
  1136. extend.materialCoe = null;
  1137. }
  1138. if(dataCode == 'materialCoe'){
  1139. value = scMathUtil.roundForObj(value,getDecimal("material"));
  1140. }
  1141. if(dataCode == 'taxRate') value = scMathUtil.roundToString(value,2);
  1142. extend = Object.keys(extend).length > 0 ? JSON.stringify(extend) : '';
  1143. if(recode[dataCode] == value) return;
  1144. let updateData = {id: recode.id, field: dataCode, value: value, extend: extend};
  1145. projectGLJ.pGljUpdate(updateData,callback);
  1146. };
  1147. },
  1148. refreshProjectGljRowByID:function (ID,row) {//row 可以不传,如果row 和 index 相等就不刷新
  1149. let me = this;
  1150. let index = _.findIndex(me.projectGljSheetData, { 'id': ID});
  1151. if(index>=0&&index != row){
  1152. me.refreshProjectGljRow(index);
  1153. }
  1154. },
  1155. getSupplyQuantity : function(supplyType, quantity) {
  1156. // 自行采购和甲定乙供则把甲供数量设置为0,其余情况则设置为当前总消耗量
  1157. let supplyQuantity = supplyType == 0 || supplyType == 3 ? 0 : quantity;
  1158. supplyQuantity = parseFloat(supplyQuantity);
  1159. return supplyQuantity;
  1160. },
  1161. getSupplyQuantityByGlj:function (glj, tender) {
  1162. //{"自行采购":0,"部分甲供":1,"完全甲供":2,"甲定乙供":3};
  1163. let supply_quantity = glj.supply_quantity;
  1164. switch (glj.supply){
  1165. case 0:
  1166. supply_quantity = 0;
  1167. break;
  1168. case 1:
  1169. break;
  1170. case 2:
  1171. supply_quantity = tender ? glj.tenderQuantity : glj.quantity;
  1172. break;
  1173. case 3:
  1174. supply_quantity = 0;
  1175. break;
  1176. }
  1177. return supply_quantity
  1178. },
  1179. checkData : function(col,setting, value) {
  1180. return sheetCommonObj.checkData(col,setting, value);
  1181. },
  1182. getProjectGLJSelected:function () {
  1183. let me = this,data = null;
  1184. let sheet = me.projectGljSpread.getActiveSheet();
  1185. if(sheet.name() == 'projectGljSheet'){//projectGljSheet/materialSheet 工料机汇总和三材汇总表
  1186. let sel = me.projectGljSheet.getSelections()[0];
  1187. let srow = sel.row == -1||sel.row == ""?0:sel.row;
  1188. if(me.projectGljSheetData.length>srow){
  1189. data = me.projectGljSheetData[srow];
  1190. }
  1191. }else if(sheet.name() == 'materialTreeSheet'){
  1192. if(this.materialTree.selected){
  1193. data = this.materialTree.selected.data;
  1194. }
  1195. }
  1196. return data;
  1197. },
  1198. initInfoPriceRightClick:function(){
  1199. let me = this;
  1200. $.contextMenu({
  1201. selector: '#info_price_sheet',
  1202. build: function ($trigger, e) {
  1203. me.rightClickTarget = SheetDataHelper.safeRightClickSelection($trigger, e, me.infoPriceSpread);
  1204. return me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.viewport ||
  1205. me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
  1206. },
  1207. items: {
  1208. "apply": {
  1209. name: "确认套用(或双快速套用)",
  1210. icon: 'fa-sign-in',
  1211. disabled: function () {
  1212. return me.rightClickTarget.row === undefined;
  1213. },
  1214. callback: function (key, opt) {
  1215. let row = me.rightClickTarget.row;
  1216. me.preApplyInfoPrice(row);
  1217. }
  1218. }
  1219. }
  1220. });
  1221. },
  1222. initRightClick : function() {
  1223. let activeSheet = this.mixRatioSheet;
  1224. let me = this;
  1225. $.contextMenu({
  1226. selector: '#mix_ratio_sheet',
  1227. build: function ($trigger, e) {
  1228. me.rightClickTarget = SheetDataHelper.safeRightClickSelection($trigger, e, me.mixRatioSpread);
  1229. return me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.viewport ||
  1230. me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
  1231. },
  1232. items: {
  1233. "deleteMixRatio": {
  1234. name: "删除",
  1235. icon: 'fa-trash-o',
  1236. disabled: function () {
  1237. return me.rightClickTarget.row === undefined;
  1238. },
  1239. callback: function (key, opt) {
  1240. let row = me.rightClickTarget.row;
  1241. me.deleteMixRatio(row);
  1242. },
  1243. visible: function(key, opt){
  1244. if(!$('#mixRatio-nav').hasClass('active')) return false;
  1245. return true;
  1246. }
  1247. },
  1248. "addMixRatio":{
  1249. name: '添加',
  1250. icon: 'fa-sign-in',
  1251. disabled: function () {
  1252. let projectGLJ = projectGljObject.getProjectGLJSelected();
  1253. return !_.includes(compositionTypes,projectGLJ.type);
  1254. },
  1255. callback: function (key, opt) {
  1256. me.selectedProjectGLJ = projectGljObject.getProjectGLJSelected();
  1257. getGLJData('addMix', null, true, null);
  1258. },
  1259. visible: function(key, opt){
  1260. if(!$('#mixRatio-nav').hasClass('active')) return false;
  1261. return true;
  1262. }
  1263. }
  1264. }
  1265. });
  1266. },
  1267. changeFileCallback:function(){
  1268. projectGljObject.unitPriceFileInit();
  1269. projectGljObject.refreshViewsData();
  1270. gljOprObj.refreshView();
  1271. projectObj.project.calcProgram.calcAllNodesAndSave(calcAllType.catAll,function () {
  1272. if(socketObject.roomInfo){
  1273. let data ={
  1274. projectID:projectObj.project.ID(),
  1275. oldRoom:socketObject.roomInfo.unitFile,
  1276. newRoom:socketObject.getUnitFileRoomID(),
  1277. userID:userID,
  1278. name:'unitFile'
  1279. };
  1280. socket.emit('changeNewRoom',data);
  1281. socketObject.roomInfo.unitFile = socketObject.getUnitFileRoomID();
  1282. }
  1283. });
  1284. },
  1285. calcPartASupplyFeeByProjectGLJs: function (projectGLJsArr) {
  1286. for (let pGLJ of projectGLJsArr){
  1287. if (pGLJ.supply == supplyType.BFJG){
  1288. let rations = calcTools.getRationsByProjectGLJ(pGLJ.id);
  1289. projectObj.project.calcProgram.calcNodesAndSave(rations, function () {
  1290. projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots);
  1291. });
  1292. }
  1293. }
  1294. },
  1295. checkUnitFileName:function (name,callback) {
  1296. let projectGLJ = projectObj.project.projectGLJ;
  1297. projectGLJ.checkUnitFileName(name,function (data) {
  1298. if(data){
  1299. $("#save-as-tips").text('已存在同名单价文件').show();
  1300. $('#save-as-confirm').attr("disabled","disabled");
  1301. }else {
  1302. $("#save-as-tips").hide();
  1303. $('#save-as-confirm').removeAttr("disabled");
  1304. if(callback) callback();
  1305. }
  1306. });
  1307. },
  1308. initFilterTypeList:function () {//初始化人材机汇总工料机类型过滤列表
  1309. let htmlString = ' <ul class="nav flex-column">';
  1310. for(let t of this.displayTypeMap){
  1311. htmlString += '<li class="nav-item "><a class="nav-link pl-4" href="javascript:void(0)" id="'+t.ID+'">'+t.text+'</a></li>';
  1312. }
  1313. htmlString += '</ul>';
  1314. $('#ALL').after(htmlString);
  1315. },
  1316. getInfoPriceOptions:async function(){
  1317. let options =await ajaxPost("/infoPrice/getOptions",{});
  1318. this.infoPriceOptions=options;
  1319. this.createSelectOptions($("#info_area"),options.areas,true);
  1320. let years = _.keysIn(options.periodMap);
  1321. this.createSelectOptions($("#info_year"),_.sortBy(years));
  1322. },
  1323. createSelectOptions:function(ele,opts,isArea){
  1324. ele.empty();
  1325. let str = `<option value=""></option>`;
  1326. for(let o of opts){
  1327. if(isArea == true){
  1328. str +=`<option value="${o.ID}">${o.name}</option>`
  1329. }else{
  1330. str +=`<option value="${o}">${o}</option>`
  1331. }
  1332. }
  1333. ele.html(str);
  1334. },
  1335. onInfoTopRowChanged:function(sender, args){
  1336. let me = projectGljObject;
  1337. const bottomRow = args.sheet.getViewportBottomRow(1);
  1338. if(me.infoPriceData >= me.infoPriceTotalSize) return;
  1339. if(me.infoPriceData.length - bottomRow < 20 ){
  1340. if(projectGljObject.infoPriceLastLoadingRow == me.infoPriceData.length){//如果最后一行已经加载过了,就不用再加载了,不然会重复加载
  1341. return;
  1342. }
  1343. console.log(bottomRow);
  1344. me.infoPriceLastLoadingRow = me.infoPriceData.length;
  1345. me.searchInfoPrice(me.infoPriceData[me.infoPriceData.length - 1]._id)
  1346. }
  1347. },
  1348. searchInfoPrice:async function(objectID){
  1349. let year = $('#info_year').val();
  1350. let month = $('#info_month').val();
  1351. let areaID = $('#info_area').val();
  1352. let keyWord = $('#info_search_name').val();
  1353. let me = projectGljObject;
  1354. try {
  1355. if(year !="" && month!="" && areaID!="") {
  1356. let condition = {
  1357. period:year+"-"+month,
  1358. areaID:areaID
  1359. }
  1360. let data ={condition:condition};
  1361. if(keyWord !="") data.keyWord = keyWord;
  1362. if(objectID) data.lastID = objectID;
  1363. let result = await ajaxPost("/infoPrice/getDataByCondition",data);
  1364. if(objectID){//分页查询
  1365. sheetCommonObj.appendData(me.infoPriceSheet, me.infoPriceData.length, 0, me.infoPriceSetting, result.items);
  1366. me.infoPriceData.splice(me.infoPriceData.length, 0, ...result.items);
  1367. }else{
  1368. me.infoPriceTotalSize = result.totalSize;
  1369. me.infoPriceLastLoadingRow = 0;
  1370. me.showInforPriceData(result.items);
  1371. }
  1372. }
  1373. } catch (error) {
  1374. console.log(error)
  1375. }
  1376. },
  1377. preApplyInfoPrice:function (row) {
  1378. let info = this.infoPriceData[row];
  1379. let projectGLJData = this.getProjectGLJSelected();
  1380. if (projectGLJData.ratio_data && projectGLJData.ratio_data.length > 0) return ;
  1381. let marketPrice = this.getInfoMarketPrice(info);
  1382. if(projectGLJData.unit == info.unit){
  1383. this.applyInfoPrice(projectGLJData,marketPrice,1);
  1384. }else if(_.includes(["t","kg"],projectGLJData.unit)&&_.includes(["t","kg"],info.unit)){
  1385. //遇到t和kg之间的转换,默认处理:1t=1000kg,不弹换算窗口
  1386. let coeMap={"t":1,"kg":1000};
  1387. let coe = coeMap[info.unit]/coeMap[projectGLJData.unit];
  1388. this.applyInfoPrice(projectGLJData,marketPrice,coe);
  1389. }else{//弹出单位转换窗口
  1390. $("#infoRow").val(row);
  1391. $("#applyGLJName").text(projectGLJData.name);
  1392. $("#applyGLJUnit").text(projectGLJData.unit);
  1393. $("#infoPriceCoe").val("");
  1394. $("#applyInfoUnit").text(info.unit);
  1395. $("#infoPriceCoeDiv").modal('show')
  1396. }
  1397. },
  1398. applyInfoPrice:function (projectGLJData,price,coe) {
  1399. let priceFrom= this.getPriceFrom();
  1400. projectObj.project.projectGLJ.updatePrice(projectGLJData,"market_price",price*coe,'pg',{"priceFrom":priceFrom});
  1401. },
  1402. getPriceFrom:function(){
  1403. let area = "";
  1404. for(let o of this.infoPriceOptions.areas){
  1405. if(o.ID == $("#info_area").val()){
  1406. area = o.name;
  1407. break;
  1408. }
  1409. }
  1410. return `${area}信息价(${$("#info_year").val()}${$("#info_month").val()})`;
  1411. },
  1412. getInfoMarketPrice:function (info) {
  1413. let taxType = projectObj.project.property.taxType;//1: 一般计税 2: 简易计税
  1414. return gljUtil.getInfoMarketPrice(info,taxType);
  1415. }
  1416. };
  1417. function getProjectResizeEles() {
  1418. let pojGljResizeEles = {};
  1419. pojGljResizeEles.eleObj = {
  1420. module: 'projectGlj',
  1421. resize: $('#projectGljResize'),
  1422. top: $('#projectGljTop'),
  1423. topSpread: $('#project_glj_sheet'),
  1424. bottom: $('#projectGljBottom'),
  1425. bottomSpread: $('#mix_ratio_sheet')
  1426. };
  1427. pojGljResizeEles.limit = {
  1428. min: 150,
  1429. max: `$(window).height()-$('.header').height()-$('#projectGljToolsBar').height()-150-5`,//5: resize.height()
  1430. notTopSpread: 0,
  1431. notBottomSpread: 0,
  1432. totalHeight: `$(window).height()-$('.header').height()-$('#projectGljToolsBar').height()-5`
  1433. };
  1434. return pojGljResizeEles;
  1435. }
  1436. function getConficMaterialResizeEles() {
  1437. let conficMaterialResizeEles = {};
  1438. conficMaterialResizeEles.eleObj = {
  1439. module: 'conficMaterial',
  1440. resize: $('#configMaterialResize'),
  1441. top: $('#configMaterialTop'),
  1442. topSpread: $('#config_material_sheet'),
  1443. bottom: $('#configMaterialBottom'),
  1444. bottomSpread: $('#related_sheet')
  1445. };
  1446. conficMaterialResizeEles.limit = {
  1447. min: 150,
  1448. max: `$(window).height()-$('.header').height()-$('#projectGljToolsBar').height()-150-5`,//5: resize.height()
  1449. notTopSpread: 0,
  1450. notBottomSpread: 0,
  1451. totalHeight: `$(window).height()-$('.header').height()-$('#projectGljToolsBar').height()-5`,
  1452. bottomNav:`$('#configMaterialBottom ul').height() + $('#filterToolDiv').height()+10`
  1453. };
  1454. return conficMaterialResizeEles;
  1455. }
  1456. function loadProjectGljSize() {
  1457. if($('#project-glj-main').is(':visible')){
  1458. let me = projectGljObject;
  1459. let pojGljResizeEles = getProjectResizeEles();
  1460. if(!$("#projectGljBottom").is(':visible')){
  1461. let total = $(window).height()-$('.header').height()-$('#projectGljToolsBar').height()+3;
  1462. $("#projectGljTop").height(total);
  1463. $("#project_glj_sheet").height(total);
  1464. me.projectGljSpread?me.projectGljSpread.refresh():'';
  1465. }else{
  1466. SlideResize.loadVerticalHeight(pojGljResizeEles.eleObj.module, pojGljResizeEles.eleObj, pojGljResizeEles.limit, function () {
  1467. me.projectGljSpread?me.projectGljSpread.refresh():'';
  1468. me.mixRatioSpread?me.mixRatioSpread.refresh():'';
  1469. //信息价相关
  1470. $('#info_price_sheet').height($("#mix_ratio_sheet").height() - $("#infoToolDiv").height());
  1471. if($('#info_price_sheet').is(':visible')) me.initInfoPriceSpread();
  1472. });
  1473. }
  1474. }else if($('#material_adjust').is(':visible')){
  1475. $('#material_adjust_sheet').height($(window).height()-$('.header').height()-$('#projectGljToolsBar').height()+3);
  1476. if(materialAdjustObj.spread)materialAdjustObj.spread.refresh();
  1477. }else if($('#config_material').is(':visible')){
  1478. let configMaterialResizeEles = getConficMaterialResizeEles();
  1479. SlideResize.loadVerticalHeight(configMaterialResizeEles.eleObj.module, configMaterialResizeEles.eleObj, configMaterialResizeEles.limit, function () {
  1480. configMaterialObj.configSpread? configMaterialObj.configSpread.refresh():'';
  1481. configMaterialObj.relatedSpread? configMaterialObj.relatedSpread.refresh():'';
  1482. /*
  1483. me.mixRatioSpread?me.mixRatioSpread.refresh():'';*/
  1484. });
  1485. }
  1486. }
  1487. //从其他建设项目中复制中,建设项目的文件层次结构名称和顺序
  1488. function getFileHierarchyInfo(treeData){
  1489. let tree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1});
  1490. tree.loadDatas(treeData);
  1491. let items = tree.items;
  1492. let rst = [];
  1493. function getFileHierarchyName(node){
  1494. let nodeName = node.data.name;
  1495. let name = [];
  1496. while (node.parent){
  1497. name.push(node.parent.data.name ? node.parent.data.name : '');
  1498. node = node.parent;
  1499. }
  1500. name = name.reverse();
  1501. name.push(nodeName);
  1502. return name.join('\\');
  1503. }
  1504. for(let node of items){
  1505. if(node.children.length === 0 ){//project
  1506. rst.push({ID: node.data.ID, fileHierarchyName: getFileHierarchyName(node)})
  1507. }
  1508. }
  1509. return rst;
  1510. }
  1511. $(function () {
  1512. let pojGljResizeEles = getProjectResizeEles();
  1513. SlideResize.verticalSlide(pojGljResizeEles.eleObj, pojGljResizeEles.limit, function () {
  1514. projectGljObject.projectGljSpread.refresh();
  1515. projectGljObject.mixRatioSpread?projectGljObject.mixRatioSpread.refresh():'';
  1516. });
  1517. let tr = getConficMaterialResizeEles();
  1518. SlideResize.verticalSlide(tr.eleObj, tr.limit, function(){
  1519. configMaterialObj.configSpread? configMaterialObj.configSpread.refresh():'';
  1520. configMaterialObj.relatedSpread? configMaterialObj.relatedSpread.refresh():'';
  1521. });
  1522. $('#tab_project_glj').on('shown.bs.tab', function (e) {
  1523. sessionStorage.setItem('mainTab', '#tab_project_glj');
  1524. let me = projectGljObject;
  1525. $(e.relatedTarget.hash).removeClass('active');
  1526. if(me.projectGljSpread==null){
  1527. me.initSpreads();
  1528. }
  1529. me.unitPriceFileInit();
  1530. me.initMixRatio();
  1531. me.initSheetViews();
  1532. //projectObj.project.projectGLJ.calcQuantity(); 在工程量有更新的地方调用
  1533. me.refreshViewsData();
  1534. loadProjectGljSize();
  1535. });
  1536. /* $('#ration_link').on('shown.bs.tab', function (e) {
  1537. let me = projectGljObject;
  1538. me.showTag='ration';
  1539. me.showProjectGljData();
  1540. });
  1541. $('#mix_ratio_link').on('shown.bs.tab', function (e) {
  1542. let me = projectGljObject;
  1543. me.showTag='mixRatio';
  1544. me.showProjectGljData();
  1545. me.initMixRatio();
  1546. });
  1547. $('#machine_ratio_link').on('shown.bs.tab', function (e) {
  1548. let me = projectGljObject;
  1549. me.showTag='machine';
  1550. me.showProjectGljData();
  1551. me.initMixRatio();
  1552. });*/
  1553. $('#pop-used-list').tooltip({
  1554. placement: "bottom",
  1555. html: true,
  1556. trigger: "hover | focus",
  1557. title: projectGljObject.getUsedTenderInfo
  1558. }
  1559. );
  1560. // 单价文件切换弹框
  1561. $('#change-unitFile').on('shown.bs.modal', function () {
  1562. let rootProjectID = projectObj.project.projectInfo.property.rootProjectID;
  1563. // 获取切换单价文件相关数据
  1564. $.ajax({
  1565. url: '/glj/get-project-info',
  1566. type: 'post',
  1567. data: {project_id: scUrlUtil.GetQueryString('project'),rootProjectID:rootProjectID},
  1568. dataType: 'json',
  1569. success: function (response) {
  1570. if (response.err === 1) {
  1571. alert('数据传输错误!');
  1572. return false;
  1573. }
  1574. let data = response.data;
  1575. projectGljObject.changeInfo = data;
  1576. $("#current-project-name").text(data.currentProjectName);
  1577. // 本项目中的单价文件
  1578. if (data.self.length > 0) {
  1579. let selfFileHtml = '';
  1580. for (let tmp of data.self) {
  1581. let select = usedUnitPriceInfo === tmp.id ? ' selected="selected"' : '';
  1582. selfFileHtml += '<option' + select + ' value="' + tmp.id + '">' + tmp.name + '</option>';
  1583. }
  1584. $("#self-file").html(selfFileHtml);
  1585. }
  1586. // 其他建设项目数据
  1587. let newDataOther = [];
  1588. if (data.other.length > 0) {
  1589. //转换成按项目管理顺序,名称包含文件夹层次
  1590. let fileHierarchyDatas = getFileHierarchyInfo(data.treeData);
  1591. for(let fileHierarchyData of fileHierarchyDatas){
  1592. let projData = _.find(data.other, {ID: fileHierarchyData.ID});
  1593. if(projData){
  1594. projData.name = fileHierarchyData.fileHierarchyName;
  1595. newDataOther.push(projData);
  1596. }
  1597. }
  1598. data.other = newDataOther;
  1599. let otherProjectHtml = '';
  1600. let otherFileHtml = '';
  1601. for (let tmp of data.other) {
  1602. otherProjectHtml += '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
  1603. otherFileData[tmp.ID] = tmp.unitPriceList;
  1604. if (otherFileHtml !== '') {
  1605. continue;
  1606. }
  1607. for (let unitPrice of tmp.unitPriceList) {
  1608. otherFileHtml += '<option value="' + unitPrice.id + '">' + unitPrice.name + '</option>';
  1609. }
  1610. }
  1611. $("#other-project").html(otherProjectHtml);
  1612. $("#other-file").html(otherFileHtml);
  1613. }
  1614. }
  1615. });
  1616. });
  1617. // 单价文件切换确认
  1618. $("#change-file-confirm").click(function () {
  1619. let type = $("input[name='change-type']:checked").val();
  1620. type = parseInt(type);
  1621. let changeUnitPriceId = 0;
  1622. $('#change-unitFile').modal("hide");
  1623. if (type === 0) {
  1624. // 从本项目中选择
  1625. changeUnitPriceId = $("#self-file").val();
  1626. if(!changeUnitPriceId){
  1627. alert('单价文件不可为空');
  1628. return;
  1629. }
  1630. submitFileChange(changeUnitPriceId,type);
  1631. } else {
  1632. // 从其他项目中复制
  1633. changeUnitPriceId = $("#other-file").val();
  1634. let newName = $("#other-file").children("option:selected").text();
  1635. projectObj.project.projectGLJ.checkUnitFileName(newName,function (need_rename) {
  1636. if(need_rename){
  1637. $("#rename-unitFile").modal({show:true});
  1638. $("#newUnitFileID").val(changeUnitPriceId);
  1639. $("#newUnitFileName").val(newName);
  1640. }else {
  1641. submitFileChange(changeUnitPriceId,type);
  1642. }
  1643. });
  1644. }
  1645. function submitFileChange(changeUnitPriceId,type) {
  1646. let data = {project_id: scUrlUtil.GetQueryString('project'), change_id: changeUnitPriceId, type: type};
  1647. projectObj.project.projectGLJ.changeFile(data,function () {
  1648. projectGljObject.changeFileCallback();
  1649. })
  1650. }
  1651. });
  1652. // 单价文件选项切换
  1653. $("input[name='change-type']").change(function () {
  1654. let type = $(this).val();
  1655. type = parseInt(type);
  1656. $("#change-unitFile .option").hide();
  1657. if (type === 0) {
  1658. $(".option.select").show();
  1659. } else {
  1660. $(".option.copy").show();
  1661. }
  1662. });
  1663. $("#unitFile-save-as").on('shown.bs.modal', function () {
  1664. // 获取当前建设项数据
  1665. $("#save-as-name").val(projectGljObject.usedUnitPriceInfo.name + '副本');
  1666. projectGljObject.checkUnitFileName(projectGljObject.usedUnitPriceInfo.name + '副本');
  1667. });
  1668. // 从其他建设项目中复制 选择建设项目
  1669. $("#other-project").change(function () {
  1670. let projectId = $(this).val();
  1671. if (otherFileData[projectId] === undefined) {
  1672. return false;
  1673. }
  1674. let otherFileHtml = '';
  1675. for (let unitPrice of otherFileData[projectId]) {
  1676. otherFileHtml += '<option value="' + unitPrice.id + '">' + unitPrice.name + '</option>';
  1677. }
  1678. $("#other-file").html(otherFileHtml);
  1679. });
  1680. $('#save-as-name').change(function () {
  1681. projectGljObject.checkUnitFileName(this.value);
  1682. });
  1683. $('#newUnitFileName').change(function () {
  1684. let projectGLJ = projectObj.project.projectGLJ;
  1685. projectGLJ.checkUnitFileName(this.value,function (data) {
  1686. if(data){
  1687. $("#renameError_unitFile").text('已存在同名单价文件').show();
  1688. //$('#renameUnitFileConfirm').attr("disabled","disabled");
  1689. }else {
  1690. $("#renameError_unitFile").hide();
  1691. // $('#renameUnitFileConfirm').removeAttr("disabled");
  1692. }
  1693. });
  1694. });
  1695. $("#renameUnitFileConfirm").click(function () {
  1696. let projectGLJ = projectObj.project.projectGLJ;
  1697. let newName = $('#newUnitFileName').val();
  1698. let changeUnitPriceId = $('#newUnitFileID').val();
  1699. projectGLJ.checkUnitFileName(newName,function (data) {
  1700. if(data){
  1701. $("#renameError_unitFile").text('已存在同名单价文件').show();
  1702. //$('#renameUnitFileConfirm').attr("disabled","disabled");
  1703. }else {
  1704. $("#renameError_unitFile").hide();
  1705. $('#rename-unitFile').modal('hide');
  1706. // $('#renameUnitFileConfirm').removeAttr("disabled");
  1707. let data = {project_id: scUrlUtil.GetQueryString('project'), change_id: changeUnitPriceId, type: 1,newName:newName};
  1708. projectObj.project.projectGLJ.changeFile(data,function () {
  1709. projectGljObject.changeFileCallback();
  1710. })
  1711. }
  1712. });
  1713. });
  1714. // 单价文件另存为操作
  1715. $("#save-as-confirm").click(function () {
  1716. let projectGLJ = projectObj.project.projectGLJ;
  1717. let name = $("#save-as-name").val();
  1718. if (name === '') {
  1719. $("#save-as-tips").text('请填写单价文件名称').show();
  1720. return false;
  1721. }
  1722. let saveData = {name: name, project_id: scUrlUtil.GetQueryString('project')};
  1723. projectGljObject.checkUnitFileName(name,function () {
  1724. projectGLJ.saveAs(saveData,function () {
  1725. projectGljObject.changeFileCallback();
  1726. $("#unitFile-save-as").modal("hide");
  1727. });
  1728. });
  1729. });
  1730. $("#filterType").on("click","ul li a",function(e){
  1731. let children = $('#filterType a');
  1732. for(let c of children){
  1733. $(c).removeClass('active');
  1734. }
  1735. $(this).addClass('active');
  1736. let me = projectGljObject;
  1737. me.displayType = filterType[this.id];
  1738. me.initSheetViews();
  1739. me.refreshViewsData();
  1740. loadProjectGljSize();
  1741. });
  1742. $("#mixRatio-nav").on('shown.bs.tab', function () {
  1743. projectGljObject.mixRatioSpread.refresh();
  1744. projectGljObject.showMixRatioData();
  1745. });
  1746. $("#ration-nav").on('shown.bs.tab', function () {
  1747. projectGljObject.mixRatioSpread.refresh();
  1748. projectGljObject.showRelatedRationDatas();
  1749. });
  1750. $("#info-nav").on('shown.bs.tab', function () {
  1751. $('#info_price_sheet').height($("#mix_ratio_sheet").height() - $("#infoToolDiv").height());
  1752. projectGljObject.initInfoPriceSpread();
  1753. /*
  1754. projectGljObject.showRelatedRationDatas(); */
  1755. });
  1756. $('#info_year').change(function () {
  1757. let periodMap = projectGljObject.infoPriceOptions.periodMap;
  1758. let year = $(this).val();
  1759. let month = $("#info_month").val();
  1760. let options = periodMap[year];
  1761. projectGljObject.createSelectOptions($("#info_month"),periodMap[year]);
  1762. if(month !=""){
  1763. if(_.includes(options,month)){
  1764. $("#info_month").val(month);
  1765. projectGljObject.searchInfoPrice();
  1766. }
  1767. }
  1768. });
  1769. $('#info_month').change(function () {
  1770. projectGljObject.searchInfoPrice();
  1771. });
  1772. $('#info_area').change(function () {
  1773. projectGljObject.searchInfoPrice();
  1774. });
  1775. $('#info_search_name').on('keypress', function (e) {
  1776. if (e.keyCode === 13) {
  1777. projectGljObject.searchInfoPrice();
  1778. }
  1779. });
  1780. $('#info_search_btn').on('click', function (e) {
  1781. projectGljObject.searchInfoPrice();
  1782. });
  1783. $('#infoPriceCoeConfirm').on('click', function (e) {
  1784. let me = projectGljObject;
  1785. let infoPriceCoe = $("#infoPriceCoe").val();
  1786. if(infoPriceCoe==="") return alert("请输入单位转换值!");
  1787. if(!(/^\d+(\.\d+)?$/.test(infoPriceCoe))) return alert("请输入数字!");
  1788. $("#infoPriceCoeDiv").modal('hide');
  1789. let pojectGLJData = me.getProjectGLJSelected();
  1790. let info=me.infoPriceData[parseInt($("#infoRow").val())];
  1791. let marketPrice = me.getInfoMarketPrice(info);
  1792. me.applyInfoPrice(pojectGLJData,marketPrice,parseFloat(infoPriceCoe));
  1793. });
  1794. $('#muti_apply_info').on('click', function (e) {
  1795. let year = $('#info_year').val();
  1796. let month = $('#info_month').val();
  1797. let areaID = $('#info_area').val();
  1798. if(year !="" && month!="" && areaID!=""){
  1799. $("#mutiApplyInfoPriceDiv").modal("show");
  1800. }
  1801. });
  1802. $('#mutiApplyinfoPriceConfirm').on('click', function (e) {
  1803. let typeMap= {};
  1804. let pgljMap = {};
  1805. let year = $('#info_year').val();
  1806. let month = $('#info_month').val();
  1807. let areaID = $('#info_area').val();
  1808. for(let e of $(".info_apply_type")){
  1809. if($(e).prop('checked') == true){
  1810. typeMap[$(e).val()] = true;
  1811. }
  1812. }
  1813. for(let pglj of projectGljObject.projectGljSheetData){
  1814. if(pglj.ratio_data && pglj.ratio_data.length > 0) continue; //有组成物时跳过
  1815. let typeString = pglj.type +"";
  1816. if(typeMap[typeString.charAt(0)]){
  1817. let index = gljUtil.getIndex(pglj,["name","specs","unit"]);
  1818. let obj = {pgljID:pglj.id,unitPriceID:pglj.unitPriceID,fullIndex:gljUtil.getIndex(pglj)};
  1819. pgljMap[index]?pgljMap[index].push(obj):pgljMap[index]=[obj];//考虑到只用三个去匹配会有重复的工料机,所以这里用数组
  1820. }
  1821. }
  1822. if(_.isEmpty(pgljMap)) return;
  1823. let condition = {
  1824. period:year+"-"+month,
  1825. areaID:areaID
  1826. }
  1827. let priceFrom = projectGljObject.getPriceFrom();
  1828. projectObj.project.projectGLJ.mutiApplyInfoPrice(pgljMap,condition,priceFrom);
  1829. });
  1830. });