project_glj_view.js 82 KB

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